@splinetool/viewer 2.0.42 → 2.0.44

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.
@@ -4159,14 +4159,14 @@ void main() {
4159
4159
  }
4160
4160
  post({ kind: 'ready' });
4161
4161
  }, 250);
4162
- })();`}),dF=z(()=>{mC=class{constructor(t,e,i){this.deps=t,this.onConsole=e,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let t of this.eventUnsubs.values())t();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(t,e){let i=this.deps;switch(t){case"setVariable":{let n=i.setVariable(String(e[0]),e[1]);return n.warning&&this.onConsole("warn",n.warning),n.ok}case"setVariables":{let n=e[0]??{},r=!0;for(let[s,a]of Object.entries(n)){let o=i.setVariable(s,a);o.warning&&this.onConsole("warn",o.warning),r=r&&o.ok}return r}case"getVariable":return i.getVariable(String(e[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(e[0]));case"getGeometry":{let n=i.getGeometry(String(e[0]),e[1]??{});return n.warning&&this.onConsole("warn",n.warning),n.data}case"updateObject":return i.updateObject(String(e[0]),e[1]??{});case"createObject":return i.createObject(String(e[0]),e[1]??{});case"createCustomMaterial":if(i.createCustomMaterial===void 0)throw new Error("createCustomMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(e[0]);case"setMaterial":if(i.setMaterial===void 0)throw new Error("setMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(e[0]),e[1]);case"cloneObject":return i.cloneObject(String(e[0]),e[1]??{});case"removeObject":return i.removeObject(String(e[0]));case"spawnObject":{let n=i.spawnObject(String(e[0]),e[1]??{});return n.warning&&this.onConsole("warn",n.warning),n.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let n=e[1]===null||e[1]===void 0?null:e[1],r=i.setInstanceTransforms(String(e[0]),n);return r<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(e[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),r}case"emitEvent":case"emitEventReverse":{let n=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return n.warning&&this.onConsole("warn",n.warning),n.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let n=String(e[0]);return n==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(n)||this.eventUnsubs.set(n,i.addSplineEventListener(n,r=>{this.onEvent(n,r)})),!0}case"unlistenEvent":{let n=String(e[0]);return n==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(n)?.(),this.eventUnsubs.delete(n)),!0}default:throw new Error(`Unknown spline bridge method: ${t}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let t=this.deps.getVariables(),e=function(i,n){let r=[];for(let s of Object.keys(n))i[s]!==n[s]&&r.push({name:s,value:n[s]});return r}(this.lastVariables??{},t);this.lastVariables=t;for(let i of e)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function lX(t,e,i,n){return[t[0]*e+t[4]*i+t[8]*n+t[12],t[1]*e+t[5]*i+t[9]*n+t[13],t[2]*e+t[6]*i+t[10]*n+t[14]]}var hX=z(()=>{}),uF,cX=z(()=>{}),dX=z(()=>{gC(),dF(),uF=class{constructor(t,e,i){this.iframe=t,this.deps=e,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=n=>{if(this.disposed||n.source!==this.iframe.contentWindow)return;let r=n.data;var s;typeof(s=r)!="object"||s===null||s[zl]!==!0||typeof s.kind!="string"||this.handleMessage(r)},this.host=new mC(e,i,(n,r)=>{this.sendEvent(n,r)})}attach(){window.addEventListener("message",this.onMessage),this.send({[zl]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) \u2014 if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),this.handshakeTimer!==null&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(t){switch(t.kind){case"ready":this.handshakeSeen=!0,this.send({[zl]:!0,kind:"ready-ack"});break;case"console":this.onConsole(t.level,t.text);break;case"call":{let e;try{e=Promise.resolve(this.host.execute(t.method,t.args))}catch(i){e=Promise.reject(i)}e.then(i=>{this.send({[zl]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let n=i instanceof Error?i.message:String(i);this.send({[zl]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:n}),this.onConsole("error",n)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[zl]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),n={bubbles:!0,cancelable:!0,view:window,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey};switch(t.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":e.dispatchEvent(new PointerEvent(t.type,{...n,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,movementX:t.movementX,movementY:t.movementY}));break;case"click":case"dblclick":e.dispatchEvent(new MouseEvent(t.type,{...n,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let r=new WheelEvent("wheel",{...n,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,deltaX:t.deltaX,deltaY:t.deltaY,deltaMode:t.deltaMode});typeof t.wheelDeltaX=="number"&&Object.defineProperty(r,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(r,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(r);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...n,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ii=z(()=>{fC(),Xq(),$q(),Yq(),Kq(),Qq(),Jq(),tX(),eX(),iX(),nX(),aX(),gC(),oX(),dF(),hX(),cX(),dX()}),uX=z(()=>{});function pF(t){return Array.isArray(t)?t:[t]}function w_(t,e){let i=0;for(;i<t.length&&i<e.length;){if(t[i]<e[i])return-1;if(t[i]>e[i])return 1;i+=1}return i!==e.length?-1:i!==t.length?1:0}var pX=z(()=>{});function Er(t,e){return Object.setPrototypeOf(t,e),t}function Xw(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function Xl(t,e,i){if(t===void 0?e===void 0?(t=0,e=10):t=e-10:e===void 0&&(e=t+10),t>e){let s=t;t=e,e=s}let n=[],r=1/(i+1);for(let s=0;s<i;s++){let a=t+(e-t)*(s+.75+.5*Math.random())*r;n.push(a)}return n}function Vc(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array}var fX=z(()=>{});function vC(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let n=t[i];n&&typeof n=="object"&&vC(n)}return Object.freeze(t)}function fF(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var $w,S_,RE,te,yC,mX=z(()=>{}),Dn=z(()=>{uX(),pX(),fX(),mX()}),_C=z(()=>{$w=class{},S_=class extends $w{constructor(t){super(),this.id=t}},RE=class extends $w{constructor(t){super(),this.data=t}}}),gX=z(()=>{}),Vb=z(()=>{te=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let n={...i,[t]:e};return Object.setPrototypeOf(n,te.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let i,n=e[t.id];i=n===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:n};let{id:r,data:s}=t,a={...e,[r]:s};return Object.setPrototypeOf(a,te.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,n=e[i];if(n===void 0)return null;{let r={...e};return Object.setPrototypeOf(r,te.prototype),delete r[i],{data:r,actual:t,reverse:{type:1,id:i,data:n}}}}return null}}}),bC=z(()=>{yC=class extends Error{}});function mF(t,e){for(let i of t)e(i.id,i.data)!==!0&&mF(i.children,e)}function gF(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)gF(i,e)}var Xn,nv,dp,Vt,$c=z(()=>{Dn(),bC(),Dn(),Xn=class extends Array{constructor(...t){super(...t),Ka(this,"partialObjectCaches"),Ka(this,"objCaches"),Ka(this,"parentCaches"),Object.setPrototypeOf(this,Xn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)vC(this[t]),t++}fillCaches0(t,e){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,e);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,e){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}rootAcestor(t){for(;t;){let e=this.parent(t);if(!e)return t;t=e}return t}isDescendantOf(t,e){for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}partialCache(t){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let e=this.get(t);e!==void 0&&this.partialObjectCaches.set(t,e)}get(t){if(this.partialObjectCaches!==void 0){let e=this.partialObjectCaches.get(t);if(e!==void 0)return e}return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,e){if(t===null)this.traverse(e);else{let i=this.get(t);i&&gF(i,e)}}traverse(t){mF(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this.parent(t),n=this.childrenArray(i),r=n.findIndex(o=>o.id===t);if(r<0)throw new Error("not expected");let s=n[r];n=[...n],n[r]={...s,data:e};let a=new Map;return a.set(t,n[r]),this.modifyArrayBy(i,n,a)}}modifyArrayBy(t,e,i=void 0){let n=t,r=e;for(;n!==null;){let a=r,o=n;if(n=this.parent(n),n===void 0)throw new Error;r=this.childrenArray(n);let l=r.findIndex(c=>c.id===o);if(l<0)throw new Error;r=[...r],r[l]={...r[l],children:a},i&&i.set(o,r[l])}Object.setPrototypeOf(r,Xn.prototype);let s=r;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[a,o]of i)s.objCaches.set(a,o);s.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else s.fillCaches();return s}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:e}){if(this.get(t)!==void 0)return!0;for(let i of e)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:e,fi:i,id:n,data:r,children:s}=t;if(e!==null&&this.get(e)===void 0||this.checkDuplicatedIdRec(t))return null;{let a=e,o=this.childrenArray(a),l={fi:i,id:n,data:r,children:s};return o=[...o,l],o.sort((c,h)=>c.fi-h.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:n}}}}deleteOp(t){let{id:e}=t;if(this.get(e)===null)return null;{let i=this.parent(e);if(i===void 0)return null;let n=this.childrenArray(i),r=n.findIndex(a=>a.id===e);t.localIndex=r,n=[...n];let s=n.splice(r,1)[0];return{data:this.modifyArrayBy(i,n),actual:t,reverse:{type:7,...s,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:n}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:n});if(e!==null){let u=e;for(;u!==null;){if(u===void 0)throw new Error;if(u===n)throw new yC("cyclic tree");u=this.parent(u)}}let r=this.parent(n);if(r===void 0)return null;let s=r,a=this.childrenArray(r),o=a.findIndex(u=>u.id===n);a=[...a];let l=a.splice(o,1)[0],c=this.modifyArrayBy(r,a);r=e,a=c.childrenArray(r);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((u,d)=>u.fi-d.fi),t.localIndex=a.indexOf(l),c=c.modifyArrayBy(r,a),{data:c,actual:t,reverse:{type:9,parent:s,fi:h,id:n}}}previous(t,e){if(e===null){let n=this.childrenArray(t);return n.length===0?null:n[n.length-1].id}let i=null;for(let n of this.childrenArray(t)){if(n.id===e)return i;i=n.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),n=i.findIndex(r=>r.id===t)+1;if(n<i.length)return i[n].id;if(e)return this.traverseSortNext(e)}}sortNext(t){let e=this.childrenArray(t);return e.length>0?e[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let e=this.childrenArray(t);return e.length>0?this.traverseSortPrevious(e[e.length-1].id):t}sortPrevious(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),n=i.findIndex(r=>r.id===t)-1;return n>=0?this.traverseSortPrevious(i[n].id):e}}getAllSorted(t){let e=[];for(let i of t){let n=this.getWithSortKey(i.id);n!==void 0&&e.push({...i,...n})}e.sort((i,n)=>w_(i.sortKey,n.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let n=this.getWithSortKey(i);n!==void 0&&e.push(n)}e.sort((i,n)=>w_(i.sortKey,n.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],n=this.get(e),r=n;if(n!==void 0){for(;e;)i.splice(0,0,n.fi),e=this.parent(e),e!==null&&(n=this.get(e));return{...r,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let n=this.childrenArray(t);if(e===null){if(n.length===0)return Xl(0,i,i);{let r=n[0].fi;return Xl(r-i,r,i)}}{let r=this.get(e);if(r===void 0||this.parent(e)!==t)throw new Error("illegal args");let s=n.find(a=>a.fi>r.fi);if(s===void 0){let a=n[n.length-1].fi;return Xl(a,a+i,i)}return Xl(r.fi,s.fi,i)}}}}),xC=z(()=>{var t;Dn(),nv=null,(t=dp||(dp={})).setPreservePrototype=function(e){nv=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===nv&&Object.setPrototypeOf(i,nv),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||Vc(e)){let n=i.props,r={},s=Vc(e)?e.slice():[...e],a=!1;if(n)for(let o of Object.keys(n)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");r[o]=s[l],s[l]=n[o],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:r}}:null}{let n=i.props,r={},s={...e},a=!1;if(n)for(let o of Object.keys(n)){r[o]=s[o];let l=n[o];l===void 0?delete s[o]:s[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,s),actual:i,reverse:{type:0,props:r}}:null}}}),Yc=z(()=>{Dn(),Dn(),Vt=class extends Array{constructor(...t){super(...t),Ka(this,"objCaches"),Object.setPrototypeOf(this,Vt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)vC(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this,n=i.findIndex(s=>s.id===t);if(n<0)throw new Error("not expected");let r=i[n];return i=[...i],i[n]={...r,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,Vt.prototype);let e=t;return typeof process<"u"||e.fillCaches(),e}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:e,id:i,data:n}=t,r=this,s={fi:e,id:i,data:n};return r=[...r,s],r.sort((a,o)=>a.fi-o.fi),t.localIndex=r.indexOf(s),{data:this.modifyArrayBy(r),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,n=i.findIndex(s=>s.id===e);if(n===-1)return null;t.localIndex=n,i=[...i];let r=i.splice(n,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...r}}}moveOp(t){let{fi:e,id:i}=t,n=this;n=[...n];let r=n.findIndex(o=>o.id===i);if(r===-1)return null;let s=n[r].fi,a={...n[r],fi:e};return n[r]=a,n.sort((o,l)=>o.fi-l.fi),t.localIndex=n.indexOf(a),{data:this.modifyArrayBy(n),actual:t,reverse:{type:6,fi:s,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let e=null;for(let i of this){if(i.id===t)return e;e=i.id}return null}insertBeforeHelper(t,e){return this.insertAfterHelper(this.previous(t),e)}insertAfterHelper(t,e){let i=this;if(t===null){if(i.length===0)return Xl(0,e,e);{let n=i[0].fi;return Xl(n-e,n,e)}}{let n=this.get(t);if(n===void 0)throw new Error("illegal args");let r=i.find(s=>s.fi>n.fi);if(r===void 0){let s=i[i.length-1].fi;return Xl(s,s+e,e)}return Xl(n.fi,r.fi,e)}}}});function vX(t,e){let i={cur:[],result:[],len:0};return[t=Hu(t,e,i)??t,i.result]}function o1(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function l1(t){t&&(t.len-=1)}function vF(t,e,i){let n=!1,r=t.map(s=>{let a=s.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(n=!0,a=o,i!==null))throw new Error("not supported");let l=Hu(s.data,e,o1(i,a));l1(i),n=n||l!==void 0,l===void 0&&(l=s.data);let c=vF(s.children,e,i);return c!==void 0?n=!0:c=s.children,{...s,id:a,data:l,children:c}});if(n)return r}function Hu(t,e,i){if(t instanceof Xn){let n=vF(t,e,i);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n}if(t instanceof Vt)return function(n,r,s){let a=!1,o=n.map(l=>{let c=l.id,h=r[c];if(h!==void 0&&typeof h=="string"&&(a=!0,c=h,s!==null))throw new Error("not supported");let u=Hu(l.data,r,o1(s,c));return l1(s),a=a||u!==void 0,u===void 0&&(u=l.data),{...l,id:c,data:u}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}(t,e,i);if(Array.isArray(t)){let n=!1,r=t.map((s,a)=>{let o=Hu(s,e,o1(i,a));return l1(i),n=n||o!==void 0,o===void 0&&(o=s),o});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t&&typeof t=="object"&&!Vc(t)){let n={},r=!1;for(let[s,a]of Object.entries(t))if(s!=="name"&&s!=="variableId"){let o=e[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");r=!0,s=o}let l=Hu(a,e,o1(i,s));l1(i),r=r||l!==void 0,l===void 0&&(l=a),n[s]=l}else n[s]=a;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n):void 0}if(typeof t=="string"){let n=e[t];return n!==void 0&&function(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}(i),n}}var yF=z(()=>{$c(),Yc(),Dn()});function Wu(t){return t&&typeof t=="object"&&t instanceof mn}function wC(t,e){if(e===void 0)return;let i=!1,n=t.map(r=>{let s=r.id,a=ig(r.data,e[s]);if(i=i||a!==void 0,a===void 0&&(a=r.data),r.children){let o=wC(r.children,e);return o!==void 0?i=!0:o=r.children,{...r,id:s,data:a,children:o}}return{...r,id:s,data:a}});return i?n:void 0}function ig(t,e){if(!Wu(e))return e;if(t instanceof Xn){let i=wC(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof Vt)return function(i,n){if(n===void 0)return;let r=!1,s=i.map(a=>{let o=a.id,l=ig(a.data,n[o]);return r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(i)),s):void 0}(t,e);if(Array.isArray(t)){let i=!1,n=t.map((r,s)=>{let a=ig(r,e[s]);return i=i||a!==void 0,a===void 0&&(a=r),a});return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n):void 0}if(t instanceof mn)return SC(t,e);if(t&&typeof t=="object"){let i={},n=!1;for(let[r,s]of Object.entries(t)){let a=ig(s,e[r]);n=n||a!==void 0,a===void 0&&(a=s),i[r]=a}return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function SC(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!Wu(e))return e;if(!Wu(t))return ah.apply(t,e);let i=new Set;for(let r of Object.keys(t))i.add(r);for(let r of Object.keys(e))i.add(r);let n=new mn;for(let r of i){let s=SC(t===void 0?void 0:t[r],e===void 0?void 0:e[r]);n[r]=s}return n}var mn,ah,M_,er,VR,MC=z(()=>{var t;$c(),Yc(),Hb(),Dn(),mn=class{unusedFunOverridesTable(e){}runOp(e){let i=[],n=this,r=0,s={};for(;r<e.path.length;){if(i.push(n),n=n===void 0?void 0:n[e.path[r]],n!==void 0&&!Wu(n))return null;r+=1}n=n?Xw(n):new mn;for(let[a,o]of Object.entries(e.props)){let l=n[a];s[a]=l,o===void 0?delete n[a]:n[a]=o}for(;r>0;){if(Object.keys(n).length===0){let a=i[r-1];a&&(n=Xw(a),delete n[e.path[r-1]])}else{let a=i[r-1];if(a){let o=Xw(a);o[e.path[r-1]]=n,n=o}else{let o=new mn;o[e.path[r-1]]=n,n=o}}r-=1}return{data:Object.setPrototypeOf(n,mn.prototype),actual:e,reverse:{...e,props:s}}}},(t=ah||(ah={})).apply=function(e,i){return ig(e,i)??e},t.merge=function(e,i){return SC(e,i)},t.filterOp=function(e,i){let n=0,r=i.path,s=e;for(;n<r.length&&s!==void 0;){if(s=jn.zoomOnce(s,r[n]),s===void 0)return i;if(!Wu(s))return;n+=1}if(s===void 0)return i;if(Wu(s)){if(i.type===0){let a={...i.props};for(let o of Object.keys(s))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=wC([i],s);return a?a[0]:i}return i}}}),yX=z(()=>{Dn(),Hb(),Vb(),$c(),bC(),xC(),Yc(),yF(),MC(),(M_||(M_={})).replaceProps=function(t,e){let i=jn.zoom(e,t.path);if(typeof i=="object"){let n={};for(let r of Object.keys(t.props))n[r]=i[r];return{...t,props:n}}return{...t,props:{}}},(t=>{function e(r,s){let a=s.path,o=[];for(;;){let l;if(r instanceof mn&&s.type===0&&(l=r.runOp({...s,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=r instanceof Xn||r instanceof Vt||r instanceof te?r.runOp(s):dp.runOp(r,s)),l!==void 0){if(l!==null){let u=l.data;for(let d=o.length-1;d>=0;d--){let p=a[d],f=o[d];if(f instanceof Xn){if(typeof p=="number")throw new Error("illegal arg");u=f.modifyById(p,u)}else if(f instanceof Vt){if(typeof p=="number")throw new Error("illegal arg");u=f.modifyById(p,u)}else if(f instanceof te){if(typeof p=="number")throw new Error("illegal arg");u=f.modifyById(p,u)}else if(f instanceof mn){let g={...f,[p]:u};u=Object.setPrototypeOf(g,mn.prototype)}else{if(typeof f!="object")return null;if(Array.isArray(f)||Vc(f)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let g=u;u=Vc(f)?f.slice():[...f],u[p]=g}else u=dp.tryPreservePrototype(f,{...f,[p]:u})}}return{data:u,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let c,h=a[o.length];if(r instanceof Xn){if(typeof h=="number")throw new Error("");c=r.get(h)?.data}else if(r instanceof Vt){if(typeof h=="number")throw new Error("");c=r.get(h)?.data}else r!==null&&(c=r[h]);if(c===void 0)return null;o.push(r),r=c}}function i(r,s){for(let a=0;a<r.length&&a<s.length;a++)if(r[a]!==s[a])return!0;return!1}function n(r,s){if(r.length!==s.length)return!1;for(let a=0;a<r.length;a++)if(r[a]!==s[a])return!1;return!0}t.drop=function(r,s){return{...r,path:r.path.slice(s)}},t.applySimple=function(r,s){return e(r,s)?.data??r},t.apply=e,t.pathDisjoint=i,t.pathEq=n,t.commutative=function(r,s){return i(r.path,s.path)},t.subsumed=function(r,s){return!(r.type!==0||s.type!==0||!n(r.path,s.path))&&Object.keys(r.props).every(a=>s.props[a]!==void 0)}})(er||(er={})),(t=>{function e(i,n){let r=i,s=[],a=[];for(let o of n)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,c,h;if(o.type===3?(l=jn.zoom(r,[...o.path,o.id]),h=er.apply(r,{...o,type:2})):(l=jn.zoom(r,[...o.path,o.id,"value"]),h=er.apply(r,o)),h!==null){r=h.data;let[u,d]=vX(r,{[o.id]:l});r=u;for(let p=0;p<d.length;p++){let f=d[p],g=f.pop();if(typeof g=="number"){let m=[g];for(let v=p+1;v<d.length;v++){let _=d[v],b=_[_.length-1];if(typeof b!="number"||!jn.equal(f,_.slice(0,_.length-1)))break;m.push(b),d.splice(v,1)}let y=jn.zoom(r,f);c=y.map((v,_)=>m.includes(_)?o.id:v),l=y,g=f.pop()}else{if(g==="alphaOverride"||g==="alpha"){l/=100;let m=l,y=jn.zoom(r,f.slice(0,f.length-2)),v=y.layers.map(_=>_.id===f[f.length-1]?{..._,data:{..._.data,[g]:m}}:_);Object.setPrototypeOf(v,Object.getPrototypeOf(y.layers)),y.layers=v}c=o.id}s.push({type:0,path:f,props:{[g]:l}}),a.push({type:0,path:f,props:{[g]:c}})}a.push(h.reverse),s.push(h.actual)}}else{let l=er.apply(r,o);l!==null&&(s.push(l.actual),r=l.data,a.push(l.reverse))}}catch(l){if(l instanceof yC)return null;throw l}return{data:r,actual:s,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,n){let r=[];for(let s of i){let[a,...o]=s.path;a===n&&r.push({...s,path:o})}return r},t.addPrefix=function(i,n){return i.map(r=>({...r,path:[n,...r.path]}))},t.concat=function(i,n){return[...i,...n]},t.compress=function(i,n){return[...i.filter(r=>!n.some(s=>er.subsumed(r,s))),...n]},t.commutative=function(i,n){return i.every(r=>n.every(s=>er.commutative(r,s)))},t.applyAll=function(i,n){for(let r of n){let s=e(i,r);s!==null&&(i=s.data)}return i},t.apply=e})(VR||(VR={}))});function Yw(t,e,i){if(t.length>0){let n=t[t.length-1];if(n.type===0&&e.type===0&&jn.equal(n.path,i))return void Object.assign(n.props,e.props)}t.push({...e,path:i})}function h1(t,e,i){return i instanceof Xn?new jb(t,e,i):i instanceof Vt?new Gb(t,e,i):i instanceof te?new Proxy(new bF(t,e,i),wF):i!==null&&typeof i=="object"?Vc(i)?i:new Proxy(new _F(t,e,i),xF):i}function Tm(t){let e=new OE(t);return[h1(e,"",t),e]}function E_(t,e){let[i,n]=Tm(t);return e(i),n.result()}function hn(t){return t instanceof jb||t instanceof Gb?t._current:t!==null&&typeof t=="object"?t[IE]:t}var IE,jR,Cf,Rd,_F,bF,Zw,xF,wF,jb,Gb,OE,jn,SF=z(()=>{Vb(),$c(),xC(),Yc(),Dn(),Hb(),IE=Symbol(),jR=Symbol(),Cf=Symbol(),Rd=class{reportOp(t,e,i=[]){let n=this;if(e===null)return;n._current=e.data;let r=i;for(;!(n instanceof OE);){let s=n._path,a=n._current;if(s!==""&&r.splice(0,0,s),n=n._parent,n===null)return;n.update(s,a)}n.push(r,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[Cf];i&&i(),delete this._children[t]}}}},_F=class extends Rd{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=dp.tryPreservePrototype(this._current,{...this._current,[t]:e})}runOp(t){this.reportOp(t,dp.runOp(this._current,t),t.path)}},bF=class extends Rd{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,te.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Zw={get(t,e){if(e===Cf)return()=>{t._parent=null};if(e===IE)return t._current;if(e===jR)return t;let{_current:i,_children:n}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[e];if(r!==void 0)return r;let s=i[e],a=h1(t,e,s);return a!==s?(n===void 0&&(n={},t._children=n),n[e]=a,a):s},has:(t,e)=>e in t._current,ownKeys:t=>Reflect.ownKeys(t._current),defineProperty(){throw Error("not supported")},getPrototypeOf:t=>Object.getPrototypeOf(t._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(t,e){let i=t._current,n=Reflect.getOwnPropertyDescriptor(i,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:i[e]}}},xF={...Zw,set(t,e,i){let n={type:0,props:{[e]:hn(i)??i}};return t.deleteChildren(e),t.runOp(n),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},wF={...Zw,set(t,e,i){return i===void 0?this.deleteProperty(t,e):(t.deleteChildren(e),t.runOp({type:1,id:e,data:i})),!0},deleteProperty:(t,e)=>(t.runOp({type:2,id:e}),!0)},jb=class extends Rd{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[Cf]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,i)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:i}=this,n=i===void 0?void 0:i[t];if(n!==void 0)return n;let r=e.get(t)?.data,s=h1(this,t,r);return s!==r?(i===void 0&&(i={},this._children=i),i[t]=s,s):r}add(t,e,i,n,r){this.runOp({type:7,parent:t,fi:e,id:i,data:n,children:r})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let n=this._current.insertAfterHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.add(t,n[r],s.id,s.data,s.children)}}insertBefore(t,e,i){let n=this._current.insertBeforeHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.add(t,n[r],s.id,s.data,s.children)}}moveAfter(t,e,i){let n=this._current.insertAfterHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.move(t,n[r],s)}}moveBefore(t,e,i){let n=this._current.insertBeforeHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.move(t,n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Gb=class extends Rd{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[Cf]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let i=0;i<e;i++){let n=this._current[i].id,r=this._current[i].fi;t(this.data(this._current[i].id),n,r,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let n=this._current[i].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:i}=this._current.at(t);return{id:e,fi:i,data:this.data(e)}}data(t){let{_current:e,_children:i}=this,n=i===void 0?void 0:i[t];if(n!==void 0)return n;let r=e.get(t)?.data,s=h1(this,t,r);return s!==r?(i===void 0&&(i={},this._children=i),i[t]=s,s):r}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,i){this.runOp({type:4,fi:t,id:e,data:i})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.add(i[n],r.id,r.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.add(i[n],r.id,r.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.move(i[n],r)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.move(i[n],r)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},OE=class extends Rd{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,i,n){Yw(this.ts,e,t),Yw(this.actual,i,t),Yw(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),Hb=z(()=>{_C(),SF(),Yc(),$c(),Dn(),(t=>{function e(n,r){return(n instanceof Xn||n instanceof jb)&&typeof r=="string"||(n instanceof Vt||n instanceof Gb)&&typeof r=="string"?n.data(r):typeof r=="number"&&Array.isArray(n)||typeof r=="string"&&typeof n=="object"&&n!==null?n[r]:void 0}function i(n,r,s=0){for(;s<r.length&&n!==void 0;)n=e(n,r[s]),s+=1;return n}t.equal=function(n,r){if(r.length!==n.length)return!1;{let s=0;for(;s<n.length;){if(n[s]!==r[s])return!1;s+=1}}return!0},t.removeOverridden=function(n,r,s){let a=i(s,n);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...r};return Object.keys(a).forEach(l=>{delete o[l]}),o}return r},t.zoomOnce=e,t.zoom=i,t.findPathes=function(n,r){let s=[];return function a(o,l){if(o instanceof S_&&o.id===r.id)s.push(l);else if(o instanceof Vt)for(let c=0;c<o.length;c++)a(o[c].data,[...l,o[c].id]);else if(o instanceof Xn)o.traverse((c,h)=>{a(h,[...l,c])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let c=0;c<o.length;c++)a(o[c],[...l,c])}else{if(Vc(o))return;if(typeof o=="object"&&o!==null)for(let c in o)a(o[c],[...l,c])}}(n,[]),s}})(jn||(jn={}))}),_X=z(()=>{});function ri(t,e){let i=[];if(!(e.length<=t.length))return null;{let n=0;for(;n<e.length;){if(e[n]==="*")i.push(t[n]);else if(t[n]!==e[n])return null;n+=1}}return i}var bX=z(()=>{});function rv(t){try{if(!bi.trusted&&!Zo){let i=Qe.sharedLength||0;i<Qe.length&&(Qe.length=i)}let e;if(bi.randomAccessStructure&&kt[mt]<64&&kt[mt]>=32&&$R?(e=$R(kt,mt,Ns,bi),kt=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),mt=Ns):e=fn(),yr&&(mt=yr.postBundlePosition,yr=null),Zo&&(Qe.restoreStructures=null),mt==Ns)Qe&&Qe.restoreStructures&&GR(),Qe=null,kt=null,Yo&&(Yo=null);else{if(mt>Ns)throw new Error("Unexpected end of MessagePack data");if(!Zo){let i;try{i=JSON.stringify(e,(n,r)=>typeof r=="bigint"?`${r}n`:r).slice(0,100)}catch(n){i="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw Qe&&Qe.restoreStructures&&GR(),BE(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||mt>Ns)&&(e.incomplete=!0),e}}function GR(){for(let t in Qe.restoreStructures)Qe[t]=Qe.restoreStructures[t];Qe.restoreStructures=null}function fn(){let t=kt[mt++];if(t<160){if(t<128){if(t<64)return t;{let e=Qe[63&t]||bi.getStructures&&MF()[63&t];return e?(e.read||(e.read=LE(e,63&t)),e.read()):t}}if(t<144){if(t-=128,bi.mapsAsObjects){let e={};for(let i=0;i<t;i++){let n=AF();n==="__proto__"&&(n="__proto_"),e[n]=fn()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(fn(),fn());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=fn();return bi.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(ua>=mt)return $l.slice(mt-fs,(mt+=e)-fs);if(ua==0&&Ns<140){let i=e<16?EC(e):EF(e);if(i!=null)return i}return C_(e)}{let e;switch(t){case 192:return null;case 193:return yr?(e=fn(),e>0?yr[1].slice(yr.position1,yr.position1+=e):yr[0].slice(yr.position0,yr.position0-=e)):PF;case 194:return!1;case 195:return!0;case 196:if(e=kt[mt++],e===void 0)throw new Error("Unexpected end of buffer");return Kw(e);case 197:return e=He.getUint16(mt),mt+=2,Kw(e);case 198:return e=He.getUint32(mt),mt+=4,Kw(e);case 199:return Xh(kt[mt++]);case 200:return e=He.getUint16(mt),mt+=2,Xh(e);case 201:return e=He.getUint32(mt),mt+=4,Xh(e);case 202:if(e=He.getFloat32(mt),bi.useFloat32>2){let i=VE[(127&kt[mt])<<1|kt[mt+1]>>7];return mt+=4,(i*e+(e>0?.5:-.5)|0)/i}return mt+=4,e;case 203:return e=He.getFloat64(mt),mt+=8,e;case 204:return kt[mt++];case 205:return e=He.getUint16(mt),mt+=2,e;case 206:return e=He.getUint32(mt),mt+=4,e;case 207:return bi.int64AsType==="number"?(e=4294967296*He.getUint32(mt),e+=He.getUint32(mt+4)):bi.int64AsType==="string"?e=He.getBigUint64(mt).toString():bi.int64AsType==="auto"?(e=He.getBigUint64(mt),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=He.getBigUint64(mt),mt+=8,e;case 208:return He.getInt8(mt++);case 209:return e=He.getInt16(mt),mt+=2,e;case 210:return e=He.getInt32(mt),mt+=4,e;case 211:return bi.int64AsType==="number"?(e=4294967296*He.getInt32(mt),e+=He.getUint32(mt+4)):bi.int64AsType==="string"?e=He.getBigInt64(mt).toString():bi.int64AsType==="auto"?(e=He.getBigInt64(mt),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=He.getBigInt64(mt),mt+=8,e;case 212:if(e=kt[mt++],e==114)return kE(63&kt[mt++]);{let i=gr[e];if(i)return i.read?(mt++,i.read(fn())):i.noBuffer?(mt++,i()):i(kt.subarray(mt,++mt));throw new Error("Unknown extension "+e)}case 213:return e=kt[mt],e==114?(mt++,kE(63&kt[mt++],kt[mt++])):Xh(2);case 214:return Xh(4);case 215:return Xh(8);case 216:return Xh(16);case 217:return e=kt[mt++],ua>=mt?$l.slice(mt-fs,(mt+=e)-fs):RF(e);case 218:return e=He.getUint16(mt),ua>=(mt+=2)?$l.slice(mt-fs,(mt+=e)-fs):IF(e);case 219:return e=He.getUint32(mt),ua>=(mt+=4)?$l.slice(mt-fs,(mt+=e)-fs):OF(e);case 220:return e=He.getUint16(mt),mt+=2,HR(e);case 221:return e=He.getUint32(mt),mt+=4,HR(e);case 222:return e=He.getUint16(mt),mt+=2,WR(e);case 223:return e=He.getUint32(mt),mt+=4,WR(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+t)}}}function LE(t,e){function i(){if(i.count++>zE){let r;try{r=t.read=new Function("r","return function(){return "+(bi.freezeData?"Object.freeze":"")+"({"+t.map(s=>s==="__proto__"?"__proto_:r()":DF.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(fn)}catch{return zE=1/0,i()}return t.read0=r,t.highByte===0&&(t.read=FE(e,t.read)),r()}let n={};for(let r=0,s=t.length;r<s;r++){let a=t[r];a==="__proto__"&&(a="__proto_"),n[a]=fn()}return bi.freezeData?Object.freeze(n):n}return i.count=0,t.read0=i,t.highByte===0?FE(e,i):i}function MF(){let t=CF(()=>(kt=null,bi.getStructures()));return Qe=bi._mergeStructures(t,Qe)}function Cm(t){let e;if(t<16&&(e=EC(t)))return e;if(t>64&&UE)return UE.decode(kt.subarray(mt,mt+=t));let i=mt+t,n=[];for(e="";mt<i;){let r=kt[mt++];if(128&r)if((224&r)==192){let s=(31&r)<<6|63&kt[mt++];s<128?n.push(65533):n.push(s)}else if((240&r)==224){let s=(31&r)<<12|(63&kt[mt++])<<6|63&kt[mt++];s<2048||s>=55296&&s<=57343?n.push(65533):n.push(s)}else if((248&r)==240){let s=(7&r)<<18|(63&kt[mt++])<<12|(63&kt[mt++])<<6|63&kt[mt++];s<65536||s>1114111?n.push(65533):(s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s))}else n.push(65533);else n.push(r);n.length>=4096&&(e+=kn.apply(String,n),n.length=0)}return n.length>0&&(e+=kn.apply(String,n)),e}function HR(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=fn();return bi.freezeData?Object.freeze(e):e}function WR(t){if(bi.mapsAsObjects){let e={};for(let i=0;i<t;i++){let n=AF();n==="__proto__"&&(n="__proto_"),e[n]=fn()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(fn(),fn());return e}}function EF(t){let e=mt,i=new Array(t);for(let n=0;n<t;n++){let r=kt[mt++];if((128&r)>0)return void(mt=e);i[n]=r}return kn.apply(String,i)}function EC(t){if(t<4){if(t<2){if(t===0)return"";{let e=kt[mt++];return(128&e)>1?void(mt-=1):kn(e)}}{let e=kt[mt++],i=kt[mt++];if((128&e)>0||(128&i)>0)return void(mt-=2);if(t<3)return kn(e,i);let n=kt[mt++];return(128&n)>0?void(mt-=3):kn(e,i,n)}}{let e=kt[mt++],i=kt[mt++],n=kt[mt++],r=kt[mt++];if((128&e)>0||(128&i)>0||(128&n)>0||(128&r)>0)return void(mt-=4);if(t<6){if(t===4)return kn(e,i,n,r);{let s=kt[mt++];return(128&s)>0?void(mt-=5):kn(e,i,n,r,s)}}if(t<8){let s=kt[mt++],a=kt[mt++];if((128&s)>0||(128&a)>0)return void(mt-=6);if(t<7)return kn(e,i,n,r,s,a);let o=kt[mt++];return(128&o)>0?void(mt-=7):kn(e,i,n,r,s,a,o)}{let s=kt[mt++],a=kt[mt++],o=kt[mt++],l=kt[mt++];if((128&s)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(mt-=8);if(t<10){if(t===8)return kn(e,i,n,r,s,a,o,l);{let c=kt[mt++];return(128&c)>0?void(mt-=9):kn(e,i,n,r,s,a,o,l,c)}}if(t<12){let c=kt[mt++],h=kt[mt++];if((128&c)>0||(128&h)>0)return void(mt-=10);if(t<11)return kn(e,i,n,r,s,a,o,l,c,h);let u=kt[mt++];return(128&u)>0?void(mt-=11):kn(e,i,n,r,s,a,o,l,c,h,u)}{let c=kt[mt++],h=kt[mt++],u=kt[mt++],d=kt[mt++];if((128&c)>0||(128&h)>0||(128&u)>0||(128&d)>0)return void(mt-=12);if(t<14){if(t===12)return kn(e,i,n,r,s,a,o,l,c,h,u,d);{let p=kt[mt++];return(128&p)>0?void(mt-=13):kn(e,i,n,r,s,a,o,l,c,h,u,d,p)}}{let p=kt[mt++],f=kt[mt++];if((128&p)>0||(128&f)>0)return void(mt-=14);if(t<15)return kn(e,i,n,r,s,a,o,l,c,h,u,d,p,f);let g=kt[mt++];return(128&g)>0?void(mt-=15):kn(e,i,n,r,s,a,o,l,c,h,u,d,p,f,g)}}}}}function qR(){let t,e=kt[mt++];if(e<192)t=e-160;else switch(e){case 217:t=kt[mt++];break;case 218:t=He.getUint16(mt),mt+=2;break;case 219:t=He.getUint32(mt),mt+=4;break;default:throw new Error("Expected string")}return Cm(t)}function Kw(t){return bi.copyBuffers?Uint8Array.prototype.slice.call(kt,mt,mt+=t):kt.subarray(mt,mt+=t)}function Xh(t){let e=kt[mt++];if(gr[e]){let i;return gr[e](kt.subarray(mt,i=mt+=t),n=>{mt=n;try{return fn()}finally{mt=i}})}throw new Error("Unknown extension type "+e)}function AF(){let t=kt[mt++];if(!(t>=160&&t<192))return mt--,TF(fn());if(t-=160,ua>=mt)return $l.slice(mt-fs,(mt+=t)-fs);if(!(ua==0&&Ns<180))return C_(t);let e,i=4095&(t<<5^(t>1?He.getUint16(mt):t>0?kt[mt]:0)),n=NE[i],r=mt,s=mt+t-3,a=0;if(n&&n.bytes==t){for(;r<s;){if(e=He.getUint32(r),e!=n[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(e=kt[r++],e!=n[a++]){r=1879048192;break}if(r===s)return mt=r,n.string;s-=3,r=mt}for(n=[],NE[i]=n,n.bytes=t;r<s;)e=He.getUint32(r),n.push(e),r+=4;for(s+=3;r<s;)e=kt[r++],n.push(e);let o=t<16?EC(t):EF(t);return n.string=o??C_(t)}function TF(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(bi.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error("Invalid property type for record: "+typeof t)}function CF(t){YR&&YR();let e=Ns,i=mt,n=T_,r=fs,s=ua,a=$l,o=A_,l=Yo,c=yr,h=new Uint8Array(kt.slice(0,Ns)),u=Qe,d=Qe.slice(0,Qe.length),p=bi,f=Zo,g=t();return Ns=e,mt=i,T_=n,fs=r,ua=s,$l=a,A_=o,Yo=l,yr=c,kt=h,Zo=f,(Qe=u).splice(0,Qe.length,...d),bi=p,He=new DataView(kt.buffer,kt.byteOffset,kt.byteLength),g}function BE(){kt=null,Yo=null,Qe=null}function xX(t){t.unpack?gr[t.type]=t.unpack:gr[t.type]=t}var UE,kt,Ns,mt,XR,A_,T_,bi,Qe,$l,fs,ua,yr,Yo,gr,He,Qw,PF,Zo,zE,$R,YR,Pm,DF,FE,C_,RF,IF,OF,kn,NE,kE,Jw,ZR,KR,QR,VE,sv,JR,tI,eI,jE,tS,Pg,wX=z(()=>{try{UE=new TextDecoder}catch{}mt=0,A_=XR=[],T_=0,bi={},fs=0,ua=0,gr=[],Qw={useRecords:!1,mapsAsObjects:!0},(PF=new class{}).name="MessagePack 0xC1",Zo=!1,zE=2,Pm=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=0&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(kt)return CF(()=>(BE(),this?this.unpack(t,e):Pm.prototype.unpack.call(Qw,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ns=e.end||t.length,mt=e.start||0):(mt=0,Ns=e>-1?e:t.length),T_=0,ua=0,$l=null,A_=XR,yr=null,kt=t;try{He=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw kt=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Pm){if(bi=this,this.structures)return Qe=this.structures,rv(e);(!Qe||Qe.length>0)&&(Qe=[])}else bi=Qw,(!Qe||Qe.length>0)&&(Qe=[]);return rv(e)}unpackMultiple(t,e){let i,n=0;try{Zo=!0;let r=t.length,s=this?this.unpack(t,r):sv.unpack(t,r);if(!e){for(i=[s];mt<r;)n=mt,i.push(rv());return i}if(e(s,n,mt)===!1)return;for(;mt<r;)if(n=mt,e(rv(),n,mt)===!1)return}catch(r){throw r.lastPosition=n,r.values=i,r}finally{Zo=!1,BE()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,n=t.length;i<n;i++){let r=t[i];r&&(r.isShared=!0,i>=32&&(r.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let n=t[i],r=e[i];r&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[i]=n),t[i]=r)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},DF=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,FE=(t,e)=>function(){let i=kt[mt++];if(i===0)return e();let n=t<32?-(t+(i<<5)):t+(i<<5),r=Qe[n]||MF()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=LE(r,t)),r.read()},C_=Cm,RF=Cm,IF=Cm,OF=Cm,kn=String.fromCharCode,NE=new Array(4096),kE=(t,e)=>{let i=fn().map(TF),n=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let r=Qe[t];return r&&(r.isShared||Zo)&&((Qe.restoreStructures||(Qe.restoreStructures=[]))[t]=r),Qe[t]=i,i.read=LE(i,n),(i.read0||i.read)()},gr[0]=()=>{},gr[0].noBuffer=!0,gr[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let n=1;n<e;n++)i<<=BigInt(8),i+=BigInt(t[n]);if(t.byteLength!==e){let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=(s,a)=>{let o=a-s;if(o<=40){let u=n.getBigUint64(s);for(let d=s+8;d<a;d+=8)u<<=BigInt(64),u|=n.getBigUint64(d);return u}let l=s+(o>>4<<3),c=r(s,l),h=r(l,a);return c<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(n.byteLength-e))|r(e,n.byteLength)}return i},Jw={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},gr[101]=()=>{let t=fn();if(!Jw[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return Jw[t[0]](t[1],{cause:t[2]})},gr[105]=t=>{if(bi.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=He.getUint32(mt-4);Yo||(Yo=new Map);let i,n=kt[mt];i=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&kt[mt+1]===115?new Set:{};let r={target:i};Yo.set(e,r);let s=fn();if(!r.used)return r.target=s;if(Object.assign(i,s),i instanceof Map)for(let[a,o]of s.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(s))i.add(a);return i},gr[112]=t=>{if(bi.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=He.getUint32(mt-4),i=Yo.get(e);return i.used=!0,i.target},gr[115]=()=>new Set(fn()),ZR=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),KR=typeof globalThis=="object"?globalThis:window,gr[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,n=ZR[e];if(!n){if(e===16)return i;if(e===17)return new DataView(i);throw new Error("Could not find typed array for code "+e)}return new KR[n](i)},gr[120]=()=>{let t=fn();return new RegExp(t[0],t[1])},QR=[],gr[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=mt;return mt+=e-t.length,yr=QR,(yr=[qR(),qR()]).position0=0,yr.position1=0,yr.postBundlePosition=mt,mt=i,fn()},gr[255]=t=>t.length==4?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid"),VE=new Array(147);for(let t=0;t<256;t++)VE[t]=+("1e"+Math.floor(45.15-.30103*t));(sv=new Pm({useRecords:!1})).unpack,sv.unpackMultiple,sv.unpack,JR=new Float32Array(1),new Uint8Array(JR.buffer,0,4)}),SX=z(()=>{wX(),_C(),MC(),Yc(),Vb(),$c(),tI=[{Class:te.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,te.prototype),t)},{Class:Vt.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Vt.prototype),t)},{Class:Xn.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Xn.prototype),t)},{Class:S_.prototype.constructor,type:4,write:t=>t.id,read:t=>new S_(t)},{Class:RE.prototype.constructor,type:5,write:t=>t.data,read:t=>new RE(t)},{Class:mn.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,mn.prototype),t)}];for(let t of tI)xX(t);eI=new Pm({structuredClone:!0}),(jE||(jE={})).deserialize=function(t){return eI.unpack(t)}}),MX=z(()=>{SX(),tS=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},Pg={deserialize:jE.deserialize,serialize:tS("CollabSerialize.serialize"),checksum:tS("CollabSerialize.checksum")}}),Ye=z(()=>{Hb(),gX(),bC(),$c(),Vb(),xC(),Yc(),yX(),_X(),SF(),bX(),_C(),MX(),yF(),MC()});function GE(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var iI,HE,Ou,av,eS,nI,rI,sI,WE,qE,aI,oI,lI,hI,cI,XE,$E,dI,uI,pI,fI,LF=z(()=>{var t,e,i;Ye(),et(),(t=iI||(iI={})).toEventUIType=function(n){return n.type==="Conditional"?n.condition.type==="Distance"?"Distance":"StateChange":n.type},t.fromEventUIType=function(n){return n==="Distance"||n==="StateChange"?"Conditional":n},HE={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(n=>{n.is=function(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"},n.defaultData=function(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new Vt}:{type:r,disabled:!1,name:"",key:void 0,actions:new Vt}}})(Ou||(Ou={})),(n=>{n.propertyDefaultData=function(r){return{type:"Property",value:[r??null,"position","x"]}},n.valueDefaultData={type:"Literal",value:0}})(av||(av={})),(e=eS||(eS={})).comparisonDefaultData=function(n){return{type:"Comparison",operator:"==",lOperand:av.propertyDefaultData(n),rOperand:{...av.valueDefaultData}}},e.distanceDefaultData=function(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}},e.stateDefaultData=function(n,r){return{type:"State",object:n??null,state:r??null}},(nI||(nI={})).isConditionalSubActions=function(n){return n.find(r=>r==="ifActions"||r==="elseActions")!==void 0},(n=>{n.is=function(r){return r.type==="Conditional"},n.defaultData=function(r){return{type:"Conditional",disabled:!1,name:"",inActions:new Vt,outActions:new Vt,condition:eS.distanceDefaultData(r)}}})(rI||(rI={})),(sI||(sI={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Vt,drop:new Vt}},(WE||(WE={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Vt},(qE||(qE={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(n=>{n.is=function(r){return r.type==="MouseHover"},n.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new Vt}}})(aI||(aI={})),(n=>{n.is=function(r){return r.type==="Scroll"},n.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Vt}}})(oI||(oI={})),(n=>{n.is=function(r){return r.type==="Start"},n.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new Vt}}})(lI||(lI={})),(n=>{n.is=function(r){return r.type==="Collision"},n.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new Vt}}})(hI||(hI={})),(n=>{n.is=function(r){return r.type==="Trigger"},n.defaultData=function(r,s){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new Vt,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}})(cI||(cI={})),(i=XE||(XE={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(n){return n.type==="Resize"},i.sizeToDevice=function(n){return typeof n=="string"?n:"custom"},i.deviceToSize=function(n){return typeof n=="string"?[...i.defaultSizes[n]]:[...n]},i.defaultData=function(){let n={size:"mobile",operator:"<",actions:new Vt},r={size:"tablet",operator:"<",actions:new Vt},s={size:[...i.defaultSizes.custom],operator:"<>",actions:new Vt},a=new Vt;return a.push({id:Ot.generateUUID(),fi:0,data:n},{id:Ot.generateUUID(),fi:1,data:r},{id:Ot.generateUUID(),fi:2,data:s}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new Vt}},(n=>{n.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},n.is=function(r){return r.type==="VariableChange"},n.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new Vt,variableId:"",objectId:null,property:"Position X"}}})($E||($E={})),(n=>{n.is=function(r){return r.type==="API"},n.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new Vt,errorActions:new Vt,userAPIId:""}}})(dI||(dI={})),(n=>{n.is=function(r){return r.type==="WEBHOOK"},n.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new Vt,userWebhookId:""}}})(uI||(uI={})),(n=>{n.is=function(r){return r.type==="AIAssistantListener"},n.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new Vt,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(pI||(pI={})),(n=>{n.is=function(r){return r.type==="AIAssistantTrigger"},n.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new Vt}}})(fI||(fI={}))});function mI(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function gI(t){return typeof t=="string"&&t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}var Zc,qu,BF,Rr,vI,Ja,oh,Dg,yI,Xu,Tn,Je,YE,_I,Yl,up,bI,xI,wI,SI,MI,EI,AI,TI,iS,CI,PI,nS,DI,RI,II,rS,OI,sS,LI,BI,UI,zI,FI,NI,kI,VI,jI,jc,Ko,Zl,ZE,KE,P_,D_,R_,I_,O_,QE,JE,L_,tA,$u,GI,aS,oS,eA,HI,B_,WI,qI,U_,XI,$I,YI,ZI,KI,QI,JI,tO,eO,Wb,AC,Ki,ki,wu,UF,Rg,z_,yc,iA,TC,F_,N_,nA,Ho,c1,ir,lS,Vl,k_,ng,hS,cS,dS,Yu,uS,rA,sA,iO,Id,zF,En,V_,nO,rO,sO,aO,Ha,rg,j_,G_,Qo,Ic,oO,Kl,H_,Jo,pS,fS,bc,Gc,xc,sg,aA,lO,_r,mS,hO,cO,Wo,Fs,Zu,oA,_s=z(()=>{var t,e,i,n,r,s,a,o;Zc="personal camera",qu="a218fcc3-276b-49b9-b485-49037fd14f5f",BF=2500134,Rr=5526619,(t=vI||{}).x="x",t.y="y",t.z="z",vI=t,(l=>{function c(d,p){return Math.pow(p[0]-d[0],2)+Math.pow(p[1]-d[1],2)}function h(d,p){return Math.sqrt(c(d,p))}function u(d,p,f){let g=l.sub(p,d),m=l.sub(f,d),y=l.dot(g,m)/l.dot(g,g),v=l.scalarMultiply(g,y);return l.add(d,v)}l.isEqual=function(d,p){return d[0]===p[0]&&d[1]===p[1]},l.lerp=function(d,p,f){return[d[0]+(p[0]-d[0])*f,d[1]+(p[1]-d[1])*f]},l.add=function(d,p){return[d[0]+p[0],d[1]+p[1]]},l.sub=function(d,p){return[d[0]-p[0],d[1]-p[1]]},l.multiply=function(d,p){return[d[0]*p[0],d[1]*p[1]]},l.divide=function(d,p){return[d[0]/p[0],d[1]/p[1]]},l.distanceSquared=c,l.distance=h,l.dot=function(d,p){return d[0]*p[0]+d[1]*p[1]},l.scalarMultiply=function(d,p){return[d[0]*p,d[1]*p]},l.projectionOnto=u,l.projectionOntoDistance=function(d,p,f){return h(d,u(d,p,f))},l.center=function(d,p){return[.5*(d[0]+p[0]),.5*(d[1]+p[1])]}})(Ja||(Ja={})),(e=oh||(oh={})).isEqual=function(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]},e.add=function(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]},e.sub=function(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]},e.div=function(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]},e.mul=function(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]},e.dist=function(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])},e.lerp=function(l,c,h){return[l[0]+(c[0]-l[0])*h,l[1]+(c[1]-l[1])*h,l[2]+(c[2]-l[2])*h]},(i=Dg||(Dg={})).isEqual=function(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]&&l[3]===c[3]},i.lerp=function(l,c,h){return[l[0]+(c[0]-l[0])*h,l[1]+(c[1]-l[1])*h,l[2]+(c[2]-l[2])*h,l[3]+(c[3]-l[3])*h]},(l=>{let c=180/Math.PI,h=Math.PI/180;function u(p){return typeof p=="number"?p*c:p}function d(p){return typeof p=="number"?p*h:p}l.radToDeg=function(p){return[u(p[0]),u(p[1]),u(p[2])]},l.degToRad=function(p){return[d(p[0]),d(p[1]),d(p[2])]}})(yI||(yI={})),(n=Xu||(Xu={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],n.isEqual=function(l,c){for(let h=0;h<16;h++)if(l[h]!==c[h])return!1;return!0},n.simplify=function(l){return l??n.identity},n.applyMatrix4=function(l,c){let h=c.slice(0);for(let u=0,d=c.length;u<d;u+=3){let p=l[3]*c[u]+l[7]*c[u+1]+l[11]*c[u+2]+l[15];h[u]=(l[0]*c[u]+l[4]*c[u+1]+l[8]*c[u+2]+l[12])/p,h[u+1]=(l[1]*c[u]+l[5]*c[u+1]+l[9]*c[u+2]+l[13])/p,h[u+2]=(l[2]*c[u]+l[6]*c[u+1]+l[10]*c[u+2]+l[14])/p}return h},(r=Tn||(Tn={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},r.white={r:1,g:1,b:1},r.red={r:1,g:0,b:0},r.black={r:0,g:0,b:0},r.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},r.clone=function(l){return{r:l.r,g:l.g,b:l.b}},r.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},r.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},r.equals=function(l,c){return l.r===c.r&&l.g===c.g&&l.b===c.b},r.equalsFixed=function(l,c){return l.r.toFixed(2)===c.r.toFixed(2)&&l.g.toFixed(2)===c.g.toFixed(2)&&l.b.toFixed(2)===c.b.toFixed(2)},r.lerp=function(l,c,h){return{r:l.r+(c.r-l.r)*h,g:l.g+(c.g-l.g)*h,b:l.b+(c.b-l.b)*h}},r.is=function(l){return!!mI(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(s=Je||(Je={})).white={...Tn.white,a:1},s.is=function(l){return!!mI(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},s.transparent={...Tn.white,a:0},s.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},s.fromHexAndA=function(l,c){return{...Tn.fromHex(l),a:c}},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},s.equals=function(l,c){return Tn.equals(l,c)&&l.a===c.a},s.equalsFixed=function(l,c){return Tn.equalsFixed(l,c)&&l.a.toFixed(2)===c.a.toFixed(2)},s.lerp=function(l,c,h){return{r:l.r+(c.r-l.r)*h,g:l.g+(c.g-l.g)*h,b:l.b+(c.b-l.b)*h,a:l.a+(c.a-l.a)*h}},s.toStyle=function({r:l,g:c,b:h,a:u}=s.white){return`rgba(${255*l}, ${255*c}, ${255*h}, ${u})`},(YE||(YE={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=_I||{})[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING",a[a.ARC=7]="ARC",a[a.NONE=8]="NONE",_I=a,(Yl||(Yl={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(up||(up={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=bI||(bI={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),EX=z(()=>{var t,e;Ye(),LF(),(xI||(xI={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(wI||(wI={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(SI||(SI={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(MI||(MI={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(EI||(EI={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(AI||(AI={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(TI||(TI={})).defaultData={type:"Reset",name:"",delay:0},(iS||(iS={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=CI||(CI={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=PI||(PI={})).defaultData={type:"Audio",name:"",...iS.defaultData},e.hasAudioByActions=i=>i.some(({data:n})=>n.type==="Audio"&&n.interaction==="play"&&n.audio),e.hasAudioByEvents=i=>{for(let{data:n}of i)if(Ou.is(n)||n.type==="Start"||n.type==="Collision"){if(e.hasAudioByActions(n.actions))return!0}else if(n.type==="Conditional"){if(e.hasAudioByActions(n.inActions)||e.hasAudioByActions(n.outActions))return!0}else if(n.type==="GameControl"&&Object.values(n.gameActions).find(r=>e.hasAudioByActions(r)))return!0},e.getAudiosByActions=i=>{let n=[];return i.forEach(r=>{let s=r.data;s.type==="Audio"&&s.interaction==="play"&&s.audio&&n.push(r),s.type==="Conditional"&&(n.push(...e.getAudiosByActions(s.ifActions)),n.push(...e.getAudiosByActions(s.elseActions)))}),n},e.getAudiosByEvents=i=>{let n=[];return i.forEach(({data:r})=>{Ou.is(r)||r.type==="Collision"||r.type==="Start"||r.type==="Trigger"?n.push(...e.getAudiosByActions(r.actions)):r.type==="Conditional"?(n.push(...e.getAudiosByActions(r.inActions)),n.push(...e.getAudiosByActions(r.outActions))):r.type==="GameControl"?Object.values(r.gameActions).forEach(s=>{n.push(...e.getAudiosByActions(s))}):r.type==="DragDrop"&&(n.push(...e.getAudiosByActions(r.dragDropActions.drag)),n.push(...e.getAudiosByActions(r.dragDropActions.drop)))}),n},(nS||(nS={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(DI||(DI={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...nS.defaultData},i.hasVideoByActions=n=>n.some(({data:r})=>r.type==="Video"&&r.interaction==="play"&&r.layerId),i.hasVideoByObject=n=>{if(n.events){for(let{data:r}of n.events)if((Ou.is(r)||r.type==="Start")&&i.hasVideoByActions(r.actions))return!0}},i.getVideosByActions=n=>{let r=[];return n.forEach(s=>{let a=s.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&r.push(s)}),r},i.getVideosByEvents=n=>{let r=[];return n.forEach(({data:s})=>{(Ou.is(s)||s.type==="Start")&&r.push(...i.getVideosByActions(s.actions))}),r}})(RI||(RI={})),(II||(II={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(rS||(rS={})).defaultData=function(){return{tweens:new Vt,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(OI||(OI={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...rS.defaultData()}},(sS||(sS={})).defaultData=function(i){return{interaction:"play",timeline:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(LI||(LI={})),(BI||(BI={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...sS.defaultData(i)}},(UI||(UI={})).defaultData=function(i,n,r){return{type:"Animation",name:"",object:i,clipId:n,crop:r,crop2:r,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(zI||(zI={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(FI||(FI={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new Vt,elseActions:new Vt,condition:[]}),(NI||(NI={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(kI||(kI={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(VI||(VI={})).defaultData={name:"",type:"UserAPI"}}),AX=z(()=>{var t;(t=jI||(jI={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),FF=z(()=>{var t;(t=jc||(jc={})).all=["PerspectiveCamera","OrthographicCamera"],t.is=function(e){return t.all.includes(e)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(s){return s===void 0||!Number.isFinite(s)||s<e.MinTargetOffset?e.DefaultTargetOffset:s},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,n=e.DefaultElevation*Math.PI/180,r=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(n),e.DefaultTargetOffset*Math.sin(n),e.DefaultTargetOffset*Math.cos(i)*Math.cos(n)],e.DefaultRotation=[Math.atan2(-Math.sin(n),Math.cos(i)*Math.cos(n))*r,Math.asin(Math.sin(i)*Math.cos(n))*r,Math.atan2(Math.sin(i)*Math.sin(n),Math.cos(i))*r],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}})(Ko||(Ko={}))}),NF=z(()=>{var t;(t=Zl||(Zl={})).defaultData=function(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof e[0]=="number"?e[0]:1,typeof e[1]=="number"?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof e[0]=="number"?e[0]+e[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(n=>(typeof n=="number"?n:1)*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},t.merge=function(e,i){let n={...e};if(KE.forEach(r=>{Object.assign(n,{[r]:i[r]??e[r]})}),n.radial={...e.radial},i.radial){let r=e.radial,s=i.radial;P_.forEach(a=>{Object.assign(n.radial,{[a]:s[a]??r[a]})})}if(n.linear={...e.linear},i.linear){let r=e.linear,s=i.linear;D_.forEach(a=>{Object.assign(n.linear,{[a]:s[a]??r[a]})})}if(n.grid={...e.grid},i.grid){let r=e.grid,s=i.grid;R_.forEach(a=>{Object.assign(n.grid,{[a]:s[a]??r[a]})})}if(n.toObject={...e.toObject},i.toObject){let r=e.toObject,s=i.toObject;I_.forEach(a=>{Object.assign(n.toObject,{[a]:s[a]??r[a]})})}if(n.randomnessObject={...e.randomnessObject},i.randomnessObject){let r=e.randomnessObject,s=i.randomnessObject;O_.forEach(a=>{Object.assign(n.randomnessObject,{[a]:s[a]??r[a]})})}return n},t.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(n,r){let s=[];n.count!==void 0&&s.push({type:0,path:r,props:{count:n.count}});for(let a of i){let o=n[a];o&&Object.keys(o).length>0&&s.push({type:0,path:[...r,a],props:o})}return s}})(ZE||(ZE={})),KE=["count"],P_=["radius","start","end","position","scale","rotation"],D_=["position","scale","rotation"],R_=["count","size"],I_=["count","position","scale","rotation"],O_=["strength","scale","rotation","position","movement","seed","freqScale"]}),kF=z(()=>{var t;_s(),(t=QE||(QE={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(JE||(JE={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:Je.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:Je.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(i==="DirectionalLight")return{type:i,color:Je.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),VF=z(()=>{var t;(t=L_||(L_={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...t.defaultCollisionData}}),jF=z(()=>{var t;(t=tA||(tA={})).defaultData={gravity:10,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:0,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},t.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),CC=z(()=>{($u||($u={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),GF=z(()=>{var t,e;(t=GI||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",GI=t,(e=aS||(aS={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,n){return i.castShadow===n.castShadow&&i.receiveShadow===n.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe&&(n.shadowCatcher??!1)===(r.shadowCatcher??!1)}})(oS||(oS={})),(eA||(eA={})).defaultData={...oS.defaultData,...aS.defaultData},(HI||(HI={})).getMaterialData=function(i,n){let r=[];if("material"in i){let s=typeof i.material=="string"?n.materials[i.material]??n.lib.materials[i.material]?.asset:i.material;s&&r.push(s)}else if("materials"in i)for(let s of i.materials){let a=typeof s=="string"?n.materials[s]??n.lib.materials[s]?.asset:s;a&&r.push(a)}return r}}),HF=z(()=>{var t;(t=B_||(B_={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),Wg=z(()=>{var t,e,i,n;Ye(),_s(),HF(),_s(),(WI||(WI={})).is=function(r){return r==="texture"||r==="video"||r==="color"||r==="depth"||r==="normal"||r==="gradient"||r==="noise"||r==="fresnel"||r==="cavity"||r==="dust"||r==="rainbow"||r==="toon"||r==="outline"||r==="particle"||r==="transmission"||r==="reflection"||r==="matcap"||r==="displace"||r==="pattern"||r==="vertexColor"||r==="light"},(qI||(qI={})).is=function(r){return r==="luminance"||r==="r"||r==="g"||r==="b"||r==="a"},(U_||(U_={})).is=function(r){return typeof r=="object"&&r!==null&&r.image!=null},(XI||(XI={})).is=function(r){return r==="phong"||r==="toon"||r==="lambert"||r==="physical"},(n=$I||{})[n.Linear=0]="Linear",n[n.Radial=1]="Radial",n[n.Polar=2]="Polar",$I=n,YI=(r=>(r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",r))(YI||{}),ZI=(r=>(r[r.NearestFilter=1003]="NearestFilter",r[r.LinearFilter=1006]="LinearFilter",r[r.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",r))(ZI||{}),(i=KI||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",KI=i,(e=QI||{})[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",QI=e,(t=JI||{})[t.F1=0]="F1",t[t.F2=1]="F2",t[t.F2MinusF1=2]="F2MinusF1",t[t.SmoothBlend=3]="SmoothBlend",t[t.Edge=4]="Edge",t[t.Power=5]="Power",t[t.Lines=6]="Lines",t[t.Cells=7]="Cells",JI=t,tO=(r=>(r[r.Lights=0]="Lights",r[r.Static=1]="Static",r[r.Camera=2]="Camera",r))(tO||{}),eO=(r=>(r[r.Circle=0]="Circle",r[r.Ring=1]="Ring",r[r.Polygon=2]="Polygon",r[r.Cross=3]="Cross",r[r.Diamond=4]="Diamond",r[r.Checkerboard=5]="Checkerboard",r[r.Line=6]="Line",r[r.Wave=7]="Wave",r))(eO||{}),Wb=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],AC=["wrapping","image","video","name","minFilter","magFilter"],(r=>{r.patch=function(s,a){let{texture:o,...l}=a;if(Object.assign(s,l),o){let c=s.texture;c&&Object.assign(c,o)}},r.defaultColorLayer=function(s){return{...r.defaultData("color"),color:s}},r.defaultData=function(s,a){return s==="light"&&a?function(o){let l={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...l,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...l,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...l,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...l,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(a):function(o){let l={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...l,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...l,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:B_.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:Tn.fromHex(Rr)};case"vertexColor":return{...l,type:"vertexColor"};case"depth":return{...l,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...l,type:"normal",cnormal:[1,1,1]};case"gradient":return{...l,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...l,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Tn.fromHex(6710886),a:1},colorB:{...Tn.fromHex(6710886),a:1},colorC:{...Tn.fromHex(16777215),a:1},colorD:{...Tn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...l,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...l,type:"fresnel",color:Je.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:Je.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...l,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...l,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Je.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:Je.fromHexAndA(0,1),contourColor:Je.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...l,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...l,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...l,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...l,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Tn.fromHex(0),a:1},colorB:{...Tn.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(s)}})(Ki||(Ki={})),(r=>{function s(a,o="layer1",l="layer2",c=Tn.fromHex(16777215)){let h=new Vt;return h.push({fi:0,data:Ki.defaultData("light",a),id:o}),h.push({fi:1,data:Ki.defaultData("color"),id:l}),{layers:h}}r.isMergable=function(a){return!a.layers.some(o=>o.data.type==="texture"&&o.data.projection!==0||o.data.type==="depth"&&!o.data.isWorldSpace||o.data.type==="noise"||o.data.type==="dust"&&o.data.noiseStrength!==0||o.data.type==="displace")},r.getHash=function(a){let o="";return a.layers.forEach(l=>{Object.entries(l.data).forEach(([c,h])=>{o+=`${c}${h}`,Array.isArray(h)?h.forEach(u=>o+=`${u}`):typeof h=="object"?Object.values(h).forEach(u=>{o+=typeof u=="number"?`${u.toFixed(4)}`:`${u}`}):o+=`${h}`})}),o},r.defaultEmptyData=function(){return{layers:new Vt}},r.defaultData=function(a="layer1",o="layer2"){return s("physical",a,o)},r.withName=function(a,o){return{...a,name:o}},r.defaultTwoLayerData=s,r.defaultColorMaterial=function(a,o,l="layer1",c="layer2"){let h=new Vt;return h.push({fi:0,data:Ki.defaultData("light",o),id:l}),h.push({fi:1,data:Ki.defaultColorLayer(a),id:c}),{layers:h}},r.defaultUIObjectMaterial=function(a){let o=Ki.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new Vt;return l.push({fi:0,data:o,id:"layer1"}),l.push({fi:1,data:{...Ki.defaultData("transmission"),alpha:1},id:"layer2"}),l.push({fi:2,data:{...Ki.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:l}},r.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",c="layer2"){let h=Ki.defaultData("texture");Object.assign(h.texture,{image:a});let u=new Vt;return u.push({fi:0,data:h,id:l}),u.push({fi:1,data:Ki.defaultData("light",o),id:c}),{layers:u}},r.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",c="layer2"){let h=Ki.defaultData("video");Object.assign(h.texture,{video:a});let u=new Vt;return u.push({fi:0,data:h,id:l}),u.push({fi:1,data:Ki.defaultData("light",o),id:c}),{layers:u}}})(ki||(ki={}))}),TX=z(()=>{wu="Roboto_regular",UF="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),WF=z(()=>{Ye(),(Rg||(Rg={})).defaultData=function(){return{points:new Vt,roundness:0,shapeHoles:[],isClosed:!1}}}),qF=z(()=>{Ye(),(z_||(z_={})).defaultData=function(){return{points:new Vt,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},yc={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(iA||(iA={})).merge=function(t,e){let i={...t};return F_.forEach(n=>{Object.assign(i,{[n]:e[n]??t[n]})}),i},TC={shape:yc,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},F_=["depth","offset","angle","twist","startScale","endScale"]}),PC=z(()=>{var t,e;WF(),qF(),(t=N_||(N_={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},t.isParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"||i==="DecalGeometry"},t.isSwappableGeometry=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"},(nA||(nA={})).merge=function(i,n){let r={...i};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...i.extrusion},Object.assign(r.extrusion,iA.merge(r.extrusion,n.extrusion))),r},(e=Ho||(Ho={})).defaultData=function(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:z_.defaultData(),extrusion:TC};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Rg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="DecalGeometry")return{type:i,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")},c1=["width","height","depth"]}),XF=z(()=>{_s(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:Tn.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let n=e(i);return n==="height"?1:n==="both"?2:0},t.getDensity=function(i){return i.density??t.defaultData.density},t.getHeightFalloff=function(i){return i.heightFalloff??t.defaultData.heightFalloff},t.getHeightBase=function(i){return i.heightBase??t.defaultData.heightBase}})(ir||(ir={}))}),DC=z(()=>{(lS||(lS={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Vl||(Vl={})).defaultData={enabled:!1,mode:"hdri",hdri:lS.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}}),$F=z(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(k_||(k_={})).defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})()}),RC=z(()=>{var t;XF(),DC(),$F(),_s(),(t=ng||(ng={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(hS||(hS={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(cS||(cS={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(dS||(dS={})),(Yu||(Yu={})).defaultData={usePhysics:!1,gravity:-10},(uS||(uS={})).defaultData={playCamera:Zc,gameControlObject:null},(rA||(rA={})).defaultData={backgroundColor:Je.fromHexAndA(BF,1),postprocessing:k_.defaultData,fog:ir.defaultData,sky:Vl.defaultData,globalPhysics:Yu.defaultData,ambient:hS.defaultData,ao:cS.defaultData,shadow:ng.defaultData,publish:uS.defaultData,grading:dS.defaultData}}),CX=z(()=>{(sA||(sA={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),qb=z(()=>{var t,e,i;Ye(),FF(),kF(),VF(),jF(),CC(),GF(),_s(),Wg(),PC(),NF(),Dn(),RC(),CX(),(t=iO||(iO={})).isComponentRelated=function(n){return n==="Component"||n==="Instance"},t.isEmptyOrComponent=function(n){return n==="Empty"||n==="Instance"},(e=Id||(Id={})).identity={...YE.identity,hiddenMatrix:Xu.identity},e.fromObject=function(n){return{position:n.position,rotation:n.rotation,scale:n.scale,pivot:n.pivot,pivotRotation:n.pivotRotation,hiddenMatrix:n.hiddenMatrix}},e.merge=function(n,r){return{position:r?.position||n.position,rotation:r?.rotation||n.rotation,pivot:r?.pivot||n.pivot,pivotRotation:r?.pivotRotation||n.pivotRotation,scale:r?.scale||n.scale,hiddenMatrix:r?.hiddenMatrix||n.hiddenMatrix}},e.diff=function(n,r){return fF({position:oh.isEqual(n.position,r.position)?void 0:r.position,rotation:oh.isEqual(n.rotation,r.rotation)?void 0:r.rotation,scale:oh.isEqual(n.scale,r.scale)?null:r.scale,hiddenMatrix:Xu.isEqual(n.hiddenMatrix,r.hiddenMatrix)?void 0:r.hiddenMatrix})},zF=["slide","offset"],(En||(En={})).defaultData={states:new Vt,events:new Vt,visible:!0,raycastLock:!1,physics:$u.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Id.identity,cloner:null},(V_||(V_={})).defaultData={type:"Empty",...En.defaultData},(nO||(nO={})).defaultData={type:"ParticleCollider",...sA.defaultData,...En.defaultData},(rO||(rO={})).defaultData={type:"Component",...En.defaultData},(sO||(sO={})).defaultData={type:"Particle",...En.defaultData,...L_.defaultData},(aO||(aO={})).defaultData={type:"Hair",...En.defaultData,...tA.defaultData},(Ha||(Ha={})).defaultData={type:"Mesh",...En.defaultData,...eA.defaultData},(rg||(rg={})).defaultData={...En.defaultData,...Id.identity,position:Ko.DefaultPosition,rotation:Ko.DefaultRotation,...Ko.defaultData},(n=>{n.defaultData=function(r){return{...En.defaultData,...JE.defaultData(r)}},n.defaultDirectionalLightData={...n.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(j_||(j_={})),(n=>{function r(s,a,o=0){for(;o<a.length;){let l=s?s[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;s=l.descendants,o+=1}}n.resolveWithDes=r,n.resolve=function(s,a,o=0){let l=r(s,a,o);if(l){let c=Object.keys(l);if(c.length===1&&c[0]==="descendants")return}return l}})(G_||(G_={})),(n=>{function r(s,a){return{...En.defaultData,...a,component:s,overrides:new mn,physics:void 0,events:void 0,type:"Instance"}}n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"],n.ofComponent=r,n.fromComponentData=function(s){let a=Id.fromObject(s.data);return r(s.id,a)}})(Qo||(Qo={})),(n=>{n.defaultData={type:"Page",...En.defaultData,physics:{...$u.defaultData,fusedBody:!1},...rA.defaultData,camera:rg.defaultData,timelines:new te},n.isUIPage=function(r){return r.uiScene!==void 0}})(Ic||(Ic={})),(i=oO||(oO={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Xu.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:$u.defaultData,states:new Vt,events:new Vt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Ko.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("RectangleGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("BooleanGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("ShapeBlendGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("TextGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("InputGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},(n=>{n.newEmpty=function(r,s){let a={name:s};return r.type==="Mesh"?(a.geometry={},"material"in r&&(a.material={layers:new mn}),"materials"in r&&(a.materials=r.materials.map(o=>({layers:new mn})))):jc.is(r.type)&&(a.perspective={},a.orthographic={}),a},n.toOps=function(r,s){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function c(h,u){for(let[d,p]of Object.entries(u.layers)){let{texture:f,...g}=p;if(f!==void 0&&Object.keys(f).length>0){let m={path:[...h,"layers",d,"texture"],props:f,type:0};o.push(m)}if(Object.keys(g).length>0){let m={path:[...h,"layers",d],props:g,type:0};o.push(m)}}}for(let[h,u]of Object.entries(s)){let d=u;if(h!=="name")if(h==="cloner")o.push(...ZE.toOps(d,["cloner"]));else if(h==="pathSnapping")o.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[p,f]of Object.entries(d))c(["materials",p],f);else if(l[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let p={path:[h,"extrusion"],props:d.extrusion,type:0};o.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[h],props:d,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[h]=d}return o},n.patch=function(r,s){if(s===void 0)return r;let a={...r};if(Object.assign(a,Id.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),jc.is(r.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=s;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(r.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:nA.merge(a.geometry,s.geometry)}),(s.material||s.materials)&&(a=function(o,l){if(l===void 0)return o;let c={...o};return"material"in c&&"material"in l&&l.material&&(c.material=E_(c.material,h=>{if(typeof h!="string")for(let[u,d]of Object.entries(l.material.layers)){let p=h.layers.data(u);p&&Ki.patch(p,d)}}).data),c.materials&&l.materials&&(c.materials=E_(c.materials,h=>{for(let u=0;u<c.materials.length;u++){let d=l.materials[u];if(typeof d!="string")for(let[p,f]of Object.entries(d.layers)){let g=h[u]?.layers?.data(p);g&&Ki.patch(g,f)}}}).data),c}(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Zl.merge(a.cloner,s.cloner)});else if(r.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Zl.merge(a.cloner,s.cloner)});else if(QE.is(r.type)){let o=s;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=Tn.clone(o.color))}return a}})(Kl||(Kl={}))}),IC=z(()=>{(H_||(H_={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),Xb=z(()=>{IC(),_s(),(Jo||(Jo={})).defaultData={orbitControls:H_.defaultData,playPage:qu,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,n=0;return e<5?n=-30:e<10&&(n=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,n],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu",asyncShaderCompilation:!0}}),YF=z(()=>{var t;(pS||(pS={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(fS||(fS={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=bc||(bc={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...pS.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:fS.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),OC=z(()=>{qb(),Ye(),Xb(),_s(),Dn(),YF(),(t=>{function e(i,n){let r=i.scene.objects.get(n);if(r&&r.data.type==="Component")return r;{let s=i.shared.lib.components[n];if(s)return{...s.asset,id:n}}}t.physicsEnabled=function(i){return i.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,n){let r=i.find(s=>s.data.type==="Page"&&s.data.timelines?.[n]!==void 0);return r&&r.data.timelines?.[n]},t.getComponentData=e,t.traverseModuleInstances=function(i,n,r){i.scene.objects.traverseFrom(n,(s,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&r(s,a,o.events)}else r(s,a,a.events)})}})(Gc||(Gc={})),(t=>{function e(n=!0,r=[]){let s=[];n&&s.push({...t.defaultLight}),s.push(...r);let a=new Xn;return a.push({fi:1,id:qu,data:{...Ic.defaultData,name:"Scene 1"},children:s}),a}function i(n){return{...t.defaultData,objects:Er(n,Xn.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:j_.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:Jo.defaultData,styles:bc.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new Xn,publish:Jo.defaultData,styles:bc.defaultData()}},t.emptyDataWithPage=function(n=!0){return{objects:e(n),publish:Jo.defaultData,styles:bc.defaultData()}},t.emptyData=function(){return{objects:new Xn,publish:{...Jo.defaultData},styles:bc.defaultData()}},t.withObjs=i,t.withObj=function(n,r){return i([{id:n,data:r,children:[],fi:0}])}})(xc||(xc={}))}),ZF=z(()=>{(sg||(sg={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),LC=z(()=>{var t,e;Ye(),Dn(),(t=aA||(aA={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new Vt}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(lO||(lO={})).defaultData=(i,n="GET")=>({url:i,method:n,name:"New API",headers:new Vt,queries:new Vt,autoStart:!0}),(i=>{function n(s){return s.textValue!==void 0}function r(s){return typeof s=="boolean"}i.isTextValue=n,i.isNumber=function(s){return typeof s=="number"},i.isBoolean=r,i.typeOfVariable=function(s){return n(s)?"string":r(s)?"boolean":"number"},i.getDisplayedValue=function(s){return i.isTextValue(s)?Array.isArray(s.textValue)?s.textValue.map(a=>a.toString().padStart(s.padding??2,"0")).join(s.deliminator??":")+(s.suffix!==void 0?" "+s.suffix:""):s.textValue.toString():i.isBoolean(s)?s?"True":"False":i.isNumber(s)?parseFloat(s.toFixed(3)).toString():s.toString()}})(_r||(_r={})),(mS||(mS={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(hO||(hO={})).all=[...mS.all,"components"],(cO||(cO={})).defaultData=function(){return{images:new te,videos:new te,colors:new te,audios:new te,particles:new te,fonts:new te,materials:new te,components:new te,variables:new te,userAPIs:new te,userWebhooks:new te}},(Wo||(Wo={})).defaultData=function(){return{images:new te,videos:new te,colors:new te,audios:new te,particles:new te,fonts:new te,materials:new te,components:new te,variables:new te,userAPIs:new te,userWebhooks:new te}},(e=Fs||(Fs={})).defaultColors=function(){return Er({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},te.prototype)},e.defaultImages=function(){return Er({},te.prototype)},e.emptyData=function(){return{catelogs:new te,materials:new te,images:new te,videos:new te,colors:new te,audios:new te,particles:new te,fonts:new te,variables:new Vt,userAPIs:new te,userWebhooks:new te,lib:Wo.defaultData()}},e.defaultVariables=function(i){switch(i){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let n=[0,0,0];return{name:"Time",value:{textValue:n,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:n,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",i)}},e.getFormattedTimerTime=function(i,n){if(n.format==="HH:mm:ss"){let r=Math.floor(i/3600),s=Math.floor((i-3600*r)/60);return{textValue:[r,s,Math.round(i-3600*r-60*s)]}}if(n.format==="mm:ss"){let r=Math.floor(i/60);return{textValue:[r,Math.round(i-60*r)]}}return n.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),PX=z(()=>{}),KF=z(()=>{var t;Ye(),OC(),ZF(),LC(),(t=Zu||(Zu={})).defaultData={schema:131,scene:xc.defaultData,frames:new te().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sg.defaultData),shared:{...Fs.emptyData(),colors:Fs.defaultColors()}},t.createDefaultData=function(){return Pg.deserialize(Pg.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:131,scene:xc.emptyDataWithPage(),frames:new te().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sg.defaultData),shared:{...Fs.emptyData(),colors:Fs.defaultColors(),images:Fs.defaultImages()}}},t.emptyData=function(){return{schema:131,scene:xc.emptyDataWithPage(),frames:new te().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sg.defaultData),shared:Fs.emptyData()}},t.clipboard2dData=function(){return{schema:131,scene:xc.emptyData(),frames:new te,shared:Fs.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:Wo.defaultData()}}},t.getComponentData=function(e,i){return Gc.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let n of i){let r=n.headers;for(let s of r)if(s.data.key.toLowerCase()==="authorization"&&s.data.value!=="")return!0}return!1}}),DX=z(()=>{(oA||(oA={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function Oc(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function Pf(t,e,i){switch(t){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:n,control2:r}=e??{...up.defaultData};return`cubicBezier( ${n[0]}, ${n[1]}, ${r[0]}, ${r[1]} )`}case 6:{let{mass:n,stiffness:r,damping:s,velocity:a}=i??{...Yl.defaultData},o=new QF(n,r,s,a),l=o.solve(1);return()=>c=>o.solve(c)/l}case 8:return()=>n=>Math.floor(n)}}var dO,uO,Lc,Ig,QF,W_,q_,JF=z(()=>{Ye(),_s(),(dO||(dO={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new te}},(uO||(uO={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(h,u){let d=[0,0],p=[1,1];if(h?.cubicControls)d=Oc(h.cubicControls.control1,d);else switch(h?.type){case 2:case 4:d=[.42,0];break;case 3:case 0:d=[0,0];break;case 1:d=[.25,.1];break;case 7:d=[.25,1]}if(u?.cubicControls)p=Oc(u.cubicControls.control2,p);else switch(u?.type){case 2:case 0:p=[1,1];break;case 3:case 4:p=[.58,1];break;case 1:p=[.25,1];break;case 7:p=[.5,1]}return{control1:d,control2:p}}function i(h){if(!t.BEZIER_PRESETS.includes(h))return;let u={type:h};return{control1:e(u).control1,control2:e(void 0,u).control2}}function n(h,u){return Math.abs(h[0]-u[0])<.001&&Math.abs(h[1]-u[1])<.001}function r(h){let u=t.ROOT_PROPERTY_ORDER.indexOf(h[0]);return u===-1?t.ROOT_PROPERTY_ORDER.length:u}function s(h){return h.layerId??h.path.join(".")}function a(h){let u=h[h.length-1];return Ig.includes(u)?u:void 0}function o(h){return h.layerId?h.layerId:(a(h.path)?h.path.slice(0,-1):h.path).join(".")}function l(h){return["material",h.type==="light"?`${h.category} lighting`:h.type]}function c(h,u,d){return{id:h,data:{id:h,time:d?.time??0,path:u,value:{},layerId:d?.layerId,index:d?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}t.getControlsWithDefault=e,t.BEZIER_PRESETS=[0,1,2,3,4,7],t.presetHandles=i,t.presetForHandles=function(h){return t.BEZIER_PRESETS.find(u=>{let d=i(u);return d!==void 0&&n(d.control1,h.control1)&&n(d.control2,h.control2)})},t.defaultData=function(h){return{id:h,keyframes:new Vt}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=r,t.propertyKey=s,t.groupKeyframes=function(h,u){let d=new Map;for(let p of h){let f=p.data;if(u?.(f))continue;let g=s(f),m=d.get(g);m||(m={id:g,path:f.path,keyframes:[],layerId:f.layerId,index:f.index},d.set(g,m)),f.isPlaceholder?m.placeholder=p.id:m.keyframes.push(p)}return[...d.values()].sort((p,f)=>{let g=r(p.path)-r(f.path);return g!==0?g:(p.index??0)-(f.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(h){let u=new Map;for(let d of h){let p=a(d.path),f=p?d.path.slice(0,-1):d.path,g=o(d),m=u.get(g);m||(m={id:g,path:f,layerId:d.layerId,index:d.index,tracks:[]},u.set(g,m)),m.tracks.push({axis:p,property:d})}return[...u.values()]},t.sortedKeyframes=function(h){return[...h].sort((u,d)=>u.data.time-d.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(h,u){return h.map(({data:d,id:p},f)=>c(u(),l(d),{layerId:p,index:f}))},t.placeholderKeyframe=c,t.createName=function(h){return Object.entries(h).reduce((u,[d,p])=>(typeof p!="string"&&u.push({name:p.name}),u),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:Pf(3),duration:1e3},opacity:{value:[0,1],easing:Pf(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:Pf(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:Pf(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:Pf(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Lc||(Lc={})),Ig=["x","y","z"],QF=class{constructor(t=1,e=100,i=10,n=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=n,this.m_w0=Math.sqrt(e/t),this.m_zeta=i/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-n)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-n+this.m_w0)}solve(t){return 1-(this.m_zeta<1?Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0))}getDuration(){let t=.16666666666666666,e=0,i=0;for(;;)if(e+=t,this.solve(e)===1){if(i++,i>=16)break}else i=0;return e*t*1e3}}}),BC=z(()=>{var t;_s(),Ye(),(W_||(W_={})).list=["idle","move","jump","run"],(t=q_||(q_={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Vt,move:new Vt,jump:new Vt,run:new Vt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Je.fromHexAndA(3728051,1)}}});function uc(t,...e){let i={};for(let n of e.flat())t!=null&&n in t&&(i[n]=t[n]);return i}function pO(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,n=e.colorB,r=[[i.r,i.g,i.b,i.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let o=2;o<10;o++)r.push(r[1]),s.push(1);let a={...uc(hn(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:r,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,a)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let i={...hn(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Fo(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function No(t,e){t.scene.objects.traverse((i,n)=>{"materials"in n?n.materials.forEach((r,s)=>{r===void 0&&(n.materials[s]=ki.defaultTwoLayerData("phong"),r=n.materials[s]),typeof r!="string"&&e(r)}):"material"in n?typeof n.material!="string"&&(n.material===void 0&&(n.material=ki.defaultTwoLayerData("phong")),e(n.material)):n.type==="Mesh"&&(n.material===void 0&&(n.material=ki.defaultTwoLayerData("phong")),e(n.material)),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&Object.getPrototypeOf(r.material)!==mn.prototype&&e(r.material)})})}function fO(t){t.layers===void 0&&Object.assign(t,ki.defaultTwoLayerData("lambert"))}function gS(t){!t.layers||t.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let i=[...e.colors];i.push(e.colors[9]);let n=[...e.steps];n.push(e.steps[9]);let r={...hn(e),colors:i,steps:n};Object.assign(e,r)}})}function mO(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(n=>{typeof n!="string"&&gS(n)}):"material"in i&&typeof i.material!="string"&&gS(i.material)}),Object.values(t.shared.materials).forEach(e=>gS(e))}function gO(t){t.layers&&t.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function vO(t){t.layers&&t.layers.forEach(e=>{(function(i){return i.type!=="displace"})(e)&&e.isMask===void 0&&(e.isMask=!1),(e.type==="texture"||e.type==="video")&&e.blending===void 0&&(e.blending=0),(e.type==="noise"||e.type==="displace"&&e.displacementType==="noise")&&(e.voronoiStyle===void 0&&(e.voronoiStyle=0),e.highCut===void 0&&(e.highCut=1),e.lowCut===void 0&&(e.lowCut=0),e.smoothness===void 0&&(e.smoothness=.3),e.seed===void 0&&(e.seed=0),e.quality===void 0&&(e.quality=1))})}function yO(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Ki.defaultData("light","phong"),n=e;Object.assign(n,i),n.visible=!1}}function _O(t){Fo(t,yO),No(t,yO)}function bO(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function xO(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var RX=z(()=>{Wg(),_s(),IC(),qb(),Ye(),Xb(),Dn(),et(),PC(),BC(),YF(),OC(),CC(),RC()}),tN={};function wO(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function SO(t){t.rotation=t.rotation.slice(0,3).map(e=>e*_c)}function eN(t){SO(t),t.type==="Page"&&SO(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(n=>n*_c))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*_c),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*_c),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=_c,e.extrusion.twist*=_c),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(hn(t.events))&&t.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function IX(t){t.scene.objects.traverse((e,i)=>{})}function OX(t){let e=t.schema??104;e!==131&&e<130&&(X_(t.asset),t.schema=130)}function Lu(t,e){e(t.data);for(let i of t.children)Lu(i,e)}function iN(t){let e=t.schema??104;e!==131&&(e<105&&(Lu(t.asset,eN),t.schema=105),e<118&&(Lu(t.asset,rN),t.schema=118),e<121&&(Lu(t.asset,hA),t.schema=121),e<130&&(Lu(t.asset,LX),t.schema=130))}function nN(t,e){No(t,e),Fo(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function X_(t){t.layers===void 0&&Object.assign(t,ki.defaultTwoLayerData("phong"))}function LX(t){"materials"in t?t.materials.forEach(e=>{e!==void 0&&typeof e!="string"&&X_(e)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&X_(t.material)}function rN(t){t.timelineAnimations=Er({},te.prototype)}function BX(t){let e=[];return t?(t.forEach((i,n)=>{let{path:r,keyframes:s}=i.data,a=r[0]==="material"?i.id:void 0;s?.length?s.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:r,layerId:a,index:n}})}):e.push(Lc.placeholderKeyframe(i.id,r,{layerId:a,index:n}))}),e.sort((i,n)=>i.data.time-n.data.time),new Vt(...e.map((i,n)=>({...i,fi:n})))):new Vt}function UX(t){for(let{id:e,data:i}of[...t.unproxy()]){let n=i.path?.[0];if(!n||!sN.includes(n))continue;let r=lA(i.value);if(!r.length)continue;let s=t.data(e);if(!s)continue;let a=i.value,[o,...l]=r;for(let c of l){let h=Ot.generateUUID();t.insertBefore(null,[{id:h,data:{...i,id:h,path:[n,c],value:a[c],easing:zX(i.easing)}}])}s.path=[n,o],s.value=a[o]}}function lA(t){return t===null||typeof t!="object"?[]:Ig.filter(e=>e in t)}function zX(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function FX(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function NX(t){let e=function(s){let a=[];for(let o of Lc.groupKeyframes(s)){let l=new Set(o.keyframes.flatMap(h=>lA(h.data.value))),c=l.size?[...l].map(h=>o.keyframes.filter(u=>lA(u.data.value).includes(h))):[o.keyframes];for(let h of c){let u=[...h].sort((d,p)=>d.data.time-p.data.time);for(let d=0;d+1<u.length;d++)a.push({left:u[d],right:u[d+1]})}}return a}([...t.unproxy()]),i=new Map,n=new Set;for(let{left:s,right:a}of e){let o=s.data.easing?.type,l=(o===void 0?void 0:Lc.presetHandles(o))?.control2??(o===5?Oc(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let c=i.get(a.id);c?FX(c,l)||n.add(a.id):i.set(a.id,l)}let r=new Map;for(let{id:s,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Lc.presetHandles(o);l&&r.set(s,l.control1)}for(let{left:s,right:a}of e)n.has(a.id)&&r.delete(s.id);for(let[s,a]of r){let o=t.data(s);!o?.easing||(o.easing.cubicControls={control1:a,control2:Oc(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:s,right:a}of e){if(!r.has(s.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Oc(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function MO(t,e){t.scene.objects.traverse((i,n)=>{let r=n;if(r.type==="Page"&&r.timelines)for(let s of Object.values(r.timelines))for(let a of Object.values(s.objectTimelines??{}))e(a.keyframes)})}function hA(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function kX(t){}function VX(t){let e=t.schema??0;if(e!==131){if(e>131)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 131). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",131),function(i,n){if(n<1&&(No(i,pO),Fo(i,pO),i.schema=1),n<2&&(function(r){Object.assign(r.scene.publish,{orbitControls:{...H_.defaultData,...hn(r.scene.publish.orbitControls)}})}(i),i.schema=2),n<3&&(function(r){function s(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,c]of Object.entries(o))if((Wb.includes(l)||typeof c=="boolean")&&delete o[l],l==="texture")for(let[h,u]of Object.entries(c))(AC.includes(h)||typeof u=="boolean")&&delete c[h]}}}r.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let c=l;c.material?s(c.material):c.materials&&c.materials.forEach(h=>{s(h)})})})}(i),i.schema=3),n<4&&(function(r){r.scene.publish.withBackground=!0}(i),i.schema=4),n<5&&(function(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),n<6&&(function(r){r.scene.objects.traverse((s,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),n<7&&(function(r){r.scene.objects.traverse((s,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),n<8&&(i.schema=8),n<9&&(mO(i),i.schema=9),n<10&&(function(r){r.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),n<11&&(function(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((s,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),n<12&&(mO(i),i.schema=12),n<13&&(function(r){r.shared.audios=Er({},te.prototype)}(i),i.schema=13),n<14&&(function(r){let s=r.shared.materials;Object.entries(s).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(s,{[a]:l})}})}(i),i.schema=14),n<15&&(function(r){Object.entries(hn(r.shared.images)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete r.shared.images[s]}),Object.entries(hn(r.shared.audios)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete r.shared.audios[s]})}(i),i.schema=15),n<16&&(function(r){r.scene.publish.settings.web.preload=!1}(i),i.schema=16),n<17&&(No(i,gO),Fo(i,gO),i.schema=17),n<18&&(No(i,fO),Fo(i,fO),i.schema=18),n<19&&(function(r){Object.assign(r.scene.publish.settings,{video:{...Jo.defaultData.settings.video,...hn(r.scene.publish.settings.video)}})}(i),i.schema=19),n<20&&(function(r){r.shared.fonts=Er({},te.prototype)}(i),function(r){let s=[];r.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let c=ki.defaultTwoLayerData("phong"),h=typeof l.color=="string"?r.shared.colors[l.color]:l.color;c.layers[1].data.color={r:h.r,g:h.g,b:h.b},c.layers[1].data.alpha=l.alpha;let u=function(f){return f.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(g=>g.charAt(0).toUpperCase()+g.slice(1)).join(" ")}(l.font);r.shared.fonts[u]===void 0&&(r.shared.fonts[u]={name:u});let d={name:l.name,...En.defaultData,...Ha.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ho.defaultData("TextGeometry"),width:l.width,height:l.height,font:u,depth:0,horizontalAlign:l.horizontalAlign,verticalAlign:l.verticalAlign,fontSize:1.40625*l.fontSize,lineHeight:l.lineHeight/1.40625,letterSpacing:l.letterSpacing-1,text:l.text,textTransform:l.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:c,states:hn(l.states),events:hn(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=hn(r.scene.objects).parent(a);r.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:d,children:[]}]),s.push(a)}}),s.forEach(a=>{r.scene.objects.delete(a)})}(i),i.schema=20),n<21&&(function(r){let s={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(s[Number(l.type)])if(Object.assign(l,{type:s[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new Vt,move:new Vt,jump:new Vt}});else{let c=new Vt;Object.assign(l,{actions:c}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&c.push({fi:0,id:Ot.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((h,u,d)=>{let p={easing:h.easing,duration:h.duration};h.easing===6?Object.assign(p,uc(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let f={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},g={state:h.state,...f,...p},m={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Vt({fi:0,id:Ot.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:Ot.generateUUID(),data:g})};c.push({fi:d,id:u,data:m})}),delete l.targets)}})})}(i),function(r){r.scene.objects.traverse((s,a)=>{function o(l,c){let h=new Vt,u=[];if(a.events.forEach((d,p,f)=>{if(d.type==="Audio"&&d.trigger===c){let g;u.push(p),d.interaction==="play"?g={...uc(d,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in d?d.after:void 0,toggle:"after"in d?d.toggle:void 0,type:"Audio"}:(d.interaction==="pause"||d.interaction==="stop")&&(g={...uc(d,"interaction","delay","object","playAudio"),type:"Audio"}),g&&h.push({fi:f,id:p,data:g})}}),u.forEach(d=>a.events.delete(d)),h.length){let d=a.events.find(p=>p.type===l)?.data;d?"actions"in d&&d.actions.insertBefore(null,h):a.events.insertBefore(null,[{id:Ot.generateUUID(),data:{type:l,actions:h}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),n<22&&(_O(i),i.schema=22),n<23&&(function(r){r.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),n<24&&(function(r){r.scene.objects.traverse((s,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(n<25||i.shared.videos===void 0)&&(function(r){r.shared.videos=Er({},te.prototype)}(i),n<25&&(i.schema=25)),n<26&&(function(r){r.scene.objects.traverse((s,a)=>{let o=r.scene.objects.unproxy().parent(s);if(o){let l=hn(r.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=hn(a).booleanExclude!==!0)}})}(i),i.schema=26),n<27&&(function(r){r.scene.objects.traverse((s,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),n<28&&(_O(i),i.schema=28),n<29&&(function(r){function s(o){Object.setPrototypeOf(o,mn.prototype),o.texture&&Object.setPrototypeOf(o.texture,mn.prototype)}function a(o){Object.setPrototypeOf(o,mn.prototype);for(let l in o)s(o[l])}r.scene.objects.traverse((o,l)=>{l.states.forEach(c=>{let h=c;if(h.material){let u=hn(h.material).layers;a(u),h.material.layers=u}if(h.materials)for(let u=0;u<h.materials.length;u++){let d=h.materials[u],p=hn(d).layers;a(p),d.layers=p}})})}(i),i.schema=29),n<30&&(function(r){r.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=ki.defaultTwoLayerData("phong"))})}(i),i.schema=30),n<31&&(function(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.scene.objects.traverse((s,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),n<33&&(function(r){r.scene.objects.traverse((s,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),n<34&&(function(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}(i),i.schema=34),n<35&&(function(r){let{video:s}=r.scene.publish.settings;s.format==="gif"&&s.fps>48&&(s.fps=15)}(i),i.schema=35),n<36&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),n<37&&(function(r){let s=r.scene.environment.usePhysics;r.scene.objects.traverse((a,o)=>{s&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),n<38&&(No(i,vO),Fo(i,vO),i.schema=38),n<39&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=q_.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),n<40&&(function(r){r.scene.styles||(r.scene.styles=bc.defaultData())}(i),i.schema=40),n<41&&(function(r){r.scene.environment.ambientLight.occlusion===void 0&&(r.scene.environment.ambientLight.occlusion=!1),r.scene.environment.ambientLight.aoFullRes===void 0&&(r.scene.environment.ambientLight.aoFullRes=!1),r.scene.environment.ambientLight.radius===void 0&&(r.scene.environment.ambientLight.radius=256),r.scene.environment.ambientLight.bias===void 0&&(r.scene.environment.ambientLight.bias=.5),r.scene.environment.ambientLight.aoColor===void 0&&(r.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),No(r,bO),Fo(r,bO)}(i),i.schema=41),n<42&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new Vt})})})}(i),i.schema=42),n<43&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),n<99){No(i,xO),Fo(i,xO),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Zc);let r=hn(i.scene.objects),s=i.scene.objects;i.scene.publish.playPage=qu,s.insertBefore(null,null,[{id:qu,data:{...Ic.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:uc(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:uc(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Yu.defaultData,...uc(i.scene.environment,"usePhysics","gravity")},camera:hn(i.scene.ownerCamera)??Ic.defaultData.camera,name:"Scene"},children:[]}]);for(let l of r)l.id!==xc.TRASH_CAN_ID&&s.move(qu,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,c)=>{c.type==="DirectionalLight"?(c.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):c.type==="SpotLight"&&(c.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(c.physics===void 0||c.physics===null)&&c.type!=="Instance"&&(c.physics={},Object.assign(c.physics,$u.defaultData)),c.physics!==void 0&&c.physics!==null&&(c.physics.enabled=c.collision??"visibility",delete c.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=Jo.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(No(t,wO),Fo(t,wO),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((n,r)=>{let s=r.geometry;s&&s.type==="PathGeometry"&&(s.extrusion.capType="flat",s.extrusion.bevel=50,s.extrusion.bevelSides=6,s.extrusion.shape.type==="Custom"&&(s.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new te,t.shared.lib=Wo.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=Er({},te.prototype)}(t),t.scene.objects.traverse((i,n)=>{eN(n)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))iN(i);e<106&&(function(i){let n=hn(i.shared.variables);i.shared.variables=Er(Object.entries(n??{}).map(([r,s],a)=>({fi:a,id:r,data:s})),Vt.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=Wo.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=Er({},te.prototype),i.shared.lib&&(i.shared.lib.particles=Wo.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((n,r)=>{r.type==="Particle"&&typeof r.renderMaterial.size=="number"&&Object.assign(r.renderMaterial,{size:[r.renderMaterial.size,r.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,n)=>{(function(r){Array.isArray(hn(r.events))&&r.events?.forEach(s=>{"disabled"in s||(s.disabled=!1),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress")&&(s.mode=s.mode||"Object")})})(n)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((n,r)=>{r.type==="Page"&&(r.postprocessing.depthOfField.focusDistance=100,r.postprocessing.depthOfField.focalLength=20,r.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((n,r)=>{Array.isArray(hn(r.events))!==!1&&r.events?.forEach(s=>{let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(o=>{s.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&(l.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,s.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),s.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,s.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):s.type==="Start"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,s.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}),s.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(t),t.schema=113),e<114&&(t.scene.publish.settings.web.imageQuality===void 0&&(t.scene.publish.settings.web.imageQuality=70),t.schema=114),e<115&&(function(i){i.shared.userAPIs=Er({},te.prototype),i.shared.userWebhooks=Er({},te.prototype),i.shared.lib&&(i.shared.lib.userAPIs=Wo.defaultData().userAPIs,i.shared.lib.userWebhooks=Wo.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Jo.defaultData.settings.videoStatic)}(t),t.schema=116),e<117&&(t.scene.publish.settings.web.pixelRatioMobile===void 0&&(t.scene.publish.settings.web.pixelRatioMobile=0),t.scene.publish.settings.web.pixelRatioDesktop===void 0&&(t.scene.publish.settings.web.pixelRatioDesktop=0),t.schema=117),e<118&&(t.shared.timelineAnimations=Er({},te.prototype),t.scene.objects.traverse((i,n)=>{rN(n)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=Zu.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=Zu.defaultData.scene.publish.settings.videoStatic.imageFormat,t.schema=119),e<120&&(t.scene.publish.settings.image.colorSpace="display-p3",t.scene.publish.settings.videoStatic.colorSpace="display-p3",t.schema=120),e<121&&(t.scene.objects.traverse((i,n)=>{hA(n),n.type==="Page"&&n.camera!==void 0&&hA(n.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=Zu.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,n)=>{n.type==="Page"&&n.sky===void 0&&(n.sky=Vl.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&(typeof r.exposure=="number"&&(r.exposure=Math.round(r.exposure/5e-4*1e4)/1e4),r.lighting===void 0&&(r.lighting=Vl.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&r.lightingIntensity===void 0&&(r.lightingIntensity=Vl.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&(r.mode===void 0&&(r.mode="physical"),r.hdri===void 0?r.hdri={...Vl.defaultData.hdri}:(r.hdri.blur===void 0&&(r.hdri.blur=Vl.defaultData.hdri.blur),Array.isArray(r.hdri.rotation)&&(r.hdri.rotation=r.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r?.hdri!==void 0&&r.hdri.showBackground===void 0&&(r.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&r.lightingQuality===void 0&&(r.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,n)=>{if(n.type==="Page"){n.camera===void 0&&(n.camera=Ic.defaultData.camera);let r=n.camera;r.far=1e5,r.perspective?r.perspective.near=70:r.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(nN(t,X_),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((n,r)=>{let s=r.states;if(!s)return;let a=r.timelineAnimations,o=[];s.forEach((l,c)=>{(l.isAnimation||a?.[c])&&o.push(c)}),o.forEach(l=>s.delete(l))})}(t),function(i){let n=i.shared,r=n.timelineAnimations;if(!r)return;let s=i.scene.objects,a=s.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(r)){let c=Er({},te.prototype),h=0,u=Boolean(l.loop);for(let[f,g]of Object.entries(l.mapping??{})){let m=s.data(f)?.timelineAnimations?.[g];!m||(h=Math.max(h,m.to??0),u=u||Boolean(m.loop),c[f]={id:f,keyframes:BX(m.properties?.unproxy())})}let d=l.page??a,p=d?s.data(d):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=Er({},te.prototype)))[o]={id:o,name:l.name,duration:h||5,...u?{loop:u}:{},objectTimelines:c})}delete n.timelineAnimations,s.traverse((o,l)=>{delete l.timelineAnimations})}(t),MO(t,UX),MO(t,NX),t.schema=131)}}jg(tN,{updateAllMaterials:()=>nN,updateDocumentSchema:()=>VX,updateLibSchema:()=>kX,updateMaterialSchema:()=>OX,updateObjectStateRec:()=>Lu,updateObjectsSchema:()=>iN,updateTextValues:()=>IX});var _c,sN,EO,ov,vS,AO,lv,wc,Df,Od,hv,yS,d1,_S,bS,TO,u1,xS,Bc,cA,$b=z(()=>{et(),KF(),Ye(),JF(),RX(),Xb(),Wg(),Dn(),LC(),qb(),DC(),_c=180/Math.PI,sN=["position","rotation","scale","shape size"]}),jX=z(()=>{var t,e,i;_s(),Ye(),Dn(),(EO||(EO={})).is=function(n){return!0},(t=ov||(ov={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(n,r){return{position:r?.position??n.position,rotation:r?.rotation??n.rotation,scale:r?.scale??n.scale,shear:r?.shear??n.shear}},t.diff=function(n,r){return fF({position:Ja.isEqual(n.position,r.position)?void 0:r.position,rotation:n.rotation===r.rotation?void 0:r.rotation,scale:Ja.isEqual(n.scale,r.scale)?void 0:r.scale,shear:n.shear&&r.shear&&Ja.isEqual(n.shear,r.shear)?void 0:r.shear})},(vS||(vS={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(AO||(AO={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(lv||(lv={})).defaultData={opacity:1,fill:{color:Je.fromHexAndA(Rr,1),enabled:!0},stroke:{color:Je.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Je.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Je.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=wc||(wc={})).newEmpty=function(n,r){return{name:r}},e.patch=function(n,r){if(r===void 0)return n;let s={...n};return Object.assign(s,ov.merge(s,r)),s=function(a,o){if(o===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let h of c)h in l&&h in o&&o[h]!==void 0&&Object.assign(l,{[h]:o[h]});return l}(s,r),s=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(s,r),s},e.toOps=function(n,r){let s,a=[];for(let[o,l]of Object.entries(r))o!=="name"&&(s===void 0&&(s={path:[],props:{},type:0},a.push(s)),s.props[o]=l);return a},(Df||(Df={})).defaultData={...ov.defaultData,...vS.defaultData,states:new Vt,events:new Vt,visible:!0,raycastLock:!1},(Od||(Od={})).defaultData={...Df.defaultData,...lv.defaultData},(hv||(hv={})).defaultData={cornerRadius:[0,0,0,0]},(yS||(yS={})).defaultData={...Od.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(d1||(d1={})).defaultData={...Od.defaultData,...hv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(_S||(_S={})).defaultData={...Od.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(bS||(bS={})).defaultData={...Od.defaultData,type:"path2d",path:"",name:"Path"},(TO||(TO={})).is=function(n){return n.type==="ellipse2d"||n.type==="rectangle2d"||n.type==="text2d"||n.type==="vector2d"||n.type==="path2d"},(u1||(u1={})).defaultData={...Df.defaultData,name:"Group",type:"group2d"},(xS||(xS={})).defaultData=()=>({...Df.defaultData,...hv.defaultData,...lv.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Je.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Je.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(n=>{n.defaultData=function(r){switch(r){case"rectangle2d":case"vector2d":return{...d1.defaultData};case"ellipse2d":return{...yS.defaultData};case"text2d":return{..._S.defaultData};case"path2d":return{...bS.defaultData};case"frame2d":return{...xS.defaultData()};case"group2d":return{...u1.defaultData}}},n.getPivot=function(r){return"width"in r&&"height"in r?[typeof r.width=="number"?.5*r.width:0,typeof r.height=="number"?.5*r.height:0]:[0,0]},n.isResizeable=function(r){return r.type==="rectangle2d"||r.type==="ellipse2d"||r.type==="text2d"||r.type==="frame2d"},n.isAutoLayoutable=function(r){return r.type==="frame2d"&&r.autoLayout!==void 0},n.hasCorners=function(r){return r.type==="rectangle2d"||r.type==="frame2d"}})(Bc||(Bc={})),(i=cA||(cA={})).defaultData={name:"UI",type:"scene2d",objects:new Xn},i.emptyData=function(){return{type:"scene2d",objects:new Xn}}}),GX=z(()=>{EX(),AX(),FF(),NF(),KF(),LF(),DX(),HF(),XF(),DC(),$b(),ZF(),PC(),CC(),kF(),Wg(),GF(),$F(),_s(),Xb(),qb(),IC(),qF(),LC(),OC(),TX(),WF(),BC(),RC(),VF(),jF(),jX()});function Sc(t,e=!1){let i=t[0].index!==null,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new Gt,c=0;for(let h=0;h<t.length;++h){let u=t[h],d=0;if(i!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in u.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(u.attributes[p]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in u.morphAttributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(u.morphAttributes[p])}if(e){let p;if(i)p=u.index.count;else{if(u.attributes.position===void 0)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;p=u.attributes.position.count}l.addGroup(c,p,h),c+=p}}if(i){let h=0,u=[];for(let d=0;d<t.length;++d){let p=t[d].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+h);h+=t[d].attributes.position.count}l.setIndex(u)}for(let h in s){let u=CO(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in a){let u=a[h][0].length;if(u!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){let p=[];for(let g=0;g<a[h].length;++g)p.push(a[h][g][d]);let f=CO(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}}return l}function CO(t){let e,i,n,r=-1,s=0;for(let c=0;c<t.length;++c){let h=t[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=h.itemSize),i!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=h.gpuType),r!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*i}let a=new e(s),o=new Ht(a,i,n),l=0;for(let c=0;c<t.length;++c){let h=t[c];if(h.isInterleavedBufferAttribute){let u=l/i;for(let d=0,p=h.count;d<p;d++)for(let f=0;f<i;f++){let g=h.getComponent(d,f);o.setComponent(d+u,f,g)}}else a.set(h.array,l);l+=h.count*i}return r!==void 0&&(o.gpuType=r),o}var qg=z(()=>{et()});function aN(t){let e=t.points.length/7,i=new Vt;for(let n=0;n<e;n++){let r=7*n,s=t.points[r+0],a=t.points[r+1],o=t.points[r+2],l=t.points[r+3],c=t.points[r+4],h=t.points[r+5],u=t.points[r+6];i.push({fi:n,id:Ot.generateUUID(),data:{roundness:u,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[c,h]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(n=>aN(n))??[]}}function oN(t){let{userData:e,uuid:i,...n}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:c}=a,h=c?.groups,u=c?.attributes??{},d=c?.morphAttributes??{},p=c?.interleavedBuffers,f=c?.arrayBuffers,g=c?.index;u.position!==void 0&&Array.isArray(u.position.array)&&(o=function(y){let v=1/0,_=1/0,b=1/0,x=-1/0,w=-1/0,S=-1/0;for(let A=0;A<y.length;A+=3){let E=y[A],P=y[A+1],T=y[A+2];v=Math.min(v,E),_=Math.min(_,P),b=Math.min(b,T),x=Math.max(x,E),w=Math.max(w,P),S=Math.max(S,T)}return{width:x-v,height:w-_,depth:S-b}}(u.position.array));let m={...l===void 0?{}:l.parameters,data:{attributes:u,morphAttributes:d,interleavedBuffers:p,arrayBuffers:f},...o===void 0?{}:o,type:"NonParametricGeometry"};return g!==void 0&&Object.assign(m.data,{index:g}),h!==void 0&&Object.assign(m.data,{groups:h.map(y=>({...y,materialIndex:y.materialIndex??0}))}),m}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=n.data?.attributes;if(o?.positionWASM===void 0){let c=new Gt;if(o?.position===void 0||o?.faceMap===void 0)return null;let h=o.position.array,u=o.faceMap.array,d=n.data.index.array;c.setAttribute("position",new Nt(h,3)),c.setIndex(new rh(d,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let _={},b=y.getIndex(),x=y.getAttribute("position"),w=b?b.count:x.count,S=0,A=Object.keys(y.attributes),E={},P={},T=[],R=["getX","getY","getZ","getW"],L=["setX","setY","setZ","setW"];for(let $=0,nt=A.length;$<nt;$++){let Q=A[$],rt=y.attributes[Q];E[Q]=new rt.constructor(new rt.array.constructor(rt.count*rt.itemSize),rt.itemSize,rt.normalized);let gt=y.morphAttributes[Q];gt&&(P[Q]||(P[Q]=[]),gt.forEach((at,ht)=>{let ct=new at.array.constructor(at.count*at.itemSize);P[Q][ht]=new at.constructor(ct,at.itemSize,at.normalized)}))}let D=.5*v,U=Math.log10(1/v),V=Math.pow(10,U),k=D*V;for(let $=0;$<w;$++){let nt=b?b.getX($):$,Q="";for(let rt=0,gt=A.length;rt<gt;rt++){let at=A[rt],ht=y.getAttribute(at),ct=ht.itemSize;for(let q=0;q<ct;q++)Q+=~~(ht[R[q]](nt)*V+k)+","}if(Q in _)T.push(_[Q]);else{for(let rt=0,gt=A.length;rt<gt;rt++){let at=A[rt],ht=y.getAttribute(at),ct=y.morphAttributes[at],q=ht.itemSize,lt=E[at],F=P[at];for(let O=0;O<q;O++){let j=R[O],Z=L[O];if(lt[Z](S,ht[j](nt)),ct)for(let I=0,G=ct.length;I<G;I++)F[I][Z](S,ct[I][j](nt))}}_[Q]=S,T.push(S),S++}}let Y=y.clone();for(let $ in y.attributes){let nt=E[$];if(Y.setAttribute($,new nt.constructor(nt.array.slice(0,S*nt.itemSize),nt.itemSize,nt.normalized)),$ in P)for(let Q=0;Q<P[$].length;Q++){let rt=P[$][Q];Y.morphAttributes[$][Q]=new rt.constructor(rt.array.slice(0,S*rt.itemSize),rt.itemSize,rt.normalized)}}return Y.setIndex(T),Y}(c),f=[],g=new Array(u[u.length-1]+1).fill(3),m=p.getIndex().array;for(let y=0,v=u.length;y<v;)u[y]===u[y+1]?(g[u[y]]++,f.push(...new Set(m.slice(3*y,3*y+6))),y+=2):(f.push(...m.slice(3*y,3*y+3)),y++);o.indexWASM={array:f},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:g}}if(o?.positionWASM===void 0||o?.positionWASM.length===0||o?.indexWASM===void 0||o?.indexWASM.length===0||o?.verticesPerFaceWASM===void 0||o?.verticesPerFaceWASM.length===0)return null;let l={type:a,...HX(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let c in o)c==="positionWASM"?l[c]=new Float32Array(o[c].array):c==="indexWASM"?l[c]=new Int32Array(o[c].array):c==="verticesPerFaceWASM"&&(l[c]=new Int8Array(o[c].array));return l.scaleBaked=[1,1,1],l}let r=e.type,s=e.parameters;return r==="VectorGeometry"?(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,width:100,height:100,shape:aN(e.shape),type:r}):r==="LatheGeometry"?{...e.parameters,type:r,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,type:r})}function HX(t){return dA.setFromArray(t),dA.getSize(Dm),{width:Dm.x,height:Dm.y,depth:Dm.z}}var dA,Dm,lN,il,ag,hN,bp,Rf,cv,wS,xp,PO,SS,DO,MS,pp,Sl,Ml,Eo,ES,RO,IO,AS,uA,tl,WX=z(()=>{Ye(),et(),qg(),new At,new qt,new xi,new C,new C,dA=new ci,Dm=new C}),qX=z(()=>{}),XX=z(()=>{Ye(),$b()}),$X=z(()=>{Wg(),[...Wb],new Set(AC)}),Yt=z(()=>{GX(),qX(),PX(),$b(),XX(),JF(),$X(),BC(),Ye()}),al=z(()=>{lN=[3,4,8,9],il=5,ag=3,hN=32}),Xg=z(()=>{et(),bp=t=>{var e;return(e=class extends t{}).geometryHelper=new ga(30,30,30),e}}),$g=z(()=>{et(),Rf=new $o,cv=new vr,wS=new At,xp=(t,e,i,n,r=!1,s=t)=>{let a=e,o=s.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),cv.copy(a.boundingSphere),cv.applyMatrix4(o),i.ray.intersectsSphere(cv)===!1||(wS.copy(o).invert(),Rf.copy(i.ray).applyMatrix4(wS),a.boundingBox!==null&&Rf.intersectsBox(a.boundingBox)===!1))return;let l,c,h,u,d,p,f=a.index,g=a.attributes.position,m=a.drawRange;if(r===!1){for(d=Math.max(0,m.start),p=Math.min(f.count,m.start+m.count);d<p;d+=3)if(c=f.getX(d),h=f.getX(d+1),u=f.getX(d+2),l=y(t,i,Rf,g,c,h,u),l)return l.faceIndex=Math.floor(d/3),void n.push(l)}else{let v=a.attributes.position,_=new C,b=new C,x=new C,w=new C,S=2,A=1/((s.scale.x+s.scale.y+s.scale.z)/3),E=A*A;for(let P=Math.max(0,m.start),T=Math.min(v.count,m.start+m.count)-1;P<T;P+=S){if(_.fromBufferAttribute(v,P),b.fromBufferAttribute(v,P+1),Rf.distanceSqToSegment(_,b,w,x)>E)continue;w.applyMatrix4(s.matrixWorld);let R=i.ray.origin.distanceTo(w);R<i.near||R>i.far||n.push({distance:R,point:x.clone().applyMatrix4(s.matrixWorld),object:t})}}function y(v,_,b,x,w,S,A){let E=new C,P=new C,T=new C,R=new C,L=new C;if(E.fromBufferAttribute(x,w),P.fromBufferAttribute(x,S),T.fromBufferAttribute(x,A),b.intersectTriangle(E,P,T,!1,R)===null)return null;L.copy(R),L.applyMatrix4(v.matrixWorld);let D=_.ray.origin.distanceTo(L);return D<_.near||D>_.far?null:{faceIndex:1,distance:D,point:L.clone(),object:v}}}}),Yb=z(()=>{et(),Xg(),$g(),PO=new C(1,1,1),SS=new C,DO=new C,MS=new qt,pp=class extends bp(Bz){constructor(t,e=15){super(e),this.object=t,this.dummy=new yp,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,e){xp(this.object,pp.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(SS,MS,DO),this.matrix.compose(SS,MS,PO),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),YX=z(()=>{et(),Sl=new C,Ml=new C,Eo=new At,ES=[new C(-1,1,1),new C(-1,-1,1),new C(1,-1,1),new C(1,1,1),new C(-1,1,-1),new C(-1,-1,-1),new C(1,-1,-1),new C(1,1,-1)],RO=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],IO=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],AS=(t,e,i)=>{t.updateEntityBoxSize(Sl,Ml),Eo.copy(e).multiply(t.matrixWorld),Ml.x===0&&Ml.y===0&&Ml.z===0?i.push(new C(Sl.x,Sl.y,Sl.z).applyMatrix4(Eo)):ES.forEach(n=>{i.push(n.clone().multiply(Ml).add(Sl).applyMatrix4(Eo))})},uA=class extends ci{constructor(){super(...arguments),this.matrix=new At,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(e=>e.clone()),this.faces=t.faces.map(e=>e.clone()),this.edges=t.edges.map(e=>e.clone()),this.centerEdges=t.centerEdges.map(e=>e.clone()),this}setFromObjectSize(t,e=!1){t.updateWorldMatrix(!1,e),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new At().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let n=[];if(i===!0){let r=[];t.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s))return Eo.copy(e).multiply(s.matrixWorld),void r.push(new C().applyMatrix4(Eo));AS(s,e,n)}}),n.length===0&&n.push(...r)}else AS(t,e,n);return this.setFromPoints(n)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(Eo.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Ml).multiplyScalar(.5),this.getCenter(Sl),Eo.copy(this.matrix).setPosition(Sl),this.vertices=ES.map(t=>t.clone().multiply(Ml).applyMatrix4(Eo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=RO.map(([t,e])=>new vs(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new C))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=IO.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),$_=z(()=>{tl={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function og(t){return t?.isParticleSystem===!0}function Hc(t){return t?.isHairSystem===!0}function nl(t){return t?.isShapeBlendEntity===!0}function Zb(t){return t?.isPathObject===!0}function as(t){return t?.isObject2D===!0}function Cr(t){return t?.isUIObject===!0}function Bu(t){return t?.isCloner===!0}function Mc(t){return t?.isClone===!0}function p1(t){return t?.isComponentObject===!0}var Li=z(()=>{});function Si(t){UC.add(t)}function Gn(t,e){let i=`${t}:${e}`;mA.has(i)||mA.add(i)}function Y_(t,e){zC.set(t,e)}function TS(t){return zC.get(t)}function wp(t,e){FC.set(t,e)}function CS(t){return FC.get(t)}function pA(t,e){NC.set(t,e)}function cN(t){return NC.get(t)}function fA(){return Kb}var UC,mA,zC,FC,NC,Kb,Z_,ke=z(()=>{UC=new Set,mA=new Set,zC=new Map,FC=new Map,NC=new Map,Kb=null,Z_=null});function dN(t){let e=t.elements;ha.set(e[0],e[1],e[2]),ca.set(e[4],e[5],e[6]),Xa.set(e[8],e[9],e[10])}function uN(){let t=Math.max(ha.lengthSq(),ca.lengthSq(),Xa.lengthSq());ha.lengthSq()>Rm*t?ms.copy(ha).normalize():ms.set(1,0,0),gs.crossVectors(Xa,ms),gs.lengthSq()<=Rm*t&&(gs.copy(ca).addScaledVector(ms,-ca.dot(ms)),gs.lengthSq()<=Rm*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=Rm&&e.set(0,1,0).cross(i),e.normalize()}(gs,ms)),gs.normalize(),Ec.crossVectors(ms,gs)}function pN(t){return dN(t),uN(),fN.makeBasis(ms,gs,Ec)}var ha,ca,Xa,ms,gs,Ec,fN,Rm,Im,dv,Ac,Qb,mN=z(()=>{et(),ha=new C,ca=new C,Xa=new C,ms=new C,gs=new C,Ec=new C,fN=new At,Rm=1e-12,Im=.01}),Yg=z(()=>{et(),mN(),dv=new At,(Ac||(Ac={})).is=function(t){return t&&t.__isSPEObject},Qb=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new At,this.copyPreviousMatrix=!0,this.hiddenMatrix=new At,this.pivotMatrix=new At,this.matrixWorldRigid=new At,this.shearScale=new At,this.shearScaleInv=new At}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(dv.copy(this.parent.matrixWorld).invert()),e.premultiply(dv.copy(this.hiddenMatrix).invert()),e.multiply(dv.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof _i&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let i of this.children)i.updateMatrixWorld(e)}updateWorldMatrix(e,i){let n=this.parent;if(e&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let r of this.children)r.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let n of this.children)Ac.is(n)&&n.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let n of this.children)Ac.is(n)&&n.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(e,i,n){return dN(e),uN(),i.makeBasis(ms,gs,Ec),n.set(ms.dot(ha),ms.dot(ca),ms.dot(Xa),0,gs.dot(ha),gs.dot(ca),gs.dot(Xa),0,Ec.dot(ha),Ec.dot(ca),Ec.dot(Xa),0,0,0,0,1),function(){let r=ha.length(),s=ca.length(),a=Xa.length(),o=Math.max(r,s,a);if(o-r>Im||o-s>Im||o-a>Im)return!0;let l=Im*o*o;return Math.abs(ha.dot(ca))>l||Math.abs(ha.dot(Xa))>l||Math.abs(ca.dot(Xa))>l}()}(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,i){this.updateWorldMatrix(!0,!1);let n=new At().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),n.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof At?e.hiddenMatrix.premultiply(n):e.applyMatrix4(n),e.updateWorldMatrix(!1,!1),this.add(e),i!==void 0&&(this.children.pop(),this.children.splice(i,0,e)),this}copy(e,i=!1){return super.copy(e,i),this.hasNonUniformScale=e.hasNonUniformScale,this}onAfterRender(e,i,n,r,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function OO(t,e,i){return jl.subVectors(e,t),Og.subVectors(e,i),jl.cross(Og).length()<=lg}function gN(t){let e=yA.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(n){let r=n.points,s=[r[0]],a=[new C(...r[0].data.position)];pc.copy(a[0]);for(let y=0;y<r.length-1;y++)jl.fromArray(r[y].data.position),Og.fromArray(r[y+1].data.position),Su.subVectors(jl,pc),Mu.subVectors(jl,Og),Su.cross(Mu).length()>lg&&(s.push(r[y]),a.push(new C().copy(jl)),pc.copy(jl));let o=r[r.length-1];s.push(o),a.push(new C(...o.data.position));let l=n.isClosed,c=s.length-(l?0:1),h=s.length,u=[],d=[];for(let y=0;y<h;y++){let v=s[y].data;u.push(new C(...v.controlPrevious.position)),d.push(new C(...v.controlNext.position))}let p=[];for(let y=0;y<c;y++){let v=y===h-1?0:y+1;p.push(OO(a[y],d[y],a[v])&&OO(a[y],u[v],a[v]))}let f=[];for(let y=0;y<h;y++){let v=s[y].data,_=a[y],b={position:_,prevDir:void 0,nextDir:void 0,controlPrevious:u[y],controlNext:d[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(f.push(b),v.roundness===0||!l&&(y===0||y===h-1))continue;let x=l&&y==0?h-1:y-1,w=l&&y==h-1?0:y+1,S=new C().subVectors(a[x],_).normalize(),A=new C().subVectors(a[w],_).normalize();b.prevDir=S,b.nextDir=A;let E=p[l&&y===0?h-1:y-1],P=p[y];if(E&&P){fc.addVectors(S,A).normalize();let T=pc.crossVectors(fc,S).length()/S.dot(fc);b.tan=T,b.removedLength=v.roundness/T}}for(let y=0;y<c;y++){let v=l&&y===h-1?0:y+1,_=f[y],b=f[v];if(_.removedLength!==0||b.removedLength!==0){let x=_.position.distanceTo(b.position);_.removedLength=Math.min(_.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let g=new Array(2*h).fill(null);for(let y=0;y<c;y++){let v=l&&y===h-1?0:y+1,_=f[y],b=f[v],x=null;if(p[y]){let w=_.position.clone(),S=b.position.clone();(_.removedLength!==0||b.removedLength!==0)&&(_.nextDir&&w.add(pc.copy(_.nextDir).setLength(_.removedLength)),b.prevDir&&S.add(pc.copy(b.prevDir).setLength(b.removedLength))),w.distanceTo(S)>lg&&(x=new Qm(w,w.clone().lerp(S,.3),S.clone().lerp(w,.3),S))}else _.position.distanceTo(b.position)>lg&&(x=new Qm(_.position,_.controlNext,b.controlPrevious,b.position));g[2*y+1]=x}for(let y=0;y<h;y++){let v=f[y];if(v.removedLength===0)continue;let _=v.position,b=v.prevDir.clone().multiplyScalar(v.removedLength).add(_),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(_),w=v.tan*v.removedLength;fc.addVectors(v.prevDir,v.nextDir).normalize(),Su.copy(b).lerp(x,.5);let S=b.distanceTo(x)/2;vA.copy(fc).multiplyScalar(Math.sqrt(Math.pow(w,2)-Math.pow(S,2))).add(Su),f1.copy(fc).multiplyScalar(-w).add(vA);let A=_.distanceTo(f1)/_.distanceTo(Su);Mu.copy(v.prevDir).multiplyScalar(A*_.distanceTo(b)).add(_),gA.copy(Mu).lerp(f1,2);let E=b.clone().lerp(Mu,4/3),P=x.clone().lerp(gA,4/3);g[2*y]=new Qm(b,E,P,x)}let m=new vN;for(let y=0;y<g.length;y++){let v=g[y];v&&m.add(v)}return m}(t);return yA.set(t.points,{isClosed:t.isClosed,curve:i}),i}var vN,lg,jl,Og,pc,fc,Su,f1,Mu,gA,vA,yA,Eu,_A,m1,yN,_N,bN,Be,Wa,LO,BO,If,PS,uv,DS,RS,Jb,bA,Kc,$a,xN=z(()=>{et(),vN=class extends dE{constructor(){super()}getPoints(t=12){let e,i=[],n=this.getCurveLengths(),r=n[n.length-1]/n.length;for(let s=0,a=this.curves;s<a.length;s++){let o=a[s],l=s===0?n[s]:n[s]-n[s-1],c=Math.ceil(t*l/r),h=o.getPoints(c);for(let u=0;u<h.length;u++){let d=h[u];e&&e.equals(d)||(i.push(d),e=d)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},lg=.001,jl=new C,Og=new C,pc=new C,fc=new C,Su=new C,f1=new C,Mu=new C,gA=new C,vA=new C,yA=new WeakMap}),ZX=z(()=>{et(),Eu=new At,_A=new qt,m1=new qt,yN=new xi,_N=new C,bN=new C(0,1,0)}),Wr=z(()=>{et(),Yt(),YX(),Ye(),$_(),Li(),ke(),Yg(),xN(),ZX(),ii(),(Be||(Be={})).is=function(t){return t&&t.__isEntity},Wa=t=>Be.is(t),LO={type:"completeState",isfromEntity:!0},BO=["x","y","z"],If=new C,PS=new C(1,1,1),uv=new qt,DS=new xi,RS=new At,Jb=t=>class extends Qb(t){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.transitionState={settled:!0,state:null},this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new uA,this._recursiveBBox=new uA,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let i=this.children[e];if(Be.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Be.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let e=this;for(;e.data.type!=="Instance";){let i=e.parent;if(!Be.is(i))return;e=i}return e}forInstancesRec(e){this.instances.forEach(i=>{i.disposed||e(i),i.forInstancesRec(e)})}super_Entity(e,i){typeof e=="string"&&(this.uuid=e),this.identity=e,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,i,n=!1){if(this.data.states.length!==0||n){for(let r of this.data.states)Kl.toOps(this.data,r.data).forEach(s=>{let a=M_.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let r=this.data.states.data(e);r&&(this.dataPatched=Kl.patch(this.data,r),Kl.toOps(this.data,r).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}n&&this.updateTransformState(this.dataPatched,i),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,i){e.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{Wa(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(n=>{n.uuid===e&&(i=n)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,n=i.indexOf(this)+1;if(Be.is(i[n]))return i[n];if(Be.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Be.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let i=this;for(;e>0&&i!==null;)i=i.parent,e-=1;return i}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let i=this.parent;for(;i;){if(e===i)return!0;i=i.parent}return!1}countToAccestor(e){let i=0,n=this;for(;n!==e;){if(n===null)return-1;n=n.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Wa(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{Be.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let n of this.children)Wa(n)&&n.isConcreteEntity&&n.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let n of this.children)Wa(n)&&n.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Wa(i)&&i.visible&&i.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,i=!1){return super.copy(e,i),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),this}hasEntityChild(){return this.children.some(e=>Wa(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(n=>{n.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),DE({position:this.position.toArray(),rotation:[this.rotation.x*Ot.RAD2DEG,this.rotation.y*Ot.RAD2DEG,this.rotation.z*Ot.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,n){return i[e].map((r,s)=>n?.shared.getVariable(r,[this.uuid,e,BO[s]])??r)}updateTransformState(e,i){let n=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),n=!0),e.rotation&&(If.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(Ot.DEG2RAD),this.rotation.setFromVector3(If),n=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),n=!0),e.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??Xu.identity)),e.pivot!==void 0||e.pivotRotation!==void 0){if(n=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(If.fromArray(e.pivot).negate(),uv.setFromEuler(DS.fromArray(e.pivotRotation.map(r=>r*Ot.DEG2RAD))).invert(),PS);else if(e.pivot!==void 0)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(e.pivotRotation!==void 0){let r=If.setFromMatrixPosition(this.pivotMatrix);uv.setFromEuler(DS.fromArray(e.pivotRotation.map(s=>s*Ot.DEG2RAD))).invert(),this.pivotMatrix.compose(r,uv,PS)}}return n&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),n}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)Be.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Be.is(e)&&e.disposeRecursively()})}toState(e=[]){return DE({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,i){e!==void 0&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},i,!1)}updateByOp(e,i,n,r){let s=this.data;this.data=i;let a=e,o=ri(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let c={...e.props};if(delete c.name,Object.values(e.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let u=jn.zoom(h,e.path.slice(2));if(u)for(let d in e.props)e.props[d]===void 0&&d in u&&(c[d]=u[d])}}a={...e,props:c,path:e.path.slice(2)}}}}else if(e.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(e.props.name!==void 0&&l.name){let{name:h,...u}=l;l=u}if(e.props.material!==void 0&&"material"in l){let{material:h,...u}=l;l=u}let c=jn.removeOverridden(e.path,e.props,l);a={...e,props:c}}}if(this.updateByPatchedOpBase(a,Kl.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),ri(e.path,["overrides"])){let l=[],c=[...e.path];for(l.push(c[1]),c.splice(0,2);c.length>0&&c[0]==="descendants";)l.push(c[1]),c.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let h of Object.keys(e.props)){l[l.length-1]=h;let u=n.scene.findInstance([this.uuid,...l]);u&&(u.overrideData=e.props[h],u.updateState(ah.apply(u.component.data,u.overrideData),n))}}else{let h=n.scene.findInstance([this.uuid,...l]);if(h){let u=jn.zoom(h.component.data,c);if((e={...e,path:c}).type===0){let d=e.props;if(u)for(let[p,f]of Object.entries(e.props))f===void 0&&(d===e.props&&(d={...e.props}),d[p]=u[p]);e={...e,props:d}}h.overrideData=G_.resolve(i.overrides,l),h.updateByOp(e,er.applySimple(h.data,e),n,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let c;for(let h of Qo.rootOverrideProps)h in e.props&&(c===void 0&&(c={}),c[h]=e.props[h]);c&&(l={...e,props:c})}else for(let c of Qo.rootOverrideProps)if(ri(e.path,[c])){l=e;break}l!==void 0&&this.instances.forEach(c=>{if(c.isInstanceRoot){let h=ah.filterOp(c.overrideData,l);h&&c.updateByOp(h,er.applySimple(c.data,h),n,!0)}}),this.instances.forEach(c=>{if(!c.isInstanceRoot){let h=ah.filterOp(c.overrideData,e);if(h){let u;u=s===c.data&&e===h?i:er.applySimple(c.data,h),c.updateByOp(h,u,n,!0)}}})}}updateByPatchedOpBase(e,i,n){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!jc.is(e.props.type)&&tl.changeEntityProptotype(this,i,n);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){tl.changeEntityProptotype(this,i,n);for(let r of this.children)Be.is(r)&&r.updateVisible(n.scene)}this.updateByPatchedOp(e,i,n)}updateByPatchedOp(e,i,n){if(e.path.length===0&&e.type===0?this.updateState(e.props,n):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,n),e.path[0]==="morphTargetInfluences"&&e.type===0){let r=i.morphTargetInfluences.get(e.path[1])?.data.name;r&&this.updateMorphInfluences(r,n.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",r]))}if(ri(e.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),ri(e.path,["cloner"])!==null){let r=er.drop(e,1);r.path.length===0&&r.type===0&&r.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(i.cloner,n):(this.setFromClonerState(i.cloner,n),this.expandCloner(n)),this.updateVisible(n.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,n=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,r=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=e.find(i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=gN(o.geometry.path),c=function(p){let f=p%1;return f<0?f+1:f===0&&p>0?1:f}(n+r),h=null;try{h=l.curves.length?l.getPointAt(c):null}catch{}if(h===null)return;a.updateMatrixWorld();let u=this.parent?RS.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):RS.copy(this.hiddenMatrix),d=function(p,f,g,m){_A.setFromRotationMatrix(Eu.extractRotation(m));let y=p.clone().applyMatrix4(Eu.copy(m).invert().multiply(g));if(f===null)m1.setFromRotationMatrix(Eu.extractRotation(g));else{let v=f.clone().applyMatrix4(Eu.extractRotation(g));m1.setFromRotationMatrix(Eu.lookAt(_N.set(0,0,0),v,bN))}return{position:y,rotation:new C().setFromEuler(yN.setFromQuaternion(_A.invert().multiply(m1))).multiplyScalar(Ot.RAD2DEG)}}(h,s==="tangential"?l.getTangentAt(c):null,a.matrixWorld,u);this.updateTransformState({position:d.position.toArray(),rotation:d.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(LO)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!e)return;let i=!1;this.traverseEntity(n=>{if(n.data.type==="Splat")return i=!0,!0}),i&&e.reloadSplats()}updateState_Entity(e,i){e.name!==void 0&&(this.name=e.name),e.raycastLock!==void 0&&(this.raycastLock=e.raycastLock),e.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in e&&e.cloner!==void 0&&(this.setFromClonerState(e.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(e,i)}get attachedSurfaceCloners(){return this.children.filter(e=>Bu(e)&&e.parameters.type==="toObject")}setFromClonerState(e,i){if(!this.disposed)if(e===null||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(tl.Cloner===null)return void Gn("cloners","a cloner");this.cloner=new tl.Cloner(this,e),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,i)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),Qc=z(()=>{et(),Wr(),(bA||(bA={})).is=t=>"objectHelper"in t,Kc=(t,e)=>class extends Jb(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,n){this.objectHelper.raycast(i,n)}showGizmos(){for(let i in this.gizmos){let n=this.gizmos[i];n instanceof Eg&&(n.visible=!0)}}updateEntityBoxSize(i,n){this.objectHelper.visible&&this.geometryHelper instanceof ga?(i.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,n)}hideGizmos(){for(let i in this.gizmos){let n=this.gizmos[i];n instanceof Eg&&(n.visible=!1)}}}}),tx=z(()=>{et(),Yb(),Qc(),$a=class extends Kc(yp,pp){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}}});function Qs(t,e,i,n,r,s,a){Om.set(r,s,a).unproject(n);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],Om.x,Om.y,Om.z)}}var Om,cs,UO,wN,KX=z(()=>{et(),Xg(),$g(),Om=new C,cs=new ql,UO=class extends gu{constructor(t){let e=new Gt,i=new zo({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={},a=new Jt(15711266),o=new Jt(15711266),l=new Jt(2857471);function c(u,d,p){h(u,p),h(d,p)}function h(u,d){n.push(0,0,0),r.push(d.r,d.g,d.b),s[u]===void 0&&(s[u]=[]),s[u].push(n.length/3-1)}c("n1","n2",a),c("n2","n4",a),c("n4","n3",a),c("n3","n1",a),c("f1","f2",a),c("f2","f4",a),c("f4","f3",a),c("f3","f1",a),c("n1","f1",a),c("n2","f2",a),c("n3","f3",a),c("n4","f4",a),c("p","n1",o),c("p","n2",o),c("p","n3",o),c("p","n4",o),c("u1","u2",l),c("u2","u3",l),c("u3","u1",l),e.setAttribute("position",new Nt(n,3)),e.setAttribute("color",new Nt(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let t=this.geometry,e=this.pointMap;cs.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;Qs("n1",e,t,cs,-1,-1,i),Qs("n2",e,t,cs,1,-1,i),Qs("n3",e,t,cs,-1,1,i),Qs("n4",e,t,cs,1,1,i);let n=i;Qs("f1",e,t,cs,-1,-1,n),Qs("f2",e,t,cs,1,-1,n),Qs("f3",e,t,cs,-1,1,n),Qs("f4",e,t,cs,1,1,n);let r=n;Qs("u1",e,t,cs,.35,1.1,r),Qs("u2",e,t,cs,-.35,1.1,r),Qs("u3",e,t,cs,0,1.55,r),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},wN=class extends bp(UO){constructor(t){super(t),this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,e){xp(this.object,this.geometry,t,e,!0)}}});function zO(t){return 1-Math.pow(1-t,3)}var $h,pv,fv,mv,Ld,gv,Oa,vn,Hs=z(()=>{et(),KX(),Yt(),Qc(),ii(),$h=new C,pv=new C,fv=new qt,mv=new C,Ld=new C,gv=new C,Oa=class extends Kc(ql,wN){constructor(t="",e={...rg.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=Ko.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let r=this._projectionTransition;if(r===void 0)return;if(this.disposed)return void this._endProjectionTransition();r.raf=requestAnimationFrame(this._tickProjectionTransition);let s=Oa.projectionTransitionRequestRender??r.requestRender;this.updateProjectionMatrix(),s?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new At,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,n=this.height;this.orthoCamera=new cp(-.5*i,.5*i,.5*n,-.5*n,-5e4,1e4),this.perspCamera=new ju(45,i/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(t){let e=Oa.projectionTransitionsEnabled;Oa.projectionTransitionsEnabled=!1;try{return t()}finally{Oa.projectionTransitionsEnabled=e}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(t){this.perspCamera.fov=t}get fov(){return this.perspCamera.fov}setNear(t,e){t==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(t,e){e>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t,e,i){typeof t=="number"&&(t=new C(t,e,i)),super.lookAt(t),this.getWorldPosition($h),this.targetOffset=$h.distanceTo(t)}getTarget(t=new C){return this.getWorldDirection(pv),this.getWorldPosition($h),pv.multiplyScalar(this.targetOffset),t.copy($h).add(pv),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition($h),$h.distanceTo(t)}updateUp(){this.getWorldQuaternion(fv),mv.set(0,0,1).applyQuaternion(fv),Ld.copy(_i.DEFAULT_UP),this.isUpVectorFlipped&&Ld.negate(),Ld.applyQuaternion(fv),gv.copy(_i.DEFAULT_UP).projectOnPlane(mv),this.angleOffsetFromUp=gv.angleTo(Ld),this.angleOffsetFromUp*=gv.cross(Ld).dot(mv)>=0?1:-1}updateTransformState(t,e){let i=super.updateTransformState(t,e);return t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(t){let e=t.getWorldPosition(new C),i=t.getWorldDirection(new C).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new C).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new C;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let n=t>e?this.aspect:1,r=t>e?1:this.aspect;this.left=-395*n,this.right=395*n,this.top=1/r*395,this.bottom=1/r*-395}else this.left=.5*-t,this.right=.5*t,this.top=.5*e,this.bottom=.5*-e;this.updateProjectionMatrix()}copyViewPlaneSize(t){this.aspect=t.aspect,this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let t=this._projectionTransition;if(t===void 0)return 1;let e=(performance.now()-t.start)/t.duration;return e>=1?1:e<=0?0:zO(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Oa.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Oa.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new At,blend:new At,blendInverse:new At,start:0,duration:Oa.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=Oa.projectionTransitionDuration,e.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,t&&(e.requestRender=t),e.raf!==0&&cancelAnimationFrame(e.raf),e.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;let e=(performance.now()-t.start)/t.duration;if(e>=1)return void this._endProjectionTransition();let i=zO(e),n=t.from.elements,r=this._activeSubCamera.projectionMatrix.elements,s=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,n[15]-n[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,r[15]-r[11]*a));for(let c=0;c<16;c++)s[c]=n[c]+(r[c]-n[c])*l;t.blendInverse.copy(t.blend).invert(),this.projectionMatrix=t.blend,this.projectionMatrixInverse=t.blendInverse}_endProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;t.raf!==0&&cancelAnimationFrame(t.raf),this._projectionTransition=void 0;let e=this._activeSubCamera;this.projectionMatrix=e.projectionMatrix,this.projectionMatrixInverse=e.projectionMatrixInverse}_syncProjectionTransition(t){let e=t._projectionTransition;if(e===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new At,blend:new At,blendInverse:new At,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(e.from),i.start=e.start,i.duration=e.duration,i.referenceDepth=e.referenceDepth,this._applyProjectionTransition()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,e,i,n,r,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,n,r,s):this.orthoCamera.setViewOffset(t,e,i,n,r,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,e){return super.copy(t,e),this.parent=t.parent,this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=Ko.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return DE({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},t)}updateCameraSubtype(t,e){let i=t==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(i,e.zoom),e.near!==void 0&&this.setNear(i,e.near),e.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(t,e){this.updateCameraState(t,e)}updateCameraState(t,e){this.updateState_Entity(t,e),t.far!==void 0&&(this.far=t.far),t.orthographic!==void 0&&this.updateCameraSubtype("orthographic",t.orthographic),t.perspective!==void 0&&this.updateCameraSubtype("perspective",t.perspective),t.type!==void 0&&(t.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(e?.shared.requestRender),this.cameraType=t.type),t.up!==void 0&&this.up.fromArray(t.up.map(i=>typeof i=="number"?i:0)),t.targetOffset!==void 0&&(this.targetOffset=Ko.sanitizeTargetOffset(t.targetOffset)),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.type===0&&this.updateCameraSubtype(t.path[0],t.props)}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}},(vn=Oa).projectionTransitionsEnabled=!1,vn.projectionTransitionDuration=350,vn.projectionTransitionMinAgeMs=1e3});function SN(t){return t.type==="TorusGeometry"&&t.arc===360}var MN,vv,xA,Lg=z(()=>{et(),MN=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},t.parameters),n=Math.abs(i.width),r=Math.abs(i.height??n),s=Math.abs(i.depth??n),a=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(i,{width:n,height:r,depth:s,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(t){let{width:e,height:i,depth:n,radius:r,revolutions:s,segments:a,pathRadius:o,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=t.parameters,d=new xA(!1,e,i,n,r,s,a,o,l,c,h,u);return Object.assign(d,{userData:{...t,type:"HelixGeometry"}})}},vv=new rh([0,0,0],1),xA=class extends Gt{constructor(t=!0,e=1,i=1,n=1,r=1,s=1,a=1,o=1,l=1,c=1,h=1,u=1){if(super(),s===0)return;let d=t&&s===1;d&&(u=0),h>100&&(h=100),h===0&&(u=0);let p,f,g,m,y,v,_,b,x=()=>new C,w=new C,S=x(),A=x(),E=x(),P=x(),T=x(),R=x(),L=x(),D=x(),U=x(),V=x(),k=x(),Y=i-2*o+.001,$=Y/s,nt=Math.ceil(a*s),Q=nt+1,rt=Y/nt,gt=-Y/2,at=c+1,ht=2*Math.PI/c,ct=Math.PI/2/u,q=Math.min((1-h/100)*o,o-.01),lt=o-q,F=0,O=2*u+2,j=at*O/2,Z=j+at*Q,I=Math.max(0,at*(Q+O)),[G,W,N]=[3,3,2].map(jt=>Array(I*jt).fill(0)),tt=[],ot=r-o;function pt(jt,Ft){let _e=Math.PI/2;v=Ft*rt,b=2*Math.PI*(v%$)/$+_e,v+=gt,_=Math.sin(b)*ot,y=Math.cos(b)*ot,t?jt.set(y,_,v):jt.set(y,v,_)}pt(w,-1e-10),pt(S,0),P.copy(w),pt(w,1);let ut=w.distanceTo(S),Pt=d?0:lt+q,bt=ut*nt+2*Pt,Rt=q,_t=bt-Pt;for(let jt=0;jt<=nt;jt++){pt(A,jt),k.subVectors(A,P).normalize(),P.copy(A),U.copy(A).setComponent(+t+1,0).normalize(),V.crossVectors(k,U).normalize();let Ft=jt===0,_e=jt===nt,be=Ft?3*Math.PI/2:ct,Vi=Ft?Rt:_t,oe=Ft?at:Z,le=Ft?0:I-at,Pe=k.clone().multiplyScalar(Ft?-lt:lt).add(A),si=k.clone().multiplyScalar(Ft?-1:1).normalize();for(let ze=0;ze<at;ze++){let Pi=ze*ht;if(T.addVectors(w.copy(U).multiplyScalar(o*Math.cos(Pi)),S.copy(V).multiplyScalar(o*Math.sin(Pi))),R.copy(T).normalize(),Ft||_e){d||(F=le+ze,[0,1,2].forEach(ui=>{G[3*F+ui]=Pe.getComponent(ui),W[3*F+ui]=si.getComponent(ui)}),N[2*F]=+_e,N[2*F+1]=ze/c),S.copy(R).multiplyScalar(q),E.addVectors(A,S);for(let ui=0;ui<u;ui++){let en=ui*ct+be;L.addVectors(w.copy(k).multiplyScalar(lt*Math.sin(en)),S.copy(R).multiplyScalar(lt*Math.cos(en))),D.copy(L).normalize(),S.addVectors(E,L),L.normalize(),F=oe+ui*at+ze,[0,1,2].forEach(yn=>{G[3*F+yn]=S.getComponent(yn),W[3*F+yn]=D.getComponent(yn)});let Kr=+Ft+Math.sin(en);N[2*F]=(Vi+lt*Kr)/bt,N[2*F+1]=ze/c}}S.addVectors(A,T),F=j+jt*at+ze,[0,1,2].forEach(ui=>{G[3*F+ui]=S.getComponent(ui),W[3*F+ui]=R.getComponent(ui)}),N[2*F]=(Pt+jt*ut)/bt,N[2*F+1]=ze/c}}let X=Q+2*u+2,[vt,Dt]=[+d,X-1];for(let jt=vt;jt<=Dt-1;jt++){let Ft=d&&jt===Dt-1;for(let _e=0;_e<at-1;_e++)p=jt*at+_e,f=p+1,g=(Ft?_e:p)+at,m=(Ft?_e+1:f)+at,jt===0?tt.push(f,m,g):jt===X-2?tt.push(p,f,g):tt.push(p,f,g,f,m,g)}this.setIndex(tt),this.setAttribute("position",new Nt(G,3)),this.setAttribute("normal",new Nt(W,3)),this.setAttribute("uv",new Nt(N,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,n,r=this.userData.parameters,s=Math.ceil(r.tubularSegments),a=r.radialSegments,o=a+1,l=[];for(let c=1;c<s;c++)for(let h=0;h<a;h++)t=c*o+h,e=t+1,i=t+o,n=e+o,l.push(t,e,i,e,n,i);for(let c=0;c<a;c++)t=s*o+c,e=t+1,i=c+o,n=c+1+o,l.push(t,e,i,e,n,i);return vv.array=new Uint32Array(l),vv.count=l.length,vv}}});function QX(t){return NO||(NO=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.42/build",i=import("./boolean.js"),[n,r]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(s=>s.arrayBuffer())]);await n.default({module_or_path:r}),Bg=n}())}function K_(){if(Bg===void 0)throw new Error("boolean-wasm is not loaded");return Bg}function kC(t){let e=Ug.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function VC(t){return Ug.set(++wA,t),wA}function JX(t,e,i){if(Bg===void 0)return-1;let{positions:n,indices:r,normals:s}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,f=[];for(let g=0,m=0;g<p.verticesPerFace.length;g++){let y=p.verticesPerFace[g];for(let v=1;v<y-1;v++)f.push(p.indices[m],p.indices[m+v],p.indices[m+v+1]);m+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(f)}}let l;l=SN(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let c,h=a.getAttribute("position");if(l===null){c=new Uint32Array(h.count);for(let p=0;p<c.length;p++)c[p]=p}else c=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let u=a.getAttribute("normal"),d=u!==void 0&&u.itemSize===3&&u.count===h.count&&u.array instanceof Float32Array&&u.isInterleavedBufferAttribute!==!0?u.array:void 0;return{positions:h.array,indices:c,normals:d}}(t,e);return VC(new Bg.CsgMesh(n,r,s))}function FO(t,e){let i=K_(),n=AN[e];if(n===void 0)throw new Error("Unknown boolean operation "+e);let r=t.map(kC);if(r.length===1)return i.clone_mesh(r[0]);let s,a=[];if(e===2&&r.length>2){let o=r[0];for(let l=1;l<r.length-1;l++)o=i.boolean_mesh(o,r[l],0),a.push(o);s=i.boolean_mesh(r[r.length-1],o,2)}else if(e===2)s=i.boolean_mesh(r[1],r[0],2);else{let o=r[r.length-1];for(let l=0;l<r.length-1&&(o=i.boolean_mesh(o,r[l],n),a.push(o),o.tri_count()!==0);l++);s=o,a.pop()}for(let o of a)o.free();return s}function IS(t,e){kC(t).transform(new Float32Array(e.elements))}function EN(t){let e=Ug.get(t);e!==void 0&&(e.free(),Ug.delete(t))}var Bg,Ug,wA,NO,AN,ex=z(()=>{et(),Lg(),Ug=new Map,wA=0,AN={0:0,1:1,2:2}});function Yh(t){return t!==null&&"booleanOp"in t}var SA,TN,t$=z(()=>{et(),Wr(),ex(),SA=class extends Jb(wi){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new At}updateVisible(t){super.updateVisible(t),this.visible=!Yh(this.parent)&&this.visible,Yh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){Yh(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(EN(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Yh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof SA&&(t.freeBooleanPointer(),Yh(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&Yh(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),Yh(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),e$=z(()=>{TN=null});function jC(t,e=0,i=t.count,n,r){let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0;for(let u=e;u<i;u++){let d=t.getX(u),p=t.getY(u),f=t.getZ(u);d<s&&(s=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>c&&(c=p),f>h&&(h=f)}Lm.min.set(s,a,o),Lm.max.set(l,c,h),Lm.getCenter(n),Lm.getSize(r).multiplyScalar(.5)}var Lm,kO,VO,Xi,Kn=z(()=>{et(),t$(),e$(),Lm=new ci,kO=new Gt,VO=new Gs,Xi=class extends SA{constructor(t,e){super(kO,VO),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){let i=TN;i===null?super.raycast(t,e):i(this,t,e)}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?jC(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function Q_(t){return t?.isClassicNodeMaterial===!0}var gn,zg,CN,PN,hg,DN,RN,IN,GC=z(()=>{}),ya=z(()=>{et(),gn=class extends Jt{constructor(t,e,i,n){super(t,e,i),this.isColorA=!0,this.a=n}setRGBA(t,e,i,n){super.setRGB(t,e,i),this.a=n}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(t){return super.equals(t)&&this.a===t.a}setStyle(t,e="srgb"){let i;if(t==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(t)){let n,r=i[1],s=i[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=r==="rgba"?parseFloat(n[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=r==="hsla"?parseFloat(n[4]):1,super.setStyle(t,e)}}return super.setStyle(t,e)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}}}),ON=z(()=>{ya(),zg=class extends gn{}}),i$=z(()=>{CN=class{constructor(t=1e4){this.timeout=t,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let i=e;e=e.next,e.prev=this.head,this.head.next=e,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),i=this.cache.get(t);return i===void 0?(i={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,i)):(i.time=e,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),LN=z(()=>{i$(),PN=class extends CN{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),BN=z(()=>{DN=class{constructor(t,e){this.data=t,this.cache=e,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},RN=class{constructor(){this.cache=new Map}remove(t){this.cache.delete(t.data)}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}}}),n$=z(()=>{et(),IN=class extends Mz{constructor(t){super(t),this.type=$n}parse(t){let e=function(p,f){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(p,f,g){f=f||1024;let m=p.pos,y=-1,v=0,_="",b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(m,m+128)));for(;0>(y=b.indexOf(`
4162
+ })();`}),dF=z(()=>{mC=class{constructor(t,e,i){this.deps=t,this.onConsole=e,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let t of this.eventUnsubs.values())t();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(t,e){let i=this.deps;switch(t){case"setVariable":{let n=i.setVariable(String(e[0]),e[1]);return n.warning&&this.onConsole("warn",n.warning),n.ok}case"setVariables":{let n=e[0]??{},r=!0;for(let[s,a]of Object.entries(n)){let o=i.setVariable(s,a);o.warning&&this.onConsole("warn",o.warning),r=r&&o.ok}return r}case"getVariable":return i.getVariable(String(e[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(e[0]));case"getGeometry":{let n=i.getGeometry(String(e[0]),e[1]??{});return n.warning&&this.onConsole("warn",n.warning),n.data}case"updateObject":return i.updateObject(String(e[0]),e[1]??{});case"createObject":return i.createObject(String(e[0]),e[1]??{});case"createCustomMaterial":if(i.createCustomMaterial===void 0)throw new Error("createCustomMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(e[0]);case"setMaterial":if(i.setMaterial===void 0)throw new Error("setMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(e[0]),e[1]);case"cloneObject":return i.cloneObject(String(e[0]),e[1]??{});case"removeObject":return i.removeObject(String(e[0]));case"spawnObject":{let n=i.spawnObject(String(e[0]),e[1]??{});return n.warning&&this.onConsole("warn",n.warning),n.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let n=e[1]===null||e[1]===void 0?null:e[1],r=i.setInstanceTransforms(String(e[0]),n);return r<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(e[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),r}case"emitEvent":case"emitEventReverse":{let n=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return n.warning&&this.onConsole("warn",n.warning),n.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let n=String(e[0]);return n==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(n)||this.eventUnsubs.set(n,i.addSplineEventListener(n,r=>{this.onEvent(n,r)})),!0}case"unlistenEvent":{let n=String(e[0]);return n==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(n)?.(),this.eventUnsubs.delete(n)),!0}default:throw new Error(`Unknown spline bridge method: ${t}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let t=this.deps.getVariables(),e=function(i,n){let r=[];for(let s of Object.keys(n))i[s]!==n[s]&&r.push({name:s,value:n[s]});return r}(this.lastVariables??{},t);this.lastVariables=t;for(let i of e)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function lX(t,e,i,n){return[t[0]*e+t[4]*i+t[8]*n+t[12],t[1]*e+t[5]*i+t[9]*n+t[13],t[2]*e+t[6]*i+t[10]*n+t[14]]}var hX=z(()=>{}),uF,cX=z(()=>{}),dX=z(()=>{gC(),dF(),uF=class{constructor(t,e,i){this.iframe=t,this.deps=e,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=n=>{if(this.disposed||n.source!==this.iframe.contentWindow)return;let r=n.data;var s;typeof(s=r)!="object"||s===null||s[zl]!==!0||typeof s.kind!="string"||this.handleMessage(r)},this.host=new mC(e,i,(n,r)=>{this.sendEvent(n,r)})}attach(){window.addEventListener("message",this.onMessage),this.send({[zl]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) \u2014 if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),this.handshakeTimer!==null&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(t){switch(t.kind){case"ready":this.handshakeSeen=!0,this.send({[zl]:!0,kind:"ready-ack"});break;case"console":this.onConsole(t.level,t.text);break;case"call":{let e;try{e=Promise.resolve(this.host.execute(t.method,t.args))}catch(i){e=Promise.reject(i)}e.then(i=>{this.send({[zl]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let n=i instanceof Error?i.message:String(i);this.send({[zl]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:n}),this.onConsole("error",n)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[zl]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),n={bubbles:!0,cancelable:!0,view:window,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey};switch(t.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":e.dispatchEvent(new PointerEvent(t.type,{...n,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,movementX:t.movementX,movementY:t.movementY}));break;case"click":case"dblclick":e.dispatchEvent(new MouseEvent(t.type,{...n,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let r=new WheelEvent("wheel",{...n,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,deltaX:t.deltaX,deltaY:t.deltaY,deltaMode:t.deltaMode});typeof t.wheelDeltaX=="number"&&Object.defineProperty(r,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(r,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(r);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...n,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ii=z(()=>{fC(),Xq(),$q(),Yq(),Kq(),Qq(),Jq(),tX(),eX(),iX(),nX(),aX(),gC(),oX(),dF(),hX(),cX(),dX()}),uX=z(()=>{});function pF(t){return Array.isArray(t)?t:[t]}function w_(t,e){let i=0;for(;i<t.length&&i<e.length;){if(t[i]<e[i])return-1;if(t[i]>e[i])return 1;i+=1}return i!==e.length?-1:i!==t.length?1:0}var pX=z(()=>{});function Er(t,e){return Object.setPrototypeOf(t,e),t}function Xw(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function Xl(t,e,i){if(t===void 0?e===void 0?(t=0,e=10):t=e-10:e===void 0&&(e=t+10),t>e){let s=t;t=e,e=s}let n=[],r=1/(i+1);for(let s=0;s<i;s++){let a=t+(e-t)*(s+.75+.5*Math.random())*r;n.push(a)}return n}function Vc(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array}var fX=z(()=>{});function vC(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let n=t[i];n&&typeof n=="object"&&vC(n)}return Object.freeze(t)}function fF(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var $w,S_,RE,te,yC,mX=z(()=>{}),Dn=z(()=>{uX(),pX(),fX(),mX()}),_C=z(()=>{$w=class{},S_=class extends $w{constructor(t){super(),this.id=t}},RE=class extends $w{constructor(t){super(),this.data=t}}}),gX=z(()=>{}),Vb=z(()=>{te=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let n={...i,[t]:e};return Object.setPrototypeOf(n,te.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let i,n=e[t.id];i=n===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:n};let{id:r,data:s}=t,a={...e,[r]:s};return Object.setPrototypeOf(a,te.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,n=e[i];if(n===void 0)return null;{let r={...e};return Object.setPrototypeOf(r,te.prototype),delete r[i],{data:r,actual:t,reverse:{type:1,id:i,data:n}}}}return null}}}),bC=z(()=>{yC=class extends Error{}});function mF(t,e){for(let i of t)e(i.id,i.data)!==!0&&mF(i.children,e)}function gF(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)gF(i,e)}var Xn,nv,dp,Vt,$c=z(()=>{Dn(),bC(),Dn(),Xn=class extends Array{constructor(...t){super(...t),Ka(this,"partialObjectCaches"),Ka(this,"objCaches"),Ka(this,"parentCaches"),Object.setPrototypeOf(this,Xn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)vC(this[t]),t++}fillCaches0(t,e){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,e);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,e){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}rootAcestor(t){for(;t;){let e=this.parent(t);if(!e)return t;t=e}return t}isDescendantOf(t,e){for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}partialCache(t){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let e=this.get(t);e!==void 0&&this.partialObjectCaches.set(t,e)}get(t){if(this.partialObjectCaches!==void 0){let e=this.partialObjectCaches.get(t);if(e!==void 0)return e}return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,e){if(t===null)this.traverse(e);else{let i=this.get(t);i&&gF(i,e)}}traverse(t){mF(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this.parent(t),n=this.childrenArray(i),r=n.findIndex(o=>o.id===t);if(r<0)throw new Error("not expected");let s=n[r];n=[...n],n[r]={...s,data:e};let a=new Map;return a.set(t,n[r]),this.modifyArrayBy(i,n,a)}}modifyArrayBy(t,e,i=void 0){let n=t,r=e;for(;n!==null;){let a=r,o=n;if(n=this.parent(n),n===void 0)throw new Error;r=this.childrenArray(n);let l=r.findIndex(c=>c.id===o);if(l<0)throw new Error;r=[...r],r[l]={...r[l],children:a},i&&i.set(o,r[l])}Object.setPrototypeOf(r,Xn.prototype);let s=r;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[a,o]of i)s.objCaches.set(a,o);s.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else s.fillCaches();return s}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:e}){if(this.get(t)!==void 0)return!0;for(let i of e)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:e,fi:i,id:n,data:r,children:s}=t;if(e!==null&&this.get(e)===void 0||this.checkDuplicatedIdRec(t))return null;{let a=e,o=this.childrenArray(a),l={fi:i,id:n,data:r,children:s};return o=[...o,l],o.sort((c,h)=>c.fi-h.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:n}}}}deleteOp(t){let{id:e}=t;if(this.get(e)===null)return null;{let i=this.parent(e);if(i===void 0)return null;let n=this.childrenArray(i),r=n.findIndex(a=>a.id===e);t.localIndex=r,n=[...n];let s=n.splice(r,1)[0];return{data:this.modifyArrayBy(i,n),actual:t,reverse:{type:7,...s,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:n}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:n});if(e!==null){let u=e;for(;u!==null;){if(u===void 0)throw new Error;if(u===n)throw new yC("cyclic tree");u=this.parent(u)}}let r=this.parent(n);if(r===void 0)return null;let s=r,a=this.childrenArray(r),o=a.findIndex(u=>u.id===n);a=[...a];let l=a.splice(o,1)[0],c=this.modifyArrayBy(r,a);r=e,a=c.childrenArray(r);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((u,d)=>u.fi-d.fi),t.localIndex=a.indexOf(l),c=c.modifyArrayBy(r,a),{data:c,actual:t,reverse:{type:9,parent:s,fi:h,id:n}}}previous(t,e){if(e===null){let n=this.childrenArray(t);return n.length===0?null:n[n.length-1].id}let i=null;for(let n of this.childrenArray(t)){if(n.id===e)return i;i=n.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),n=i.findIndex(r=>r.id===t)+1;if(n<i.length)return i[n].id;if(e)return this.traverseSortNext(e)}}sortNext(t){let e=this.childrenArray(t);return e.length>0?e[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let e=this.childrenArray(t);return e.length>0?this.traverseSortPrevious(e[e.length-1].id):t}sortPrevious(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),n=i.findIndex(r=>r.id===t)-1;return n>=0?this.traverseSortPrevious(i[n].id):e}}getAllSorted(t){let e=[];for(let i of t){let n=this.getWithSortKey(i.id);n!==void 0&&e.push({...i,...n})}e.sort((i,n)=>w_(i.sortKey,n.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let n=this.getWithSortKey(i);n!==void 0&&e.push(n)}e.sort((i,n)=>w_(i.sortKey,n.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],n=this.get(e),r=n;if(n!==void 0){for(;e;)i.splice(0,0,n.fi),e=this.parent(e),e!==null&&(n=this.get(e));return{...r,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let n=this.childrenArray(t);if(e===null){if(n.length===0)return Xl(0,i,i);{let r=n[0].fi;return Xl(r-i,r,i)}}{let r=this.get(e);if(r===void 0||this.parent(e)!==t)throw new Error("illegal args");let s=n.find(a=>a.fi>r.fi);if(s===void 0){let a=n[n.length-1].fi;return Xl(a,a+i,i)}return Xl(r.fi,s.fi,i)}}}}),xC=z(()=>{var t;Dn(),nv=null,(t=dp||(dp={})).setPreservePrototype=function(e){nv=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===nv&&Object.setPrototypeOf(i,nv),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||Vc(e)){let n=i.props,r={},s=Vc(e)?e.slice():[...e],a=!1;if(n)for(let o of Object.keys(n)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");r[o]=s[l],s[l]=n[o],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:r}}:null}{let n=i.props,r={},s={...e},a=!1;if(n)for(let o of Object.keys(n)){r[o]=s[o];let l=n[o];l===void 0?delete s[o]:s[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,s),actual:i,reverse:{type:0,props:r}}:null}}}),Yc=z(()=>{Dn(),Dn(),Vt=class extends Array{constructor(...t){super(...t),Ka(this,"objCaches"),Object.setPrototypeOf(this,Vt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)vC(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this,n=i.findIndex(s=>s.id===t);if(n<0)throw new Error("not expected");let r=i[n];return i=[...i],i[n]={...r,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,Vt.prototype);let e=t;return typeof process<"u"||e.fillCaches(),e}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:e,id:i,data:n}=t,r=this,s={fi:e,id:i,data:n};return r=[...r,s],r.sort((a,o)=>a.fi-o.fi),t.localIndex=r.indexOf(s),{data:this.modifyArrayBy(r),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,n=i.findIndex(s=>s.id===e);if(n===-1)return null;t.localIndex=n,i=[...i];let r=i.splice(n,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...r}}}moveOp(t){let{fi:e,id:i}=t,n=this;n=[...n];let r=n.findIndex(o=>o.id===i);if(r===-1)return null;let s=n[r].fi,a={...n[r],fi:e};return n[r]=a,n.sort((o,l)=>o.fi-l.fi),t.localIndex=n.indexOf(a),{data:this.modifyArrayBy(n),actual:t,reverse:{type:6,fi:s,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let e=null;for(let i of this){if(i.id===t)return e;e=i.id}return null}insertBeforeHelper(t,e){return this.insertAfterHelper(this.previous(t),e)}insertAfterHelper(t,e){let i=this;if(t===null){if(i.length===0)return Xl(0,e,e);{let n=i[0].fi;return Xl(n-e,n,e)}}{let n=this.get(t);if(n===void 0)throw new Error("illegal args");let r=i.find(s=>s.fi>n.fi);if(r===void 0){let s=i[i.length-1].fi;return Xl(s,s+e,e)}return Xl(n.fi,r.fi,e)}}}});function vX(t,e){let i={cur:[],result:[],len:0};return[t=Hu(t,e,i)??t,i.result]}function o1(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function l1(t){t&&(t.len-=1)}function vF(t,e,i){let n=!1,r=t.map(s=>{let a=s.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(n=!0,a=o,i!==null))throw new Error("not supported");let l=Hu(s.data,e,o1(i,a));l1(i),n=n||l!==void 0,l===void 0&&(l=s.data);let c=vF(s.children,e,i);return c!==void 0?n=!0:c=s.children,{...s,id:a,data:l,children:c}});if(n)return r}function Hu(t,e,i){if(t instanceof Xn){let n=vF(t,e,i);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n}if(t instanceof Vt)return function(n,r,s){let a=!1,o=n.map(l=>{let c=l.id,h=r[c];if(h!==void 0&&typeof h=="string"&&(a=!0,c=h,s!==null))throw new Error("not supported");let u=Hu(l.data,r,o1(s,c));return l1(s),a=a||u!==void 0,u===void 0&&(u=l.data),{...l,id:c,data:u}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}(t,e,i);if(Array.isArray(t)){let n=!1,r=t.map((s,a)=>{let o=Hu(s,e,o1(i,a));return l1(i),n=n||o!==void 0,o===void 0&&(o=s),o});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t&&typeof t=="object"&&!Vc(t)){let n={},r=!1;for(let[s,a]of Object.entries(t))if(s!=="name"&&s!=="variableId"){let o=e[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");r=!0,s=o}let l=Hu(a,e,o1(i,s));l1(i),r=r||l!==void 0,l===void 0&&(l=a),n[s]=l}else n[s]=a;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n):void 0}if(typeof t=="string"){let n=e[t];return n!==void 0&&function(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}(i),n}}var yF=z(()=>{$c(),Yc(),Dn()});function Wu(t){return t&&typeof t=="object"&&t instanceof mn}function wC(t,e){if(e===void 0)return;let i=!1,n=t.map(r=>{let s=r.id,a=ig(r.data,e[s]);if(i=i||a!==void 0,a===void 0&&(a=r.data),r.children){let o=wC(r.children,e);return o!==void 0?i=!0:o=r.children,{...r,id:s,data:a,children:o}}return{...r,id:s,data:a}});return i?n:void 0}function ig(t,e){if(!Wu(e))return e;if(t instanceof Xn){let i=wC(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof Vt)return function(i,n){if(n===void 0)return;let r=!1,s=i.map(a=>{let o=a.id,l=ig(a.data,n[o]);return r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(i)),s):void 0}(t,e);if(Array.isArray(t)){let i=!1,n=t.map((r,s)=>{let a=ig(r,e[s]);return i=i||a!==void 0,a===void 0&&(a=r),a});return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n):void 0}if(t instanceof mn)return SC(t,e);if(t&&typeof t=="object"){let i={},n=!1;for(let[r,s]of Object.entries(t)){let a=ig(s,e[r]);n=n||a!==void 0,a===void 0&&(a=s),i[r]=a}return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function SC(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!Wu(e))return e;if(!Wu(t))return ah.apply(t,e);let i=new Set;for(let r of Object.keys(t))i.add(r);for(let r of Object.keys(e))i.add(r);let n=new mn;for(let r of i){let s=SC(t===void 0?void 0:t[r],e===void 0?void 0:e[r]);n[r]=s}return n}var mn,ah,M_,er,VR,MC=z(()=>{var t;$c(),Yc(),Hb(),Dn(),mn=class{unusedFunOverridesTable(e){}runOp(e){let i=[],n=this,r=0,s={};for(;r<e.path.length;){if(i.push(n),n=n===void 0?void 0:n[e.path[r]],n!==void 0&&!Wu(n))return null;r+=1}n=n?Xw(n):new mn;for(let[a,o]of Object.entries(e.props)){let l=n[a];s[a]=l,o===void 0?delete n[a]:n[a]=o}for(;r>0;){if(Object.keys(n).length===0){let a=i[r-1];a&&(n=Xw(a),delete n[e.path[r-1]])}else{let a=i[r-1];if(a){let o=Xw(a);o[e.path[r-1]]=n,n=o}else{let o=new mn;o[e.path[r-1]]=n,n=o}}r-=1}return{data:Object.setPrototypeOf(n,mn.prototype),actual:e,reverse:{...e,props:s}}}},(t=ah||(ah={})).apply=function(e,i){return ig(e,i)??e},t.merge=function(e,i){return SC(e,i)},t.filterOp=function(e,i){let n=0,r=i.path,s=e;for(;n<r.length&&s!==void 0;){if(s=jn.zoomOnce(s,r[n]),s===void 0)return i;if(!Wu(s))return;n+=1}if(s===void 0)return i;if(Wu(s)){if(i.type===0){let a={...i.props};for(let o of Object.keys(s))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=wC([i],s);return a?a[0]:i}return i}}}),yX=z(()=>{Dn(),Hb(),Vb(),$c(),bC(),xC(),Yc(),yF(),MC(),(M_||(M_={})).replaceProps=function(t,e){let i=jn.zoom(e,t.path);if(typeof i=="object"){let n={};for(let r of Object.keys(t.props))n[r]=i[r];return{...t,props:n}}return{...t,props:{}}},(t=>{function e(r,s){let a=s.path,o=[];for(;;){let l;if(r instanceof mn&&s.type===0&&(l=r.runOp({...s,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=r instanceof Xn||r instanceof Vt||r instanceof te?r.runOp(s):dp.runOp(r,s)),l!==void 0){if(l!==null){let u=l.data;for(let d=o.length-1;d>=0;d--){let p=a[d],f=o[d];if(f instanceof Xn){if(typeof p=="number")throw new Error("illegal arg");u=f.modifyById(p,u)}else if(f instanceof Vt){if(typeof p=="number")throw new Error("illegal arg");u=f.modifyById(p,u)}else if(f instanceof te){if(typeof p=="number")throw new Error("illegal arg");u=f.modifyById(p,u)}else if(f instanceof mn){let g={...f,[p]:u};u=Object.setPrototypeOf(g,mn.prototype)}else{if(typeof f!="object")return null;if(Array.isArray(f)||Vc(f)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let g=u;u=Vc(f)?f.slice():[...f],u[p]=g}else u=dp.tryPreservePrototype(f,{...f,[p]:u})}}return{data:u,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let c,h=a[o.length];if(r instanceof Xn){if(typeof h=="number")throw new Error("");c=r.get(h)?.data}else if(r instanceof Vt){if(typeof h=="number")throw new Error("");c=r.get(h)?.data}else r!==null&&(c=r[h]);if(c===void 0)return null;o.push(r),r=c}}function i(r,s){for(let a=0;a<r.length&&a<s.length;a++)if(r[a]!==s[a])return!0;return!1}function n(r,s){if(r.length!==s.length)return!1;for(let a=0;a<r.length;a++)if(r[a]!==s[a])return!1;return!0}t.drop=function(r,s){return{...r,path:r.path.slice(s)}},t.applySimple=function(r,s){return e(r,s)?.data??r},t.apply=e,t.pathDisjoint=i,t.pathEq=n,t.commutative=function(r,s){return i(r.path,s.path)},t.subsumed=function(r,s){return!(r.type!==0||s.type!==0||!n(r.path,s.path))&&Object.keys(r.props).every(a=>s.props[a]!==void 0)}})(er||(er={})),(t=>{function e(i,n){let r=i,s=[],a=[];for(let o of n)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,c,h;if(o.type===3?(l=jn.zoom(r,[...o.path,o.id]),h=er.apply(r,{...o,type:2})):(l=jn.zoom(r,[...o.path,o.id,"value"]),h=er.apply(r,o)),h!==null){r=h.data;let[u,d]=vX(r,{[o.id]:l});r=u;for(let p=0;p<d.length;p++){let f=d[p],g=f.pop();if(typeof g=="number"){let m=[g];for(let v=p+1;v<d.length;v++){let _=d[v],b=_[_.length-1];if(typeof b!="number"||!jn.equal(f,_.slice(0,_.length-1)))break;m.push(b),d.splice(v,1)}let y=jn.zoom(r,f);c=y.map((v,_)=>m.includes(_)?o.id:v),l=y,g=f.pop()}else{if(g==="alphaOverride"||g==="alpha"){l/=100;let m=l,y=jn.zoom(r,f.slice(0,f.length-2)),v=y.layers.map(_=>_.id===f[f.length-1]?{..._,data:{..._.data,[g]:m}}:_);Object.setPrototypeOf(v,Object.getPrototypeOf(y.layers)),y.layers=v}c=o.id}s.push({type:0,path:f,props:{[g]:l}}),a.push({type:0,path:f,props:{[g]:c}})}a.push(h.reverse),s.push(h.actual)}}else{let l=er.apply(r,o);l!==null&&(s.push(l.actual),r=l.data,a.push(l.reverse))}}catch(l){if(l instanceof yC)return null;throw l}return{data:r,actual:s,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,n){let r=[];for(let s of i){let[a,...o]=s.path;a===n&&r.push({...s,path:o})}return r},t.addPrefix=function(i,n){return i.map(r=>({...r,path:[n,...r.path]}))},t.concat=function(i,n){return[...i,...n]},t.compress=function(i,n){return[...i.filter(r=>!n.some(s=>er.subsumed(r,s))),...n]},t.commutative=function(i,n){return i.every(r=>n.every(s=>er.commutative(r,s)))},t.applyAll=function(i,n){for(let r of n){let s=e(i,r);s!==null&&(i=s.data)}return i},t.apply=e})(VR||(VR={}))});function Yw(t,e,i){if(t.length>0){let n=t[t.length-1];if(n.type===0&&e.type===0&&jn.equal(n.path,i))return void Object.assign(n.props,e.props)}t.push({...e,path:i})}function h1(t,e,i){return i instanceof Xn?new jb(t,e,i):i instanceof Vt?new Gb(t,e,i):i instanceof te?new Proxy(new bF(t,e,i),wF):i!==null&&typeof i=="object"?Vc(i)?i:new Proxy(new _F(t,e,i),xF):i}function Tm(t){let e=new OE(t);return[h1(e,"",t),e]}function E_(t,e){let[i,n]=Tm(t);return e(i),n.result()}function hn(t){return t instanceof jb||t instanceof Gb?t._current:t!==null&&typeof t=="object"?t[IE]:t}var IE,jR,Cf,Rd,_F,bF,Zw,xF,wF,jb,Gb,OE,jn,SF=z(()=>{Vb(),$c(),xC(),Yc(),Dn(),Hb(),IE=Symbol(),jR=Symbol(),Cf=Symbol(),Rd=class{reportOp(t,e,i=[]){let n=this;if(e===null)return;n._current=e.data;let r=i;for(;!(n instanceof OE);){let s=n._path,a=n._current;if(s!==""&&r.splice(0,0,s),n=n._parent,n===null)return;n.update(s,a)}n.push(r,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[Cf];i&&i(),delete this._children[t]}}}},_F=class extends Rd{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=dp.tryPreservePrototype(this._current,{...this._current,[t]:e})}runOp(t){this.reportOp(t,dp.runOp(this._current,t),t.path)}},bF=class extends Rd{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,te.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Zw={get(t,e){if(e===Cf)return()=>{t._parent=null};if(e===IE)return t._current;if(e===jR)return t;let{_current:i,_children:n}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[e];if(r!==void 0)return r;let s=i[e],a=h1(t,e,s);return a!==s?(n===void 0&&(n={},t._children=n),n[e]=a,a):s},has:(t,e)=>e in t._current,ownKeys:t=>Reflect.ownKeys(t._current),defineProperty(){throw Error("not supported")},getPrototypeOf:t=>Object.getPrototypeOf(t._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(t,e){let i=t._current,n=Reflect.getOwnPropertyDescriptor(i,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:i[e]}}},xF={...Zw,set(t,e,i){let n={type:0,props:{[e]:hn(i)??i}};return t.deleteChildren(e),t.runOp(n),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},wF={...Zw,set(t,e,i){return i===void 0?this.deleteProperty(t,e):(t.deleteChildren(e),t.runOp({type:1,id:e,data:i})),!0},deleteProperty:(t,e)=>(t.runOp({type:2,id:e}),!0)},jb=class extends Rd{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[Cf]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,i)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:i}=this,n=i===void 0?void 0:i[t];if(n!==void 0)return n;let r=e.get(t)?.data,s=h1(this,t,r);return s!==r?(i===void 0&&(i={},this._children=i),i[t]=s,s):r}add(t,e,i,n,r){this.runOp({type:7,parent:t,fi:e,id:i,data:n,children:r})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let n=this._current.insertAfterHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.add(t,n[r],s.id,s.data,s.children)}}insertBefore(t,e,i){let n=this._current.insertBeforeHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.add(t,n[r],s.id,s.data,s.children)}}moveAfter(t,e,i){let n=this._current.insertAfterHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.move(t,n[r],s)}}moveBefore(t,e,i){let n=this._current.insertBeforeHelper(t,e,i.length);for(let r=0;r<i.length;r++){let s=i[r];this.move(t,n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Gb=class extends Rd{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[Cf]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let i=0;i<e;i++){let n=this._current[i].id,r=this._current[i].fi;t(this.data(this._current[i].id),n,r,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let n=this._current[i].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:i}=this._current.at(t);return{id:e,fi:i,data:this.data(e)}}data(t){let{_current:e,_children:i}=this,n=i===void 0?void 0:i[t];if(n!==void 0)return n;let r=e.get(t)?.data,s=h1(this,t,r);return s!==r?(i===void 0&&(i={},this._children=i),i[t]=s,s):r}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,i){this.runOp({type:4,fi:t,id:e,data:i})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.add(i[n],r.id,r.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.add(i[n],r.id,r.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.move(i[n],r)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let r=e[n];this.move(i[n],r)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},OE=class extends Rd{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,i,n){Yw(this.ts,e,t),Yw(this.actual,i,t),Yw(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),Hb=z(()=>{_C(),SF(),Yc(),$c(),Dn(),(t=>{function e(n,r){return(n instanceof Xn||n instanceof jb)&&typeof r=="string"||(n instanceof Vt||n instanceof Gb)&&typeof r=="string"?n.data(r):typeof r=="number"&&Array.isArray(n)||typeof r=="string"&&typeof n=="object"&&n!==null?n[r]:void 0}function i(n,r,s=0){for(;s<r.length&&n!==void 0;)n=e(n,r[s]),s+=1;return n}t.equal=function(n,r){if(r.length!==n.length)return!1;{let s=0;for(;s<n.length;){if(n[s]!==r[s])return!1;s+=1}}return!0},t.removeOverridden=function(n,r,s){let a=i(s,n);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...r};return Object.keys(a).forEach(l=>{delete o[l]}),o}return r},t.zoomOnce=e,t.zoom=i,t.findPathes=function(n,r){let s=[];return function a(o,l){if(o instanceof S_&&o.id===r.id)s.push(l);else if(o instanceof Vt)for(let c=0;c<o.length;c++)a(o[c].data,[...l,o[c].id]);else if(o instanceof Xn)o.traverse((c,h)=>{a(h,[...l,c])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let c=0;c<o.length;c++)a(o[c],[...l,c])}else{if(Vc(o))return;if(typeof o=="object"&&o!==null)for(let c in o)a(o[c],[...l,c])}}(n,[]),s}})(jn||(jn={}))}),_X=z(()=>{});function ri(t,e){let i=[];if(!(e.length<=t.length))return null;{let n=0;for(;n<e.length;){if(e[n]==="*")i.push(t[n]);else if(t[n]!==e[n])return null;n+=1}}return i}var bX=z(()=>{});function rv(t){try{if(!bi.trusted&&!Zo){let i=Qe.sharedLength||0;i<Qe.length&&(Qe.length=i)}let e;if(bi.randomAccessStructure&&kt[mt]<64&&kt[mt]>=32&&$R?(e=$R(kt,mt,Ns,bi),kt=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),mt=Ns):e=fn(),yr&&(mt=yr.postBundlePosition,yr=null),Zo&&(Qe.restoreStructures=null),mt==Ns)Qe&&Qe.restoreStructures&&GR(),Qe=null,kt=null,Yo&&(Yo=null);else{if(mt>Ns)throw new Error("Unexpected end of MessagePack data");if(!Zo){let i;try{i=JSON.stringify(e,(n,r)=>typeof r=="bigint"?`${r}n`:r).slice(0,100)}catch(n){i="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw Qe&&Qe.restoreStructures&&GR(),BE(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||mt>Ns)&&(e.incomplete=!0),e}}function GR(){for(let t in Qe.restoreStructures)Qe[t]=Qe.restoreStructures[t];Qe.restoreStructures=null}function fn(){let t=kt[mt++];if(t<160){if(t<128){if(t<64)return t;{let e=Qe[63&t]||bi.getStructures&&MF()[63&t];return e?(e.read||(e.read=LE(e,63&t)),e.read()):t}}if(t<144){if(t-=128,bi.mapsAsObjects){let e={};for(let i=0;i<t;i++){let n=AF();n==="__proto__"&&(n="__proto_"),e[n]=fn()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(fn(),fn());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=fn();return bi.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(ua>=mt)return $l.slice(mt-fs,(mt+=e)-fs);if(ua==0&&Ns<140){let i=e<16?EC(e):EF(e);if(i!=null)return i}return C_(e)}{let e;switch(t){case 192:return null;case 193:return yr?(e=fn(),e>0?yr[1].slice(yr.position1,yr.position1+=e):yr[0].slice(yr.position0,yr.position0-=e)):PF;case 194:return!1;case 195:return!0;case 196:if(e=kt[mt++],e===void 0)throw new Error("Unexpected end of buffer");return Kw(e);case 197:return e=He.getUint16(mt),mt+=2,Kw(e);case 198:return e=He.getUint32(mt),mt+=4,Kw(e);case 199:return Xh(kt[mt++]);case 200:return e=He.getUint16(mt),mt+=2,Xh(e);case 201:return e=He.getUint32(mt),mt+=4,Xh(e);case 202:if(e=He.getFloat32(mt),bi.useFloat32>2){let i=VE[(127&kt[mt])<<1|kt[mt+1]>>7];return mt+=4,(i*e+(e>0?.5:-.5)|0)/i}return mt+=4,e;case 203:return e=He.getFloat64(mt),mt+=8,e;case 204:return kt[mt++];case 205:return e=He.getUint16(mt),mt+=2,e;case 206:return e=He.getUint32(mt),mt+=4,e;case 207:return bi.int64AsType==="number"?(e=4294967296*He.getUint32(mt),e+=He.getUint32(mt+4)):bi.int64AsType==="string"?e=He.getBigUint64(mt).toString():bi.int64AsType==="auto"?(e=He.getBigUint64(mt),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=He.getBigUint64(mt),mt+=8,e;case 208:return He.getInt8(mt++);case 209:return e=He.getInt16(mt),mt+=2,e;case 210:return e=He.getInt32(mt),mt+=4,e;case 211:return bi.int64AsType==="number"?(e=4294967296*He.getInt32(mt),e+=He.getUint32(mt+4)):bi.int64AsType==="string"?e=He.getBigInt64(mt).toString():bi.int64AsType==="auto"?(e=He.getBigInt64(mt),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=He.getBigInt64(mt),mt+=8,e;case 212:if(e=kt[mt++],e==114)return kE(63&kt[mt++]);{let i=gr[e];if(i)return i.read?(mt++,i.read(fn())):i.noBuffer?(mt++,i()):i(kt.subarray(mt,++mt));throw new Error("Unknown extension "+e)}case 213:return e=kt[mt],e==114?(mt++,kE(63&kt[mt++],kt[mt++])):Xh(2);case 214:return Xh(4);case 215:return Xh(8);case 216:return Xh(16);case 217:return e=kt[mt++],ua>=mt?$l.slice(mt-fs,(mt+=e)-fs):RF(e);case 218:return e=He.getUint16(mt),ua>=(mt+=2)?$l.slice(mt-fs,(mt+=e)-fs):IF(e);case 219:return e=He.getUint32(mt),ua>=(mt+=4)?$l.slice(mt-fs,(mt+=e)-fs):OF(e);case 220:return e=He.getUint16(mt),mt+=2,HR(e);case 221:return e=He.getUint32(mt),mt+=4,HR(e);case 222:return e=He.getUint16(mt),mt+=2,WR(e);case 223:return e=He.getUint32(mt),mt+=4,WR(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+t)}}}function LE(t,e){function i(){if(i.count++>zE){let r;try{r=t.read=new Function("r","return function(){return "+(bi.freezeData?"Object.freeze":"")+"({"+t.map(s=>s==="__proto__"?"__proto_:r()":DF.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(fn)}catch{return zE=1/0,i()}return t.read0=r,t.highByte===0&&(t.read=FE(e,t.read)),r()}let n={};for(let r=0,s=t.length;r<s;r++){let a=t[r];a==="__proto__"&&(a="__proto_"),n[a]=fn()}return bi.freezeData?Object.freeze(n):n}return i.count=0,t.read0=i,t.highByte===0?FE(e,i):i}function MF(){let t=CF(()=>(kt=null,bi.getStructures()));return Qe=bi._mergeStructures(t,Qe)}function Cm(t){let e;if(t<16&&(e=EC(t)))return e;if(t>64&&UE)return UE.decode(kt.subarray(mt,mt+=t));let i=mt+t,n=[];for(e="";mt<i;){let r=kt[mt++];if(128&r)if((224&r)==192){let s=(31&r)<<6|63&kt[mt++];s<128?n.push(65533):n.push(s)}else if((240&r)==224){let s=(31&r)<<12|(63&kt[mt++])<<6|63&kt[mt++];s<2048||s>=55296&&s<=57343?n.push(65533):n.push(s)}else if((248&r)==240){let s=(7&r)<<18|(63&kt[mt++])<<12|(63&kt[mt++])<<6|63&kt[mt++];s<65536||s>1114111?n.push(65533):(s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s))}else n.push(65533);else n.push(r);n.length>=4096&&(e+=kn.apply(String,n),n.length=0)}return n.length>0&&(e+=kn.apply(String,n)),e}function HR(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=fn();return bi.freezeData?Object.freeze(e):e}function WR(t){if(bi.mapsAsObjects){let e={};for(let i=0;i<t;i++){let n=AF();n==="__proto__"&&(n="__proto_"),e[n]=fn()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(fn(),fn());return e}}function EF(t){let e=mt,i=new Array(t);for(let n=0;n<t;n++){let r=kt[mt++];if((128&r)>0)return void(mt=e);i[n]=r}return kn.apply(String,i)}function EC(t){if(t<4){if(t<2){if(t===0)return"";{let e=kt[mt++];return(128&e)>1?void(mt-=1):kn(e)}}{let e=kt[mt++],i=kt[mt++];if((128&e)>0||(128&i)>0)return void(mt-=2);if(t<3)return kn(e,i);let n=kt[mt++];return(128&n)>0?void(mt-=3):kn(e,i,n)}}{let e=kt[mt++],i=kt[mt++],n=kt[mt++],r=kt[mt++];if((128&e)>0||(128&i)>0||(128&n)>0||(128&r)>0)return void(mt-=4);if(t<6){if(t===4)return kn(e,i,n,r);{let s=kt[mt++];return(128&s)>0?void(mt-=5):kn(e,i,n,r,s)}}if(t<8){let s=kt[mt++],a=kt[mt++];if((128&s)>0||(128&a)>0)return void(mt-=6);if(t<7)return kn(e,i,n,r,s,a);let o=kt[mt++];return(128&o)>0?void(mt-=7):kn(e,i,n,r,s,a,o)}{let s=kt[mt++],a=kt[mt++],o=kt[mt++],l=kt[mt++];if((128&s)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(mt-=8);if(t<10){if(t===8)return kn(e,i,n,r,s,a,o,l);{let c=kt[mt++];return(128&c)>0?void(mt-=9):kn(e,i,n,r,s,a,o,l,c)}}if(t<12){let c=kt[mt++],h=kt[mt++];if((128&c)>0||(128&h)>0)return void(mt-=10);if(t<11)return kn(e,i,n,r,s,a,o,l,c,h);let u=kt[mt++];return(128&u)>0?void(mt-=11):kn(e,i,n,r,s,a,o,l,c,h,u)}{let c=kt[mt++],h=kt[mt++],u=kt[mt++],d=kt[mt++];if((128&c)>0||(128&h)>0||(128&u)>0||(128&d)>0)return void(mt-=12);if(t<14){if(t===12)return kn(e,i,n,r,s,a,o,l,c,h,u,d);{let p=kt[mt++];return(128&p)>0?void(mt-=13):kn(e,i,n,r,s,a,o,l,c,h,u,d,p)}}{let p=kt[mt++],f=kt[mt++];if((128&p)>0||(128&f)>0)return void(mt-=14);if(t<15)return kn(e,i,n,r,s,a,o,l,c,h,u,d,p,f);let g=kt[mt++];return(128&g)>0?void(mt-=15):kn(e,i,n,r,s,a,o,l,c,h,u,d,p,f,g)}}}}}function qR(){let t,e=kt[mt++];if(e<192)t=e-160;else switch(e){case 217:t=kt[mt++];break;case 218:t=He.getUint16(mt),mt+=2;break;case 219:t=He.getUint32(mt),mt+=4;break;default:throw new Error("Expected string")}return Cm(t)}function Kw(t){return bi.copyBuffers?Uint8Array.prototype.slice.call(kt,mt,mt+=t):kt.subarray(mt,mt+=t)}function Xh(t){let e=kt[mt++];if(gr[e]){let i;return gr[e](kt.subarray(mt,i=mt+=t),n=>{mt=n;try{return fn()}finally{mt=i}})}throw new Error("Unknown extension type "+e)}function AF(){let t=kt[mt++];if(!(t>=160&&t<192))return mt--,TF(fn());if(t-=160,ua>=mt)return $l.slice(mt-fs,(mt+=t)-fs);if(!(ua==0&&Ns<180))return C_(t);let e,i=4095&(t<<5^(t>1?He.getUint16(mt):t>0?kt[mt]:0)),n=NE[i],r=mt,s=mt+t-3,a=0;if(n&&n.bytes==t){for(;r<s;){if(e=He.getUint32(r),e!=n[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(e=kt[r++],e!=n[a++]){r=1879048192;break}if(r===s)return mt=r,n.string;s-=3,r=mt}for(n=[],NE[i]=n,n.bytes=t;r<s;)e=He.getUint32(r),n.push(e),r+=4;for(s+=3;r<s;)e=kt[r++],n.push(e);let o=t<16?EC(t):EF(t);return n.string=o??C_(t)}function TF(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(bi.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error("Invalid property type for record: "+typeof t)}function CF(t){YR&&YR();let e=Ns,i=mt,n=T_,r=fs,s=ua,a=$l,o=A_,l=Yo,c=yr,h=new Uint8Array(kt.slice(0,Ns)),u=Qe,d=Qe.slice(0,Qe.length),p=bi,f=Zo,g=t();return Ns=e,mt=i,T_=n,fs=r,ua=s,$l=a,A_=o,Yo=l,yr=c,kt=h,Zo=f,(Qe=u).splice(0,Qe.length,...d),bi=p,He=new DataView(kt.buffer,kt.byteOffset,kt.byteLength),g}function BE(){kt=null,Yo=null,Qe=null}function xX(t){t.unpack?gr[t.type]=t.unpack:gr[t.type]=t}var UE,kt,Ns,mt,XR,A_,T_,bi,Qe,$l,fs,ua,yr,Yo,gr,He,Qw,PF,Zo,zE,$R,YR,Pm,DF,FE,C_,RF,IF,OF,kn,NE,kE,Jw,ZR,KR,QR,VE,sv,JR,tI,eI,jE,tS,Pg,wX=z(()=>{try{UE=new TextDecoder}catch{}mt=0,A_=XR=[],T_=0,bi={},fs=0,ua=0,gr=[],Qw={useRecords:!1,mapsAsObjects:!0},(PF=new class{}).name="MessagePack 0xC1",Zo=!1,zE=2,Pm=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=0&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(kt)return CF(()=>(BE(),this?this.unpack(t,e):Pm.prototype.unpack.call(Qw,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ns=e.end||t.length,mt=e.start||0):(mt=0,Ns=e>-1?e:t.length),T_=0,ua=0,$l=null,A_=XR,yr=null,kt=t;try{He=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw kt=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Pm){if(bi=this,this.structures)return Qe=this.structures,rv(e);(!Qe||Qe.length>0)&&(Qe=[])}else bi=Qw,(!Qe||Qe.length>0)&&(Qe=[]);return rv(e)}unpackMultiple(t,e){let i,n=0;try{Zo=!0;let r=t.length,s=this?this.unpack(t,r):sv.unpack(t,r);if(!e){for(i=[s];mt<r;)n=mt,i.push(rv());return i}if(e(s,n,mt)===!1)return;for(;mt<r;)if(n=mt,e(rv(),n,mt)===!1)return}catch(r){throw r.lastPosition=n,r.values=i,r}finally{Zo=!1,BE()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,n=t.length;i<n;i++){let r=t[i];r&&(r.isShared=!0,i>=32&&(r.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let n=t[i],r=e[i];r&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[i]=n),t[i]=r)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},DF=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,FE=(t,e)=>function(){let i=kt[mt++];if(i===0)return e();let n=t<32?-(t+(i<<5)):t+(i<<5),r=Qe[n]||MF()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=LE(r,t)),r.read()},C_=Cm,RF=Cm,IF=Cm,OF=Cm,kn=String.fromCharCode,NE=new Array(4096),kE=(t,e)=>{let i=fn().map(TF),n=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let r=Qe[t];return r&&(r.isShared||Zo)&&((Qe.restoreStructures||(Qe.restoreStructures=[]))[t]=r),Qe[t]=i,i.read=LE(i,n),(i.read0||i.read)()},gr[0]=()=>{},gr[0].noBuffer=!0,gr[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let n=1;n<e;n++)i<<=BigInt(8),i+=BigInt(t[n]);if(t.byteLength!==e){let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=(s,a)=>{let o=a-s;if(o<=40){let u=n.getBigUint64(s);for(let d=s+8;d<a;d+=8)u<<=BigInt(64),u|=n.getBigUint64(d);return u}let l=s+(o>>4<<3),c=r(s,l),h=r(l,a);return c<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(n.byteLength-e))|r(e,n.byteLength)}return i},Jw={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},gr[101]=()=>{let t=fn();if(!Jw[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return Jw[t[0]](t[1],{cause:t[2]})},gr[105]=t=>{if(bi.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=He.getUint32(mt-4);Yo||(Yo=new Map);let i,n=kt[mt];i=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&kt[mt+1]===115?new Set:{};let r={target:i};Yo.set(e,r);let s=fn();if(!r.used)return r.target=s;if(Object.assign(i,s),i instanceof Map)for(let[a,o]of s.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(s))i.add(a);return i},gr[112]=t=>{if(bi.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=He.getUint32(mt-4),i=Yo.get(e);return i.used=!0,i.target},gr[115]=()=>new Set(fn()),ZR=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),KR=typeof globalThis=="object"?globalThis:window,gr[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,n=ZR[e];if(!n){if(e===16)return i;if(e===17)return new DataView(i);throw new Error("Could not find typed array for code "+e)}return new KR[n](i)},gr[120]=()=>{let t=fn();return new RegExp(t[0],t[1])},QR=[],gr[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=mt;return mt+=e-t.length,yr=QR,(yr=[qR(),qR()]).position0=0,yr.position1=0,yr.postBundlePosition=mt,mt=i,fn()},gr[255]=t=>t.length==4?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid"),VE=new Array(147);for(let t=0;t<256;t++)VE[t]=+("1e"+Math.floor(45.15-.30103*t));(sv=new Pm({useRecords:!1})).unpack,sv.unpackMultiple,sv.unpack,JR=new Float32Array(1),new Uint8Array(JR.buffer,0,4)}),SX=z(()=>{wX(),_C(),MC(),Yc(),Vb(),$c(),tI=[{Class:te.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,te.prototype),t)},{Class:Vt.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Vt.prototype),t)},{Class:Xn.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Xn.prototype),t)},{Class:S_.prototype.constructor,type:4,write:t=>t.id,read:t=>new S_(t)},{Class:RE.prototype.constructor,type:5,write:t=>t.data,read:t=>new RE(t)},{Class:mn.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,mn.prototype),t)}];for(let t of tI)xX(t);eI=new Pm({structuredClone:!0}),(jE||(jE={})).deserialize=function(t){return eI.unpack(t)}}),MX=z(()=>{SX(),tS=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},Pg={deserialize:jE.deserialize,serialize:tS("CollabSerialize.serialize"),checksum:tS("CollabSerialize.checksum")}}),Ye=z(()=>{Hb(),gX(),bC(),$c(),Vb(),xC(),Yc(),yX(),_X(),SF(),bX(),_C(),MX(),yF(),MC()});function GE(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var iI,HE,Ou,av,eS,nI,rI,sI,WE,qE,aI,oI,lI,hI,cI,XE,$E,dI,uI,pI,fI,LF=z(()=>{var t,e,i;Ye(),et(),(t=iI||(iI={})).toEventUIType=function(n){return n.type==="Conditional"?n.condition.type==="Distance"?"Distance":"StateChange":n.type},t.fromEventUIType=function(n){return n==="Distance"||n==="StateChange"?"Conditional":n},HE={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(n=>{n.is=function(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"},n.defaultData=function(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new Vt}:{type:r,disabled:!1,name:"",key:void 0,actions:new Vt}}})(Ou||(Ou={})),(n=>{n.propertyDefaultData=function(r){return{type:"Property",value:[r??null,"position","x"]}},n.valueDefaultData={type:"Literal",value:0}})(av||(av={})),(e=eS||(eS={})).comparisonDefaultData=function(n){return{type:"Comparison",operator:"==",lOperand:av.propertyDefaultData(n),rOperand:{...av.valueDefaultData}}},e.distanceDefaultData=function(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}},e.stateDefaultData=function(n,r){return{type:"State",object:n??null,state:r??null}},(nI||(nI={})).isConditionalSubActions=function(n){return n.find(r=>r==="ifActions"||r==="elseActions")!==void 0},(n=>{n.is=function(r){return r.type==="Conditional"},n.defaultData=function(r){return{type:"Conditional",disabled:!1,name:"",inActions:new Vt,outActions:new Vt,condition:eS.distanceDefaultData(r)}}})(rI||(rI={})),(sI||(sI={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Vt,drop:new Vt}},(WE||(WE={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Vt},(qE||(qE={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(n=>{n.is=function(r){return r.type==="MouseHover"},n.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new Vt}}})(aI||(aI={})),(n=>{n.is=function(r){return r.type==="Scroll"},n.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Vt}}})(oI||(oI={})),(n=>{n.is=function(r){return r.type==="Start"},n.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new Vt}}})(lI||(lI={})),(n=>{n.is=function(r){return r.type==="Collision"},n.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new Vt}}})(hI||(hI={})),(n=>{n.is=function(r){return r.type==="Trigger"},n.defaultData=function(r,s){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new Vt,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}})(cI||(cI={})),(i=XE||(XE={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(n){return n.type==="Resize"},i.sizeToDevice=function(n){return typeof n=="string"?n:"custom"},i.deviceToSize=function(n){return typeof n=="string"?[...i.defaultSizes[n]]:[...n]},i.defaultData=function(){let n={size:"mobile",operator:"<",actions:new Vt},r={size:"tablet",operator:"<",actions:new Vt},s={size:[...i.defaultSizes.custom],operator:"<>",actions:new Vt},a=new Vt;return a.push({id:Ot.generateUUID(),fi:0,data:n},{id:Ot.generateUUID(),fi:1,data:r},{id:Ot.generateUUID(),fi:2,data:s}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new Vt}},(n=>{n.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},n.is=function(r){return r.type==="VariableChange"},n.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new Vt,variableId:"",objectId:null,property:"Position X"}}})($E||($E={})),(n=>{n.is=function(r){return r.type==="API"},n.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new Vt,errorActions:new Vt,userAPIId:""}}})(dI||(dI={})),(n=>{n.is=function(r){return r.type==="WEBHOOK"},n.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new Vt,userWebhookId:""}}})(uI||(uI={})),(n=>{n.is=function(r){return r.type==="AIAssistantListener"},n.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new Vt,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(pI||(pI={})),(n=>{n.is=function(r){return r.type==="AIAssistantTrigger"},n.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new Vt}}})(fI||(fI={}))});function mI(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function gI(t){return typeof t=="string"&&t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}var Zc,qu,BF,Rr,vI,Ja,oh,Dg,yI,Xu,Tn,Je,YE,_I,Yl,up,bI,xI,wI,SI,MI,EI,AI,TI,iS,CI,PI,nS,DI,RI,II,rS,OI,sS,LI,BI,UI,zI,FI,NI,kI,VI,jI,jc,Ko,Zl,ZE,KE,P_,D_,R_,I_,O_,QE,JE,L_,tA,$u,GI,aS,oS,eA,HI,B_,WI,qI,U_,XI,$I,YI,ZI,KI,QI,JI,tO,eO,Wb,AC,Ki,ki,wu,UF,Rg,z_,yc,iA,TC,F_,N_,nA,Ho,c1,ir,lS,Vl,k_,ng,hS,cS,dS,Yu,uS,rA,sA,iO,Id,zF,En,V_,nO,rO,sO,aO,Ha,rg,j_,G_,Qo,Ic,oO,Kl,H_,Jo,pS,fS,bc,Gc,xc,sg,aA,lO,_r,mS,hO,cO,Wo,Fs,Zu,oA,_s=z(()=>{var t,e,i,n,r,s,a,o;Zc="personal camera",qu="a218fcc3-276b-49b9-b485-49037fd14f5f",BF=2500134,Rr=5526619,(t=vI||{}).x="x",t.y="y",t.z="z",vI=t,(l=>{function c(d,p){return Math.pow(p[0]-d[0],2)+Math.pow(p[1]-d[1],2)}function h(d,p){return Math.sqrt(c(d,p))}function u(d,p,f){let g=l.sub(p,d),m=l.sub(f,d),y=l.dot(g,m)/l.dot(g,g),v=l.scalarMultiply(g,y);return l.add(d,v)}l.isEqual=function(d,p){return d[0]===p[0]&&d[1]===p[1]},l.lerp=function(d,p,f){return[d[0]+(p[0]-d[0])*f,d[1]+(p[1]-d[1])*f]},l.add=function(d,p){return[d[0]+p[0],d[1]+p[1]]},l.sub=function(d,p){return[d[0]-p[0],d[1]-p[1]]},l.multiply=function(d,p){return[d[0]*p[0],d[1]*p[1]]},l.divide=function(d,p){return[d[0]/p[0],d[1]/p[1]]},l.distanceSquared=c,l.distance=h,l.dot=function(d,p){return d[0]*p[0]+d[1]*p[1]},l.scalarMultiply=function(d,p){return[d[0]*p,d[1]*p]},l.projectionOnto=u,l.projectionOntoDistance=function(d,p,f){return h(d,u(d,p,f))},l.center=function(d,p){return[.5*(d[0]+p[0]),.5*(d[1]+p[1])]}})(Ja||(Ja={})),(e=oh||(oh={})).isEqual=function(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]},e.add=function(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]},e.sub=function(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]},e.div=function(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]},e.mul=function(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]},e.dist=function(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])},e.lerp=function(l,c,h){return[l[0]+(c[0]-l[0])*h,l[1]+(c[1]-l[1])*h,l[2]+(c[2]-l[2])*h]},(i=Dg||(Dg={})).isEqual=function(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]&&l[3]===c[3]},i.lerp=function(l,c,h){return[l[0]+(c[0]-l[0])*h,l[1]+(c[1]-l[1])*h,l[2]+(c[2]-l[2])*h,l[3]+(c[3]-l[3])*h]},(l=>{let c=180/Math.PI,h=Math.PI/180;function u(p){return typeof p=="number"?p*c:p}function d(p){return typeof p=="number"?p*h:p}l.radToDeg=function(p){return[u(p[0]),u(p[1]),u(p[2])]},l.degToRad=function(p){return[d(p[0]),d(p[1]),d(p[2])]}})(yI||(yI={})),(n=Xu||(Xu={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],n.isEqual=function(l,c){for(let h=0;h<16;h++)if(l[h]!==c[h])return!1;return!0},n.simplify=function(l){return l??n.identity},n.applyMatrix4=function(l,c){let h=c.slice(0);for(let u=0,d=c.length;u<d;u+=3){let p=l[3]*c[u]+l[7]*c[u+1]+l[11]*c[u+2]+l[15];h[u]=(l[0]*c[u]+l[4]*c[u+1]+l[8]*c[u+2]+l[12])/p,h[u+1]=(l[1]*c[u]+l[5]*c[u+1]+l[9]*c[u+2]+l[13])/p,h[u+2]=(l[2]*c[u]+l[6]*c[u+1]+l[10]*c[u+2]+l[14])/p}return h},(r=Tn||(Tn={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},r.white={r:1,g:1,b:1},r.red={r:1,g:0,b:0},r.black={r:0,g:0,b:0},r.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},r.clone=function(l){return{r:l.r,g:l.g,b:l.b}},r.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},r.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},r.equals=function(l,c){return l.r===c.r&&l.g===c.g&&l.b===c.b},r.equalsFixed=function(l,c){return l.r.toFixed(2)===c.r.toFixed(2)&&l.g.toFixed(2)===c.g.toFixed(2)&&l.b.toFixed(2)===c.b.toFixed(2)},r.lerp=function(l,c,h){return{r:l.r+(c.r-l.r)*h,g:l.g+(c.g-l.g)*h,b:l.b+(c.b-l.b)*h}},r.is=function(l){return!!mI(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(s=Je||(Je={})).white={...Tn.white,a:1},s.is=function(l){return!!mI(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},s.transparent={...Tn.white,a:0},s.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},s.fromHexAndA=function(l,c){return{...Tn.fromHex(l),a:c}},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},s.equals=function(l,c){return Tn.equals(l,c)&&l.a===c.a},s.equalsFixed=function(l,c){return Tn.equalsFixed(l,c)&&l.a.toFixed(2)===c.a.toFixed(2)},s.lerp=function(l,c,h){return{r:l.r+(c.r-l.r)*h,g:l.g+(c.g-l.g)*h,b:l.b+(c.b-l.b)*h,a:l.a+(c.a-l.a)*h}},s.toStyle=function({r:l,g:c,b:h,a:u}=s.white){return`rgba(${255*l}, ${255*c}, ${255*h}, ${u})`},(YE||(YE={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=_I||{})[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING",a[a.ARC=7]="ARC",a[a.NONE=8]="NONE",_I=a,(Yl||(Yl={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(up||(up={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=bI||(bI={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),EX=z(()=>{var t,e;Ye(),LF(),(xI||(xI={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(wI||(wI={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(SI||(SI={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(MI||(MI={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(EI||(EI={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(AI||(AI={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(TI||(TI={})).defaultData={type:"Reset",name:"",delay:0},(iS||(iS={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=CI||(CI={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=PI||(PI={})).defaultData={type:"Audio",name:"",...iS.defaultData},e.hasAudioByActions=i=>i.some(({data:n})=>n.type==="Audio"&&n.interaction==="play"&&n.audio),e.hasAudioByEvents=i=>{for(let{data:n}of i)if(Ou.is(n)||n.type==="Start"||n.type==="Collision"){if(e.hasAudioByActions(n.actions))return!0}else if(n.type==="Conditional"){if(e.hasAudioByActions(n.inActions)||e.hasAudioByActions(n.outActions))return!0}else if(n.type==="GameControl"&&Object.values(n.gameActions).find(r=>e.hasAudioByActions(r)))return!0},e.getAudiosByActions=i=>{let n=[];return i.forEach(r=>{let s=r.data;s.type==="Audio"&&s.interaction==="play"&&s.audio&&n.push(r),s.type==="Conditional"&&(n.push(...e.getAudiosByActions(s.ifActions)),n.push(...e.getAudiosByActions(s.elseActions)))}),n},e.getAudiosByEvents=i=>{let n=[];return i.forEach(({data:r})=>{Ou.is(r)||r.type==="Collision"||r.type==="Start"||r.type==="Trigger"?n.push(...e.getAudiosByActions(r.actions)):r.type==="Conditional"?(n.push(...e.getAudiosByActions(r.inActions)),n.push(...e.getAudiosByActions(r.outActions))):r.type==="GameControl"?Object.values(r.gameActions).forEach(s=>{n.push(...e.getAudiosByActions(s))}):r.type==="DragDrop"&&(n.push(...e.getAudiosByActions(r.dragDropActions.drag)),n.push(...e.getAudiosByActions(r.dragDropActions.drop)))}),n},(nS||(nS={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(DI||(DI={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...nS.defaultData},i.hasVideoByActions=n=>n.some(({data:r})=>r.type==="Video"&&r.interaction==="play"&&r.layerId),i.hasVideoByObject=n=>{if(n.events){for(let{data:r}of n.events)if((Ou.is(r)||r.type==="Start")&&i.hasVideoByActions(r.actions))return!0}},i.getVideosByActions=n=>{let r=[];return n.forEach(s=>{let a=s.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&r.push(s)}),r},i.getVideosByEvents=n=>{let r=[];return n.forEach(({data:s})=>{(Ou.is(s)||s.type==="Start")&&r.push(...i.getVideosByActions(s.actions))}),r}})(RI||(RI={})),(II||(II={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(rS||(rS={})).defaultData=function(){return{tweens:new Vt,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(OI||(OI={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...rS.defaultData()}},(sS||(sS={})).defaultData=function(i){return{interaction:"play",timeline:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(LI||(LI={})),(BI||(BI={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...sS.defaultData(i)}},(UI||(UI={})).defaultData=function(i,n,r){return{type:"Animation",name:"",object:i,clipId:n,crop:r,crop2:r,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(zI||(zI={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(FI||(FI={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new Vt,elseActions:new Vt,condition:[]}),(NI||(NI={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(kI||(kI={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(VI||(VI={})).defaultData={name:"",type:"UserAPI"}}),AX=z(()=>{var t;(t=jI||(jI={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),FF=z(()=>{var t;(t=jc||(jc={})).all=["PerspectiveCamera","OrthographicCamera"],t.is=function(e){return t.all.includes(e)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(s){return s===void 0||!Number.isFinite(s)||s<e.MinTargetOffset?e.DefaultTargetOffset:s},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,n=e.DefaultElevation*Math.PI/180,r=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(n),e.DefaultTargetOffset*Math.sin(n),e.DefaultTargetOffset*Math.cos(i)*Math.cos(n)],e.DefaultRotation=[Math.atan2(-Math.sin(n),Math.cos(i)*Math.cos(n))*r,Math.asin(Math.sin(i)*Math.cos(n))*r,Math.atan2(Math.sin(i)*Math.sin(n),Math.cos(i))*r],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}})(Ko||(Ko={}))}),NF=z(()=>{var t;(t=Zl||(Zl={})).defaultData=function(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof e[0]=="number"?e[0]:1,typeof e[1]=="number"?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof e[0]=="number"?e[0]+e[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(n=>(typeof n=="number"?n:1)*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},t.merge=function(e,i){let n={...e};if(KE.forEach(r=>{Object.assign(n,{[r]:i[r]??e[r]})}),n.radial={...e.radial},i.radial){let r=e.radial,s=i.radial;P_.forEach(a=>{Object.assign(n.radial,{[a]:s[a]??r[a]})})}if(n.linear={...e.linear},i.linear){let r=e.linear,s=i.linear;D_.forEach(a=>{Object.assign(n.linear,{[a]:s[a]??r[a]})})}if(n.grid={...e.grid},i.grid){let r=e.grid,s=i.grid;R_.forEach(a=>{Object.assign(n.grid,{[a]:s[a]??r[a]})})}if(n.toObject={...e.toObject},i.toObject){let r=e.toObject,s=i.toObject;I_.forEach(a=>{Object.assign(n.toObject,{[a]:s[a]??r[a]})})}if(n.randomnessObject={...e.randomnessObject},i.randomnessObject){let r=e.randomnessObject,s=i.randomnessObject;O_.forEach(a=>{Object.assign(n.randomnessObject,{[a]:s[a]??r[a]})})}return n},t.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(n,r){let s=[];n.count!==void 0&&s.push({type:0,path:r,props:{count:n.count}});for(let a of i){let o=n[a];o&&Object.keys(o).length>0&&s.push({type:0,path:[...r,a],props:o})}return s}})(ZE||(ZE={})),KE=["count"],P_=["radius","start","end","position","scale","rotation"],D_=["position","scale","rotation"],R_=["count","size"],I_=["count","position","scale","rotation"],O_=["strength","scale","rotation","position","movement","seed","freqScale"]}),kF=z(()=>{var t;_s(),(t=QE||(QE={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(JE||(JE={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:Je.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:Je.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(i==="DirectionalLight")return{type:i,color:Je.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),VF=z(()=>{var t;(t=L_||(L_={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...t.defaultCollisionData}}),jF=z(()=>{var t;(t=tA||(tA={})).defaultData={gravity:10,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:0,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},t.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),CC=z(()=>{($u||($u={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),GF=z(()=>{var t,e;(t=GI||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",GI=t,(e=aS||(aS={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,n){return i.castShadow===n.castShadow&&i.receiveShadow===n.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe&&(n.shadowCatcher??!1)===(r.shadowCatcher??!1)}})(oS||(oS={})),(eA||(eA={})).defaultData={...oS.defaultData,...aS.defaultData},(HI||(HI={})).getMaterialData=function(i,n){let r=[];if("material"in i){let s=typeof i.material=="string"?n.materials[i.material]??n.lib.materials[i.material]?.asset:i.material;s&&r.push(s)}else if("materials"in i)for(let s of i.materials){let a=typeof s=="string"?n.materials[s]??n.lib.materials[s]?.asset:s;a&&r.push(a)}return r}}),HF=z(()=>{var t;(t=B_||(B_={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),Wg=z(()=>{var t,e,i,n;Ye(),_s(),HF(),_s(),(WI||(WI={})).is=function(r){return r==="texture"||r==="video"||r==="color"||r==="depth"||r==="normal"||r==="gradient"||r==="noise"||r==="fresnel"||r==="cavity"||r==="dust"||r==="rainbow"||r==="toon"||r==="outline"||r==="particle"||r==="transmission"||r==="reflection"||r==="matcap"||r==="displace"||r==="pattern"||r==="vertexColor"||r==="light"},(qI||(qI={})).is=function(r){return r==="luminance"||r==="r"||r==="g"||r==="b"||r==="a"},(U_||(U_={})).is=function(r){return typeof r=="object"&&r!==null&&r.image!=null},(XI||(XI={})).is=function(r){return r==="phong"||r==="toon"||r==="lambert"||r==="physical"},(n=$I||{})[n.Linear=0]="Linear",n[n.Radial=1]="Radial",n[n.Polar=2]="Polar",$I=n,YI=(r=>(r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",r))(YI||{}),ZI=(r=>(r[r.NearestFilter=1003]="NearestFilter",r[r.LinearFilter=1006]="LinearFilter",r[r.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",r))(ZI||{}),(i=KI||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",KI=i,(e=QI||{})[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",QI=e,(t=JI||{})[t.F1=0]="F1",t[t.F2=1]="F2",t[t.F2MinusF1=2]="F2MinusF1",t[t.SmoothBlend=3]="SmoothBlend",t[t.Edge=4]="Edge",t[t.Power=5]="Power",t[t.Lines=6]="Lines",t[t.Cells=7]="Cells",JI=t,tO=(r=>(r[r.Lights=0]="Lights",r[r.Static=1]="Static",r[r.Camera=2]="Camera",r))(tO||{}),eO=(r=>(r[r.Circle=0]="Circle",r[r.Ring=1]="Ring",r[r.Polygon=2]="Polygon",r[r.Cross=3]="Cross",r[r.Diamond=4]="Diamond",r[r.Checkerboard=5]="Checkerboard",r[r.Line=6]="Line",r[r.Wave=7]="Wave",r))(eO||{}),Wb=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],AC=["wrapping","image","video","name","minFilter","magFilter"],(r=>{r.patch=function(s,a){let{texture:o,...l}=a;if(Object.assign(s,l),o){let c=s.texture;c&&Object.assign(c,o)}},r.defaultColorLayer=function(s){return{...r.defaultData("color"),color:s}},r.defaultData=function(s,a){return s==="light"&&a?function(o){let l={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...l,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...l,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...l,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...l,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(a):function(o){let l={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...l,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...l,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:B_.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:Tn.fromHex(Rr)};case"vertexColor":return{...l,type:"vertexColor"};case"depth":return{...l,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...l,type:"normal",cnormal:[1,1,1]};case"gradient":return{...l,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...l,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Tn.fromHex(6710886),a:1},colorB:{...Tn.fromHex(6710886),a:1},colorC:{...Tn.fromHex(16777215),a:1},colorD:{...Tn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...l,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...l,type:"fresnel",color:Je.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:Je.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...l,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...l,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Je.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:Je.fromHexAndA(0,1),contourColor:Je.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...l,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...l,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...l,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...l,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Tn.fromHex(0),a:1},colorB:{...Tn.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(s)}})(Ki||(Ki={})),(r=>{function s(a,o="layer1",l="layer2",c=Tn.fromHex(16777215)){let h=new Vt;return h.push({fi:0,data:Ki.defaultData("light",a),id:o}),h.push({fi:1,data:Ki.defaultData("color"),id:l}),{layers:h}}r.isMergable=function(a){return!a.layers.some(o=>o.data.type==="texture"&&o.data.projection!==0||o.data.type==="depth"&&!o.data.isWorldSpace||o.data.type==="noise"||o.data.type==="dust"&&o.data.noiseStrength!==0||o.data.type==="displace")},r.getHash=function(a){let o="";return a.layers.forEach(l=>{Object.entries(l.data).forEach(([c,h])=>{o+=`${c}${h}`,Array.isArray(h)?h.forEach(u=>o+=`${u}`):typeof h=="object"?Object.values(h).forEach(u=>{o+=typeof u=="number"?`${u.toFixed(4)}`:`${u}`}):o+=`${h}`})}),o},r.defaultEmptyData=function(){return{layers:new Vt}},r.defaultData=function(a="layer1",o="layer2"){return s("physical",a,o)},r.withName=function(a,o){return{...a,name:o}},r.defaultTwoLayerData=s,r.defaultColorMaterial=function(a,o,l="layer1",c="layer2"){let h=new Vt;return h.push({fi:0,data:Ki.defaultData("light",o),id:l}),h.push({fi:1,data:Ki.defaultColorLayer(a),id:c}),{layers:h}},r.defaultUIObjectMaterial=function(a){let o=Ki.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new Vt;return l.push({fi:0,data:o,id:"layer1"}),l.push({fi:1,data:{...Ki.defaultData("transmission"),alpha:1},id:"layer2"}),l.push({fi:2,data:{...Ki.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:l}},r.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",c="layer2"){let h=Ki.defaultData("texture");Object.assign(h.texture,{image:a});let u=new Vt;return u.push({fi:0,data:h,id:l}),u.push({fi:1,data:Ki.defaultData("light",o),id:c}),{layers:u}},r.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",c="layer2"){let h=Ki.defaultData("video");Object.assign(h.texture,{video:a});let u=new Vt;return u.push({fi:0,data:h,id:l}),u.push({fi:1,data:Ki.defaultData("light",o),id:c}),{layers:u}}})(ki||(ki={}))}),TX=z(()=>{wu="Roboto_regular",UF="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),WF=z(()=>{Ye(),(Rg||(Rg={})).defaultData=function(){return{points:new Vt,roundness:0,shapeHoles:[],isClosed:!1}}}),qF=z(()=>{Ye(),(z_||(z_={})).defaultData=function(){return{points:new Vt,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},yc={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(iA||(iA={})).merge=function(t,e){let i={...t};return F_.forEach(n=>{Object.assign(i,{[n]:e[n]??t[n]})}),i},TC={shape:yc,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},F_=["depth","offset","angle","twist","startScale","endScale"]}),PC=z(()=>{var t,e;WF(),qF(),(t=N_||(N_={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},t.isParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"||i==="DecalGeometry"},t.isSwappableGeometry=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"},(nA||(nA={})).merge=function(i,n){let r={...i};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...i.extrusion},Object.assign(r.extrusion,iA.merge(r.extrusion,n.extrusion))),r},(e=Ho||(Ho={})).defaultData=function(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:z_.defaultData(),extrusion:TC};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Rg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="DecalGeometry")return{type:i,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")},c1=["width","height","depth"]}),XF=z(()=>{_s(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:Tn.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let n=e(i);return n==="height"?1:n==="both"?2:0},t.getDensity=function(i){return i.density??t.defaultData.density},t.getHeightFalloff=function(i){return i.heightFalloff??t.defaultData.heightFalloff},t.getHeightBase=function(i){return i.heightBase??t.defaultData.heightBase}})(ir||(ir={}))}),DC=z(()=>{(lS||(lS={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Vl||(Vl={})).defaultData={enabled:!1,mode:"hdri",hdri:lS.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}}),$F=z(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(k_||(k_={})).defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})()}),RC=z(()=>{var t;XF(),DC(),$F(),_s(),(t=ng||(ng={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(hS||(hS={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(cS||(cS={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(dS||(dS={})),(Yu||(Yu={})).defaultData={usePhysics:!1,gravity:-10},(uS||(uS={})).defaultData={playCamera:Zc,gameControlObject:null},(rA||(rA={})).defaultData={backgroundColor:Je.fromHexAndA(BF,1),postprocessing:k_.defaultData,fog:ir.defaultData,sky:Vl.defaultData,globalPhysics:Yu.defaultData,ambient:hS.defaultData,ao:cS.defaultData,shadow:ng.defaultData,publish:uS.defaultData,grading:dS.defaultData}}),CX=z(()=>{(sA||(sA={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),qb=z(()=>{var t,e,i;Ye(),FF(),kF(),VF(),jF(),CC(),GF(),_s(),Wg(),PC(),NF(),Dn(),RC(),CX(),(t=iO||(iO={})).isComponentRelated=function(n){return n==="Component"||n==="Instance"},t.isEmptyOrComponent=function(n){return n==="Empty"||n==="Instance"},(e=Id||(Id={})).identity={...YE.identity,hiddenMatrix:Xu.identity},e.fromObject=function(n){return{position:n.position,rotation:n.rotation,scale:n.scale,pivot:n.pivot,pivotRotation:n.pivotRotation,hiddenMatrix:n.hiddenMatrix}},e.merge=function(n,r){return{position:r?.position||n.position,rotation:r?.rotation||n.rotation,pivot:r?.pivot||n.pivot,pivotRotation:r?.pivotRotation||n.pivotRotation,scale:r?.scale||n.scale,hiddenMatrix:r?.hiddenMatrix||n.hiddenMatrix}},e.diff=function(n,r){return fF({position:oh.isEqual(n.position,r.position)?void 0:r.position,rotation:oh.isEqual(n.rotation,r.rotation)?void 0:r.rotation,scale:oh.isEqual(n.scale,r.scale)?null:r.scale,hiddenMatrix:Xu.isEqual(n.hiddenMatrix,r.hiddenMatrix)?void 0:r.hiddenMatrix})},zF=["slide","offset"],(En||(En={})).defaultData={states:new Vt,events:new Vt,visible:!0,raycastLock:!1,physics:$u.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Id.identity,cloner:null},(V_||(V_={})).defaultData={type:"Empty",...En.defaultData},(nO||(nO={})).defaultData={type:"ParticleCollider",...sA.defaultData,...En.defaultData},(rO||(rO={})).defaultData={type:"Component",...En.defaultData},(sO||(sO={})).defaultData={type:"Particle",...En.defaultData,...L_.defaultData},(aO||(aO={})).defaultData={type:"Hair",...En.defaultData,...tA.defaultData},(Ha||(Ha={})).defaultData={type:"Mesh",...En.defaultData,...eA.defaultData},(rg||(rg={})).defaultData={...En.defaultData,...Id.identity,position:Ko.DefaultPosition,rotation:Ko.DefaultRotation,...Ko.defaultData},(n=>{n.defaultData=function(r){return{...En.defaultData,...JE.defaultData(r)}},n.defaultDirectionalLightData={...n.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(j_||(j_={})),(n=>{function r(s,a,o=0){for(;o<a.length;){let l=s?s[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;s=l.descendants,o+=1}}n.resolveWithDes=r,n.resolve=function(s,a,o=0){let l=r(s,a,o);if(l){let c=Object.keys(l);if(c.length===1&&c[0]==="descendants")return}return l}})(G_||(G_={})),(n=>{function r(s,a){return{...En.defaultData,...a,component:s,overrides:new mn,physics:void 0,events:void 0,type:"Instance"}}n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"],n.ofComponent=r,n.fromComponentData=function(s){let a=Id.fromObject(s.data);return r(s.id,a)}})(Qo||(Qo={})),(n=>{n.defaultData={type:"Page",...En.defaultData,physics:{...$u.defaultData,fusedBody:!1},...rA.defaultData,camera:rg.defaultData,timelines:new te},n.isUIPage=function(r){return r.uiScene!==void 0}})(Ic||(Ic={})),(i=oO||(oO={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Xu.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:$u.defaultData,states:new Vt,events:new Vt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Ko.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("RectangleGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("BooleanGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("ShapeBlendGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("TextGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...En.defaultData,...Ha.defaultData,geometry:Ho.defaultData("InputGeometry"),material:ki.defaultTwoLayerData("physical","layer1","layer2")},(n=>{n.newEmpty=function(r,s){let a={name:s};return r.type==="Mesh"?(a.geometry={},"material"in r&&(a.material={layers:new mn}),"materials"in r&&(a.materials=r.materials.map(o=>({layers:new mn})))):jc.is(r.type)&&(a.perspective={},a.orthographic={}),a},n.toOps=function(r,s){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function c(h,u){for(let[d,p]of Object.entries(u.layers)){let{texture:f,...g}=p;if(f!==void 0&&Object.keys(f).length>0){let m={path:[...h,"layers",d,"texture"],props:f,type:0};o.push(m)}if(Object.keys(g).length>0){let m={path:[...h,"layers",d],props:g,type:0};o.push(m)}}}for(let[h,u]of Object.entries(s)){let d=u;if(h!=="name")if(h==="cloner")o.push(...ZE.toOps(d,["cloner"]));else if(h==="pathSnapping")o.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[p,f]of Object.entries(d))c(["materials",p],f);else if(l[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let p={path:[h,"extrusion"],props:d.extrusion,type:0};o.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[h],props:d,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[h]=d}return o},n.patch=function(r,s){if(s===void 0)return r;let a={...r};if(Object.assign(a,Id.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),jc.is(r.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=s;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(r.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:nA.merge(a.geometry,s.geometry)}),(s.material||s.materials)&&(a=function(o,l){if(l===void 0)return o;let c={...o};return"material"in c&&"material"in l&&l.material&&(c.material=E_(c.material,h=>{if(typeof h!="string")for(let[u,d]of Object.entries(l.material.layers)){let p=h.layers.data(u);p&&Ki.patch(p,d)}}).data),c.materials&&l.materials&&(c.materials=E_(c.materials,h=>{for(let u=0;u<c.materials.length;u++){let d=l.materials[u];if(typeof d!="string")for(let[p,f]of Object.entries(d.layers)){let g=h[u]?.layers?.data(p);g&&Ki.patch(g,f)}}}).data),c}(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Zl.merge(a.cloner,s.cloner)});else if(r.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Zl.merge(a.cloner,s.cloner)});else if(QE.is(r.type)){let o=s;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=Tn.clone(o.color))}return a}})(Kl||(Kl={}))}),IC=z(()=>{(H_||(H_={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),Xb=z(()=>{IC(),_s(),(Jo||(Jo={})).defaultData={orbitControls:H_.defaultData,playPage:qu,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,n=0;return e<5?n=-30:e<10&&(n=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,n],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu",asyncShaderCompilation:!0}}),YF=z(()=>{var t;(pS||(pS={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(fS||(fS={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=bc||(bc={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...pS.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:fS.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),OC=z(()=>{qb(),Ye(),Xb(),_s(),Dn(),YF(),(t=>{function e(i,n){let r=i.scene.objects.get(n);if(r&&r.data.type==="Component")return r;{let s=i.shared.lib.components[n];if(s)return{...s.asset,id:n}}}t.physicsEnabled=function(i){return i.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,n){let r=i.find(s=>s.data.type==="Page"&&s.data.timelines?.[n]!==void 0);return r&&r.data.timelines?.[n]},t.getComponentData=e,t.traverseModuleInstances=function(i,n,r){i.scene.objects.traverseFrom(n,(s,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&r(s,a,o.events)}else r(s,a,a.events)})}})(Gc||(Gc={})),(t=>{function e(n=!0,r=[]){let s=[];n&&s.push({...t.defaultLight}),s.push(...r);let a=new Xn;return a.push({fi:1,id:qu,data:{...Ic.defaultData,name:"Scene 1"},children:s}),a}function i(n){return{...t.defaultData,objects:Er(n,Xn.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:j_.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:Jo.defaultData,styles:bc.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new Xn,publish:Jo.defaultData,styles:bc.defaultData()}},t.emptyDataWithPage=function(n=!0){return{objects:e(n),publish:Jo.defaultData,styles:bc.defaultData()}},t.emptyData=function(){return{objects:new Xn,publish:{...Jo.defaultData},styles:bc.defaultData()}},t.withObjs=i,t.withObj=function(n,r){return i([{id:n,data:r,children:[],fi:0}])}})(xc||(xc={}))}),ZF=z(()=>{(sg||(sg={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),LC=z(()=>{var t,e;Ye(),Dn(),(t=aA||(aA={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new Vt}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(lO||(lO={})).defaultData=(i,n="GET")=>({url:i,method:n,name:"New API",headers:new Vt,queries:new Vt,autoStart:!0}),(i=>{function n(s){return s.textValue!==void 0}function r(s){return typeof s=="boolean"}i.isTextValue=n,i.isNumber=function(s){return typeof s=="number"},i.isBoolean=r,i.typeOfVariable=function(s){return n(s)?"string":r(s)?"boolean":"number"},i.getDisplayedValue=function(s){return i.isTextValue(s)?Array.isArray(s.textValue)?s.textValue.map(a=>a.toString().padStart(s.padding??2,"0")).join(s.deliminator??":")+(s.suffix!==void 0?" "+s.suffix:""):s.textValue.toString():i.isBoolean(s)?s?"True":"False":i.isNumber(s)?parseFloat(s.toFixed(3)).toString():s.toString()}})(_r||(_r={})),(mS||(mS={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(hO||(hO={})).all=[...mS.all,"components"],(cO||(cO={})).defaultData=function(){return{images:new te,videos:new te,colors:new te,audios:new te,particles:new te,fonts:new te,materials:new te,components:new te,variables:new te,userAPIs:new te,userWebhooks:new te}},(Wo||(Wo={})).defaultData=function(){return{images:new te,videos:new te,colors:new te,audios:new te,particles:new te,fonts:new te,materials:new te,components:new te,variables:new te,userAPIs:new te,userWebhooks:new te}},(e=Fs||(Fs={})).defaultColors=function(){return Er({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},te.prototype)},e.defaultImages=function(){return Er({},te.prototype)},e.emptyData=function(){return{catelogs:new te,materials:new te,images:new te,videos:new te,colors:new te,audios:new te,particles:new te,fonts:new te,variables:new Vt,userAPIs:new te,userWebhooks:new te,lib:Wo.defaultData()}},e.defaultVariables=function(i){switch(i){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let n=[0,0,0];return{name:"Time",value:{textValue:n,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:n,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",i)}},e.getFormattedTimerTime=function(i,n){if(n.format==="HH:mm:ss"){let r=Math.floor(i/3600),s=Math.floor((i-3600*r)/60);return{textValue:[r,s,Math.round(i-3600*r-60*s)]}}if(n.format==="mm:ss"){let r=Math.floor(i/60);return{textValue:[r,Math.round(i-60*r)]}}return n.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),PX=z(()=>{}),KF=z(()=>{var t;Ye(),OC(),ZF(),LC(),(t=Zu||(Zu={})).defaultData={schema:131,scene:xc.defaultData,frames:new te().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sg.defaultData),shared:{...Fs.emptyData(),colors:Fs.defaultColors()}},t.createDefaultData=function(){return Pg.deserialize(Pg.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:131,scene:xc.emptyDataWithPage(),frames:new te().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sg.defaultData),shared:{...Fs.emptyData(),colors:Fs.defaultColors(),images:Fs.defaultImages()}}},t.emptyData=function(){return{schema:131,scene:xc.emptyDataWithPage(),frames:new te().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sg.defaultData),shared:Fs.emptyData()}},t.clipboard2dData=function(){return{schema:131,scene:xc.emptyData(),frames:new te,shared:Fs.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:Wo.defaultData()}}},t.getComponentData=function(e,i){return Gc.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let n of i){let r=n.headers;for(let s of r)if(s.data.key.toLowerCase()==="authorization"&&s.data.value!=="")return!0}return!1}}),DX=z(()=>{(oA||(oA={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function Oc(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function Pf(t,e,i){switch(t){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:n,control2:r}=e??{...up.defaultData};return`cubicBezier( ${n[0]}, ${n[1]}, ${r[0]}, ${r[1]} )`}case 6:{let{mass:n,stiffness:r,damping:s,velocity:a}=i??{...Yl.defaultData},o=new QF(n,r,s,a),l=o.solve(1);return()=>c=>o.solve(c)/l}case 8:return()=>n=>Math.floor(n)}}var dO,uO,Lc,Ig,QF,W_,q_,JF=z(()=>{Ye(),_s(),(dO||(dO={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new te}},(uO||(uO={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(h,u){let d=[0,0],p=[1,1];if(h?.cubicControls)d=Oc(h.cubicControls.control1,d);else switch(h?.type){case 2:case 4:d=[.42,0];break;case 3:case 0:d=[0,0];break;case 1:d=[.25,.1];break;case 7:d=[.25,1]}if(u?.cubicControls)p=Oc(u.cubicControls.control2,p);else switch(u?.type){case 2:case 0:p=[1,1];break;case 3:case 4:p=[.58,1];break;case 1:p=[.25,1];break;case 7:p=[.5,1]}return{control1:d,control2:p}}function i(h){if(!t.BEZIER_PRESETS.includes(h))return;let u={type:h};return{control1:e(u).control1,control2:e(void 0,u).control2}}function n(h,u){return Math.abs(h[0]-u[0])<.001&&Math.abs(h[1]-u[1])<.001}function r(h){let u=t.ROOT_PROPERTY_ORDER.indexOf(h[0]);return u===-1?t.ROOT_PROPERTY_ORDER.length:u}function s(h){return h.layerId??h.path.join(".")}function a(h){let u=h[h.length-1];return Ig.includes(u)?u:void 0}function o(h){return h.layerId?h.layerId:(a(h.path)?h.path.slice(0,-1):h.path).join(".")}function l(h){return["material",h.type==="light"?`${h.category} lighting`:h.type]}function c(h,u,d){return{id:h,data:{id:h,time:d?.time??0,path:u,value:{},layerId:d?.layerId,index:d?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}t.getControlsWithDefault=e,t.BEZIER_PRESETS=[0,1,2,3,4,7],t.presetHandles=i,t.presetForHandles=function(h){return t.BEZIER_PRESETS.find(u=>{let d=i(u);return d!==void 0&&n(d.control1,h.control1)&&n(d.control2,h.control2)})},t.defaultData=function(h){return{id:h,keyframes:new Vt}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=r,t.propertyKey=s,t.groupKeyframes=function(h,u){let d=new Map;for(let p of h){let f=p.data;if(u?.(f))continue;let g=s(f),m=d.get(g);m||(m={id:g,path:f.path,keyframes:[],layerId:f.layerId,index:f.index},d.set(g,m)),f.isPlaceholder?m.placeholder=p.id:m.keyframes.push(p)}return[...d.values()].sort((p,f)=>{let g=r(p.path)-r(f.path);return g!==0?g:(p.index??0)-(f.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(h){let u=new Map;for(let d of h){let p=a(d.path),f=p?d.path.slice(0,-1):d.path,g=o(d),m=u.get(g);m||(m={id:g,path:f,layerId:d.layerId,index:d.index,tracks:[]},u.set(g,m)),m.tracks.push({axis:p,property:d})}return[...u.values()]},t.sortedKeyframes=function(h){return[...h].sort((u,d)=>u.data.time-d.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(h,u){return h.map(({data:d,id:p},f)=>c(u(),l(d),{layerId:p,index:f}))},t.placeholderKeyframe=c,t.createName=function(h){return Object.entries(h).reduce((u,[d,p])=>(typeof p!="string"&&u.push({name:p.name}),u),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:Pf(3),duration:1e3},opacity:{value:[0,1],easing:Pf(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:Pf(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:Pf(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:Pf(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Lc||(Lc={})),Ig=["x","y","z"],QF=class{constructor(t=1,e=100,i=10,n=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=n,this.m_w0=Math.sqrt(e/t),this.m_zeta=i/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-n)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-n+this.m_w0)}solve(t){return 1-(this.m_zeta<1?Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0))}getDuration(){let t=.16666666666666666,e=0,i=0;for(;;)if(e+=t,this.solve(e)===1){if(i++,i>=16)break}else i=0;return e*t*1e3}}}),BC=z(()=>{var t;_s(),Ye(),(W_||(W_={})).list=["idle","move","jump","run"],(t=q_||(q_={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Vt,move:new Vt,jump:new Vt,run:new Vt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Je.fromHexAndA(3728051,1)}}});function uc(t,...e){let i={};for(let n of e.flat())t!=null&&n in t&&(i[n]=t[n]);return i}function pO(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,n=e.colorB,r=[[i.r,i.g,i.b,i.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let o=2;o<10;o++)r.push(r[1]),s.push(1);let a={...uc(hn(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:r,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,a)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let i={...hn(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Fo(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function No(t,e){t.scene.objects.traverse((i,n)=>{"materials"in n?n.materials.forEach((r,s)=>{r===void 0&&(n.materials[s]=ki.defaultTwoLayerData("phong"),r=n.materials[s]),typeof r!="string"&&e(r)}):"material"in n?typeof n.material!="string"&&(n.material===void 0&&(n.material=ki.defaultTwoLayerData("phong")),e(n.material)):n.type==="Mesh"&&(n.material===void 0&&(n.material=ki.defaultTwoLayerData("phong")),e(n.material)),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&Object.getPrototypeOf(r.material)!==mn.prototype&&e(r.material)})})}function fO(t){t.layers===void 0&&Object.assign(t,ki.defaultTwoLayerData("lambert"))}function gS(t){!t.layers||t.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let i=[...e.colors];i.push(e.colors[9]);let n=[...e.steps];n.push(e.steps[9]);let r={...hn(e),colors:i,steps:n};Object.assign(e,r)}})}function mO(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(n=>{typeof n!="string"&&gS(n)}):"material"in i&&typeof i.material!="string"&&gS(i.material)}),Object.values(t.shared.materials).forEach(e=>gS(e))}function gO(t){t.layers&&t.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function vO(t){t.layers&&t.layers.forEach(e=>{(function(i){return i.type!=="displace"})(e)&&e.isMask===void 0&&(e.isMask=!1),(e.type==="texture"||e.type==="video")&&e.blending===void 0&&(e.blending=0),(e.type==="noise"||e.type==="displace"&&e.displacementType==="noise")&&(e.voronoiStyle===void 0&&(e.voronoiStyle=0),e.highCut===void 0&&(e.highCut=1),e.lowCut===void 0&&(e.lowCut=0),e.smoothness===void 0&&(e.smoothness=.3),e.seed===void 0&&(e.seed=0),e.quality===void 0&&(e.quality=1))})}function yO(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Ki.defaultData("light","phong"),n=e;Object.assign(n,i),n.visible=!1}}function _O(t){Fo(t,yO),No(t,yO)}function bO(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function xO(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var RX=z(()=>{Wg(),_s(),IC(),qb(),Ye(),Xb(),Dn(),et(),PC(),BC(),YF(),OC(),CC(),RC()}),tN={};function wO(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function SO(t){t.rotation=t.rotation.slice(0,3).map(e=>e*_c)}function eN(t){SO(t),t.type==="Page"&&SO(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(n=>n*_c))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*_c),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*_c),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=_c,e.extrusion.twist*=_c),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(hn(t.events))&&t.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function IX(t){t.scene.objects.traverse((e,i)=>{})}function OX(t){let e=t.schema??104;e!==131&&e<130&&(X_(t.asset),t.schema=130)}function Lu(t,e){e(t.data);for(let i of t.children)Lu(i,e)}function iN(t){let e=t.schema??104;e!==131&&(e<105&&(Lu(t.asset,eN),t.schema=105),e<118&&(Lu(t.asset,rN),t.schema=118),e<121&&(Lu(t.asset,hA),t.schema=121),e<130&&(Lu(t.asset,LX),t.schema=130))}function nN(t,e){No(t,e),Fo(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function X_(t){t.layers===void 0&&Object.assign(t,ki.defaultTwoLayerData("phong"))}function LX(t){"materials"in t?t.materials.forEach(e=>{e!==void 0&&typeof e!="string"&&X_(e)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&X_(t.material)}function rN(t){t.timelineAnimations=Er({},te.prototype)}function BX(t){let e=[];return t?(t.forEach((i,n)=>{let{path:r,keyframes:s}=i.data,a=r[0]==="material"?i.id:void 0;s?.length?s.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:r,layerId:a,index:n}})}):e.push(Lc.placeholderKeyframe(i.id,r,{layerId:a,index:n}))}),e.sort((i,n)=>i.data.time-n.data.time),new Vt(...e.map((i,n)=>({...i,fi:n})))):new Vt}function UX(t){for(let{id:e,data:i}of[...t.unproxy()]){let n=i.path?.[0];if(!n||!sN.includes(n))continue;let r=lA(i.value);if(!r.length)continue;let s=t.data(e);if(!s)continue;let a=i.value,[o,...l]=r;for(let c of l){let h=Ot.generateUUID();t.insertBefore(null,[{id:h,data:{...i,id:h,path:[n,c],value:a[c],easing:zX(i.easing)}}])}s.path=[n,o],s.value=a[o]}}function lA(t){return t===null||typeof t!="object"?[]:Ig.filter(e=>e in t)}function zX(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function FX(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function NX(t){let e=function(s){let a=[];for(let o of Lc.groupKeyframes(s)){let l=new Set(o.keyframes.flatMap(h=>lA(h.data.value))),c=l.size?[...l].map(h=>o.keyframes.filter(u=>lA(u.data.value).includes(h))):[o.keyframes];for(let h of c){let u=[...h].sort((d,p)=>d.data.time-p.data.time);for(let d=0;d+1<u.length;d++)a.push({left:u[d],right:u[d+1]})}}return a}([...t.unproxy()]),i=new Map,n=new Set;for(let{left:s,right:a}of e){let o=s.data.easing?.type,l=(o===void 0?void 0:Lc.presetHandles(o))?.control2??(o===5?Oc(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let c=i.get(a.id);c?FX(c,l)||n.add(a.id):i.set(a.id,l)}let r=new Map;for(let{id:s,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Lc.presetHandles(o);l&&r.set(s,l.control1)}for(let{left:s,right:a}of e)n.has(a.id)&&r.delete(s.id);for(let[s,a]of r){let o=t.data(s);!o?.easing||(o.easing.cubicControls={control1:a,control2:Oc(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:s,right:a}of e){if(!r.has(s.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Oc(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function MO(t,e){t.scene.objects.traverse((i,n)=>{let r=n;if(r.type==="Page"&&r.timelines)for(let s of Object.values(r.timelines))for(let a of Object.values(s.objectTimelines??{}))e(a.keyframes)})}function hA(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function kX(t){}function VX(t){let e=t.schema??0;if(e!==131){if(e>131)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 131). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",131),function(i,n){if(n<1&&(No(i,pO),Fo(i,pO),i.schema=1),n<2&&(function(r){Object.assign(r.scene.publish,{orbitControls:{...H_.defaultData,...hn(r.scene.publish.orbitControls)}})}(i),i.schema=2),n<3&&(function(r){function s(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,c]of Object.entries(o))if((Wb.includes(l)||typeof c=="boolean")&&delete o[l],l==="texture")for(let[h,u]of Object.entries(c))(AC.includes(h)||typeof u=="boolean")&&delete c[h]}}}r.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let c=l;c.material?s(c.material):c.materials&&c.materials.forEach(h=>{s(h)})})})}(i),i.schema=3),n<4&&(function(r){r.scene.publish.withBackground=!0}(i),i.schema=4),n<5&&(function(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),n<6&&(function(r){r.scene.objects.traverse((s,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),n<7&&(function(r){r.scene.objects.traverse((s,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),n<8&&(i.schema=8),n<9&&(mO(i),i.schema=9),n<10&&(function(r){r.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),n<11&&(function(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((s,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),n<12&&(mO(i),i.schema=12),n<13&&(function(r){r.shared.audios=Er({},te.prototype)}(i),i.schema=13),n<14&&(function(r){let s=r.shared.materials;Object.entries(s).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(s,{[a]:l})}})}(i),i.schema=14),n<15&&(function(r){Object.entries(hn(r.shared.images)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete r.shared.images[s]}),Object.entries(hn(r.shared.audios)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete r.shared.audios[s]})}(i),i.schema=15),n<16&&(function(r){r.scene.publish.settings.web.preload=!1}(i),i.schema=16),n<17&&(No(i,gO),Fo(i,gO),i.schema=17),n<18&&(No(i,fO),Fo(i,fO),i.schema=18),n<19&&(function(r){Object.assign(r.scene.publish.settings,{video:{...Jo.defaultData.settings.video,...hn(r.scene.publish.settings.video)}})}(i),i.schema=19),n<20&&(function(r){r.shared.fonts=Er({},te.prototype)}(i),function(r){let s=[];r.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let c=ki.defaultTwoLayerData("phong"),h=typeof l.color=="string"?r.shared.colors[l.color]:l.color;c.layers[1].data.color={r:h.r,g:h.g,b:h.b},c.layers[1].data.alpha=l.alpha;let u=function(f){return f.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(g=>g.charAt(0).toUpperCase()+g.slice(1)).join(" ")}(l.font);r.shared.fonts[u]===void 0&&(r.shared.fonts[u]={name:u});let d={name:l.name,...En.defaultData,...Ha.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ho.defaultData("TextGeometry"),width:l.width,height:l.height,font:u,depth:0,horizontalAlign:l.horizontalAlign,verticalAlign:l.verticalAlign,fontSize:1.40625*l.fontSize,lineHeight:l.lineHeight/1.40625,letterSpacing:l.letterSpacing-1,text:l.text,textTransform:l.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:c,states:hn(l.states),events:hn(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=hn(r.scene.objects).parent(a);r.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:d,children:[]}]),s.push(a)}}),s.forEach(a=>{r.scene.objects.delete(a)})}(i),i.schema=20),n<21&&(function(r){let s={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(s[Number(l.type)])if(Object.assign(l,{type:s[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new Vt,move:new Vt,jump:new Vt}});else{let c=new Vt;Object.assign(l,{actions:c}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&c.push({fi:0,id:Ot.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((h,u,d)=>{let p={easing:h.easing,duration:h.duration};h.easing===6?Object.assign(p,uc(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let f={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},g={state:h.state,...f,...p},m={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Vt({fi:0,id:Ot.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:Ot.generateUUID(),data:g})};c.push({fi:d,id:u,data:m})}),delete l.targets)}})})}(i),function(r){r.scene.objects.traverse((s,a)=>{function o(l,c){let h=new Vt,u=[];if(a.events.forEach((d,p,f)=>{if(d.type==="Audio"&&d.trigger===c){let g;u.push(p),d.interaction==="play"?g={...uc(d,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in d?d.after:void 0,toggle:"after"in d?d.toggle:void 0,type:"Audio"}:(d.interaction==="pause"||d.interaction==="stop")&&(g={...uc(d,"interaction","delay","object","playAudio"),type:"Audio"}),g&&h.push({fi:f,id:p,data:g})}}),u.forEach(d=>a.events.delete(d)),h.length){let d=a.events.find(p=>p.type===l)?.data;d?"actions"in d&&d.actions.insertBefore(null,h):a.events.insertBefore(null,[{id:Ot.generateUUID(),data:{type:l,actions:h}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),n<22&&(_O(i),i.schema=22),n<23&&(function(r){r.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),n<24&&(function(r){r.scene.objects.traverse((s,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(n<25||i.shared.videos===void 0)&&(function(r){r.shared.videos=Er({},te.prototype)}(i),n<25&&(i.schema=25)),n<26&&(function(r){r.scene.objects.traverse((s,a)=>{let o=r.scene.objects.unproxy().parent(s);if(o){let l=hn(r.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=hn(a).booleanExclude!==!0)}})}(i),i.schema=26),n<27&&(function(r){r.scene.objects.traverse((s,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),n<28&&(_O(i),i.schema=28),n<29&&(function(r){function s(o){Object.setPrototypeOf(o,mn.prototype),o.texture&&Object.setPrototypeOf(o.texture,mn.prototype)}function a(o){Object.setPrototypeOf(o,mn.prototype);for(let l in o)s(o[l])}r.scene.objects.traverse((o,l)=>{l.states.forEach(c=>{let h=c;if(h.material){let u=hn(h.material).layers;a(u),h.material.layers=u}if(h.materials)for(let u=0;u<h.materials.length;u++){let d=h.materials[u],p=hn(d).layers;a(p),d.layers=p}})})}(i),i.schema=29),n<30&&(function(r){r.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=ki.defaultTwoLayerData("phong"))})}(i),i.schema=30),n<31&&(function(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.scene.objects.traverse((s,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),n<33&&(function(r){r.scene.objects.traverse((s,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),n<34&&(function(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}(i),i.schema=34),n<35&&(function(r){let{video:s}=r.scene.publish.settings;s.format==="gif"&&s.fps>48&&(s.fps=15)}(i),i.schema=35),n<36&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),n<37&&(function(r){let s=r.scene.environment.usePhysics;r.scene.objects.traverse((a,o)=>{s&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),n<38&&(No(i,vO),Fo(i,vO),i.schema=38),n<39&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=q_.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),n<40&&(function(r){r.scene.styles||(r.scene.styles=bc.defaultData())}(i),i.schema=40),n<41&&(function(r){r.scene.environment.ambientLight.occlusion===void 0&&(r.scene.environment.ambientLight.occlusion=!1),r.scene.environment.ambientLight.aoFullRes===void 0&&(r.scene.environment.ambientLight.aoFullRes=!1),r.scene.environment.ambientLight.radius===void 0&&(r.scene.environment.ambientLight.radius=256),r.scene.environment.ambientLight.bias===void 0&&(r.scene.environment.ambientLight.bias=.5),r.scene.environment.ambientLight.aoColor===void 0&&(r.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),No(r,bO),Fo(r,bO)}(i),i.schema=41),n<42&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new Vt})})})}(i),i.schema=42),n<43&&(function(r){r.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),n<99){No(i,xO),Fo(i,xO),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Zc);let r=hn(i.scene.objects),s=i.scene.objects;i.scene.publish.playPage=qu,s.insertBefore(null,null,[{id:qu,data:{...Ic.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:uc(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:uc(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Yu.defaultData,...uc(i.scene.environment,"usePhysics","gravity")},camera:hn(i.scene.ownerCamera)??Ic.defaultData.camera,name:"Scene"},children:[]}]);for(let l of r)l.id!==xc.TRASH_CAN_ID&&s.move(qu,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,c)=>{c.type==="DirectionalLight"?(c.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):c.type==="SpotLight"&&(c.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(c.physics===void 0||c.physics===null)&&c.type!=="Instance"&&(c.physics={},Object.assign(c.physics,$u.defaultData)),c.physics!==void 0&&c.physics!==null&&(c.physics.enabled=c.collision??"visibility",delete c.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=Jo.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(No(t,wO),Fo(t,wO),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((n,r)=>{let s=r.geometry;s&&s.type==="PathGeometry"&&(s.extrusion.capType="flat",s.extrusion.bevel=50,s.extrusion.bevelSides=6,s.extrusion.shape.type==="Custom"&&(s.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new te,t.shared.lib=Wo.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=Er({},te.prototype)}(t),t.scene.objects.traverse((i,n)=>{eN(n)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))iN(i);e<106&&(function(i){let n=hn(i.shared.variables);i.shared.variables=Er(Object.entries(n??{}).map(([r,s],a)=>({fi:a,id:r,data:s})),Vt.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=Wo.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=Er({},te.prototype),i.shared.lib&&(i.shared.lib.particles=Wo.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((n,r)=>{r.type==="Particle"&&typeof r.renderMaterial.size=="number"&&Object.assign(r.renderMaterial,{size:[r.renderMaterial.size,r.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,n)=>{(function(r){Array.isArray(hn(r.events))&&r.events?.forEach(s=>{"disabled"in s||(s.disabled=!1),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress")&&(s.mode=s.mode||"Object")})})(n)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((n,r)=>{r.type==="Page"&&(r.postprocessing.depthOfField.focusDistance=100,r.postprocessing.depthOfField.focalLength=20,r.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((n,r)=>{Array.isArray(hn(r.events))!==!1&&r.events?.forEach(s=>{let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(o=>{s.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&(l.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,s.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),s.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,s.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):s.type==="Start"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,s.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}),s.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(t),t.schema=113),e<114&&(t.scene.publish.settings.web.imageQuality===void 0&&(t.scene.publish.settings.web.imageQuality=70),t.schema=114),e<115&&(function(i){i.shared.userAPIs=Er({},te.prototype),i.shared.userWebhooks=Er({},te.prototype),i.shared.lib&&(i.shared.lib.userAPIs=Wo.defaultData().userAPIs,i.shared.lib.userWebhooks=Wo.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Jo.defaultData.settings.videoStatic)}(t),t.schema=116),e<117&&(t.scene.publish.settings.web.pixelRatioMobile===void 0&&(t.scene.publish.settings.web.pixelRatioMobile=0),t.scene.publish.settings.web.pixelRatioDesktop===void 0&&(t.scene.publish.settings.web.pixelRatioDesktop=0),t.schema=117),e<118&&(t.shared.timelineAnimations=Er({},te.prototype),t.scene.objects.traverse((i,n)=>{rN(n)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=Zu.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=Zu.defaultData.scene.publish.settings.videoStatic.imageFormat,t.schema=119),e<120&&(t.scene.publish.settings.image.colorSpace="display-p3",t.scene.publish.settings.videoStatic.colorSpace="display-p3",t.schema=120),e<121&&(t.scene.objects.traverse((i,n)=>{hA(n),n.type==="Page"&&n.camera!==void 0&&hA(n.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=Zu.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,n)=>{n.type==="Page"&&n.sky===void 0&&(n.sky=Vl.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&(typeof r.exposure=="number"&&(r.exposure=Math.round(r.exposure/5e-4*1e4)/1e4),r.lighting===void 0&&(r.lighting=Vl.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&r.lightingIntensity===void 0&&(r.lightingIntensity=Vl.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&(r.mode===void 0&&(r.mode="physical"),r.hdri===void 0?r.hdri={...Vl.defaultData.hdri}:(r.hdri.blur===void 0&&(r.hdri.blur=Vl.defaultData.hdri.blur),Array.isArray(r.hdri.rotation)&&(r.hdri.rotation=r.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r?.hdri!==void 0&&r.hdri.showBackground===void 0&&(r.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,n)=>{let r=n.sky;n.type==="Page"&&r!==void 0&&r.lightingQuality===void 0&&(r.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,n)=>{if(n.type==="Page"){n.camera===void 0&&(n.camera=Ic.defaultData.camera);let r=n.camera;r.far=1e5,r.perspective?r.perspective.near=70:r.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(nN(t,X_),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((n,r)=>{let s=r.states;if(!s)return;let a=r.timelineAnimations,o=[];s.forEach((l,c)=>{(l.isAnimation||a?.[c])&&o.push(c)}),o.forEach(l=>s.delete(l))})}(t),function(i){let n=i.shared,r=n.timelineAnimations;if(!r)return;let s=i.scene.objects,a=s.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(r)){let c=Er({},te.prototype),h=0,u=Boolean(l.loop);for(let[f,g]of Object.entries(l.mapping??{})){let m=s.data(f)?.timelineAnimations?.[g];!m||(h=Math.max(h,m.to??0),u=u||Boolean(m.loop),c[f]={id:f,keyframes:BX(m.properties?.unproxy())})}let d=l.page??a,p=d?s.data(d):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=Er({},te.prototype)))[o]={id:o,name:l.name,duration:h||5,...u?{loop:u}:{},objectTimelines:c})}delete n.timelineAnimations,s.traverse((o,l)=>{delete l.timelineAnimations})}(t),MO(t,UX),MO(t,NX),t.schema=131)}}jg(tN,{updateAllMaterials:()=>nN,updateDocumentSchema:()=>VX,updateLibSchema:()=>kX,updateMaterialSchema:()=>OX,updateObjectStateRec:()=>Lu,updateObjectsSchema:()=>iN,updateTextValues:()=>IX});var _c,sN,EO,ov,vS,AO,lv,wc,Df,Od,hv,yS,d1,_S,bS,TO,u1,xS,Bc,cA,$b=z(()=>{et(),KF(),Ye(),JF(),RX(),Xb(),Wg(),Dn(),LC(),qb(),DC(),_c=180/Math.PI,sN=["position","rotation","scale","shape size"]}),jX=z(()=>{var t,e,i;_s(),Ye(),Dn(),(EO||(EO={})).is=function(n){return!0},(t=ov||(ov={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(n,r){return{position:r?.position??n.position,rotation:r?.rotation??n.rotation,scale:r?.scale??n.scale,shear:r?.shear??n.shear}},t.diff=function(n,r){return fF({position:Ja.isEqual(n.position,r.position)?void 0:r.position,rotation:n.rotation===r.rotation?void 0:r.rotation,scale:Ja.isEqual(n.scale,r.scale)?void 0:r.scale,shear:n.shear&&r.shear&&Ja.isEqual(n.shear,r.shear)?void 0:r.shear})},(vS||(vS={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(AO||(AO={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(lv||(lv={})).defaultData={opacity:1,fill:{color:Je.fromHexAndA(Rr,1),enabled:!0},stroke:{color:Je.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Je.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Je.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=wc||(wc={})).newEmpty=function(n,r){return{name:r}},e.patch=function(n,r){if(r===void 0)return n;let s={...n};return Object.assign(s,ov.merge(s,r)),s=function(a,o){if(o===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let h of c)h in l&&h in o&&o[h]!==void 0&&Object.assign(l,{[h]:o[h]});return l}(s,r),s=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(s,r),s},e.toOps=function(n,r){let s,a=[];for(let[o,l]of Object.entries(r))o!=="name"&&(s===void 0&&(s={path:[],props:{},type:0},a.push(s)),s.props[o]=l);return a},(Df||(Df={})).defaultData={...ov.defaultData,...vS.defaultData,states:new Vt,events:new Vt,visible:!0,raycastLock:!1},(Od||(Od={})).defaultData={...Df.defaultData,...lv.defaultData},(hv||(hv={})).defaultData={cornerRadius:[0,0,0,0]},(yS||(yS={})).defaultData={...Od.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(d1||(d1={})).defaultData={...Od.defaultData,...hv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(_S||(_S={})).defaultData={...Od.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(bS||(bS={})).defaultData={...Od.defaultData,type:"path2d",path:"",name:"Path"},(TO||(TO={})).is=function(n){return n.type==="ellipse2d"||n.type==="rectangle2d"||n.type==="text2d"||n.type==="vector2d"||n.type==="path2d"},(u1||(u1={})).defaultData={...Df.defaultData,name:"Group",type:"group2d"},(xS||(xS={})).defaultData=()=>({...Df.defaultData,...hv.defaultData,...lv.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Je.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Je.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(n=>{n.defaultData=function(r){switch(r){case"rectangle2d":case"vector2d":return{...d1.defaultData};case"ellipse2d":return{...yS.defaultData};case"text2d":return{..._S.defaultData};case"path2d":return{...bS.defaultData};case"frame2d":return{...xS.defaultData()};case"group2d":return{...u1.defaultData}}},n.getPivot=function(r){return"width"in r&&"height"in r?[typeof r.width=="number"?.5*r.width:0,typeof r.height=="number"?.5*r.height:0]:[0,0]},n.isResizeable=function(r){return r.type==="rectangle2d"||r.type==="ellipse2d"||r.type==="text2d"||r.type==="frame2d"},n.isAutoLayoutable=function(r){return r.type==="frame2d"&&r.autoLayout!==void 0},n.hasCorners=function(r){return r.type==="rectangle2d"||r.type==="frame2d"}})(Bc||(Bc={})),(i=cA||(cA={})).defaultData={name:"UI",type:"scene2d",objects:new Xn},i.emptyData=function(){return{type:"scene2d",objects:new Xn}}}),GX=z(()=>{EX(),AX(),FF(),NF(),KF(),LF(),DX(),HF(),XF(),DC(),$b(),ZF(),PC(),CC(),kF(),Wg(),GF(),$F(),_s(),Xb(),qb(),IC(),qF(),LC(),OC(),TX(),WF(),BC(),RC(),VF(),jF(),jX()});function Sc(t,e=!1){let i=t[0].index!==null,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new Gt,c=0;for(let h=0;h<t.length;++h){let u=t[h],d=0;if(i!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in u.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(u.attributes[p]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in u.morphAttributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(u.morphAttributes[p])}if(e){let p;if(i)p=u.index.count;else{if(u.attributes.position===void 0)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;p=u.attributes.position.count}l.addGroup(c,p,h),c+=p}}if(i){let h=0,u=[];for(let d=0;d<t.length;++d){let p=t[d].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+h);h+=t[d].attributes.position.count}l.setIndex(u)}for(let h in s){let u=CO(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in a){let u=a[h][0].length;if(u!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){let p=[];for(let g=0;g<a[h].length;++g)p.push(a[h][g][d]);let f=CO(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}}return l}function CO(t){let e,i,n,r=-1,s=0;for(let c=0;c<t.length;++c){let h=t[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=h.itemSize),i!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=h.gpuType),r!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*i}let a=new e(s),o=new Ht(a,i,n),l=0;for(let c=0;c<t.length;++c){let h=t[c];if(h.isInterleavedBufferAttribute){let u=l/i;for(let d=0,p=h.count;d<p;d++)for(let f=0;f<i;f++){let g=h.getComponent(d,f);o.setComponent(d+u,f,g)}}else a.set(h.array,l);l+=h.count*i}return r!==void 0&&(o.gpuType=r),o}var qg=z(()=>{et()});function aN(t){let e=t.points.length/7,i=new Vt;for(let n=0;n<e;n++){let r=7*n,s=t.points[r+0],a=t.points[r+1],o=t.points[r+2],l=t.points[r+3],c=t.points[r+4],h=t.points[r+5],u=t.points[r+6];i.push({fi:n,id:Ot.generateUUID(),data:{roundness:u,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[c,h]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(n=>aN(n))??[]}}function oN(t){let{userData:e,uuid:i,...n}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:c}=a,h=c?.groups,u=c?.attributes??{},d=c?.morphAttributes??{},p=c?.interleavedBuffers,f=c?.arrayBuffers,g=c?.index;u.position!==void 0&&Array.isArray(u.position.array)&&(o=function(y){let v=1/0,_=1/0,b=1/0,x=-1/0,w=-1/0,S=-1/0;for(let A=0;A<y.length;A+=3){let E=y[A],P=y[A+1],T=y[A+2];v=Math.min(v,E),_=Math.min(_,P),b=Math.min(b,T),x=Math.max(x,E),w=Math.max(w,P),S=Math.max(S,T)}return{width:x-v,height:w-_,depth:S-b}}(u.position.array));let m={...l===void 0?{}:l.parameters,data:{attributes:u,morphAttributes:d,interleavedBuffers:p,arrayBuffers:f},...o===void 0?{}:o,type:"NonParametricGeometry"};return g!==void 0&&Object.assign(m.data,{index:g}),h!==void 0&&Object.assign(m.data,{groups:h.map(y=>({...y,materialIndex:y.materialIndex??0}))}),m}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=n.data?.attributes;if(o?.positionWASM===void 0){let c=new Gt;if(o?.position===void 0||o?.faceMap===void 0)return null;let h=o.position.array,u=o.faceMap.array,d=n.data.index.array;c.setAttribute("position",new Nt(h,3)),c.setIndex(new rh(d,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let _={},b=y.getIndex(),x=y.getAttribute("position"),w=b?b.count:x.count,S=0,A=Object.keys(y.attributes),E={},P={},T=[],R=["getX","getY","getZ","getW"],L=["setX","setY","setZ","setW"];for(let $=0,nt=A.length;$<nt;$++){let Q=A[$],rt=y.attributes[Q];E[Q]=new rt.constructor(new rt.array.constructor(rt.count*rt.itemSize),rt.itemSize,rt.normalized);let gt=y.morphAttributes[Q];gt&&(P[Q]||(P[Q]=[]),gt.forEach((at,ht)=>{let ct=new at.array.constructor(at.count*at.itemSize);P[Q][ht]=new at.constructor(ct,at.itemSize,at.normalized)}))}let D=.5*v,U=Math.log10(1/v),V=Math.pow(10,U),k=D*V;for(let $=0;$<w;$++){let nt=b?b.getX($):$,Q="";for(let rt=0,gt=A.length;rt<gt;rt++){let at=A[rt],ht=y.getAttribute(at),ct=ht.itemSize;for(let q=0;q<ct;q++)Q+=~~(ht[R[q]](nt)*V+k)+","}if(Q in _)T.push(_[Q]);else{for(let rt=0,gt=A.length;rt<gt;rt++){let at=A[rt],ht=y.getAttribute(at),ct=y.morphAttributes[at],q=ht.itemSize,lt=E[at],F=P[at];for(let O=0;O<q;O++){let j=R[O],Z=L[O];if(lt[Z](S,ht[j](nt)),ct)for(let I=0,G=ct.length;I<G;I++)F[I][Z](S,ct[I][j](nt))}}_[Q]=S,T.push(S),S++}}let Y=y.clone();for(let $ in y.attributes){let nt=E[$];if(Y.setAttribute($,new nt.constructor(nt.array.slice(0,S*nt.itemSize),nt.itemSize,nt.normalized)),$ in P)for(let Q=0;Q<P[$].length;Q++){let rt=P[$][Q];Y.morphAttributes[$][Q]=new rt.constructor(rt.array.slice(0,S*rt.itemSize),rt.itemSize,rt.normalized)}}return Y.setIndex(T),Y}(c),f=[],g=new Array(u[u.length-1]+1).fill(3),m=p.getIndex().array;for(let y=0,v=u.length;y<v;)u[y]===u[y+1]?(g[u[y]]++,f.push(...new Set(m.slice(3*y,3*y+6))),y+=2):(f.push(...m.slice(3*y,3*y+3)),y++);o.indexWASM={array:f},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:g}}if(o?.positionWASM===void 0||o?.positionWASM.length===0||o?.indexWASM===void 0||o?.indexWASM.length===0||o?.verticesPerFaceWASM===void 0||o?.verticesPerFaceWASM.length===0)return null;let l={type:a,...HX(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let c in o)c==="positionWASM"?l[c]=new Float32Array(o[c].array):c==="indexWASM"?l[c]=new Int32Array(o[c].array):c==="verticesPerFaceWASM"&&(l[c]=new Int8Array(o[c].array));return l.scaleBaked=[1,1,1],l}let r=e.type,s=e.parameters;return r==="VectorGeometry"?(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,width:100,height:100,shape:aN(e.shape),type:r}):r==="LatheGeometry"?{...e.parameters,type:r,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,type:r})}function HX(t){return dA.setFromArray(t),dA.getSize(Dm),{width:Dm.x,height:Dm.y,depth:Dm.z}}var dA,Dm,lN,il,ag,hN,bp,Rf,cv,wS,xp,PO,SS,DO,MS,pp,Sl,Ml,Eo,ES,RO,IO,AS,uA,tl,WX=z(()=>{Ye(),et(),qg(),new At,new qt,new xi,new C,new C,dA=new ci,Dm=new C}),qX=z(()=>{}),XX=z(()=>{Ye(),$b()}),$X=z(()=>{Wg(),[...Wb],new Set(AC)}),Yt=z(()=>{GX(),qX(),PX(),$b(),XX(),JF(),$X(),BC(),Ye()}),al=z(()=>{lN=[3,4,8,9],il=5,ag=3,hN=32}),Xg=z(()=>{et(),bp=t=>{var e;return(e=class extends t{}).geometryHelper=new ga(30,30,30),e}}),$g=z(()=>{et(),Rf=new $o,cv=new vr,wS=new At,xp=(t,e,i,n,r=!1,s=t)=>{let a=e,o=s.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),cv.copy(a.boundingSphere),cv.applyMatrix4(o),i.ray.intersectsSphere(cv)===!1||(wS.copy(o).invert(),Rf.copy(i.ray).applyMatrix4(wS),a.boundingBox!==null&&Rf.intersectsBox(a.boundingBox)===!1))return;let l,c,h,u,d,p,f=a.index,g=a.attributes.position,m=a.drawRange;if(r===!1){for(d=Math.max(0,m.start),p=Math.min(f.count,m.start+m.count);d<p;d+=3)if(c=f.getX(d),h=f.getX(d+1),u=f.getX(d+2),l=y(t,i,Rf,g,c,h,u),l)return l.faceIndex=Math.floor(d/3),void n.push(l)}else{let v=a.attributes.position,_=new C,b=new C,x=new C,w=new C,S=2,A=1/((s.scale.x+s.scale.y+s.scale.z)/3),E=A*A;for(let P=Math.max(0,m.start),T=Math.min(v.count,m.start+m.count)-1;P<T;P+=S){if(_.fromBufferAttribute(v,P),b.fromBufferAttribute(v,P+1),Rf.distanceSqToSegment(_,b,w,x)>E)continue;w.applyMatrix4(s.matrixWorld);let R=i.ray.origin.distanceTo(w);R<i.near||R>i.far||n.push({distance:R,point:x.clone().applyMatrix4(s.matrixWorld),object:t})}}function y(v,_,b,x,w,S,A){let E=new C,P=new C,T=new C,R=new C,L=new C;if(E.fromBufferAttribute(x,w),P.fromBufferAttribute(x,S),T.fromBufferAttribute(x,A),b.intersectTriangle(E,P,T,!1,R)===null)return null;L.copy(R),L.applyMatrix4(v.matrixWorld);let D=_.ray.origin.distanceTo(L);return D<_.near||D>_.far?null:{faceIndex:1,distance:D,point:L.clone(),object:v}}}}),Yb=z(()=>{et(),Xg(),$g(),PO=new C(1,1,1),SS=new C,DO=new C,MS=new qt,pp=class extends bp(Bz){constructor(t,e=15){super(e),this.object=t,this.dummy=new yp,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,e){xp(this.object,pp.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(SS,MS,DO),this.matrix.compose(SS,MS,PO),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),YX=z(()=>{et(),Sl=new C,Ml=new C,Eo=new At,ES=[new C(-1,1,1),new C(-1,-1,1),new C(1,-1,1),new C(1,1,1),new C(-1,1,-1),new C(-1,-1,-1),new C(1,-1,-1),new C(1,1,-1)],RO=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],IO=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],AS=(t,e,i)=>{t.updateEntityBoxSize(Sl,Ml),Eo.copy(e).multiply(t.matrixWorld),Ml.x===0&&Ml.y===0&&Ml.z===0?i.push(new C(Sl.x,Sl.y,Sl.z).applyMatrix4(Eo)):ES.forEach(n=>{i.push(n.clone().multiply(Ml).add(Sl).applyMatrix4(Eo))})},uA=class extends ci{constructor(){super(...arguments),this.matrix=new At,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(e=>e.clone()),this.faces=t.faces.map(e=>e.clone()),this.edges=t.edges.map(e=>e.clone()),this.centerEdges=t.centerEdges.map(e=>e.clone()),this}setFromObjectSize(t,e=!1){t.updateWorldMatrix(!1,e),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new At().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let n=[];if(i===!0){let r=[];t.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s))return Eo.copy(e).multiply(s.matrixWorld),void r.push(new C().applyMatrix4(Eo));AS(s,e,n)}}),n.length===0&&n.push(...r)}else AS(t,e,n);return this.setFromPoints(n)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(Eo.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Ml).multiplyScalar(.5),this.getCenter(Sl),Eo.copy(this.matrix).setPosition(Sl),this.vertices=ES.map(t=>t.clone().multiply(Ml).applyMatrix4(Eo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=RO.map(([t,e])=>new vs(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new C))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=IO.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),$_=z(()=>{tl={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function og(t){return t?.isParticleSystem===!0}function Hc(t){return t?.isHairSystem===!0}function nl(t){return t?.isShapeBlendEntity===!0}function Zb(t){return t?.isPathObject===!0}function as(t){return t?.isObject2D===!0}function Cr(t){return t?.isUIObject===!0}function Bu(t){return t?.isCloner===!0}function Mc(t){return t?.isClone===!0}function p1(t){return t?.isComponentObject===!0}var Li=z(()=>{});function Si(t){UC.add(t)}function Gn(t,e){let i=`${t}:${e}`;mA.has(i)||mA.add(i)}function Y_(t,e){zC.set(t,e)}function TS(t){return zC.get(t)}function wp(t,e){FC.set(t,e)}function CS(t){return FC.get(t)}function pA(t,e){NC.set(t,e)}function cN(t){return NC.get(t)}function fA(){return Kb}var UC,mA,zC,FC,NC,Kb,Z_,ke=z(()=>{UC=new Set,mA=new Set,zC=new Map,FC=new Map,NC=new Map,Kb=null,Z_=null});function dN(t){let e=t.elements;ha.set(e[0],e[1],e[2]),ca.set(e[4],e[5],e[6]),Xa.set(e[8],e[9],e[10])}function uN(){let t=Math.max(ha.lengthSq(),ca.lengthSq(),Xa.lengthSq());ha.lengthSq()>Rm*t?ms.copy(ha).normalize():ms.set(1,0,0),gs.crossVectors(Xa,ms),gs.lengthSq()<=Rm*t&&(gs.copy(ca).addScaledVector(ms,-ca.dot(ms)),gs.lengthSq()<=Rm*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=Rm&&e.set(0,1,0).cross(i),e.normalize()}(gs,ms)),gs.normalize(),Ec.crossVectors(ms,gs)}function pN(t){return dN(t),uN(),fN.makeBasis(ms,gs,Ec)}var ha,ca,Xa,ms,gs,Ec,fN,Rm,Im,dv,Ac,Qb,mN=z(()=>{et(),ha=new C,ca=new C,Xa=new C,ms=new C,gs=new C,Ec=new C,fN=new At,Rm=1e-12,Im=.01}),Yg=z(()=>{et(),mN(),dv=new At,(Ac||(Ac={})).is=function(t){return t&&t.__isSPEObject},Qb=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new At,this.copyPreviousMatrix=!0,this.hiddenMatrix=new At,this.pivotMatrix=new At,this.matrixWorldRigid=new At,this.shearScale=new At,this.shearScaleInv=new At}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(dv.copy(this.parent.matrixWorld).invert()),e.premultiply(dv.copy(this.hiddenMatrix).invert()),e.multiply(dv.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof _i&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let i of this.children)i.updateMatrixWorld(e)}updateWorldMatrix(e,i){let n=this.parent;if(e&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let r of this.children)r.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let n of this.children)Ac.is(n)&&n.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let n of this.children)Ac.is(n)&&n.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(e,i,n){return dN(e),uN(),i.makeBasis(ms,gs,Ec),n.set(ms.dot(ha),ms.dot(ca),ms.dot(Xa),0,gs.dot(ha),gs.dot(ca),gs.dot(Xa),0,Ec.dot(ha),Ec.dot(ca),Ec.dot(Xa),0,0,0,0,1),function(){let r=ha.length(),s=ca.length(),a=Xa.length(),o=Math.max(r,s,a);if(o-r>Im||o-s>Im||o-a>Im)return!0;let l=Im*o*o;return Math.abs(ha.dot(ca))>l||Math.abs(ha.dot(Xa))>l||Math.abs(ca.dot(Xa))>l}()}(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,i){this.updateWorldMatrix(!0,!1);let n=new At().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),n.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof At?e.hiddenMatrix.premultiply(n):e.applyMatrix4(n),e.updateWorldMatrix(!1,!1),this.add(e),i!==void 0&&(this.children.pop(),this.children.splice(i,0,e)),this}copy(e,i=!1){return super.copy(e,i),this.hasNonUniformScale=e.hasNonUniformScale,this}onAfterRender(e,i,n,r,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function OO(t,e,i){return jl.subVectors(e,t),Og.subVectors(e,i),jl.cross(Og).length()<=lg}function gN(t){let e=yA.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(n){let r=n.points,s=[r[0]],a=[new C(...r[0].data.position)];pc.copy(a[0]);for(let y=0;y<r.length-1;y++)jl.fromArray(r[y].data.position),Og.fromArray(r[y+1].data.position),Su.subVectors(jl,pc),Mu.subVectors(jl,Og),Su.cross(Mu).length()>lg&&(s.push(r[y]),a.push(new C().copy(jl)),pc.copy(jl));let o=r[r.length-1];s.push(o),a.push(new C(...o.data.position));let l=n.isClosed,c=s.length-(l?0:1),h=s.length,u=[],d=[];for(let y=0;y<h;y++){let v=s[y].data;u.push(new C(...v.controlPrevious.position)),d.push(new C(...v.controlNext.position))}let p=[];for(let y=0;y<c;y++){let v=y===h-1?0:y+1;p.push(OO(a[y],d[y],a[v])&&OO(a[y],u[v],a[v]))}let f=[];for(let y=0;y<h;y++){let v=s[y].data,_=a[y],b={position:_,prevDir:void 0,nextDir:void 0,controlPrevious:u[y],controlNext:d[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(f.push(b),v.roundness===0||!l&&(y===0||y===h-1))continue;let x=l&&y==0?h-1:y-1,w=l&&y==h-1?0:y+1,S=new C().subVectors(a[x],_).normalize(),A=new C().subVectors(a[w],_).normalize();b.prevDir=S,b.nextDir=A;let E=p[l&&y===0?h-1:y-1],P=p[y];if(E&&P){fc.addVectors(S,A).normalize();let T=pc.crossVectors(fc,S).length()/S.dot(fc);b.tan=T,b.removedLength=v.roundness/T}}for(let y=0;y<c;y++){let v=l&&y===h-1?0:y+1,_=f[y],b=f[v];if(_.removedLength!==0||b.removedLength!==0){let x=_.position.distanceTo(b.position);_.removedLength=Math.min(_.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let g=new Array(2*h).fill(null);for(let y=0;y<c;y++){let v=l&&y===h-1?0:y+1,_=f[y],b=f[v],x=null;if(p[y]){let w=_.position.clone(),S=b.position.clone();(_.removedLength!==0||b.removedLength!==0)&&(_.nextDir&&w.add(pc.copy(_.nextDir).setLength(_.removedLength)),b.prevDir&&S.add(pc.copy(b.prevDir).setLength(b.removedLength))),w.distanceTo(S)>lg&&(x=new Qm(w,w.clone().lerp(S,.3),S.clone().lerp(w,.3),S))}else _.position.distanceTo(b.position)>lg&&(x=new Qm(_.position,_.controlNext,b.controlPrevious,b.position));g[2*y+1]=x}for(let y=0;y<h;y++){let v=f[y];if(v.removedLength===0)continue;let _=v.position,b=v.prevDir.clone().multiplyScalar(v.removedLength).add(_),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(_),w=v.tan*v.removedLength;fc.addVectors(v.prevDir,v.nextDir).normalize(),Su.copy(b).lerp(x,.5);let S=b.distanceTo(x)/2;vA.copy(fc).multiplyScalar(Math.sqrt(Math.pow(w,2)-Math.pow(S,2))).add(Su),f1.copy(fc).multiplyScalar(-w).add(vA);let A=_.distanceTo(f1)/_.distanceTo(Su);Mu.copy(v.prevDir).multiplyScalar(A*_.distanceTo(b)).add(_),gA.copy(Mu).lerp(f1,2);let E=b.clone().lerp(Mu,4/3),P=x.clone().lerp(gA,4/3);g[2*y]=new Qm(b,E,P,x)}let m=new vN;for(let y=0;y<g.length;y++){let v=g[y];v&&m.add(v)}return m}(t);return yA.set(t.points,{isClosed:t.isClosed,curve:i}),i}var vN,lg,jl,Og,pc,fc,Su,f1,Mu,gA,vA,yA,Eu,_A,m1,yN,_N,bN,Be,Wa,LO,BO,If,PS,uv,DS,RS,Jb,bA,Kc,$a,xN=z(()=>{et(),vN=class extends dE{constructor(){super()}getPoints(t=12){let e,i=[],n=this.getCurveLengths(),r=n[n.length-1]/n.length;for(let s=0,a=this.curves;s<a.length;s++){let o=a[s],l=s===0?n[s]:n[s]-n[s-1],c=Math.ceil(t*l/r),h=o.getPoints(c);for(let u=0;u<h.length;u++){let d=h[u];e&&e.equals(d)||(i.push(d),e=d)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},lg=.001,jl=new C,Og=new C,pc=new C,fc=new C,Su=new C,f1=new C,Mu=new C,gA=new C,vA=new C,yA=new WeakMap}),ZX=z(()=>{et(),Eu=new At,_A=new qt,m1=new qt,yN=new xi,_N=new C,bN=new C(0,1,0)}),Wr=z(()=>{et(),Yt(),YX(),Ye(),$_(),Li(),ke(),Yg(),xN(),ZX(),ii(),(Be||(Be={})).is=function(t){return t&&t.__isEntity},Wa=t=>Be.is(t),LO={type:"completeState",isfromEntity:!0},BO=["x","y","z"],If=new C,PS=new C(1,1,1),uv=new qt,DS=new xi,RS=new At,Jb=t=>class extends Qb(t){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.transitionState={settled:!0,state:null},this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new uA,this._recursiveBBox=new uA,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let i=this.children[e];if(Be.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Be.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let e=this;for(;e.data.type!=="Instance";){let i=e.parent;if(!Be.is(i))return;e=i}return e}forInstancesRec(e){this.instances.forEach(i=>{i.disposed||e(i),i.forInstancesRec(e)})}super_Entity(e,i){typeof e=="string"&&(this.uuid=e),this.identity=e,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,i,n=!1){if(this.data.states.length!==0||n){for(let r of this.data.states)Kl.toOps(this.data,r.data).forEach(s=>{let a=M_.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let r=this.data.states.data(e);r&&(this.dataPatched=Kl.patch(this.data,r),Kl.toOps(this.data,r).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}n&&this.updateTransformState(this.dataPatched,i),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,i){e.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{Wa(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(n=>{n.uuid===e&&(i=n)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,n=i.indexOf(this)+1;if(Be.is(i[n]))return i[n];if(Be.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Be.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let i=this;for(;e>0&&i!==null;)i=i.parent,e-=1;return i}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let i=this.parent;for(;i;){if(e===i)return!0;i=i.parent}return!1}countToAccestor(e){let i=0,n=this;for(;n!==e;){if(n===null)return-1;n=n.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Wa(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{Be.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let n of this.children)Wa(n)&&n.isConcreteEntity&&n.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let n of this.children)Wa(n)&&n.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Wa(i)&&i.visible&&i.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,i=!1){return super.copy(e,i),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),this}hasEntityChild(){return this.children.some(e=>Wa(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(n=>{n.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),DE({position:this.position.toArray(),rotation:[this.rotation.x*Ot.RAD2DEG,this.rotation.y*Ot.RAD2DEG,this.rotation.z*Ot.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,n){return i[e].map((r,s)=>n?.shared.getVariable(r,[this.uuid,e,BO[s]])??r)}updateTransformState(e,i){let n=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),n=!0),e.rotation&&(If.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(Ot.DEG2RAD),this.rotation.setFromVector3(If),n=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),n=!0),e.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??Xu.identity)),e.pivot!==void 0||e.pivotRotation!==void 0){if(n=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(If.fromArray(e.pivot).negate(),uv.setFromEuler(DS.fromArray(e.pivotRotation.map(r=>r*Ot.DEG2RAD))).invert(),PS);else if(e.pivot!==void 0)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(e.pivotRotation!==void 0){let r=If.setFromMatrixPosition(this.pivotMatrix);uv.setFromEuler(DS.fromArray(e.pivotRotation.map(s=>s*Ot.DEG2RAD))).invert(),this.pivotMatrix.compose(r,uv,PS)}}return n&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),n}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)Be.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Be.is(e)&&e.disposeRecursively()})}toState(e=[]){return DE({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,i){e!==void 0&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},i,!1)}updateByOp(e,i,n,r){let s=this.data;this.data=i;let a=e,o=ri(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let c={...e.props};if(delete c.name,Object.values(e.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let u=jn.zoom(h,e.path.slice(2));if(u)for(let d in e.props)e.props[d]===void 0&&d in u&&(c[d]=u[d])}}a={...e,props:c,path:e.path.slice(2)}}}}else if(e.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(e.props.name!==void 0&&l.name){let{name:h,...u}=l;l=u}if(e.props.material!==void 0&&"material"in l){let{material:h,...u}=l;l=u}let c=jn.removeOverridden(e.path,e.props,l);a={...e,props:c}}}if(this.updateByPatchedOpBase(a,Kl.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),ri(e.path,["overrides"])){let l=[],c=[...e.path];for(l.push(c[1]),c.splice(0,2);c.length>0&&c[0]==="descendants";)l.push(c[1]),c.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let h of Object.keys(e.props)){l[l.length-1]=h;let u=n.scene.findInstance([this.uuid,...l]);u&&(u.overrideData=e.props[h],u.updateState(ah.apply(u.component.data,u.overrideData),n))}}else{let h=n.scene.findInstance([this.uuid,...l]);if(h){let u=jn.zoom(h.component.data,c);if((e={...e,path:c}).type===0){let d=e.props;if(u)for(let[p,f]of Object.entries(e.props))f===void 0&&(d===e.props&&(d={...e.props}),d[p]=u[p]);e={...e,props:d}}h.overrideData=G_.resolve(i.overrides,l),h.updateByOp(e,er.applySimple(h.data,e),n,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let c;for(let h of Qo.rootOverrideProps)h in e.props&&(c===void 0&&(c={}),c[h]=e.props[h]);c&&(l={...e,props:c})}else for(let c of Qo.rootOverrideProps)if(ri(e.path,[c])){l=e;break}l!==void 0&&this.instances.forEach(c=>{if(c.isInstanceRoot){let h=ah.filterOp(c.overrideData,l);h&&c.updateByOp(h,er.applySimple(c.data,h),n,!0)}}),this.instances.forEach(c=>{if(!c.isInstanceRoot){let h=ah.filterOp(c.overrideData,e);if(h){let u;u=s===c.data&&e===h?i:er.applySimple(c.data,h),c.updateByOp(h,u,n,!0)}}})}}updateByPatchedOpBase(e,i,n){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!jc.is(e.props.type)&&tl.changeEntityProptotype(this,i,n);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){tl.changeEntityProptotype(this,i,n);for(let r of this.children)Be.is(r)&&r.updateVisible(n.scene)}this.updateByPatchedOp(e,i,n)}updateByPatchedOp(e,i,n){if(e.path.length===0&&e.type===0?this.updateState(e.props,n):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,n),e.path[0]==="morphTargetInfluences"&&e.type===0){let r=i.morphTargetInfluences.get(e.path[1])?.data.name;r&&this.updateMorphInfluences(r,n.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",r]))}if(ri(e.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),ri(e.path,["cloner"])!==null){let r=er.drop(e,1);r.path.length===0&&r.type===0&&r.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(i.cloner,n):(this.setFromClonerState(i.cloner,n),this.expandCloner(n)),this.updateVisible(n.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,n=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,r=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=e.find(i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=gN(o.geometry.path),c=function(p){let f=p%1;return f<0?f+1:f===0&&p>0?1:f}(n+r),h=null;try{h=l.curves.length?l.getPointAt(c):null}catch{}if(h===null)return;a.updateMatrixWorld();let u=this.parent?RS.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):RS.copy(this.hiddenMatrix),d=function(p,f,g,m){_A.setFromRotationMatrix(Eu.extractRotation(m));let y=p.clone().applyMatrix4(Eu.copy(m).invert().multiply(g));if(f===null)m1.setFromRotationMatrix(Eu.extractRotation(g));else{let v=f.clone().applyMatrix4(Eu.extractRotation(g));m1.setFromRotationMatrix(Eu.lookAt(_N.set(0,0,0),v,bN))}return{position:y,rotation:new C().setFromEuler(yN.setFromQuaternion(_A.invert().multiply(m1))).multiplyScalar(Ot.RAD2DEG)}}(h,s==="tangential"?l.getTangentAt(c):null,a.matrixWorld,u);this.updateTransformState({position:d.position.toArray(),rotation:d.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(LO)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!e)return;let i=!1;this.traverseEntity(n=>{if(n.data.type==="Splat")return i=!0,!0}),i&&e.reloadSplats()}updateState_Entity(e,i){e.name!==void 0&&(this.name=e.name),e.raycastLock!==void 0&&(this.raycastLock=e.raycastLock),e.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in e&&e.cloner!==void 0&&(this.setFromClonerState(e.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(e,i)}get attachedSurfaceCloners(){return this.children.filter(e=>Bu(e)&&e.parameters.type==="toObject")}setFromClonerState(e,i){if(!this.disposed)if(e===null||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(tl.Cloner===null)return void Gn("cloners","a cloner");this.cloner=new tl.Cloner(this,e),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,i)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),Qc=z(()=>{et(),Wr(),(bA||(bA={})).is=t=>"objectHelper"in t,Kc=(t,e)=>class extends Jb(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,n){this.objectHelper.raycast(i,n)}showGizmos(){for(let i in this.gizmos){let n=this.gizmos[i];n instanceof Eg&&(n.visible=!0)}}updateEntityBoxSize(i,n){this.objectHelper.visible&&this.geometryHelper instanceof ga?(i.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,n)}hideGizmos(){for(let i in this.gizmos){let n=this.gizmos[i];n instanceof Eg&&(n.visible=!1)}}}}),tx=z(()=>{et(),Yb(),Qc(),$a=class extends Kc(yp,pp){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}}});function Qs(t,e,i,n,r,s,a){Om.set(r,s,a).unproject(n);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],Om.x,Om.y,Om.z)}}var Om,cs,UO,wN,KX=z(()=>{et(),Xg(),$g(),Om=new C,cs=new ql,UO=class extends gu{constructor(t){let e=new Gt,i=new zo({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={},a=new Jt(15711266),o=new Jt(15711266),l=new Jt(2857471);function c(u,d,p){h(u,p),h(d,p)}function h(u,d){n.push(0,0,0),r.push(d.r,d.g,d.b),s[u]===void 0&&(s[u]=[]),s[u].push(n.length/3-1)}c("n1","n2",a),c("n2","n4",a),c("n4","n3",a),c("n3","n1",a),c("f1","f2",a),c("f2","f4",a),c("f4","f3",a),c("f3","f1",a),c("n1","f1",a),c("n2","f2",a),c("n3","f3",a),c("n4","f4",a),c("p","n1",o),c("p","n2",o),c("p","n3",o),c("p","n4",o),c("u1","u2",l),c("u2","u3",l),c("u3","u1",l),e.setAttribute("position",new Nt(n,3)),e.setAttribute("color",new Nt(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let t=this.geometry,e=this.pointMap;cs.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;Qs("n1",e,t,cs,-1,-1,i),Qs("n2",e,t,cs,1,-1,i),Qs("n3",e,t,cs,-1,1,i),Qs("n4",e,t,cs,1,1,i);let n=i;Qs("f1",e,t,cs,-1,-1,n),Qs("f2",e,t,cs,1,-1,n),Qs("f3",e,t,cs,-1,1,n),Qs("f4",e,t,cs,1,1,n);let r=n;Qs("u1",e,t,cs,.35,1.1,r),Qs("u2",e,t,cs,-.35,1.1,r),Qs("u3",e,t,cs,0,1.55,r),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},wN=class extends bp(UO){constructor(t){super(t),this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,e){xp(this.object,this.geometry,t,e,!0)}}});function zO(t){return 1-Math.pow(1-t,3)}var $h,pv,fv,mv,Ld,gv,Oa,vn,Hs=z(()=>{et(),KX(),Yt(),Qc(),ii(),$h=new C,pv=new C,fv=new qt,mv=new C,Ld=new C,gv=new C,Oa=class extends Kc(ql,wN){constructor(t="",e={...rg.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=Ko.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let r=this._projectionTransition;if(r===void 0)return;if(this.disposed)return void this._endProjectionTransition();r.raf=requestAnimationFrame(this._tickProjectionTransition);let s=Oa.projectionTransitionRequestRender??r.requestRender;this.updateProjectionMatrix(),s?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new At,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,n=this.height;this.orthoCamera=new cp(-.5*i,.5*i,.5*n,-.5*n,-5e4,1e4),this.perspCamera=new ju(45,i/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(t){let e=Oa.projectionTransitionsEnabled;Oa.projectionTransitionsEnabled=!1;try{return t()}finally{Oa.projectionTransitionsEnabled=e}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(t){this.perspCamera.fov=t}get fov(){return this.perspCamera.fov}setNear(t,e){t==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(t,e){e>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t,e,i){typeof t=="number"&&(t=new C(t,e,i)),super.lookAt(t),this.getWorldPosition($h),this.targetOffset=$h.distanceTo(t)}getTarget(t=new C){return this.getWorldDirection(pv),this.getWorldPosition($h),pv.multiplyScalar(this.targetOffset),t.copy($h).add(pv),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition($h),$h.distanceTo(t)}updateUp(){this.getWorldQuaternion(fv),mv.set(0,0,1).applyQuaternion(fv),Ld.copy(_i.DEFAULT_UP),this.isUpVectorFlipped&&Ld.negate(),Ld.applyQuaternion(fv),gv.copy(_i.DEFAULT_UP).projectOnPlane(mv),this.angleOffsetFromUp=gv.angleTo(Ld),this.angleOffsetFromUp*=gv.cross(Ld).dot(mv)>=0?1:-1}updateTransformState(t,e){let i=super.updateTransformState(t,e);return t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(t){let e=t.getWorldPosition(new C),i=t.getWorldDirection(new C).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new C).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new C;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let n=t>e?this.aspect:1,r=t>e?1:this.aspect;this.left=-395*n,this.right=395*n,this.top=1/r*395,this.bottom=1/r*-395}else this.left=.5*-t,this.right=.5*t,this.top=.5*e,this.bottom=.5*-e;this.updateProjectionMatrix()}copyViewPlaneSize(t){this.aspect=t.aspect,this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let t=this._projectionTransition;if(t===void 0)return 1;let e=(performance.now()-t.start)/t.duration;return e>=1?1:e<=0?0:zO(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Oa.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Oa.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new At,blend:new At,blendInverse:new At,start:0,duration:Oa.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=Oa.projectionTransitionDuration,e.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,t&&(e.requestRender=t),e.raf!==0&&cancelAnimationFrame(e.raf),e.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;let e=(performance.now()-t.start)/t.duration;if(e>=1)return void this._endProjectionTransition();let i=zO(e),n=t.from.elements,r=this._activeSubCamera.projectionMatrix.elements,s=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,n[15]-n[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,r[15]-r[11]*a));for(let c=0;c<16;c++)s[c]=n[c]+(r[c]-n[c])*l;t.blendInverse.copy(t.blend).invert(),this.projectionMatrix=t.blend,this.projectionMatrixInverse=t.blendInverse}_endProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;t.raf!==0&&cancelAnimationFrame(t.raf),this._projectionTransition=void 0;let e=this._activeSubCamera;this.projectionMatrix=e.projectionMatrix,this.projectionMatrixInverse=e.projectionMatrixInverse}_syncProjectionTransition(t){let e=t._projectionTransition;if(e===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new At,blend:new At,blendInverse:new At,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(e.from),i.start=e.start,i.duration=e.duration,i.referenceDepth=e.referenceDepth,this._applyProjectionTransition()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,e,i,n,r,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,n,r,s):this.orthoCamera.setViewOffset(t,e,i,n,r,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,e){return super.copy(t,e),this.parent=t.parent,this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=Ko.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return DE({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},t)}updateCameraSubtype(t,e){let i=t==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(i,e.zoom),e.near!==void 0&&this.setNear(i,e.near),e.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(t,e){this.updateCameraState(t,e)}updateCameraState(t,e){this.updateState_Entity(t,e),t.far!==void 0&&(this.far=t.far),t.orthographic!==void 0&&this.updateCameraSubtype("orthographic",t.orthographic),t.perspective!==void 0&&this.updateCameraSubtype("perspective",t.perspective),t.type!==void 0&&(t.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(e?.shared.requestRender),this.cameraType=t.type),t.up!==void 0&&this.up.fromArray(t.up.map(i=>typeof i=="number"?i:0)),t.targetOffset!==void 0&&(this.targetOffset=Ko.sanitizeTargetOffset(t.targetOffset)),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.type===0&&this.updateCameraSubtype(t.path[0],t.props)}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}},(vn=Oa).projectionTransitionsEnabled=!1,vn.projectionTransitionDuration=350,vn.projectionTransitionMinAgeMs=1e3});function SN(t){return t.type==="TorusGeometry"&&t.arc===360}var MN,vv,xA,Lg=z(()=>{et(),MN=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},t.parameters),n=Math.abs(i.width),r=Math.abs(i.height??n),s=Math.abs(i.depth??n),a=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(i,{width:n,height:r,depth:s,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(t){let{width:e,height:i,depth:n,radius:r,revolutions:s,segments:a,pathRadius:o,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=t.parameters,d=new xA(!1,e,i,n,r,s,a,o,l,c,h,u);return Object.assign(d,{userData:{...t,type:"HelixGeometry"}})}},vv=new rh([0,0,0],1),xA=class extends Gt{constructor(t=!0,e=1,i=1,n=1,r=1,s=1,a=1,o=1,l=1,c=1,h=1,u=1){if(super(),s===0)return;let d=t&&s===1;d&&(u=0),h>100&&(h=100),h===0&&(u=0);let p,f,g,m,y,v,_,b,x=()=>new C,w=new C,S=x(),A=x(),E=x(),P=x(),T=x(),R=x(),L=x(),D=x(),U=x(),V=x(),k=x(),Y=i-2*o+.001,$=Y/s,nt=Math.ceil(a*s),Q=nt+1,rt=Y/nt,gt=-Y/2,at=c+1,ht=2*Math.PI/c,ct=Math.PI/2/u,q=Math.min((1-h/100)*o,o-.01),lt=o-q,F=0,O=2*u+2,j=at*O/2,Z=j+at*Q,I=Math.max(0,at*(Q+O)),[G,W,N]=[3,3,2].map(jt=>Array(I*jt).fill(0)),tt=[],ot=r-o;function pt(jt,Ft){let _e=Math.PI/2;v=Ft*rt,b=2*Math.PI*(v%$)/$+_e,v+=gt,_=Math.sin(b)*ot,y=Math.cos(b)*ot,t?jt.set(y,_,v):jt.set(y,v,_)}pt(w,-1e-10),pt(S,0),P.copy(w),pt(w,1);let ut=w.distanceTo(S),Pt=d?0:lt+q,bt=ut*nt+2*Pt,Rt=q,_t=bt-Pt;for(let jt=0;jt<=nt;jt++){pt(A,jt),k.subVectors(A,P).normalize(),P.copy(A),U.copy(A).setComponent(+t+1,0).normalize(),V.crossVectors(k,U).normalize();let Ft=jt===0,_e=jt===nt,be=Ft?3*Math.PI/2:ct,Vi=Ft?Rt:_t,oe=Ft?at:Z,le=Ft?0:I-at,Pe=k.clone().multiplyScalar(Ft?-lt:lt).add(A),si=k.clone().multiplyScalar(Ft?-1:1).normalize();for(let ze=0;ze<at;ze++){let Pi=ze*ht;if(T.addVectors(w.copy(U).multiplyScalar(o*Math.cos(Pi)),S.copy(V).multiplyScalar(o*Math.sin(Pi))),R.copy(T).normalize(),Ft||_e){d||(F=le+ze,[0,1,2].forEach(ui=>{G[3*F+ui]=Pe.getComponent(ui),W[3*F+ui]=si.getComponent(ui)}),N[2*F]=+_e,N[2*F+1]=ze/c),S.copy(R).multiplyScalar(q),E.addVectors(A,S);for(let ui=0;ui<u;ui++){let en=ui*ct+be;L.addVectors(w.copy(k).multiplyScalar(lt*Math.sin(en)),S.copy(R).multiplyScalar(lt*Math.cos(en))),D.copy(L).normalize(),S.addVectors(E,L),L.normalize(),F=oe+ui*at+ze,[0,1,2].forEach(yn=>{G[3*F+yn]=S.getComponent(yn),W[3*F+yn]=D.getComponent(yn)});let Kr=+Ft+Math.sin(en);N[2*F]=(Vi+lt*Kr)/bt,N[2*F+1]=ze/c}}S.addVectors(A,T),F=j+jt*at+ze,[0,1,2].forEach(ui=>{G[3*F+ui]=S.getComponent(ui),W[3*F+ui]=R.getComponent(ui)}),N[2*F]=(Pt+jt*ut)/bt,N[2*F+1]=ze/c}}let X=Q+2*u+2,[vt,Dt]=[+d,X-1];for(let jt=vt;jt<=Dt-1;jt++){let Ft=d&&jt===Dt-1;for(let _e=0;_e<at-1;_e++)p=jt*at+_e,f=p+1,g=(Ft?_e:p)+at,m=(Ft?_e+1:f)+at,jt===0?tt.push(f,m,g):jt===X-2?tt.push(p,f,g):tt.push(p,f,g,f,m,g)}this.setIndex(tt),this.setAttribute("position",new Nt(G,3)),this.setAttribute("normal",new Nt(W,3)),this.setAttribute("uv",new Nt(N,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,n,r=this.userData.parameters,s=Math.ceil(r.tubularSegments),a=r.radialSegments,o=a+1,l=[];for(let c=1;c<s;c++)for(let h=0;h<a;h++)t=c*o+h,e=t+1,i=t+o,n=e+o,l.push(t,e,i,e,n,i);for(let c=0;c<a;c++)t=s*o+c,e=t+1,i=c+o,n=c+1+o,l.push(t,e,i,e,n,i);return vv.array=new Uint32Array(l),vv.count=l.length,vv}}});function QX(t){return NO||(NO=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.44/build",i=import("./boolean.js"),[n,r]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(s=>s.arrayBuffer())]);await n.default({module_or_path:r}),Bg=n}())}function K_(){if(Bg===void 0)throw new Error("boolean-wasm is not loaded");return Bg}function kC(t){let e=Ug.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function VC(t){return Ug.set(++wA,t),wA}function JX(t,e,i){if(Bg===void 0)return-1;let{positions:n,indices:r,normals:s}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,f=[];for(let g=0,m=0;g<p.verticesPerFace.length;g++){let y=p.verticesPerFace[g];for(let v=1;v<y-1;v++)f.push(p.indices[m],p.indices[m+v],p.indices[m+v+1]);m+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(f)}}let l;l=SN(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let c,h=a.getAttribute("position");if(l===null){c=new Uint32Array(h.count);for(let p=0;p<c.length;p++)c[p]=p}else c=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let u=a.getAttribute("normal"),d=u!==void 0&&u.itemSize===3&&u.count===h.count&&u.array instanceof Float32Array&&u.isInterleavedBufferAttribute!==!0?u.array:void 0;return{positions:h.array,indices:c,normals:d}}(t,e);return VC(new Bg.CsgMesh(n,r,s))}function FO(t,e){let i=K_(),n=AN[e];if(n===void 0)throw new Error("Unknown boolean operation "+e);let r=t.map(kC);if(r.length===1)return i.clone_mesh(r[0]);let s,a=[];if(e===2&&r.length>2){let o=r[0];for(let l=1;l<r.length-1;l++)o=i.boolean_mesh(o,r[l],0),a.push(o);s=i.boolean_mesh(r[r.length-1],o,2)}else if(e===2)s=i.boolean_mesh(r[1],r[0],2);else{let o=r[r.length-1];for(let l=0;l<r.length-1&&(o=i.boolean_mesh(o,r[l],n),a.push(o),o.tri_count()!==0);l++);s=o,a.pop()}for(let o of a)o.free();return s}function IS(t,e){kC(t).transform(new Float32Array(e.elements))}function EN(t){let e=Ug.get(t);e!==void 0&&(e.free(),Ug.delete(t))}var Bg,Ug,wA,NO,AN,ex=z(()=>{et(),Lg(),Ug=new Map,wA=0,AN={0:0,1:1,2:2}});function Yh(t){return t!==null&&"booleanOp"in t}var SA,TN,t$=z(()=>{et(),Wr(),ex(),SA=class extends Jb(wi){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new At}updateVisible(t){super.updateVisible(t),this.visible=!Yh(this.parent)&&this.visible,Yh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){Yh(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(EN(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Yh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof SA&&(t.freeBooleanPointer(),Yh(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&Yh(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),Yh(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),e$=z(()=>{TN=null});function jC(t,e=0,i=t.count,n,r){let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0;for(let u=e;u<i;u++){let d=t.getX(u),p=t.getY(u),f=t.getZ(u);d<s&&(s=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>c&&(c=p),f>h&&(h=f)}Lm.min.set(s,a,o),Lm.max.set(l,c,h),Lm.getCenter(n),Lm.getSize(r).multiplyScalar(.5)}var Lm,kO,VO,Xi,Kn=z(()=>{et(),t$(),e$(),Lm=new ci,kO=new Gt,VO=new Gs,Xi=class extends SA{constructor(t,e){super(kO,VO),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){let i=TN;i===null?super.raycast(t,e):i(this,t,e)}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?jC(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function Q_(t){return t?.isClassicNodeMaterial===!0}var gn,zg,CN,PN,hg,DN,RN,IN,GC=z(()=>{}),ya=z(()=>{et(),gn=class extends Jt{constructor(t,e,i,n){super(t,e,i),this.isColorA=!0,this.a=n}setRGBA(t,e,i,n){super.setRGB(t,e,i),this.a=n}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(t){return super.equals(t)&&this.a===t.a}setStyle(t,e="srgb"){let i;if(t==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(t)){let n,r=i[1],s=i[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=r==="rgba"?parseFloat(n[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=r==="hsla"?parseFloat(n[4]):1,super.setStyle(t,e)}}return super.setStyle(t,e)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}}}),ON=z(()=>{ya(),zg=class extends gn{}}),i$=z(()=>{CN=class{constructor(t=1e4){this.timeout=t,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let i=e;e=e.next,e.prev=this.head,this.head.next=e,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),i=this.cache.get(t);return i===void 0?(i={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,i)):(i.time=e,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),LN=z(()=>{i$(),PN=class extends CN{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),BN=z(()=>{DN=class{constructor(t,e){this.data=t,this.cache=e,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},RN=class{constructor(){this.cache=new Map}remove(t){this.cache.delete(t.data)}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}}}),n$=z(()=>{et(),IN=class extends Mz{constructor(t){super(t),this.type=$n}parse(t){let e=function(p,f){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(p,f,g){f=f||1024;let m=p.pos,y=-1,v=0,_="",b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(m,m+128)));for(;0>(y=b.indexOf(`
4163
4163
  `))&&v<f&&m<p.byteLength;)_+=b,v+=b.length,m+=128,b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(m,m+128)));return-1<y&&(g!==!1&&(p.pos+=v+y+1),_+b.slice(0,y))},n=function(p,f,g,m){let y=p[f+3],v=Math.pow(2,y-128)/255;g[m+0]=p[f+0]*v,g[m+1]=p[f+1]*v,g[m+2]=p[f+2]*v,g[m+3]=1},r=function(p,f,g,m){let y=p[f+3],v=Math.pow(2,y-128)/255;g[m+0]=Wl.toHalfFloat(Math.min(p[f+0]*v,65504)),g[m+1]=Wl.toHalfFloat(Math.min(p[f+1]*v,65504)),g[m+2]=Wl.toHalfFloat(Math.min(p[f+2]*v,65504)),g[m+3]=Wl.toHalfFloat(1)},s=new Uint8Array(t);s.pos=0;let a,o,l,c=function(p){let f,g,m=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,v=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,b=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,x={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};for((p.pos>=p.byteLength||!(f=i(p)))&&e(1,"no header found"),(g=f.match(m))||e(3,"bad initial token"),x.valid|=1,x.programtype=g[1],x.string+=f+`
4164
4164
  `;f=i(p),f!==!1;)if(x.string+=f+`
4165
4165
  `,f.charAt(0)!=="#"){if((g=f.match(y))&&(x.gamma=parseFloat(g[1])),(g=f.match(v))&&(x.exposure=parseFloat(g[1])),(g=f.match(_))&&(x.valid|=2,x.format=g[1]),(g=f.match(b))&&(x.valid|=4,x.height=parseInt(g[1],10),x.width=parseInt(g[2],10)),2&x.valid&&4&x.valid)break}else x.comments+=f+`
4166
4166
  `;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(s),h=c.width,u=c.height,d=function(p,f,g){let m=f;if(m<8||m>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);m!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*f*g);y.length||e(4,"unable to allocate buffer space");let v=0,_=0,b=4*m,x=new Uint8Array(4),w=new Uint8Array(b),S=g;for(;S>0&&_<p.byteLength;){_+4>p.byteLength&&e(1),x[0]=p[_++],x[1]=p[_++],x[2]=p[_++],x[3]=p[_++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=m)&&e(3,"bad rgbe scanline format");let A,E=0;for(;E<b&&_<p.byteLength;){A=p[_++];let T=A>128;if(T&&(A-=128),(A===0||E+A>b)&&e(3,"bad scanline data"),T){let R=p[_++];for(let L=0;L<A;L++)w[E++]=R}else w.set(p.subarray(_,_+A),E),E+=A,_+=A}let P=m;for(let T=0;T<P;T++){let R=0;y[v]=w[T+R],R+=m,y[v+1]=w[T+R],R+=m,y[v+2]=w[T+R],R+=m,y[v+3]=w[T+R],v+=4}S--}return y}(s.subarray(s.pos),h,u);switch(this.type){case $e:l=d.length/4;let p=new Float32Array(4*l);for(let g=0;g<l;g++)n(d,4*g,p,4*g);a=p,o=$e;break;case $n:l=d.length/4;let f=new Uint16Array(4*l);for(let g=0;g<l;g++)r(d,4*g,f,4*g);a=f,o=$n;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:u,data:a,header:c.string,gamma:c.gamma,exposure:c.exposure,type:o,colorSpace:Vu,minFilter:de,magFilter:de,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function jO(t){return t.length>2&&t[0]===35&&t[1]===63}var GO,HC,qo,r$=z(()=>{et(),n$()}),UN=z(()=>{et(),LN(),BN(),r$(),GO=0,HC=class extends DN{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++GO,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=t.type==="video",this.isBuffer=t.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?t:t.data)}async updateSrc(t){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let e=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let r of Object.values(n))for(let s of Object.values(r))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=t,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof t!="string"){let n,r=new FileReader;r.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(s=>{r.onloadend=a=>{n=a.target?.result,s(null)}}),this.img.src=n}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?jO(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let n=t instanceof Uint8Array?t:null;if(n===null)try{n=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{n=null}let r=n!==null&&jO(n)?function(s){try{let a=new IN().parse(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,c=a.data,h=new Uint16Array(c.length),u=4*o,d=g=>Wl.toHalfFloat(Math.pow(Math.max(Wl.fromHalfFloat(g),0),1/2.2)),p=new Map,f=g=>{let m=p.get(g);return m===void 0&&(m=d(g),p.set(g,m)),m};for(let g=0;g<l;g++){let m=g*u,y=(l-1-g)*u;for(let v=0;v<u;v+=4)h[y+v]=f(c[m+v]),h[y+v+1]=f(c[m+v+1]),h[y+v+2]=f(c[m+v+2]),h[y+v+3]=c[m+v+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(n):null;r!==null&&(this.isHdr=!0,this.img=r,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:(hg||(hg=new PN),hg.load(i)),this.img.onload=e,await new Promise(n=>{this.img.onload=()=>{e(),n(null)}});var i}getTexture(t,e=1008,i=1006){let n=this._cache[t]?.[e]?.[i];if(n)return n;{let r;return this.isBuffer?r=this.img.texture:this.isVideo?r=new gz(this.img,void 0,t,t):this.isHdr?(r=function(s){let a=new Cn(s.data,s.width,s.height,qi,$n);return a.flipY=!1,a.image.isSplineHdr=!0,a.needsUpdate=!0,a}(this.img),r.wrapS=t,r.wrapT=t,r.magFilter=i,r.minFilter=e):r=new zi(this.img,void 0,t,t,i,e),this.isBuffer||(r.anisotropy=8,r.generateMipmaps=e===1008),this.loaded&&(r.needsUpdate=!0),this._cache[t]===void 0&&(this._cache[t]={}),this._cache[t][e]===void 0&&(this._cache[t][e]={}),this._cache[t][e][i]=r,r}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let n of Object.values(i))n&&(n.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,n]of Object.entries(e))for(let[r,s]of Object.entries(n))s?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][r]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),WC=z(()=>{UN(),qo=class extends HC{}});function s$(t){if(typeof t=="string")return t;let e=MA.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},MA.set(t,e)),e.url}var MA,a$=z(()=>{MA=new Map});function o$(){if(!EA)return HO||(HO=async function(){await Promise.resolve().then(()=>(mP(),l9)),zN(window!==void 0?window:global),EA=!0}())}var zN,FN,EA,HO,NN=z(()=>{FN=new Promise(t=>{zN=t}),EA=!1});function WO(t,e){t.forEach(i=>{"dragDropActions"in i.data?(e.push(...i.data.dragDropActions.drag),e.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(e.push(...i.data.inActions),e.push(...i.data.outActions)):"gameActions"in i.data?(e.push(...i.data.gameActions.idle),e.push(...i.data.gameActions.move),e.push(...i.data.gameActions.jump),e.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(n=>{e.push(...n.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(n=>{n.data.type==="Conditional"&&n.data.ifActions&&(e.push(...n.data.ifActions),e.push(...n.data.elseActions))}))})}function l$(t){let e=!1,i=[];return t.scene.objects.traverse((n,r)=>{if(r.type==="Page"&&r.uiScene!==void 0&&r.uiScene.objects.traverse((s,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;WO(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),r.events===void 0||Array.isArray(r.events)===!1)return!0;WO(r.events,i),e=e||i.some(s=>s.data.type==="Audio")}),e}var qO,Uu,qC=z(()=>{a$(),NN(),FN.then(t=>qO=t),Uu=class{constructor({src:t,volume:e,delay:i,loop:n}){let r;this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)},r=typeof t=="string"?{src:t}:{src:s$(t),format:"wav"},this.sound=new qO.Howl(r),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),n!==void 0&&(this.loop=n)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,i){this.sound.on(t,e,i)}off(t,e,i){this.sound.off(t,e,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function XO(t){let e=!1;return t.scene.objects.traverse((i,n)=>{n.type==="Mesh"&&(n.geometry.type==="TextGeometry"||n.geometry.type==="InputGeometry")&&(e=!0)}),e}var XC,$C=z(()=>{XC=null});function $O(t){return new it(t.y,-t.x)}var YC,AA,kN,VN,yv,YO,J_,jN,OS,tb=z(()=>{et(),YC=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,n=t.parameters?.radiusBottom,r=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);r.thetaLength=Ot.clamp(r.thetaLength,0,360),r.hollow=Ot.clamp(r.hollow??0,0,1);let s=r.width/2,a=r.radiusTop??s,o=r.radiusBottom??s;if(a===o?(a=s,o=s):a>o?(a=s,o=o*s/a):(a=a*s/o,o=s),r.shapeBlendNode){a=i??s,o=n??s;let l=2*Math.max(a,o);r.width=l,r.depth=l}return{parameters:Object.assign(r,{width:Math.abs(r.width),height:Math.abs(r.height??r.width),depth:Math.abs(r.depth??r.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:n,height:r,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:c,radiusTop:h,radiusBottom:u,cornerRadius:d,cornerSegments:p,hollow:f}=t.parameters;c===0?(e=new Gt,e.setAttribute("position",new Nt([],3))):e=d||f?new AA(h,u,r,s,a,o,l,c*Math.PI/180,d,d,p,f):new Km(h,u,r,s,a,o,l,c*Math.PI/180);let g=n/i;return g!==1&&e.scale(1,1,g),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},AA=class extends Gt{constructor(t,e,i,n,r,s,a,o,l,c,h,u,d=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,n=Math.floor(n)||8,r=Math.floor(r)||1,s=s!==void 0&&s,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,s&&(l=0,c=0);let p=i/2;d&&t==0&&(t=l),d&&e==0&&(e=c);let f=new it(t,p),g=new it(e,-p),m=null,y=null,v=null,_=null,b=f.clone().sub(g),x=0,w=0,S=0;u>0&&(x=Math.min(t,e)*(1-u),w=t-x,S=e-x);let A=f.clone();A.x-=x;let E=Math.PI-b.angle(),P=b.angle(),T=Math.tan(P/2),R=Math.tan(E/2),L=T+R,D=u?L:R,U=u?L:T;if(l=Math.min(l,(t-w)/D,b.length()/L),c=Math.min(c,(e-S)/U,b.length()/L),l>0){let tt=l/T;m=f.clone().sub(new it(tt,l)),u&&(v=m.clone(),v.x-=x-L*l),f.sub(b.clone().setLength(tt))}if(c>0){let tt=c/R;y=g.clone().sub(new it(tt,-c)),g.add(b.clone().setLength(tt)),u&&(_=y.clone(),_.x-=x-L*c,A.sub(b.clone().setLength(tt)))}b=f.clone().sub(g);let V=b.length()<.5,k=[],Y=[],$=[],nt=[],Q=[],rt=[],gt=(tt,ot,pt,ut,Pt)=>{for(let bt=0;bt<h+1;bt++){let Rt=bt/h,_t=ut<0?Rt:1-Rt;Pt&&(_t-=1),_t*=tt;let X=Math.sin(_t),vt=Math.cos(_t)*ut,Dt=vt*ot+pt.y;k.push(X*ot+pt.x),Y.push(Dt),$.push(X),nt.push(vt),Q.push(.5+Dt/i),rt.push(!1)}},at=(tt,ot,pt)=>{let ut=[tt,ot];pt<0&&ut.reverse();for(let Pt of ut)k.push(Pt),Y.push(p*pt),$.push(0),nt.push(pt),Q.push(.5),rt.push(!0)};if(_&&y?(gt(E,c,_,-1,!0),gt(P,c,y,-1,!1)):y?(at(y.x,0,-1),gt(P,c,y,-1,!1)):s||at(e,S,-1),!V){let tt=$O(b).normalize();for(let ot=0;ot<=r;ot++){let pt=ot/r,ut=b.y*pt+g.y;k.push(b.x*pt+g.x),Y.push(ut),$.push(tt.x),nt.push(tt.y),Q.push(.5+ut/i),rt.push(!1)}}if(v&&m?(gt(E,l,m,1,!1),gt(P,l,v,1,!0)):m?(gt(E,l,m,1,!1),at(m.x,0,1)):s||at(t,w,1),u&&!V){let tt=$O(b).multiplyScalar(-1).normalize();for(let ot=0;ot<=r;ot++){let pt=ot/r,ut=b.y*-pt+A.y;k.push(b.x*-pt+A.x),Y.push(ut),$.push(tt.x),nt.push(tt.y),Q.push(.5+ut/i),rt.push(!1)}}let ht=k.length,ct=ht+(u&&!s?1:0),q=(tt,ot)=>tt*ht+(ot===ht?0:ot),lt=o<2*Math.PI,F=(n+1)*ht+(lt?2*(1+ct):0),O=new Float32Array(3*F),j=new Float32Array(3*F),Z=new Float32Array(2*F),I=F-1>65535?new Uint32Array(n*Math.max(0,ct-1)*6+(lt?2*(ct+1)*3:0)):new Uint16Array(n*Math.max(0,ct-1)*6+(lt?2*(ct+1)*3:0)),G=0,W=0;for(let tt=0;tt<=n;tt++){let ot=tt/n,pt=ot*o+a,ut=Math.sin(pt),Pt=Math.cos(pt);for(let bt=0;bt<ht;bt++){let Rt=3*W,_t=2*W,X=k[bt],vt=$[bt];O[Rt]=X*ut,O[Rt+1]=Y[bt],O[Rt+2]=X*Pt,j[Rt]=vt*ut,j[Rt+1]=nt[bt],j[Rt+2]=vt*Pt,rt[bt]?(Z[_t]=.5,Z[_t+1]=.5):(Z[_t]=ot,Z[_t+1]=Q[bt]),W++}}for(let tt=0;tt<n;tt++)for(let ot=0;ot<ct-1;ot++){if(s&&u&&ot==r)continue;let pt=q(tt,ot),ut=q(tt+1,ot),Pt=q(tt+1,ot+1),bt=q(tt,ot+1),Rt=O[3*Pt+0],_t=O[3*Pt+2];I[G++]=pt,I[G++]=ut,I[G++]=bt,(Rt!=0||_t!=0)&&(I[G++]=ut,I[G++]=Pt,I[G++]=bt)}function N(tt,ot,pt){let ut=Math.sin(pt),Pt=Math.cos(pt),bt=-Pt,Rt=ut,_t=tt<0?(Ft,_e,be)=>{I[G++]=Ft,I[G++]=_e,I[G++]=be}:(Ft,_e,be)=>{I[G++]=Ft,I[G++]=be,I[G++]=_e},X=(t+e+w+S)/4,vt=3*W,Dt=2*W;O[vt]=X*ut,O[vt+1]=0,O[vt+2]=X*Pt,j[vt]=bt,j[vt+1]=0,j[vt+2]=Rt,Z[Dt]=.5,Z[Dt+1]=.5;let jt=W++;for(let Ft=0;Ft<ct;Ft++){let _e=3*(ot+(Ft===ht?0:Ft));vt=3*W,Dt=2*W,O[vt]=O[_e],O[vt+1]=O[_e+1],O[vt+2]=O[_e+2],j[vt]=bt,j[vt+1]=0,j[vt+2]=Rt;let be=_e/3*2|0;Z[Dt]=Z[be],Z[Dt+1]=Z[be+1],W++}for(let Ft=jt+1;Ft<W-1;Ft++)_t(jt,Ft,Ft+1);_t(jt,W-1,jt+1)}lt&&(N(-1,0,a),N(1,n*ht,a+o)),this.setIndex(new Ht(I.slice(0,G),1)),this.setAttribute("position",new Ht(O,3)),this.setAttribute("normal",new Ht(j,3)),this.setAttribute("uv",new Ht(Z,2))}}}),ZO=z(()=>{et(),tb(),kN=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},t.parameters);return i.thetaLength=Ot.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,depth:n,height:r,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:c,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:d}=t.parameters;c===0?(e=new Gt,e.setAttribute("position",new Nt([],3))):e=h>0||u>0||c<360?new AA(0,i/2,r,s,a,o,l,c*Math.PI/180,h,u,d,0,!0):new y_(i/2,r,s,a,o);let p=n/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),KO=z(()=>{et(),VN=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,height:n,depth:r,widthSegments:s,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:c}=t.parameters;return e=l===0?new ga(i,n,r,s,a,o):new YO(i,n,r,s,a,o,l,c),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},yv=Math.PI/2,YO=class extends Gt{constructor(t=1,e=1,i=1,n=1,r=1,s=1,a=0,o=4){super(),this.type="BoxGeometry",n=Math.floor(n),r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,c=o+1,h=2*((s+1)*(r+1)+(n+1)*(s+1)+(n+1)*(r+1))+(l?4*c*(s+1+(n+1)+(r+1))+c*(c+1)/2*8:0),u=2*(s*r+n*s+n*r)+(l?4*o*(s+n+r):0),d=l?8*o*o:0,p=new Float32Array(3*h),f=new Float32Array(3*h),g=new Float32Array(2*h),m=h-1>65535?new Uint32Array(6*u+3*d):new Uint16Array(6*u+3*d),y=0,v=0,_=new Float64Array(c),b=new Float64Array(c),x=new Float64Array(c),w=new Float64Array(c);for(let L=0;L<c;L++){let D=L/o*yv;_[L]=Math.sin(D)*a,b[L]=(1-Math.cos(D))*a,x[L]=Math.sin(D),w[L]=Math.cos(D)}let S=c*(c+1)/2,A=new Float64Array(3*S),E=new Float64Array(3*S);{let L=new C(t/2,e/2,i/2);L.subScalar(a);let D=0;for(let U=0;U<=o;U++){let V=yv*(1-U/o),k=Math.cos(V),Y=Math.sin(V),$=0;for(let nt=0;nt<=U;nt++){let Q=k*Math.cos($),rt=Y,gt=k*Math.sin($);A[3*D]=Q,A[3*D+1]=rt,A[3*D+2]=gt,E[3*D]=L.x+Q*a,E[3*D+1]=L.y+rt*a,E[3*D+2]=L.z+gt*a,D++,$+=yv/U}}}function P(L,D,U,V,k,Y,$,nt,Q,rt){let gt=(Y-2*a)/Q,at=($-2*a)/rt,ht=Y/2-a,ct=$/2-a,q=nt/2,lt=Q+1,F=rt+1,O=0,j=new C;for(let Z=0;Z<F;Z++){let I=Z*at-ct;for(let G=0;G<lt;G++){let W=G*gt-ht,N=3*(y+O),tt=2*(y+O);j[L]=W*V,j[D]=I*k,j[U]=q,p[N]=j.x,p[N+1]=j.y,p[N+2]=j.z,j[L]=0,j[D]=0,j[U]=nt>0?1:-1,f[N]=j.x,f[N+1]=j.y,f[N+2]=j.z,g[tt]=G/Q,g[tt+1]=1-Z/rt,O+=1}}for(let Z=0;Z<rt;Z++)for(let I=0;I<Q;I++){let G=y+I+lt*Z,W=y+I+lt*(Z+1),N=y+(I+1)+lt*(Z+1),tt=y+(I+1)+lt*Z;m[v++]=G,m[v++]=W,m[v++]=tt,m[v++]=W,m[v++]=N,m[v++]=tt}y+=O}function T(L,D,U,V,k,Y,$,nt,Q,rt){let gt=($-2*a)/rt,at=$/2-a,ht=nt/2-a,ct=Q/2,q=rt+1,lt=0,F=new C,O=new C;for(let j=0;j<o+1;j++){F[D]=(ht+_[j])*k,F[U]=(ct-b[j])*Y,O[L]=0,O[D]=x[j]*Math.sign(F[D]),O[U]=w[j]*Math.sign(F[U]);for(let Z=0;Z<q;Z++){let I=Z*gt-at;F[L]=I*V;let G=3*(y+lt),W=2*(y+lt);p[G]=F.x,p[G+1]=F.y,p[G+2]=F.z,f[G]=O.x,f[G+1]=O.y,f[G+2]=O.z,g[W]=Z/rt,g[W+1]=0,lt+=1}}for(let j=0;j<o;j++)for(let Z=0;Z<rt;Z++){let I=y+Z+q*j,G=y+Z+q*(j+1),W=y+(Z+1)+q*(j+1),N=y+(Z+1)+q*j;m[v++]=I,m[v++]=G,m[v++]=N,m[v++]=G,m[v++]=W,m[v++]=N}y+=lt}function R(L,D,U){let V=L*D*U>0?(Y,$,nt)=>{m[v++]=Y,m[v++]=$,m[v++]=nt}:(Y,$,nt)=>{m[v++]=Y,m[v++]=nt,m[v++]=$},k=y;for(let Y=0;Y<S;Y++){let $=3*Y,nt=3*y,Q=2*y;p[nt]=L*E[$],p[nt+1]=D*E[$+1],p[nt+2]=U*E[$+2],f[nt]=L*A[$],f[nt+1]=D*A[$+1],f[nt+2]=U*A[$+2],g[Q]=0,g[Q+1]=0,y++}for(let Y=0;Y<o;Y++){let $=k+Y*(Y+1)/2,nt=k+(Y+1)*(Y+2)/2;V($,nt+1,nt);for(let Q=1;Q<=Y;Q++)V($+Q-1,$+Q,nt+Q),V($+Q,nt+Q+1,nt+Q)}}P("z","y","x",-1,-1,i,e,t,s,r),P("z","y","x",1,-1,i,e,-t,s,r),P("x","z","y",1,1,t,i,e,n,s),P("x","z","y",1,-1,t,i,-e,n,s),P("x","y","z",1,-1,t,e,i,n,r),P("x","y","z",-1,-1,t,e,-i,n,r),a>0&&(T("z","y","x",-1,-1,1,i,e,t,s),T("z","y","x",1,-1,-1,i,e,t,s),T("z","y","x",-1,1,-1,i,e,t,s),T("z","y","x",1,1,1,i,e,t,s),T("x","y","z",-1,-1,-1,t,e,i,n),T("x","y","z",1,-1,1,t,e,i,n),T("x","y","z",-1,1,1,t,e,i,n),T("x","y","z",1,1,-1,t,e,i,n),T("y","x","z",-1,-1,1,e,t,i,r),T("y","x","z",1,-1,-1,e,t,i,r),T("y","x","z",1,1,1,e,t,i,r),T("y","x","z",-1,1,-1,e,t,i,r),R(1,1,1),R(-1,1,1),R(1,-1,1),R(-1,-1,1),R(1,1,-1),R(-1,1,-1),R(1,-1,-1),R(-1,-1,-1)),this.setIndex(new Ht(m,1)),this.setAttribute("position",new Ht(p,3)),this.setAttribute("normal",new Ht(f,3)),this.setAttribute("uv",new Ht(g,2))}}}),GN=z(()=>{et(),J_=class extends Gt{constructor(t=[],e=[],i="",n=1,r=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,c=0;return function(){(r=Math.min(.99999,r))==0&&(s=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new C,d=u.clone(),p=new pn,f=r*n,g=n-f,m=s+1,y=new C,v=(q,lt)=>y.subVectors(q,lt).normalize(),_=(q,lt)=>Array(q).fill(void 0).map(lt),b=_(t.length/3,(q,lt)=>new C().fromArray(t,3*lt).setLength(n)),x=[],w=1e6;for(let q=0;q<b.length;q++){let lt,F,O,j=b[q],Z=[],I=1e10,G=-1;for(;(G=e.indexOf(q,G+1))!=-1;){let ot=G-G%3;lt=e[ot+(G+1)%3],F=e[ot+(G+2)%3],O=j.distanceToSquared(b[lt]),I=Math.min(I,O),Z.push([lt,F,O])}I+=1e-6;let W=[],N=0,tt=Z.length;for(let ot=0;ot<tt;ot++){[lt,F,O]=Z[N];let pt=x[lt]?.includes(q)==1;O<=I&&W.push(lt+ +pt*w),N=Z.findIndex(ut=>ut[0]==F)}x.push(W)}let S=[];{let q,lt,F=0,O=0,j=h==3;for(let Z=0;Z<=s;Z++){q=Z*(Z+1)/2,lt=(Z+1)*(Z+2)/2;for(let I=0;I<s-Z;I++)[F,O]=[q+I+Z+2,lt+I+Z+3],S.push(q,lt,...j?[O,q]:[F,lt],O,F),[q,lt]=[F,O];S.push(q,lt,q+s+2)}}let A=0;for(let q=0;q<x.length;q++)for(let lt=0;lt<h;lt++)x[q][lt]<w&&A++;let E=b.length*h*S.length*3+A*m*6*3+2*A*3*3;a=new Float64Array(E),o=new Float64Array(E),l=new Float64Array(E/3*2);let P=(q,lt,F)=>{let O=c/3*2;l[O]=Math.atan2(F,-q)/2/Math.PI+.5,l[O+1]=1-(Math.atan2(-lt,Math.sqrt(q*q+F*F))/Math.PI+.5)},T=q=>{a[c]=q.x,a[c+1]=q.y,a[c+2]=q.z,o[c]=y.x,o[c+1]=y.y,o[c+2]=y.z,P(q.x,q.y,q.z),c+=3},R=q=>{a[c]=q[0].x,a[c+1]=q[0].y,a[c+2]=q[0].z,o[c]=q[1].x,o[c+1]=q[1].y,o[c+2]=q[1].z,P(q[0].x,q[0].y,q[0].z),c+=3},L=(s+2)*(s+3)/2,D=new Float64Array(3*L),U=new Float64Array(3*L),V=new Float64Array(2*L),k=_(2*h*m,()=>new C),Y=_(s*Math.max(0,s-1)/2,()=>new C),$=u.clone(),nt=u.clone(),Q=u.clone(),rt=u.clone(),gt=u.clone(),at=[],ht=_(b.length,()=>_(h,()=>u.clone()));for(let q=0;q<b.length;q++){u.copy(b[q]).normalize(),$.copy(u).multiplyScalar(g);let lt=x[q];for(let W=0;W<lt.length;W++){let N=lt[W],tt=lt[(W+1)%h];p.setFromPointsAndIndices(b,q,N%w,tt%w),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint($,ht[q][W])}let F=0,O=[],j=[],Z=new C;s==0&&[...ht[q]].reduce((W,N)=>W.add(N),Z).multiplyScalar(1/h);for(let W=0;W<h;W++){let N=[],tt=(W-1+h)%h,ot=ht[q][tt],pt=ht[q][W];u.copy(ot).sub($),d.copy(pt).sub($);let ut=$.angleTo(u),Pt=u.angleTo(d),bt=Math.cos(ut)*f;s==0?nt.copy(Z):nt.copy($).setLength(g+bt),O.push(bt);let Rt=[nt,ot,pt];for(let _t=0;_t<2;_t++){let X=Rt[_t],vt=Rt[_t+1];rt.subVectors(X,$),gt.subVectors(vt,$),Q.crossVectors(rt,gt).normalize();for(let Dt=0;Dt<m;Dt++){let jt=[ut,Pt][_t]*Dt/m;u.copy(rt).applyAxisAngle(Q,jt).add($),k[F++].copy(u),_t&&(v(u,$),N.push([Dt==0?X:u.clone(),y.clone()]))}_t&&(v(vt,$),N.push([vt,y.clone()]))}j.push(N)}at.push(j);let I=2*m,G=2;for(let W=0;W<h;W++){let N=I*W,tt=I*((W+1)%h),ot=0,pt=[k[N]];for(let ut=1;ut<m;ut++){let Pt=k[N+ut],bt=k[tt+ut];pt.push(Pt);for(let Rt=1,_t=ut-G+1;Rt<=_t;Rt++)u.lerpVectors(Pt,bt,Rt/(_t+1)),u.sub($).setLength(O[W]).add($),pt.push(Y[ot++].copy(u));pt.push(bt)}for(let ut=0;ut<m;ut++)pt.push(k[ut+m+N]);pt.push(k[tt+m]);for(let ut=0,Pt=pt.length;ut<Pt;ut++){let bt=pt[ut],Rt=3*ut,_t=2*ut;D[Rt]=bt.x,D[Rt+1]=bt.y,D[Rt+2]=bt.z,v(bt,$),U[Rt]=y.x,U[Rt+1]=y.y,U[Rt+2]=y.z,V[_t]=Math.atan2(bt.z,-bt.x)/2/Math.PI+.5,V[_t+1]=1-(Math.atan2(-bt.y,Math.sqrt(bt.x*bt.x+bt.z*bt.z))/Math.PI+.5)}for(let ut=0,Pt=S.length;ut<Pt;ut++){let bt=3*S[ut],Rt=2*S[ut],_t=c/3*2;a[c]=D[bt],a[c+1]=D[bt+1],a[c+2]=D[bt+2],o[c]=U[bt],o[c+1]=U[bt+1],o[c+2]=U[bt+2],l[_t]=V[Rt],l[_t+1]=V[Rt+1],c+=3}}}let ct=[];for(let q=0;q<x.length;q++)for(let lt=0;lt<h;lt++){let F=x[q][lt];if(F<w){let O=x[F].findIndex(I=>I%w==q),j=at[q][lt],Z=at[F][O];for(let I=0;I<m;I++){let G=j[I],W=Z[m-I],N=j[I+1],tt=Z[m-(I+1)];R(G),R(W),R(N),R(N),R(W),R(tt)}ct.push(j[0][0],Z[m][0],j[m][0],Z[0][0])}}for(;ct.length;){let q,lt,F,[O,j]=ct.splice(0,2);q=j;let Z=[O];for(;O!=q;)Z.push(q),lt=ct.indexOf(q),F=lt%2,q=ct.splice(lt-F,2)[1-F];y.subVectors(Z[0],Z[1]).cross(u.subVectors(Z[0],Z[2])).normalize();let I=y.dot(Z[0])<0;I&&y.negate();for(let G=1;G<=Z.length-2;G++)T(Z[G+ +I]),T(Z[G+1-+I]),T(Z[0])}}(),function(){let h=new C,u=new C,d=new C,p=new C,f=new it,g=new it,m=new it,y=(b,x,w,S)=>{S<0&&b.x===1&&(l[x]=b.x-1),w.x===0&&w.z===0&&(l[x]=S/2/Math.PI+.5)};for(let b=0,x=0;b<c;b+=9,x+=6){h.set(a[b+0],a[b+1],a[b+2]),u.set(a[b+3],a[b+4],a[b+5]),d.set(a[b+6],a[b+7],a[b+8]),f.set(l[x+0],l[x+1]),g.set(l[x+2],l[x+3]),m.set(l[x+4],l[x+5]),p.copy(h).add(u).add(d).divideScalar(3);let w=_(p);y(f,x+0,h,w),y(g,x+2,u,w),y(m,x+4,d,w)}let v=c/3*2;for(let b=0;b<v;b+=6){let x=l[b+0],w=l[b+2],S=l[b+4],A=Math.max(x,w,S),E=Math.min(x,w,S);A>.9&&E<.1&&(x<.2&&(l[b+0]+=1),w<.2&&(l[b+2]+=1),S<.2&&(l[b+4]+=1))}function _(b){return Math.atan2(b.z,-b.x)}}(),this.setAttribute("position",new Ht(new Float32Array(a.subarray(0,c)),3)),this.setAttribute("normal",new Ht(new Float32Array(o.subarray(0,c)),3)),void this.setAttribute("uv",new Ht(new Float32Array(l.subarray(0,c/3*2)),2))}static fromJSON(t){return new J_(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),QO=z(()=>{GN(),et(),jN=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:n,detail:r,corner:s,cornerSides:a}=t.parameters,o=r===0&&s!==0?new OS(.5*e,s,a):new hE(.5*e,r),l=i/e,c=n/e;return(l!==1||c!==1)&&o.scale(1,l,c),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},OS=class extends J_{constructor(t=1,e=.2,i=4){let n=(1+Math.sqrt(5))/2,r=1/n,s="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],s,t,e,i),this.type=s}static fromJSON(t){return new OS(t.radius,t.corner,t.cornerSides)}}});function JO(t,e=new it){let i=t.length();return e.set(-t.y/i,t.x/i)}function h$(t){let e=new it;e.addVectors(t.v0,Cc.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new it;return i.addVectors(t.v2,Fg.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new zs(t.v0,e,i,t.v2)}function Bm(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function c$(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function d$(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function HN(t,e,i){let n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((r*r+n*n-s*s)/(2*r*n))}function u$(t,e,i){return e4(t,e)&&e4(e,i)&&TA(t.position,e.position,i.position)}function TA(t,e,i){return Cc.copy(e).sub(t).cross(Fg.copy(i).sub(t))===0}function p$(t,e,i,n,r){let s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=(t.y+e.y)/2,o=(t.x+e.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.y-e.y)/s,c=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.x-t.x)/s;return n.set(o+l,a+c),r.set(o-l,a-c),[n,r]}function f$(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function m$(t,e,i,n,r,s){let a,o=e.x-t.x,l=e.y-t.y,c=i.x-t.x,h=i.y-t.y,u=Math.sqrt((o+c)*(o+c)+(l+h)*(l+h));return HN(e,t,i)>Math.PI&&(u*=-1),a=Bm(h,l)?(l+h)*(n/u-.5)*8/3/(o-c):(o+c)*(n/u-.5)*8/3/(h-l),r.set(e.x-a*l,e.y+a*o),s.set(i.x+a*h,i.y-a*c),[r,s]}function t4(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function e4(t,e){return TA(t.position,t.controls[1].position,e.position)&&TA(t.position,e.controls[0].position,e.position)}function i4(t,e=12,i=!1){let n=[];for(let r=0,s=t.length;r<s;r++){let a=t[r],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Tc(a.roundedCurveCorner,e);r>0&&(n[r-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Tc(a.curveAfter,e)),n.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(n[t.length-1]+=.5*Tc(t[0].roundedCurveCorner,e)),n}function Tc(t,e=12){return t&&t instanceof wm?2*e:t&&(t instanceof ps||t instanceof cE)?1:t&&t instanceof i1?e*t.points.length:e}var Au,_v,bv,Uc,g1,Cc,Fg,WN,qN,XN,$N,CA,PA,xv,n4,r4,s4,a4,o4,Ni,YN=z(()=>{et(),Au=1e-12,_v=class{constructor(t){this.position=new it,this.startPosition=new it,this.uuid=Ot.generateUUID(),this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new _v(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},bv=class extends _v{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new bv(this.parent).copy(this)}},Uc=class extends _v{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new bv(this),new bv(this))}static create(t,e){let i=new Uc(t,new it(...e.position));return i.controls[0].position.set(...e.controlPrevious.position),i.controls[1].position.set(...e.controlNext.position),i.roundness=e.roundness,i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored,i}getOppositeControl(t){let e=this.controls.indexOf(t);return e===0?this.controls[1]:e===1?this.controls[0]:null}applyOffsetToControls(t,e=1){for(let i=0,n=this.controls.length;i<n;i++){let r=this.controls[i];this.position.distanceTo(r.position)<=e?r.position.copy(this.position):r.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new Uc(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),e=this.curveAfter?.getTangentAt(0);return[t,e]}computeNormals(t=new it,e=new it){let[i,n]=this.computeTangents();return i&&n&&(JO(i,t),JO(n,e)),[t,e]}computeTangent(t=new it){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new it){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},g1=t=>t,Cc=new it,Fg=new it,WN=new it,qN=new it,XN=new it,$N=new it,CA=new C,PA=new C}),yh=z(()=>{et(),YN(),xv=new it,n4=new it,r4=new it,s4=new it,a4=new it,o4=new it,Ni=class extends Sg{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new kr(new C(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Ot.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let n=new Ni;return n.isClosed=t.isClosed,n.points=t.points.map(r=>Uc.create(r.id,r.data)),typeof t.roundness=="number"&&(n.roundness=t.roundness),n.shapeHoles=t.shapeHoles.map(r=>Ni.createFromState(r)),e!==void 0&&i!==void 0&&n.applySize(e,i),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let e=0,i=this.points.length;e<i;e++)this.points[e].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(e=>this.getPointIndexById(e)).filter(e=>e>=0)}getPointIndexById(t){let e=this.points.length,i=this.points.findIndex(n=>n.uuid===t);if(i<0){let n=e;for(let r=0,s=this.shapeHoles.length;r<s;r++){let a=this.shapeHoles[r],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+n;n+=o}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let e=this.points.length;for(let i=0,n=this.shapeHoles.length;i<n;i++){let r=this.shapeHoles[i],s=t-e;if(s<=r.points.length-1)return r.points[s];e+=r.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let e=this.points.indexOf(t);if(e>=0)return e;if(e=this.points.length,this.shapeHoles.length>0)for(let i=0,n=this.shapeHoles.length;i<n;i++){let r=this.shapeHoles[i],s=r.points.indexOf(t);if(s>=0)return e+s;e+=r.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(e=>e.points));return[...this.points,...t]}applySize(t,e){t===0&&(t=.001),e===0&&(e=.001),this._width=t,this._height=e}applyScale(t,e){let i=xv.set(t,e);for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let n=0,r=this.shapeHoles.length;n<r;n++)this.shapeHoles[n].applyScale(t,e);this._update()}createPoint(t,e=0,i=Ot.generateUUID()){let n;n=t instanceof it?t:new it(t,e);let r=new Uc(i,n);return r.roundness=this.roundness,r}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,e){this.points.splice(e,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let e=0,i=this.points.length;e<i;e++){let n=this.points[e];if(n.uuid===t)return n}for(let e=0,i=this.shapeHoles.length;e<i;e++){let n=this.shapeHoles[e].getPointByUuid(t);if(n)return n}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let e=this.points.indexOf(t);e>=0&&this.points.splice(e,1),this.needsUpdate=!0}removePointById(t){let e=this.points.find(i=>i.uuid===t);e&&this.removePoint(e)}update(){for(let t=0,e=this.shapeHoles.length;t<e;t++)this.shapeHoles[t].update();this._update()}extractShapePointsToBuffer(t,e=12,i=!1){this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e);let n=i?this.roundedCurveDivisions:this.curveDivisions;return function(r,s,a=12,o=!0){let l,c=PA.set(0,0,0),h=0,u=[];for(let d=0;d<s.length;d++){let p=g1(s[d]),f=Cc,g=Tc(p,a);u.push(g);for(let m=0;m<=g;m++)if(p instanceof zs||p instanceof Go||p instanceof ps){if(p.getPoint(m/g,f),c.set(f.x,f.y,0),l!==void 0&&d$(l,c))continue;l===void 0&&(l=CA),l.copy(c),r.setXYZ(h,c.x,c.y,c.z),h++}}o&&h>1&&(r.getX(h-1)!==r.getX(0)||r.getY(h-1)!==r.getY(0)||r.getZ(h-1)!==r.getZ(0))&&(r.setXYZ(h,r.getX(0),r.getY(0),r.getZ(0)),h++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),n.reduce((r,s)=>r+s,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=i4(this.points,t,!1),this.roundedCurveDivisions=i4(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(n,r,s,a=12,o=!0){let l=PA.set(0,0,0),c=0,h=[];for(let u=0;u<r.length;u++){if(s[u]===!1)continue;let d,p=g1(r[u]),f=Cc,g=Tc(p,a);h.push(g);for(let m=0;m<=g;m++)if(p instanceof zs||p instanceof Go||p instanceof ps){if(p.getPoint(m/g,f),l.set(f.x,f.y,0),d?.equals(l))continue;d===void 0?d=CA:(n.setXYZ(c,d.x,d.y,d.z),c++,n.setXYZ(c,l.x,l.y,l.z),c++),d.copy(l)}}return o&&c>1&&!(n.getX(c-1)===n.getX(0)&&n.getY(c-1)===n.getY(0)&&n.getZ(c-1)===n.getZ(0))&&(n.setXYZ(c,n.getX(0),n.getY(0),n.getZ(0)),c++),h}(t,this.curves,e,i,this.autoClose).reduce((n,r)=>n+r,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,n,r=12,s=!0){let a,o=0;for(let l=0;l<n.length;l++){let c=g1(n[l]),h=Tc(c,r),u=Cc;for(let d=0;d<=h;d++)if(c instanceof zs||c instanceof Go||c instanceof ps){if(c.getPoint(d/h,u),a!==void 0&&c$(a,u,Au))continue;a===void 0&&(a=Fg),a.copy(u),i.push(u.x,u.y),o++}}return Bm(i[0],i[i.length-2],Au)&&Bm(i[1],i[i.length-1],Au)&&(i.pop(),i.pop()),s&&o>1&&!(Bm(i[o-1],i[1],Au)&&Bm(i[o-2],i[0],Au))&&(i.push(i[0],i[1]),o++),i}(t,this.roundedCurves,e,this.autoClose)}getCurveIndexFromVertexId(t,e=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=e?this.roundedCurveDivisions:this.curveDivisions,r=0;e&&this.points[0].roundedCurveCorner!==void 0&&(r=.5*Tc(this.points[0].roundedCurveCorner,this.subdivision));let s=t-r;s<0&&(s+=n.reduce((a,o)=>a+o,0));for(let a=0,o=n.length;a<o;a++){let l=n[a];if(s<i+l)return[a,(s-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let n=this.points[t],r=this.points[t>=this.points.length-1?0:t+1],s=this.curveDivisions,a=s[t];if(t4(n,r)){let l=n.position.distanceTo(r.position);return n.position.distanceTo(xv.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=s[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){t4(e,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(e.controls[1].position.x,e.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,e.curveAfter=i;let n=i.clone();t.roundedCurveBefore=n,e.roundedCurveAfter=n,t.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let n=this.points[e];if(e===0)this.moveTo(n.position.x,n.position.y);else{let r=this.points[e-1];this._applyCurveForPoint(n,r)}}let t=this.getLastPoint();if(t?.curveAfter&&(t.curveAfter=void 0),this.isClosed){let e=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(e,i)}if(this.points.length>2){let e=0;for(let i=0,n=this.points.length;i<n;i++){let r=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=r.roundness,l=s&&a&&u$(s,r,a);if(!r.controlsMoved()&&o>0&&!l){let c=r.curveBefore,h=r.curveAfter;if(c===void 0||h===void 0)continue;let u,d=r.roundedCurveBefore,p=r.roundedCurveAfter,f=c instanceof ps?c.v1.distanceTo(c.v2):c.getLength(),g=h instanceof ps?h.v1.distanceTo(h.v2):h.getLength(),m=Math.min(o,.499*f),y=Math.min(o,.499*g),v=Math.min(m,y),_=1-v/f,b=v/g,x=c.getPointAt(_,xv),w=h.getPointAt(b,n4);if(this._subSplitCurve(c,d,_,x,void 0),this._subSplitCurve(h,p,b,void 0,w),this.useCubicForRoundedCorners){let S=HN(x,r.position,w)/2,A=Math.tan(S)*x.distanceTo(r.position),[E,P]=p$(x,w,A,r4,s4),T=f$(E,P,r.position),[R,L]=m$(T,x,w,A,a4,o4);u=new zs(x.clone(),R.clone(),L.clone(),w.clone())}else u=new Go(x.clone(),r.position.clone(),w.clone());r.roundedCurveCorner=u,this.roundedCurves.splice(i+e,0,u),e++}}}}_subSplitCurve(t,e,i,n,r){if(!(t instanceof ps)){let s=t,a=e,o=s.getUtoTmapping(i,0),l=function(c,h,u,d,p=.5){let f=Cc.subVectors(h,c).multiplyScalar(p).add(c),g=Fg.subVectors(u,h).multiplyScalar(p).add(h),m=WN.subVectors(d,u).multiplyScalar(p).add(u),y=f,v=qN.subVectors(g,f).multiplyScalar(p).add(f),_=XN.subVectors(m,g).multiplyScalar(p).add(g),b=m,x=$N.subVectors(_,v).multiplyScalar(p).add(v);return[c.x,c.y,y.x,y.y,v.x,v.y,x.x,x.y,_.x,_.y,b.x,b.y,d.x,d.y]}(s.v0,s.v1,s.v2,s.v3,o);return n!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),r!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return n!==void 0&&e.v2.copy(n),r!==void 0&&e.v1.copy(r),e}clone(){let t=new Ni(this._width,this._height);return t.points=this.points.map(e=>e.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(e=>e.clone()),t}toJSON(){return{points:this.points.reduce((t,e)=>t.concat(e.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let e=t.points.length/7;for(let i=0;i<e;i++){let n=7*i,r=t.points[n+0],s=t.points[n+1],a=t.points[n+2],o=t.points[n+3],l=t.points[n+4],c=t.points[n+5],h=t.points[n+6],u=new Uc(Ot.generateUUID(),new it(r,s));u.controls[0].position.set(a,o),u.controls[1].position.set(l,c),u.roundness=h,this.points.push(u)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let n=new Ni;return n.fromJSON(i),n}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(n,r)=>{r instanceof zs&&r.v3.equals(n.position)&&n.controls[0].position.copy(r.v2)};return this.points=(n=>{let r,s,a=[];for(r=0,s=n.length;r<s;r++)n[r]instanceof Go&&(n[r]=h$(n[r]));for(r=0,s=n.length;r<s;r++){let c,h=n[r],u=r>0?n[r-1]:null;h instanceof zs?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof ps&&(c=this.createPoint(h.v1)),c!==void 0&&(u!==null&&i(c,u),a.push(c))}let o=n[n.length-1],l=!1;return o instanceof zs?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof ps&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof Sg&&(this.shapeHoles=t.holes.map(n=>{let r=new Ni;return r.fromShape(n),r})),this.update(),this}updatePoint(t,e){let i=this.getPointByUuid(t);i&&(e.position!==void 0&&i.position.fromArray(e.position),e.roundness!==void 0&&(i.roundness=e.roundness),e.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(t,e){let i=this.getPointByUuid(t)?.controls[0];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}updateNextControl(t,e){let i=this.getPointByUuid(t)?.controls[1];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}}});function LS({x:t,y:e},i,n,r,s){return{x:t*i+r,y:e*n+s}}function g$(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(t),r=Math.sin(t),s=Math.cos(t+e),a=Math.sin(t+e);return[{x:n-r*i,y:r+n*i},{x:s+a*i,y:a-s*i},{x:s,y:a}]}function l4(t,e,i,n){let r=t*n-e*i<0?-1:1,s=Math.min(1,Math.max(-1,t*i+e*n));return r*Math.acos(s)}var v1,v$=z(()=>{v1=2*Math.PI});function he(t,e){if(!t)throw e||"Assertion Failed!"}function Ql(t){var e=t.windingRule,i=e===void 0?fi.ODD:e,n=t.elementType,r=n===void 0?An.POLYGONS:n,s=t.polySize,a=s===void 0?3:s,o=t.vertexSize,l=o===void 0?2:o,c=t.normal,h=c===void 0?[0,0,1]:c,u=t.contours,d=u===void 0?[]:u,p=t.strict,f=p===void 0||p,g=t.debug,m=g!==void 0&&g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var y=new ZN;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(i,r,a,l,h,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:m?y.mesh:void 0}}}var fi,An,re,Bd,Of,Zh,BS,US,zS,h4,wv,FS,c4,d4,ZN,NS,KN,QN,Sp=z(()=>{var t;(t=fi||(fi={}))[t.ODD=0]="ODD",t[t.NONZERO=1]="NONZERO",t[t.POSITIVE=2]="POSITIVE",t[t.NEGATIVE=3]="NEGATIVE",t[t.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(An||(An={})),re=function(){function e(){}return e.vertEq=function(i,n){return i.s===n.s&&i.t===n.t},e.vertLeq=function(i,n){return i.s<n.s||i.s===n.s&&i.t<=n.t},e.transLeq=function(i,n){return i.t<n.t||i.t===n.t&&i.s<=n.s},e.edgeGoesLeft=function(i){return e.vertLeq(i.Dst,i.Org)},e.edgeGoesRight=function(i){return e.vertLeq(i.Org,i.Dst)},e.vertL1dist=function(i,n){return Math.abs(i.s-n.s)+Math.abs(i.t-n.t)},e.edgeEval=function(i,n,r){he(e.vertLeq(i,n)&&e.vertLeq(n,r));var s=n.s-i.s,a=r.s-n.s;return s+a>0?s<a?n.t-i.t+(i.t-r.t)*(s/(s+a)):n.t-r.t+(r.t-i.t)*(a/(s+a)):0},e.edgeSign=function(i,n,r){he(e.vertLeq(i,n)&&e.vertLeq(n,r));var s=n.s-i.s,a=r.s-n.s;return s+a>0?(n.t-r.t)*s+(n.t-i.t)*a:0},e.transEval=function(i,n,r){he(e.transLeq(i,n)&&e.transLeq(n,r));var s=n.t-i.t,a=r.t-n.t;return s+a>0?s<a?n.s-i.s+(i.s-r.s)*(s/(s+a)):n.s-r.s+(r.s-i.s)*(a/(s+a)):0},e.transSign=function(i,n,r){he(e.transLeq(i,n)&&e.transLeq(n,r));var s=n.t-i.t,a=r.t-n.t;return s+a>0?(n.s-r.s)*s+(n.s-i.s)*a:0},e.vertCCW=function(i,n,r){return i.s*(n.t-r.t)+n.s*(r.t-i.t)+r.s*(i.t-n.t)>=0},e.interpolate=function(i,n,r,s){return(i=i<0?0:i)<=(r=r<0?0:r)?r===0?(n+s)/2:n+i/(i+r)*(s-n):s+r/(i+r)*(n-s)},e.intersect=function(i,n,r,s,a){var o,l,c;e.vertLeq(i,n)||(c=i,i=n,n=c),e.vertLeq(r,s)||(c=r,r=s,s=c),e.vertLeq(i,r)||(c=i,i=r,r=c,c=n,n=s,s=c),e.vertLeq(r,n)?e.vertLeq(n,s)?((o=e.edgeEval(i,r,n))+(l=e.edgeEval(r,n,s))<0&&(o=-o,l=-l),a.s=e.interpolate(o,r.s,l,n.s)):((o=e.edgeSign(i,r,n))+(l=-e.edgeSign(i,s,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,r.s,l,s.s)):a.s=(r.s+n.s)/2,e.transLeq(i,n)||(c=i,i=n,n=c),e.transLeq(r,s)||(c=r,r=s,s=c),e.transLeq(i,r)||(c=i,i=r,r=c,c=n,n=s,s=c),e.transLeq(r,n)?e.transLeq(n,s)?((o=e.transEval(i,r,n))+(l=e.transEval(r,n,s))<0&&(o=-o,l=-l),a.t=e.interpolate(o,r.t,l,n.t)):((o=e.transSign(i,r,n))+(l=-e.transSign(i,s,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,r.t,l,s.t)):a.t=(r.t+n.t)/2},e}(),Bd=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},Of=function(){function e(i){this.side=i,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),e}(),Zh=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},BS=function(){function e(){var i=new Zh,n=new Bd,r=new Of(0),s=new Of(1);i.next=i.prev=i,i.anEdge=null,n.next=n.prev=n,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=i,this.fHead=n,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(i){var n=new Of(0),r=new Of(1);i.Sym.side<i.side&&(i=i.Sym);var s=i.Sym.next;return r.next=s,s.Sym.next=n,n.next=i,i.Sym.next=r,n.Sym=r,n.Onext=n,n.Lnext=r,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,r.Sym=n,r.Onext=r,r.Lnext=n,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,n},e.prototype.splice_=function(i,n){var r=i.Onext,s=n.Onext;r.Sym.Lnext=n,s.Sym.Lnext=i,i.Onext=s,n.Onext=r},e.prototype.makeVertex_=function(i,n,r){var s=i;he(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=n;var o=n;do o.Org=s,o=o.Onext;while(o!==n)},e.prototype.makeFace_=function(i,n,r){var s=i;he(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=n,s.trail=null,s.marked=!1,s.inside=r.inside;var o=n;do o.Lface=s,o=o.Lnext;while(o!==n)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var n=i.next,r=i.Sym.next;n.Sym.next=r,r.Sym.next=n},e.prototype.killVertex_=function(i,n){var r=i.anEdge,s=r;do s.Org=n,s=s.Onext;while(s!==r);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,n){var r=i.anEdge,s=r;do s.Lface=n,s=s.Lnext;while(s!==r);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new Zh,n=new Zh,r=new Bd,s=this.makeEdge_(this.eHead);return this.makeVertex_(i,s,this.vHead),this.makeVertex_(n,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(i,n){var r=!1,s=!1;if(i!==n){if(n.Org!==i.Org&&(s=!0,this.killVertex_(n.Org,i.Org)),n.Lface!==i.Lface&&(r=!0,this.killFace_(n.Lface,i.Lface)),this.splice_(n,i),!s){var a=new Zh;this.makeVertex_(a,n,i.Org),i.Org.anEdge=i}if(!r){var o=new Bd;this.makeFace_(o,n,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var n=i.Sym,r=!1;if(i.Lface!==i.Rface&&(r=!0,this.killFace_(i.Lface,i.Rface)),i.Onext===i)this.killVertex_(i.Org,null);else if(i.Rface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev),!r){var s=new Bd;this.makeFace_(s,i,i.Lface)}n.Onext===n?(this.killVertex_(n.Org,null),this.killFace_(n.Lface,null)):(i.Lface.anEdge=n.Oprev,n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var n=this.makeEdge_(i),r=n.Sym;this.splice_(n,i.Lnext),n.Org=i.Dst;var s=new Zh;return this.makeVertex_(s,r,n.Org),n.Lface=r.Lface=i.Lface,n},e.prototype.splitEdge=function(i){var n=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,n),i.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=i.Rface,n.winding=i.winding,n.Sym.winding=i.Sym.winding,n.idx=i.idx,n.Sym.idx=i.Sym.idx,n},e.prototype.connect=function(i,n){var r=!1,s=this.makeEdge_(i),a=s.Sym;if(n.Lface!==i.Lface&&(r=!0,this.killFace_(n.Lface,i.Lface)),this.splice_(s,i.Lnext),this.splice_(a,n),s.Org=i.Dst,a.Org=n.Org,s.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!r){var o=new Bd;this.makeFace_(o,s,i.Lface)}return s},e.prototype.zapFace=function(i){var n,r,s,a,o,l=i.anEdge;r=l.Lnext;do r=(n=r).Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),(s=n.Sym).Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var n=i.anEdge,r=0;do r++,n=n.Lnext;while(n!==i.anEdge);return r},e.prototype.mergeConvexFaces=function(i){var n,r,s,a,o;for(n=this.fHead.next;n!==this.fHead;n=n.next)if(n.inside)for(o=(r=n.anEdge).Org;s=r.Lnext,(a=r.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(n)+this.countFaceVerts_(a.Lface)-2<=i&&re.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&re.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null),!r||r.Lnext.Org!==o;)r=s;return!0},e.prototype.check=function(){var i,n,r,s,a,o,l=this.fHead,c=this.vHead,h=this.eHead;for(n=l,n=l;(i=n.next)!==l;n=i){he(i.prev===n),a=i.anEdge;do he(a.Sym!==a),he(a.Sym.Sym===a),he(a.Lnext.Onext.Sym===a),he(a.Onext.Sym.Lnext===a),he(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(he(i.prev===n&&i.anEdge===null),s=c,s=c;(r=s.next)!==c;s=r){he(r.prev===s),a=r.anEdge;do he(a.Sym!==a),he(a.Sym.Sym===a),he(a.Lnext.Onext.Sym===a),he(a.Onext.Sym.Lnext===a),he(a.Org===r),a=a.Onext;while(a!==r.anEdge)}for(he(r.prev===s&&r.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)he(a.Sym.next===o.Sym),he(a.Sym!==a),he(a.Sym.Sym===a),he(a.Org!==null),he(a.Dst!==null),he(a.Lnext.Onext.Sym===a),he(a.Onext.Sym.Lnext===a);he(a.Sym.next===o.Sym&&a.Sym===this.eHeadSym&&a.Sym.Sym===a&&a.Org===null&&a.Dst===null&&a.Lface===null&&a.Rface===null)},e}(),US=function(){this.handle=null},zS=function(){this.key=null,this.node=0},h4=function(){function e(i,n){this.leq=n,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=i,this.nodes=[],this.handles=[];for(var r=0;r<i+1;r++)this.nodes[r]=new US,this.handles[r]=new zS;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var n,r,s,a=this.nodes,o=this.handles;for(n=a[i].handle;;){if((s=i<<1)<this.size&&this.leq(o[a[s+1].handle].key,o[a[s].handle].key)&&++s,he(s<=this.max),r=a[s].handle,s>this.size||this.leq(o[n].key,o[r].key)){a[i].handle=n,o[n].node=i;break}a[i].handle=r,o[r].node=i,i=s}},e.prototype.floatUp_=function(i){var n,r,s,a=this.nodes,o=this.handles;for(n=a[i].handle;;){if(r=a[s=i>>1].handle,s===0||this.leq(o[r].key,o[n].key)){a[i].handle=n,o[n].node=i;break}a[i].handle=r,o[r].node=i,i=s}},e.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(i){var n,r;if(2*(n=++this.size)>this.max){var s,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new US;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new zS}return this.freeList===0?r=n:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[n].handle=r,this.handles[r].node=n,this.handles[r].key=i,this.initialized&&this.floatUp_(n),r},e.prototype.extractMin=function(){var i=this.nodes,n=this.handles,r=i[1].handle,s=n[r].key;return this.size>0&&(i[1].handle=i[this.size].handle,n[i[1].handle].node=1,n[r].key=null,n[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(i){var n,r=this.nodes,s=this.handles;he(i>=1&&i<=this.max&&s[i].key!==null),r[n=s[i].node].handle=r[this.size].handle,s[r[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(s[r[n>>1].handle].key,s[r[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),s[i].key=null,s[i].node=this.freeList,this.freeList=i},e}(),wv=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},FS=function(){this.key=null,this.next=null,this.prev=null},c4=function(){function e(i,n){this.frame=i,this.leq=n,this.head=new FS,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(i){return this.insertBefore(this.head,i)},e.prototype.search=function(i){var n=this.head;do n=n.next;while(n.key!==null&&!this.leq(this.frame,i,n.key));return n},e.prototype.insertBefore=function(i,n){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,n));var r=new FS;return r.key=n,r.next=i.next,i.next.prev=r,r.prev=i,i.next=r,r},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),d4=function(){function e(){}return e.regionBelow=function(i){return i.nodeUp.prev.key},e.regionAbove=function(i){return i.nodeUp.next.key},e.debugEvent=function(i){},e.addWinding=function(i,n){i.winding+=n.winding,i.Sym.winding+=n.Sym.winding},e.edgeLeq=function(i,n,r){var s=i.event,a=n.eUp,o=r.eUp;return a.Dst===s?o.Dst===s?re.vertLeq(a.Org,o.Org)?re.edgeSign(o.Dst,a.Org,o.Org)<=0:re.edgeSign(a.Dst,o.Org,a.Org)>=0:re.edgeSign(o.Dst,s,o.Org)<=0:o.Dst===s?re.edgeSign(a.Dst,s,a.Org)>=0:re.edgeEval(a.Dst,s,a.Org)>=re.edgeEval(o.Dst,s,o.Org)},e.deleteRegion=function(i,n){n.fixUpperEdge&&he(n.eUp.winding===0),n.eUp.activeRegion=null,i.dict.delete(n.nodeUp)},e.fixUpperEdge=function(i,n,r){he(n.fixUpperEdge),i.mesh.delete(n.eUp),n.fixUpperEdge=!1,n.eUp=r,r.activeRegion=n},e.topLeftRegion=function(i,n){var r,s=n.eUp.Org;do n=e.regionAbove(n);while(n.eUp.Org===s);if(n.fixUpperEdge){if((r=i.mesh.connect(e.regionBelow(n).eUp.Sym,n.eUp.Lnext))===null)return null;e.fixUpperEdge(i,n,r),n=e.regionAbove(n)}return n},e.topRightRegion=function(i){var n=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===n);return i},e.addRegionBelow=function(i,n,r){var s=new wv;return s.eUp=r,s.nodeUp=i.dict.insertBefore(n.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(i,n){switch(i.windingRule){case fi.ODD:return!!(1&n);case fi.NONZERO:return n!==0;case fi.POSITIVE:return n>0;case fi.NEGATIVE:return n<0;case fi.ABS_GEQ_TWO:return n>=2||n<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,n){n.windingNumber=e.regionAbove(n).windingNumber+n.eUp.winding,n.inside=e.isWindingInside(i,n.windingNumber)},e.finishRegion=function(i,n){var r=n.eUp,s=r.Lface;s.inside=n.inside,s.anEdge=r,e.deleteRegion(i,n)},e.finishLeftRegions=function(i,n,r){for(var s,a=null,o=n,l=n.eUp;o!==r;){if(o.fixUpperEdge=!1,(s=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}s=i.mesh.connect(l.Lprev,s.Sym),e.fixUpperEdge(i,a,s)}l.Onext!==s&&(i.mesh.splice(s.Oprev,s),i.mesh.splice(l,s)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,n,r,s,a,o){var l,c,h,u,d=!0;h=r;do he(re.vertLeq(h.Org,h.Dst)),e.addRegionBelow(i,n,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(n).eUp.Rprev),c=n,u=a;(h=(l=e.regionBelow(c)).eUp.Sym).Org===u.Org;)h.Onext!==u&&(i.mesh.splice(h.Oprev,h),i.mesh.splice(u.Oprev,h)),l.windingNumber=c.windingNumber-h.winding,l.inside=e.isWindingInside(i,l.windingNumber),c.dirty=!0,!d&&e.checkForRightSplice(i,c)&&(e.addWinding(h,u),e.deleteRegion(i,c),i.mesh.delete(u)),d=!1,c=l,u=h;c.dirty=!0,he(c.windingNumber-h.winding===l.windingNumber),o&&e.walkDirtyRegions(i,c)},e.spliceMergeVertices=function(i,n,r){i.mesh.splice(n,r)},e.vertexWeights=function(i,n,r){var s=re.vertL1dist(n,i),a=re.vertL1dist(r,i),o=.5*a/(s+a),l=.5*s/(s+a);i.coords[0]+=o*n.coords[0]+l*r.coords[0],i.coords[1]+=o*n.coords[1]+l*r.coords[1],i.coords[2]+=o*n.coords[2]+l*r.coords[2]},e.getIntersectData=function(i,n,r,s,a,o){n.coords[0]=n.coords[1]=n.coords[2]=0,n.idx=-1,e.vertexWeights(n,r,s),e.vertexWeights(n,a,o)},e.checkForRightSplice=function(i,n){var r=e.regionBelow(n),s=n.eUp,a=r.eUp;if(re.vertLeq(s.Org,a.Org)){if(re.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;re.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(i.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,s)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(s,a.Oprev),n.dirty=r.dirty=!0)}else{if(re.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(n).dirty=n.dirty=!0,i.mesh.splitEdge(s.Sym),i.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(i,n){var r,s=e.regionBelow(n),a=n.eUp,o=s.eUp;if(he(!re.vertEq(a.Dst,o.Dst)),re.vertLeq(a.Dst,o.Dst)){if(re.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(n).dirty=n.dirty=!0,r=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,r),r.Lface.inside=n.inside}else{if(re.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;n.dirty=s.dirty=!0,r=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),r.Rface.inside=n.inside}return!0},e.checkForIntersect=function(i,n){var r,s,a=e.regionBelow(n),o=n.eUp,l=a.eUp,c=o.Org,h=l.Org,u=o.Dst,d=l.Dst,p=new Zh;if(he(!re.vertEq(d,u)),he(re.edgeSign(u,i.event,c)<=0),he(re.edgeSign(d,i.event,h)>=0),he(c!==i.event&&h!==i.event),he(!n.fixUpperEdge&&!a.fixUpperEdge),c===h||Math.min(c.t,u.t)>Math.max(h.t,d.t))return!1;if(re.vertLeq(c,h)){if(re.edgeSign(d,c,h)>0)return!1}else if(re.edgeSign(u,h,c)<0)return!1;return e.debugEvent(i),re.intersect(u,c,d,h,p),he(Math.min(c.t,u.t)<=p.t),he(p.t<=Math.max(h.t,d.t)),he(Math.min(d.s,u.s)<=p.s),he(p.s<=Math.max(h.s,c.s)),re.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),r=re.vertLeq(c,h)?c:h,re.vertLeq(r,p)&&(p.s=r.s,p.t=r.t),re.vertEq(p,c)||re.vertEq(p,h)?(e.checkForRightSplice(i,n),!1):!re.vertEq(u,i.event)&&re.edgeSign(u,i.event,p)>=0||!re.vertEq(d,i.event)&&re.edgeSign(d,i.event,p)<=0?d===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),n=e.topLeftRegion(i,n),o=e.regionBelow(n).eUp,e.finishLeftRegions(i,e.regionBelow(n),a),e.addRightEdges(i,n,o.Oprev,o,o,!0),!0):u===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=n,n=e.topRightRegion(n),s=e.regionBelow(n).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,n,l.Onext,o.Rprev,s,!0),!0):(re.edgeSign(u,i.event,p)>=0&&(e.regionAbove(n).dirty=n.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),re.edgeSign(d,i.event,p)<=0&&(n.dirty=a.dirty=!0,i.mesh.splitEdge(l.Sym),l.Org.s=i.event.s,l.Org.t=i.event.t),!1):(i.mesh.splitEdge(o.Sym),i.mesh.splitEdge(l.Sym),i.mesh.splice(l.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=i.pq.insert(o.Org),e.getIntersectData(i,o.Org,c,u,h,d),e.regionAbove(n).dirty=n.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,n){for(var r,s,a=e.regionBelow(n);;){for(;a.dirty;)n=a,a=e.regionBelow(a);if(!n.dirty&&(a=n,(n=e.regionAbove(n))===null||!n.dirty))return;if(n.dirty=!1,r=n.eUp,s=a.eUp,r.Dst!==s.Dst&&e.checkForLeftSplice(i,n)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(s),s=(a=e.regionBelow(n)).eUp):n.fixUpperEdge&&(e.deleteRegion(i,n),i.mesh.delete(r),r=(n=e.regionAbove(a)).eUp)),r.Org!==s.Org){if(r.Dst===s.Dst||n.fixUpperEdge||a.fixUpperEdge||r.Dst!==i.event&&s.Dst!==i.event)e.checkForRightSplice(i,n);else if(e.checkForIntersect(i,n))return}r.Org===s.Org&&r.Dst===s.Dst&&(e.addWinding(s,r),e.deleteRegion(i,n),i.mesh.delete(r),n=e.regionAbove(a))}},e.connectRightVertex=function(i,n,r){var s,a=r.Onext,o=e.regionBelow(n),l=n.eUp,c=o.eUp,h=!1;l.Dst!==c.Dst&&e.checkForIntersect(i,n),re.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),n=e.topLeftRegion(i,n),a=e.regionBelow(n).eUp,e.finishLeftRegions(i,e.regionBelow(n),o),h=!0),re.vertEq(c.Org,i.event)&&(i.mesh.splice(r,c.Oprev),r=e.finishLeftRegions(i,o,null),h=!0),h?e.addRightEdges(i,n,r.Onext,a,a,!0):(s=re.vertLeq(c.Org,l.Org)?c.Oprev:l,s=i.mesh.connect(r.Lprev,s),e.addRightEdges(i,n,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,n))},e.connectLeftDegenerate=function(i,n,r){var s,a,o,l,c;return s=n.eUp,re.vertEq(s.Org,r)?(he(!1),void e.spliceMergeVertices(i,s,r.anEdge)):re.vertEq(s.Dst,r)?(he(!1),n=e.topRightRegion(n),a=l=(o=(c=e.regionBelow(n)).eUp.Sym).Onext,c.fixUpperEdge&&(he(a!==o),e.deleteRegion(i,c),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(r.anEdge,o),re.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,n,o.Onext,l,a,!0)):(i.mesh.splitEdge(s.Sym),n.fixUpperEdge&&(i.mesh.delete(s.Onext),n.fixUpperEdge=!1),i.mesh.splice(r.anEdge,s),void e.sweepEvent(i,r))},e.connectLeftVertex=function(i,n){var r,s,a,o,l,c,h=new wv;if(h.eUp=n.anEdge.Sym,r=i.dict.search(h).key,s=e.regionBelow(r)){if(o=r.eUp,l=s.eUp,re.edgeSign(o.Dst,n,o.Org)===0)return void e.connectLeftDegenerate(i,r,n);a=re.vertLeq(l.Dst,o.Dst)?r:s,r.inside||a.fixUpperEdge?(c=a===r?i.mesh.connect(n.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,n.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,c):e.computeWinding(i,e.addRegionBelow(i,r,c)),e.sweepEvent(i,n)):e.addRightEdges(i,r,n.anEdge,n.anEdge,null,!0)}},e.sweepEvent=function(i,n){i.event=n,e.debugEvent(i);for(var r=n.anEdge;r.activeRegion===null;)if((r=r.Onext)===n.anEdge)return void e.connectLeftVertex(i,n);var s=e.topLeftRegion(i,r.activeRegion);he(s!==null);var a=e.regionBelow(s),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,s,l):e.addRightEdges(i,s,l.Onext,o,o,!0)},e.addSentinel=function(i,n,r,s){var a=new wv,o=i.mesh.makeEdge();o.Org.s=r,o.Org.t=s,o.Dst.s=n,o.Dst.t=s,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},e.initEdgeDict=function(i){i.dict=new c4(i,e.edgeLeq);var n=i.bmax[0]-i.bmin[0],r=i.bmax[1]-i.bmin[1],s=i.bmin[0]-n,a=i.bmax[0]+n,o=i.bmin[1]-r,l=i.bmax[1]+r;e.addSentinel(i,s,a,o),e.addSentinel(i,s,a,l)},e.doneEdgeDict=function(i){for(var n,r=0;(n=i.dict.min().key)!==null;)n.sentinel||(he(n.fixUpperEdge),he(++r===1)),he(n.windingNumber===0),e.deleteRegion(i,n)},e.removeDegenerateEdges=function(i){var n,r,s,a=i.mesh.eHead;for(n=a.next;n!==a;n=r)r=n.next,s=n.Lnext,re.vertEq(n.Org,n.Dst)&&n.Lnext.Lnext!==n&&(e.spliceMergeVertices(i,s,n),i.mesh.delete(n),s=(n=s).Lnext),s.Lnext===n&&(s!==n&&((s===r||s===r.Sym)&&(r=r.next),i.mesh.delete(s)),(n===r||n===r.Sym)&&(r=r.next),i.mesh.delete(n))},e.initPriorityQ=function(i){var n,r,s,a=0;for(r=(s=i.mesh.vHead).next;r!==s;r=r.next)a++;for(a+=8,n=i.pq=new h4(a,re.vertLeq),r=(s=i.mesh.vHead).next;r!==s;r=r.next)r.pqHandle=n.insert(r);return r===s&&(n.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,n){var r,s,a;for(r=n.fHead.next;r!==n.fHead;r=s)s=r.next,he((a=r.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,n){var r,s;if(n===void 0&&(n=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(r=i.pq.extractMin())!==null;){for(;(s=i.pq.min())!==null&&re.vertEq(s,r);)s=i.pq.extractMin(),e.spliceMergeVertices(i,r.anEdge,s.anEdge);e.sweepEvent(i,r)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(n&&i.mesh.check(),!0)},e}(),ZN=function(){function e(){this.mesh=new BS,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=fi.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(i,n){return i[0]*n[0]+i[1]*n[1]+i[2]*n[2]},e.prototype.normalize_=function(i){var n=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!n)throw"Zero-size vector!";n=Math.sqrt(n),i[0]/=n,i[1]/=n,i[2]/=n},e.prototype.longAxis_=function(i){var n=0;return Math.abs(i[1])>Math.abs(i[0])&&(n=1),Math.abs(i[2])>Math.abs(i[n])&&(n=2),n},e.prototype.computeNormal_=function(i){var n,r,s,a,o,l,c=[0,0,0],h=[0,0,0],u=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],g=[null,null,null],m=this.mesh.vHead;n=m.next;for(var y=0;y<3;++y)a=n.coords[y],h[y]=a,g[y]=n,c[y]=a,f[y]=n;for(n=m.next;n!==m;n=n.next)for(var v=0;v<3;++v)(a=n.coords[v])<h[v]&&(h[v]=a,g[v]=n),a>c[v]&&(c[v]=a,f[v]=n);var _=0;if(c[1]-h[1]>c[0]-h[0]&&(_=1),c[2]-h[2]>c[_]-h[_]&&(_=2),h[_]>=c[_])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,r=g[_],s=f[_],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],n=m.next;n!==m;n=n.next)d[0]=n.coords[0]-s.coords[0],d[1]=n.coords[1]-s.coords[1],d[2]=n.coords[2]-s.coords[2],p[0]=u[1]*d[2]-u[2]*d[1],p[1]=u[2]*d[0]-u[0]*d[2],p[2]=u[0]*d[1]-u[1]*d[0],(o=p[0]*p[0]+p[1]*p[1]+p[2]*p[2])>l&&(l=o,i[0]=p[0],i[1]=p[1],i[2]=p[2]);l<=0&&(i[0]=i[1]=i[2]=0,i[this.longAxis_(u)]=1)},e.prototype.checkOrientation_=function(){for(var i,n,r=this.mesh.fHead,s=this.mesh.vHead,a=0,o=r.next;o!==r;o=o.next)if(!((n=o.anEdge).winding<=0))do a+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==o.anEdge);if(a<0){for(i=s.next;i!==s;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var i,n,r=this.mesh.vHead,s=[0,0,0],a=!1;s[0]=this.normal[0],s[1]=this.normal[1],s[2]=this.normal[2],!s[0]&&!s[1]&&!s[2]&&(this.computeNormal_(s),a=!0),i=this.sUnit,n=this.tUnit;var o=this.longAxis_(s);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(o+2)%3]=s[o]>0?1:-1;for(var l=r.next;l!==r;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,n);a&&this.checkOrientation_();for(var c=!0,h=r.next;h!==r;h=h.next)c?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,c=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(i,n){i.winding+=n.winding,i.Sym.winding+=n.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,n){var r,s;if((r=n.anEdge).Lnext===r||r.Lnext.Lnext===r)throw"Mono region invalid";for(;re.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;re.vertLeq(r.Org,r.Dst);r=r.Lnext);for(s=r.Lprev;r.Lnext!==s;)if(re.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(re.edgeGoesLeft(s.Lnext)||re.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)s=i.connect(s.Lnext,s).Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(re.edgeGoesRight(r.Lprev)||re.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)r=i.connect(r,r.Lprev).Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)s=i.connect(s.Lnext,s).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var n,r=i.fHead.next;r!==i.fHead;r=n)if(n=r.next,r.inside&&!this.tessellateMonoRegion_(i,r))return!1;return!0},e.prototype.discardExterior_=function(i){for(var n,r=i.fHead.next;r!==i.fHead;r=n)n=r.next,r.inside||i.zapFace(r)},e.prototype.setWindingNumber_=function(i,n,r){for(var s,a=i.eHead.next;a!==i.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?n:-n:r?i.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},e.prototype.outputPolymesh_=function(i,n,r,s){var a,o,l=0,c=0;r>3&&i.mergeConvexFaces(r);for(var h=i.vHead.next;h!==i.vHead;h=h.next)h.n=-1;for(var u=i.fHead.next;u!==i.fHead;u=u.next)if(u.n=-1,u.inside){a=u.anEdge,o=0;do(h=a.Org).n===-1&&(h.n=c,c++),o++,a=a.Lnext;while(a!==u.anEdge);if(o>r)throw"Face vertex greater that support polygon";u.n=l,++l}for(this.elementCount=l,n===An.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*r,this.vertexCount=c,this.vertices=[],this.vertices.length=c*s,this.vertexIndices=[],this.vertexIndices.length=c,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var d=h.n*s;this.vertices[d+0]=h.coords[0],this.vertices[d+1]=h.coords[1],s>2&&(this.vertices[d+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}var p=0;for(u=i.fHead.next;u!==i.fHead;u=u.next)if(u.inside){a=u.anEdge,o=0;do h=a.Org,this.elements[p++]=h.n,o++,a=a.Lnext;while(a!==u.anEdge);for(var f=o;f<r;++f)this.elements[p++]=-1;if(n===An.CONNECTED_POLYGONS){a=u.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==u.anEdge);for(var g=o;g<r;++g)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,n){var r,s,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){s=r=l.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*n,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var c=0,h=0,u=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,s=r=l.anEdge;do this.vertices[c++]=r.Org.coords[0],this.vertices[c++]=r.Org.coords[1],n>2&&(this.vertices[c++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==s);this.elements[u++]=a,this.elements[u++]=o,a+=o}},e.prototype.addContour=function(i,n){this.mesh===null&&(this.mesh=new BS),i<2&&(i=2),i>3&&(i=3);for(var r=null,s=0;s<n.length;s+=i)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=n[s+0],r.Org.coords[1]=n[s+1],r.Org.coords[2]=i>2?n[s+2]:0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(i,n,r,s,a,o){if(i===void 0&&(i=fi.ODD),n===void 0&&(n=An.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),d4.computeInterior(this,o);var l=this.mesh;return n===An.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),n===An.BOUNDARY_CONTOURS?this.outputContours_(l,s):this.outputPolymesh_(l,n,r,s),!0},e}(),fi.ODD,fi.NONZERO,fi.POSITIVE,fi.NEGATIVE,fi.ABS_GEQ_TWO,An.POLYGONS,An.CONNECTED_POLYGONS,An.BOUNDARY_CONTOURS}),y$=z(()=>{(KN=NS=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let i=t*NS.eSize;this.buffer=new ArrayBuffer(i);let n=Float32Array.BYTES_PER_ELEMENT,r=0;this.positions=new Float32Array(this.buffer,r*n,3*t),r+=3*t,this.normals=new Float32Array(this.buffer,r*n,3*t),r+=3*t,this.uvs=new Float32Array(this.buffer,r*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let i=t*NS.eSize,n=new ArrayBuffer(i),r=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(n,s*r,3*t);s+=3*t;let o=new Float32Array(n,s*r,3*t);s+=3*t;let l=new Float32Array(n,s*r,2*t);e?(a.set(this.positions.subarray(0,3*this.size)),o.set(this.normals.subarray(0,3*this.size)),l.set(this.uvs.subarray(0,2*this.size))):(a.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=n,this.positions=a,this.normals=o,this.uvs=l,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let i=this.size;return this.size=e,i}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}}).eSize=8*Float32Array.BYTES_PER_ELEMENT}),_$=z(()=>{QN=class{constructor(t=[],e=(i,n)=>i<n?-1:i>n?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:i}=this,n=e[t];for(;t>0;){let r=t-1>>1,s=e[r];if(i(n,s)>=0)break;e[t]=s,t=r}e[t]=n}_down(t){let{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t<n;){let s=1+(t<<1),a=s+1;if(a<this.length&&i(e[a],e[s])<0&&(s=a),i(e[s],r)>=0)break;e[t]=e[s],t=s}e[t]=r}}});function Sv(t,e,i,n){this.x=t,this.y=e,this.h=i,this.d=function(r,s,a){let o=!1,l=1/0;for(let c of a)for(let h=0,u=c.length,d=u-1;h<u;d=h++){let p=c[h],f=c[d];p[1]>s!=f[1]>s&&r<(f[0]-p[0])*(s-p[1])/(f[1]-p[1])+p[0]&&(o=!o),l=Math.min(l,b$(r,s,p,f))}return l===0?0:(o?1:-1)*Math.sqrt(l)}(t,e,n),this.max=this.d+this.h*Math.SQRT2}function b$(t,e,i,n){let r=i[0],s=i[1],a=n[0]-r,o=n[1]-s;if(a!==0||o!==0){let l=((t-r)*a+(e-s)*o)/(a*a+o*o);l>1?(r=n[0],s=n[1]):l>0&&(r+=a*l,s+=o*l)}return a=t-r,o=e-s,a*a+o*o}var eb,DA,RA,Mv,ib,IA,OA,_h,x$=z(()=>{_$()}),ZC=z(()=>{et(),Sp(),y$(),ii(),x$(),eb={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},DA={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},RA={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Mv=(t,e)=>([i,n])=>(n<i&&(n+=e),(t>=i?t:t+e)<=n),ib=class extends Gt{constructor(t,e,i=0,n=12,r=3,s=fi.ODD,a=!1){super(),this.forPathBevel=a,this.type="ShapeGeometry",this.vertexCache={},this._shape=t,this._depth=e,this._curveSegments=n,this._bevelSegmentsInput=r;let o,l,c,h=this._shape.extractShapePointsToFlatArray([],n),u=this._shape.shapeHoles.map(E=>{let P=E.extractShapePointsToFlatArray([],n),T=[];for(let R=P.length-1;R>=1;R-=2){let L=P[R-1],D=P[R-0];T.push(L,D)}return T}),d=[],p=[];for(let E=0;E<h.length;E+=2)p.push([h[E],h[E+1]]);d.push(p);for(let E=0;E<u.length;E++){let P=u[E],T=[];for(let R=0;R<P.length;R+=2)T.push([P[R],P[R+1]]);d.push(T)}o=t.isText?.1*new Fb().setFromPoints(t.points.map(E=>E.position)).getSize(new it).length():d[0].length===0?i:i>0?function(E,P,T=1,R=!1){let L=1/0,D=1/0,U=-1/0,V=-1/0;for(let[q,lt]of E[0])q<L&&(L=q),lt<D&&(D=lt),q>U&&(U=q),lt>V&&(V=lt);let k=U-L,Y=V-D,$=Math.max(T,Math.min(k,Y));if($===T){let q=[L,D];return q.distance=0,q.distance}let nt=new QN([],(q,lt)=>lt.max-q.max),Q=function(q){let lt=0,F=0,O=0,j=q[0];for(let I=0,G=j.length,W=G-1;I<G;W=I++){let N=j[I],tt=j[W],ot=N[0]*tt[1]-tt[0]*N[1];F+=(N[0]+tt[0])*ot,O+=(N[1]+tt[1])*ot,lt+=3*ot}let Z=new Sv(F/lt,O/lt,0,q);return lt===0||Z.d<0?new Sv(j[0][0],j[0][1],0,q):Z}(E),rt=new Sv(L+k/2,D+Y/2,0,E);rt.d>Q.d&&(Q=rt);let gt=2;function at(q,lt,F){let O=new Sv(q,lt,F,E);if(gt++,O.max>Q.d+T&&nt.push(O),O.d>Q.d&&(Q=O,R&&console.log(`found best ${Math.round(1e4*O.d)/1e4} after ${gt} probes`),Q.d>P))return P}let ht=$/2;for(let q=L;q<U;q+=$)for(let lt=D;lt<V;lt+=$)at(q+ht,lt+ht,ht);for(;nt.length;){let{max:q,x:lt,y:F,h:O}=nt.pop();if(q-Q.d<=T)break;ht=O/2,at(lt-ht,F-ht,ht),at(lt+ht,F-ht,ht),at(lt-ht,F+ht,ht),at(lt+ht,F+ht,ht)}R&&console.log(`num probes: ${gt}
4167
4167
  best distance: ${Q.d}`);let ct=[Q.x,Q.y];return ct.distance=Q.d,ct.distance}(d,i):1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,o,e/2),this._bevelSegments=Math.floor(r));try{l=Ql({windingRule:s,elementType:An.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[h]})}catch{l=eb}try{c=Ql({windingRule:fi.ODD,elementType:An.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{c=DA}if(!l)throw new Error("error generating geometry");let f=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let E=0;E<c.elements.length;E++){let P=c.elements[E],T=E%2==0?l.vertexCount:0;l.elements.push(P+T)}for(let E=0;E<c.vertexIndices.length;E++){let P=c.vertexIndices[E],T=l.vertexCount;l.vertexIndices.push(P+T)}for(let E=0;E<c.vertices.length;E++){let P=c.vertices[E];l.vertices.push(P)}}let g=1/0,m=-1/0,y=1/0,v=-1/0;for(let E=0,P=l.vertexCount;E<P;E++){let T=2*E,R=l.vertices[T+0],L=l.vertices[T+1];R<g&&(g=R),R>m&&(m=R),L<y&&(y=L),L>v&&(v=L)}this._minX=g,this._minY=y,this._width=m-g,this._height=v-y,this._buffer=new KN(this._computeBufferEstimatedSize(l));let _=[],b=[];for(let E=l.elementCount-1;E>=0;E--){let P=E>=f,T=2*E,R=l.elements[T+0],L=l.elements[T+1],D=R+L,U={start:R,count:L,normals:[],continuous:[],concave:[]},V=R,k=D-1,Y=R+1,$=this._shape.roundedCurves.length;do{let at=V-R,ht=l.vertices[2*k+0],ct=l.vertices[2*k+1],q=l.vertices[2*V+0],lt=l.vertices[2*V+1],F=l.vertices[2*Y+0],O=l.vertices[2*Y+1],j=q-ht,Z=lt-ct,I=Math.sqrt(j*j+Z*Z);j/=I,Z/=I;let G=q-F,W=lt-O,N=Math.sqrt(G*G+W*W);G/=N,W/=N,U.normals[2*at+0]=-W,U.normals[2*at+1]=G,U.concave[at]=j*W-Z*G>0;let tt=l.vertexIndices[V];if(Array.isArray(tt))U.continuous[at]=!1;else{let[ot,pt]=this._shape.getCurveIndexFromVertexId(tt-1,!0);if(pt>0&&pt<1)U.continuous[at]=!0;else{let ut=pt===1?ot+1:ot-1;ut=(ut+$)%$;let Pt=pt===1?0:1,bt=this._shape.roundedCurves[ot].getTangent(pt),Rt=this._shape.roundedCurves[ut].getTangent(Pt);U.continuous[at]=bt.dot(Rt)>.95}}P&&(U.normals[2*at+0]*=-1,U.normals[2*at+1]*=-1),[k,V,Y]=[V,Y,Y+1],Y>=D&&(Y-=L)}while(Y!==R+1);let nt=[];nt.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(2*R,2*D),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((at,ht)=>[ht,ht]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(2*R,2*D)});let Q=0;for(let at=1;at<=this._bevelSegments;at++){let ht=at/this._bevelSegments*Math.PI/2,ct=(1-Math.cos(ht))*this._bevel,q=[],lt=[],F=[],O=[],j=0;for(let I=0;I<L;I++){let G=2*I,W=(I-1+L)%L*2,N=l.vertices[2*U.start+G+0],tt=l.vertices[2*U.start+G+1],ot=-U.normals[W+0]*ct,pt=-U.normals[W+1]*ct,ut=-U.normals[G+0]*ct,Pt=-U.normals[G+1]*ct;if(U.concave[I]||!U.concave[I]&&P){let bt=Math.atan2(pt,ot),Rt=Math.atan2(Pt,ut);Rt>bt&&(Rt-=2*Math.PI);let _t=Rt-bt;if(U.continuous[I]||P){let X=bt+_t/2,vt=Math.cos(X)*ct,Dt=Math.sin(X)*ct;q[2*j+0]=N+vt*(P?-1:1),q[2*j+1]=tt+Dt*(P?-1:1),O[j]=I,j++}else{let X=Math.max(1,Math.floor(n/4*Math.abs(_t)/Math.PI));for(let vt=0;vt<=X;vt++){let Dt=bt+_t*(vt/X),jt=Math.cos(Dt)*ct,Ft=Math.sin(Dt)*ct;q[2*j+0]=N+jt,q[2*j+1]=tt+Ft,O[j]=I,j++}}}else q[2*j+0]=N+ot,q[2*j+1]=tt+pt,O[j]=I,lt[I]=j,j++,q[2*j+0]=N,q[2*j+1]=tt,O[j]=I,j++,q[2*j+0]=N+ut,q[2*j+1]=tt+Pt,O[j]=I,F[I]=j,j++}let Z=Ql({windingRule:fi.POSITIVE,elementType:An.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[q],edgeCreateCallback:I=>{let G=I.Org.idx,W=O[G],N=O[(G+1)%O.length];I.idx=[W,N],I.Sym.idx=[N,W]},vertexIdCallback:I=>{let G=I.Lprev.idx;return[G?G[1]:0,I.idx?I.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${at}'th loop`);if(!Z.vertexCount){let I=(at-1)/this._bevelSegments*Math.PI/2;Q=(1-Math.sin(I))*this._bevel;break}for(let I=0;I<Z.vertexIndices.length;I++){let[G,W]=Z.vertexIndices[I];if(G===W)continue;let N=W;W<G&&(N+=L);for(let tt=G;tt<N;tt++){let ot=tt%L,pt=(tt+1)%L;if(!U.continuous[ot]||!U.continuous[pt]){Z.vertexIndices[I]=[G,ot],Z.vertexIndices.splice(I+1,0,[pt,W]),Z.vertices.splice(2*(I+1),0,Z.vertices[2*I],Z.vertices[2*I+1]);break}}}nt.push({bevelI:at,angle:ht,size:ct,boundary:Z,reverseMap:O,insetPoints:q})}let rt=(at,ht,ct)=>{let q=0,lt=at.boundary.vertexIndices.length;for(;q<lt&&ct(at.boundary.vertexIndices[ht]);)ht=(ht+1)%lt,q++;return q},gt=_.length;for(let at=1;at<nt.length;at++){let ht=nt[at-1],ct=nt[at],q=ht.boundary.vertexIndices.length,lt=ct.boundary.vertexIndices.length;if(!q||!lt)break;let F=U.concave.length,O=0,j=Mv(O,L);for(;!ht.boundary.vertexIndices.filter(j).length||!ct.boundary.vertexIndices.filter(j).length;)O++,j=Mv(O,L);let Z=ht.boundary.vertexIndices.findIndex(j),I=ct.boundary.vertexIndices.findIndex(j);do Z=(Z+1)%q;while(j(ht.boundary.vertexIndices[Z]));do I=(I+1)%lt;while(j(ct.boundary.vertexIndices[I]));O=(O+1)%L;let G,W,N=O,tt=0,ot=this._buildBevelVert(U,ht,(Z-1+q)%q,void 0,tt),pt=this._buildBevelVert(U,ct,(I-1+lt)%lt,void 0,tt),ut=!1;do{tt=(O||F)/F,j=Mv(O,L);let Pt=rt(ht,Z,j),bt=rt(ct,I,j),Rt=ut;if(ut=!1,Pt&&!bt){for(let _t=0;_t<Pt;_t++)G=this._buildBevelVert(U,ht,(Z+_t)%q,_t/(Pt-1),tt),_.push(ot.topN,G.topP,pt.topN),a===!1&&_.push(G.bottomP,ot.bottomN,pt.bottomN),ot=G;ut=!0}else if(!Pt&&bt)for(let _t=0;_t<bt;_t++)W=this._buildBevelVert(U,ct,(I+_t)%lt,_t/(bt-1),tt),_.push(pt.topN,ot.topP,W.topP),a===!1&&_.push(ot.bottomP,pt.bottomN,W.bottomP),pt=W;else if(Pt&&bt)if(G=this._buildBevelVert(U,ht,Z,0,tt),W=this._buildBevelVert(U,ct,I,0,tt),Rt?(_.push(ot.topN,W.topP,pt.topN),_.push(ot.topN,G.topP,W.topP),a===!1&&(_.push(W.bottomP,ot.bottomN,pt.bottomN),_.push(W.bottomP,G.bottomP,ot.bottomN))):(_.push(pt.topN,ot.topN,G.topP),_.push(pt.topN,G.topP,W.topP),a===!1&&(_.push(G.bottomP,ot.bottomN,pt.bottomN),_.push(G.bottomP,pt.bottomN,W.bottomP))),ot=G,pt=W,Pt===bt)for(let _t=1;_t<Pt;_t++)G=this._buildBevelVert(U,ht,(Z+_t)%q,_t/(Pt-1),tt),W=this._buildBevelVert(U,ct,(I+_t)%lt,_t/(bt-1),tt),_.push(ot.topN,G.topP,pt.topN),_.push(pt.topN,G.topP,W.topP),a===!1&&(_.push(G.bottomP,ot.bottomN,pt.bottomN),_.push(G.bottomP,pt.bottomN,W.bottomP)),ot=G,pt=W;else if(Pt>bt){let _t=Pt/bt,X=0;for(let vt=1;vt<Pt;vt++)G=this._buildBevelVert(U,ht,(Z+vt)%q,vt/(Pt-1),tt),_.push(ot.topN,G.topP,pt.topN),a===!1&&_.push(G.bottomP,ot.bottomN,pt.bottomN),ot=G,vt>(X+1)*_t&&(X++,W=this._buildBevelVert(U,ct,(I+X)%lt,X/(bt-1),tt),_.push(pt.topN,G.topP,W.topP),a===!1&&_.push(G.bottomP,pt.bottomN,W.bottomP),pt=W)}else{let _t=bt/Pt,X=0;for(let vt=1;vt<bt;vt++)W=this._buildBevelVert(U,ct,(I+vt)%lt,vt/(bt-1),tt),_.push(pt.topN,G.topP,W.topP),a===!1&&_.push(G.bottomP,pt.bottomN,W.bottomP),pt=W,vt>(X+1)*_t&&(X++,G=this._buildBevelVert(U,ht,(Z+X)%q,X/(Pt-1),tt),_.push(ot.topN,G.topP,pt.topN),a===!1&&_.push(G.bottomP,ot.bottomN,pt.bottomN),ot=G)}Z=(Z+Pt)%q,I=(I+bt)%lt,O=(O+1)%F}while(O!==N)}if(a===!1&&this._depth>2*this._bevel&&this._buildWall(nt,U,_),P){let at=[];for(let ht=_.length-1;ht>=gt+2;ht-=3){let ct=_[ht-2],q=_[ht-1],lt=_[ht-0];at.push(lt,q,ct)}_.splice(gt,_.length-gt,...at)}if(P){let at=[];for(let ht=nt[nt.length-1].boundary.vertices.length-1;ht>=1;ht-=2){let ct=nt[nt.length-1].boundary.vertices[ht-1],q=nt[nt.length-1].boundary.vertices[ht-0];at.push(ct,q)}b.push(at)}if(!P){let at,ht=nt[nt.length-1];try{at=Ql({windingRule:nt.length>1?fi.POSITIVE:fi.ODD,elementType:An.POLYGONS,vertexSize:2,strict:!0,contours:[ht.insetPoints,...b]})}catch{at=RA}if(!at)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<o&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ct=0;ct<3*at.elementCount;ct+=3){let q=this._buildSurfaceVert(at,at.elements[ct+0],Q),lt=this._buildSurfaceVert(at,at.elements[ct+1],Q),F=this._buildSurfaceVert(at,at.elements[ct+2],Q);_.push(q.top,lt.top,F.top),a===!1&&_.push(F.bottom,lt.bottom,q.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Ht(Uint32Array.from(_),1),w=new Ht(this._buffer.positions,3),S=new Ht(this._buffer.normals,3),A=new Ht(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,A.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",A),this.setIndex(x)}_computeBufferEstimatedSize(t){return 2*t.vertexCount*(2+this._bevelSegments)}_buildWall(t,e,i){let n=t[0];for(let r=0,s=n.boundary.vertexCount;r<s;r++){let a=this._buildBevelVert(e,n,r),o=this._buildBevelVert(e,n,(r+1)%s);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(t,e,i){let n=e.toString();if(n in this.vertexCache)return this.vertexCache[n];let r=t.vertices[2*e+0],s=t.vertices[2*e+1],a=(r-this._minX)/this._width,o=(s-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),c=3*l,h=2*l,u={top:l+0,bottom:l+1};return this._buffer.positions[c+0]=r,this._buffer.positions[c+1]=s,this._buffer.positions[c+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[h+0]=a,this._buffer.uvs[h+1]=o,this.forPathBevel===!1&&(this._buffer.positions[c+3]=r,this._buffer.positions[c+4]=s,this._buffer.positions[c+5]=i,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[h+2]=a,this._buffer.uvs[h+3]=o),this.vertexCache[n]=u,u}_buildBevelVert(t,e,i,n=1,r){let s=`${e.bevelI}:${i}`;if(s in this.vertexCache&&r!==0&&r!==1&&(!r||r===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let a,o,l,c,[h,u]=e.boundary.vertexIndices[i];h!==u?(o=h,a=u,c=!1,l=t.continuous[o]&&t.continuous[a]):(a=h,o=(a-1+t.count)%t.count,c=t.concave[a]&&e.bevelI>0,l=t.continuous[a]||c);let d=Math.cos(e.angle),p=Math.sin(e.angle),f=2*i,g=2*a,m=2*o,y=e.boundary.vertices[f+0],v=e.boundary.vertices[f+1],_=(1-p)*this._bevel,b=(y-this._minX)/this._width,x=(v-this._minY)/this._height;this.forPathBevel&&(r!==void 0&&(b=r),x=1);let w=t.normals[g+0],S=t.normals[g+1],A=t.normals[m+0],E=t.normals[m+1];if(c){w+=(A-w)*(1-n),S+=(E-S)*(1-n);let D=Math.sqrt(w*w+S*S);w/=D,S/=D}let P=this.forPathBevel?this._buffer.get(l?1:2):this._buffer.get(l?2:4),T=3*P,R=2*P,L={i,fi:a,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:r};return this._buffer.positions[T+0]=y,this._buffer.positions[T+1]=v,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-_,this._buffer.normals[T+0]=w*d,this._buffer.normals[T+1]=S*d,this._buffer.normals[T+2]=p,this._buffer.uvs[R+0]=b,this._buffer.uvs[R+1]=x,this.forPathBevel===!1&&(this._buffer.positions[T+3]=y,this._buffer.positions[T+4]=v,this._buffer.positions[T+5]=_,this._buffer.normals[T+3]=w*d,this._buffer.normals[T+4]=S*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[R+2]=x,this._buffer.uvs[R+3]=b),l||(this.forPathBevel?(P+=1,T+=3,R+=2):(P+=2,T+=6,R+=4),L.topP=P+0,L.bottomP=P+1,this._buffer.positions[T+0]=y,this._buffer.positions[T+1]=v,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-_,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=E*d,this._buffer.normals[T+2]=p,this._buffer.uvs[R+0]=b,this._buffer.uvs[R+1]=x,this.forPathBevel===!1&&(this._buffer.positions[T+3]=y,this._buffer.positions[T+4]=v,this._buffer.positions[T+5]=_,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=E*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[R+2]=x,this._buffer.uvs[R+3]=b)),this.vertexCache[s]=L,L}clone(){let t=new ib(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=kb(this.userData),t}}}),JN=z(()=>{et(),Sp(),ii(),ZC(),IA=class extends Gt{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=fi.ODD,this.elementType=An.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:fi.ODD,elementType:An.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let n,r,s,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,c=!0;for(let d=0,p=a.length/2;d<p;d++){let f=2*d,g=a[f+0],m=a[f+1];if(r!==void 0&&g!==r&&(l=!1),s!==void 0&&m!==s&&(c=!1),r=g,s=m,!l&&!c)break}if(!l&&!c)try{n=Ql({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=eb}let h=n?.vertexCount??1,u=n?.elementCount??1;if(this._positionAttribute=new Ht(new Float32Array(3*h),3),this._normalAttribute=new Ht(new Float32Array(3*h),3),this._uvAttribute=new Ht(new Float32Array(2*h),2),this._indexAttribute=new Ht(new Uint32Array(3*u),1),n){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let v=0,_=h;v<_;v++){let b=2*v,x=n.vertices[b+0],w=n.vertices[b+1];x<d&&(d=x),x>p&&(p=x),w<f&&(f=w),w>g&&(g=w)}let m=p-d,y=g-f;for(let v=0,_=h;v<_;v++){let b=2*v,x=n.vertices[b+0],w=n.vertices[b+1],S=(x-d)/m,A=(w-f)/y;this._positionAttribute.setXYZ(v,x,w,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,S,A)}for(let v=0,_=u;v<_;v++){let b=3*v,x=n.elements[b+0],w=n.elements[b+1],S=n.elements[b+2];this._indexAttribute.setX(b+0,x),this._indexAttribute.setX(b+1,w),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(n?.elementCount??1))}clone(){let t=new IA(this._shape,this._curveSegments);return t.userData=kb(this.userData),t}}}),w$=z(()=>{Sp(),ii(),ZC(),OA=class extends ib{constructor(t,e,i=0,n=12,r=3,s=fi.ODD){super(t,e,i,n,r,s),this.type="ShapeGeometry"}_computeBufferEstimatedSize(t){return 2*t.vertexCount*(2+this._bevelSegments)}_buildWall(t,e,i){let n=t[0];for(let r=0,s=n.boundary.vertexCount;r<s;r++){let a=this._buildBevelVert(e,n,r),o=this._buildBevelVert(e,n,(r+1)%s);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let t=new OA(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=kb(this.userData),t}}}),dh=z(()=>{yh(),JN(),w$(),Sp(),_h=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,n=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:fi.ODD},t.parameters),r=Math.abs(n.width),s=Math.abs(n.height??n.width),a=Math.abs(n.depth??0),o=t.shape??e?.shape,l=o?.roundness??n.roundness;o!==void 0&&(o instanceof Ni?(i=o,(i.width!==r||i.height!==s)&&i.applySize(r,s)):i=new Ni(r,s).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let c=i??new Ni(r,s);return{parameters:Object.assign(n,{width:r,height:s,depth:a,roundness:l}),shape:c}}static build(t){let e,{depth:i,extrudeBevelSize:n,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:o}=t.parameters;return t.shape.roundness=a,e=i<=0?new IA(t.shape,s,{windingRule:o}):new OA(t.shape,i,n,s,r,o),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function S$(t,e,i,n,r,s){if(n>=KC)return r>30||r%4==0?(function(h,u,d,p=0,f=0,g=0){let m=.5522847498,y=u*m,v=d*m;h.addPoint(Ev(f-u,g,f-u,g-v,f-u,g+v)),h.addPoint(Ev(f,g+d,f-y,g+d,f+y,g+d)),h.addPoint(Ev(f+u,g,f+u,g+v,f+u,g-v)),h.addPoint(Ev(f,g-d,f+y,g-d,f-y,g-d)),p>0&&ek(h,u,d,p)}(t,e,i,s),Math.round(r/4)):u4(t,n,r,e,i,s);let a={x:0,y:i},o=(n=Math.max(n,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},c=function({px:h,py:u,cx:d,cy:p,rx:f,ry:g,largeArcFlag:m,sweepFlag:y}){let v=[];if(f===0||g===0)return[];let _=(h-d)/2,b=(u-p)/2;if(_===0&&b===0)return[];f=Math.abs(f),g=Math.abs(g);let x=Math.pow(_,2)/Math.pow(f,2)+Math.pow(b,2)/Math.pow(g,2);x>1&&(f*=Math.sqrt(x),g*=Math.sqrt(x));let w=function(L,D,U,V,k,Y,$,nt,Q,rt){let gt=Math.pow(k,2),at=Math.pow(Y,2),ht=Math.pow($,2),ct=Math.pow(nt,2),q=gt*at-gt*ct-at*ht;q<0&&(q=0),q/=gt*ct+at*ht,q=Math.sqrt(q)*(Q===rt?-1:1);let lt=q*k/Y*nt,F=q*-Y/k*$,O=lt+(L+U)/2,j=F+(D+V)/2,Z=($-lt)/k,I=(nt-F)/Y,G=(-$-lt)/k,W=(-nt-F)/Y,N=l4(1,0,Z,I),tt=l4(Z,I,G,W);return!rt&&tt>0&&(tt-=v1),rt&&tt<0&&(tt+=v1),{centerx:O,centery:j,ang1:N,ang2:tt}}(h,u,d,p,f,g,_,b,m,y),{ang1:S,ang2:A}=w,{centerx:E,centery:P}=w,T=Math.abs(A)/(v1/4);Math.abs(1-T)<1e-7&&(T=1);let R=Math.max(Math.ceil(T),1);A/=R;for(let L=0;L<R;L++)v.push(g$(S,A)),S+=A;return v.map(L=>{let{x:D,y:U}=LS(L[0],f,g,E,P),{x:V,y:k}=LS(L[1],f,g,E,P),{x:Y,y:$}=LS(L[2],f,g,E,P);return{x1:D,y1:U,x2:V,y2:k,x:Y,y:$}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%c.length===0?function(h,u,d,p,f,g,m,y){let v=Math.round(f/p.length);h.addPoint(Ku(u,d));for(let _=0,b=p.length;_<b;_++){let x=p[_],w=h.points[_],S=Ku(x.x,x.y);w.controls[1].position.set(x.x1,x.y1),S.controls[0].position.set(x.x2,x.y2),h.addPoint(S)}return y>0?tk(h,g,m,y):h.addPoint(Ku(0,0)),v}(t,a.x,a.y,c,r,e,i,s):u4(t,n,r,e,i,s)}function u4(t,e,i,n,r,s){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,c=Math.sin(l)*n,h=Math.cos(l)*r;t.addPoint(Ku(c,h))}return e<KC?s>0?tk(t,n,r,s):t.addPoint(Ku(0,0)):(t.removePoint(t.points[t.points.length-1]),s>0&&ek(t,n,r,s)),1}function Ku(t,e){return new Uc(Ot.generateUUID(),new it(t,e))}function Ev(t,e,i,n,r,s){let a=Ku(t,e);return a.controls[0].position.set(i,n),a.controls[1].position.set(r,s),a}function tk(t,e,i,n){ik(t,e,i,n).forEach(r=>t.addPoint(r))}function ek(t,e,i,n){let r=ik(t,e,i,n),s=new Ni;r.forEach(a=>s.addPoint(a)),s.isClosed=!0,t.shapeHoles.push(s)}function ik(t,e,i,n){let r=n*e/100,s=r*(Math.abs(i)/Math.abs(e)),a=new it(r/e,s/i),o=t.points.map(l=>{let c=l.clone();return c.uuid=Ot.generateUUID(),c}).reverse();return o.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),h=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(h),l.controls[1].position.copy(c)}),o}var KC,ix,nk,kS,rk,nb=z(()=>{yh(),YN(),v$(),dh(),et(),KC=2*Math.PI,ix=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return i.angle=Ot.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof Ni?t.shape:new Ni,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let e,{width:i,height:n,spikes:r,angle:s,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:c}=t.parameters,h=t.shape,u=S$(h,.5*i,.5*n,s*Math.PI/180,r,a);return h.isClosed=!0,h.update(),s===0?(e=new Gt,e.setAttribute("position",new Nt([],3))):e=_h.create({shape:h,parameters:{subdivisions:u,depth:o,extrudeBevelSize:l,extrudeBevelSegments:c}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),p4=z(()=>{et(),GN(),nk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:n,detail:r,corner:s,cornerSides:a}=t.parameters,o=r===0&&s!==0?new kS(.5*e,s,a):new pE(.5*e,r),l=i/e,c=n/e;return(l!==1||c!==1)&&o.scale(1,l,c),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},kS=class extends J_{constructor(t=1,e=.2,i=4){let n=(1+Math.sqrt(5))/2,r="IcosahedronGeometry";super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],r,t,e,i),this.type=r}static fromJSON(t){return new kS(t.radius,t.corner,t.cornerSides)}}}),f4=z(()=>{et(),rk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let i=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{points:e,segments:i,verticalSegments:n}=t.parameters,r=new Sg;r.moveTo(e[0].x,e[0].y),r.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new fE(r.extractPoints(n).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...t,type:"LatheGeometry"}})}}});function Ud(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function M$(t){let{positions:e,faces:i,materialIndices:n,uvs:r}=t,s=e.length/3,a=i.length/3,o=r!==null&&a>0,l=3*a,c=new Uint32Array(l),h=new Uint32Array(l),u=new Uint32Array(l),d=new Uint32Array(l),p=new Uint32Array(l),f=0,g=8;for(;g<2*l;)g*=2;let m=g-1,y=new Int32Array(g).fill(-1),v=(D,U)=>{let V=(Math.imul(D,2654435761)^U)&m;for(;;){let k=y[V];if(k===-1)return y[V]=f,c[f]=D,h[f]=U,f++;if(c[k]===D&&h[k]===U)return k;V=V+1&m}},_=(D,U)=>{let V=D<U?D:U,k=D<U?U:D,Y=(Math.imul(V,2654435761)^k)&m;for(;;){let $=y[Y];if(c[$]===V&&h[$]===k)return $;Y=Y+1&m}},b=new Uint32Array(s),x=new Float64Array(3*s),w=(D,U,V)=>{let k=D<U?v(D,U):v(U,D),Y=++u[k];Y===1?d[k]=V:Y===2&&(p[k]=V),b[D]++,b[U]++,x[3*D]+=e[3*U],x[3*D+1]+=e[3*U+1],x[3*D+2]+=e[3*U+2],x[3*U]+=e[3*D],x[3*U+1]+=e[3*D+1],x[3*U+2]+=e[3*D+2]};for(let D=0;D<a;D++){let U=i[3*D],V=i[3*D+1],k=i[3*D+2];w(U,V,k),w(V,k,U),w(k,U,V)}let S=new Float64Array(3*f);for(let D=0;D<f;D++){let U=3*c[D],V=3*h[D];if(u[D]===2){let k=3*d[D],Y=3*p[D];S[3*D]=.375*(e[U]+e[V])+.125*(e[k]+e[Y]),S[3*D+1]=.375*(e[U+1]+e[V+1])+.125*(e[k+1]+e[Y+1]),S[3*D+2]=.375*(e[U+2]+e[V+2])+.125*(e[k+2]+e[Y+2])}else S[3*D]=.5*(e[U]+e[V]),S[3*D+1]=.5*(e[U+1]+e[V+1]),S[3*D+2]=.5*(e[U+2]+e[V+2])}let A,E=new Float64Array(3*s);for(let D=0;D<s;D++){let U=b[D];U===3?A=3/16:U>3&&(A=3/(8*U));let V=1-U*Number(A),k=Number(A);U===2&&(V=3/4,k=1/8),E[3*D]=e[3*D]*V+x[3*D]*k,E[3*D+1]=e[3*D+1]*V+x[3*D+1]*k,E[3*D+2]=e[3*D+2]*V+x[3*D+2]*k}let P=new Float64Array(3*(s+f));P.set(E),P.set(S,3*s);let T=new Uint32Array(12*a),R=new Array(4*a),L=o?new Float64Array(24*a):null;for(let D=0;D<a;D++){let U=i[3*D],V=i[3*D+1],k=i[3*D+2],Y=_(U,V)+s,$=_(V,k)+s,nt=_(k,U)+s,Q=12*D;T[Q++]=Y,T[Q++]=$,T[Q++]=nt,T[Q++]=U,T[Q++]=Y,T[Q++]=nt,T[Q++]=V,T[Q++]=$,T[Q++]=Y,T[Q++]=k,T[Q++]=nt,T[Q++]=$;let rt=n[D];if(R[4*D]=rt,R[4*D+1]=rt,R[4*D+2]=rt,R[4*D+3]=rt,L!==null){let gt=6*D,at=r[gt],ht=r[gt+1],ct=r[gt+2],q=r[gt+3],lt=r[gt+4],F=r[gt+5],O=Ud(at,ct),j=Ud(ht,q),Z=Ud(ct,lt),I=Ud(q,F),G=Ud(at,lt),W=Ud(ht,F),N=24*D;L[N++]=O,L[N++]=j,L[N++]=Z,L[N++]=I,L[N++]=G,L[N++]=W,L[N++]=at,L[N++]=ht,L[N++]=O,L[N++]=j,L[N++]=G,L[N++]=W,L[N++]=ct,L[N++]=q,L[N++]=Z,L[N++]=I,L[N++]=O,L[N++]=j,L[N++]=lt,L[N++]=F,L[N++]=G,L[N++]=W,L[N++]=Z,L[N++]=I}}return{positions:P,faces:T,materialIndices:R,uvs:L}}var Av,sk,wn,ak,QC,E$=z(()=>{et(),Av=1e4,sk=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(n){let r=n.getAttribute("position");if(r===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let s=n.getAttribute("uv"),a=n.getIndex(),o=r.count,l=new Map,c=new Uint32Array(o),h=[],u=0;for(let v=0;v<o;v++){let _=r.getX(v),b=r.getY(v),x=r.getZ(v),w=Math.round(_*Av),S=Math.round(b*Av),A=Math.round(x*Av),E=l.get(w);E===void 0&&(E=new Map,l.set(w,E));let P=E.get(S);P===void 0&&(P=new Map,E.set(S,P));let T=P.get(A);T===void 0&&(T=u++,P.set(A,T),h.push(_,b,x)),c[v]=T}let d=[],p=[],f=s===void 0?null:[],g=a!==null?a.count:o,m=(v,_)=>{let b=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,w=a!==null?a.getX(v+2):v+2;if(!(b<o&&x<o&&w<o))return;let S=c[b],A=c[x],E=c[w];S===A||A===E||E===S||(d.push(S,A,E),p.push(_),f!==null&&f.push(s.getX(b),s.getY(b),s.getX(x),s.getY(x),s.getX(w),s.getY(w)))},y=n.groups;if(y.length>0)for(let v=0;v<y.length;v++){let _=y[v],b=_.materialIndex===void 0?0:_.materialIndex,x=Math.max(_.start,0),w=Math.min(_.start+_.count,g);for(let S=x;S<w&&S+2<g;S+=3)m(S,b)}else for(let v=0;v+2<g;v+=3)m(v,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(d),materialIndices:p,uvs:f===null?null:Float64Array.from(f)}}(t),i=this.subdivisions;for(;i-- >0;)e=M$(e);return function(n,r){let{positions:s,faces:a,materialIndices:o,uvs:l}=n,c=s.length/3,h=a.length/3,u=new Float64Array(3*c);for(let y=0;y<h;y++){let v=3*a[3*y],_=3*a[3*y+1],b=3*a[3*y+2],x=s[b]-s[_],w=s[b+1]-s[_+1],S=s[b+2]-s[_+2],A=s[v]-s[_],E=s[v+1]-s[_+1],P=s[v+2]-s[_+2],T=w*P-S*E,R=S*A-x*P,L=x*E-w*A;u[v]+=T,u[v+1]+=R,u[v+2]+=L,u[_]+=T,u[_+1]+=R,u[_+2]+=L,u[b]+=T,u[b+1]+=R,u[b+2]+=L}for(let y=0;y<c;y++){let v=u[3*y],_=u[3*y+1],b=u[3*y+2],x=Math.sqrt(v*v+_*_+b*b)||1;u[3*y]=v/x,u[3*y+1]=_/x,u[3*y+2]=b/x}let d=3*h,p=new Float32Array(3*d),f=new Float32Array(3*d),g=l!==null&&l.length>0?new Float32Array(2*d):null;for(let y=0;y<d;y++){let v=3*a[y];p[3*y]=s[v],p[3*y+1]=s[v+1],p[3*y+2]=s[v+2],f[3*y]=u[v],f[3*y+1]=u[v+1],f[3*y+2]=u[v+2]}g!==null&&g.set(l.subarray(0,2*d));let m=new Gt;m.setAttribute("position",new Ht(p,3)),d>0&&(m.setAttribute("normal",new Ht(f,3)),m.setAttribute("color",new Ht(new Float32Array(3*d).fill(1),3))),g!==null&&m.setAttribute("uv",new Ht(g,2));for(let y=0;y<h;){let v=o[y],_=y;do y++;while(y<h&&o[y]===v);m.addGroup(3*_,3*(y-_),v)}return r.boundingBox!==null&&(m.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(m.boundingSphere=r.boundingSphere.clone()),m}(e,t)}}}),m4=z(()=>{et(),E$(),wn=new C,ak=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,n=t.geometry??e?.geometry??new Gt().copy(new ga(100,100,100));e===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(wn),i={width:wn.x,height:wn.y,depth:wn.z,subdivisions:0}):i=e.parameters;let r={...i,...t.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:n}}static build(t){let{width:e,height:i,depth:n,subdivisions:r}=t.parameters,s=t.geometry??new Gt().copy(new ga(100,100,100)),a=s.userData.parameters;a===void 0?(s.boundingBox=function(l){let c=new ci,h=l.attributes.position;return h?(c.setFromBufferAttribute(h),c):(c.makeEmpty(),c)}(s),s.boundingBox.getSize(wn)):wn.set(a.width,a.height,a.depth),(e!==wn.x||i!==wn.y||n!==wn.z)&&s.scale(wn.x===0?1:e/wn.x,wn.y===0?1:i/wn.y,wn.z===0?1:n/wn.z);let o=s.originalGeometry;try{r>0?(o===void 0||a?.subdivisions!==r)&&(o===void 0&&(o=s),s=new sk(r).modify(o)):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete t.geometry,Object.assign(s,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new oC(i).load(t,n=>{let r=this.normalizeInputs({geometry:n});n.boundingBox.getSize(wn);let s=100/wn.x;Object.assign(r.parameters,{width:100,height:wn.y*s,depth:wn.z*s}),e(this.build(r))})}}}),LA=z(()=>{yh(),dh(),QC=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},t.parameters);return{shape:t.shape&&t.shape instanceof Ni?t.shape:new Ni,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,spikes:n,cornerRadius:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o}=t.parameters,l=t.shape,c=.5*e,h=.5*i,u=2*Math.PI/n;for(let p=0;p<n;p++){let f=u*p,g=0+Math.sin(f)*c,m=0+Math.cos(f)*h;l.addPoint(l.createPoint(g,m))}l.isClosed=!0;for(let p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=_h.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...t,type:"PolygonGeometry"}})}}});function Lf(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function VS(t,e,i,n,r,s){let a=lk.copy(e).sub(t),o=hk.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),n===r){let c=a.add(o).normalize();s.copy(t).addScaledVector(c,n/Math.sin(l/2))}else{let c=a.angleTo(o);s.copy(t),s.addScaledVector(a,r/Math.sin(c)),s.addScaledVector(o,n/Math.sin(c))}}function A$(t,e,i){let n=t.clone().sub(e),r=i.clone().sub(e);return n.projectOnVector(r),n.add(e)}var ok,lk,hk,g4,nx,ck,dk,uk,v4,JC,pk,fk,mk,gk,y4=z(()=>{et(),ok=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:n,radialSegments:r,heightSegments:s,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,c=new g4(.5*e,i,r,s,a,o,l),h=n/e;return h!==1&&c.scale(1,1,h),Object.assign(c,{userData:{...t,type:"PyramidGeometry"}})}},lk=new C,hk=new C,g4=class extends Gt{constructor(t=.5,e=1,i=4,n=1,r=!1,s=0,a=4){super(),i=Math.floor(Math.max(3,i)),n=Math.floor(n),a=Math.floor(a);let o,l=[],c=[],h=[],u=[],d=0,p=e/2,f=Math.PI/i,g=t*Math.cos(Math.PI/i),m=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,_=new C(0,-p,0),b=new C(0,p,0),x=new it(t,-p),w=new it(g,-p),S=new it(0,b.y).sub(w),A=new it(0,b.y).sub(x),E=new it(S.y,-S.x).normalize(),P=new it(A.y,-A.x).normalize(),T=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;s=Math.min(s,T);{let Y=new C(E.x,E.y,0),$=new C(Math.cos(m)*Y.x,Y.y,Math.sin(m)*Y.x);o=Y.angleTo($)}let R=s/Math.tan((Math.PI-S.angle())/2),L=s/Math.tan((Math.PI-o)/2),D=new C;if(!r){c.push(_.x,_.y,_.z),h.push(0,-1,0),u.push(0,0);let Y=d++,$=[],nt=x.clone(),Q=R/Math.cos(Math.PI/i);nt.x-=Q;for(let rt=0;rt<i;rt++){let gt=rt/i*Math.PI*2+f;Lf(nt,new it(Math.sin(gt),Math.cos(gt)),D),c.push(D.x,D.y,D.z),h.push(0,-1,0),u.push(0,0),$.push(d++)}for(let rt=0;rt<$.length;rt++)l.push($[rt],Y,$[(rt+1)%$.length])}let U=[];{let Y=new C,$=new C,nt=new C,Q=new C,rt=new C,gt=new C;for(let at=0;at<i;at++){let ht=at/i*Math.PI*2+f,ct=(at+.5)/i*Math.PI*2+f,q=(at+1)/i*Math.PI*2+f,lt=new it(Math.sin(ht),Math.cos(ht)),F=new it(Math.sin(ct),Math.cos(ct)),O=new it(Math.sin(q),Math.cos(q));Lf(x,lt,$),Lf(x,O,nt),Lf(E,F,Y),VS(b,$,nt,L,L,Q),c.push(Q.x,Q.y,Q.z),VS($,b,nt,L,R,rt),c.push(rt.x,rt.y,rt.z),VS(nt,$,b,R,L,gt),c.push(gt.x,gt.y,gt.z),h.push(Y.x,Y.y,Y.z),h.push(Y.x,Y.y,Y.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),u.push(0,0),u.push(0,0);let j=d++,Z=d++,I=d++;if(l.push(j,Z,I),s>0){{let N=$.clone().add(nt).multiplyScalar(.5),tt=b.clone().sub(N).normalize(),ot=_.clone().sub(N).normalize().add(tt).normalize().multiplyScalar(-1);V(N,gt.clone().sub(rt),ot,S.angle())}let G,W;{let N=new C;Lf(P,O,N);let tt=gt.clone().add(Q).multiplyScalar(.5);tt=A$(tt,nt,b);let ot=gt.clone().sub(Q);[G,W]=V(tt,ot,N,o,Q.y)}{let N=G,tt=N.clone().setY(0).normalize(),ot=new C(0,-1,0),pt=tt.clone().cross(ot);k(N,tt,ot,pt)}U.concat(W);{let N=S.angle(),tt=Math.PI-N,ot=b.clone();ot.y-=s/Math.sin(N-Math.PI/2);let pt=new C,ut=[];for(let bt=0;bt<a;bt++){let Rt=[],_t=Math.PI/2-tt*bt/a,X=Math.cos(_t),vt=Math.sin(_t),Dt=ct;for(let jt=0;jt<=bt;jt++){let Ft=Math.cos(Dt),_e=Math.sin(Dt);Y.x=X*_e,Y.y=vt,Y.z=X*Ft,pt.copy(ot).addScaledVector(Y,s),c.push(pt.x,pt.y,pt.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),Rt.push(d++),Dt+=2*Math.PI/bt/i}ut.push(Rt)}W.reverse(),ut.push(W);let Pt=ut.length-1;for(let bt=0;bt<Pt;bt++){let Rt=ut[bt],_t=ut[bt+1],X=Rt.length-1;l.push(_t[1],Rt[0],_t[0]);for(let vt=1;vt<=X;vt++)l.push(Rt[vt],Rt[vt-1],_t[vt]),l.push(_t[vt+1],Rt[vt],_t[vt])}}}}}function V(Y,$,nt,Q,rt){let gt=-Q/2,at=(Math.PI-Q)/2,ht=$.clone().normalize().cross(nt);Y.addScaledVector(nt,-s/Math.sin(at));let ct=new C,q=new C,lt=d,F=[];for(let O=0;O<=a;O++){let j=gt+O/a*Q;q.set(0,0,0),q.addScaledVector(ht,Math.sin(j)),q.addScaledVector(nt,Math.cos(j));for(let Z=0;Z<=1;Z++){let I=Z/1-.5;if(ct.copy(Y),ct.addScaledVector($,I),ct.addScaledVector(q,s),rt!=null){let G=Math.max(0,ct.y-rt);ct.addScaledVector($,-G/$.y)}c.push(ct.x,ct.y,ct.z),h.push(q.x,q.y,q.z),u.push(0,0),Z===0&&F.push(d),d++}}for(let O=0;O<a;O++)for(let j=0;j<1;j++){let Z=lt+j+2*O,I=Z+2,G=I+1,W=Z+1;l.push(Z,I,W),l.push(I,G,W)}return[Y.clone().addScaledVector($,.5),F]}function k(Y,$,nt,Q){let rt=Math.PI/2,gt=A.angle()-rt,at=[],ht=new C,ct=new C;for(let lt=0;lt<=a;lt++){let F=[],O=lt/a;for(let j=0;j<=lt;j++){let Z=((lt?j/lt:0)-.5)*v,I=Math.cos(Z),G=Math.sin(Z),W=(rt+Math.atan(Math.tan(gt)*I))*O,N=Math.cos(W),tt=Math.sin(W);ht.set(0,0,0),ht.addScaledVector($,tt*I),ht.addScaledVector(nt,N),ht.addScaledVector(Q,tt*G),ct.copy(Y).addScaledVector(ht,s),c.push(ct.x,ct.y,ct.z),h.push(ht.x,ht.y,ht.z),u.push(0,0),F.push(d++)}at.push(F)}let q=at.length-1;for(let lt=0;lt<q;lt++){let F=at[lt],O=at[lt+1],j=F.length-1;l.push(F[0],O[1],O[0]);for(let Z=1;Z<=j;Z++)l.push(F[Z-1],F[Z],O[Z]),l.push(F[Z],O[Z+1],O[Z])}}this.setIndex(l),this.setAttribute("position",new Nt(c,3)),this.setAttribute("normal",new Nt(h,3)),this.setAttribute("uv",new Nt(u,2))}}}),rb=z(()=>{yh(),dh(),nx=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof Ni?t.shape:new Ni,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:n}}static build(t){let e=t.shape,{width:i,height:n,cornerRadius:r,cornerType:s,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=t.parameters,c={x:.5*i,y:.5*n},h={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function d(b,x,w){return x>i&&w>n?Math.min(b*i/x,b*n/w):x>i?b*i/x:w>n?b*n/w:b}let p=[];p[0]=r[0]===0?0:d(r[0],r[0]+r[3],r[0]+r[1]),p[1]=r[1]===0?0:d(r[1],r[1]+r[2],r[1]+r[0]),p[2]=r[2]===0?0:d(r[2],r[2]+r[1],r[2]+r[3]),p[3]=r[3]===0?0:d(r[3],r[3]+r[0],r[3]+r[2]);let f=h.x,g=u.x,m=u.y,y=h.y;e.addPoint(e.createPoint(f,m)),e.addPoint(e.createPoint(g,m)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(f,y)),e.isClosed=!0;let v=!0;for(let b=0,x=e.points.length;b<x;b++)e.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(v=!1);v&&(e.roundness=p[0]),e.useCubicForRoundedCorners=s!==1,e.update();let _=_h.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),_4=z(()=>{et(),ck=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},t.parameters);return i.thetaLength=Ot.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i=100,height:n=i,depth:r=i,widthSegments:s=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:c,thetaLength:h}=t.parameters;return h===0?(e=new Gt,e.setAttribute("position",new Nt([],3))):e=new sh(.5*i,s,a,o,l,c,h*Ot.DEG2RAD),e.scale(1,n/i,r/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),b4=z(()=>{et(),dk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(t){let{width:e=100,height:i=e,widthSegments:n=8,heightSegments:r=8}=t.parameters,s=new lo(e,i,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...t,type:"PlaneGeometry"}})}}}),x4=z(()=>{et(),uk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:n,angle:r,cornerRadius:s,cornerSegments:a}=t.parameters,o=new v4(e,i,n,r,s,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},v4=class extends Gt{constructor(t=1,e=1,i=1,n=90,r=10,s=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],c=.001;r==0&&(s=1),s=Math.max(1,Math.floor(s)),r=Math.min(r,100),n=Math.min(180-c,n),n*=Math.PI/180;let h=[],u=Math.PI/2,d=(ct=0,q=0,lt=0)=>new C(ct,q,lt),p=d(),f=d(),[g,m,y]=[e/2,t/2,i/2],v=-m,_=+m,[b,x,w]=[d(v,-g,+y),d(v,-g,-y),d(v,+g,-y)],S=(ct,q=!1)=>Math.sin(ct-Math.PI/(+q+1)),A=(ct,q=!1)=>Math.cos(ct-Math.PI/(+q+1));w.y=Math.sin(n)*e-g;let E=Math.cos(n)*e-y,P=b.z-c;n<=u?(w.z=Math.min(E,P),w.z==P&&(w.y-=(E-P)/Math.tan(u-n))):x.z=Math.min(x.z-E-y,b.z-c),p.subVectors(b,x),f.subVectors(w,x);let T=Math.min(p.length(),f.length())*r/100,R=T*Math.tan(n/2),L=T/Math.cos(n/2),D=p.clone().normalize().add(f.normalize()).setLength(L).add(x);p.set(0,S(n,!0),A(n,!0)),h.push([w,p.clone()]);let U=(Math.PI-n)/s;for(let ct=0;ct<=s;ct++){let q=u+n+ct*U;p.set(0,Math.sin(q)*R,Math.cos(q)*R),p.add(D),f.set(0,S(q),A(q)),h.push([p.clone(),f.clone()])}h.push([b,d(0,1,0)]);let V=Math.sin(U/2)*R*2,k=h.length-1,Y=h[0][0].distanceTo(h[1][0]),$=Y+V*s+h[k-1][0].distanceTo(h[k][0]);h[0].push(1);for(let ct=0;ct<=s;ct++)h[ct+1].push(1-(Y+ct*V)/$);h[k].push(0);let nt,Q,rt,[gt,at,ht]=h[0];for(let ct=1;ct<h.length;ct++)[nt,Q,rt]=h[ct],a.push(v,gt.y,gt.z,v,nt.y,nt.z,_,gt.y,gt.z,_,gt.y,gt.z,v,nt.y,nt.z,_,nt.y,nt.z),o.push(0,at.y,at.z,0,Q.y,Q.z,0,at.y,at.z,0,at.y,at.z,0,Q.y,Q.z,0,Q.y,Q.z),l.push(0,ht,0,rt,1,ht,1,ht,0,rt,1,rt),[gt,at,ht]=[nt,Q,rt];this.setAttribute("position",new Nt(a,3)),this.setAttribute("normal",new Nt(o,3)),this.setAttribute("uv",new Nt(l,2))}}}),BA=z(()=>{yh(),dh(),JC=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return{shape:t.shape&&t.shape instanceof Ni?t.shape:new Ni,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,innerRadiusPercent:n,spikes:r,cornerRadius:s,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:c}=t.parameters,h=t.shape,u=.5*e,d=.5*i,p=a*Math.PI/360/r,f=Math.PI/2*3*-1,g=u*n/100,m=d*n/100;if(r===3&&n===50){p=2*Math.PI/r;for(let v=0;v<r;v++){let _=p*v,b=0+Math.sin(_)*u,x=0+Math.cos(_)*d;h.addPoint(h.createPoint(b,x))}}else for(let v=0;v<r;v++){let _=0+Math.cos(f)*u,b=0+Math.sin(f)*d;h.addPoint(h.createPoint(_,b)),f+=p,_=0+Math.cos(f)*g,b=0+Math.sin(f)*m,h.addPoint(h.createPoint(_,b)),f+=p}h.isClosed=!0;for(let v=0,_=h.points.length;v<_;v++)h.points[v].roundness=s;h.roundness=s,h.update();let y=_h.create({shape:h,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(y,{userData:{...t,type:"StarGeometry"}})}}}),w4=z(()=>{et(),pk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i}=t.parameters,n=new lo(e,i);return Object.assign(n,{userData:{...t,type:"TextFrameGeometry"}})}}}),S4=z(()=>{et(),Lg(),fk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},t.parameters),n=Math.abs(i.width),r=Math.abs(i.height??i.width);i.shapeBlendNode&&(r=n);let s=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:n,height:r,depth:s})}}static build(t){let{width:e,height:i,depth:n,radialSegments:r,tubularSegments:s,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,c=function(h,u,d,p,f,g,m,y,v,_,b){[u,d]=[d,u],m=u/2;let x=Ot.clamp(f/360,0,1);if(x===0){let w=new Gt;return w.setAttribute("position",new Nt([],3)),w}return x===1&&(_=0),new xA(!0,h,u,d,p,x,g,m,0,v,_,b)}(e,i,n,.5*e,a,s,0,0,r,o,l);return c.scale(1,i/e,1),Object.assign(c,{userData:{...t,type:"TorusGeometry"}})}}}),M4=z(()=>{et(),mk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??.125*i.width})}}static build(t){let{width:e,tube:i,tubularSegments:n,radialSegments:r,p:s,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new mE(o,i,n,r,s,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),E4=z(()=>{yh(),dh(),gk=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},t.parameters);return{shape:t.shape&&t.shape instanceof Ni?t.shape:new Ni,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e=100,height:i,cornerRadius:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:a,isRect:o}=t.parameters,l=t.shape,c=.5*e,h=.5*i;o?(l.addPoint(l.createPoint(-c,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=n;l.roundness=n,l.update();let u=_h.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...t,type:"TriangleGeometry"}})}}}),T$=z(()=>{}),C$=z(()=>{et(),new vr,new At,new $o,new C,new C,new C,new C});function A4(){let t=new Gt;return t.setAttribute("position",new Ht(new Float32Array([]),3)),t.setIndex(new Ht(new Uint16Array([]),1)),t}var T4,UA,vk=z(()=>{Dn(),Yt(),Sp(),et(),qg(),yh(),dh(),T4=A4().attributes,UA=class extends Gt{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,T4),this.userData={parameters:t,type:"TextGeometry"};let i=e.getFont(t.font);i?.isLoaded?(this.font=i,this.update(t,e)):this.updateFont(t.font,e).then(()=>{this.update(t,e),e?.requestRender()})}async updateFont(t,e){let i=e.getFont(t);i&&(this.font=i,await i.loadingPromise)}update(t,e){let i=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:n,height:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:c}=t,h=_r.getDisplayedValue(l),u=function(b,x,w,S){let A=typeof b.width=="string"?Number(S.getVariable(b.width)):b.width,E=[""],P="";for(let T of w)P+=T,T===" "||T===`
4168
4168
  `?(E[E.length-1]+=P,P="",T===`
4169
- `&&E.push("")):x.getTextWidth(E[E.length-1]+P,b)>A&&(E[E.length-1].length&&E.push(""),x.getTextWidth(E[E.length-1]+P,b)>A&&(P.length===1?(E[E.length-1]+=P,P=""):(E[E.length-1]+=P.slice(0,-1),P=P[P.length-1],E.push(""))));return E[E.length-1]+=P,E}(t,i,c===2?h.toUpperCase():c===3?h.toLowerCase():h,e),{shapes:d,charWidths:p,charCoords:f}=i.generateShapes(u,t,e),g=.5*(typeof n=="number"?n:Number(e.getVariable(n))),m=.5*(typeof r=="number"?r:Number(e.getVariable(r))),y=d.map(b=>new Ni().fromShape(b,!0));this.vectorShapes=y;let v=y.map(b=>_h.create({shape:b,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:a,windingRule:s<=0?fi.NONZERO:fi.ODD,subdivisions:this.isLowResolution&&s>0?1:12}})),_=v.length?Sc(v):A4();_.translate(-g,m,0),this.dispose(),this.wrappedText=u,this.charCoords=f,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(_.attributes).forEach(([b,x])=>{this.setAttribute(b,x)}),this.setIndex(_.index),this.computeBoundingSphere()}clone(){let t=Er(new Gt,UA.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([e,i])=>{this.setAttribute(e,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t,e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:t}},e)}get text(){return this.userData.parameters.text??""}}});function P$(t){if(!zA)return C4||(C4=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.42/build",i=import("./process.js"),[n,r]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=n.default,a=await s({wasmBinary:r});yk(a),zA=!0}())}var yk,t3,zA,C4,rx=z(()=>{t3=new Promise(t=>{yk=t}),zA=!1});function jS(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),n=Object.keys(e.attributes);if(i.length!==n.length)return!1;for(let o of n){let l=t.attributes[o],c=e.attributes[o];if(l===void 0||l.isInterleavedBufferAttribute===!0||c.isInterleavedBufferAttribute===!0||l.itemSize!==c.itemSize||l.normalized!==c.normalized||l.array.constructor!==c.array.constructor||l.array.length!==c.array.length)return!1}let r=t.index,s=e.index;if(r===null!=(s===null))return!1;let a=!1;if(r!==null&&s!==null){if(r.array.length!==s.array.length)return!1;let o=r.array.constructor,l=s.array.constructor;if(o!==l){if(o!==Uint32Array||l!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let o=0;o<e.groups.length;o++){let l=t.groups[o],c=e.groups[o];if(l.start!==c.start||l.count!==c.count||l.materialIndex!==c.materialIndex)return!1}for(let o of n){let l=t.attributes[o],c=e.attributes[o];l.array.set(c.array),l.needsUpdate=!0}if(r!==null&&s!==null){if(a){let o=r.array,l=s.array;for(let c=0,h=l.length;c<h;c++){let u=l[c];o[c]=u===65535?4294967295:u}}else r.array.set(s.array);r.needsUpdate=!0}return t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t.boundingBox=null,t.boundingSphere=null,!0}function FA(t,e,i,n){let r,s,a,o=t.position.array,l=t.normal.array,c=_k.makeScale(e,i,n).invert().elements;for(let h=0,u=o.length;h<u;h+=3)o[h]*=e,o[h+1]*=i,o[h+2]*=n,r=l[h],s=l[h+1],a=l[h+2],l[h]=c[0]*r+c[4]*s+c[8]*a,l[h+1]=c[1]*r+c[5]*s+c[9]*a,l[h+2]=c[2]*r+c[6]*s+c[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var _k,bk=z(()=>{et(),_k=new At});function NA(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function Tv(t){if(t!=null){if(Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView))return t;if(typeof t=="object")return function(e){let i=Object.keys(e),n=0;for(let s of i){let a=NA(s);a>=n&&(n=a+1)}if(n===0||n>i.length)return;let r=new Array(n);for(let s=0;s<n;s++){let a=e[s];if(typeof a!="number")return;r[s]=a}return r}(t)}}function GS(t){if(t==null)return"missing";if(Array.isArray(t))return`Array(${t.length})`;if(ArrayBuffer.isView(t)){let l=t;return`${t.constructor.name}(${l.length})`}if(typeof t!="object")return typeof t;let e=Object.keys(t),i=e.filter(l=>NA(l)===-1),n=0;for(let l of e){let c=NA(l);c>=n&&(n=c+1)}let r=t,s=-1,a=-1;for(let l=0;l<n;l++)l in r?typeof r[l]!="number"&&a===-1&&(a=l):s===-1&&(s=l);let o=[`${e.length} keys`,"max index "+(n-1)];return s!==-1&&o.push(`first missing index ${s}`),a!==-1&&o.push(`non-number at ${a} (${typeof r[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function xk(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function e3(t,e){let i=e?e.count:t.count,n=0,r=1e4,s=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let u=e?e.getX(h):h,d=t.getX(u),p=t.getY(u),f=t.getZ(u),g=Math.round(d*r),m=Math.round(p*r),y=Math.round(f*r),v=s.get(g);v===void 0&&(v=new Map,s.set(g,v));let _=v.get(m);_===void 0&&(_=new Map,v.set(m,_));let b=_.get(y);b===void 0&&(b=n++,_.set(y,b),o.push(d,p,f)),a[h]=b}let l=[],c=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||(l.push(a[h],a[h+1],a[h+2]),c.push(e?e.getX(h):h,e?e.getX(h+1):h+1,e?e.getX(h+2):h+2));return{positions:o,triIndices:l,triOriginals:c}}var Bf,Kh,Qt,HS,WS,qS,Fi,Uf,Cv,Pv,Dv,kA,y1,Mp=z(()=>{et(),rx(),Yt(),sx(),bk(),Lg(),Bf=new ci,Kh=new C,t3.then(t=>{Qt=t}),HS=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),WS=new Uint32Array([0,1,2,3]),qS=new Uint8Array([4]),Fi=class extends Gt{constructor(t,e){super(),this.data=t,this.flatShading=e,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,e){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),n=oh.div(e.map(a=>typeof a=="number"?a:0),i);if(n.every(a=>a===1))return;this.subdividedGeometry&&FA(this.subdividedGeometry.attributes,...n),this.originalGeometry&&FA(this.originalGeometry.attributes,...n),this.data=t;let r=this.userData.parameters;this.userData.parameters={width:r.width*n[0],height:r.height*n[1],depth:r.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(Kh.fromArray(n));let s=Kh.set(r.width,r.height,r.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(t){this.freeSubdivPointer(),this.data=t;let e=t.phongAngle??35;this.flatShading&&(e=-1);let i=null;if(t.subdivisions>0){let r=0;try{r=Fi.allocate(t),i=Fi.buildRefined(r,t.subdivisions,e)}catch(s){console.error(s,t)}finally{r&&Fi.freeSubdivPointer(r)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let n=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=n}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=Fi.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new ga(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Fi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new vr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;Bf.setFromBufferAttribute(e),Bf.getCenter(i),t.boundingSphere.radius=i.distanceTo(Bf.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Bf.getSize(Kh);let n={width:Kh.x,height:Kh.y,depth:Kh.z};return this.userData.parameters=n,n}static build(t,e,i,n){let r,s,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Qt.free_bvh(e),Qt.free_subdivision_surface(e));try{r=Fi.allocate(t,n)}catch(l){console.error(l,t),r=Fi.allocate({positionWASM:HS,indexWASM:WS,verticesPerFaceWASM:qS},n)}Qt.set_destination_refinement_level(r,0);let o=Fi.buildLevel(r,!0,a);return s=t.subdivisions>0?Fi.buildRefined(r,t.subdivisions,a):null,{subdivPointer:r,originalGeometry:o,subdividedGeometry:s}}static buildRefined(t,e,i){try{return Qt.set_destination_refinement_level(t,e),Fi.buildLevel(t,!1,i)??null}catch{try{return Qt.set_destination_refinement_level(t,e-1),Fi.buildLevel(t,!1,i)??null}catch{return null}}}static primitiveToQuads(t,e,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let n,r=t.shape!==void 0||t.path!==void 0?e.geometry:Jl(t,i,!1,e);n=SN(t)?r.getClosedTorusIndicesForBooleanOrSubdiv():r.getIndex();let s,{positions:a,triIndices:o,triOriginals:l}=e3(r.getAttribute("position"),n);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let d=t.radialSegments*t.heightSegments*3*2;s=[d,d+3*t.radialSegments]}let{indices:c,verticesPerFace:h,uvs:u}=function(d,p,f,g,m){let y=[],v=[],_=m?f.getAttribute("uv"):void 0,b=_&&_.itemSize===2?[]:void 0,x=A=>{if(b){let E=m[A];b.push(_.getX(E),_.getY(E))}};if(f.userData.shape!==void 0&&f.userData.parameters.depth===0&&f.userData.shape.shapeHoles.length===0){let A=f.userData.shape.extractShapePointsToFlatArray([]),E=f.userData.parameters.spikes;if(f.userData.type==="EllipseGeometry"&&E<=24&&E%4==0&&f.userData.parameters.angle>=360){let R=A.length/2/E;A=A.filter((L,D)=>Math.floor(D/2)%R===0)}let P=0;for(let R=0;R<A.length;R+=2)P+=(A[R]-A[(R===0?A.length:R)-2])*(A[R+1]+A[(R===0?A.length:R)-1]);d.length=0;let T=0;if(P<0)for(let R=0;R<A.length;R+=2)d.push(A[R],A[R+1],0),y.push(T++);else for(let R=A.length-2;R>=0;R-=2)d.push(A[R],A[R+1],0),y.push(T++);return v.push(T),{indices:y,verticesPerFace:v}}let w=new Float32Array([f.userData.parameters.depth])[0],S=0;for(;S<p.length;){if(f.useNgonForTopBottomFaceDuringBake){let A=0;if((d[3*p[S]+2]===w||d[3*p[S]+2]===0)&&A++,(d[3*p[S+1]+2]===w||d[3*p[S+1]+2]===0)&&A++,(d[3*p[S+2]+2]===w||d[3*p[S+2]+2]===0)&&A++,A===3)break}if(p[S+1]===p[S+3]&&p[S+2]===p[S+5]||p[S+0]===p[S+3]&&p[S+2]===p[S+4]){Uf.set(d[3*p[S]],d[3*p[S]+1],d[3*p[S]+2]),Cv.set(d[3*p[S+1]],d[3*p[S+1]+1],d[3*p[S+1]+2]),Pv.set(d[3*p[S+4]],d[3*p[S+4]+1],d[3*p[S+4]+2]),Dv.set(d[3*p[S+5]],d[3*p[S+5]+1],d[3*p[S+5]+2]),Cv.sub(Uf).normalize(),Pv.sub(Uf).normalize(),Dv.sub(Uf).normalize();let A=Cv.cross(Pv).dot(Dv),E=S;Math.abs(A)>.005||g&&g.some((P,T)=>T%2!=1&&E>=g[T]&&E<g[T+1])?(y.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),v.push(3),S+=3):(y.push(p[S],p[S+1],p[S+4],p[S+5]),x(S),x(S+1),x(S+4),x(S+5),v.push(4),S+=6)}else y.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),v.push(3),S+=3}if(f.useNgonForTopBottomFaceDuringBake){let A=[],E=[],P=0;for(let T=0,R=0;T<d.length;T+=3,R++)d[T+2]===0&&(A.push(R),P++),d[T+2]===w&&E.push(R);if(f.userData.parameters.extrudeBevelSize===0){let T=E[0];E[0]=E[1],E[1]=T}A.reverse(),y.push(...A,...E),v.push(P,P),b=void 0}return{indices:y,verticesPerFace:v,uvs:b}}(a,o,r,s,l);return{positions:a,indices:c,verticesPerFace:h,uvs:u}}static allocate(t,e){let i,n,r,s=[],a=[],o=Tv(t.positionWASM),l=Tv(t.indexWASM),c=Tv(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!c?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${GS(t.positionWASM)}, indexWASM ${GS(t.indexWASM)}, verticesPerFaceWASM ${GS(t.verticesPerFaceWASM)}`);i=o,n=l,r=c;let S=Tv(t.uvWASM);Qt.alloc_subdivision_surface_uvs&&S&&S.length===2*n.length&&(a=S)}else i=HS,n=WS,r=qS;let h=i.length,u=n.length,d=r.length,p=i.length+s.length+a.length,f=n.length+r.length,g=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Qt._malloc(g);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let v,_=new Float32Array(Qt.HEAPF32.buffer,y,p),b=new Uint32Array(Qt.HEAPU32.buffer,y+m,f);_.set(i,0),_.set(s,i.length),_.set(a,i.length+s.length),b.set(n,0),b.set(r,n.length),t?.scaleBaked?.some(S=>S!==1)&&(v=new At().makeScale(...t.scaleBaked.map(S=>typeof S=="number"?S:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,w=a.length?v?Qt.alloc_subdivision_surface_uvs2(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,x,a.length,v.elements):Qt.alloc_subdivision_surface_uvs(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,x,a.length):v?Qt.alloc_subdivision_surface2(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,v.elements):Qt.alloc_subdivision_surface(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Qt._free(y),w}static buildLevel(t,e,i,n,r,s=!1){let a=r?Qt.get_mesh_data2(t,e?Qt.Level.CONTROL:Qt.Level.REFINED,i,r.elements):Qt.get_mesh_data(t,e?Qt.Level.CONTROL:Qt.Level.REFINED,i),o=Qt.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),c=0,h=Qt.HEAPU32[o[c]>>2],u=Qt.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let d=Qt.HEAPU32[o[c]>>2],p=Qt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=Qt.HEAPU32[o[c]>>2],g=Qt.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let m,y=Qt.HEAPU32[o[c]>>2],v=Qt.HEAPU32.subarray(y>>2,(y>>2)+l[c]);if(c++,Qt.alloc_subdivision_surface_uvs){let b=o[9];if(b>0){let x=Qt.HEAPU32[o[8]>>2];m=Qt.HEAPF32.subarray(x>>2,(x>>2)+b)}}if(n===void 0){let b=new Gt;if(b.setIndex(new rh(v,1)),b.setAttribute("position",new Nt(u,3)),b.setAttribute("normal",new Nt(p,3)),m&&b.setAttribute("uv",new Nt(m,2)),e){b.setAttribute("faceMap",new rh(g,1));let x=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Ht(x,4))}return Qt.free_mesh_data(a),b.userData.type="SubdivGeometry",b}if(n.getAttribute("position").copyArray(u),n.getAttribute("normal").copyArray(p),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,s){let b=n.getIndex();b!==null&&b.array.length===v.length&&(b.copyArray(v),b.needsUpdate=!0)}let _=n.getAttribute("uv");m&&_&&_.array.length===m.length&&(_.copyArray(m),_.needsUpdate=!0),Qt.free_mesh_data(a)}static freeSubdivPointer(t){Qt.free_bvh(t),Qt.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let n=Qt.get_wireframe_data_for_base_level(t),r=Qt.HEAPU32.subarray(n>>2,4+(n>>2)),s=r.subarray(2,4),a=0,o=Qt.HEAPU32[r[a]>>2],l=Qt.HEAPF32.subarray(o>>2,(o>>2)+s[a]);a++;let c=Qt.HEAPU32[r[a]>>2],h=Qt.HEAPU32.subarray(c>>2,(c>>2)+s[a]);if(e===void 0){let u=new Gt;u.setAttribute("position",new Nt(l,3));let d=new Float32Array(l.length);for(let p=0,f=l.length;p<f;)d[p++]=i.r,d[p++]=i.g,d[p++]=i.b;return u.setAttribute("color",new Ht(d,3)),u.setIndex(new rh(h,1)),Qt.free_wireframe_data_for_base_level(n),u}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Qt.free_wireframe_data_for_base_level(n)}static updateCollabMesh(t,e,i){let n=e===0;n||Qt.set_destination_refinement_level(t,e);let r=i?Qt.get_topological_data2(t,n?Qt.Level.CONTROL:Qt.Level.REFINED,i.elements):Qt.get_topological_data(t,n?Qt.Level.CONTROL:Qt.Level.REFINED),s=Qt.HEAPU32.subarray(r>>2,8+(r>>2)),a=s.subarray(3,6),o=0,l=Qt.HEAPU32[s[o]>>2],c=new Float32Array(Qt.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=Qt.HEAPU32[s[o]>>2],u=new Uint32Array(Qt.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let d,p=Qt.HEAPU32[s[o]>>2],f=new Uint8Array(Qt.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Qt.alloc_subdivision_surface_uvs){let g=s[7];if(g>0){let m=Qt.HEAPU32[s[6]>>2];d=new Float32Array(Qt.HEAPF32.subarray(m>>2,(m>>2)+g))}}return Qt.free_topological_data(r),{positions:c,indices:u,verticesPerFace:f,uvs:d}}},Uf=new C,Cv=new C,Pv=new C,Dv=new C}),wk=z(()=>{ZO(),KO(),tb(),QO(),nb(),Lg(),p4(),f4(),m4(),LA(),y4(),rb(),_4(),b4(),x4(),BA(),w4(),S4(),M4(),E4(),dh(),ke(),ZO(),KO(),tb(),QO(),nb(),T$(),Lg(),p4(),f4(),m4(),LA(),y4(),rb(),_4(),b4(),x4(),BA(),w4(),S4(),M4(),E4(),dh(),C$(),JN(),vk(),Mp(),rx(),ex(),kA={ConeGeometry:kN,CubeGeometry:VN,CylinderGeometry:YC,DodecahedronGeometry:jN,EllipseGeometry:ix,HelixGeometry:MN,IcosahedronGeometry:nk,LatheGeometry:rk,NonParametricGeometry:ak,PolygonGeometry:QC,PyramidGeometry:ok,RectangleGeometry:nx,SphereGeometry:ck,PlaneGeometry:dk,BackdropGeometry:uk,StarGeometry:JC,TextFrameGeometry:pk,TorusGeometry:fk,TorusKnotGeometry:mk,TriangleGeometry:gk,VectorGeometry:_h},y1=t=>{let e=kA[t.type]??cN(t.type);if(e===void 0)throw new Error(`No geometry factory registered for "${t.type}" \u2014 was its feature compiled out of this runtime build?`);return e.create(t)}});function Jl(t,e,i,n){let r,s,a;t.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(t)),a=[[],["extrusion"]]):(s={...t},a=[[]]);for(let c of a){let h=s;for(let u of c)h=h[u];for(r in h){let u=h[r];gI(u)&&!Sk.includes(r)&&(h[r]=e.getVariable(u,[n.uuid,"geometry",...c,r]),gI(h[r])&&(h[r]=1))}}let o,l={parameters:s,type:s.type};if(s.type==="PathGeometry")l.path=s.path;else if(s.type==="VectorGeometry"){let c=Ni.createFromState(s.shape,s.width,s.height);l.shape=c}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),l.geometry=new oC().parse(s),l.geometry.groups.length===0){let c=l.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else{if(s.type==="SubdivGeometry"){let c=new Fi(s,i);return c.data=t,c}if(s.type==="TextGeometry"||s.type==="InputGeometry"){let c=cN(s.type);if(c)return c.create(s,e);Gn("text",`a ${s.type}`);let h=Ni.createFromState(Rg.defaultData(),100,100);return y1({...s,shape:h,type:"VectorGeometry"})}if(s.type==="UIGeometry")return nx.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}try{o=y1(l)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${l}`);let h=Ni.createFromState(Rg.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=y1(l)}return o}var Sk,P4,VA,sx=z(()=>{Yt(),et(),wk(),ke(),rb(),yh(),Mp(),Sk=["font"]}),D$=z(()=>{sx(),P4=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,i){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,i),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.objects.set(e,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){e===this.objects.get(t)&&this.unreachable.delete(t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},VA=class extends P4{constructor(t){super(),this.flatShading=t}disposeObject(t){t.dispose()}createObject(t,e,i){let n=Jl(t,e,this.flatShading,i);return n.computeBoundingSphere(),n}}});function sb(){return ax}function Mk(){if(ax==="webgpu"){if(I4!==void 0)return I4;GA||(GA=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(jA===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return jA}function Ek(t,e){return Mk().createRootMaterial(t,e)}function D4(t,e,i){return Mk().createSharedMaterial(t,e,i)}function R4(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function Ak(){return R$}var ax,I4,jA,GA,HA,R$,WA,Tk,bh=z(()=>{ax="webgl",GA=!1}),I$=z(()=>{Tk={markNeedsUpdateRendererDirty:()=>{}}});function Pc(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let n=t.layers?.find(r=>r.data.type==="light");if(n){let r=n.data,s=Number(e.getVariable(r.alphaOverride));if((typeof r.alphaOverride=="string"?s/100:r.alphaOverride)<1)return!0}for(let r of t.layers){if(r.data.type!=="displace"&&r.data.isMask)return!0;if(r.data.type!=="displace"&&"alpha"in r.data&&r.data.type!=="light"&&r.data.type!=="fresnel"&&r.data.type!=="cavity"&&r.data.type!=="dust"&&r.data.type!=="texture"&&r.data.type!=="matcap"&&r.data.type!=="rainbow"&&r.data.type!=="outline"&&r.data.type!=="pattern"){let s=r.data.visible?r.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(e.getVariable(s)??100)/100))),s===1&&r.data.type==="depth"||r.data.type==="gradient"){for(let a of r.data.colors)if(a[3]<1){s=a[3];break}}else if(s===1&&r.data.type==="noise"){let a=e.color(r.data.colorA).a,o=e.color(r.data.colorB).a,l=e.color(r.data.colorC).a,c=e.color(r.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,c)));h<1&&(s=h)}i+=(1-i)*s}}return i<1}var i3=z(()=>{});function fp(t){return typeof t=="string"||typeof t=="number"&&t!==0}var uh,Xt,ox,Ck,O4,L4,ys,rl=z(()=>{uh=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,Xt=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),ox={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},Ck={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),Ep=z(()=>{et(),Yg(),O4=class extends Qb(_i){},L4=t=>t.type==="Mesh",ys=class extends O4{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=t.hasNonUniformScale}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];i?.object!==e&&(i&&this.remove(i),i=new ys(e),this.add(i),this.children.splice(t,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.hiddenMatrix=e.hiddenMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let t=this.object.cloner;return(t===void 0||this.parent!==t||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return L4(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(t){}}});function B4(){return n3}var n3,r3,s3=z(()=>{n3=null,r3=null});function qA(t){return"variable_"+t}var XS,$S,YS,U4,ZS,z4,F4,ab,a3=z(()=>{Yt(),ON(),UN(),WC(),ya(),qC(),$C(),D$(),bh(),BN(),I$(),i3(),rl(),Wr(),Ep(),Ye(),et(),s3(),ke(),XS=new At,$S=new C,YS=new qt,U4=new C,ZS=new xi,z4=class extends RN{constructor(t){super(),this.shared=t}create(t){return new HC(t,this.shared)}},(ab=F4=class{constructor(t,e={},i=!0,n=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=n,this.geometryCache=new VA(!0),this.geometryCache2=new VA(!1),this.imageHolderCache=new z4(this),this.thisContext={scene:Tk,shared:this},this.deletedImage=new qo(oA.emptyImage,this),this.deletedVideo=new qo(B_.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,e.images)for(let[r,s]of Object.entries(e.images))this.addImage(r,s);if(e.videos)for(let[r,s]of Object.entries(e.videos))this.addVideo(r,s);if(e.audios)for(let[r,s]of Object.entries(e.audios))this.addAudio(r,s);if(e.particles)for(let[r,s]of Object.entries(e.particles))this.addParticle(r,s);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=D4(ki.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,i=!1){this.data=t,this.resetLib(t.lib);for(let{id:n,data:r}of t.variables)this.addVariableHolder(n,r),e&&this.updateVariableHolder(n,r);for(let[n,r]of Object.entries(t.userAPIs??{}))this.addUserAPI(n,r);for(let[n,r]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(n,r);if(!i){for(let[n,r]of Object.entries(t.images))this.addImage(n,r);for(let[n,r]of Object.entries(t.videos))this.addVideo(n,r)}for(let[n,r]of Object.entries(t.colors))this.addColor(n,r);for(let[n,r]of Object.entries(t.lib.materials))this.addMaterial(n,r.asset);for(let[n,r]of Object.entries(t.materials))this.addMaterial(n,r);for(let[n,r]of Object.entries(t.audios))this.addAudio(n,r);for(let[n,r]of Object.entries(t.particles))this.addParticle(n,r);for(let[n,r]of Object.entries(t.fonts))this.addFont(n,r)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:ki.defaultTwoLayerData("phong").layers}),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=D4(e,this.thisContext,t);this.materials[t]=i}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){return this.materials[t]}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:ki.defaultTwoLayerData("phong").layers}),Ek(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new qo(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new qo(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new qo(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):(this.colors[t]=new zg(e.r,e.g,e.b,"a"in e?e.a:1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[t];return this.colors[t].r=e.r??i.r,this.colors[t].g=e.g??i.g,this.colors[t].b=e.b??i.b,this.colors[t].a=e.a??i.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t!="string")return new gn(t.r,t.g,t.b,"a"in t?t.a:1);{let i=this.getColor(t);i?e=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new gn(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Uu)return e;{let i=new Uu({src:e.data});return this.audios[t]=i,i}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Uu&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=XC;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):Gn("text","a font asset")}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._requestRender=void 0,Object.values(this.audios).forEach(t=>{t instanceof Uu&&t.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let i=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let n=localStorage.getItem(qA(t));i=n!==null?JSON.parse(n):e.value}return this.variables[t]={value:i,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(qA(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let n=this.entityOpContext.scene,r=!1;for(let s=this.variables[t].locations.length-1;s>=0;s--){let a=this.variables[t].locations[s];if(a[0]==="material"){let o=a[1],l=i,c={scene:n,shared:this},h=a.slice(2);n.traverseMaterial(d=>{let p=d.root??d;p.uuid===o&&p.onVariableUpdate(h,l,c)});let u=this.materials[o];u&&u.onVariableUpdate(h,l,c)}else{let o=n.find(a[0]);if(o===void 0){this.variables[t].locations.splice(s,1);continue}if(r=!0,a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)o=o[a[l]];a[1]==="rotation"?o[a[a.length-1]]=i*Ot.DEG2RAD:o[a[a.length-1]]=i}if(o=n.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),Be.is(o))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")o.onVariableUpdate();else if(a[1]==="geometry"){let l=o;o.component&&(l=o.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(h=>{let u=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(u.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return r&&n.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let n=i.dataPatched,r=n?.geometry;if(!r||typeof r.type!="string"||r.type==="VectorGeometry"||r.type==="PathGeometry")return!1;let s=c=>c.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let c of Object.keys(r))a.set(s(c),c);let o={};for(let[c,h]of Object.entries(e??{})){let u=a.get(s(c));if(u===void 0||u==="type"||u==="font"||u==="shape"||u==="path"||u==="data")continue;if(u==="text"){(typeof h=="string"||typeof h=="number")&&(o[u]={textValue:String(h)});continue}let d=r[u];typeof h=="number"&&isFinite(h)&&(typeof d=="number"||typeof d=="string")&&(o[u]=h)}if(Object.keys(o).length===0)return!1;let l={...r,...o};return i.dataPatched={...n,geometry:l},this.transientGeometryKeys.has(r)&&i.chooseGeoemtryCache(this).forceDelete(n.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let n=i.dataPatched,r=n?.geometry;if(!r||r.type!=="NonParametricGeometry")return!1;let s=e?.vertices;if(s===void 0||typeof s.length!="number"||s.length<9||s.length%3!=0||s.length/3>F4.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,c=s instanceof Float32Array?s:Float32Array.from(s),h=c.length/3;if(e.normals!==void 0){if(e.normals.length!==c.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*h)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=h>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(x.length===0||x.length%3!=0)return!1;for(let w=0;w<x.length;w++)if(x[w]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=r.data,w=x?.index;if(w?.array?.length){if(h<(x?.attributes?.position?.array?.length??0)/3){let S=w.array;for(let A=0;A<S.length;A++)if(S[A]>=h)return!1}l=w}}let u=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0;for(let x=0;x<c.length;x+=3){let w=c[x],S=c[x+1],A=c[x+2];w<u&&(u=w),w>f&&(f=w),S<d&&(d=S),S>g&&(g=S),A<p&&(p=A),A>m&&(m=A)}let y=(x,w)=>({array:x,itemSize:w,type:"Float32Array",normalized:!1}),v={position:y(c,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let _={...r,width:f-u,height:g-d,depth:m-p,data:{attributes:v,...l?{index:l}:{}}},b=this.transientGeometryKeys.has(r);return i.dataPatched={...n,geometry:_},this.transientGeometryKeys.add(_),i.applyTransientGeometryData(this.entityOpContext,b),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let n=i.cloner;if(n===void 0)return-1;let r=n.children,s=Math.PI/180,a=!1;if(e===null)for(let o of r)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return r.length;{let o=Math.min(e.length,r.length);for(let l=0;l<o;l++){let c=e[l],h=r[l];if(c==null){h.transformOverride!==void 0&&(h.transformOverride=void 0,a=!0);continue}let u=h.transformOverride??{position:[h.position.x,h.position.y,h.position.z],rotation:[h.rotation.x,h.rotation.y,h.rotation.z],scale:[h.scale.x,h.scale.y,h.scale.z]};c.position&&(typeof c.position.x=="number"&&(u.position[0]=c.position.x),typeof c.position.y=="number"&&(u.position[1]=c.position.y),typeof c.position.z=="number"&&(u.position[2]=c.position.z)),c.rotation&&(typeof c.rotation.x=="number"&&(u.rotation[0]=c.rotation.x*s),typeof c.rotation.y=="number"&&(u.rotation[1]=c.rotation.y*s),typeof c.rotation.z=="number"&&(u.rotation[2]=c.rotation.z*s)),c.scale&&(typeof c.scale.x=="number"&&(u.scale[0]=c.scale.x),typeof c.scale.y=="number"&&(u.scale[1]=c.scale.y),typeof c.scale.z=="number"&&(u.scale[2]=c.scale.z)),h.transformOverride=u,h.position.fromArray(u.position),h.rotation.fromArray(u.rotation),h.scale.fromArray(u.scale),h.updateMatrix(),h.hasNonUniformScale&&(h.updateMatrixWorld(),h.updateMatrixWorldRigid())}}}return a?n.update(this.entityOpContext):n.syncInstanceMatrices(),n.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let n=new ys(t);n.playModeVisible=e.visible!==!1,n.expand(),typeof e.name=="string"&&(n.name=e.name);let r=Math.PI/180;return n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(n.position.x=e.position.x),typeof e.position.y=="number"&&(n.position.y=e.position.y),typeof e.position.z=="number"&&(n.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(n.rotation.x=e.rotation.x*r),typeof e.rotation.y=="number"&&(n.rotation.y=e.rotation.y*r),typeof e.rotation.z=="number"&&(n.rotation.z=e.rotation.z*r)),e.scale&&(typeof e.scale.x=="number"&&(n.scale.x=e.scale.x),typeof e.scale.y=="number"&&(n.scale.y=e.scale.y),typeof e.scale.z=="number"&&(n.scale.z=e.scale.z)),n.updateMatrix(),i.add(n),n.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),n}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let n=[];for(let c of Array.isArray(i)?i:[i]){let h=c.root??c;h&&Array.isArray(h.layers)&&h.data&&!n.includes(h)&&n.push(h)}if(n.length===0)return!1;let r={scene:this.entityOpContext.scene,shared:this},s=c=>c.toLowerCase().replace(/[\s_.-]+/g,""),a=c=>{if(typeof c=="string"){let h=new gn(1,1,1,1);try{h.set(c)}catch{return null}return{r:h.r,g:h.g,b:h.b,a:void 0}}if(c&&typeof c=="object"&&"r"in c){let h=c;if([h.r,h.g,h.b].some(d=>typeof d!="number"||!isFinite(d)))return null;let u=Math.max(h.r,h.g,h.b)>1?1/255:1;return{r:h.r*u,g:h.g*u,b:h.b*u,a:typeof h.a=="number"?Math.max(0,Math.min(h.a,1)):void 0}}return null},o=(c,h,u)=>{if(!c.hasValue(h))return!1;let d=c.getValue(h);if(!d||typeof d!="object"||!d.isColor)return!1;let p=u.a??(typeof d.a=="number"?d.a:1);return d instanceof zg?c.setValue(h,new gn(u.r,u.g,u.b,p)):typeof d.setRGBA=="function"?d.setRGBA(u.r,u.g,u.b,p):d.setRGB(u.r,u.g,u.b),!0},l=!1;for(let c of n){let h=c.data.layers??[],u=d=>c.layers.find(p=>p.uuid===d);if(e.color!==void 0){let d=a(e.color),p=h.find(g=>g.data.type==="color"),f=p&&u(p.id);if(d&&f&&o(f,"color",d)&&(l=!0,d.a!==void 0)){let g=d.a<1||Pc(c.data,this);c.setTransparent?c.setTransparent(g,r.scene):c.transparent=g}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(c.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),r),l=!0);for(let d of e.layers??[]){if(!d||typeof d!="object")continue;let p=typeof d.id=="string"?h.find(y=>y.id===d.id):typeof d.index=="number"?h[d.index]:typeof d.type=="string"?h.find(y=>y.data.type===d.type):void 0,f=p&&u(p.id);if(!p||!f)continue;let g=ox[p.data.type]??[],m=Object.keys(p.data);for(let[y,v]of Object.entries(d)){if(y==="id"||y==="index"||y==="type")continue;let _=m.find(x=>x===y)??m.find(x=>s(x)===s(y))??y;if(g.includes(_))continue;let b=a(v);if(b&&o(f,_,b))l=!0;else if(typeof v=="number"&&isFinite(v))c.onVariableUpdate?.(["layer",p.id,_],v,r),l=!0;else if(Array.isArray(v)&&v.length<=3&&v.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];v.forEach((w,S)=>{c.onVariableUpdate?.(["layer",p.id,_,x[S]],w,r)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let i=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return i.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&i?.getPhysicsLocalMatrix?.(XS))return XS.decompose($S,YS,U4),t[1]==="position"?$S[t[2]]:(ZS.setFromQuaternion(YS,i.rotation.order),ZS[t[2]]*Ot.RAD2DEG);for(let n=1;n<t.length;n++)i=i[t[n]];return t[1]==="rotation"&&(i*=Ot.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let n=this.variables[i],r=n.locations?.findIndex(s=>jn.equal(s,e));r!==void 0&&r!==-1&&n.locations.splice(r,1)}if(typeof t=="string"){let i=t,n=t;do{if(n=i,this.variables[i]===void 0)break;let r=this.variables[i].value;e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),i=r}while(typeof i=="string");return i}return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,i]of Object.entries(t.images))this.addImage(e,i.asset);for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i.asset);for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i.asset);for(let[e,i]of Object.entries(t.colors))this.addColor(e,i.asset);for(let[e,i]of Object.entries(t.fonts))this.addFont(e,i.asset);for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i.asset);for(let[e,i]of Object.entries(t.variables))this.addVariableHolder(e,i.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,i){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(er.drop(t,2),e.materials[t.path[1]],{shared:this,scene:i});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,i):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let n=e.userAPIs[t.path[1]];if(n){let r=t.type===0&&t.props.debounce===void 0,s=this.getUserAPI(t.path[1]);s!==void 0&&s===this.openAIRealtime?s.update(n):s?.update(n,this,r)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let n=e.userWebhooks[t.path[1]];n&&this.getUserWebhook(t.path[1])?.update(n)}}else t.path[0]==="lib"&&this.updateLibByOp(er.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let n=this.getFont(t),r={...this.data.fonts[t],url:e.props.url};n.update(r),n.loadingPromise.then(()=>this.requestRender()),i.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let i=r3;return i===null?(Gn("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=B4();return i===null?(Gn("api-services","a user API integration"),!1):(this.userAPIs[t]=i.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let i=B4();return i===null?(Gn("api-services","a user webhook"),!1):(this.userWebhooks[t]=i.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new ab(Fs.emptyData())});function Pk(t){return Q_(t)||t?.isTSLNodeMaterial===!0}var Hr,KS,QS,JS,N4,t2,Ai,Dk=z(()=>{GC()}),Jc=z(()=>{Yt(),Kn(),bh(),Dk(),Ye(),Dn(),Hr=class extends Xi{setMaterialOverride(t,e){this.materialOverride=R4(t),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),e.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(t,e,i){if(super.updateByPatchedOp(t,e,i),ri(t.path,["geometry"])&&this.syncShadowCatcher(i),function(n,r){let s=[];if(r.length!==n.length)return null;{let a=0;for(;a<n.length;){if(r[a]==="*")s.push(n[a]);else if(n[a]!==r[a])return null;a+=1}}return s}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[n,r]of Object.entries(t.props)){let s=this.material[Number(n)],a=i.shared.material(r);a!==s&&Hr.disposeOneMaterial(s),this.material[Number(n)]=a}else if(ri(t.path,["material"])){let n=this.material;!Array.isArray(n)&&typeof n?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&n.updateByOp(er.drop(t,1),e.material,i)}else if(ri(t.path,["materials","*"])&&Array.isArray(this.material)){let n=t.path[1];if("materials"in e&&n<this.material.length){let r=e.materials[n];typeof r!="string"&&this.material[n].updateByOp(er.drop(t,2),r,i)}}}get needsAO(){return this.material!==void 0&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(t,e){super.updateState(t,e),t.castShadow!==void 0&&(this.castShadow=t.castShadow),t.receiveShadow!==void 0&&(this.receiveShadow=t.receiveShadow);let i,n=this.dataPatched;this.syncShapeBlendNodeLayer(),this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let r=this.materialOverride!==void 0;!r&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(n.flatShading,n.side,n.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!r&&(t.geometry?.type==="NonParametricGeometry"||"materials"in t)&&("materials"in t&&t.materials!==void 0?(this.disposeMaterial(),this.material=t.materials.map(a=>e.shared.material(a).getFlavor(n.flatShading,n.side,n.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(n.flatShading,n.side,n.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!r&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(s.materials[0]).getFlavor(n.flatShading,n.side,n.wireframe)),!r&&(t.flatShading!==void 0||t.wireframe!==void 0||t.side!==void 0))if(Array.isArray(this.material))for(let a=0;a<this.material.length;a++)this.material[a]=this.material[a].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe,i);this.syncShadowCatcher(e)}shadowCatcherActive(){let t=this.dataPatched,e=t.geometry?.type;return t.shadowCatcher===!0&&(e==="RectangleGeometry"||e==="PlaneGeometry")}syncShadowCatcher(t){let e=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=HA===void 0?null:R4(HA());if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=e.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,t.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.material=t.shared.material(e.material).getFlavor(e.flatShading,e.side,e.wireframe),t.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow)}static disposeOneMaterial(t){var e;Pk(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&pF(this.material).forEach(t=>{Hr.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),qr=z(()=>{Yt(),Ye(),a3(),Jc(),et(),sx(),Mp(),bk(),KS=new C,QS=new ve,JS=new ve,N4=new C,t2=new At,Ai=class extends Hr{constructor(t,e,i){super(t,e),this.data=e,this.isSkinnedMesh=!1,this.localGeometry=void 0,e.bindMode&&e.bindMatrix&&(this.bindMode=e.bindMode,this.bindMatrix=new At().fromArray(e.bindMatrix),this.bindMatrixInverse=new At)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof Gt&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof Gt?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof ab){let t=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(t),i=this.dataPatched.geometry;this.geometryCreateDeleyed=e.get(i,t,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(t){this.localGeometry=t}get is2DAndNoDepth(){let t=this.dataPatched.geometry;return N_.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return N_.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),ri(t.path,["geometry"])&&this.updateByPatchedOpGeometry(er.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}get appliedGeometrySize(){let t=this.localGeometry?.userData;if(t!==void 0&&t.sxPrev!==void 0)return[t.sxPrev,t.syPrev,t.szPrev]}updateGeometryInteractions(t,e){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let n,r,s,a=t;if(this.localGeometry===void 0){let u={...this.data.geometry,...a};this.localGeometry=Jl(u,e,this.data.flatShading,this)}a.scaleBaked?[n,r,s]=a.scaleBaked:{width:n,height:r,depth:s}=a;let o=this.localGeometry.userData,l=typeof n=="number"?n:1,c=typeof r=="number"?r:1,h=typeof s=="number"?s:1;o.sxPrev!==void 0&&FA(this.localGeometry.attributes,l/o.sxPrev,c/o.syPrev,h/o.szPrev),o.sxPrev=l,o.syPrev=c,o.szPrev=h}else{let n=Jl({...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&jS(this.localGeometry,n)?n.dispose():(this.localGeometry?.dispose(),this.localGeometry=n)}}refreshAttachedClonersInteractions(t){for(let e of this.attachedSurfaceCloners)e.update(t)}refreshAttachedCloners(t){for(let e of this.attachedSurfaceCloners)t.scene.addPendingUpdateCloner(e.object)}refreshAttachedPaths(t){for(let e of this.attachedPaths)t.scene.addPendingCommand(()=>e.updateShape())}createGeometryDelayed(t){this.geometryCreateDeleyed=t.shared,this.refreshAttachedCloners(t),this.refreshAttachedPaths(t)}updateByPatchedOpGeometry(t,e,i){let n=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Fi&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!n&&t.type===0&&t.path.length===0&&xk(t.props)&&this.geometryCreateDeleyed instanceof Fi&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!n&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof Gt&&!(this.geometryCreateDeleyed instanceof Fi)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let r=i.shared,s=this.chooseGeoemtryCache(r),a=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=Jl(o,r,this.data.flatShading,this);jS(a,l)?(l.dispose(),a.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,n=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}n||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(t,e){this.createGeometryDelayed(e)}applyTransientGeometryData(t,e){let i=t.shared,n=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof Gt&&!(this.geometryCreateDeleyed instanceof Fi)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let r=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(r.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let a=Jl(n,i,this.data.flatShading,this);return jS(s,a)?(a.dispose(),s.computeBoundingSphere(),r.mutateIfUnique(this._geometryCacheKey,n)):(a.computeBoundingSphere(),r.forceDelete(this._geometryCacheKey),r.adopt(n,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=n,this.refreshAttachedCloners(t),void this.refreshAttachedPaths(t)}}e&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),t.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(t)}updateState(t,e){t.geometry!==void 0&&this.updateGeometryOnStateUpdate(t.geometry,e);let i=t.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:n,value:r}}of i)this.updateMorphInfluences(n,e.shared.getVariable(r,[this.uuid,"morphTargetInfluences",n]))}super.updateState(t,e)}updateMorphInfluences(t,e){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[t];i!==void 0&&(this.morphTargetInfluences[i]=e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(t,e){let i=this.geometry.userData.parameters;this.is2DType?t.set(0,0,.5*i.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?t.fromArray(i.centerOffset):t.setScalar(0),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(t,e){this.skeleton=t,this.isSkinnedMesh=!0,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(t){let e=new ve,i=this.geometry.attributes.skinWeight;for(let n=0,r=i.count;n<r;n++){e.fromBufferAttribute(i,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),i.setXYZW(n,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let n=this.geometry;QS.fromBufferAttribute(n.attributes.skinIndex,t),JS.fromBufferAttribute(n.attributes.skinWeight,t),KS.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){let s=JS.getComponent(r);if(s!==0){let a=QS.getComponent(r);t2.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(N4.copy(KS).applyMatrix4(t2),s)}}return e.applyMatrix4(this.bindMatrixInverse)}}});function Qu(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!Q_(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Ai&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,n=new Float32Array(i.length),r=new C;for(let s=0;s<i.length;s+=3)r.set(i[s],i[s+1],i[s+2]).normalize(),n[s]=r.x,n[s+1]=r.y,n[s+2]=r.z;e.geometry.setAttribute("extrudeNormal",new Nt(n,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,n=e.geometry.attributes,r=n.position.array,s=n.normal.array,a=new Float32Array(r.length);for(let o=0;o<r.length;o+=3){let l=`${r[o]}_${r[o+1]}_${r[o+2]}`,c=new C(s[o],s[o+1],s[o+2]);i.has(l)?i.get(l)?.normals.push(c):i.set(l,{normals:[c],result:new C})}i.forEach((o,l)=>{for(let c of o.normals)o.result.add(c);o.result.divideScalar(o.normals.length)});for(let o=0;o<r.length;o+=3){let l=`${r[o]}_${r[o+1]}_${r[o+2]}`,c=i.get(l)?.result;c&&(a[o]=c.x,a[o+1]=c.y,a[o+2]=c.z)}e.geometry.setAttribute("extrudeNormal",new Nt(a,3))}(t)}function e2(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function Ju(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,n=e.randomColor;if(n!==void 0&&3*n.count===i.length)return;let r=new Float32Array(i.length),s=parseInt(t.uuid.replace(/\D/g,"")),a=[e2(Ot.seededRandom(s)),e2(Ot.seededRandom(s+1e4)),e2(Ot.seededRandom(s+2e4))];for(let o=0;o<i.length;o++)r[o]=a[o%3];t.geometry.setAttribute("randomColor",new Ht(r,3))}var lx=z(()=>{et(),GC(),qr()});function k4(t){let e=!1;return t.scene.objects.traverse((i,n)=>{n.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function O$(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function V4(t,e,i,n){let r=16*(e.children.length+1);Um.length<r&&(Um=new Float32Array(r));let s=0,a=l=>{l.toArray(Um,16*s),s++},o=e.parameters.hideBase!==!0;o&&a(n),XA.multiplyMatrices(t.hiddenMatrix,t.matrix);for(let l of e.children)!Mc(l)||l.playModeVisible===!1||($A.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),_1.multiplyMatrices(XA,$A),(!o||!_1.equals(n))&&a(_1));try{return s===0?0:function(l,c){return VC(K_().instanced_union(kC(l),c))}(i,Um.subarray(0,16*s))}finally{EN(i)}}var Ao,j4,XA,$A,_1,Um,lh,ob,hx,pa,to,lb,Zg=z(()=>{Kn(),et(),ex(),lx(),Jc(),Li(),Ao=new At,j4=new At,XA=new At,$A=new At,_1=new At,Um=new Float32Array(0),lh=class extends Hr{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new Gt,this.onAfterRender=(n,r,s,a,o,l)=>{super.onAfterRender(n,r,s,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&t.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(t,e=!0){if(this.booleanMeshSetAddress!==-1&&!t)return;for(let n=0;n<this.children.length;n++){let r=this.children[n];r instanceof lh&&r.dataPatched.visible===!0&&r.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let r=this.children[n];if(r instanceof Xi&&r.dataPatched.visible===!0&&r.geometry.attributes.position?.count>0&&r.geometry.drawRange.count>0&&r.booleanMeshSetAddress!==0){Ao.multiplyMatrices(r.hiddenMatrix,r.matrix).multiply(r.pivotMatrix);try{let s=O$(r,this);if(r.booleanMeshSetAddress===-1){if((r.geometry.index??r.geometry.getAttribute("position")).count/3<15e5){let a=JX(r.geometry,t===!0);r.booleanMeshSetAddress=s===void 0||a===-1?a:V4(r,s,a,Ao)}if(r.booleanMeshSetAddress===-1)return;s===void 0&&IS(r.booleanMeshSetAddress,Ao),r.booleanMatrixInvOld.copy(Ao).invert(),r.booleanWasTransformed=!1}else r instanceof lh&&r.needsTransformForDownstream===!0?(s===void 0?IS(r.booleanMeshSetAddress,Ao):r.booleanMeshSetAddress=V4(r,s,r.booleanMeshSetAddress,Ao),r.needsTransformForDownstream=!1):r.booleanWasTransformed===!0&&(IS(r.booleanMeshSetAddress,j4.multiplyMatrices(Ao,r.booleanMatrixInvOld)),r.booleanMatrixInvOld.copy(Ao).invert(),r.booleanWasTransformed=!1)}catch(s){console.error(s),r.booleanMeshSetAddress=0,r.geometry.userData.booleanOperationDidFail=!0;continue}if(r.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(r.booleanMeshSetAddress),r.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let n=this.geometry;n.dispose(),this.geometry=new Gt,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere,this.geometry.setAttribute("position",new Nt([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(n,r){let s=K_(),a=FO(n,r),o=s.mesh_topological_data(a),l=o.positions(),c=o.indices();return o.free(),a.free(),{positions:l,indices:c,verticesPerFace:new Uint8Array(c.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new Gt,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(n,r,s,a){let o=K_(),l=FO(n,r),c=o.mesh_render_data(l,Math.max(a,0));if(s.setAttribute("position",new Nt(c.positions(),3)),s.setAttribute("normal",new Nt(c.normals(),3)),c.free(),s.boundingSphere===null&&(s.boundingSphere=new vr),l.tri_count()===0)s.boundingSphere.center.set(0,0,0),s.boundingSphere.radius=0,s.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();s.boundingSphere.center.set(h[0],h[1],h[2]),s.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,s.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return VC(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Qu(this),Ju(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),Kg=z(()=>{et(),Wr(),Qc(),(ob||(ob={})).is=function(t){return Be.is(t)&&t instanceof _u},hx=(t,e)=>class extends Kc(t,e){updateState_Light(i,n){if(this.updateState_Entity(i,n),i.color!==void 0&&(this.color=n.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let r=this.shadow;r.camera.far=i.depth,r.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),xh=z(()=>{Zg(),Kn(),Qc(),pa=t=>t instanceof Xi,to=t=>t!==null&&t instanceof lh,lb=t=>bA.is(t)});function mr(t,e){return e.color(t)}function G4(t=new Date,e){let i=e.format,n=t.getSeconds(),r=t;e&&e.timeZone!==null&&(r=function(u,d){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:d,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(u),f=g=>Number(p.find(m=>m.type===g)?.value);return new Date(f("year"),f("month")-1,f("day"),f("hour"),f("minute"),f("second"),u.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let s,a=r.getHours(),o=r.getMinutes();e.format12h24h==="12ampm"&&(s=a>=12?"PM":"AM");let l,c,h=a;switch(e.format12h24h!=="24"&&(h=a%12,h===0&&(h=12)),i){case"HH:mm:ss":l=[h,o,n];break;case"HH:mm":l=[h,o];break;case"HH":l=[h],s=void 0;break;case"mm":l=[o],s=void 0;break;case"ss":l=[n],s=void 0;break;case"year":c=r.getFullYear();break;case"month":c=r.getMonth()+1;break;case"dayOfYear":c=Math.floor((r.getTime()-new Date(r.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=r.getDate();break;case"secondOfDay":c=60*a*60+60*o+n;break;default:console.error("Unknown time format",i),c=0}return l!==void 0?{textValue:l,suffix:s}:c}var YA,Qg,o3=z(()=>{}),L$=z(()=>{et(),Xg(),$g(),YA=class extends bp(Lz){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){xp(this.object,YA.geometryHelper,t,e)}}}),l3=z(()=>{et(),L$(),Kg(),Qg=class extends hx(Pz,YA){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let r=new Mg(this.shadow.camera);r.visible=!1,this.gizmos.shadowmap=r}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Mg&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&function(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),i&&this.update()}}});function h3(t){return t instanceof Hr&&t.needsAO&&!nl(t)&&t.isDecalObject!==!0}function c3(t){let e=t.cloner;if(e&&Array.isArray(e.children))for(let i of e.children)i?.layers&&(i.layers.mask=t.layers.mask)}function d3(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function H4(t,e){let i={outline:!1,cavity:!1},n=t.layers.mask&cx,r=e.getLayersOfType("transmission"),s=e.getLayersOfType("outline"),a=d3(e),o=e.getLayersOfType("cavity");return(s.length>0||o.length>0)&&(t.layers.set(8),r.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=s.length>0,i.cavity=o.length>0,Ju(t),Qu(t)),r.length===0&&s.length===0&&o.length===0&&a===0&&t.layers.set(0),n&&t.layers.set(9),!n&&h3(t)&&t.layers.enable(5),c3(t),i}function W4(t,e){if(!e.layers)return!1;let i=t.layers.mask&cx,n=!1,r=e.getLayersOfType("transmission").filter(l=>l.data.visible),s=e.getLayersOfType("outline").filter(l=>l.data.visible),a=d3(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return r.length>0&&(t.layers.set(3),(s.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),n=!0),r.length===0&&s.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&h3(t)&&t.layers.enable(5),c3(t),n}function q4(t,e){var i;if(!e.layers)return!1;let n=t.layers.mask&cx,r=!1,s=d3(e),a=e.getLayersOfType("transmission").filter(c=>c.data.visible),o=e.getLayersOfType("outline").filter(c=>c.data.visible),l=e.getLayersOfType("cavity").filter(c=>c.data.visible);return s>0&&((i=t.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),t.layers.set(4),a.length>0&&t.layers.enable(3),(o.length>0||l.length>0)&&t.layers.enable(8),r=!0),s===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),n&&t.layers.set(9),!n&&h3(t)&&t.layers.enable(5),c3(t),r}function ZA(t,e,i,n=!1){let r=t.cloner;if(r){let s=null;if(t.raycast===wi.prototype.raycast||t.raycast===Xi.prototype.raycast){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),s=a.boundingSphere)}for(let a of r.children){if(s!==null&&(KA.copy(s).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(KA)))continue;let o=Ik.copy(a.matrixWorld).invert(),l=Ok.copy(e.ray).applyMatrix4(o),c=t.matrixWorld;l.applyMatrix4(c);let h=Rk;h.set(l.origin,l.direction),h.near=e.near,h.far=e.far,h.layers.mask=e.layers.mask;let u=h.intersectObject(t,!1);u.length>0&&i.push({...u[0],object:n?a:t})}}}var cx,Rk,Ik,Ok,KA,Rv,Lk,i2,n2,r2,Jg,un,Bk=z(()=>{Li(),lx(),Kn(),Jc(),et(),cx=512,Rk=new lC,Ik=new At,Ok=new $o,KA=new vr}),B$=z(()=>{et(),Xg(),$g(),Rv=class extends bp(Iz){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){xp(this.object,Rv.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=Rv._vector,e=this.object.distance?this.object.distance:1e3,i=e*Math.tan(this.object.angle);this.cone.scale.set(i,i,e),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let r=0,s=this.cone.material.length;r<s;r++)this.cone.material[r].color.set(n);else this.cone.material.color.set(n)}}},(Lk=Rv)._vector=new C}),u3=z(()=>{et(),B$(),Kg(),i2=new C,n2=new C,r2=new qt,Jg=class extends hx(Tz,Lk){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=2*Ot.RAD2DEG*this.angle,n.aspect=1,n.near=100,n.far=2500;let r=new Mg(this.shadow.camera);r.visible=!1,this.gizmos.shadowmap=r,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Mg&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),n2.setFromMatrixPosition(this.matrixWorld),r2.setFromRotationMatrix(this.matrixWorld),i2.copy(this.up).applyQuaternion(r2).negate().multiplyScalar(this.distance),this.target.position.copy(n2).add(i2),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),ol=z(()=>{Yt(),Hs(),et(),Wr(),ya(),o3(),al(),l3(),Ye(),bh(),et(),Jc(),xh(),Bk(),u3(),ke(),Zg(),un=class extends Jb(rs){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new gn(1,1,1,1),this.fog=null,this.backupFog=new nE(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ir.getDensity({}),this.fogHeightFalloff=ir.getHeightFalloff({}),this.fogHeightBase=ir.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new Jt,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new vn(Zc,{...rg.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Az(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),e.uiScene){let n=fA();n===null?Gn("ui-2d","a page's 2D scene"):this.uiScene=new n.Scene2D((Array.isArray(t)?t[0]:t)+"-ui",e.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else e.uiFrame&&this.createUICanvas(e.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(t,e){let i=fA();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,e),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(t),this.uiCanvas?.applySize()})):Gn("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(t,e){t.color!==void 0&&(this.ambientLight.color=mr(t.color,e)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity*Math.PI),t.enabled!==void 0&&(t.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(t){this.isActive=!0,t.fog=this.fog,this.traverseEntity(e=>{e instanceof lh&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof Hr)if(Array.isArray(t.material))for(let e of t.material)e.needsUpdate=!0;else t.material.needsUpdate=!0,t.material.dispose()})}updateShadow(t){if(t.softShadowQuality===void 0&&t.type===void 0||!this.isActive)return;let e=this.data.shadow;var i,n;i=ng.isSoft(e),n=e?.softShadowQuality,WA!==void 0&&WA(i,n)&&this.forceMaterialsUpdate()}updateFog(t,e){t.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=mr(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ir.getMode(t),this.fogDensity=ir.getDensity(t),this.fogHeightFalloff=ir.getHeightFalloff(t),this.fogHeightBase=ir.getHeightBase(t)}updateSky(t,e){this.skyState=t??null,this.skyStateVersion++;let i=t?.hdri?.image;this.skyHdriHolder=i!=null?e.image(i):null}updateAo(t,e){t.aoColor!==void 0&&(this.aoColor=mr(t.aoColor,e))}updateByOp(t,e,i,n){let r=this.data.uiFrame;super.updateByOp(t,e,i,n);let s=e;ri(t.path,["fog"])?this.updateFog(s.fog,i.shared):ri(t.path,["sky"])?this.updateSky(s.sky,i.shared):ri(t.path,["grading"])?this.gradingState=s.grading??null:ri(t.path,["ao"])?this.updateAo(s.ao,i.shared):ri(t.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):ri(t.path,["shadow"])?this.updateShadow(s.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||r!==s.uiFrame)&&this.updateUIFrame(t.props.uiFrame,i)}updateUIFrame(t,e){t?(this.uiCanvas||this.createUICanvas(t,e),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(t)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(t,e){this.updateState_Entity(t,e),t.backgroundColor!==void 0&&this.setBackgroundColor(mr(t.backgroundColor,e.shared)),t.fog!==void 0&&this.updateFog(t.fog,e.shared),t.sky!==void 0&&this.updateSky(t.sky,e.shared),t.grading!==void 0&&(this.gradingState=t.grading),t.ambient!==void 0&&this.updateAmbientLight(t.ambient,e.shared),t.ao!==void 0&&this.updateAo(t.ao,e.shared),t.shadow!==void 0&&this.updateShadow(t.shadow)}createFrame(t,e){}raycast(t,e){super.raycast(t,e)}switchActiveCamera(t){t&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(il).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof Qg&&i.visible&&t<ag&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof Jg&&i.visible&&t<il-ag&&(this.penumbraSizeArrayCache[ag+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=n=>{for(let r of n.children){let s=r.cloner;Be.is(r)&&(r.visible||s?.object.data.visible)&&((pa(r)||lb(r)&&this.scene.enableHelpers&&r.objectHelper.visible)&&(t.intersectObject(r,!1,e),ZA(r,t,e,!0)),i(r))}};return i(this),e}updateEntity2DByOp(t,e,i,n){this.uiCanvas?.updateEntity2DByOp(t,e,i,n)}}});function X4(){return Uk}function s2(){if(hb===null)throw new Error('[spe] Classic (WebGL) particles are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return hb}function a2(t){return t?.isWebGPUSplineRenderer===!0}var Uk,hb,tp,zk=z(()=>{Uk=null,hb=null}),p3=z(()=>{et(),Yb(),Qc(),tp=class extends Kc(yp,pp){constructor(t,e,i){super(),this.super_Entity(t,e),this.context=i,this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e)}}}),U$=gp((t,e)=>{var i,n;i=t,n=function(){return r.importState=function(s){var a=new r;return a.importState(s),a},r;function r(){return function(s){var a=0,o=0,l=0,c=1;s.length==0&&(s=[+new Date]);var h=function(){var p=4022871197,f=function(g){g=g.toString();for(var m=0;m<g.length;m++){var y=.02519603282416938*(p+=g.charCodeAt(m));y-=p=y>>>0,p=(y*=p)>>>0,p+=4294967296*(y-=p)}return 23283064365386963e-26*(p>>>0)};return f.version="Mash 0.9",f}();a=h(" "),o=h(" "),l=h(" ");for(var u=0;u<s.length;u++)(a-=h(s[u]))<0&&(a+=1),(o-=h(s[u]))<0&&(o+=1),(l-=h(s[u]))<0&&(l+=1);h=null;var d=function(){var p=2091639*a+23283064365386963e-26*c;return a=o,o=l,l=p-(c=0|p)};return d.next=d,d.uint32=function(){return 4294967296*d()},d.fract53=function(){return d()+11102230246251565e-32*(2097152*d()|0)},d.version="Alea 0.9",d.args=s,d.exportState=function(){return[a,o,l,c]},d.importState=function(p){a=+p[0]||0,o=+p[1]||0,l=+p[2]||0,c=+p[3]||0},d}(Array.prototype.slice.call(arguments))}},typeof t=="object"?e.exports=n():typeof define=="function"&&define.amd?define(n):i.Alea=n()});function z$(t){let e=!1;return t.scene.objects.traverse((i,n)=>{n.type==="Mesh"&&n.geometry.type==="SubdivGeometry"&&(e=!0)}),e}var Js,zd,mp,t0=z(()=>{Kn(),et(),Mp(),lx(),qr(),Js=new ci,zd=new C,mp=class extends Ai{constructor(t,e,i){super(t,e,i),this.data=e,this.hiddenMatrixOld=new At,this.smoothShading=!0,this.skipReactionUpdate=!1}chooseGeoemtryCache(t){return this.dataPatched.flatShading?t.geometryCache:t.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(t,e){let i=this.geometry.userData.parameters;t.copy(this.originalGeometryNew.boundingSphere.center),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(t){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:n,subdivPointer:r}=Fi.build(t,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=r,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qu(this),Ju(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}updateState(t,e){if(super.updateState(t,e),t.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(n=>n.getFlavor(!1,n.side,n.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!t.flatShading,this.createGeometryDelayed(e)}}updateMesh(t=!1,e=!1,i=!1){e&&this.subdividedGeometry||Fi.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&Fi.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let t=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=Fi.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Fi.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qu(this),Ju(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}raycast(t,e){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,Xi.prototype.raycast.call(this,t,e),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new vr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;Js.setFromBufferAttribute(e),Js.getCenter(i),t.boundingSphere.radius=i.distanceTo(Js.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Js.getSize(zd),this.hasNonUniformScale&&zd.divide(this.scale);let n={width:zd.x,height:zd.y,depth:zd.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(t){let e=this.originalGeometry;Js.min.set(t[0],t[2],t[4]),Js.max.set(t[1],t[3],t[5]),this.hasNonUniformScale&&(Js.min.applyMatrix4(this.shearScaleInv),Js.max.applyMatrix4(this.shearScaleInv)),e.boundingSphere===null&&(e.boundingSphere=new vr);let i=e.boundingSphere.center;Js.getCenter(i),e.boundingSphere.radius=i.distanceTo(Js.max)}freeSubdivPointer(){this.subdivPointer&&(Fi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(t){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry,i=e?.uuid,n=e?.userData.parameters,r=t.subdivisions>0?Fi.buildRefined(this.subdivPointer,t.subdivisions,this.smoothShading?t.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=r??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qu(this),Ju(this),n!==void 0&&(this.localGeometry.userData.parameters=n),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),this.localGeometry&&(t.type===0&&t.path.length===0&&xk(t.props)&&this.subdivPointer?this.updateSubdivisionLevel(e):this.createGeometryByControls(e))}}});function f3(t){if(t.component){let e=t.component.instances.indexOf(t);e>=0&&t.component.instances.splice(e,1);for(let i of t.children)Be.is(i)&&f3(i)}}var cg,QA,dx,Fk=z(()=>{Wr()}),F$=gp((t,e)=>{function i(n,r,s,a){this.message=n,this.expected=r,this.found=s,this.location=a,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i)}(function(n,r){function s(){this.constructor=n}s.prototype=r.prototype,n.prototype=new s})(i,Error),i.buildMessage=function(n,r){var s,a={literal:function(u){return'"'+l(u.text)+'"'},class:function(u){var d,p="";for(d=0;d<u.parts.length;d++)p+=u.parts[d]instanceof Array?c(u.parts[d][0])+"-"+c(u.parts[d][1]):c(u.parts[d]);return"["+(u.inverted?"^":"")+p+"]"},any:function(u){return"any character"},end:function(u){return"end of input"},other:function(u){return u.description}};function o(u){return u.charCodeAt(0).toString(16).toUpperCase()}function l(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+o(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+o(d)})}function c(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+o(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+o(d)})}function h(u){return a[u.type](u)}return"Expected "+function(u){var d,p,f=new Array(u.length);for(d=0;d<u.length;d++)f[d]=h(u[d]);if(f.sort(),f.length>0){for(d=1,p=1;d<f.length;d++)f[d-1]!==f[d]&&(f[p]=f[d],p++);f.length=p}switch(f.length){case 1:return f[0];case 2:return f[0]+" or "+f[1];default:return f.slice(0,-1).join(", ")+", or "+f[f.length-1]}}(n)+" but "+((s=r)?'"'+l(s)+'"':"end of input")+" found."},e.exports={SyntaxError:i,parse:function(n,r){r=r!==void 0?r:{};var s,a={},o={svg_path:Pe},l=Pe,c=function(J){if(!J)return[];for(var Et=[],ft=0;ft<J.length;ft++)Et=Et.concat.apply(Et,J[ft]);var St=Et[0];return St&&St.code=="m"&&(delete St.relative,St.code="M"),Et},h=function(J,Et){return function(ft,St){if(!St)return[ft];for(var It=[ft],B=0,st=St.length;B<st;B++)It[B+1]=St[B][1];return It}(J,Et)},u=/^[Mm]/,d=be(["M","m"],!1,!1),p=function(J,Et,ft){var St=uo(J,[Et]);return ft&&(St=St.concat(uo(J=="M"?"L":"l",ft[1]))),St},f=/^[Zz]/,g=be(["Z","z"],!1,!1),m=function(){return uo("Z")},y=/^[Ll]/,v=be(["L","l"],!1,!1),_=function(J,Et){return uo(J,Et)},b=/^[Hh]/,x=be(["H","h"],!1,!1),w=function(J,Et){return uo(J,Et.map(function(ft){return{x:ft}}))},S=/^[Vv]/,A=be(["V","v"],!1,!1),E=function(J,Et){return uo(J,Et.map(function(ft){return{y:ft}}))},P=/^[Cc]/,T=be(["C","c"],!1,!1),R=function(J,Et,ft){return{x1:J.x,y1:J.y,x2:Et.x,y2:Et.y,x:ft.x,y:ft.y}},L=/^[Ss]/,D=be(["S","s"],!1,!1),U=function(J,Et){return{x2:J.x,y2:J.y,x:Et.x,y:Et.y}},V=/^[Qq]/,k=be(["Q","q"],!1,!1),Y=function(J,Et){return{x1:J.x,y1:J.y,x:Et.x,y:Et.y}},$=/^[Tt]/,nt=be(["T","t"],!1,!1),Q=/^[Aa]/,rt=be(["A","a"],!1,!1),gt=function(J,Et,ft,St,It,B){return{rx:J,ry:Et,xAxisRotation:ft,largeArc:St,sweep:It,x:B.x,y:B.y}},at=function(J,Et){return{x:J,y:Et}},ht=function(J){return 1*J},ct=function(J){return 1*J.join("")},q=/^[01]/,lt=be(["0","1"],!1,!1),F=function(J){return J=="1"},O=function(){return""},j=",",Z=_e(",",!1),I=function(J){return J.join("")},G=".",W=_e(".",!1),N=/^[eE]/,tt=be(["e","E"],!1,!1),ot=/^[+\-]/,pt=be(["+","-"],!1,!1),ut=/^[0-9]/,Pt=be([["0","9"]],!1,!1),bt=function(J){return J.join("")},Rt=/^[ \t\n\r]/,_t=be([" "," ",`
4169
+ `&&E.push("")):x.getTextWidth(E[E.length-1]+P,b)>A&&(E[E.length-1].length&&E.push(""),x.getTextWidth(E[E.length-1]+P,b)>A&&(P.length===1?(E[E.length-1]+=P,P=""):(E[E.length-1]+=P.slice(0,-1),P=P[P.length-1],E.push(""))));return E[E.length-1]+=P,E}(t,i,c===2?h.toUpperCase():c===3?h.toLowerCase():h,e),{shapes:d,charWidths:p,charCoords:f}=i.generateShapes(u,t,e),g=.5*(typeof n=="number"?n:Number(e.getVariable(n))),m=.5*(typeof r=="number"?r:Number(e.getVariable(r))),y=d.map(b=>new Ni().fromShape(b,!0));this.vectorShapes=y;let v=y.map(b=>_h.create({shape:b,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:a,windingRule:s<=0?fi.NONZERO:fi.ODD,subdivisions:this.isLowResolution&&s>0?1:12}})),_=v.length?Sc(v):A4();_.translate(-g,m,0),this.dispose(),this.wrappedText=u,this.charCoords=f,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(_.attributes).forEach(([b,x])=>{this.setAttribute(b,x)}),this.setIndex(_.index),this.computeBoundingSphere()}clone(){let t=Er(new Gt,UA.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([e,i])=>{this.setAttribute(e,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t,e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:t}},e)}get text(){return this.userData.parameters.text??""}}});function P$(t){if(!zA)return C4||(C4=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.44/build",i=import("./process.js"),[n,r]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=n.default,a=await s({wasmBinary:r});yk(a),zA=!0}())}var yk,t3,zA,C4,rx=z(()=>{t3=new Promise(t=>{yk=t}),zA=!1});function jS(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),n=Object.keys(e.attributes);if(i.length!==n.length)return!1;for(let o of n){let l=t.attributes[o],c=e.attributes[o];if(l===void 0||l.isInterleavedBufferAttribute===!0||c.isInterleavedBufferAttribute===!0||l.itemSize!==c.itemSize||l.normalized!==c.normalized||l.array.constructor!==c.array.constructor||l.array.length!==c.array.length)return!1}let r=t.index,s=e.index;if(r===null!=(s===null))return!1;let a=!1;if(r!==null&&s!==null){if(r.array.length!==s.array.length)return!1;let o=r.array.constructor,l=s.array.constructor;if(o!==l){if(o!==Uint32Array||l!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let o=0;o<e.groups.length;o++){let l=t.groups[o],c=e.groups[o];if(l.start!==c.start||l.count!==c.count||l.materialIndex!==c.materialIndex)return!1}for(let o of n){let l=t.attributes[o],c=e.attributes[o];l.array.set(c.array),l.needsUpdate=!0}if(r!==null&&s!==null){if(a){let o=r.array,l=s.array;for(let c=0,h=l.length;c<h;c++){let u=l[c];o[c]=u===65535?4294967295:u}}else r.array.set(s.array);r.needsUpdate=!0}return t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t.boundingBox=null,t.boundingSphere=null,!0}function FA(t,e,i,n){let r,s,a,o=t.position.array,l=t.normal.array,c=_k.makeScale(e,i,n).invert().elements;for(let h=0,u=o.length;h<u;h+=3)o[h]*=e,o[h+1]*=i,o[h+2]*=n,r=l[h],s=l[h+1],a=l[h+2],l[h]=c[0]*r+c[4]*s+c[8]*a,l[h+1]=c[1]*r+c[5]*s+c[9]*a,l[h+2]=c[2]*r+c[6]*s+c[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var _k,bk=z(()=>{et(),_k=new At});function NA(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function Tv(t){if(t!=null){if(Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView))return t;if(typeof t=="object")return function(e){let i=Object.keys(e),n=0;for(let s of i){let a=NA(s);a>=n&&(n=a+1)}if(n===0||n>i.length)return;let r=new Array(n);for(let s=0;s<n;s++){let a=e[s];if(typeof a!="number")return;r[s]=a}return r}(t)}}function GS(t){if(t==null)return"missing";if(Array.isArray(t))return`Array(${t.length})`;if(ArrayBuffer.isView(t)){let l=t;return`${t.constructor.name}(${l.length})`}if(typeof t!="object")return typeof t;let e=Object.keys(t),i=e.filter(l=>NA(l)===-1),n=0;for(let l of e){let c=NA(l);c>=n&&(n=c+1)}let r=t,s=-1,a=-1;for(let l=0;l<n;l++)l in r?typeof r[l]!="number"&&a===-1&&(a=l):s===-1&&(s=l);let o=[`${e.length} keys`,"max index "+(n-1)];return s!==-1&&o.push(`first missing index ${s}`),a!==-1&&o.push(`non-number at ${a} (${typeof r[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function xk(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function e3(t,e){let i=e?e.count:t.count,n=0,r=1e4,s=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let u=e?e.getX(h):h,d=t.getX(u),p=t.getY(u),f=t.getZ(u),g=Math.round(d*r),m=Math.round(p*r),y=Math.round(f*r),v=s.get(g);v===void 0&&(v=new Map,s.set(g,v));let _=v.get(m);_===void 0&&(_=new Map,v.set(m,_));let b=_.get(y);b===void 0&&(b=n++,_.set(y,b),o.push(d,p,f)),a[h]=b}let l=[],c=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||(l.push(a[h],a[h+1],a[h+2]),c.push(e?e.getX(h):h,e?e.getX(h+1):h+1,e?e.getX(h+2):h+2));return{positions:o,triIndices:l,triOriginals:c}}var Bf,Kh,Qt,HS,WS,qS,Fi,Uf,Cv,Pv,Dv,kA,y1,Mp=z(()=>{et(),rx(),Yt(),sx(),bk(),Lg(),Bf=new ci,Kh=new C,t3.then(t=>{Qt=t}),HS=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),WS=new Uint32Array([0,1,2,3]),qS=new Uint8Array([4]),Fi=class extends Gt{constructor(t,e){super(),this.data=t,this.flatShading=e,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,e){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),n=oh.div(e.map(a=>typeof a=="number"?a:0),i);if(n.every(a=>a===1))return;this.subdividedGeometry&&FA(this.subdividedGeometry.attributes,...n),this.originalGeometry&&FA(this.originalGeometry.attributes,...n),this.data=t;let r=this.userData.parameters;this.userData.parameters={width:r.width*n[0],height:r.height*n[1],depth:r.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(Kh.fromArray(n));let s=Kh.set(r.width,r.height,r.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(t){this.freeSubdivPointer(),this.data=t;let e=t.phongAngle??35;this.flatShading&&(e=-1);let i=null;if(t.subdivisions>0){let r=0;try{r=Fi.allocate(t),i=Fi.buildRefined(r,t.subdivisions,e)}catch(s){console.error(s,t)}finally{r&&Fi.freeSubdivPointer(r)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let n=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=n}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=Fi.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new ga(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Fi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new vr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;Bf.setFromBufferAttribute(e),Bf.getCenter(i),t.boundingSphere.radius=i.distanceTo(Bf.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Bf.getSize(Kh);let n={width:Kh.x,height:Kh.y,depth:Kh.z};return this.userData.parameters=n,n}static build(t,e,i,n){let r,s,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Qt.free_bvh(e),Qt.free_subdivision_surface(e));try{r=Fi.allocate(t,n)}catch(l){console.error(l,t),r=Fi.allocate({positionWASM:HS,indexWASM:WS,verticesPerFaceWASM:qS},n)}Qt.set_destination_refinement_level(r,0);let o=Fi.buildLevel(r,!0,a);return s=t.subdivisions>0?Fi.buildRefined(r,t.subdivisions,a):null,{subdivPointer:r,originalGeometry:o,subdividedGeometry:s}}static buildRefined(t,e,i){try{return Qt.set_destination_refinement_level(t,e),Fi.buildLevel(t,!1,i)??null}catch{try{return Qt.set_destination_refinement_level(t,e-1),Fi.buildLevel(t,!1,i)??null}catch{return null}}}static primitiveToQuads(t,e,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let n,r=t.shape!==void 0||t.path!==void 0?e.geometry:Jl(t,i,!1,e);n=SN(t)?r.getClosedTorusIndicesForBooleanOrSubdiv():r.getIndex();let s,{positions:a,triIndices:o,triOriginals:l}=e3(r.getAttribute("position"),n);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let d=t.radialSegments*t.heightSegments*3*2;s=[d,d+3*t.radialSegments]}let{indices:c,verticesPerFace:h,uvs:u}=function(d,p,f,g,m){let y=[],v=[],_=m?f.getAttribute("uv"):void 0,b=_&&_.itemSize===2?[]:void 0,x=A=>{if(b){let E=m[A];b.push(_.getX(E),_.getY(E))}};if(f.userData.shape!==void 0&&f.userData.parameters.depth===0&&f.userData.shape.shapeHoles.length===0){let A=f.userData.shape.extractShapePointsToFlatArray([]),E=f.userData.parameters.spikes;if(f.userData.type==="EllipseGeometry"&&E<=24&&E%4==0&&f.userData.parameters.angle>=360){let R=A.length/2/E;A=A.filter((L,D)=>Math.floor(D/2)%R===0)}let P=0;for(let R=0;R<A.length;R+=2)P+=(A[R]-A[(R===0?A.length:R)-2])*(A[R+1]+A[(R===0?A.length:R)-1]);d.length=0;let T=0;if(P<0)for(let R=0;R<A.length;R+=2)d.push(A[R],A[R+1],0),y.push(T++);else for(let R=A.length-2;R>=0;R-=2)d.push(A[R],A[R+1],0),y.push(T++);return v.push(T),{indices:y,verticesPerFace:v}}let w=new Float32Array([f.userData.parameters.depth])[0],S=0;for(;S<p.length;){if(f.useNgonForTopBottomFaceDuringBake){let A=0;if((d[3*p[S]+2]===w||d[3*p[S]+2]===0)&&A++,(d[3*p[S+1]+2]===w||d[3*p[S+1]+2]===0)&&A++,(d[3*p[S+2]+2]===w||d[3*p[S+2]+2]===0)&&A++,A===3)break}if(p[S+1]===p[S+3]&&p[S+2]===p[S+5]||p[S+0]===p[S+3]&&p[S+2]===p[S+4]){Uf.set(d[3*p[S]],d[3*p[S]+1],d[3*p[S]+2]),Cv.set(d[3*p[S+1]],d[3*p[S+1]+1],d[3*p[S+1]+2]),Pv.set(d[3*p[S+4]],d[3*p[S+4]+1],d[3*p[S+4]+2]),Dv.set(d[3*p[S+5]],d[3*p[S+5]+1],d[3*p[S+5]+2]),Cv.sub(Uf).normalize(),Pv.sub(Uf).normalize(),Dv.sub(Uf).normalize();let A=Cv.cross(Pv).dot(Dv),E=S;Math.abs(A)>.005||g&&g.some((P,T)=>T%2!=1&&E>=g[T]&&E<g[T+1])?(y.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),v.push(3),S+=3):(y.push(p[S],p[S+1],p[S+4],p[S+5]),x(S),x(S+1),x(S+4),x(S+5),v.push(4),S+=6)}else y.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),v.push(3),S+=3}if(f.useNgonForTopBottomFaceDuringBake){let A=[],E=[],P=0;for(let T=0,R=0;T<d.length;T+=3,R++)d[T+2]===0&&(A.push(R),P++),d[T+2]===w&&E.push(R);if(f.userData.parameters.extrudeBevelSize===0){let T=E[0];E[0]=E[1],E[1]=T}A.reverse(),y.push(...A,...E),v.push(P,P),b=void 0}return{indices:y,verticesPerFace:v,uvs:b}}(a,o,r,s,l);return{positions:a,indices:c,verticesPerFace:h,uvs:u}}static allocate(t,e){let i,n,r,s=[],a=[],o=Tv(t.positionWASM),l=Tv(t.indexWASM),c=Tv(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!c?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${GS(t.positionWASM)}, indexWASM ${GS(t.indexWASM)}, verticesPerFaceWASM ${GS(t.verticesPerFaceWASM)}`);i=o,n=l,r=c;let S=Tv(t.uvWASM);Qt.alloc_subdivision_surface_uvs&&S&&S.length===2*n.length&&(a=S)}else i=HS,n=WS,r=qS;let h=i.length,u=n.length,d=r.length,p=i.length+s.length+a.length,f=n.length+r.length,g=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Qt._malloc(g);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let v,_=new Float32Array(Qt.HEAPF32.buffer,y,p),b=new Uint32Array(Qt.HEAPU32.buffer,y+m,f);_.set(i,0),_.set(s,i.length),_.set(a,i.length+s.length),b.set(n,0),b.set(r,n.length),t?.scaleBaked?.some(S=>S!==1)&&(v=new At().makeScale(...t.scaleBaked.map(S=>typeof S=="number"?S:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,w=a.length?v?Qt.alloc_subdivision_surface_uvs2(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,x,a.length,v.elements):Qt.alloc_subdivision_surface_uvs(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,x,a.length):v?Qt.alloc_subdivision_surface2(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,v.elements):Qt.alloc_subdivision_surface(y,h,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Qt._free(y),w}static buildLevel(t,e,i,n,r,s=!1){let a=r?Qt.get_mesh_data2(t,e?Qt.Level.CONTROL:Qt.Level.REFINED,i,r.elements):Qt.get_mesh_data(t,e?Qt.Level.CONTROL:Qt.Level.REFINED,i),o=Qt.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),c=0,h=Qt.HEAPU32[o[c]>>2],u=Qt.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let d=Qt.HEAPU32[o[c]>>2],p=Qt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=Qt.HEAPU32[o[c]>>2],g=Qt.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let m,y=Qt.HEAPU32[o[c]>>2],v=Qt.HEAPU32.subarray(y>>2,(y>>2)+l[c]);if(c++,Qt.alloc_subdivision_surface_uvs){let b=o[9];if(b>0){let x=Qt.HEAPU32[o[8]>>2];m=Qt.HEAPF32.subarray(x>>2,(x>>2)+b)}}if(n===void 0){let b=new Gt;if(b.setIndex(new rh(v,1)),b.setAttribute("position",new Nt(u,3)),b.setAttribute("normal",new Nt(p,3)),m&&b.setAttribute("uv",new Nt(m,2)),e){b.setAttribute("faceMap",new rh(g,1));let x=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Ht(x,4))}return Qt.free_mesh_data(a),b.userData.type="SubdivGeometry",b}if(n.getAttribute("position").copyArray(u),n.getAttribute("normal").copyArray(p),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,s){let b=n.getIndex();b!==null&&b.array.length===v.length&&(b.copyArray(v),b.needsUpdate=!0)}let _=n.getAttribute("uv");m&&_&&_.array.length===m.length&&(_.copyArray(m),_.needsUpdate=!0),Qt.free_mesh_data(a)}static freeSubdivPointer(t){Qt.free_bvh(t),Qt.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let n=Qt.get_wireframe_data_for_base_level(t),r=Qt.HEAPU32.subarray(n>>2,4+(n>>2)),s=r.subarray(2,4),a=0,o=Qt.HEAPU32[r[a]>>2],l=Qt.HEAPF32.subarray(o>>2,(o>>2)+s[a]);a++;let c=Qt.HEAPU32[r[a]>>2],h=Qt.HEAPU32.subarray(c>>2,(c>>2)+s[a]);if(e===void 0){let u=new Gt;u.setAttribute("position",new Nt(l,3));let d=new Float32Array(l.length);for(let p=0,f=l.length;p<f;)d[p++]=i.r,d[p++]=i.g,d[p++]=i.b;return u.setAttribute("color",new Ht(d,3)),u.setIndex(new rh(h,1)),Qt.free_wireframe_data_for_base_level(n),u}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Qt.free_wireframe_data_for_base_level(n)}static updateCollabMesh(t,e,i){let n=e===0;n||Qt.set_destination_refinement_level(t,e);let r=i?Qt.get_topological_data2(t,n?Qt.Level.CONTROL:Qt.Level.REFINED,i.elements):Qt.get_topological_data(t,n?Qt.Level.CONTROL:Qt.Level.REFINED),s=Qt.HEAPU32.subarray(r>>2,8+(r>>2)),a=s.subarray(3,6),o=0,l=Qt.HEAPU32[s[o]>>2],c=new Float32Array(Qt.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=Qt.HEAPU32[s[o]>>2],u=new Uint32Array(Qt.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let d,p=Qt.HEAPU32[s[o]>>2],f=new Uint8Array(Qt.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Qt.alloc_subdivision_surface_uvs){let g=s[7];if(g>0){let m=Qt.HEAPU32[s[6]>>2];d=new Float32Array(Qt.HEAPF32.subarray(m>>2,(m>>2)+g))}}return Qt.free_topological_data(r),{positions:c,indices:u,verticesPerFace:f,uvs:d}}},Uf=new C,Cv=new C,Pv=new C,Dv=new C}),wk=z(()=>{ZO(),KO(),tb(),QO(),nb(),Lg(),p4(),f4(),m4(),LA(),y4(),rb(),_4(),b4(),x4(),BA(),w4(),S4(),M4(),E4(),dh(),ke(),ZO(),KO(),tb(),QO(),nb(),T$(),Lg(),p4(),f4(),m4(),LA(),y4(),rb(),_4(),b4(),x4(),BA(),w4(),S4(),M4(),E4(),dh(),C$(),JN(),vk(),Mp(),rx(),ex(),kA={ConeGeometry:kN,CubeGeometry:VN,CylinderGeometry:YC,DodecahedronGeometry:jN,EllipseGeometry:ix,HelixGeometry:MN,IcosahedronGeometry:nk,LatheGeometry:rk,NonParametricGeometry:ak,PolygonGeometry:QC,PyramidGeometry:ok,RectangleGeometry:nx,SphereGeometry:ck,PlaneGeometry:dk,BackdropGeometry:uk,StarGeometry:JC,TextFrameGeometry:pk,TorusGeometry:fk,TorusKnotGeometry:mk,TriangleGeometry:gk,VectorGeometry:_h},y1=t=>{let e=kA[t.type]??cN(t.type);if(e===void 0)throw new Error(`No geometry factory registered for "${t.type}" \u2014 was its feature compiled out of this runtime build?`);return e.create(t)}});function Jl(t,e,i,n){let r,s,a;t.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(t)),a=[[],["extrusion"]]):(s={...t},a=[[]]);for(let c of a){let h=s;for(let u of c)h=h[u];for(r in h){let u=h[r];gI(u)&&!Sk.includes(r)&&(h[r]=e.getVariable(u,[n.uuid,"geometry",...c,r]),gI(h[r])&&(h[r]=1))}}let o,l={parameters:s,type:s.type};if(s.type==="PathGeometry")l.path=s.path;else if(s.type==="VectorGeometry"){let c=Ni.createFromState(s.shape,s.width,s.height);l.shape=c}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),l.geometry=new oC().parse(s),l.geometry.groups.length===0){let c=l.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else{if(s.type==="SubdivGeometry"){let c=new Fi(s,i);return c.data=t,c}if(s.type==="TextGeometry"||s.type==="InputGeometry"){let c=cN(s.type);if(c)return c.create(s,e);Gn("text",`a ${s.type}`);let h=Ni.createFromState(Rg.defaultData(),100,100);return y1({...s,shape:h,type:"VectorGeometry"})}if(s.type==="UIGeometry")return nx.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}try{o=y1(l)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${l}`);let h=Ni.createFromState(Rg.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=y1(l)}return o}var Sk,P4,VA,sx=z(()=>{Yt(),et(),wk(),ke(),rb(),yh(),Mp(),Sk=["font"]}),D$=z(()=>{sx(),P4=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,i){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,i),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.objects.set(e,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){e===this.objects.get(t)&&this.unreachable.delete(t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},VA=class extends P4{constructor(t){super(),this.flatShading=t}disposeObject(t){t.dispose()}createObject(t,e,i){let n=Jl(t,e,this.flatShading,i);return n.computeBoundingSphere(),n}}});function sb(){return ax}function Mk(){if(ax==="webgpu"){if(I4!==void 0)return I4;GA||(GA=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(jA===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return jA}function Ek(t,e){return Mk().createRootMaterial(t,e)}function D4(t,e,i){return Mk().createSharedMaterial(t,e,i)}function R4(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function Ak(){return R$}var ax,I4,jA,GA,HA,R$,WA,Tk,bh=z(()=>{ax="webgl",GA=!1}),I$=z(()=>{Tk={markNeedsUpdateRendererDirty:()=>{}}});function Pc(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let n=t.layers?.find(r=>r.data.type==="light");if(n){let r=n.data,s=Number(e.getVariable(r.alphaOverride));if((typeof r.alphaOverride=="string"?s/100:r.alphaOverride)<1)return!0}for(let r of t.layers){if(r.data.type!=="displace"&&r.data.isMask)return!0;if(r.data.type!=="displace"&&"alpha"in r.data&&r.data.type!=="light"&&r.data.type!=="fresnel"&&r.data.type!=="cavity"&&r.data.type!=="dust"&&r.data.type!=="texture"&&r.data.type!=="matcap"&&r.data.type!=="rainbow"&&r.data.type!=="outline"&&r.data.type!=="pattern"){let s=r.data.visible?r.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(e.getVariable(s)??100)/100))),s===1&&r.data.type==="depth"||r.data.type==="gradient"){for(let a of r.data.colors)if(a[3]<1){s=a[3];break}}else if(s===1&&r.data.type==="noise"){let a=e.color(r.data.colorA).a,o=e.color(r.data.colorB).a,l=e.color(r.data.colorC).a,c=e.color(r.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,c)));h<1&&(s=h)}i+=(1-i)*s}}return i<1}var i3=z(()=>{});function fp(t){return typeof t=="string"||typeof t=="number"&&t!==0}var uh,Xt,ox,Ck,O4,L4,ys,rl=z(()=>{uh=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,Xt=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),ox={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},Ck={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),Ep=z(()=>{et(),Yg(),O4=class extends Qb(_i){},L4=t=>t.type==="Mesh",ys=class extends O4{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=t.hasNonUniformScale}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];i?.object!==e&&(i&&this.remove(i),i=new ys(e),this.add(i),this.children.splice(t,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.hiddenMatrix=e.hiddenMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let t=this.object.cloner;return(t===void 0||this.parent!==t||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return L4(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(t){}}});function B4(){return n3}var n3,r3,s3=z(()=>{n3=null,r3=null});function qA(t){return"variable_"+t}var XS,$S,YS,U4,ZS,z4,F4,ab,a3=z(()=>{Yt(),ON(),UN(),WC(),ya(),qC(),$C(),D$(),bh(),BN(),I$(),i3(),rl(),Wr(),Ep(),Ye(),et(),s3(),ke(),XS=new At,$S=new C,YS=new qt,U4=new C,ZS=new xi,z4=class extends RN{constructor(t){super(),this.shared=t}create(t){return new HC(t,this.shared)}},(ab=F4=class{constructor(t,e={},i=!0,n=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=n,this.geometryCache=new VA(!0),this.geometryCache2=new VA(!1),this.imageHolderCache=new z4(this),this.thisContext={scene:Tk,shared:this},this.deletedImage=new qo(oA.emptyImage,this),this.deletedVideo=new qo(B_.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,e.images)for(let[r,s]of Object.entries(e.images))this.addImage(r,s);if(e.videos)for(let[r,s]of Object.entries(e.videos))this.addVideo(r,s);if(e.audios)for(let[r,s]of Object.entries(e.audios))this.addAudio(r,s);if(e.particles)for(let[r,s]of Object.entries(e.particles))this.addParticle(r,s);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=D4(ki.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,i=!1){this.data=t,this.resetLib(t.lib);for(let{id:n,data:r}of t.variables)this.addVariableHolder(n,r),e&&this.updateVariableHolder(n,r);for(let[n,r]of Object.entries(t.userAPIs??{}))this.addUserAPI(n,r);for(let[n,r]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(n,r);if(!i){for(let[n,r]of Object.entries(t.images))this.addImage(n,r);for(let[n,r]of Object.entries(t.videos))this.addVideo(n,r)}for(let[n,r]of Object.entries(t.colors))this.addColor(n,r);for(let[n,r]of Object.entries(t.lib.materials))this.addMaterial(n,r.asset);for(let[n,r]of Object.entries(t.materials))this.addMaterial(n,r);for(let[n,r]of Object.entries(t.audios))this.addAudio(n,r);for(let[n,r]of Object.entries(t.particles))this.addParticle(n,r);for(let[n,r]of Object.entries(t.fonts))this.addFont(n,r)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:ki.defaultTwoLayerData("phong").layers}),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=D4(e,this.thisContext,t);this.materials[t]=i}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){return this.materials[t]}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:ki.defaultTwoLayerData("phong").layers}),Ek(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new qo(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new qo(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new qo(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):(this.colors[t]=new zg(e.r,e.g,e.b,"a"in e?e.a:1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[t];return this.colors[t].r=e.r??i.r,this.colors[t].g=e.g??i.g,this.colors[t].b=e.b??i.b,this.colors[t].a=e.a??i.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t!="string")return new gn(t.r,t.g,t.b,"a"in t?t.a:1);{let i=this.getColor(t);i?e=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new gn(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Uu)return e;{let i=new Uu({src:e.data});return this.audios[t]=i,i}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Uu&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=XC;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):Gn("text","a font asset")}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._requestRender=void 0,Object.values(this.audios).forEach(t=>{t instanceof Uu&&t.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let i=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let n=localStorage.getItem(qA(t));i=n!==null?JSON.parse(n):e.value}return this.variables[t]={value:i,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(qA(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let n=this.entityOpContext.scene,r=!1;for(let s=this.variables[t].locations.length-1;s>=0;s--){let a=this.variables[t].locations[s];if(a[0]==="material"){let o=a[1],l=i,c={scene:n,shared:this},h=a.slice(2);n.traverseMaterial(d=>{let p=d.root??d;p.uuid===o&&p.onVariableUpdate(h,l,c)});let u=this.materials[o];u&&u.onVariableUpdate(h,l,c)}else{let o=n.find(a[0]);if(o===void 0){this.variables[t].locations.splice(s,1);continue}if(r=!0,a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)o=o[a[l]];a[1]==="rotation"?o[a[a.length-1]]=i*Ot.DEG2RAD:o[a[a.length-1]]=i}if(o=n.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),Be.is(o))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")o.onVariableUpdate();else if(a[1]==="geometry"){let l=o;o.component&&(l=o.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(h=>{let u=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(u.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return r&&n.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let n=i.dataPatched,r=n?.geometry;if(!r||typeof r.type!="string"||r.type==="VectorGeometry"||r.type==="PathGeometry")return!1;let s=c=>c.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let c of Object.keys(r))a.set(s(c),c);let o={};for(let[c,h]of Object.entries(e??{})){let u=a.get(s(c));if(u===void 0||u==="type"||u==="font"||u==="shape"||u==="path"||u==="data")continue;if(u==="text"){(typeof h=="string"||typeof h=="number")&&(o[u]={textValue:String(h)});continue}let d=r[u];typeof h=="number"&&isFinite(h)&&(typeof d=="number"||typeof d=="string")&&(o[u]=h)}if(Object.keys(o).length===0)return!1;let l={...r,...o};return i.dataPatched={...n,geometry:l},this.transientGeometryKeys.has(r)&&i.chooseGeoemtryCache(this).forceDelete(n.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let n=i.dataPatched,r=n?.geometry;if(!r||r.type!=="NonParametricGeometry")return!1;let s=e?.vertices;if(s===void 0||typeof s.length!="number"||s.length<9||s.length%3!=0||s.length/3>F4.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,c=s instanceof Float32Array?s:Float32Array.from(s),h=c.length/3;if(e.normals!==void 0){if(e.normals.length!==c.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*h)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=h>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(x.length===0||x.length%3!=0)return!1;for(let w=0;w<x.length;w++)if(x[w]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=r.data,w=x?.index;if(w?.array?.length){if(h<(x?.attributes?.position?.array?.length??0)/3){let S=w.array;for(let A=0;A<S.length;A++)if(S[A]>=h)return!1}l=w}}let u=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0;for(let x=0;x<c.length;x+=3){let w=c[x],S=c[x+1],A=c[x+2];w<u&&(u=w),w>f&&(f=w),S<d&&(d=S),S>g&&(g=S),A<p&&(p=A),A>m&&(m=A)}let y=(x,w)=>({array:x,itemSize:w,type:"Float32Array",normalized:!1}),v={position:y(c,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let _={...r,width:f-u,height:g-d,depth:m-p,data:{attributes:v,...l?{index:l}:{}}},b=this.transientGeometryKeys.has(r);return i.dataPatched={...n,geometry:_},this.transientGeometryKeys.add(_),i.applyTransientGeometryData(this.entityOpContext,b),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let n=i.cloner;if(n===void 0)return-1;let r=n.children,s=Math.PI/180,a=!1;if(e===null)for(let o of r)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return r.length;{let o=Math.min(e.length,r.length);for(let l=0;l<o;l++){let c=e[l],h=r[l];if(c==null){h.transformOverride!==void 0&&(h.transformOverride=void 0,a=!0);continue}let u=h.transformOverride??{position:[h.position.x,h.position.y,h.position.z],rotation:[h.rotation.x,h.rotation.y,h.rotation.z],scale:[h.scale.x,h.scale.y,h.scale.z]};c.position&&(typeof c.position.x=="number"&&(u.position[0]=c.position.x),typeof c.position.y=="number"&&(u.position[1]=c.position.y),typeof c.position.z=="number"&&(u.position[2]=c.position.z)),c.rotation&&(typeof c.rotation.x=="number"&&(u.rotation[0]=c.rotation.x*s),typeof c.rotation.y=="number"&&(u.rotation[1]=c.rotation.y*s),typeof c.rotation.z=="number"&&(u.rotation[2]=c.rotation.z*s)),c.scale&&(typeof c.scale.x=="number"&&(u.scale[0]=c.scale.x),typeof c.scale.y=="number"&&(u.scale[1]=c.scale.y),typeof c.scale.z=="number"&&(u.scale[2]=c.scale.z)),h.transformOverride=u,h.position.fromArray(u.position),h.rotation.fromArray(u.rotation),h.scale.fromArray(u.scale),h.updateMatrix(),h.hasNonUniformScale&&(h.updateMatrixWorld(),h.updateMatrixWorldRigid())}}}return a?n.update(this.entityOpContext):n.syncInstanceMatrices(),n.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let n=new ys(t);n.playModeVisible=e.visible!==!1,n.expand(),typeof e.name=="string"&&(n.name=e.name);let r=Math.PI/180;return n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(n.position.x=e.position.x),typeof e.position.y=="number"&&(n.position.y=e.position.y),typeof e.position.z=="number"&&(n.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(n.rotation.x=e.rotation.x*r),typeof e.rotation.y=="number"&&(n.rotation.y=e.rotation.y*r),typeof e.rotation.z=="number"&&(n.rotation.z=e.rotation.z*r)),e.scale&&(typeof e.scale.x=="number"&&(n.scale.x=e.scale.x),typeof e.scale.y=="number"&&(n.scale.y=e.scale.y),typeof e.scale.z=="number"&&(n.scale.z=e.scale.z)),n.updateMatrix(),i.add(n),n.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),n}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let n=[];for(let c of Array.isArray(i)?i:[i]){let h=c.root??c;h&&Array.isArray(h.layers)&&h.data&&!n.includes(h)&&n.push(h)}if(n.length===0)return!1;let r={scene:this.entityOpContext.scene,shared:this},s=c=>c.toLowerCase().replace(/[\s_.-]+/g,""),a=c=>{if(typeof c=="string"){let h=new gn(1,1,1,1);try{h.set(c)}catch{return null}return{r:h.r,g:h.g,b:h.b,a:void 0}}if(c&&typeof c=="object"&&"r"in c){let h=c;if([h.r,h.g,h.b].some(d=>typeof d!="number"||!isFinite(d)))return null;let u=Math.max(h.r,h.g,h.b)>1?1/255:1;return{r:h.r*u,g:h.g*u,b:h.b*u,a:typeof h.a=="number"?Math.max(0,Math.min(h.a,1)):void 0}}return null},o=(c,h,u)=>{if(!c.hasValue(h))return!1;let d=c.getValue(h);if(!d||typeof d!="object"||!d.isColor)return!1;let p=u.a??(typeof d.a=="number"?d.a:1);return d instanceof zg?c.setValue(h,new gn(u.r,u.g,u.b,p)):typeof d.setRGBA=="function"?d.setRGBA(u.r,u.g,u.b,p):d.setRGB(u.r,u.g,u.b),!0},l=!1;for(let c of n){let h=c.data.layers??[],u=d=>c.layers.find(p=>p.uuid===d);if(e.color!==void 0){let d=a(e.color),p=h.find(g=>g.data.type==="color"),f=p&&u(p.id);if(d&&f&&o(f,"color",d)&&(l=!0,d.a!==void 0)){let g=d.a<1||Pc(c.data,this);c.setTransparent?c.setTransparent(g,r.scene):c.transparent=g}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(c.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),r),l=!0);for(let d of e.layers??[]){if(!d||typeof d!="object")continue;let p=typeof d.id=="string"?h.find(y=>y.id===d.id):typeof d.index=="number"?h[d.index]:typeof d.type=="string"?h.find(y=>y.data.type===d.type):void 0,f=p&&u(p.id);if(!p||!f)continue;let g=ox[p.data.type]??[],m=Object.keys(p.data);for(let[y,v]of Object.entries(d)){if(y==="id"||y==="index"||y==="type")continue;let _=m.find(x=>x===y)??m.find(x=>s(x)===s(y))??y;if(g.includes(_))continue;let b=a(v);if(b&&o(f,_,b))l=!0;else if(typeof v=="number"&&isFinite(v))c.onVariableUpdate?.(["layer",p.id,_],v,r),l=!0;else if(Array.isArray(v)&&v.length<=3&&v.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];v.forEach((w,S)=>{c.onVariableUpdate?.(["layer",p.id,_,x[S]],w,r)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let i=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return i.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&i?.getPhysicsLocalMatrix?.(XS))return XS.decompose($S,YS,U4),t[1]==="position"?$S[t[2]]:(ZS.setFromQuaternion(YS,i.rotation.order),ZS[t[2]]*Ot.RAD2DEG);for(let n=1;n<t.length;n++)i=i[t[n]];return t[1]==="rotation"&&(i*=Ot.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let n=this.variables[i],r=n.locations?.findIndex(s=>jn.equal(s,e));r!==void 0&&r!==-1&&n.locations.splice(r,1)}if(typeof t=="string"){let i=t,n=t;do{if(n=i,this.variables[i]===void 0)break;let r=this.variables[i].value;e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),i=r}while(typeof i=="string");return i}return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,i]of Object.entries(t.images))this.addImage(e,i.asset);for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i.asset);for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i.asset);for(let[e,i]of Object.entries(t.colors))this.addColor(e,i.asset);for(let[e,i]of Object.entries(t.fonts))this.addFont(e,i.asset);for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i.asset);for(let[e,i]of Object.entries(t.variables))this.addVariableHolder(e,i.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,i){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(er.drop(t,2),e.materials[t.path[1]],{shared:this,scene:i});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,i):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let n=e.userAPIs[t.path[1]];if(n){let r=t.type===0&&t.props.debounce===void 0,s=this.getUserAPI(t.path[1]);s!==void 0&&s===this.openAIRealtime?s.update(n):s?.update(n,this,r)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let n=e.userWebhooks[t.path[1]];n&&this.getUserWebhook(t.path[1])?.update(n)}}else t.path[0]==="lib"&&this.updateLibByOp(er.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let n=this.getFont(t),r={...this.data.fonts[t],url:e.props.url};n.update(r),n.loadingPromise.then(()=>this.requestRender()),i.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let i=r3;return i===null?(Gn("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=B4();return i===null?(Gn("api-services","a user API integration"),!1):(this.userAPIs[t]=i.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let i=B4();return i===null?(Gn("api-services","a user webhook"),!1):(this.userWebhooks[t]=i.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new ab(Fs.emptyData())});function Pk(t){return Q_(t)||t?.isTSLNodeMaterial===!0}var Hr,KS,QS,JS,N4,t2,Ai,Dk=z(()=>{GC()}),Jc=z(()=>{Yt(),Kn(),bh(),Dk(),Ye(),Dn(),Hr=class extends Xi{setMaterialOverride(t,e){this.materialOverride=R4(t),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),e.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(t,e,i){if(super.updateByPatchedOp(t,e,i),ri(t.path,["geometry"])&&this.syncShadowCatcher(i),function(n,r){let s=[];if(r.length!==n.length)return null;{let a=0;for(;a<n.length;){if(r[a]==="*")s.push(n[a]);else if(n[a]!==r[a])return null;a+=1}}return s}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[n,r]of Object.entries(t.props)){let s=this.material[Number(n)],a=i.shared.material(r);a!==s&&Hr.disposeOneMaterial(s),this.material[Number(n)]=a}else if(ri(t.path,["material"])){let n=this.material;!Array.isArray(n)&&typeof n?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&n.updateByOp(er.drop(t,1),e.material,i)}else if(ri(t.path,["materials","*"])&&Array.isArray(this.material)){let n=t.path[1];if("materials"in e&&n<this.material.length){let r=e.materials[n];typeof r!="string"&&this.material[n].updateByOp(er.drop(t,2),r,i)}}}get needsAO(){return this.material!==void 0&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(t,e){super.updateState(t,e),t.castShadow!==void 0&&(this.castShadow=t.castShadow),t.receiveShadow!==void 0&&(this.receiveShadow=t.receiveShadow);let i,n=this.dataPatched;this.syncShapeBlendNodeLayer(),this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let r=this.materialOverride!==void 0;!r&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(n.flatShading,n.side,n.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!r&&(t.geometry?.type==="NonParametricGeometry"||"materials"in t)&&("materials"in t&&t.materials!==void 0?(this.disposeMaterial(),this.material=t.materials.map(a=>e.shared.material(a).getFlavor(n.flatShading,n.side,n.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(n.flatShading,n.side,n.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!r&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(s.materials[0]).getFlavor(n.flatShading,n.side,n.wireframe)),!r&&(t.flatShading!==void 0||t.wireframe!==void 0||t.side!==void 0))if(Array.isArray(this.material))for(let a=0;a<this.material.length;a++)this.material[a]=this.material[a].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe,i);this.syncShadowCatcher(e)}shadowCatcherActive(){let t=this.dataPatched,e=t.geometry?.type;return t.shadowCatcher===!0&&(e==="RectangleGeometry"||e==="PlaneGeometry")}syncShadowCatcher(t){let e=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=HA===void 0?null:R4(HA());if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=e.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,t.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.material=t.shared.material(e.material).getFlavor(e.flatShading,e.side,e.wireframe),t.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow)}static disposeOneMaterial(t){var e;Pk(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&pF(this.material).forEach(t=>{Hr.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),qr=z(()=>{Yt(),Ye(),a3(),Jc(),et(),sx(),Mp(),bk(),KS=new C,QS=new ve,JS=new ve,N4=new C,t2=new At,Ai=class extends Hr{constructor(t,e,i){super(t,e),this.data=e,this.isSkinnedMesh=!1,this.localGeometry=void 0,e.bindMode&&e.bindMatrix&&(this.bindMode=e.bindMode,this.bindMatrix=new At().fromArray(e.bindMatrix),this.bindMatrixInverse=new At)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof Gt&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof Gt?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof ab){let t=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(t),i=this.dataPatched.geometry;this.geometryCreateDeleyed=e.get(i,t,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(t){this.localGeometry=t}get is2DAndNoDepth(){let t=this.dataPatched.geometry;return N_.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return N_.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),ri(t.path,["geometry"])&&this.updateByPatchedOpGeometry(er.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}get appliedGeometrySize(){let t=this.localGeometry?.userData;if(t!==void 0&&t.sxPrev!==void 0)return[t.sxPrev,t.syPrev,t.szPrev]}updateGeometryInteractions(t,e){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let n,r,s,a=t;if(this.localGeometry===void 0){let u={...this.data.geometry,...a};this.localGeometry=Jl(u,e,this.data.flatShading,this)}a.scaleBaked?[n,r,s]=a.scaleBaked:{width:n,height:r,depth:s}=a;let o=this.localGeometry.userData,l=typeof n=="number"?n:1,c=typeof r=="number"?r:1,h=typeof s=="number"?s:1;o.sxPrev!==void 0&&FA(this.localGeometry.attributes,l/o.sxPrev,c/o.syPrev,h/o.szPrev),o.sxPrev=l,o.syPrev=c,o.szPrev=h}else{let n=Jl({...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&jS(this.localGeometry,n)?n.dispose():(this.localGeometry?.dispose(),this.localGeometry=n)}}refreshAttachedClonersInteractions(t){for(let e of this.attachedSurfaceCloners)e.update(t)}refreshAttachedCloners(t){for(let e of this.attachedSurfaceCloners)t.scene.addPendingUpdateCloner(e.object)}refreshAttachedPaths(t){for(let e of this.attachedPaths)t.scene.addPendingCommand(()=>e.updateShape())}createGeometryDelayed(t){this.geometryCreateDeleyed=t.shared,this.refreshAttachedCloners(t),this.refreshAttachedPaths(t)}updateByPatchedOpGeometry(t,e,i){let n=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Fi&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!n&&t.type===0&&t.path.length===0&&xk(t.props)&&this.geometryCreateDeleyed instanceof Fi&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!n&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof Gt&&!(this.geometryCreateDeleyed instanceof Fi)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let r=i.shared,s=this.chooseGeoemtryCache(r),a=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=Jl(o,r,this.data.flatShading,this);jS(a,l)?(l.dispose(),a.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,n=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}n||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(t,e){this.createGeometryDelayed(e)}applyTransientGeometryData(t,e){let i=t.shared,n=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof Gt&&!(this.geometryCreateDeleyed instanceof Fi)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let r=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(r.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let a=Jl(n,i,this.data.flatShading,this);return jS(s,a)?(a.dispose(),s.computeBoundingSphere(),r.mutateIfUnique(this._geometryCacheKey,n)):(a.computeBoundingSphere(),r.forceDelete(this._geometryCacheKey),r.adopt(n,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=n,this.refreshAttachedCloners(t),void this.refreshAttachedPaths(t)}}e&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),t.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(t)}updateState(t,e){t.geometry!==void 0&&this.updateGeometryOnStateUpdate(t.geometry,e);let i=t.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:n,value:r}}of i)this.updateMorphInfluences(n,e.shared.getVariable(r,[this.uuid,"morphTargetInfluences",n]))}super.updateState(t,e)}updateMorphInfluences(t,e){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[t];i!==void 0&&(this.morphTargetInfluences[i]=e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(t,e){let i=this.geometry.userData.parameters;this.is2DType?t.set(0,0,.5*i.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?t.fromArray(i.centerOffset):t.setScalar(0),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(t,e){this.skeleton=t,this.isSkinnedMesh=!0,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(t){let e=new ve,i=this.geometry.attributes.skinWeight;for(let n=0,r=i.count;n<r;n++){e.fromBufferAttribute(i,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),i.setXYZW(n,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let n=this.geometry;QS.fromBufferAttribute(n.attributes.skinIndex,t),JS.fromBufferAttribute(n.attributes.skinWeight,t),KS.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){let s=JS.getComponent(r);if(s!==0){let a=QS.getComponent(r);t2.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(N4.copy(KS).applyMatrix4(t2),s)}}return e.applyMatrix4(this.bindMatrixInverse)}}});function Qu(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!Q_(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Ai&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,n=new Float32Array(i.length),r=new C;for(let s=0;s<i.length;s+=3)r.set(i[s],i[s+1],i[s+2]).normalize(),n[s]=r.x,n[s+1]=r.y,n[s+2]=r.z;e.geometry.setAttribute("extrudeNormal",new Nt(n,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,n=e.geometry.attributes,r=n.position.array,s=n.normal.array,a=new Float32Array(r.length);for(let o=0;o<r.length;o+=3){let l=`${r[o]}_${r[o+1]}_${r[o+2]}`,c=new C(s[o],s[o+1],s[o+2]);i.has(l)?i.get(l)?.normals.push(c):i.set(l,{normals:[c],result:new C})}i.forEach((o,l)=>{for(let c of o.normals)o.result.add(c);o.result.divideScalar(o.normals.length)});for(let o=0;o<r.length;o+=3){let l=`${r[o]}_${r[o+1]}_${r[o+2]}`,c=i.get(l)?.result;c&&(a[o]=c.x,a[o+1]=c.y,a[o+2]=c.z)}e.geometry.setAttribute("extrudeNormal",new Nt(a,3))}(t)}function e2(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function Ju(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,n=e.randomColor;if(n!==void 0&&3*n.count===i.length)return;let r=new Float32Array(i.length),s=parseInt(t.uuid.replace(/\D/g,"")),a=[e2(Ot.seededRandom(s)),e2(Ot.seededRandom(s+1e4)),e2(Ot.seededRandom(s+2e4))];for(let o=0;o<i.length;o++)r[o]=a[o%3];t.geometry.setAttribute("randomColor",new Ht(r,3))}var lx=z(()=>{et(),GC(),qr()});function k4(t){let e=!1;return t.scene.objects.traverse((i,n)=>{n.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function O$(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function V4(t,e,i,n){let r=16*(e.children.length+1);Um.length<r&&(Um=new Float32Array(r));let s=0,a=l=>{l.toArray(Um,16*s),s++},o=e.parameters.hideBase!==!0;o&&a(n),XA.multiplyMatrices(t.hiddenMatrix,t.matrix);for(let l of e.children)!Mc(l)||l.playModeVisible===!1||($A.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),_1.multiplyMatrices(XA,$A),(!o||!_1.equals(n))&&a(_1));try{return s===0?0:function(l,c){return VC(K_().instanced_union(kC(l),c))}(i,Um.subarray(0,16*s))}finally{EN(i)}}var Ao,j4,XA,$A,_1,Um,lh,ob,hx,pa,to,lb,Zg=z(()=>{Kn(),et(),ex(),lx(),Jc(),Li(),Ao=new At,j4=new At,XA=new At,$A=new At,_1=new At,Um=new Float32Array(0),lh=class extends Hr{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new Gt,this.onAfterRender=(n,r,s,a,o,l)=>{super.onAfterRender(n,r,s,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&t.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(t,e=!0){if(this.booleanMeshSetAddress!==-1&&!t)return;for(let n=0;n<this.children.length;n++){let r=this.children[n];r instanceof lh&&r.dataPatched.visible===!0&&r.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let r=this.children[n];if(r instanceof Xi&&r.dataPatched.visible===!0&&r.geometry.attributes.position?.count>0&&r.geometry.drawRange.count>0&&r.booleanMeshSetAddress!==0){Ao.multiplyMatrices(r.hiddenMatrix,r.matrix).multiply(r.pivotMatrix);try{let s=O$(r,this);if(r.booleanMeshSetAddress===-1){if((r.geometry.index??r.geometry.getAttribute("position")).count/3<15e5){let a=JX(r.geometry,t===!0);r.booleanMeshSetAddress=s===void 0||a===-1?a:V4(r,s,a,Ao)}if(r.booleanMeshSetAddress===-1)return;s===void 0&&IS(r.booleanMeshSetAddress,Ao),r.booleanMatrixInvOld.copy(Ao).invert(),r.booleanWasTransformed=!1}else r instanceof lh&&r.needsTransformForDownstream===!0?(s===void 0?IS(r.booleanMeshSetAddress,Ao):r.booleanMeshSetAddress=V4(r,s,r.booleanMeshSetAddress,Ao),r.needsTransformForDownstream=!1):r.booleanWasTransformed===!0&&(IS(r.booleanMeshSetAddress,j4.multiplyMatrices(Ao,r.booleanMatrixInvOld)),r.booleanMatrixInvOld.copy(Ao).invert(),r.booleanWasTransformed=!1)}catch(s){console.error(s),r.booleanMeshSetAddress=0,r.geometry.userData.booleanOperationDidFail=!0;continue}if(r.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(r.booleanMeshSetAddress),r.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let n=this.geometry;n.dispose(),this.geometry=new Gt,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere,this.geometry.setAttribute("position",new Nt([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(n,r){let s=K_(),a=FO(n,r),o=s.mesh_topological_data(a),l=o.positions(),c=o.indices();return o.free(),a.free(),{positions:l,indices:c,verticesPerFace:new Uint8Array(c.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new Gt,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(n,r,s,a){let o=K_(),l=FO(n,r),c=o.mesh_render_data(l,Math.max(a,0));if(s.setAttribute("position",new Nt(c.positions(),3)),s.setAttribute("normal",new Nt(c.normals(),3)),c.free(),s.boundingSphere===null&&(s.boundingSphere=new vr),l.tri_count()===0)s.boundingSphere.center.set(0,0,0),s.boundingSphere.radius=0,s.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();s.boundingSphere.center.set(h[0],h[1],h[2]),s.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,s.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return VC(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Qu(this),Ju(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),Kg=z(()=>{et(),Wr(),Qc(),(ob||(ob={})).is=function(t){return Be.is(t)&&t instanceof _u},hx=(t,e)=>class extends Kc(t,e){updateState_Light(i,n){if(this.updateState_Entity(i,n),i.color!==void 0&&(this.color=n.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let r=this.shadow;r.camera.far=i.depth,r.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),xh=z(()=>{Zg(),Kn(),Qc(),pa=t=>t instanceof Xi,to=t=>t!==null&&t instanceof lh,lb=t=>bA.is(t)});function mr(t,e){return e.color(t)}function G4(t=new Date,e){let i=e.format,n=t.getSeconds(),r=t;e&&e.timeZone!==null&&(r=function(u,d){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:d,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(u),f=g=>Number(p.find(m=>m.type===g)?.value);return new Date(f("year"),f("month")-1,f("day"),f("hour"),f("minute"),f("second"),u.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let s,a=r.getHours(),o=r.getMinutes();e.format12h24h==="12ampm"&&(s=a>=12?"PM":"AM");let l,c,h=a;switch(e.format12h24h!=="24"&&(h=a%12,h===0&&(h=12)),i){case"HH:mm:ss":l=[h,o,n];break;case"HH:mm":l=[h,o];break;case"HH":l=[h],s=void 0;break;case"mm":l=[o],s=void 0;break;case"ss":l=[n],s=void 0;break;case"year":c=r.getFullYear();break;case"month":c=r.getMonth()+1;break;case"dayOfYear":c=Math.floor((r.getTime()-new Date(r.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=r.getDate();break;case"secondOfDay":c=60*a*60+60*o+n;break;default:console.error("Unknown time format",i),c=0}return l!==void 0?{textValue:l,suffix:s}:c}var YA,Qg,o3=z(()=>{}),L$=z(()=>{et(),Xg(),$g(),YA=class extends bp(Lz){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){xp(this.object,YA.geometryHelper,t,e)}}}),l3=z(()=>{et(),L$(),Kg(),Qg=class extends hx(Pz,YA){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let r=new Mg(this.shadow.camera);r.visible=!1,this.gizmos.shadowmap=r}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Mg&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&function(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),i&&this.update()}}});function h3(t){return t instanceof Hr&&t.needsAO&&!nl(t)&&t.isDecalObject!==!0}function c3(t){let e=t.cloner;if(e&&Array.isArray(e.children))for(let i of e.children)i?.layers&&(i.layers.mask=t.layers.mask)}function d3(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function H4(t,e){let i={outline:!1,cavity:!1},n=t.layers.mask&cx,r=e.getLayersOfType("transmission"),s=e.getLayersOfType("outline"),a=d3(e),o=e.getLayersOfType("cavity");return(s.length>0||o.length>0)&&(t.layers.set(8),r.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=s.length>0,i.cavity=o.length>0,Ju(t),Qu(t)),r.length===0&&s.length===0&&o.length===0&&a===0&&t.layers.set(0),n&&t.layers.set(9),!n&&h3(t)&&t.layers.enable(5),c3(t),i}function W4(t,e){if(!e.layers)return!1;let i=t.layers.mask&cx,n=!1,r=e.getLayersOfType("transmission").filter(l=>l.data.visible),s=e.getLayersOfType("outline").filter(l=>l.data.visible),a=d3(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return r.length>0&&(t.layers.set(3),(s.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),n=!0),r.length===0&&s.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&h3(t)&&t.layers.enable(5),c3(t),n}function q4(t,e){var i;if(!e.layers)return!1;let n=t.layers.mask&cx,r=!1,s=d3(e),a=e.getLayersOfType("transmission").filter(c=>c.data.visible),o=e.getLayersOfType("outline").filter(c=>c.data.visible),l=e.getLayersOfType("cavity").filter(c=>c.data.visible);return s>0&&((i=t.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),t.layers.set(4),a.length>0&&t.layers.enable(3),(o.length>0||l.length>0)&&t.layers.enable(8),r=!0),s===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),n&&t.layers.set(9),!n&&h3(t)&&t.layers.enable(5),c3(t),r}function ZA(t,e,i,n=!1){let r=t.cloner;if(r){let s=null;if(t.raycast===wi.prototype.raycast||t.raycast===Xi.prototype.raycast){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),s=a.boundingSphere)}for(let a of r.children){if(s!==null&&(KA.copy(s).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(KA)))continue;let o=Ik.copy(a.matrixWorld).invert(),l=Ok.copy(e.ray).applyMatrix4(o),c=t.matrixWorld;l.applyMatrix4(c);let h=Rk;h.set(l.origin,l.direction),h.near=e.near,h.far=e.far,h.layers.mask=e.layers.mask;let u=h.intersectObject(t,!1);u.length>0&&i.push({...u[0],object:n?a:t})}}}var cx,Rk,Ik,Ok,KA,Rv,Lk,i2,n2,r2,Jg,un,Bk=z(()=>{Li(),lx(),Kn(),Jc(),et(),cx=512,Rk=new lC,Ik=new At,Ok=new $o,KA=new vr}),B$=z(()=>{et(),Xg(),$g(),Rv=class extends bp(Iz){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){xp(this.object,Rv.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=Rv._vector,e=this.object.distance?this.object.distance:1e3,i=e*Math.tan(this.object.angle);this.cone.scale.set(i,i,e),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let r=0,s=this.cone.material.length;r<s;r++)this.cone.material[r].color.set(n);else this.cone.material.color.set(n)}}},(Lk=Rv)._vector=new C}),u3=z(()=>{et(),B$(),Kg(),i2=new C,n2=new C,r2=new qt,Jg=class extends hx(Tz,Lk){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=2*Ot.RAD2DEG*this.angle,n.aspect=1,n.near=100,n.far=2500;let r=new Mg(this.shadow.camera);r.visible=!1,this.gizmos.shadowmap=r,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Mg&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),n2.setFromMatrixPosition(this.matrixWorld),r2.setFromRotationMatrix(this.matrixWorld),i2.copy(this.up).applyQuaternion(r2).negate().multiplyScalar(this.distance),this.target.position.copy(n2).add(i2),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),ol=z(()=>{Yt(),Hs(),et(),Wr(),ya(),o3(),al(),l3(),Ye(),bh(),et(),Jc(),xh(),Bk(),u3(),ke(),Zg(),un=class extends Jb(rs){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new gn(1,1,1,1),this.fog=null,this.backupFog=new nE(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ir.getDensity({}),this.fogHeightFalloff=ir.getHeightFalloff({}),this.fogHeightBase=ir.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new Jt,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new vn(Zc,{...rg.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Az(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),e.uiScene){let n=fA();n===null?Gn("ui-2d","a page's 2D scene"):this.uiScene=new n.Scene2D((Array.isArray(t)?t[0]:t)+"-ui",e.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else e.uiFrame&&this.createUICanvas(e.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(t,e){let i=fA();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,e),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(t),this.uiCanvas?.applySize()})):Gn("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(t,e){t.color!==void 0&&(this.ambientLight.color=mr(t.color,e)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity*Math.PI),t.enabled!==void 0&&(t.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(t){this.isActive=!0,t.fog=this.fog,this.traverseEntity(e=>{e instanceof lh&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof Hr)if(Array.isArray(t.material))for(let e of t.material)e.needsUpdate=!0;else t.material.needsUpdate=!0,t.material.dispose()})}updateShadow(t){if(t.softShadowQuality===void 0&&t.type===void 0||!this.isActive)return;let e=this.data.shadow;var i,n;i=ng.isSoft(e),n=e?.softShadowQuality,WA!==void 0&&WA(i,n)&&this.forceMaterialsUpdate()}updateFog(t,e){t.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=mr(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ir.getMode(t),this.fogDensity=ir.getDensity(t),this.fogHeightFalloff=ir.getHeightFalloff(t),this.fogHeightBase=ir.getHeightBase(t)}updateSky(t,e){this.skyState=t??null,this.skyStateVersion++;let i=t?.hdri?.image;this.skyHdriHolder=i!=null?e.image(i):null}updateAo(t,e){t.aoColor!==void 0&&(this.aoColor=mr(t.aoColor,e))}updateByOp(t,e,i,n){let r=this.data.uiFrame;super.updateByOp(t,e,i,n);let s=e;ri(t.path,["fog"])?this.updateFog(s.fog,i.shared):ri(t.path,["sky"])?this.updateSky(s.sky,i.shared):ri(t.path,["grading"])?this.gradingState=s.grading??null:ri(t.path,["ao"])?this.updateAo(s.ao,i.shared):ri(t.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):ri(t.path,["shadow"])?this.updateShadow(s.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||r!==s.uiFrame)&&this.updateUIFrame(t.props.uiFrame,i)}updateUIFrame(t,e){t?(this.uiCanvas||this.createUICanvas(t,e),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(t)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(t,e){this.updateState_Entity(t,e),t.backgroundColor!==void 0&&this.setBackgroundColor(mr(t.backgroundColor,e.shared)),t.fog!==void 0&&this.updateFog(t.fog,e.shared),t.sky!==void 0&&this.updateSky(t.sky,e.shared),t.grading!==void 0&&(this.gradingState=t.grading),t.ambient!==void 0&&this.updateAmbientLight(t.ambient,e.shared),t.ao!==void 0&&this.updateAo(t.ao,e.shared),t.shadow!==void 0&&this.updateShadow(t.shadow)}createFrame(t,e){}raycast(t,e){super.raycast(t,e)}switchActiveCamera(t){t&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(il).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof Qg&&i.visible&&t<ag&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof Jg&&i.visible&&t<il-ag&&(this.penumbraSizeArrayCache[ag+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=n=>{for(let r of n.children){let s=r.cloner;Be.is(r)&&(r.visible||s?.object.data.visible)&&((pa(r)||lb(r)&&this.scene.enableHelpers&&r.objectHelper.visible)&&(t.intersectObject(r,!1,e),ZA(r,t,e,!0)),i(r))}};return i(this),e}updateEntity2DByOp(t,e,i,n){this.uiCanvas?.updateEntity2DByOp(t,e,i,n)}}});function X4(){return Uk}function s2(){if(hb===null)throw new Error('[spe] Classic (WebGL) particles are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return hb}function a2(t){return t?.isWebGPUSplineRenderer===!0}var Uk,hb,tp,zk=z(()=>{Uk=null,hb=null}),p3=z(()=>{et(),Yb(),Qc(),tp=class extends Kc(yp,pp){constructor(t,e,i){super(),this.super_Entity(t,e),this.context=i,this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e)}}}),U$=gp((t,e)=>{var i,n;i=t,n=function(){return r.importState=function(s){var a=new r;return a.importState(s),a},r;function r(){return function(s){var a=0,o=0,l=0,c=1;s.length==0&&(s=[+new Date]);var h=function(){var p=4022871197,f=function(g){g=g.toString();for(var m=0;m<g.length;m++){var y=.02519603282416938*(p+=g.charCodeAt(m));y-=p=y>>>0,p=(y*=p)>>>0,p+=4294967296*(y-=p)}return 23283064365386963e-26*(p>>>0)};return f.version="Mash 0.9",f}();a=h(" "),o=h(" "),l=h(" ");for(var u=0;u<s.length;u++)(a-=h(s[u]))<0&&(a+=1),(o-=h(s[u]))<0&&(o+=1),(l-=h(s[u]))<0&&(l+=1);h=null;var d=function(){var p=2091639*a+23283064365386963e-26*c;return a=o,o=l,l=p-(c=0|p)};return d.next=d,d.uint32=function(){return 4294967296*d()},d.fract53=function(){return d()+11102230246251565e-32*(2097152*d()|0)},d.version="Alea 0.9",d.args=s,d.exportState=function(){return[a,o,l,c]},d.importState=function(p){a=+p[0]||0,o=+p[1]||0,l=+p[2]||0,c=+p[3]||0},d}(Array.prototype.slice.call(arguments))}},typeof t=="object"?e.exports=n():typeof define=="function"&&define.amd?define(n):i.Alea=n()});function z$(t){let e=!1;return t.scene.objects.traverse((i,n)=>{n.type==="Mesh"&&n.geometry.type==="SubdivGeometry"&&(e=!0)}),e}var Js,zd,mp,t0=z(()=>{Kn(),et(),Mp(),lx(),qr(),Js=new ci,zd=new C,mp=class extends Ai{constructor(t,e,i){super(t,e,i),this.data=e,this.hiddenMatrixOld=new At,this.smoothShading=!0,this.skipReactionUpdate=!1}chooseGeoemtryCache(t){return this.dataPatched.flatShading?t.geometryCache:t.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(t,e){let i=this.geometry.userData.parameters;t.copy(this.originalGeometryNew.boundingSphere.center),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(t){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:n,subdivPointer:r}=Fi.build(t,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=r,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qu(this),Ju(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}updateState(t,e){if(super.updateState(t,e),t.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(n=>n.getFlavor(!1,n.side,n.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!t.flatShading,this.createGeometryDelayed(e)}}updateMesh(t=!1,e=!1,i=!1){e&&this.subdividedGeometry||Fi.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&Fi.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let t=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=Fi.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Fi.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qu(this),Ju(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}raycast(t,e){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,Xi.prototype.raycast.call(this,t,e),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new vr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;Js.setFromBufferAttribute(e),Js.getCenter(i),t.boundingSphere.radius=i.distanceTo(Js.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Js.getSize(zd),this.hasNonUniformScale&&zd.divide(this.scale);let n={width:zd.x,height:zd.y,depth:zd.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(t){let e=this.originalGeometry;Js.min.set(t[0],t[2],t[4]),Js.max.set(t[1],t[3],t[5]),this.hasNonUniformScale&&(Js.min.applyMatrix4(this.shearScaleInv),Js.max.applyMatrix4(this.shearScaleInv)),e.boundingSphere===null&&(e.boundingSphere=new vr);let i=e.boundingSphere.center;Js.getCenter(i),e.boundingSphere.radius=i.distanceTo(Js.max)}freeSubdivPointer(){this.subdivPointer&&(Fi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(t){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry,i=e?.uuid,n=e?.userData.parameters,r=t.subdivisions>0?Fi.buildRefined(this.subdivPointer,t.subdivisions,this.smoothShading?t.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=r??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qu(this),Ju(this),n!==void 0&&(this.localGeometry.userData.parameters=n),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),this.localGeometry&&(t.type===0&&t.path.length===0&&xk(t.props)&&this.subdivPointer?this.updateSubdivisionLevel(e):this.createGeometryByControls(e))}}});function f3(t){if(t.component){let e=t.component.instances.indexOf(t);e>=0&&t.component.instances.splice(e,1);for(let i of t.children)Be.is(i)&&f3(i)}}var cg,QA,dx,Fk=z(()=>{Wr()}),F$=gp((t,e)=>{function i(n,r,s,a){this.message=n,this.expected=r,this.found=s,this.location=a,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i)}(function(n,r){function s(){this.constructor=n}s.prototype=r.prototype,n.prototype=new s})(i,Error),i.buildMessage=function(n,r){var s,a={literal:function(u){return'"'+l(u.text)+'"'},class:function(u){var d,p="";for(d=0;d<u.parts.length;d++)p+=u.parts[d]instanceof Array?c(u.parts[d][0])+"-"+c(u.parts[d][1]):c(u.parts[d]);return"["+(u.inverted?"^":"")+p+"]"},any:function(u){return"any character"},end:function(u){return"end of input"},other:function(u){return u.description}};function o(u){return u.charCodeAt(0).toString(16).toUpperCase()}function l(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+o(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+o(d)})}function c(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+o(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+o(d)})}function h(u){return a[u.type](u)}return"Expected "+function(u){var d,p,f=new Array(u.length);for(d=0;d<u.length;d++)f[d]=h(u[d]);if(f.sort(),f.length>0){for(d=1,p=1;d<f.length;d++)f[d-1]!==f[d]&&(f[p]=f[d],p++);f.length=p}switch(f.length){case 1:return f[0];case 2:return f[0]+" or "+f[1];default:return f.slice(0,-1).join(", ")+", or "+f[f.length-1]}}(n)+" but "+((s=r)?'"'+l(s)+'"':"end of input")+" found."},e.exports={SyntaxError:i,parse:function(n,r){r=r!==void 0?r:{};var s,a={},o={svg_path:Pe},l=Pe,c=function(J){if(!J)return[];for(var Et=[],ft=0;ft<J.length;ft++)Et=Et.concat.apply(Et,J[ft]);var St=Et[0];return St&&St.code=="m"&&(delete St.relative,St.code="M"),Et},h=function(J,Et){return function(ft,St){if(!St)return[ft];for(var It=[ft],B=0,st=St.length;B<st;B++)It[B+1]=St[B][1];return It}(J,Et)},u=/^[Mm]/,d=be(["M","m"],!1,!1),p=function(J,Et,ft){var St=uo(J,[Et]);return ft&&(St=St.concat(uo(J=="M"?"L":"l",ft[1]))),St},f=/^[Zz]/,g=be(["Z","z"],!1,!1),m=function(){return uo("Z")},y=/^[Ll]/,v=be(["L","l"],!1,!1),_=function(J,Et){return uo(J,Et)},b=/^[Hh]/,x=be(["H","h"],!1,!1),w=function(J,Et){return uo(J,Et.map(function(ft){return{x:ft}}))},S=/^[Vv]/,A=be(["V","v"],!1,!1),E=function(J,Et){return uo(J,Et.map(function(ft){return{y:ft}}))},P=/^[Cc]/,T=be(["C","c"],!1,!1),R=function(J,Et,ft){return{x1:J.x,y1:J.y,x2:Et.x,y2:Et.y,x:ft.x,y:ft.y}},L=/^[Ss]/,D=be(["S","s"],!1,!1),U=function(J,Et){return{x2:J.x,y2:J.y,x:Et.x,y:Et.y}},V=/^[Qq]/,k=be(["Q","q"],!1,!1),Y=function(J,Et){return{x1:J.x,y1:J.y,x:Et.x,y:Et.y}},$=/^[Tt]/,nt=be(["T","t"],!1,!1),Q=/^[Aa]/,rt=be(["A","a"],!1,!1),gt=function(J,Et,ft,St,It,B){return{rx:J,ry:Et,xAxisRotation:ft,largeArc:St,sweep:It,x:B.x,y:B.y}},at=function(J,Et){return{x:J,y:Et}},ht=function(J){return 1*J},ct=function(J){return 1*J.join("")},q=/^[01]/,lt=be(["0","1"],!1,!1),F=function(J){return J=="1"},O=function(){return""},j=",",Z=_e(",",!1),I=function(J){return J.join("")},G=".",W=_e(".",!1),N=/^[eE]/,tt=be(["e","E"],!1,!1),ot=/^[+\-]/,pt=be(["+","-"],!1,!1),ut=/^[0-9]/,Pt=be([["0","9"]],!1,!1),bt=function(J){return J.join("")},Rt=/^[ \t\n\r]/,_t=be([" "," ",`
4170
4170
  `,"\r"],!1,!1),X=0,vt=[{line:1,column:1}],Dt=0,jt=[],Ft=0;if("startRule"in r){if(!(r.startRule in o))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');l=o[r.startRule]}function _e(J,Et){return{type:"literal",text:J,ignoreCase:Et}}function be(J,Et,ft){return{type:"class",parts:J,inverted:Et,ignoreCase:ft}}function Vi(J){var Et,ft=vt[J];if(ft)return ft;for(Et=J-1;!vt[Et];)Et--;for(ft={line:(ft=vt[Et]).line,column:ft.column};Et<J;)n.charCodeAt(Et)===10?(ft.line++,ft.column=1):ft.column++,Et++;return vt[J]=ft,ft}function oe(J,Et){var ft=Vi(J),St=Vi(Et);return{start:{offset:J,line:ft.line,column:ft.column},end:{offset:Et,line:St.line,column:St.column}}}function le(J){X<Dt||(X>Dt&&(Dt=X,jt=[]),jt.push(J))}function Pe(){var J,Et,ft,St,It;for(J=X,Et=[],ft=Oe();ft!==a;)Et.push(ft),ft=Oe();if(Et!==a)if(ft=function(){var B,st,xt,Mt,dt,wt;if(B=X,(st=si())!==a){for(xt=[],Mt=X,dt=[],wt=Oe();wt!==a;)dt.push(wt),wt=Oe();for(dt!==a&&(wt=si())!==a?Mt=dt=[dt,wt]:(X=Mt,Mt=a);Mt!==a;){for(xt.push(Mt),Mt=X,dt=[],wt=Oe();wt!==a;)dt.push(wt),wt=Oe();dt!==a&&(wt=si())!==a?Mt=dt=[dt,wt]:(X=Mt,Mt=a)}xt!==a?B=st=h(st,xt):(X=B,B=a)}else X=B,B=a;return B}(),ft===a&&(ft=null),ft!==a){for(St=[],It=Oe();It!==a;)St.push(It),It=Oe();St!==a?J=Et=c(ft):(X=J,J=a)}else X=J,J=a;else X=J,J=a;return J}function si(){var J,Et,ft,St,It,B;if(J=X,Et=function(){var st,xt,Mt,dt,wt,Lt,$t;if(st=X,u.test(n.charAt(X))?(xt=n.charAt(X),X++):(xt=a,Ft===0&&le(d)),xt!==a){for(Mt=[],dt=Oe();dt!==a;)Mt.push(dt),dt=Oe();Mt!==a&&(dt=_n())!==a?(wt=X,(Lt=xe())===a&&(Lt=null),Lt!==a&&($t=Pi())!==a?wt=Lt=[Lt,$t]:(X=wt,wt=a),wt===a&&(wt=null),wt!==a?st=xt=p(xt,dt,wt):(X=st,st=a)):(X=st,st=a)}else X=st,st=a;return st}(),Et!==a){for(ft=[],St=X,It=[],B=Oe();B!==a;)It.push(B),B=Oe();for(It!==a&&(B=ze())!==a?St=It=[It,B]:(X=St,St=a);St!==a;){for(ft.push(St),St=X,It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a&&(B=ze())!==a?St=It=[It,B]:(X=St,St=a)}ft!==a?J=Et=h(Et,ft):(X=J,J=a)}else X=J,J=a;return J}function ze(){var J,Et;return f.test(n.charAt(X))?(Et=n.charAt(X),X++):(Et=a,Ft===0&&le(g)),Et!==a&&(Et=m()),(J=Et)===a&&(J=function(){var ft,St,It,B;if(ft=X,y.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(v)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a&&(B=Pi())!==a?ft=St=_(St,B):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,b.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(x)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a&&(B=ui())!==a?ft=St=w(St,B):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,S.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(A)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a&&(B=ui())!==a?ft=St=E(St,B):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,P.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(T)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a?(B=function(){var st,xt,Mt,dt,wt,Lt;if(st=X,(xt=en())!==a){for(Mt=[],dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=en())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);dt!==a;)Mt.push(dt),dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=en())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);Mt!==a?st=xt=h(xt,Mt):(X=st,st=a)}else X=st,st=a;return st}(),B!==a?ft=St=_(St,B):(X=ft,ft=a)):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,L.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(D)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a?(B=function(){var st,xt,Mt,dt,wt,Lt;if(st=X,(xt=Kr())!==a){for(Mt=[],dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=Kr())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);dt!==a;)Mt.push(dt),dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=Kr())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);Mt!==a?st=xt=h(xt,Mt):(X=st,st=a)}else X=st,st=a;return st}(),B!==a?ft=St=_(St,B):(X=ft,ft=a)):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,V.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(k)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a?(B=function(){var st,xt,Mt,dt,wt,Lt;if(st=X,(xt=yn())!==a){for(Mt=[],dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=yn())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);dt!==a;)Mt.push(dt),dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=yn())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);Mt!==a?st=xt=h(xt,Mt):(X=st,st=a)}else X=st,st=a;return st}(),B!==a?ft=St=_(St,B):(X=ft,ft=a)):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,$.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(nt)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a?(B=function(){var st,xt,Mt,dt,wt,Lt;if(st=X,(xt=_n())!==a){for(Mt=[],dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=_n())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);dt!==a;)Mt.push(dt),dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=_n())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);Mt!==a?st=xt=h(xt,Mt):(X=st,st=a)}else X=st,st=a;return st}(),B!==a?ft=St=_(St,B):(X=ft,ft=a)):(X=ft,ft=a)}else X=ft,ft=a;return ft}())===a&&(J=function(){var ft,St,It,B;if(ft=X,Q.test(n.charAt(X))?(St=n.charAt(X),X++):(St=a,Ft===0&&le(rt)),St!==a){for(It=[],B=Oe();B!==a;)It.push(B),B=Oe();It!==a?(B=function(){var st,xt,Mt,dt,wt,Lt;if(st=X,(xt=Qr())!==a){for(Mt=[],dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=Qr())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);dt!==a;)Mt.push(dt),dt=X,(wt=xe())===a&&(wt=null),wt!==a&&(Lt=Qr())!==a?dt=wt=[wt,Lt]:(X=dt,dt=a);Mt!==a?st=xt=h(xt,Mt):(X=st,st=a)}else X=st,st=a;return st}(),B!==a?ft=St=_(St,B):(X=ft,ft=a)):(X=ft,ft=a)}else X=ft,ft=a;return ft}()),J}function Pi(){var J,Et,ft,St,It,B;if(J=X,(Et=_n())!==a){for(ft=[],St=X,(It=xe())===a&&(It=null),It!==a&&(B=_n())!==a?St=It=[It,B]:(X=St,St=a);St!==a;)ft.push(St),St=X,(It=xe())===a&&(It=null),It!==a&&(B=_n())!==a?St=It=[It,B]:(X=St,St=a);ft!==a?J=Et=h(Et,ft):(X=J,J=a)}else X=J,J=a;return J}function ui(){var J,Et,ft,St,It,B;if(J=X,(Et=co())!==a){for(ft=[],St=X,(It=xe())===a&&(It=null),It!==a&&(B=co())!==a?St=It=[It,B]:(X=St,St=a);St!==a;)ft.push(St),St=X,(It=xe())===a&&(It=null),It!==a&&(B=co())!==a?St=It=[It,B]:(X=St,St=a);ft!==a?J=Et=h(Et,ft):(X=J,J=a)}else X=J,J=a;return J}function en(){var J,Et,ft,St,It,B;return J=X,(Et=_n())!==a?((ft=xe())===a&&(ft=null),ft!==a&&(St=_n())!==a?((It=xe())===a&&(It=null),It!==a&&(B=_n())!==a?J=Et=R(Et,St,B):(X=J,J=a)):(X=J,J=a)):(X=J,J=a),J}function Kr(){var J,Et,ft,St;return J=X,(Et=_n())!==a?((ft=xe())===a&&(ft=null),ft!==a&&(St=_n())!==a?J=Et=U(Et,St):(X=J,J=a)):(X=J,J=a),J}function yn(){var J,Et,ft,St;return J=X,(Et=_n())!==a?((ft=xe())===a&&(ft=null),ft!==a&&(St=_n())!==a?J=Et=Y(Et,St):(X=J,J=a)):(X=J,J=a),J}function Qr(){var J,Et,ft,St,It,B,st,xt,Mt,dt,wt;return J=X,(Et=yt())!==a?((ft=xe())===a&&(ft=null),ft!==a&&(St=yt())!==a?((It=xe())===a&&(It=null),It!==a&&(B=co())!==a&&xe()!==a&&(st=Bp())!==a?((xt=xe())===a&&(xt=null),xt!==a&&(Mt=Bp())!==a?((dt=xe())===a&&(dt=null),dt!==a&&(wt=_n())!==a?J=Et=gt(Et,St,B,st,Mt,wt):(X=J,J=a)):(X=J,J=a)):(X=J,J=a)):(X=J,J=a)):(X=J,J=a),J}function _n(){var J,Et,ft,St;return J=X,(Et=co())!==a?((ft=xe())===a&&(ft=null),ft!==a&&(St=co())!==a?J=Et=at(Et,St):(X=J,J=a)):(X=J,J=a),J}function yt(){var J;return(J=zp())===a&&(J=ba()),J!==a&&(J=ht(J)),J}function co(){var J,Et,ft;return J=X,(Et=od())===a&&(Et=null),Et!==a&&(ft=zp())!==a?J=Et=[Et,ft]:(X=J,J=a),J===a&&(J=X,(Et=od())===a&&(Et=null),Et!==a&&(ft=ba())!==a?J=Et=[Et,ft]:(X=J,J=a)),J!==a&&(J=ct(J)),J}function Bp(){var J;return q.test(n.charAt(X))?(J=n.charAt(X),X++):(J=a,Ft===0&&le(lt)),J!==a&&(J=F(J)),J}function xe(){var J,Et,ft,St,It;if(J=X,Et=[],(ft=Oe())!==a)for(;ft!==a;)Et.push(ft),ft=Oe();else Et=a;if(Et!==a)if((ft=Up())===a&&(ft=null),ft!==a){for(St=[],It=Oe();It!==a;)St.push(It),It=Oe();St!==a?J=Et=[Et,ft,St]:(X=J,J=a)}else X=J,J=a;else X=J,J=a;if(J===a){if(J=X,Et=X,(ft=Up())!==a){for(St=[],It=Oe();It!==a;)St.push(It),It=Oe();St!==a?Et=ft=[ft,St]:(X=Et,Et=a)}else X=Et,Et=a;Et!==a&&(Et=O()),J=Et}return J}function Up(){var J;return n.charCodeAt(X)===44?(J=j,X++):(J=a,Ft===0&&le(Z)),J}function zp(){var J,Et,ft;return J=X,Et=function(){var St,It,B,st;return St=X,(It=ba())===a&&(It=null),It!==a?(n.charCodeAt(X)===46?(B=G,X++):(B=a,Ft===0&&le(W)),B!==a&&(st=ba())!==a?St=It=[It,B,st]:(X=St,St=a)):(X=St,St=a),St===a&&(St=X,(It=ba())!==a?(n.charCodeAt(X)===46?(B=G,X++):(B=a,Ft===0&&le(W)),B!==a?St=It=[It,B]:(X=St,St=a)):(X=St,St=a)),St!==a&&(St=I(St)),St}(),Et!==a?((ft=Fp())===a&&(ft=null),ft!==a?J=Et=[Et,ft]:(X=J,J=a)):(X=J,J=a),J===a&&(J=X,(Et=ba())!==a&&(ft=Fp())!==a?J=Et=[Et,ft]:(X=J,J=a)),J!==a&&(J=I(J)),J}function Fp(){var J,Et,ft,St;return J=X,N.test(n.charAt(X))?(Et=n.charAt(X),X++):(Et=a,Ft===0&&le(tt)),Et!==a?((ft=od())===a&&(ft=null),ft!==a&&(St=ba())!==a?J=Et=[Et,ft,St]:(X=J,J=a)):(X=J,J=a),J!==a&&(J=I(J)),J}function od(){var J;return ot.test(n.charAt(X))?(J=n.charAt(X),X++):(J=a,Ft===0&&le(pt)),J}function ba(){var J,Et;if(J=[],ut.test(n.charAt(X))?(Et=n.charAt(X),X++):(Et=a,Ft===0&&le(Pt)),Et!==a)for(;Et!==a;)J.push(Et),ut.test(n.charAt(X))?(Et=n.charAt(X),X++):(Et=a,Ft===0&&le(Pt));else J=a;return J!==a&&(J=bt(J)),J}function Oe(){var J;return Rt.test(n.charAt(X))?(J=n.charAt(X),X++):(J=a,Ft===0&&le(_t)),J!==a&&(J=O()),J}var ld,hd,xa,ul={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Np in ul)ul[Np.toUpperCase()]=ul[Np];function uo(J,Et){Et||(Et=[{}]);for(var ft=Et.length;ft--;){var St={code:J,command:ul[J]};for(var It in J==J.toLowerCase()&&(St.relative=!0),Et[ft])St[It]=Et[ft][It];Et[ft]=St}return Et}if((s=l())!==a&&X===n.length)return s;throw s!==a&&X<n.length&&le({type:"end"}),ld=jt,hd=Dt<n.length?n.charAt(Dt):null,xa=Dt<n.length?oe(Dt,Dt+1):oe(Dt,Dt),new i(i.buildMessage(ld,hd),ld,hd,xa)}}}),m3=gp((t,e)=>{var i=F$().parse;i.parseSVG=i,i.makeAbsolute=function(n){var r,s={x:0,y:0},a={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){for(var l in o.command==="moveto"&&(r=o),o.x0=s.x,o.y0=s.y,a)l in o&&(o[l]+=o.relative?o[a[l]]:0);"x"in o||(o.x=s.x),"y"in o||(o.y=s.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=r.x,o.y=r.y),s=o}),n},e.exports=i}),Nk=z(()=>{cg=new Set}),N$=z(()=>{et(),Xg(),$g(),QA=class extends bp(Oz){constructor(t,e=15,i=6710886){super(t,e,i),this.object=t,this.name=`PointLightHelper: ${t.uuid}`}raycast(t,e){xp(this.object,QA.geometryHelper,t,e)}}}),kk=z(()=>{et(),N$(),Kg(),dx=class extends hx(Cz,QA){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let r=new C(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new C(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),a=new ci(r,s),o=new Eg(a,new Jt(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof Eg){let i=this.shadow.camera,n=new C(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),r=new C(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);e.box.set(n,r),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}});function $4(t){let e=JA.get(t);return e===void 0&&(e=Vk++,JA.set(t,e)),e}function k$(t,e,i,n){let r=t,s=e;return[$4(i),$4(n),r.layers?.mask??0,r.renderOrder??0,(r.castShadow??s.castShadow)===!0?1:0,(r.receiveShadow??s.receiveShadow)===!0?1:0].join(":")}var JA,Vk,tT,eT,Iv,jk,V$=z(()=>{Li(),JA=new WeakMap,Vk=1}),j$=z(()=>{et(),eT=(tT=[8,32,128,512])[tT.length-1],Iv=new At().makeScale(0,0,0),jk=class extends zb{constructor(t,e,i,n){super(t,e,i),this.isInstanceGroup=!0,this.members=new Array(i).fill(null),this.raycast=()=>{},this.matrixAutoUpdate=!1,this.frustumCulled=!1,this.adoptPassState(n);for(let r=0;r<i;r++)this.setMatrixAt(r,Iv);this.instanceMatrix.needsUpdate=!0}adoptPassState(t){this.layers.mask=t.layers.mask,this.renderOrder=t.renderOrder,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow}assign(t,e){this.members[t]=e}writeSlot(t,e,i){return i===!1?(this.setMatrixAt(t,Iv),!1):(this.setMatrixAt(t,e.matrixWorld),!0)}park(t){this.members[t]=null,this.setMatrixAt(t,Iv)}get memberCount(){let t=0;for(let e of this.members)e!==null&&t++;return t}}});function Gk(t,e){let i=e.get(t);if(i!==void 0)return i;let n=t.visible&&(t.parent===null||Gk(t.parent,e));return e.set(t,n),n}var Hk,G$=z(()=>{V$(),j$(),Hk=class{constructor(t=8){this.minGroupSize=t,this.groups=[],this.groupKeys=new WeakMap,this.placements=new Map,this.visibilityMemo=new Map,this.page=null,this.stats={instancingGroups:0,instancedDrawsSaved:0,instancingRegroups:0,instancingParks:0,instancingIneligible:{}}}update(t,e){this.page!==t&&(this.teardown(),this.page=t,e=!0),t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),e&&this.reconcile(t),this.refresh()}reconcile(t){let e={},i=new Map;t.traverse(s=>{if(s.isInstanceGroup===!0)return;let a=function(l){if(l.isMesh!==!0)return"not-a-mesh";if(nl(l)||Cr(l)||Hc(l)||og(l))return"excluded-type";let c=function(f){let g=Mc(f)?f.object:f;return g.geometry!==void 0?g:void 0}(l);if(c===void 0)return"not-a-mesh";let h=c.material;if(h===void 0)return"not-a-mesh";if(Array.isArray(h))return"array-material";let u=c.builtSharedGeometry;if(u===void 0)return"unrealized-geometry";if(!function(f){return f.isShared===!0}(u))return"unshared-geometry";if(u.attributes.position===void 0)return"empty-geometry";if(u.morphAttributes.position!==void 0)return"morph";if(c.isSkinnedMesh===!0)return"skinned";let d=c.morphTargetInfluences;if(d!==void 0&&d.length>0)return"morph";if(u.drawRange.start!==0||u.drawRange.count!==Number.POSITIVE_INFINITY)return"draw-range";let p=h;return p.positionNode!=null||p.castShadowPositionNode!=null?"position-node":p.transparent===!0?"transparent":c.userData?.__splinePlanarMirror!==void 0?"reflection":function(f){let g=f;for(;g!==null;){let m=g.states;if(m!==void 0&&Object.keys(m).length>0)return!0;g=g.parent}return!1}(c)?"interaction-states":{object:l,owner:c,geometry:u,material:h,key:k$(l,c,u,h)}}(s);if(typeof a=="string")return void(e[a]=(e[a]??0)+1);let o=i.get(a.key);o===void 0?i.set(a.key,[a]):o.push(a)});let n=new Map;for(let[s,a]of i)for(let o of a)n.set(o.object,s);let r=!1;for(let[s,a]of this.placements)n.get(s)!==this.groupKeys.get(a.group)&&this.parkPlacement(s,a);for(let s=this.groups.length-1;s>=0;s--){let a=this.groups[s];a.memberCount>=this.minGroupSize||(this.destroyGroup(a),this.groups.splice(s,1),r=!0)}for(let[s,a]of i){let o=a.filter(c=>!this.placements.has(c.object));if(o.length===0)continue;let l=0;for(let c of this.groups){if(l>=o.length)break;if(this.groupKeys.get(c)!==s)continue;let{members:h}=c;for(let u=0;u<h.length&&l<o.length;u++)h[u]===null&&this.place(c,u,o[l++].object)}for(;o.length-l>=this.minGroupSize;){let c=o.slice(l,l+eT);this.groups.push(this.createGroup(t,s,c)),l+=c.length,r=!0}}r&&this.stats.instancingRegroups++,this.publishGroupStats(),this.stats.instancingIneligible=e}createGroup(t,e,i){let n=i[0],r=new jk(n.geometry,n.material,function(s){for(let a of tT)if(s<=a)return a;return eT}(i.length),n.object);this.groupKeys.set(r,e);for(let s=0;s<i.length;s++)this.place(r,s,i[s].object);return t.add(r),r}destroyGroup(t){for(let e=0;e<t.members.length;e++){let i=t.members[e];i!==null&&this.parkPlacement(i,{group:t,slot:e})}t.removeFromParent(),t.dispose()}place(t,e,i){t.assign(e,i),this.placements.set(i,{group:t,slot:e}),i.isDrawSuppressed=!0}parkPlacement(t,e){e.group.park(e.slot),e.group.instanceMatrix.needsUpdate=!0,this.placements.delete(t),t.isDrawSuppressed=!1,this.stats.instancingParks++}refresh(){this.visibilityMemo.clear();for(let t of this.groups){let{members:e}=t,i=null;for(let n=0;n<e.length;n++){let r=e[n];r!==null&&(i===null&&(i=r),t.writeSlot(n,r,Gk(r,this.visibilityMemo)))}i!==null&&(t.adoptPassState(i),t.instanceMatrix.needsUpdate=!0)}}teardown(){for(let t of this.groups)this.destroyGroup(t);this.groups.length=0;for(let t of this.placements.keys())t.isDrawSuppressed=!1;this.placements.clear(),this.publishGroupStats()}dispose(){this.teardown(),this.page=null}publishGroupStats(){let t=0;for(let e of this.groups){let i=e.memberCount;i>0&&(t+=i-1)}this.stats.instancingGroups=this.groups.length,this.stats.instancedDrawsSaved=t}}});function H$(t,e,i){i.length=0;let{axis:n,sign:r,limit:s}=e;for(let a=0;a<t.length;a++){let o=t[a],l=t[(a+1)%t.length],c=(n===0?o.px:n===1?o.py:o.pz)*r-s,h=(n===0?l.px:n===1?l.py:l.pz)*r-s,u=c<=0,d=h<=0;if(u&&i.push(o),u!==d){let p=c/(c-h);i.push({px:o.px+(l.px-o.px)*p,py:o.py+(l.py-o.py)*p,pz:o.pz+(l.pz-o.pz)*p,nx:o.nx+(l.nx-o.nx)*p,ny:o.ny+(l.ny-o.ny)*p,nz:o.nz+(l.nz-o.nz)*p})}}return i}function W$(t,e,i,n,r,s,a,o,l){let c=t.geometry,h=c.getAttribute("position");if(h===void 0||h.count===0)return!0;let u=c.getAttribute("normal"),d=c.getIndex(),p=d!==null?d.count:h.count;if(p>Wk)return!0;let f=c.drawRange.start,g=f+(c.drawRange.count===1/0?p-f:Math.min(c.drawRange.count,p-f));Tu.copy(t.objectToDecal),zm.getNormalMatrix(Tu);let m=[],y=[];for(let v=f;v+2<g;v+=3){let _=d!==null?d.getX(v):v,b=d!==null?d.getX(v+1):v+1,x=d!==null?d.getX(v+2):v+2;if(ja.fromBufferAttribute(h,_).applyMatrix4(Tu),Bo.fromBufferAttribute(h,b).applyMatrix4(Tu),Uo.fromBufferAttribute(h,x).applyMatrix4(Tu),ja.z>i&&Bo.z>i&&Uo.z>i||ja.z<-i&&Bo.z<-i&&Uo.z<-i)continue;Nr.subVectors(Bo,ja),iT.subVectors(Uo,ja),Ul.crossVectors(Nr,iT);let w=Ul.length();if(!(w===0||Ul.z/w<=Xk)){if(m.length=0,u!==void 0)Nr.fromBufferAttribute(u,_).applyMatrix3(zm),m.push({px:ja.x,py:ja.y,pz:ja.z,nx:Nr.x,ny:Nr.y,nz:Nr.z}),Nr.fromBufferAttribute(u,b).applyMatrix3(zm),m.push({px:Bo.x,py:Bo.y,pz:Bo.z,nx:Nr.x,ny:Nr.y,nz:Nr.z}),Nr.fromBufferAttribute(u,x).applyMatrix3(zm),m.push({px:Uo.x,py:Uo.y,pz:Uo.z,nx:Nr.x,ny:Nr.y,nz:Nr.z});else{Ul.divideScalar(w);for(let S of[ja,Bo,Uo])m.push({px:S.x,py:S.y,pz:S.z,nx:Ul.x,ny:Ul.y,nz:Ul.z})}for(let S of e){if(m.length===0)break;let A=H$(m,S,y);y=m,m=A}if(!(m.length<3)){if(a.length/3+3*(m.length-2)>qk)return!1;for(let S=1;S+1<m.length;S++)for(let A of[m[0],m[S],m[S+1]]){l.push(A.px*n+.5,A.py*r+.5);let E=A.nx,P=A.ny,T=A.nz,R=Math.hypot(E,P,T);R>0?(E/=R,P/=R,T/=R):(E=0,P=0,T=1),a.push(A.px+E*s,A.py+P*s,A.pz+T*s),o.push(E,P,T)}}}}return!0}var Wk,qk,Xk,Tu,zm,ja,Bo,Uo,Nr,iT,Ul,Ov,o2,l2,h2,b1,$k,q$=z(()=>{et(),Wk=15e5,qk=3e5,Xk=.01,Tu=new At,zm=new ue,ja=new C,Bo=new C,Uo=new C,Nr=new C,iT=new C,Ul=new C}),X$=z(()=>{et(),Ye(),Jc(),Kn(),Wr(),q$(),lx(),Ov=new ci,o2=new ci,l2=new At,h2=new C,b1=class extends Hr{constructor(t,e,i){super(t,e),this.data=e,this.geometry=new Gt,this.lastSignature=[],this.nextSignature=[],this.scanned=[],this.lastParams={width:0,height:0,depth:0,offset:0},this.targetFilter=new Set,this.context=i;let n=this.data.geometry;this.lastParams={width:this.resolveNumber(n.width,0),height:this.resolveNumber(n.height,0),depth:this.resolveNumber(n.depth,0),offset:n.offset??0},this.geometry.userData={type:"DecalGeometry",parameters:{...this.lastParams}}}get isLOD(){return this.updateDecal(),!1}get isDecalObject(){return!0}resolveNumber(t,e){if(typeof t=="number")return t;let i=Number(this.context.shared.getVariable(t));return Number.isFinite(i)?i:e}currentParams(){let t=this.dataPatched.geometry;return{width:this.resolveNumber(t.width,this.lastParams.width),height:this.resolveNumber(t.height,this.lastParams.height),depth:this.resolveNumber(t.depth,this.lastParams.depth),offset:t.offset??0}}projectionRoot(){let t=this.parent;for(;t!==null&&Be.is(t);){if(t.data?.type==="Page")return t;t=t.parent}return this.context.scene}currentTargetFilter(){let t=this.dataPatched.geometry;if(t.projection!=="select")return null;let e=t.projectionTargets;if(e!==this.targetFilterSource&&(this.targetFilterSource=e,this.targetFilter.clear(),e!==void 0))for(let i of e)this.targetFilter.add(i);return this.targetFilter}static matchesTargetFilter(t,e,i){let n=t;for(;n!==null&&n!==i;){if(e.has(n.uuid))return!0;n=n.parent}return!1}scanTargets(t,e,i){let n=this.scanned;n.length=0;let r=this.projectionRoot();if(r===null)return n;let s=this.currentTargetFilter();if(s!==null&&s.size===0)return n;Ov.makeEmpty();for(let a=0;a<8;a++)h2.set((1&a?.5:-.5)*t,(2&a?.5:-.5)*e,(4&a?.5:-.5)*i).applyMatrix4(this.matrixWorld),Ov.expandByPoint(h2);return r.traverse(a=>{if(a===this||!Be.is(a)||!(a instanceof Xi)||a instanceof b1||a.dataPatched?.type!=="Mesh"||!a.visible||a.destroyedInAction||512&a.layers.mask||s!==null&&!b1.matchesTargetFilter(a,s,r))return;let o=a.geometry,l=o?.getAttribute("position");l===void 0||l.count===0||o.drawRange.count!==0&&(o.boundingBox===null&&o.computeBoundingBox(),o2.copy(o.boundingBox).applyMatrix4(a.matrixWorld),Ov.intersectsBox(o2)&&n.push(a))}),n}collectSignature(t,e,i){t.length=0,t.push(i.width,i.height,i.depth,i.offset);for(let n of this.matrixWorld.elements)t.push(n);for(let n of e){t.push(n.id,n.geometry.id);let r=n.geometry.getAttribute("position");t.push(r===void 0?-1:"version"in r?r.version:r.data.version);let s=n.geometry.getIndex();t.push(s!==null?s.version:-1),t.push(n.geometry.drawRange.count===1/0?-1:n.geometry.drawRange.count);for(let a of n.matrixWorld.elements)t.push(a)}}signaturesEqual(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}updateDecal(){if(this.disposed)return!1;this.updateWorldMatrix(!0,!1);let t=this.currentParams(),e=this.scanTargets(t.width,t.height,t.depth);if(this.collectSignature(this.nextSignature,e,t),this.signaturesEqual(this.nextSignature,this.lastSignature))return!1;let i=this.lastSignature;this.lastSignature=this.nextSignature,this.nextSignature=i,this.lastParams=t,l2.copy(this.matrixWorld).invert();let n=e.map(r=>({geometry:r.geometry,objectToDecal:new At().multiplyMatrices(l2,r.matrixWorld)}));return this.geometry.dispose(),this.geometry=function(r,s){let a=Math.max(Math.abs(s.width),1e-6),o=Math.max(Math.abs(s.height),1e-6),l=Math.max(Math.abs(s.depth),1e-6),c=[{axis:0,sign:1,limit:a/2},{axis:0,sign:-1,limit:a/2},{axis:1,sign:1,limit:o/2},{axis:1,sign:-1,limit:o/2},{axis:2,sign:1,limit:l/2},{axis:2,sign:-1,limit:l/2}],h=[],u=[],d=[];for(let f of r)if(!W$(f,c,l/2,1/a,1/o,s.offset,h,u,d))break;let p=new Gt;return p.setAttribute("position",new Nt(h,3)),p.setAttribute("normal",new Nt(u,3)),p.setAttribute("uv",new Nt(d,2)),h.length===0?(p.setDrawRange(0,0),p.boundingSphere=new vr):p.computeBoundingSphere(),p}(n,t),this.geometry.userData={type:"DecalGeometry",parameters:{width:t.width,height:t.height,depth:t.depth}},Qu(this),Ju(this),this.resetBBoxNeedsUpdate(),!0}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),ri(t.path,["geometry"])&&this.resetBBoxNeedsUpdate()}updateEntityBoxSize(t,e){let i=this.currentParams();t.setScalar(0),e.set(i.width,i.height,i.depth).multiplyScalar(.5)}dispose(){super.dispose(),this.geometry.dispose()}}}),$$=z(()=>{et(),Yb(),Qc(),$k=class extends Kc(oE,pp){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}}});function g3(t,e,i){if(console.assert(e.type!==void 0),e.type==="Mesh")return function(n,r,s){let a;if(x1!==void 0&&r?.geometry&&"subdivisions"in r.geometry&&(r.geometry.subdivisions??0)>x1&&Object.assign(r.geometry,{subdivisions:x1}),r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry"){let o=CS(r.geometry.type);return o?o(n,r,s):(Gn(r.geometry.type==="InputGeometry"?"textinputs":"text",`a Mesh with ${r.geometry.type}`),new Ai(n,r,s))}if(r.geometry.type==="SubdivGeometry")a=new mp(n,r,s);else if(r.geometry.type==="PathGeometry"||r.geometry.type==="VectorGeometry"||r.geometry.type==="ShapeBlendGeometry"){let o=CS(r.geometry.type);o?a=o(n,r,s):(Gn(r.geometry.type==="ShapeBlendGeometry"?"shape-blends":r.geometry.type==="PathGeometry"?"3d-paths":"vector-shapes",`a Mesh with ${r.geometry.type}`),a=new Ai(n,r,s))}else if(r.geometry.type==="BooleanGeometry")a=new lh(n,r,s);else if(r.geometry.type==="DecalGeometry")a=new b1(n,r,s);else if(r.geometry.type==="UIGeometry"){let o=CS("UIGeometry");o?a=o(n,r,s):(Gn("ui-2d","a Mesh with UIGeometry"),a=new Ai(n,r,s))}else a=new Ai(n,r,s);return a}(t,e,i);if(e.type==="Empty")return new $a(t,e);if(e.type==="Particle"){let n=TS("Particle");return n?n(t,e,i):(Gn("particles","a Particle system"),new $a(t,e))}if(e.type==="ParticleCollider")return new tp(t,e,i);if(e.type==="Hair"){let n=TS("Hair");return n?n(t,e,i):(Gn("hair","a Hair System"),new $a(t,e))}if(e.type==="Splat")return new $a(t,e);if(e.type==="Bone")return new $k(t,e);if(e.type==="Page")return new un(t,e,i);if(e.type==="PointLight")return new dx(t,e,i);if(e.type==="SpotLight")return new Jg(t,e,i);if(e.type==="DirectionalLight")return new Qg(t,e,i);if(e.type==="Component"||e.type==="Instance"){let n=TS(e.type);return n?n(t,e,i):(Gn("components",`a ${e.type}`),new $a(t,e))}return jc.is(e.type)?new vn(t,e):(console.error(e),new $a(t,e))}function Y$(t,e,i){let n=g3(t.identity,e,i),r=t.children,s=t.attachedPaths,a=t.parent,o=t.component,l=t.instances,c=t.overrideData,h=t.uuid,u=t.stateSelection;t.dispose();for(let d of Object.keys(t))delete t[d];Object.setPrototypeOf(t,Object.getPrototypeOf(n));for(let d of Object.keys(n))t[d]=n[d];t.children=[...t.children,...r],t.attachedPaths=s,t.parent=a,t.component=o,t.instances=l,t.uuid=h,t.overrideData=c,t.updateState(t.data,i),u&&t.changeSelectedState(u,i),t.resetBBoxNeedsUpdate()}var x1,Yk,Zk,Kk,th,w1,Qk,nT,Z$=z(()=>{Yt(),t0(),Zg(),X$(),qr(),tx(),kk(),u3(),l3(),Hs(),$_(),$$(),ol(),p3(),ke(),x1=function(){try{let t=window.location.href;if(t.includes("reducesubdiv=")){let e=t.indexOf("reducesubdiv=")+13;return parseInt(t.slice(e,e+1))}}catch{}}(),tl.createEntity=g3,tl.changeEntityProptotype=Y$}),K$=z(()=>{Yk=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((i,n)=>{let r=[n,i],s=i;for(;this._constraints.has(s);){if(s=this._constraints.get(s),r.includes(s)){console.warn(`circular dependency detected: ${r.join(" -> ")}`);break}e.has(s)||r.push(s)}for(let a=r.length-2;a>=0;a--)if(!e.has(r[a])){let o=t.find(r[a]);o?o.applyPathSnapping(t):console.warn(`missing entity ${r[a]}`),e.add(r[a])}})}findDependency(t,e){let i=t;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===e)return!0;return!1}}}),Q$=z(()=>{Zk="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL"}),J$=z(()=>{Kk=`
4171
4171
  function sortWorker(self) {
4172
4172
  let wasmInstance;
@@ -9842,11 +9842,11 @@ void main() {
9842
9842
  void main() {
9843
9843
  vec4 texel = texture2D( tDiffuse, vUv );
9844
9844
  gl_FragColor = texel;
9845
- }`}),YQ=new class{constructor(t){this._mesh=new wi($Q,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,XQ)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(jV),Y2=null,Z2=null,ZQ=me.identity(),GV=class{constructor(t,e,i,n){var r;this.uuid=t,this.width=e,this.height=i,this.context=n,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||cg.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height;this.renderer.dpr=J5(s,a,this.dpr,this.isScreenSpace),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{if(s.target?.uuid!==void 0){let a=this.frameRoot?.find(s.target.uuid);a&&a.dispatchEvent({...s,target:a})}},this.scene2d=new F3(Ot.generateUUID(),cA.defaultData,{dpr:window.devicePixelRatio,shared:n.shared}),this.canvas=(Y2===null&&(Y2=document.createElement("canvas")),Y2),this.renderer=(r=this.canvas,Z2===null&&(Z2=new kQ(r)),Z2),this.promise=this.init(),this.renderTarget=new Ne(1,1,{type:$n,stencilBuffer:!1,depthBuffer:!1}),n.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=n.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new vz(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(t){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,t.blitTextureToTarget)t.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{jV.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),YQ.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,n){this.scene2d.updateEntityByOp(t,e,i,n),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,i=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=i,this.frameOverride.localMatrix=ZQ,this.isScreenSpace&&(this.frameOverride.fill.color=Je.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},HV({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let i=Math.max(1,t?.width??this.width),n=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=n,this._innerApplySize();let r=function(s,a,o,l){let c=J5(s,a,o,l),h=Math.max(o,512/Math.min(s,a)),u=Math.min(h,c);return{width:Math.max(1,Math.ceil(s*u)),height:Math.max(1,Math.ceil(a*u))}}(i,n,e,this.isScreenSpace);this.renderTarget.setSize(r.width,r.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(e&&e instanceof so)return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent),i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginState",this.onFrameOverrideObjectEvent),t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function HV({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s}){if(t instanceof so&&e instanceof so||t instanceof hh&&e instanceof hh)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],c=e.children[a];l&&c&&l.uuid===c.uuid&&KQ({objectOverride:l,objectRoot:c,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s})}}function KQ({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s}){let[a,o]=function(u){if(K2(u))return[u.width,u.height];if(u instanceof wb){let[d,p]=u.getHalfSize();return[2*d,2*p]}if(u instanceof hh){let[d,p]=u.recursiveBBox.getHalfSize();return[2*d,2*p]}return[0,0]}(e),{width:l,height:c,position:h}=VV({constraints:t.data,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=h,t.data={...t.data,position:h},t.states)for(let u in t.states)QQ({stateId:u,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s});if(K2(t)||t instanceof hh)K2(t)&&(t.width=l,t.height=c,t.data={...t.data,width:l,height:c}),HV({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:o});else if(t instanceof wb){let u=e,d=a!==0?l/a:1,p=o!==0?c/o:1;t.path=function(f,g=1,m=1){if(g<=0||m<=0)return f;if(NV(f))return console.warn("Cannot scale invalid path",f),$2([]);if(g===1&&m===1)return f;try{return $2((0,qQ.parseSVG)(f).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*g),"y"in v&&(v.y=v.y*m),"x1"in v&&(v.x1=v.x1*g),"x2"in v&&(v.x2=v.x2*g),"y1"in v&&(v.y1=v.y1*m),"y2"in v&&(v.y2=v.y2*m),"rx"in v&&(v.rx=v.rx*g),"ry"in v&&(v.ry=v.ry*m),v}))}catch(y){return console.warn("Error parsing SVG path",y),$2([])}}(u.path,d,p),t.data={...t.data,path:t.path}}}function QQ({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:n,newParentHeight:r,initialParentWidth:s,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:c,height:h,position:u}=VV({constraints:e.data,newParentWidth:n,newParentHeight:r,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:Bc.isResizeable(l)?l.width:0,objectInitialHeight:Bc.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:u}),Bc.isResizeable(o)&&Object.assign(e.states[t],{width:c,height:h})}}function K2(t){return t instanceof n0||t instanceof so||t instanceof U3||t instanceof z3}sx();var tB,JQ=class extends Ai{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new GV(t+"-canvas",e.geometry.width,e.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),t.type===0&&(t.props.frame!==void 0&&this.applyFrame(t.props.frame,i.shared),(t.props.width!==void 0||t.props.height!==void 0)&&this.applySize(t.props,i.shared))}applySize(t,e){let i=t?.width??this.dataPatched.geometry.width,n=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:n}),this.applyGeometryParametersFromFrame(e)}applyFrame(t,e){this.uiCanvas.applyFrame(t),this.applyGeometryParametersFromFrame(e),this.applyMaterialParametersFromFrame({shared:e})}applyGeometryParametersFromFrame(t){let e=this.frame;e&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Jl(this.dataPatched.geometry,t,this.data.flatShading,this))}applyMaterialParametersFromFrame(t){let e=this.frame;if(e){let i=e.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset?.(this.dataPatched.material,t,!0)}}updateEntity2DByOp(t,e,i,n){this.uiCanvas.updateEntity2DByOp(t,e,i,n),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(n):ri(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:n}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(t){super.removeInteractionGeometry(t),this.applySize({},t)}updateGeometryInteractions(t,e){super.updateGeometryInteractions(t,e),this.applySize({width:t.width,height:t.height},e);let i={...this.data.geometry,...t};this.localGeometry?.dispose(),this.localGeometry=Jl(i,e,this.data.flatShading,this)}};ke(),wp("UIGeometry",(t,e,i)=>new JQ(t,e,i)),Kb=tB={Scene2D:F3,UICanvas:GV,loadHanaUIRUNTIME:function(){return _b||(_b=async()=>async function(t,e){return await t.default(e?{module_or_path:e}:void 0),Object.getOwnPropertyDescriptor(t.Engine.prototype,"scene")||Object.defineProperty(t.Engine.prototype,"scene",{get:function(){let i=Object.create(t.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>t.Engine.create(i,JSON.parse('{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}'),!0)}}(await Promise.resolve().then(()=>(dD(),cD)),N5??function(){let t=typeof process<"u"?"2.0.42":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),zV().then(()=>{})},setHanaUIWasmUrl:function(t){N5=t}},Z_!==null&&tB.setHanaUIWasmUrl(Z_),Si("ui-2d"),vk(),et();var WV,Q2,tJ=class{constructor(){this.type="ShapePath",this.color=new Jt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Jm,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath?.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath?.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(c,h,u,d){let p=c.x,f=h.x,g=u.x,m=d.x,y=c.y,v=h.y,_=u.y,b=d.y,x=(m-g)*(y-_)-(b-_)*(p-g),w=(b-_)*(f-p)-(m-g)*(v-y),S=x/w,A=((f-p)*(y-_)-(v-y)*(p-g))/w;if(w===0&&x!==0||S<=0||S>=1||A<0||A>1)return null;if(x===0&&w===0){for(let E=0;E<2;E++){if(i(E===0?u:d,c,h),t.loc===0){let P=E===0?u:d;return{x:P.x,y:P.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(f-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let E=0;E<2;E++)if(i(E===0?u:d,c,h),t.loc===0){let P=E===0?u:d;return{x:P.x,y:P.y,t:t.t}}return{x:+(p+S*(f-p)).toPrecision(10),y:+(y+S*(v-y)).toPrecision(10),t:S}}function i(c,h,u){let d,p=u.x-h.x,f=u.y-h.y,g=c.x-h.x,m=c.y-h.y,y=p*m-g*f;return c.x===h.x&&c.y===h.y?(t.loc=0,void(t.t=0)):c.x===u.x&&c.y===u.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*g<0||f*m<0?t.loc=5:Math.sqrt(p*p+f*f)<Math.sqrt(g*g+m*m)?t.loc=6:(d=p!==0?g/p:m/f,t.loc=2,t.t=d))}let n=0,r=999999999,s=-999999999,a=[];this.subPaths.forEach(c=>{let h=c.getPoints(),u=-999999999,d=999999999,p=-999999999,f=999999999;for(let g=0;g<h.length;g++){let m=h[g];m.y>u&&(u=m.y),m.y<d&&(d=m.y),m.x>p&&(p=m.x),m.x<f&&(f=m.x)}s<=p&&(s=p+1),r>=f&&(r=f-1),h.length&&a.push({curves:c.curves,points:h,isCW:uE.isClockWise(h),identifier:n++,boundingBox:new Fb(new it(f,d),new it(p,u))})});let o=a.map(c=>function(h,u,d,p,f){(f==null||f==="")&&(f="nonzero");let g=new it;h.boundingBox.getCenter(g);let m=function(w,S,A){let E=new it;S.getCenter(E);let P=[];return A.forEach(T=>{T.boundingBox.containsPoint(E)&&function(R,L){let D=[],U=[];for(let V=1;V<R.length;V++){let k=R[V-1],Y=R[V];for(let $=1;$<L.length;$++){let nt=e(k,Y,L[$-1],L[$]);nt!==null&&D.find(Q=>Q.t<=nt.t+Number.EPSILON&&Q.t>=nt.t-Number.EPSILON)===void 0&&(D.push(nt),U.push(new it(nt.x,nt.y)))}}return U}(w,T.points).forEach(R=>{P.push({identifier:T.identifier,isCW:T.isCW,point:R})})}),P.sort((T,R)=>T.point.x-R.point.x),P}([new it(d,g.y),new it(p,g.y)],h.boundingBox,u);m.sort((w,S)=>w.point.x-S.point.x);let y=[],v=[];m.forEach(w=>{w.identifier===h.identifier?y.push(w):v.push(w)});let _=y[0].point.x,b=[],x=0;for(;x<v.length&&v[x].point.x<_;)b.length>0&&b[b.length-1]===v[x].identifier?b.pop():b.push(v[x].identifier),x++;if(b.push(h.identifier),f==="evenodd"){let w=b.length%2==0,S=b[b.length-2];return{identifier:h.identifier,isHole:w,for:S}}if(f==="nonzero"){let w=!0,S=null,A=null;for(let E=0;E<b.length;E++){let P=b[E];u[P]&&(w?(A=u[P].isCW,w=!1,S=P):A!==u[P].isCW&&(A=u[P].isCW,w=!0))}return{identifier:h.identifier,isHole:w,for:S}}console.warn('fill-rule: "'+f+'" is currently not implemented.')}(c,a,r,s,this.userData?.style.fillRule)),l=[];return a.forEach(c=>{let h=o[c.identifier];if(h&&!h.isHole){let u=new Sg;u.curves=c.curves,o.filter(d=>d?.isHole&&d.for===c.identifier).forEach(d=>{if(d){let p=a[d.identifier],f=new Jm;f.curves=p.curves,u.holes.push(f)}}),l.push(u)}}),l}},qV=!1,eB=new Promise(t=>{WV=t}),iB=!1;function nB(){if(qV=!0,!iB)return Q2||(Q2=async function(){let t=await import("./opentype.js");WV(t),iB=!0}(),Q2)}var eJ=new class{async load(t,e,i=()=>{}){let{load:n}=await eB;n(t,(r,s)=>{r||!s?i(r??"Something went wrong"):e(s)})}async parse(t){let{parse:e,Bidi:i}=await eB;try{let n=e(t),r=new i,s=a=>n.charToGlyphIndex(a.char);return r.registerModifier("glyphIndex",null,s),r.applyFeatures(n,n.defaultRenderOptions.features),{font:n,bidi:r}}catch(n){console.error(n)}}};function iJ(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}et(),$C(),ke(),wp("TextGeometry",(t,e,i)=>new B3(t,e,i));var rB={create:(t,e)=>new UA(t,e)};pA("TextGeometry",rB),pA("InputGeometry",rB),XC=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{this._layoutErrorWarned=!1;let e=await async function(i){let n,r,s=!1;if(i.url?(n=await async function(a){let o;try{o=await fetch(a)}catch(l){throw new Error(`could not fetch the font at ${a}: ${l}`)}if(!o.ok)throw new Error(`${o.status} ${o.statusText} fetching the font at ${a}`);return await o.arrayBuffer()}(i.url),r=i.url,s=i.url.startsWith("/")):i.data&&(n=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),n){if(!qV)return{font:void 0,url:r,intercepted:s,arr:n,bidi:null};{let a=await eJ.parse(n);if(a)return{font:a.font,url:r,intercepted:s,arr:n,bidi:a.bidi}}}}(t);e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}warnLayoutError(t){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,t))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let n=this._bidi;n.getTextGlyphs(e);let r=n.tokenizer.tokens,s=[],a=0,o=i.length===r.length;for(let l=0;l<i.length;l++){let c=i[l].index,h=String.fromCharCode(i[l].unicode),u=r[a];if(iJ(c,u)||o)s.push({char:h,index:c,replacements:[u.state.glyphIndex],replacementChars:[u.char]}),a++;else{let d=u.char,p="",f=[u.state.glyphIndex],g=[],m=!1;for(;!m;)a++,p=e.charAt(a),d+=p,f.push(t.charToGlyphIndex(p)),g=t.stringToGlyphs(d),g.length===1&&g[0].index===c&&(m=!0),a>e.length&&(m=!0);s.push({char:h,index:c,replacements:f,replacementChars:Array.from(d)}),a++}}return s}generateShapes(t,e,i){if(!this._isLoaded)return;let n=this.font,r=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,a=t.map(y=>this.getTextWidth(y,e)),o=typeof e.width=="string"?Number(i.getVariable(e.width)):e.width,l=typeof e.height=="string"?Number(i.getVariable(e.height)):e.height,c=this.getCharWidth(`
9845
+ }`}),YQ=new class{constructor(t){this._mesh=new wi($Q,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,XQ)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(jV),Y2=null,Z2=null,ZQ=me.identity(),GV=class{constructor(t,e,i,n){var r;this.uuid=t,this.width=e,this.height=i,this.context=n,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||cg.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height;this.renderer.dpr=J5(s,a,this.dpr,this.isScreenSpace),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{if(s.target?.uuid!==void 0){let a=this.frameRoot?.find(s.target.uuid);a&&a.dispatchEvent({...s,target:a})}},this.scene2d=new F3(Ot.generateUUID(),cA.defaultData,{dpr:window.devicePixelRatio,shared:n.shared}),this.canvas=(Y2===null&&(Y2=document.createElement("canvas")),Y2),this.renderer=(r=this.canvas,Z2===null&&(Z2=new kQ(r)),Z2),this.promise=this.init(),this.renderTarget=new Ne(1,1,{type:$n,stencilBuffer:!1,depthBuffer:!1}),n.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=n.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new vz(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(t){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,t.blitTextureToTarget)t.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{jV.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),YQ.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,n){this.scene2d.updateEntityByOp(t,e,i,n),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,i=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=i,this.frameOverride.localMatrix=ZQ,this.isScreenSpace&&(this.frameOverride.fill.color=Je.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},HV({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let i=Math.max(1,t?.width??this.width),n=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=n,this._innerApplySize();let r=function(s,a,o,l){let c=J5(s,a,o,l),h=Math.max(o,512/Math.min(s,a)),u=Math.min(h,c);return{width:Math.max(1,Math.ceil(s*u)),height:Math.max(1,Math.ceil(a*u))}}(i,n,e,this.isScreenSpace);this.renderTarget.setSize(r.width,r.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(e&&e instanceof so)return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent),i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginState",this.onFrameOverrideObjectEvent),t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function HV({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s}){if(t instanceof so&&e instanceof so||t instanceof hh&&e instanceof hh)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],c=e.children[a];l&&c&&l.uuid===c.uuid&&KQ({objectOverride:l,objectRoot:c,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s})}}function KQ({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s}){let[a,o]=function(u){if(K2(u))return[u.width,u.height];if(u instanceof wb){let[d,p]=u.getHalfSize();return[2*d,2*p]}if(u instanceof hh){let[d,p]=u.recursiveBBox.getHalfSize();return[2*d,2*p]}return[0,0]}(e),{width:l,height:c,position:h}=VV({constraints:t.data,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=h,t.data={...t.data,position:h},t.states)for(let u in t.states)QQ({stateId:u,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:n,initialParentWidth:r,initialParentHeight:s});if(K2(t)||t instanceof hh)K2(t)&&(t.width=l,t.height=c,t.data={...t.data,width:l,height:c}),HV({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:o});else if(t instanceof wb){let u=e,d=a!==0?l/a:1,p=o!==0?c/o:1;t.path=function(f,g=1,m=1){if(g<=0||m<=0)return f;if(NV(f))return console.warn("Cannot scale invalid path",f),$2([]);if(g===1&&m===1)return f;try{return $2((0,qQ.parseSVG)(f).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*g),"y"in v&&(v.y=v.y*m),"x1"in v&&(v.x1=v.x1*g),"x2"in v&&(v.x2=v.x2*g),"y1"in v&&(v.y1=v.y1*m),"y2"in v&&(v.y2=v.y2*m),"rx"in v&&(v.rx=v.rx*g),"ry"in v&&(v.ry=v.ry*m),v}))}catch(y){return console.warn("Error parsing SVG path",y),$2([])}}(u.path,d,p),t.data={...t.data,path:t.path}}}function QQ({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:n,newParentHeight:r,initialParentWidth:s,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:c,height:h,position:u}=VV({constraints:e.data,newParentWidth:n,newParentHeight:r,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:Bc.isResizeable(l)?l.width:0,objectInitialHeight:Bc.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:u}),Bc.isResizeable(o)&&Object.assign(e.states[t],{width:c,height:h})}}function K2(t){return t instanceof n0||t instanceof so||t instanceof U3||t instanceof z3}sx();var tB,JQ=class extends Ai{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new GV(t+"-canvas",e.geometry.width,e.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),t.type===0&&(t.props.frame!==void 0&&this.applyFrame(t.props.frame,i.shared),(t.props.width!==void 0||t.props.height!==void 0)&&this.applySize(t.props,i.shared))}applySize(t,e){let i=t?.width??this.dataPatched.geometry.width,n=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:n}),this.applyGeometryParametersFromFrame(e)}applyFrame(t,e){this.uiCanvas.applyFrame(t),this.applyGeometryParametersFromFrame(e),this.applyMaterialParametersFromFrame({shared:e})}applyGeometryParametersFromFrame(t){let e=this.frame;e&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Jl(this.dataPatched.geometry,t,this.data.flatShading,this))}applyMaterialParametersFromFrame(t){let e=this.frame;if(e){let i=e.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset?.(this.dataPatched.material,t,!0)}}updateEntity2DByOp(t,e,i,n){this.uiCanvas.updateEntity2DByOp(t,e,i,n),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(n):ri(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:n}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(t){super.removeInteractionGeometry(t),this.applySize({},t)}updateGeometryInteractions(t,e){super.updateGeometryInteractions(t,e),this.applySize({width:t.width,height:t.height},e);let i={...this.data.geometry,...t};this.localGeometry?.dispose(),this.localGeometry=Jl(i,e,this.data.flatShading,this)}};ke(),wp("UIGeometry",(t,e,i)=>new JQ(t,e,i)),Kb=tB={Scene2D:F3,UICanvas:GV,loadHanaUIRUNTIME:function(){return _b||(_b=async()=>async function(t,e){return await t.default(e?{module_or_path:e}:void 0),Object.getOwnPropertyDescriptor(t.Engine.prototype,"scene")||Object.defineProperty(t.Engine.prototype,"scene",{get:function(){let i=Object.create(t.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>t.Engine.create(i,JSON.parse('{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}'),!0)}}(await Promise.resolve().then(()=>(dD(),cD)),N5??function(){let t=typeof process<"u"?"2.0.44":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),zV().then(()=>{})},setHanaUIWasmUrl:function(t){N5=t}},Z_!==null&&tB.setHanaUIWasmUrl(Z_),Si("ui-2d"),vk(),et();var WV,Q2,tJ=class{constructor(){this.type="ShapePath",this.color=new Jt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Jm,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath?.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath?.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(c,h,u,d){let p=c.x,f=h.x,g=u.x,m=d.x,y=c.y,v=h.y,_=u.y,b=d.y,x=(m-g)*(y-_)-(b-_)*(p-g),w=(b-_)*(f-p)-(m-g)*(v-y),S=x/w,A=((f-p)*(y-_)-(v-y)*(p-g))/w;if(w===0&&x!==0||S<=0||S>=1||A<0||A>1)return null;if(x===0&&w===0){for(let E=0;E<2;E++){if(i(E===0?u:d,c,h),t.loc===0){let P=E===0?u:d;return{x:P.x,y:P.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(f-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let E=0;E<2;E++)if(i(E===0?u:d,c,h),t.loc===0){let P=E===0?u:d;return{x:P.x,y:P.y,t:t.t}}return{x:+(p+S*(f-p)).toPrecision(10),y:+(y+S*(v-y)).toPrecision(10),t:S}}function i(c,h,u){let d,p=u.x-h.x,f=u.y-h.y,g=c.x-h.x,m=c.y-h.y,y=p*m-g*f;return c.x===h.x&&c.y===h.y?(t.loc=0,void(t.t=0)):c.x===u.x&&c.y===u.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*g<0||f*m<0?t.loc=5:Math.sqrt(p*p+f*f)<Math.sqrt(g*g+m*m)?t.loc=6:(d=p!==0?g/p:m/f,t.loc=2,t.t=d))}let n=0,r=999999999,s=-999999999,a=[];this.subPaths.forEach(c=>{let h=c.getPoints(),u=-999999999,d=999999999,p=-999999999,f=999999999;for(let g=0;g<h.length;g++){let m=h[g];m.y>u&&(u=m.y),m.y<d&&(d=m.y),m.x>p&&(p=m.x),m.x<f&&(f=m.x)}s<=p&&(s=p+1),r>=f&&(r=f-1),h.length&&a.push({curves:c.curves,points:h,isCW:uE.isClockWise(h),identifier:n++,boundingBox:new Fb(new it(f,d),new it(p,u))})});let o=a.map(c=>function(h,u,d,p,f){(f==null||f==="")&&(f="nonzero");let g=new it;h.boundingBox.getCenter(g);let m=function(w,S,A){let E=new it;S.getCenter(E);let P=[];return A.forEach(T=>{T.boundingBox.containsPoint(E)&&function(R,L){let D=[],U=[];for(let V=1;V<R.length;V++){let k=R[V-1],Y=R[V];for(let $=1;$<L.length;$++){let nt=e(k,Y,L[$-1],L[$]);nt!==null&&D.find(Q=>Q.t<=nt.t+Number.EPSILON&&Q.t>=nt.t-Number.EPSILON)===void 0&&(D.push(nt),U.push(new it(nt.x,nt.y)))}}return U}(w,T.points).forEach(R=>{P.push({identifier:T.identifier,isCW:T.isCW,point:R})})}),P.sort((T,R)=>T.point.x-R.point.x),P}([new it(d,g.y),new it(p,g.y)],h.boundingBox,u);m.sort((w,S)=>w.point.x-S.point.x);let y=[],v=[];m.forEach(w=>{w.identifier===h.identifier?y.push(w):v.push(w)});let _=y[0].point.x,b=[],x=0;for(;x<v.length&&v[x].point.x<_;)b.length>0&&b[b.length-1]===v[x].identifier?b.pop():b.push(v[x].identifier),x++;if(b.push(h.identifier),f==="evenodd"){let w=b.length%2==0,S=b[b.length-2];return{identifier:h.identifier,isHole:w,for:S}}if(f==="nonzero"){let w=!0,S=null,A=null;for(let E=0;E<b.length;E++){let P=b[E];u[P]&&(w?(A=u[P].isCW,w=!1,S=P):A!==u[P].isCW&&(A=u[P].isCW,w=!0))}return{identifier:h.identifier,isHole:w,for:S}}console.warn('fill-rule: "'+f+'" is currently not implemented.')}(c,a,r,s,this.userData?.style.fillRule)),l=[];return a.forEach(c=>{let h=o[c.identifier];if(h&&!h.isHole){let u=new Sg;u.curves=c.curves,o.filter(d=>d?.isHole&&d.for===c.identifier).forEach(d=>{if(d){let p=a[d.identifier],f=new Jm;f.curves=p.curves,u.holes.push(f)}}),l.push(u)}}),l}},qV=!1,eB=new Promise(t=>{WV=t}),iB=!1;function nB(){if(qV=!0,!iB)return Q2||(Q2=async function(){let t=await import("./opentype.js");WV(t),iB=!0}(),Q2)}var eJ=new class{async load(t,e,i=()=>{}){let{load:n}=await eB;n(t,(r,s)=>{r||!s?i(r??"Something went wrong"):e(s)})}async parse(t){let{parse:e,Bidi:i}=await eB;try{let n=e(t),r=new i,s=a=>n.charToGlyphIndex(a.char);return r.registerModifier("glyphIndex",null,s),r.applyFeatures(n,n.defaultRenderOptions.features),{font:n,bidi:r}}catch(n){console.error(n)}}};function iJ(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}et(),$C(),ke(),wp("TextGeometry",(t,e,i)=>new B3(t,e,i));var rB={create:(t,e)=>new UA(t,e)};pA("TextGeometry",rB),pA("InputGeometry",rB),XC=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{this._layoutErrorWarned=!1;let e=await async function(i){let n,r,s=!1;if(i.url?(n=await async function(a){let o;try{o=await fetch(a)}catch(l){throw new Error(`could not fetch the font at ${a}: ${l}`)}if(!o.ok)throw new Error(`${o.status} ${o.statusText} fetching the font at ${a}`);return await o.arrayBuffer()}(i.url),r=i.url,s=i.url.startsWith("/")):i.data&&(n=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),n){if(!qV)return{font:void 0,url:r,intercepted:s,arr:n,bidi:null};{let a=await eJ.parse(n);if(a)return{font:a.font,url:r,intercepted:s,arr:n,bidi:a.bidi}}}}(t);e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}warnLayoutError(t){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,t))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let n=this._bidi;n.getTextGlyphs(e);let r=n.tokenizer.tokens,s=[],a=0,o=i.length===r.length;for(let l=0;l<i.length;l++){let c=i[l].index,h=String.fromCharCode(i[l].unicode),u=r[a];if(iJ(c,u)||o)s.push({char:h,index:c,replacements:[u.state.glyphIndex],replacementChars:[u.char]}),a++;else{let d=u.char,p="",f=[u.state.glyphIndex],g=[],m=!1;for(;!m;)a++,p=e.charAt(a),d+=p,f.push(t.charToGlyphIndex(p)),g=t.stringToGlyphs(d),g.length===1&&g[0].index===c&&(m=!0),a>e.length&&(m=!0);s.push({char:h,index:c,replacements:f,replacementChars:Array.from(d)}),a++}}return s}generateShapes(t,e,i){if(!this._isLoaded)return;let n=this.font,r=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,a=t.map(y=>this.getTextWidth(y,e)),o=typeof e.width=="string"?Number(i.getVariable(e.width)):e.width,l=typeof e.height=="string"?Number(i.getVariable(e.height)):e.height,c=this.getCharWidth(`
9846
9846
  `,e),h=e.horizontalAlign===1?c:0,u=this.getLineInitialOffsetX(a[0],o,e.horizontalAlign,t[0],c),d=this.getLineInitialOffsetY(s,t.length,l,r,e.verticalAlign),p=[],f=t.map(()=>[]),g=t.map(()=>[]);for(let y=0;y<t.length;y++){let v=t[y],_={features:{liga:!0},letterSpacing:e.letterSpacing},b=[];try{b=n.stringToGlyphs(v,_)}catch(E){this.warnLayoutError(E)}u=this.getLineInitialOffsetX(a[y],o,e.horizontalAlign,v,c);let x=[];try{x=this.reverseLigaturesTable(n,v,b)}catch(E){this.warnLayoutError(E)}let w=this.computeSpaceWidthForLine(t,y,e,i),S=0,A=b[0];A&&e.horizontalAlign===2&&A.leftSideBearing!==void 0&&(u-=A.leftSideBearing*r);try{this.font?.forEachGlyph(v,u,d,e.fontSize,_,(E,P,T,R,L)=>{let D=E.index===0?`
9847
9847
  `:E.unicode?String.fromCharCode(E.unicode):void 0,U=x[S],V=0;if(D===`
9848
9848
  `)V=h;else if(D===" ")V=w;else{let k=this.createPath(E,r,P,T,e);k&&(V=k.offsetX,p.push(k.path))}if(U&&U.replacements.length!==1){let k=U.replacements.map(Q=>(n.glyphs.get(Q).advanceWidth??0)*r),Y=k.reduce((Q,rt)=>Q+rt,0),$=k.map(Q=>Q/Y),nt=P;for(let Q=0;Q<$.length;Q++){let rt=V*$[Q];g[y].push([nt,T]),f[y].push(rt),nt+=rt}}else g[y].push([P,T]),f[y].push(V);S++})}catch(E){this.warnLayoutError(E)}d-=s}let m=[];for(let y=0,v=p.length;y<v;y++)m.push(...p[y].toShapes());return{shapes:m,charWidths:f,lineWidths:a,charCoords:g}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,i,n,r){return(i===3||i===2)&&n.indexOf(`
9849
- `)>=0&&(t-=r),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,n,r){let s=e*t,a=t-Math.abs(this.ascender-this.descender)*n,o=-this.ascender*n-a/2;return r===3?-(i-s-o):r===2?-(.5*i-.5*s-o):o}createPath(t,e,i,n,r){let s=t.getPath(i,-n,r.fontSize,{kerning:!1,letterSpacing:r.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new tJ,o=(t.advanceWidth??1)*e;if(t)for(let l of s.commands){let c=a.currentPath?.currentPoint;if(!c||l.type==="Z"||c.x!==l.x||-c.y!==l.y)switch(l.type){case"M":a.moveTo(l.x,-l.y);break;case"L":a.lineTo(l.x,-l.y);break;case"Q":a.quadraticCurveTo(l.x1,-l.y1,l.x,-l.y);break;case"C":a.bezierCurveTo(l.x1,-l.y1,l.x2,-l.y2,l.x,-l.y)}}return a.subPaths.forEach(l=>{let c=function(h){if(h.length){let u=h[0];if(u instanceof ps)return u.v1;if(u instanceof zs||u instanceof Go)return u.v0}}(l.curves);c!==void 0&&l.currentPoint.distanceTo(c)>0&&l.lineTo(c.x,c.y)}),{offsetX:o,path:a}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(t,e,i,n){let r=this.getCharWidth(" ",i),s=t[e];if(s){let a=this.countSpaces(s.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(n.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-a*r))/a}return r}countSpaces(t){return(t.match(/ /g)||[]).length}},Si("text"),Yt();var XV=null;function sB(){return XV}function nJ(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&Gc.traverseModuleInstances(t,i.id,(n,r,s)=>{for(let a of s)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ii();var hy=(t,e)=>{let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)},J2=t=>t*(Math.PI/180),cy=new Map,Sb=(t,e,i)=>{let n,r=e.split(/[ ,]+/g);for(let s=0;s<r.length;s+=1)n=r[s],t.addEventListener?t.addEventListener(n,i,!1):t.attachEvent&&t.attachEvent(n,i)},Mb=(t,e,i)=>{let n,r=e.split(/[ ,]+/g);for(let s=0;s<r.length;s+=1)n=r[s],t.removeEventListener?t.removeEventListener(n,i):t.detachEvent&&t.detachEvent(n,i)},$V=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),aB=()=>{if(!(typeof window>"u"))return{x:window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},tM=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},eM=(t,e,i)=>{let n=YV(t);for(let r in n)if(Object.prototype.hasOwnProperty.call(n,r))if(typeof e=="string")n[r]=e+" "+i;else{let s="";for(let a=0,o=e.length;a<o;a+=1)s+=e[a]+" "+i+", ";n[r]=s.slice(0,-2)}return n},YV=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},iM=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},RT=(t,e)=>{if(t.length)for(let i=0,n=t.length;i<n;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(ZV="ontouchstart"in window,KV=!!window.PointerEvent,QV=!!window.MSPointerEvent);var ZV,KV,QV,$d,oB={start:"mousedown",move:"mousemove",end:"mouseup"},Qf={};function mc(){}KV?$d={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:QV?$d={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:ZV?($d={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Qf=oB):$d=oB,mc.prototype.on=function(t,e){var i,n=this,r=t.split(/[ ,]+/g);n._handlers_=n._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],n._handlers_[i]=n._handlers_[i]||[],n._handlers_[i].push(e);return n},mc.prototype.off=function(t,e){var i=this;return i._handlers_=i._handlers_||{},t===void 0?i._handlers_={}:e===void 0?i._handlers_[t]=null:i._handlers_[t]&&i._handlers_[t].indexOf(e)>=0&&i._handlers_[t].splice(i._handlers_[t].indexOf(e),1),i},mc.prototype.trigger=function(t,e){var i,n=this,r=t.split(/[ ,]+/g);n._handlers_=n._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],n._handlers_[i]&&n._handlers_[i].length&&n._handlers_[i].forEach(function(a){a.call(n,{type:i,target:n},e)})},mc.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,n)=>{let r={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&Object.prototype.hasOwnProperty.call(n,s)?r[s]=n[s]:Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s]);return r})(e.options,t))},mc.prototype.bindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[e]=function(){typeof i["on"+e]=="function"?i["on"+e].apply(i,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},Sb(t,$d[e],i._domHandlers_[e]),Qf[e]&&Sb(t,Qf[e],i._domHandlers_[e]),i},mc.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},Mb(t,$d[e],i._domHandlers_[e]),Qf[e]&&Mb(t,Qf[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var N3=mc;function Nn(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Nn.id,Nn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Nn.prototype=new N3,Nn.constructor=Nn,Nn.id=0,Nn.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Nn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let r=YV("borderRadius");for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(r[s]="50%");return r})(),i=eM("transition","opacity",t),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},iM(n.el,i),this.options.shape==="circle"&&iM(n.back,e),iM(n.front,e),this.applyStyles(n),this},Nn.prototype.applyStyles=function(t){for(var e in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,e))for(var i in t[e])this.ui[e].style[i]=t[e][i];return this},Nn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Nn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Nn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null},Nn.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof t=="function"&&t.call(this)},e.options.fadeTime)),e},Nn.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var i=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=i,typeof t=="function"&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let i=e.options.restJoystick,n={};n.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,n.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,n)}return e},Nn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var n=i.options.fadeTime+"ms",r={};r.front=eM("transition",["top","left"],n);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(r),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Nn.prototype.restCallback=function(){var t=this,e={};e.front=eM("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Nn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Nn.prototype.computeDirection=function(t){var e,i,n,r=t.angle.radian,s=Math.PI/4,a=Math.PI/2;if(r>s&&r<3*s&&!t.lockX?e="up":r>-s&&r<=s&&!t.lockY?e="left":r>3*-s&&r<=-s&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=r>-a&&r<a?"left":"right"),t.lockX||(n=r>0?"up":"down"),t.force>this.options.threshold){var o,l={};for(o in this.direction)Object.prototype.hasOwnProperty.call(this.direction,o)&&(l[o]=this.direction[o]);var c={};for(o in this.direction={x:i,y:n,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(c[o]=!0);if(c.x&&c.y&&c.angle)return t;(!c.x||!c.y)&&this.trigger("plain",t),c.x||this.trigger("plain:"+i,t),c.y||this.trigger("plain:"+n,t),c.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var rJ=Nn;function ln(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=ln.id,ln.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let n=getComputedStyle(i.options.zone.parentElement);return n&&n.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}ln.prototype=new N3,ln.constructor=ln,ln.id=0,ln.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(i){if(i===void 0)return e[0];for(var n=0,r=e.length;n<r;n+=1)if(e[n].identifier===i)return e[n];return!1}},ln.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},ln.prototype.begin=function(){var t=this,e=t.options;if(e.mode==="static"){var i=t.createNipple(e.position,t.manager.getIdentifier());i.add(),t.idles.push(i)}},ln.prototype.createNipple=function(t,e){var i=this,n=i.manager.scroll,r={},s=i.options,a=i.parentIsFlex?n.x:n.x+i.box.left,o=i.parentIsFlex?n.y:n.y+i.box.top;if(t.x&&t.y)r={x:t.x-a,y:t.y-o};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",s.zone.appendChild(l);var c=l.getBoundingClientRect();s.zone.removeChild(l),r=t,t={x:c.left+n.x,y:c.top+n.y}}var h=new rJ(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:e,position:t,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(tM(h.ui.el,r),tM(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h},ln.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},ln.prototype.bindNipple=function(t){var e,i=this,n=function(r,s){e=r.type+" "+s.id+":"+r.type,i.trigger(e,s)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",n),t.on("dir:up dir:right dir:down dir:left",n),t.on("plain:up plain:right plain:down plain:left",n)},ln.prototype.pressureFn=function(t,e,i){var n=this,r=0;clearInterval(n.pressureIntervals[i]),n.pressureIntervals[i]=setInterval(function(){var s=t.force||t.pressure||t.webkitForce||0;s!==r&&(e.trigger("pressure",s),n.trigger("pressure "+e.identifier+":pressure",s),r=s)}.bind(n),100)},ln.prototype.onstart=function(t){var e=this,i=e.options,n=t;return t=$V(t),e.updateBox(),RT(t,function(r){e.actives.length<i.maxNumberOfNipples?e.processOnStart(r):n.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(s){if(Object.values(n.touches).findIndex(function(o){return o.identifier===s})<0){var a=[t[0]];a.identifier=s,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(r))}),e.manager.bindDocument(),!1},ln.prototype.processOnStart=function(t){var e,i=this,n=i.options,r=i.manager.getIdentifier(t),s=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(r,a);o.identifier!==r&&i.manager.removeIdentifier(o.identifier),o.identifier=r;var l=function(c){c.trigger("start",c),i.trigger("start "+c.id+":start",c),c.show(),s>0&&i.pressureFn(t,c,c.identifier),i.processOnMove(t)};if((e=i.idles.indexOf(o))>=0&&i.idles.splice(e,1),i.actives.push(o),i.ids.push(o.identifier),n.mode!=="semi")l(o);else{if(!(hy(a,o.position)<=n.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},ln.prototype.getOrCreate=function(t,e){var i,n=this,r=n.options;return/(semi|static)/.test(r.mode)?(i=n.idles[0])?(n.idles.splice(0,1),i):r.mode==="semi"?n.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=n.createNipple(e,t)},ln.prototype.processOnMove=function(t){var e=this,i=e.options,n=e.manager.getIdentifier(t),r=e.nipples.get(n),s=e.manager.scroll;if((_=>isNaN(_.buttons)?_.pressure!==0:_.buttons!==0)(t)){if(!r)return console.error("Found zombie joystick with ID "+n),void e.manager.removeIdentifier(n);if(i.dynamicPage){var a=r.el.getBoundingClientRect();r.position={x:s.x+a.left,y:s.y+a.top}}r.identifier=n;var o=r.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=r.position.y),i.lockY&&(l.x=r.position.x);var c,h,u=hy(l,r.position),d=((_,b)=>{let x=b.x-_.x,w=b.y-_.y;return(S=>S*(180/Math.PI))(Math.atan2(w,x))})(l,r.position),p=J2(d),f=u/o,g={distance:u,position:l};if(r.options.shape==="circle"?(c=Math.min(u,o),h=((_,b,x)=>{let w={x:0,y:0};return x=J2(x),w.x=_.x-b*Math.cos(x),w.y=_.y-b*Math.sin(x),w})(r.position,c,d)):(h=((_,b,x)=>({x:Math.min(Math.max(_.x,b.x-x),b.x+x),y:Math.min(Math.max(_.y,b.y-x),b.y+x)}))(l,r.position,o),c=hy(h,r.position)),i.follow){if(u>o){let _=l.x-h.x,b=l.y-h.y;r.position.x+=_,r.position.y+=b,r.el.style.top=r.position.y-(e.box.top+s.y)+"px",r.el.style.left=r.position.x-(e.box.left+s.x)+"px",u=hy(l,r.position)}}else l=h,u=c;var m=l.x-r.position.x,y=l.y-r.position.y;r.frontPosition={x:m,y},i.dataOnly||tM(r.ui.front,r.frontPosition);var v={identifier:r.identifier,position:l,force:f,pressure:t.force||t.pressure||t.webkitForce||0,distance:u,angle:{radian:p,degree:d},vector:{x:m/o,y:-y/o},raw:g,instance:r,lockX:i.lockX,lockY:i.lockY};(v=r.computeDirection(v)).angle={radian:J2(180-d),degree:180-d},r.trigger("move",v),e.trigger("move "+r.id+":move",v)}else this.processOnEnd(t)},ln.prototype.processOnEnd=function(t){var e=this,i=e.options,n=e.manager.getIdentifier(t),r=e.nipples.get(n),s=e.manager.removeIdentifier(r.identifier);!r||(i.dataOnly||r.hide(function(){i.mode==="dynamic"&&(r.trigger("removed",r),e.trigger("removed "+r.id+":removed",r),e.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(e.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),e.trigger("end "+r.id+":end",r),e.ids.indexOf(r.identifier)>=0&&e.ids.splice(e.ids.indexOf(r.identifier),1),e.actives.indexOf(r)>=0&&e.actives.splice(e.actives.indexOf(r),1),/(semi|static)/.test(i.mode)?e.idles.push(r):e.nipples.indexOf(r)>=0&&e.nipples.splice(e.nipples.indexOf(r),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[s.id]=s.identifier))},ln.prototype.onDestroyed=function(t,e){var i=this;i.nipples.indexOf(e)>=0&&i.nipples.splice(i.nipples.indexOf(e),1),i.actives.indexOf(e)>=0&&i.actives.splice(i.actives.indexOf(e),1),i.idles.indexOf(e)>=0&&i.idles.splice(i.idles.indexOf(e),1),i.ids.indexOf(e.identifier)>=0&&i.ids.splice(i.ids.indexOf(e.identifier),1),i.manager.removeIdentifier(e.identifier),i.manager.unbindDocument()},ln.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(i){i.destroy()}),t.pressureIntervals)Object.prototype.hasOwnProperty.call(t.pressureIntervals,e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off(),t.pressureIntervals={},t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.manager=null};var sJ=ln;function Mn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=aB(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var n;e.collections.forEach(function(r){r.forEach(function(s){n=s.el.getBoundingClientRect(),s.position={x:e.scroll.x+n.left,y:e.scroll.y+n.top}})})};return e._onResize=function(){(n=>{cy.has(n)&&clearTimeout(cy.get(n)),cy.set(n,setTimeout(function(){cy.delete(n),n()},100))})(i)},e._onScroll=function(){e.scroll=aB()},e.collections}Mn.prototype=new N3,Mn.constructor=Mn,Mn.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var i;return t.collections.every(function(n){return!(i=n.get(e))}),i}},Mn.prototype.create=function(t){return this.createCollection(t)},Mn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,Sb(window,"resize",t._onResize),Sb(window,"scroll",t._onScroll))},Mn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,Mb(window,"resize",t._onResize),Mb(window,"scroll",t._onScroll))},Mn.prototype.createCollection=function(t){var e=this,i=new sJ(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},Mn.prototype.bindCollection=function(t){var e,i=this,n=function(r,s){e=r.type+" "+s.id+":"+r.type,i.trigger(e,s)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",n),t.on("dir:up dir:right dir:down dir:left",n),t.on("plain:up plain:right plain:down plain:left",n)},Mn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},Mn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},Mn.prototype.getIdentifier=function(t){var e;return t?(e=t.identifier===void 0?t.pointerId:t.identifier)===void 0&&(e=this.latest||0):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},Mn.prototype.removeIdentifier=function(t){var e={};for(var i in this.ids)if(this.ids[i]===t){e.id=i,e.identifier=this.ids[i],delete this.ids[i];break}return e},Mn.prototype.onmove=function(t){return this.onAny("move",t),!1},Mn.prototype.onend=function(t){return this.onAny("end",t),!1},Mn.prototype.oncancel=function(t){return this.onAny("end",t),!1},Mn.prototype.onAny=function(t,e){var i,n=this,r="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=$V(e);var s=function(a,o,l){l.ids.indexOf(o)>=0&&(l[r](a),a._found_=!0)};return RT(e,function(a){i=n.getIdentifier(a),RT(n.collections,s.bind(null,a,i)),a._found_||n.removeIdentifier(i)}),!1},Mn.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.unbindWindowEvents(),t.ids={},t.index=0,t.collections.forEach(function(e){e.destroy()}),t.collections=[],t.off()},Mn.prototype.onDestroyed=function(t,e){var i=this;if(i.collections.indexOf(e)<0)return!1;i.collections.splice(i.collections.indexOf(e),1),i.collections.length===0&&i.unbindWindowEvents()};var aJ=Mn,rp=null;function lB(){return rp||(rp=new aJ),rp}var oJ={create:function(t){return lB().create(t)},destroy:function(){rp&&(rp.destroy(),rp=null)},get factory(){return lB()}},lJ=oJ;ii(),Yt(),et(),Hs(),Wr(),Yt();var JV=null;function nM(){return JV}var tj,rM,hJ=new Promise(t=>{tj=t});function cJ(t){return rM||(rM=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.42/build",i=import("./physics.js"),[n,r]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(s=>s.arrayBuffer())]);await n.init(r),tj(n)}(),rM)}function ej(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,n=e[4]**2+e[5]**2+e[6]**2,r=e[8]**2+e[9]**2+e[10]**2,s=e[0]**2+e[4]**2+e[8]**2,a=e[1]**2+e[5]**2+e[9]**2,o=e[2]**2+e[6]**2+e[10]**2,l=1e-8;return i<l||n<l||r<l||s<l||a<l||o<l}function Vo(t,e){let i=new Gt;if(e&&ej(e))return i.setAttribute("position",new Nt([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new Nt([],3)),i.setIndex([]),i;let{positions:n,triIndices:r}=e3(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new Nt(n,3)),i.setIndex(r),e&&i.applyMatrix4(e),i}Li(),Wr(),ke(),p3(),et(),et(),Mp(),qg();var Ge,dJ=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=Rn(e,e.actions,n,r,s,i),this.target=e.target}disconnect(){rr(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>e.play()),this.actions.Animation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},hB=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.page=n,this.currentIntersectedObjects=[],this.actions=Rn(e,e.actions,n,r,s,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=n.scene.find(a);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(t){return this.target==="all"||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){rr(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};Li(),hJ.then(t=>Ge=t);var Sn=new C,Is=new qt,Dl=new C,cB=(new xi(0,0,0,"YXZ"),new xi(0,0,0,"XYZ")),ia=new C,sM=new C,aM=new C(1,1,1),Yd=new qt,dy=new At,dB=new At,uJ={type:"updateMatrix"},uB=new qt,oM=new vr,lM=.01,IT={type:"beginEvent",eventName:"Collision"},pJ={type:"beginEvent",eventName:"Trigger"},Eb=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.hiddenMatrix!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function Zd(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(Mc(t)?t.object:t)}var fJ=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==Ge.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,n,r]=this.rigidBodyToMesh.get(e.handle);if(Sn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Is.copy(e.rotation()),i.matrixWorld.compose(Sn,Is,n),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(uJ),r){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let a of s.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,n)=>{if(n===!1)return;let r,s;if(this.sensorToTriggerEvent[e]?(r=this.sensorToTriggerEvent[e],s=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(r=this.sensorToTriggerEvent[i],s=this.sharedGameControlGlobals.colliderToEntity.get(e)),r&&s&&r.isValidTriggeringObject(s))r.dispatch();else{for(let a=this.sharedGameControlGlobals.createdObjects.length-1;a>=0;a--){let o=this.sharedGameControlGlobals.createdObjects[a];if(o.userData.hasCollisionDestroy&&(o.rigidBody?.collider(0).handle===e||o.rigidBody?.collider(0).handle===i)){this.sharedGameControlGlobals.createdObjects.splice(a,1),o.removeFromParent();let l=o.rigidBody;requestAnimationFrame(()=>{o.rigidBody===l&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(l),o.rigidBody=void 0)});break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let a=this.sharedGameControlGlobals.colliderToEntity.get(i),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,i)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,e)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let h of o)h.data.target==="scene"&&this.dispatchCollisionEvent(h,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),c=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(c!==void 0)for(let h of c)h.data.target==="scene"&&this.dispatchCollisionEvent(h,l,i)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events){if(i.data.disabled===!0)continue;let n=i.data.actions?.find(r=>r.data.type==="Destroy")?.data;if(n)for(let r of n.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let n of i.data.objects){let r=this.page.scene.find(n);r&&(r.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return e===void 0&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(nM()===null)return void Gn("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let n,r=i instanceof tp,s=og(i);if(Bu(i)||r||s)return;n=Mc(i)?i.object:i;let a=n.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=n.userData.hasDestroy===!0,c=n.userData.hasDrag===!0;if(Eb(a)||l||c||n.dataPatched.events.some(h=>h.data.disabled!==!0&&(h.data.type==="GameControl"||h.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let h=o.getAttribute("position");if(h!==void 0&&h.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(h),h.version,o.index!==null?this._staticBVHIdOf(o.index):-1,o.index!==null?o.index.version:-1);for(let u of i.matrixWorld.elements)e.push(u)}}return!!Zd(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((s,a)=>s===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let n=Sc(t.map(s=>Vo(s.geometry,s.matrixWorld)),!1),r=new(nM())(n);this._staticBVHCache={signature:e,bvh:r},this.sharedGameControlGlobals.staticMeshBVH=r}}addRigidBody(t,e,i){if(ej(t.matrixWorld))return;let n=[],r="geometry"in t?t.geometry:void 0,s=e.dataPatched;if(r?.getAttribute("position")!==void 0&&n.push(Vo(r,t.shearScale)),s.physics.fusedBody){let a=this.gatherChildrenGeom(t,n);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&s.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(n.length>0){let a,o=!1,l=!i.fromCreate&&s.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Ge.RigidBodyDesc.dynamic(),a.setLinearDamping(s.physics.damping).setAngularDamping(s.physics.damping).setAdditionalMass(1e-9).setGravityScale(s.physics.gravityScale).enabledRotations(...s.physics.enabledRotation).enabledTranslations(...s.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Ge.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Ge.RigidBodyDesc.fixed();let c=Sc(n);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(Sn,Is,Dl),t.position0=Sn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Is.clone(),Sn.divideScalar(this.pixelsPerMeter),a.setTranslation(Sn.x,Sn.y,Sn.z).setRotation(Is),r?c?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):c?.scale(Dl.x/this.pixelsPerMeter,Dl.y/this.pixelsPerMeter,Dl.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),u=!(s.geometry===void 0||s.geometry.type==="SubdivGeometry"||s.geometry.type==="NonParametricGeometry"||s.geometry.type==="BooleanGeometry"||s.geometry.type==="VectorGeometry"||s.geometry.type==="StarGeometry"||s.geometry.type==="RectangleGeometry"||s.geometry.type==="EllipseGeometry"||s.geometry.type==="TriangleGeometry"||s.geometry.type==="TorusGeometry"||s.geometry.type==="HelixGeometry");try{this.addCollider(h,s.physics,c,e,u)}catch{try{this.addCollider(h,s.physics,c,e,!1)}catch(d){console.error(d)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[t,Dl.clone(),s.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(h.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,h,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=h}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(Vo(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Sc(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(nM())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,n,r=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let s;i&&(s=e.colliderType==="trimesh"?Ge.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Ge.ColliderDesc.convexMesh(i.getAttribute("position").array,r?i.getIndex().array:void 0)),s.setFrictionCombineRule(Ge.CoefficientCombineRule.Average).setRestitutionCombineRule(Ge.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(s,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,n),this.sharedGameControlGlobals.entityToCollisionEvents[n.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Ge.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Zd(t);return(n,r)=>{if(r===0)return;if(i&&n.parent===t)return!0;let s;if(Bu(n)){if(!n.objectForSample)return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(n.objectForSample.dataPatched.physics.fusedBody)return;s=n.object}else if(Mc(n))s=n.object;else if(s=n,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;r===1?t.hasNonUniformScale?n.matrixWorld.multiplyMatrices(t.shearScale,n.hiddenMatrix):n.matrixWorld.copy(n.hiddenMatrix):n.matrixWorld.multiplyMatrices(n.parent.matrixWorld,n.hiddenMatrix),n.matrixWorld.multiply(n.matrix);let o=n.geometry;return o?.getAttribute("position")!==void 0&&e.push(Vo(o,n.matrixWorld)),!!Zd(n)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(a=>{for(let o of a.dataPatched.events)if(o.data.disabled===!1&&o.data.type==="Trigger")return this.needsCollisionDetection=!0,!0});let n=sB();if(n!==null?i=n.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Gn("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:c,hoverRotatePanMode:h}=this.eventManager.publish.orbitControls;(a||o||l||c||h!==0)&&(this.orbitControls=new EV(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let r=this.renderer.domElement.width/this.renderer.getPixelRatio(),s=this.renderer.domElement.height/this.renderer.getPixelRatio();sB()?.createJoysticks(this,r,s),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Ge.World(new Ge.Vector3(0,this.gravity,0)),this.events=new Ge.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(Bu(a)){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(Mc(a))o=a.object;else{if(og(a)||Hc(a)||a instanceof tp)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,c=o.dataPatched;for(let m of c.events)m.data.disabled!==!0&&m.data.type==="GameControl"&&(l=m.data);if(!c.physics||(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled))return!0;a.updateMatrixWorldRigid();let h=Eb(c),u=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let m of c.events)if(m.data.disabled!==!0){if(m.data.type==="Collision"){u=!0;let y=new dJ(m.id,m.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(v=>v.id!==m.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(m.data.type==="Follow"){f=!0;let y=m.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(l!==void 0){let m=Ge.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Sn,Is,Dl),a.position0=Sn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Is.clone(),Sn.divideScalar(this.pixelsPerMeter),m.setTranslation(Sn.x,Sn.y,Sn.z).setRotation(Is);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(m);a.rigidBody=v,y=l.collider.type==="sphere"?Ge.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Ge.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Ge.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(Ge.CoefficientCombineRule.Average).setDensity(c.physics.density).setFriction(c.physics.friction).setRestitution(0).setRestitutionCombineRule(Ge.CoefficientCombineRule.Min);let _=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(_.handle,o),Sn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Dl.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),_.setTranslationWrtParent(Sn);let b=new qt().setFromEuler(new xi().setFromVector3(new C().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));_.setRotationWrtParent(b),_.setActiveEvents(Ge.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else c.physics.rigidBody==="dynamic"||h||f||d||p||u?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,c.physics.fusedBody)):(g&&t.push(Vo(g,a.matrixWorld)),c.physics.fusedBody&&!Zd(a)&&a.traverseObject((m,y)=>{if(y===0)return;let v;if(Bu(m)){if(!m.objectForSample)return m.object.dataPatched.physics.fusedBody===!0&&m.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(m.objectForSample.dataPatched.physics.fusedBody)return;v=m.object}else{if(og(m)||Hc(m)||m instanceof tp)return;if(Mc(m))v=m.object;else if(v=m,v.dataPatched.cloner?.hideBase)return!0}let _=v.dataPatched;if(_.physics.enabled==="visibility"?!_.visible:!_.physics.enabled)return!0;let b=m.geometry;return b?.getAttribute("position")!==void 0&&t.push(Vo(b,m.matrixWorld)),!!Zd(m)||void 0}),this.generateSensorColliderDescs(o,c.physics.fusedBody,e));return!(c.physics?.fusedBody!==!0&&!l&&!Zd(a))||void 0}),t.length===0)return;let i=Sc(t),n=i.getIndex().count>0;if(!n&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=Ge.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r);if(n){let a=Ge.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Ge.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Ge.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let i=new hB(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),n=new At().compose(ia.fromArray(e.data.position.map(r=>typeof r=="number"?r:0)),Yd.setFromEuler(cB.fromArray(e.data.rotation.map(r=>typeof r=="number"?r:0))),aM);if(e.data.triggerZone==="box"){let r=new ci;r.min.fromArray(e.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),r.max.fromArray(e.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([r,n,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,n,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):this.initializationCounter===2&&this.gameControl&&(e=!this.gameControl.update(t)&&e),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(t===0)e=this.stepPhysics()&&e;else{let n=t/1e3;n<i&&n>.55*i&&(n=i),this.accumulator+=n;let r=performance.now(),s=0,a=6;for(;this.accumulator>=i&&s<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,s++,!(performance.now()-r>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(Sn,Is,Dl);let e=t;e.prevQ===void 0?(e.prevQ=Is.clone(),e.prevT=Sn.clone()):(e.prevQ.copy(Is),e.prevT.copy(Sn))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,n]=this.fixedBodiesToWatch[t];(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(n)||(i.setBodyType(Ge.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1))}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(t===void 0)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),n=t.translation(),r=Math.hypot(i.x,i.z);for(let s=0;s<t.numColliders();s++){let a=t.collider(s);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let c=l.translation(),h=-1/0,u=0,d=0;if(e.contactPair(a,o,y=>{let v=y.normal(),_=v.x*(c.x-n.x)+v.y*(c.y-n.y)+v.z*(c.z-n.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let b=_*v.x,x=_*v.z,w=Math.hypot(b,x);if(w<1e-4)return;let S=(i.x*b+i.z*x)/w;S>h&&(h=S,u=b/w,d=x/w)}),h===-1/0)return;let p=i.x*u+i.z*d;if(p<-lM)return;let f=l.linvel();if(r>lM&&p>lM){let y=f.x*u+f.z*d;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:u*v,y:f.y,z:d*v},!0)}let g=f.x*u+f.z*d-Math.max(0,p);if(g<=0)return;let m=.5*g;l.setLinvel({x:f.x-u*m,y:f.y,z:f.z-d*m},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let t of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(t),t.rigidBody.setNextKinematicTranslation(Sn.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(Is);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)t.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let n,r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let s of e.cloner.children)if(s.rigidBody===r){n=s;break}}t.dispatch(n),e.dispatchEvent(IT)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let n=dB.copy(t.matrixWorld).invert();t.traverseEntity((r,s)=>{if(e===!1&&s===1)return!0;for(let a of r.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new hB(a.id,a.data,r,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Ge.ColliderDesc.cuboid(...a.data.size.map(c=>(typeof c=="number"?c:1)/(2*this.pixelsPerMeter))):Ge.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Ge.ActiveEvents.COLLISION_EVENTS),ia.fromArray(a.data.position.map(c=>typeof c=="number"?c:0)),Yd.setFromEuler(cB.fromArray(a.data.rotation.map(c=>typeof c=="number"?c:0))),dy.compose(ia,Yd,aM).premultiply(r.matrixWorld),i?(dy.decompose(ia,Yd,sM),o.setActiveCollisionTypes(Ge.ActiveCollisionTypes.KINEMATIC_FIXED|Ge.ActiveCollisionTypes.DYNAMIC_FIXED)):(dy.premultiply(n).decompose(ia,Yd,sM),t.rigidBody.bodyType()===Ge.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Ge.RigidBodyType.Fixed?o.setActiveCollisionTypes(Ge.ActiveCollisionTypes.KINEMATIC_FIXED|Ge.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Ge.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Ge.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),ia.divideScalar(this.pixelsPerMeter),o.setTranslation(ia.x,ia.y,ia.z),o.setRotation(Yd),i)i.push([o,l]);else{let c=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[c.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,n,r,s]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(r===o||s.isValidTriggeringObject(Be.is(o)?o:o.object)===!1)continue;let l=dB.copy(r.matrixWorld).decompose(ia,uB,sM).compose(ia,uB,aM).multiply(n),c=dy.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof ci?t=h.intersectsBox(i,c):(oM.radius=i,oM.center.setFromMatrixPosition(c),t=h.intersectsSphere(oM)),t?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),r.dispatchEvent(pJ)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(u=>u!==o)}}}};Ep(),et(),tb(),Ye(),bh();var hM=.02,pB=new C,fB=new C,mJ=new C,Mr=new C,Do=new C,Kd=new C,cM=new At,mB=new At,gJ=new At,ds=new qt,sc=new qt,Qd=new xi(0,0,0,"YXZ"),vJ=new C(1,0,0),Fa=new C(0,1,0),yJ=new C(0,0,1),gB=new C(1,1,1),vB=[],yB=t=>vB[t]??(vB[t]=new C),dM=new C,_J=new C,bJ=new C,xJ=new C,_B=new qt,wJ=new C,bB=new qt,Qn=new vs,Os=new ci,SJ={type:"requestRender"},MJ={type:"updateMatrix"},OT=class extends Vn{constructor(t,e,i,n,r,s,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=n,this.controlsManager=r,this.cameraFollow=s,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new At,this.target0=new C,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new xi(0,0,0,"YXZ"),this.position0Cam=new C,this.quat0Cam=new qt,this.scale0Cam=new C,this.hiddenMatrix0Cam=new At,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new vs(new C(0,-40,0),new C(0,40,0)),matrix:new At,position:new C,rotation:new qt},this.euler=new xi(0,0,0,"YXZ"),this.eulerDelta=new C,this.lastPosition=new C,this.lastCameraQuaternion=new qt,this.lastCameraPosition=new C,this.PI_2=Math.PI/2,this.prevMouse=new it,this.velocityTarget=new C,this.velocity=new C,this.directionXZ=new C,this.rotVelocityStick=new C,this.rotVelocityTarget=new C,this.rotVelocity=new C,this.rotDirection=new C,this.nonColliderRotOffset=new At,this.nonColliderPosOffset=new At,this.firstPointerId=-1,this.rot=new C,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new At,this.objectToTarget=new C,this.objectToTarget0=new C,this.objectToCamXZ=new C,this.objectToCamXZ0=new C,this.targetToCamera=new C,this.targetToCamera0=new C,this.cameraPolarAxis0=new C,this.targetPos=new C,this.targetQuat=new qt,this.lerpFactorPos=new C().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new qt,this.objXZQuatInv=new qt,this.objXZRotMat=new At,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new C,this.pushedVelocity=new C,this.groundYRotation=0,this.objectRealQuat=new qt,this.colliderWorldQuat=new qt,this.groundNormal=new C,this.groundTilt=new qt,this.groundTiltInv=new qt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new C,this.quaternion=new qt,this.scale=new C,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!ss&&!TE&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(TE&&hF<15.5&&!ss?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?OT.isLocked=!0:OT.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let y=f.axes[m];g===0?m===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=r.sharedGameControlGlobals,t===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let c=this.euler0.clone(),h=c.y;if(this.objectRealQuat.copy(this.quaternion),c.y=0,this.quaternion.setFromEuler(c),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),c.set(0,h,0),this.quaternion.setFromEuler(c),this.rot.setFromEuler(c),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f,g=new C(0,0,-1).applyQuaternion(this.camera.quaternion),m=new C().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(g.y)<1e-6?(m.y=0,g.y=0,f=m.projectOnVector(g)):f=m.y/g.y>0?g.multiplyScalar(m.y/g.y):g.multiplyScalar(m.length()),this.targetToCamera0.copy(f).negate();let y=this.camera.position.clone().add(f);this.objectToTarget0.subVectors(y,this.position);let v=new xi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof vn&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??Yu.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??Yu.defaultData.usePhysics,this.jumpPower=20*i.jumpPower,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??q_.defaultDataThirdPerson.orientWith,this.slopeThresh=65*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*hM/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*hM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*hM/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let u=new C().fromArray(i.collider.position.map(f=>typeof f=="number"?f:0)),d=new qt().setFromEuler(new xi().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(u).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(u,d,gB),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let f=new Vt;f.push({fi:0,data:{...Ki.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Ki.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=Ek({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new wi(YC.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(t=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let e=new xi().setFromQuaternion(this.quaternion,"YXZ"),i=e.y;this.objectRealQuat.copy(this.quaternion),e.y=0,this.quaternion.setFromEuler(e),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),e.set(0,i,0),this.quaternion.setFromEuler(e),this.rot.setFromEuler(e),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof vn?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let t=this.data,e=this.sharedAssets;t.gameActions!==void 0&&(this.actions={},W_.list.forEach(i=>{this.actions[i]=Rn({...t,disabled:!1,type:"GameControl"},t.gameActions[i],this.page,e,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),rr(this.actions.idle),rr(this.actions.move),rr(this.actions.run),rr(this.actions.jump)}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].Transition.forEach(e=>{e.play()}),this.actions[t].Animation.forEach(e=>{e.play(this.initialAction===!1)}),this.actions[t].TimelineAnimation.forEach(e=>{e.play()}),this.actions[t].Create.forEach(e=>{e.dispatchStart()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("start")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].Transition.forEach(e=>{e.stop(),e.object.currentState!==null&&e.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[t].TimelineAnimation.forEach(e=>{e.stop()}),this.actions[t].Create.forEach(e=>{e.dispatchStop()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("stop")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Mr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(t){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let e=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*e,n=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Do.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*e,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0),a.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let o=a.collider.parent(),l=o!==null&&o.isKinematic()?o:null,c=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&c?.userData.isFollowingObj!==this.object.uuid){let h=this.object.getWorldPosition(Mr).add(this.collider.position).divideScalar(this.pixelsPerMeter),u=l.velocityAtPoint(h);this.groundVelocity.set(u.x,u.y,u.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=l.angvel().y*e}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=Mr.subVectors(this.path[1],this.position),o=Do.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let r=mJ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Do.copy(r);s.y=0,r.set(0,r.y,s.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let s=Mr;this.camera.getWorldDirection(s);let a=Kd.copy(Fa).multiplyScalar(s.dot(Fa));s.sub(a);let o=Do.copy(this.directionXZ);o.x*=-1,this.rot.y=s.angleTo(o)*(s.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Qd.setFromVector3(this.rot),this.moveMode==="walk"&&(Qd.x=0),r.applyEuler(Qd),n&&(sc.setFromUnitVectors(Fa,this.groundNormal),r.applyQuaternion(sc)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(dM,_B,_J);let o=this.object.getWorldPosition(bJ).add(this.collider.position).sub(dM);bB.copy(a.prevQ).invert().premultiply(_B);let l=Kd.subVectors(dM,a.prevT).add(xJ.copy(o).applyQuaternion(bB).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),c=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Mr.copy(r).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let h=Be.is(a)?a:a.object;if(c!==null&&this.lastHitObj!==h){let u;a instanceof ys&&(u=a);let d=this.sharedGameControlGlobals.entityToCollisionEvents[h.uuid];if(d)for(let p of d)p.data.target==="character"&&(p.dispatch(u),h.dispatchEvent(IT));this.lastHitObj=h}c!==null&&(Math.abs(l.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=l.x),Math.abs(l.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=l.y),Math.abs(l.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=l.z),yB(s++).copy(c.normal1).applyQuaternion(a.quaternion))}if(s>0){for(let a=0;a<s;a++){let o=yB(a),l=o.dot(r);l<0&&r.addScaledVector(o,-l)}r.add(this.pushedVelocity)}else r.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(e),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*e,this.euler.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*e),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Fa,this.euler.y-this.euler0.y);let s=Do.copy(this.objectToCamXZ).normalize(),a=Kd.copy(r).multiplyScalar(e);a.y=0;let o=a.sub(Mr.copy(s).multiplyScalar(a.dot(s))).cross(s).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Ot.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Ot.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Ot.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Qd.copy(this.euler),Qd.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Qd)),ds.setFromAxisAngle(vJ,this.rot.x),sc.setFromAxisAngle(Fa,this.rot.y),sc.multiply(ds),ds.setFromAxisAngle(yJ,this.rot.z),sc.multiply(ds),this.quaternion.copy(sc),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Do.copy(r).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new C;for(let h=0;h<5;h++){let u=s.length(),d=Kd.copy(s).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,d,this.object.rigidBody.collider(0).shape,0,u,!1,12,void 0,void 0,this.object.rigidBody),a===null){h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(s);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let v of y)if(v.data.target==="character"){let _,b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(a.collider.handle))._parent;if(p.cloner){for(let x of p.cloner.children)if(x.rigidBody===b){_=x;break}}v.dispatch(_),p.dispatchEvent(IT)}}}let f=pB.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),g=fB.copy(d).multiplyScalar(a.time_of_impact).dot(f),m=a.time_of_impact;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=a.time_of_impact*(g-this.offset)/g,o.addScaledVector(d,m)),s.copy(d).multiplyScalar(u-m),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=Kd.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let _=y.add(v);_.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(_,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);b!==null&&b.time_of_impact===0&&(f.y=0,f.normalize())}s.addScaledVector(f,-s.dot(f))}}this.position.addScaledVector(o,this.pixelsPerMeter),Mr.copy(this.position).divideScalar(this.pixelsPerMeter),ds.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,c=l!==void 0&&wJ.copy(Mr).sub(l.translation()).lengthSq()>1;l!==void 0&&(c?(l.setTranslation(Mr,!0),l.setRotation(ds,!0)):(l.setNextKinematicTranslation(Mr),l.setNextKinematicRotation(ds)))}else{let s=this.onObject?1:5,a=r.multiplyScalar(e/s);for(let o=0;o<s;o++)this.position.add(a),this.collisionAdjustment(e/s)}else this.position.addScaledVector(r,e);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),a=this.targetToCamera.add(s);cM.lookAt(a,s,Fa).setPosition(a),cM.decompose(this.targetPos,this.targetQuat,Mr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Ot.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Ot.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(MJ),!(this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)||(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(SJ),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=ds.setFromAxisAngle(Fa,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Ot.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e),t=this.cameraXAxis==="Limit"?Ot.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):Ot.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let n=sc.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(n)}groundTiltAdjustment(t){180*Fa.angleTo(t)/Math.PI<15||180*Fa.angleTo(t)/Math.PI>85?ds.identity():ds.setFromUnitVectors(Fa,t),this.groundTilt.slerp(ds,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=fB.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=cM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mr,ds,Do).compose(Mr,ds,gB);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(r=>{if(r===this.object||r.isDescendantOf(this.object)||!r.bvhGeometry||!r.bvhGeometry.boundsTree)return;Os.makeEmpty(),r.updateMatrixWorldRigid();let s=r.matrixWorldRigid,a=mB.copy(s).invert(),o=gJ.copy(mB).multiply(i);Qn.copy(this.collider.segment),Qn.start.applyMatrix4(o),Qn.end.applyMatrix4(o);let l=pB.copy(this.position).applyMatrix4(a);Os.expandByPoint(Qn.start),Os.expandByPoint(Qn.end),Os.min.addScalar(-this.collider.radius),Os.max.addScalar(this.collider.radius),r.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:c=>c.distanceToPoint(Qn.end),intersectsBounds:c=>c.intersectsBox(Os),intersectsTriangle:c=>{let h=Mr,u=Do,d=c.closestPointToSegment(Qn,h,u);if(d<this.collider.radius){let p=this.collider.radius-d,f=u.sub(h).normalize(),g=Kd.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(s).sub(this.position);e.add(m),Qn.start.addScaledVector(f,p),Qn.end.addScaledVector(f,p)}}})}),Os.makeEmpty(),Qn.copy(this.collider.segment),Qn.start.applyMatrix4(i),Qn.end.applyMatrix4(i),Os.expandByPoint(Qn.start),Os.expandByPoint(Qn.end),Os.min.addScalar(-this.collider.radius),Os.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:r=>r.distanceToPoint(Qn.end),intersectsBounds:r=>r.intersectsBox(Os),intersectsTriangle:r=>{let s=Mr,a=Do,o=r.closestPointToSegment(Qn,s,a);if(o<this.collider.radius){let l=this.collider.radius-o,c=a.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(c),e.addScaledVector(c,l),Qn.start.addScaledVector(c,l),Qn.end.addScaledVector(c,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let n=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(n),this.position.add(e)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},ij=OT;ij.isLocked=!1,et(),qg(),Ep(),Mp();var nj,rj,uM,EJ=new Promise(t=>{nj=t});function AJ(t){return uM||(uM=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.42/build";typeof window<"u"&&(rj=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[n,r]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=n.default,a=await s({wasmBinary:r});nj(a)}(),uM)}ii();var sj,Fe,ur,TJ=t=>`
9849
+ `)>=0&&(t-=r),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,n,r){let s=e*t,a=t-Math.abs(this.ascender-this.descender)*n,o=-this.ascender*n-a/2;return r===3?-(i-s-o):r===2?-(.5*i-.5*s-o):o}createPath(t,e,i,n,r){let s=t.getPath(i,-n,r.fontSize,{kerning:!1,letterSpacing:r.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new tJ,o=(t.advanceWidth??1)*e;if(t)for(let l of s.commands){let c=a.currentPath?.currentPoint;if(!c||l.type==="Z"||c.x!==l.x||-c.y!==l.y)switch(l.type){case"M":a.moveTo(l.x,-l.y);break;case"L":a.lineTo(l.x,-l.y);break;case"Q":a.quadraticCurveTo(l.x1,-l.y1,l.x,-l.y);break;case"C":a.bezierCurveTo(l.x1,-l.y1,l.x2,-l.y2,l.x,-l.y)}}return a.subPaths.forEach(l=>{let c=function(h){if(h.length){let u=h[0];if(u instanceof ps)return u.v1;if(u instanceof zs||u instanceof Go)return u.v0}}(l.curves);c!==void 0&&l.currentPoint.distanceTo(c)>0&&l.lineTo(c.x,c.y)}),{offsetX:o,path:a}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(t,e,i,n){let r=this.getCharWidth(" ",i),s=t[e];if(s){let a=this.countSpaces(s.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(n.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-a*r))/a}return r}countSpaces(t){return(t.match(/ /g)||[]).length}},Si("text"),Yt();var XV=null;function sB(){return XV}function nJ(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&Gc.traverseModuleInstances(t,i.id,(n,r,s)=>{for(let a of s)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ii();var hy=(t,e)=>{let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)},J2=t=>t*(Math.PI/180),cy=new Map,Sb=(t,e,i)=>{let n,r=e.split(/[ ,]+/g);for(let s=0;s<r.length;s+=1)n=r[s],t.addEventListener?t.addEventListener(n,i,!1):t.attachEvent&&t.attachEvent(n,i)},Mb=(t,e,i)=>{let n,r=e.split(/[ ,]+/g);for(let s=0;s<r.length;s+=1)n=r[s],t.removeEventListener?t.removeEventListener(n,i):t.detachEvent&&t.detachEvent(n,i)},$V=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),aB=()=>{if(!(typeof window>"u"))return{x:window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},tM=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},eM=(t,e,i)=>{let n=YV(t);for(let r in n)if(Object.prototype.hasOwnProperty.call(n,r))if(typeof e=="string")n[r]=e+" "+i;else{let s="";for(let a=0,o=e.length;a<o;a+=1)s+=e[a]+" "+i+", ";n[r]=s.slice(0,-2)}return n},YV=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},iM=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},RT=(t,e)=>{if(t.length)for(let i=0,n=t.length;i<n;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(ZV="ontouchstart"in window,KV=!!window.PointerEvent,QV=!!window.MSPointerEvent);var ZV,KV,QV,$d,oB={start:"mousedown",move:"mousemove",end:"mouseup"},Qf={};function mc(){}KV?$d={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:QV?$d={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:ZV?($d={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Qf=oB):$d=oB,mc.prototype.on=function(t,e){var i,n=this,r=t.split(/[ ,]+/g);n._handlers_=n._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],n._handlers_[i]=n._handlers_[i]||[],n._handlers_[i].push(e);return n},mc.prototype.off=function(t,e){var i=this;return i._handlers_=i._handlers_||{},t===void 0?i._handlers_={}:e===void 0?i._handlers_[t]=null:i._handlers_[t]&&i._handlers_[t].indexOf(e)>=0&&i._handlers_[t].splice(i._handlers_[t].indexOf(e),1),i},mc.prototype.trigger=function(t,e){var i,n=this,r=t.split(/[ ,]+/g);n._handlers_=n._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],n._handlers_[i]&&n._handlers_[i].length&&n._handlers_[i].forEach(function(a){a.call(n,{type:i,target:n},e)})},mc.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,n)=>{let r={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&Object.prototype.hasOwnProperty.call(n,s)?r[s]=n[s]:Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s]);return r})(e.options,t))},mc.prototype.bindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[e]=function(){typeof i["on"+e]=="function"?i["on"+e].apply(i,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},Sb(t,$d[e],i._domHandlers_[e]),Qf[e]&&Sb(t,Qf[e],i._domHandlers_[e]),i},mc.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},Mb(t,$d[e],i._domHandlers_[e]),Qf[e]&&Mb(t,Qf[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var N3=mc;function Nn(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Nn.id,Nn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Nn.prototype=new N3,Nn.constructor=Nn,Nn.id=0,Nn.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Nn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let r=YV("borderRadius");for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(r[s]="50%");return r})(),i=eM("transition","opacity",t),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},iM(n.el,i),this.options.shape==="circle"&&iM(n.back,e),iM(n.front,e),this.applyStyles(n),this},Nn.prototype.applyStyles=function(t){for(var e in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,e))for(var i in t[e])this.ui[e].style[i]=t[e][i];return this},Nn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Nn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Nn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null},Nn.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof t=="function"&&t.call(this)},e.options.fadeTime)),e},Nn.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var i=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=i,typeof t=="function"&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let i=e.options.restJoystick,n={};n.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,n.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,n)}return e},Nn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var n=i.options.fadeTime+"ms",r={};r.front=eM("transition",["top","left"],n);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(r),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Nn.prototype.restCallback=function(){var t=this,e={};e.front=eM("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Nn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Nn.prototype.computeDirection=function(t){var e,i,n,r=t.angle.radian,s=Math.PI/4,a=Math.PI/2;if(r>s&&r<3*s&&!t.lockX?e="up":r>-s&&r<=s&&!t.lockY?e="left":r>3*-s&&r<=-s&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=r>-a&&r<a?"left":"right"),t.lockX||(n=r>0?"up":"down"),t.force>this.options.threshold){var o,l={};for(o in this.direction)Object.prototype.hasOwnProperty.call(this.direction,o)&&(l[o]=this.direction[o]);var c={};for(o in this.direction={x:i,y:n,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(c[o]=!0);if(c.x&&c.y&&c.angle)return t;(!c.x||!c.y)&&this.trigger("plain",t),c.x||this.trigger("plain:"+i,t),c.y||this.trigger("plain:"+n,t),c.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var rJ=Nn;function ln(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=ln.id,ln.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let n=getComputedStyle(i.options.zone.parentElement);return n&&n.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}ln.prototype=new N3,ln.constructor=ln,ln.id=0,ln.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(i){if(i===void 0)return e[0];for(var n=0,r=e.length;n<r;n+=1)if(e[n].identifier===i)return e[n];return!1}},ln.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},ln.prototype.begin=function(){var t=this,e=t.options;if(e.mode==="static"){var i=t.createNipple(e.position,t.manager.getIdentifier());i.add(),t.idles.push(i)}},ln.prototype.createNipple=function(t,e){var i=this,n=i.manager.scroll,r={},s=i.options,a=i.parentIsFlex?n.x:n.x+i.box.left,o=i.parentIsFlex?n.y:n.y+i.box.top;if(t.x&&t.y)r={x:t.x-a,y:t.y-o};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",s.zone.appendChild(l);var c=l.getBoundingClientRect();s.zone.removeChild(l),r=t,t={x:c.left+n.x,y:c.top+n.y}}var h=new rJ(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:e,position:t,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(tM(h.ui.el,r),tM(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h},ln.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},ln.prototype.bindNipple=function(t){var e,i=this,n=function(r,s){e=r.type+" "+s.id+":"+r.type,i.trigger(e,s)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",n),t.on("dir:up dir:right dir:down dir:left",n),t.on("plain:up plain:right plain:down plain:left",n)},ln.prototype.pressureFn=function(t,e,i){var n=this,r=0;clearInterval(n.pressureIntervals[i]),n.pressureIntervals[i]=setInterval(function(){var s=t.force||t.pressure||t.webkitForce||0;s!==r&&(e.trigger("pressure",s),n.trigger("pressure "+e.identifier+":pressure",s),r=s)}.bind(n),100)},ln.prototype.onstart=function(t){var e=this,i=e.options,n=t;return t=$V(t),e.updateBox(),RT(t,function(r){e.actives.length<i.maxNumberOfNipples?e.processOnStart(r):n.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(s){if(Object.values(n.touches).findIndex(function(o){return o.identifier===s})<0){var a=[t[0]];a.identifier=s,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(r))}),e.manager.bindDocument(),!1},ln.prototype.processOnStart=function(t){var e,i=this,n=i.options,r=i.manager.getIdentifier(t),s=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(r,a);o.identifier!==r&&i.manager.removeIdentifier(o.identifier),o.identifier=r;var l=function(c){c.trigger("start",c),i.trigger("start "+c.id+":start",c),c.show(),s>0&&i.pressureFn(t,c,c.identifier),i.processOnMove(t)};if((e=i.idles.indexOf(o))>=0&&i.idles.splice(e,1),i.actives.push(o),i.ids.push(o.identifier),n.mode!=="semi")l(o);else{if(!(hy(a,o.position)<=n.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},ln.prototype.getOrCreate=function(t,e){var i,n=this,r=n.options;return/(semi|static)/.test(r.mode)?(i=n.idles[0])?(n.idles.splice(0,1),i):r.mode==="semi"?n.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=n.createNipple(e,t)},ln.prototype.processOnMove=function(t){var e=this,i=e.options,n=e.manager.getIdentifier(t),r=e.nipples.get(n),s=e.manager.scroll;if((_=>isNaN(_.buttons)?_.pressure!==0:_.buttons!==0)(t)){if(!r)return console.error("Found zombie joystick with ID "+n),void e.manager.removeIdentifier(n);if(i.dynamicPage){var a=r.el.getBoundingClientRect();r.position={x:s.x+a.left,y:s.y+a.top}}r.identifier=n;var o=r.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=r.position.y),i.lockY&&(l.x=r.position.x);var c,h,u=hy(l,r.position),d=((_,b)=>{let x=b.x-_.x,w=b.y-_.y;return(S=>S*(180/Math.PI))(Math.atan2(w,x))})(l,r.position),p=J2(d),f=u/o,g={distance:u,position:l};if(r.options.shape==="circle"?(c=Math.min(u,o),h=((_,b,x)=>{let w={x:0,y:0};return x=J2(x),w.x=_.x-b*Math.cos(x),w.y=_.y-b*Math.sin(x),w})(r.position,c,d)):(h=((_,b,x)=>({x:Math.min(Math.max(_.x,b.x-x),b.x+x),y:Math.min(Math.max(_.y,b.y-x),b.y+x)}))(l,r.position,o),c=hy(h,r.position)),i.follow){if(u>o){let _=l.x-h.x,b=l.y-h.y;r.position.x+=_,r.position.y+=b,r.el.style.top=r.position.y-(e.box.top+s.y)+"px",r.el.style.left=r.position.x-(e.box.left+s.x)+"px",u=hy(l,r.position)}}else l=h,u=c;var m=l.x-r.position.x,y=l.y-r.position.y;r.frontPosition={x:m,y},i.dataOnly||tM(r.ui.front,r.frontPosition);var v={identifier:r.identifier,position:l,force:f,pressure:t.force||t.pressure||t.webkitForce||0,distance:u,angle:{radian:p,degree:d},vector:{x:m/o,y:-y/o},raw:g,instance:r,lockX:i.lockX,lockY:i.lockY};(v=r.computeDirection(v)).angle={radian:J2(180-d),degree:180-d},r.trigger("move",v),e.trigger("move "+r.id+":move",v)}else this.processOnEnd(t)},ln.prototype.processOnEnd=function(t){var e=this,i=e.options,n=e.manager.getIdentifier(t),r=e.nipples.get(n),s=e.manager.removeIdentifier(r.identifier);!r||(i.dataOnly||r.hide(function(){i.mode==="dynamic"&&(r.trigger("removed",r),e.trigger("removed "+r.id+":removed",r),e.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(e.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),e.trigger("end "+r.id+":end",r),e.ids.indexOf(r.identifier)>=0&&e.ids.splice(e.ids.indexOf(r.identifier),1),e.actives.indexOf(r)>=0&&e.actives.splice(e.actives.indexOf(r),1),/(semi|static)/.test(i.mode)?e.idles.push(r):e.nipples.indexOf(r)>=0&&e.nipples.splice(e.nipples.indexOf(r),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[s.id]=s.identifier))},ln.prototype.onDestroyed=function(t,e){var i=this;i.nipples.indexOf(e)>=0&&i.nipples.splice(i.nipples.indexOf(e),1),i.actives.indexOf(e)>=0&&i.actives.splice(i.actives.indexOf(e),1),i.idles.indexOf(e)>=0&&i.idles.splice(i.idles.indexOf(e),1),i.ids.indexOf(e.identifier)>=0&&i.ids.splice(i.ids.indexOf(e.identifier),1),i.manager.removeIdentifier(e.identifier),i.manager.unbindDocument()},ln.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(i){i.destroy()}),t.pressureIntervals)Object.prototype.hasOwnProperty.call(t.pressureIntervals,e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off(),t.pressureIntervals={},t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.manager=null};var sJ=ln;function Mn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=aB(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var n;e.collections.forEach(function(r){r.forEach(function(s){n=s.el.getBoundingClientRect(),s.position={x:e.scroll.x+n.left,y:e.scroll.y+n.top}})})};return e._onResize=function(){(n=>{cy.has(n)&&clearTimeout(cy.get(n)),cy.set(n,setTimeout(function(){cy.delete(n),n()},100))})(i)},e._onScroll=function(){e.scroll=aB()},e.collections}Mn.prototype=new N3,Mn.constructor=Mn,Mn.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var i;return t.collections.every(function(n){return!(i=n.get(e))}),i}},Mn.prototype.create=function(t){return this.createCollection(t)},Mn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,Sb(window,"resize",t._onResize),Sb(window,"scroll",t._onScroll))},Mn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,Mb(window,"resize",t._onResize),Mb(window,"scroll",t._onScroll))},Mn.prototype.createCollection=function(t){var e=this,i=new sJ(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},Mn.prototype.bindCollection=function(t){var e,i=this,n=function(r,s){e=r.type+" "+s.id+":"+r.type,i.trigger(e,s)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",n),t.on("dir:up dir:right dir:down dir:left",n),t.on("plain:up plain:right plain:down plain:left",n)},Mn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},Mn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},Mn.prototype.getIdentifier=function(t){var e;return t?(e=t.identifier===void 0?t.pointerId:t.identifier)===void 0&&(e=this.latest||0):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},Mn.prototype.removeIdentifier=function(t){var e={};for(var i in this.ids)if(this.ids[i]===t){e.id=i,e.identifier=this.ids[i],delete this.ids[i];break}return e},Mn.prototype.onmove=function(t){return this.onAny("move",t),!1},Mn.prototype.onend=function(t){return this.onAny("end",t),!1},Mn.prototype.oncancel=function(t){return this.onAny("end",t),!1},Mn.prototype.onAny=function(t,e){var i,n=this,r="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=$V(e);var s=function(a,o,l){l.ids.indexOf(o)>=0&&(l[r](a),a._found_=!0)};return RT(e,function(a){i=n.getIdentifier(a),RT(n.collections,s.bind(null,a,i)),a._found_||n.removeIdentifier(i)}),!1},Mn.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.unbindWindowEvents(),t.ids={},t.index=0,t.collections.forEach(function(e){e.destroy()}),t.collections=[],t.off()},Mn.prototype.onDestroyed=function(t,e){var i=this;if(i.collections.indexOf(e)<0)return!1;i.collections.splice(i.collections.indexOf(e),1),i.collections.length===0&&i.unbindWindowEvents()};var aJ=Mn,rp=null;function lB(){return rp||(rp=new aJ),rp}var oJ={create:function(t){return lB().create(t)},destroy:function(){rp&&(rp.destroy(),rp=null)},get factory(){return lB()}},lJ=oJ;ii(),Yt(),et(),Hs(),Wr(),Yt();var JV=null;function nM(){return JV}var tj,rM,hJ=new Promise(t=>{tj=t});function cJ(t){return rM||(rM=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.44/build",i=import("./physics.js"),[n,r]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(s=>s.arrayBuffer())]);await n.init(r),tj(n)}(),rM)}function ej(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,n=e[4]**2+e[5]**2+e[6]**2,r=e[8]**2+e[9]**2+e[10]**2,s=e[0]**2+e[4]**2+e[8]**2,a=e[1]**2+e[5]**2+e[9]**2,o=e[2]**2+e[6]**2+e[10]**2,l=1e-8;return i<l||n<l||r<l||s<l||a<l||o<l}function Vo(t,e){let i=new Gt;if(e&&ej(e))return i.setAttribute("position",new Nt([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new Nt([],3)),i.setIndex([]),i;let{positions:n,triIndices:r}=e3(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new Nt(n,3)),i.setIndex(r),e&&i.applyMatrix4(e),i}Li(),Wr(),ke(),p3(),et(),et(),Mp(),qg();var Ge,dJ=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=Rn(e,e.actions,n,r,s,i),this.target=e.target}disconnect(){rr(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>e.play()),this.actions.Animation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},hB=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.page=n,this.currentIntersectedObjects=[],this.actions=Rn(e,e.actions,n,r,s,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=n.scene.find(a);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(t){return this.target==="all"||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){rr(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};Li(),hJ.then(t=>Ge=t);var Sn=new C,Is=new qt,Dl=new C,cB=(new xi(0,0,0,"YXZ"),new xi(0,0,0,"XYZ")),ia=new C,sM=new C,aM=new C(1,1,1),Yd=new qt,dy=new At,dB=new At,uJ={type:"updateMatrix"},uB=new qt,oM=new vr,lM=.01,IT={type:"beginEvent",eventName:"Collision"},pJ={type:"beginEvent",eventName:"Trigger"},Eb=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.hiddenMatrix!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function Zd(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(Mc(t)?t.object:t)}var fJ=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==Ge.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,n,r]=this.rigidBodyToMesh.get(e.handle);if(Sn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Is.copy(e.rotation()),i.matrixWorld.compose(Sn,Is,n),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(uJ),r){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let a of s.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,n)=>{if(n===!1)return;let r,s;if(this.sensorToTriggerEvent[e]?(r=this.sensorToTriggerEvent[e],s=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(r=this.sensorToTriggerEvent[i],s=this.sharedGameControlGlobals.colliderToEntity.get(e)),r&&s&&r.isValidTriggeringObject(s))r.dispatch();else{for(let a=this.sharedGameControlGlobals.createdObjects.length-1;a>=0;a--){let o=this.sharedGameControlGlobals.createdObjects[a];if(o.userData.hasCollisionDestroy&&(o.rigidBody?.collider(0).handle===e||o.rigidBody?.collider(0).handle===i)){this.sharedGameControlGlobals.createdObjects.splice(a,1),o.removeFromParent();let l=o.rigidBody;requestAnimationFrame(()=>{o.rigidBody===l&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(l),o.rigidBody=void 0)});break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let a=this.sharedGameControlGlobals.colliderToEntity.get(i),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,i)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,e)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let h of o)h.data.target==="scene"&&this.dispatchCollisionEvent(h,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),c=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(c!==void 0)for(let h of c)h.data.target==="scene"&&this.dispatchCollisionEvent(h,l,i)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events){if(i.data.disabled===!0)continue;let n=i.data.actions?.find(r=>r.data.type==="Destroy")?.data;if(n)for(let r of n.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let n of i.data.objects){let r=this.page.scene.find(n);r&&(r.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return e===void 0&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(nM()===null)return void Gn("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let n,r=i instanceof tp,s=og(i);if(Bu(i)||r||s)return;n=Mc(i)?i.object:i;let a=n.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=n.userData.hasDestroy===!0,c=n.userData.hasDrag===!0;if(Eb(a)||l||c||n.dataPatched.events.some(h=>h.data.disabled!==!0&&(h.data.type==="GameControl"||h.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let h=o.getAttribute("position");if(h!==void 0&&h.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(h),h.version,o.index!==null?this._staticBVHIdOf(o.index):-1,o.index!==null?o.index.version:-1);for(let u of i.matrixWorld.elements)e.push(u)}}return!!Zd(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((s,a)=>s===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let n=Sc(t.map(s=>Vo(s.geometry,s.matrixWorld)),!1),r=new(nM())(n);this._staticBVHCache={signature:e,bvh:r},this.sharedGameControlGlobals.staticMeshBVH=r}}addRigidBody(t,e,i){if(ej(t.matrixWorld))return;let n=[],r="geometry"in t?t.geometry:void 0,s=e.dataPatched;if(r?.getAttribute("position")!==void 0&&n.push(Vo(r,t.shearScale)),s.physics.fusedBody){let a=this.gatherChildrenGeom(t,n);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&s.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(n.length>0){let a,o=!1,l=!i.fromCreate&&s.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Ge.RigidBodyDesc.dynamic(),a.setLinearDamping(s.physics.damping).setAngularDamping(s.physics.damping).setAdditionalMass(1e-9).setGravityScale(s.physics.gravityScale).enabledRotations(...s.physics.enabledRotation).enabledTranslations(...s.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Ge.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Ge.RigidBodyDesc.fixed();let c=Sc(n);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(Sn,Is,Dl),t.position0=Sn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Is.clone(),Sn.divideScalar(this.pixelsPerMeter),a.setTranslation(Sn.x,Sn.y,Sn.z).setRotation(Is),r?c?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):c?.scale(Dl.x/this.pixelsPerMeter,Dl.y/this.pixelsPerMeter,Dl.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),u=!(s.geometry===void 0||s.geometry.type==="SubdivGeometry"||s.geometry.type==="NonParametricGeometry"||s.geometry.type==="BooleanGeometry"||s.geometry.type==="VectorGeometry"||s.geometry.type==="StarGeometry"||s.geometry.type==="RectangleGeometry"||s.geometry.type==="EllipseGeometry"||s.geometry.type==="TriangleGeometry"||s.geometry.type==="TorusGeometry"||s.geometry.type==="HelixGeometry");try{this.addCollider(h,s.physics,c,e,u)}catch{try{this.addCollider(h,s.physics,c,e,!1)}catch(d){console.error(d)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[t,Dl.clone(),s.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(h.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,h,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=h}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(Vo(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Sc(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(nM())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,n,r=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let s;i&&(s=e.colliderType==="trimesh"?Ge.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Ge.ColliderDesc.convexMesh(i.getAttribute("position").array,r?i.getIndex().array:void 0)),s.setFrictionCombineRule(Ge.CoefficientCombineRule.Average).setRestitutionCombineRule(Ge.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(s,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,n),this.sharedGameControlGlobals.entityToCollisionEvents[n.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Ge.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Zd(t);return(n,r)=>{if(r===0)return;if(i&&n.parent===t)return!0;let s;if(Bu(n)){if(!n.objectForSample)return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(n.objectForSample.dataPatched.physics.fusedBody)return;s=n.object}else if(Mc(n))s=n.object;else if(s=n,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;r===1?t.hasNonUniformScale?n.matrixWorld.multiplyMatrices(t.shearScale,n.hiddenMatrix):n.matrixWorld.copy(n.hiddenMatrix):n.matrixWorld.multiplyMatrices(n.parent.matrixWorld,n.hiddenMatrix),n.matrixWorld.multiply(n.matrix);let o=n.geometry;return o?.getAttribute("position")!==void 0&&e.push(Vo(o,n.matrixWorld)),!!Zd(n)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(a=>{for(let o of a.dataPatched.events)if(o.data.disabled===!1&&o.data.type==="Trigger")return this.needsCollisionDetection=!0,!0});let n=sB();if(n!==null?i=n.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Gn("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:c,hoverRotatePanMode:h}=this.eventManager.publish.orbitControls;(a||o||l||c||h!==0)&&(this.orbitControls=new EV(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let r=this.renderer.domElement.width/this.renderer.getPixelRatio(),s=this.renderer.domElement.height/this.renderer.getPixelRatio();sB()?.createJoysticks(this,r,s),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Ge.World(new Ge.Vector3(0,this.gravity,0)),this.events=new Ge.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(Bu(a)){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(Mc(a))o=a.object;else{if(og(a)||Hc(a)||a instanceof tp)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,c=o.dataPatched;for(let m of c.events)m.data.disabled!==!0&&m.data.type==="GameControl"&&(l=m.data);if(!c.physics||(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled))return!0;a.updateMatrixWorldRigid();let h=Eb(c),u=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let m of c.events)if(m.data.disabled!==!0){if(m.data.type==="Collision"){u=!0;let y=new dJ(m.id,m.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(v=>v.id!==m.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(m.data.type==="Follow"){f=!0;let y=m.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(l!==void 0){let m=Ge.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Sn,Is,Dl),a.position0=Sn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Is.clone(),Sn.divideScalar(this.pixelsPerMeter),m.setTranslation(Sn.x,Sn.y,Sn.z).setRotation(Is);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(m);a.rigidBody=v,y=l.collider.type==="sphere"?Ge.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Ge.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Ge.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(Ge.CoefficientCombineRule.Average).setDensity(c.physics.density).setFriction(c.physics.friction).setRestitution(0).setRestitutionCombineRule(Ge.CoefficientCombineRule.Min);let _=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(_.handle,o),Sn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Dl.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),_.setTranslationWrtParent(Sn);let b=new qt().setFromEuler(new xi().setFromVector3(new C().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));_.setRotationWrtParent(b),_.setActiveEvents(Ge.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else c.physics.rigidBody==="dynamic"||h||f||d||p||u?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,c.physics.fusedBody)):(g&&t.push(Vo(g,a.matrixWorld)),c.physics.fusedBody&&!Zd(a)&&a.traverseObject((m,y)=>{if(y===0)return;let v;if(Bu(m)){if(!m.objectForSample)return m.object.dataPatched.physics.fusedBody===!0&&m.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(m.objectForSample.dataPatched.physics.fusedBody)return;v=m.object}else{if(og(m)||Hc(m)||m instanceof tp)return;if(Mc(m))v=m.object;else if(v=m,v.dataPatched.cloner?.hideBase)return!0}let _=v.dataPatched;if(_.physics.enabled==="visibility"?!_.visible:!_.physics.enabled)return!0;let b=m.geometry;return b?.getAttribute("position")!==void 0&&t.push(Vo(b,m.matrixWorld)),!!Zd(m)||void 0}),this.generateSensorColliderDescs(o,c.physics.fusedBody,e));return!(c.physics?.fusedBody!==!0&&!l&&!Zd(a))||void 0}),t.length===0)return;let i=Sc(t),n=i.getIndex().count>0;if(!n&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=Ge.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r);if(n){let a=Ge.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Ge.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Ge.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let i=new hB(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),n=new At().compose(ia.fromArray(e.data.position.map(r=>typeof r=="number"?r:0)),Yd.setFromEuler(cB.fromArray(e.data.rotation.map(r=>typeof r=="number"?r:0))),aM);if(e.data.triggerZone==="box"){let r=new ci;r.min.fromArray(e.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),r.max.fromArray(e.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([r,n,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,n,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):this.initializationCounter===2&&this.gameControl&&(e=!this.gameControl.update(t)&&e),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(t===0)e=this.stepPhysics()&&e;else{let n=t/1e3;n<i&&n>.55*i&&(n=i),this.accumulator+=n;let r=performance.now(),s=0,a=6;for(;this.accumulator>=i&&s<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,s++,!(performance.now()-r>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(Sn,Is,Dl);let e=t;e.prevQ===void 0?(e.prevQ=Is.clone(),e.prevT=Sn.clone()):(e.prevQ.copy(Is),e.prevT.copy(Sn))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,n]=this.fixedBodiesToWatch[t];(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(n)||(i.setBodyType(Ge.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1))}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(t===void 0)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),n=t.translation(),r=Math.hypot(i.x,i.z);for(let s=0;s<t.numColliders();s++){let a=t.collider(s);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let c=l.translation(),h=-1/0,u=0,d=0;if(e.contactPair(a,o,y=>{let v=y.normal(),_=v.x*(c.x-n.x)+v.y*(c.y-n.y)+v.z*(c.z-n.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let b=_*v.x,x=_*v.z,w=Math.hypot(b,x);if(w<1e-4)return;let S=(i.x*b+i.z*x)/w;S>h&&(h=S,u=b/w,d=x/w)}),h===-1/0)return;let p=i.x*u+i.z*d;if(p<-lM)return;let f=l.linvel();if(r>lM&&p>lM){let y=f.x*u+f.z*d;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:u*v,y:f.y,z:d*v},!0)}let g=f.x*u+f.z*d-Math.max(0,p);if(g<=0)return;let m=.5*g;l.setLinvel({x:f.x-u*m,y:f.y,z:f.z-d*m},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let t of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(t),t.rigidBody.setNextKinematicTranslation(Sn.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(Is);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)t.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let n,r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let s of e.cloner.children)if(s.rigidBody===r){n=s;break}}t.dispatch(n),e.dispatchEvent(IT)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let n=dB.copy(t.matrixWorld).invert();t.traverseEntity((r,s)=>{if(e===!1&&s===1)return!0;for(let a of r.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new hB(a.id,a.data,r,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Ge.ColliderDesc.cuboid(...a.data.size.map(c=>(typeof c=="number"?c:1)/(2*this.pixelsPerMeter))):Ge.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Ge.ActiveEvents.COLLISION_EVENTS),ia.fromArray(a.data.position.map(c=>typeof c=="number"?c:0)),Yd.setFromEuler(cB.fromArray(a.data.rotation.map(c=>typeof c=="number"?c:0))),dy.compose(ia,Yd,aM).premultiply(r.matrixWorld),i?(dy.decompose(ia,Yd,sM),o.setActiveCollisionTypes(Ge.ActiveCollisionTypes.KINEMATIC_FIXED|Ge.ActiveCollisionTypes.DYNAMIC_FIXED)):(dy.premultiply(n).decompose(ia,Yd,sM),t.rigidBody.bodyType()===Ge.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Ge.RigidBodyType.Fixed?o.setActiveCollisionTypes(Ge.ActiveCollisionTypes.KINEMATIC_FIXED|Ge.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Ge.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Ge.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),ia.divideScalar(this.pixelsPerMeter),o.setTranslation(ia.x,ia.y,ia.z),o.setRotation(Yd),i)i.push([o,l]);else{let c=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[c.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,n,r,s]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(r===o||s.isValidTriggeringObject(Be.is(o)?o:o.object)===!1)continue;let l=dB.copy(r.matrixWorld).decompose(ia,uB,sM).compose(ia,uB,aM).multiply(n),c=dy.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof ci?t=h.intersectsBox(i,c):(oM.radius=i,oM.center.setFromMatrixPosition(c),t=h.intersectsSphere(oM)),t?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),r.dispatchEvent(pJ)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(u=>u!==o)}}}};Ep(),et(),tb(),Ye(),bh();var hM=.02,pB=new C,fB=new C,mJ=new C,Mr=new C,Do=new C,Kd=new C,cM=new At,mB=new At,gJ=new At,ds=new qt,sc=new qt,Qd=new xi(0,0,0,"YXZ"),vJ=new C(1,0,0),Fa=new C(0,1,0),yJ=new C(0,0,1),gB=new C(1,1,1),vB=[],yB=t=>vB[t]??(vB[t]=new C),dM=new C,_J=new C,bJ=new C,xJ=new C,_B=new qt,wJ=new C,bB=new qt,Qn=new vs,Os=new ci,SJ={type:"requestRender"},MJ={type:"updateMatrix"},OT=class extends Vn{constructor(t,e,i,n,r,s,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=n,this.controlsManager=r,this.cameraFollow=s,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new At,this.target0=new C,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new xi(0,0,0,"YXZ"),this.position0Cam=new C,this.quat0Cam=new qt,this.scale0Cam=new C,this.hiddenMatrix0Cam=new At,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new vs(new C(0,-40,0),new C(0,40,0)),matrix:new At,position:new C,rotation:new qt},this.euler=new xi(0,0,0,"YXZ"),this.eulerDelta=new C,this.lastPosition=new C,this.lastCameraQuaternion=new qt,this.lastCameraPosition=new C,this.PI_2=Math.PI/2,this.prevMouse=new it,this.velocityTarget=new C,this.velocity=new C,this.directionXZ=new C,this.rotVelocityStick=new C,this.rotVelocityTarget=new C,this.rotVelocity=new C,this.rotDirection=new C,this.nonColliderRotOffset=new At,this.nonColliderPosOffset=new At,this.firstPointerId=-1,this.rot=new C,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new At,this.objectToTarget=new C,this.objectToTarget0=new C,this.objectToCamXZ=new C,this.objectToCamXZ0=new C,this.targetToCamera=new C,this.targetToCamera0=new C,this.cameraPolarAxis0=new C,this.targetPos=new C,this.targetQuat=new qt,this.lerpFactorPos=new C().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new qt,this.objXZQuatInv=new qt,this.objXZRotMat=new At,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new C,this.pushedVelocity=new C,this.groundYRotation=0,this.objectRealQuat=new qt,this.colliderWorldQuat=new qt,this.groundNormal=new C,this.groundTilt=new qt,this.groundTiltInv=new qt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new C,this.quaternion=new qt,this.scale=new C,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!ss&&!TE&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(TE&&hF<15.5&&!ss?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?OT.isLocked=!0:OT.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let y=f.axes[m];g===0?m===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=r.sharedGameControlGlobals,t===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let c=this.euler0.clone(),h=c.y;if(this.objectRealQuat.copy(this.quaternion),c.y=0,this.quaternion.setFromEuler(c),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),c.set(0,h,0),this.quaternion.setFromEuler(c),this.rot.setFromEuler(c),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f,g=new C(0,0,-1).applyQuaternion(this.camera.quaternion),m=new C().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(g.y)<1e-6?(m.y=0,g.y=0,f=m.projectOnVector(g)):f=m.y/g.y>0?g.multiplyScalar(m.y/g.y):g.multiplyScalar(m.length()),this.targetToCamera0.copy(f).negate();let y=this.camera.position.clone().add(f);this.objectToTarget0.subVectors(y,this.position);let v=new xi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof vn&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??Yu.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??Yu.defaultData.usePhysics,this.jumpPower=20*i.jumpPower,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??q_.defaultDataThirdPerson.orientWith,this.slopeThresh=65*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*hM/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*hM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*hM/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let u=new C().fromArray(i.collider.position.map(f=>typeof f=="number"?f:0)),d=new qt().setFromEuler(new xi().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(u).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(u,d,gB),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let f=new Vt;f.push({fi:0,data:{...Ki.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Ki.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=Ek({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new wi(YC.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(t=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let e=new xi().setFromQuaternion(this.quaternion,"YXZ"),i=e.y;this.objectRealQuat.copy(this.quaternion),e.y=0,this.quaternion.setFromEuler(e),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),e.set(0,i,0),this.quaternion.setFromEuler(e),this.rot.setFromEuler(e),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof vn?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let t=this.data,e=this.sharedAssets;t.gameActions!==void 0&&(this.actions={},W_.list.forEach(i=>{this.actions[i]=Rn({...t,disabled:!1,type:"GameControl"},t.gameActions[i],this.page,e,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),rr(this.actions.idle),rr(this.actions.move),rr(this.actions.run),rr(this.actions.jump)}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].Transition.forEach(e=>{e.play()}),this.actions[t].Animation.forEach(e=>{e.play(this.initialAction===!1)}),this.actions[t].TimelineAnimation.forEach(e=>{e.play()}),this.actions[t].Create.forEach(e=>{e.dispatchStart()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("start")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].Transition.forEach(e=>{e.stop(),e.object.currentState!==null&&e.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[t].TimelineAnimation.forEach(e=>{e.stop()}),this.actions[t].Create.forEach(e=>{e.dispatchStop()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("stop")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Mr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(t){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let e=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*e,n=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Do.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*e,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0),a.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let o=a.collider.parent(),l=o!==null&&o.isKinematic()?o:null,c=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&c?.userData.isFollowingObj!==this.object.uuid){let h=this.object.getWorldPosition(Mr).add(this.collider.position).divideScalar(this.pixelsPerMeter),u=l.velocityAtPoint(h);this.groundVelocity.set(u.x,u.y,u.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=l.angvel().y*e}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=Mr.subVectors(this.path[1],this.position),o=Do.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let r=mJ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Do.copy(r);s.y=0,r.set(0,r.y,s.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let s=Mr;this.camera.getWorldDirection(s);let a=Kd.copy(Fa).multiplyScalar(s.dot(Fa));s.sub(a);let o=Do.copy(this.directionXZ);o.x*=-1,this.rot.y=s.angleTo(o)*(s.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Qd.setFromVector3(this.rot),this.moveMode==="walk"&&(Qd.x=0),r.applyEuler(Qd),n&&(sc.setFromUnitVectors(Fa,this.groundNormal),r.applyQuaternion(sc)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(dM,_B,_J);let o=this.object.getWorldPosition(bJ).add(this.collider.position).sub(dM);bB.copy(a.prevQ).invert().premultiply(_B);let l=Kd.subVectors(dM,a.prevT).add(xJ.copy(o).applyQuaternion(bB).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),c=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Mr.copy(r).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let h=Be.is(a)?a:a.object;if(c!==null&&this.lastHitObj!==h){let u;a instanceof ys&&(u=a);let d=this.sharedGameControlGlobals.entityToCollisionEvents[h.uuid];if(d)for(let p of d)p.data.target==="character"&&(p.dispatch(u),h.dispatchEvent(IT));this.lastHitObj=h}c!==null&&(Math.abs(l.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=l.x),Math.abs(l.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=l.y),Math.abs(l.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=l.z),yB(s++).copy(c.normal1).applyQuaternion(a.quaternion))}if(s>0){for(let a=0;a<s;a++){let o=yB(a),l=o.dot(r);l<0&&r.addScaledVector(o,-l)}r.add(this.pushedVelocity)}else r.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(e),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*e,this.euler.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*e),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Fa,this.euler.y-this.euler0.y);let s=Do.copy(this.objectToCamXZ).normalize(),a=Kd.copy(r).multiplyScalar(e);a.y=0;let o=a.sub(Mr.copy(s).multiplyScalar(a.dot(s))).cross(s).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Ot.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Ot.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Ot.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Qd.copy(this.euler),Qd.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Qd)),ds.setFromAxisAngle(vJ,this.rot.x),sc.setFromAxisAngle(Fa,this.rot.y),sc.multiply(ds),ds.setFromAxisAngle(yJ,this.rot.z),sc.multiply(ds),this.quaternion.copy(sc),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Do.copy(r).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new C;for(let h=0;h<5;h++){let u=s.length(),d=Kd.copy(s).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,d,this.object.rigidBody.collider(0).shape,0,u,!1,12,void 0,void 0,this.object.rigidBody),a===null){h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(s);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let v of y)if(v.data.target==="character"){let _,b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(a.collider.handle))._parent;if(p.cloner){for(let x of p.cloner.children)if(x.rigidBody===b){_=x;break}}v.dispatch(_),p.dispatchEvent(IT)}}}let f=pB.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),g=fB.copy(d).multiplyScalar(a.time_of_impact).dot(f),m=a.time_of_impact;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=a.time_of_impact*(g-this.offset)/g,o.addScaledVector(d,m)),s.copy(d).multiplyScalar(u-m),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=Kd.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let _=y.add(v);_.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(_,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);b!==null&&b.time_of_impact===0&&(f.y=0,f.normalize())}s.addScaledVector(f,-s.dot(f))}}this.position.addScaledVector(o,this.pixelsPerMeter),Mr.copy(this.position).divideScalar(this.pixelsPerMeter),ds.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,c=l!==void 0&&wJ.copy(Mr).sub(l.translation()).lengthSq()>1;l!==void 0&&(c?(l.setTranslation(Mr,!0),l.setRotation(ds,!0)):(l.setNextKinematicTranslation(Mr),l.setNextKinematicRotation(ds)))}else{let s=this.onObject?1:5,a=r.multiplyScalar(e/s);for(let o=0;o<s;o++)this.position.add(a),this.collisionAdjustment(e/s)}else this.position.addScaledVector(r,e);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),a=this.targetToCamera.add(s);cM.lookAt(a,s,Fa).setPosition(a),cM.decompose(this.targetPos,this.targetQuat,Mr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Ot.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Ot.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(MJ),!(this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)||(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(SJ),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=ds.setFromAxisAngle(Fa,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Ot.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e),t=this.cameraXAxis==="Limit"?Ot.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):Ot.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let n=sc.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(n)}groundTiltAdjustment(t){180*Fa.angleTo(t)/Math.PI<15||180*Fa.angleTo(t)/Math.PI>85?ds.identity():ds.setFromUnitVectors(Fa,t),this.groundTilt.slerp(ds,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=fB.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=cM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mr,ds,Do).compose(Mr,ds,gB);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(r=>{if(r===this.object||r.isDescendantOf(this.object)||!r.bvhGeometry||!r.bvhGeometry.boundsTree)return;Os.makeEmpty(),r.updateMatrixWorldRigid();let s=r.matrixWorldRigid,a=mB.copy(s).invert(),o=gJ.copy(mB).multiply(i);Qn.copy(this.collider.segment),Qn.start.applyMatrix4(o),Qn.end.applyMatrix4(o);let l=pB.copy(this.position).applyMatrix4(a);Os.expandByPoint(Qn.start),Os.expandByPoint(Qn.end),Os.min.addScalar(-this.collider.radius),Os.max.addScalar(this.collider.radius),r.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:c=>c.distanceToPoint(Qn.end),intersectsBounds:c=>c.intersectsBox(Os),intersectsTriangle:c=>{let h=Mr,u=Do,d=c.closestPointToSegment(Qn,h,u);if(d<this.collider.radius){let p=this.collider.radius-d,f=u.sub(h).normalize(),g=Kd.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(s).sub(this.position);e.add(m),Qn.start.addScaledVector(f,p),Qn.end.addScaledVector(f,p)}}})}),Os.makeEmpty(),Qn.copy(this.collider.segment),Qn.start.applyMatrix4(i),Qn.end.applyMatrix4(i),Os.expandByPoint(Qn.start),Os.expandByPoint(Qn.end),Os.min.addScalar(-this.collider.radius),Os.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:r=>r.distanceToPoint(Qn.end),intersectsBounds:r=>r.intersectsBox(Os),intersectsTriangle:r=>{let s=Mr,a=Do,o=r.closestPointToSegment(Qn,s,a);if(o<this.collider.radius){let l=this.collider.radius-o,c=a.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(c),e.addScaledVector(c,l),Qn.start.addScaledVector(c,l),Qn.end.addScaledVector(c,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let n=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(n),this.position.add(e)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},ij=OT;ij.isLocked=!1,et(),qg(),Ep(),Mp();var nj,rj,uM,EJ=new Promise(t=>{nj=t});function AJ(t){return uM||(uM=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.44/build";typeof window<"u"&&(rj=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[n,r]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=n.default,a=await s({wasmBinary:r});nj(a)}(),uM)}ii();var sj,Fe,ur,TJ=t=>`
9850
9850
  (async function() {
9851
9851
  const [wasmImport, wasmBinary] = await Promise.all([
9852
9852
  import('${t}' + 'navmesh.js'),
@@ -9856,7 +9856,7 @@ void main() {
9856
9856
  self.module = await wasmModule({ wasmBinary });
9857
9857
  postMessage('ready');
9858
9858
  })();
9859
- `,CJ={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};EJ.then(t=>{sj=t,Fe=new t.Vec3,ur=new t.Vec3});var PJ=new C,DJ=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(ae.length!==1)return;let{raycaster:n,page:r}=this.eventContext;this.eventContext.updateRaycaster(i);let s=r.raycastWithClones(n);if(s.length!==0){if(this.gameControl){let a=PJ.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,s[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,n)=>r=>{let s;if(r instanceof zc){if(!r.objectForSample)return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(r.objectForSample.dataPatched.physics.fusedBody)return;s=r.object}else if(r instanceof ys)s=r.object;else if(s=r,s.dataPatched.cloner?.disabled===!1&&s.dataPatched.cloner?.hideBase&&s.dataPatched.physics?.fusedBody!==!0)return!0;if(n&&!s.userData.navmesh)return;let a=s.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;r.updateMatrixWorldRigid();let o=Eb(a),l=s.userData.hasDestroy,c=s.userData.hasDrag,h=!1,u=!1;for(let d of a.events)d.data.disabled!==!0&&(d.data.type==="GameControl"?h=!0:d.data.type==="Follow"&&(u=!0));if(h||o||u||l||c)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in r&&r.geometry&&i.push(Vo(r.geometry,r.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return r.traverseObject((d,p)=>{if(p===0)return;let f;if(d instanceof zc){if(!d.objectForSample)return d.object.dataPatched.physics.fusedBody===!0&&d.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(d.objectForSample.dataPatched.physics.fusedBody)return;f=d.object}else if(d instanceof ys)f=d.object;else if(f=d,d.dataPatched.cloner?.hideBase)return!0;let g=f.dataPatched;if(!g.visible&&g.physics?.enabled!==!0)return!0;"geometry"in d&&d.geometry&&i.push(Vo(d.geometry,d.matrixWorld))}),!0},this.traverseNoPhysics=(i,n)=>r=>{let s;if(r instanceof zc)return;s=r instanceof ys?r.object:r;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(n&&!s.userData.navmesh)return;let o=r.geometry,l=s.userData.hasDestroy===!0,c=s.userData.hasDrag===!0;if(Eb(a)||l||c||s.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(Vo(o,r.matrixWorld))},this.navmeshWasm=sj,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?TJ(rj??"https://cdn.spline.design/@splinetool/runtime@2.0.42/build/"):`
9859
+ `,CJ={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};EJ.then(t=>{sj=t,Fe=new t.Vec3,ur=new t.Vec3});var PJ=new C,DJ=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(ae.length!==1)return;let{raycaster:n,page:r}=this.eventContext;this.eventContext.updateRaycaster(i);let s=r.raycastWithClones(n);if(s.length!==0){if(this.gameControl){let a=PJ.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,s[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,n)=>r=>{let s;if(r instanceof zc){if(!r.objectForSample)return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(r.objectForSample.dataPatched.physics.fusedBody)return;s=r.object}else if(r instanceof ys)s=r.object;else if(s=r,s.dataPatched.cloner?.disabled===!1&&s.dataPatched.cloner?.hideBase&&s.dataPatched.physics?.fusedBody!==!0)return!0;if(n&&!s.userData.navmesh)return;let a=s.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;r.updateMatrixWorldRigid();let o=Eb(a),l=s.userData.hasDestroy,c=s.userData.hasDrag,h=!1,u=!1;for(let d of a.events)d.data.disabled!==!0&&(d.data.type==="GameControl"?h=!0:d.data.type==="Follow"&&(u=!0));if(h||o||u||l||c)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in r&&r.geometry&&i.push(Vo(r.geometry,r.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return r.traverseObject((d,p)=>{if(p===0)return;let f;if(d instanceof zc){if(!d.objectForSample)return d.object.dataPatched.physics.fusedBody===!0&&d.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(d.objectForSample.dataPatched.physics.fusedBody)return;f=d.object}else if(d instanceof ys)f=d.object;else if(f=d,d.dataPatched.cloner?.hideBase)return!0;let g=f.dataPatched;if(!g.visible&&g.physics?.enabled!==!0)return!0;"geometry"in d&&d.geometry&&i.push(Vo(d.geometry,d.matrixWorld))}),!0},this.traverseNoPhysics=(i,n)=>r=>{let s;if(r instanceof zc)return;s=r instanceof ys?r.object:r;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(n&&!s.userData.navmesh)return;let o=r.geometry,l=s.userData.hasDestroy===!0,c=s.userData.hasDrag===!0;if(Eb(a)||l||c||s.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(Vo(o,r.matrixWorld))},this.navmeshWasm=sj,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?TJ(rj??"https://cdn.spline.design/@splinetool/runtime@2.0.44/build/"):`
9860
9860
  (async function() {
9861
9861
  const [wasmImport, wasmBinary] = await Promise.all([
9862
9862
  import(self.location.origin + '/_libraries/navmesh.js'),
@@ -9911,7 +9911,7 @@ onmessage = function(messageEvent) {
9911
9911
  <svg width="${m}" height="${.4*a}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
9912
9912
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
9913
9913
  </svg>
9914
- `),g.addEventListener("pointerdown",()=>{t.gameControl.movementState.jump=1,t.requestRender()}),g.addEventListener("touchend",y=>y.preventDefault()),void(t.joysticks[r]=[void 0,s])}let p={zone:s,mode:"static",position:h,size:a};l==="hide"&&(p.restOpacity=0);let f=lJ.create(p);f.on("move",(g,m)=>{let y=t.gameControl;n==="pos"?m.force<.2?y.moveForce=0:(y.movementState.movePosZ=Math.sin(-m.angle.radian),y.movementState.movePosX=Math.cos(-m.angle.radian),m.force>1.2?y.movementState.run=1:y.movementState.run=0,m.force<.3?y.moveForce=(m.force-.2)/.1:y.moveForce=1):n==="rot"&&(m.force<.2?y.rotForce=0:(y.movementState.rotPosX=m.vector.y,y.movementState.rotPosY=-m.vector.x,m.force<.3?y.rotForce=(m.force-.2)/.1:y.rotForce=1)),t.requestRender()}),f.on("end",(g,m)=>{let y=t.gameControl;n==="pos"?(y.movementState.movePosZ=0,y.movementState.movePosX=0,y.moveForce=1):n==="rot"&&(y.movementState.rotPosX=0,y.movementState.rotPosY=0,y.rotForce=1)}),t.joysticks[r]=[f,s]})}};ke(),XV=IJ,Si("game-controls"),et();var D1=Math.pow(2,-24),k3=Symbol("SKIP_GENERATION"),aj={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[k3]:!1};function Qi(t,e,i){return i.min.x=e[t],i.min.y=e[t+1],i.min.z=e[t+2],i.max.x=e[t+3],i.max.y=e[t+4],i.max.z=e[t+5],i}function xB(t){let e=-1,i=-1/0;for(let n=0;n<3;n++){let r=t[n+3]-t[n];r>i&&(i=r,e=n)}return e}function wB(t,e){e.set(t)}function SB(t,e,i){let n,r;for(let s=0;s<3;s++){let a=s+3;n=t[s],r=e[s],i[s]=n<r?n:r,n=t[a],r=e[a],i[a]=n>r?n:r}}function uy(t,e,i){for(let n=0;n<3;n++){let r=e[t+2*n],s=e[t+2*n+1],a=r-s,o=r+s;a<i[n]&&(i[n]=a),o>i[n+3]&&(i[n+3]=o)}}function Jf(t){let e=t[3]-t[0],i=t[4]-t[1],n=t[5]-t[2];return 2*(e*i+i*n+n*e)}function Wn(t,e){return e[t+15]===65535}function Dr(t,e){return e[t+6]}function Gr(t,e){return e[t+14]}function sr(t){return t+8}function ar(t,e){return t+8*e[t+6]}function V3(t,e){return e[t+7]}function pM(t,e,i,n,r){let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,y=t.offset||0;for(let v=6*(e-y),_=6*(e+i-y);v<_;v+=6){let b=t[v+0],x=t[v+1],w=b-x,S=b+x;w<s&&(s=w),S>l&&(l=S),b<u&&(u=b),b>f&&(f=b);let A=t[v+2],E=t[v+3],P=A-E,T=A+E;P<a&&(a=P),T>c&&(c=T),A<d&&(d=A),A>g&&(g=A);let R=t[v+4],L=t[v+5],D=R-L,U=R+L;D<o&&(o=D),U>h&&(h=U),R<p&&(p=R),R>m&&(m=R)}n[0]=s,n[1]=a,n[2]=o,n[3]=l,n[4]=c,n[5]=h,r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=g,r[5]=m}var oj,R1,LT,lj,OJ=(t,e)=>t.candidate-e.candidate,Rl=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),py=new Float32Array(6),fM=class{constructor(){this.boundingData=new Float32Array(6)}},LJ=Math.pow(2,32);function BT(t){return"count"in t?1:1+BT(t.left)+BT(t.right)}function BJ(t,e,i){return oj=new Float32Array(i),R1=new Uint32Array(i),LT=new Uint16Array(i),lj=new Uint8Array(i),UT(t,e)}function UT(t,e){let i=t/4,n=t/2,r="count"in e,s=e.boundingData;for(let a=0;a<6;a++)oj[i+a]=s[a];if(r)return e.buffer?(lj.set(new Uint8Array(e.buffer),t),t+e.buffer.byteLength):(R1[i+6]=e.offset,LT[n+14]=e.count,LT[n+15]=65535,t+32);{let{left:a,right:o,splitAxis:l}=e,c=UT(t+32,a),h=c/32-t/32;if(h>LJ)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return R1[i+6]=h,R1[i+7]=l,UT(c,o)}}function UJ(t,e){let i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=t.getRootRanges(e.range),r=n[0],s=n[n.length-1],a={offset:r.offset,count:s.offset+s.count-r.offset},o=new Float32Array(6*a.count);o.offset=a.offset,t.computePrimitiveBounds(a.offset,a.count,o),t._roots=n.map(l=>{let c=function(d,p,f,g,m,y){let{maxDepth:v,verbose:_,maxLeafSize:b,strategy:x,onProgress:w}=m,S=d.primitiveBuffer,A=d.primitiveBufferStride,E=new Float32Array(6),P=!1,T=new fM;return pM(p,f,g,T.boundingData,E),function L(D,U,V,k=null,Y=0){if(!P&&Y>=v&&(P=!0,_&&console.warn(`BVH: Max depth of ${v} reached when generating BVH. Consider increasing maxDepth.`)),V<=b||Y>=v)return R(U+V),D.offset=U,D.count=V,D;let $=function(Q,rt,gt,at,ht,ct){let q=-1,lt=0;if(ct===0)q=xB(rt),q!==-1&&(lt=(rt[q]+rt[q+3])/2);else if(ct===1)q=xB(Q),q!==-1&&(lt=function(F,O,j,Z){let I=0,G=F.offset;for(let W=O,N=O+j;W<N;W++)I+=F[6*(W-G)+2*Z];return I/j}(gt,at,ht,q));else if(ct===2){let F=Jf(Q),O=1.25*ht,j=gt.offset||0,Z=6*(at-j),I=6*(at+ht-j);for(let G=0;G<3;G++){let W=rt[G],N=(rt[G+3]-W)/32;if(ht<8){let tt=[...Rl];tt.length=ht;let ot=0;for(let ut=Z;ut<I;ut+=6,ot++){let Pt=tt[ot];Pt.candidate=gt[ut+2*G],Pt.count=0;let{bounds:bt,leftCacheBounds:Rt,rightCacheBounds:_t}=Pt;for(let X=0;X<3;X++)_t[X]=1/0,_t[X+3]=-1/0,Rt[X]=1/0,Rt[X+3]=-1/0,bt[X]=1/0,bt[X+3]=-1/0;uy(ut,gt,bt)}tt.sort(OJ);let pt=ht;for(let ut=0;ut<pt;ut++){let Pt=tt[ut];for(;ut+1<pt&&tt[ut+1].candidate===Pt.candidate;)tt.splice(ut+1,1),pt--}for(let ut=Z;ut<I;ut+=6){let Pt=gt[ut+2*G];for(let bt=0;bt<pt;bt++){let Rt=tt[bt];Pt>=Rt.candidate?uy(ut,gt,Rt.rightCacheBounds):(uy(ut,gt,Rt.leftCacheBounds),Rt.count++)}}for(let ut=0;ut<pt;ut++){let Pt=tt[ut],bt=Pt.count,Rt=ht-Pt.count,_t=Pt.leftCacheBounds,X=Pt.rightCacheBounds,vt=0;bt!==0&&(vt=Jf(_t)/F);let Dt=0;Rt!==0&&(Dt=Jf(X)/F);let jt=1+1.25*(vt*bt+Dt*Rt);jt<O&&(q=G,O=jt,lt=Pt.candidate)}}else{for(let pt=0;pt<32;pt++){let ut=Rl[pt];ut.count=0,ut.candidate=W+N+pt*N;let Pt=ut.bounds;for(let bt=0;bt<3;bt++)Pt[bt]=1/0,Pt[bt+3]=-1/0}for(let pt=Z;pt<I;pt+=6){let ut=~~((gt[pt+2*G]-W)/N);ut>=32&&(ut=31);let Pt=Rl[ut];Pt.count++,uy(pt,gt,Pt.bounds)}let tt=Rl[31];wB(tt.bounds,tt.rightCacheBounds);for(let pt=30;pt>=0;pt--){let ut=Rl[pt],Pt=Rl[pt+1];SB(ut.bounds,Pt.rightCacheBounds,ut.rightCacheBounds)}let ot=0;for(let pt=0;pt<31;pt++){let ut=Rl[pt],Pt=ut.count,bt=ut.bounds,Rt=Rl[pt+1].rightCacheBounds;Pt!==0&&(ot===0?wB(bt,py):SB(bt,py,py)),ot+=Pt;let _t=0,X=0;ot!==0&&(_t=Jf(py)/F);let vt=ht-ot;vt!==0&&(X=Jf(Rt)/F);let Dt=1+1.25*(_t*ot+X*vt);Dt<O&&(q=G,O=Dt,lt=ut.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${ct} used.`);return{axis:q,pos:lt}}(D.boundingData,k,p,U,V,x);if($.axis===-1)return R(U+V),D.offset=U,D.count=V,D;let nt=function(Q,rt,gt,at,ht,ct){let q=at,lt=at+ht-1,F=ct.pos,O=2*ct.axis,j=gt.offset||0;for(;;){for(;q<=lt&&gt[6*(q-j)+O]<F;)q++;for(;q<=lt&&gt[6*(lt-j)+O]>=F;)lt--;if(!(q<lt))return q;for(let Z=0;Z<rt;Z++){let I=Q[q*rt+Z];Q[q*rt+Z]=Q[lt*rt+Z],Q[lt*rt+Z]=I}for(let Z=0;Z<6;Z++){let I=q-j,G=lt-j,W=gt[6*I+Z];gt[6*I+Z]=gt[6*G+Z],gt[6*G+Z]=W}q++,lt--}}(S,A,p,U,V,$);if(nt===U||nt===U+V)R(U+V),D.offset=U,D.count=V;else{D.splitAxis=$.axis;let Q=new fM,rt=U,gt=nt-U;D.left=Q,pM(p,rt,gt,Q.boundingData,E),L(Q,rt,gt,E,Y+1);let at=new fM,ht=nt,ct=V-gt;D.right=at,pM(p,ht,ct,at.boundingData,E),L(at,ht,ct,E,Y+1)}return D}(T,f,g,E),T;function R(L){w&&w((L-y.offset)/y.count)}}(t,o,l.offset,l.count,e,a),h=BT(c),u=new i(32*h);return BJ(0,c,u),u})}et();var eh,Fu,j3=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}},Bi=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let t=[],e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}},Jd=[],fy=new j3(()=>new ci);function zJ(t,e,i,n,r,s){eh=fy.getPrimitive(),Fu=fy.getPrimitive(),Jd.push(eh,Fu),Bi.setBuffer(t._roots[e]);let a=zT(0,t.geometry,i,n,r,s);Bi.clearBuffer(),fy.releasePrimitive(eh),fy.releasePrimitive(Fu),Jd.pop(),Jd.pop();let o=Jd.length;return o>0&&(Fu=Jd[o-1],eh=Jd[o-2]),a}function zT(t,e,i,n,r=null,s=0,a=0){let{float32Array:o,uint16Array:l,uint32Array:c}=Bi,h=2*t;if(Wn(h,l)){let u=Dr(t,c),d=Gr(h,l);return Qi(t,o,eh),n(u,d,!1,a,s+t/8,eh)}{let u,d,p,f,g=function(E){let{uint16Array:P,uint32Array:T}=Bi,R=2*E;for(;!Wn(R,P);)R=2*(E=sr(E));return Dr(E,T)},m=function(E){let{uint16Array:P,uint32Array:T}=Bi,R=2*E;for(;!Wn(R,P);)R=2*(E=ar(E,T));return Dr(E,T)+Gr(R,P)},y=sr(t),v=ar(t,c),_=y,b=v;if(r&&(p=eh,f=Fu,Qi(_,o,p),Qi(b,o,f),u=r(p),d=r(f),d<u)){_=v,b=y;let E=u;u=d,d=E,p=f}p||(p=eh,Qi(_,o,p));let x,w=i(p,Wn(2*_,l),u,a+1,s+_/8);if(w===2){let E=g(_);x=n(E,m(_)-E,!0,a+1,s+_/8,p)}else x=w&&zT(_,e,i,n,r,s,a+1);if(x)return!0;f=Fu,Qi(b,o,f);let S,A=i(f,Wn(2*b,l),d,a+1,s+b/8);if(A===2){let E=g(b);S=n(E,m(b)-E,!0,a+1,s+b/8,f)}else S=A&&zT(b,e,i,n,r,s,a+1);return!!S}}et();var fg=new Bi.constructor,Ab=new Bi.constructor,Nl=new j3(()=>new ci),tu=new ci,eu=new ci,mM=new ci,gM=new ci,vM=!1;function ra(t,e,i,n,r,s=0,a=0,o=0,l=0,c=null,h=!1){let u,d;h?(u=Ab,d=fg):(u=fg,d=Ab);let p=u.float32Array,f=u.uint32Array,g=u.uint16Array,m=d.float32Array,y=d.uint32Array,v=d.uint16Array,_=2*e,b=Wn(2*t,g),x=Wn(_,v),w=!1;if(x&&b)w=h?r(Dr(e,y),Gr(2*e,v),Dr(t,f),Gr(2*t,g),l,a+e/8,o,s+t/8):r(Dr(t,f),Gr(2*t,g),Dr(e,y),Gr(2*e,v),o,s+t/8,l,a+e/8);else if(x){let S=Nl.getPrimitive();Qi(e,m,S),S.applyMatrix4(i);let A=sr(t),E=ar(t,f);Qi(A,p,tu),Qi(E,p,eu);let P=S.intersectsBox(tu),T=S.intersectsBox(eu);w=P&&ra(e,A,n,i,r,a,s,l,o+1,S,!h)||T&&ra(e,E,n,i,r,a,s,l,o+1,S,!h),Nl.releasePrimitive(S)}else{let S=sr(e),A=ar(e,y);Qi(S,m,mM),Qi(A,m,gM);let E=c.intersectsBox(mM),P=c.intersectsBox(gM);if(E&&P)w=ra(t,S,i,n,r,s,a,o,l+1,c,h)||ra(t,A,i,n,r,s,a,o,l+1,c,h);else if(E)if(b)w=ra(t,S,i,n,r,s,a,o,l+1,c,h);else{let T=Nl.getPrimitive();T.copy(mM).applyMatrix4(i);let R=sr(t),L=ar(t,f);Qi(R,p,tu),Qi(L,p,eu);let D=T.intersectsBox(tu),U=T.intersectsBox(eu);w=D&&ra(S,R,n,i,r,a,s,l,o+1,T,!h)||U&&ra(S,L,n,i,r,a,s,l,o+1,T,!h),Nl.releasePrimitive(T)}else if(P)if(b)w=ra(t,A,i,n,r,s,a,o,l+1,c,h);else{let T=Nl.getPrimitive();T.copy(gM).applyMatrix4(i);let R=sr(t),L=ar(t,f);Qi(R,p,tu),Qi(L,p,eu);let D=T.intersectsBox(tu),U=T.intersectsBox(eu);w=D&&ra(A,R,n,i,r,a,s,l,o+1,T,!h)||U&&ra(A,L,n,i,r,a,s,l,o+1,T,!h),Nl.releasePrimitive(T)}}return w}var MB=new ci,iu=new Float32Array(6),FJ=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){UJ(this,t={...aj,...t})}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(t,e,i,n){let r=1/0,s=1/0,a=1/0,o=-1/0,l=-1/0,c=-1/0;for(let h=t,u=t+e;h<u;h++){this.writePrimitiveBounds(h,iu,0);let[d,p,f,g,m,y]=iu;d<r&&(r=d),g>o&&(o=g),p<s&&(s=p),m>l&&(l=m),f<a&&(a=f),y>c&&(c=y)}return i[n+0]=r,i[n+1]=s,i[n+2]=a,i[n+3]=o,i[n+4]=l,i[n+5]=c,i}computePrimitiveBounds(t,e,i){let n=i.offset||0;for(let r=t,s=t+e;r<s;r++){this.writePrimitiveBounds(r,iu,0);let[a,o,l,c,h,u]=iu,d=(a+c)/2,p=(o+h)/2,f=(l+u)/2,g=(c-a)/2,m=(h-o)/2,y=(u-l)/2,v=6*(r-n);i[v+0]=d,i[v+1]=g+(Math.abs(d)+g)*D1,i[v+2]=p,i[v+3]=m+(Math.abs(p)+m)*D1,i[v+4]=f,i[v+5]=y+(Math.abs(f)+y)*D1}return i}shiftPrimitiveOffsets(t){let e=this._indirectBuffer;if(e)for(let i=0,n=e.length;i<n;i++)e[i]+=t;else{let i=this._roots;for(let n=0;n<i.length;n++){let r=i[n],s=new Uint32Array(r),a=new Uint16Array(r),o=r.byteLength/32;for(let l=0;l<o;l++){let c=8*l;Wn(2*c,a)&&(s[c+6]+=t)}}}}traverse(t,e=0){let i=this._roots[e],n=new Uint32Array(i),r=new Uint16Array(i);(function s(a,o=0){let l=2*a,c=Wn(l,r);if(c){let h=n[a+6],u=r[l+14];t(o,c,new Float32Array(i,4*a,6),h,u)}else{let h=sr(a),u=ar(a,n),d=V3(a,n);t(o,c,new Float32Array(i,4*a,6),d)||(s(h,o+1),s(u,o+1))}})(0)}refit(){let t=this._roots;for(let e=0,i=t.length;e<i;e++){let n=t[e],r=new Uint32Array(n),s=new Uint16Array(n),a=new Float32Array(n);for(let o=n.byteLength/32-1;o>=0;o--){let l=8*o,c=2*l;if(Wn(c,s)){let h=Dr(l,r),u=Gr(c,s);this.writePrimitiveRangeBounds(h,u,iu,0),a.set(iu,l)}else{let h=sr(l),u=ar(l,r);for(let d=0;d<3;d++){let p=a[h+d],f=a[h+d+3],g=a[u+d],m=a[u+d+3];a[l+d]=p<g?p:g,a[l+d+3]=f>m?f:m}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(e=>{Qi(0,new Float32Array(e),MB),t.union(MB)}),t}shapecast(t){let{boundsTraverseOrder:e,intersectsBounds:i,intersectsRange:n,intersectsPrimitive:r,scratchPrimitive:s,iterate:a}=t;if(n&&r){let h=n;n=(u,d,p,f,g)=>!!h(u,d,p,f,g)||a(u,d,this,r,p,f,s)}else n||(n=r?(h,u,d,p)=>a(h,u,this,r,d,p,s):(h,u,d)=>d);let o=!1,l=0,c=this._roots;for(let h=0,u=c.length;h<u;h++){let d=c[h];if(o=zJ(this,h,i,n,e,l),o)break;l+=d.byteLength/32}return o}bvhcast(t,e,i){let{intersectsRanges:n}=i;return function(r,s,a,o){if(vM)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");vM=!0;let l,c=r._roots,h=s._roots,u=0,d=0,p=new At().copy(a).invert();for(let f=0,g=c.length;f<g;f++){fg.setBuffer(c[f]),d=0;let m=Nl.getPrimitive();Qi(0,fg.float32Array,m),m.applyMatrix4(p);for(let y=0,v=h.length;y<v&&(Ab.setBuffer(h[y]),l=ra(0,0,a,p,o,u,d,0,0,m),Ab.clearBuffer(),d+=h[y].byteLength/32,!l);y++);if(Nl.releasePrimitive(m),fg.clearBuffer(),u+=c[f].byteLength/32,l)break}return vM=!1,l}(this,t,e,n)}};function FT(t){return t.index?t.index.count:t.attributes.position.count}function bx(t){return FT(t)/3}function EB(t,e,i){let n=function(d,p,f){let g=FT(d)/f,m=p||d.drawRange,y=m.start/f,v=(m.start+m.count)/f,_=Math.max(0,y),b=Math.min(g,v)-_;return{offset:Math.floor(_),count:Math.floor(b)}}(t,e,i),r=function(d,p){return d.groups.map(f=>({offset:f.start/p,count:f.count/p}))}(t,i);if(!r.length)return[n];let s=[],a=n.offset,o=n.offset+n.count,l=FT(t)/i,c=[];for(let d of r){let{offset:p,count:f}=d,g=p,m=p+(isFinite(f)?f:l-p);g<o&&m>a&&(c.push({pos:Math.max(a,g),isStart:!0}),c.push({pos:Math.min(o,m),isStart:!1}))}c.sort((d,p)=>d.pos!==p.pos?d.pos-p.pos:d.type==="end"?-1:1);let h=0,u=null;for(let d of c){let p=d.pos;h!==0&&p!==u&&s.push({offset:u,count:p-u}),h+=d.isStart?1:-1,u=p}return s}et(),et();var NJ=class extends FJ{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(t){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(t){}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("BVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");if(e.useSharedArrayBuffer&&!(typeof SharedArrayBuffer<"u"))throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=t,this.resolvePrimitiveIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,(e={...aj,...e})[k3]||this.init(e)}init(t){let{geometry:e,primitiveStride:i}=this;if(t.indirect){let n=function(r,s){let a=r[r.length-1],o=a.offset+a.count>65536,l=r.reduce((p,f)=>p+f.count,0),c=o?4:2,h=s?new SharedArrayBuffer(l*c):new ArrayBuffer(l*c),u=o?new Uint32Array(h):new Uint16Array(h),d=0;for(let p=0;p<r.length;p++){let{offset:f,count:g}=r[p];for(let m=0;m<g;m++)u[d+m]=f+m;d+=g}return u}(EB(e,t.range,i),t.useSharedArrayBuffer);this._indirectBuffer=n}else(function(n,r){if(!n.index){let s=n.attributes.position.count,a=function(o,l=ArrayBuffer){return o>65535?new Uint32Array(new l(4*o)):new Uint16Array(new l(2*o))}(s,r.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);n.setIndex(new Ht(a,1));for(let o=0;o<s;o++)a[o]=o}})(e,t);super.init(t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ci))}getRootRanges(t){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:EB(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}};et(),et(),et();var ao=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,n=-1/0;for(let r=0,s=t.length;r<s;r++){let a=t[r][e];i=a<i?a:i,n=a>n?a:n}this.min=i,this.max=n}setFromPoints(t,e){let i=1/0,n=-1/0;for(let r=0,s=e.length;r<s;r++){let a=e[r],o=t.dot(a);i=o<i?o:i,n=o>n?o:n}this.min=i,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};ao.prototype.setFromBox=function(){let t=new C;return function(e,i){let n=i.min,r=i.max,s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let c=0;c<=1;c++){t.x=n.x*o+r.x*(1-o),t.y=n.y*l+r.y*(1-l),t.z=n.z*c+r.z*(1-c);let h=e.dot(t);s=Math.min(h,s),a=Math.max(h,a)}this.min=s,this.max=a}}(),new ao,et(),et();var kJ=function(){let t=new C,e=new C,i=new C;return function(n,r,s){let a=n.start,o=t,l=r.start,c=e;i.subVectors(a,l),t.subVectors(n.end,n.start),e.subVectors(r.end,r.start);let h,u,d=i.dot(c),p=c.dot(o),f=c.dot(c),g=i.dot(o),m=o.dot(o)*f-p*p;h=m!==0?(d*p-g*f)/m:0,u=(d+h*p)/f,s.x=h,s.y=u}}(),NT=function(){let t=new it,e=new C,i=new C;return function(n,r,s,a){kJ(n,r,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return n.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void n.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?n.at(0,s):n.at(1,s),void r.closestPointToPoint(s,!0,a);{let c,h;c=o<0?n.start:n.end,h=l<0?r.start:r.end;let u=e,d=i;return n.closestPointToPoint(h,!0,e),r.closestPointToPoint(c,!0,i),u.distanceToSquared(h)<=d.distanceToSquared(c)?(s.copy(u),void a.copy(h)):(s.copy(c),void a.copy(d))}}}(),VJ=function(){let t=new C,e=new C,i=new kr,n=new vs;return function(r,s){let{radius:a,center:o}=r,{a:l,b:c,c:h}=s;if(n.start=l,n.end=c,n.closestPointToPoint(o,!0,t).distanceTo(o)<=a||(n.start=l,n.end=h,n.closestPointToPoint(o,!0,t).distanceTo(o)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(o,!0,t).distanceTo(o)<=a))return!0;let u=s.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=a){let d=u.projectPoint(o,e);if(s.containsPoint(d))return!0}return!1}}(),jJ=["x","y","z"],gc=1e-15;function Ls(t){return Math.abs(t)<gc}var fa=class extends pn{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new C),this.satBounds=new Array(4).fill().map(()=>new ao),this.points=[this.a,this.b,this.c],this.plane=new kr,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new vs,this.needsUpdate=!0}intersectsSphere(t){return VJ(t,this)}update(){let t=this.a,e=this.b,i=this.c,n=this.points,r=this.satAxes,s=this.satBounds,a=r[0],o=s[0];this.getNormal(a),o.setFromPoints(a,n);let l=r[1],c=s[1];l.subVectors(t,e),c.setFromPoints(l,n);let h=r[2],u=s[2];h.subVectors(e,i),u.setFromPoints(h,n);let d=r[3],p=s[3];d.subVectors(i,t),p.setFromPoints(d,n);let f=l.length(),g=h.length(),m=d.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,f<gc?g<gc||m<gc?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(i)):g<gc?m<gc?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):m<gc&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};fa.prototype.closestPointToSegment=function(){let t=new C,e=new C,i=new vs;return function(n,r=null,s=null){let a,{start:o,end:l}=n,c=this.points,h=1/0;for(let u=0;u<3;u++){let d=(u+1)%3;i.start.copy(c[u]),i.end.copy(c[d]),NT(i,n,t,e),a=t.distanceToSquared(e),a<h&&(h=a,r&&r.copy(t),s&&s.copy(e))}return this.closestPointToPoint(o,t),a=o.distanceToSquared(t),a<h&&(h=a,r&&r.copy(t),s&&s.copy(o)),this.closestPointToPoint(l,t),a=l.distanceToSquared(t),a<h&&(h=a,r&&r.copy(t),s&&s.copy(l)),Math.sqrt(h)}}(),fa.prototype.intersectsTriangle=function(){let t=new fa,e=new ao,i=new ao,n=new C,r=new C,s=new C,a=new C,o=new vs,l=new vs,c=new C,h=new it,u=new it;function d(v,_,b,x){let w=n;v.isDegenerateIntoPoint||v.isDegenerateIntoSegment?w.copy(_.plane.normal):w.copy(v.plane.normal);let S=v.satBounds,A=v.satAxes;for(let T=1;T<4;T++){let R=S[T],L=A[T];if(e.setFromPoints(L,_.points),R.isSeparated(e)||(a.copy(w).cross(L),e.setFromPoints(a,v.points),i.setFromPoints(a,_.points),e.isSeparated(i)))return!1}let E=_.satBounds,P=_.satAxes;for(let T=1;T<4;T++){let R=E[T],L=P[T];if(e.setFromPoints(L,v.points),R.isSeparated(e)||(a.crossVectors(w,L),e.setFromPoints(a,v.points),i.setFromPoints(a,_.points),e.isSeparated(i)))return!1}return b&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),b.start.set(0,0,0),b.end.set(0,0,0)),!0}function p(v,_,b,x,w,S,A,E,P,T,R){let L=A/(A-E);T.x=x+(w-x)*L,R.start.subVectors(_,v).multiplyScalar(L).add(v),L=A/(A-P),T.y=x+(S-x)*L,R.end.subVectors(b,v).multiplyScalar(L).add(v)}function f(v,_,b,x,w,S,A,E,P,T,R){if(w>0)p(v.c,v.a,v.b,x,_,b,P,A,E,T,R);else if(S>0)p(v.b,v.a,v.c,b,_,x,E,A,P,T,R);else if(E*P>0||A!=0)p(v.a,v.b,v.c,_,b,x,A,E,P,T,R);else if(E!=0)p(v.b,v.a,v.c,b,_,x,E,A,P,T,R);else{if(P==0)return!0;p(v.c,v.a,v.b,x,_,b,P,A,E,T,R)}return!1}function g(v,_,b,x){let w=_.degenerateSegment,S=v.plane.distanceToPoint(w.start),A=v.plane.distanceToPoint(w.end);return Ls(S)?Ls(A)?d(v,_,b,x):(b&&(b.start.copy(w.start),b.end.copy(w.start)),v.containsPoint(w.start)):Ls(A)?(b&&(b.start.copy(w.end),b.end.copy(w.end)),v.containsPoint(w.end)):v.plane.intersectLine(w,n)!=null&&(b&&(b.start.copy(n),b.end.copy(n)),v.containsPoint(n))}function m(v,_,b){let x=_.a;return!(!Ls(v.plane.distanceToPoint(x))||!v.containsPoint(x)||(b&&(b.start.copy(x),b.end.copy(x)),0))}function y(v,_,b){let x=v.degenerateSegment,w=_.a;return x.closestPointToPoint(w,!0,n),w.distanceToSquared(n)<1e-30&&(b&&(b.start.copy(w),b.end.copy(w)),!0)}return function(v,_=null,b=!1){this.needsUpdate&&this.update(),v.isExtendedTriangle?v.needsUpdate&&v.update():(t.copy(v),t.update(),v=t);let x=function(F,O,j,Z){if(F.isDegenerateIntoSegment){if(O.isDegenerateIntoSegment){let I=F.degenerateSegment,G=O.degenerateSegment,W=r,N=s;I.delta(W),G.delta(N);let tt=n.subVectors(G.start,I.start),ot=W.x*N.y-W.y*N.x;if(Ls(ot))return!1;let pt=(tt.x*N.y-tt.y*N.x)/ot,ut=-(W.x*tt.y-W.y*tt.x)/ot;return!(pt<0||pt>1||ut<0||ut>1||!Ls(I.start.z+W.z*pt-(G.start.z+N.z*ut))||(j&&(j.start.copy(I.start).addScaledVector(W,pt),j.end.copy(I.start).addScaledVector(W,pt)),0))}return O.isDegenerateIntoPoint?y(F,O,j):g(O,F,j,Z)}return F.isDegenerateIntoPoint?O.isDegenerateIntoPoint?O.a.distanceToSquared(F.a)<1e-30&&(j&&(j.start.copy(F.a),j.end.copy(F.a)),!0):O.isDegenerateIntoSegment?y(O,F,j):m(O,F,j):O.isDegenerateIntoPoint?m(F,O,j):O.isDegenerateIntoSegment?g(F,O,j,Z):void 0}(this,v,_,b);if(x!==void 0)return x;let w=this.plane,S=v.plane,A=S.distanceToPoint(this.a),E=S.distanceToPoint(this.b),P=S.distanceToPoint(this.c);Ls(A)&&(A=0),Ls(E)&&(E=0),Ls(P)&&(P=0);let T=A*E,R=A*P;if(T>0&&R>0)return!1;let L=w.distanceToPoint(v.a),D=w.distanceToPoint(v.b),U=w.distanceToPoint(v.c);Ls(L)&&(L=0),Ls(D)&&(D=0),Ls(U)&&(U=0);let V=L*D,k=L*U;if(V>0&&k>0)return!1;r.copy(w.normal),s.copy(S.normal);let Y=r.cross(s),$=0,nt=Math.abs(Y.x),Q=Math.abs(Y.y);Q>nt&&(nt=Q,$=1),Math.abs(Y.z)>nt&&($=2);let rt=jJ[$],gt=this.a[rt],at=this.b[rt],ht=this.c[rt],ct=v.a[rt],q=v.b[rt],lt=v.c[rt];if(f(this,gt,at,ht,T,R,A,E,P,h,o))return d(this,v,_,b);if(f(v,ct,q,lt,V,k,L,D,U,u,l))return d(this,v,_,b);if(h.y<h.x){let F=h.y;h.y=h.x,h.x=F,c.copy(o.start),o.start.copy(o.end),o.end.copy(c)}if(u.y<u.x){let F=u.y;u.y=u.x,u.x=F,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return!(h.y<u.x||u.y<h.x||(_&&(u.x>h.x?_.start.copy(l.start):_.start.copy(o.start),u.y<h.y?_.end.copy(l.end):_.end.copy(o.end)),0))}}(),fa.prototype.distanceToPoint=function(){let t=new C;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),fa.prototype.distanceToTriangle=function(){let t=new C,e=new C,i=["a","b","c"],n=new vs,r=new vs;return function(s,a=null,o=null){let l=a||o?n:null;if(this.intersectsTriangle(s,l,!0))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let h=0;h<3;h++){let u,d=i[h],p=s[d];this.closestPointToPoint(p,t),u=p.distanceToSquared(t),u<c&&(c=u,a&&a.copy(t),o&&o.copy(p));let f=this[d];s.closestPointToPoint(f,t),u=f.distanceToSquared(t),u<c&&(c=u,a&&a.copy(f),o&&o.copy(t))}for(let h=0;h<3;h++){let u=i[h],d=i[(h+1)%3];n.set(this[u],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];r.set(s[f],s[g]),NT(n,r,t,e);let m=t.distanceToSquared(e);m<c&&(c=m,a&&a.copy(t),o&&o.copy(e))}}return Math.sqrt(c)}}();var Vr=class{constructor(t,e,i){this.isOrientedBox=!0,this.min=new C,this.max=new C,this.matrix=new At,this.invMatrix=new At,this.points=new Array(8).fill().map(()=>new C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new ao),this.alignedSatBounds=new Array(3).fill().map(()=>new ao),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Vr.prototype.update=function(){let t=this.matrix,e=this.min,i=this.max,n=this.points;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let u=n[1*l|2*c|4*h];u.x=l?i.x:e.x,u.y=c?i.y:e.y,u.z=h?i.z:e.z,u.applyMatrix4(t)}let r=this.satBounds,s=this.satAxes,a=n[0];for(let l=0;l<3;l++){let c=s[l],h=r[l],u=n[1<<l];c.subVectors(a,u),h.setFromPoints(c,n)}let o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Vr.prototype.intersectsBox=function(){let t=new ao;return function(e){this.needsUpdate&&this.update();let i=e.min,n=e.max,r=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(t.min=i.x,t.max=n.x,a[0].isSeparated(t)||(t.min=i.y,t.max=n.y,a[1].isSeparated(t))||(t.min=i.z,t.max=n.z,a[2].isSeparated(t)))return!1;for(let o=0;o<3;o++){let l=s[o],c=r[o];if(t.setFromBox(l,e),c.isSeparated(t))return!1}return!0}}(),Vr.prototype.intersectsTriangle=function(){let t=new fa,e=new Array(3),i=new ao,n=new ao,r=new C;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(t.copy(s),t.update(),s=t);let a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let u=0;u<3;u++){let d=a[u],p=o[u];if(i.setFromPoints(p,e),d.isSeparated(i))return!1}let l=s.satBounds,c=s.satAxes,h=this.points;for(let u=0;u<3;u++){let d=l[u],p=c[u];if(i.setFromPoints(p,h),d.isSeparated(i))return!1}for(let u=0;u<3;u++){let d=o[u];for(let p=0;p<4;p++){let f=c[p];if(r.crossVectors(d,f),i.setFromPoints(r,e),n.setFromPoints(r,h),i.isSeparated(n))return!1}}return!0}}(),Vr.prototype.closestPointToPoint=function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e},Vr.prototype.distanceToPoint=function(){let t=new C;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),Vr.prototype.distanceToBox=function(){let t=["x","y","z"],e=new Array(12).fill().map(()=>new vs),i=new Array(12).fill().map(()=>new vs),n=new C,r=new C;return function(s,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(r),this.closestPointToPoint(r,n),s.closestPointToPoint(n,r),o&&o.copy(n),l&&l.copy(r)),0;let c=a*a,h=s.min,u=s.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];r.copy(m).clamp(h,u);let y=m.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(m),l&&l.copy(r),y<c))return Math.sqrt(y)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){let v=(g+1)%3,_=(g+2)%3,b=1<<g|m<<v|y<<_,x=d[m<<v|y<<_],w=d[b];e[f].set(x,w);let S=t[g],A=t[v],E=t[_],P=i[f],T=P.start,R=P.end;T[S]=h[S],T[A]=m?h[A]:u[A],T[E]=y?h[E]:u[A],R[S]=u[S],R[A]=m?h[A]:u[A],R[E]=y?h[E]:u[A],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){r.x=g?u.x:h.x,r.y=m?u.y:h.y,r.z=y?u.z:h.z,this.closestPointToPoint(r,n);let v=r.distanceToSquared(n);if(v<p&&(p=v,o&&o.copy(n),l&&l.copy(r),v<c))return Math.sqrt(v)}for(let g=0;g<12;g++){let m=e[g];for(let y=0;y<12;y++){let v=i[y];NT(m,v,n,r);let _=n.distanceToSquared(r);if(_<p&&(p=_,o&&o.copy(n),l&&l.copy(r),_<c))return Math.sqrt(_)}}return Math.sqrt(p)}}();var ks=new class extends j3{constructor(){super(()=>new fa)}};et();var tm=new C,yM=new C;et();var my=parseInt(el)>=169,GJ=parseInt(el)<=161,ac=new C,oc=new C,lc=new C,gy=new it,vy=new it,yy=new it,AB=new C,TB=new C,CB=new C,em=new C;function PB(t,e,i,n,r,s,a,o,l,c,h){ac.fromBufferAttribute(e,s),oc.fromBufferAttribute(e,a),lc.fromBufferAttribute(e,o);let u=function(d,p,f,g,m,y,v,_){let b;if(b=y===qn?d.intersectTriangle(g,f,p,!0,m):d.intersectTriangle(p,f,g,y!==Hn,m),b===null)return null;let x=d.origin.distanceTo(m);return x<v||x>_?null:{distance:x,point:m.clone()}}(t,ac,oc,lc,em,l,c,h);if(u){if(n){gy.fromBufferAttribute(n,s),vy.fromBufferAttribute(n,a),yy.fromBufferAttribute(n,o),u.uv=new it;let p=pn.getInterpolation(em,ac,oc,lc,gy,vy,yy,u.uv);my||(u.uv=p)}if(r){gy.fromBufferAttribute(r,s),vy.fromBufferAttribute(r,a),yy.fromBufferAttribute(r,o),u.uv1=new it;let p=pn.getInterpolation(em,ac,oc,lc,gy,vy,yy,u.uv1);my||(u.uv1=p),GJ&&(u.uv2=u.uv1)}if(i){AB.fromBufferAttribute(i,s),TB.fromBufferAttribute(i,a),CB.fromBufferAttribute(i,o),u.normal=new C;let p=pn.getInterpolation(em,ac,oc,lc,AB,TB,CB,u.normal);u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1),my||(u.normal=p)}let d={a:s,b:a,c:o,normal:new C,materialIndex:0};if(pn.getNormal(ac,oc,lc,d.normal),u.face=d,u.faceIndex=s,my){let p=new C;pn.getBarycoord(em,ac,oc,lc,p),u.barycoord=p}}return u}function DB(t){return t&&t.isMaterial?t.side:t}function xx(t,e,i,n,r,s,a){let o=3*n,l=o+0,c=o+1,h=o+2,{index:u,groups:d}=t;t.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));let{position:p,normal:f,uv:g,uv1:m}=t.attributes;if(Array.isArray(e)){let y=3*n;for(let v=0,_=d.length;v<_;v++){let{start:b,count:x,materialIndex:w}=d[v];if(y>=b&&y<b+x){let S=PB(i,p,f,g,m,l,c,h,DB(e[w]),s,a);if(S){if(S.faceIndex=n,S.face.materialIndex=w,!r)return S;r.push(S)}}}}else{let y=PB(i,p,f,g,m,l,c,h,DB(e),s,a);if(y){if(y.faceIndex=n,y.face.materialIndex=0,!r)return y;r.push(y)}}return null}function Pn(t,e,i,n){let r=t.a,s=t.b,a=t.c,o=e,l=e+1,c=e+2;i&&(o=i.getX(o),l=i.getX(l),c=i.getX(c)),r.x=n.getX(o),r.y=n.getY(o),r.z=n.getZ(o),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),a.x=n.getX(c),a.y=n.getY(c),a.z=n.getZ(c)}function HJ(t,e,i,n,r,s,a){let{geometry:o}=i,{index:l}=o,c=o.attributes.position;for(let h=t,u=e+t;h<u;h++){let d;if(d=h,Pn(a,3*d,l,c),a.needsUpdate=!0,n(a,d,r,s))return!0}return!1}function WJ(t,e=null){e&&Array.isArray(e)&&(e=new Set(e));let i,n,r,s,a=t.geometry,o=a.index?a.index.array:null,l=a.attributes.position,c=0,h=t._roots;for(let d=0,p=h.length;d<p;d++)i=h[d],n=new Uint32Array(i),r=new Uint16Array(i),s=new Float32Array(i),u(0,c),c+=i.byteLength;function u(d,p,f=!1){let g=2*d;if(Wn(g,r)){let m=Dr(d,n),y=1/0,v=1/0,_=1/0,b=-1/0,x=-1/0,w=-1/0;for(let S=3*m,A=3*(m+Gr(g,r));S<A;S++){let E=o[S],P=l.getX(E),T=l.getY(E),R=l.getZ(E);P<y&&(y=P),P>b&&(b=P),T<v&&(v=T),T>x&&(x=T),R<_&&(_=R),R>w&&(w=R)}return(s[d+0]!==y||s[d+1]!==v||s[d+2]!==_||s[d+3]!==b||s[d+4]!==x||s[d+5]!==w)&&(s[d+0]=y,s[d+1]=v,s[d+2]=_,s[d+3]=b,s[d+4]=x,s[d+5]=w,!0)}{let m=sr(d),y=ar(d,n),v=f,_=!1,b=!1;if(e){if(!v){let E=m/8+p/32,P=y/8+p/32;_=e.has(E),b=e.has(P),v=!_&&!b}}else _=!0,b=!0;let x=v||b,w=!1;(v||_)&&(w=u(m,p,v));let S=!1;x&&(S=u(y,p,v));let A=w||S;if(A)for(let E=0;E<3;E++){let P=m+E,T=y+E,R=s[P],L=s[P+3],D=s[T],U=s[T+3];s[d+E]=R<D?R:D,s[d+E+3]=L>U?L:U}return A}}}function vh(t,e,i,n,r){let s,a,o,l,c,h,u=1/i.direction.x,d=1/i.direction.y,p=1/i.direction.z,f=i.origin.x,g=i.origin.y,m=i.origin.z,y=e[t],v=e[t+3],_=e[t+1],b=e[t+3+1],x=e[t+2],w=e[t+3+2];return u>=0?(s=(y-f)*u,a=(v-f)*u):(s=(v-f)*u,a=(y-f)*u),d>=0?(o=(_-g)*d,l=(b-g)*d):(o=(b-g)*d,l=(_-g)*d),!(s>l||o>a||((o>s||isNaN(s))&&(s=o),(l<a||isNaN(a))&&(a=l),p>=0?(c=(x-m)*p,h=(w-m)*p):(c=(w-m)*p,h=(x-m)*p),s>h||c>a))&&((c>s||s!=s)&&(s=c),(h<a||a!=a)&&(a=h),s<=r&&a>=n)}function qJ(t,e,i,n,r,s,a){let{geometry:o}=i,{index:l}=o,c=o.attributes.position;for(let h=t,u=e+t;h<u;h++){let d;if(d=i.resolveTriangleIndex(h),Pn(a,3*d,l,c),a.needsUpdate=!0,n(a,d,r,s))return!0}return!1}function XJ(t,e,i,n,r,s,a){Bi.setBuffer(t._roots[e]),kT(0,t,i,n,r,s,a),Bi.clearBuffer()}function kT(t,e,i,n,r,s,a){let{float32Array:o,uint16Array:l,uint32Array:c}=Bi,h=2*t;if(Wn(h,l))(function(u,d,p,f,g,m,y,v){let{geometry:_,_indirectBuffer:b}=u;for(let x=f,w=f+g;x<w;x++)xx(_,d,p,x,m,y,v)})(e,i,n,Dr(t,c),Gr(h,l),r,s,a);else{let u=sr(t);vh(u,o,n,s,a)&&kT(u,e,i,n,r,s,a);let d=ar(t,c);vh(d,o,n,s,a)&&kT(d,e,i,n,r,s,a)}}var $J=["x","y","z"];function YJ(t,e,i,n,r,s){Bi.setBuffer(t._roots[e]);let a=VT(0,t,i,n,r,s);return Bi.clearBuffer(),a}function VT(t,e,i,n,r,s){let{float32Array:a,uint16Array:o,uint32Array:l}=Bi,c=2*t;if(Wn(c,o))return function(h,u,d,p,f,g,m){let{geometry:y,_indirectBuffer:v}=h,_=1/0,b=null;for(let x=p,w=p+f;x<w;x++){let S;S=xx(y,u,d,x,null,g,m),S&&S.distance<_&&(b=S,_=S.distance)}return b}(e,i,n,Dr(t,l),Gr(c,o),r,s);{let h,u,d=V3(t,l),p=$J[d],f=n.direction[p]>=0;f?(h=sr(t),u=ar(t,l)):(h=ar(t,l),u=sr(t));let g=vh(h,a,n,r,s)?VT(h,e,i,n,r,s):null;if(g){let y=g.point[p];if(f?y<=a[u+d]:y>=a[u+d+3])return g}let m=vh(u,a,n,r,s)?VT(u,e,i,n,r,s):null;return g&&m?g.distance<=m.distance?g:m:g||m||null}}et();var _y=new ci,nu=new fa,ru=new fa,im=new At,RB=new Vr,by=new Vr;function ZJ(t,e,i,n){Bi.setBuffer(t._roots[e]);let r=jT(0,t,i,n);return Bi.clearBuffer(),r}function jT(t,e,i,n,r=null){let{float32Array:s,uint16Array:a,uint32Array:o}=Bi,l=2*t;if(r===null&&(i.boundingBox||i.computeBoundingBox(),RB.set(i.boundingBox.min,i.boundingBox.max,n),r=RB),!Wn(l,a)){let c=sr(t),h=ar(t,o);return Qi(c,s,_y),!!(r.intersectsBox(_y)&&jT(c,e,i,n,r)||(Qi(h,s,_y),r.intersectsBox(_y)&&jT(h,e,i,n,r)))}{let c=e.geometry,h=c.index,u=c.attributes.position,d=i.index,p=i.attributes.position,f=Dr(t,o),g=Gr(l,a);if(im.copy(n).invert(),i.boundsTree)return Qi(t,s,by),by.matrix.copy(im),by.needsUpdate=!0,i.boundsTree.shapecast({intersectsBounds:m=>by.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(n),m.b.applyMatrix4(n),m.c.applyMatrix4(n),m.needsUpdate=!0;for(let y=3*f,v=3*(g+f);y<v;y+=3)if(Pn(ru,y,h,u),ru.needsUpdate=!0,m.intersectsTriangle(ru))return!0;return!1}});{let m=bx(i);for(let y=3*f,v=3*(g+f);y<v;y+=3){Pn(nu,y,h,u),nu.a.applyMatrix4(im),nu.b.applyMatrix4(im),nu.c.applyMatrix4(im),nu.needsUpdate=!0;for(let _=0,b=3*m;_<b;_+=3)if(Pn(ru,_,d,p),ru.needsUpdate=!0,nu.intersectsTriangle(ru))return!0}}}}et();var xy=new At,_M=new Vr,nm=new Vr,KJ=new C,QJ=new C,JJ=new C,ttt=new C;function ett(t,e,i,n={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),_M.set(e.boundingBox.min,e.boundingBox.max,i),_M.needsUpdate=!0;let o=t.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,u=e.index,d=ks.getPrimitive(),p=ks.getPrimitive(),f=KJ,g=QJ,m=null,y=null;r&&(m=JJ,y=ttt);let v=1/0,_=null,b=null;return xy.copy(i).invert(),nm.matrix.copy(xy),t.shapecast({boundsTraverseOrder:x=>_M.distanceToBox(x),intersectsBounds:(x,w,S)=>S<v&&S<a&&(w&&(nm.min.copy(x.min),nm.max.copy(x.max),nm.needsUpdate=!0),!0),intersectsRange:(x,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>nm.distanceToBox(S),intersectsBounds:(S,A,E)=>E<v&&E<a,intersectsRange:(S,A)=>{for(let E=S,P=S+A;E<P;E++){Pn(p,3*E,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let T=x,R=x+w;T<R;T++){Pn(d,3*T,c,l),d.needsUpdate=!0;let L=d.distanceToTriangle(p,f,m);if(L<v&&(g.copy(f),y&&y.copy(m),v=L,_=T,b=E),L<s)return!0}}}});for(let S=0,A=bx(e);S<A;S++){Pn(p,3*S,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let E=x,P=x+w;E<P;E++){Pn(d,3*E,c,l),d.needsUpdate=!0;let T=d.distanceToTriangle(p,f,m);if(T<v&&(g.copy(f),y&&y.copy(m),v=T,_=E,b=S),T<s)return!0}}}}),ks.releasePrimitive(d),ks.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(g):n.point=g.clone(),n.distance=v,n.faceIndex=_,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(xy),g.applyMatrix4(xy),r.distance=g.sub(r.point).length(),r.faceIndex=b),n)}function itt(t,e=null){e&&Array.isArray(e)&&(e=new Set(e));let i,n,r,s,a=t.geometry,o=a.index?a.index.array:null,l=a.attributes.position,c=0,h=t._roots;for(let d=0,p=h.length;d<p;d++)i=h[d],n=new Uint32Array(i),r=new Uint16Array(i),s=new Float32Array(i),u(0,c),c+=i.byteLength;function u(d,p,f=!1){let g=2*d;if(Wn(g,r)){let m=Dr(d,n),y=1/0,v=1/0,_=1/0,b=-1/0,x=-1/0,w=-1/0;for(let S=m,A=m+Gr(g,r);S<A;S++){let E=3*t.resolveTriangleIndex(S);for(let P=0;P<3;P++){let T=E+P;T=o?o[T]:T;let R=l.getX(T),L=l.getY(T),D=l.getZ(T);R<y&&(y=R),R>b&&(b=R),L<v&&(v=L),L>x&&(x=L),D<_&&(_=D),D>w&&(w=D)}}return(s[d+0]!==y||s[d+1]!==v||s[d+2]!==_||s[d+3]!==b||s[d+4]!==x||s[d+5]!==w)&&(s[d+0]=y,s[d+1]=v,s[d+2]=_,s[d+3]=b,s[d+4]=x,s[d+5]=w,!0)}{let m=sr(d),y=ar(d,n),v=f,_=!1,b=!1;if(e){if(!v){let E=m/8+p/32,P=y/8+p/32;_=e.has(E),b=e.has(P),v=!_&&!b}}else _=!0,b=!0;let x=v||b,w=!1;(v||_)&&(w=u(m,p,v));let S=!1;x&&(S=u(y,p,v));let A=w||S;if(A)for(let E=0;E<3;E++){let P=m+E,T=y+E,R=s[P],L=s[P+3],D=s[T],U=s[T+3];s[d+E]=R<D?R:D,s[d+E+3]=L>U?L:U}return A}}}function ntt(t,e,i,n,r,s,a){Bi.setBuffer(t._roots[e]),GT(0,t,i,n,r,s,a),Bi.clearBuffer()}function GT(t,e,i,n,r,s,a){let{float32Array:o,uint16Array:l,uint32Array:c}=Bi,h=2*t;if(Wn(h,l))(function(u,d,p,f,g,m,y,v){let{geometry:_,_indirectBuffer:b}=u;for(let x=f,w=f+g;x<w;x++)xx(_,d,p,b?b[x]:x,m,y,v)})(e,i,n,Dr(t,c),Gr(h,l),r,s,a);else{let u=sr(t);vh(u,o,n,s,a)&&GT(u,e,i,n,r,s,a);let d=ar(t,c);vh(d,o,n,s,a)&&GT(d,e,i,n,r,s,a)}}var rtt=["x","y","z"];function stt(t,e,i,n,r,s){Bi.setBuffer(t._roots[e]);let a=HT(0,t,i,n,r,s);return Bi.clearBuffer(),a}function HT(t,e,i,n,r,s){let{float32Array:a,uint16Array:o,uint32Array:l}=Bi,c=2*t;if(Wn(c,o))return function(h,u,d,p,f,g,m){let{geometry:y,_indirectBuffer:v}=h,_=1/0,b=null;for(let x=p,w=p+f;x<w;x++){let S;S=xx(y,u,d,v?v[x]:x,null,g,m),S&&S.distance<_&&(b=S,_=S.distance)}return b}(e,i,n,Dr(t,l),Gr(c,o),r,s);{let h,u,d=V3(t,l),p=rtt[d],f=n.direction[p]>=0;f?(h=sr(t),u=ar(t,l)):(h=ar(t,l),u=sr(t));let g=vh(h,a,n,r,s)?HT(h,e,i,n,r,s):null;if(g){let y=g.point[p];if(f?y<=a[u+d]:y>=a[u+d+3])return g}let m=vh(u,a,n,r,s)?HT(u,e,i,n,r,s):null;return g&&m?g.distance<=m.distance?g:m:g||m||null}}et();var wy=new ci,su=new fa,au=new fa,rm=new At,IB=new Vr,Sy=new Vr;function att(t,e,i,n){Bi.setBuffer(t._roots[e]);let r=WT(0,t,i,n);return Bi.clearBuffer(),r}function WT(t,e,i,n,r=null){let{float32Array:s,uint16Array:a,uint32Array:o}=Bi,l=2*t;if(r===null&&(i.boundingBox||i.computeBoundingBox(),IB.set(i.boundingBox.min,i.boundingBox.max,n),r=IB),!Wn(l,a)){let c=sr(t),h=ar(t,o);return Qi(c,s,wy),!!(r.intersectsBox(wy)&&WT(c,e,i,n,r)||(Qi(h,s,wy),r.intersectsBox(wy)&&WT(h,e,i,n,r)))}{let c=e.geometry,h=c.index,u=c.attributes.position,d=i.index,p=i.attributes.position,f=Dr(t,o),g=Gr(l,a);if(rm.copy(n).invert(),i.boundsTree)return Qi(t,s,Sy),Sy.matrix.copy(rm),Sy.needsUpdate=!0,i.boundsTree.shapecast({intersectsBounds:m=>Sy.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(n),m.b.applyMatrix4(n),m.c.applyMatrix4(n),m.needsUpdate=!0;for(let y=f,v=g+f;y<v;y++)if(Pn(au,3*e.resolveTriangleIndex(y),h,u),au.needsUpdate=!0,m.intersectsTriangle(au))return!0;return!1}});{let m=bx(i);for(let y=f,v=g+f;y<v;y++){let _=e.resolveTriangleIndex(y);Pn(su,3*_,h,u),su.a.applyMatrix4(rm),su.b.applyMatrix4(rm),su.c.applyMatrix4(rm),su.needsUpdate=!0;for(let b=0,x=3*m;b<x;b+=3)if(Pn(au,b,d,p),au.needsUpdate=!0,su.intersectsTriangle(au))return!0}}}}et();var My=new At,bM=new Vr,sm=new Vr,ott=new C,ltt=new C,htt=new C,ctt=new C;function dtt(t,e,i,n={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),bM.set(e.boundingBox.min,e.boundingBox.max,i),bM.needsUpdate=!0;let o=t.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,u=e.index,d=ks.getPrimitive(),p=ks.getPrimitive(),f=ott,g=ltt,m=null,y=null;r&&(m=htt,y=ctt);let v=1/0,_=null,b=null;return My.copy(i).invert(),sm.matrix.copy(My),t.shapecast({boundsTraverseOrder:x=>bM.distanceToBox(x),intersectsBounds:(x,w,S)=>S<v&&S<a&&(w&&(sm.min.copy(x.min),sm.max.copy(x.max),sm.needsUpdate=!0),!0),intersectsRange:(x,w)=>{if(e.boundsTree){let S=e.boundsTree;return S.shapecast({boundsTraverseOrder:A=>sm.distanceToBox(A),intersectsBounds:(A,E,P)=>P<v&&P<a,intersectsRange:(A,E)=>{for(let P=A,T=A+E;P<T;P++){let R=S.resolveTriangleIndex(P);Pn(p,3*R,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let L=x,D=x+w;L<D;L++){let U=t.resolveTriangleIndex(L);Pn(d,3*U,c,l),d.needsUpdate=!0;let V=d.distanceToTriangle(p,f,m);if(V<v&&(g.copy(f),y&&y.copy(m),v=V,_=L,b=P),V<s)return!0}}}})}for(let S=0,A=bx(e);S<A;S++){Pn(p,3*S,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let E=x,P=x+w;E<P;E++){let T=t.resolveTriangleIndex(E);Pn(d,3*T,c,l),d.needsUpdate=!0;let R=d.distanceToTriangle(p,f,m);if(R<v&&(g.copy(f),y&&y.copy(m),v=R,_=E,b=S),R<s)return!0}}}}),ks.releasePrimitive(d),ks.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(g):n.point=g.clone(),n.distance=v,n.faceIndex=_,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(My),g.applyMatrix4(My),r.distance=g.sub(r.point).length(),r.faceIndex=b),n)}function OB(t,e,i){return t===null?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(i.ray.origin),t.object=e,t)}var Ey=new Vr,Ay=new $o,LB=new C,BB=new At,UB=new C,xM=["getX","getY","getZ"],qT=class extends NJ{static serialize(t,e={}){e={cloneBuffers:!0,...e};let i=t.geometry,n=t._roots,r=t._indirectBuffer,s=i.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return e.cloneBuffers?(a.roots=n.map(o=>o.slice()),a.index=s?s.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=n,a.index=s?s.array:null,a.indirectBuffer=r),a}static deserialize(t,e,i={}){i={setIndex:!0,indirect:Boolean(t.indirectBuffer),...i};let{index:n,roots:r,indirectBuffer:s}=t;t.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),function(o){for(let l=0;l<o.length;l++){let c=o[l],h=new Uint32Array(c),u=new Uint16Array(c);for(let d=0,p=c.byteLength/32;d<p;d++){let f=8*d;Wn(2*f,u)||(h[f+6]=h[f+6]/8-d)}}}(r));let a=new qT(e,{...i,[k3]:!0});if(a._roots=r,a._indirectBuffer=s||null,i.setIndex){let o=e.getIndex();if(o===null){let l=new Ht(t.index,1,!1);e.setIndex(l)}else o.array!==n&&(o.array.set(n),o.needsUpdate=!0)}return a}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(t,e={}){e.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),e={...e,maxLeafSize:e.maxLeafTris}),super(t,e)}shiftTriangleOffsets(t){return super.shiftPrimitiveOffsets(t)}writePrimitiveBounds(t,e,i){let n=this.geometry,r=this._indirectBuffer,s=n.attributes.position,a=n.index?n.index.array:null,o=3*(r?r[t]:t),l=o+0,c=o+1,h=o+2;a&&(l=a[l],c=a[c],h=a[h]);for(let u=0;u<3;u++){let d=s[xM[u]](l),p=s[xM[u]](c),f=s[xM[u]](h),g=d;p<g&&(g=p),f<g&&(g=f);let m=d;p>m&&(m=p),f>m&&(m=f),e[i+u]=g,e[i+u+3]=m}return e}computePrimitiveBounds(t,e,i){let n=this.geometry,r=this._indirectBuffer,s=n.attributes.position,a=n.index?n.index.array:null,o=s.normalized;if(t<0||e+t-i.offset>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");let l=s.array,c=s.offset||0,h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);let u=["getX","getY","getZ"],d=i.offset;for(let p=t,f=t+e;p<f;p++){let g=3*(r?r[p]:p),m=6*(p-d),y=g+0,v=g+1,_=g+2;a&&(y=a[y],v=a[v],_=a[_]),o||(y=y*h+c,v=v*h+c,_=_*h+c);for(let b=0;b<3;b++){let x,w,S;o?(x=s[u[b]](y),w=s[u[b]](v),S=s[u[b]](_)):(x=l[y+b],w=l[v+b],S=l[_+b]);let A=x;w<A&&(A=w),S<A&&(A=S);let E=x;w>E&&(E=w),S>E&&(E=S);let P=(E-A)/2,T=2*b;i[m+T+0]=A+P,i[m+T+1]=P+(Math.abs(A)+P)*D1}}return i}raycastObject3D(t,e,i=[]){let{material:n}=t;if(n===void 0)return;BB.copy(t.matrixWorld).invert(),Ay.copy(e.ray).applyMatrix4(BB),UB.setFromMatrixScale(t.matrixWorld),LB.copy(Ay.direction).multiply(UB);let r=LB.length(),s=e.near/r,a=e.far/r;if(e.firstHitOnly===!0){let o=this.raycastFirst(Ay,n,s,a);o=OB(o,t,e),o&&i.push(o)}else{let o=this.raycast(Ay,n,s,a);for(let l=0,c=o.length;l<c;l++){let h=OB(o[l],t,e);h&&i.push(h)}}return i}refit(t=null){return(this.indirect?itt:WJ)(this,t)}raycast(t,e=Vs,i=0,n=1/0){let r=this._roots,s=[],a=this.indirect?ntt:XJ;for(let o=0,l=r.length;o<l;o++)a(this,o,e,t,s,i,n);return s}raycastFirst(t,e=Vs,i=0,n=1/0){let r=this._roots,s=null,a=this.indirect?stt:YJ;for(let o=0,l=r.length;o<l;o++){let c=a(this,o,e,t,i,n);c!=null&&(s==null||c.distance<s.distance)&&(s=c)}return s}intersectsGeometry(t,e){let i=!1,n=this._roots,r=this.indirect?att:ZJ;for(let s=0,a=n.length;s<a&&(i=r(this,s,t,e),!i);s++);return i}shapecast(t){let e=ks.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?qJ:HJ});return ks.releasePrimitive(e),i}bvhcast(t,e,i){let{intersectsRanges:n,intersectsTriangles:r}=i,s=ks.getPrimitive(),a=this.geometry.index,o=this.geometry.attributes.position,l=this.indirect?p=>{let f=this.resolveTriangleIndex(p);Pn(s,3*f,a,o)}:p=>{Pn(s,3*p,a,o)},c=ks.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,d=t.indirect?p=>{let f=t.resolveTriangleIndex(p);Pn(c,3*f,h,u)}:p=>{Pn(c,3*p,h,u)};if(r){if(!(t instanceof qT))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');let p=(f,g,m,y,v,_,b,x)=>{for(let w=m,S=m+y;w<S;w++){d(w),c.a.applyMatrix4(e),c.b.applyMatrix4(e),c.c.applyMatrix4(e),c.needsUpdate=!0;for(let A=f,E=f+g;A<E;A++)if(l(A),s.needsUpdate=!0,r(s,c,A,w,v,_,b,x))return!0}return!1};if(n){let f=n;n=function(g,m,y,v,_,b,x,w){return!!f(g,m,y,v,_,b,x,w)||p(g,m,y,v,_,b,x,w)}}else n=p}return super.bvhcast(t,e,{intersectsRanges:n})}intersectsBox(t,e){return Ey.set(t.min,t.max,e),Ey.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Ey.intersectsBox(i),intersectsTriangle:i=>Ey.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},n={},r=0,s=1/0){return(this.indirect?dtt:ett)(this,t,e,i,n,r,s)}closestPointToPoint(t,e={},i=0,n=1/0){return function(r,s,a={},o=0,l=1/0){let c=o*o,h=l*l,u=1/0,d=null;if(r.shapecast({boundsTraverseOrder:f=>(tm.copy(s).clamp(f.min,f.max),tm.distanceToSquared(s)),intersectsBounds:(f,g,m)=>m<u&&m<h,intersectsTriangle:(f,g)=>{f.closestPointToPoint(s,tm);let m=s.distanceToSquared(tm);return m<u&&(yM.copy(tm),u=m,d=g),m<c}}),u===1/0)return null;let p=Math.sqrt(u);return a.point?a.point.copy(yM):a.point=yM.clone(),a.distance=p,a.faceIndex=d,a}(this,t,e,i,n)}};ke(),JV=qT,Si("collision-bvh"),Li(),ii(),ol();var utt=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.entered=!1,this.actions=Rn(e,e.actions,n,r,s,i)}disconnect(){rr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatchStart()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()),this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},ptt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{ae.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{ae.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{ae.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:n,reverse:r})=>{if(!i||!n)return;let s=i0(i);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(a=>a.dispatchUserEvent(r)))}}connect(){let{page:t,sharedAssets:e}=this.eventContext,i=(r,s)=>{if(r.visible&&r.data?.events.length){for(let{id:a,data:o}of r.data.events)if(!o.disabled&&o.type==="MouseHover")try{let l=new utt(a,o,r,t,e,this.eventManager);this.eventsPerObjects[r.uuid]?this.eventsPerObjects[r.uuid].push(l):this.eventsPerObjects[r.uuid]=[l]}catch{}this.eventsPerObjects[r.uuid]?.length&&this.objects.push(as(r)?s:r)}};if(t.traverseEntity(r=>{(Cr(r)||r instanceof un)&&r.frame?.traverse(s=>{i(s,r)}),i(r)}),!this.objects.length)return;let{domElement:n}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),n.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),n.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),ss&&(t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp)),t.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(e=>{e.forEach(i=>{i.disconnect()})}),this.objects.forEach(e=>{e.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(t=!1){let e=[];if(!t){let{stopRaycast:i,raycaster:n,page:r,pointerScreen:s}=this.eventContext,a=!1;if(r.uiCanvas&&(a=ko(r,[s.x,s.y],Object.keys(this.eventsPerObjects),o=>{e.push(o)})),i&&!a){let o=A1(n,r,this.objects);e=MT(o),o.forEach(l=>{Cr(l.object)&&ko(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),c=>{e.push(c)})})}else this.objects.forEach(o=>{let l=gb(n,o);l&&(e.push(o),Cr(o)&&ko(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),c=>{e.push(c)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{e.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(n=>n.dispatchLeave()))}),e.length&&e.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(n=>n.dispatchEnter())}),this._prevObjects=e}};ke(),xs("MouseHover",({eventContext:t,eventManager:e})=>new ptt(t,e)),Si("mousehover"),Li(),ol();var ftt=class{constructor(){this.elapsed=0,this.lastRealTimeMs=null,this.paused=!1}get time(){return this.elapsed}tick(t){let e=0;return this.lastRealTimeMs!==null&&(e=Math.min((t-this.lastRealTimeMs)/1e3,.25),e<0&&(e=0)),this.lastRealTimeMs=t,this.paused||(this.elapsed+=e),this.elapsed}step(t){return this.paused||(this.elapsed+=t),this.elapsed}resync(t){this.lastRealTimeMs=t}seek(t){this.elapsed=t}reset(){this.elapsed=0,this.lastRealTimeMs=null,this.paused=!1}},ye=Math.fround,mtt=[.01,100],gtt=[.01,1e4],vtt=[.01,1e3],ytt=[.01,1e3];function Ty(t,[e,i]){return Math.min(Math.max(t,e),i)}function hj(t,e,i,n,r){t=Ty(t,mtt),e=Ty(e,gtt),i=Ty(i,vtt),n=Ty(n,ytt);let s=Math.sqrt(e/t),a=i/(2*Math.sqrt(e*t)),o=a<1?s*Math.sqrt(1-a*a):0,l=a<1?(a*s-n)/o:-n+s;return c=>{let h=r!==void 0?r*c:c;return h=a<1?Math.exp(-h*a*s)*(1*Math.cos(o*h)+l*Math.sin(o*h)):(1+l*h)*Math.exp(-h*s),c===0||c===1?c:1-h}}var _tt=ye(.001),btt=ye(1e-7),Cy=ye(.1);function cj(t,e){return ye(ye(1-ye(3*e))+ye(3*t))}function dj(t,e){return ye(ye(3*e)-ye(6*t))}function uj(t){return ye(3*t)}function Py(t,e,i){return ye(ye(ye(ye(ye(cj(e,i)*t)+dj(e,i))*t)+uj(e))*t)}function zB(t,e,i){let n=ye(ye(ye(3*cj(e,i))*t)*t),r=ye(ye(2*dj(e,i))*t);return ye(ye(n+r)+uj(e))}var xtt=t=>t;function ou(t,e,i,n){if(t=ye(t),e=ye(e),i=ye(i),n=ye(n),t<0||t>1||i<0||i>1||t===e&&i===n)return xtt;let r=new Float32Array(11);for(let s=0;s<11;s++)r[s]=Py(ye(s*Cy),t,i);return s=>(s=ye(s))===0||s===1?s:Py((a=>{let o=0,l=1;for(;l!==10&&r[l]<=a;)o=ye(o+Cy),l+=1;l-=1;let c=ye(ye(a-r[l])/ye(r[l+1]-r[l])),h=ye(o+ye(c*Cy)),u=zB(h,t,i);return u>=_tt?function(d,p,f,g){for(let m=0;m<4;m++){let y=zB(p,f,g);if(y===0)return p;let v=ye(Py(p,f,g)-d);p=ye(p-ye(v/y))}return p}(a,h,t,i):u===0?h:function(d,p,f,g,m){let y,v=0,_=0;do v=ye(p+ye(ye(f-p)/2)),y=ye(Py(v,g,m)-d),y>0?f=v:p=v,_+=1;while(Math.abs(y)>btt&&_<10);return v}(a,o,ye(o+Cy),t,i)})(s),e,n)}var wtt=ye(1.70158);function pj(t,e,i){switch(t.easing){case 0:default:return i;case 1:return ou(.25,.1,.25,1)(i);case 2:return ou(.42,0,1,1)(i);case 3:return ou(0,0,.58,1)(i);case 4:return ou(.42,0,.58,1)(i);case 7:return ou(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:n,control2:r}=t;return n&&r?ou(n[0],n[1],r[0],r[1])(i):i}case 6:{let{mass:n,stiffness:r,damping:s,velocity:a}=t;return n===void 0||r===void 0||s===void 0||a===void 0?i:ye(hj(n,r,s,a,e)(i))}}}ye(wtt+1);var pr=Math.fround;function wM(t){return t==="pingpong"||t==="pingpong-rewind"}var Stt=class{constructor(t){this.config=t,this.effectiveCycleDuration=this.cycleDuration(0)}layout(t){let{config:e}=this;if(wM(e.direction)&&t%2==1)return{startDelay:0,endDelay:0};switch(e.delayDirection){case"start-once":return t===0?{startDelay:e.delay,endDelay:0}:{startDelay:0,endDelay:0};case"start":return{startDelay:e.delay,endDelay:0};case"end":return{startDelay:0,endDelay:e.delay};default:return{startDelay:e.delay,endDelay:e.delay}}}cycleDuration(t){let{config:e}=this,{startDelay:i,endDelay:n}=this.layout(t);return pr(e.duration+i+n)}get totalDuration(){let{config:t}=this;if(t.repeat===-1)return 1/0;let e=0;for(let i=0;i<=t.repeat;i++)e=pr(e+this.cycleDuration(i));return e}isFinished(t){return t>=this.totalDuration}resolve(t){let e,i,{config:n}=this,r=pr(t);if(n.delayDirection==="start-once"){let h=pr(n.delay+n.duration);if(r<h)e=0,i=r;else{let u=pr(r-h);e=1+Math.floor(pr(u/n.duration)),i=pr(u%n.duration)}}else if(wM(n.direction)){let h=this.cycleDuration(0),u=pr(h+n.duration),d=Math.floor(pr(r/u)),p=pr(r%u);p<h?(e=2*d,i=p):(e=2*d+1,i=pr(p-h))}else{let h=this.cycleDuration(0);e=Math.floor(pr(r/h)),i=pr(r%h)}if(n.repeat!==-1&&e>=n.repeat+1)return null;let s,{startDelay:a}=this.layout(e),o=wM(n.direction)&&e%2==1,l=a,c=pr(l+n.duration);if(i<l)s=o?n.duration:0;else if(i>=c)s=o?0:n.duration;else{let h=pr(i-l);s=o?pr(n.duration-h):h}return{cycleIndex:e,localTime:s,isReverse:o}}},SM=Math.fround;function Mtt(t){return[...t].sort((e,i)=>e.time-i.time)}var am=Math.fround;function Fc(t){return Math.round(1e9*t)}function Tb(t,e){return(Fc(t)+Fc(e))/1e9}function MM(t,e,i){return Fc(t)-Fc(e)<Fc(i)}var Ett=Math.fround;function FB(t){return t==="pingpong"||t==="pingpong-rewind"}function NB(t,e){return e?t==="start"?"end":t==="end"?"start":t:t}var fj=class{constructor(t,e,i={}){this.hooks=i,this.isPlaying=!1,this.playingIndex=0,this.seekIndex=-1,this.currentRepeat=0,this.isReversed=!1,this.startTime=0,this.isToggledForward=!1,this.hasPlayedOnce=!1,this.isFirstTweenAfterStart=!1,this.hasClaimed=!1,this.config=t,this.tweens=e,this.delay=Ett(t.delay/1e3)}get currentTween(){return this.tweens[this.playingIndex]}play(t){if(this.tweens.length===0||this.isPlaying&&this.config.runMode!=="Toggle"||this.hasPlayedOnce&&this.config.runMode==="Once")return;let e=this.isPlaying;this.isPlaying=!0,this.hasPlayedOnce=!0,this.currentRepeat=this.config.repeat,this.startTime=t,this.seekIndex=-1,this.hooks.isOwner?.()===!1&&(this.isToggledForward=!1,!e&&!this.isReversed&&this.hooks.assignCurrentState?.()),this.hasClaimed=!1,this.config.runMode==="Toggle"?(this.toggleDirection(),e?this.openPass():this.startChain()):this.startChain()}stop(){this.currentTween?.stop(),this.isPlaying=!1,this.isReversed=!1,this.hasClaimed=!1}playDirected(t,e){if(this.tweens.length===0)return;let i=this.isPlaying;i&&this.isForward===e||(this.isPlaying=!0,this.hasPlayedOnce=!0,this.currentRepeat=this.config.repeat,this.startTime=t,this.seekIndex=-1,this.isToggledForward=e,this.isReversed=!e,this.hooks.isOwner?.()===!1&&!i&&!this.isReversed&&this.hooks.assignCurrentState?.(),this.hasClaimed=!1,i?this.openPass():this.startChain())}get isAnimating(){return this.isPlaying&&this.hasClaimed}get isForward(){return!this.isReversed}seek(t){if(this.tweens.length===0)return;this.hooks.claim?.();let e=this.tweens.reduce((s,a)=>s+a.duration,0)*t,i=this.tweens.length-1,n=1,r=0;for(let s=0;s<this.tweens.length;s++){let a=this.tweens[s];if(r+a.duration>e){i=s,n=(e-r)/a.duration;break}r+=a.duration}for(this.seekIndex===-1&&(this.seekIndex=0);this.seekIndex<i;)this.tweens[this.seekIndex].seek(1),this.seekIndex+=1,this.tweens[this.seekIndex].rearm();for(;this.seekIndex>i;)this.tweens[this.seekIndex].seek(0),this.seekIndex-=1;this.tweens[i].seek(n)}update(t){if(!this.isPlaying)return;if(this.claimWhenDue(t)&&this.currentTween.rearm(),this.hasClaimed&&this.hooks.isOwner?.()===!1)return void this.stop();let e=NB(this.config.delayDirection,this.isReversed);if(MM(t,this.startTime,this.leadingDelay)||(this.currentTween.update(t),!this.isPlaying)||this.currentTween.isPlaying)return;if(this.isFirstTweenAfterStart=!1,this.isReversed?this.playingIndex>0:this.playingIndex<this.tweens.length-1)return void this.advanceToNextTween();let i=0;if(e==="end"||e==="start-end"){if(MM(t,this.currentTween.endTime,this.delay))return;i=this.delay}this.currentRepeat!==0?(this.currentRepeat>0&&(this.currentRepeat-=1),FB(this.config.direction)&&(this.config.runMode==="Toggle"?this.toggleDirection():this.isReversed=!this.isReversed),this.startTime=Tb(this.currentTween.endTime,i),this.playingIndex=this.isReversed?this.tweens.length-1:0,this.config.direction==="normal"&&this.currentTween.seek(this.currentTween.isReversed?1:0),this.openPass()):this.stop()}advanceToNextTween(){let t=this.currentTween;t.isPingpong&&t.config.repeat%2==1&&t.seek(t.isReversed?0:1);let e=t.endTime,i=this.isReversed;this.playingIndex+=i?-1:1;let n=this.currentTween;i&&n.isPingpong&&n.config.repeat%2==1&&n.seek(1),this.resume(e)}startChain(){this.playingIndex=this.isReversed?this.tweens.length-1:0,this.isFirstTweenAfterStart=!0,this.openPass()}openPass(){this.claimWhenDue(this.startTime);let t=this.tweens[0];this.hasClaimed&&!this.isReversed&&t&&t.duration===0&&(t.seek(1),!this.isPlaying)||this.resume(Tb(this.startTime,this.leadingDelay))}claimWhenDue(t){return!this.hasClaimed&&!MM(t,this.startTime,this.leadingDelay)&&(this.hasClaimed=!0,this.hooks.claim?.(),!0)}get leadingDelay(){let t=NB(this.config.delayDirection,this.isReversed);return t==="start-once"?this.isFirstTweenAfterStart?this.delay:0:t!=="start"&&t!=="start-end"||this.isReversed||this.playingIndex!==0||FB(this.config.direction)&&!this.isFirstTweenAfterStart?0:this.delay}resume(t){let e=this.currentTween;this.isReversed&&this.config.direction==="pingpong-rewind"&&(e.overrideDirection="pingpong-rewind"),e.isReversed=!(!this.isReversed||e.repeatDirection!=="normal"&&e.config.repeat%2==1),e.start(t)}toggleDirection(){this.isToggledForward=!this.isToggledForward,this.isReversed=!this.isToggledForward}},Na=Math.fround,mj=class{constructor(t,e,i){this.apply=e,this.onStart=i,this.isPlaying=!1,this.isReversed=!1,this.endTime=0,this.startTime=0,this.isFirstLerpAfterStart=!1,this.config=t,this.duration=function(n,r){if(n.easing!==6)return r;let{mass:s,stiffness:a,damping:o,velocity:l}=n;return s===void 0||a===void 0||o===void 0||l===void 0?r:function(c,h,u,d){let p=.16666666666666666,f=0,g=0,m=hj(c,h,u,d);for(let y=0;y<1e5;y++)if(f+=p,m(f)===1){if(g+=1,g>=16)break}else g=0;return ye(f*p)}(s,a,o,l)}(t.ease,Na(t.duration/1e3)),this.delay=Na(t.delay/1e3),this.currentRepeat=t.repeat}get repeatDirection(){return this.overrideDirection??this.config.direction}get isPingpong(){let t=this.repeatDirection;return t==="pingpong"||t==="pingpong-rewind"}get actualDelayDirection(){return this.isReversed?this.config.delayDirection==="start"?"end":this.config.delayDirection==="end"?"start":this.config.delayDirection:this.config.delayDirection}start(t){this.isPlaying=!0,this.currentRepeat=this.config.repeat,this.isFirstLerpAfterStart=!0,this.startTime=t,this.onStart?.()}stop(){this.isPlaying=!1}rearm(){this.onStart?.()}seek(t){this.lerp(t)}update(t){if(!this.isPlaying)return;let e=function(s,a){return function(o){let l=Math.trunc(o/1e9),c=o-1e9*l;return am(am(l)+am(am(c)/am(1e9)))}(Fc(s)-Fc(a))}(t,this.startTime),i=0;if(this.isFirstLerpAfterStart||!this.isPingpong){let s=this.actualDelayDirection;if(this.config.delayDirection==="start-once"&&this.isFirstLerpAfterStart||s==="start"||s==="start-end"){if(e<this.delay)return;i=this.delay}}e=Na(e-i);let n=this.duration===0?1:Math.min(Math.max(Na(e/this.duration),0),1);if(this.lerp(n),!this.isPlaying||n!==1)return;let r=this.actualDelayDirection;if(r==="end"||r==="start-end"){if(e<Na(this.duration+this.delay))return;this.endTime=Tb(this.startTime,Na(Na(i+this.duration)+this.delay))}else this.endTime=Tb(this.startTime,Na(i+this.duration));this.isFirstLerpAfterStart=!1,this.currentRepeat!==0?(this.currentRepeat>0&&(this.currentRepeat-=1),this.isPingpong?this.isReversed=!this.isReversed:this.lerp(0),this.startTime=t,this.onStart?.()):this.stop()}lerp(t){this.repeatDirection==="pingpong-rewind"&&this.isReversed?(t=Na(1-t),t=this.ease(t),t=Na(1-t)):t=this.ease(t),this.apply(t)}ease(t){return pj(this.config.ease,this.duration,t)}};function Dy(){return typeof performance<"u"?performance.now():Date.now()}var Ji=new class{constructor(){this.clock=new ftt,this.tickables=new Set,this.pendingRemovals=new Set,this.rafId=null,this.isFlushing=!1,this.useInternalRaf=!0,this.step=t=>{this.rafId=null,this.clock.tick(t),this.flush(),this.tickables.size>0&&this.requestFrame()}}get isUsingInternalRaf(){return this.useInternalRaf}set isUsingInternalRaf(t){this.useInternalRaf=t,t?(this.clock.resync(Dy()),this.requestFrame()):this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}get time(){return this.clock.time}get running(){return this.tickables.size>0}add(t){this.pendingRemovals.delete(t),this.tickables.size===0&&this.rafId===null&&this.clock.resync(Dy()),this.tickables.add(t),this.requestFrame()}remove(t){this.isFlushing?this.pendingRemovals.add(t):this.tickables.delete(t)}init(){this.clock.resync(Dy())}dispose(){this.removeAll(),this.clock.reset()}removeAll(){this.tickables.clear(),this.pendingRemovals.clear(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}update(t){this.clock.step(t/1e3),this.flush()}pause(){this.clock.paused=!0}resume(){this.clock.paused=!1,this.clock.resync(Dy()),this.requestFrame()}requestFrame(){this.rafId!==null||!this.useInternalRaf||this.tickables.size!==0&&(typeof requestAnimationFrame>"u"||(this.rafId=requestAnimationFrame(this.step)))}flush(){let t=this.clock.time;this.isFlushing=!0;try{for(let e of this.tickables)this.pendingRemovals.has(e)||e.update(t)}finally{this.isFlushing=!1;for(let e of this.pendingRemovals)this.tickables.delete(e);this.pendingRemovals.clear()}}},Att=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.scrollCounter=0,this.actions=Rn(e,e.actions,n,r,s,i)}connect(){this.scrollCounter=0}disconnect(){rr(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(i)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.TimelineAnimation.forEach(n=>n.seek(i)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch()),this.actions.ClearLocalStorage.forEach(n=>n.dispatch()),this.actions.UserAPI.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},Ttt=class{constructor(t,e,i,n,r,s,a){this.id=t,this.data=e,this.object=i,this.domElement=s,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.deferred=new Set,this.settleDriver={update:()=>this.settleDeferred()},this.actions=Rn(e,e.actions,n,r,a,i)}getStickyParentElement(){let t=this.domElement;for(;t;){if(window.getComputedStyle(t).position==="sticky")return t;t=t.parentElement}return null}computeScrollBounds(){let t=this.getStickyParentElement(),e=t?.parentElement,i=this.domElement.getBoundingClientRect(),n={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(e){let c=e.getBoundingClientRect(),h=window.getComputedStyle(t),u=parseFloat(h.marginTop)+parseFloat(h.marginBottom),d=parseFloat(h.top),p=parseFloat(h.bottom),f=c.height-u;if(isNaN(d)){if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,m=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===g-p?(n.top+=c.top-i.height+p+m,n.bottom+=c.top-i.height+p+m):i.bottom<g-p&&(n.top-=f-i.height,n.bottom-=f-i.height)}}else i.top===d?(n.top+=c.top-d,n.bottom+=c.top-d):i.top<0&&(n.top-=f-i.height,n.bottom-=f-i.height)}let r=document.body,s=document.documentElement,a=window.pageYOffset||s.scrollTop||r.scrollTop,o=s.clientTop||r.clientTop||0,l=Math.round(n.top+a-o);if(this.data.startFrom==="enter"){let c=window.innerHeight,h=n.height,u=this.data.enterAnchor,d=u==="top"?c:u==="bottom"?c-h:c-.5*h;this.scrollStart=l-d}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=n}connect(){this.computeScrollBounds(),this.settle()}disconnect(){Ji.remove(this.settleDriver),this.deferred.clear(),rr(this.actions)}handleResize(){this.computeScrollBounds(),this.settle()}settle(){this.computeScroll({x:window.scrollX,y:window.scrollY},{settle:!0})}settleDeferred(){let t=[...this.deferred].filter(e=>!e.contested);t.length&&(t.forEach(e=>this.deferred.delete(e)),this.seekTransitions(t,this.scaleAt(window.scrollY))),this.deferred.size===0&&Ji.remove(this.settleDriver)}scaleAt(t){let e=this.scrollEnd-this.scrollStart;return Math.min(1,Math.max(0,(t-this.scrollStart)/e))}seekTransitions(t,e){t.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())}),t.forEach(i=>i.seek(e))}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:t,y:e},{settle:i=!1}={}){let n=this.actions.Transition;i?(n=n.filter(s=>!s.contested||(this.deferred.add(s),!1)),this.deferred.size&&Ji.add(this.settleDriver)):(this.deferred.clear(),Ji.remove(this.settleDriver));let r=this.scaleAt(e);this.seekTransitions(n,r),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.TimelineAnimation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},Ctt=class extends Or{constructor(t,e){super(t),this.managers=e,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,n])=>{n.forEach(r=>r.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(a=>a.dispatch(n))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),r.forEach(s=>s.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:n,reverse:r})=>{if(!i||!n)return;let s=i0(i);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(a=>{a.dispatchUserEvent(r)}))}}connect(){let{page:t,sharedAssets:e,domElement:i,isExport:n}=this.eventContext,r=s=>{if(s.data?.events.length){for(let{id:a,data:o}of s.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger!=="load"&&n){let l=new Ttt(a,o,s,t,e,i,this.managers);this.scrollEventsPerObject.has(s)?this.scrollEventsPerObject.get(s)?.push(l):this.scrollEventsPerObject.set(s,[l])}else{let l=new Att(a,o,s,t,e,this.managers);this.wheelEventsPerObject.has(s)?this.wheelEventsPerObject.get(s)?.push(l):this.wheelEventsPerObject.set(s,[l])}}};t.traverseEntity(s=>{(Cr(s)||s instanceof un)&&s.frame?.traverse(a=>{r(a)}),r(s)}),this.intersectionObserver=new IntersectionObserver(s=>{let a=s[0];a&&(this.isInview=a.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([s,a])=>{a.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([s,a])=>{a.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(i=>i.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(i=>i.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)})}};ke(),xs("Scroll",({eventContext:t,eventManager:e})=>new Ctt(t,e)),Si("scroll"),et(),xh(),Wr(),ii(),Kn(),tx();var om=new C,Il=new C,hc=new C,kB=new kr,oi=new C,Fn=new C,VB=new C,ih=new qt,Ptt=new At,EM=new ue,lu=new C,ka=new C,hu=.2;function AM(t,e){!e||(e[0]<e[1]&&(t.x=Math.min(Math.max(t.x,e[0]),e[1])),e[2]<e[3]&&(t.y=Math.min(Math.max(t.y,e[2]),e[3])),e[4]<e[5]&&(t.z=Math.min(Math.max(t.z,e[4]),e[5])))}var Dtt=function(){let t=new At;return(e,i,n)=>{let r=e.obj;t.copy(r.hiddenMatrix),r.parent!==null&&t.premultiply(r.parent.matrixWorld),t.invert(),r.position.copy(i),e.reference==="global"&&AM(r.position,e.limits),r.position.applyMatrix4(t),e.reference==="parent"?AM(r.position,e.limits):e.reference==="local"&&(ih.copy(e.quat0).invert(),r.position.sub(e.position0),r.position.applyQuaternion(ih),AM(r.position,e.limits),ih.invert(),r.position.applyQuaternion(ih),r.position.add(e.position0)),t.multiply(n??r.matrixWorld).decompose(oi,r.quaternion,Fn),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid()),r instanceof Xi&&to(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),Rtt=class{constructor(t,e,i,n,r,s,a){this.object=t,this.id=e,this.data=i,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Rn(i,i.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=Rn(i,i.dragDropActions.drop,n,r,s,this.object);let o=[];this.data.objects.forEach(l=>{let c=n.find(l);!c||c.data.visible!==!1&&(o.push(c),a[c.uuid]&&a[c.uuid].forEach(h=>{let u=n.find(h);!u||u.data.visible!==!1&&o.push(u)}))}),this.data.dropDestinations.forEach(l=>{let c=n.find(l);!c||c.data.visible!==!1&&(this.dropDestIds.push(c.uuid),a[c.uuid]&&a[c.uuid].forEach(h=>{let u=n.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new C().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new C().setFromMatrixPosition(l.matrixWorld),pointStart:new C,pointEnd:new C,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new C().copy(l.position),quat0:new qt().copy(l.quaternion),snapped:!1,orientationMatrix:new At,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){rr(this.actionsDrag),rr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Itt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.lastCursorRaycastTime=0,this.trailingCursorTimer=null,this.trailingCursorEvent=null,this.onPointerDown=i=>{if(ae.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(this.lastDropDestination=null,s.length!==0){for(let a of this.events){let o=0;for(let{obj:l,pointEnd:c,pointStart:h}of a.dragItems){if(l===s[0].object||l===s[0].object.object||Be.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(a.activeIdx=o,a.activeDragItem.reset=!1,a.activeDragItem.currentDampingFactor=a.data.dampingFactor,a.activeDragItem.snapped=!1,a.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){a.activeDragItem.obj.rigidBody&&(a.activeDragItem.obj.rigidBody.setBodyType(2,!0),this.eventManager.controlsManager.sharedGameControlGlobals.kinematicBodyToEntity.set(a.activeDragItem.obj.rigidBody.handle,a.activeDragItem.obj));let u=a.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldRigid(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(oi,ih,Fn),u.prevQ===void 0?(u.prevQ=ih.clone(),u.prevT=oi.clone()):(u.prevQ.copy(ih),u.prevT.copy(oi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(a.activeDragItem.obj)}return this.calcPlaneIntersectPos(l,h,a.data.plane,a.data.referenceFrame),c.copy(h),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||a.data.drop===!1||a.data.resetOnSnapFail===!1)&&a.activeDragItem.fromPosition.setFromMatrixPosition(a.activeDragItem.obj.matrixWorld),this.activeEvent=a,void(this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1))}o++}}this.activeEvent=null}else this.activeEvent=null},this.runTrailingCursorUpdate=()=>{this.trailingCursorTimer=null;let i=this.trailingCursorEvent;this.trailingCursorEvent=null,i!==null&&ae.length===0&&(this.eventContext.updateRaycaster(i),this.lastCursorRaycastTime=performance.now(),this.updateCursorFromRaycast())},this.onPointerMove=i=>{if(ae.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:n,page:r}=this.eventContext;if(ae.length===0){if(!this.events.some(a=>a.data.cursor==="hand"||a.data.cursor==="move"))return;let s=performance.now();return s-this.lastCursorRaycastTime<16?(this.trailingCursorEvent=i,void(this.trailingCursorTimer===null&&(this.trailingCursorTimer=window.setTimeout(this.runTrailingCursorUpdate,32)))):(this.trailingCursorEvent=null,this.lastCursorRaycastTime=s,void this.updateCursorFromRaycast())}if(this.activeEvent&&this.activeEvent.activeDragItem){let s,a=this.activeEvent.activeDragItem;if(a.snapped=!1,this.activeEvent.data.drop&&(s=r.raycastWithClones(n).filter(o=>a.obj!==o.object&&!a.obj.isAncestorOf(o.object.uuid)&&!(o.object instanceof $a)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(l=>l===o.object.uuid||r.scene.find(l).isAncestorOf(o.object.uuid))))[0]),s){let o=VB.copy(s.face.normal).applyMatrix3(EM.getNormalMatrix(s.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")a.fromPosition.setFromMatrixPosition(s.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(a.fromPosition.copy(s.point),this.activeEvent.data.snapSurfaceMode==="bbox"){oi.copy(o).applyMatrix3(EM.setFromMatrix4(a.obj.matrixWorld).transpose());let l=a.obj;oi.x>hu?Fn.x=-l.recursiveBBox.min.x:oi.x<-hu&&(Fn.x=-l.recursiveBBox.max.x),oi.y>hu?Fn.y=-l.recursiveBBox.min.y:oi.y<-hu&&(Fn.y=-l.recursiveBBox.max.y),oi.z>hu?Fn.z=-l.recursiveBBox.min.z:oi.z<-hu&&(Fn.z=-l.recursiveBBox.max.z),Fn.applyMatrix3(EM.invert())}else Fn.copy(o).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);a.fromPosition.add(Fn)}this.activeEvent.data.autoOrient&&(oi.set(0,1,0).cross(o),oi.length()<1e-4&&oi.set(-1,0,0).cross(o),Fn.crossVectors(VB,oi),a.orientationMatrix.makeBasis(oi,Fn,o)),a.pointStart.copy(a.fromPosition),a.pointEnd.copy(a.pointStart),a.currentDampingFactor=this.activeEvent.snapDampingFactor,a.snapped=!0,this.lastDropDestination!==s.object&&(this.lastDropDestination=s.object,this.activeEvent.actionsDrop.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(l=>{l.dispatchThrottled()}))}else a.orientationMatrix.makeRotationFromQuaternion(a.quat0),this.lastDropDestination=null,a.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(a.obj,a.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(o=>{o.stop(),o.object.currentState!==null&&o.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(o=>{o.stop()}),this.activeEvent.actionsDrop.Audio.forEach(o=>{o.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(o=>{o.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(o=>{o.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(o=>o.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(o=>o.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(o=>o.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(o=>o.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(o=>o.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(o=>{o.play()}),this.activeEvent.actionsDrag.Animation.forEach(o=>{o.play()}),this.activeEvent.actionsDrag.Audio.forEach(o=>{o.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(o=>{o.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(o=>{o.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(o=>{o.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(o=>{o.stop(),o.object.currentState!==null&&o.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(o=>{o.stop()}))},500),this.updateDragItem(a),a.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.eventManager.controlsManager.sharedGameControlGlobals.kinematicBodyToEntity.delete(this.activeEvent.activeDragItem.obj.rigidBody.handle),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(r=>r.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let t={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(t[i.component.uuid]?t[i.component.uuid].push(i.uuid):t[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(n=>n.data.type==="DragDrop"&&!n.data.disabled).forEach(n=>{this.events.push(new Rtt(i,n.id,n.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,t))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let t=this.eventContext.domElement;t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),this.trailingCursorTimer!==null&&(clearTimeout(this.trailingCursorTimer),this.trailingCursorTimer=null),this.trailingCursorEvent=null,this.events.forEach(e=>e.dispose())}setCursor(t){this.eventContext.domElement.style.cursor=t}onAnimationFrameDamping(){for(let t of this.events)for(let e of t.dragItems)e.paused||this.updateDragItem(e,!0)}calcPlaneIntersectPos(t,e,i,n){let{getCamera:r,raycaster:s}=this.eventContext;r().getWorldDirection(Il),Il.negate();let a=ih.identity();switch(n==="parent"?Ptt.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix).decompose(oi,a,Fn):n==="local"&&t.matrixWorld.decompose(oi,a,Fn),i){case"x":oi.set(1,0,0).applyQuaternion(a),lu.copy(Il).cross(oi),ka.copy(oi).cross(lu);break;case"y":oi.set(0,1,0).applyQuaternion(a),lu.copy(Il).cross(oi),ka.copy(oi).cross(lu);break;case"z":oi.set(0,0,1).applyQuaternion(a),lu.copy(Il).cross(oi),ka.copy(oi).cross(lu);break;case"xy":ka.set(0,0,1).applyQuaternion(a);break;case"yz":ka.set(1,0,0).applyQuaternion(a);break;case"xz":ka.set(0,1,0).applyQuaternion(a);break;case"adaptive":Il.angleTo(Fn.set(0,1,0))>Math.PI/6?(oi.crossVectors(Fn.set(0,1,0),Il),ka.crossVectors(oi,Fn)):ka.set(0,1,0);break;default:ka.copy(Il)}hc.setFromMatrixPosition(t.matrixWorld);let o=t.userData.lockedPlane?t.userData.worldPosition0:hc;if(kB.setFromNormalAndCoplanarPoint(ka,o),s.ray.intersectPlane(kB,e)&&(i==="x"||i==="y"||i==="z")){let l=Fn.subVectors(e,o).dot(oi);e.copy(o).addScaledVector(oi,l)}}updateDragItem(t,e=!1){hc.setFromMatrixPosition(t.obj.matrixWorld),t.reset==="current"?om.subVectors(t.fromPosition,hc).divideScalar(t.currentDampingFactor):t.reset==="original"?(om.subVectors(t.obj.userData.worldPosition0,hc).divideScalar(t.currentDampingFactor),t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart)):om.subVectors(t.pointEnd,t.pointStart).add(t.fromPosition).sub(hc).divideScalar(t.currentDampingFactor),t.paused=!(t.currentDampingFactor>1)||om.length()<.01,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||e)&&Dtt(t,om.add(hc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?t.orientationMatrix:null),t.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}updateCursorFromRaycast(){let{raycaster:t,page:e}=this.eventContext,i=e.raycastWithClones(t),n=!1;for(let r of this.events){for(let{obj:s}of r.dragItems)if(s===i[0]?.object||s===i[0]?.object?.object||Be.is(s)&&s.isAncestorOf(i[0]?.object.uuid)){switch(n=!0,r.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move")}break}if(n)break}n||this.setCursor("default")}};ke(),xs("DragDrop",({eventContext:t,eventManager:e})=>new Itt(t,e)),Si("dragdrop"),et(),xh(),ii(),Yt(),Kn();var cu=new C,TM=new C,Ro=new C,Io=new C,jB=new kr,Ott={type:"requestRender"},Ltt=function(){let t=new C,e=new C;return(i,n,r)=>r>0?(t.subVectors(i,n),t.length()<=r?i:e.copy(n).add(t.normalize().multiplyScalar(r))):n}(),GB=function(){let t=new At;return(e,i)=>{e.position.copy(i),e.parent!==null&&(t.copy(e.parent.matrixWorld).invert(),e.position.applyMatrix4(t)),t.copy(e.hiddenMatrix).invert(),e.position.applyMatrix4(t),e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldRigid()),e instanceof Xi&&to(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),Btt=class{constructor(t,e,i,n,r,s){this.data=t,this.id=e,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new C,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...WE.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Rn(t,t.actions,n,r,s,i)}},Utt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(ae.length>1)){this.eventContext.updateRaycaster(i);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}},this.onMouseEnter=i=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)},this.onMouseLeave=i=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:t}=this.eventContext;if(t.traverseEntity(n=>{let r=n.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Btt(r.data,r.id,n,t,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:e,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let r=n.target,s=this.onTargetChange(n);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:t,eventElement:e}=this.eventContext;this.domEventsNeeded.clear(),ss&&t.removeEventListener("pointerdown",this.onMouseMove),e.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,n]of this.pairOfEventListeners)i.removeEventListener("requestRender",n);for(let i of this.events)i.paused=!0,i.isReset=!1,rr(i.actions)}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t,!0)}updateSingleEvent(t,e=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:n,limitDistanceEnabled:r}=t.data;if(t.object.getWorldPosition(Ro),t.isReset)Io.copy(t.worldPosition0);else if(t.target)t.target.getWorldPosition(Io);else{let{getCamera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a().getWorldDirection(TM),TM.negate(),cu.copy(TM)):i==="xy"?cu.set(0,0,1):i==="xz"?cu.set(0,1,0):i==="yz"&&cu.set(1,0,0),jB.setFromNormalAndCoplanarPoint(cu,Ro),!o.ray.intersectPlane(jB,Io))return}if(!t.isReset){if(Io.distanceTo(t.worldPosition0)>n&&r&&t.target){if(t.snapComplete=!1,t.data.snapDelay&&(t.delayFinished=!1,typeof window<"u"&&t.timeoutId!==null&&(window.clearTimeout(t.timeoutId),t.timeoutId=null)),t.wasOutside=!0,!t.data.resetAfterDistanceLimit)return;Io.copy(t.worldPosition0),t.currentDampingFactor=t.resetDampingFactor}else if(t.wasOutside&&(t.data.snapDelay&&typeof window<"u"&&(t.timeoutId=window.setTimeout(()=>{t.delayFinished=!0,t.paused=!1,this.updateSingleEvent(t)},1e3*t.data.snapDelay)),t.currentDampingFactor=t.data.dampingFactor,t.wasOutside=!1),t.delayFinished===!1)return}t.data.enabledTranslation[0]===!1&&(Io.x=Ro.x),t.data.enabledTranslation[1]===!1&&(Io.y=Ro.y),t.data.enabledTranslation[2]===!1&&(Io.z=Ro.z);let s=Ltt(Ro,Io,t.wasOutside?0:t.data.maxDelta);if(t.currentDampingFactor>1){let a=cu.subVectors(s,Ro).divideScalar(t.currentDampingFactor);Ro.add(a),e&&GB(t.object,Ro),t.paused=a.length()<.01}else GB(t.object,s),t.paused=!0;t.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),t.object.dispatchEvent(Ott)}};et(),Yt(),xh(),ii(),Kn(),mN();var lm=new C,Ry=new C,hm=new At,du=new qt,Ol=new qt,cm=new C,dm=new C,cc=new C,Oo=new C,CM=new kr,ztt={type:"requestRender"},Ftt={type:"changeRotation"},HB=function(){let t=new At;return function(e,i){e.parent!==null?t.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):t.copy(e.hiddenMatrix),i.premultiply(pN(t).invert()),e.rotation.setFromRotationMatrix(i),e.updateMatrix(),e instanceof Xi&&to(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),Ntt=class{constructor(t,e,i,n){this.id=e,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new qt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...qE.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),isNaN(this.worldQuaternion0.x)&&(this.worldQuaternion0.x=0),isNaN(this.worldQuaternion0.y)&&(this.worldQuaternion0.y=0),isNaN(this.worldQuaternion0.z)&&(this.worldQuaternion0.z=0),isNaN(this.worldQuaternion0.w)&&(this.worldQuaternion0.w=1),this.resetDampingFactor=80/this.data.resetSpeed+1}},ktt=class extends Or{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=t=>{if(!(ae.length>1)){this._lastMouseEvent=t,this.eventContext.updateRaycaster(t);for(let e of this.events)e.target===void 0&&this.updateSingleEvent(e)}},this.onMouseEnter=t=>{for(let e of this.events)e.target===void 0&&(e.isReset=!1,e.currentDampingFactor=e.data.dampingFactor)},this.onMouseLeave=t=>{for(let e of this.events)e.target===void 0&&(e.data.resetOnPointerLeave&&(e.isReset=!0,e.currentDampingFactor=e.resetDampingFactor),this.updateSingleEvent(e))},this.onScroll=t=>{if(this._lastMouseEvent){let e=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(e)}},this.onTargetChange=t=>()=>{this.updateSingleEvent(t)},this.createUserEventListener=t=>({eventName:e,target:i})=>{if(!e||!i)return;let n=i0(e);n&&n==="LookAt"&&this.updateSingleEvent(t)}}connect(){let{page:t}=this.eventContext;if(t.traverseEntity(n=>{let r=n.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Ntt(r.data,r.id,n,t))}),!this.events.length)return;let{domElement:e,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),o=n.target;this.pairOfEventListeners.push([o,a]),o.addEventListener("requestRender",a)}let r=this.createUserEventListener(n),s=n.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:t,eventElement:e}=this.eventContext;this.domEventsNeeded.clear(),ss&&t.removeEventListener("pointerdown",this.onMouseMove),e.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave),e.removeEventListener("scroll",this.onScroll);for(let[i,n]of this.pairOfEventListeners)i.removeEventListener("requestRender",n);for(let[i,n]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",n);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t)}updateSingleEvent(t){let{tilt:e,axis:i,distance:n,plane:r,limitDistance:s,enabledRotation:a,limitDistanceEnabled:o}=t.data,{getCamera:l,raycaster:c}=this.eventContext,{object:h,target:u}=t;if(h.getWorldPosition(cm),!t.isReset)if(t.target)t.target.getWorldPosition(dm);else{if(r==="custom"?(l().getWorldDirection(Ry),Ry.negate(),CM.setFromNormalAndCoplanarPoint(Ry,cm)):(r==="xy"?lm.set(0,0,1):r==="xz"?lm.set(0,1,0):r==="yz"&&lm.set(1,0,0),CM.setFromNormalAndCoplanarPoint(lm,cm)),!c.ray.intersectPlane(CM,dm))return;n>0&&(r==="custom"||r===void 0)&&dm.addScaledVector(Ry,n)}if(t.isReset||(u?e==="target"?cc.copy(u.up).applyMatrix4(hm.extractRotation(u.matrixWorld)).normalize():a.some(d=>d===!1)?(i==="x"?(Oo.set(0,0,1),a[2]===!1&&Oo.set(0,1,0)):i==="y"?(Oo.set(1,0,0),a[0]===!1&&Oo.set(0,0,1)):(Oo.set(0,1,0),a[1]===!1&&Oo.set(1,0,0)),cc.copy(Oo).applyQuaternion(t.worldQuaternion0).normalize()):cc.set(0,1,0):r==="custom"?cc.set(0,1,0):cc.copy(lm)),t.isReset)Ol.copy(t.worldQuaternion0);else if(cm.distanceTo(dm)>s&&o&&u){if(t.data.snapDelay&&(t.delayFinished=!1,typeof window<"u"&&t.timeoutId!==null&&(window.clearTimeout(t.timeoutId),t.timeoutId=null)),t.wasOutside=!0,!t.data.resetAfterDistanceLimit)return;Ol.copy(t.worldQuaternion0),t.currentDampingFactor=t.resetDampingFactor}else{if(t.wasOutside&&(t.data.snapDelay&&typeof window<"u"&&(t.timeoutId=window.setTimeout(()=>{t.delayFinished=!0,t.paused=!1,this.updateSingleEvent(t)},1e3*t.data.snapDelay)),t.currentDampingFactor=t.data.dampingFactor,t.wasOutside=!1),t.delayFinished===!1)return;(function(d,p,f,g,m,y){let v=hm.elements;on.subVectors(p,f),on.lengthSq()===0&&(on.z=1),on.normalize(),zn.crossVectors(g,on),zn.lengthSq()===0&&(Math.abs(g.z)===1?on.x+=1e-4:on.z+=1e-4,on.normalize(),zn.crossVectors(g,on)),zn.normalize(),Bs.crossVectors(on,zn),m==="x"?y.z===1?[zn,Bs,on]=[on,zn,Bs]:(zn.negate(),[zn,on]=[on,zn]):m==="y"?y.x===1?[zn,Bs,on]=[Bs,on,zn]:(zn.negate(),[Bs,on]=[on,Bs]):y.x===1&&(zn.negate(),[zn,Bs]=[Bs,zn]),v[0]=zn.x,v[4]=Bs.x,v[8]=on.x,v[1]=zn.y,v[5]=Bs.y,v[9]=on.y,v[2]=zn.z,v[6]=Bs.z,v[10]=on.z})(0,dm,cm,cc,i,Oo),Ol.setFromRotationMatrix(hm),du.setFromUnitVectors(Oo.applyQuaternion(Ol),cc),a.some(d=>d===!1)&&e!=="target"&&Ol.premultiply(du).normalize()}t.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),du.setFromRotationMatrix(pN(h.matrixWorld)),du.slerp(Ol,1/t.currentDampingFactor),HB(h,hm.makeRotationFromQuaternion(du)),t.paused=8*(1-du.dot(Ol))<1e-6):(HB(h,hm.makeRotationFromQuaternion(Ol)),t.paused=!0),t.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(ztt),h.dispatchEvent(Ftt)}},Bs=new C,zn=new C,on=new C;ke(),xs("Follow",({eventContext:t,eventManager:e})=>new Utt(t,e)),xs("LookAt",({eventContext:t})=>new ktt(t)),Si("tracking"),Li(),Yt(),ol();var Vtt=class{constructor(t,e,i,n,r,s,a,o){this.eventId=t,this.id=e,this.data=i,this.dataEvent=n,this.object=r,this.stage=!1,this.actions=Rn(n,i.actions,s,a,o,r,"Toggle")}disconnect(){rr(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.play()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>t.play())}},jtt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.breakpoints=[],this.resize=(i,n)=>{this.breakpoints.forEach(r=>{let s,a=XE.deviceToSize(r.data.size),o=r.dataEvent.orientation==="horizontal"?i:n;switch(r.data.operator){case"<":s=o<a[0];break;case">":s=o>a[0];break;case"<>":s=o>a[0]&&o<a[1]}r.stage!==s&&(r.stage=s,r.stage?r.dispatchIn():r.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let n of i){let{width:r,height:s}=n.contentRect;this.resize(r,s)}})}connect(){let{page:t,sharedAssets:e,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let n=r=>{if(r.visible&&r.data?.events.length)for(let{data:s,id:a}of r.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:o,id:l})=>{try{let c=new Vtt(a,l,o,s,r,t,e,this.eventManager);this.breakpoints.push(c)}catch{}})};t.traverseEntity(r=>{(Cr(r)||r instanceof un)&&r.frame?.traverse(s=>{n(s)}),n(r)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(t=>{t.disconnect()}),this.breakpoints=[]}};function WB(t){return Object.values(t).some(e=>e.length>0)}ke(),xs("Resize",({eventContext:t,eventManager:e})=>new jtt(t,e)),Si("resize"),et();var Gtt=new C,Htt=new C,gj=(new At,new C,new qt,new C,new xi,class{constructor(t,e,i,n,r){this.actionsIn=Rn(t,t.inActions,i,n,r,e),this.actionsOut=Rn(t,t.outActions,i,n,r,e)}disconnect(){rr(this.actionsIn),rr(this.actionsOut)}}),Wtt=class extends gj{constructor(t,e,i,n,r,s){super(e,i,n,r,s),this.id=t,this.data=e,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let c=Gtt.setFromMatrixPosition(this.objects[0].matrixWorld),h=Htt.setFromMatrixPosition(this.objects[1].matrixWorld),u=c.distanceTo(h)<=this.distance?"in":"out";if(this.stage!==u){this.stage=u;let d=u==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Particles.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.TimelineAnimation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch()),d.ClearLocalStorage.forEach(p=>p.dispatch()),d.UserAPI.forEach(p=>p.dispatch())}};let{distance:a,fromObject:o,toObject:l}=e.condition;this.distance=a;for(let c of[o,l]){if(!c)throw new Error("Missing property");let h=n.find(c);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){window.setTimeout(()=>{this.objects.forEach(t=>{t.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld),t.addEventListener("updateMatrix",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(t=>{t.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld),t.removeEventListener("updateMatrix",this.onUpdateMatrixWorld)})}},qtt=class extends gj{constructor(t,e,i,n,r,s){super(e,i,n,r,s),this.id=t,this.data=e,this.object=i,this.onTransitionState=({settled:l,state:c})=>{l&&c===(this.toState??null)?WB(this.actionsIn)&&this.runInActions():WB(this.actionsOut)&&this.runOutActions()};let{condition:a}=e;if(!a.object)throw new Error("Missing property");let o=n.find(a.object)??n.scene.find2D(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){this.toObject.addEventListener("transitionState",this.onTransitionState)}disconnect(){super.disconnect(),this.toObject.removeEventListener("transitionState",this.onTransitionState)}runOutActions(){this.actionsOut.Audio.forEach(t=>t.dispatchConditional()),this.actionsOut.Particles.forEach(t=>t.dispatchConditional()),this.actionsOut.Video.forEach(t=>t.dispatchConditional()),this.actionsOut.Link.forEach(t=>t.dispatch()),this.actionsOut.Create.forEach(t=>t.dispatch()),this.actionsOut.Destroy.forEach(t=>t.dispatch()),this.actionsOut.Reset.forEach(t=>t.dispatch()),this.actionsIn.Transition.forEach(t=>{this.drivesWatchedObject(t)||t.pause()}),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(t=>t.play()),this.actionsOut.Animation.forEach(t=>t.play()),this.actionsOut.TimelineAnimation.forEach(t=>t.play()),this.actionsIn.SwitchCamera.forEach(t=>t.pause()),this.actionsOut.SwitchCamera.forEach(t=>t.play()),this.actionsOut.SceneTransition.forEach(t=>t.dispatch()),this.actionsOut.SetVariable.forEach(t=>t.checkConditions()),this.actionsOut.SetVariable.forEach(t=>t.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actionsOut.ClearLocalStorage.forEach(t=>t.dispatch()),this.actionsOut.UserAPI.forEach(t=>t.dispatch())}runInActions(){this.actionsIn.Audio.forEach(t=>t.dispatchConditional()),this.actionsIn.Particles.forEach(t=>t.dispatchConditional()),this.actionsIn.Video.forEach(t=>t.dispatchConditional()),this.actionsIn.Link.forEach(t=>t.dispatch()),this.actionsIn.Create.forEach(t=>t.dispatch()),this.actionsIn.Destroy.forEach(t=>t.dispatch()),this.actionsIn.Reset.forEach(t=>t.dispatch()),this.actionsOut.Transition.forEach(t=>{this.drivesWatchedObject(t)||t.pause()}),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(t=>t.play()),this.actionsIn.Animation.forEach(t=>t.play()),this.actionsIn.TimelineAnimation.forEach(t=>t.play()),this.actionsOut.SwitchCamera.forEach(t=>t.pause()),this.actionsIn.SwitchCamera.forEach(t=>t.play()),this.actionsIn.SceneTransition.forEach(t=>t.dispatch()),this.actionsIn.SetVariable.forEach(t=>t.checkConditions()),this.actionsIn.SetVariable.forEach(t=>t.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actionsOut.ClearLocalStorage.forEach(t=>t.dispatch()),this.actionsOut.UserAPI.forEach(t=>t.dispatch())}drivesWatchedObject(t){return t.object===this.toObject}},Xtt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:t,sharedAssets:e}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let{id:n,data:r}of i.data.events)if(!r.disabled&&r.type==="Conditional")try{let s;r.condition.type==="Comparison"||(r.condition.type==="Distance"?s=new Wtt(n,r,i,t,e,this.eventManager):r.condition.type==="State"&&(s=new qtt(n,r,i,t,e,this.eventManager))),s&&(this.eventsPerConditions[r.condition.type].push(s),(s.actionsIn.Video.length||s.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(e=>e.disconnect()))}};ke(),xs("Conditional",({eventContext:t,eventManager:e})=>new Xtt(t,e)),Si("conditional"),Yt(),o3(),et();var qB=new At,PM=new C,XB=new qt,$tt=new C,$B=new xi,Ytt=class extends Or{constructor(t,e,i,n,r){super(t),this.sharedVariables=e,this.eventManager=i,this.needsMouse=n,this.needsRaycast=r,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=s=>{let a=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],c=[];for(let d=0;d<this.propertiesToWatch.length;d++){let{objectId:p,property:f,prevValue:g}=this.propertiesToWatch[d],m=this.eventContext.scene.find(p),y=$E.propertyPaths[f];if(y[0]==="width"||y[0]==="height"||y[0]==="depth")m=m.geometry.userData.parameters[y[0]];else if((y[0]==="position"||y[0]==="rotation"&&y.length>1)&&m.getPhysicsLocalMatrix?.(qB))qB.decompose(PM,XB,$tt),y[0]==="position"?m=y.length>1?PM[y[1]]:PM:($B.setFromQuaternion(XB,m.rotation.order),m=$B[y[1]]);else for(let v=0;v<y.length;v++)m=m[y[v]];g===null?this.propertiesToWatch[d].prevValue=m instanceof C?m.clone():m:(m instanceof C?!m.equals(g):g!==m)&&(c.push({objId:p,property:f}),m instanceof C?this.propertiesToWatch[d].prevValue.copy(m):this.propertiesToWatch[d].prevValue=m)}for(let d=0;d<this.variablesToWatch.length;d++){let{id:p,prevValue:f}=this.variablesToWatch[d],g=a.getVariable(p);g!==f&&(l.push(p),this.variablesToWatch[d].prevValue=g)}for(let d=0;d<this.dynamicVars.length;d++){let{id:p,expectedTime:f,last:g,data:m,timerSeconds:y,startValue:v}=this.dynamicVars[d],_=1e3;if(m.dynamicVariableType!=="timer"&&m.dynamicVariableType!=="stopwatch"||m.format!=="number3decimal"?m.dynamicVariableType==="counter"?_=m.updateInterval:m.dynamicVariableType==="random"&&(_=m.isStatic?1/0:m.updateInterval):_=1,f!==-1){if(a.getDynamicVariablePlayState(p)!=="Stopped"&&a.getDynamicVariablePlayState(p)!=="Restarted"||(this.dynamicVars[d].last=s,this.dynamicVars[d].expectedTime=s+_,m.dynamicVariableType==="counter"&&a.getVariable(p)!==v&&(a.updateVariable(p,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[d].timerSeconds!==v&&(this.dynamicVars[d].timerSeconds=v,a.updateVariable(p,Fs.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),a.getDynamicVariablePlayState(p)==="Restarted"&&a.setDynamicVariablePlayState(p,"Playing"),a.getDynamicVariablePlayState(p)!=="Stopped")){if(a.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[d].deltaToExpectedTime===void 0&&(this.dynamicVars[d].deltaToExpectedTime=Math.max(this.dynamicVars[d].expectedTime-s,0)),this.dynamicVars[d].last=s-(_-this.dynamicVars[d].deltaToExpectedTime),this.dynamicVars[d].expectedTime=s+this.dynamicVars[d].deltaToExpectedTime;continue}if(this.dynamicVars[d].deltaToExpectedTime=void 0,s>=f)if(this.dynamicVars[d].last=s,this.dynamicVars[d].expectedTime+=_,m.dynamicVariableType==="random"){let b=m.min+Math.random()*(m.max-m.min),x=m.decimals;b=Math.round(b*Math.pow(10,x))/Math.pow(10,x),a.updateVariable(p,b),l.push(p),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){let b=a.getVariable(p),x=a.getDynamicVariableToggleIsForward(p)??!0,w=a.getVariable(p)+m.increment*(x?1:-1);m.hasEnd&&(w=m.increment>0?Ot.clamp(w,v,m.endValue):Ot.clamp(w,m.endValue,v),w===v&&a.setDynamicVariableToggleIsForward(p,void 0),m.repeat?w===m.endValue&&(w=v):(w===v||w===m.endValue)&&a.setDynamicVariablePlayState(p,"Paused")),w!==b&&(l.push(p),a.updateVariable(p,w),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time"){let b=a.getVariable(p),x=G4(o,m);if(typeof b=="object"&&"textValue"in b&&typeof x=="object"&&"textValue"in x){if(Array.isArray(b.textValue)&&Array.isArray(x.textValue)){if(b.textValue.every((w,S)=>w===x.textValue[S]))continue}else if(b.textValue===x.textValue)continue}else if(b===x)continue;a.updateVariable(p,x),l.push(p),this.eventManager.requestRender()}else{let b=_r.isTextValue(m.endValue)?YB(m.endValue.textValue):m.endValue,x=a.getDynamicVariableToggleIsForward(p)??!0,w=y+(s-g)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(x?1:-1);w=Math.max(w,0),m.hasEnd&&(w=m.dynamicVariableType==="stopwatch"?Ot.clamp(w,v,b):Ot.clamp(w,b,v),w===v&&a.setDynamicVariableToggleIsForward(p,void 0),m.repeat?Math.abs(w-b)<(m.format==="number3decimal"?1e-4:.1)&&(w=v):(Math.abs(w-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(w-b)<(m.format==="number3decimal"?1e-4:.1))&&a.setDynamicVariablePlayState(p,"Paused")),w!==y&&(l.push(p),this.dynamicVars[d].timerSeconds=w,a.updateVariable(p,Fs.getFormattedTimerTime(w,m)),this.eventManager.requestRender())}}}else this.dynamicVars[d].last=s,this.dynamicVars[d].expectedTime=s+_}let h=!1;a.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=a.mouseProperty,h=!0);let u=!1;a.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=a.raycastProperty,u=!0),this.events.forEach(d=>{(l.includes(d.data.variableId)||c.find(p=>p.objId===d.data.objectId&&p.property===d.data.property)||d.data.variableId==="mouseProperty"&&h||d.data.variableId==="raycastProperty"&&u)&&(d.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let t=Date.now()-this.pauseTime;for(let e=0;e<this.dynamicVars.length;e++)this.dynamicVars[e].last+=t,this.dynamicVars[e].expectedTime+=t}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new Ztt(i.id,i.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(e=>e.data.variableId==="objectProperty"&&e.data.objectId!==null).map(e=>({objectId:e.data.objectId,property:e.data.property,prevValue:null}));let t=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:e,data:i})=>{if(!("dynamicVariableType"in i))return void(this.events.find(r=>r.data.variableId===e)&&this.variablesToWatch.push({id:e,prevValue:t.getVariable(e)}));let n;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let r;if(_r.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let s=i.value.textValue;r=s.length===3?s[2]+60*s[1]+3600*s[0]:s[1]+60*s[0]}else r=i.value;n=r,this.dynamicVars.push({id:e,last:-1,expectedTime:-1,data:i,timerSeconds:r,startValue:n})}else i.dynamicVariableType==="time"&&t.updateVariable(e,G4(new Date,i)),i.dynamicVariableType==="counter"&&(n=_r.isTextValue(i.value)?YB(i.value.textValue):i.value),this.dynamicVars.push({id:e,last:-1,expectedTime:-1,data:i,startValue:n})}),this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(t=>t.dispose())}},Ztt=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.actions=Rn(e,e.actions,n,r,s,i)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.TimelineAnimation.forEach(e=>e.dispatchConditional()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispose(){rr(this.actions)}};function YB(t){return t.length===3?t[2]+60*t[1]+3600*t[0]:t[1]+60*t[0]}Yt();var Ktt=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Ti(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=xV(this.data.expression,this.shared,_r.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}},Qtt=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n,this.timeoutId=null}dispatchInner(){if(Ti(this.shared,this.condition)===!1)return!1;let t=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e!==void 0&&!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};ke(),xs("VariableChange",({eventContext:t,sharedVariables:e,eventManager:i,needsMouse:n,needsRaycast:r})=>new Ytt(t,e,i,n,r)),Pr("SetVariable",({data:t,page:e,shared:i,actionCondition:n})=>new Ktt(t,e,i,n)),Pr("DynamicVariablePlay",({data:t,page:e,shared:i,actionCondition:n})=>new Qtt(t,e,i,n)),Si("variables");var Jtt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:i})=>{this.events.forEach(n=>{n.data.userAPIId===i&&n.dispatchSuccess()})},this.onError=({userAPIId:i})=>{this.events.forEach(n=>{n.data.userAPIId===i&&n.dispatchError()})},this.userAPIs=t.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="API"&&!e.data.disabled).forEach(e=>{this.events.push(new tet(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([t,e])=>{e.on("success",this.onSuccess),e.on("error",this.onError),e.autostart&&e.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([t,e])=>{e.off("success",this.onSuccess),e.off("error",this.onError)})}},tet=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.successActions=Rn(e,e.successActions,n,r,s,i),this.errorActions=Rn(e,e.errorActions,n,r,s,i)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}},eet=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:i})=>{this.events.forEach(n=>{n.data.userWebhookId===i&&n.dispatch()})},this.userWebhooks=t.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="WEBHOOK"&&!e.data.disabled).forEach(e=>{this.events.push(new iet(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([t,e])=>{e.connect(),e.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([t,e])=>{e.off("message",this.onMessage),e.disconnect()})}},iet=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.actions=Rn(e,e.actions,n,r,s,i)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}},net=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;if(this.data.userAPIId){let t=this.shared.getUserAPI(this.data.userAPIId);t&&"callUserAPI"in t&&t.callUserAPI(this.shared)}}dispose(){}};s3(),Ye(),Yt(),ii();var ret=class{constructor(t,e,i){this.id=t,this.userAPI=e,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(n=>n()),this.emitter=_x(),this._innerCallUserAPI=async n=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await async function(r,s,a=new AbortController){let o,l,c=r.url,h=r.proxy?.enabled??!1;if(r.integration?.type==="OpenAI"){let d=jm(r.integration.prompt===""?[]:JSON.parse(r.integration.prompt),s),p=r.integration.behavior===""?[]:jm(JSON.parse(r.integration.behavior),s);l=`{
9914
+ `),g.addEventListener("pointerdown",()=>{t.gameControl.movementState.jump=1,t.requestRender()}),g.addEventListener("touchend",y=>y.preventDefault()),void(t.joysticks[r]=[void 0,s])}let p={zone:s,mode:"static",position:h,size:a};l==="hide"&&(p.restOpacity=0);let f=lJ.create(p);f.on("move",(g,m)=>{let y=t.gameControl;n==="pos"?m.force<.2?y.moveForce=0:(y.movementState.movePosZ=Math.sin(-m.angle.radian),y.movementState.movePosX=Math.cos(-m.angle.radian),m.force>1.2?y.movementState.run=1:y.movementState.run=0,m.force<.3?y.moveForce=(m.force-.2)/.1:y.moveForce=1):n==="rot"&&(m.force<.2?y.rotForce=0:(y.movementState.rotPosX=m.vector.y,y.movementState.rotPosY=-m.vector.x,m.force<.3?y.rotForce=(m.force-.2)/.1:y.rotForce=1)),t.requestRender()}),f.on("end",(g,m)=>{let y=t.gameControl;n==="pos"?(y.movementState.movePosZ=0,y.movementState.movePosX=0,y.moveForce=1):n==="rot"&&(y.movementState.rotPosX=0,y.movementState.rotPosY=0,y.rotForce=1)}),t.joysticks[r]=[f,s]})}};ke(),XV=IJ,Si("game-controls"),et();var D1=Math.pow(2,-24),k3=Symbol("SKIP_GENERATION"),aj={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[k3]:!1};function Qi(t,e,i){return i.min.x=e[t],i.min.y=e[t+1],i.min.z=e[t+2],i.max.x=e[t+3],i.max.y=e[t+4],i.max.z=e[t+5],i}function xB(t){let e=-1,i=-1/0;for(let n=0;n<3;n++){let r=t[n+3]-t[n];r>i&&(i=r,e=n)}return e}function wB(t,e){e.set(t)}function SB(t,e,i){let n,r;for(let s=0;s<3;s++){let a=s+3;n=t[s],r=e[s],i[s]=n<r?n:r,n=t[a],r=e[a],i[a]=n>r?n:r}}function uy(t,e,i){for(let n=0;n<3;n++){let r=e[t+2*n],s=e[t+2*n+1],a=r-s,o=r+s;a<i[n]&&(i[n]=a),o>i[n+3]&&(i[n+3]=o)}}function Jf(t){let e=t[3]-t[0],i=t[4]-t[1],n=t[5]-t[2];return 2*(e*i+i*n+n*e)}function Wn(t,e){return e[t+15]===65535}function Dr(t,e){return e[t+6]}function Gr(t,e){return e[t+14]}function sr(t){return t+8}function ar(t,e){return t+8*e[t+6]}function V3(t,e){return e[t+7]}function pM(t,e,i,n,r){let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,y=t.offset||0;for(let v=6*(e-y),_=6*(e+i-y);v<_;v+=6){let b=t[v+0],x=t[v+1],w=b-x,S=b+x;w<s&&(s=w),S>l&&(l=S),b<u&&(u=b),b>f&&(f=b);let A=t[v+2],E=t[v+3],P=A-E,T=A+E;P<a&&(a=P),T>c&&(c=T),A<d&&(d=A),A>g&&(g=A);let R=t[v+4],L=t[v+5],D=R-L,U=R+L;D<o&&(o=D),U>h&&(h=U),R<p&&(p=R),R>m&&(m=R)}n[0]=s,n[1]=a,n[2]=o,n[3]=l,n[4]=c,n[5]=h,r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=g,r[5]=m}var oj,R1,LT,lj,OJ=(t,e)=>t.candidate-e.candidate,Rl=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),py=new Float32Array(6),fM=class{constructor(){this.boundingData=new Float32Array(6)}},LJ=Math.pow(2,32);function BT(t){return"count"in t?1:1+BT(t.left)+BT(t.right)}function BJ(t,e,i){return oj=new Float32Array(i),R1=new Uint32Array(i),LT=new Uint16Array(i),lj=new Uint8Array(i),UT(t,e)}function UT(t,e){let i=t/4,n=t/2,r="count"in e,s=e.boundingData;for(let a=0;a<6;a++)oj[i+a]=s[a];if(r)return e.buffer?(lj.set(new Uint8Array(e.buffer),t),t+e.buffer.byteLength):(R1[i+6]=e.offset,LT[n+14]=e.count,LT[n+15]=65535,t+32);{let{left:a,right:o,splitAxis:l}=e,c=UT(t+32,a),h=c/32-t/32;if(h>LJ)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return R1[i+6]=h,R1[i+7]=l,UT(c,o)}}function UJ(t,e){let i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=t.getRootRanges(e.range),r=n[0],s=n[n.length-1],a={offset:r.offset,count:s.offset+s.count-r.offset},o=new Float32Array(6*a.count);o.offset=a.offset,t.computePrimitiveBounds(a.offset,a.count,o),t._roots=n.map(l=>{let c=function(d,p,f,g,m,y){let{maxDepth:v,verbose:_,maxLeafSize:b,strategy:x,onProgress:w}=m,S=d.primitiveBuffer,A=d.primitiveBufferStride,E=new Float32Array(6),P=!1,T=new fM;return pM(p,f,g,T.boundingData,E),function L(D,U,V,k=null,Y=0){if(!P&&Y>=v&&(P=!0,_&&console.warn(`BVH: Max depth of ${v} reached when generating BVH. Consider increasing maxDepth.`)),V<=b||Y>=v)return R(U+V),D.offset=U,D.count=V,D;let $=function(Q,rt,gt,at,ht,ct){let q=-1,lt=0;if(ct===0)q=xB(rt),q!==-1&&(lt=(rt[q]+rt[q+3])/2);else if(ct===1)q=xB(Q),q!==-1&&(lt=function(F,O,j,Z){let I=0,G=F.offset;for(let W=O,N=O+j;W<N;W++)I+=F[6*(W-G)+2*Z];return I/j}(gt,at,ht,q));else if(ct===2){let F=Jf(Q),O=1.25*ht,j=gt.offset||0,Z=6*(at-j),I=6*(at+ht-j);for(let G=0;G<3;G++){let W=rt[G],N=(rt[G+3]-W)/32;if(ht<8){let tt=[...Rl];tt.length=ht;let ot=0;for(let ut=Z;ut<I;ut+=6,ot++){let Pt=tt[ot];Pt.candidate=gt[ut+2*G],Pt.count=0;let{bounds:bt,leftCacheBounds:Rt,rightCacheBounds:_t}=Pt;for(let X=0;X<3;X++)_t[X]=1/0,_t[X+3]=-1/0,Rt[X]=1/0,Rt[X+3]=-1/0,bt[X]=1/0,bt[X+3]=-1/0;uy(ut,gt,bt)}tt.sort(OJ);let pt=ht;for(let ut=0;ut<pt;ut++){let Pt=tt[ut];for(;ut+1<pt&&tt[ut+1].candidate===Pt.candidate;)tt.splice(ut+1,1),pt--}for(let ut=Z;ut<I;ut+=6){let Pt=gt[ut+2*G];for(let bt=0;bt<pt;bt++){let Rt=tt[bt];Pt>=Rt.candidate?uy(ut,gt,Rt.rightCacheBounds):(uy(ut,gt,Rt.leftCacheBounds),Rt.count++)}}for(let ut=0;ut<pt;ut++){let Pt=tt[ut],bt=Pt.count,Rt=ht-Pt.count,_t=Pt.leftCacheBounds,X=Pt.rightCacheBounds,vt=0;bt!==0&&(vt=Jf(_t)/F);let Dt=0;Rt!==0&&(Dt=Jf(X)/F);let jt=1+1.25*(vt*bt+Dt*Rt);jt<O&&(q=G,O=jt,lt=Pt.candidate)}}else{for(let pt=0;pt<32;pt++){let ut=Rl[pt];ut.count=0,ut.candidate=W+N+pt*N;let Pt=ut.bounds;for(let bt=0;bt<3;bt++)Pt[bt]=1/0,Pt[bt+3]=-1/0}for(let pt=Z;pt<I;pt+=6){let ut=~~((gt[pt+2*G]-W)/N);ut>=32&&(ut=31);let Pt=Rl[ut];Pt.count++,uy(pt,gt,Pt.bounds)}let tt=Rl[31];wB(tt.bounds,tt.rightCacheBounds);for(let pt=30;pt>=0;pt--){let ut=Rl[pt],Pt=Rl[pt+1];SB(ut.bounds,Pt.rightCacheBounds,ut.rightCacheBounds)}let ot=0;for(let pt=0;pt<31;pt++){let ut=Rl[pt],Pt=ut.count,bt=ut.bounds,Rt=Rl[pt+1].rightCacheBounds;Pt!==0&&(ot===0?wB(bt,py):SB(bt,py,py)),ot+=Pt;let _t=0,X=0;ot!==0&&(_t=Jf(py)/F);let vt=ht-ot;vt!==0&&(X=Jf(Rt)/F);let Dt=1+1.25*(_t*ot+X*vt);Dt<O&&(q=G,O=Dt,lt=ut.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${ct} used.`);return{axis:q,pos:lt}}(D.boundingData,k,p,U,V,x);if($.axis===-1)return R(U+V),D.offset=U,D.count=V,D;let nt=function(Q,rt,gt,at,ht,ct){let q=at,lt=at+ht-1,F=ct.pos,O=2*ct.axis,j=gt.offset||0;for(;;){for(;q<=lt&&gt[6*(q-j)+O]<F;)q++;for(;q<=lt&&gt[6*(lt-j)+O]>=F;)lt--;if(!(q<lt))return q;for(let Z=0;Z<rt;Z++){let I=Q[q*rt+Z];Q[q*rt+Z]=Q[lt*rt+Z],Q[lt*rt+Z]=I}for(let Z=0;Z<6;Z++){let I=q-j,G=lt-j,W=gt[6*I+Z];gt[6*I+Z]=gt[6*G+Z],gt[6*G+Z]=W}q++,lt--}}(S,A,p,U,V,$);if(nt===U||nt===U+V)R(U+V),D.offset=U,D.count=V;else{D.splitAxis=$.axis;let Q=new fM,rt=U,gt=nt-U;D.left=Q,pM(p,rt,gt,Q.boundingData,E),L(Q,rt,gt,E,Y+1);let at=new fM,ht=nt,ct=V-gt;D.right=at,pM(p,ht,ct,at.boundingData,E),L(at,ht,ct,E,Y+1)}return D}(T,f,g,E),T;function R(L){w&&w((L-y.offset)/y.count)}}(t,o,l.offset,l.count,e,a),h=BT(c),u=new i(32*h);return BJ(0,c,u),u})}et();var eh,Fu,j3=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}},Bi=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let t=[],e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}},Jd=[],fy=new j3(()=>new ci);function zJ(t,e,i,n,r,s){eh=fy.getPrimitive(),Fu=fy.getPrimitive(),Jd.push(eh,Fu),Bi.setBuffer(t._roots[e]);let a=zT(0,t.geometry,i,n,r,s);Bi.clearBuffer(),fy.releasePrimitive(eh),fy.releasePrimitive(Fu),Jd.pop(),Jd.pop();let o=Jd.length;return o>0&&(Fu=Jd[o-1],eh=Jd[o-2]),a}function zT(t,e,i,n,r=null,s=0,a=0){let{float32Array:o,uint16Array:l,uint32Array:c}=Bi,h=2*t;if(Wn(h,l)){let u=Dr(t,c),d=Gr(h,l);return Qi(t,o,eh),n(u,d,!1,a,s+t/8,eh)}{let u,d,p,f,g=function(E){let{uint16Array:P,uint32Array:T}=Bi,R=2*E;for(;!Wn(R,P);)R=2*(E=sr(E));return Dr(E,T)},m=function(E){let{uint16Array:P,uint32Array:T}=Bi,R=2*E;for(;!Wn(R,P);)R=2*(E=ar(E,T));return Dr(E,T)+Gr(R,P)},y=sr(t),v=ar(t,c),_=y,b=v;if(r&&(p=eh,f=Fu,Qi(_,o,p),Qi(b,o,f),u=r(p),d=r(f),d<u)){_=v,b=y;let E=u;u=d,d=E,p=f}p||(p=eh,Qi(_,o,p));let x,w=i(p,Wn(2*_,l),u,a+1,s+_/8);if(w===2){let E=g(_);x=n(E,m(_)-E,!0,a+1,s+_/8,p)}else x=w&&zT(_,e,i,n,r,s,a+1);if(x)return!0;f=Fu,Qi(b,o,f);let S,A=i(f,Wn(2*b,l),d,a+1,s+b/8);if(A===2){let E=g(b);S=n(E,m(b)-E,!0,a+1,s+b/8,f)}else S=A&&zT(b,e,i,n,r,s,a+1);return!!S}}et();var fg=new Bi.constructor,Ab=new Bi.constructor,Nl=new j3(()=>new ci),tu=new ci,eu=new ci,mM=new ci,gM=new ci,vM=!1;function ra(t,e,i,n,r,s=0,a=0,o=0,l=0,c=null,h=!1){let u,d;h?(u=Ab,d=fg):(u=fg,d=Ab);let p=u.float32Array,f=u.uint32Array,g=u.uint16Array,m=d.float32Array,y=d.uint32Array,v=d.uint16Array,_=2*e,b=Wn(2*t,g),x=Wn(_,v),w=!1;if(x&&b)w=h?r(Dr(e,y),Gr(2*e,v),Dr(t,f),Gr(2*t,g),l,a+e/8,o,s+t/8):r(Dr(t,f),Gr(2*t,g),Dr(e,y),Gr(2*e,v),o,s+t/8,l,a+e/8);else if(x){let S=Nl.getPrimitive();Qi(e,m,S),S.applyMatrix4(i);let A=sr(t),E=ar(t,f);Qi(A,p,tu),Qi(E,p,eu);let P=S.intersectsBox(tu),T=S.intersectsBox(eu);w=P&&ra(e,A,n,i,r,a,s,l,o+1,S,!h)||T&&ra(e,E,n,i,r,a,s,l,o+1,S,!h),Nl.releasePrimitive(S)}else{let S=sr(e),A=ar(e,y);Qi(S,m,mM),Qi(A,m,gM);let E=c.intersectsBox(mM),P=c.intersectsBox(gM);if(E&&P)w=ra(t,S,i,n,r,s,a,o,l+1,c,h)||ra(t,A,i,n,r,s,a,o,l+1,c,h);else if(E)if(b)w=ra(t,S,i,n,r,s,a,o,l+1,c,h);else{let T=Nl.getPrimitive();T.copy(mM).applyMatrix4(i);let R=sr(t),L=ar(t,f);Qi(R,p,tu),Qi(L,p,eu);let D=T.intersectsBox(tu),U=T.intersectsBox(eu);w=D&&ra(S,R,n,i,r,a,s,l,o+1,T,!h)||U&&ra(S,L,n,i,r,a,s,l,o+1,T,!h),Nl.releasePrimitive(T)}else if(P)if(b)w=ra(t,A,i,n,r,s,a,o,l+1,c,h);else{let T=Nl.getPrimitive();T.copy(gM).applyMatrix4(i);let R=sr(t),L=ar(t,f);Qi(R,p,tu),Qi(L,p,eu);let D=T.intersectsBox(tu),U=T.intersectsBox(eu);w=D&&ra(A,R,n,i,r,a,s,l,o+1,T,!h)||U&&ra(A,L,n,i,r,a,s,l,o+1,T,!h),Nl.releasePrimitive(T)}}return w}var MB=new ci,iu=new Float32Array(6),FJ=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){UJ(this,t={...aj,...t})}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(t,e,i,n){let r=1/0,s=1/0,a=1/0,o=-1/0,l=-1/0,c=-1/0;for(let h=t,u=t+e;h<u;h++){this.writePrimitiveBounds(h,iu,0);let[d,p,f,g,m,y]=iu;d<r&&(r=d),g>o&&(o=g),p<s&&(s=p),m>l&&(l=m),f<a&&(a=f),y>c&&(c=y)}return i[n+0]=r,i[n+1]=s,i[n+2]=a,i[n+3]=o,i[n+4]=l,i[n+5]=c,i}computePrimitiveBounds(t,e,i){let n=i.offset||0;for(let r=t,s=t+e;r<s;r++){this.writePrimitiveBounds(r,iu,0);let[a,o,l,c,h,u]=iu,d=(a+c)/2,p=(o+h)/2,f=(l+u)/2,g=(c-a)/2,m=(h-o)/2,y=(u-l)/2,v=6*(r-n);i[v+0]=d,i[v+1]=g+(Math.abs(d)+g)*D1,i[v+2]=p,i[v+3]=m+(Math.abs(p)+m)*D1,i[v+4]=f,i[v+5]=y+(Math.abs(f)+y)*D1}return i}shiftPrimitiveOffsets(t){let e=this._indirectBuffer;if(e)for(let i=0,n=e.length;i<n;i++)e[i]+=t;else{let i=this._roots;for(let n=0;n<i.length;n++){let r=i[n],s=new Uint32Array(r),a=new Uint16Array(r),o=r.byteLength/32;for(let l=0;l<o;l++){let c=8*l;Wn(2*c,a)&&(s[c+6]+=t)}}}}traverse(t,e=0){let i=this._roots[e],n=new Uint32Array(i),r=new Uint16Array(i);(function s(a,o=0){let l=2*a,c=Wn(l,r);if(c){let h=n[a+6],u=r[l+14];t(o,c,new Float32Array(i,4*a,6),h,u)}else{let h=sr(a),u=ar(a,n),d=V3(a,n);t(o,c,new Float32Array(i,4*a,6),d)||(s(h,o+1),s(u,o+1))}})(0)}refit(){let t=this._roots;for(let e=0,i=t.length;e<i;e++){let n=t[e],r=new Uint32Array(n),s=new Uint16Array(n),a=new Float32Array(n);for(let o=n.byteLength/32-1;o>=0;o--){let l=8*o,c=2*l;if(Wn(c,s)){let h=Dr(l,r),u=Gr(c,s);this.writePrimitiveRangeBounds(h,u,iu,0),a.set(iu,l)}else{let h=sr(l),u=ar(l,r);for(let d=0;d<3;d++){let p=a[h+d],f=a[h+d+3],g=a[u+d],m=a[u+d+3];a[l+d]=p<g?p:g,a[l+d+3]=f>m?f:m}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(e=>{Qi(0,new Float32Array(e),MB),t.union(MB)}),t}shapecast(t){let{boundsTraverseOrder:e,intersectsBounds:i,intersectsRange:n,intersectsPrimitive:r,scratchPrimitive:s,iterate:a}=t;if(n&&r){let h=n;n=(u,d,p,f,g)=>!!h(u,d,p,f,g)||a(u,d,this,r,p,f,s)}else n||(n=r?(h,u,d,p)=>a(h,u,this,r,d,p,s):(h,u,d)=>d);let o=!1,l=0,c=this._roots;for(let h=0,u=c.length;h<u;h++){let d=c[h];if(o=zJ(this,h,i,n,e,l),o)break;l+=d.byteLength/32}return o}bvhcast(t,e,i){let{intersectsRanges:n}=i;return function(r,s,a,o){if(vM)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");vM=!0;let l,c=r._roots,h=s._roots,u=0,d=0,p=new At().copy(a).invert();for(let f=0,g=c.length;f<g;f++){fg.setBuffer(c[f]),d=0;let m=Nl.getPrimitive();Qi(0,fg.float32Array,m),m.applyMatrix4(p);for(let y=0,v=h.length;y<v&&(Ab.setBuffer(h[y]),l=ra(0,0,a,p,o,u,d,0,0,m),Ab.clearBuffer(),d+=h[y].byteLength/32,!l);y++);if(Nl.releasePrimitive(m),fg.clearBuffer(),u+=c[f].byteLength/32,l)break}return vM=!1,l}(this,t,e,n)}};function FT(t){return t.index?t.index.count:t.attributes.position.count}function bx(t){return FT(t)/3}function EB(t,e,i){let n=function(d,p,f){let g=FT(d)/f,m=p||d.drawRange,y=m.start/f,v=(m.start+m.count)/f,_=Math.max(0,y),b=Math.min(g,v)-_;return{offset:Math.floor(_),count:Math.floor(b)}}(t,e,i),r=function(d,p){return d.groups.map(f=>({offset:f.start/p,count:f.count/p}))}(t,i);if(!r.length)return[n];let s=[],a=n.offset,o=n.offset+n.count,l=FT(t)/i,c=[];for(let d of r){let{offset:p,count:f}=d,g=p,m=p+(isFinite(f)?f:l-p);g<o&&m>a&&(c.push({pos:Math.max(a,g),isStart:!0}),c.push({pos:Math.min(o,m),isStart:!1}))}c.sort((d,p)=>d.pos!==p.pos?d.pos-p.pos:d.type==="end"?-1:1);let h=0,u=null;for(let d of c){let p=d.pos;h!==0&&p!==u&&s.push({offset:u,count:p-u}),h+=d.isStart?1:-1,u=p}return s}et(),et();var NJ=class extends FJ{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(t){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(t){}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("BVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");if(e.useSharedArrayBuffer&&!(typeof SharedArrayBuffer<"u"))throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=t,this.resolvePrimitiveIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,(e={...aj,...e})[k3]||this.init(e)}init(t){let{geometry:e,primitiveStride:i}=this;if(t.indirect){let n=function(r,s){let a=r[r.length-1],o=a.offset+a.count>65536,l=r.reduce((p,f)=>p+f.count,0),c=o?4:2,h=s?new SharedArrayBuffer(l*c):new ArrayBuffer(l*c),u=o?new Uint32Array(h):new Uint16Array(h),d=0;for(let p=0;p<r.length;p++){let{offset:f,count:g}=r[p];for(let m=0;m<g;m++)u[d+m]=f+m;d+=g}return u}(EB(e,t.range,i),t.useSharedArrayBuffer);this._indirectBuffer=n}else(function(n,r){if(!n.index){let s=n.attributes.position.count,a=function(o,l=ArrayBuffer){return o>65535?new Uint32Array(new l(4*o)):new Uint16Array(new l(2*o))}(s,r.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);n.setIndex(new Ht(a,1));for(let o=0;o<s;o++)a[o]=o}})(e,t);super.init(t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ci))}getRootRanges(t){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:EB(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}};et(),et(),et();var ao=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,n=-1/0;for(let r=0,s=t.length;r<s;r++){let a=t[r][e];i=a<i?a:i,n=a>n?a:n}this.min=i,this.max=n}setFromPoints(t,e){let i=1/0,n=-1/0;for(let r=0,s=e.length;r<s;r++){let a=e[r],o=t.dot(a);i=o<i?o:i,n=o>n?o:n}this.min=i,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};ao.prototype.setFromBox=function(){let t=new C;return function(e,i){let n=i.min,r=i.max,s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let c=0;c<=1;c++){t.x=n.x*o+r.x*(1-o),t.y=n.y*l+r.y*(1-l),t.z=n.z*c+r.z*(1-c);let h=e.dot(t);s=Math.min(h,s),a=Math.max(h,a)}this.min=s,this.max=a}}(),new ao,et(),et();var kJ=function(){let t=new C,e=new C,i=new C;return function(n,r,s){let a=n.start,o=t,l=r.start,c=e;i.subVectors(a,l),t.subVectors(n.end,n.start),e.subVectors(r.end,r.start);let h,u,d=i.dot(c),p=c.dot(o),f=c.dot(c),g=i.dot(o),m=o.dot(o)*f-p*p;h=m!==0?(d*p-g*f)/m:0,u=(d+h*p)/f,s.x=h,s.y=u}}(),NT=function(){let t=new it,e=new C,i=new C;return function(n,r,s,a){kJ(n,r,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return n.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void n.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?n.at(0,s):n.at(1,s),void r.closestPointToPoint(s,!0,a);{let c,h;c=o<0?n.start:n.end,h=l<0?r.start:r.end;let u=e,d=i;return n.closestPointToPoint(h,!0,e),r.closestPointToPoint(c,!0,i),u.distanceToSquared(h)<=d.distanceToSquared(c)?(s.copy(u),void a.copy(h)):(s.copy(c),void a.copy(d))}}}(),VJ=function(){let t=new C,e=new C,i=new kr,n=new vs;return function(r,s){let{radius:a,center:o}=r,{a:l,b:c,c:h}=s;if(n.start=l,n.end=c,n.closestPointToPoint(o,!0,t).distanceTo(o)<=a||(n.start=l,n.end=h,n.closestPointToPoint(o,!0,t).distanceTo(o)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(o,!0,t).distanceTo(o)<=a))return!0;let u=s.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=a){let d=u.projectPoint(o,e);if(s.containsPoint(d))return!0}return!1}}(),jJ=["x","y","z"],gc=1e-15;function Ls(t){return Math.abs(t)<gc}var fa=class extends pn{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new C),this.satBounds=new Array(4).fill().map(()=>new ao),this.points=[this.a,this.b,this.c],this.plane=new kr,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new vs,this.needsUpdate=!0}intersectsSphere(t){return VJ(t,this)}update(){let t=this.a,e=this.b,i=this.c,n=this.points,r=this.satAxes,s=this.satBounds,a=r[0],o=s[0];this.getNormal(a),o.setFromPoints(a,n);let l=r[1],c=s[1];l.subVectors(t,e),c.setFromPoints(l,n);let h=r[2],u=s[2];h.subVectors(e,i),u.setFromPoints(h,n);let d=r[3],p=s[3];d.subVectors(i,t),p.setFromPoints(d,n);let f=l.length(),g=h.length(),m=d.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,f<gc?g<gc||m<gc?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(i)):g<gc?m<gc?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):m<gc&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};fa.prototype.closestPointToSegment=function(){let t=new C,e=new C,i=new vs;return function(n,r=null,s=null){let a,{start:o,end:l}=n,c=this.points,h=1/0;for(let u=0;u<3;u++){let d=(u+1)%3;i.start.copy(c[u]),i.end.copy(c[d]),NT(i,n,t,e),a=t.distanceToSquared(e),a<h&&(h=a,r&&r.copy(t),s&&s.copy(e))}return this.closestPointToPoint(o,t),a=o.distanceToSquared(t),a<h&&(h=a,r&&r.copy(t),s&&s.copy(o)),this.closestPointToPoint(l,t),a=l.distanceToSquared(t),a<h&&(h=a,r&&r.copy(t),s&&s.copy(l)),Math.sqrt(h)}}(),fa.prototype.intersectsTriangle=function(){let t=new fa,e=new ao,i=new ao,n=new C,r=new C,s=new C,a=new C,o=new vs,l=new vs,c=new C,h=new it,u=new it;function d(v,_,b,x){let w=n;v.isDegenerateIntoPoint||v.isDegenerateIntoSegment?w.copy(_.plane.normal):w.copy(v.plane.normal);let S=v.satBounds,A=v.satAxes;for(let T=1;T<4;T++){let R=S[T],L=A[T];if(e.setFromPoints(L,_.points),R.isSeparated(e)||(a.copy(w).cross(L),e.setFromPoints(a,v.points),i.setFromPoints(a,_.points),e.isSeparated(i)))return!1}let E=_.satBounds,P=_.satAxes;for(let T=1;T<4;T++){let R=E[T],L=P[T];if(e.setFromPoints(L,v.points),R.isSeparated(e)||(a.crossVectors(w,L),e.setFromPoints(a,v.points),i.setFromPoints(a,_.points),e.isSeparated(i)))return!1}return b&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),b.start.set(0,0,0),b.end.set(0,0,0)),!0}function p(v,_,b,x,w,S,A,E,P,T,R){let L=A/(A-E);T.x=x+(w-x)*L,R.start.subVectors(_,v).multiplyScalar(L).add(v),L=A/(A-P),T.y=x+(S-x)*L,R.end.subVectors(b,v).multiplyScalar(L).add(v)}function f(v,_,b,x,w,S,A,E,P,T,R){if(w>0)p(v.c,v.a,v.b,x,_,b,P,A,E,T,R);else if(S>0)p(v.b,v.a,v.c,b,_,x,E,A,P,T,R);else if(E*P>0||A!=0)p(v.a,v.b,v.c,_,b,x,A,E,P,T,R);else if(E!=0)p(v.b,v.a,v.c,b,_,x,E,A,P,T,R);else{if(P==0)return!0;p(v.c,v.a,v.b,x,_,b,P,A,E,T,R)}return!1}function g(v,_,b,x){let w=_.degenerateSegment,S=v.plane.distanceToPoint(w.start),A=v.plane.distanceToPoint(w.end);return Ls(S)?Ls(A)?d(v,_,b,x):(b&&(b.start.copy(w.start),b.end.copy(w.start)),v.containsPoint(w.start)):Ls(A)?(b&&(b.start.copy(w.end),b.end.copy(w.end)),v.containsPoint(w.end)):v.plane.intersectLine(w,n)!=null&&(b&&(b.start.copy(n),b.end.copy(n)),v.containsPoint(n))}function m(v,_,b){let x=_.a;return!(!Ls(v.plane.distanceToPoint(x))||!v.containsPoint(x)||(b&&(b.start.copy(x),b.end.copy(x)),0))}function y(v,_,b){let x=v.degenerateSegment,w=_.a;return x.closestPointToPoint(w,!0,n),w.distanceToSquared(n)<1e-30&&(b&&(b.start.copy(w),b.end.copy(w)),!0)}return function(v,_=null,b=!1){this.needsUpdate&&this.update(),v.isExtendedTriangle?v.needsUpdate&&v.update():(t.copy(v),t.update(),v=t);let x=function(F,O,j,Z){if(F.isDegenerateIntoSegment){if(O.isDegenerateIntoSegment){let I=F.degenerateSegment,G=O.degenerateSegment,W=r,N=s;I.delta(W),G.delta(N);let tt=n.subVectors(G.start,I.start),ot=W.x*N.y-W.y*N.x;if(Ls(ot))return!1;let pt=(tt.x*N.y-tt.y*N.x)/ot,ut=-(W.x*tt.y-W.y*tt.x)/ot;return!(pt<0||pt>1||ut<0||ut>1||!Ls(I.start.z+W.z*pt-(G.start.z+N.z*ut))||(j&&(j.start.copy(I.start).addScaledVector(W,pt),j.end.copy(I.start).addScaledVector(W,pt)),0))}return O.isDegenerateIntoPoint?y(F,O,j):g(O,F,j,Z)}return F.isDegenerateIntoPoint?O.isDegenerateIntoPoint?O.a.distanceToSquared(F.a)<1e-30&&(j&&(j.start.copy(F.a),j.end.copy(F.a)),!0):O.isDegenerateIntoSegment?y(O,F,j):m(O,F,j):O.isDegenerateIntoPoint?m(F,O,j):O.isDegenerateIntoSegment?g(F,O,j,Z):void 0}(this,v,_,b);if(x!==void 0)return x;let w=this.plane,S=v.plane,A=S.distanceToPoint(this.a),E=S.distanceToPoint(this.b),P=S.distanceToPoint(this.c);Ls(A)&&(A=0),Ls(E)&&(E=0),Ls(P)&&(P=0);let T=A*E,R=A*P;if(T>0&&R>0)return!1;let L=w.distanceToPoint(v.a),D=w.distanceToPoint(v.b),U=w.distanceToPoint(v.c);Ls(L)&&(L=0),Ls(D)&&(D=0),Ls(U)&&(U=0);let V=L*D,k=L*U;if(V>0&&k>0)return!1;r.copy(w.normal),s.copy(S.normal);let Y=r.cross(s),$=0,nt=Math.abs(Y.x),Q=Math.abs(Y.y);Q>nt&&(nt=Q,$=1),Math.abs(Y.z)>nt&&($=2);let rt=jJ[$],gt=this.a[rt],at=this.b[rt],ht=this.c[rt],ct=v.a[rt],q=v.b[rt],lt=v.c[rt];if(f(this,gt,at,ht,T,R,A,E,P,h,o))return d(this,v,_,b);if(f(v,ct,q,lt,V,k,L,D,U,u,l))return d(this,v,_,b);if(h.y<h.x){let F=h.y;h.y=h.x,h.x=F,c.copy(o.start),o.start.copy(o.end),o.end.copy(c)}if(u.y<u.x){let F=u.y;u.y=u.x,u.x=F,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return!(h.y<u.x||u.y<h.x||(_&&(u.x>h.x?_.start.copy(l.start):_.start.copy(o.start),u.y<h.y?_.end.copy(l.end):_.end.copy(o.end)),0))}}(),fa.prototype.distanceToPoint=function(){let t=new C;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),fa.prototype.distanceToTriangle=function(){let t=new C,e=new C,i=["a","b","c"],n=new vs,r=new vs;return function(s,a=null,o=null){let l=a||o?n:null;if(this.intersectsTriangle(s,l,!0))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let h=0;h<3;h++){let u,d=i[h],p=s[d];this.closestPointToPoint(p,t),u=p.distanceToSquared(t),u<c&&(c=u,a&&a.copy(t),o&&o.copy(p));let f=this[d];s.closestPointToPoint(f,t),u=f.distanceToSquared(t),u<c&&(c=u,a&&a.copy(f),o&&o.copy(t))}for(let h=0;h<3;h++){let u=i[h],d=i[(h+1)%3];n.set(this[u],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];r.set(s[f],s[g]),NT(n,r,t,e);let m=t.distanceToSquared(e);m<c&&(c=m,a&&a.copy(t),o&&o.copy(e))}}return Math.sqrt(c)}}();var Vr=class{constructor(t,e,i){this.isOrientedBox=!0,this.min=new C,this.max=new C,this.matrix=new At,this.invMatrix=new At,this.points=new Array(8).fill().map(()=>new C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new ao),this.alignedSatBounds=new Array(3).fill().map(()=>new ao),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Vr.prototype.update=function(){let t=this.matrix,e=this.min,i=this.max,n=this.points;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let u=n[1*l|2*c|4*h];u.x=l?i.x:e.x,u.y=c?i.y:e.y,u.z=h?i.z:e.z,u.applyMatrix4(t)}let r=this.satBounds,s=this.satAxes,a=n[0];for(let l=0;l<3;l++){let c=s[l],h=r[l],u=n[1<<l];c.subVectors(a,u),h.setFromPoints(c,n)}let o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Vr.prototype.intersectsBox=function(){let t=new ao;return function(e){this.needsUpdate&&this.update();let i=e.min,n=e.max,r=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(t.min=i.x,t.max=n.x,a[0].isSeparated(t)||(t.min=i.y,t.max=n.y,a[1].isSeparated(t))||(t.min=i.z,t.max=n.z,a[2].isSeparated(t)))return!1;for(let o=0;o<3;o++){let l=s[o],c=r[o];if(t.setFromBox(l,e),c.isSeparated(t))return!1}return!0}}(),Vr.prototype.intersectsTriangle=function(){let t=new fa,e=new Array(3),i=new ao,n=new ao,r=new C;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(t.copy(s),t.update(),s=t);let a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let u=0;u<3;u++){let d=a[u],p=o[u];if(i.setFromPoints(p,e),d.isSeparated(i))return!1}let l=s.satBounds,c=s.satAxes,h=this.points;for(let u=0;u<3;u++){let d=l[u],p=c[u];if(i.setFromPoints(p,h),d.isSeparated(i))return!1}for(let u=0;u<3;u++){let d=o[u];for(let p=0;p<4;p++){let f=c[p];if(r.crossVectors(d,f),i.setFromPoints(r,e),n.setFromPoints(r,h),i.isSeparated(n))return!1}}return!0}}(),Vr.prototype.closestPointToPoint=function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e},Vr.prototype.distanceToPoint=function(){let t=new C;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),Vr.prototype.distanceToBox=function(){let t=["x","y","z"],e=new Array(12).fill().map(()=>new vs),i=new Array(12).fill().map(()=>new vs),n=new C,r=new C;return function(s,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(r),this.closestPointToPoint(r,n),s.closestPointToPoint(n,r),o&&o.copy(n),l&&l.copy(r)),0;let c=a*a,h=s.min,u=s.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];r.copy(m).clamp(h,u);let y=m.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(m),l&&l.copy(r),y<c))return Math.sqrt(y)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){let v=(g+1)%3,_=(g+2)%3,b=1<<g|m<<v|y<<_,x=d[m<<v|y<<_],w=d[b];e[f].set(x,w);let S=t[g],A=t[v],E=t[_],P=i[f],T=P.start,R=P.end;T[S]=h[S],T[A]=m?h[A]:u[A],T[E]=y?h[E]:u[A],R[S]=u[S],R[A]=m?h[A]:u[A],R[E]=y?h[E]:u[A],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){r.x=g?u.x:h.x,r.y=m?u.y:h.y,r.z=y?u.z:h.z,this.closestPointToPoint(r,n);let v=r.distanceToSquared(n);if(v<p&&(p=v,o&&o.copy(n),l&&l.copy(r),v<c))return Math.sqrt(v)}for(let g=0;g<12;g++){let m=e[g];for(let y=0;y<12;y++){let v=i[y];NT(m,v,n,r);let _=n.distanceToSquared(r);if(_<p&&(p=_,o&&o.copy(n),l&&l.copy(r),_<c))return Math.sqrt(_)}}return Math.sqrt(p)}}();var ks=new class extends j3{constructor(){super(()=>new fa)}};et();var tm=new C,yM=new C;et();var my=parseInt(el)>=169,GJ=parseInt(el)<=161,ac=new C,oc=new C,lc=new C,gy=new it,vy=new it,yy=new it,AB=new C,TB=new C,CB=new C,em=new C;function PB(t,e,i,n,r,s,a,o,l,c,h){ac.fromBufferAttribute(e,s),oc.fromBufferAttribute(e,a),lc.fromBufferAttribute(e,o);let u=function(d,p,f,g,m,y,v,_){let b;if(b=y===qn?d.intersectTriangle(g,f,p,!0,m):d.intersectTriangle(p,f,g,y!==Hn,m),b===null)return null;let x=d.origin.distanceTo(m);return x<v||x>_?null:{distance:x,point:m.clone()}}(t,ac,oc,lc,em,l,c,h);if(u){if(n){gy.fromBufferAttribute(n,s),vy.fromBufferAttribute(n,a),yy.fromBufferAttribute(n,o),u.uv=new it;let p=pn.getInterpolation(em,ac,oc,lc,gy,vy,yy,u.uv);my||(u.uv=p)}if(r){gy.fromBufferAttribute(r,s),vy.fromBufferAttribute(r,a),yy.fromBufferAttribute(r,o),u.uv1=new it;let p=pn.getInterpolation(em,ac,oc,lc,gy,vy,yy,u.uv1);my||(u.uv1=p),GJ&&(u.uv2=u.uv1)}if(i){AB.fromBufferAttribute(i,s),TB.fromBufferAttribute(i,a),CB.fromBufferAttribute(i,o),u.normal=new C;let p=pn.getInterpolation(em,ac,oc,lc,AB,TB,CB,u.normal);u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1),my||(u.normal=p)}let d={a:s,b:a,c:o,normal:new C,materialIndex:0};if(pn.getNormal(ac,oc,lc,d.normal),u.face=d,u.faceIndex=s,my){let p=new C;pn.getBarycoord(em,ac,oc,lc,p),u.barycoord=p}}return u}function DB(t){return t&&t.isMaterial?t.side:t}function xx(t,e,i,n,r,s,a){let o=3*n,l=o+0,c=o+1,h=o+2,{index:u,groups:d}=t;t.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));let{position:p,normal:f,uv:g,uv1:m}=t.attributes;if(Array.isArray(e)){let y=3*n;for(let v=0,_=d.length;v<_;v++){let{start:b,count:x,materialIndex:w}=d[v];if(y>=b&&y<b+x){let S=PB(i,p,f,g,m,l,c,h,DB(e[w]),s,a);if(S){if(S.faceIndex=n,S.face.materialIndex=w,!r)return S;r.push(S)}}}}else{let y=PB(i,p,f,g,m,l,c,h,DB(e),s,a);if(y){if(y.faceIndex=n,y.face.materialIndex=0,!r)return y;r.push(y)}}return null}function Pn(t,e,i,n){let r=t.a,s=t.b,a=t.c,o=e,l=e+1,c=e+2;i&&(o=i.getX(o),l=i.getX(l),c=i.getX(c)),r.x=n.getX(o),r.y=n.getY(o),r.z=n.getZ(o),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),a.x=n.getX(c),a.y=n.getY(c),a.z=n.getZ(c)}function HJ(t,e,i,n,r,s,a){let{geometry:o}=i,{index:l}=o,c=o.attributes.position;for(let h=t,u=e+t;h<u;h++){let d;if(d=h,Pn(a,3*d,l,c),a.needsUpdate=!0,n(a,d,r,s))return!0}return!1}function WJ(t,e=null){e&&Array.isArray(e)&&(e=new Set(e));let i,n,r,s,a=t.geometry,o=a.index?a.index.array:null,l=a.attributes.position,c=0,h=t._roots;for(let d=0,p=h.length;d<p;d++)i=h[d],n=new Uint32Array(i),r=new Uint16Array(i),s=new Float32Array(i),u(0,c),c+=i.byteLength;function u(d,p,f=!1){let g=2*d;if(Wn(g,r)){let m=Dr(d,n),y=1/0,v=1/0,_=1/0,b=-1/0,x=-1/0,w=-1/0;for(let S=3*m,A=3*(m+Gr(g,r));S<A;S++){let E=o[S],P=l.getX(E),T=l.getY(E),R=l.getZ(E);P<y&&(y=P),P>b&&(b=P),T<v&&(v=T),T>x&&(x=T),R<_&&(_=R),R>w&&(w=R)}return(s[d+0]!==y||s[d+1]!==v||s[d+2]!==_||s[d+3]!==b||s[d+4]!==x||s[d+5]!==w)&&(s[d+0]=y,s[d+1]=v,s[d+2]=_,s[d+3]=b,s[d+4]=x,s[d+5]=w,!0)}{let m=sr(d),y=ar(d,n),v=f,_=!1,b=!1;if(e){if(!v){let E=m/8+p/32,P=y/8+p/32;_=e.has(E),b=e.has(P),v=!_&&!b}}else _=!0,b=!0;let x=v||b,w=!1;(v||_)&&(w=u(m,p,v));let S=!1;x&&(S=u(y,p,v));let A=w||S;if(A)for(let E=0;E<3;E++){let P=m+E,T=y+E,R=s[P],L=s[P+3],D=s[T],U=s[T+3];s[d+E]=R<D?R:D,s[d+E+3]=L>U?L:U}return A}}}function vh(t,e,i,n,r){let s,a,o,l,c,h,u=1/i.direction.x,d=1/i.direction.y,p=1/i.direction.z,f=i.origin.x,g=i.origin.y,m=i.origin.z,y=e[t],v=e[t+3],_=e[t+1],b=e[t+3+1],x=e[t+2],w=e[t+3+2];return u>=0?(s=(y-f)*u,a=(v-f)*u):(s=(v-f)*u,a=(y-f)*u),d>=0?(o=(_-g)*d,l=(b-g)*d):(o=(b-g)*d,l=(_-g)*d),!(s>l||o>a||((o>s||isNaN(s))&&(s=o),(l<a||isNaN(a))&&(a=l),p>=0?(c=(x-m)*p,h=(w-m)*p):(c=(w-m)*p,h=(x-m)*p),s>h||c>a))&&((c>s||s!=s)&&(s=c),(h<a||a!=a)&&(a=h),s<=r&&a>=n)}function qJ(t,e,i,n,r,s,a){let{geometry:o}=i,{index:l}=o,c=o.attributes.position;for(let h=t,u=e+t;h<u;h++){let d;if(d=i.resolveTriangleIndex(h),Pn(a,3*d,l,c),a.needsUpdate=!0,n(a,d,r,s))return!0}return!1}function XJ(t,e,i,n,r,s,a){Bi.setBuffer(t._roots[e]),kT(0,t,i,n,r,s,a),Bi.clearBuffer()}function kT(t,e,i,n,r,s,a){let{float32Array:o,uint16Array:l,uint32Array:c}=Bi,h=2*t;if(Wn(h,l))(function(u,d,p,f,g,m,y,v){let{geometry:_,_indirectBuffer:b}=u;for(let x=f,w=f+g;x<w;x++)xx(_,d,p,x,m,y,v)})(e,i,n,Dr(t,c),Gr(h,l),r,s,a);else{let u=sr(t);vh(u,o,n,s,a)&&kT(u,e,i,n,r,s,a);let d=ar(t,c);vh(d,o,n,s,a)&&kT(d,e,i,n,r,s,a)}}var $J=["x","y","z"];function YJ(t,e,i,n,r,s){Bi.setBuffer(t._roots[e]);let a=VT(0,t,i,n,r,s);return Bi.clearBuffer(),a}function VT(t,e,i,n,r,s){let{float32Array:a,uint16Array:o,uint32Array:l}=Bi,c=2*t;if(Wn(c,o))return function(h,u,d,p,f,g,m){let{geometry:y,_indirectBuffer:v}=h,_=1/0,b=null;for(let x=p,w=p+f;x<w;x++){let S;S=xx(y,u,d,x,null,g,m),S&&S.distance<_&&(b=S,_=S.distance)}return b}(e,i,n,Dr(t,l),Gr(c,o),r,s);{let h,u,d=V3(t,l),p=$J[d],f=n.direction[p]>=0;f?(h=sr(t),u=ar(t,l)):(h=ar(t,l),u=sr(t));let g=vh(h,a,n,r,s)?VT(h,e,i,n,r,s):null;if(g){let y=g.point[p];if(f?y<=a[u+d]:y>=a[u+d+3])return g}let m=vh(u,a,n,r,s)?VT(u,e,i,n,r,s):null;return g&&m?g.distance<=m.distance?g:m:g||m||null}}et();var _y=new ci,nu=new fa,ru=new fa,im=new At,RB=new Vr,by=new Vr;function ZJ(t,e,i,n){Bi.setBuffer(t._roots[e]);let r=jT(0,t,i,n);return Bi.clearBuffer(),r}function jT(t,e,i,n,r=null){let{float32Array:s,uint16Array:a,uint32Array:o}=Bi,l=2*t;if(r===null&&(i.boundingBox||i.computeBoundingBox(),RB.set(i.boundingBox.min,i.boundingBox.max,n),r=RB),!Wn(l,a)){let c=sr(t),h=ar(t,o);return Qi(c,s,_y),!!(r.intersectsBox(_y)&&jT(c,e,i,n,r)||(Qi(h,s,_y),r.intersectsBox(_y)&&jT(h,e,i,n,r)))}{let c=e.geometry,h=c.index,u=c.attributes.position,d=i.index,p=i.attributes.position,f=Dr(t,o),g=Gr(l,a);if(im.copy(n).invert(),i.boundsTree)return Qi(t,s,by),by.matrix.copy(im),by.needsUpdate=!0,i.boundsTree.shapecast({intersectsBounds:m=>by.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(n),m.b.applyMatrix4(n),m.c.applyMatrix4(n),m.needsUpdate=!0;for(let y=3*f,v=3*(g+f);y<v;y+=3)if(Pn(ru,y,h,u),ru.needsUpdate=!0,m.intersectsTriangle(ru))return!0;return!1}});{let m=bx(i);for(let y=3*f,v=3*(g+f);y<v;y+=3){Pn(nu,y,h,u),nu.a.applyMatrix4(im),nu.b.applyMatrix4(im),nu.c.applyMatrix4(im),nu.needsUpdate=!0;for(let _=0,b=3*m;_<b;_+=3)if(Pn(ru,_,d,p),ru.needsUpdate=!0,nu.intersectsTriangle(ru))return!0}}}}et();var xy=new At,_M=new Vr,nm=new Vr,KJ=new C,QJ=new C,JJ=new C,ttt=new C;function ett(t,e,i,n={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),_M.set(e.boundingBox.min,e.boundingBox.max,i),_M.needsUpdate=!0;let o=t.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,u=e.index,d=ks.getPrimitive(),p=ks.getPrimitive(),f=KJ,g=QJ,m=null,y=null;r&&(m=JJ,y=ttt);let v=1/0,_=null,b=null;return xy.copy(i).invert(),nm.matrix.copy(xy),t.shapecast({boundsTraverseOrder:x=>_M.distanceToBox(x),intersectsBounds:(x,w,S)=>S<v&&S<a&&(w&&(nm.min.copy(x.min),nm.max.copy(x.max),nm.needsUpdate=!0),!0),intersectsRange:(x,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>nm.distanceToBox(S),intersectsBounds:(S,A,E)=>E<v&&E<a,intersectsRange:(S,A)=>{for(let E=S,P=S+A;E<P;E++){Pn(p,3*E,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let T=x,R=x+w;T<R;T++){Pn(d,3*T,c,l),d.needsUpdate=!0;let L=d.distanceToTriangle(p,f,m);if(L<v&&(g.copy(f),y&&y.copy(m),v=L,_=T,b=E),L<s)return!0}}}});for(let S=0,A=bx(e);S<A;S++){Pn(p,3*S,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let E=x,P=x+w;E<P;E++){Pn(d,3*E,c,l),d.needsUpdate=!0;let T=d.distanceToTriangle(p,f,m);if(T<v&&(g.copy(f),y&&y.copy(m),v=T,_=E,b=S),T<s)return!0}}}}),ks.releasePrimitive(d),ks.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(g):n.point=g.clone(),n.distance=v,n.faceIndex=_,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(xy),g.applyMatrix4(xy),r.distance=g.sub(r.point).length(),r.faceIndex=b),n)}function itt(t,e=null){e&&Array.isArray(e)&&(e=new Set(e));let i,n,r,s,a=t.geometry,o=a.index?a.index.array:null,l=a.attributes.position,c=0,h=t._roots;for(let d=0,p=h.length;d<p;d++)i=h[d],n=new Uint32Array(i),r=new Uint16Array(i),s=new Float32Array(i),u(0,c),c+=i.byteLength;function u(d,p,f=!1){let g=2*d;if(Wn(g,r)){let m=Dr(d,n),y=1/0,v=1/0,_=1/0,b=-1/0,x=-1/0,w=-1/0;for(let S=m,A=m+Gr(g,r);S<A;S++){let E=3*t.resolveTriangleIndex(S);for(let P=0;P<3;P++){let T=E+P;T=o?o[T]:T;let R=l.getX(T),L=l.getY(T),D=l.getZ(T);R<y&&(y=R),R>b&&(b=R),L<v&&(v=L),L>x&&(x=L),D<_&&(_=D),D>w&&(w=D)}}return(s[d+0]!==y||s[d+1]!==v||s[d+2]!==_||s[d+3]!==b||s[d+4]!==x||s[d+5]!==w)&&(s[d+0]=y,s[d+1]=v,s[d+2]=_,s[d+3]=b,s[d+4]=x,s[d+5]=w,!0)}{let m=sr(d),y=ar(d,n),v=f,_=!1,b=!1;if(e){if(!v){let E=m/8+p/32,P=y/8+p/32;_=e.has(E),b=e.has(P),v=!_&&!b}}else _=!0,b=!0;let x=v||b,w=!1;(v||_)&&(w=u(m,p,v));let S=!1;x&&(S=u(y,p,v));let A=w||S;if(A)for(let E=0;E<3;E++){let P=m+E,T=y+E,R=s[P],L=s[P+3],D=s[T],U=s[T+3];s[d+E]=R<D?R:D,s[d+E+3]=L>U?L:U}return A}}}function ntt(t,e,i,n,r,s,a){Bi.setBuffer(t._roots[e]),GT(0,t,i,n,r,s,a),Bi.clearBuffer()}function GT(t,e,i,n,r,s,a){let{float32Array:o,uint16Array:l,uint32Array:c}=Bi,h=2*t;if(Wn(h,l))(function(u,d,p,f,g,m,y,v){let{geometry:_,_indirectBuffer:b}=u;for(let x=f,w=f+g;x<w;x++)xx(_,d,p,b?b[x]:x,m,y,v)})(e,i,n,Dr(t,c),Gr(h,l),r,s,a);else{let u=sr(t);vh(u,o,n,s,a)&&GT(u,e,i,n,r,s,a);let d=ar(t,c);vh(d,o,n,s,a)&&GT(d,e,i,n,r,s,a)}}var rtt=["x","y","z"];function stt(t,e,i,n,r,s){Bi.setBuffer(t._roots[e]);let a=HT(0,t,i,n,r,s);return Bi.clearBuffer(),a}function HT(t,e,i,n,r,s){let{float32Array:a,uint16Array:o,uint32Array:l}=Bi,c=2*t;if(Wn(c,o))return function(h,u,d,p,f,g,m){let{geometry:y,_indirectBuffer:v}=h,_=1/0,b=null;for(let x=p,w=p+f;x<w;x++){let S;S=xx(y,u,d,v?v[x]:x,null,g,m),S&&S.distance<_&&(b=S,_=S.distance)}return b}(e,i,n,Dr(t,l),Gr(c,o),r,s);{let h,u,d=V3(t,l),p=rtt[d],f=n.direction[p]>=0;f?(h=sr(t),u=ar(t,l)):(h=ar(t,l),u=sr(t));let g=vh(h,a,n,r,s)?HT(h,e,i,n,r,s):null;if(g){let y=g.point[p];if(f?y<=a[u+d]:y>=a[u+d+3])return g}let m=vh(u,a,n,r,s)?HT(u,e,i,n,r,s):null;return g&&m?g.distance<=m.distance?g:m:g||m||null}}et();var wy=new ci,su=new fa,au=new fa,rm=new At,IB=new Vr,Sy=new Vr;function att(t,e,i,n){Bi.setBuffer(t._roots[e]);let r=WT(0,t,i,n);return Bi.clearBuffer(),r}function WT(t,e,i,n,r=null){let{float32Array:s,uint16Array:a,uint32Array:o}=Bi,l=2*t;if(r===null&&(i.boundingBox||i.computeBoundingBox(),IB.set(i.boundingBox.min,i.boundingBox.max,n),r=IB),!Wn(l,a)){let c=sr(t),h=ar(t,o);return Qi(c,s,wy),!!(r.intersectsBox(wy)&&WT(c,e,i,n,r)||(Qi(h,s,wy),r.intersectsBox(wy)&&WT(h,e,i,n,r)))}{let c=e.geometry,h=c.index,u=c.attributes.position,d=i.index,p=i.attributes.position,f=Dr(t,o),g=Gr(l,a);if(rm.copy(n).invert(),i.boundsTree)return Qi(t,s,Sy),Sy.matrix.copy(rm),Sy.needsUpdate=!0,i.boundsTree.shapecast({intersectsBounds:m=>Sy.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(n),m.b.applyMatrix4(n),m.c.applyMatrix4(n),m.needsUpdate=!0;for(let y=f,v=g+f;y<v;y++)if(Pn(au,3*e.resolveTriangleIndex(y),h,u),au.needsUpdate=!0,m.intersectsTriangle(au))return!0;return!1}});{let m=bx(i);for(let y=f,v=g+f;y<v;y++){let _=e.resolveTriangleIndex(y);Pn(su,3*_,h,u),su.a.applyMatrix4(rm),su.b.applyMatrix4(rm),su.c.applyMatrix4(rm),su.needsUpdate=!0;for(let b=0,x=3*m;b<x;b+=3)if(Pn(au,b,d,p),au.needsUpdate=!0,su.intersectsTriangle(au))return!0}}}}et();var My=new At,bM=new Vr,sm=new Vr,ott=new C,ltt=new C,htt=new C,ctt=new C;function dtt(t,e,i,n={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),bM.set(e.boundingBox.min,e.boundingBox.max,i),bM.needsUpdate=!0;let o=t.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,u=e.index,d=ks.getPrimitive(),p=ks.getPrimitive(),f=ott,g=ltt,m=null,y=null;r&&(m=htt,y=ctt);let v=1/0,_=null,b=null;return My.copy(i).invert(),sm.matrix.copy(My),t.shapecast({boundsTraverseOrder:x=>bM.distanceToBox(x),intersectsBounds:(x,w,S)=>S<v&&S<a&&(w&&(sm.min.copy(x.min),sm.max.copy(x.max),sm.needsUpdate=!0),!0),intersectsRange:(x,w)=>{if(e.boundsTree){let S=e.boundsTree;return S.shapecast({boundsTraverseOrder:A=>sm.distanceToBox(A),intersectsBounds:(A,E,P)=>P<v&&P<a,intersectsRange:(A,E)=>{for(let P=A,T=A+E;P<T;P++){let R=S.resolveTriangleIndex(P);Pn(p,3*R,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let L=x,D=x+w;L<D;L++){let U=t.resolveTriangleIndex(L);Pn(d,3*U,c,l),d.needsUpdate=!0;let V=d.distanceToTriangle(p,f,m);if(V<v&&(g.copy(f),y&&y.copy(m),v=V,_=L,b=P),V<s)return!0}}}})}for(let S=0,A=bx(e);S<A;S++){Pn(p,3*S,u,h),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let E=x,P=x+w;E<P;E++){let T=t.resolveTriangleIndex(E);Pn(d,3*T,c,l),d.needsUpdate=!0;let R=d.distanceToTriangle(p,f,m);if(R<v&&(g.copy(f),y&&y.copy(m),v=R,_=E,b=S),R<s)return!0}}}}),ks.releasePrimitive(d),ks.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(g):n.point=g.clone(),n.distance=v,n.faceIndex=_,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(My),g.applyMatrix4(My),r.distance=g.sub(r.point).length(),r.faceIndex=b),n)}function OB(t,e,i){return t===null?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(i.ray.origin),t.object=e,t)}var Ey=new Vr,Ay=new $o,LB=new C,BB=new At,UB=new C,xM=["getX","getY","getZ"],qT=class extends NJ{static serialize(t,e={}){e={cloneBuffers:!0,...e};let i=t.geometry,n=t._roots,r=t._indirectBuffer,s=i.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return e.cloneBuffers?(a.roots=n.map(o=>o.slice()),a.index=s?s.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=n,a.index=s?s.array:null,a.indirectBuffer=r),a}static deserialize(t,e,i={}){i={setIndex:!0,indirect:Boolean(t.indirectBuffer),...i};let{index:n,roots:r,indirectBuffer:s}=t;t.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),function(o){for(let l=0;l<o.length;l++){let c=o[l],h=new Uint32Array(c),u=new Uint16Array(c);for(let d=0,p=c.byteLength/32;d<p;d++){let f=8*d;Wn(2*f,u)||(h[f+6]=h[f+6]/8-d)}}}(r));let a=new qT(e,{...i,[k3]:!0});if(a._roots=r,a._indirectBuffer=s||null,i.setIndex){let o=e.getIndex();if(o===null){let l=new Ht(t.index,1,!1);e.setIndex(l)}else o.array!==n&&(o.array.set(n),o.needsUpdate=!0)}return a}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(t,e={}){e.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),e={...e,maxLeafSize:e.maxLeafTris}),super(t,e)}shiftTriangleOffsets(t){return super.shiftPrimitiveOffsets(t)}writePrimitiveBounds(t,e,i){let n=this.geometry,r=this._indirectBuffer,s=n.attributes.position,a=n.index?n.index.array:null,o=3*(r?r[t]:t),l=o+0,c=o+1,h=o+2;a&&(l=a[l],c=a[c],h=a[h]);for(let u=0;u<3;u++){let d=s[xM[u]](l),p=s[xM[u]](c),f=s[xM[u]](h),g=d;p<g&&(g=p),f<g&&(g=f);let m=d;p>m&&(m=p),f>m&&(m=f),e[i+u]=g,e[i+u+3]=m}return e}computePrimitiveBounds(t,e,i){let n=this.geometry,r=this._indirectBuffer,s=n.attributes.position,a=n.index?n.index.array:null,o=s.normalized;if(t<0||e+t-i.offset>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");let l=s.array,c=s.offset||0,h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);let u=["getX","getY","getZ"],d=i.offset;for(let p=t,f=t+e;p<f;p++){let g=3*(r?r[p]:p),m=6*(p-d),y=g+0,v=g+1,_=g+2;a&&(y=a[y],v=a[v],_=a[_]),o||(y=y*h+c,v=v*h+c,_=_*h+c);for(let b=0;b<3;b++){let x,w,S;o?(x=s[u[b]](y),w=s[u[b]](v),S=s[u[b]](_)):(x=l[y+b],w=l[v+b],S=l[_+b]);let A=x;w<A&&(A=w),S<A&&(A=S);let E=x;w>E&&(E=w),S>E&&(E=S);let P=(E-A)/2,T=2*b;i[m+T+0]=A+P,i[m+T+1]=P+(Math.abs(A)+P)*D1}}return i}raycastObject3D(t,e,i=[]){let{material:n}=t;if(n===void 0)return;BB.copy(t.matrixWorld).invert(),Ay.copy(e.ray).applyMatrix4(BB),UB.setFromMatrixScale(t.matrixWorld),LB.copy(Ay.direction).multiply(UB);let r=LB.length(),s=e.near/r,a=e.far/r;if(e.firstHitOnly===!0){let o=this.raycastFirst(Ay,n,s,a);o=OB(o,t,e),o&&i.push(o)}else{let o=this.raycast(Ay,n,s,a);for(let l=0,c=o.length;l<c;l++){let h=OB(o[l],t,e);h&&i.push(h)}}return i}refit(t=null){return(this.indirect?itt:WJ)(this,t)}raycast(t,e=Vs,i=0,n=1/0){let r=this._roots,s=[],a=this.indirect?ntt:XJ;for(let o=0,l=r.length;o<l;o++)a(this,o,e,t,s,i,n);return s}raycastFirst(t,e=Vs,i=0,n=1/0){let r=this._roots,s=null,a=this.indirect?stt:YJ;for(let o=0,l=r.length;o<l;o++){let c=a(this,o,e,t,i,n);c!=null&&(s==null||c.distance<s.distance)&&(s=c)}return s}intersectsGeometry(t,e){let i=!1,n=this._roots,r=this.indirect?att:ZJ;for(let s=0,a=n.length;s<a&&(i=r(this,s,t,e),!i);s++);return i}shapecast(t){let e=ks.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?qJ:HJ});return ks.releasePrimitive(e),i}bvhcast(t,e,i){let{intersectsRanges:n,intersectsTriangles:r}=i,s=ks.getPrimitive(),a=this.geometry.index,o=this.geometry.attributes.position,l=this.indirect?p=>{let f=this.resolveTriangleIndex(p);Pn(s,3*f,a,o)}:p=>{Pn(s,3*p,a,o)},c=ks.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,d=t.indirect?p=>{let f=t.resolveTriangleIndex(p);Pn(c,3*f,h,u)}:p=>{Pn(c,3*p,h,u)};if(r){if(!(t instanceof qT))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');let p=(f,g,m,y,v,_,b,x)=>{for(let w=m,S=m+y;w<S;w++){d(w),c.a.applyMatrix4(e),c.b.applyMatrix4(e),c.c.applyMatrix4(e),c.needsUpdate=!0;for(let A=f,E=f+g;A<E;A++)if(l(A),s.needsUpdate=!0,r(s,c,A,w,v,_,b,x))return!0}return!1};if(n){let f=n;n=function(g,m,y,v,_,b,x,w){return!!f(g,m,y,v,_,b,x,w)||p(g,m,y,v,_,b,x,w)}}else n=p}return super.bvhcast(t,e,{intersectsRanges:n})}intersectsBox(t,e){return Ey.set(t.min,t.max,e),Ey.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Ey.intersectsBox(i),intersectsTriangle:i=>Ey.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},n={},r=0,s=1/0){return(this.indirect?dtt:ett)(this,t,e,i,n,r,s)}closestPointToPoint(t,e={},i=0,n=1/0){return function(r,s,a={},o=0,l=1/0){let c=o*o,h=l*l,u=1/0,d=null;if(r.shapecast({boundsTraverseOrder:f=>(tm.copy(s).clamp(f.min,f.max),tm.distanceToSquared(s)),intersectsBounds:(f,g,m)=>m<u&&m<h,intersectsTriangle:(f,g)=>{f.closestPointToPoint(s,tm);let m=s.distanceToSquared(tm);return m<u&&(yM.copy(tm),u=m,d=g),m<c}}),u===1/0)return null;let p=Math.sqrt(u);return a.point?a.point.copy(yM):a.point=yM.clone(),a.distance=p,a.faceIndex=d,a}(this,t,e,i,n)}};ke(),JV=qT,Si("collision-bvh"),Li(),ii(),ol();var utt=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.entered=!1,this.actions=Rn(e,e.actions,n,r,s,i)}disconnect(){rr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatchStart()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()),this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},ptt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{ae.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{ae.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{ae.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:n,reverse:r})=>{if(!i||!n)return;let s=i0(i);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(a=>a.dispatchUserEvent(r)))}}connect(){let{page:t,sharedAssets:e}=this.eventContext,i=(r,s)=>{if(r.visible&&r.data?.events.length){for(let{id:a,data:o}of r.data.events)if(!o.disabled&&o.type==="MouseHover")try{let l=new utt(a,o,r,t,e,this.eventManager);this.eventsPerObjects[r.uuid]?this.eventsPerObjects[r.uuid].push(l):this.eventsPerObjects[r.uuid]=[l]}catch{}this.eventsPerObjects[r.uuid]?.length&&this.objects.push(as(r)?s:r)}};if(t.traverseEntity(r=>{(Cr(r)||r instanceof un)&&r.frame?.traverse(s=>{i(s,r)}),i(r)}),!this.objects.length)return;let{domElement:n}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),n.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),n.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),ss&&(t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp)),t.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(e=>{e.forEach(i=>{i.disconnect()})}),this.objects.forEach(e=>{e.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(t=!1){let e=[];if(!t){let{stopRaycast:i,raycaster:n,page:r,pointerScreen:s}=this.eventContext,a=!1;if(r.uiCanvas&&(a=ko(r,[s.x,s.y],Object.keys(this.eventsPerObjects),o=>{e.push(o)})),i&&!a){let o=A1(n,r,this.objects);e=MT(o),o.forEach(l=>{Cr(l.object)&&ko(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),c=>{e.push(c)})})}else this.objects.forEach(o=>{let l=gb(n,o);l&&(e.push(o),Cr(o)&&ko(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),c=>{e.push(c)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{e.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(n=>n.dispatchLeave()))}),e.length&&e.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(n=>n.dispatchEnter())}),this._prevObjects=e}};ke(),xs("MouseHover",({eventContext:t,eventManager:e})=>new ptt(t,e)),Si("mousehover"),Li(),ol();var ftt=class{constructor(){this.elapsed=0,this.lastRealTimeMs=null,this.paused=!1}get time(){return this.elapsed}tick(t){let e=0;return this.lastRealTimeMs!==null&&(e=Math.min((t-this.lastRealTimeMs)/1e3,.25),e<0&&(e=0)),this.lastRealTimeMs=t,this.paused||(this.elapsed+=e),this.elapsed}step(t){return this.paused||(this.elapsed+=t),this.elapsed}resync(t){this.lastRealTimeMs=t}seek(t){this.elapsed=t}reset(){this.elapsed=0,this.lastRealTimeMs=null,this.paused=!1}},ye=Math.fround,mtt=[.01,100],gtt=[.01,1e4],vtt=[.01,1e3],ytt=[.01,1e3];function Ty(t,[e,i]){return Math.min(Math.max(t,e),i)}function hj(t,e,i,n,r){t=Ty(t,mtt),e=Ty(e,gtt),i=Ty(i,vtt),n=Ty(n,ytt);let s=Math.sqrt(e/t),a=i/(2*Math.sqrt(e*t)),o=a<1?s*Math.sqrt(1-a*a):0,l=a<1?(a*s-n)/o:-n+s;return c=>{let h=r!==void 0?r*c:c;return h=a<1?Math.exp(-h*a*s)*(1*Math.cos(o*h)+l*Math.sin(o*h)):(1+l*h)*Math.exp(-h*s),c===0||c===1?c:1-h}}var _tt=ye(.001),btt=ye(1e-7),Cy=ye(.1);function cj(t,e){return ye(ye(1-ye(3*e))+ye(3*t))}function dj(t,e){return ye(ye(3*e)-ye(6*t))}function uj(t){return ye(3*t)}function Py(t,e,i){return ye(ye(ye(ye(ye(cj(e,i)*t)+dj(e,i))*t)+uj(e))*t)}function zB(t,e,i){let n=ye(ye(ye(3*cj(e,i))*t)*t),r=ye(ye(2*dj(e,i))*t);return ye(ye(n+r)+uj(e))}var xtt=t=>t;function ou(t,e,i,n){if(t=ye(t),e=ye(e),i=ye(i),n=ye(n),t<0||t>1||i<0||i>1||t===e&&i===n)return xtt;let r=new Float32Array(11);for(let s=0;s<11;s++)r[s]=Py(ye(s*Cy),t,i);return s=>(s=ye(s))===0||s===1?s:Py((a=>{let o=0,l=1;for(;l!==10&&r[l]<=a;)o=ye(o+Cy),l+=1;l-=1;let c=ye(ye(a-r[l])/ye(r[l+1]-r[l])),h=ye(o+ye(c*Cy)),u=zB(h,t,i);return u>=_tt?function(d,p,f,g){for(let m=0;m<4;m++){let y=zB(p,f,g);if(y===0)return p;let v=ye(Py(p,f,g)-d);p=ye(p-ye(v/y))}return p}(a,h,t,i):u===0?h:function(d,p,f,g,m){let y,v=0,_=0;do v=ye(p+ye(ye(f-p)/2)),y=ye(Py(v,g,m)-d),y>0?f=v:p=v,_+=1;while(Math.abs(y)>btt&&_<10);return v}(a,o,ye(o+Cy),t,i)})(s),e,n)}var wtt=ye(1.70158);function pj(t,e,i){switch(t.easing){case 0:default:return i;case 1:return ou(.25,.1,.25,1)(i);case 2:return ou(.42,0,1,1)(i);case 3:return ou(0,0,.58,1)(i);case 4:return ou(.42,0,.58,1)(i);case 7:return ou(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:n,control2:r}=t;return n&&r?ou(n[0],n[1],r[0],r[1])(i):i}case 6:{let{mass:n,stiffness:r,damping:s,velocity:a}=t;return n===void 0||r===void 0||s===void 0||a===void 0?i:ye(hj(n,r,s,a,e)(i))}}}ye(wtt+1);var pr=Math.fround;function wM(t){return t==="pingpong"||t==="pingpong-rewind"}var Stt=class{constructor(t){this.config=t,this.effectiveCycleDuration=this.cycleDuration(0)}layout(t){let{config:e}=this;if(wM(e.direction)&&t%2==1)return{startDelay:0,endDelay:0};switch(e.delayDirection){case"start-once":return t===0?{startDelay:e.delay,endDelay:0}:{startDelay:0,endDelay:0};case"start":return{startDelay:e.delay,endDelay:0};case"end":return{startDelay:0,endDelay:e.delay};default:return{startDelay:e.delay,endDelay:e.delay}}}cycleDuration(t){let{config:e}=this,{startDelay:i,endDelay:n}=this.layout(t);return pr(e.duration+i+n)}get totalDuration(){let{config:t}=this;if(t.repeat===-1)return 1/0;let e=0;for(let i=0;i<=t.repeat;i++)e=pr(e+this.cycleDuration(i));return e}isFinished(t){return t>=this.totalDuration}resolve(t){let e,i,{config:n}=this,r=pr(t);if(n.delayDirection==="start-once"){let h=pr(n.delay+n.duration);if(r<h)e=0,i=r;else{let u=pr(r-h);e=1+Math.floor(pr(u/n.duration)),i=pr(u%n.duration)}}else if(wM(n.direction)){let h=this.cycleDuration(0),u=pr(h+n.duration),d=Math.floor(pr(r/u)),p=pr(r%u);p<h?(e=2*d,i=p):(e=2*d+1,i=pr(p-h))}else{let h=this.cycleDuration(0);e=Math.floor(pr(r/h)),i=pr(r%h)}if(n.repeat!==-1&&e>=n.repeat+1)return null;let s,{startDelay:a}=this.layout(e),o=wM(n.direction)&&e%2==1,l=a,c=pr(l+n.duration);if(i<l)s=o?n.duration:0;else if(i>=c)s=o?0:n.duration;else{let h=pr(i-l);s=o?pr(n.duration-h):h}return{cycleIndex:e,localTime:s,isReverse:o}}},SM=Math.fround;function Mtt(t){return[...t].sort((e,i)=>e.time-i.time)}var am=Math.fround;function Fc(t){return Math.round(1e9*t)}function Tb(t,e){return(Fc(t)+Fc(e))/1e9}function MM(t,e,i){return Fc(t)-Fc(e)<Fc(i)}var Ett=Math.fround;function FB(t){return t==="pingpong"||t==="pingpong-rewind"}function NB(t,e){return e?t==="start"?"end":t==="end"?"start":t:t}var fj=class{constructor(t,e,i={}){this.hooks=i,this.isPlaying=!1,this.playingIndex=0,this.seekIndex=-1,this.currentRepeat=0,this.isReversed=!1,this.startTime=0,this.isToggledForward=!1,this.hasPlayedOnce=!1,this.isFirstTweenAfterStart=!1,this.hasClaimed=!1,this.isUnwinding=!1,this.config=t,this.tweens=e,this.delay=Ett(t.delay/1e3)}get currentTween(){return this.tweens[this.playingIndex]}play(t){if(this.tweens.length===0||this.isPlaying&&this.config.runMode!=="Toggle"||this.hasPlayedOnce&&this.config.runMode==="Once")return;let e=this.isPlaying;this.isPlaying=!0,this.hasPlayedOnce=!0,this.isUnwinding=!1,this.currentRepeat=this.passRepeat,this.startTime=t,this.seekIndex=-1,this.hooks.isOwner?.()===!1&&(this.isToggledForward=!1,!e&&!this.isReversed&&this.hooks.assignCurrentState?.()),this.hasClaimed=!1,this.config.runMode==="Toggle"?(this.toggleDirection(),e?this.openPass():this.startChain()):this.startChain()}stop(){this.currentTween?.stop(),this.isPlaying=!1,this.isReversed=!1,this.hasClaimed=!1,this.isUnwinding=!1}unwindFromHere(){this.isUnwinding=!0,this.currentRepeat=0,this.currentTween?.endAfterCurrentPass()}get passRepeat(){return this.isUnwinding?0:this.config.repeat}playDirected(t,e){if(this.tweens.length===0)return;let i=this.isPlaying;i&&this.isForward===e?e||this.unwindFromHere():(this.isPlaying=!0,this.hasPlayedOnce=!0,this.isUnwinding=!e,this.currentRepeat=this.passRepeat,this.startTime=t,this.seekIndex=-1,this.isToggledForward=e,this.isReversed=!e,this.hooks.isOwner?.()===!1&&!i&&!this.isReversed&&this.hooks.assignCurrentState?.(),this.hasClaimed=!1,i?this.openPass():this.startChain())}get isAnimating(){return this.isPlaying&&this.hasClaimed}get isForward(){return!this.isReversed}seek(t){if(this.tweens.length===0)return;this.hooks.claim?.();let e=this.tweens.reduce((s,a)=>s+a.duration,0)*t,i=this.tweens.length-1,n=1,r=0;for(let s=0;s<this.tweens.length;s++){let a=this.tweens[s];if(r+a.duration>e){i=s,n=(e-r)/a.duration;break}r+=a.duration}for(this.seekIndex===-1&&(this.seekIndex=0);this.seekIndex<i;)this.tweens[this.seekIndex].seek(1),this.seekIndex+=1,this.tweens[this.seekIndex].rearm();for(;this.seekIndex>i;)this.tweens[this.seekIndex].seek(0),this.seekIndex-=1;this.tweens[i].seek(n)}update(t){if(!this.isPlaying)return;if(this.claimWhenDue(t)&&this.currentTween.rearm(),this.hasClaimed&&this.hooks.isOwner?.()===!1)return void this.stop();let e=NB(this.config.delayDirection,this.isReversed);if(MM(t,this.startTime,this.leadingDelay)||(this.currentTween.update(t),!this.isPlaying)||this.currentTween.isPlaying)return;if(this.isFirstTweenAfterStart=!1,this.isReversed?this.playingIndex>0:this.playingIndex<this.tweens.length-1)return void this.advanceToNextTween();let i=0;if(e==="end"||e==="start-end"){if(MM(t,this.currentTween.endTime,this.delay))return;i=this.delay}this.currentRepeat!==0?(this.currentRepeat>0&&(this.currentRepeat-=1),FB(this.config.direction)&&(this.config.runMode==="Toggle"?this.toggleDirection():this.isReversed=!this.isReversed),this.startTime=Tb(this.currentTween.endTime,i),this.playingIndex=this.isReversed?this.tweens.length-1:0,this.config.direction==="normal"&&this.currentTween.seek(this.currentTween.isReversed?1:0),this.openPass()):this.stop()}advanceToNextTween(){let t=this.currentTween;t.isPingpong&&t.config.repeat%2==1&&t.seek(t.isReversed?0:1);let e=t.endTime,i=this.isReversed;this.playingIndex+=i?-1:1;let n=this.currentTween;i&&n.isPingpong&&n.config.repeat%2==1&&n.seek(1),this.resume(e)}startChain(){this.playingIndex=this.isReversed?this.tweens.length-1:0,this.isFirstTweenAfterStart=!0,this.openPass()}openPass(){this.claimWhenDue(this.startTime);let t=this.tweens[0];this.hasClaimed&&!this.isReversed&&t&&t.duration===0&&(t.seek(1),!this.isPlaying)||this.resume(Tb(this.startTime,this.leadingDelay))}claimWhenDue(t){return!this.hasClaimed&&!MM(t,this.startTime,this.leadingDelay)&&(this.hasClaimed=!0,this.hooks.claim?.(),!0)}get leadingDelay(){let t=NB(this.config.delayDirection,this.isReversed);return t==="start-once"?this.isFirstTweenAfterStart?this.delay:0:t!=="start"&&t!=="start-end"||this.isReversed||this.playingIndex!==0||FB(this.config.direction)&&!this.isFirstTweenAfterStart?0:this.delay}resume(t){let e=this.currentTween;this.isReversed&&this.config.direction==="pingpong-rewind"&&(e.overrideDirection="pingpong-rewind"),e.isReversed=!(!this.isReversed||e.repeatDirection!=="normal"&&e.config.repeat%2==1),e.start(t),this.isUnwinding&&e.endAfterCurrentPass()}toggleDirection(){this.isToggledForward=!this.isToggledForward,this.isReversed=!this.isToggledForward}},Na=Math.fround,mj=class{constructor(t,e,i){this.apply=e,this.onStart=i,this.isPlaying=!1,this.isReversed=!1,this.endTime=0,this.startTime=0,this.isFirstLerpAfterStart=!1,this.config=t,this.duration=function(n,r){if(n.easing!==6)return r;let{mass:s,stiffness:a,damping:o,velocity:l}=n;return s===void 0||a===void 0||o===void 0||l===void 0?r:function(c,h,u,d){let p=.16666666666666666,f=0,g=0,m=hj(c,h,u,d);for(let y=0;y<1e5;y++)if(f+=p,m(f)===1){if(g+=1,g>=16)break}else g=0;return ye(f*p)}(s,a,o,l)}(t.ease,Na(t.duration/1e3)),this.delay=Na(t.delay/1e3),this.currentRepeat=t.repeat}get repeatDirection(){return this.overrideDirection??this.config.direction}get isPingpong(){let t=this.repeatDirection;return t==="pingpong"||t==="pingpong-rewind"}get actualDelayDirection(){return this.isReversed?this.config.delayDirection==="start"?"end":this.config.delayDirection==="end"?"start":this.config.delayDirection:this.config.delayDirection}start(t){this.isPlaying=!0,this.currentRepeat=this.config.repeat,this.isFirstLerpAfterStart=!0,this.startTime=t,this.onStart?.()}endAfterCurrentPass(){this.currentRepeat<0&&(this.currentRepeat=0)}stop(){this.isPlaying=!1}rearm(){this.onStart?.()}seek(t){this.lerp(t)}update(t){if(!this.isPlaying)return;let e=function(s,a){return function(o){let l=Math.trunc(o/1e9),c=o-1e9*l;return am(am(l)+am(am(c)/am(1e9)))}(Fc(s)-Fc(a))}(t,this.startTime),i=0;if(this.isFirstLerpAfterStart||!this.isPingpong){let s=this.actualDelayDirection;if(this.config.delayDirection==="start-once"&&this.isFirstLerpAfterStart||s==="start"||s==="start-end"){if(e<this.delay)return;i=this.delay}}e=Na(e-i);let n=this.duration===0?1:Math.min(Math.max(Na(e/this.duration),0),1);if(this.lerp(n),!this.isPlaying||n!==1)return;let r=this.actualDelayDirection;if(r==="end"||r==="start-end"){if(e<Na(this.duration+this.delay))return;this.endTime=Tb(this.startTime,Na(Na(i+this.duration)+this.delay))}else this.endTime=Tb(this.startTime,Na(i+this.duration));this.isFirstLerpAfterStart=!1,this.currentRepeat!==0?(this.currentRepeat>0&&(this.currentRepeat-=1),this.isPingpong?this.isReversed=!this.isReversed:this.lerp(0),this.startTime=t,this.onStart?.()):this.stop()}lerp(t){this.repeatDirection==="pingpong-rewind"&&this.isReversed?(t=Na(1-t),t=this.ease(t),t=Na(1-t)):t=this.ease(t),this.apply(t)}ease(t){return pj(this.config.ease,this.duration,t)}};function Dy(){return typeof performance<"u"?performance.now():Date.now()}var Ji=new class{constructor(){this.clock=new ftt,this.tickables=new Set,this.pendingRemovals=new Set,this.rafId=null,this.isFlushing=!1,this.useInternalRaf=!0,this.step=t=>{this.rafId=null,this.clock.tick(t),this.flush(),this.tickables.size>0&&this.requestFrame()}}get isUsingInternalRaf(){return this.useInternalRaf}set isUsingInternalRaf(t){this.useInternalRaf=t,t?(this.clock.resync(Dy()),this.requestFrame()):this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}get time(){return this.clock.time}get running(){return this.tickables.size>0}add(t){this.pendingRemovals.delete(t),this.tickables.size===0&&this.rafId===null&&this.clock.resync(Dy()),this.tickables.add(t),this.requestFrame()}remove(t){this.isFlushing?this.pendingRemovals.add(t):this.tickables.delete(t)}init(){this.clock.resync(Dy())}dispose(){this.removeAll(),this.clock.reset()}removeAll(){this.tickables.clear(),this.pendingRemovals.clear(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}update(t){this.clock.step(t/1e3),this.flush()}pause(){this.clock.paused=!0}resume(){this.clock.paused=!1,this.clock.resync(Dy()),this.requestFrame()}requestFrame(){this.rafId!==null||!this.useInternalRaf||this.tickables.size!==0&&(typeof requestAnimationFrame>"u"||(this.rafId=requestAnimationFrame(this.step)))}flush(){let t=this.clock.time;this.isFlushing=!0;try{for(let e of this.tickables)this.pendingRemovals.has(e)||e.update(t)}finally{this.isFlushing=!1;for(let e of this.pendingRemovals)this.tickables.delete(e);this.pendingRemovals.clear()}}},Att=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.scrollCounter=0,this.actions=Rn(e,e.actions,n,r,s,i)}connect(){this.scrollCounter=0}disconnect(){rr(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(i)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.TimelineAnimation.forEach(n=>n.seek(i)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch()),this.actions.ClearLocalStorage.forEach(n=>n.dispatch()),this.actions.UserAPI.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},Ttt=class{constructor(t,e,i,n,r,s,a){this.id=t,this.data=e,this.object=i,this.domElement=s,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.deferred=new Set,this.settleDriver={update:()=>this.settleDeferred()},this.actions=Rn(e,e.actions,n,r,a,i)}getStickyParentElement(){let t=this.domElement;for(;t;){if(window.getComputedStyle(t).position==="sticky")return t;t=t.parentElement}return null}computeScrollBounds(){let t=this.getStickyParentElement(),e=t?.parentElement,i=this.domElement.getBoundingClientRect(),n={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(e){let c=e.getBoundingClientRect(),h=window.getComputedStyle(t),u=parseFloat(h.marginTop)+parseFloat(h.marginBottom),d=parseFloat(h.top),p=parseFloat(h.bottom),f=c.height-u;if(isNaN(d)){if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,m=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===g-p?(n.top+=c.top-i.height+p+m,n.bottom+=c.top-i.height+p+m):i.bottom<g-p&&(n.top-=f-i.height,n.bottom-=f-i.height)}}else i.top===d?(n.top+=c.top-d,n.bottom+=c.top-d):i.top<0&&(n.top-=f-i.height,n.bottom-=f-i.height)}let r=document.body,s=document.documentElement,a=window.pageYOffset||s.scrollTop||r.scrollTop,o=s.clientTop||r.clientTop||0,l=Math.round(n.top+a-o);if(this.data.startFrom==="enter"){let c=window.innerHeight,h=n.height,u=this.data.enterAnchor,d=u==="top"?c:u==="bottom"?c-h:c-.5*h;this.scrollStart=l-d}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=n}connect(){this.computeScrollBounds(),this.settle()}disconnect(){Ji.remove(this.settleDriver),this.deferred.clear(),rr(this.actions)}handleResize(){this.computeScrollBounds(),this.settle()}settle(){this.computeScroll({x:window.scrollX,y:window.scrollY},{settle:!0})}settleDeferred(){let t=[...this.deferred].filter(e=>!e.contested);t.length&&(t.forEach(e=>this.deferred.delete(e)),this.seekTransitions(t,this.scaleAt(window.scrollY))),this.deferred.size===0&&Ji.remove(this.settleDriver)}scaleAt(t){let e=this.scrollEnd-this.scrollStart;return Math.min(1,Math.max(0,(t-this.scrollStart)/e))}seekTransitions(t,e){t.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())}),t.forEach(i=>i.seek(e))}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:t,y:e},{settle:i=!1}={}){let n=this.actions.Transition;i?(n=n.filter(s=>!s.contested||(this.deferred.add(s),!1)),this.deferred.size&&Ji.add(this.settleDriver)):(this.deferred.clear(),Ji.remove(this.settleDriver));let r=this.scaleAt(e);this.seekTransitions(n,r),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.TimelineAnimation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()}),this.actions.TimelineAnimation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},Ctt=class extends Or{constructor(t,e){super(t),this.managers=e,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,n])=>{n.forEach(r=>r.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(a=>a.dispatch(n))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),r.forEach(s=>s.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:n,reverse:r})=>{if(!i||!n)return;let s=i0(i);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(a=>{a.dispatchUserEvent(r)}))}}connect(){let{page:t,sharedAssets:e,domElement:i,isExport:n}=this.eventContext,r=s=>{if(s.data?.events.length){for(let{id:a,data:o}of s.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger!=="load"&&n){let l=new Ttt(a,o,s,t,e,i,this.managers);this.scrollEventsPerObject.has(s)?this.scrollEventsPerObject.get(s)?.push(l):this.scrollEventsPerObject.set(s,[l])}else{let l=new Att(a,o,s,t,e,this.managers);this.wheelEventsPerObject.has(s)?this.wheelEventsPerObject.get(s)?.push(l):this.wheelEventsPerObject.set(s,[l])}}};t.traverseEntity(s=>{(Cr(s)||s instanceof un)&&s.frame?.traverse(a=>{r(a)}),r(s)}),this.intersectionObserver=new IntersectionObserver(s=>{let a=s[0];a&&(this.isInview=a.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([s,a])=>{a.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([s,a])=>{a.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(i=>i.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(i=>i.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)})}};ke(),xs("Scroll",({eventContext:t,eventManager:e})=>new Ctt(t,e)),Si("scroll"),et(),xh(),Wr(),ii(),Kn(),tx();var om=new C,Il=new C,hc=new C,kB=new kr,oi=new C,Fn=new C,VB=new C,ih=new qt,Ptt=new At,EM=new ue,lu=new C,ka=new C,hu=.2;function AM(t,e){!e||(e[0]<e[1]&&(t.x=Math.min(Math.max(t.x,e[0]),e[1])),e[2]<e[3]&&(t.y=Math.min(Math.max(t.y,e[2]),e[3])),e[4]<e[5]&&(t.z=Math.min(Math.max(t.z,e[4]),e[5])))}var Dtt=function(){let t=new At;return(e,i,n)=>{let r=e.obj;t.copy(r.hiddenMatrix),r.parent!==null&&t.premultiply(r.parent.matrixWorld),t.invert(),r.position.copy(i),e.reference==="global"&&AM(r.position,e.limits),r.position.applyMatrix4(t),e.reference==="parent"?AM(r.position,e.limits):e.reference==="local"&&(ih.copy(e.quat0).invert(),r.position.sub(e.position0),r.position.applyQuaternion(ih),AM(r.position,e.limits),ih.invert(),r.position.applyQuaternion(ih),r.position.add(e.position0)),t.multiply(n??r.matrixWorld).decompose(oi,r.quaternion,Fn),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid()),r instanceof Xi&&to(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),Rtt=class{constructor(t,e,i,n,r,s,a){this.object=t,this.id=e,this.data=i,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Rn(i,i.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=Rn(i,i.dragDropActions.drop,n,r,s,this.object);let o=[];this.data.objects.forEach(l=>{let c=n.find(l);!c||c.data.visible!==!1&&(o.push(c),a[c.uuid]&&a[c.uuid].forEach(h=>{let u=n.find(h);!u||u.data.visible!==!1&&o.push(u)}))}),this.data.dropDestinations.forEach(l=>{let c=n.find(l);!c||c.data.visible!==!1&&(this.dropDestIds.push(c.uuid),a[c.uuid]&&a[c.uuid].forEach(h=>{let u=n.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new C().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new C().setFromMatrixPosition(l.matrixWorld),pointStart:new C,pointEnd:new C,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new C().copy(l.position),quat0:new qt().copy(l.quaternion),snapped:!1,orientationMatrix:new At,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){rr(this.actionsDrag),rr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Itt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.lastCursorRaycastTime=0,this.trailingCursorTimer=null,this.trailingCursorEvent=null,this.onPointerDown=i=>{if(ae.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(this.lastDropDestination=null,s.length!==0){for(let a of this.events){let o=0;for(let{obj:l,pointEnd:c,pointStart:h}of a.dragItems){if(l===s[0].object||l===s[0].object.object||Be.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(a.activeIdx=o,a.activeDragItem.reset=!1,a.activeDragItem.currentDampingFactor=a.data.dampingFactor,a.activeDragItem.snapped=!1,a.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){a.activeDragItem.obj.rigidBody&&(a.activeDragItem.obj.rigidBody.setBodyType(2,!0),this.eventManager.controlsManager.sharedGameControlGlobals.kinematicBodyToEntity.set(a.activeDragItem.obj.rigidBody.handle,a.activeDragItem.obj));let u=a.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldRigid(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(oi,ih,Fn),u.prevQ===void 0?(u.prevQ=ih.clone(),u.prevT=oi.clone()):(u.prevQ.copy(ih),u.prevT.copy(oi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(a.activeDragItem.obj)}return this.calcPlaneIntersectPos(l,h,a.data.plane,a.data.referenceFrame),c.copy(h),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||a.data.drop===!1||a.data.resetOnSnapFail===!1)&&a.activeDragItem.fromPosition.setFromMatrixPosition(a.activeDragItem.obj.matrixWorld),this.activeEvent=a,void(this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1))}o++}}this.activeEvent=null}else this.activeEvent=null},this.runTrailingCursorUpdate=()=>{this.trailingCursorTimer=null;let i=this.trailingCursorEvent;this.trailingCursorEvent=null,i!==null&&ae.length===0&&(this.eventContext.updateRaycaster(i),this.lastCursorRaycastTime=performance.now(),this.updateCursorFromRaycast())},this.onPointerMove=i=>{if(ae.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:n,page:r}=this.eventContext;if(ae.length===0){if(!this.events.some(a=>a.data.cursor==="hand"||a.data.cursor==="move"))return;let s=performance.now();return s-this.lastCursorRaycastTime<16?(this.trailingCursorEvent=i,void(this.trailingCursorTimer===null&&(this.trailingCursorTimer=window.setTimeout(this.runTrailingCursorUpdate,32)))):(this.trailingCursorEvent=null,this.lastCursorRaycastTime=s,void this.updateCursorFromRaycast())}if(this.activeEvent&&this.activeEvent.activeDragItem){let s,a=this.activeEvent.activeDragItem;if(a.snapped=!1,this.activeEvent.data.drop&&(s=r.raycastWithClones(n).filter(o=>a.obj!==o.object&&!a.obj.isAncestorOf(o.object.uuid)&&!(o.object instanceof $a)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(l=>l===o.object.uuid||r.scene.find(l).isAncestorOf(o.object.uuid))))[0]),s){let o=VB.copy(s.face.normal).applyMatrix3(EM.getNormalMatrix(s.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")a.fromPosition.setFromMatrixPosition(s.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(a.fromPosition.copy(s.point),this.activeEvent.data.snapSurfaceMode==="bbox"){oi.copy(o).applyMatrix3(EM.setFromMatrix4(a.obj.matrixWorld).transpose());let l=a.obj;oi.x>hu?Fn.x=-l.recursiveBBox.min.x:oi.x<-hu&&(Fn.x=-l.recursiveBBox.max.x),oi.y>hu?Fn.y=-l.recursiveBBox.min.y:oi.y<-hu&&(Fn.y=-l.recursiveBBox.max.y),oi.z>hu?Fn.z=-l.recursiveBBox.min.z:oi.z<-hu&&(Fn.z=-l.recursiveBBox.max.z),Fn.applyMatrix3(EM.invert())}else Fn.copy(o).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);a.fromPosition.add(Fn)}this.activeEvent.data.autoOrient&&(oi.set(0,1,0).cross(o),oi.length()<1e-4&&oi.set(-1,0,0).cross(o),Fn.crossVectors(VB,oi),a.orientationMatrix.makeBasis(oi,Fn,o)),a.pointStart.copy(a.fromPosition),a.pointEnd.copy(a.pointStart),a.currentDampingFactor=this.activeEvent.snapDampingFactor,a.snapped=!0,this.lastDropDestination!==s.object&&(this.lastDropDestination=s.object,this.activeEvent.actionsDrop.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(l=>{l.dispatchThrottled()}))}else a.orientationMatrix.makeRotationFromQuaternion(a.quat0),this.lastDropDestination=null,a.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(a.obj,a.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(o=>{o.stop(),o.object.currentState!==null&&o.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(o=>{o.stop()}),this.activeEvent.actionsDrop.Audio.forEach(o=>{o.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(o=>{o.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(o=>{o.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(o=>o.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(o=>o.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(o=>o.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(o=>o.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(o=>o.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(o=>{o.play()}),this.activeEvent.actionsDrag.Animation.forEach(o=>{o.play()}),this.activeEvent.actionsDrag.Audio.forEach(o=>{o.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(o=>{o.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(o=>{o.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(o=>{o.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(o=>{o.stop(),o.object.currentState!==null&&o.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(o=>{o.stop()}))},500),this.updateDragItem(a),a.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.eventManager.controlsManager.sharedGameControlGlobals.kinematicBodyToEntity.delete(this.activeEvent.activeDragItem.obj.rigidBody.handle),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(r=>r.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let t={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(t[i.component.uuid]?t[i.component.uuid].push(i.uuid):t[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(n=>n.data.type==="DragDrop"&&!n.data.disabled).forEach(n=>{this.events.push(new Rtt(i,n.id,n.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,t))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let t=this.eventContext.domElement;t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),this.trailingCursorTimer!==null&&(clearTimeout(this.trailingCursorTimer),this.trailingCursorTimer=null),this.trailingCursorEvent=null,this.events.forEach(e=>e.dispose())}setCursor(t){this.eventContext.domElement.style.cursor=t}onAnimationFrameDamping(){for(let t of this.events)for(let e of t.dragItems)e.paused||this.updateDragItem(e,!0)}calcPlaneIntersectPos(t,e,i,n){let{getCamera:r,raycaster:s}=this.eventContext;r().getWorldDirection(Il),Il.negate();let a=ih.identity();switch(n==="parent"?Ptt.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix).decompose(oi,a,Fn):n==="local"&&t.matrixWorld.decompose(oi,a,Fn),i){case"x":oi.set(1,0,0).applyQuaternion(a),lu.copy(Il).cross(oi),ka.copy(oi).cross(lu);break;case"y":oi.set(0,1,0).applyQuaternion(a),lu.copy(Il).cross(oi),ka.copy(oi).cross(lu);break;case"z":oi.set(0,0,1).applyQuaternion(a),lu.copy(Il).cross(oi),ka.copy(oi).cross(lu);break;case"xy":ka.set(0,0,1).applyQuaternion(a);break;case"yz":ka.set(1,0,0).applyQuaternion(a);break;case"xz":ka.set(0,1,0).applyQuaternion(a);break;case"adaptive":Il.angleTo(Fn.set(0,1,0))>Math.PI/6?(oi.crossVectors(Fn.set(0,1,0),Il),ka.crossVectors(oi,Fn)):ka.set(0,1,0);break;default:ka.copy(Il)}hc.setFromMatrixPosition(t.matrixWorld);let o=t.userData.lockedPlane?t.userData.worldPosition0:hc;if(kB.setFromNormalAndCoplanarPoint(ka,o),s.ray.intersectPlane(kB,e)&&(i==="x"||i==="y"||i==="z")){let l=Fn.subVectors(e,o).dot(oi);e.copy(o).addScaledVector(oi,l)}}updateDragItem(t,e=!1){hc.setFromMatrixPosition(t.obj.matrixWorld),t.reset==="current"?om.subVectors(t.fromPosition,hc).divideScalar(t.currentDampingFactor):t.reset==="original"?(om.subVectors(t.obj.userData.worldPosition0,hc).divideScalar(t.currentDampingFactor),t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart)):om.subVectors(t.pointEnd,t.pointStart).add(t.fromPosition).sub(hc).divideScalar(t.currentDampingFactor),t.paused=!(t.currentDampingFactor>1)||om.length()<.01,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||e)&&Dtt(t,om.add(hc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?t.orientationMatrix:null),t.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}updateCursorFromRaycast(){let{raycaster:t,page:e}=this.eventContext,i=e.raycastWithClones(t),n=!1;for(let r of this.events){for(let{obj:s}of r.dragItems)if(s===i[0]?.object||s===i[0]?.object?.object||Be.is(s)&&s.isAncestorOf(i[0]?.object.uuid)){switch(n=!0,r.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move")}break}if(n)break}n||this.setCursor("default")}};ke(),xs("DragDrop",({eventContext:t,eventManager:e})=>new Itt(t,e)),Si("dragdrop"),et(),xh(),ii(),Yt(),Kn();var cu=new C,TM=new C,Ro=new C,Io=new C,jB=new kr,Ott={type:"requestRender"},Ltt=function(){let t=new C,e=new C;return(i,n,r)=>r>0?(t.subVectors(i,n),t.length()<=r?i:e.copy(n).add(t.normalize().multiplyScalar(r))):n}(),GB=function(){let t=new At;return(e,i)=>{e.position.copy(i),e.parent!==null&&(t.copy(e.parent.matrixWorld).invert(),e.position.applyMatrix4(t)),t.copy(e.hiddenMatrix).invert(),e.position.applyMatrix4(t),e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldRigid()),e instanceof Xi&&to(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),Btt=class{constructor(t,e,i,n,r,s){this.data=t,this.id=e,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new C,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...WE.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Rn(t,t.actions,n,r,s,i)}},Utt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(ae.length>1)){this.eventContext.updateRaycaster(i);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}},this.onMouseEnter=i=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)},this.onMouseLeave=i=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:t}=this.eventContext;if(t.traverseEntity(n=>{let r=n.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Btt(r.data,r.id,n,t,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:e,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let r=n.target,s=this.onTargetChange(n);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:t,eventElement:e}=this.eventContext;this.domEventsNeeded.clear(),ss&&t.removeEventListener("pointerdown",this.onMouseMove),e.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,n]of this.pairOfEventListeners)i.removeEventListener("requestRender",n);for(let i of this.events)i.paused=!0,i.isReset=!1,rr(i.actions)}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t,!0)}updateSingleEvent(t,e=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:n,limitDistanceEnabled:r}=t.data;if(t.object.getWorldPosition(Ro),t.isReset)Io.copy(t.worldPosition0);else if(t.target)t.target.getWorldPosition(Io);else{let{getCamera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a().getWorldDirection(TM),TM.negate(),cu.copy(TM)):i==="xy"?cu.set(0,0,1):i==="xz"?cu.set(0,1,0):i==="yz"&&cu.set(1,0,0),jB.setFromNormalAndCoplanarPoint(cu,Ro),!o.ray.intersectPlane(jB,Io))return}if(!t.isReset){if(Io.distanceTo(t.worldPosition0)>n&&r&&t.target){if(t.snapComplete=!1,t.data.snapDelay&&(t.delayFinished=!1,typeof window<"u"&&t.timeoutId!==null&&(window.clearTimeout(t.timeoutId),t.timeoutId=null)),t.wasOutside=!0,!t.data.resetAfterDistanceLimit)return;Io.copy(t.worldPosition0),t.currentDampingFactor=t.resetDampingFactor}else if(t.wasOutside&&(t.data.snapDelay&&typeof window<"u"&&(t.timeoutId=window.setTimeout(()=>{t.delayFinished=!0,t.paused=!1,this.updateSingleEvent(t)},1e3*t.data.snapDelay)),t.currentDampingFactor=t.data.dampingFactor,t.wasOutside=!1),t.delayFinished===!1)return}t.data.enabledTranslation[0]===!1&&(Io.x=Ro.x),t.data.enabledTranslation[1]===!1&&(Io.y=Ro.y),t.data.enabledTranslation[2]===!1&&(Io.z=Ro.z);let s=Ltt(Ro,Io,t.wasOutside?0:t.data.maxDelta);if(t.currentDampingFactor>1){let a=cu.subVectors(s,Ro).divideScalar(t.currentDampingFactor);Ro.add(a),e&&GB(t.object,Ro),t.paused=a.length()<.01}else GB(t.object,s),t.paused=!0;t.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),t.object.dispatchEvent(Ott)}};et(),Yt(),xh(),ii(),Kn(),mN();var lm=new C,Ry=new C,hm=new At,du=new qt,Ol=new qt,cm=new C,dm=new C,cc=new C,Oo=new C,CM=new kr,ztt={type:"requestRender"},Ftt={type:"changeRotation"},HB=function(){let t=new At;return function(e,i){e.parent!==null?t.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):t.copy(e.hiddenMatrix),i.premultiply(pN(t).invert()),e.rotation.setFromRotationMatrix(i),e.updateMatrix(),e instanceof Xi&&to(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),Ntt=class{constructor(t,e,i,n){this.id=e,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new qt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...qE.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),isNaN(this.worldQuaternion0.x)&&(this.worldQuaternion0.x=0),isNaN(this.worldQuaternion0.y)&&(this.worldQuaternion0.y=0),isNaN(this.worldQuaternion0.z)&&(this.worldQuaternion0.z=0),isNaN(this.worldQuaternion0.w)&&(this.worldQuaternion0.w=1),this.resetDampingFactor=80/this.data.resetSpeed+1}},ktt=class extends Or{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=t=>{if(!(ae.length>1)){this._lastMouseEvent=t,this.eventContext.updateRaycaster(t);for(let e of this.events)e.target===void 0&&this.updateSingleEvent(e)}},this.onMouseEnter=t=>{for(let e of this.events)e.target===void 0&&(e.isReset=!1,e.currentDampingFactor=e.data.dampingFactor)},this.onMouseLeave=t=>{for(let e of this.events)e.target===void 0&&(e.data.resetOnPointerLeave&&(e.isReset=!0,e.currentDampingFactor=e.resetDampingFactor),this.updateSingleEvent(e))},this.onScroll=t=>{if(this._lastMouseEvent){let e=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(e)}},this.onTargetChange=t=>()=>{this.updateSingleEvent(t)},this.createUserEventListener=t=>({eventName:e,target:i})=>{if(!e||!i)return;let n=i0(e);n&&n==="LookAt"&&this.updateSingleEvent(t)}}connect(){let{page:t}=this.eventContext;if(t.traverseEntity(n=>{let r=n.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Ntt(r.data,r.id,n,t))}),!this.events.length)return;let{domElement:e,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),o=n.target;this.pairOfEventListeners.push([o,a]),o.addEventListener("requestRender",a)}let r=this.createUserEventListener(n),s=n.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:t,eventElement:e}=this.eventContext;this.domEventsNeeded.clear(),ss&&t.removeEventListener("pointerdown",this.onMouseMove),e.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave),e.removeEventListener("scroll",this.onScroll);for(let[i,n]of this.pairOfEventListeners)i.removeEventListener("requestRender",n);for(let[i,n]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",n);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t)}updateSingleEvent(t){let{tilt:e,axis:i,distance:n,plane:r,limitDistance:s,enabledRotation:a,limitDistanceEnabled:o}=t.data,{getCamera:l,raycaster:c}=this.eventContext,{object:h,target:u}=t;if(h.getWorldPosition(cm),!t.isReset)if(t.target)t.target.getWorldPosition(dm);else{if(r==="custom"?(l().getWorldDirection(Ry),Ry.negate(),CM.setFromNormalAndCoplanarPoint(Ry,cm)):(r==="xy"?lm.set(0,0,1):r==="xz"?lm.set(0,1,0):r==="yz"&&lm.set(1,0,0),CM.setFromNormalAndCoplanarPoint(lm,cm)),!c.ray.intersectPlane(CM,dm))return;n>0&&(r==="custom"||r===void 0)&&dm.addScaledVector(Ry,n)}if(t.isReset||(u?e==="target"?cc.copy(u.up).applyMatrix4(hm.extractRotation(u.matrixWorld)).normalize():a.some(d=>d===!1)?(i==="x"?(Oo.set(0,0,1),a[2]===!1&&Oo.set(0,1,0)):i==="y"?(Oo.set(1,0,0),a[0]===!1&&Oo.set(0,0,1)):(Oo.set(0,1,0),a[1]===!1&&Oo.set(1,0,0)),cc.copy(Oo).applyQuaternion(t.worldQuaternion0).normalize()):cc.set(0,1,0):r==="custom"?cc.set(0,1,0):cc.copy(lm)),t.isReset)Ol.copy(t.worldQuaternion0);else if(cm.distanceTo(dm)>s&&o&&u){if(t.data.snapDelay&&(t.delayFinished=!1,typeof window<"u"&&t.timeoutId!==null&&(window.clearTimeout(t.timeoutId),t.timeoutId=null)),t.wasOutside=!0,!t.data.resetAfterDistanceLimit)return;Ol.copy(t.worldQuaternion0),t.currentDampingFactor=t.resetDampingFactor}else{if(t.wasOutside&&(t.data.snapDelay&&typeof window<"u"&&(t.timeoutId=window.setTimeout(()=>{t.delayFinished=!0,t.paused=!1,this.updateSingleEvent(t)},1e3*t.data.snapDelay)),t.currentDampingFactor=t.data.dampingFactor,t.wasOutside=!1),t.delayFinished===!1)return;(function(d,p,f,g,m,y){let v=hm.elements;on.subVectors(p,f),on.lengthSq()===0&&(on.z=1),on.normalize(),zn.crossVectors(g,on),zn.lengthSq()===0&&(Math.abs(g.z)===1?on.x+=1e-4:on.z+=1e-4,on.normalize(),zn.crossVectors(g,on)),zn.normalize(),Bs.crossVectors(on,zn),m==="x"?y.z===1?[zn,Bs,on]=[on,zn,Bs]:(zn.negate(),[zn,on]=[on,zn]):m==="y"?y.x===1?[zn,Bs,on]=[Bs,on,zn]:(zn.negate(),[Bs,on]=[on,Bs]):y.x===1&&(zn.negate(),[zn,Bs]=[Bs,zn]),v[0]=zn.x,v[4]=Bs.x,v[8]=on.x,v[1]=zn.y,v[5]=Bs.y,v[9]=on.y,v[2]=zn.z,v[6]=Bs.z,v[10]=on.z})(0,dm,cm,cc,i,Oo),Ol.setFromRotationMatrix(hm),du.setFromUnitVectors(Oo.applyQuaternion(Ol),cc),a.some(d=>d===!1)&&e!=="target"&&Ol.premultiply(du).normalize()}t.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),du.setFromRotationMatrix(pN(h.matrixWorld)),du.slerp(Ol,1/t.currentDampingFactor),HB(h,hm.makeRotationFromQuaternion(du)),t.paused=8*(1-du.dot(Ol))<1e-6):(HB(h,hm.makeRotationFromQuaternion(Ol)),t.paused=!0),t.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(ztt),h.dispatchEvent(Ftt)}},Bs=new C,zn=new C,on=new C;ke(),xs("Follow",({eventContext:t,eventManager:e})=>new Utt(t,e)),xs("LookAt",({eventContext:t})=>new ktt(t)),Si("tracking"),Li(),Yt(),ol();var Vtt=class{constructor(t,e,i,n,r,s,a,o){this.eventId=t,this.id=e,this.data=i,this.dataEvent=n,this.object=r,this.stage=!1,this.actions=Rn(n,i.actions,s,a,o,r,"Toggle")}disconnect(){rr(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.play()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>t.play())}},jtt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.breakpoints=[],this.resize=(i,n)=>{this.breakpoints.forEach(r=>{let s,a=XE.deviceToSize(r.data.size),o=r.dataEvent.orientation==="horizontal"?i:n;switch(r.data.operator){case"<":s=o<a[0];break;case">":s=o>a[0];break;case"<>":s=o>a[0]&&o<a[1]}r.stage!==s&&(r.stage=s,r.stage?r.dispatchIn():r.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let n of i){let{width:r,height:s}=n.contentRect;this.resize(r,s)}})}connect(){let{page:t,sharedAssets:e,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let n=r=>{if(r.visible&&r.data?.events.length)for(let{data:s,id:a}of r.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:o,id:l})=>{try{let c=new Vtt(a,l,o,s,r,t,e,this.eventManager);this.breakpoints.push(c)}catch{}})};t.traverseEntity(r=>{(Cr(r)||r instanceof un)&&r.frame?.traverse(s=>{n(s)}),n(r)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(t=>{t.disconnect()}),this.breakpoints=[]}};function WB(t){return Object.values(t).some(e=>e.length>0)}ke(),xs("Resize",({eventContext:t,eventManager:e})=>new jtt(t,e)),Si("resize"),et();var Gtt=new C,Htt=new C,gj=(new At,new C,new qt,new C,new xi,class{constructor(t,e,i,n,r){this.actionsIn=Rn(t,t.inActions,i,n,r,e),this.actionsOut=Rn(t,t.outActions,i,n,r,e)}disconnect(){rr(this.actionsIn),rr(this.actionsOut)}}),Wtt=class extends gj{constructor(t,e,i,n,r,s){super(e,i,n,r,s),this.id=t,this.data=e,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let c=Gtt.setFromMatrixPosition(this.objects[0].matrixWorld),h=Htt.setFromMatrixPosition(this.objects[1].matrixWorld),u=c.distanceTo(h)<=this.distance?"in":"out";if(this.stage!==u){this.stage=u;let d=u==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Particles.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.TimelineAnimation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch()),d.ClearLocalStorage.forEach(p=>p.dispatch()),d.UserAPI.forEach(p=>p.dispatch())}};let{distance:a,fromObject:o,toObject:l}=e.condition;this.distance=a;for(let c of[o,l]){if(!c)throw new Error("Missing property");let h=n.find(c);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){window.setTimeout(()=>{this.objects.forEach(t=>{t.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld),t.addEventListener("updateMatrix",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(t=>{t.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld),t.removeEventListener("updateMatrix",this.onUpdateMatrixWorld)})}},qtt=class extends gj{constructor(t,e,i,n,r,s){super(e,i,n,r,s),this.id=t,this.data=e,this.object=i,this.onTransitionState=({settled:l,state:c})=>{l&&c===(this.toState??null)?WB(this.actionsIn)&&this.runInActions():WB(this.actionsOut)&&this.runOutActions()};let{condition:a}=e;if(!a.object)throw new Error("Missing property");let o=n.find(a.object)??n.scene.find2D(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){this.toObject.addEventListener("transitionState",this.onTransitionState)}disconnect(){super.disconnect(),this.toObject.removeEventListener("transitionState",this.onTransitionState)}runOutActions(){this.actionsOut.Audio.forEach(t=>t.dispatchConditional()),this.actionsOut.Particles.forEach(t=>t.dispatchConditional()),this.actionsOut.Video.forEach(t=>t.dispatchConditional()),this.actionsOut.Link.forEach(t=>t.dispatch()),this.actionsOut.Create.forEach(t=>t.dispatch()),this.actionsOut.Destroy.forEach(t=>t.dispatch()),this.actionsOut.Reset.forEach(t=>t.dispatch()),this.actionsIn.Transition.forEach(t=>{this.drivesWatchedObject(t)||t.pause()}),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(t=>t.play()),this.actionsOut.Animation.forEach(t=>t.play()),this.actionsOut.TimelineAnimation.forEach(t=>t.play()),this.actionsIn.SwitchCamera.forEach(t=>t.pause()),this.actionsOut.SwitchCamera.forEach(t=>t.play()),this.actionsOut.SceneTransition.forEach(t=>t.dispatch()),this.actionsOut.SetVariable.forEach(t=>t.checkConditions()),this.actionsOut.SetVariable.forEach(t=>t.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actionsOut.ClearLocalStorage.forEach(t=>t.dispatch()),this.actionsOut.UserAPI.forEach(t=>t.dispatch())}runInActions(){this.actionsIn.Audio.forEach(t=>t.dispatchConditional()),this.actionsIn.Particles.forEach(t=>t.dispatchConditional()),this.actionsIn.Video.forEach(t=>t.dispatchConditional()),this.actionsIn.Link.forEach(t=>t.dispatch()),this.actionsIn.Create.forEach(t=>t.dispatch()),this.actionsIn.Destroy.forEach(t=>t.dispatch()),this.actionsIn.Reset.forEach(t=>t.dispatch()),this.actionsOut.Transition.forEach(t=>{this.drivesWatchedObject(t)||t.pause()}),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(t=>t.play()),this.actionsIn.Animation.forEach(t=>t.play()),this.actionsIn.TimelineAnimation.forEach(t=>t.play()),this.actionsOut.SwitchCamera.forEach(t=>t.pause()),this.actionsIn.SwitchCamera.forEach(t=>t.play()),this.actionsIn.SceneTransition.forEach(t=>t.dispatch()),this.actionsIn.SetVariable.forEach(t=>t.checkConditions()),this.actionsIn.SetVariable.forEach(t=>t.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actionsOut.ClearLocalStorage.forEach(t=>t.dispatch()),this.actionsOut.UserAPI.forEach(t=>t.dispatch())}drivesWatchedObject(t){return t.object===this.toObject}},Xtt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:t,sharedAssets:e}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let{id:n,data:r}of i.data.events)if(!r.disabled&&r.type==="Conditional")try{let s;r.condition.type==="Comparison"||(r.condition.type==="Distance"?s=new Wtt(n,r,i,t,e,this.eventManager):r.condition.type==="State"&&(s=new qtt(n,r,i,t,e,this.eventManager))),s&&(this.eventsPerConditions[r.condition.type].push(s),(s.actionsIn.Video.length||s.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(e=>e.disconnect()))}};ke(),xs("Conditional",({eventContext:t,eventManager:e})=>new Xtt(t,e)),Si("conditional"),Yt(),o3(),et();var qB=new At,PM=new C,XB=new qt,$tt=new C,$B=new xi,Ytt=class extends Or{constructor(t,e,i,n,r){super(t),this.sharedVariables=e,this.eventManager=i,this.needsMouse=n,this.needsRaycast=r,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=s=>{let a=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],c=[];for(let d=0;d<this.propertiesToWatch.length;d++){let{objectId:p,property:f,prevValue:g}=this.propertiesToWatch[d],m=this.eventContext.scene.find(p),y=$E.propertyPaths[f];if(y[0]==="width"||y[0]==="height"||y[0]==="depth")m=m.geometry.userData.parameters[y[0]];else if((y[0]==="position"||y[0]==="rotation"&&y.length>1)&&m.getPhysicsLocalMatrix?.(qB))qB.decompose(PM,XB,$tt),y[0]==="position"?m=y.length>1?PM[y[1]]:PM:($B.setFromQuaternion(XB,m.rotation.order),m=$B[y[1]]);else for(let v=0;v<y.length;v++)m=m[y[v]];g===null?this.propertiesToWatch[d].prevValue=m instanceof C?m.clone():m:(m instanceof C?!m.equals(g):g!==m)&&(c.push({objId:p,property:f}),m instanceof C?this.propertiesToWatch[d].prevValue.copy(m):this.propertiesToWatch[d].prevValue=m)}for(let d=0;d<this.variablesToWatch.length;d++){let{id:p,prevValue:f}=this.variablesToWatch[d],g=a.getVariable(p);g!==f&&(l.push(p),this.variablesToWatch[d].prevValue=g)}for(let d=0;d<this.dynamicVars.length;d++){let{id:p,expectedTime:f,last:g,data:m,timerSeconds:y,startValue:v}=this.dynamicVars[d],_=1e3;if(m.dynamicVariableType!=="timer"&&m.dynamicVariableType!=="stopwatch"||m.format!=="number3decimal"?m.dynamicVariableType==="counter"?_=m.updateInterval:m.dynamicVariableType==="random"&&(_=m.isStatic?1/0:m.updateInterval):_=1,f!==-1){if(a.getDynamicVariablePlayState(p)!=="Stopped"&&a.getDynamicVariablePlayState(p)!=="Restarted"||(this.dynamicVars[d].last=s,this.dynamicVars[d].expectedTime=s+_,m.dynamicVariableType==="counter"&&a.getVariable(p)!==v&&(a.updateVariable(p,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[d].timerSeconds!==v&&(this.dynamicVars[d].timerSeconds=v,a.updateVariable(p,Fs.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),a.getDynamicVariablePlayState(p)==="Restarted"&&a.setDynamicVariablePlayState(p,"Playing"),a.getDynamicVariablePlayState(p)!=="Stopped")){if(a.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[d].deltaToExpectedTime===void 0&&(this.dynamicVars[d].deltaToExpectedTime=Math.max(this.dynamicVars[d].expectedTime-s,0)),this.dynamicVars[d].last=s-(_-this.dynamicVars[d].deltaToExpectedTime),this.dynamicVars[d].expectedTime=s+this.dynamicVars[d].deltaToExpectedTime;continue}if(this.dynamicVars[d].deltaToExpectedTime=void 0,s>=f)if(this.dynamicVars[d].last=s,this.dynamicVars[d].expectedTime+=_,m.dynamicVariableType==="random"){let b=m.min+Math.random()*(m.max-m.min),x=m.decimals;b=Math.round(b*Math.pow(10,x))/Math.pow(10,x),a.updateVariable(p,b),l.push(p),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){let b=a.getVariable(p),x=a.getDynamicVariableToggleIsForward(p)??!0,w=a.getVariable(p)+m.increment*(x?1:-1);m.hasEnd&&(w=m.increment>0?Ot.clamp(w,v,m.endValue):Ot.clamp(w,m.endValue,v),w===v&&a.setDynamicVariableToggleIsForward(p,void 0),m.repeat?w===m.endValue&&(w=v):(w===v||w===m.endValue)&&a.setDynamicVariablePlayState(p,"Paused")),w!==b&&(l.push(p),a.updateVariable(p,w),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time"){let b=a.getVariable(p),x=G4(o,m);if(typeof b=="object"&&"textValue"in b&&typeof x=="object"&&"textValue"in x){if(Array.isArray(b.textValue)&&Array.isArray(x.textValue)){if(b.textValue.every((w,S)=>w===x.textValue[S]))continue}else if(b.textValue===x.textValue)continue}else if(b===x)continue;a.updateVariable(p,x),l.push(p),this.eventManager.requestRender()}else{let b=_r.isTextValue(m.endValue)?YB(m.endValue.textValue):m.endValue,x=a.getDynamicVariableToggleIsForward(p)??!0,w=y+(s-g)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(x?1:-1);w=Math.max(w,0),m.hasEnd&&(w=m.dynamicVariableType==="stopwatch"?Ot.clamp(w,v,b):Ot.clamp(w,b,v),w===v&&a.setDynamicVariableToggleIsForward(p,void 0),m.repeat?Math.abs(w-b)<(m.format==="number3decimal"?1e-4:.1)&&(w=v):(Math.abs(w-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(w-b)<(m.format==="number3decimal"?1e-4:.1))&&a.setDynamicVariablePlayState(p,"Paused")),w!==y&&(l.push(p),this.dynamicVars[d].timerSeconds=w,a.updateVariable(p,Fs.getFormattedTimerTime(w,m)),this.eventManager.requestRender())}}}else this.dynamicVars[d].last=s,this.dynamicVars[d].expectedTime=s+_}let h=!1;a.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=a.mouseProperty,h=!0);let u=!1;a.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=a.raycastProperty,u=!0),this.events.forEach(d=>{(l.includes(d.data.variableId)||c.find(p=>p.objId===d.data.objectId&&p.property===d.data.property)||d.data.variableId==="mouseProperty"&&h||d.data.variableId==="raycastProperty"&&u)&&(d.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let t=Date.now()-this.pauseTime;for(let e=0;e<this.dynamicVars.length;e++)this.dynamicVars[e].last+=t,this.dynamicVars[e].expectedTime+=t}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new Ztt(i.id,i.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(e=>e.data.variableId==="objectProperty"&&e.data.objectId!==null).map(e=>({objectId:e.data.objectId,property:e.data.property,prevValue:null}));let t=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:e,data:i})=>{if(!("dynamicVariableType"in i))return void(this.events.find(r=>r.data.variableId===e)&&this.variablesToWatch.push({id:e,prevValue:t.getVariable(e)}));let n;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let r;if(_r.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let s=i.value.textValue;r=s.length===3?s[2]+60*s[1]+3600*s[0]:s[1]+60*s[0]}else r=i.value;n=r,this.dynamicVars.push({id:e,last:-1,expectedTime:-1,data:i,timerSeconds:r,startValue:n})}else i.dynamicVariableType==="time"&&t.updateVariable(e,G4(new Date,i)),i.dynamicVariableType==="counter"&&(n=_r.isTextValue(i.value)?YB(i.value.textValue):i.value),this.dynamicVars.push({id:e,last:-1,expectedTime:-1,data:i,startValue:n})}),this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(t=>t.dispose())}},Ztt=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.actions=Rn(e,e.actions,n,r,s,i)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.TimelineAnimation.forEach(e=>e.dispatchConditional()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispose(){rr(this.actions)}};function YB(t){return t.length===3?t[2]+60*t[1]+3600*t[0]:t[1]+60*t[0]}Yt();var Ktt=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Ti(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=xV(this.data.expression,this.shared,_r.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}},Qtt=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n,this.timeoutId=null}dispatchInner(){if(Ti(this.shared,this.condition)===!1)return!1;let t=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e!==void 0&&!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};ke(),xs("VariableChange",({eventContext:t,sharedVariables:e,eventManager:i,needsMouse:n,needsRaycast:r})=>new Ytt(t,e,i,n,r)),Pr("SetVariable",({data:t,page:e,shared:i,actionCondition:n})=>new Ktt(t,e,i,n)),Pr("DynamicVariablePlay",({data:t,page:e,shared:i,actionCondition:n})=>new Qtt(t,e,i,n)),Si("variables");var Jtt=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:i})=>{this.events.forEach(n=>{n.data.userAPIId===i&&n.dispatchSuccess()})},this.onError=({userAPIId:i})=>{this.events.forEach(n=>{n.data.userAPIId===i&&n.dispatchError()})},this.userAPIs=t.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="API"&&!e.data.disabled).forEach(e=>{this.events.push(new tet(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([t,e])=>{e.on("success",this.onSuccess),e.on("error",this.onError),e.autostart&&e.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([t,e])=>{e.off("success",this.onSuccess),e.off("error",this.onError)})}},tet=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.successActions=Rn(e,e.successActions,n,r,s,i),this.errorActions=Rn(e,e.errorActions,n,r,s,i)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}},eet=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:i})=>{this.events.forEach(n=>{n.data.userWebhookId===i&&n.dispatch()})},this.userWebhooks=t.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="WEBHOOK"&&!e.data.disabled).forEach(e=>{this.events.push(new iet(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([t,e])=>{e.connect(),e.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([t,e])=>{e.off("message",this.onMessage),e.disconnect()})}},iet=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.actions=Rn(e,e.actions,n,r,s,i)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}},net=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;if(this.data.userAPIId){let t=this.shared.getUserAPI(this.data.userAPIId);t&&"callUserAPI"in t&&t.callUserAPI(this.shared)}}dispose(){}};s3(),Ye(),Yt(),ii();var ret=class{constructor(t,e,i){this.id=t,this.userAPI=e,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(n=>n()),this.emitter=_x(),this._innerCallUserAPI=async n=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await async function(r,s,a=new AbortController){let o,l,c=r.url,h=r.proxy?.enabled??!1;if(r.integration?.type==="OpenAI"){let d=jm(r.integration.prompt===""?[]:JSON.parse(r.integration.prompt),s),p=r.integration.behavior===""?[]:jm(JSON.parse(r.integration.behavior),s);l=`{
9915
9915
  "model": "${r.integration.model}",
9916
9916
  "messages": [${r.integration.useBehavior?`
9917
9917
  {
@@ -9927,11 +9927,11 @@ onmessage = function(messageEvent) {
9927
9927
  `:"")+jm(i.children,e);if(i.type==="variable"){let r=e.getVariable(i.variableId);if(r!==void 0)return vj(r,e)}}return""}).join("");Yt();var DM=1e3,ZB=512e3,aet=class{constructor(t,e){this.id=t,this.userWebhook=e,this.result=void 0,this._connected=!1,this.emitter=_x(),this.reconnectWaitFor=DM,this._onError=i=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()},this._onConnected=i=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=DM,this._connected=!0},this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=DM,this._connected=!1},this._onMessage=i=>{let n,r=i.data;try{n=JSON.parse(r)}catch(s){console.error("Error parsing webhook message",s)}if(n){let s=!1;this.userWebhook.parametersSchemas.forEach(({data:a})=>{n[a.name]!==void 0&&function(o,l){let c=typeof o;return!!((l==="string"||l==="number")&&c===l||l==="boolean"&&(o==="true"||o==="false"||o===!0||o===!1)||l==="image"&&c==="string"&&o.startsWith("http"))}(n[a.name],a.type)&&(this.result===void 0&&(this.result={}),this.result[a.name]=n[a.name],s=!0)}),s&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource("https://hooks.spline.design/events?hashFile="+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>ZB&&(this.reconnectWaitFor=ZB),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let e of this.userWebhook.parametersSchemas)if(e.data.name===t)return aA.defaultParameterValueByType(e.data.type)}}};ke(),xs("API",({eventContext:t,eventManager:e})=>new Jtt(t,e)),xs("WEBHOOK",({eventContext:t,eventManager:e})=>new eet(t,e)),Pr("UserAPI",({data:t,page:e,shared:i,actionCondition:n})=>new net(t,e,i,n)),function(t){n3=t}({createUserAPI:(t,e,i)=>new ret(t,e,i),createUserWebhook:(t,e)=>new aet(t,e)}),Si("api-services");var oet=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.onVoice=({value:i,frequencies:n})=>{this.events.forEach(r=>{r.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="AIAssistantListener"&&!e.data.disabled).forEach(e=>{this.events.push(new het(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},het=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.actions=Rn(e,e.actions,n,r,s,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}},cet=class extends Or{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.onTriggerEvent=({description:i,direction:n})=>{let r=this.events.find(s=>s.data.description===i);r&&(n==="backward"?r.dispatchReverse():r.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="AIAssistantTrigger"&&!e.data.disabled).forEach(e=>{this.events.push(new det(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},det=class{constructor(t,e,i,n,r,s){this.id=t,this.data=e,this.object=i,this.actions=Rn(e,e.actions,n,r,s,i)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};s3();var uet=function(t){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(i,n,r,s)=>String(n+n+r+r+s+s));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null},KB=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],pet=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],ch=[],G3=[];for(let t=1;t<=8;t++)for(let e=0;e<KB.length;e++){let i=KB[e];ch.push(i/Math.pow(2,8-t)),G3.push(pet[e]+t)}var Cb=[32,2e3],QB=ch.filter((t,e)=>ch[e]>Cb[0]&&ch[e]<Cb[1]),fet=G3.filter((t,e)=>ch[e]>Cb[0]&&ch[e]<Cb[1]),met=class{static getFrequencies(t,e,i,n="frequency",r=-100,s=-30){i||(i=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(i));let a,o,l,c=e/2,h=1/i.length*c;if(n==="music"||n==="voice"){let d=n==="voice"?QB:ch,p=Array(d.length).fill(r);for(let f=0;f<i.length;f++){let g=f*h,m=i[f];for(let y=d.length-1;y>=0;y--)if(g>d[y]){p[y]=Math.max(p[y],m);break}}a=p,o=n==="voice"?QB:ch,l=n==="voice"?fet:G3}else a=Array.from(i),o=a.map((d,p)=>h*p),l=o.map(d=>`${d.toFixed(2)} Hz`);let u=a.map(d=>Math.max(0,Math.min((d-r)/(s-r),1)));return{values:new Float32Array(u),frequencies:o,labels:l}}},get=class{constructor(t){this.value=0,this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return met.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((i,n)=>i+n,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},vet=class{constructor(t){this.callbacks=t,this.rafId=0,this.isOpen=!1,this.onMessage=e=>{this.callbacks.onMessage(e.data)},this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()},this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(t){let e=await async function(s){try{return(await(await fetch("https://relayserver.spline.design/session?uuidfile="+s)).json()).token}catch(a){console.error("Token generation error:",a)}}(t);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=s=>{let a=s.streams[0];this.audioElement.srcObject=a,this.analyser=new get(a)};let i=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(i.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let n=await this.pc.createOffer();await this.pc.setLocalDescription(n);let r={type:"answer",sdp:await(await fetch("https://api.openai.com/v1/realtime/calls?model=gpt-realtime",{method:"POST",body:n.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(r),this.animate()}send(t){return!!this.dc&&(this.dc.send(t),!0)}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}},yet=class{constructor(t,e,i){this.data=t,this.id=e,this.shared=i,this.emitter=_x(),this.voice=0,this.frequencies=new Float32Array([0]),this.events=[],this.isConnected=!1,this.isToolsAdded=!1,this.tools=[],this.onServerEvent=n=>{let r=JSON.parse(n);if(this.appendEvent(r),r.type==="session.created"&&this.onSessionCreated(),r.type==="response.done"&&r.response?.output){for(let s of r.response.output)if(s.type==="function_call")for(let[a,o]of this.tools)s.name===a.name&&(o(JSON.parse(s.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}},this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()},this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(t){this.data=t}setColorByName(t,e){let i=this.shared.getColorByName(t);if(i){let{id:n}=i,{r,g:s,b:a}=uet(e)??{r:0,g:0,b:0};this.shared.updateColor(n,{r:r/255,g:s/255,b:a/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let t={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,i)=>{this.voice=e,this.frequencies=i,this.emitter.emit("voice",{value:e,frequencies:i})}};this.hosted=function(e,i,n){if(!function(){try{return window.__SPLINE_PLAY_VOICE_HOST__===!0&&window.parent!==window}catch{return!1}}())return null;let r=!1,s=o=>{window.parent.postMessage({__splinePlayFrame:!0,...o},"*")},a=o=>{if(o.source!==window.parent)return;let l=o.data;!l||l.__splinePlayFrameHost!==!0||l.id!==e||(l.type==="voice-open"?(r=!0,n.onOpen()):l.type==="voice-message"&&typeof l.data=="string"?n.onMessage(l.data):l.type==="voice-level"&&typeof l.value=="number"?n.onVoice(l.value,l.frequencies instanceof Float32Array?l.frequencies:new Float32Array(0)):l.type==="voice-error"&&console.error("Voice assistant host error:",l.message))};return window.addEventListener("message",a),s({type:"voice-connect",id:e,hash:i}),{send:o=>!!r&&(s({type:"voice-send",id:e,message:o}),!0),disconnect:()=>{r=!1,window.removeEventListener("message",a),s({type:"voice-disconnect",id:e})}}}(this.id,this.data.integration.hash,t),!this.hosted&&(this.session=new vet(t),await this.session.connect(this.data.integration.hash))}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){t.event_id=t.event_id||crypto.randomUUID();let e=JSON.stringify(t);(this.hosted?this.hosted.send(e):this.session?.send(e))?this.appendEvent(t):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:r})=>{this.setColorByName("Voice Assistant Color",r)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:r,value:s})=>{let a=this.shared.getVariableByName(r);if(a){let o,l=this.shared.getVariable(a.id);o=typeof l=="number"?parseFloat(s):typeof l=="boolean"?s.toLowerCase()==="true":{textValue:s},this.shared.updateVariable(a.id,o)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:r,value:s})=>{this.setColorByName(r,s)});let i=this.shared.scene,n=[];i.traverseEntity(r=>{r.data.events.forEach(s=>{if(s.data.type==="AIAssistantTrigger"){let{description:a}=s.data;n.push(a)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(n)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:r,direction:s})=>{this.emitter.emit("trigger_event",{description:r,direction:s})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([r])=>r)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((i,n)=>i+n,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};ke(),xs("AIAssistantListener",({eventContext:t,eventManager:e})=>new oet(t,e)),xs("AIAssistantTrigger",({eventContext:t,eventManager:e})=>new cet(t,e)),r3=(t,e,i)=>new yet(t,e,i),Si("ai-assistant"),ii();var H3=class extends B3{constructor(t,e,i){super(t,e,i),this.data=e}};Yt(),et(),Yt(),et();var yj=class extends yp{constructor(){super(),this.caretIndex=0,this._caretVisibleAlpha=1,this._selectionVisibleAlpha=.3,this.current={start:0,end:void 0},this.matrixAutoUpdate=!1,this.caretMesh=new wi(new lo(1,1),new Gs({transparent:!0,opacity:0,side:Hn})),this.add(this.caretMesh),this.selectionMesh=new wi(new lo(1,1),new Gs({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:Hn})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(t){this.visible=!0,this.object=t,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=.5*-this.caretHeight,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(this.object===void 0)return;this.updateHelperMatrix();let{depth:t}=this.object.geometry.userData.parameters;this.caretMesh.position.z=t,this.selectionMesh.position.z=t}updateHelperMatrix(){if(this.object===void 0)return;let t=this.object,e=t.parent;e!==null&&e.updateWorldMatrix(!0,!1),t.matrixAutoUpdate&&t.updateMatrix(),e!==null?(this.matrixWorld.multiplyMatrices(e.matrixWorld,t.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,t.matrix)):this.matrixWorld.multiplyMatrices(t.hiddenMatrix,t.matrix),this.matrix.copy(this.matrixWorld);for(let i of this.children)i.matrixWorld.copy(this.matrixWorld);t.updateWorldMatrix(!0,!0)}setCaretColor(t){let e=this.caretMesh.material;e.color.setRGB(t.r,t.g,t.b);let i=this._caretVisibleAlpha===e.opacity;this._caretVisibleAlpha=t.a,i&&(e.opacity=this._caretVisibleAlpha)}setSelectionColor(t){this.selectionMesh.material.color.setRGB(t.r,t.g,t.b)}setCaretPosition(t,e={}){if(this.object===void 0)return;this.caretIndex=t;let i=this.object.wrappedText,[n,r]=Iy(i,t),[s,a]=t>0?Iy(i,t-1):[null,null];(t>0&&i.length?i[s].charAt(a):null)===`
9928
9928
  `&&(n++,r=0),this.current.start=t,this.current.end=void 0;let[o,l]=RM(this.object,n,r),{AD:c,descender:h}=this.object,u=h+.5*c,{width:d,height:p,depth:f}=this.object.geometry.userData.parameters,g=typeof d=="string"?0:d,m=typeof p=="string"?0:p;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(o-.5*g,l+u+.5*m,f),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(t,e){if(this.object===void 0)return;let i=this.object.wrappedText;this.current.start=t,this.current.end=e;let n=[],r=[],s=function(m,y,v){let[_,b]=Iy(m,y),[x,w]=Iy(m,v),S=[];b>=m[_].length&&(_++,b=0);for(let A=_;A<=x;A++){let E=m[A],P=A===_?b:0,T=A===x?w:E.length;S.push([A,P,T])}return S}(i,t,e),{lineHeight:a,AD:o,descender:l}=this.object,c=l+.5*o-.5*a;for(let[m,y,v]of s)if(y!==v){let[_,b]=RM(this.object,m,y),[x,w]=RM(this.object,m,v),S=b,A=w;S+=c,A+=c,A+=a;let E=n.length/3;n.push(_,S,0),n.push(x,S,0),n.push(x,A,0),n.push(_,A,0),r.push(E+0,E+1,E+2),r.push(E+2,E+3,E+0)}let h=new Gt;h.setIndex(r),h.setAttribute("position",new Nt(n,3));let{width:u,height:d,depth:p}=this.object.geometry.userData.parameters,f=typeof u=="string"?0:u,g=typeof d=="string"?0:d;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=h,this.selectionMesh.position.x=.5*-f,this.selectionMesh.position.y=.5*g,this.selectionMesh.position.z=p,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(t,e,i="previous"){if(this.object===void 0||this.object.font===void 0)return;let n=this.object.wrappedText,r=n.length,s=this.object.lineHeight,a=r*s,{height:o,verticalAlign:l}=this.object.geometry.userData.parameters,c=typeof o=="string"?0:o,h=0;l===3?h=c-a:l===2&&(h=.5*c-.5*a);let u=Math.min(Math.floor(Math.max(Math.min(-e-h,a),0)/s),r-1),d=this.object.charCoords[u],p=this.object.charWidths[u],f=0,g=!1;if(i==="previous"){for(let m=0;m<d.length;m++)if(d[m][0]+.5*p[m]-t>0){f=m,g=!0;break}}else if(i==="closest"){let m=1/0;for(let y=0;y<d.length;y++){let v=d[y][0]+.5*p[y],_=Math.abs(v-t);_<m&&(m=_,f=y,g=!0)}}else for(let m=0;m<d.length;m++){let y=d[m][0],v=d[m][0]+p[m];if(t>=y&&t<v){f=m,g=!0;break}}return g||(f=d.length),{index:this.getGlobalIndexFromLineAndCharIndexes(n,u,f),lineIndex:u,characterIndex:f}}getGlobalIndexFromLineAndCharIndexes(t,e,i){return t.slice(0,e).reduce((n,r)=>n+r.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function RM(t,e,i){let{charCoords:n,charWidths:r,initialOffsetY:s,lineHeight:a}=t;if(n[e]&&n[e].length===0||n.length===0){let u=0,{horizontalAlign:d}=t.data.geometry,p=t.wrappedText,{width:f}=t.geometry.userData.parameters;return p.length===1&&p[0].length===0&&(d===3?u=.5*f:d===2&&(u=f)),[u,s-a*e]}let o=n[e];if(o===void 0||o.length===0)return[0,0];let[l,c]=o[Math.min(i,o.length-1)],h=l;return i>=o.length&&(h+=r[e][i-1]),[h,c]}function Iy(t,e){let i=0;for(let n=0;n<t.length;n++){let r=t[n],s=e-i;if(s<=r.length)return[n,s];i+=r.length}return[Math.max(0,t.length-1),t[t.length-1]?.length??0]}function _et(t,e){return typeof t=="string"?e.data.colors[t]:t}function bet(t){return t.colors[0]}et();var xet=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=t=>{let e=[t.clientX,t.clientY],i=new Date().getTime();if(this._clickCount>0){let n=e[0]-this._lastPosition[0],r=e[1]-this._lastPosition[1];Math.sqrt(n*n+r*r)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=t=>{}}start(t,e=500,i=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=i,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}};ii();var wet=new C(0,0,1),JB=new C,tU=new C,eU=new ue,Met=class{constructor(t,e,i,n,r){this.containerScene=t,this.raycaster=e,this.sharedAssets=i,this.requestRender=n,this.onExit=r,this.htmlInput=null,this.virtualInput=null,this.helper=new yj,this.doubleClickHandler=new xet,this.isDragging=!1,this.plane=new kr,this.caretInterval=0,this.planeIntersection=new C,this.projected=new it,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{let s=this.virtualInput?.data;if(this.virtualInput!==void 0&&s){let a=s.material,o=function(l,c){let h=Tn.fromHex(3223857),u=.8;for(let d of l.layers){if(d.data.type==="light"||d.data.type==="displace"||d.data.type==="fresnel"||d.data.type==="dust"||d.data.type==="matcap"||d.data.type==="texture"||d.data.type==="toon"||d.data.type==="outline"||d.data.type==="transmission"||d.data.type==="noise"||d.data.type==="vertexColor")continue;let p=typeof d.data.alpha=="string"?Number(c.getVariable(d.data.alpha)):d.data.alpha;if(d.data.type==="color"&&p>.3){h=_et(d.data.color,c),u=p;break}if((d.data.type==="depth"||d.data.type==="gradient")&&p>.3){let f=bet(d.data);h={r:f[0],g:f[1],b:f[2]},u=typeof d.data.alpha=="string"?1:d.data.alpha;break}}return{...h,a:u}}(typeof a=="string"?this.sharedAssets.data.materials[a]:a,this.sharedAssets);this.helper.setCaretColor(o)}},this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)},this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))},this.handleCaretUpdate=s=>{if(!this.htmlInput||!this.virtualInput)return;let a=this.helper,o=s?.key==="ArrowLeft"||s?.key==="ArrowRight",l=s?.key==="ArrowUp"||s?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(a.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:o,verticalKeyMove:l}),this.startAnimateTextCursor()):a.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=function(){let t=document.createElement("textarea");return t.style.position="fixed",t.style.top="200px",t.style.left="400px",t.style.zIndex="-1",t.style.border="1px solid rgba(255,0,0,0.5)",t.style.width="10px",t.style.height="500px",t.style.color="white",t.style.opacity="0.5",t.style.background="transparent",t.style.display="none",t.style.margin="0px",t.style.padding="0px",t.style.boxSizing="content-box",t.style.pointerEvents="none",t}(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,e=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0},{lineIndex:i}=e,{index:n,characterIndex:r}=e;this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[i][Math.max(0,r-1)]===`
9929
9929
  `&&(n--,r--),this._lastIndex=n,this._isFirstDragMove=!0;let s=this.checkClickedObject();if(t===1){if(s===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=n,this.isDragging=!0,this.setInputSelection(n)}else s===this.virtualInput&&(t===2?this.selectClosestWord(i,r):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let e=this.data?.geometry.text;this.htmlInput.value=typeof e=="string"?"":e?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:i,characterIndex:n}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0},r=e;i!==void 0&&n!==void 0&&this.virtualInput?.wrappedText[i][n-1]===`
9930
- `&&r--,this.htmlInput.setSelectionRange(Math.min(t,r),Math.max(t,r))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof H3)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,n=i[t],r=e+1,s=e;n[e]!==" "&&(r=this.findNextCharOccurence(n,e,"forward"," "),s=this.findNextCharOccurence(n,e,"backward"," "),s>0&&s++,r>=n.length-1&&t===i.length-1&&r++);let a=this.helper,o=a.getGlobalIndexFromLineAndCharIndexes(i,t,s),l=a.getGlobalIndexFromLineAndCharIndexes(i,t,r);this.setInputSelection(o,l)}findNextCharOccurence(t,e,i,n=" "){let r=Math.max(0,t.length-1),s=i==="forward"?r:0,a=i==="forward"?1:-1,o=Math.max(Math.min(e,r),0);for(;o!==s;)if(o+=a,t.charAt(o)===n)return o;return s}getPointOnPlane(){let t=this.virtualInput?.data;if(this.virtualInput&&t&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new C);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let i=typeof t.geometry.width=="number"?t.geometry.width:1,n=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+.5*i,e.y-.5*n)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(eU.getNormalMatrix(this.virtualInput.matrixWorld),JB.copy(wet).applyMatrix3(eU).normalize(),this.virtualInput.localToWorld(tU.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(JB,tU))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),Xc&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=function(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}(t.geometry.horizontalAlign))}},_j=(t,e)=>{if(typeof t=="string"){let i=e.data(t);if(i)return _j(i.value,e)}return _r.getDisplayedValue(t)};function iU(t,e){let i=t.text,n="";if(typeof i=="string"){let r=e.variables.data(n);r&&(n=_j(r.value,e.variables))}else n=i.textValue.toString();return n}var Eet=class extends Or{constructor(t,e){super(t),this.eventManager=e,this._textInputs=[],this.sceneHelpers=new rs,this.helper=new yj,this._onMouseDownFocusIn=i=>{if(ae.length>1)return;this.eventContext.updateRaycaster(i);let n=null;if(this.eventContext.raycaster){for(let r of this._textInputs)if(this.eventContext.raycaster.intersectObject(r,!0).length>0){n=r;break}}this.focusOnTextInput(n),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let n=this.textInputManager.htmlInput;this.helper.hide(),n?.setSelectionRange(n.value.length,n.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:n,virtualInput:r,helper:s}=this.textInputManager;if(!n||!r)return;let a=n.value;r.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=r.data;s.update();let l=o.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new Met(this.sceneHelpers,t.raycaster,t.sharedAssets,t.requestRender,this.onExit)}connect(){let t=[];if(this.eventContext.scene.traverseEntity(n=>{n instanceof H3&&t.push(n)}),this._textInputs=t,t.length===0)return;let{domElement:e}=this.eventContext;e.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let t=this.textInputManager.htmlInput,{domElement:e,sharedAssets:i}=this.eventContext;e.removeEventListener("pointerdown",this._onMouseDownFocusIn),t?.removeEventListener("keyup",this._onCaretUpdate),t?.removeEventListener("keydown",this._onCaretUpdate),t?.removeEventListener("beforeinput",this._onCaretUpdate),t?.removeEventListener("paste",this._onCaretUpdate),t?.removeEventListener("cut",this._onCaretUpdate),t?.removeEventListener("select",this._onCaretUpdate),t?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(n=>{let r=iU(n.data.geometry,this.eventContext.sharedAssets.data);n.textGeometry.setText(r,i)}),e.removeEventListener("pointerdown",this._onMouseDown,!1),e.removeEventListener("pointerup",this._onMouseUp,!1),e.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(t){this.textInputManager.focus(t),this.textInputManager.onTextMaterialChanged();let e=this.textInputManager.htmlInput;if(!e||t===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=iU(t.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);e.value=i,e.setSelectionRange(0,0),this.textInputManager.helper.show(t),e.style.display="block",e.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:n}=this.eventContext;n.removeEventListener("pointerdown",this._onMouseDownFocusIn),n.addEventListener("pointerdown",this._onMouseDown,!1),n.addEventListener("pointerup",this._onMouseUp,!1),n.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};ke(),xs("Textfields",({eventContext:t,eventManager:e})=>new Eet(t,e)),wp("InputGeometry",(t,e,i)=>new H3(t,e,i)),Si("textinputs"),qC();var bj=new Map,mg=new Map,Oy=class{constructor(t,e,i,n){this.data=e,this.isPlayAudioAction=!0;let{audio:r,volume:s,delay:a,loop:o}=e;if(!r)throw new Error("Missing property");try{let l=typeof r=="string"?n.getAudio(r).src:r.data;this.audioPlayer=new Uu({src:l,volume:s,delay:a,loop:o})}catch{console.warn(`Could not create an audio player for this object: "${i.name}" and this audio: "${r}"`)}mg.has(i.uuid)?mg.get(i.uuid).push(this):mg.set(i.uuid,[this]),bj.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},Aet=class{constructor(t){this.data=t,this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=bj.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=mg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...mg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Tet=class{constructor(t,e,i,n,r){if(this.data=e,this.shared=n,this.condition=r,e.interaction==="play")this.interaction=new Oy(t,e,i,n);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new Aet(e)}}dispatchBasic(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof Oy?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof Oy?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof Oy&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};ke(),Pr("Audio",({id:t,data:e,object:i,shared:n,actionCondition:r})=>new Tet(t,e,i,n,r)),Si("audio"),ii();var xj=new Map,gg=new Map,IM=class{constructor(t,e,i){this.data=e,this.isPlayVideoAction=!0,this.delay=0,this.status="stopped";let{layerId:n,loop:r,volume:s,delay:a}=e;if(this.object=i,n===void 0)throw new Error("Missing property");let o=function(l,c){let h;if("material"in l){let d=l.material;h=Array.isArray(d)?l.material[0].layers.find(p=>p.uuid===c):l.material.layers.find(p=>p.uuid===c)}if(!h)return;let u=h.color?.texture?.image?.img??h.holders?.find(d=>d.isVideo)?.img;return u instanceof HTMLVideoElement?u:void 0}(i,n);o&&(this.videoElement=o,this.videoElement.loop=r===1/0,Xc&&(this.videoElement.autoplay=!0),s!==void 0&&(this.videoElement.volume=s)),a!==void 0&&(this.delay=a),gg.has(i.uuid)?gg.get(i.uuid).push(this):gg.set(i.uuid,[this]),xj.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(n=>{}).catch(n=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let i=this.videoElement.duration;if(i>0){let n=t%i;this.videoElement.currentTime=n}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Cet=class{constructor(t){this.data=t,this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=xj.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=gg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let t=[...gg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Pet=class{constructor(t,e,i,n,r){if(this.data=e,this.shared=n,this.condition=r,e.interaction==="play")this.interaction=new IM(t,e,i);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new Cet(e)}}dispatchBasic(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof IM?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof IM?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};Li(),ke(),Pr("Video",({id:t,data:e,object:i,shared:n,actionCondition:r})=>as(i)?null:new Pet(t,e,i,n,r)),Si("video"),ii(),et(),Ep();var OM=(()=>{let t,e,i,n,r=!1;function s(l){!t&&!nU()&&(e?.sharedGameControlGlobals.createdObjects.length??0)>0&&(t=requestAnimationFrame(a)),l&&(e=l,n=l.requestRender,!r&&typeof document<"u"&&(document.addEventListener("visibilitychange",o),r=!0))}function a(l){if(!e||!n)return t=void 0,void(i=void 0);let c=i?l-i:0,h=e.sharedGameControlGlobals.createdObjects,u=e.sharedGameControlGlobals.nCreatedPerAction,d=h.length,p=0;for(;p<d;){let f=h[p];f.userData.createdTime===void 0&&(f.userData.createdTime=l),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&l-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,c/1e3),f.updateMatrix(),n()),p++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,h.splice(p,1),f.removeFromParent(),e.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(e.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),e.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,e.sharedGameControlGlobals.entitiesWithTransformAnim=e.sharedGameControlGlobals.entitiesWithTransformAnim.filter(g=>g.bvhGeometry!==void 0)),d--,n())}t=p>0?requestAnimationFrame(a):void 0,i=p>0?l:void 0}function o(){nU()?t&&(cancelAnimationFrame(t),t=void 0,i=void 0):s()}return{play:s,dispose:function(){t&&(cancelAnimationFrame(t),t=void 0),r&&typeof document<"u"&&(document.removeEventListener("visibilitychange",o),r=!1),e=void 0,n=void 0,i=void 0}}})();function nU(){return!!document&&document.hidden}var rU=new qt,Det=new C,Ret=new C,Iet=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.controlsManager=i,this.shared=n,this.condition=r,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Ot.generateUUID(),this.dispatch=()=>{if(Ti(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()},this.dispatchFromStart=()=>{if(Ti(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))},this.dispatchThrottled=function(a,o=0,l={}){return Cg(a,o,{leading:l.leading!==!1,trailing:l.trailing!==!1,maxWait:o})}(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let a=new ys(this.object);if(a.playModeVisible=!0,a.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,c=this.page.scene.find(l);c&&(c.updateMatrixWorldRigid(),a.hiddenMatrix.copy(c.matrixWorldRigid))}a.scale.copy(this.object.scale),a.position.fromArray(this.data.position.map(l=>typeof l=="number"?l:0)),a.rotation.fromArray(this.data.rotation.map(l=>typeof l=="number"?l:0)),a.updateMatrix(),this.page.add(a);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(a),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,a.updateWorldMatrix(!0,!0),a.traverseObject(this.traverseObjectCB),OM.play(),this.controlsManager.requestRender()},this.traverseObjectCB=a=>{let o;if(a.hasNonUniformScale&&a.updateMatrixWorldRigid(),this.controlsManager.sharedGameControlGlobals.rapierWorld){if(a instanceof zc){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(a instanceof ys)o=a.object;else if(o=a,o.dataPatched.cloner?.hideBase)return!0}else{if(a instanceof zc)return;o=a instanceof ys?a.object:a}this.data.destroy==="Time"?a.userData.lifetime=1e3*this.data.lifetime:this.data.destroy==="Quantity"&&(a.userData.quantity=this.data.destroyAfterQuantity,a.userData.actionId=this.uniqueId);let l=new C().fromArray(this.data.velocity.map(h=>typeof h=="number"?h:0)),c=o.dataPatched;if(!(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(a,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(a.rigidBody?.collider(0).setActiveEvents(1),a.userData.hasCollisionDestroy=!0),a.matrixWorld.decompose(Det,rU,Ret),l.applyQuaternion(rU),this.data.velocity.some(h=>h!==0)&&this.data.dynamic&&a.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in a.object&&this.controlsManager.addBoundsTree(a),this.data.velocity.some(h=>h!==0)&&this.data.dynamic&&(a.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let s=this.page.scene.find(this.data.object);if(!s)throw new Error("Missing Property");if(this.object=s,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");OM.play(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],OM.dispose()}},Oet=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.controlsManager=i,this.shared=n,this.condition=r,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=s=>{this.timeoutIdQueue.shift();let a=this.page.scene.find(s);if(a===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=!o||a.dataPatched.physics?.fusedBody;if(a.cloner){for(let c of a.cloner.children)l?(c.playModeVisible=!1,c.rigidBody&&a.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(c.rigidBody.collider(0).handle),o.removeRigidBody(c.rigidBody),c.rigidBody=void 0),c.bvhGeometry&&(c.bvhGeometry=void 0)):this.clone===void 0||this.clone===c?(c.playModeVisible=!1,c.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(c.rigidBody.collider(0).handle),o.removeRigidBody(c.rigidBody),c.rigidBody=void 0)):c.playModeVisible===void 0&&(c.playModeVisible=!0);a.cloner.syncInstanceMatrices(),(l||this.clone===void 0||this.clone===!1)&&(a.visible=!1,a.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(a.rigidBody.collider(0).handle),o.removeRigidBody(a.rigidBody),a.rigidBody=void 0),a.bvhGeometry&&(a.bvhGeometry=void 0))}else a.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(a.rigidBody.collider(0).handle),o.removeRigidBody(a.rigidBody),a.rigidBody=void 0),a.bvhGeometry&&(a.bvhGeometry=void 0),a.visible=!1;this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(c=>c.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(c=>c.rigidBody!==void 0),a.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...t.objects]}dispatch(t){if(Ti(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()}dispatchFromStart(){if(Ti(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};ke(),Pr("Create",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Iet(t,e,i.controlsManager,n,r)),Pr("Destroy",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Oet(t,e,i.controlsManager,n,r)),Si("create-destroy"),Yt(),Yt(),Wr(),et(),Hs(),qr(),Li();var sU=new C;function W3(t,e,i=!1){let n=[],r=s=>{let a=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let o of a.states){let l={...o.data};s.states||(s.states={}),s.states[o.id]=wc.patch(a,l)}oU(t.scene,s,null,e,a.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),aU(t)};t.scene.traverse2D(r),t.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(sU,!0),s.rigidBody?.setAngvel(sU,!0)),!Be.is(s))return;let a=s.uuid,o=s.data;if(delete s.states,s.uuid===Zc)return;let l=!1;n.some(c=>t.scene.find(a)?.isDescendantOf(c))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&n.push(a),s.data=o,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null,s.transitionState={settled:!0,state:null};for(let c of o.states){let h={...c.data};t.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete h.position,c.data.rotation!==void 0&&delete h.rotation,c.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[c.id]=Kl.patch(o,h)}oU(t.scene,s,null,e,o.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),Cr(s)&&s.frame&&(s.frame.traverse(c=>r(c)),s.uiCanvas?.applySize())}),aU(t),t.frame&&(t.frame.traverse(s=>r(s)),t.uiCanvas?.applySize())}function aU(t){t.traverseEntity(e=>{for(let i of e.data.events){let n=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...i.data.actions);break;case"GameControl":for(let r of Object.values(i.data.gameActions))n.push(...r);break;case"DragDrop":n.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":n.push(...i.data.inActions,...i.data.outActions)}for(let r of n)if(r.data.type==="Create"&&r.data.hideBase==="Yes"){let s=t.scene.find(r.data.object);s&&(s.visible=!1)}}})}function oU(t,e,i,n,r=!1){if(t.markShadowsDirty(),e instanceof Ai&&!nl(e)&&e.removeInteractionGeometry(n),as(e)?e.changeSelectedState(i,{shared:n},r):e.changeSelectedState(i,{scene:t,shared:n},r),e instanceof Ai&&e.updateGeometryGroupsIfNeeded(),e instanceof vn&&e.updateCameraState(e.dataPatched,{scene:t,shared:n}),!as(e)){if(e.cloner){let s=!1;for(let a of e.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,s=!0);s&&t.addPendingUpdateCloner(e),e.cloner.syncInstanceMatrices()}e.updateVisible()}}var Let=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.eventManager=i,this.shared=n,this.condition=r,this.timeOutId=-1,this.scene=e.scene}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},1e3*this.data.delay))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(e=>e.uuid!==this.data.target||e.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,1e3*this.data.duration),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.sleep(),e.wakeUp(),e.data.autoPlay?e.start():e.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),W3(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function Bet(t){return{easing:t.type,control1:Oc(t.cubicControls?.control1,[0,0]),control2:Oc(t.cubicControls?.control2,[1,1]),...t.springParameters}}function uu(t,e){let i=[];for(let n of t??[]){let r=e(n.data);r!==void 0&&i.push({time:n.data.time,ease:Bet(n.data.easing),value:r})}return{keyframes:Mtt(i)}}function Va(t,e){if(t.keyframes.length===0)return;let{index0:i,index1:n,t:r}=function(o,l){if(o.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(l<=o[0].time)return{index0:0,index1:0,t:1};let{found:c,index:h}=function(m,y){let v=m.length,_=0,b=v;for(;_<b;){let x=_+Math.floor(v/2),w=m[x].time;if(w<y)_=x+1;else{if(!(w>y))return{found:!0,index:x};b=x}v=b-_}return{found:!1,index:_}}(o,l);if(c)return{index0:h,index1:h,t:1};if(h>=o.length){let m=o.length-1;return{index0:m,index1:m,t:1}}let u=h-1,d=h,p=o[u].time,f=o[d].time;if(f===p)return{index0:u,index1:d,t:.5};let g=SM(f-p);return{index0:u,index1:d,t:pj({...o[u].ease,control2:o[d].ease.control2},g,SM(SM(l-p)/g))}}(t.keyframes,e),s=t.read;if(s&&s.index0===i&&s.index1===n&&s.t===r)return;let a={index0:i,index1:n,from:t.keyframes[i].value,to:t.keyframes[n].value,t:r};return t.read=a,a}function Uet(t){t.read=void 0}function Ly(t,e,i){return t+(e-t)*i}ke(),Pr("SceneTransition",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Let(t,e,i,n,r)),Si("scene-transition"),Yt(),et(),Yt(),Yt(),et(),Kn(),Hs(),l3(),kk(),u3(),qr(),Li(),rl(),Dk(),Yt(),ii(),et(),ya();var{degToRad:kit,radToDeg:Vit}=Ot,lU=new C,hU=new C,cU=new qt;function fr(t,e,i,n,r,s){let a=i[t]!==void 0?i[t]:void 0,o=n[t];if(o==null)return;let l=a!=null?typeof a=="string"?Number(r.getVariable(a)??0):a:e[t],c=typeof o=="string"?Number(r.getVariable(o)??0):o;return l!==c?{update:h=>{let u=Ot.lerp(l,c,h);e[t]=s?Math.trunc(u):u},start:()=>{e[t]=l},end:()=>{e[t]=c}}:void 0}function XT(t,e,i,n,r,s){let a=i[t]?i[t]:void 0,o=n[t];if(!o)return;let l=e[t],c=[...a??l].map(u=>typeof u=="string"?Number(r.getVariable(u)??0):u),h=[...o].map(u=>typeof u=="string"?Number(r.getVariable(u)??0):u);return c.length!==h.length||Gu(c,h)?void 0:{update:u=>{c.forEach((d,p)=>{let f=Ot.lerp(d,h[p],u);e[t][p]=s?Math.trunc(f):f})},start:()=>{Object.assign(e[t],c)},end:()=>{Object.assign(e[t],h)}}}function Pb(t,e,i){return e.forEach((n,r)=>{t.setComponent(r,typeof n=="string"?Number(i.getVariable(n)??0):n)}),t}function dU(t,e,i,n,r){let s=i[t]?i[t]:void 0,a=n[t];if(!a)return;let o=e[t],l=s?Pb(new C,s,r):o.clone(),c=Pb(new C,a,r);return l.equals(c)?void 0:{update:h=>{o.lerpVectors(l,c,h)},start:()=>{o.copy(l)},end:()=>{o.copy(c)}}}function uU(t,e,i){return e.forEach((n,r)=>{t.setComponent(r,typeof n=="string"?Number(i.getVariable(n)??0):n)}),t}function By(t,e,i,n,r){let s=i[t]?i[t]:void 0,a=n[t];if(!a)return;let o=e[t],l=!(o instanceof it),c=o instanceof it?o:new it().fromArray(o),h=s?uU(new it,s,r):c.clone(),u=uU(new it,a,r);return h.equals(u)?void 0:{update:d=>{c.lerpVectors(h,u,d),l&&(e[t]=c.toArray())},start:()=>{c.copy(h),l&&(e[t]=c.toArray())},end:()=>{c.copy(u),l&&(e[t]=c.toArray())}}}function Uy(t,e,i,n,r){let s=i[t]?i[t]:void 0,a=n[t];if(!a)return;let o=e[t],l=new gn(o.r,o.g,o.b,o.a),c=s?typeof s=="string"?r.getColor(s).clone():new gn(s.r,s.g,s.b,s.a):l.clone(),h=typeof a=="string"?r.getColor(a).clone():new gn(a.r,a.g,a.b,a.a);return c.equals(h)?void 0:{update:u=>{l.lerpColors(c,h,u);let d=Ot.lerp(c.a,h.a,u);l.a=d,e[t]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(h)}}}function Ll(t,e,i,n,r){return typeof e[t]=="number"?fr(t,e,i??{},n,r):Array.isArray(e[t])?XT(t,e,i??{},n,r):void 0}function zet(t,e){if(t)for(let[i,n]of Object.entries(e)){let r=t[i];if(Array.isArray(r)&&Array.isArray(n)){let s=Math.min(r.length,n.length);for(let a=0;a<s;a++)r[a]=n[a]}else t[i]=n}}function zy(t,e,i,n){let r={};if(!e||!i)return r;for(let s of t){let a=e[s],o=i[s];if(typeof a=="number"&&typeof o=="number")r[s]=Ot.lerp(a,o,n);else if(Array.isArray(a)&&Array.isArray(o)){let l=Math.min(a.length,o.length);r[s]=Array.from({length:l},(c,h)=>Ot.lerp(a[h],o[h],n))}}return r}new xi;var pU=[["radial",P_],["linear",D_],["grid",R_],["toObject",I_],["randomnessObject",O_]];function wj(t,e,i,n,r){let s=t.getValue(n);if(s!==void 0){if(n==="colors")return function(a,o,l,c="colors"){if(!a.hasValue(c)||!(c in l))return;let h=[],u=a.getValue(c),d=o?o[c]:u.map(f=>f.toArray()),p=l[c];for(let f=0;f<u.length;++f){let g=[...d[f]],m=[...p[f]];Dg.isEqual(g,m)||h.push({update:y=>{u[f].fromArray(Dg.lerp(g,m,y))},start:()=>{u[f].fromArray(g)},end:()=>{u[f].fromArray(m)}})}return h.length?h:void 0}(t,e,i,n);if(Array.isArray(s))return n==="steps"?function(a,o,l,c="steps"){if(!a.hasValue(c)||!(c in l))return;let h=[],u=a.getValue(c),d=o?o[c]:u,p=l[c];return Gu(d,p)||h.push({update:f=>{let g=[...u];for(let m=0;m<u.length;++m){let y=d[m],v=p[m];g[m]=Ot.lerp(y,v,f)}a.setValue(c,g)},start:()=>{a.setValue(c,d)},end:()=>{a.setValue(c,p)}}),h.length?h:void 0}(t,e,i,n):void 0;if(typeof s=="number")return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=o?o[c]:a.getValue(c),d=l[c],p=typeof u=="string"?Number(h.getVariable(u)??0):u,f=typeof d=="string"?Number(h.getVariable(d)??0):d;return{update:g=>{a.setValue(c,Ot.lerp(p,f,g))},start:()=>{a.setValue(c,p)},end:()=>{a.setValue(c,f)}}}(t,e,i,n,r);if(typeof s!="boolean"){if(s instanceof it)return function(a,o,l,c){if(!a.hasValue(c)||!(c in l))return;let h=a.getValue(c),u=o?new it().fromArray(o[c]):h.clone(),d=new it().fromArray(l[c]);return u.equals(d)?void 0:{update:p=>{h.lerpVectors(u,d,p)},start:()=>{h.copy(u)},end:()=>{h.copy(d)}}}(t,e,i,n);if(s instanceof C)return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=a.getValue(c),d=o?o[c]:void 0,p=l[c],f=d?Pb(new C,d,h):u.clone(),g=Pb(new C,p,h);return f.equals(g)?void 0:{update:m=>{u.lerpVectors(f,g,m)},start:()=>{u.copy(f)},end:()=>{u.copy(g)}}}(t,e,i,n,r);if(s instanceof gn)return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=o?o[c]:void 0,d=l[c],p=a.getValue(c),f=u?typeof u=="string"?h.color(u).clone():new Jt().setRGB(u.r,u.g,u.b):p.clone(),g=typeof d=="string"?h.color(d).clone():new gn(d.r,d.g,d.b,d.a);if(f.equals(g))return;let m=p.clone();return{update:y=>{a.getValue(c)!==m&&a.setValue(c,m),m.lerpColors(f,g,y)},start:()=>{m.copy(f)},end:()=>{m.copy(g)}}}(t,e,i,n,r);if(s instanceof Jt)return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=o?o[c]:void 0,d=l[c],p=a.getValue(c),f=u?typeof u=="string"?h.color(u).clone():new Jt().setRGB(u.r,u.g,u.b):p.clone(),g=typeof d=="string"?h.color(d).clone():new Jt().setRGB(d.r,d.g,d.b);if(f.equals(g))return;let m=p.clone();return{update:y=>{a.getValue(c)!==m&&a.setValue(c,m),m.lerpColors(f,g,y)},start:()=>{m.copy(f)},end:()=>{m.copy(g)}}}(t,e,i,n,r);if("isTexture"in s)return function(a,o,l,c="texture",h){if(!a.hasValue(c)||!(c in l))return;let u=A=>Number(typeof A=="string"?h?.getVariable(A)??0:A??0),d=a.getNode("rotation"),p=o?u(o[c]?.rotation):(d?.value??0)*Ot.RAD2DEG,f=u(l[c]?.rotation);if(d&&Math.abs(p-f)>1e-9)return{update:A=>{d.value=Ot.lerp(p,f,A)*Ot.DEG2RAD},start:()=>{d.value=p*Ot.DEG2RAD},end:()=>{d.value=f*Ot.DEG2RAD}};let g=function(A){let E=A.getNode("mat");if(typeof E?.updateMatrix=="function")return E;let P=A.getValue("mat");return typeof P?.updateMatrix=="function"?P:void 0}(a);if(!g)return;let m=o?o[c]:g,y=l[c],v=[...m.repeat],_=[...m.offset],b=[...y.repeat],x=[...y.offset],w=m.rotation??0,S=y.rotation??0;return Ja.isEqual(v,b)&&Ja.isEqual(_,x)&&w===S?void 0:{update:A=>{g.repeat=Ja.lerp(v,b,A),g.offset=Ja.lerp(_,x,A),g.rotation=Ot.lerp(w,S,A),g.updateMatrix()},start:()=>{g.repeat=[...v],g.offset=[..._],g.rotation=w,g.updateMatrix()},end:()=>{g.repeat=[...b],g.offset=[...x],g.rotation=S,g.updateMatrix()}}}(t,e,i,n,r)}}}function fU(t,e,i,n){let r=[],s=Pc(i,n)||!!e.layers&&Pc(e,n);r.push(function(a,o){return{update:()=>{a.transparent=o}}}(t,s)),function(a,o,l){let c=a.ensureRainbowNoiseCompiled;if(typeof c=="function")for(let h of[...a.layers]){if(h.type!=="rainbow")continue;let u=o.layers?.data(h.uuid),d=l.layers.data(h.uuid);(fp(u?.noiseStrength)||fp(d?.noiseStrength))&&c.call(a,h.uuid)}}(t,e,i);for(let a of t.layers){let o=e.layers?.data(a.uuid),l=i.layers.data(a.uuid);if(!l||a.type!=="light"&&(!(a.visible??1)||!(l.visible??1)))continue;let c=ox[a.type]??[],h=a.getNames().filter(u=>!c.includes(u)&&!Wb.some(d=>u.includes(d)));for(let u of h)try{let d=wj(a,o,l,u,n);d&&(Array.isArray(d)?r.push(...d):r.push(d))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${u}`,d)}}return r}function mU(t,e,i,n,r,s){let a=wj(e,i,n,t,s);!a||(Array.isArray(a)?a.forEach(o=>o.update(r)):a.update(r))}function Lo(t,e,i){!t||(t[e]={...t[e],...i})}function Fet(t,e,i,n,r,s,a){let o=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(t.on){case"position":case"scale":{let l=Va(t.track,i);if(!l)return;let c=Ly(l.from,l.to,l.t);return e[t.on][t.axis]=c,Lo(s,t.on,{[t.axis]:c}),void o()}case"rotation":{let l=Va(t.track,i);if(!l)return;let c=Ly(l.from,l.to,l.t);return e.rotation[t.axis]=c*Ot.DEG2RAD,Lo(s,"rotation",{[t.axis]:c}),void o()}case"shapeSize":{let l=Va(t.track,i);if(!(l&&e instanceof Ai))return;let c=Ly(l.from,l.to,l.t);return e.userData.value={...e.userData.value,[t.axis]:c},Lo(s,"shapeSize",{[t.axis]:c}),a.size=!0,a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"opacity":{let l=Va(t.track,i);if(!l||!(e instanceof Xi)||Array.isArray(e.material))return;let c=e.material.getLayersOfType("light")[0];if(c===void 0)return;let h=Ot.lerp(l.from,l.to,l.t);return e.material.transparent=!0,mU("alphaOverride",c,{alphaOverride:h},{alphaOverride:h+1},0,n.shared),s&&(s.opacity=h),void(a.render=!0)}case"material":{let l=Va(t.track,i);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:c}=t,h={};for(let u in c.data){if(!(u in l.from)||!(u in l.to))continue;let d=$T(l.from[u],l.to[u],l.t,r);if(d===void 0)continue;h[u]=d;let p=c.getValue(u);p!==void 0&&(u==="alpha"&&typeof p=="number"&&p>0&&e instanceof Xi&&!Array.isArray(e.material)&&(e.material.transparent=!0),mU(u,c,l.from,l.to,l.t,n.shared))}return Lo(s,"material",{[c.uuid]:h}),void(a.render=!0)}case"light":{let l=Va(t.track,i);if(!l||!(e instanceof Qg||e instanceof dx||e instanceof Jg))return;let c=$T(l.from,l.to,l.t,r);return e[t.field]=c,Lo(s,"light",{[t.field]:c}),void(a.render=!0)}case"camera":{let l=Va(t.track,i);if(!(l&&e instanceof vn))return;let c=Ly(l.from,l.to,l.t);return e[t.field]=c,void Lo(s,"camera",{[t.field]:c})}case"cloner":{let l=Va(t.track,i);if(!l)return;let c=e.cloner?.parameters,h=function(u,d,p,f){if(!u)return{};let g=zy(["count"],d,p,f);g.count!==void 0&&(g.count=Math.trunc(g.count));for(let[m,y]of pU){if(!u[m])continue;let v=zy(y,d[m],p[m],f);Object.keys(v).length&&(g[m]=v)}return g}(c,l.from,l.to,l.t);return function(u,d){if(u){d.count!==void 0&&(u.count=d.count);for(let[p]of pU){let f=d[p];f&&zet(u[p],f)}}}(c,h),Lo(s,"cloner",h),a.cloner=!0,a.boolean=!0,void(a.render=!0)}case"pathExtrusion":{let l=Va(t.track,i);if(!l||!Zb(e))return;let c=zy(F_,l.from,l.to,l.t),h=e.geometry.userData.parameters;return h.extrusion={...h.extrusion,...c},Lo(s,"pathExtrusion",c),e.updateGeometryInteractions({extrusion:{...h.extrusion}},n.shared),a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"pathSnapping":{let l=Va(t.track,i);if(!l)return;let c=e,h=zy(zF,l.from,l.to,l.t);return c.userData.pathSnapping={...c.userData.pathSnapping,...h},Lo(s,"pathSnapping",h),c.updatePathSnapping(c.userData.pathSnapping),void(a.render=!0)}}}function $T(t,e,i,n){if(typeof t=="string"&&n&&(t=n.color(t)),typeof e=="string"&&n&&(e=n.color(e)),typeof t=="number")return Ot.lerp(t,e,i);if(Je.is(t))return Je.lerp(t,e,i);if(Tn.is(t))return Tn.lerp(t,e,i);if(Array.isArray(t))return(t.length>e.length?e:t).map((r,s)=>{if(Array.isArray(r)){let a=t[s].length>e[s].length?e[s].length:t[s].length;return(a===4?Dg:a===3?oh:Ja).lerp(t[s],e[s],i)}return Ot.lerp(t[s],e[s],i)});if(typeof t=="object"&&t!==null){let r={};for(let s in t){let a=$T(t[s],e[s],i,n);a!==void 0&&(r[s]=a)}return r}}Yt(),et(),ya(),i3(),rl(),ii(),Li(),Yt(),Hs(),Li(),Kn(),Hs(),Kg(),qr(),Jc(),et(),Yt(),et(),t0(),Li(),ii(),Li(),et(),xh(),et();var LM=new C,gU=new xi;function Net(t,e,i,n,r){let s=[];return t.data.visible&&s.push(...function(a,o,l,c,h){let u,d,p,f,g,m,y,v,_=[];if(as(a)?(u=By("position",a,o,l,h),u&&_.push(u),p=fr("rotation",a,o,l,h),p&&_.push(p),f=By("shear",a,o,l,h),f&&_.push(f)):(v={slide:o.pathSnapping?.slide??a.updatedPathSnapping?.slide??a.dataPatched.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.updatedPathSnapping?.offset??a.dataPatched.pathSnapping?.offset??0},m=fr("slide",v,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,h),m&&_.push(m),y=fr("offset",v,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,h),y&&_.push(y),!m&&!y&&(u=dU("position",a,o,l,h),u&&_.push(u),d=dU("scale",a,o,l,h),d&&_.push(d),p=function(b,x,w,S,A){let E=x?.rotation?x.rotation.map(D=>(typeof D=="string"?Number(A.getVariable(D)??0):D)*Ot.DEG2RAD):void 0,P=w.rotation?.map(D=>(typeof D=="string"?Number(A.getVariable(D)??0):D)*Ot.DEG2RAD);if(!P)return;let T=E?new C().fromArray(E):new C().setFromEuler(b.rotation),R=new C().fromArray(P);if(T.equals(R))return;let L=LM.subVectors(R,T);if(S&&L.toArray().every(D=>Math.abs(D)<2*Math.PI)){let D=new qt().setFromEuler(gU.setFromVector3(T)),U=new qt().setFromEuler(gU.setFromVector3(R));return{update:V=>{(function(k,Y,$,nt){if(nt===0)return $.copy(k);if(nt===1)return $.copy(Y);let Q=k.w*Y.w+k.x*Y.x+k.y*Y.y+k.z*Y.z;if(Q>=1)return $.copy(k);let rt=1-Q*Q;if(rt<=Number.EPSILON){let q=1-nt;return $.w=q*k.w+nt*Y.w,$.x=q*k.x+nt*Y.x,$.y=q*k.y+nt*Y.y,$.z=q*k.z+nt*Y.z,$.normalize(),$}let gt=Math.sqrt(rt),at=Math.atan2(gt,Q),ht=Math.sin((1-nt)*at)/gt,ct=Math.sin(nt*at)/gt;$.w=k.w*ht+Y.w*ct,$.x=k.x*ht+Y.x*ct,$.y=k.y*ht+Y.y*ct,$.z=k.z*ht+Y.z*ct})(D,U,b.quaternion,V)},start:()=>{b.rotation.setFromVector3(T)},end:()=>{b.rotation.setFromVector3(R)}}}return{update:D=>{LM.lerpVectors(T,R,D),b.rotation.setFromVector3(LM)},start:()=>{b.rotation.setFromVector3(T)},end:()=>{b.rotation.setFromVector3(R)}}}(a,o,l,c,h),p&&_.push(p),g=function(b,x,w,S){let A=w[b]?w[b]:void 0,E=S[b];if(!E)return;let P=x[b],T=A?new At().fromArray(A):P.clone(),R=new C,L=new qt,D=new C;T.decompose(R,L,D);let U=new At().fromArray(E),V=new C,k=new qt,Y=new C;return U.decompose(V,k,Y),T.equals(U)?void 0:{update:$=>{cU.slerpQuaternions(L,k,$),lU.lerpVectors(R,V,$),hU.lerpVectors(D,Y,$),P.compose(lU,cU,hU)},start:()=>{P.compose(R,L,D)},end:()=>{P.compose(V,k,Y)}}}("hiddenMatrix",a,o,l),g&&_.push(g))),u||d||p||g||m||y){let b=as(a)?()=>{a.updateWorldMatrix(!0,!1,!0),a.resetBBoxNeedsUpdate()}:()=>{a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldRigid()),a.parent?.matrixWorldFusedFalse&&(a.matrixWorld.multiplyMatrices(a.parent.matrixWorldFusedFalse,a.matrix),a.matrixWorldNeedsUpdate=!1),pa(a)&&to(a.parent)&&a.invalidateDownstreamBooleanData(!0),a.updatePathSnapping(Object.assign({},o.pathSnapping,v))};_.push({update:b,start:b,end:b})}return _}(t,e,i,r,n.shared)),as(t)?s.push(...function(a,o,l,c,h){let u,d,p,f,g,m,y,v,_,b,x,w,S,A,E,P=[];if("width"in a&&(u=fr("width",a,o,l,h),u&&P.push(u)),"height"in a&&(d=fr("height",a,o,l,h),d&&P.push(d)),a instanceof Jn||a instanceof so){let T={...o.fill},R={...l.fill};T.enabled!==void 0&&T.enabled!==R.enabled&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.fill.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),p=Uy("color",a.fill,T,R,h),p&&P.push(p)}if(a instanceof Jn){let T={...o.stroke},R={...l.stroke};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.stroke.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),f=Uy("color",a.stroke,T,R,h),f&&P.push(f),g=fr("thickness",a.stroke,T,R,h),g&&P.push(g)}if(a instanceof Jn){let T={...o.dropShadow},R={...l.dropShadow};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.dropShadow.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),m=Uy("color",a.dropShadow,T,R,h),m&&P.push(m),y=fr("blurRadius",a.dropShadow,T,R,h),y&&P.push(y),_=fr("spread",a.dropShadow,T,R,h),_&&P.push(_),v=By("offset",a.dropShadow,T,R,h),v&&P.push(v)}if(a instanceof Jn){let T={...o.innerShadow},R={...l.innerShadow};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.innerShadow.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),b=Uy("color",a.innerShadow,T,R,h),b&&P.push(b),x=fr("blurRadius",a.innerShadow,T,R,h),x&&P.push(x),S=fr("spread",a.innerShadow,T,R,h),S&&P.push(S),w=By("offset",a.innerShadow,T,R,h),w&&P.push(w)}if(a instanceof Jn||a instanceof so){let T={...o.backgroundBlur},R={...l.backgroundBlur};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.backgroundBlur.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),A=fr("radius",a.backgroundBlur,T,R,h),A&&P.push(A)}if(a instanceof Jn){let T={...o.layerBlur},R={...l.layerBlur};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.layerBlur.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),E=fr("radius",a.layerBlur,T,R,h),E&&P.push(E)}if(a instanceof so||a instanceof n0){let T=XT("cornerRadius",a,o,l,h);T&&P.push(T)}return P}(t,e,i,0,n.shared)):(t.data.visible&&s.push(...function(a,o,l,c){let h=[];if(!("cloner"in l)||!a.cloner)return h;let u=a.cloner,d="cloner"in o?o.cloner:{},p=l.cloner;KE.forEach(_=>{let b;b=_==="count"?fr("count",u.parameters,d,p,c.shared,!0):Ll(_,u.parameters,d??{},p,c.shared),b&&h.push(b)});let f=function(_,b,x,w){if(_.parameters.type!=="radial")return;let S=b.radial,A=x.radial;if(!A)return;let E=_.parameters.radial,P=[];return P_.forEach(T=>{let R=Ll(T,E,S??{},A,w);R&&P.push(R)}),P}(u,d,p,c.shared);f?.length&&h.push(...f);let g=function(_,b,x,w){if(_.parameters.type!=="linear")return;let S=b.linear,A=x.linear;if(!A)return;let E=[],P=_.parameters.linear;return D_.forEach(T=>{let R=Ll(T,P,S??{},A,w);R&&E.push(R)}),E}(u,d,p,c.shared);g?.length&&h.push(...g);let m=function(_,b,x,w){if(_.parameters.type!=="grid")return;let S=b.grid,A=x.grid;if(!A)return;let E=[],P=_.parameters.grid;return R_.forEach(T=>{let R;R=T==="count"?XT(T,P,S??{},A,w,!0):Ll(T,P,S??{},A,w),R&&E.push(R)}),E}(u,d,p,c.shared);m?.length&&h.push(...m);let y=function(_,b,x,w){if(_.parameters.type!=="toObject")return;let S=b.toObject,A=x.toObject;if(!A)return;let E=[],P=_.parameters.toObject;return I_.forEach(T=>{let R;R=T==="count"?fr(T,P,S??{},A,w,!0):Ll(T,P,S??{},A,w),R&&E.push(R)}),E}(u,d,p,c.shared);y?.length&&h.push(...y);let v=function(_,b,x,w){if(!_.parameters.randomness)return;let S=b.randomnessObject,A=x.randomnessObject;if(!A)return;let E=[],P=_.parameters.randomnessObject;return O_.forEach(T=>{let R=Ll(T,P,S??{},A,w);R&&E.push(R)}),E}(u,d,p,c.shared);return v?.length&&h.push(...v),h.length&&h.push({update:()=>{u.update(c)}}),h}(t,e,i,n)),t instanceof Xi?(t instanceof Ai&&t.data.visible&&s.push(...function(a,o,l,c){let h=[];if(!("geometry"in l)||nl(a))return h;let u=a.geometry.userData.parameters,d="geometry"in o?o.geometry:{},p=l.geometry;if(a instanceof mp){let f=function(g,m,y,v){if(y.scaleBaked===void 0)return;let _=(m.scaleBaked??g.appliedGeometrySize??g.data.geometry.scaleBaked).map(w=>typeof w=="string"?Number(v.shared.getVariable(w)??0):w),b=y.scaleBaked.map(w=>typeof w=="string"?Number(v.shared.getVariable(w)??0):w);if(oh.isEqual(_,b))return;let x=[];return x.push({update:w=>{g.updateGeometryInteractions({scaleBaked:[Ot.lerp(_[0],b[0],w),Ot.lerp(_[1],b[1],w),Ot.lerp(_[2],b[2],w)]},v.shared),g.invalidateDownstreamBooleanData(),g.refreshAttachedClonersInteractions(v)},start:()=>{g.updateGeometryInteractions({scaleBaked:_},v.shared),g.invalidateDownstreamBooleanData(),g.refreshAttachedClonersInteractions(v)},end:()=>{g.updateGeometryInteractions({scaleBaked:b},v.shared),g.invalidateDownstreamBooleanData(),g.refreshAttachedClonersInteractions(v)}}),x}(a,d,p,c);f&&h.push(...f)}else{let f={},g=a.appliedGeometrySize;if(Object.assign(f,PE(u,c1),g?{width:g[0],height:g[1],depth:g[2]}:{},PE(d,c1)),c1.forEach(m=>{let y=Ll(m,f,d,p,c.shared);y&&h.push(y)}),Zb(a)){Object.assign(f,{extrusion:{...u.extrusion}});let m=function(y,v,_,b){if(!_.extrusion)return;let x=y.extrusion,w=v.extrusion??{},S=_.extrusion,A=[];return F_.forEach(E=>{let P=Ll(E,x,w,S,b);P&&A.push(P)}),A}(f,d,p,c.shared);m&&h.push(...m)}h.length&&h.push({update:m=>{a.updateGeometryInteractions(f,c.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(c)},start:m=>{a.updateGeometryInteractions(f,c.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(c)},end:m=>{a.updateGeometryInteractions(f,c.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(c)}})}return h}(t,e,i,n)),t.data.visible&&!(t instanceof Hr&&t.materialOverride)&&s.push(...function(a,o,l,c){let h=[];if(Array.isArray(a.material)){if(!("materials"in l)||!l.materials)return h;let u="materials"in o&&o.materials?o.materials:[],d=l.materials;a.material.forEach((p,f)=>{if(!d[f])return;let g=u[f]??{},m=d[f];typeof g=="string"||typeof m=="string"||h.push(...fU(p,g,m,c))})}else{if(!("material"in l)||!l.material)return h;let u="material"in o&&o.material?o.material:{},d=l.material;if(typeof u=="string"||typeof d=="string")return h;h.push(...fU(a.material,u,d,c))}return h}(t,e,i,n.shared))):ob.is(t)?t.data.visible&&s.push(...function(a,o,l,c){let h=[];if(l.intensity!==void 0){let u=fr("intensity",a,o,l,c);u&&h.push(u)}if(l.color!==void 0){let u=function(d,p,f,g,m){let y=f[d]?f[d]:void 0,v=g[d];if(!v)return;let _=p[d],b=y?typeof y=="string"?m.getColor(y).clone():new Jt().setRGB(y.r,y.g,y.b):_.clone(),x=typeof v=="string"?m.getColor(v).clone():new Jt().setRGB(v.r,v.g,v.b);if(b.equals(x))return;let w=_.clone();return{update:S=>{w.lerpColors(b,x,S),p[d]?.copy?.(w)},start:()=>{w.copy(b)},end:()=>{w.copy(x)}}}("color",a,o,l,c);u&&h.push(u)}return h}(t,e,i,n.shared)):t instanceof vn&&s.push(...function(a,o,l,c){let h=[],u=a.cameraType==="OrthographicCamera"?o.orthographic?.zoom:o.perspective?.zoom,d=a.cameraType==="OrthographicCamera"?l.orthographic?.zoom:l.perspective?.zoom;if(d!==void 0){let p=u??a.zoom,f=d;p!==f&&h.push({update:g=>{a.zoom=Ot.lerp(p,f,g),a.updateProjectionMatrix()},start:()=>{a.zoom=p,a.updateProjectionMatrix()},end:()=>{a.zoom=f,a.updateProjectionMatrix()}})}if(l.targetOffset!==void 0){let p=fr("targetOffset",a,o,l,c);p&&h.push(p)}return h}(t,e,i,n.shared))),s.length?{update:a=>{s.forEach(o=>o.update(a))},start:a=>{s.forEach(o=>o.start?.(a))},end:a=>{s.forEach(o=>o.end?.(a))}}:void 0}var Sj={type:"beginState"};function Mj(t){if(t.easing===5){let{control1:e,control2:i}=t;return{easing:5,control1:e??up.defaultData.control1,control2:i??up.defaultData.control2}}if(t.easing===6){let{mass:e,stiffness:i,damping:n,velocity:r}=t;return{easing:6,mass:e??Yl.defaultData.mass,stiffness:i??Yl.defaultData.stiffness,damping:n??Yl.defaultData.damping,velocity:r??Yl.defaultData.velocity}}return{easing:t.easing}}function Ej(t){return{delay:t.delay,delayDirection:t.delayDirection??"start-end",direction:t.direction??"normal",repeat:t.repeat}}var Aj={type:"completeState",isfromEntity:!1};function I1(t,e){let i,n;if(typeof e=="string"?(i=e,n=t.states?.[i]):e===null&&(i=null,n=t.data),i!==void 0&&n!==void 0)return{id:i,data:n}}var YT=class{constructor(t,e,i,n,r,s,a,o={}){this.object=t,this.fromRef=e,this.toRef=i,this.data=n,this.sharedAssets=r,this.allowSlerp=s,this.page=a,this.hooks=o,this.builtReversed=!1,this.startStateId=null,this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=as(this.object)?null:this.object.transitionState.state,this.callback=Net(this.object,{},this.end.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)},this.onChange=l=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(l),this.object.requestRender()),this.writeState(l)},this.runner=new mj(function(l){return{duration:l.duration,ease:Mj(l),...Ej(l)}}(n),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let n=I1(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=I1(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(e===void 0)throw new Error("Missing property");let i=I1(this.object,e);if(!i)throw new Error("Missing property");this.to=i,this.buildCallback()}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||as(this.object))return;let e=t===1,i=t>.5?this.targetStateId:this.startStateId,n=this.object.transitionState;n.settled===e&&n.state===i||(this.object.transitionState={settled:e,state:i},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=i,this.object.dispatchEvent({type:"transitionState",settled:e,state:i}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:i}),this.object.traverseEntity(r=>{r!==this.object&&r instanceof vn&&r.dispatchEvent(e?Aj:Sj)}),e?this.hooks.onComplete?.(i):this.hooks.onBegin?.(i))}};Hs();var ZT=new Map,vg=new Map,na=class extends Vn{constructor(t,e,i,n,r,s,a){super(),this.id=t,this.data=e,this.scene=i,this.sharedAssets=n,this.object=r,this.eventType=s,this.actionCondition=a,this.evaluators=[],this.elapsed=0,this.lastTime=null,this.direction=1,this._playing=!1,this._finished=!1,this.hasPlayedOnce=!1,this.pauseOnNextCycleEnd=!1,this.lastCycleIndex=0;try{let o=Gc.findTimeline(this.scene.data.objects,this.data.timeline),l=o.duration;this.animatedObjectIds=Object.keys(o.objectTimelines),this.animatedObjectIds.forEach(c=>{let h=this.scene.find(c);if(!h)return;let u=o.objectTimelines[c];!u||this.evaluators.push(function(d,p,f,g,m){let y=function(v,_){let b=[];return Lc.groupKeyframes(_.keyframes).forEach(x=>{let w=x.path?.[0],S=x.path[1],A=()=>uu(x.keyframes,E=>E.value);switch(w){case"position":case"rotation":case"scale":return void(S&&Ig.includes(S)&&b.push({on:w,axis:S,track:A()}));case"shape size":return void(S&&Ig.includes(S)&&"geometry"in v&&b.push({on:"shapeSize",axis:S,track:A()}));case"path extrusion":return void(Zb(v)&&b.push({on:"pathExtrusion",track:uu(x.keyframes,E=>E.value)}));case"path snapping":return void(v.data.pathSnapping&&b.push({on:"pathSnapping",track:uu(x.keyframes,E=>E.value)}));case"material":return void(v.type==="Mesh"&&"material"in v&&function(E,P){let T=Pk(E.material)?E.material:void 0,R=P.layerId;if(!T||!R)return[];let L=P.keyframes.some($=>fp($.data.value?.noiseStrength)),D=T.ensureRainbowNoiseCompiled,U=$=>{L&&typeof D=="function"&&D.call(T,$)},V=$=>"data"in $?[{on:"material",layer:$,track:uu(P.keyframes,nt=>nt.value)}]:[];U(R);let k=T.getLayerByUuid(R);if(k)return V(k);let Y=P.path[1];for(let $ of T.getLayersOfType(Y))U($.uuid);return(T.getLayersOfType(Y)??[]).flatMap(V)}(v,x).forEach(E=>b.push(E)));case"opacity":return void(v.type==="Mesh"&&"material"in v&&b.push({on:"opacity",track:A()}));case"cloner":return void b.push({on:"cloner",track:uu(x.keyframes,E=>E.value)});case"camera":return void(v instanceof vn&&b.push({on:"camera",field:"zoom",track:A()}));case"light":return void((v instanceof Qg||v instanceof dx||v instanceof Jg)&&b.push({on:"light",field:x.path[1],track:uu(x.keyframes,E=>E.value)}))}}),b}(d,p);return{duration:f,evaluate(v,_){d.resetBBoxNeedsUpdate();let b={transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1};for(let x of y)Fet(x,d,v,g,m,_,b);(function(x,w,S){if(w.size&&x instanceof Ai){let{x:A,y:E,z:P}=x.userData.value;x.updateGeometryInteractions({width:A,height:E,depth:P},S.shared)}w.cloner&&x.cloner?.update(S),w.transform&&x.updateMatrix(),w.bounds&&x.resetBBoxNeedsUpdate(),w.boolean&&x instanceof Ai&&x.invalidateDownstreamBooleanData(),w.render&&x.dispatchEvent({type:"requestRender"})})(d,b,g)},invalidate(){for(let v of y)Uet(v.track)}}}(h,{...u},l,{scene:i,shared:n},this.sharedAssets))}),this.schedule=new Stt(function(c,h){return{duration:h,delay:pr(c.delay/1e3),delayDirection:c.delayDirection??"start-end",direction:c.direction??"normal",repeat:c.repeat}}(this.data,l))}catch{throw new Error("Missing property")}r&&(vg.has(r.uuid)?vg.get(r.uuid).push(this):vg.set(r.uuid,[this])),ZT.set(t,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(t){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(t-this.lastTime)*this.direction)),this.lastTime=t,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0)return void this.pause();let t=this.schedule.resolve(this.elapsed);if(t){if(t.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=t.cycleIndex,this.pauseOnNextCycleEnd))return this.pauseOnNextCycleEnd=!1,void this.pause();for(let e of this.evaluators)e.evaluate(t.localTime)}else this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(t=>{let e=this.scene.find(t);e instanceof vn&&e.dispatchEvent(Aj)})}startTicking(){this._playing=!0,this.lastTime=null;for(let t of this.evaluators)t.invalidate();Ji.add(this)}play(){let t=this.eventType!==void 0&&GE(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&GE(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!t||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(e=>{let i=this.scene.find(e);i instanceof vn&&i.dispatchEvent(Sj)}),!t&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,Ji.remove(this)}stop(){this.pause(),this.elapsed=0,this.lastCycleIndex=0,this.applyAtElapsed(),this._finished=!1}seek(t){let e=this.schedule.totalDuration;this.elapsed=t*(Number.isFinite(e)?e:this.schedule.effectiveCycleDuration);for(let i of this.evaluators)i.invalidate();this.applyAtElapsed()}toggle(t){let e=t??this.direction===-1;this._playing&&this.direction===(e?1:-1)||(e&&this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=e?1:-1,this.pauseOnNextCycleEnd=!1,this.startTicking())}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},ket=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>{i[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(i=>{i[this.data.interaction]()}))}getTimelineActions(t){let e=ZT.get(t);return e?[e]:[...ZT.values()].filter(i=>i.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=vg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllTimelines(){let t=[...vg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Vet=class{constructor(t,e,i,n,r,s,a){this.data=e;let o="interaction"in e?e.interaction:"play";if(o==="play"||o===void 0)this.interaction=new na(t,e,i,n,r,s,a);else{if(o!=="pause"&&o!=="stop")throw new Error("Missing property");this.interaction=new ket(e)}}get playing(){return this.interaction instanceof na&&this.interaction.playing}get finished(){return!(this.interaction instanceof na)||this.interaction.finished}get paused(){return!(this.interaction instanceof na)||this.interaction.paused}play(){if(this.interaction instanceof na)return this.interaction.play();this.interaction.dispatch()}stop(){this.interaction instanceof na&&this.interaction.stop()}seek(t){this.interaction instanceof na&&this.interaction.seek(t)}toggle(t){this.interaction instanceof na?this.interaction.toggle(t):this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof na?this.interaction.playFromCurrent():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof na?Ti(this.interaction.sharedAssets,this.interaction.actionCondition)&&this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof na&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};function jet(t){let e=t.tweens[0]?.data;return{delay:e?.delay??t.delay,delayDirection:e?.delayDirection??"start-once",direction:e?.direction??t.direction,repeat:e?.repeat??t.repeat}}ke(),Pr("TimelineAnimation",({id:t,data:e,page:i,shared:n,object:r,eventType:s,actionCondition:a})=>new Vet(t,e,i.scene,n,r,s,a)),Si("timeline"),Li(),Yt(),et(),Hs();var Get={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},Het=class extends Vn{constructor(t,e,i,n,r,s){if(super(),this.eventType=t,this.data=e,this.page=i,this.shared=n,this.condition=r,this.runModeOverride=s,this.tweens=[],this.hasPlayedOnce=!1,!e.object)throw new Error("Missing property");let a=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,e.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}get contested(){let t=this.object.previousAction;return t!==null&&t!==this&&t.animating}init(){this.initialCurrentState=I1(this.object,this.object.currentState).id,this.build()}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:GE(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}build(){let t=this.data.tweens,e=[];try{let i=t[0].data.state;i!==void 0&&e.push(new YT(this.object,i,i,Get,this.shared,this.data.allowSlerp??!1,this.page));for(let n=1;n<t.length;n++){let r=t[n-1],s=t[n];e.push(new YT(this.object,r.data.state===void 0?this.currentState:r.data.state,s.data.state===void 0?this.currentState:s.data.state,s.data,this.shared,this.data.allowSlerp??!1,this.page))}}catch(i){return void(i instanceof Error&&console.error(i.message))}this.tweens=e,this.runner=new fj({...Ej(jet(this.data)),runMode:this.runMode},e.map(i=>i.runner),{claim:()=>this.claimObject(),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(){return this.object.previousAction!==this&&(this.object.previousAction?.animating===!0&&this.object.previousAction.pause(),this.object.previousAction=this,!0)}rebindTweens(){for(let t of this.tweens)try{t.rebind()}catch(e){e instanceof Error&&console.error(e.message)}this.object instanceof vn&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ji.remove(this)}play(){if(Ti(this.shared,this.condition)===!1||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(Ji.time),this.runner.isPlaying&&Ji.add(this))}pause(){this.runner?.stop(),Ji.remove(this)}stop(){this.pause();let t=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;as(this.object)?this.object.changeSelectedState(t,{shared:this.shared}):this.object.changeSelectedState(t,{scene:this.page.scene,shared:this.shared}),this.object.currentState=t}seek(t){if(Ti(this.shared,this.condition)===!1)return!1;this.runner?.seek(t)}playDirected(t){if(Ti(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(Ji.time,t),this.runner.isPlaying&&Ji.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};function Tj(t){let e=t?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(e?.length){let i=function(n){if(!n||n.length===0)return;let r;for(let s of n)s==s&&(r===void 0||s>r)&&(r=s);return r}(e);return i&&i>2?i:2}return 2}et(),ii();var Wet=class extends Vn{constructor(t,e,i,n,r){super(),this.data=t,this.page=e,this.animationControls=i,this.shared=n,this.condition=r,this.startOnceDelay=0,this.toggleIsForward=!1;let s=t.object,a=e.scene.find(t.object);a&&Array.isArray(a.identity)&&(s=a.identity[0]),this.data={...t,object:s};let o=this.animationControls.clipIdToAction[t.clipId+"/"+s];if(this.duration=o?.getClip()?.duration??1,this.data.crop2){let l=Tj(o?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=o?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=t.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(t=!1){if(Ti(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let e=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,n])=>{let r=i.split("/")[1];this.threeAnimAction!==n&&r===e&&(t?n.fadeOut(.2):n.stop())}),t&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(t){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Ot.clamp(this.threeAnimAction.time+1/60*t,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(t,e=!1){if(Ti(this.shared,this.condition)===!1)return!1;this.toggleIsForward=t??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([n,r])=>{let s=n.split("/")[1];this.threeAnimAction!==r&&s===i&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();t&&(t.duration=this.duration),this.pause()}},Cj=null;ke(),Cj=YT,Pr("Transition",({eventType:t,data:e,page:i,shared:n,actionCondition:r,runModeOverride:s})=>new Het(t,e,i,n,r,s)),Pr("Animation",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Wet(t,e,i.animationControls,n,r)),Si("transitions"),ii();var vU=(t,e)=>e.some(i=>i instanceof RegExp?i.test(t):i===t),qet=class{constructor({url:t,context:e},i,n,r){if(this.controlsManager=i,this.shared=n,this.condition=r,!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:function(s,a){if(a={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...a},s=s.trim(),/^data:/i.test(s))return((h,{stripHash:u})=>{let d=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(h);if(!d)throw new Error(`Invalid URL: ${h}`);let{type:p,data:f,hash:g}=d.groups,m=p.split(";");g=u?"":g;let y=!1;m[m.length-1]==="base64"&&(m.pop(),y=!0);let v=(m.shift()||"").toLowerCase(),_=[...m.map(b=>{let[x,w=""]=b.split("=").map(S=>S.trim());return x==="charset"&&(w=w.toLowerCase(),w==="us-ascii")?"":`${x}${w?`=${w}`:""}`}).filter(Boolean)];return y&&_.push("base64"),(_.length>0||v&&v!=="text/plain")&&_.unshift(v),`data:${_.join(";")},${y?f.trim():f}${g?`#${g}`:""}`})(s,a);if(/^view-source:/i.test(s))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let o=s.startsWith("//");!o&&/^\.*\//.test(s)||(s=s.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,a.defaultProtocol));let l=new URL(s);if(a.forceHttp&&a.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(a.forceHttp&&l.protocol==="https:"&&(l.protocol="http:"),a.forceHttps&&l.protocol==="http:"&&(l.protocol="https:"),a.stripAuthentication&&(l.username="",l.password=""),a.stripHash?l.hash="":a.stripTextFragment&&(l.hash=l.hash.replace(/#?:~:text.*?$/i,"")),l.pathname){let h=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,u=0,d="";for(;;){let p=h.exec(l.pathname);if(!p)break;let f=p[0],g=p.index;d+=l.pathname.slice(u,g).replace(/\/{2,}/g,"/"),d+=f,u=g+f.length}d+=l.pathname.slice(u,l.pathname.length).replace(/\/{2,}/g,"/"),l.pathname=d}if(l.pathname)try{l.pathname=decodeURI(l.pathname)}catch{}if(a.removeDirectoryIndex===!0&&(a.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(a.removeDirectoryIndex)&&a.removeDirectoryIndex.length>0){let h=l.pathname.split("/"),u=h[h.length-1];vU(u,a.removeDirectoryIndex)&&(h=h.slice(0,-1),l.pathname=h.slice(1).join("/")+"/")}if(l.hostname&&(l.hostname=l.hostname.replace(/\.$/,""),a.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(l.hostname)&&(l.hostname=l.hostname.replace(/^www\./,""))),Array.isArray(a.removeQueryParameters))for(let h of[...l.searchParams.keys()])vU(h,a.removeQueryParameters)&&l.searchParams.delete(h);if(a.removeQueryParameters===!0&&(l.search=""),a.sortQueryParameters){l.searchParams.sort();try{l.search=decodeURIComponent(l.search)}catch{}}a.removeTrailingSlash&&(l.pathname=l.pathname.replace(/\/$/,""));let c=s;return s=l.toString(),!a.removeSingleSlash&&l.pathname==="/"&&!c.endsWith("/")&&l.hash===""&&(s=s.replace(/\/$/,"")),(a.removeTrailingSlash||l.pathname==="/")&&l.hash===""&&a.removeSingleSlash&&(s=s.replace(/\/$/,"")),o&&!a.normalizeProtocol&&(s=s.replace(/^http:\/\//,"//")),a.stripProtocol&&(s=s.replace(/^(?:https?:)?\/\//,"")),s}(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;Xc?window.location.assign(this.url):(this.context==="tab"||oF&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(ae[0]),ae.splice(0,ae.length))}},Xet=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.shared=i,this.eventManager=n,this.condition=r}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),W3(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},1e3*(this.data.delay??0))}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};et();var $et={type:"beginState"},yU={type:"completeState",isfromEntity:!1},_U={type:"requestRender"},Yet=class extends Vn{constructor(t,e,i,n){super(),this.data=t,this.page=e,this.shared=i,this.condition=n,this.toggleIsForward=!1,this.posStart=new C,this.posEnd=new C,this.qStart=new qt,this.qEnd=new qt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(t=!1){if(!this.data.animate)return;let e=this.page.scene.find(this.data.targetCamera);if(!e||!e.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let i={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:Mj(this.data)},n=r=>{let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,r),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,r),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*r,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(_U),r===1&&s.dispatchEvent(yU)};this.runner=new mj(i,n,()=>{this.data.runMode!=="Toggle"||this.toggleIsForward?(this.posEnd.copy(e.position),this.qEnd.copy(e.quaternion),this.zoomEnd=e.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(e.uuid)):this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)),this.page.activeCamera.dispatchEvent($et),n(0)})}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ji.remove(this)}start(){!this.runner||(this.runner.start(Ji.time),Ji.add(this))}switchCamera(t){let e=this.page.activeCamera,i=this.page.scene.find(t);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),e.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Ti(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.start()):this.switchCamera(this.data.targetCamera)},1e3*this.data.delay)}catch{}}pause(){this.runner?.stop(),Ji.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(t){if(Ti(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,t!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=t??!this.toggleIsForward,this.buildAnimation(!0),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=t??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(),this.start()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(yU),this.page.activeCamera.dispatchEvent(_U))},1e3*this.data.delay)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};a3();var Zet=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(t=>{this.shared.getVariable(t);let e=this.shared.data.variables.data(t)?.value;e!==void 0&&this.shared.updateVariable(t,e),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(qA(t))})}dispose(){}};ke(),Pr("Link",({data:t,eventManager:e,shared:i,actionCondition:n})=>new qet(t,e.controlsManager,i,n)),Pr("Reset",({data:t,page:e,shared:i,eventManager:n,actionCondition:r})=>new Xet(t,e,i,n,r)),Pr("SwitchCamera",({data:t,page:e,shared:i,actionCondition:n})=>new Yet(t,e,i,n)),Pr("ClearLocalStorage",({data:t,page:e,shared:i,actionCondition:n})=>new Zet(t,e,i,n)),Si("misc-actions"),ke(),qr(),ol(),v3(),a3();var Nu,BM,Ket=class{get sharedAssets(){return this.shared}constructor(t,e={},i=!0){this.shared=new ab(t.shared,e,!0,i),this.scene=new ux(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof un&&!t.uiScene&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.scene.releaseInstanceGroups(),this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Ai&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};function bU(t){return BM||(BM=Promise.resolve().then(()=>(aY(),r6)).then(({DRACOLoader:e})=>((Nu=new e).setDecoderPath(t!==void 0?`${t}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload(),Nu.decoderPending))),BM}async function Qet(t){if(Nu){let e,i={attributeIDs:Nu.defaultAttributeIDs,attributeTypes:Nu.defaultAttributeTypes,useUniqueIDs:!1};try{e=await Nu.decodeGeometry(new Int8Array(t).buffer,i)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function xU(t){for(let e of t){let i=await Qet(e.geometry.data.draco);if(i){let n=e.geometry.data;i.index&&(n.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let r={};i.attributes.forEach(({name:s,array:a,itemSize:o})=>{r[s]={array:a,itemSize:o,type:"Float32Array",normalized:!1}}),n.attributes=r,n.draco=void 0}}}function Jet(t){let e=this._clip.duration,i=this._clip.start??0,n=this.loop,r=this.time+t,s=this._loopCount,a=n===p_;if(t===0)return s===-1||!a||1&~s?r:e-(r-i);if(n===QM){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=e||r<i){let o=Math.floor((r-i)/(e-i));r-=(e-i)*o,s+=Math.abs(o);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a||(r=t>0?e:i,this.repetitions===1&&(r=e)),this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&!(1&~s))return e-(r-i)}return r}v3(),Ye(),ex(),Zg(),t0(),$C(),xh(),rx(),Jk(),n6(),ya(),et(),et();var wU=!1,tit=class{constructor(t,e,i,n){this.scene=t,this.requestRender=e,this.updateDisplayProgress=i,this.animationInspectorState=n,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=r=>{r.data.type==="Empty"&&Array.isArray(r.data.animations)&&r.data.animations.forEach((s,a)=>{let o=s[0]+"/";if(Array.isArray(r.identity)?o+=r.identity[0]:o+=r.uuid,this.clipIdToAction[o])return;let l=n1.parse(JSON.parse(s[2]));r.animations[a]=l;let c=this.mixer.clipAction(l,r);wU===!1&&(Object.getPrototypeOf(c)._updateTime=Jet,wU=!0),c.clampWhenFinished=!0,this.clipIdToAction[o]=c})},this.mixer=new Rz(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let i=this.scene.find(e);if(!i)return;let n=i.animations.find(s=>s.uuid===t);if(!n)return;let r=this.clipIdToAction[t];!r||(r.stop(),this.mixer.uncacheClip(n),delete this.clipIdToAction[t],i.animations=i.animations.filter(s=>s.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.scene.markShadowsDirty(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=JM}),this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,i=this.clipIdToAction[e];if(i)return t&&(t.repeat>=0&&(i.repetitions=t.repeat+1),(t.direction==="pingpong"||t.direction==="pingpong-rewind")&&t.repeat!==0&&(i.loop=p_)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.scene.markShadowsDirty(),this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return Tj(this.activeClip??void 0)}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let i=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(t/(this.maxFrames-1),.9999)*this.activeClip.duration),this.scene.markShadowsDirty(),this.requestRender(),i&&(this.clipIdToAction[e].paused=!0)}};al(),ol(),NN(),Jc(),Kg(),LN(),o6();var eit={bloom:()=>Promise.resolve().then(()=>(uY(),dY)),chromaticAberration:()=>Promise.resolve().then(()=>(mY(),fY)),vignette:()=>Promise.resolve().then(()=>(yY(),vY)),noise:()=>Promise.resolve().then(()=>(xY(),bY)),hueSaturation:()=>Promise.resolve().then(()=>(MY(),SY)),brightnessContrast:()=>Promise.resolve().then(()=>(TY(),AY)),depthOfField:()=>Promise.resolve().then(()=>(DY(),PY)),pixelation:()=>Promise.resolve().then(()=>(OY(),IY))};function iit(t){return function(e,i){return Promise.all(e.map(n=>i[n]?.().catch(r=>{console.warn(`[spline] Failed to load the ${n} postprocessing effect (webgl); the effect will be skipped.`,r)}))).then(()=>{})}(t,eit)}ii();var nit=vp(LY(),1);function Fy(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function rit(t){return{id:t.uuid,name:t.name,type:t.object.data?.type??t.object.type,visible:t.playModeVisible!==!1,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ot.RAD2DEG,y:t.rotation.y*Ot.RAD2DEG,z:t.rotation.z*Ot.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},spawned:!0}}function Ny(t){return{id:t.uuid,name:t.name,type:t.type??"Object",visible:t.visible,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ot.RAD2DEG,y:t.rotation.y*Ot.RAD2DEG,z:t.rotation.z*Ot.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}}function Pj(t,e,i){let n=a=>t.findObjectById(a)??t.findObjectByName(a),r=new Map,s=a=>{let o=r.get(a);if(o)return o;for(let l of r.values())if(l.name===a)return l};return{setVariable:(a,o)=>a in t.getVariables()?(t.setVariable(a,o),{ok:!0}):{ok:!1,warning:`spline.setVariable: no variable named "${a}" in this scene.`},getVariable:a=>t.getVariable(a),getVariables:()=>t.getVariables(),getAllObjects:()=>t.getAllObjects().map(Ny),findObject:a=>{let o=n(a);return o?Ny(o):void 0},getGeometry:(a,o)=>{if(!i)return{warning:"spline.getGeometry: not available in this runtime integration."};let l=s(a),c=l?l.object:(()=>{let p=n(a);return p?i.findEntity(p.uuid):void 0})();if(!c)return{warning:`spline.getGeometry: no object named "${a}" (names/ids come from getAllObjects).`};let h,u=l??c;o.space==="world"&&(u.updateWorldMatrix?.(!0,!1),h=u.matrixWorld?.elements);let d=function(p,f){let g=p?.getAttribute("position");if(!g||!g.count)return null;let m=g.count,y=f??null,v=p.getIndex?.()??null,_=Math.floor((v?v.count:m)/3),b=1/0,x=1/0,w=1/0,S=-1/0,A=-1/0,E=-1/0,P=new Float32Array(3*m);for(let D=0;D<m;D++){let U=g.getX(D),V=g.getY(D),k=g.getZ(D);y&&([U,V,k]=lX(y,U,V,k)),U<b&&(b=U),V<x&&(x=V),k<w&&(w=k),U>S&&(S=U),V>A&&(A=V),k>E&&(E=k),P[3*D]=U,P[3*D+1]=V,P[3*D+2]=k}let T={space:y?"world":"local",vertexCount:m,triangleCount:_,indexed:v!==null,bounds:{min:[b,x,w],max:[S,A,E],size:[S-b,A-x,E-w]},vertices:P};if(v){let D=new Uint32Array(v.count);for(let U=0;U<v.count;U++)D[U]=v.getX(U);T.indices=D}let R=p.getAttribute("normal");if(R&&R.count===m){let D=y?function(U){let V=U[0],k=U[4],Y=U[8],$=U[1],nt=U[5],Q=U[9],rt=U[2],gt=U[6],at=U[10],ht=V*(nt*at-Q*gt)-k*($*at-Q*rt)+Y*($*gt-nt*rt);if(!isFinite(ht)||Math.abs(ht)<1e-12)return null;let ct=1/ht,q=[(nt*at-Q*gt)*ct,(Y*gt-k*at)*ct,(k*Q-Y*nt)*ct,(Q*rt-$*at)*ct,(V*at-Y*rt)*ct,(Y*$-V*Q)*ct,($*gt-nt*rt)*ct,(k*rt-V*gt)*ct,(V*nt-k*$)*ct];return[q[0],q[3],q[6],q[1],q[4],q[7],q[2],q[5],q[8]]}(y):void 0;if(!y||D){let U=new Float32Array(3*m);for(let V=0;V<m;V++){let k=R.getX(V),Y=R.getY(V),$=R.getZ(V);if(D){let nt=D[0]*k+D[1]*Y+D[2]*$,Q=D[3]*k+D[4]*Y+D[5]*$,rt=D[6]*k+D[7]*Y+D[8]*$,gt=Math.hypot(nt,Q,rt);gt>1e-12?(k=nt/gt,Y=Q/gt,$=rt/gt):(k=nt,Y=Q,$=rt)}U[3*V]=k,U[3*V+1]=Y,U[3*V+2]=$}T.normals=U}}let L=p.getAttribute("uv");if(L&&L.count===m){let D=new Float32Array(2*m);for(let U=0;U<m;U++)D[2*U]=L.getX(U),D[2*U+1]=L.getY(U);T.uvs=D}return T}(c.geometry,h);return d?{data:{id:u.uuid,name:u.name,geometry:c.data?.geometry?.type,...d}}:{warning:`spline.getGeometry: "${u.name}" has no readable geometry \u2014 only meshes do (lights, cameras and groups have none; read a group's child meshes instead).`}},updateObject:(a,o)=>{let l=s(a);if(l){let{position:m,rotation:y,scale:v,visible:_}=o;return m&&(typeof m.x=="number"&&(l.position.x=m.x),typeof m.y=="number"&&(l.position.y=m.y),typeof m.z=="number"&&(l.position.z=m.z)),y&&(typeof y.x=="number"&&(l.rotation.x=y.x*Ot.DEG2RAD),typeof y.y=="number"&&(l.rotation.y=y.y*Ot.DEG2RAD),typeof y.z=="number"&&(l.rotation.z=y.z*Ot.DEG2RAD)),v&&(typeof v.x=="number"&&(l.scale.x=v.x),typeof v.y=="number"&&(l.scale.y=v.y),typeof v.z=="number"&&(l.scale.z=v.z)),typeof _=="boolean"&&(l.playModeVisible=_),l.updateMatrix(),t.requestRender(),!0}let c=n(a);if(!c)return!1;let{position:h,rotation:u,scale:d,visible:p,geometry:f,material:g}=o;if(f&&typeof f=="object"&&i){let m=i.findEntity(c.uuid);if(m){let{vertices:y,normals:v,uvs:_,indices:b,...x}=f;Fy(y)&&i.shared.updateEntityGeometryVertices(m,{vertices:y,normals:Fy(v)?v:void 0,uvs:Fy(_)?_:void 0,indices:Fy(b)?b:void 0}),Object.keys(x).length>0&&i.shared.updateEntityGeometryParams(m,x)}}if(g&&typeof g=="object"&&i){let m=i.findEntity(c.uuid);m&&i.shared.updateEntityMaterialParams(m,g)}return h&&(typeof h.x=="number"&&(c.position.x=h.x),typeof h.y=="number"&&(c.position.y=h.y),typeof h.z=="number"&&(c.position.z=h.z)),u&&(typeof u.x=="number"&&(c.rotation.x=u.x*Ot.DEG2RAD),typeof u.y=="number"&&(c.rotation.y=u.y*Ot.DEG2RAD),typeof u.z=="number"&&(c.rotation.z=u.z*Ot.DEG2RAD)),d&&(typeof d.x=="number"&&(c.scale.x=d.x),typeof d.y=="number"&&(c.scale.y=d.y),typeof d.z=="number"&&(c.scale.z=d.z)),typeof p=="boolean"&&(c.visible=p),t.requestRender(),!0},createObject:async(a,o)=>Ny(await t.createObject(a,o)),createCustomMaterial:a=>t.createCustomMaterial(a),setMaterial:(a,o)=>t.setMaterial(a,o),cloneObject:(a,o)=>Ny(t.cloneObject(a,o)),removeObject:a=>t.removeObject(a),spawnObject:(a,o)=>{if(!i)return{warning:"spline.spawnObject: not available in this runtime integration."};let l=n(a),c=l?i.findEntity(l.uuid):void 0;if(!c)return{warning:`spline.spawnObject: no object named "${a}" to use as a template.`};if(r.size>=500)return{warning:"spline.spawnObject: spawn budget reached (500 live copies) \u2014 destroyObject old copies (or reuse them) instead of spawning more."};let h=i.shared.spawnRuntimeClone(c,o??{});return h?(r.set(h.uuid,h),t.requestRender(),{object:rit(h)}):{warning:`spline.spawnObject: "${a}" cannot be spawned from.`}},destroyObject:a=>{let o=s(a);return!(!i||!o||(r.delete(o.uuid),i.shared.destroyRuntimeClone(o),t.requestRender(),0))},setInstanceTransforms:(a,o)=>{if(!i)return-1;let l=n(a),c=l?i.findEntity(l.uuid):void 0;if(!c)return-1;let h=i.shared.setEntityInstanceTransforms(c,o);return h>=0&&t.requestRender(),h},emitEvent:(a,o,l)=>{let c=n(o);return c?(l?c.emitEventReverse(a):c.emitEvent(a),{ok:!0}):{ok:!1,warning:`spline.emitEvent: no object named "${o}".`}},requestRender:()=>t.requestRender(),addSplineEventListener:(a,o)=>{let l=c=>{o({target:{id:c.target?.id??"",name:c.target?.name??""}})};return t.addEventListener(a,l),()=>t.removeEventListener(a,l)},getCanvas:()=>e}}et(),ii();var Dj=class{constructor(t,e,i){this.iframe=t,this.bridge=e,this.observer=i}static mount(t,e,i,n){if(typeof document>"u")return null;let r=e.parentElement;if(!r)return null;getComputedStyle(r).position==="static"&&(r.style.position="relative");let s=document.createElement("iframe");s.setAttribute("sandbox","allow-scripts allow-forms allow-pointer-lock"),s.title="Spline HTML content";let a=s.style;a.position="absolute",a.border="0",a.background="transparent",a.pointerEvents="auto",a.colorScheme="normal";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(r),s.srcdoc=function(h){let u=`<script>${cF}<\/script>`,d=/<head(\s[^>]*)?>/i.exec(h);if(d){let f=d.index+d[0].length;return h.slice(0,f)+u+h.slice(f)}let p=/<html(\s[^>]*)?>/i.exec(h);if(p){let f=p.index+p[0].length;return h.slice(0,f)+`<head>${u}</head>`+h.slice(f)}return u+h}(i),r.insertBefore(s,e.nextSibling);let c=new uF(s,Pj(t,e,n),(h,u)=>{h==="warn"?console.warn(`[spline html] ${u}`):h==="error"&&console.error(`[spline html] ${u}`)});return c.attach(),new Dj(s,c,l)}dispose(){this.bridge.dispose(),this.observer.disconnect(),this.iframe.remove()}};ii();var O1="data-spline-html-content",sit=`
9930
+ `&&r--,this.htmlInput.setSelectionRange(Math.min(t,r),Math.max(t,r))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof H3)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,n=i[t],r=e+1,s=e;n[e]!==" "&&(r=this.findNextCharOccurence(n,e,"forward"," "),s=this.findNextCharOccurence(n,e,"backward"," "),s>0&&s++,r>=n.length-1&&t===i.length-1&&r++);let a=this.helper,o=a.getGlobalIndexFromLineAndCharIndexes(i,t,s),l=a.getGlobalIndexFromLineAndCharIndexes(i,t,r);this.setInputSelection(o,l)}findNextCharOccurence(t,e,i,n=" "){let r=Math.max(0,t.length-1),s=i==="forward"?r:0,a=i==="forward"?1:-1,o=Math.max(Math.min(e,r),0);for(;o!==s;)if(o+=a,t.charAt(o)===n)return o;return s}getPointOnPlane(){let t=this.virtualInput?.data;if(this.virtualInput&&t&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new C);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let i=typeof t.geometry.width=="number"?t.geometry.width:1,n=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+.5*i,e.y-.5*n)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(eU.getNormalMatrix(this.virtualInput.matrixWorld),JB.copy(wet).applyMatrix3(eU).normalize(),this.virtualInput.localToWorld(tU.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(JB,tU))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),Xc&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=function(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}(t.geometry.horizontalAlign))}},_j=(t,e)=>{if(typeof t=="string"){let i=e.data(t);if(i)return _j(i.value,e)}return _r.getDisplayedValue(t)};function iU(t,e){let i=t.text,n="";if(typeof i=="string"){let r=e.variables.data(n);r&&(n=_j(r.value,e.variables))}else n=i.textValue.toString();return n}var Eet=class extends Or{constructor(t,e){super(t),this.eventManager=e,this._textInputs=[],this.sceneHelpers=new rs,this.helper=new yj,this._onMouseDownFocusIn=i=>{if(ae.length>1)return;this.eventContext.updateRaycaster(i);let n=null;if(this.eventContext.raycaster){for(let r of this._textInputs)if(this.eventContext.raycaster.intersectObject(r,!0).length>0){n=r;break}}this.focusOnTextInput(n),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let n=this.textInputManager.htmlInput;this.helper.hide(),n?.setSelectionRange(n.value.length,n.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:n,virtualInput:r,helper:s}=this.textInputManager;if(!n||!r)return;let a=n.value;r.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=r.data;s.update();let l=o.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new Met(this.sceneHelpers,t.raycaster,t.sharedAssets,t.requestRender,this.onExit)}connect(){let t=[];if(this.eventContext.scene.traverseEntity(n=>{n instanceof H3&&t.push(n)}),this._textInputs=t,t.length===0)return;let{domElement:e}=this.eventContext;e.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let t=this.textInputManager.htmlInput,{domElement:e,sharedAssets:i}=this.eventContext;e.removeEventListener("pointerdown",this._onMouseDownFocusIn),t?.removeEventListener("keyup",this._onCaretUpdate),t?.removeEventListener("keydown",this._onCaretUpdate),t?.removeEventListener("beforeinput",this._onCaretUpdate),t?.removeEventListener("paste",this._onCaretUpdate),t?.removeEventListener("cut",this._onCaretUpdate),t?.removeEventListener("select",this._onCaretUpdate),t?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(n=>{let r=iU(n.data.geometry,this.eventContext.sharedAssets.data);n.textGeometry.setText(r,i)}),e.removeEventListener("pointerdown",this._onMouseDown,!1),e.removeEventListener("pointerup",this._onMouseUp,!1),e.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(t){this.textInputManager.focus(t),this.textInputManager.onTextMaterialChanged();let e=this.textInputManager.htmlInput;if(!e||t===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=iU(t.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);e.value=i,e.setSelectionRange(0,0),this.textInputManager.helper.show(t),e.style.display="block",e.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:n}=this.eventContext;n.removeEventListener("pointerdown",this._onMouseDownFocusIn),n.addEventListener("pointerdown",this._onMouseDown,!1),n.addEventListener("pointerup",this._onMouseUp,!1),n.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};ke(),xs("Textfields",({eventContext:t,eventManager:e})=>new Eet(t,e)),wp("InputGeometry",(t,e,i)=>new H3(t,e,i)),Si("textinputs"),qC();var bj=new Map,mg=new Map,Oy=class{constructor(t,e,i,n){this.data=e,this.isPlayAudioAction=!0;let{audio:r,volume:s,delay:a,loop:o}=e;if(!r)throw new Error("Missing property");try{let l=typeof r=="string"?n.getAudio(r).src:r.data;this.audioPlayer=new Uu({src:l,volume:s,delay:a,loop:o})}catch{console.warn(`Could not create an audio player for this object: "${i.name}" and this audio: "${r}"`)}mg.has(i.uuid)?mg.get(i.uuid).push(this):mg.set(i.uuid,[this]),bj.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},Aet=class{constructor(t){this.data=t,this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=bj.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=mg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...mg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Tet=class{constructor(t,e,i,n,r){if(this.data=e,this.shared=n,this.condition=r,e.interaction==="play")this.interaction=new Oy(t,e,i,n);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new Aet(e)}}dispatchBasic(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof Oy?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof Oy?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof Oy&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};ke(),Pr("Audio",({id:t,data:e,object:i,shared:n,actionCondition:r})=>new Tet(t,e,i,n,r)),Si("audio"),ii();var xj=new Map,gg=new Map,IM=class{constructor(t,e,i){this.data=e,this.isPlayVideoAction=!0,this.delay=0,this.status="stopped";let{layerId:n,loop:r,volume:s,delay:a}=e;if(this.object=i,n===void 0)throw new Error("Missing property");let o=function(l,c){let h;if("material"in l){let d=l.material;h=Array.isArray(d)?l.material[0].layers.find(p=>p.uuid===c):l.material.layers.find(p=>p.uuid===c)}if(!h)return;let u=h.color?.texture?.image?.img??h.holders?.find(d=>d.isVideo)?.img;return u instanceof HTMLVideoElement?u:void 0}(i,n);o&&(this.videoElement=o,this.videoElement.loop=r===1/0,Xc&&(this.videoElement.autoplay=!0),s!==void 0&&(this.videoElement.volume=s)),a!==void 0&&(this.delay=a),gg.has(i.uuid)?gg.get(i.uuid).push(this):gg.set(i.uuid,[this]),xj.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(n=>{}).catch(n=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let i=this.videoElement.duration;if(i>0){let n=t%i;this.videoElement.currentTime=n}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Cet=class{constructor(t){this.data=t,this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=xj.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=gg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let t=[...gg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Pet=class{constructor(t,e,i,n,r){if(this.data=e,this.shared=n,this.condition=r,e.interaction==="play")this.interaction=new IM(t,e,i);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new Cet(e)}}dispatchBasic(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof IM?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ti(this.shared,this.condition)===!1)return!1;this.interaction instanceof IM?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};Li(),ke(),Pr("Video",({id:t,data:e,object:i,shared:n,actionCondition:r})=>as(i)?null:new Pet(t,e,i,n,r)),Si("video"),ii(),et(),Ep();var OM=(()=>{let t,e,i,n,r=!1;function s(l){!t&&!nU()&&(e?.sharedGameControlGlobals.createdObjects.length??0)>0&&(t=requestAnimationFrame(a)),l&&(e=l,n=l.requestRender,!r&&typeof document<"u"&&(document.addEventListener("visibilitychange",o),r=!0))}function a(l){if(!e||!n)return t=void 0,void(i=void 0);let c=i?l-i:0,h=e.sharedGameControlGlobals.createdObjects,u=e.sharedGameControlGlobals.nCreatedPerAction,d=h.length,p=0;for(;p<d;){let f=h[p];f.userData.createdTime===void 0&&(f.userData.createdTime=l),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&l-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,c/1e3),f.updateMatrix(),n()),p++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,h.splice(p,1),f.removeFromParent(),e.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(e.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),e.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,e.sharedGameControlGlobals.entitiesWithTransformAnim=e.sharedGameControlGlobals.entitiesWithTransformAnim.filter(g=>g.bvhGeometry!==void 0)),d--,n())}t=p>0?requestAnimationFrame(a):void 0,i=p>0?l:void 0}function o(){nU()?t&&(cancelAnimationFrame(t),t=void 0,i=void 0):s()}return{play:s,dispose:function(){t&&(cancelAnimationFrame(t),t=void 0),r&&typeof document<"u"&&(document.removeEventListener("visibilitychange",o),r=!1),e=void 0,n=void 0,i=void 0}}})();function nU(){return!!document&&document.hidden}var rU=new qt,Det=new C,Ret=new C,Iet=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.controlsManager=i,this.shared=n,this.condition=r,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Ot.generateUUID(),this.dispatch=()=>{if(Ti(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()},this.dispatchFromStart=()=>{if(Ti(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))},this.dispatchThrottled=function(a,o=0,l={}){return Cg(a,o,{leading:l.leading!==!1,trailing:l.trailing!==!1,maxWait:o})}(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let a=new ys(this.object);if(a.playModeVisible=!0,a.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,c=this.page.scene.find(l);c&&(c.updateMatrixWorldRigid(),a.hiddenMatrix.copy(c.matrixWorldRigid))}a.scale.copy(this.object.scale),a.position.fromArray(this.data.position.map(l=>typeof l=="number"?l:0)),a.rotation.fromArray(this.data.rotation.map(l=>typeof l=="number"?l:0)),a.updateMatrix(),this.page.add(a);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(a),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,a.updateWorldMatrix(!0,!0),a.traverseObject(this.traverseObjectCB),OM.play(),this.controlsManager.requestRender()},this.traverseObjectCB=a=>{let o;if(a.hasNonUniformScale&&a.updateMatrixWorldRigid(),this.controlsManager.sharedGameControlGlobals.rapierWorld){if(a instanceof zc){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(a instanceof ys)o=a.object;else if(o=a,o.dataPatched.cloner?.hideBase)return!0}else{if(a instanceof zc)return;o=a instanceof ys?a.object:a}this.data.destroy==="Time"?a.userData.lifetime=1e3*this.data.lifetime:this.data.destroy==="Quantity"&&(a.userData.quantity=this.data.destroyAfterQuantity,a.userData.actionId=this.uniqueId);let l=new C().fromArray(this.data.velocity.map(h=>typeof h=="number"?h:0)),c=o.dataPatched;if(!(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(a,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(a.rigidBody?.collider(0).setActiveEvents(1),a.userData.hasCollisionDestroy=!0),a.matrixWorld.decompose(Det,rU,Ret),l.applyQuaternion(rU),this.data.velocity.some(h=>h!==0)&&this.data.dynamic&&a.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in a.object&&this.controlsManager.addBoundsTree(a),this.data.velocity.some(h=>h!==0)&&this.data.dynamic&&(a.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let s=this.page.scene.find(this.data.object);if(!s)throw new Error("Missing Property");if(this.object=s,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");OM.play(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],OM.dispose()}},Oet=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.controlsManager=i,this.shared=n,this.condition=r,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=s=>{this.timeoutIdQueue.shift();let a=this.page.scene.find(s);if(a===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=!o||a.dataPatched.physics?.fusedBody;if(a.cloner){for(let c of a.cloner.children)l?(c.playModeVisible=!1,c.rigidBody&&a.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(c.rigidBody.collider(0).handle),o.removeRigidBody(c.rigidBody),c.rigidBody=void 0),c.bvhGeometry&&(c.bvhGeometry=void 0)):this.clone===void 0||this.clone===c?(c.playModeVisible=!1,c.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(c.rigidBody.collider(0).handle),o.removeRigidBody(c.rigidBody),c.rigidBody=void 0)):c.playModeVisible===void 0&&(c.playModeVisible=!0);a.cloner.syncInstanceMatrices(),(l||this.clone===void 0||this.clone===!1)&&(a.visible=!1,a.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(a.rigidBody.collider(0).handle),o.removeRigidBody(a.rigidBody),a.rigidBody=void 0),a.bvhGeometry&&(a.bvhGeometry=void 0))}else a.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(a.rigidBody.collider(0).handle),o.removeRigidBody(a.rigidBody),a.rigidBody=void 0),a.bvhGeometry&&(a.bvhGeometry=void 0),a.visible=!1;this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(c=>c.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(c=>c.rigidBody!==void 0),a.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...t.objects]}dispatch(t){if(Ti(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()}dispatchFromStart(){if(Ti(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};ke(),Pr("Create",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Iet(t,e,i.controlsManager,n,r)),Pr("Destroy",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Oet(t,e,i.controlsManager,n,r)),Si("create-destroy"),Yt(),Yt(),Wr(),et(),Hs(),qr(),Li();var sU=new C;function W3(t,e,i=!1){let n=[],r=s=>{let a=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let o of a.states){let l={...o.data};s.states||(s.states={}),s.states[o.id]=wc.patch(a,l)}oU(t.scene,s,null,e,a.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),aU(t)};t.scene.traverse2D(r),t.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(sU,!0),s.rigidBody?.setAngvel(sU,!0)),!Be.is(s))return;let a=s.uuid,o=s.data;if(delete s.states,s.uuid===Zc)return;let l=!1;n.some(c=>t.scene.find(a)?.isDescendantOf(c))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&n.push(a),s.data=o,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null,s.transitionState={settled:!0,state:null};for(let c of o.states){let h={...c.data};t.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete h.position,c.data.rotation!==void 0&&delete h.rotation,c.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[c.id]=Kl.patch(o,h)}oU(t.scene,s,null,e,o.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),Cr(s)&&s.frame&&(s.frame.traverse(c=>r(c)),s.uiCanvas?.applySize())}),aU(t),t.frame&&(t.frame.traverse(s=>r(s)),t.uiCanvas?.applySize())}function aU(t){t.traverseEntity(e=>{for(let i of e.data.events){let n=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...i.data.actions);break;case"GameControl":for(let r of Object.values(i.data.gameActions))n.push(...r);break;case"DragDrop":n.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":n.push(...i.data.inActions,...i.data.outActions)}for(let r of n)if(r.data.type==="Create"&&r.data.hideBase==="Yes"){let s=t.scene.find(r.data.object);s&&(s.visible=!1)}}})}function oU(t,e,i,n,r=!1){if(t.markShadowsDirty(),e instanceof Ai&&!nl(e)&&e.removeInteractionGeometry(n),as(e)?e.changeSelectedState(i,{shared:n},r):e.changeSelectedState(i,{scene:t,shared:n},r),e instanceof Ai&&e.updateGeometryGroupsIfNeeded(),e instanceof vn&&e.updateCameraState(e.dataPatched,{scene:t,shared:n}),!as(e)){if(e.cloner){let s=!1;for(let a of e.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,s=!0);s&&t.addPendingUpdateCloner(e),e.cloner.syncInstanceMatrices()}e.updateVisible()}}var Let=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.eventManager=i,this.shared=n,this.condition=r,this.timeOutId=-1,this.scene=e.scene}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},1e3*this.data.delay))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(e=>e.uuid!==this.data.target||e.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,1e3*this.data.duration),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.sleep(),e.wakeUp(),e.data.autoPlay?e.start():e.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),W3(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function Bet(t){return{easing:t.type,control1:Oc(t.cubicControls?.control1,[0,0]),control2:Oc(t.cubicControls?.control2,[1,1]),...t.springParameters}}function uu(t,e){let i=[];for(let n of t??[]){let r=e(n.data);r!==void 0&&i.push({time:n.data.time,ease:Bet(n.data.easing),value:r})}return{keyframes:Mtt(i)}}function Va(t,e){if(t.keyframes.length===0)return;let{index0:i,index1:n,t:r}=function(o,l){if(o.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(l<=o[0].time)return{index0:0,index1:0,t:1};let{found:c,index:h}=function(m,y){let v=m.length,_=0,b=v;for(;_<b;){let x=_+Math.floor(v/2),w=m[x].time;if(w<y)_=x+1;else{if(!(w>y))return{found:!0,index:x};b=x}v=b-_}return{found:!1,index:_}}(o,l);if(c)return{index0:h,index1:h,t:1};if(h>=o.length){let m=o.length-1;return{index0:m,index1:m,t:1}}let u=h-1,d=h,p=o[u].time,f=o[d].time;if(f===p)return{index0:u,index1:d,t:.5};let g=SM(f-p);return{index0:u,index1:d,t:pj({...o[u].ease,control2:o[d].ease.control2},g,SM(SM(l-p)/g))}}(t.keyframes,e),s=t.read;if(s&&s.index0===i&&s.index1===n&&s.t===r)return;let a={index0:i,index1:n,from:t.keyframes[i].value,to:t.keyframes[n].value,t:r};return t.read=a,a}function Uet(t){t.read=void 0}function Ly(t,e,i){return t+(e-t)*i}ke(),Pr("SceneTransition",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Let(t,e,i,n,r)),Si("scene-transition"),Yt(),et(),Yt(),Yt(),et(),Kn(),Hs(),l3(),kk(),u3(),qr(),Li(),rl(),Dk(),Yt(),ii(),et(),ya();var{degToRad:kit,radToDeg:Vit}=Ot,lU=new C,hU=new C,cU=new qt;function fr(t,e,i,n,r,s){let a=i[t]!==void 0?i[t]:void 0,o=n[t];if(o==null)return;let l=a!=null?typeof a=="string"?Number(r.getVariable(a)??0):a:e[t],c=typeof o=="string"?Number(r.getVariable(o)??0):o;return l!==c?{update:h=>{let u=Ot.lerp(l,c,h);e[t]=s?Math.trunc(u):u},start:()=>{e[t]=l},end:()=>{e[t]=c}}:void 0}function XT(t,e,i,n,r,s){let a=i[t]?i[t]:void 0,o=n[t];if(!o)return;let l=e[t],c=[...a??l].map(u=>typeof u=="string"?Number(r.getVariable(u)??0):u),h=[...o].map(u=>typeof u=="string"?Number(r.getVariable(u)??0):u);return c.length!==h.length||Gu(c,h)?void 0:{update:u=>{c.forEach((d,p)=>{let f=Ot.lerp(d,h[p],u);e[t][p]=s?Math.trunc(f):f})},start:()=>{Object.assign(e[t],c)},end:()=>{Object.assign(e[t],h)}}}function Pb(t,e,i){return e.forEach((n,r)=>{t.setComponent(r,typeof n=="string"?Number(i.getVariable(n)??0):n)}),t}function dU(t,e,i,n,r){let s=i[t]?i[t]:void 0,a=n[t];if(!a)return;let o=e[t],l=s?Pb(new C,s,r):o.clone(),c=Pb(new C,a,r);return l.equals(c)?void 0:{update:h=>{o.lerpVectors(l,c,h)},start:()=>{o.copy(l)},end:()=>{o.copy(c)}}}function uU(t,e,i){return e.forEach((n,r)=>{t.setComponent(r,typeof n=="string"?Number(i.getVariable(n)??0):n)}),t}function By(t,e,i,n,r){let s=i[t]?i[t]:void 0,a=n[t];if(!a)return;let o=e[t],l=!(o instanceof it),c=o instanceof it?o:new it().fromArray(o),h=s?uU(new it,s,r):c.clone(),u=uU(new it,a,r);return h.equals(u)?void 0:{update:d=>{c.lerpVectors(h,u,d),l&&(e[t]=c.toArray())},start:()=>{c.copy(h),l&&(e[t]=c.toArray())},end:()=>{c.copy(u),l&&(e[t]=c.toArray())}}}function Uy(t,e,i,n,r){let s=i[t]?i[t]:void 0,a=n[t];if(!a)return;let o=e[t],l=new gn(o.r,o.g,o.b,o.a),c=s?typeof s=="string"?r.getColor(s).clone():new gn(s.r,s.g,s.b,s.a):l.clone(),h=typeof a=="string"?r.getColor(a).clone():new gn(a.r,a.g,a.b,a.a);return c.equals(h)?void 0:{update:u=>{l.lerpColors(c,h,u);let d=Ot.lerp(c.a,h.a,u);l.a=d,e[t]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(h)}}}function Ll(t,e,i,n,r){return typeof e[t]=="number"?fr(t,e,i??{},n,r):Array.isArray(e[t])?XT(t,e,i??{},n,r):void 0}function zet(t,e){if(t)for(let[i,n]of Object.entries(e)){let r=t[i];if(Array.isArray(r)&&Array.isArray(n)){let s=Math.min(r.length,n.length);for(let a=0;a<s;a++)r[a]=n[a]}else t[i]=n}}function zy(t,e,i,n){let r={};if(!e||!i)return r;for(let s of t){let a=e[s],o=i[s];if(typeof a=="number"&&typeof o=="number")r[s]=Ot.lerp(a,o,n);else if(Array.isArray(a)&&Array.isArray(o)){let l=Math.min(a.length,o.length);r[s]=Array.from({length:l},(c,h)=>Ot.lerp(a[h],o[h],n))}}return r}new xi;var pU=[["radial",P_],["linear",D_],["grid",R_],["toObject",I_],["randomnessObject",O_]];function wj(t,e,i,n,r){let s=t.getValue(n);if(s!==void 0){if(n==="colors")return function(a,o,l,c="colors"){if(!a.hasValue(c)||!(c in l))return;let h=[],u=a.getValue(c),d=o?o[c]:u.map(f=>f.toArray()),p=l[c];for(let f=0;f<u.length;++f){let g=[...d[f]],m=[...p[f]];Dg.isEqual(g,m)||h.push({update:y=>{u[f].fromArray(Dg.lerp(g,m,y))},start:()=>{u[f].fromArray(g)},end:()=>{u[f].fromArray(m)}})}return h.length?h:void 0}(t,e,i,n);if(Array.isArray(s))return n==="steps"?function(a,o,l,c="steps"){if(!a.hasValue(c)||!(c in l))return;let h=[],u=a.getValue(c),d=o?o[c]:u,p=l[c];return Gu(d,p)||h.push({update:f=>{let g=[...u];for(let m=0;m<u.length;++m){let y=d[m],v=p[m];g[m]=Ot.lerp(y,v,f)}a.setValue(c,g)},start:()=>{a.setValue(c,d)},end:()=>{a.setValue(c,p)}}),h.length?h:void 0}(t,e,i,n):void 0;if(typeof s=="number")return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=o?o[c]:a.getValue(c),d=l[c],p=typeof u=="string"?Number(h.getVariable(u)??0):u,f=typeof d=="string"?Number(h.getVariable(d)??0):d;return{update:g=>{a.setValue(c,Ot.lerp(p,f,g))},start:()=>{a.setValue(c,p)},end:()=>{a.setValue(c,f)}}}(t,e,i,n,r);if(typeof s!="boolean"){if(s instanceof it)return function(a,o,l,c){if(!a.hasValue(c)||!(c in l))return;let h=a.getValue(c),u=o?new it().fromArray(o[c]):h.clone(),d=new it().fromArray(l[c]);return u.equals(d)?void 0:{update:p=>{h.lerpVectors(u,d,p)},start:()=>{h.copy(u)},end:()=>{h.copy(d)}}}(t,e,i,n);if(s instanceof C)return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=a.getValue(c),d=o?o[c]:void 0,p=l[c],f=d?Pb(new C,d,h):u.clone(),g=Pb(new C,p,h);return f.equals(g)?void 0:{update:m=>{u.lerpVectors(f,g,m)},start:()=>{u.copy(f)},end:()=>{u.copy(g)}}}(t,e,i,n,r);if(s instanceof gn)return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=o?o[c]:void 0,d=l[c],p=a.getValue(c),f=u?typeof u=="string"?h.color(u).clone():new Jt().setRGB(u.r,u.g,u.b):p.clone(),g=typeof d=="string"?h.color(d).clone():new gn(d.r,d.g,d.b,d.a);if(f.equals(g))return;let m=p.clone();return{update:y=>{a.getValue(c)!==m&&a.setValue(c,m),m.lerpColors(f,g,y)},start:()=>{m.copy(f)},end:()=>{m.copy(g)}}}(t,e,i,n,r);if(s instanceof Jt)return function(a,o,l,c,h){if(!a.hasValue(c)||!(c in l))return;let u=o?o[c]:void 0,d=l[c],p=a.getValue(c),f=u?typeof u=="string"?h.color(u).clone():new Jt().setRGB(u.r,u.g,u.b):p.clone(),g=typeof d=="string"?h.color(d).clone():new Jt().setRGB(d.r,d.g,d.b);if(f.equals(g))return;let m=p.clone();return{update:y=>{a.getValue(c)!==m&&a.setValue(c,m),m.lerpColors(f,g,y)},start:()=>{m.copy(f)},end:()=>{m.copy(g)}}}(t,e,i,n,r);if("isTexture"in s)return function(a,o,l,c="texture",h){if(!a.hasValue(c)||!(c in l))return;let u=A=>Number(typeof A=="string"?h?.getVariable(A)??0:A??0),d=a.getNode("rotation"),p=o?u(o[c]?.rotation):(d?.value??0)*Ot.RAD2DEG,f=u(l[c]?.rotation);if(d&&Math.abs(p-f)>1e-9)return{update:A=>{d.value=Ot.lerp(p,f,A)*Ot.DEG2RAD},start:()=>{d.value=p*Ot.DEG2RAD},end:()=>{d.value=f*Ot.DEG2RAD}};let g=function(A){let E=A.getNode("mat");if(typeof E?.updateMatrix=="function")return E;let P=A.getValue("mat");return typeof P?.updateMatrix=="function"?P:void 0}(a);if(!g)return;let m=o?o[c]:g,y=l[c],v=[...m.repeat],_=[...m.offset],b=[...y.repeat],x=[...y.offset],w=m.rotation??0,S=y.rotation??0;return Ja.isEqual(v,b)&&Ja.isEqual(_,x)&&w===S?void 0:{update:A=>{g.repeat=Ja.lerp(v,b,A),g.offset=Ja.lerp(_,x,A),g.rotation=Ot.lerp(w,S,A),g.updateMatrix()},start:()=>{g.repeat=[...v],g.offset=[..._],g.rotation=w,g.updateMatrix()},end:()=>{g.repeat=[...b],g.offset=[...x],g.rotation=S,g.updateMatrix()}}}(t,e,i,n,r)}}}function fU(t,e,i,n){let r=[],s=Pc(i,n)||!!e.layers&&Pc(e,n);r.push(function(a,o){return{update:()=>{a.transparent=o}}}(t,s)),function(a,o,l){let c=a.ensureRainbowNoiseCompiled;if(typeof c=="function")for(let h of[...a.layers]){if(h.type!=="rainbow")continue;let u=o.layers?.data(h.uuid),d=l.layers.data(h.uuid);(fp(u?.noiseStrength)||fp(d?.noiseStrength))&&c.call(a,h.uuid)}}(t,e,i);for(let a of t.layers){let o=e.layers?.data(a.uuid),l=i.layers.data(a.uuid);if(!l||a.type!=="light"&&(!(a.visible??1)||!(l.visible??1)))continue;let c=ox[a.type]??[],h=a.getNames().filter(u=>!c.includes(u)&&!Wb.some(d=>u.includes(d)));for(let u of h)try{let d=wj(a,o,l,u,n);d&&(Array.isArray(d)?r.push(...d):r.push(d))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${u}`,d)}}return r}function mU(t,e,i,n,r,s){let a=wj(e,i,n,t,s);!a||(Array.isArray(a)?a.forEach(o=>o.update(r)):a.update(r))}function Lo(t,e,i){!t||(t[e]={...t[e],...i})}function Fet(t,e,i,n,r,s,a){let o=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(t.on){case"position":case"scale":{let l=Va(t.track,i);if(!l)return;let c=Ly(l.from,l.to,l.t);return e[t.on][t.axis]=c,Lo(s,t.on,{[t.axis]:c}),void o()}case"rotation":{let l=Va(t.track,i);if(!l)return;let c=Ly(l.from,l.to,l.t);return e.rotation[t.axis]=c*Ot.DEG2RAD,Lo(s,"rotation",{[t.axis]:c}),void o()}case"shapeSize":{let l=Va(t.track,i);if(!(l&&e instanceof Ai))return;let c=Ly(l.from,l.to,l.t);return e.userData.value={...e.userData.value,[t.axis]:c},Lo(s,"shapeSize",{[t.axis]:c}),a.size=!0,a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"opacity":{let l=Va(t.track,i);if(!l||!(e instanceof Xi)||Array.isArray(e.material))return;let c=e.material.getLayersOfType("light")[0];if(c===void 0)return;let h=Ot.lerp(l.from,l.to,l.t);return e.material.transparent=!0,mU("alphaOverride",c,{alphaOverride:h},{alphaOverride:h+1},0,n.shared),s&&(s.opacity=h),void(a.render=!0)}case"material":{let l=Va(t.track,i);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:c}=t,h={};for(let u in c.data){if(!(u in l.from)||!(u in l.to))continue;let d=$T(l.from[u],l.to[u],l.t,r);if(d===void 0)continue;h[u]=d;let p=c.getValue(u);p!==void 0&&(u==="alpha"&&typeof p=="number"&&p>0&&e instanceof Xi&&!Array.isArray(e.material)&&(e.material.transparent=!0),mU(u,c,l.from,l.to,l.t,n.shared))}return Lo(s,"material",{[c.uuid]:h}),void(a.render=!0)}case"light":{let l=Va(t.track,i);if(!l||!(e instanceof Qg||e instanceof dx||e instanceof Jg))return;let c=$T(l.from,l.to,l.t,r);return e[t.field]=c,Lo(s,"light",{[t.field]:c}),void(a.render=!0)}case"camera":{let l=Va(t.track,i);if(!(l&&e instanceof vn))return;let c=Ly(l.from,l.to,l.t);return e[t.field]=c,void Lo(s,"camera",{[t.field]:c})}case"cloner":{let l=Va(t.track,i);if(!l)return;let c=e.cloner?.parameters,h=function(u,d,p,f){if(!u)return{};let g=zy(["count"],d,p,f);g.count!==void 0&&(g.count=Math.trunc(g.count));for(let[m,y]of pU){if(!u[m])continue;let v=zy(y,d[m],p[m],f);Object.keys(v).length&&(g[m]=v)}return g}(c,l.from,l.to,l.t);return function(u,d){if(u){d.count!==void 0&&(u.count=d.count);for(let[p]of pU){let f=d[p];f&&zet(u[p],f)}}}(c,h),Lo(s,"cloner",h),a.cloner=!0,a.boolean=!0,void(a.render=!0)}case"pathExtrusion":{let l=Va(t.track,i);if(!l||!Zb(e))return;let c=zy(F_,l.from,l.to,l.t),h=e.geometry.userData.parameters;return h.extrusion={...h.extrusion,...c},Lo(s,"pathExtrusion",c),e.updateGeometryInteractions({extrusion:{...h.extrusion}},n.shared),a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"pathSnapping":{let l=Va(t.track,i);if(!l)return;let c=e,h=zy(zF,l.from,l.to,l.t);return c.userData.pathSnapping={...c.userData.pathSnapping,...h},Lo(s,"pathSnapping",h),c.updatePathSnapping(c.userData.pathSnapping),void(a.render=!0)}}}function $T(t,e,i,n){if(typeof t=="string"&&n&&(t=n.color(t)),typeof e=="string"&&n&&(e=n.color(e)),typeof t=="number")return Ot.lerp(t,e,i);if(Je.is(t))return Je.lerp(t,e,i);if(Tn.is(t))return Tn.lerp(t,e,i);if(Array.isArray(t))return(t.length>e.length?e:t).map((r,s)=>{if(Array.isArray(r)){let a=t[s].length>e[s].length?e[s].length:t[s].length;return(a===4?Dg:a===3?oh:Ja).lerp(t[s],e[s],i)}return Ot.lerp(t[s],e[s],i)});if(typeof t=="object"&&t!==null){let r={};for(let s in t){let a=$T(t[s],e[s],i,n);a!==void 0&&(r[s]=a)}return r}}Yt(),et(),ya(),i3(),rl(),ii(),Li(),Yt(),Hs(),Li(),Kn(),Hs(),Kg(),qr(),Jc(),et(),Yt(),et(),t0(),Li(),ii(),Li(),et(),xh(),et();var LM=new C,gU=new xi;function Net(t,e,i,n,r){let s=[];return t.data.visible&&s.push(...function(a,o,l,c,h){let u,d,p,f,g,m,y,v,_=[];if(as(a)?(u=By("position",a,o,l,h),u&&_.push(u),p=fr("rotation",a,o,l,h),p&&_.push(p),f=By("shear",a,o,l,h),f&&_.push(f)):(v={slide:o.pathSnapping?.slide??a.updatedPathSnapping?.slide??a.dataPatched.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.updatedPathSnapping?.offset??a.dataPatched.pathSnapping?.offset??0},m=fr("slide",v,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,h),m&&_.push(m),y=fr("offset",v,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,h),y&&_.push(y),!m&&!y&&(u=dU("position",a,o,l,h),u&&_.push(u),d=dU("scale",a,o,l,h),d&&_.push(d),p=function(b,x,w,S,A){let E=x?.rotation?x.rotation.map(D=>(typeof D=="string"?Number(A.getVariable(D)??0):D)*Ot.DEG2RAD):void 0,P=w.rotation?.map(D=>(typeof D=="string"?Number(A.getVariable(D)??0):D)*Ot.DEG2RAD);if(!P)return;let T=E?new C().fromArray(E):new C().setFromEuler(b.rotation),R=new C().fromArray(P);if(T.equals(R))return;let L=LM.subVectors(R,T);if(S&&L.toArray().every(D=>Math.abs(D)<2*Math.PI)){let D=new qt().setFromEuler(gU.setFromVector3(T)),U=new qt().setFromEuler(gU.setFromVector3(R));return{update:V=>{(function(k,Y,$,nt){if(nt===0)return $.copy(k);if(nt===1)return $.copy(Y);let Q=k.w*Y.w+k.x*Y.x+k.y*Y.y+k.z*Y.z;if(Q>=1)return $.copy(k);let rt=1-Q*Q;if(rt<=Number.EPSILON){let q=1-nt;return $.w=q*k.w+nt*Y.w,$.x=q*k.x+nt*Y.x,$.y=q*k.y+nt*Y.y,$.z=q*k.z+nt*Y.z,$.normalize(),$}let gt=Math.sqrt(rt),at=Math.atan2(gt,Q),ht=Math.sin((1-nt)*at)/gt,ct=Math.sin(nt*at)/gt;$.w=k.w*ht+Y.w*ct,$.x=k.x*ht+Y.x*ct,$.y=k.y*ht+Y.y*ct,$.z=k.z*ht+Y.z*ct})(D,U,b.quaternion,V)},start:()=>{b.rotation.setFromVector3(T)},end:()=>{b.rotation.setFromVector3(R)}}}return{update:D=>{LM.lerpVectors(T,R,D),b.rotation.setFromVector3(LM)},start:()=>{b.rotation.setFromVector3(T)},end:()=>{b.rotation.setFromVector3(R)}}}(a,o,l,c,h),p&&_.push(p),g=function(b,x,w,S){let A=w[b]?w[b]:void 0,E=S[b];if(!E)return;let P=x[b],T=A?new At().fromArray(A):P.clone(),R=new C,L=new qt,D=new C;T.decompose(R,L,D);let U=new At().fromArray(E),V=new C,k=new qt,Y=new C;return U.decompose(V,k,Y),T.equals(U)?void 0:{update:$=>{cU.slerpQuaternions(L,k,$),lU.lerpVectors(R,V,$),hU.lerpVectors(D,Y,$),P.compose(lU,cU,hU)},start:()=>{P.compose(R,L,D)},end:()=>{P.compose(V,k,Y)}}}("hiddenMatrix",a,o,l),g&&_.push(g))),u||d||p||g||m||y){let b=as(a)?()=>{a.updateWorldMatrix(!0,!1,!0),a.resetBBoxNeedsUpdate()}:()=>{a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldRigid()),a.parent?.matrixWorldFusedFalse&&(a.matrixWorld.multiplyMatrices(a.parent.matrixWorldFusedFalse,a.matrix),a.matrixWorldNeedsUpdate=!1),pa(a)&&to(a.parent)&&a.invalidateDownstreamBooleanData(!0),a.updatePathSnapping(Object.assign({},o.pathSnapping,v))};_.push({update:b,start:b,end:b})}return _}(t,e,i,r,n.shared)),as(t)?s.push(...function(a,o,l,c,h){let u,d,p,f,g,m,y,v,_,b,x,w,S,A,E,P=[];if("width"in a&&(u=fr("width",a,o,l,h),u&&P.push(u)),"height"in a&&(d=fr("height",a,o,l,h),d&&P.push(d)),a instanceof Jn||a instanceof so){let T={...o.fill},R={...l.fill};T.enabled!==void 0&&T.enabled!==R.enabled&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.fill.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),p=Uy("color",a.fill,T,R,h),p&&P.push(p)}if(a instanceof Jn){let T={...o.stroke},R={...l.stroke};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.stroke.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),f=Uy("color",a.stroke,T,R,h),f&&P.push(f),g=fr("thickness",a.stroke,T,R,h),g&&P.push(g)}if(a instanceof Jn){let T={...o.dropShadow},R={...l.dropShadow};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.dropShadow.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),m=Uy("color",a.dropShadow,T,R,h),m&&P.push(m),y=fr("blurRadius",a.dropShadow,T,R,h),y&&P.push(y),_=fr("spread",a.dropShadow,T,R,h),_&&P.push(_),v=By("offset",a.dropShadow,T,R,h),v&&P.push(v)}if(a instanceof Jn){let T={...o.innerShadow},R={...l.innerShadow};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.innerShadow.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,color:{...T.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),b=Uy("color",a.innerShadow,T,R,h),b&&P.push(b),x=fr("blurRadius",a.innerShadow,T,R,h),x&&P.push(x),S=fr("spread",a.innerShadow,T,R,h),S&&P.push(S),w=By("offset",a.innerShadow,T,R,h),w&&P.push(w)}if(a instanceof Jn||a instanceof so){let T={...o.backgroundBlur},R={...l.backgroundBlur};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.backgroundBlur.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),A=fr("radius",a.backgroundBlur,T,R,h),A&&P.push(A)}if(a instanceof Jn){let T={...o.layerBlur},R={...l.layerBlur};(T.enabled||R.enabled)&&(P.push(function(L){return{update:()=>{L instanceof Jn&&(L.layerBlur.enabled=!0)}}}(a)),T.enabled||Object.assign(T,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),E=fr("radius",a.layerBlur,T,R,h),E&&P.push(E)}if(a instanceof so||a instanceof n0){let T=XT("cornerRadius",a,o,l,h);T&&P.push(T)}return P}(t,e,i,0,n.shared)):(t.data.visible&&s.push(...function(a,o,l,c){let h=[];if(!("cloner"in l)||!a.cloner)return h;let u=a.cloner,d="cloner"in o?o.cloner:{},p=l.cloner;KE.forEach(_=>{let b;b=_==="count"?fr("count",u.parameters,d,p,c.shared,!0):Ll(_,u.parameters,d??{},p,c.shared),b&&h.push(b)});let f=function(_,b,x,w){if(_.parameters.type!=="radial")return;let S=b.radial,A=x.radial;if(!A)return;let E=_.parameters.radial,P=[];return P_.forEach(T=>{let R=Ll(T,E,S??{},A,w);R&&P.push(R)}),P}(u,d,p,c.shared);f?.length&&h.push(...f);let g=function(_,b,x,w){if(_.parameters.type!=="linear")return;let S=b.linear,A=x.linear;if(!A)return;let E=[],P=_.parameters.linear;return D_.forEach(T=>{let R=Ll(T,P,S??{},A,w);R&&E.push(R)}),E}(u,d,p,c.shared);g?.length&&h.push(...g);let m=function(_,b,x,w){if(_.parameters.type!=="grid")return;let S=b.grid,A=x.grid;if(!A)return;let E=[],P=_.parameters.grid;return R_.forEach(T=>{let R;R=T==="count"?XT(T,P,S??{},A,w,!0):Ll(T,P,S??{},A,w),R&&E.push(R)}),E}(u,d,p,c.shared);m?.length&&h.push(...m);let y=function(_,b,x,w){if(_.parameters.type!=="toObject")return;let S=b.toObject,A=x.toObject;if(!A)return;let E=[],P=_.parameters.toObject;return I_.forEach(T=>{let R;R=T==="count"?fr(T,P,S??{},A,w,!0):Ll(T,P,S??{},A,w),R&&E.push(R)}),E}(u,d,p,c.shared);y?.length&&h.push(...y);let v=function(_,b,x,w){if(!_.parameters.randomness)return;let S=b.randomnessObject,A=x.randomnessObject;if(!A)return;let E=[],P=_.parameters.randomnessObject;return O_.forEach(T=>{let R=Ll(T,P,S??{},A,w);R&&E.push(R)}),E}(u,d,p,c.shared);return v?.length&&h.push(...v),h.length&&h.push({update:()=>{u.update(c)}}),h}(t,e,i,n)),t instanceof Xi?(t instanceof Ai&&t.data.visible&&s.push(...function(a,o,l,c){let h=[];if(!("geometry"in l)||nl(a))return h;let u=a.geometry.userData.parameters,d="geometry"in o?o.geometry:{},p=l.geometry;if(a instanceof mp){let f=function(g,m,y,v){if(y.scaleBaked===void 0)return;let _=(m.scaleBaked??g.appliedGeometrySize??g.data.geometry.scaleBaked).map(w=>typeof w=="string"?Number(v.shared.getVariable(w)??0):w),b=y.scaleBaked.map(w=>typeof w=="string"?Number(v.shared.getVariable(w)??0):w);if(oh.isEqual(_,b))return;let x=[];return x.push({update:w=>{g.updateGeometryInteractions({scaleBaked:[Ot.lerp(_[0],b[0],w),Ot.lerp(_[1],b[1],w),Ot.lerp(_[2],b[2],w)]},v.shared),g.invalidateDownstreamBooleanData(),g.refreshAttachedClonersInteractions(v)},start:()=>{g.updateGeometryInteractions({scaleBaked:_},v.shared),g.invalidateDownstreamBooleanData(),g.refreshAttachedClonersInteractions(v)},end:()=>{g.updateGeometryInteractions({scaleBaked:b},v.shared),g.invalidateDownstreamBooleanData(),g.refreshAttachedClonersInteractions(v)}}),x}(a,d,p,c);f&&h.push(...f)}else{let f={},g=a.appliedGeometrySize;if(Object.assign(f,PE(u,c1),g?{width:g[0],height:g[1],depth:g[2]}:{},PE(d,c1)),c1.forEach(m=>{let y=Ll(m,f,d,p,c.shared);y&&h.push(y)}),Zb(a)){Object.assign(f,{extrusion:{...u.extrusion}});let m=function(y,v,_,b){if(!_.extrusion)return;let x=y.extrusion,w=v.extrusion??{},S=_.extrusion,A=[];return F_.forEach(E=>{let P=Ll(E,x,w,S,b);P&&A.push(P)}),A}(f,d,p,c.shared);m&&h.push(...m)}h.length&&h.push({update:m=>{a.updateGeometryInteractions(f,c.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(c)},start:m=>{a.updateGeometryInteractions(f,c.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(c)},end:m=>{a.updateGeometryInteractions(f,c.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(c)}})}return h}(t,e,i,n)),t.data.visible&&!(t instanceof Hr&&t.materialOverride)&&s.push(...function(a,o,l,c){let h=[];if(Array.isArray(a.material)){if(!("materials"in l)||!l.materials)return h;let u="materials"in o&&o.materials?o.materials:[],d=l.materials;a.material.forEach((p,f)=>{if(!d[f])return;let g=u[f]??{},m=d[f];typeof g=="string"||typeof m=="string"||h.push(...fU(p,g,m,c))})}else{if(!("material"in l)||!l.material)return h;let u="material"in o&&o.material?o.material:{},d=l.material;if(typeof u=="string"||typeof d=="string")return h;h.push(...fU(a.material,u,d,c))}return h}(t,e,i,n.shared))):ob.is(t)?t.data.visible&&s.push(...function(a,o,l,c){let h=[];if(l.intensity!==void 0){let u=fr("intensity",a,o,l,c);u&&h.push(u)}if(l.color!==void 0){let u=function(d,p,f,g,m){let y=f[d]?f[d]:void 0,v=g[d];if(!v)return;let _=p[d],b=y?typeof y=="string"?m.getColor(y).clone():new Jt().setRGB(y.r,y.g,y.b):_.clone(),x=typeof v=="string"?m.getColor(v).clone():new Jt().setRGB(v.r,v.g,v.b);if(b.equals(x))return;let w=_.clone();return{update:S=>{w.lerpColors(b,x,S),p[d]?.copy?.(w)},start:()=>{w.copy(b)},end:()=>{w.copy(x)}}}("color",a,o,l,c);u&&h.push(u)}return h}(t,e,i,n.shared)):t instanceof vn&&s.push(...function(a,o,l,c){let h=[],u=a.cameraType==="OrthographicCamera"?o.orthographic?.zoom:o.perspective?.zoom,d=a.cameraType==="OrthographicCamera"?l.orthographic?.zoom:l.perspective?.zoom;if(d!==void 0){let p=u??a.zoom,f=d;p!==f&&h.push({update:g=>{a.zoom=Ot.lerp(p,f,g),a.updateProjectionMatrix()},start:()=>{a.zoom=p,a.updateProjectionMatrix()},end:()=>{a.zoom=f,a.updateProjectionMatrix()}})}if(l.targetOffset!==void 0){let p=fr("targetOffset",a,o,l,c);p&&h.push(p)}return h}(t,e,i,n.shared))),s.length?{update:a=>{s.forEach(o=>o.update(a))},start:a=>{s.forEach(o=>o.start?.(a))},end:a=>{s.forEach(o=>o.end?.(a))}}:void 0}var Sj={type:"beginState"};function Mj(t){if(t.easing===5){let{control1:e,control2:i}=t;return{easing:5,control1:e??up.defaultData.control1,control2:i??up.defaultData.control2}}if(t.easing===6){let{mass:e,stiffness:i,damping:n,velocity:r}=t;return{easing:6,mass:e??Yl.defaultData.mass,stiffness:i??Yl.defaultData.stiffness,damping:n??Yl.defaultData.damping,velocity:r??Yl.defaultData.velocity}}return{easing:t.easing}}function Ej(t){return{delay:t.delay,delayDirection:t.delayDirection??"start-end",direction:t.direction??"normal",repeat:t.repeat}}var Aj={type:"completeState",isfromEntity:!1};function I1(t,e){let i,n;if(typeof e=="string"?(i=e,n=t.states?.[i]):e===null&&(i=null,n=t.data),i!==void 0&&n!==void 0)return{id:i,data:n}}var YT=class{constructor(t,e,i,n,r,s,a,o={}){this.object=t,this.fromRef=e,this.toRef=i,this.data=n,this.sharedAssets=r,this.allowSlerp=s,this.page=a,this.hooks=o,this.builtReversed=!1,this.startStateId=null,this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=as(this.object)?null:this.object.transitionState.state,this.callback=Net(this.object,{},this.end.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)},this.onChange=l=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(l),this.object.requestRender()),this.writeState(l)},this.runner=new mj(function(l){return{duration:l.duration,ease:Mj(l),...Ej(l)}}(n),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let n=I1(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=I1(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(e===void 0)throw new Error("Missing property");let i=I1(this.object,e);if(!i)throw new Error("Missing property");this.to=i,this.buildCallback()}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||as(this.object))return;let e=t===1,i=t>.5?this.targetStateId:this.startStateId,n=this.object.transitionState;n.settled===e&&n.state===i||(this.object.transitionState={settled:e,state:i},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=i,this.object.dispatchEvent({type:"transitionState",settled:e,state:i}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:i}),this.object.traverseEntity(r=>{r!==this.object&&r instanceof vn&&r.dispatchEvent(e?Aj:Sj)}),e?this.hooks.onComplete?.(i):this.hooks.onBegin?.(i))}};Hs();var ZT=new Map,vg=new Map,na=class extends Vn{constructor(t,e,i,n,r,s,a){super(),this.id=t,this.data=e,this.scene=i,this.sharedAssets=n,this.object=r,this.eventType=s,this.actionCondition=a,this.evaluators=[],this.elapsed=0,this.lastTime=null,this.direction=1,this._playing=!1,this._finished=!1,this.hasPlayedOnce=!1,this.pauseOnNextCycleEnd=!1,this.lastCycleIndex=0;try{let o=Gc.findTimeline(this.scene.data.objects,this.data.timeline),l=o.duration;this.animatedObjectIds=Object.keys(o.objectTimelines),this.animatedObjectIds.forEach(c=>{let h=this.scene.find(c);if(!h)return;let u=o.objectTimelines[c];!u||this.evaluators.push(function(d,p,f,g,m){let y=function(v,_){let b=[];return Lc.groupKeyframes(_.keyframes).forEach(x=>{let w=x.path?.[0],S=x.path[1],A=()=>uu(x.keyframes,E=>E.value);switch(w){case"position":case"rotation":case"scale":return void(S&&Ig.includes(S)&&b.push({on:w,axis:S,track:A()}));case"shape size":return void(S&&Ig.includes(S)&&"geometry"in v&&b.push({on:"shapeSize",axis:S,track:A()}));case"path extrusion":return void(Zb(v)&&b.push({on:"pathExtrusion",track:uu(x.keyframes,E=>E.value)}));case"path snapping":return void(v.data.pathSnapping&&b.push({on:"pathSnapping",track:uu(x.keyframes,E=>E.value)}));case"material":return void(v.type==="Mesh"&&"material"in v&&function(E,P){let T=Pk(E.material)?E.material:void 0,R=P.layerId;if(!T||!R)return[];let L=P.keyframes.some($=>fp($.data.value?.noiseStrength)),D=T.ensureRainbowNoiseCompiled,U=$=>{L&&typeof D=="function"&&D.call(T,$)},V=$=>"data"in $?[{on:"material",layer:$,track:uu(P.keyframes,nt=>nt.value)}]:[];U(R);let k=T.getLayerByUuid(R);if(k)return V(k);let Y=P.path[1];for(let $ of T.getLayersOfType(Y))U($.uuid);return(T.getLayersOfType(Y)??[]).flatMap(V)}(v,x).forEach(E=>b.push(E)));case"opacity":return void(v.type==="Mesh"&&"material"in v&&b.push({on:"opacity",track:A()}));case"cloner":return void b.push({on:"cloner",track:uu(x.keyframes,E=>E.value)});case"camera":return void(v instanceof vn&&b.push({on:"camera",field:"zoom",track:A()}));case"light":return void((v instanceof Qg||v instanceof dx||v instanceof Jg)&&b.push({on:"light",field:x.path[1],track:uu(x.keyframes,E=>E.value)}))}}),b}(d,p);return{duration:f,evaluate(v,_){d.resetBBoxNeedsUpdate();let b={transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1};for(let x of y)Fet(x,d,v,g,m,_,b);(function(x,w,S){if(w.size&&x instanceof Ai){let{x:A,y:E,z:P}=x.userData.value;x.updateGeometryInteractions({width:A,height:E,depth:P},S.shared)}w.cloner&&x.cloner?.update(S),w.transform&&x.updateMatrix(),w.bounds&&x.resetBBoxNeedsUpdate(),w.boolean&&x instanceof Ai&&x.invalidateDownstreamBooleanData(),w.render&&x.dispatchEvent({type:"requestRender"})})(d,b,g)},invalidate(){for(let v of y)Uet(v.track)}}}(h,{...u},l,{scene:i,shared:n},this.sharedAssets))}),this.schedule=new Stt(function(c,h){return{duration:h,delay:pr(c.delay/1e3),delayDirection:c.delayDirection??"start-end",direction:c.direction??"normal",repeat:c.repeat}}(this.data,l))}catch{throw new Error("Missing property")}r&&(vg.has(r.uuid)?vg.get(r.uuid).push(this):vg.set(r.uuid,[this])),ZT.set(t,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(t){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(t-this.lastTime)*this.direction)),this.lastTime=t,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0)return void this.pause();let t=this.schedule.resolve(this.elapsed);if(t){if(t.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=t.cycleIndex,this.pauseOnNextCycleEnd))return this.pauseOnNextCycleEnd=!1,void this.pause();for(let e of this.evaluators)e.evaluate(t.localTime)}else this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(t=>{let e=this.scene.find(t);e instanceof vn&&e.dispatchEvent(Aj)})}startTicking(){this._playing=!0,this.lastTime=null;for(let t of this.evaluators)t.invalidate();Ji.add(this)}play(){let t=this.eventType!==void 0&&GE(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&GE(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!t||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(e=>{let i=this.scene.find(e);i instanceof vn&&i.dispatchEvent(Sj)}),!t&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,Ji.remove(this)}stop(){this.pause(),this.elapsed=0,this.lastCycleIndex=0,this.applyAtElapsed(),this._finished=!1}seek(t){let e=this.schedule.totalDuration;this.elapsed=t*(Number.isFinite(e)?e:this.schedule.effectiveCycleDuration);for(let i of this.evaluators)i.invalidate();this.applyAtElapsed()}toggle(t){let e=t??this.direction===-1;this._playing&&this.direction===(e?1:-1)?e&&(this.pauseOnNextCycleEnd=!1):(e?(this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.pauseOnNextCycleEnd=!1):(this.direction=this.schedule.resolve(this.elapsed)?.isReverse?1:-1,this.pauseOnNextCycleEnd=!0),this.startTicking())}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},ket=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>{i[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(i=>{i[this.data.interaction]()}))}getTimelineActions(t){let e=ZT.get(t);return e?[e]:[...ZT.values()].filter(i=>i.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=vg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllTimelines(){let t=[...vg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Vet=class{constructor(t,e,i,n,r,s,a){this.data=e;let o="interaction"in e?e.interaction:"play";if(o==="play"||o===void 0)this.interaction=new na(t,e,i,n,r,s,a);else{if(o!=="pause"&&o!=="stop")throw new Error("Missing property");this.interaction=new ket(e)}}get playing(){return this.interaction instanceof na&&this.interaction.playing}get finished(){return!(this.interaction instanceof na)||this.interaction.finished}get paused(){return!(this.interaction instanceof na)||this.interaction.paused}play(){if(this.interaction instanceof na)return this.interaction.play();this.interaction.dispatch()}stop(){this.interaction instanceof na&&this.interaction.stop()}seek(t){this.interaction instanceof na&&this.interaction.seek(t)}toggle(t){this.interaction instanceof na?this.interaction.toggle(t):this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof na?this.interaction.playFromCurrent():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof na?Ti(this.interaction.sharedAssets,this.interaction.actionCondition)&&this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof na&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};function jet(t){let e=t.tweens[0]?.data;return{delay:e?.delay??t.delay,delayDirection:e?.delayDirection??"start-once",direction:e?.direction??t.direction,repeat:e?.repeat??t.repeat}}ke(),Pr("TimelineAnimation",({id:t,data:e,page:i,shared:n,object:r,eventType:s,actionCondition:a})=>new Vet(t,e,i.scene,n,r,s,a)),Si("timeline"),Li(),Yt(),et(),Hs();var Get={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},Het=class extends Vn{constructor(t,e,i,n,r,s){if(super(),this.eventType=t,this.data=e,this.page=i,this.shared=n,this.condition=r,this.runModeOverride=s,this.tweens=[],this.hasPlayedOnce=!1,!e.object)throw new Error("Missing property");let a=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,e.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}get contested(){let t=this.object.previousAction;return t!==null&&t!==this&&t.animating}init(){this.initialCurrentState=I1(this.object,this.object.currentState).id,this.build()}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:GE(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}build(){let t=this.data.tweens,e=[];try{let i=t[0].data.state;i!==void 0&&e.push(new YT(this.object,i,i,Get,this.shared,this.data.allowSlerp??!1,this.page));for(let n=1;n<t.length;n++){let r=t[n-1],s=t[n];e.push(new YT(this.object,r.data.state===void 0?this.currentState:r.data.state,s.data.state===void 0?this.currentState:s.data.state,s.data,this.shared,this.data.allowSlerp??!1,this.page))}}catch(i){return void(i instanceof Error&&console.error(i.message))}this.tweens=e,this.runner=new fj({...Ej(jet(this.data)),runMode:this.runMode},e.map(i=>i.runner),{claim:()=>this.claimObject(),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(){return this.object.previousAction!==this&&(this.object.previousAction?.animating===!0&&this.object.previousAction.pause(),this.object.previousAction=this,!0)}rebindTweens(){for(let t of this.tweens)try{t.rebind()}catch(e){e instanceof Error&&console.error(e.message)}this.object instanceof vn&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ji.remove(this)}play(){if(Ti(this.shared,this.condition)===!1||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(Ji.time),this.runner.isPlaying&&Ji.add(this))}pause(){this.runner?.stop(),Ji.remove(this)}stop(){this.pause();let t=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;as(this.object)?this.object.changeSelectedState(t,{shared:this.shared}):this.object.changeSelectedState(t,{scene:this.page.scene,shared:this.shared}),this.object.currentState=t}seek(t){if(Ti(this.shared,this.condition)===!1)return!1;this.runner?.seek(t)}playDirected(t){if(Ti(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(Ji.time,t),this.runner.isPlaying&&Ji.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};function Tj(t){let e=t?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(e?.length){let i=function(n){if(!n||n.length===0)return;let r;for(let s of n)s==s&&(r===void 0||s>r)&&(r=s);return r}(e);return i&&i>2?i:2}return 2}et(),ii();var Wet=class extends Vn{constructor(t,e,i,n,r){super(),this.data=t,this.page=e,this.animationControls=i,this.shared=n,this.condition=r,this.startOnceDelay=0,this.toggleIsForward=!1;let s=t.object,a=e.scene.find(t.object);a&&Array.isArray(a.identity)&&(s=a.identity[0]),this.data={...t,object:s};let o=this.animationControls.clipIdToAction[t.clipId+"/"+s];if(this.duration=o?.getClip()?.duration??1,this.data.crop2){let l=Tj(o?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=o?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=t.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(t=!1){if(Ti(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let e=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,n])=>{let r=i.split("/")[1];this.threeAnimAction!==n&&r===e&&(t?n.fadeOut(.2):n.stop())}),t&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(t){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Ot.clamp(this.threeAnimAction.time+1/60*t,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(t,e=!1){if(Ti(this.shared,this.condition)===!1)return!1;this.toggleIsForward=t??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([n,r])=>{let s=n.split("/")[1];this.threeAnimAction!==r&&s===i&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();t&&(t.duration=this.duration),this.pause()}},Cj=null;ke(),Cj=YT,Pr("Transition",({eventType:t,data:e,page:i,shared:n,actionCondition:r,runModeOverride:s})=>new Het(t,e,i,n,r,s)),Pr("Animation",({data:t,page:e,eventManager:i,shared:n,actionCondition:r})=>new Wet(t,e,i.animationControls,n,r)),Si("transitions"),ii();var vU=(t,e)=>e.some(i=>i instanceof RegExp?i.test(t):i===t),qet=class{constructor({url:t,context:e},i,n,r){if(this.controlsManager=i,this.shared=n,this.condition=r,!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:function(s,a){if(a={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...a},s=s.trim(),/^data:/i.test(s))return((h,{stripHash:u})=>{let d=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(h);if(!d)throw new Error(`Invalid URL: ${h}`);let{type:p,data:f,hash:g}=d.groups,m=p.split(";");g=u?"":g;let y=!1;m[m.length-1]==="base64"&&(m.pop(),y=!0);let v=(m.shift()||"").toLowerCase(),_=[...m.map(b=>{let[x,w=""]=b.split("=").map(S=>S.trim());return x==="charset"&&(w=w.toLowerCase(),w==="us-ascii")?"":`${x}${w?`=${w}`:""}`}).filter(Boolean)];return y&&_.push("base64"),(_.length>0||v&&v!=="text/plain")&&_.unshift(v),`data:${_.join(";")},${y?f.trim():f}${g?`#${g}`:""}`})(s,a);if(/^view-source:/i.test(s))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let o=s.startsWith("//");!o&&/^\.*\//.test(s)||(s=s.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,a.defaultProtocol));let l=new URL(s);if(a.forceHttp&&a.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(a.forceHttp&&l.protocol==="https:"&&(l.protocol="http:"),a.forceHttps&&l.protocol==="http:"&&(l.protocol="https:"),a.stripAuthentication&&(l.username="",l.password=""),a.stripHash?l.hash="":a.stripTextFragment&&(l.hash=l.hash.replace(/#?:~:text.*?$/i,"")),l.pathname){let h=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,u=0,d="";for(;;){let p=h.exec(l.pathname);if(!p)break;let f=p[0],g=p.index;d+=l.pathname.slice(u,g).replace(/\/{2,}/g,"/"),d+=f,u=g+f.length}d+=l.pathname.slice(u,l.pathname.length).replace(/\/{2,}/g,"/"),l.pathname=d}if(l.pathname)try{l.pathname=decodeURI(l.pathname)}catch{}if(a.removeDirectoryIndex===!0&&(a.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(a.removeDirectoryIndex)&&a.removeDirectoryIndex.length>0){let h=l.pathname.split("/"),u=h[h.length-1];vU(u,a.removeDirectoryIndex)&&(h=h.slice(0,-1),l.pathname=h.slice(1).join("/")+"/")}if(l.hostname&&(l.hostname=l.hostname.replace(/\.$/,""),a.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(l.hostname)&&(l.hostname=l.hostname.replace(/^www\./,""))),Array.isArray(a.removeQueryParameters))for(let h of[...l.searchParams.keys()])vU(h,a.removeQueryParameters)&&l.searchParams.delete(h);if(a.removeQueryParameters===!0&&(l.search=""),a.sortQueryParameters){l.searchParams.sort();try{l.search=decodeURIComponent(l.search)}catch{}}a.removeTrailingSlash&&(l.pathname=l.pathname.replace(/\/$/,""));let c=s;return s=l.toString(),!a.removeSingleSlash&&l.pathname==="/"&&!c.endsWith("/")&&l.hash===""&&(s=s.replace(/\/$/,"")),(a.removeTrailingSlash||l.pathname==="/")&&l.hash===""&&a.removeSingleSlash&&(s=s.replace(/\/$/,"")),o&&!a.normalizeProtocol&&(s=s.replace(/^http:\/\//,"//")),a.stripProtocol&&(s=s.replace(/^(?:https?:)?\/\//,"")),s}(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;Xc?window.location.assign(this.url):(this.context==="tab"||oF&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(ae[0]),ae.splice(0,ae.length))}},Xet=class{constructor(t,e,i,n,r){this.data=t,this.page=e,this.shared=i,this.eventManager=n,this.condition=r}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),W3(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},1e3*(this.data.delay??0))}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};et();var $et={type:"beginState"},yU={type:"completeState",isfromEntity:!1},_U={type:"requestRender"},Yet=class extends Vn{constructor(t,e,i,n){super(),this.data=t,this.page=e,this.shared=i,this.condition=n,this.toggleIsForward=!1,this.posStart=new C,this.posEnd=new C,this.qStart=new qt,this.qEnd=new qt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(t=!1){if(!this.data.animate)return;let e=this.page.scene.find(this.data.targetCamera);if(!e||!e.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let i={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:Mj(this.data)},n=r=>{let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,r),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,r),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*r,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(_U),r===1&&s.dispatchEvent(yU)};this.runner=new mj(i,n,()=>{this.data.runMode!=="Toggle"||this.toggleIsForward?(this.posEnd.copy(e.position),this.qEnd.copy(e.quaternion),this.zoomEnd=e.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(e.uuid)):this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)),this.page.activeCamera.dispatchEvent($et),n(0)})}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ji.remove(this)}start(){!this.runner||(this.runner.start(Ji.time),Ji.add(this))}switchCamera(t){let e=this.page.activeCamera,i=this.page.scene.find(t);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),e.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Ti(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.start()):this.switchCamera(this.data.targetCamera)},1e3*this.data.delay)}catch{}}pause(){this.runner?.stop(),Ji.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(t){if(Ti(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,t!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=t??!this.toggleIsForward,this.buildAnimation(!0),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=t??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(),this.start()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(yU),this.page.activeCamera.dispatchEvent(_U))},1e3*this.data.delay)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};a3();var Zet=class{constructor(t,e,i,n){this.data=t,this.page=e,this.shared=i,this.condition=n}dispatch(){if(Ti(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(t=>{this.shared.getVariable(t);let e=this.shared.data.variables.data(t)?.value;e!==void 0&&this.shared.updateVariable(t,e),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(qA(t))})}dispose(){}};ke(),Pr("Link",({data:t,eventManager:e,shared:i,actionCondition:n})=>new qet(t,e.controlsManager,i,n)),Pr("Reset",({data:t,page:e,shared:i,eventManager:n,actionCondition:r})=>new Xet(t,e,i,n,r)),Pr("SwitchCamera",({data:t,page:e,shared:i,actionCondition:n})=>new Yet(t,e,i,n)),Pr("ClearLocalStorage",({data:t,page:e,shared:i,actionCondition:n})=>new Zet(t,e,i,n)),Si("misc-actions"),ke(),qr(),ol(),v3(),a3();var Nu,BM,Ket=class{get sharedAssets(){return this.shared}constructor(t,e={},i=!0){this.shared=new ab(t.shared,e,!0,i),this.scene=new ux(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof un&&!t.uiScene&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.scene.releaseInstanceGroups(),this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Ai&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};function bU(t){return BM||(BM=Promise.resolve().then(()=>(aY(),r6)).then(({DRACOLoader:e})=>((Nu=new e).setDecoderPath(t!==void 0?`${t}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload(),Nu.decoderPending))),BM}async function Qet(t){if(Nu){let e,i={attributeIDs:Nu.defaultAttributeIDs,attributeTypes:Nu.defaultAttributeTypes,useUniqueIDs:!1};try{e=await Nu.decodeGeometry(new Int8Array(t).buffer,i)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function xU(t){for(let e of t){let i=await Qet(e.geometry.data.draco);if(i){let n=e.geometry.data;i.index&&(n.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let r={};i.attributes.forEach(({name:s,array:a,itemSize:o})=>{r[s]={array:a,itemSize:o,type:"Float32Array",normalized:!1}}),n.attributes=r,n.draco=void 0}}}function Jet(t){let e=this._clip.duration,i=this._clip.start??0,n=this.loop,r=this.time+t,s=this._loopCount,a=n===p_;if(t===0)return s===-1||!a||1&~s?r:e-(r-i);if(n===QM){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=e||r<i){let o=Math.floor((r-i)/(e-i));r-=(e-i)*o,s+=Math.abs(o);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a||(r=t>0?e:i,this.repetitions===1&&(r=e)),this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&!(1&~s))return e-(r-i)}return r}v3(),Ye(),ex(),Zg(),t0(),$C(),xh(),rx(),Jk(),n6(),ya(),et(),et();var wU=!1,tit=class{constructor(t,e,i,n){this.scene=t,this.requestRender=e,this.updateDisplayProgress=i,this.animationInspectorState=n,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=r=>{r.data.type==="Empty"&&Array.isArray(r.data.animations)&&r.data.animations.forEach((s,a)=>{let o=s[0]+"/";if(Array.isArray(r.identity)?o+=r.identity[0]:o+=r.uuid,this.clipIdToAction[o])return;let l=n1.parse(JSON.parse(s[2]));r.animations[a]=l;let c=this.mixer.clipAction(l,r);wU===!1&&(Object.getPrototypeOf(c)._updateTime=Jet,wU=!0),c.clampWhenFinished=!0,this.clipIdToAction[o]=c})},this.mixer=new Rz(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let i=this.scene.find(e);if(!i)return;let n=i.animations.find(s=>s.uuid===t);if(!n)return;let r=this.clipIdToAction[t];!r||(r.stop(),this.mixer.uncacheClip(n),delete this.clipIdToAction[t],i.animations=i.animations.filter(s=>s.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.scene.markShadowsDirty(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=JM}),this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,i=this.clipIdToAction[e];if(i)return t&&(t.repeat>=0&&(i.repetitions=t.repeat+1),(t.direction==="pingpong"||t.direction==="pingpong-rewind")&&t.repeat!==0&&(i.loop=p_)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.scene.markShadowsDirty(),this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return Tj(this.activeClip??void 0)}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let i=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(t/(this.maxFrames-1),.9999)*this.activeClip.duration),this.scene.markShadowsDirty(),this.requestRender(),i&&(this.clipIdToAction[e].paused=!0)}};al(),ol(),NN(),Jc(),Kg(),LN(),o6();var eit={bloom:()=>Promise.resolve().then(()=>(uY(),dY)),chromaticAberration:()=>Promise.resolve().then(()=>(mY(),fY)),vignette:()=>Promise.resolve().then(()=>(yY(),vY)),noise:()=>Promise.resolve().then(()=>(xY(),bY)),hueSaturation:()=>Promise.resolve().then(()=>(MY(),SY)),brightnessContrast:()=>Promise.resolve().then(()=>(TY(),AY)),depthOfField:()=>Promise.resolve().then(()=>(DY(),PY)),pixelation:()=>Promise.resolve().then(()=>(OY(),IY))};function iit(t){return function(e,i){return Promise.all(e.map(n=>i[n]?.().catch(r=>{console.warn(`[spline] Failed to load the ${n} postprocessing effect (webgl); the effect will be skipped.`,r)}))).then(()=>{})}(t,eit)}ii();var nit=vp(LY(),1);function Fy(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function rit(t){return{id:t.uuid,name:t.name,type:t.object.data?.type??t.object.type,visible:t.playModeVisible!==!1,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ot.RAD2DEG,y:t.rotation.y*Ot.RAD2DEG,z:t.rotation.z*Ot.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},spawned:!0}}function Ny(t){return{id:t.uuid,name:t.name,type:t.type??"Object",visible:t.visible,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ot.RAD2DEG,y:t.rotation.y*Ot.RAD2DEG,z:t.rotation.z*Ot.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}}function Pj(t,e,i){let n=a=>t.findObjectById(a)??t.findObjectByName(a),r=new Map,s=a=>{let o=r.get(a);if(o)return o;for(let l of r.values())if(l.name===a)return l};return{setVariable:(a,o)=>a in t.getVariables()?(t.setVariable(a,o),{ok:!0}):{ok:!1,warning:`spline.setVariable: no variable named "${a}" in this scene.`},getVariable:a=>t.getVariable(a),getVariables:()=>t.getVariables(),getAllObjects:()=>t.getAllObjects().map(Ny),findObject:a=>{let o=n(a);return o?Ny(o):void 0},getGeometry:(a,o)=>{if(!i)return{warning:"spline.getGeometry: not available in this runtime integration."};let l=s(a),c=l?l.object:(()=>{let p=n(a);return p?i.findEntity(p.uuid):void 0})();if(!c)return{warning:`spline.getGeometry: no object named "${a}" (names/ids come from getAllObjects).`};let h,u=l??c;o.space==="world"&&(u.updateWorldMatrix?.(!0,!1),h=u.matrixWorld?.elements);let d=function(p,f){let g=p?.getAttribute("position");if(!g||!g.count)return null;let m=g.count,y=f??null,v=p.getIndex?.()??null,_=Math.floor((v?v.count:m)/3),b=1/0,x=1/0,w=1/0,S=-1/0,A=-1/0,E=-1/0,P=new Float32Array(3*m);for(let D=0;D<m;D++){let U=g.getX(D),V=g.getY(D),k=g.getZ(D);y&&([U,V,k]=lX(y,U,V,k)),U<b&&(b=U),V<x&&(x=V),k<w&&(w=k),U>S&&(S=U),V>A&&(A=V),k>E&&(E=k),P[3*D]=U,P[3*D+1]=V,P[3*D+2]=k}let T={space:y?"world":"local",vertexCount:m,triangleCount:_,indexed:v!==null,bounds:{min:[b,x,w],max:[S,A,E],size:[S-b,A-x,E-w]},vertices:P};if(v){let D=new Uint32Array(v.count);for(let U=0;U<v.count;U++)D[U]=v.getX(U);T.indices=D}let R=p.getAttribute("normal");if(R&&R.count===m){let D=y?function(U){let V=U[0],k=U[4],Y=U[8],$=U[1],nt=U[5],Q=U[9],rt=U[2],gt=U[6],at=U[10],ht=V*(nt*at-Q*gt)-k*($*at-Q*rt)+Y*($*gt-nt*rt);if(!isFinite(ht)||Math.abs(ht)<1e-12)return null;let ct=1/ht,q=[(nt*at-Q*gt)*ct,(Y*gt-k*at)*ct,(k*Q-Y*nt)*ct,(Q*rt-$*at)*ct,(V*at-Y*rt)*ct,(Y*$-V*Q)*ct,($*gt-nt*rt)*ct,(k*rt-V*gt)*ct,(V*nt-k*$)*ct];return[q[0],q[3],q[6],q[1],q[4],q[7],q[2],q[5],q[8]]}(y):void 0;if(!y||D){let U=new Float32Array(3*m);for(let V=0;V<m;V++){let k=R.getX(V),Y=R.getY(V),$=R.getZ(V);if(D){let nt=D[0]*k+D[1]*Y+D[2]*$,Q=D[3]*k+D[4]*Y+D[5]*$,rt=D[6]*k+D[7]*Y+D[8]*$,gt=Math.hypot(nt,Q,rt);gt>1e-12?(k=nt/gt,Y=Q/gt,$=rt/gt):(k=nt,Y=Q,$=rt)}U[3*V]=k,U[3*V+1]=Y,U[3*V+2]=$}T.normals=U}}let L=p.getAttribute("uv");if(L&&L.count===m){let D=new Float32Array(2*m);for(let U=0;U<m;U++)D[2*U]=L.getX(U),D[2*U+1]=L.getY(U);T.uvs=D}return T}(c.geometry,h);return d?{data:{id:u.uuid,name:u.name,geometry:c.data?.geometry?.type,...d}}:{warning:`spline.getGeometry: "${u.name}" has no readable geometry \u2014 only meshes do (lights, cameras and groups have none; read a group's child meshes instead).`}},updateObject:(a,o)=>{let l=s(a);if(l){let{position:m,rotation:y,scale:v,visible:_}=o;return m&&(typeof m.x=="number"&&(l.position.x=m.x),typeof m.y=="number"&&(l.position.y=m.y),typeof m.z=="number"&&(l.position.z=m.z)),y&&(typeof y.x=="number"&&(l.rotation.x=y.x*Ot.DEG2RAD),typeof y.y=="number"&&(l.rotation.y=y.y*Ot.DEG2RAD),typeof y.z=="number"&&(l.rotation.z=y.z*Ot.DEG2RAD)),v&&(typeof v.x=="number"&&(l.scale.x=v.x),typeof v.y=="number"&&(l.scale.y=v.y),typeof v.z=="number"&&(l.scale.z=v.z)),typeof _=="boolean"&&(l.playModeVisible=_),l.updateMatrix(),t.requestRender(),!0}let c=n(a);if(!c)return!1;let{position:h,rotation:u,scale:d,visible:p,geometry:f,material:g}=o;if(f&&typeof f=="object"&&i){let m=i.findEntity(c.uuid);if(m){let{vertices:y,normals:v,uvs:_,indices:b,...x}=f;Fy(y)&&i.shared.updateEntityGeometryVertices(m,{vertices:y,normals:Fy(v)?v:void 0,uvs:Fy(_)?_:void 0,indices:Fy(b)?b:void 0}),Object.keys(x).length>0&&i.shared.updateEntityGeometryParams(m,x)}}if(g&&typeof g=="object"&&i){let m=i.findEntity(c.uuid);m&&i.shared.updateEntityMaterialParams(m,g)}return h&&(typeof h.x=="number"&&(c.position.x=h.x),typeof h.y=="number"&&(c.position.y=h.y),typeof h.z=="number"&&(c.position.z=h.z)),u&&(typeof u.x=="number"&&(c.rotation.x=u.x*Ot.DEG2RAD),typeof u.y=="number"&&(c.rotation.y=u.y*Ot.DEG2RAD),typeof u.z=="number"&&(c.rotation.z=u.z*Ot.DEG2RAD)),d&&(typeof d.x=="number"&&(c.scale.x=d.x),typeof d.y=="number"&&(c.scale.y=d.y),typeof d.z=="number"&&(c.scale.z=d.z)),typeof p=="boolean"&&(c.visible=p),t.requestRender(),!0},createObject:async(a,o)=>Ny(await t.createObject(a,o)),createCustomMaterial:a=>t.createCustomMaterial(a),setMaterial:(a,o)=>t.setMaterial(a,o),cloneObject:(a,o)=>Ny(t.cloneObject(a,o)),removeObject:a=>t.removeObject(a),spawnObject:(a,o)=>{if(!i)return{warning:"spline.spawnObject: not available in this runtime integration."};let l=n(a),c=l?i.findEntity(l.uuid):void 0;if(!c)return{warning:`spline.spawnObject: no object named "${a}" to use as a template.`};if(r.size>=500)return{warning:"spline.spawnObject: spawn budget reached (500 live copies) \u2014 destroyObject old copies (or reuse them) instead of spawning more."};let h=i.shared.spawnRuntimeClone(c,o??{});return h?(r.set(h.uuid,h),t.requestRender(),{object:rit(h)}):{warning:`spline.spawnObject: "${a}" cannot be spawned from.`}},destroyObject:a=>{let o=s(a);return!(!i||!o||(r.delete(o.uuid),i.shared.destroyRuntimeClone(o),t.requestRender(),0))},setInstanceTransforms:(a,o)=>{if(!i)return-1;let l=n(a),c=l?i.findEntity(l.uuid):void 0;if(!c)return-1;let h=i.shared.setEntityInstanceTransforms(c,o);return h>=0&&t.requestRender(),h},emitEvent:(a,o,l)=>{let c=n(o);return c?(l?c.emitEventReverse(a):c.emitEvent(a),{ok:!0}):{ok:!1,warning:`spline.emitEvent: no object named "${o}".`}},requestRender:()=>t.requestRender(),addSplineEventListener:(a,o)=>{let l=c=>{o({target:{id:c.target?.id??"",name:c.target?.name??""}})};return t.addEventListener(a,l),()=>t.removeEventListener(a,l)},getCanvas:()=>e}}et(),ii();var Dj=class{constructor(t,e,i){this.iframe=t,this.bridge=e,this.observer=i}static mount(t,e,i,n){if(typeof document>"u")return null;let r=e.parentElement;if(!r)return null;getComputedStyle(r).position==="static"&&(r.style.position="relative");let s=document.createElement("iframe");s.setAttribute("sandbox","allow-scripts allow-forms allow-pointer-lock"),s.title="Spline HTML content";let a=s.style;a.position="absolute",a.border="0",a.background="transparent",a.pointerEvents="auto",a.colorScheme="normal";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(r),s.srcdoc=function(h){let u=`<script>${cF}<\/script>`,d=/<head(\s[^>]*)?>/i.exec(h);if(d){let f=d.index+d[0].length;return h.slice(0,f)+u+h.slice(f)}let p=/<html(\s[^>]*)?>/i.exec(h);if(p){let f=p.index+p[0].length;return h.slice(0,f)+`<head>${u}</head>`+h.slice(f)}return u+h}(i),r.insertBefore(s,e.nextSibling);let c=new uF(s,Pj(t,e,n),(h,u)=>{h==="warn"?console.warn(`[spline html] ${u}`):h==="error"&&console.error(`[spline html] ${u}`)});return c.attach(),new Dj(s,c,l)}dispose(){this.bridge.dispose(),this.observer.disconnect(),this.iframe.remove()}};ii();var O1="data-spline-html-content",sit=`
9931
9931
  [${O1}] { pointer-events: none; }
9932
9932
  [${O1}] > * { pointer-events: auto; }
9933
9933
  [${O1}] [data-spline-passthrough] { pointer-events: none; }
9934
- `,Rj=class{constructor(t,e,i,n,r){this.container=t,this.host=e,this.observer=i,this.previousSplineGlobal=n,this.removeLateLifecycleShim=r}static mount(t,e,i,n){if(typeof document>"u")return null;let r=e.parentElement;if(!r)return null;getComputedStyle(r).position==="static"&&(r.style.position="relative");let s=document.createElement("div");s.setAttribute(O1,"");let a=s.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(r);let c=document.createElement("style");c.textContent=sit,s.appendChild(c);let h=new DOMParser().parseFromString(i,"text/html"),u=Array.from(h.querySelectorAll("script"));for(let v of u)v.remove();for(let v of Array.from(h.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&s.appendChild(v);for(;h.body.firstChild;)s.appendChild(h.body.firstChild);r.insertBefore(s,e.nextSibling);let d=new Map,p=new mC(Pj(t,e,n),(v,_)=>{v==="warn"?console.warn(`[spline html] ${_}`):v==="error"&&console.error(`[spline html] ${_}`)},(v,_)=>{let b=d.get(v);if(b)for(let x of b)try{x(_)}catch(w){console.error(w)}}),f=(v,_)=>{try{return Promise.resolve(p.execute(v,_))}catch(b){return Promise.reject(b)}},g={ready:Promise.resolve(),setVariable:(v,_)=>f("setVariable",[v,_]),setVariables:v=>f("setVariables",[v]),getVariable:v=>f("getVariable",[v]),getVariables:()=>f("getVariables",[]),getAllObjects:()=>f("getAllObjects",[]),findObjectByName:v=>f("findObjectByName",[v]),findObjectById:v=>f("findObjectById",[v]),getGeometry:(v,_)=>f("getGeometry",[v,_??{}]),updateObject:(v,_)=>f("updateObject",[v,_]),createObject:(v,_)=>f("createObject",[v,_??{}]),createCustomMaterial:v=>f("createCustomMaterial",[v]),setMaterial:(v,_)=>f("setMaterial",[v,_]),cloneObject:(v,_)=>f("cloneObject",[v,_??{}]),removeObject:v=>f("removeObject",[v]),spawnObject:(v,_)=>f("spawnObject",[v,_??{}]),destroyObject:v=>f("destroyObject",[v]),setInstanceTransforms:(v,_)=>f("setInstanceTransforms",[v,_??null]),emitEvent:(v,_)=>f("emitEvent",[v,_]),emitEventReverse:(v,_)=>f("emitEventReverse",[v,_]),requestRender:()=>f("requestRender",[]),addEventListener:(v,_)=>{if(typeof _!="function")return;let b=d.get(v);b||(b=new Set,d.set(v,b),f("listenEvent",[v])),b.add(_)},removeEventListener:(v,_)=>{let b=d.get(v);!b||(b.delete(_),b.size===0&&(d.delete(v),f("unlistenEvent",[v])))}},m=window.spline;window.spline=g;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],_=(x,w)=>{let S=new Set,A=x.addEventListener.bind(x),E=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(P,T,R)=>{if(A(P,T,R),!w.includes(P)||T==null)return;let L={type:P,listener:T};S.add(L),queueMicrotask(()=>{!S.delete(L)||((D,U,V)=>{let k=new Event(V);try{typeof U=="function"?U.call(D,k):U.handleEvent?.(k)}catch(Y){console.error(Y)}})(x,L.listener,L.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(P,T,R)=>{E(P,T,R);for(let L of S)L.type===P&&L.listener===T&&S.delete(L)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,S.clear()})};_(document,["DOMContentLoaded"]),_(window,["load"]);let b=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(w){console.error(w)}})}}),v.push(()=>{b?Object.defineProperty(window,"onload",b):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of u){let _=document.createElement("script");for(let b of Array.from(v.attributes))_.setAttribute(b.name,b.value);v.src?_.async=!1:_.textContent=v.textContent,s.appendChild(_)}return new Rj(s,p,l,m,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline!==void 0&&(window.spline=this.previousSplineGlobal)}};function Ij(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function SU(t){if(typeof t.material=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(!Ij(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=Ak()?.NodeMaterial;if(i!==void 0&&e instanceof i)return{options:{...t,material:void 0},material:e};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => \u2026) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, \u2026).")}if(e.isShaderMaterial===!0)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend \u2014 port the shader to TSL with app.createCustomMaterial((three) => \u2026), or use a built-in material (MeshStandardMaterial, \u2026).");return{options:{...t,material:void 0},material:e}}Yt(),Ye(),et(),wk(),ya(),Ye(),Yt(),WX(),bh();var ait=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),MU="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",oit={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},lit={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},hit={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data \u2014 clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime \u2014 clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto \u2014 clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame \u2014 clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor \u2014 clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},cit={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},dit={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function Vg(t,e){return t===void 0?[e[0],e[1],e[2]]:Array.isArray(t)?[t[0]??e[0],t[1]??e[1],t[2]??e[2]]:[t.x??e[0],t.y??e[1],t.z??e[2]]}function Oj(t){return typeof t=="number"?[t,t,t]:Vg(t,[1,1,1])}function KT(t){let e=new gn(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function EU(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return ki.defaultColorMaterial(AU(Rr),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(e.shared.materials))if(a===i||o.name===i)return a;if(function(a){let o=a.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)||/^(rgb|hsl)a?\(/.test(o)||Jt.NAMES[o]!==void 0}(i))return ki.defaultColorMaterial(KT(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(a){let o=Object.entries(a.shared.materials).map(([,l])=>`'${l.name}'`).filter(l=>l!=="'undefined'");return o.length?o.join(", "):"(none)"}(e)}) and is not a valid CSS color.`)}if(typeof i=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(Ij(i))throw new Error("createObject: a three.js material instance cannot be stored in the document \u2014 this entry point does not support it.");let n=i.color!==void 0?KT(i.color):AU(Rr),r=ki.defaultColorMaterial(n,"physical","layer1","layer2"),s=r.layers.find(a=>a.data.type==="light");if(s){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(s.data,a)}if(i.alpha!==void 0){let a=r.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return r}function AU(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function uit(t){let e=Ho.defaultData("TextGeometry"),{text:i,...n}=t,r=n.fontSize;return r!==void 0&&n.width===void 0&&(n.width=350*r/16),r!==void 0&&n.height===void 0&&(n.height=50*r/16),Object.assign(e,n),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function ky(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function pit(t,e){return oN({userData:{type:t,...kA[t].normalizeInputs({parameters:e})}})}function fit(t,e,i){let{objectType:n,geometryType:r}=t,s=function(l){let c={};for(let[h,u]of Object.entries(l))!ait.has(h)&&u!==void 0&&(c[h]=u);return c}(e),a={states:new Vt,events:new Vt};if(n==="Mesh"&&r){if(r==="NonParametricGeometry"){let{geometry:l,doubleSide:c}=function(h){let u=ky(h.vertices);if(!u||u.length<9||u.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let d=u.length/3;if(d>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${d}); keep it under 60000.`);let p=ky(h.indices);if(p&&p.length){let _=p.find(b=>!Number.isInteger(b)||b<0||b>=d);if(_!==void 0)throw new Error(`createObject('CustomMesh'): index ${_} is out of range (mesh has ${d} vertices).`)}else p=null;let f=new Gt;f.setAttribute("position",new Nt(u,3));let g=ky(h.normals),m=g!==null&&g.length===u.length;m&&f.setAttribute("normal",new Nt(g,3));let y=ky(h.uvs);y&&y.length===2*d&&f.setAttribute("uv",new Nt(y,2));let v=!1;if(!m){let _=p??Array.from({length:d},(w,S)=>S),{closed:b,inverted:x}=function(w,S){let A=w.length/3,E=new Map,P=new Array(A);for(let D=0;D<A;D++){let U=`${Math.round(1e4*w[3*D])},${Math.round(1e4*w[3*D+1])},${Math.round(1e4*w[3*D+2])}`,V=E.get(U);V===void 0?(E.set(U,D),P[D]=D):P[D]=V}let T=new Map;for(let D=0;D+2<S.length;D+=3){let U=P[S[D]],V=P[S[D+1]],k=P[S[D+2]];for(let[Y,$]of[[U,V],[V,k],[k,U]]){if(Y===$)continue;let nt=Y<$?Y+"_"+$:$+"_"+Y;T.set(nt,(T.get(nt)??0)+1)}}let R=T.size>0;for(let D of T.values())if(D!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let L=0;for(let D=0;D+2<S.length;D+=3){let U=3*S[D],V=3*S[D+1],k=3*S[D+2],Y=w[U],$=w[U+1],nt=w[U+2],Q=w[V],rt=w[V+1],gt=w[V+2],at=w[k],ht=w[k+1],ct=w[k+2];L+=Y*(rt*ct-gt*ht)+$*(gt*at-Q*ct)+nt*(Q*ht-rt*at)}return{closed:!0,inverted:L<0}}(u,_);if(b&&x){for(let w=0;w+2<_.length;w+=3){let S=_[w+1];_[w+1]=_[w+2],_[w+2]=S}p=_}else b||(v=!0)}return p&&f.setIndex(p),m||f.computeVertexNormals(),{geometry:oN({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:f.toJSON().data}),doubleSide:v}}(s);Object.assign(a,Ha.defaultData,{geometry:l,materials:[EU(e,i)]}),c&&(a.side=2)}else Object.assign(a,Ha.defaultData,{geometry:r==="TextGeometry"?uit(s):pit(r,s),material:EU(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else n==="Empty"?Object.assign(a,V_.defaultData):(Object.assign(a,j_.defaultData(n),s),e.color!==void 0&&(a.color=KT(e.color)));a.visible=e.visible??!0,a.position=Vg(e.position,[0,0,0]),a.rotation=Vg(e.rotation,[0,0,0]),a.scale=Oj(e.scale);let o=(r&&cit[r])??dit[n]??n;return a.name=e.name??Lj(o,i.scene.objects),a}function Lj(t,e){let i=new Set;if(e.traverse((r,s)=>{i.add(s.name??"")}),!i.has(t))return t;let n=2;for(;i.has(`${t} ${n}`);)n++;return`${t} ${n}`}function Bj(t,e){let i=Ot.generateUUID();if(t.data.type==="Component")return{data:{...Qo.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let n=t.data;return n.type==="Empty"&&n.animations?.length&&(n={...n,animations:n.animations.map(([r,s,a])=>{let o=Ot.generateUUID(),l=a.indexOf(r);return[o,s,l!==-1?a.slice(0,l)+o+a.slice(l+r.length):a]})}),{...t,id:i,data:n,children:t.children.map(r=>Bj(r,e))}}function mit(t){let e={};return function(i,n){return Hu(i,n,null)??i}(Bj(t,e),e)}function git(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(vit)??[],n=e.layers?.find(r=>r.type==="light");return{layers:i,alpha:n?.node.alphaOverride?.value??1}}function vit(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}bh(),Li(),qC(),ya();var um=new gn(0,0,0,1),yit={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};Yt(),Yt();var _it=new it;function TU(t){let e=new gn(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var Uj=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:n,renderer:r,htmlContentMode:s="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<hN?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),Hc(o)&&(this._renderer?.isWebGPUSplineRenderer!==!0&&o.warnClassicFallbackOnce(),o.isSimulating&&(o.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let o=Math.min(1,1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration);this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=o,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),this._renderer.lastFrameIncomplete===!0&&(this._skipRender=!1),this._renderer.skyAnimationActive===!0&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=_it.set(this._viewportWidth,this._viewportHeight)),a){let o=this._viewportWidth,l=this._viewportHeight;this._renderer.setSize(o-1,l-1,!1),this._renderer.setSize(o,l,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=Cg(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=s,this.renderMode=e?"auto":i,n!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(n)),this._rendererBackend=r??"webgl",r===void 0){let a=null;try{a=new URLSearchParams(window.location.search).get("renderer")}catch{}a==="webgpu"||a==="webgl"||a==="webgl2"?this._rendererBackend=a==="webgl2"?"webgl":a:(this._rendererAuto=!0,this._rendererBackend="webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(BY(),T6)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",FR,!0),a.addEventListener("pointerdown",iv,!0),a.addEventListener("pointermove",iv,!0),a.addEventListener("pointerup",Dd,!0),a.addEventListener("pointercancel",Dd,!0),a.addEventListener("pointerleave",Dd,!0),window.addEventListener("keydown",NR,!0),window.addEventListener("keyup",kR,!0)}(t)}async _createRenderer(){this._rendererBackend,this._rendererBackend;{let{SplineRenderer:t,rendererGlobals:e}=await Promise.resolve().then(()=>(JL(),_T));try{new URLSearchParams(window.location.search).get("taa")==="off"&&(e.taaEnabled.value=!1)}catch{}return new t({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"})}}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let t=window.devicePixelRatio||1,e=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=e*t,this.canvas.height=i*t;let n=this.canvas.getContext("2d");n&&(n.scale(t,t),n.fillStyle="rgba(127, 127, 127, 0.85)",n.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",n.textAlign="center",n.textBaseline="middle",n.fillText("This scene requires a WebGPU-capable browser.",e/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(t,e,i){(function(r){let s="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(s+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(s)})(t),this.disposed=!1;let n=await(await fetch(t,i)).arrayBuffer();await this.start(n,{variables:e})}async start(t,{interactive:e=!0,variables:i}={}){if(this.disposed)return;Ji.init();let n=await async function(d){let[p,f]=Tm(Pg.deserialize(new Uint8Array(d)));if((p.schema??0)!==131){let{updateDocumentSchema:g}=await Promise.resolve().then(()=>($b(),tN));g(p)}return f.result().data}(t);this._data=n;let r=function(d){let p=[];return d.scene.objects.traverse((f,g)=>{g.type==="Mesh"&&g.geometry.type==="NonParametricGeometry"&&g.geometry.data.draco!==void 0&&p.push(g)}),p}(n);n.version&&(0,nit.default)(n.version,"2.0.42")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath!==void 0&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(d){aT=d}(this._wasmPath));let s=async function(){}();await Promise.all([s,r.length&&bU(this._wasmPath),k4(n)&&QX(this._wasmPath),z$(n)&&P$(this._wasmPath),Gc.physicsEnabled(n.scene.objects)&&cJ(this._wasmPath),XO(n)&&nB(),Y4(n)&&nY(),l$(n)&&o$(),Y5(n)&&s.then(()=>fA()?.loadHanaUIRUNTIME()),nJ(n)&&AJ(this._wasmPath)].filter(Boolean)),r.length&&await xU(r),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=n.scene.publish.renderer;if(this._rendererAuto&&a==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&a==="webgpu")return void this._failWebGPURequired();let o=function(d){let p=new Set;return d.scene.objects.traverse((f,g)=>{if(g.type!=="Page")return;let m=g.postprocessing;if(m&&typeof m=="object"&&m.enabled===!0)for(let[y,v]of Object.entries(m))y!=="enabled"&&v&&typeof v=="object"&&v.enabled===!0&&p.add(y)}),[...p]}(n);this._rendererBackend,this._rendererBackend!=="webgpu"&&await Promise.all([Promise.resolve().then(()=>(JL(),_T)),iit(o)]),function(d){ax=d}((this._rendererBackend,"webgl"));let l=new Ket(n);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:d}=await Promise.resolve().then(()=>(gK(),hV)),p=performance.now();d(n,l.scene);let f=performance.now();console.log("Merged geometries in ",f-p," ms")}k4(n)&&this._scene.traverse(d=>{to(d)&&d.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(d=>{Bu(d)&&d.pendingMediaLoad&&d.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(d=>{d.type==="ParticleSystem"&&(d.wakeUp(),d.data.autoPlay?d.start():d.stop()),Hc(d)&&d.setPlayMode(!0)});let c=Object.keys(n.shared.fonts).flatMap(d=>{let p=this._sharedAssetsManager.getFont(d);return p?[p.loadingPromise]:[]});if(Promise.all(c).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),XO(n)&&function(d){if(Gc.physicsEnabled(d.scene.objects))return!0;let p=!1;return d.scene.objects.traverse((f,g)=>{if(g.events){if(Array.isArray(g.events)){for(let m of g.events)if(m.data.disabled!==!0&&m.data.type==="GameControl"&&m.data.collisionEnabled){p=!0;break}}else for(let m of Object.values(g.events))if(m.disabled!==!0&&m.type==="GameControl"&&m.collisionEnabled){p=!0;break}}}),p}(n)&&await Promise.all(c),Y5(n)){let d=[];this._scene.traverseEntity(p=>{(Cr(p)||p instanceof un)&&p.uiCanvas&&d.push(p.uiCanvas)}),await Promise.all(d.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),W3(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=await this._createRenderer()),!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0;let d=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(d()?n.scene.publish.settings.web.pixelRatioMobile:n.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),n.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");await f.loadPromise;let g=f.getTexture(1001);this._renderer.pipeline.setWatermark(g)}}Y4(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let h=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(h.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=h.size[0],this._viewportHeight=h.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new KK(this._renderer,this._camera,new it(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),e){let d=new DK(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new fJ(d),this._animationControls=new tit(this._scene,this._requestRenderAutoMode),this._eventManager=new WK(n.scene.publish,this._controls,this._animationControls,d,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0;let u=n.scene.publish.htmlContent?.html;if(e&&u&&this._htmlContentMode!=="none"){let d={shared:this._sharedAssetsManager,findEntity:p=>this._scene?.getObjectByProperty("uuid",p)??this._scene?.getObjectByName(p)};this._htmlContentOverlay=(this._htmlContentMode==="inline"?Rj.mount(this,this.canvas,u,d):Dj.mount(this,this.canvas,u,d))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,n]of e)this.setVariable(i,n)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){let n=e;typeof i.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof i.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(n=e.toString());let r=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(i.id,r),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let i=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(i)}}_getVariableValue(t){return typeof t!="string"&&_r.isTextValue(t)?_r.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(i=>i.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(!(e.uuid===Zc||this._scene.isInvisibleObjects(e)||e instanceof un)){let i=this._createProxyObject(e);i&&t.push(i)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof EV&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=TU(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,hg&&hg.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{L2.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(t){t.removeEventListener("pointerdown",FR,!0),t.removeEventListener("pointerdown",iv,!0),t.removeEventListener("pointermove",iv,!0),t.removeEventListener("pointerup",Dd,!0),t.removeEventListener("pointercancel",Dd,!0),t.removeEventListener("pointerleave",Dd,!0),window.removeEventListener("keydown",NR,!0),window.removeEventListener("keyup",kR,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Ji.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e,i=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);t.traverseAncestors(h=>{h instanceof un&&(e=h.name)});let n=this._sharedAssetsManager,r={shared:n,scene:this._scene},s=h=>{if(h===null||h==="Base State")return null;if(h&&t.data.states){let u=t.data.states.find(d=>d.data.name===h);return u?u.id:void 0}},a="material"in t?t.material:void 0,o=t.materialOverride,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,material:o??(a?git(a):void 0),parentUuid:t.parent instanceof un||t instanceof ux?void 0:t.parent?.uuid,emitEvent(h){t.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){t.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){t.visible&&(t.visible=!1,r.shared.requestRender())},show(){t.visible||(t.visible=!0,r.shared.requestRender())},get state(){let h=t.stateSelection;if(h!==null)return t.data.states.find(({id:u})=>u===h)?.data.name},set state(h){let u;if(h!==void 0){let d=typeof h=="string"?t.data.states.find(({id:p})=>p===h):t.data.states[h];if(d)u=d.id;else{let p=typeof h=="string"?s(h):void 0;p&&(u=p)}}t.changeSelectedState(u??null,r),t.currentState=u??null,t.dispatchEvent({type:"completeState",state:u??null}),r.shared.requestRender()},transition(h){let u=Cj;if(u===null)return Gn("transitions","obj.transition()"),{transition(b){return this},play(){return this},pause(){return this},reset(){return this},seek(b){return this}};let d,p,f=this,g=[],m=!1,y=()=>{p=new fj({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},g.map(b=>b.runner))},v={update(b){p?.update(b),p?.isPlaying!==!0&&Ji.remove(v)}},_={transition({from:b,to:x,duration:w,delay:S,...A}){let E=s(b);E===void 0&&(E=d);let P=s(x);return d=P,g.push(new u(t,E,P,{state:P,repeat:0,delay:S??0,delayDirection:"start-once",direction:"normal",duration:w??1e3,...A,...A.easing===6?Yl.defaultData:A.easing===5?up.defaultData:{}},n,!1,i.activePage,{onBegin:()=>{(b&&E||b==="Base State"&&!E)&&(f.state=E??void 0)},onComplete:()=>{f.state=P??void 0}})),y(),this},play(){return p?(m=!0,p.play(Ji.time),p.isPlaying&&Ji.add(v),this):this},pause(){return p?.stop(),Ji.remove(v),this},reset(){return this.pause(),m=!1,y(),p?.seek(0),this},seek(b){let x=g.reduce((w,S)=>w+S.runner.duration,0);return x>0&&p?.seek(b/1e3/x),this}};return _.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{m||_.play()}),_},set color(h){let u=TU(h);if(ob.is(t))return void(t.color=u);if(!(t.type==="Mesh"&&"material"in t&&t instanceof Hr))return;let d={r:u.r,g:u.g,b:u.b,a:u.a},p=t.materialOverride;if(p!==void 0){let m=p.color;return void(m?.isColor===!0&&typeof m.setStyle=="function"&&(m.setStyle(h),r.shared.requestRender()))}let f=Array.isArray(t.material)?t.material[0]:t.material,g=f.data.layers.find(m=>m.data.type==="color")?.id;if(g)f.updateByOp({type:0,path:["layers",g],props:{color:{...d}}},f.data,r);else{let m=f.data,y=m.layers.find(S=>S.data.type==="light");if(!y)return;let v=m.layers.indexOf(y)===0?y:null,_=m.layers.at(v?m.layers.indexOf(v)+1:0),b={type:4,fi:v?v.fi+(_?(_.fi-v.fi)/2:1):_?_.fi/2:1,id:Ot.generateUUID(),data:{...Ki.defaultData("color"),color:d},localIndex:0},x=m.layers.insertAfterHelper(v?.id??null,1),w=m.layers.runOp({...b,fi:x[0]}).data;Object.assign(f.data,{layers:w}),f.updateByOp({...b,path:["layers"]},f.data,r)}}},c=L2(l,(h,u)=>{let d=t[h],p=function(f){return f.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(f,g,m){let y=Array.isArray(m)?m[0]:m;if(f[0]==="layers"){let v=parseInt(f[1]),_=y.layers[v],b=f[2];_&&b&&function(x,w,S){let A=x[0];try{if(function(E,P){return!!yit[P]?.includes(E)}(A,S.type,x.slice(1)))if(A==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let E=parseInt(x[1]),P=S.getValue(A)?.[E];if(!P)throw new Error("Color index out of range");um.setStyle(w),P.set(um.r,um.g,um.b,um.a)}else S.getValue(A)?.setStyle(w);else if(A==="texture"||A==="video"){let E=S.color;(function(P,T,R,L){let D=P[0];if(D==="repeat"||D==="offset"||D==="rotation"){let U=L.getNode("mat"),V=U&&typeof U.updateMatrix=="function"?U:L.getValue("mat");if(!V)return;if(D==="rotation")V.rotation=parseFloat(T);else{let k=P[1];if(k===void 0)T instanceof Array&&T.length===2&&Object.assign(V,{[D]:T});else{let Y=V[D],$=parseInt(k)===0?[parseFloat(T),Y[1]]:[Y[0],parseFloat(T)];Object.assign(V,{[D]:$})}}V.updateMatrix()}else D==="wrapping"||D==="minFilter"||D==="magFilter"?D==="wrapping"?R.texture.wrap=T:R.texture[D]=T:D==="image"&&P[1]==="data"&&R.texture.image.updateSrc(T)})(x.slice(1),w,E,S)}else{let E=x[1],P=S.getValue(A);P?.isVector3&&E!==void 0||P?.isVector2&&E!==void 0?P.setComponent(parseInt(E),w):S.setValue(A,w)}}catch(E){console.error("Error setting material value",E)}}(f.slice(2),g,_)}else f[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=g,g<1&&(y.transparent=!0))})}(p.slice(1),u,a),typeof d!="object"&&Object.getOwnPropertyDescriptor(t,h)?.writable&&(t[h]=u),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,c),c}setUIWasmUrl(t){(function(e){Z_=e,Kb?.setHanaUIWasmUrl(e)})(t)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let i;if(typeof e=="string"){if(!e.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(e)).arrayBuffer();i=new Uint8Array(l)}}else i=e;let n=Pg.deserialize(i),r="data"in n&&n.data.draco!==void 0;r&&await bU(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!s)return void console.warn(`Object ${t} not found`);if(s.data.type!=="Mesh"||!(s instanceof Hr))return void console.warn(`Object ${t} is not a mesh`);let a=s,o={...a.data,geometry:n};r&&await xU([o]),a.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of a.data.states){let c={...l.data};a.states||(a.states={}),a.states[l.id]=Kl.patch(o,c)}return i}_applyDocumentTransaction(t){this._data=t.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let e of t.actual){let i=e.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...e,path:[]},this._sharedAssetsManager)}}_findEntity(t){return this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t)}_resolveParentId(t){if(t===void 0)return this._scene.activePage.uuid;let e=typeof t=="string"?t:t.uuid,i=this._findEntity(e);if(!i)throw new Error(`parent '${e}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(t){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof t!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let e=Ak();if(e===void 0&&e===void 0)throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=t(e);if(typeof i!="object"||i===null||i.isMaterial!==!0)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives \u2014 e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(t,e){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded \u2014 call load() or start() first.");let n=typeof t=="string"?t:t.uuid,r=this._findEntity(n);if(!r)throw new Error(`setMaterial: '${n}' \u2014 no object with that name or uuid in the scene.`);if(!(r instanceof Hr))throw new Error(`setMaterial: '${n}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let s=typeof e=="function"?await this.createCustomMaterial(e):e;if(sb()!=="webgpu")throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let a=SU({material:s});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return r.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(r.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,n=this._data;if(!i||!n)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let r=function(m){if(typeof m!="string"||m.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${MU}.`);let y=m.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=lit[y];if(v)return{objectType:v};let _=oit[y];if(_)return{objectType:"Mesh",geometryType:_};let b=hit[y];throw b?new Error(`createObject: '${m}' is not supported \u2014 ${b}`):new Error(`createObject: '${m}' is not a creatable Spline type \u2014 use one of ${MU}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let s,a,{options:o,material:l}=SU(e);if(l!==void 0){if(r.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(sb()!=="webgpu")throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if(r.geometryType==="TextGeometry"){if(!UC.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature \u2014 re-export the scene with a Text object present, or load the full runtime build.");if(await nB(),a=e.font??wu,n.shared.fonts[a]===void 0){if(a!==wu){let m=Object.keys(n.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${m||"(none)"}.`)}s={name:wu,url:UF}}}let c=this._resolveParentId(e.parent),h=fit(r,o,n),u=Ot.generateUUID(),[d,p]=Tm(n);s&&(d.shared.fonts[wu]=s),d.scene.objects.insertAfter(c,null,[{id:u,data:h,children:[]}]);let f=p.result();if(s&&this._sharedAssetsManager.addFont(wu,s),a!==void 0){let m=this._sharedAssetsManager.getFont(a);m&&await m.loadingPromise}this._applyDocumentTransaction(f);let g=i.find(u);return l!==void 0&&g.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(g)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,n=this._data;if(!i||!n)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)throw new Error(`cloneObject: '${r}' \u2014 no object with that name or uuid in the scene.`);if(s instanceof un)throw new Error("cloneObject: pages cannot be cloned.");let a=n.scene.objects.get(s.uuid);if(!a)throw new Error(`cloneObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,f,g){let m={...p.data};return f.position!==void 0&&(m.position=Vg(f.position,[0,0,0])),f.rotation!==void 0&&(m.rotation=Vg(f.rotation,[0,0,0])),f.scale!==void 0&&(m.scale=Oj(f.scale)),f.visible!==void 0&&(m.visible=f.visible),m.name=f.name??Lj(`${p.data.name??"Object"} Copy`,g),{...p,data:m}}(mit(a),e,n.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):n.scene.objects.parent(s.uuid)??null,c=e.parent!==void 0?null:s.uuid,[h,u]=Tm(n);h.scene.objects.insertAfter(l,c,[o]),this._applyDocumentTransaction(u.result());let d=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(d)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let n=typeof t=="string"?t:t?.uuid,r=n?this._findEntity(n):void 0;if(!r)return!1;if(r instanceof un)throw new Error("removeObject: pages cannot be removed.");if(r.data.type==="PerspectiveCamera"||r.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(r.uuid)===void 0)throw new Error(`removeObject: '${n}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let s=[];r.traverseEntity(l=>{s.push(l.uuid)});let[a,o]=Tm(i);a.scene.objects.delete(r.uuid),this._applyDocumentTransaction(o.result());for(let l of s){let c=this._proxyObjectCache.get(l);c&&(L2.unsubscribe(c),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var wx=window,Sx=wx.ShadowRoot&&(wx.ShadyCSS===void 0||wx.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,q3=Symbol(),zj=new WeakMap,r0=class{constructor(e,i,n){if(this._$cssResult$=!0,n!==q3)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(Sx&&e===void 0){let n=i!==void 0&&i.length===1;n&&(e=zj.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&zj.set(i,e))}return e}toString(){return this.cssText}},Fj=t=>new r0(typeof t=="string"?t:t+"",void 0,q3),X3=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((n,r,s)=>n+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[s+1],t[0]);return new r0(i,t,q3)},$3=(t,e)=>{Sx?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let n=document.createElement("style"),r=wx.litNonce;r!==void 0&&n.setAttribute("nonce",r),n.textContent=i.cssText,t.appendChild(n)})},Mx=Sx?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let n of e.cssRules)i+=n.cssText;return Fj(i)})(t):t;var Y3,Ex=window,Nj=Ex.trustedTypes,bit=Nj?Nj.emptyScript:"",kj=Ex.reactiveElementPolyfillSupport,K3={toAttribute(t,e){switch(e){case Boolean:t=t?bit:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},Vj=(t,e)=>e!==t&&(e==e||t==t),Z3={attribute:!0,type:String,converter:K3,reflect:!1,hasChanged:Vj},Q3="finalized",dl=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((i,n)=>{let r=this._$Ep(n,i);r!==void 0&&(this._$Ev.set(r,n),e.push(r))}),e}static createProperty(e,i=Z3){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let n=typeof e=="symbol"?Symbol():"__"+e,r=this.getPropertyDescriptor(e,n,i);r!==void 0&&Object.defineProperty(this.prototype,e,r)}}static getPropertyDescriptor(e,i,n){return{get(){return this[i]},set(r){let s=this[e];this[i]=r,this.requestUpdate(e,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Z3}static finalize(){if(this.hasOwnProperty(Q3))return!1;this[Q3]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,n=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let r of n)this.createProperty(r,i[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let r of n)i.unshift(Mx(r))}else e!==void 0&&i.push(Mx(e));return i}static _$Ep(e,i){let n=i.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(i=>i(this))}addController(e){var i,n;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((n=e.hostConnected)===null||n===void 0||n.call(e))}removeController(e){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var e;let i=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return $3(i,this.constructor.elementStyles),i}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var n;return(n=i.hostConnected)===null||n===void 0?void 0:n.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var n;return(n=i.hostDisconnected)===null||n===void 0?void 0:n.call(i)})}attributeChangedCallback(e,i,n){this._$AK(e,n)}_$EO(e,i,n=Z3){var r;let s=this.constructor._$Ep(e,n);if(s!==void 0&&n.reflect===!0){let a=(((r=n.converter)===null||r===void 0?void 0:r.toAttribute)!==void 0?n.converter:K3).toAttribute(i,n.type);this._$El=e,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(e,i){var n;let r=this.constructor,s=r._$Ev.get(e);if(s!==void 0&&this._$El!==s){let a=r.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?a.converter:K3;this._$El=s,this[s]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,n){let r=!0;e!==void 0&&(((n=n||this.constructor.getPropertyOptions(e)).hasChanged||Vj)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),n.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,n))):r=!1),!this.isUpdatePending&&r&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((r,s)=>this[s]=r),this._$Ei=void 0);let i=!1,n=this._$AL;try{i=this.shouldUpdate(n),i?(this.willUpdate(n),(e=this._$ES)===null||e===void 0||e.forEach(r=>{var s;return(s=r.hostUpdate)===null||s===void 0?void 0:s.call(r)}),this.update(n)):this._$Ek()}catch(r){throw i=!1,this._$Ek(),r}i&&this._$AE(n)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(n=>{var r;return(r=n.hostUpdated)===null||r===void 0?void 0:r.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((i,n)=>this._$EO(n,this[n],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};dl[Q3]=!0,dl.elementProperties=new Map,dl.elementStyles=[],dl.shadowRootOptions={mode:"open"},kj?.({ReactiveElement:dl}),((Y3=Ex.reactiveElementVersions)!==null&&Y3!==void 0?Y3:Ex.reactiveElementVersions=[]).push("1.6.3");var J3,Ax=window,Ip=Ax.trustedTypes,jj=Ip?Ip.createPolicy("lit-html",{createHTML:t=>t}):void 0,eP="$lit$",Mh=`lit$${(Math.random()+"").slice(9)}$`,Yj="?"+Mh,xit=`<${Yj}>`,nd=document,a0=()=>nd.createComment(""),o0=t=>t===null||typeof t!="object"&&typeof t!="function",Zj=Array.isArray,wit=t=>Zj(t)||typeof t?.[Symbol.iterator]=="function",tP=`[
9934
+ `,Rj=class{constructor(t,e,i,n,r){this.container=t,this.host=e,this.observer=i,this.previousSplineGlobal=n,this.removeLateLifecycleShim=r}static mount(t,e,i,n){if(typeof document>"u")return null;let r=e.parentElement;if(!r)return null;getComputedStyle(r).position==="static"&&(r.style.position="relative");let s=document.createElement("div");s.setAttribute(O1,"");let a=s.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(r);let c=document.createElement("style");c.textContent=sit,s.appendChild(c);let h=new DOMParser().parseFromString(i,"text/html"),u=Array.from(h.querySelectorAll("script"));for(let v of u)v.remove();for(let v of Array.from(h.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&s.appendChild(v);for(;h.body.firstChild;)s.appendChild(h.body.firstChild);r.insertBefore(s,e.nextSibling);let d=new Map,p=new mC(Pj(t,e,n),(v,_)=>{v==="warn"?console.warn(`[spline html] ${_}`):v==="error"&&console.error(`[spline html] ${_}`)},(v,_)=>{let b=d.get(v);if(b)for(let x of b)try{x(_)}catch(w){console.error(w)}}),f=(v,_)=>{try{return Promise.resolve(p.execute(v,_))}catch(b){return Promise.reject(b)}},g={ready:Promise.resolve(),setVariable:(v,_)=>f("setVariable",[v,_]),setVariables:v=>f("setVariables",[v]),getVariable:v=>f("getVariable",[v]),getVariables:()=>f("getVariables",[]),getAllObjects:()=>f("getAllObjects",[]),findObjectByName:v=>f("findObjectByName",[v]),findObjectById:v=>f("findObjectById",[v]),getGeometry:(v,_)=>f("getGeometry",[v,_??{}]),updateObject:(v,_)=>f("updateObject",[v,_]),createObject:(v,_)=>f("createObject",[v,_??{}]),createCustomMaterial:v=>f("createCustomMaterial",[v]),setMaterial:(v,_)=>f("setMaterial",[v,_]),cloneObject:(v,_)=>f("cloneObject",[v,_??{}]),removeObject:v=>f("removeObject",[v]),spawnObject:(v,_)=>f("spawnObject",[v,_??{}]),destroyObject:v=>f("destroyObject",[v]),setInstanceTransforms:(v,_)=>f("setInstanceTransforms",[v,_??null]),emitEvent:(v,_)=>f("emitEvent",[v,_]),emitEventReverse:(v,_)=>f("emitEventReverse",[v,_]),requestRender:()=>f("requestRender",[]),addEventListener:(v,_)=>{if(typeof _!="function")return;let b=d.get(v);b||(b=new Set,d.set(v,b),f("listenEvent",[v])),b.add(_)},removeEventListener:(v,_)=>{let b=d.get(v);!b||(b.delete(_),b.size===0&&(d.delete(v),f("unlistenEvent",[v])))}},m=window.spline;window.spline=g;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],_=(x,w)=>{let S=new Set,A=x.addEventListener.bind(x),E=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(P,T,R)=>{if(A(P,T,R),!w.includes(P)||T==null)return;let L={type:P,listener:T};S.add(L),queueMicrotask(()=>{!S.delete(L)||((D,U,V)=>{let k=new Event(V);try{typeof U=="function"?U.call(D,k):U.handleEvent?.(k)}catch(Y){console.error(Y)}})(x,L.listener,L.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(P,T,R)=>{E(P,T,R);for(let L of S)L.type===P&&L.listener===T&&S.delete(L)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,S.clear()})};_(document,["DOMContentLoaded"]),_(window,["load"]);let b=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(w){console.error(w)}})}}),v.push(()=>{b?Object.defineProperty(window,"onload",b):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of u){let _=document.createElement("script");for(let b of Array.from(v.attributes))_.setAttribute(b.name,b.value);v.src?_.async=!1:_.textContent=v.textContent,s.appendChild(_)}return new Rj(s,p,l,m,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline!==void 0&&(window.spline=this.previousSplineGlobal)}};function Ij(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function SU(t){if(typeof t.material=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(!Ij(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=Ak()?.NodeMaterial;if(i!==void 0&&e instanceof i)return{options:{...t,material:void 0},material:e};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => \u2026) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, \u2026).")}if(e.isShaderMaterial===!0)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend \u2014 port the shader to TSL with app.createCustomMaterial((three) => \u2026), or use a built-in material (MeshStandardMaterial, \u2026).");return{options:{...t,material:void 0},material:e}}Yt(),Ye(),et(),wk(),ya(),Ye(),Yt(),WX(),bh();var ait=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),MU="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",oit={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},lit={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},hit={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data \u2014 clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime \u2014 clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto \u2014 clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame \u2014 clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor \u2014 clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},cit={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},dit={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function Vg(t,e){return t===void 0?[e[0],e[1],e[2]]:Array.isArray(t)?[t[0]??e[0],t[1]??e[1],t[2]??e[2]]:[t.x??e[0],t.y??e[1],t.z??e[2]]}function Oj(t){return typeof t=="number"?[t,t,t]:Vg(t,[1,1,1])}function KT(t){let e=new gn(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function EU(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return ki.defaultColorMaterial(AU(Rr),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(e.shared.materials))if(a===i||o.name===i)return a;if(function(a){let o=a.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)||/^(rgb|hsl)a?\(/.test(o)||Jt.NAMES[o]!==void 0}(i))return ki.defaultColorMaterial(KT(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(a){let o=Object.entries(a.shared.materials).map(([,l])=>`'${l.name}'`).filter(l=>l!=="'undefined'");return o.length?o.join(", "):"(none)"}(e)}) and is not a valid CSS color.`)}if(typeof i=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(Ij(i))throw new Error("createObject: a three.js material instance cannot be stored in the document \u2014 this entry point does not support it.");let n=i.color!==void 0?KT(i.color):AU(Rr),r=ki.defaultColorMaterial(n,"physical","layer1","layer2"),s=r.layers.find(a=>a.data.type==="light");if(s){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(s.data,a)}if(i.alpha!==void 0){let a=r.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return r}function AU(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function uit(t){let e=Ho.defaultData("TextGeometry"),{text:i,...n}=t,r=n.fontSize;return r!==void 0&&n.width===void 0&&(n.width=350*r/16),r!==void 0&&n.height===void 0&&(n.height=50*r/16),Object.assign(e,n),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function ky(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function pit(t,e){return oN({userData:{type:t,...kA[t].normalizeInputs({parameters:e})}})}function fit(t,e,i){let{objectType:n,geometryType:r}=t,s=function(l){let c={};for(let[h,u]of Object.entries(l))!ait.has(h)&&u!==void 0&&(c[h]=u);return c}(e),a={states:new Vt,events:new Vt};if(n==="Mesh"&&r){if(r==="NonParametricGeometry"){let{geometry:l,doubleSide:c}=function(h){let u=ky(h.vertices);if(!u||u.length<9||u.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let d=u.length/3;if(d>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${d}); keep it under 60000.`);let p=ky(h.indices);if(p&&p.length){let _=p.find(b=>!Number.isInteger(b)||b<0||b>=d);if(_!==void 0)throw new Error(`createObject('CustomMesh'): index ${_} is out of range (mesh has ${d} vertices).`)}else p=null;let f=new Gt;f.setAttribute("position",new Nt(u,3));let g=ky(h.normals),m=g!==null&&g.length===u.length;m&&f.setAttribute("normal",new Nt(g,3));let y=ky(h.uvs);y&&y.length===2*d&&f.setAttribute("uv",new Nt(y,2));let v=!1;if(!m){let _=p??Array.from({length:d},(w,S)=>S),{closed:b,inverted:x}=function(w,S){let A=w.length/3,E=new Map,P=new Array(A);for(let D=0;D<A;D++){let U=`${Math.round(1e4*w[3*D])},${Math.round(1e4*w[3*D+1])},${Math.round(1e4*w[3*D+2])}`,V=E.get(U);V===void 0?(E.set(U,D),P[D]=D):P[D]=V}let T=new Map;for(let D=0;D+2<S.length;D+=3){let U=P[S[D]],V=P[S[D+1]],k=P[S[D+2]];for(let[Y,$]of[[U,V],[V,k],[k,U]]){if(Y===$)continue;let nt=Y<$?Y+"_"+$:$+"_"+Y;T.set(nt,(T.get(nt)??0)+1)}}let R=T.size>0;for(let D of T.values())if(D!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let L=0;for(let D=0;D+2<S.length;D+=3){let U=3*S[D],V=3*S[D+1],k=3*S[D+2],Y=w[U],$=w[U+1],nt=w[U+2],Q=w[V],rt=w[V+1],gt=w[V+2],at=w[k],ht=w[k+1],ct=w[k+2];L+=Y*(rt*ct-gt*ht)+$*(gt*at-Q*ct)+nt*(Q*ht-rt*at)}return{closed:!0,inverted:L<0}}(u,_);if(b&&x){for(let w=0;w+2<_.length;w+=3){let S=_[w+1];_[w+1]=_[w+2],_[w+2]=S}p=_}else b||(v=!0)}return p&&f.setIndex(p),m||f.computeVertexNormals(),{geometry:oN({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:f.toJSON().data}),doubleSide:v}}(s);Object.assign(a,Ha.defaultData,{geometry:l,materials:[EU(e,i)]}),c&&(a.side=2)}else Object.assign(a,Ha.defaultData,{geometry:r==="TextGeometry"?uit(s):pit(r,s),material:EU(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else n==="Empty"?Object.assign(a,V_.defaultData):(Object.assign(a,j_.defaultData(n),s),e.color!==void 0&&(a.color=KT(e.color)));a.visible=e.visible??!0,a.position=Vg(e.position,[0,0,0]),a.rotation=Vg(e.rotation,[0,0,0]),a.scale=Oj(e.scale);let o=(r&&cit[r])??dit[n]??n;return a.name=e.name??Lj(o,i.scene.objects),a}function Lj(t,e){let i=new Set;if(e.traverse((r,s)=>{i.add(s.name??"")}),!i.has(t))return t;let n=2;for(;i.has(`${t} ${n}`);)n++;return`${t} ${n}`}function Bj(t,e){let i=Ot.generateUUID();if(t.data.type==="Component")return{data:{...Qo.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let n=t.data;return n.type==="Empty"&&n.animations?.length&&(n={...n,animations:n.animations.map(([r,s,a])=>{let o=Ot.generateUUID(),l=a.indexOf(r);return[o,s,l!==-1?a.slice(0,l)+o+a.slice(l+r.length):a]})}),{...t,id:i,data:n,children:t.children.map(r=>Bj(r,e))}}function mit(t){let e={};return function(i,n){return Hu(i,n,null)??i}(Bj(t,e),e)}function git(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(vit)??[],n=e.layers?.find(r=>r.type==="light");return{layers:i,alpha:n?.node.alphaOverride?.value??1}}function vit(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}bh(),Li(),qC(),ya();var um=new gn(0,0,0,1),yit={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};Yt(),Yt();var _it=new it;function TU(t){let e=new gn(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var Uj=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:n,renderer:r,htmlContentMode:s="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<hN?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),Hc(o)&&(this._renderer?.isWebGPUSplineRenderer!==!0&&o.warnClassicFallbackOnce(),o.isSimulating&&(o.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let o=Math.min(1,1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration);this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=o,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),this._renderer.lastFrameIncomplete===!0&&(this._skipRender=!1),this._renderer.skyAnimationActive===!0&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=_it.set(this._viewportWidth,this._viewportHeight)),a){let o=this._viewportWidth,l=this._viewportHeight;this._renderer.setSize(o-1,l-1,!1),this._renderer.setSize(o,l,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=Cg(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=s,this.renderMode=e?"auto":i,n!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(n)),this._rendererBackend=r??"webgl",r===void 0){let a=null;try{a=new URLSearchParams(window.location.search).get("renderer")}catch{}a==="webgpu"||a==="webgl"||a==="webgl2"?this._rendererBackend=a==="webgl2"?"webgl":a:(this._rendererAuto=!0,this._rendererBackend="webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(BY(),T6)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",FR,!0),a.addEventListener("pointerdown",iv,!0),a.addEventListener("pointermove",iv,!0),a.addEventListener("pointerup",Dd,!0),a.addEventListener("pointercancel",Dd,!0),a.addEventListener("pointerleave",Dd,!0),window.addEventListener("keydown",NR,!0),window.addEventListener("keyup",kR,!0)}(t)}async _createRenderer(){this._rendererBackend,this._rendererBackend;{let{SplineRenderer:t,rendererGlobals:e}=await Promise.resolve().then(()=>(JL(),_T));try{new URLSearchParams(window.location.search).get("taa")==="off"&&(e.taaEnabled.value=!1)}catch{}return new t({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"})}}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let t=window.devicePixelRatio||1,e=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=e*t,this.canvas.height=i*t;let n=this.canvas.getContext("2d");n&&(n.scale(t,t),n.fillStyle="rgba(127, 127, 127, 0.85)",n.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",n.textAlign="center",n.textBaseline="middle",n.fillText("This scene requires a WebGPU-capable browser.",e/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(t,e,i){(function(r){let s="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(s+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(s)})(t),this.disposed=!1;let n=await(await fetch(t,i)).arrayBuffer();await this.start(n,{variables:e})}async start(t,{interactive:e=!0,variables:i}={}){if(this.disposed)return;Ji.init();let n=await async function(d){let[p,f]=Tm(Pg.deserialize(new Uint8Array(d)));if((p.schema??0)!==131){let{updateDocumentSchema:g}=await Promise.resolve().then(()=>($b(),tN));g(p)}return f.result().data}(t);this._data=n;let r=function(d){let p=[];return d.scene.objects.traverse((f,g)=>{g.type==="Mesh"&&g.geometry.type==="NonParametricGeometry"&&g.geometry.data.draco!==void 0&&p.push(g)}),p}(n);n.version&&(0,nit.default)(n.version,"2.0.44")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath!==void 0&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(d){aT=d}(this._wasmPath));let s=async function(){}();await Promise.all([s,r.length&&bU(this._wasmPath),k4(n)&&QX(this._wasmPath),z$(n)&&P$(this._wasmPath),Gc.physicsEnabled(n.scene.objects)&&cJ(this._wasmPath),XO(n)&&nB(),Y4(n)&&nY(),l$(n)&&o$(),Y5(n)&&s.then(()=>fA()?.loadHanaUIRUNTIME()),nJ(n)&&AJ(this._wasmPath)].filter(Boolean)),r.length&&await xU(r),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=n.scene.publish.renderer;if(this._rendererAuto&&a==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&a==="webgpu")return void this._failWebGPURequired();let o=function(d){let p=new Set;return d.scene.objects.traverse((f,g)=>{if(g.type!=="Page")return;let m=g.postprocessing;if(m&&typeof m=="object"&&m.enabled===!0)for(let[y,v]of Object.entries(m))y!=="enabled"&&v&&typeof v=="object"&&v.enabled===!0&&p.add(y)}),[...p]}(n);this._rendererBackend,this._rendererBackend!=="webgpu"&&await Promise.all([Promise.resolve().then(()=>(JL(),_T)),iit(o)]),function(d){ax=d}((this._rendererBackend,"webgl"));let l=new Ket(n);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:d}=await Promise.resolve().then(()=>(gK(),hV)),p=performance.now();d(n,l.scene);let f=performance.now();console.log("Merged geometries in ",f-p," ms")}k4(n)&&this._scene.traverse(d=>{to(d)&&d.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(d=>{Bu(d)&&d.pendingMediaLoad&&d.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(d=>{d.type==="ParticleSystem"&&(d.wakeUp(),d.data.autoPlay?d.start():d.stop()),Hc(d)&&d.setPlayMode(!0)});let c=Object.keys(n.shared.fonts).flatMap(d=>{let p=this._sharedAssetsManager.getFont(d);return p?[p.loadingPromise]:[]});if(Promise.all(c).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),XO(n)&&function(d){if(Gc.physicsEnabled(d.scene.objects))return!0;let p=!1;return d.scene.objects.traverse((f,g)=>{if(g.events){if(Array.isArray(g.events)){for(let m of g.events)if(m.data.disabled!==!0&&m.data.type==="GameControl"&&m.data.collisionEnabled){p=!0;break}}else for(let m of Object.values(g.events))if(m.disabled!==!0&&m.type==="GameControl"&&m.collisionEnabled){p=!0;break}}}),p}(n)&&await Promise.all(c),Y5(n)){let d=[];this._scene.traverseEntity(p=>{(Cr(p)||p instanceof un)&&p.uiCanvas&&d.push(p.uiCanvas)}),await Promise.all(d.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),W3(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=await this._createRenderer()),!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0;let d=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(d()?n.scene.publish.settings.web.pixelRatioMobile:n.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),n.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");await f.loadPromise;let g=f.getTexture(1001);this._renderer.pipeline.setWatermark(g)}}Y4(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let h=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(h.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=h.size[0],this._viewportHeight=h.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new KK(this._renderer,this._camera,new it(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),e){let d=new DK(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new fJ(d),this._animationControls=new tit(this._scene,this._requestRenderAutoMode),this._eventManager=new WK(n.scene.publish,this._controls,this._animationControls,d,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0;let u=n.scene.publish.htmlContent?.html;if(e&&u&&this._htmlContentMode!=="none"){let d={shared:this._sharedAssetsManager,findEntity:p=>this._scene?.getObjectByProperty("uuid",p)??this._scene?.getObjectByName(p)};this._htmlContentOverlay=(this._htmlContentMode==="inline"?Rj.mount(this,this.canvas,u,d):Dj.mount(this,this.canvas,u,d))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,n]of e)this.setVariable(i,n)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){let n=e;typeof i.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof i.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(n=e.toString());let r=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(i.id,r),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let i=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(i)}}_getVariableValue(t){return typeof t!="string"&&_r.isTextValue(t)?_r.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(i=>i.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(!(e.uuid===Zc||this._scene.isInvisibleObjects(e)||e instanceof un)){let i=this._createProxyObject(e);i&&t.push(i)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof EV&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=TU(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,hg&&hg.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{L2.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(t){t.removeEventListener("pointerdown",FR,!0),t.removeEventListener("pointerdown",iv,!0),t.removeEventListener("pointermove",iv,!0),t.removeEventListener("pointerup",Dd,!0),t.removeEventListener("pointercancel",Dd,!0),t.removeEventListener("pointerleave",Dd,!0),window.removeEventListener("keydown",NR,!0),window.removeEventListener("keyup",kR,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Ji.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e,i=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);t.traverseAncestors(h=>{h instanceof un&&(e=h.name)});let n=this._sharedAssetsManager,r={shared:n,scene:this._scene},s=h=>{if(h===null||h==="Base State")return null;if(h&&t.data.states){let u=t.data.states.find(d=>d.data.name===h);return u?u.id:void 0}},a="material"in t?t.material:void 0,o=t.materialOverride,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,material:o??(a?git(a):void 0),parentUuid:t.parent instanceof un||t instanceof ux?void 0:t.parent?.uuid,emitEvent(h){t.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){t.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){t.visible&&(t.visible=!1,r.shared.requestRender())},show(){t.visible||(t.visible=!0,r.shared.requestRender())},get state(){let h=t.stateSelection;if(h!==null)return t.data.states.find(({id:u})=>u===h)?.data.name},set state(h){let u;if(h!==void 0){let d=typeof h=="string"?t.data.states.find(({id:p})=>p===h):t.data.states[h];if(d)u=d.id;else{let p=typeof h=="string"?s(h):void 0;p&&(u=p)}}t.changeSelectedState(u??null,r),t.currentState=u??null,t.dispatchEvent({type:"completeState",state:u??null}),r.shared.requestRender()},transition(h){let u=Cj;if(u===null)return Gn("transitions","obj.transition()"),{transition(b){return this},play(){return this},pause(){return this},reset(){return this},seek(b){return this}};let d,p,f=this,g=[],m=!1,y=()=>{p=new fj({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},g.map(b=>b.runner))},v={update(b){p?.update(b),p?.isPlaying!==!0&&Ji.remove(v)}},_={transition({from:b,to:x,duration:w,delay:S,...A}){let E=s(b);E===void 0&&(E=d);let P=s(x);return d=P,g.push(new u(t,E,P,{state:P,repeat:0,delay:S??0,delayDirection:"start-once",direction:"normal",duration:w??1e3,...A,...A.easing===6?Yl.defaultData:A.easing===5?up.defaultData:{}},n,!1,i.activePage,{onBegin:()=>{(b&&E||b==="Base State"&&!E)&&(f.state=E??void 0)},onComplete:()=>{f.state=P??void 0}})),y(),this},play(){return p?(m=!0,p.play(Ji.time),p.isPlaying&&Ji.add(v),this):this},pause(){return p?.stop(),Ji.remove(v),this},reset(){return this.pause(),m=!1,y(),p?.seek(0),this},seek(b){let x=g.reduce((w,S)=>w+S.runner.duration,0);return x>0&&p?.seek(b/1e3/x),this}};return _.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{m||_.play()}),_},set color(h){let u=TU(h);if(ob.is(t))return void(t.color=u);if(!(t.type==="Mesh"&&"material"in t&&t instanceof Hr))return;let d={r:u.r,g:u.g,b:u.b,a:u.a},p=t.materialOverride;if(p!==void 0){let m=p.color;return void(m?.isColor===!0&&typeof m.setStyle=="function"&&(m.setStyle(h),r.shared.requestRender()))}let f=Array.isArray(t.material)?t.material[0]:t.material,g=f.data.layers.find(m=>m.data.type==="color")?.id;if(g)f.updateByOp({type:0,path:["layers",g],props:{color:{...d}}},f.data,r);else{let m=f.data,y=m.layers.find(S=>S.data.type==="light");if(!y)return;let v=m.layers.indexOf(y)===0?y:null,_=m.layers.at(v?m.layers.indexOf(v)+1:0),b={type:4,fi:v?v.fi+(_?(_.fi-v.fi)/2:1):_?_.fi/2:1,id:Ot.generateUUID(),data:{...Ki.defaultData("color"),color:d},localIndex:0},x=m.layers.insertAfterHelper(v?.id??null,1),w=m.layers.runOp({...b,fi:x[0]}).data;Object.assign(f.data,{layers:w}),f.updateByOp({...b,path:["layers"]},f.data,r)}}},c=L2(l,(h,u)=>{let d=t[h],p=function(f){return f.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(f,g,m){let y=Array.isArray(m)?m[0]:m;if(f[0]==="layers"){let v=parseInt(f[1]),_=y.layers[v],b=f[2];_&&b&&function(x,w,S){let A=x[0];try{if(function(E,P){return!!yit[P]?.includes(E)}(A,S.type,x.slice(1)))if(A==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let E=parseInt(x[1]),P=S.getValue(A)?.[E];if(!P)throw new Error("Color index out of range");um.setStyle(w),P.set(um.r,um.g,um.b,um.a)}else S.getValue(A)?.setStyle(w);else if(A==="texture"||A==="video"){let E=S.color;(function(P,T,R,L){let D=P[0];if(D==="repeat"||D==="offset"||D==="rotation"){let U=L.getNode("mat"),V=U&&typeof U.updateMatrix=="function"?U:L.getValue("mat");if(!V)return;if(D==="rotation")V.rotation=parseFloat(T);else{let k=P[1];if(k===void 0)T instanceof Array&&T.length===2&&Object.assign(V,{[D]:T});else{let Y=V[D],$=parseInt(k)===0?[parseFloat(T),Y[1]]:[Y[0],parseFloat(T)];Object.assign(V,{[D]:$})}}V.updateMatrix()}else D==="wrapping"||D==="minFilter"||D==="magFilter"?D==="wrapping"?R.texture.wrap=T:R.texture[D]=T:D==="image"&&P[1]==="data"&&R.texture.image.updateSrc(T)})(x.slice(1),w,E,S)}else{let E=x[1],P=S.getValue(A);P?.isVector3&&E!==void 0||P?.isVector2&&E!==void 0?P.setComponent(parseInt(E),w):S.setValue(A,w)}}catch(E){console.error("Error setting material value",E)}}(f.slice(2),g,_)}else f[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=g,g<1&&(y.transparent=!0))})}(p.slice(1),u,a),typeof d!="object"&&Object.getOwnPropertyDescriptor(t,h)?.writable&&(t[h]=u),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,c),c}setUIWasmUrl(t){(function(e){Z_=e,Kb?.setHanaUIWasmUrl(e)})(t)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let i;if(typeof e=="string"){if(!e.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(e)).arrayBuffer();i=new Uint8Array(l)}}else i=e;let n=Pg.deserialize(i),r="data"in n&&n.data.draco!==void 0;r&&await bU(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!s)return void console.warn(`Object ${t} not found`);if(s.data.type!=="Mesh"||!(s instanceof Hr))return void console.warn(`Object ${t} is not a mesh`);let a=s,o={...a.data,geometry:n};r&&await xU([o]),a.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of a.data.states){let c={...l.data};a.states||(a.states={}),a.states[l.id]=Kl.patch(o,c)}return i}_applyDocumentTransaction(t){this._data=t.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let e of t.actual){let i=e.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...e,path:[]},this._sharedAssetsManager)}}_findEntity(t){return this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t)}_resolveParentId(t){if(t===void 0)return this._scene.activePage.uuid;let e=typeof t=="string"?t:t.uuid,i=this._findEntity(e);if(!i)throw new Error(`parent '${e}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(t){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof t!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let e=Ak();if(e===void 0&&e===void 0)throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=t(e);if(typeof i!="object"||i===null||i.isMaterial!==!0)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives \u2014 e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(t,e){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded \u2014 call load() or start() first.");let n=typeof t=="string"?t:t.uuid,r=this._findEntity(n);if(!r)throw new Error(`setMaterial: '${n}' \u2014 no object with that name or uuid in the scene.`);if(!(r instanceof Hr))throw new Error(`setMaterial: '${n}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let s=typeof e=="function"?await this.createCustomMaterial(e):e;if(sb()!=="webgpu")throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let a=SU({material:s});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return r.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(r.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,n=this._data;if(!i||!n)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let r=function(m){if(typeof m!="string"||m.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${MU}.`);let y=m.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=lit[y];if(v)return{objectType:v};let _=oit[y];if(_)return{objectType:"Mesh",geometryType:_};let b=hit[y];throw b?new Error(`createObject: '${m}' is not supported \u2014 ${b}`):new Error(`createObject: '${m}' is not a creatable Spline type \u2014 use one of ${MU}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let s,a,{options:o,material:l}=SU(e);if(l!==void 0){if(r.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(sb()!=="webgpu")throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if(r.geometryType==="TextGeometry"){if(!UC.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature \u2014 re-export the scene with a Text object present, or load the full runtime build.");if(await nB(),a=e.font??wu,n.shared.fonts[a]===void 0){if(a!==wu){let m=Object.keys(n.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${m||"(none)"}.`)}s={name:wu,url:UF}}}let c=this._resolveParentId(e.parent),h=fit(r,o,n),u=Ot.generateUUID(),[d,p]=Tm(n);s&&(d.shared.fonts[wu]=s),d.scene.objects.insertAfter(c,null,[{id:u,data:h,children:[]}]);let f=p.result();if(s&&this._sharedAssetsManager.addFont(wu,s),a!==void 0){let m=this._sharedAssetsManager.getFont(a);m&&await m.loadingPromise}this._applyDocumentTransaction(f);let g=i.find(u);return l!==void 0&&g.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(g)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,n=this._data;if(!i||!n)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)throw new Error(`cloneObject: '${r}' \u2014 no object with that name or uuid in the scene.`);if(s instanceof un)throw new Error("cloneObject: pages cannot be cloned.");let a=n.scene.objects.get(s.uuid);if(!a)throw new Error(`cloneObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,f,g){let m={...p.data};return f.position!==void 0&&(m.position=Vg(f.position,[0,0,0])),f.rotation!==void 0&&(m.rotation=Vg(f.rotation,[0,0,0])),f.scale!==void 0&&(m.scale=Oj(f.scale)),f.visible!==void 0&&(m.visible=f.visible),m.name=f.name??Lj(`${p.data.name??"Object"} Copy`,g),{...p,data:m}}(mit(a),e,n.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):n.scene.objects.parent(s.uuid)??null,c=e.parent!==void 0?null:s.uuid,[h,u]=Tm(n);h.scene.objects.insertAfter(l,c,[o]),this._applyDocumentTransaction(u.result());let d=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(d)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let n=typeof t=="string"?t:t?.uuid,r=n?this._findEntity(n):void 0;if(!r)return!1;if(r instanceof un)throw new Error("removeObject: pages cannot be removed.");if(r.data.type==="PerspectiveCamera"||r.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(r.uuid)===void 0)throw new Error(`removeObject: '${n}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let s=[];r.traverseEntity(l=>{s.push(l.uuid)});let[a,o]=Tm(i);a.scene.objects.delete(r.uuid),this._applyDocumentTransaction(o.result());for(let l of s){let c=this._proxyObjectCache.get(l);c&&(L2.unsubscribe(c),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var wx=window,Sx=wx.ShadowRoot&&(wx.ShadyCSS===void 0||wx.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,q3=Symbol(),zj=new WeakMap,r0=class{constructor(e,i,n){if(this._$cssResult$=!0,n!==q3)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(Sx&&e===void 0){let n=i!==void 0&&i.length===1;n&&(e=zj.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&zj.set(i,e))}return e}toString(){return this.cssText}},Fj=t=>new r0(typeof t=="string"?t:t+"",void 0,q3),X3=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((n,r,s)=>n+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[s+1],t[0]);return new r0(i,t,q3)},$3=(t,e)=>{Sx?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let n=document.createElement("style"),r=wx.litNonce;r!==void 0&&n.setAttribute("nonce",r),n.textContent=i.cssText,t.appendChild(n)})},Mx=Sx?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let n of e.cssRules)i+=n.cssText;return Fj(i)})(t):t;var Y3,Ex=window,Nj=Ex.trustedTypes,bit=Nj?Nj.emptyScript:"",kj=Ex.reactiveElementPolyfillSupport,K3={toAttribute(t,e){switch(e){case Boolean:t=t?bit:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},Vj=(t,e)=>e!==t&&(e==e||t==t),Z3={attribute:!0,type:String,converter:K3,reflect:!1,hasChanged:Vj},Q3="finalized",dl=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((i,n)=>{let r=this._$Ep(n,i);r!==void 0&&(this._$Ev.set(r,n),e.push(r))}),e}static createProperty(e,i=Z3){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let n=typeof e=="symbol"?Symbol():"__"+e,r=this.getPropertyDescriptor(e,n,i);r!==void 0&&Object.defineProperty(this.prototype,e,r)}}static getPropertyDescriptor(e,i,n){return{get(){return this[i]},set(r){let s=this[e];this[i]=r,this.requestUpdate(e,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Z3}static finalize(){if(this.hasOwnProperty(Q3))return!1;this[Q3]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,n=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let r of n)this.createProperty(r,i[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let r of n)i.unshift(Mx(r))}else e!==void 0&&i.push(Mx(e));return i}static _$Ep(e,i){let n=i.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(i=>i(this))}addController(e){var i,n;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((n=e.hostConnected)===null||n===void 0||n.call(e))}removeController(e){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var e;let i=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return $3(i,this.constructor.elementStyles),i}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var n;return(n=i.hostConnected)===null||n===void 0?void 0:n.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var n;return(n=i.hostDisconnected)===null||n===void 0?void 0:n.call(i)})}attributeChangedCallback(e,i,n){this._$AK(e,n)}_$EO(e,i,n=Z3){var r;let s=this.constructor._$Ep(e,n);if(s!==void 0&&n.reflect===!0){let a=(((r=n.converter)===null||r===void 0?void 0:r.toAttribute)!==void 0?n.converter:K3).toAttribute(i,n.type);this._$El=e,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(e,i){var n;let r=this.constructor,s=r._$Ev.get(e);if(s!==void 0&&this._$El!==s){let a=r.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?a.converter:K3;this._$El=s,this[s]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,n){let r=!0;e!==void 0&&(((n=n||this.constructor.getPropertyOptions(e)).hasChanged||Vj)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),n.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,n))):r=!1),!this.isUpdatePending&&r&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((r,s)=>this[s]=r),this._$Ei=void 0);let i=!1,n=this._$AL;try{i=this.shouldUpdate(n),i?(this.willUpdate(n),(e=this._$ES)===null||e===void 0||e.forEach(r=>{var s;return(s=r.hostUpdate)===null||s===void 0?void 0:s.call(r)}),this.update(n)):this._$Ek()}catch(r){throw i=!1,this._$Ek(),r}i&&this._$AE(n)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(n=>{var r;return(r=n.hostUpdated)===null||r===void 0?void 0:r.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((i,n)=>this._$EO(n,this[n],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};dl[Q3]=!0,dl.elementProperties=new Map,dl.elementStyles=[],dl.shadowRootOptions={mode:"open"},kj?.({ReactiveElement:dl}),((Y3=Ex.reactiveElementVersions)!==null&&Y3!==void 0?Y3:Ex.reactiveElementVersions=[]).push("1.6.3");var J3,Ax=window,Ip=Ax.trustedTypes,jj=Ip?Ip.createPolicy("lit-html",{createHTML:t=>t}):void 0,eP="$lit$",Mh=`lit$${(Math.random()+"").slice(9)}$`,Yj="?"+Mh,xit=`<${Yj}>`,nd=document,a0=()=>nd.createComment(""),o0=t=>t===null||typeof t!="object"&&typeof t!="function",Zj=Array.isArray,wit=t=>Zj(t)||typeof t?.[Symbol.iterator]=="function",tP=`[
9935
9935
  \f\r]`,s0=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Gj=/-->/g,Hj=/>/g,ed=RegExp(`>|${tP}(?:([^\\s"'>=/]+)(${tP}*=${tP}*(?:[^
9936
9936
  \f\r"'\`<>=]|("|')|))|$)`,"g"),Wj=/'/g,qj=/"/g,Kj=/^(?:script|style|textarea|title)$/i,Qj=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),Jj=Qj(1),Yut=Qj(2),rd=Symbol.for("lit-noChange"),hr=Symbol.for("lit-nothing"),Xj=new WeakMap,id=nd.createTreeWalker(nd,129,null,!1);function t9(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return jj!==void 0?jj.createHTML(e):e}var Sit=(t,e)=>{let i=t.length-1,n=[],r,s=e===2?"<svg>":"",a=s0;for(let o=0;o<i;o++){let l=t[o],c,h,u=-1,d=0;for(;d<l.length&&(a.lastIndex=d,h=a.exec(l),h!==null);)d=a.lastIndex,a===s0?h[1]==="!--"?a=Gj:h[1]!==void 0?a=Hj:h[2]!==void 0?(Kj.test(h[2])&&(r=RegExp("</"+h[2],"g")),a=ed):h[3]!==void 0&&(a=ed):a===ed?h[0]===">"?(a=r??s0,u=-1):h[1]===void 0?u=-2:(u=a.lastIndex-h[2].length,c=h[1],a=h[3]===void 0?ed:h[3]==='"'?qj:Wj):a===qj||a===Wj?a=ed:a===Gj||a===Hj?a=s0:(a=ed,r=void 0);let p=a===ed&&t[o+1].startsWith("/>")?" ":"";s+=a===s0?l+xit:u>=0?(n.push(c),l.slice(0,u)+eP+l.slice(u)+Mh+p):l+Mh+(u===-2?(n.push(void 0),o):p)}return[t9(t,s+(t[i]||"<?>")+(e===2?"</svg>":"")),n]},sd=class{constructor({strings:e,_$litType$:i},n){let r;this.parts=[];let s=0,a=0,o=e.length-1,l=this.parts,[c,h]=Sit(e,i);if(this.el=sd.createElement(c,n),id.currentNode=this.el.content,i===2){let u=this.el.content,d=u.firstChild;d.remove(),u.append(...d.childNodes)}for(;(r=id.nextNode())!==null&&l.length<o;){if(r.nodeType===1){if(r.hasAttributes()){let u=[];for(let d of r.getAttributeNames())if(d.endsWith(eP)||d.startsWith(Mh)){let p=h[a++];if(u.push(d),p!==void 0){let f=r.getAttribute(p.toLowerCase()+eP).split(Mh),g=/([.?@])?(.*)/.exec(p);l.push({type:1,index:s,name:g[2],strings:f,ctor:g[1]==="."?nP:g[1]==="?"?rP:g[1]==="@"?sP:Lp})}else l.push({type:6,index:s})}for(let d of u)r.removeAttribute(d)}if(Kj.test(r.tagName)){let u=r.textContent.split(Mh),d=u.length-1;if(d>0){r.textContent=Ip?Ip.emptyScript:"";for(let p=0;p<d;p++)r.append(u[p],a0()),id.nextNode(),l.push({type:2,index:++s});r.append(u[d],a0())}}}else if(r.nodeType===8)if(r.data===Yj)l.push({type:2,index:s});else{let u=-1;for(;(u=r.data.indexOf(Mh,u+1))!==-1;)l.push({type:7,index:s}),u+=Mh.length-1}s++}}static createElement(e,i){let n=nd.createElement("template");return n.innerHTML=e,n}};function Op(t,e,i=t,n){var r,s,a,o;if(e===rd)return e;let l=n!==void 0?(r=i._$Co)===null||r===void 0?void 0:r[n]:i._$Cl,c=o0(e)?void 0:e._$litDirective$;return l?.constructor!==c&&((s=l?._$AO)===null||s===void 0||s.call(l,!1),c===void 0?l=void 0:(l=new c(t),l._$AT(t,i,n)),n!==void 0?((a=(o=i)._$Co)!==null&&a!==void 0?a:o._$Co=[])[n]=l:i._$Cl=l),l!==void 0&&(e=Op(t,l._$AS(t,e.values),l,n)),e}var iP=class{constructor(e,i){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var i;let{el:{content:n},parts:r}=this._$AD,s=((i=e?.creationScope)!==null&&i!==void 0?i:nd).importNode(n,!0);id.currentNode=s;let a=id.nextNode(),o=0,l=0,c=r[0];for(;c!==void 0;){if(o===c.index){let h;c.type===2?h=new ad(a,a.nextSibling,this,e):c.type===1?h=new c.ctor(a,c.name,c.strings,this,e):c.type===6&&(h=new aP(a,this,e)),this._$AV.push(h),c=r[++l]}o!==c?.index&&(a=id.nextNode(),o++)}return id.currentNode=nd,s}v(e){let i=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,i),i+=n.strings.length-2):n._$AI(e[i])),i++}},ad=class{constructor(e,i,n,r){var s;this.type=2,this._$AH=hr,this._$AN=void 0,this._$AA=e,this._$AB=i,this._$AM=n,this.options=r,this._$Cp=(s=r?.isConnected)===null||s===void 0||s}get _$AU(){var e,i;return(i=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&i!==void 0?i:this._$Cp}get parentNode(){let e=this._$AA.parentNode,i=this._$AM;return i!==void 0&&e?.nodeType===11&&(e=i.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,i=this){e=Op(this,e,i),o0(e)?e===hr||e==null||e===""?(this._$AH!==hr&&this._$AR(),this._$AH=hr):e!==this._$AH&&e!==rd&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):wit(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==hr&&o0(this._$AH)?this._$AA.nextSibling.data=e:this.$(nd.createTextNode(e)),this._$AH=e}g(e){var i;let{values:n,_$litType$:r}=e,s=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=sd.createElement(t9(r.h,r.h[0]),this.options)),r);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===s)this._$AH.v(n);else{let a=new iP(s,this),o=a.u(this.options);a.v(n),this.$(o),this._$AH=a}}_$AC(e){let i=Xj.get(e.strings);return i===void 0&&Xj.set(e.strings,i=new sd(e)),i}T(e){Zj(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,n,r=0;for(let s of e)r===i.length?i.push(n=new ad(this.k(a0()),this.k(a0()),this,this.options)):n=i[r],n._$AI(s),r++;r<i.length&&(this._$AR(n&&n._$AB.nextSibling,r),i.length=r)}_$AR(e=this._$AA.nextSibling,i){var n;for((n=this._$AP)===null||n===void 0||n.call(this,!1,!0,i);e&&e!==this._$AB;){let r=e.nextSibling;e.remove(),e=r}}setConnected(e){var i;this._$AM===void 0&&(this._$Cp=e,(i=this._$AP)===null||i===void 0||i.call(this,e))}},Lp=class{constructor(e,i,n,r,s){this.type=1,this._$AH=hr,this._$AN=void 0,this.element=e,this.name=i,this._$AM=r,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=hr}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,i=this,n,r){let s=this.strings,a=!1;if(s===void 0)e=Op(this,e,i,0),a=!o0(e)||e!==this._$AH&&e!==rd,a&&(this._$AH=e);else{let o=e,l,c;for(e=s[0],l=0;l<s.length-1;l++)c=Op(this,o[n+l],i,l),c===rd&&(c=this._$AH[l]),a||(a=!o0(c)||c!==this._$AH[l]),c===hr?e=hr:e!==hr&&(e+=(c??"")+s[l+1]),this._$AH[l]=c}a&&!r&&this.j(e)}j(e){e===hr?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},nP=class extends Lp{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===hr?void 0:e}},Mit=Ip?Ip.emptyScript:"",rP=class extends Lp{constructor(){super(...arguments),this.type=4}j(e){e&&e!==hr?this.element.setAttribute(this.name,Mit):this.element.removeAttribute(this.name)}},sP=class extends Lp{constructor(e,i,n,r,s){super(e,i,n,r,s),this.type=5}_$AI(e,i=this){var n;if((e=(n=Op(this,e,i,0))!==null&&n!==void 0?n:hr)===rd)return;let r=this._$AH,s=e===hr&&r!==hr||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,a=e!==hr&&(r===hr||s);s&&this.element.removeEventListener(this.name,this,r),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var i,n;typeof this._$AH=="function"?this._$AH.call((n=(i=this.options)===null||i===void 0?void 0:i.host)!==null&&n!==void 0?n:this.element,e):this._$AH.handleEvent(e)}},aP=class{constructor(e,i,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=i,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Op(this,e)}};var $j=Ax.litHtmlPolyfillSupport;$j?.(sd,ad),((J3=Ax.litHtmlVersions)!==null&&J3!==void 0?J3:Ax.litHtmlVersions=[]).push("2.8.0");var l0=(t,e,i)=>{var n,r;let s=(n=i?.renderBefore)!==null&&n!==void 0?n:e,a=s._$litPart$;if(a===void 0){let o=(r=i?.renderBefore)!==null&&r!==void 0?r:null;s._$litPart$=a=new ad(e.insertBefore(a0(),o),o,void 0,i??{})}return a._$AI(t),a};var oP,lP;var Eh=class extends dl{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,i;let n=super.createRenderRoot();return(e=(i=this.renderOptions).renderBefore)!==null&&e!==void 0||(i.renderBefore=n.firstChild),n}update(e){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=l0(i,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return rd}};Eh.finalized=!0,Eh._$litElement$=!0,(oP=globalThis.litElementHydrateSupport)===null||oP===void 0||oP.call(globalThis,{LitElement:Eh});var e9=globalThis.litElementPolyfillSupport;e9?.({LitElement:Eh});((lP=globalThis.litElementVersions)!==null&&lP!==void 0?lP:globalThis.litElementVersions=[]).push("3.3.3");var i9=t=>e=>typeof e=="function"?((i,n)=>(customElements.define(i,n),n))(t,e):((i,n)=>{let{kind:r,elements:s}=n;return{kind:r,elements:s,finisher(a){customElements.define(i,a)}}})(t,e);var Eit=(t,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},Ait=(t,e,i)=>{e.constructor.createProperty(i,t)};function ws(t){return(e,i)=>i!==void 0?Ait(t,e,i):Eit(t,e)}var hP,wpt=((hP=window.HTMLSlotElement)===null||hP===void 0?void 0:hP.prototype.assignedElements)!=null?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter(i=>i.nodeType===Node.ELEMENT_NODE);var Tx=window.IntersectionObserver!=null;var n9=(t=32,e=2)=>{let i=t/2;return Jj` <style>
9937
9937
  :host {