@splinetool/viewer 2.0.80 → 2.0.82
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.
|
@@ -344,13 +344,13 @@ ${t.stack}`:r}function fTt(t){t<1028||(nh[t]=Eb,Eb=t)}function Ho(t,e){return t=
|
|
|
344
344
|
}
|
|
345
345
|
post({ kind: 'ready' });
|
|
346
346
|
}, 250);
|
|
347
|
-
})();`}),umt=j(()=>{Q7=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 r=i.setVariable(String(e[0]),e[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=e[0]??{},s=!0;for(let[n,a]of Object.entries(r)){let o=i.setVariable(n,a);o.warning&&this.onConsole("warn",o.warning),s=s&&o.ok}return s}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 r=i.getGeometry(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.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"getTexture":if(i.getTexture===void 0)throw new Error("getTexture: not available on this surface \u2014 a three.js texture instance needs the inline HTML-content mode (editor Preview/Play and web exports).");return i.getTexture(String(e[0]),e[1]??{});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 r=i.spawnObject(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let r=e[1]===null||e[1]===void 0?null:e[1],s=i.setInstanceTransforms(String(e[0]),r);return s<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).`),s}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(e[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,s=>{this.onEvent(r,s)})),!0}case"unlistenEvent":{let r=String(e[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!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,r){let s=[];for(let n of Object.keys(r))i[n]!==r[n]&&s.push({name:n,value:r[n]});return s}(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 CMt(t,e,i,r){return[t[0]*e+t[4]*i+t[8]*r+t[12],t[1]*e+t[5]*i+t[9]*r+t[13],t[2]*e+t[6]*i+t[10]*r+t[14]]}var EMt=j(()=>{}),dmt,PMt=j(()=>{}),RMt=j(()=>{J7(),umt(),dmt=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=r=>{if(this.disposed||r.source!==this.iframe.contentWindow)return;let s=r.data;var n;typeof(n=s)!="object"||n===null||n[jp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new Q7(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[jp]:!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({[jp]:!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({[jp]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[jp]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[jp]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),r={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,{...r,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,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,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(s,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(s,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(s);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...r,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ir=j(()=>{Z7(),cMt(),pMt(),mMt(),gMt(),yMt(),vMt(),bMt(),_Mt(),xMt(),wMt(),MMt(),J7(),AMt(),umt(),EMt(),PMt(),RMt()}),DMt=j(()=>{});function cmt(t){return Array.isArray(t)?t:[t]}function JR(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 NMt=j(()=>{});function $a(t,e){return Object.setPrototypeOf(t,e),t}function qN(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function Jp(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 n=t;t=e,e=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=t+(e-t)*(n+.75+.5*Math.random())*s;r.push(a)}return r}function Qg(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 OMt=j(()=>{});function tG(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let r=t[i];r&&typeof r=="object"&&tG(r)}return Object.freeze(t)}function pmt(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var HN,t4,W8,Be,eG,IMt=j(()=>{}),hn=j(()=>{DMt(),NMt(),OMt(),IMt()}),iG=j(()=>{HN=class{},t4=class extends HN{constructor(t){super(),this.id=t}},W8=class extends HN{constructor(t){super(),this.data=t}}}),BMt=j(()=>{}),E5=j(()=>{Be=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let r={...i,[t]:e};return Object.setPrototypeOf(r,Be.prototype),r}}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,r=e[t.id];i=r===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:r};let{id:s,data:n}=t,a={...e,[s]:n};return Object.setPrototypeOf(a,Be.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,r=e[i];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Be.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),rG=j(()=>{eG=class extends Error{}});function mmt(t,e){for(let i of t)e(i.id,i.data)!==!0&&mmt(i.children,e)}function fmt(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)fmt(i,e)}var In,gM,Nv,ye,r0=j(()=>{hn(),rG(),hn(),In=class extends Array{constructor(...t){super(...t),pc(this,"partialObjectCaches"),pc(this,"objCaches"),pc(this,"parentCaches"),Object.setPrototypeOf(this,In.prototype)}deepFreeze(){let t=0;for(;t<this.length;)tG(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&&fmt(i,e)}}traverse(t){mmt(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),r=this.childrenArray(i),s=r.findIndex(o=>o.id===t);if(s<0)throw new Error("not expected");let n=r[s];r=[...r],r[s]={...n,data:e};let a=new Map;return a.set(t,r[s]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(t,e,i=void 0){let r=t,s=e;for(;r!==null;){let a=s,o=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let l=s.findIndex(u=>u.id===o);if(l<0)throw new Error;s=[...s],s[l]={...s[l],children:a},i&&i.set(o,s[l])}Object.setPrototypeOf(s,In.prototype);let n=s;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){n.objCaches=this.objCaches;for(let[a,o]of i)n.objCaches.set(a,o);n.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else n.fillCaches();return n}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:r,data:s,children:n}=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:r,data:s,children:n};return o=[...o,l],o.sort((u,h)=>u.fi-h.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:r}}}}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 r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);t.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:t,reverse:{type:7,...n,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:r}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:r});if(e!==null){let d=e;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new eG("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],u=this.modifyArrayBy(s,a);s=e,a=u.childrenArray(s);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),u=u.modifyArrayBy(s,a),{data:u,actual:t,reverse:{type:9,parent:n,fi:h,id:r}}}previous(t,e){if(e===null){let r=this.childrenArray(t);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(t)){if(r.id===e)return i;i=r.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)+1;if(r<i.length)return i[r].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),r=i.findIndex(s=>s.id===t)-1;return r>=0?this.traverseSortPrevious(i[r].id):e}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push({...i,...r})}e.sort((i,r)=>JR(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i);r!==void 0&&e.push(r)}e.sort((i,r)=>JR(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],r=this.get(e),s=r;if(r!==void 0){for(;e;)i.splice(0,0,r.fi),e=this.parent(e),e!==null&&(r=this.get(e));return{...s,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let r=this.childrenArray(t);if(e===null){if(r.length===0)return Jp(0,i,i);{let s=r[0].fi;return Jp(s-i,s,i)}}{let s=this.get(e);if(s===void 0||this.parent(e)!==t)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Jp(a,a+i,i)}return Jp(s.fi,n.fi,i)}}}}),sG=j(()=>{var t;hn(),gM=null,(t=Nv||(Nv={})).setPreservePrototype=function(e){gM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===gM&&Object.setPrototypeOf(i,gM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||Qg(e)){let r=i.props,s={},n=Qg(e)?e.slice():[...e],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");s[o]=n[l],n[l]=r[o],a=!0}return a?{data:n,actual:i,reverse:{type:0,props:s}}:null}{let r=i.props,s={},n={...e},a=!1;if(r)for(let o of Object.keys(r)){s[o]=n[o];let l=r[o];l===void 0?delete n[o]:n[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,n),actual:i,reverse:{type:0,props:s}}:null}}}),s0=j(()=>{hn(),hn(),ye=class extends Array{constructor(...t){super(...t),pc(this,"objCaches"),Object.setPrototypeOf(this,ye.prototype)}deepFreeze(){let t=0;for(;t<this.length;)tG(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,r=i.findIndex(n=>n.id===t);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,ye.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:r}=t,s=this,n={fi:e,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),t.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,r=i.findIndex(n=>n.id===e);if(r===-1)return null;t.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...s}}}moveOp(t){let{fi:e,id:i}=t,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:e};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),t.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:t,reverse:{type:6,fi:n,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 Jp(0,e,e);{let r=i[0].fi;return Jp(r-e,r,e)}}{let r=this.get(t);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Jp(n,n+e,e)}return Jp(r.fi,s.fi,e)}}}});function VMt(t,e){let i={cur:[],result:[],len:0};return[t=av(t,e,i)??t,i.result]}function RP(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function DP(t){t&&(t.len-=1)}function gmt(t,e,i){let r=!1,s=t.map(n=>{let a=n.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=av(n.data,e,RP(i,a));DP(i),r=r||l!==void 0,l===void 0&&(l=n.data);let u=gmt(n.children,e,i);return u!==void 0?r=!0:u=n.children,{...n,id:a,data:l,children:u}});if(r)return s}function av(t,e,i){if(t instanceof In){let r=gmt(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ye)return function(r,s,n){let a=!1,o=r.map(l=>{let u=l.id,h=s[u];if(h!==void 0&&typeof h=="string"&&(a=!0,u=h,n!==null))throw new Error("not supported");let d=av(l.data,s,RP(n,u));return DP(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:u,data:d}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(r)),o}(t,e,i);if(Array.isArray(t)){let r=!1,s=t.map((n,a)=>{let o=av(n,e,RP(i,a));return DP(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(t)),s):void 0}if(t&&typeof t=="object"&&!Qg(t)){let r={},s=!1;for(let[n,a]of Object.entries(t))if(n!=="name"&&n!=="variableId"){let o=e[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=av(a,e,RP(i,n));DP(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(typeof t=="string"){let r=e[t];return r!==void 0&&function(s){if(s===null)return null;s.result.push(s.cur.slice(0,s.len))}(i),r}}var ymt=j(()=>{r0(),s0(),hn()});function ov(t){return t&&typeof t=="object"&&t instanceof As}function nG(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=j2(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=nG(s.children,e);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}return{...s,id:n,data:a}});return i?r:void 0}function j2(t,e){if(!ov(e))return e;if(t instanceof In){let i=nG(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ye)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=j2(a.data,r[o]);return s=s||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return s?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}(t,e);if(Array.isArray(t)){let i=!1,r=t.map((s,n)=>{let a=j2(s,e[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t instanceof As)return aG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=j2(n,e[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function aG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!ov(e))return e;if(!ov(t))return um.apply(t,e);let i=new Set;for(let s of Object.keys(t))i.add(s);for(let s of Object.keys(e))i.add(s);let r=new As;for(let s of i){let n=aG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var As,um,e4,ea,k$,P5=j(()=>{var t;r0(),s0(),N5(),hn(),As=class{unusedFunOverridesTable(e){}runOp(e){let i=[],r=this,s=0,n={};for(;s<e.path.length;){if(i.push(r),r=r===void 0?void 0:r[e.path[s]],r!==void 0&&!ov(r))return null;s+=1}r=r?qN(r):new As;for(let[a,o]of Object.entries(e.props)){let l=r[a];n[a]=l,o===void 0?delete r[a]:r[a]=o}for(;s>0;){if(Object.keys(r).length===0){let a=i[s-1];a&&(r=qN(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=qN(a);o[e.path[s-1]]=r,r=o}else{let o=new As;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,As.prototype),actual:e,reverse:{...e,props:n}}}},(t=um||(um={})).apply=function(e,i){return j2(e,i)??e},t.merge=function(e,i){return aG(e,i)},t.filterOp=function(e,i){let r=0,s=i.path,n=e;for(;r<s.length&&n!==void 0;){if(n=Dn.zoomOnce(n,s[r]),n===void 0)return i;if(!ov(n))return;r+=1}if(n===void 0)return i;if(ov(n)){if(i.type===0){let a={...i.props};for(let o of Object.keys(n))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=nG([i],n);return a?a[0]:i}return i}}}),kMt=j(()=>{hn(),N5(),E5(),r0(),rG(),sG(),s0(),ymt(),P5(),(e4||(e4={})).replaceProps=function(t,e){let i=Dn.zoom(e,t.path);if(typeof i=="object"){let r={};for(let s of Object.keys(t.props))r[s]=i[s];return{...t,props:r}}return{...t,props:{}}},(t=>{function e(s,n){let a=n.path,o=[];for(;;){let l;if(s instanceof As&&n.type===0&&(l=s.runOp({...n,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=s instanceof In||s instanceof ye||s instanceof Be?s.runOp(n):Nv.runOp(s,n)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],m=o[c];if(m instanceof In){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ye){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Be){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof As){let f={...m,[p]:d};d=Object.setPrototypeOf(f,As.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||Qg(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=Qg(m)?m.slice():[...m],d[p]=f}else d=Nv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let u,h=a[o.length];if(s instanceof In){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else if(s instanceof ye){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else s!==null&&(u=s[h]);if(u===void 0)return null;o.push(s),s=u}}function i(s,n){for(let a=0;a<s.length&&a<n.length;a++)if(s[a]!==n[a])return!0;return!1}function r(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==n[a])return!1;return!0}t.drop=function(s,n){return{...s,path:s.path.slice(n)}},t.applySimple=function(s,n){return e(s,n)?.data??s},t.apply=e,t.pathDisjoint=i,t.pathEq=r,t.commutative=function(s,n){return i(s.path,n.path)},t.subsumed=function(s,n){return!(s.type!==0||n.type!==0||!r(s.path,n.path))&&Object.keys(s.props).every(a=>n.props[a]!==void 0)}})(ea||(ea={})),(t=>{function e(i,r){let s=i,n=[],a=[];for(let o of r)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,u,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=ea.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=ea.apply(s,o)),h!==null){s=h.data;let[d,c]=VMt(s,{[o.id]:l});s=d;for(let p=0;p<c.length;p++){let m=c[p],f=m.pop();if(typeof f=="number"){let g=[f];for(let v=p+1;v<c.length;v++){let b=c[v],_=b[b.length-1];if(typeof _!="number"||!Dn.equal(m,b.slice(0,b.length-1)))break;g.push(_),c.splice(v,1)}let y=Dn.zoom(s,m);u=y.map((v,b)=>g.includes(b)?o.id:v),l=y,f=m.pop()}else{if(f==="alphaOverride"||f==="alpha"){l/=100;let g=l,y=Dn.zoom(s,m.slice(0,m.length-2)),v=y.layers.map(b=>b.id===m[m.length-1]?{...b,data:{...b.data,[f]:g}}:b);Object.setPrototypeOf(v,Object.getPrototypeOf(y.layers)),y.layers=v}u=o.id}n.push({type:0,path:m,props:{[f]:l}}),a.push({type:0,path:m,props:{[f]:u}})}a.push(h.reverse),n.push(h.actual)}}else{let l=ea.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof eG)return null;throw l}return{data:s,actual:n,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,r){let s=[];for(let n of i){let[a,...o]=n.path;a===r&&s.push({...n,path:o})}return s},t.addPrefix=function(i,r){return i.map(s=>({...s,path:[r,...s.path]}))},t.concat=function(i,r){return[...i,...r]},t.compress=function(i,r){return[...i.filter(s=>!r.some(n=>ea.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>ea.commutative(s,n)))},t.applyAll=function(i,r){for(let s of r){let n=e(i,s);n!==null&&(i=n.data)}return i},t.apply=e})(k$||(k$={}))});function z$(t,e){return t instanceof As?Object.setPrototypeOf(e,As.prototype):Nv.tryPreservePrototype(t,e)}function $N(t,e,i){if(t.length>0){let r=t[t.length-1];if(r.type===0&&e.type===0&&Dn.equal(r.path,i))return void Object.assign(r.props,e.props)}t.push({...e,path:i})}function NP(t,e,i){return i instanceof In?new R5(t,e,i):i instanceof ye?new D5(t,e,i):i instanceof Be?new Proxy(new bmt(t,e,i),xmt):i!==null&&typeof i=="object"?Qg(i)?i:new Proxy(new vmt(t,e,i),_mt):i}function Ww(t){let e=new H8(t);return[NP(e,"",t),e]}function i4(t,e){let[i,r]=Ww(t);return e(i),r.result()}function qs(t){return t instanceof R5||t instanceof D5?t._current:t!==null&&typeof t=="object"?t[q8]:t}var q8,L$,r_,k0,vmt,bmt,XN,_mt,xmt,R5,D5,H8,Dn,wmt=j(()=>{E5(),r0(),sG(),s0(),hn(),N5(),P5(),q8=Symbol(),L$=Symbol(),r_=Symbol(),k0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof H8);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[r_];i&&i(),delete this._children[t]}}}},vmt=class extends k0{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=z$(this._current,{...this._current,[t]:e})}runOp(t){let e=Nv.runOp(this._current,t);e!==null&&(e.data=z$(this._current,e.data)),this.reportOp(t,e,t.path)}},bmt=class extends k0{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,Be.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},XN={get(t,e){if(e===r_)return()=>{t._parent=null};if(e===q8)return t._current;if(e===L$)return t;let{_current:i,_children:r}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[e];if(s!==void 0)return s;let n=i[e],a=NP(t,e,n);return a!==n?(r===void 0&&(r={},t._children=r),r[e]=a,a):n},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,r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[e]}}},_mt={...XN,set(t,e,i){let r={type:0,props:{[e]:qs(i)??i}};return t.deleteChildren(e),t.runOp(r),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},xmt={...XN,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)},R5=class extends k0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[r_]=()=>{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,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=NP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}add(t,e,i,r,s){this.runOp({type:7,parent:t,fi:e,id:i,data:r,children:s})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}insertBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}moveAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}moveBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}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)}},D5=class extends k0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[r_]=()=>{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 r=this._current[i].id,s=this._current[i].fi;t(this.data(this._current[i].id),r,s,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id;if(t(this.data(r),r))return this.get(r)}}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,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=NP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}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 r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},H8=class extends k0{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,r){$N(this.ts,e,t),$N(this.actual,i,t),$N(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),N5=j(()=>{iG(),wmt(),s0(),r0(),hn(),(t=>{function e(r,s){return(r instanceof In||r instanceof R5)&&typeof s=="string"||(r instanceof ye||r instanceof D5)&&typeof s=="string"?r.data(s):typeof s=="number"&&Array.isArray(r)||typeof s=="string"&&typeof r=="object"&&r!==null?r[s]:void 0}function i(r,s,n=0){for(;n<s.length&&r!==void 0;)r=e(r,s[n]),n+=1;return r}t.equal=function(r,s){if(s.length!==r.length)return!1;{let n=0;for(;n<r.length;){if(r[n]!==s[n])return!1;n+=1}}return!0},t.removeOverridden=function(r,s,n){let a=i(n,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...s};return Object.keys(a).forEach(l=>{delete o[l]}),o}return s},t.zoomOnce=e,t.zoom=i,t.findPathes=function(r,s){let n=[];return function a(o,l){if(o instanceof t4&&o.id===s.id)n.push(l);else if(o instanceof ye)for(let u=0;u<o.length;u++)a(o[u].data,[...l,o[u].id]);else if(o instanceof In)o.traverse((u,h)=>{a(h,[...l,u])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let u=0;u<o.length;u++)a(o[u],[...l,u])}else{if(Qg(o))return;if(typeof o=="object"&&o!==null)for(let u in o)a(o[u],[...l,u])}}(r,[]),n}})(Dn||(Dn={}))}),zMt=j(()=>{});function er(t,e){let i=[];if(!(e.length<=t.length))return null;{let r=0;for(;r<e.length;){if(e[r]==="*")i.push(t[r]);else if(t[r]!==e[r])return null;r+=1}}return i}var LMt=j(()=>{});function yM(t){try{if(!Er.trusted&&!gc){let i=Wi.sharedLength||0;i<Wi.length&&(Wi.length=i)}let e;if(Er.randomAccessStructure&&pe[ft]<64&&pe[ft]>=32&&q$?(e=q$(pe,ft,Ql,Er),pe=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),ft=Ql):e=Ys(),Da&&(ft=Da.postBundlePosition,Da=null),gc&&(Wi.restoreStructures=null),ft==Ql)Wi&&Wi.restoreStructures&&F$(),Wi=null,pe=null,fc&&(fc=null);else{if(ft>Ql)throw new Error("Unexpected end of MessagePack data");if(!gc){let i;try{i=JSON.stringify(e,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw Wi&&Wi.restoreStructures&&F$(),X8(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||ft>Ql)&&(e.incomplete=!0),e}}function F$(){for(let t in Wi.restoreStructures)Wi[t]=Wi.restoreStructures[t];Wi.restoreStructures=null}function Ys(){let t=pe[ft++];if(t<160){if(t<128){if(t<64)return t;{let e=Wi[63&t]||Er.getStructures&&Smt()[63&t];return e?(e.read||(e.read=$8(e,63&t)),e.read()):t}}if(t<144){if(t-=128,Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=Mmt();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(qh>=ft)return tm.slice(ft-pl,(ft+=e)-pl);if(qh==0&&Ql<140){let i=e<16?oG(e):Tmt(e);if(i!=null)return i}return n4(e)}{let e;switch(t){case 192:return null;case 193:return Da?(e=Ys(),e>0?Da[1].slice(Da.position1,Da.position1+=e):Da[0].slice(Da.position0,Da.position0-=e)):Emt;case 194:return!1;case 195:return!0;case 196:if(e=pe[ft++],e===void 0)throw new Error("Unexpected end of buffer");return YN(e);case 197:return e=zi.getUint16(ft),ft+=2,YN(e);case 198:return e=zi.getUint32(ft),ft+=4,YN(e);case 199:return tf(pe[ft++]);case 200:return e=zi.getUint16(ft),ft+=2,tf(e);case 201:return e=zi.getUint32(ft),ft+=4,tf(e);case 202:if(e=zi.getFloat32(ft),Er.useFloat32>2){let i=tU[(127&pe[ft])<<1|pe[ft+1]>>7];return ft+=4,(i*e+(e>0?.5:-.5)|0)/i}return ft+=4,e;case 203:return e=zi.getFloat64(ft),ft+=8,e;case 204:return pe[ft++];case 205:return e=zi.getUint16(ft),ft+=2,e;case 206:return e=zi.getUint32(ft),ft+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*zi.getUint32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigUint64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigUint64(ft),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigUint64(ft),ft+=8,e;case 208:return zi.getInt8(ft++);case 209:return e=zi.getInt16(ft),ft+=2,e;case 210:return e=zi.getInt32(ft),ft+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*zi.getInt32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigInt64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigInt64(ft),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigInt64(ft),ft+=8,e;case 212:if(e=pe[ft++],e==114)return J8(63&pe[ft++]);{let i=Ma[e];if(i)return i.read?(ft++,i.read(Ys())):i.noBuffer?(ft++,i()):i(pe.subarray(ft,++ft));throw new Error("Unknown extension "+e)}case 213:return e=pe[ft],e==114?(ft++,J8(63&pe[ft++],pe[ft++])):tf(2);case 214:return tf(4);case 215:return tf(8);case 216:return tf(16);case 217:return e=pe[ft++],qh>=ft?tm.slice(ft-pl,(ft+=e)-pl):Rmt(e);case 218:return e=zi.getUint16(ft),qh>=(ft+=2)?tm.slice(ft-pl,(ft+=e)-pl):Dmt(e);case 219:return e=zi.getUint32(ft),qh>=(ft+=4)?tm.slice(ft-pl,(ft+=e)-pl):Nmt(e);case 220:return e=zi.getUint16(ft),ft+=2,U$(e);case 221:return e=zi.getUint32(ft),ft+=4,U$(e);case 222:return e=zi.getUint16(ft),ft+=2,j$(e);case 223:return e=zi.getUint32(ft),ft+=4,j$(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 $8(t,e){function i(){if(i.count++>K8){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":Pmt.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")(Ys)}catch{return K8=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=Z8(e,t.read)),s()}let r={};for(let s=0,n=t.length;s<n;s++){let a=t[s];a==="__proto__"&&(a="__proto_"),r[a]=Ys()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?Z8(e,i):i}function Smt(){let t=Cmt(()=>(pe=null,Er.getStructures()));return Wi=Er._mergeStructures(t,Wi)}function qw(t){let e;if(t<16&&(e=oG(t)))return e;if(t>64&&Y8)return Y8.decode(pe.subarray(ft,ft+=t));let i=ft+t,r=[];for(e="";ft<i;){let s=pe[ft++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&pe[ft++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&pe[ft++])<<6|63&pe[ft++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&pe[ft++])<<12|(63&pe[ft++])<<6|63&pe[ft++];n<65536||n>1114111?r.push(65533):(n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n))}else r.push(65533);else r.push(s);r.length>=4096&&(e+=Tn.apply(String,r),r.length=0)}return r.length>0&&(e+=Tn.apply(String,r)),e}function U$(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}function j$(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=Mmt();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}function Tmt(t){let e=ft,i=new Array(t);for(let r=0;r<t;r++){let s=pe[ft++];if((128&s)>0)return void(ft=e);i[r]=s}return Tn.apply(String,i)}function oG(t){if(t<4){if(t<2){if(t===0)return"";{let e=pe[ft++];return(128&e)>1?void(ft-=1):Tn(e)}}{let e=pe[ft++],i=pe[ft++];if((128&e)>0||(128&i)>0)return void(ft-=2);if(t<3)return Tn(e,i);let r=pe[ft++];return(128&r)>0?void(ft-=3):Tn(e,i,r)}}{let e=pe[ft++],i=pe[ft++],r=pe[ft++],s=pe[ft++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(ft-=4);if(t<6){if(t===4)return Tn(e,i,r,s);{let n=pe[ft++];return(128&n)>0?void(ft-=5):Tn(e,i,r,s,n)}}if(t<8){let n=pe[ft++],a=pe[ft++];if((128&n)>0||(128&a)>0)return void(ft-=6);if(t<7)return Tn(e,i,r,s,n,a);let o=pe[ft++];return(128&o)>0?void(ft-=7):Tn(e,i,r,s,n,a,o)}{let n=pe[ft++],a=pe[ft++],o=pe[ft++],l=pe[ft++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(ft-=8);if(t<10){if(t===8)return Tn(e,i,r,s,n,a,o,l);{let u=pe[ft++];return(128&u)>0?void(ft-=9):Tn(e,i,r,s,n,a,o,l,u)}}if(t<12){let u=pe[ft++],h=pe[ft++];if((128&u)>0||(128&h)>0)return void(ft-=10);if(t<11)return Tn(e,i,r,s,n,a,o,l,u,h);let d=pe[ft++];return(128&d)>0?void(ft-=11):Tn(e,i,r,s,n,a,o,l,u,h,d)}{let u=pe[ft++],h=pe[ft++],d=pe[ft++],c=pe[ft++];if((128&u)>0||(128&h)>0||(128&d)>0||(128&c)>0)return void(ft-=12);if(t<14){if(t===12)return Tn(e,i,r,s,n,a,o,l,u,h,d,c);{let p=pe[ft++];return(128&p)>0?void(ft-=13):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p)}}{let p=pe[ft++],m=pe[ft++];if((128&p)>0||(128&m)>0)return void(ft-=14);if(t<15)return Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m);let f=pe[ft++];return(128&f)>0?void(ft-=15):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m,f)}}}}}function G$(){let t,e=pe[ft++];if(e<192)t=e-160;else switch(e){case 217:t=pe[ft++];break;case 218:t=zi.getUint16(ft),ft+=2;break;case 219:t=zi.getUint32(ft),ft+=4;break;default:throw new Error("Expected string")}return qw(t)}function YN(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(pe,ft,ft+=t):pe.subarray(ft,ft+=t)}function tf(t){let e=pe[ft++];if(Ma[e]){let i;return Ma[e](pe.subarray(ft,i=ft+=t),r=>{ft=r;try{return Ys()}finally{ft=i}})}throw new Error("Unknown extension type "+e)}function Mmt(){let t=pe[ft++];if(!(t>=160&&t<192))return ft--,Amt(Ys());if(t-=160,qh>=ft)return tm.slice(ft-pl,(ft+=t)-pl);if(!(qh==0&&Ql<180))return n4(t);let e,i=4095&(t<<5^(t>1?zi.getUint16(ft):t>0?pe[ft]:0)),r=Q8[i],s=ft,n=ft+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=zi.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=pe[s++],e!=r[a++]){s=1879048192;break}if(s===n)return ft=s,r.string;n-=3,s=ft}for(r=[],Q8[i]=r,r.bytes=t;s<n;)e=zi.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=pe[s++],r.push(e);let o=t<16?oG(t):Tmt(t);return r.string=o??n4(t)}function Amt(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(Er.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 Cmt(t){H$&&H$();let e=Ql,i=ft,r=s4,s=pl,n=qh,a=tm,o=r4,l=fc,u=Da,h=new Uint8Array(pe.slice(0,Ql)),d=Wi,c=Wi.slice(0,Wi.length),p=Er,m=gc,f=t();return Ql=e,ft=i,s4=r,pl=s,qh=n,tm=a,r4=o,fc=l,Da=u,pe=h,gc=m,(Wi=d).splice(0,Wi.length,...c),Er=p,zi=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),f}function X8(){pe=null,fc=null,Wi=null}function FMt(t){t.unpack?Ma[t.type]=t.unpack:Ma[t.type]=t}var Y8,pe,Ql,ft,W$,r4,s4,Er,Wi,tm,pl,qh,Da,fc,Ma,zi,KN,Emt,gc,K8,q$,H$,Hw,Pmt,Z8,n4,Rmt,Dmt,Nmt,Tn,Q8,J8,ZN,$$,X$,Y$,tU,vM,K$,Z$,Q$,eU,QN,ES,UMt=j(()=>{try{Y8=new TextDecoder}catch{}ft=0,r4=W$=[],s4=0,Er={},pl=0,qh=0,Ma=[],KN={useRecords:!1,mapsAsObjects:!0},(Emt=new class{}).name="MessagePack 0xC1",gc=!1,K8=2,Hw=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(pe)return Cmt(()=>(X8(),this?this.unpack(t,e):Hw.prototype.unpack.call(KN,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ql=e.end||t.length,ft=e.start||0):(ft=0,Ql=e>-1?e:t.length),s4=0,qh=0,tm=null,r4=W$,Da=null,pe=t;try{zi=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw pe=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 Hw){if(Er=this,this.structures)return Wi=this.structures,yM(e);(!Wi||Wi.length>0)&&(Wi=[])}else Er=KN,(!Wi||Wi.length>0)&&(Wi=[]);return yM(e)}unpackMultiple(t,e){let i,r=0;try{gc=!0;let s=t.length,n=this?this.unpack(t,s):vM.unpack(t,s);if(!e){for(i=[n];ft<s;)r=ft,i.push(yM());return i}if(e(n,r,ft)===!1)return;for(;ft<s;)if(r=ft,e(yM(),r,ft)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{gc=!1,X8()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,r=t.length;i<r;i++){let s=t[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let r=t[i],s=e[i];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[i]=r),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},Pmt=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,Z8=(t,e)=>function(){let i=pe[ft++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=Wi[r]||Smt()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=$8(s,t)),s.read()},n4=qw,Rmt=qw,Dmt=qw,Nmt=qw,Tn=String.fromCharCode,Q8=new Array(4096),J8=(t,e)=>{let i=Ys().map(Amt),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=Wi[t];return s&&(s.isShared||gc)&&((Wi.restoreStructures||(Wi.restoreStructures=[]))[t]=s),Wi[t]=i,i.read=$8(i,r),(i.read0||i.read)()},Ma[0]=()=>{},Ma[0].noBuffer=!0,Ma[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let r=1;r<e;r++)i<<=BigInt(8),i+=BigInt(t[r]);if(t.byteLength!==e){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=(n,a)=>{let o=a-n;if(o<=40){let d=r.getBigUint64(n);for(let c=n+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=n+(o>>4<<3),u=s(n,l),h=s(l,a);return u<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},ZN={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},Ma[101]=()=>{let t=Ys();if(!ZN[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return ZN[t[0]](t[1],{cause:t[2]})},Ma[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4);fc||(fc=new Map);let i,r=pe[ft];i=r>=144&&r<160||r==220||r==221?[]:r>=128&&r<144||r==222||r==223?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&pe[ft+1]===115?new Set:{};let s={target:i};fc.set(e,s);let n=Ys();if(!s.used)return s.target=n;if(Object.assign(i,n),i instanceof Map)for(let[a,o]of n.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(n))i.add(a);return i},Ma[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4),i=fc.get(e);return i.used=!0,i.target},Ma[115]=()=>new Set(Ys()),$$=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),X$=typeof globalThis=="object"?globalThis:window,Ma[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=$$[e];if(!r){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 X$[r](i)},Ma[120]=()=>{let t=Ys();return new RegExp(t[0],t[1])},Y$=[],Ma[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=ft;return ft+=e-t.length,Da=Y$,(Da=[G$(),G$()]).position0=0,Da.position1=0,Da.postBundlePosition=ft,ft=i,Ys()},Ma[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"),tU=new Array(147);for(let t=0;t<256;t++)tU[t]=+("1e"+Math.floor(45.15-.30103*t));(vM=new Hw({useRecords:!1})).unpack,vM.unpackMultiple,vM.unpack,K$=new Float32Array(1),new Uint8Array(K$.buffer,0,4)}),jMt=j(()=>{UMt(),iG(),P5(),s0(),E5(),r0(),Z$=[{Class:Be.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Be.prototype),t)},{Class:ye.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ye.prototype),t)},{Class:In.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,In.prototype),t)},{Class:t4.prototype.constructor,type:4,write:t=>t.id,read:t=>new t4(t)},{Class:W8.prototype.constructor,type:5,write:t=>t.data,read:t=>new W8(t)},{Class:As.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,As.prototype),t)}];for(let t of Z$)FMt(t);Q$=new Hw({structuredClone:!0}),(eU||(eU={})).deserialize=function(t){return Q$.unpack(t)}}),GMt=j(()=>{jMt(),QN=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},ES={deserialize:eU.deserialize,serialize:QN("CollabSerialize.serialize"),checksum:QN("CollabSerialize.checksum")}}),Fi=j(()=>{N5(),BMt(),rG(),r0(),E5(),sG(),s0(),kMt(),zMt(),wmt(),LMt(),iG(),GMt(),ymt(),P5()});function iU(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var J$,rU,G2,bM,JN,tX,eX,iX,sU,nU,rX,sX,nX,aX,oX,aU,oU,lX,hX,uX,dX,Omt=j(()=>{var t,e,i;Fi(),dt(),(t=J$||(J$={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},t.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},rU={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"]},(r=>{r.is=function(s){return s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"},r.defaultData=function(s){return s==="MouseDown"||s==="MouseUp"||s==="MousePress"?{type:s,mode:"Object",disabled:!1,name:"",actions:new ye}:{type:s,disabled:!1,name:"",key:void 0,actions:new ye}}})(G2||(G2={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(bM||(bM={})),(e=JN||(JN={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:bM.propertyDefaultData(r),rOperand:{...bM.valueDefaultData}}},e.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},e.stateDefaultData=function(r,s){return{type:"State",object:r??null,state:s??null}},(tX||(tX={})).isConditionalSubActions=function(r){return r.find(s=>s==="ifActions"||s==="elseActions")!==void 0},(r=>{r.is=function(s){return s.type==="Conditional"},r.defaultData=function(s){return{type:"Conditional",disabled:!1,name:"",inActions:new ye,outActions:new ye,condition:JN.distanceDefaultData(s)}}})(eX||(eX={})),(iX||(iX={})).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 ye,drop:new ye}},(sU||(sU={})).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 ye},(nU||(nU={})).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},(r=>{r.is=function(s){return s.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new ye}}})(rX||(rX={})),(r=>{r.is=function(s){return s.type==="Scroll"},r.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ye}}})(sX||(sX={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ye}}})(nX||(nX={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ye}}})(aX||(aX={})),(r=>{r.is=function(s){return s.type==="Trigger"},r.defaultData=function(s,n){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new ye,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(oX||(oX={})),(i=aU||(aU={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(r){return r.type==="Resize"},i.sizeToDevice=function(r){return typeof r=="string"?r:"custom"},i.deviceToSize=function(r){return typeof r=="string"?[...i.defaultSizes[r]]:[...r]},i.defaultData=function(){let r={size:"mobile",operator:"<",actions:new ye},s={size:"tablet",operator:"<",actions:new ye},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ye},a=new ye;return a.push({id:qt.generateUUID(),fi:0,data:r},{id:qt.generateUUID(),fi:1,data:s},{id:qt.generateUUID(),fi:2,data:n}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new ye}},(r=>{r.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"]},r.is=function(s){return s.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new ye,variableId:"",objectId:null,property:"Position X"}}})(oU||(oU={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ye,errorActions:new ye,userAPIId:""}}})(lX||(lX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ye,userWebhookId:""}}})(hX||(hX={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ye,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(uX||(uX={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ye}}})(dX||(dX={}))});function cX(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function pX(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 n0,lv,Imt,Jg,mX,qu,dm,PS,fX,hv,an,qi,lU,gX,em,Ov,yX,vX,bX,_X,xX,wX,SX,TX,tO,MX,AX,eO,CX,EX,PX,iO,RX,rO,DX,NX,sO,OX,hU,IX,BX,VX,kX,zX,LX,t0,yc,im,uU,dU,a4,o4,l4,h4,u4,cU,pU,d4,mU,uv,FX,nO,aO,fU,UX,c4,jX,GX,gU,WX,qX,HX,$X,XX,YX,KX,ZX,QX,O5,lG,Hs,cs,M1,Bmt,RS,p4,mg,yU,hG,m4,f4,vU,hc,OP,ia,oO,Yp,wl=j(()=>{var t,e,i,r,s,n,a,o;n0="personal camera",lv="a218fcc3-276b-49b9-b485-49037fd14f5f",Imt=2500134,Jg=5526619,(t=mX||{}).x="x",t.y="y",t.z="z",mX=t,(l=>{function u(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function h(c,p){return Math.sqrt(u(c,p))}function d(c,p,m){let f=l.sub(p,c),g=l.sub(m,c),y=l.dot(f,g)/l.dot(f,f),v=l.scalarMultiply(f,y);return l.add(c,v)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,m){return[c[0]+(p[0]-c[0])*m,c[1]+(p[1]-c[1])*m]},l.add=function(c,p){return[c[0]+p[0],c[1]+p[1]]},l.sub=function(c,p){return[c[0]-p[0],c[1]-p[1]]},l.multiply=function(c,p){return[c[0]*p[0],c[1]*p[1]]},l.divide=function(c,p){return[c[0]/p[0],c[1]/p[1]]},l.distanceSquared=u,l.distance=h,l.dot=function(c,p){return c[0]*p[0]+c[1]*p[1]},l.scalarMultiply=function(c,p){return[c[0]*p,c[1]*p]},l.projectionOnto=d,l.projectionOntoDistance=function(c,p,m){return h(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(qu||(qu={})),(e=dm||(dm={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]},e.add=function(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]},e.sub=function(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]},e.div=function(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]},e.mul=function(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]},e.dist=function(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])},e.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h]},(i=PS||(PS={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]&&l[3]===u[3]},i.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h,l[3]+(u[3]-l[3])*h]},(l=>{let u=180/Math.PI,h=Math.PI/180;function d(p){return typeof p=="number"?p*u:p}function c(p){return typeof p=="number"?p*h:p}l.radToDeg=function(p){return[d(p[0]),d(p[1]),d(p[2])]},l.degToRad=function(p){return[c(p[0]),c(p[1]),c(p[2])]}})(fX||(fX={})),(r=hv||(hv={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,u){for(let h=0;h<16;h++)if(l[h]!==u[h])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,u){let h=u.slice(0);for(let d=0,c=u.length;d<c;d+=3){let p=l[3]*u[d]+l[7]*u[d+1]+l[11]*u[d+2]+l[15];h[d]=(l[0]*u[d]+l[4]*u[d+1]+l[8]*u[d+2]+l[12])/p,h[d+1]=(l[1]*u[d]+l[5]*u[d+1]+l[9]*u[d+2]+l[13])/p,h[d+2]=(l[2]*u[d]+l[6]*u[d+1]+l[10]*u[d+2]+l[14])/p}return h},(s=an||(an={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},s.clone=function(l){return{r:l.r,g:l.g,b:l.b}},s.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},s.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},s.equals=function(l,u){return l.r===u.r&&l.g===u.g&&l.b===u.b},s.equalsFixed=function(l,u){return l.r.toFixed(2)===u.r.toFixed(2)&&l.g.toFixed(2)===u.g.toFixed(2)&&l.b.toFixed(2)===u.b.toFixed(2)},s.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h}},s.is=function(l){return!!cX(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=qi||(qi={})).white={...an.white,a:1},n.is=function(l){return!!cX(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...an.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,u){return{...an.fromHex(l),a:u}},n.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}},n.equals=function(l,u){return an.equals(l,u)&&l.a===u.a},n.equalsFixed=function(l,u){return an.equalsFixed(l,u)&&l.a.toFixed(2)===u.a.toFixed(2)},n.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h,a:l.a+(u.a-l.a)*h}},n.toStyle=function({r:l,g:u,b:h,a:d}=n.white){return`rgba(${255*l}, ${255*u}, ${255*h}, ${d})`},(lU||(lU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=gX||{})[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",gX=a,(em||(em={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Ov||(Ov={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=yX||(yX={})).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]}),WMt=j(()=>{var t,e;Fi(),Omt(),(vX||(vX={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(bX||(bX={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(_X||(_X={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(xX||(xX={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(wX||(wX={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(SX||(SX={})).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"},(TX||(TX={})).defaultData={type:"Reset",name:"",delay:0},(tO||(tO={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=MX||(MX={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=AX||(AX={})).defaultData={type:"Audio",name:"",...tO.defaultData},e.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),e.hasAudioByEvents=i=>e.getAudiosByEvents(i).length>0,e.getAudiosByActions=i=>{let r=[];return i.forEach(s=>{let n=s.data;n.type==="Audio"&&n.interaction==="play"&&n.audio&&r.push(s),n.type==="Conditional"&&(r.push(...e.getAudiosByActions(n.ifActions)),r.push(...e.getAudiosByActions(n.elseActions)))}),r},e.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:s})=>{G2.is(s)||s.type==="Collision"||s.type==="Start"||s.type==="Trigger"||s.type==="VariableChange"||s.type==="WEBHOOK"||s.type==="AIAssistantTrigger"?r.push(...e.getAudiosByActions(s.actions)):s.type==="Conditional"?(r.push(...e.getAudiosByActions(s.inActions)),r.push(...e.getAudiosByActions(s.outActions))):s.type==="GameControl"?Object.values(s.gameActions).forEach(n=>{r.push(...e.getAudiosByActions(n))}):s.type==="DragDrop"?(r.push(...e.getAudiosByActions(s.dragDropActions.drag)),r.push(...e.getAudiosByActions(s.dragDropActions.drop))):s.type==="Resize"?s.breakpoints.forEach(({data:n})=>{r.push(...e.getAudiosByActions(n.actions))}):s.type==="API"&&(r.push(...e.getAudiosByActions(s.successActions)),r.push(...e.getAudiosByActions(s.errorActions)))}),r},(eO||(eO={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(CX||(CX={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...eO.defaultData},i.hasVideoByActions=r=>r.some(({data:s})=>s.type==="Video"&&s.interaction==="play"&&s.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:s}of r.events)if((G2.is(s)||s.type==="Start")&&i.hasVideoByActions(s.actions))return!0}},i.getVideosByActions=r=>{let s=[];return r.forEach(n=>{let a=n.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&s.push(n)}),s},i.getVideosByEvents=r=>{let s=[];return r.forEach(({data:n})=>{(G2.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(EX||(EX={})),(PX||(PX={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(iO||(iO={})).defaultData=function(){return{tweens:new ye,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(RX||(RX={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...iO.defaultData()}},(rO||(rO={})).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}})(DX||(DX={})),(NX||(NX={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...rO.defaultData(i)}},(sO||(sO={})).defaultData=function(i,r,s){return{interaction:"play",object:i,clipId:r,crop:s,crop2:s,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(OX||(OX={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...sO.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(hU||(hU={})),(IX||(IX={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(BX||(BX={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ye,elseActions:new ye,condition:[]}),(VX||(VX={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(kX||(kX={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(zX||(zX={})).defaultData={name:"",type:"UserAPI"}}),qMt=j(()=>{var t;(t=LX||(LX={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),Vmt=j(()=>{var t;(t=t0||(t0={})).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(n){return n===void 0||!Number.isFinite(n)||n<e.MinTargetOffset?e.DefaultTargetOffset:n},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,r=e.DefaultElevation*Math.PI/180,s=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(r),e.DefaultTargetOffset*Math.sin(r),e.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],e.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*s,Math.asin(Math.sin(i)*Math.cos(r))*s,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*s],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(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}})(yc||(yc={}))}),kmt=j(()=>{var t;(t=im||(im={})).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(r=>(typeof r=="number"?r: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 r={...e};if(dU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;a4.forEach(a=>{Object.assign(r.radial,{[a]:n[a]??s[a]})})}if(r.linear={...e.linear},i.linear){let s=e.linear,n=i.linear;o4.forEach(a=>{Object.assign(r.linear,{[a]:n[a]??s[a]})})}if(r.grid={...e.grid},i.grid){let s=e.grid,n=i.grid;l4.forEach(a=>{Object.assign(r.grid,{[a]:n[a]??s[a]})})}if(r.toObject={...e.toObject},i.toObject){let s=e.toObject,n=i.toObject;h4.forEach(a=>{Object.assign(r.toObject,{[a]:n[a]??s[a]})})}if(r.randomnessObject={...e.randomnessObject},i.randomnessObject){let s=e.randomnessObject,n=i.randomnessObject;u4.forEach(a=>{Object.assign(r.randomnessObject,{[a]:n[a]??s[a]})})}return r},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(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}})(uU||(uU={})),dU=["count"],a4=["radius","start","end","position","scale","rotation"],o4=["position","scale","rotation"],l4=["count","size"],h4=["count","position","scale","rotation"],u4=["strength","scale","rotation","position","movement","seed","freqScale"]}),zmt=j(()=>{var t;wl(),(t=cU||(cU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(pU||(pU={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:qi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:qi.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:qi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),Lmt=j(()=>{var t;(t=d4||(d4={})).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}}),Fmt=j(()=>{var t;(t=mU||(mU={})).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"]}),uG=j(()=>{(uv||(uv={})).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]}}),Umt=j(()=>{var t,e;(t=FX||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",FX=t,(e=nO||(nO={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(r,s){return r.flatShading===s.flatShading&&r.side===s.side&&r.wireframe===s.wireframe&&(r.shadowCatcher??!1)===(s.shadowCatcher??!1)}})(aO||(aO={})),(fU||(fU={})).defaultData={...aO.defaultData,...nO.defaultData},(UX||(UX={})).getMaterialData=function(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}}),jmt=j(()=>{var t;(t=c4||(c4={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),KS=j(()=>{var t,e,i,r;Fi(),wl(),jmt(),wl(),(jX||(jX={})).is=function(s){return s==="texture"||s==="video"||s==="color"||s==="depth"||s==="normal"||s==="gradient"||s==="noise"||s==="fresnel"||s==="cavity"||s==="dust"||s==="rainbow"||s==="toon"||s==="outline"||s==="particle"||s==="transmission"||s==="reflection"||s==="matcap"||s==="displace"||s==="pattern"||s==="vertexColor"||s==="light"},(GX||(GX={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(gU||(gU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(WX||(WX={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(r=qX||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",qX=r,HX=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(HX||{}),$X=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))($X||{}),(i=XX||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",XX=i,(e=YX||{})[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",YX=e,(t=KX||{})[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",KX=t,ZX=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(ZX||{}),QX=(s=>(s[s.Circle=0]="Circle",s[s.Ring=1]="Ring",s[s.Polygon=2]="Polygon",s[s.Cross=3]="Cross",s[s.Diamond=4]="Diamond",s[s.Checkerboard=5]="Checkerboard",s[s.Line=6]="Line",s[s.Wave=7]="Wave",s))(QX||{}),O5=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],lG=["wrapping","image","video","name","minFilter","magFilter"],(s=>{s.patch=function(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let u=n.texture;u&&Object.assign(u,o)}},s.defaultColorLayer=function(n){return{...s.defaultData("color"),color:n}},s.defaultData=function(n,a){return n==="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:c4.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:an.fromHex(Jg)};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:{...an.fromHex(6710886),a:1},colorB:{...an.fromHex(6710886),a:1},colorC:{...an.fromHex(16777215),a:1},colorD:{...an.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:qi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:qi.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:qi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:qi.fromHexAndA(0,1),contourColor:qi.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:{...an.fromHex(0),a:1},colorB:{...an.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}}}(n)}})(Hs||(Hs={})),(s=>{function n(a,o="layer1",l="layer2",u=an.fromHex(16777215)){let h=new ye;return h.push({fi:0,data:Hs.defaultData("light",a),id:o}),h.push({fi:1,data:Hs.defaultData("color"),id:l}),{layers:h}}s.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")},s.getHash=function(a){let o="";return a.layers.forEach(l=>{Object.entries(l.data).forEach(([u,h])=>{o+=`${u}${h}`,Array.isArray(h)?h.forEach(d=>o+=`${d}`):typeof h=="object"?Object.values(h).forEach(d=>{o+=typeof d=="number"?`${d.toFixed(4)}`:`${d}`}):o+=`${h}`})}),o},s.defaultEmptyData=function(){return{layers:new ye}},s.defaultData=function(a="layer1",o="layer2"){return n("physical",a,o)},s.withName=function(a,o){return{...a,name:o}},s.defaultTwoLayerData=n,s.defaultColorMaterial=function(a,o,l="layer1",u="layer2"){let h=new ye;return h.push({fi:0,data:Hs.defaultData("light",o),id:l}),h.push({fi:1,data:Hs.defaultColorLayer(a),id:u}),{layers:h}},s.defaultUIObjectMaterial=function(a){let o=Hs.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new ye;return l.push({fi:0,data:o,id:"layer1"}),l.push({fi:1,data:{...Hs.defaultData("transmission"),alpha:1},id:"layer2"}),l.push({fi:2,data:{...Hs.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:l}},s.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Hs.defaultData("texture");Object.assign(h.texture,{image:a});let d=new ye;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Hs.defaultData("light",o),id:u}),{layers:d}},s.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Hs.defaultData("video");Object.assign(h.texture,{video:a});let d=new ye;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Hs.defaultData("light",o),id:u}),{layers:d}}})(cs||(cs={}))}),HMt=j(()=>{M1="Roboto_regular",Bmt="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),$Mt=j(()=>{HMt()}),Gmt=j(()=>{Fi(),(RS||(RS={})).defaultData=function(){return{points:new ye,roundness:0,shapeHoles:[],isClosed:!1}}}),Wmt=j(()=>{Fi(),(p4||(p4={})).defaultData=function(){return{points:new ye,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},mg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(yU||(yU={})).merge=function(t,e){let i={...t};return m4.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},hG={shape:mg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},m4=["depth","offset","angle","twist","startScale","endScale"]}),dG=j(()=>{var t,e;Gmt(),Wmt(),(t=f4||(f4={})).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"},(vU||(vU={})).merge=function(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,yU.merge(s.extrusion,r.extrusion))),s},(e=hc||(hc={})).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:p4.defaultData(),extrusion:hG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:RS.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")},OP=["width","height","depth"]}),qmt=j(()=>{wl(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:an.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let r=e(i);return r==="height"?1:r==="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}})(ia||(ia={}))}),cG=j(()=>{(oO||(oO={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Yp||(Yp={})).defaultData={enabled:!1,mode:"hdri",hdri:oO.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function XMt(t){let e=typeof t=="string"?Number.parseInt(t,10):t;return typeof e=="number"&&Number.isFinite(e)?Math.min(5,Math.max(0,Math.round(e))):3}var g4,dv,lO,hO,uO,cv,dO,bU,_U,JX,z0,Hmt,nn,y4,tY,eY,iY,rY,Bu,W2,v4,b4,vc,Ug,sY,rm,_4,bc,cO,pO,wg,e0,Sg,q2,xU,nY,Na,mO,aY,oY,uc,Zl,pv,wU,$mt=j(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(g4||(g4={})).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}}})()}),pG=j(()=>{var t;qmt(),cG(),$mt(),wl(),(t=dv||(dv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(lO||(lO={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(hO||(hO={})).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}})(uO||(uO={})),(cv||(cv={})).defaultData={usePhysics:!1,gravity:-10},(dO||(dO={})).defaultData={playCamera:n0,gameControlObject:null},(bU||(bU={})).defaultData={backgroundColor:qi.fromHexAndA(Imt,1),postprocessing:g4.defaultData,fog:ia.defaultData,sky:Yp.defaultData,globalPhysics:cv.defaultData,ambient:lO.defaultData,ao:hO.defaultData,shadow:dv.defaultData,publish:dO.defaultData,grading:uO.defaultData}}),YMt=j(()=>{(_U||(_U={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),I5=j(()=>{var t,e,i;Fi(),Vmt(),zmt(),Lmt(),Fmt(),uG(),Umt(),wl(),KS(),dG(),kmt(),hn(),pG(),YMt(),(t=JX||(JX={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=z0||(z0={})).identity={...lU.identity,hiddenMatrix:hv.identity},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,hiddenMatrix:r.hiddenMatrix}},e.merge=function(r,s){return{position:s?.position||r.position,rotation:s?.rotation||r.rotation,pivot:s?.pivot||r.pivot,pivotRotation:s?.pivotRotation||r.pivotRotation,scale:s?.scale||r.scale,hiddenMatrix:s?.hiddenMatrix||r.hiddenMatrix}},e.diff=function(r,s){return pmt({position:dm.isEqual(r.position,s.position)?void 0:s.position,rotation:dm.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:dm.isEqual(r.scale,s.scale)?null:s.scale,hiddenMatrix:hv.isEqual(r.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})},Hmt=["slide","offset"],(nn||(nn={})).defaultData={states:new ye,events:new ye,visible:!0,raycastLock:!1,physics:uv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...z0.identity,cloner:null},(y4||(y4={})).defaultData={type:"Empty",...nn.defaultData},(tY||(tY={})).defaultData={type:"ParticleCollider",..._U.defaultData,...nn.defaultData},(eY||(eY={})).defaultData={type:"Component",...nn.defaultData},(iY||(iY={})).defaultData={type:"Particle",...nn.defaultData,...d4.defaultData},(rY||(rY={})).defaultData={type:"Hair",...nn.defaultData,...mU.defaultData},(Bu||(Bu={})).defaultData={type:"Mesh",...nn.defaultData,...fU.defaultData},(W2||(W2={})).defaultData={...nn.defaultData,...z0.identity,position:yc.DefaultPosition,rotation:yc.DefaultRotation,...yc.defaultData},(r=>{r.defaultData=function(s){return{...nn.defaultData,...pU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(v4||(v4={})),(r=>{function s(n,a,o=0){for(;o<a.length;){let l=n?n[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;n=l.descendants,o+=1}}r.resolveWithDes=s,r.resolve=function(n,a,o=0){let l=s(n,a,o);if(l){let u=Object.keys(l);if(u.length===1&&u[0]==="descendants")return}return l}})(b4||(b4={})),(r=>{function s(n,a){return{...nn.defaultData,...a,component:n,overrides:new As,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=s,r.fromComponentData=function(n){let a=z0.fromObject(n.data);return s(n.id,a)}})(vc||(vc={})),(r=>{r.defaultData={type:"Page",...nn.defaultData,physics:{...uv.defaultData,fusedBody:!1},...bU.defaultData,camera:W2.defaultData,timelines:new Be},r.isUIPage=function(s){return s.uiScene!==void 0}})(Ug||(Ug={})),(i=sY||(sY={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:hv.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:uv.defaultData,states:new ye,events:new ye,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...yc.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",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("RectangleGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("BooleanGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("ShapeBlendGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("TextGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("InputGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(s,n){let a={name:n};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new As}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new As})))):t0.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[c,p]of Object.entries(d.layers)){let{texture:m,...f}=p;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...h,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...h,"layers",c],props:f,type:0};o.push(g)}}}for(let[h,d]of Object.entries(n)){let c=d;if(h!=="name")if(h==="cloner")o.push(...uU.toOps(c,["cloner"]));else if(h==="pathSnapping")o.push({path:[h],props:{slide:c.slide,offset:c.offset},type:0});else if(h==="material")u(["material"],c);else if(h==="materials")for(let[p,m]of Object.entries(c))u(["materials",p],m);else if(l[h]===0){if(h==="geometry"&&c.extrusion!==void 0){let p={path:[h,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[h],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[h]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,z0.merge(a,n)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:n.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??a.pathSnapping?.offset??0})}),t0.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=n;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(s.type==="Mesh")"geometry"in n&&Object.assign(a,{geometry:vU.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let u={...o};return"material"in u&&"material"in l&&l.material&&(u.material=i4(u.material,h=>{if(typeof h!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=h.layers.data(d);p&&Hs.patch(p,c)}}).data),u.materials&&l.materials&&(u.materials=i4(u.materials,h=>{for(let d=0;d<u.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=h[d]?.layers?.data(p);f&&Hs.patch(f,m)}}}).data),u}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:im.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:im.merge(a.cloner,n.cloner)});else if(cU.is(s.type)){let o=n;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=an.clone(o.color))}return a}})(rm||(rm={}))}),mG=j(()=>{(_4||(_4={})).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}}),B5=j(()=>{mG(),wl(),(bc||(bc={})).defaultData={orbitControls:_4.defaultData,playPage:lv,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,r=0;return e<5?r=-30:e<10&&(r=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,r],"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}}),Xmt=j(()=>{var t;(cO||(cO={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(pO||(pO={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=wg||(wg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...cO.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:pO.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),fG=j(()=>{I5(),Fi(),B5(),wl(),hn(),Xmt(),(t=>{function e(i,r){let s=i.scene.objects.get(r);if(s&&s.data.type==="Component")return s;{let n=i.shared.lib.components[r];if(n)return{...n.asset,id:r}}}t.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,r){let s=i.find(n=>n.data.type==="Page"&&n.data.timelines?.[r]!==void 0);return s&&s.data.timelines?.[r]},t.getComponentData=e,t.traverseModuleInstances=function(i,r,s){i.scene.objects.traverseFrom(r,(n,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&s(n,a,o.events)}else s(n,a,a.events)})}})(e0||(e0={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new In;return a.push({fi:1,id:lv,data:{...Ug.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:$a(r,In.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:v4.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:bc.defaultData,styles:wg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new In,publish:bc.defaultData,styles:wg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:bc.defaultData,styles:wg.defaultData()}},t.emptyData=function(){return{objects:new In,publish:{...bc.defaultData},styles:wg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(Sg||(Sg={}))}),Ymt=j(()=>{(q2||(q2={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),gG=j(()=>{var t,e;Fi(),hn(),(t=xU||(xU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ye}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(nY||(nY={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ye,queries:new ye,autoStart:!0}),(i=>{function r(n){return n.textValue!==void 0}function s(n){return typeof n=="boolean"}i.isTextValue=r,i.isNumber=function(n){return typeof n=="number"},i.isBoolean=s,i.typeOfVariable=function(n){return r(n)?"string":s(n)?"boolean":"number"},i.getDisplayedValue=function(n){return i.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(a=>a.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():i.isBoolean(n)?n?"True":"False":i.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}})(Na||(Na={})),(mO||(mO={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(aY||(aY={})).all=[...mO.all,"components"],(oY||(oY={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(uc||(uc={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(e=Zl||(Zl={})).defaultColors=function(){return $a({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Be.prototype)},e.defaultImages=function(){return $a({},Be.prototype)},e.emptyData=function(){return{catelogs:new Be,materials:new Be,images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,variables:new ye,userAPIs:new Be,userWebhooks:new Be,lib:uc.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 r=[0,0,0];return{name:"Time",value:{textValue:r,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:r,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,r){if(r.format==="HH:mm:ss"){let s=Math.floor(i/3600),n=Math.floor((i-3600*s)/60);return{textValue:[s,n,Math.round(i-3600*s-60*n)]}}if(r.format==="mm:ss"){let s=Math.floor(i/60);return{textValue:[s,Math.round(i-60*s)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),KMt=j(()=>{}),Kmt=j(()=>{var t;Fi(),fG(),Ymt(),gG(),(t=pv||(pv={})).defaultData={schema:132,scene:Sg.defaultData,frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",q2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors()}},t.createDefaultData=function(){return ES.deserialize(ES.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:132,scene:Sg.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",q2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors(),images:Zl.defaultImages()}}},t.emptyData=function(){return{schema:132,scene:Sg.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",q2.defaultData),shared:Zl.emptyData()}},t.clipboard2dData=function(){return{schema:132,scene:Sg.emptyData(),frames:new Be,shared:Zl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:uc.defaultData()}}},t.getComponentData=function(e,i){return e0.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let r of i){let s=r.headers;for(let n of s)if(n.data.key.toLowerCase()==="authorization"&&n.data.value!=="")return!0}return!1}}),ZMt=j(()=>{(wU||(wU={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function jg(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function s_(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:r,control2:s}=e??{...Ov.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...em.defaultData},o=new Zmt(r,s,n,a),l=o.solve(1);return()=>u=>o.solve(u)/l}case 8:return()=>r=>Math.floor(r)}}var lY,hY,Gg,DS,Zmt,x4,w4,Qmt=j(()=>{Fi(),wl(),(lY||(lY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new Be}},(hY||(hY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(h,d){let c=[0,0],p=[1,1];if(h?.cubicControls)c=jg(h.cubicControls.control1,c);else switch(h?.type){case 2:case 4:c=[.42,0];break;case 3:case 0:c=[0,0];break;case 1:c=[.25,.1];break;case 7:c=[.25,1]}if(d?.cubicControls)p=jg(d.cubicControls.control2,p);else switch(d?.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:c,control2:p}}function i(h){if(!t.BEZIER_PRESETS.includes(h))return;let d={type:h};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(h,d){return Math.abs(h[0]-d[0])<.001&&Math.abs(h[1]-d[1])<.001}function s(h){let d=t.ROOT_PROPERTY_ORDER.indexOf(h[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(h){return h.layerId??h.path.join(".")}function a(h){let d=h[h.length-1];return DS.includes(d)?d: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 u(h,d,c){return{id:h,data:{id:h,time:c?.time??0,path:d,value:{},layerId:c?.layerId,index:c?.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(d=>{let c=i(d);return c!==void 0&&r(c.control1,h.control1)&&r(c.control2,h.control2)})},t.defaultData=function(h){return{id:h,keyframes:new ye}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=s,t.propertyKey=n,t.groupKeyframes=function(h,d){let c=new Map;for(let p of h){let m=p.data;if(d?.(m))continue;let f=n(m),g=c.get(f);g||(g={id:f,path:m.path,keyframes:[],layerId:m.layerId,index:m.index},c.set(f,g)),m.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,m)=>{let f=s(p.path)-s(m.path);return f!==0?f:(p.index??0)-(m.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(h){let d=new Map;for(let c of h){let p=a(c.path),m=p?c.path.slice(0,-1):c.path,f=o(c),g=d.get(f);g||(g={id:f,path:m,layerId:c.layerId,index:c.index,tracks:[]},d.set(f,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},t.sortedKeyframes=function(h){return[...h].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(h,d){return h.map(({data:c,id:p},m)=>u(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=u,t.createName=function(h){return Object.entries(h).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:s_(3),duration:1e3},opacity:{value:[0,1],easing:s_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:s_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:s_(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:s_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Gg||(Gg={})),DS=["x","y","z"],Zmt=class{constructor(t=1,e=100,i=10,r=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=r,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-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+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}}}),yG=j(()=>{var t;wl(),Fi(),(x4||(x4={})).list=["idle","move","jump","run"],(t=w4||(w4={})).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 ye,move:new ye,jump:new ye,run:new ye},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:qi.fromHexAndA(3728051,1)}}});function sg(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function uY(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,r=e.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...sg(qs(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:s,steps:n,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={...qs(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Zd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function Qd(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=cs.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==As.prototype&&e(s.material)})})}function dY(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("lambert"))}function fO(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 r=[...e.steps];r.push(e.steps[9]);let s={...qs(e),colors:i,steps:r};Object.assign(e,s)}})}function cY(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&fO(r)}):"material"in i&&typeof i.material!="string"&&fO(i.material)}),Object.values(t.shared.materials).forEach(e=>fO(e))}function pY(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 mY(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 fY(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Hs.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function gY(t){Zd(t,fY),Qd(t,fY)}function yY(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function vY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var QMt=j(()=>{KS(),wl(),mG(),I5(),Fi(),B5(),hn(),dt(),dG(),yG(),Xmt(),fG(),uG(),pG()}),Jmt={};function bY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function tft(t){let e=t.geometry;e!==void 0&&nft.has(e.type)&&e.extrusionVersion===void 0&&(e.extrusionVersion=1)}function _Y(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s),d=[o*u,n*h+a*u*l,a*h-n*u*l],c=Math.hypot(e[0],e[1],e[2])||1;return Math.abs((d[0]*e[0]+d[1]*e[1]+d[2]*e[2])/c)}function eft(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*Op)})(t),t.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(s,n){let a=Array.isArray(n)&&n.length>=3&&n.every(u=>typeof u=="number"&&Number.isFinite(u))?n:[0,1,0],o=_Y(s,a),l=_Y(s.map(u=>u*aft),a);return Math.abs(o-l)<1e-6?s.some(u=>Math.abs(u)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*Op)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Op))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*Op),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*Op),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=Op,e.extrusion.twist*=Op),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(qs(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 JMt(t){t.scene.objects.traverse((e,i)=>{})}function t3t(t){let e=t.schema??104;e!==132&&e<130&&(S4(t.asset),t.schema=130)}function fg(t,e){e(t.data);for(let i of t.children)fg(i,e)}function ift(t){let e=t.schema??104;e!==132&&(e<105&&(fg(t.asset,eft),t.schema=105),e<118&&(fg(t.asset,sft),t.schema=118),e<121&&(fg(t.asset,TU),t.schema=121),e<130&&(fg(t.asset,e3t),t.schema=130),e<132&&(fg(t.asset,tft),t.schema=132))}function rft(t,e){Qd(t,e),Zd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function S4(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("phong"))}function e3t(t){"materials"in t?t.materials.forEach(e=>{e!==void 0&&typeof e!="string"&&S4(e)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&S4(t.material)}function sft(t){t.timelineAnimations=$a({},Be.prototype)}function i3t(t){let e=[];return t?(t.forEach((i,r)=>{let{path:s,keyframes:n}=i.data,a=s[0]==="material"?i.id:void 0;n?.length?n.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:s,layerId:a,index:r}})}):e.push(Gg.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ye(...e.map((i,r)=>({...i,fi:r})))):new ye}function r3t(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!oft.includes(r))continue;let s=SU(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let u of l){let h=qt.generateUUID();t.insertBefore(null,[{id:h,data:{...i,id:h,path:[r,u],value:a[u],easing:s3t(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function SU(t){return t===null||typeof t!="object"?[]:DS.filter(e=>e in t)}function s3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function n3t(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function a3t(t){let e=function(n){let a=[];for(let o of Gg.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(h=>SU(h.data.value))),u=l.size?[...l].map(h=>o.keyframes.filter(d=>SU(d.data.value).includes(h))):[o.keyframes];for(let h of u){let d=[...h].sort((c,p)=>c.data.time-p.data.time);for(let c=0;c+1<d.length;c++)a.push({left:d[c],right:d[c+1]})}}return a}([...t.unproxy()]),i=new Map,r=new Set;for(let{left:n,right:a}of e){let o=n.data.easing?.type,l=(o===void 0?void 0:Gg.presetHandles(o))?.control2??(o===5?jg(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let u=i.get(a.id);u?n3t(u,l)||r.add(a.id):i.set(a.id,l)}let s=new Map;for(let{id:n,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Gg.presetHandles(o);l&&s.set(n,l.control1)}for(let{left:n,right:a}of e)r.has(a.id)&&s.delete(n.id);for(let[n,a]of s){let o=t.data(n);!o?.easing||(o.easing.cubicControls={control1:a,control2:jg(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:n,right:a}of e){if(!s.has(n.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:jg(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function xY(t,e){t.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="Page"&&s.timelines)for(let n of Object.values(s.timelines))for(let a of Object.values(n.objectTimelines??{}))e(a.keyframes)})}function TU(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function o3t(t){}function l3t(t){let e=t.schema??0;if(e!==132){if(e>132)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 132). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",132),function(i,r){if(r<1&&(Qd(i,uY),Zd(i,uY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{..._4.defaultData,...qs(s.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(s){function n(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,u]of Object.entries(o))if((O5.includes(l)||typeof u=="boolean")&&delete o[l],l==="texture")for(let[h,d]of Object.entries(u))(lG.includes(h)||typeof d=="boolean")&&delete u[h]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let u=l;u.material?n(u.material):u.materials&&u.materials.forEach(h=>{n(h)})})})}(i),i.schema=3),r<4&&(function(s){s.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(s){s.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(s){s.scene.objects.traverse((n,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),r<7&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&(cY(i),i.schema=9),r<10&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(s){s.scene.environment.ambientLight.softShadows=!1,s.scene.environment.ambientLight.softShadowQuality="low",s.scene.objects.traverse((n,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),s.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(cY(i),i.schema=12),r<13&&(function(s){s.shared.audios=$a({},Be.prototype)}(i),i.schema=13),r<14&&(function(s){let n=s.shared.materials;Object.entries(n).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(n,{[a]:l})}})}(i),i.schema=14),r<15&&(function(s){Object.entries(qs(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(qs(s.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.audios[n]})}(i),i.schema=15),r<16&&(function(s){s.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Qd(i,pY),Zd(i,pY),i.schema=17),r<18&&(Qd(i,dY),Zd(i,dY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...bc.defaultData.settings.video,...qs(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=$a({},Be.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let u=cs.defaultTwoLayerData("phong"),h=typeof l.color=="string"?s.shared.colors[l.color]:l.color;u.layers[1].data.color={r:h.r,g:h.g,b:h.b},u.layers[1].data.alpha=l.alpha;let d=function(m){return m.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(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}(l.font);s.shared.fonts[d]===void 0&&(s.shared.fonts[d]={name:d});let c={name:l.name,...nn.defaultData,...Bu.defaultData,flatShading:!1,wireframe:!1,geometry:{...hc.defaultData("TextGeometry"),width:l.width,height:l.height,font:d,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:u,states:qs(l.states),events:qs(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=qs(s.scene.objects).parent(a);s.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),n.push(a)}}),n.forEach(a=>{s.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(s){let n={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};s.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(n[Number(l.type)])if(Object.assign(l,{type:n[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 ye,move:new ye,jump:new ye}});else{let u=new ye;Object.assign(l,{actions:u}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&u.push({fi:0,id:qt.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((h,d,c)=>{let p={easing:h.easing,duration:h.duration};h.easing===6?Object.assign(p,sg(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let m={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},f={state:h.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ye({fi:0,id:qt.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:qt.generateUUID(),data:f})};u.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,u){let h=new ye,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===u){let f;d.push(p),c.interaction==="play"?f={...sg(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(f={...sg(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&h.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),h.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,h):a.events.insertBefore(null,[{id:qt.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),r<22&&(gY(i),i.schema=22),r<23&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(s){s.scene.objects.traverse((n,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),(r<25||i.shared.videos===void 0)&&(function(s){s.shared.videos=$a({},Be.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(s){s.scene.objects.traverse((n,a)=>{let o=s.scene.objects.unproxy().parent(n);if(o){let l=qs(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=qs(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(s){s.scene.objects.traverse((n,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),r<28&&(gY(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,As.prototype),o.texture&&Object.setPrototypeOf(o.texture,As.prototype)}function a(o){Object.setPrototypeOf(o,As.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(u=>{let h=u;if(h.material){let d=qs(h.material).layers;a(d),h.material.layers=d}if(h.materials)for(let d=0;d<h.materials.length;d++){let c=h.materials[d],p=qs(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=cs.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(s){s.scene.publish.orbitControls.autoZoom===void 0&&(s.scene.publish.orbitControls.autoZoom=!1),s.scene.objects.traverse((n,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),r<33&&(function(s){s.scene.objects.traverse((n,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),r<34&&(function(s){s.scene.publish.mouseEventTarget===void 0&&(s.scene.publish.mouseEventTarget="canvas"),s.scene.publish.settings.web.hint===void 0&&(s.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(s){let{video:n}=s.scene.publish.settings;n.format==="gif"&&n.fps>48&&(n.fps=15)}(i),i.schema=35),r<36&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(s){let n=s.scene.environment.usePhysics;s.scene.objects.traverse((a,o)=>{n&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Qd(i,mY),Zd(i,mY),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=w4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=wg.defaultData())}(i),i.schema=40),r<41&&(function(s){s.scene.environment.ambientLight.occlusion===void 0&&(s.scene.environment.ambientLight.occlusion=!1),s.scene.environment.ambientLight.aoFullRes===void 0&&(s.scene.environment.ambientLight.aoFullRes=!1),s.scene.environment.ambientLight.radius===void 0&&(s.scene.environment.ambientLight.radius=256),s.scene.environment.ambientLight.bias===void 0&&(s.scene.environment.ambientLight.bias=.5),s.scene.environment.ambientLight.aoColor===void 0&&(s.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Qd(s,yY),Zd(s,yY)}(i),i.schema=41),r<42&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new ye})})})}(i),i.schema=42),r<43&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Qd(i,vY),Zd(i,vY),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=n0);let s=qs(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=lv,n.insertBefore(null,null,[{id:lv,data:{...Ug.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:sg(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:sg(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...cv.defaultData,...sg(i.scene.environment,"usePhysics","gravity")},camera:qs(i.scene.ownerCamera)??Ug.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==Sg.TRASH_CAN_ID&&n.move(lv,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,u)=>{u.type==="DirectionalLight"?(u.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):u.type==="SpotLight"&&(u.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(u.physics===void 0||u.physics===null)&&u.type!=="Instance"&&(u.physics={},Object.assign(u.physics,uv.defaultData)),u.physics!==void 0&&u.physics!==null&&(u.physics.enabled=u.collision??"visibility",delete u.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=bc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(Qd(t,bY),Zd(t,bY),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new Be,t.shared.lib=uc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=$a({},Be.prototype)}(t),t.scene.objects.traverse((i,r)=>{eft(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))ift(i);e<106&&(function(i){let r=qs(i.shared.variables);i.shared.variables=$a(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ye.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=uc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.particles=uc.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Particle"&&typeof s.renderMaterial.size=="number"&&Object.assign(s.renderMaterial,{size:[s.renderMaterial.size,s.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,r)=>{(function(s){Array.isArray(qs(s.events))&&s.events?.forEach(n=>{"disabled"in n||(n.disabled=!1),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress")&&(n.mode=n.mode||"Object")})})(r)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Page"&&(s.postprocessing.depthOfField.focusDistance=100,s.postprocessing.depthOfField.focalLength=20,s.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((r,s)=>{Array.isArray(qs(s.events))!==!1&&s.events?.forEach(n=>{let a=n.runMode;n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="Collision"||n.type==="Trigger"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):n.type==="MouseHover"||n.type==="MousePress"||n.type==="KeyPress"?n.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):n.type==="GameControl"?(delete n.actions,Object.keys(n.gameActions).forEach(o=>{n.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):n.type==="DragDrop"?(delete n.actions,n.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),n.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):n.type==="Resize"?(delete n.actions,n.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):n.type==="Start"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="VariableChange"||n.type==="Scroll"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="Conditional"&&(delete n.actions,n.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),n.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||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=$a({},Be.prototype),i.shared.userWebhooks=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.userAPIs=uc.defaultData().userAPIs,i.shared.lib.userWebhooks=uc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=bc.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=$a({},Be.prototype),t.scene.objects.traverse((i,r)=>{sft(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=pv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=pv.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,r)=>{TU(r),r.type==="Page"&&r.camera!==void 0&&TU(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=pv.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=Yp.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(typeof s.exposure=="number"&&(s.exposure=Math.round(s.exposure/5e-4*1e4)/1e4),s.lighting===void 0&&(s.lighting=Yp.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingIntensity===void 0&&(s.lightingIntensity=Yp.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(s.mode===void 0&&(s.mode="physical"),s.hdri===void 0?s.hdri={...Yp.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=Yp.defaultData.hdri.blur),Array.isArray(s.hdri.rotation)&&(s.hdri.rotation=s.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s?.hdri!==void 0&&s.hdri.showBackground===void 0&&(s.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingQuality===void 0&&(s.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=Ug.defaultData.camera);let s=r.camera;s.far=1e5,s.perspective?s.perspective.near=70:s.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(rft(t,S4),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.states;if(!n)return;let a=s.timelineAnimations,o=[];n.forEach((l,u)=>{(l.isAnimation||a?.[u])&&o.push(u)}),o.forEach(l=>n.delete(l))})}(t),function(i){let r=i.shared,s=r.timelineAnimations;if(!s)return;let n=i.scene.objects,a=n.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(s)){let u=$a({},Be.prototype),h=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(h=Math.max(h,g.to??0),d=d||Boolean(g.loop),u[m]={id:m,keyframes:i3t(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=$a({},Be.prototype)))[o]={id:o,name:l.name,duration:h||5,...d?{loop:d}:{},objectTimelines:u})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),xY(t,r3t),xY(t,a3t),t.schema=131),e<132&&(t.scene.objects.traverse((i,r)=>tft(r)),t.schema=132)}}XS(Jmt,{updateAllMaterials:()=>rft,updateDocumentSchema:()=>l3t,updateLibSchema:()=>o3t,updateMaterialSchema:()=>t3t,updateObjectStateRec:()=>fg,updateObjectsSchema:()=>ift,updateTextValues:()=>JMt});var nft,Op,aft,oft,wY,_M,gO,SY,xM,Tg,n_,L0,wM,yO,IP,vO,bO,TY,BP,_O,Wg,MU,V5=j(()=>{dt(),Kmt(),Fi(),Qmt(),QMt(),B5(),KS(),hn(),gG(),I5(),cG(),nft=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),Op=180/Math.PI,aft=Math.PI/180,oft=["position","rotation","scale","shape size"]}),h3t=j(()=>{var t,e,i;wl(),Fi(),hn(),(wY||(wY={})).is=function(r){return!0},(t=_M||(_M={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}},t.diff=function(r,s){return pmt({position:qu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:qu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&qu.isEqual(r.shear,s.shear)?void 0:s.shear})},(gO||(gO={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(SY||(SY={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(xM||(xM={})).defaultData={opacity:1,fill:{color:qi.fromHexAndA(Jg,1),enabled:!0},stroke:{color:qi.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:qi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:qi.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=Tg||(Tg={})).newEmpty=function(r,s){return{name:s}},e.patch=function(r,s){if(s===void 0)return r;let n={...r};return Object.assign(n,_M.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let h of u)h in l&&h in o&&o[h]!==void 0&&Object.assign(l,{[h]:o[h]});return l}(n,s),n=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}(n,s),n},e.toOps=function(r,s){let n,a=[];for(let[o,l]of Object.entries(s))o!=="name"&&(n===void 0&&(n={path:[],props:{},type:0},a.push(n)),n.props[o]=l);return a},(n_||(n_={})).defaultData={..._M.defaultData,...gO.defaultData,states:new ye,events:new ye,visible:!0,raycastLock:!1},(L0||(L0={})).defaultData={...n_.defaultData,...xM.defaultData},(wM||(wM={})).defaultData={cornerRadius:[0,0,0,0]},(yO||(yO={})).defaultData={...L0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(IP||(IP={})).defaultData={...L0.defaultData,...wM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(vO||(vO={})).defaultData={...L0.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"},(bO||(bO={})).defaultData={...L0.defaultData,type:"path2d",path:"",name:"Path"},(TY||(TY={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(BP||(BP={})).defaultData={...n_.defaultData,name:"Group",type:"group2d"},(_O||(_O={})).defaultData=()=>({...n_.defaultData,...wM.defaultData,...xM.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:qi.fromHexAndA(4737101,1),enabled:!0},stroke:{color:qi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(s){switch(s){case"rectangle2d":case"vector2d":return{...IP.defaultData};case"ellipse2d":return{...yO.defaultData};case"text2d":return{...vO.defaultData};case"path2d":return{...bO.defaultData};case"frame2d":return{..._O.defaultData()};case"group2d":return{...BP.defaultData}}},r.getPivot=function(s){return"width"in s&&"height"in s?[typeof s.width=="number"?.5*s.width:0,typeof s.height=="number"?.5*s.height:0]:[0,0]},r.isResizeable=function(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"},r.isAutoLayoutable=function(s){return s.type==="frame2d"&&s.autoLayout!==void 0},r.hasCorners=function(s){return s.type==="rectangle2d"||s.type==="frame2d"}})(Wg||(Wg={})),(i=MU||(MU={})).defaultData={name:"UI",type:"scene2d",objects:new In},i.emptyData=function(){return{type:"scene2d",objects:new In}}}),u3t=j(()=>{WMt(),qMt(),Vmt(),kmt(),Kmt(),Omt(),ZMt(),jmt(),qmt(),cG(),V5(),Ymt(),dG(),uG(),zmt(),KS(),Umt(),$mt(),wl(),B5(),I5(),mG(),Wmt(),gG(),fG(),$Mt(),Gmt(),yG(),pG(),Lmt(),Fmt(),h3t()});function Mg(t,e=!1){let i=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),n={},a={},o=t[0].morphTargetsRelative,l=new ge,u=0;for(let h=0;h<t.length;++h){let d=t[h],c=0;if(i!==(d.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 d.attributes){if(!r.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;n[p]===void 0&&(n[p]=[]),n[p].push(d.attributes[p]),c++}if(c!==r.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!==d.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 d.morphAttributes){if(!s.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(d.morphAttributes[p])}if(e){let p;if(i)p=d.index.count;else{if(d.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=d.attributes.position.count}l.addGroup(u,p,h),u+=p}}if(i){let h=0,d=[];for(let c=0;c<t.length;++c){let p=t[c].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+h);h+=t[c].attributes.position.count}l.setIndex(d)}for(let h in n){let d=MY(n[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(let h in a){let d=a[h][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[h].length;++f)p.push(a[h][f][c]);let m=MY(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}}return l}function MY(t){let e,i,r,s=-1,n=0;for(let u=0;u<t.length;++u){let h=t[u];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(r===void 0&&(r=h.normalized),r!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=h.gpuType),s!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=h.count*i}let a=new e(n),o=new _e(a,i,r),l=0;for(let u=0;u<t.length;++u){let h=t[u];if(h.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=h.count;c<p;c++)for(let m=0;m<i;m++){let f=h.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(h.array,l);l+=h.count*i}return s!==void 0&&(o.gpuType=s),o}var ZS=j(()=>{dt()});function lft(t){let e=t.points.length/7,i=new ye;for(let r=0;r<e;r++){let s=7*r,n=t.points[s+0],a=t.points[s+1],o=t.points[s+2],l=t.points[s+3],u=t.points[s+4],h=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:qt.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[u,h]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>lft(r))??[]}}function hft(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:u}=a,h=u?.groups,d=u?.attributes??{},c=u?.morphAttributes??{},p=u?.interleavedBuffers,m=u?.arrayBuffers,f=u?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(y){let v=1/0,b=1/0,_=1/0,x=-1/0,S=-1/0,w=-1/0;for(let T=0;T<y.length;T+=3){let C=y[T],M=y[T+1],A=y[T+2];v=Math.min(v,C),b=Math.min(b,M),_=Math.min(_,A),x=Math.max(x,C),S=Math.max(S,M),w=Math.max(w,A)}return{width:x-v,height:S-b,depth:w-_}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:m},...o===void 0?{}:o,type:"NonParametricGeometry"};return f!==void 0&&Object.assign(g.data,{index:f}),h!==void 0&&Object.assign(g.data,{groups:h.map(y=>({...y,materialIndex:y.materialIndex??0}))}),g}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let u=new ge;if(o?.position===void 0||o?.faceMap===void 0)return null;let h=o.position.array,d=o.faceMap.array,c=r.data.index.array;u.setAttribute("position",new fe(h,3)),u.setIndex(new hm(c,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let b={},_=y.getIndex(),x=y.getAttribute("position"),S=_?_.count:x.count,w=0,T=Object.keys(y.attributes),C={},M={},A=[],R=["getX","getY","getZ","getW"],O=["setX","setY","setZ","setW"];for(let V=0,H=T.length;V<H;V++){let W=T[V],X=y.attributes[W];C[W]=new X.constructor(new X.array.constructor(X.count*X.itemSize),X.itemSize,X.normalized);let st=y.morphAttributes[W];st&&(M[W]||(M[W]=[]),st.forEach((nt,xt)=>{let pt=new nt.array.constructor(nt.count*nt.itemSize);M[W][xt]=new nt.constructor(pt,nt.itemSize,nt.normalized)}))}let N=.5*v,B=Math.log10(1/v),L=Math.pow(10,B),z=N*L;for(let V=0;V<S;V++){let H=_?_.getX(V):V,W="";for(let X=0,st=T.length;X<st;X++){let nt=T[X],xt=y.getAttribute(nt),pt=xt.itemSize;for(let K=0;K<pt;K++)W+=~~(xt[R[K]](H)*L+z)+","}if(W in b)A.push(b[W]);else{for(let X=0,st=T.length;X<st;X++){let nt=T[X],xt=y.getAttribute(nt),pt=y.morphAttributes[nt],K=xt.itemSize,ct=C[nt],St=M[nt];for(let wt=0;wt<K;wt++){let Tt=R[wt],yt=O[wt];if(ct[yt](w,xt[Tt](H)),pt)for(let Ot=0,Ft=pt.length;Ot<Ft;Ot++)St[Ot][yt](w,pt[Ot][Tt](H))}}b[W]=w,A.push(w),w++}}let k=y.clone();for(let V in y.attributes){let H=C[V];if(k.setAttribute(V,new H.constructor(H.array.slice(0,w*H.itemSize),H.itemSize,H.normalized)),V in M)for(let W=0;W<M[V].length;W++){let X=M[V][W];k.morphAttributes[V][W]=new X.constructor(X.array.slice(0,w*X.itemSize),X.itemSize,X.normalized)}}return k.setIndex(A),k}(u),m=[],f=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let y=0,v=d.length;y<v;)d[y]===d[y+1]?(f[d[y]]++,m.push(...new Set(g.slice(3*y,3*y+6))),y+=2):(m.push(...g.slice(3*y,3*y+3)),y++);o.indexWASM={array:m},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:f}}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,...d3t(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let u in o)u==="positionWASM"?l[u]=new Float32Array(o[u].array):u==="indexWASM"?l[u]=new Int32Array(o[u].array):u==="verticesPerFaceWASM"&&(l[u]=new Int8Array(o[u].array));return l.scaleBaked=[1,1,1],l}let s=e.type,n=e.parameters;return s==="VectorGeometry"?(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,width:100,height:100,shape:lft(e.shape),type:s}):s==="LatheGeometry"?{...e.parameters,type:s,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,type:s})}function d3t(t){return AU.setFromArray(t),AU.getSize($w),{width:$w.x,height:$w.y,depth:$w.z}}var AU,$w,xO,c3t=j(()=>{Fi(),dt(),ZS(),new _t,new Se,new Qi,new P,new P,AU=new pr,$w=new P}),p3t=j(()=>{var t;(t=xO||{}).view="view",t.edit="edit",((xO=t)||(xO={})).canWrite=function(e){return e!=="view"},class extends Error{constructor(e,i){super(`This is a ${e.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=e,this.expected=i,this.name="DocumentKindMismatchError"}}}),uft,CU,VP,dft,cft,Xv,a_,SM,wO,Yv,AY,SO,CY,TO,Iv,Hc,$c,dd,MO,EY,PY,AO,EU,_c,pft=j(()=>{p3t()}),m3t=j(()=>{}),f3t=j(()=>{Fi(),V5(),pft()}),g3t=j(()=>{KS(),[...O5],new Set(lG)}),ke=j(()=>{u3t(),m3t(),KMt(),V5(),f3t(),pft(),Qmt(),g3t(),yG(),Fi()}),k5=j(()=>{uft=[3,4,8,9],CU=5,VP=3,dft=32,cft=.98}),QS=j(()=>{dt(),Xv=t=>{var e;return(e=class extends t{}).geometryHelper=new Zh(30,30,30),e}}),JS=j(()=>{dt(),a_=new mc,SM=new ta,wO=new _t,Yv=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),SM.copy(a.boundingSphere),SM.applyMatrix4(o),i.ray.intersectsSphere(SM)===!1||(wO.copy(o).invert(),a_.copy(i.ray).applyMatrix4(wO),a.boundingBox!==null&&a_.intersectsBox(a.boundingBox)===!1))return;let l,u,h,d,c,p,m=a.index,f=a.attributes.position,g=a.drawRange;if(s===!1){for(c=Math.max(0,g.start),p=Math.min(m.count,g.start+g.count);c<p;c+=3)if(u=m.getX(c),h=m.getX(c+1),d=m.getX(c+2),l=y(t,i,a_,f,u,h,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new P,_=new P,x=new P,S=new P,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T;for(let M=Math.max(0,g.start),A=Math.min(v.count,g.start+g.count)-1;M<A;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),a_.distanceSqToSegment(b,_,S,x)>C)continue;S.applyMatrix4(n.matrixWorld);let R=i.ray.origin.distanceTo(S);R<i.near||R>i.far||r.push({distance:R,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let C=new P,M=new P,A=new P,R=new P,O=new P;if(C.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),A.fromBufferAttribute(x,T),_.intersectTriangle(C,M,A,!1,R)===null)return null;O.copy(R),O.applyMatrix4(v.matrixWorld);let N=b.ray.origin.distanceTo(O);return N<b.near||N>b.far?null:{faceIndex:1,distance:N,point:O.clone(),object:v}}}}),z5=j(()=>{dt(),QS(),JS(),AY=new P(1,1,1),SO=new P,CY=new P,TO=new Se,Iv=class extends Xv(nmt){constructor(t,e=15){super(e),this.object=t,this.dummy=new $v,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){Yv(this.object,Iv.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(SO,TO,CY),this.matrix.compose(SO,TO,AY),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),y3t=j(()=>{dt(),Hc=new P,$c=new P,dd=new _t,MO=[new P(-1,1,1),new P(-1,-1,1),new P(1,-1,1),new P(1,1,1),new P(-1,1,-1),new P(-1,-1,-1),new P(1,-1,-1),new P(1,1,-1)],EY=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],PY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],AO=(t,e,i)=>{t.updateEntityBoxSize(Hc,$c),dd.copy(e).multiply(t.matrixWorld),$c.x===0&&$c.y===0&&$c.z===0?i.push(new P(Hc.x,Hc.y,Hc.z).applyMatrix4(dd)):MO.forEach(r=>{i.push(r.clone().multiply($c).add(Hc).applyMatrix4(dd))})},EU=class extends pr{constructor(){super(...arguments),this.matrix=new _t,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 _t().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let r=[];if(i===!0){let s=[];t.traverseEntity(n=>{if(n.visible||n.cloner&&n.data.visible){if(!("geometry"in n))return dd.copy(e).multiply(n.matrixWorld),void s.push(new P().applyMatrix4(dd));AO(n,e,r)}}),r.length===0&&r.push(...s)}else AO(t,e,r);return this.setFromPoints(r)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(dd.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize($c).multiplyScalar(.5),this.getCenter(Hc),dd.copy(this.matrix).setPosition(Hc),this.vertices=MO.map(t=>t.clone().multiply($c).applyMatrix4(dd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=EY.map(([t,e])=>new yl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=PY.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),T4=j(()=>{_c={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function H2(t){return t?.isParticleSystem===!0}function i0(t){return t?.isHairSystem===!0}function Ec(t){return t?.isShapeBlendEntity===!0}function L5(t){return t?.isPathObject===!0}function jo(t){return t?.isObject2D===!0}function Ya(t){return t?.isUIObject===!0}function $1(t){return t?.isCloner===!0}function Ag(t){return t?.isClone===!0}function kP(t){return t?.isComponentObject===!0}var ns=j(()=>{});function Or(t){vG.add(t)}function Nn(t,e){let i=`${t}:${e}`;DU.has(i)||DU.add(i)}function M4(t,e){bG.set(t,e)}function CO(t){return bG.get(t)}function Kv(t,e){_G.set(t,e)}function EO(t){return _G.get(t)}function PU(t,e){xG.set(t,e)}function mft(t){return xG.get(t)}function RU(){return F5}var vG,DU,bG,_G,xG,F5,A4,Ii=j(()=>{vG=new Set,DU=new Set,bG=new Map,_G=new Map,xG=new Map,F5=null,A4=null});function fft(t){let e=t.elements;Uh.set(e[0],e[1],e[2]),jh.set(e[4],e[5],e[6]),ku.set(e[8],e[9],e[10])}function gft(){let t=Math.max(Uh.lengthSq(),jh.lengthSq(),ku.lengthSq());Uh.lengthSq()>Xw*t?ml.copy(Uh).normalize():ml.set(1,0,0),fl.crossVectors(ku,ml),fl.lengthSq()<=Xw*t&&(fl.copy(jh).addScaledVector(ml,-jh.dot(ml)),fl.lengthSq()<=Xw*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=Xw&&e.set(0,1,0).cross(i),e.normalize()}(fl,ml)),fl.normalize(),Cg.crossVectors(ml,fl)}var Uh,jh,ku,ml,fl,Cg,yft,Xw,Yw,TM,Eg,U5,vft=j(()=>{dt(),Uh=new P,jh=new P,ku=new P,ml=new P,fl=new P,Cg=new P,yft=new _t,Xw=1e-12,Yw=.01}),tT=j(()=>{dt(),vft(),TM=new _t,(Eg||(Eg={})).is=function(t){return t&&t.__isSPEObject},U5=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new _t,this.copyPreviousMatrix=!0,this.hiddenMatrix=new _t,this.pivotMatrix=new _t,this.matrixWorldRigid=new _t,this.shearScale=new _t,this.shearScaleInv=new _t}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(TM.copy(this.parent.matrixWorld).invert()),e.premultiply(TM.copy(this.hiddenMatrix).invert()),e.multiply(TM.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof dr&&(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 r=this.parent;if(e&&r!==null&&r.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 s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let r of this.children)Eg.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Eg.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(e,i,r){return fft(e),gft(),i.makeBasis(ml,fl,Cg),r.set(ml.dot(Uh),ml.dot(jh),ml.dot(ku),0,fl.dot(Uh),fl.dot(jh),fl.dot(ku),0,Cg.dot(Uh),Cg.dot(jh),Cg.dot(ku),0,0,0,0,1),function(){let s=Uh.length(),n=jh.length(),a=ku.length(),o=Math.max(s,n,a);if(o-s>Yw||o-n>Yw||o-a>Yw)return!0;let l=Yw*o*o;return Math.abs(Uh.dot(jh))>l||Math.abs(Uh.dot(ku))>l||Math.abs(jh.dot(ku))>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 r=new _t().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),r.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof _t?e.hiddenMatrix.premultiply(r):e.applyMatrix4(r),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,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function RY(t,e,i){return Kp.subVectors(e,t),NS.subVectors(e,i),Kp.cross(NS).length()<=$2}function bft(t){let e=IU.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(r){let s=r.points,n=[s[0]],a=[new P(...s[0].data.position)];ng.copy(a[0]);for(let y=0;y<s.length-1;y++)Kp.fromArray(s[y].data.position),NS.fromArray(s[y+1].data.position),A1.subVectors(Kp,ng),C1.subVectors(Kp,NS),A1.cross(C1).length()>$2&&(n.push(s[y]),a.push(new P().copy(Kp)),ng.copy(Kp));let o=s[s.length-1];n.push(o),a.push(new P(...o.data.position));let l=r.isClosed,u=n.length-(l?0:1),h=n.length,d=[],c=[];for(let y=0;y<h;y++){let v=n[y].data;d.push(new P(...v.controlPrevious.position)),c.push(new P(...v.controlNext.position))}let p=[];for(let y=0;y<u;y++){let v=y===h-1?0:y+1;p.push(RY(a[y],c[y],a[v])&&RY(a[y],d[v],a[v]))}let m=[];for(let y=0;y<h;y++){let v=n[y].data,b=a[y],_={position:b,prevDir:void 0,nextDir:void 0,controlPrevious:d[y],controlNext:c[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(m.push(_),v.roundness===0||!l&&(y===0||y===h-1))continue;let x=l&&y==0?h-1:y-1,S=l&&y==h-1?0:y+1,w=new P().subVectors(a[x],b).normalize(),T=new P().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let C=p[l&&y===0?h-1:y-1],M=p[y];if(C&&M){ag.addVectors(w,T).normalize();let A=ng.crossVectors(ag,w).length()/w.dot(ag);_.tan=A,_.removedLength=v.roundness/A}}for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v];if(b.removedLength!==0||_.removedLength!==0){let x=b.position.distanceTo(_.position);b.removedLength=Math.min(b.removedLength,x/2),_.removedLength=Math.min(_.removedLength,x/2)}}let f=new Array(2*h).fill(null);for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v],x=null;if(p[y]){let S=b.position.clone(),w=_.position.clone();(b.removedLength!==0||_.removedLength!==0)&&(b.nextDir&&S.add(ng.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(ng.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>$2&&(x=new z2(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>$2&&(x=new z2(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<h;y++){let v=m[y];if(v.removedLength===0)continue;let b=v.position,_=v.prevDir.clone().multiplyScalar(v.removedLength).add(b),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(b),S=v.tan*v.removedLength;ag.addVectors(v.prevDir,v.nextDir).normalize(),A1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;OU.copy(ag).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(A1),zP.copy(ag).multiplyScalar(-S).add(OU);let T=b.distanceTo(zP)/b.distanceTo(A1);C1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),NU.copy(C1).lerp(zP,2);let C=_.clone().lerp(C1,4/3),M=x.clone().lerp(NU,4/3);f[2*y]=new z2(_,C,M,x)}let g=new _ft;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return IU.set(t.points,{isClosed:t.isClosed,curve:i}),i}var _ft,$2,Kp,NS,ng,ag,A1,zP,C1,NU,OU,IU,E1,BU,LP,xft,wft,Sft,Mi,Vu,DY,NY,o_,PO,MM,RO,DO,j5,VU,a0,zu,Tft=j(()=>{dt(),_ft=class extends E8{constructor(){super()}getPoints(t=12){let e,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],u=Math.ceil(t*l/s),h=o.getPoints(u);for(let d=0;d<h.length;d++){let c=h[d];e&&e.equals(c)||(i.push(c),e=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},$2=.001,Kp=new P,NS=new P,ng=new P,ag=new P,A1=new P,zP=new P,C1=new P,NU=new P,OU=new P,IU=new WeakMap}),v3t=j(()=>{dt(),E1=new _t,BU=new Se,LP=new Se,xft=new Qi,wft=new P,Sft=new P(0,1,0)}),vo=j(()=>{dt(),ke(),y3t(),Fi(),T4(),ns(),Ii(),tT(),Tft(),v3t(),ir(),(Mi||(Mi={})).is=function(t){return t&&t.__isEntity},Vu=t=>Mi.is(t),DY={type:"completeState",isfromEntity:!0},NY=["x","y","z"],o_=new P,PO=new P(1,1,1),MM=new Se,RO=new Qi,DO=new _t,j5=t=>class extends U5(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 EU,this._recursiveBBox=new EU,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(Mi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Mi.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(!Mi.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,r=!1){if(this.data.states.length!==0||r){for(let s of this.data.states)rm.toOps(this.data,s.data).forEach(n=>{let a=e4.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let s=this.data.states.data(e);s&&(this.dataPatched=rm.patch(this.data,s),rm.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&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=>{Vu(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(r=>{r.uuid===e&&(i=r)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,r=i.indexOf(this)+1;if(Mi.is(i[r]))return i[r];if(Mi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Mi.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,r=this;for(;r!==e;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Vu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{Mi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Vu(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=>Vu(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),G8({position:this.position.toArray(),rotation:[this.rotation.x*qt.RAD2DEG,this.rotation.y*qt.RAD2DEG,this.rotation.z*qt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,r){return i[e].map((s,n)=>r?.shared.getVariable(s,[this.uuid,e,NY[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(o_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(qt.DEG2RAD),this.rotation.setFromVector3(o_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??hv.identity)),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(o_.fromArray(e.pivot).negate(),MM.setFromEuler(RO.fromArray(e.pivotRotation.map(s=>s*qt.DEG2RAD))).invert(),PO);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 s=o_.setFromMatrixPosition(this.pivotMatrix);MM.setFromEuler(RO.fromArray(e.pivotRotation.map(n=>n*qt.DEG2RAD))).invert(),this.pivotMatrix.compose(s,MM,PO)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}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)Mi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Mi.is(e)&&e.disposeRecursively()})}toState(e=[]){return G8({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,r,s){let n=this.data;this.data=i;let a=e,o=er(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let u={...e.props};if(delete u.name,Object.values(e.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let d=Dn.zoom(h,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(u[c]=d[c])}}a={...e,props:u,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,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:h,...d}=l;l=d}let u=Dn.removeOverridden(e.path,e.props,l);a={...e,props:u}}}if(this.updateByPatchedOpBase(a,rm.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),er(e.path,["overrides"])){let l=[],u=[...e.path];for(l.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)l.push(u[1]),u.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 d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[h],d.updateState(um.apply(d.component.data,d.overrideData),r))}}else{let h=r.scene.findInstance([this.uuid,...l]);if(h){let d=Dn.zoom(h.component.data,u);if((e={...e,path:u}).type===0){let c=e.props;if(d)for(let[p,m]of Object.entries(e.props))m===void 0&&(c===e.props&&(c={...e.props}),c[p]=d[p]);e={...e,props:c}}h.overrideData=b4.resolve(i.overrides,l),h.updateByOp(e,ea.applySimple(h.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let u;for(let h of vc.rootOverrideProps)h in e.props&&(u===void 0&&(u={}),u[h]=e.props[h]);u&&(l={...e,props:u})}else for(let u of vc.rootOverrideProps)if(er(e.path,[u])){l=e;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let h=um.filterOp(u.overrideData,l);h&&u.updateByOp(h,ea.applySimple(u.data,h),r,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let h=um.filterOp(u.overrideData,e);if(h){let d;d=n===u.data&&e===h?i:ea.applySimple(u.data,h),u.updateByOp(h,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!t0.is(e.props.type)&&_c.changeEntityProptotype(this,i,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){_c.changeEntityProptotype(this,i,r);for(let s of this.children)Mi.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(e,i,r)}updateByPatchedOp(e,i,r){if(e.path.length===0&&e.type===0?this.updateState(e.props,r):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,r),e.path[0]==="morphTargetInfluences"&&e.type===0){let s=i.morphTargetInfluences.get(e.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",s]))}if(er(e.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),er(e.path,["cloner"])!==null){let s=ea.drop(e,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.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,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,n=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=bft(o.geometry.path),u=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),h=null;try{h=l.curves.length?l.getPointAt(u):null}catch{}if(h===null)return;a.updateMatrixWorld();let d=this.parent?DO.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):DO.copy(this.hiddenMatrix),c=function(p,m,f,g){BU.setFromRotationMatrix(E1.extractRotation(g));let y=p.clone().applyMatrix4(E1.copy(g).invert().multiply(f));if(m===null)LP.setFromRotationMatrix(E1.extractRotation(f));else{let v=m.clone().applyMatrix4(E1.extractRotation(f));LP.setFromRotationMatrix(E1.lookAt(wft.set(0,0,0),v,Sft))}return{position:y,rotation:new P().setFromEuler(xft.setFromQuaternion(BU.invert().multiply(LP))).multiplyScalar(qt.RAD2DEG)}}(h,n==="tangential"?l.getTangentAt(u):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(DY)})}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(r=>{if(r.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=>$1(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(_c.Cloner===null)return void Nn("cloners","a cloner");this.cloner=new _c.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"})}}}),o0=j(()=>{dt(),vo(),(VU||(VU={})).is=t=>"objectHelper"in t,a0=(t,e)=>class extends j5(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof TS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Zh?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof TS&&(r.visible=!1)}}}}),G5=j(()=>{dt(),z5(),o0(),zu=class extends a0($v,Iv){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 hh(t,e,i,r,s,n,a){Kw.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let u=0,h=o.length;u<h;u++)l.setXYZ(o[u],Kw.x,Kw.y,Kw.z)}}var Kw,Xo,OY,Mft,b3t=j(()=>{dt(),QS(),JS(),Kw=new P,Xo=new xg,OY=class extends x1{constructor(t){let e=new ge,i=new zh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new ae(15711266),o=new ae(15711266),l=new ae(2857471);function u(d,c,p){h(d,p),h(c,p)}function h(d,c){r.push(0,0,0),s.push(c.r,c.g,c.b),n[d]===void 0&&(n[d]=[]),n[d].push(r.length/3-1)}u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",o),u("p","n2",o),u("p","n3",o),u("p","n4",o),u("u1","u2",l),u("u2","u3",l),u("u3","u1",l),e.setAttribute("position",new fe(r,3)),e.setAttribute("color",new fe(s,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=n,this.update()}update(){let t=this.geometry,e=this.pointMap;Xo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;hh("n1",e,t,Xo,-1,-1,i),hh("n2",e,t,Xo,1,-1,i),hh("n3",e,t,Xo,-1,1,i),hh("n4",e,t,Xo,1,1,i);let r=i;hh("f1",e,t,Xo,-1,-1,r),hh("f2",e,t,Xo,1,-1,r),hh("f3",e,t,Xo,-1,1,r),hh("f4",e,t,Xo,1,1,r);let s=r;hh("u1",e,t,Xo,.35,1.1,s),hh("u2",e,t,Xo,-.35,1.1,s),hh("u3",e,t,Xo,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},Mft=class extends Xv(OY){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){Yv(this.object,this.geometry,t,e,!0)}}});function IY(t){return 1-Math.pow(1-t,3)}var ef,AM,CM,EM,F0,PM,uu,ks,Qh=j(()=>{dt(),b3t(),ke(),o0(),ir(),ef=new P,AM=new P,CM=new Se,EM=new P,F0=new P,PM=new P,uu=class extends a0(xg,Mft){constructor(t="",e={...W2.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=yc.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let s=this._projectionTransition;if(s===void 0)return;if(this.disposed)return void this._endProjectionTransition();s.raf=requestAnimationFrame(this._tickProjectionTransition);let n=uu.projectionTransitionRequestRender??s.requestRender;this.updateProjectionMatrix(),n?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new _t,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Dv(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new kh(45,i/r,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=uu.projectionTransitionsEnabled;uu.projectionTransitionsEnabled=!1;try{return t()}finally{uu.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 P(t,e,i)),super.lookAt(t),this.getWorldPosition(ef),this.targetOffset=ef.distanceTo(t)}getTarget(t=new P){return this.getWorldDirection(AM),this.getWorldPosition(ef),AM.multiplyScalar(this.targetOffset),t.copy(ef).add(AM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(ef),ef.distanceTo(t)}updateUp(){this.getWorldQuaternion(CM),EM.set(0,0,1).applyQuaternion(CM),F0.copy(dr.DEFAULT_UP),this.isUpVectorFlipped&&F0.negate(),F0.applyQuaternion(CM),PM.copy(dr.DEFAULT_UP).projectOnPlane(EM),this.angleOffsetFromUp=PM.angleTo(F0),this.angleOffsetFromUp*=PM.cross(F0).dot(EM)>=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 P),i=t.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new P;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let r=t>e?this.aspect:1,s=t>e?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/s*395,this.bottom=1/s*-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:IY(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return uu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=uu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new _t,blend:new _t,blendInverse:new _t,start:0,duration:uu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=uu.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=IY(e),r=t.from.elements,s=this._activeSubCamera.projectionMatrix.elements,n=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*a));for(let u=0;u<16;u++)n[u]=r[u]+(s[u]-r[u])*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 _t,blend:new _t,blendInverse:new _t,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,r,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,r,s,n):this.orthoCamera.setViewOffset(t,e,i,r,s,n),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=yc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return G8({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=yc.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}}},(ks=uu).projectionTransitionsEnabled=!1,ks.projectionTransitionDuration=350,ks.projectionTransitionMinAgeMs=1e3});function Aft(t){return t.type==="TorusGeometry"&&t.arc===360}var Cft,RM,kU,OS=j(()=>{dt(),Cft=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),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,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:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:u,cornerRadius:h,cornerSegments:d}=t.parameters,c=new kU(!1,e,i,r,s,n,a,o,l,u,h,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},RM=new hm([0,0,0],1),kU=class extends ge{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,u=1,h=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),h>100&&(h=100),h===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new P,S=new P,w=x(),T=x(),C=x(),M=x(),A=x(),R=x(),O=x(),N=x(),B=x(),L=x(),z=x(),k=i-2*o+.001,V=k/n,H=Math.ceil(a*n),W=H+1,X=k/H,st=-k/2,nt=u+1,xt=2*Math.PI/u,pt=Math.PI/2/d,K=Math.min((1-h/100)*o,o-.01),ct=o-K,St=0,wt=2*d+2,Tt=nt*wt/2,yt=Tt+nt*W,Ot=Math.max(0,nt*(W+wt)),[Ft,Bt,zt]=[3,3,2].map(Ve=>Array(Ot*Ve).fill(0)),Vt=[],Wt=s-o;function $t(Ve,ie){let oi=Math.PI/2;v=ie*X,_=2*Math.PI*(v%V)/V+oi,v+=st,b=Math.sin(_)*Wt,y=Math.cos(_)*Wt,t?Ve.set(y,b,v):Ve.set(y,v,b)}$t(S,-1e-10),$t(w,0),M.copy(S),$t(S,1);let Pt=S.distanceTo(w),oe=c?0:ct+K,jt=Pt*H+2*oe,Zt=K,Jt=jt-oe;for(let Ve=0;Ve<=H;Ve++){$t(T,Ve),z.subVectors(T,M).normalize(),M.copy(T),B.copy(T).setComponent(+t+1,0).normalize(),L.crossVectors(z,B).normalize();let ie=Ve===0,oi=Ve===H,xi=ie?3*Math.PI/2:pt,Ks=ie?Zt:Jt,Hi=ie?nt:yt,li=ie?0:Ot-nt,Ur=z.clone().multiplyScalar(ie?-ct:ct).add(T),Jr=z.clone().multiplyScalar(ie?-1:1).normalize();for(let jr=0;jr<nt;jr++){let Ui=jr*xt;if(A.addVectors(S.copy(B).multiplyScalar(o*Math.cos(Ui)),w.copy(L).multiplyScalar(o*Math.sin(Ui))),R.copy(A).normalize(),ie||oi){c||(St=li+jr,[0,1,2].forEach(Ci=>{Ft[3*St+Ci]=Ur.getComponent(Ci),Bt[3*St+Ci]=Jr.getComponent(Ci)}),zt[2*St]=+oi,zt[2*St+1]=jr/u),w.copy(R).multiplyScalar(K),C.addVectors(T,w);for(let Ci=0;Ci<d;Ci++){let Zs=Ci*pt+xi;O.addVectors(S.copy(z).multiplyScalar(ct*Math.sin(Zs)),w.copy(R).multiplyScalar(ct*Math.cos(Zs))),N.copy(O).normalize(),w.addVectors(C,O),O.normalize(),St=Hi+Ci*nt+jr,[0,1,2].forEach(_r=>{Ft[3*St+_r]=w.getComponent(_r),Bt[3*St+_r]=N.getComponent(_r)});let ps=+ie+Math.sin(Zs);zt[2*St]=(Ks+ct*ps)/jt,zt[2*St+1]=jr/u}}w.addVectors(T,A),St=Tt+Ve*nt+jr,[0,1,2].forEach(Ci=>{Ft[3*St+Ci]=w.getComponent(Ci),Bt[3*St+Ci]=R.getComponent(Ci)}),zt[2*St]=(oe+Ve*Pt)/jt,zt[2*St+1]=jr/u}}let $=W+2*d+2,[se,Pe]=[+c,$-1];for(let Ve=se;Ve<=Pe-1;Ve++){let ie=c&&Ve===Pe-1;for(let oi=0;oi<nt-1;oi++)p=Ve*nt+oi,m=p+1,f=(ie?oi:p)+nt,g=(ie?oi+1:m)+nt,Ve===0?Vt.push(m,g,f):Ve===$-2?Vt.push(p,m,f):Vt.push(p,m,f,m,g,f)}this.setIndex(Vt),this.setAttribute("position",new fe(Ft,3)),this.setAttribute("normal",new fe(Bt,3)),this.setAttribute("uv",new fe(zt,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,r,s=this.userData.parameters,n=Math.ceil(s.tubularSegments),a=s.radialSegments,o=a+1,l=[];for(let u=1;u<n;u++)for(let h=0;h<a;h++)t=u*o+h,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let u=0;u<a;u++)t=n*o+u,e=t+1,i=u+o,r=u+1+o,l.push(t,e,i,e,r,i);return RM.array=new Uint32Array(l),RM.count=l.length,RM}}});function _3t(t){return VY||(VY=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),IS=r}())}function C4(){if(IS===void 0)throw new Error("boolean-wasm is not loaded");return IS}function wG(t){let e=BS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function SG(t){return BS.set(++zU,t),zU}function x3t(t,e,i){if(IS===void 0)return-1;let{positions:r,indices:s,normals:n}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,m=[];for(let f=0,g=0;f<p.verticesPerFace.length;f++){let y=p.verticesPerFace[f];for(let v=1;v<y-1;v++)m.push(p.indices[g],p.indices[g+v],p.indices[g+v+1]);g+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(m)}}let l;l=Aft(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let u,h=a.getAttribute("position");if(l===null){u=new Uint32Array(h.count);for(let p=0;p<u.length;p++)u[p]=p}else u=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===h.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:h.array,indices:u,normals:c}}(t,e);return SG(new IS.CsgMesh(r,s,n))}function BY(t,e){let i=C4(),r=Pft[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(wG);if(s.length===1)return i.clone_mesh(s[0]);let n,a=[];if(e===2&&s.length>2){let o=s[0];for(let l=1;l<s.length-1;l++)o=i.boolean_mesh(o,s[l],0),a.push(o);n=i.boolean_mesh(s[s.length-1],o,2)}else if(e===2)n=i.boolean_mesh(s[1],s[0],2);else{let o=s[s.length-1];for(let l=0;l<s.length-1&&(o=i.boolean_mesh(o,s[l],r),a.push(o),o.tri_count()!==0);l++);n=o,a.pop()}for(let o of a)o.free();return n}function NO(t,e){wG(t).transform(new Float32Array(e.elements))}function Eft(t){let e=BS.get(t);e!==void 0&&(e.free(),BS.delete(t))}var IS,BS,zU,VY,Pft,W5=j(()=>{dt(),OS(),BS=new Map,zU=0,Pft={0:0,1:1,2:2}});function rf(t){return t!==null&&"booleanOp"in t}var LU,Rft,w3t=j(()=>{dt(),vo(),W5(),LU=class extends j5(vr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new _t}updateVisible(t){super.updateVisible(t),this.visible=!rf(this.parent)&&this.visible,rf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){rf(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Eft(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof LU&&(t.freeBooleanPointer(),rf(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&rf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),rf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),S3t=j(()=>{Rft=null});function TG(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,u=-1/0,h=-1/0;for(let d=e;d<i;d++){let c=t.getX(d),p=t.getY(d),m=t.getZ(d);c<n&&(n=c),p<a&&(a=p),m<o&&(o=m),c>l&&(l=c),p>u&&(u=p),m>h&&(h=m)}Zw.min.set(n,a,o),Zw.max.set(l,u,h),Zw.getCenter(r),Zw.getSize(s).multiplyScalar(.5)}var Zw,kY,zY,Vs,la=j(()=>{dt(),w3t(),S3t(),Zw=new pr,kY=new ge,zY=new Uo,Vs=class extends LU{constructor(t,e){super(kY,zY),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){if(this.raycastDeformed(t,e))return;let i=Rft;i===null?super.raycast(t,e):i(this,t,e)}raycastDeformed(t,e){return!1}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?TG(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function E4(t){return t?.isClassicNodeMaterial===!0}var Dr,FU,Dft,Nft,X2,Oft,Ift,Bft,MG=j(()=>{}),Dc=j(()=>{dt(),Dr=class extends ae{constructor(t,e,i,r){super(t,e,i),this.isColorA=!0,this.a=r}setRGBA(t,e,i,r){super.setRGB(t,e,i),this.a=r}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 r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[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}}}),T3t=j(()=>{Dc(),FU=class extends Dr{}}),M3t=j(()=>{Dft=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}}}),Vft=j(()=>{M3t(),Nft=class extends Dft{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),kft=j(()=>{Oft=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}},Ift=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}}}),A3t=j(()=>{dt(),Bft=class extends Kpt{constructor(t){super(t),this.type=ai}parse(t){let e=function(p,m){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},i=function(p,m,f){m=m||1024;let g=p.pos,y=-1,v=0,b="",_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(y=_.indexOf(`
|
|
347
|
+
})();`}),umt=j(()=>{Q7=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 r=i.setVariable(String(e[0]),e[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=e[0]??{},s=!0;for(let[n,a]of Object.entries(r)){let o=i.setVariable(n,a);o.warning&&this.onConsole("warn",o.warning),s=s&&o.ok}return s}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 r=i.getGeometry(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.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"getTexture":if(i.getTexture===void 0)throw new Error("getTexture: not available on this surface \u2014 a three.js texture instance needs the inline HTML-content mode (editor Preview/Play and web exports).");return i.getTexture(String(e[0]),e[1]??{});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 r=i.spawnObject(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let r=e[1]===null||e[1]===void 0?null:e[1],s=i.setInstanceTransforms(String(e[0]),r);return s<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).`),s}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(e[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,s=>{this.onEvent(r,s)})),!0}case"unlistenEvent":{let r=String(e[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!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,r){let s=[];for(let n of Object.keys(r))i[n]!==r[n]&&s.push({name:n,value:r[n]});return s}(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 CMt(t,e,i,r){return[t[0]*e+t[4]*i+t[8]*r+t[12],t[1]*e+t[5]*i+t[9]*r+t[13],t[2]*e+t[6]*i+t[10]*r+t[14]]}var EMt=j(()=>{}),dmt,PMt=j(()=>{}),RMt=j(()=>{J7(),umt(),dmt=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=r=>{if(this.disposed||r.source!==this.iframe.contentWindow)return;let s=r.data;var n;typeof(n=s)!="object"||n===null||n[jp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new Q7(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[jp]:!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({[jp]:!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({[jp]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[jp]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[jp]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),r={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,{...r,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,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,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(s,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(s,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(s);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...r,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ir=j(()=>{Z7(),cMt(),pMt(),mMt(),gMt(),yMt(),vMt(),bMt(),_Mt(),xMt(),wMt(),MMt(),J7(),AMt(),umt(),EMt(),PMt(),RMt()}),DMt=j(()=>{});function cmt(t){return Array.isArray(t)?t:[t]}function JR(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 NMt=j(()=>{});function $a(t,e){return Object.setPrototypeOf(t,e),t}function qN(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function Jp(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 n=t;t=e,e=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=t+(e-t)*(n+.75+.5*Math.random())*s;r.push(a)}return r}function Qg(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 OMt=j(()=>{});function tG(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let r=t[i];r&&typeof r=="object"&&tG(r)}return Object.freeze(t)}function pmt(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var HN,t4,W8,Be,eG,IMt=j(()=>{}),hn=j(()=>{DMt(),NMt(),OMt(),IMt()}),iG=j(()=>{HN=class{},t4=class extends HN{constructor(t){super(),this.id=t}},W8=class extends HN{constructor(t){super(),this.data=t}}}),BMt=j(()=>{}),E5=j(()=>{Be=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let r={...i,[t]:e};return Object.setPrototypeOf(r,Be.prototype),r}}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,r=e[t.id];i=r===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:r};let{id:s,data:n}=t,a={...e,[s]:n};return Object.setPrototypeOf(a,Be.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,r=e[i];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Be.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),rG=j(()=>{eG=class extends Error{}});function mmt(t,e){for(let i of t)e(i.id,i.data)!==!0&&mmt(i.children,e)}function fmt(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)fmt(i,e)}var In,gM,Nv,ye,r0=j(()=>{hn(),rG(),hn(),In=class extends Array{constructor(...t){super(...t),pc(this,"partialObjectCaches"),pc(this,"objCaches"),pc(this,"parentCaches"),Object.setPrototypeOf(this,In.prototype)}deepFreeze(){let t=0;for(;t<this.length;)tG(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&&fmt(i,e)}}traverse(t){mmt(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),r=this.childrenArray(i),s=r.findIndex(o=>o.id===t);if(s<0)throw new Error("not expected");let n=r[s];r=[...r],r[s]={...n,data:e};let a=new Map;return a.set(t,r[s]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(t,e,i=void 0){let r=t,s=e;for(;r!==null;){let a=s,o=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let l=s.findIndex(u=>u.id===o);if(l<0)throw new Error;s=[...s],s[l]={...s[l],children:a},i&&i.set(o,s[l])}Object.setPrototypeOf(s,In.prototype);let n=s;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){n.objCaches=this.objCaches;for(let[a,o]of i)n.objCaches.set(a,o);n.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else n.fillCaches();return n}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:r,data:s,children:n}=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:r,data:s,children:n};return o=[...o,l],o.sort((u,h)=>u.fi-h.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:r}}}}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 r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);t.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:t,reverse:{type:7,...n,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:r}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:r});if(e!==null){let d=e;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new eG("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],u=this.modifyArrayBy(s,a);s=e,a=u.childrenArray(s);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),u=u.modifyArrayBy(s,a),{data:u,actual:t,reverse:{type:9,parent:n,fi:h,id:r}}}previous(t,e){if(e===null){let r=this.childrenArray(t);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(t)){if(r.id===e)return i;i=r.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)+1;if(r<i.length)return i[r].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),r=i.findIndex(s=>s.id===t)-1;return r>=0?this.traverseSortPrevious(i[r].id):e}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push({...i,...r})}e.sort((i,r)=>JR(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i);r!==void 0&&e.push(r)}e.sort((i,r)=>JR(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],r=this.get(e),s=r;if(r!==void 0){for(;e;)i.splice(0,0,r.fi),e=this.parent(e),e!==null&&(r=this.get(e));return{...s,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let r=this.childrenArray(t);if(e===null){if(r.length===0)return Jp(0,i,i);{let s=r[0].fi;return Jp(s-i,s,i)}}{let s=this.get(e);if(s===void 0||this.parent(e)!==t)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Jp(a,a+i,i)}return Jp(s.fi,n.fi,i)}}}}),sG=j(()=>{var t;hn(),gM=null,(t=Nv||(Nv={})).setPreservePrototype=function(e){gM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===gM&&Object.setPrototypeOf(i,gM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||Qg(e)){let r=i.props,s={},n=Qg(e)?e.slice():[...e],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");s[o]=n[l],n[l]=r[o],a=!0}return a?{data:n,actual:i,reverse:{type:0,props:s}}:null}{let r=i.props,s={},n={...e},a=!1;if(r)for(let o of Object.keys(r)){s[o]=n[o];let l=r[o];l===void 0?delete n[o]:n[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,n),actual:i,reverse:{type:0,props:s}}:null}}}),s0=j(()=>{hn(),hn(),ye=class extends Array{constructor(...t){super(...t),pc(this,"objCaches"),Object.setPrototypeOf(this,ye.prototype)}deepFreeze(){let t=0;for(;t<this.length;)tG(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,r=i.findIndex(n=>n.id===t);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,ye.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:r}=t,s=this,n={fi:e,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),t.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,r=i.findIndex(n=>n.id===e);if(r===-1)return null;t.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...s}}}moveOp(t){let{fi:e,id:i}=t,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:e};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),t.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:t,reverse:{type:6,fi:n,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 Jp(0,e,e);{let r=i[0].fi;return Jp(r-e,r,e)}}{let r=this.get(t);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Jp(n,n+e,e)}return Jp(r.fi,s.fi,e)}}}});function VMt(t,e){let i={cur:[],result:[],len:0};return[t=av(t,e,i)??t,i.result]}function RP(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function DP(t){t&&(t.len-=1)}function gmt(t,e,i){let r=!1,s=t.map(n=>{let a=n.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=av(n.data,e,RP(i,a));DP(i),r=r||l!==void 0,l===void 0&&(l=n.data);let u=gmt(n.children,e,i);return u!==void 0?r=!0:u=n.children,{...n,id:a,data:l,children:u}});if(r)return s}function av(t,e,i){if(t instanceof In){let r=gmt(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ye)return function(r,s,n){let a=!1,o=r.map(l=>{let u=l.id,h=s[u];if(h!==void 0&&typeof h=="string"&&(a=!0,u=h,n!==null))throw new Error("not supported");let d=av(l.data,s,RP(n,u));return DP(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:u,data:d}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(r)),o}(t,e,i);if(Array.isArray(t)){let r=!1,s=t.map((n,a)=>{let o=av(n,e,RP(i,a));return DP(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(t)),s):void 0}if(t&&typeof t=="object"&&!Qg(t)){let r={},s=!1;for(let[n,a]of Object.entries(t))if(n!=="name"&&n!=="variableId"){let o=e[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=av(a,e,RP(i,n));DP(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(typeof t=="string"){let r=e[t];return r!==void 0&&function(s){if(s===null)return null;s.result.push(s.cur.slice(0,s.len))}(i),r}}var ymt=j(()=>{r0(),s0(),hn()});function ov(t){return t&&typeof t=="object"&&t instanceof As}function nG(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=j2(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=nG(s.children,e);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}return{...s,id:n,data:a}});return i?r:void 0}function j2(t,e){if(!ov(e))return e;if(t instanceof In){let i=nG(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ye)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=j2(a.data,r[o]);return s=s||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return s?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}(t,e);if(Array.isArray(t)){let i=!1,r=t.map((s,n)=>{let a=j2(s,e[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t instanceof As)return aG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=j2(n,e[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function aG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!ov(e))return e;if(!ov(t))return um.apply(t,e);let i=new Set;for(let s of Object.keys(t))i.add(s);for(let s of Object.keys(e))i.add(s);let r=new As;for(let s of i){let n=aG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var As,um,e4,ea,k$,P5=j(()=>{var t;r0(),s0(),N5(),hn(),As=class{unusedFunOverridesTable(e){}runOp(e){let i=[],r=this,s=0,n={};for(;s<e.path.length;){if(i.push(r),r=r===void 0?void 0:r[e.path[s]],r!==void 0&&!ov(r))return null;s+=1}r=r?qN(r):new As;for(let[a,o]of Object.entries(e.props)){let l=r[a];n[a]=l,o===void 0?delete r[a]:r[a]=o}for(;s>0;){if(Object.keys(r).length===0){let a=i[s-1];a&&(r=qN(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=qN(a);o[e.path[s-1]]=r,r=o}else{let o=new As;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,As.prototype),actual:e,reverse:{...e,props:n}}}},(t=um||(um={})).apply=function(e,i){return j2(e,i)??e},t.merge=function(e,i){return aG(e,i)},t.filterOp=function(e,i){let r=0,s=i.path,n=e;for(;r<s.length&&n!==void 0;){if(n=Dn.zoomOnce(n,s[r]),n===void 0)return i;if(!ov(n))return;r+=1}if(n===void 0)return i;if(ov(n)){if(i.type===0){let a={...i.props};for(let o of Object.keys(n))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=nG([i],n);return a?a[0]:i}return i}}}),kMt=j(()=>{hn(),N5(),E5(),r0(),rG(),sG(),s0(),ymt(),P5(),(e4||(e4={})).replaceProps=function(t,e){let i=Dn.zoom(e,t.path);if(typeof i=="object"){let r={};for(let s of Object.keys(t.props))r[s]=i[s];return{...t,props:r}}return{...t,props:{}}},(t=>{function e(s,n){let a=n.path,o=[];for(;;){let l;if(s instanceof As&&n.type===0&&(l=s.runOp({...n,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=s instanceof In||s instanceof ye||s instanceof Be?s.runOp(n):Nv.runOp(s,n)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],m=o[c];if(m instanceof In){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ye){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Be){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof As){let f={...m,[p]:d};d=Object.setPrototypeOf(f,As.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||Qg(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=Qg(m)?m.slice():[...m],d[p]=f}else d=Nv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let u,h=a[o.length];if(s instanceof In){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else if(s instanceof ye){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else s!==null&&(u=s[h]);if(u===void 0)return null;o.push(s),s=u}}function i(s,n){for(let a=0;a<s.length&&a<n.length;a++)if(s[a]!==n[a])return!0;return!1}function r(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==n[a])return!1;return!0}t.drop=function(s,n){return{...s,path:s.path.slice(n)}},t.applySimple=function(s,n){return e(s,n)?.data??s},t.apply=e,t.pathDisjoint=i,t.pathEq=r,t.commutative=function(s,n){return i(s.path,n.path)},t.subsumed=function(s,n){return!(s.type!==0||n.type!==0||!r(s.path,n.path))&&Object.keys(s.props).every(a=>n.props[a]!==void 0)}})(ea||(ea={})),(t=>{function e(i,r){let s=i,n=[],a=[];for(let o of r)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,u,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=ea.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=ea.apply(s,o)),h!==null){s=h.data;let[d,c]=VMt(s,{[o.id]:l});s=d;for(let p=0;p<c.length;p++){let m=c[p],f=m.pop();if(typeof f=="number"){let g=[f];for(let v=p+1;v<c.length;v++){let b=c[v],_=b[b.length-1];if(typeof _!="number"||!Dn.equal(m,b.slice(0,b.length-1)))break;g.push(_),c.splice(v,1)}let y=Dn.zoom(s,m);u=y.map((v,b)=>g.includes(b)?o.id:v),l=y,f=m.pop()}else{if(f==="alphaOverride"||f==="alpha"){l/=100;let g=l,y=Dn.zoom(s,m.slice(0,m.length-2)),v=y.layers.map(b=>b.id===m[m.length-1]?{...b,data:{...b.data,[f]:g}}:b);Object.setPrototypeOf(v,Object.getPrototypeOf(y.layers)),y.layers=v}u=o.id}n.push({type:0,path:m,props:{[f]:l}}),a.push({type:0,path:m,props:{[f]:u}})}a.push(h.reverse),n.push(h.actual)}}else{let l=ea.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof eG)return null;throw l}return{data:s,actual:n,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,r){let s=[];for(let n of i){let[a,...o]=n.path;a===r&&s.push({...n,path:o})}return s},t.addPrefix=function(i,r){return i.map(s=>({...s,path:[r,...s.path]}))},t.concat=function(i,r){return[...i,...r]},t.compress=function(i,r){return[...i.filter(s=>!r.some(n=>ea.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>ea.commutative(s,n)))},t.applyAll=function(i,r){for(let s of r){let n=e(i,s);n!==null&&(i=n.data)}return i},t.apply=e})(k$||(k$={}))});function z$(t,e){return t instanceof As?Object.setPrototypeOf(e,As.prototype):Nv.tryPreservePrototype(t,e)}function $N(t,e,i){if(t.length>0){let r=t[t.length-1];if(r.type===0&&e.type===0&&Dn.equal(r.path,i))return void Object.assign(r.props,e.props)}t.push({...e,path:i})}function NP(t,e,i){return i instanceof In?new R5(t,e,i):i instanceof ye?new D5(t,e,i):i instanceof Be?new Proxy(new bmt(t,e,i),xmt):i!==null&&typeof i=="object"?Qg(i)?i:new Proxy(new vmt(t,e,i),_mt):i}function Ww(t){let e=new H8(t);return[NP(e,"",t),e]}function i4(t,e){let[i,r]=Ww(t);return e(i),r.result()}function qs(t){return t instanceof R5||t instanceof D5?t._current:t!==null&&typeof t=="object"?t[q8]:t}var q8,L$,r_,k0,vmt,bmt,XN,_mt,xmt,R5,D5,H8,Dn,wmt=j(()=>{E5(),r0(),sG(),s0(),hn(),N5(),P5(),q8=Symbol(),L$=Symbol(),r_=Symbol(),k0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof H8);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[r_];i&&i(),delete this._children[t]}}}},vmt=class extends k0{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=z$(this._current,{...this._current,[t]:e})}runOp(t){let e=Nv.runOp(this._current,t);e!==null&&(e.data=z$(this._current,e.data)),this.reportOp(t,e,t.path)}},bmt=class extends k0{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,Be.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},XN={get(t,e){if(e===r_)return()=>{t._parent=null};if(e===q8)return t._current;if(e===L$)return t;let{_current:i,_children:r}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[e];if(s!==void 0)return s;let n=i[e],a=NP(t,e,n);return a!==n?(r===void 0&&(r={},t._children=r),r[e]=a,a):n},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,r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[e]}}},_mt={...XN,set(t,e,i){let r={type:0,props:{[e]:qs(i)??i}};return t.deleteChildren(e),t.runOp(r),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},xmt={...XN,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)},R5=class extends k0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[r_]=()=>{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,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=NP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}add(t,e,i,r,s){this.runOp({type:7,parent:t,fi:e,id:i,data:r,children:s})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}insertBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}moveAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}moveBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}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)}},D5=class extends k0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[r_]=()=>{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 r=this._current[i].id,s=this._current[i].fi;t(this.data(this._current[i].id),r,s,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id;if(t(this.data(r),r))return this.get(r)}}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,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=NP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}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 r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},H8=class extends k0{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,r){$N(this.ts,e,t),$N(this.actual,i,t),$N(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),N5=j(()=>{iG(),wmt(),s0(),r0(),hn(),(t=>{function e(r,s){return(r instanceof In||r instanceof R5)&&typeof s=="string"||(r instanceof ye||r instanceof D5)&&typeof s=="string"?r.data(s):typeof s=="number"&&Array.isArray(r)||typeof s=="string"&&typeof r=="object"&&r!==null?r[s]:void 0}function i(r,s,n=0){for(;n<s.length&&r!==void 0;)r=e(r,s[n]),n+=1;return r}t.equal=function(r,s){if(s.length!==r.length)return!1;{let n=0;for(;n<r.length;){if(r[n]!==s[n])return!1;n+=1}}return!0},t.removeOverridden=function(r,s,n){let a=i(n,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...s};return Object.keys(a).forEach(l=>{delete o[l]}),o}return s},t.zoomOnce=e,t.zoom=i,t.findPathes=function(r,s){let n=[];return function a(o,l){if(o instanceof t4&&o.id===s.id)n.push(l);else if(o instanceof ye)for(let u=0;u<o.length;u++)a(o[u].data,[...l,o[u].id]);else if(o instanceof In)o.traverse((u,h)=>{a(h,[...l,u])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let u=0;u<o.length;u++)a(o[u],[...l,u])}else{if(Qg(o))return;if(typeof o=="object"&&o!==null)for(let u in o)a(o[u],[...l,u])}}(r,[]),n}})(Dn||(Dn={}))}),zMt=j(()=>{});function er(t,e){let i=[];if(!(e.length<=t.length))return null;{let r=0;for(;r<e.length;){if(e[r]==="*")i.push(t[r]);else if(t[r]!==e[r])return null;r+=1}}return i}var LMt=j(()=>{});function yM(t){try{if(!Er.trusted&&!gc){let i=Wi.sharedLength||0;i<Wi.length&&(Wi.length=i)}let e;if(Er.randomAccessStructure&&pe[ft]<64&&pe[ft]>=32&&q$?(e=q$(pe,ft,Ql,Er),pe=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),ft=Ql):e=Ys(),Da&&(ft=Da.postBundlePosition,Da=null),gc&&(Wi.restoreStructures=null),ft==Ql)Wi&&Wi.restoreStructures&&F$(),Wi=null,pe=null,fc&&(fc=null);else{if(ft>Ql)throw new Error("Unexpected end of MessagePack data");if(!gc){let i;try{i=JSON.stringify(e,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw Wi&&Wi.restoreStructures&&F$(),X8(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||ft>Ql)&&(e.incomplete=!0),e}}function F$(){for(let t in Wi.restoreStructures)Wi[t]=Wi.restoreStructures[t];Wi.restoreStructures=null}function Ys(){let t=pe[ft++];if(t<160){if(t<128){if(t<64)return t;{let e=Wi[63&t]||Er.getStructures&&Smt()[63&t];return e?(e.read||(e.read=$8(e,63&t)),e.read()):t}}if(t<144){if(t-=128,Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=Mmt();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(qh>=ft)return tm.slice(ft-pl,(ft+=e)-pl);if(qh==0&&Ql<140){let i=e<16?oG(e):Tmt(e);if(i!=null)return i}return n4(e)}{let e;switch(t){case 192:return null;case 193:return Da?(e=Ys(),e>0?Da[1].slice(Da.position1,Da.position1+=e):Da[0].slice(Da.position0,Da.position0-=e)):Emt;case 194:return!1;case 195:return!0;case 196:if(e=pe[ft++],e===void 0)throw new Error("Unexpected end of buffer");return YN(e);case 197:return e=zi.getUint16(ft),ft+=2,YN(e);case 198:return e=zi.getUint32(ft),ft+=4,YN(e);case 199:return tf(pe[ft++]);case 200:return e=zi.getUint16(ft),ft+=2,tf(e);case 201:return e=zi.getUint32(ft),ft+=4,tf(e);case 202:if(e=zi.getFloat32(ft),Er.useFloat32>2){let i=tU[(127&pe[ft])<<1|pe[ft+1]>>7];return ft+=4,(i*e+(e>0?.5:-.5)|0)/i}return ft+=4,e;case 203:return e=zi.getFloat64(ft),ft+=8,e;case 204:return pe[ft++];case 205:return e=zi.getUint16(ft),ft+=2,e;case 206:return e=zi.getUint32(ft),ft+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*zi.getUint32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigUint64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigUint64(ft),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigUint64(ft),ft+=8,e;case 208:return zi.getInt8(ft++);case 209:return e=zi.getInt16(ft),ft+=2,e;case 210:return e=zi.getInt32(ft),ft+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*zi.getInt32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigInt64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigInt64(ft),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigInt64(ft),ft+=8,e;case 212:if(e=pe[ft++],e==114)return J8(63&pe[ft++]);{let i=Ma[e];if(i)return i.read?(ft++,i.read(Ys())):i.noBuffer?(ft++,i()):i(pe.subarray(ft,++ft));throw new Error("Unknown extension "+e)}case 213:return e=pe[ft],e==114?(ft++,J8(63&pe[ft++],pe[ft++])):tf(2);case 214:return tf(4);case 215:return tf(8);case 216:return tf(16);case 217:return e=pe[ft++],qh>=ft?tm.slice(ft-pl,(ft+=e)-pl):Rmt(e);case 218:return e=zi.getUint16(ft),qh>=(ft+=2)?tm.slice(ft-pl,(ft+=e)-pl):Dmt(e);case 219:return e=zi.getUint32(ft),qh>=(ft+=4)?tm.slice(ft-pl,(ft+=e)-pl):Nmt(e);case 220:return e=zi.getUint16(ft),ft+=2,U$(e);case 221:return e=zi.getUint32(ft),ft+=4,U$(e);case 222:return e=zi.getUint16(ft),ft+=2,j$(e);case 223:return e=zi.getUint32(ft),ft+=4,j$(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 $8(t,e){function i(){if(i.count++>K8){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":Pmt.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")(Ys)}catch{return K8=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=Z8(e,t.read)),s()}let r={};for(let s=0,n=t.length;s<n;s++){let a=t[s];a==="__proto__"&&(a="__proto_"),r[a]=Ys()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?Z8(e,i):i}function Smt(){let t=Cmt(()=>(pe=null,Er.getStructures()));return Wi=Er._mergeStructures(t,Wi)}function qw(t){let e;if(t<16&&(e=oG(t)))return e;if(t>64&&Y8)return Y8.decode(pe.subarray(ft,ft+=t));let i=ft+t,r=[];for(e="";ft<i;){let s=pe[ft++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&pe[ft++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&pe[ft++])<<6|63&pe[ft++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&pe[ft++])<<12|(63&pe[ft++])<<6|63&pe[ft++];n<65536||n>1114111?r.push(65533):(n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n))}else r.push(65533);else r.push(s);r.length>=4096&&(e+=Tn.apply(String,r),r.length=0)}return r.length>0&&(e+=Tn.apply(String,r)),e}function U$(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}function j$(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=Mmt();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}function Tmt(t){let e=ft,i=new Array(t);for(let r=0;r<t;r++){let s=pe[ft++];if((128&s)>0)return void(ft=e);i[r]=s}return Tn.apply(String,i)}function oG(t){if(t<4){if(t<2){if(t===0)return"";{let e=pe[ft++];return(128&e)>1?void(ft-=1):Tn(e)}}{let e=pe[ft++],i=pe[ft++];if((128&e)>0||(128&i)>0)return void(ft-=2);if(t<3)return Tn(e,i);let r=pe[ft++];return(128&r)>0?void(ft-=3):Tn(e,i,r)}}{let e=pe[ft++],i=pe[ft++],r=pe[ft++],s=pe[ft++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(ft-=4);if(t<6){if(t===4)return Tn(e,i,r,s);{let n=pe[ft++];return(128&n)>0?void(ft-=5):Tn(e,i,r,s,n)}}if(t<8){let n=pe[ft++],a=pe[ft++];if((128&n)>0||(128&a)>0)return void(ft-=6);if(t<7)return Tn(e,i,r,s,n,a);let o=pe[ft++];return(128&o)>0?void(ft-=7):Tn(e,i,r,s,n,a,o)}{let n=pe[ft++],a=pe[ft++],o=pe[ft++],l=pe[ft++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(ft-=8);if(t<10){if(t===8)return Tn(e,i,r,s,n,a,o,l);{let u=pe[ft++];return(128&u)>0?void(ft-=9):Tn(e,i,r,s,n,a,o,l,u)}}if(t<12){let u=pe[ft++],h=pe[ft++];if((128&u)>0||(128&h)>0)return void(ft-=10);if(t<11)return Tn(e,i,r,s,n,a,o,l,u,h);let d=pe[ft++];return(128&d)>0?void(ft-=11):Tn(e,i,r,s,n,a,o,l,u,h,d)}{let u=pe[ft++],h=pe[ft++],d=pe[ft++],c=pe[ft++];if((128&u)>0||(128&h)>0||(128&d)>0||(128&c)>0)return void(ft-=12);if(t<14){if(t===12)return Tn(e,i,r,s,n,a,o,l,u,h,d,c);{let p=pe[ft++];return(128&p)>0?void(ft-=13):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p)}}{let p=pe[ft++],m=pe[ft++];if((128&p)>0||(128&m)>0)return void(ft-=14);if(t<15)return Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m);let f=pe[ft++];return(128&f)>0?void(ft-=15):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m,f)}}}}}function G$(){let t,e=pe[ft++];if(e<192)t=e-160;else switch(e){case 217:t=pe[ft++];break;case 218:t=zi.getUint16(ft),ft+=2;break;case 219:t=zi.getUint32(ft),ft+=4;break;default:throw new Error("Expected string")}return qw(t)}function YN(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(pe,ft,ft+=t):pe.subarray(ft,ft+=t)}function tf(t){let e=pe[ft++];if(Ma[e]){let i;return Ma[e](pe.subarray(ft,i=ft+=t),r=>{ft=r;try{return Ys()}finally{ft=i}})}throw new Error("Unknown extension type "+e)}function Mmt(){let t=pe[ft++];if(!(t>=160&&t<192))return ft--,Amt(Ys());if(t-=160,qh>=ft)return tm.slice(ft-pl,(ft+=t)-pl);if(!(qh==0&&Ql<180))return n4(t);let e,i=4095&(t<<5^(t>1?zi.getUint16(ft):t>0?pe[ft]:0)),r=Q8[i],s=ft,n=ft+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=zi.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=pe[s++],e!=r[a++]){s=1879048192;break}if(s===n)return ft=s,r.string;n-=3,s=ft}for(r=[],Q8[i]=r,r.bytes=t;s<n;)e=zi.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=pe[s++],r.push(e);let o=t<16?oG(t):Tmt(t);return r.string=o??n4(t)}function Amt(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(Er.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 Cmt(t){H$&&H$();let e=Ql,i=ft,r=s4,s=pl,n=qh,a=tm,o=r4,l=fc,u=Da,h=new Uint8Array(pe.slice(0,Ql)),d=Wi,c=Wi.slice(0,Wi.length),p=Er,m=gc,f=t();return Ql=e,ft=i,s4=r,pl=s,qh=n,tm=a,r4=o,fc=l,Da=u,pe=h,gc=m,(Wi=d).splice(0,Wi.length,...c),Er=p,zi=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),f}function X8(){pe=null,fc=null,Wi=null}function FMt(t){t.unpack?Ma[t.type]=t.unpack:Ma[t.type]=t}var Y8,pe,Ql,ft,W$,r4,s4,Er,Wi,tm,pl,qh,Da,fc,Ma,zi,KN,Emt,gc,K8,q$,H$,Hw,Pmt,Z8,n4,Rmt,Dmt,Nmt,Tn,Q8,J8,ZN,$$,X$,Y$,tU,vM,K$,Z$,Q$,eU,QN,ES,UMt=j(()=>{try{Y8=new TextDecoder}catch{}ft=0,r4=W$=[],s4=0,Er={},pl=0,qh=0,Ma=[],KN={useRecords:!1,mapsAsObjects:!0},(Emt=new class{}).name="MessagePack 0xC1",gc=!1,K8=2,Hw=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(pe)return Cmt(()=>(X8(),this?this.unpack(t,e):Hw.prototype.unpack.call(KN,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ql=e.end||t.length,ft=e.start||0):(ft=0,Ql=e>-1?e:t.length),s4=0,qh=0,tm=null,r4=W$,Da=null,pe=t;try{zi=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw pe=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 Hw){if(Er=this,this.structures)return Wi=this.structures,yM(e);(!Wi||Wi.length>0)&&(Wi=[])}else Er=KN,(!Wi||Wi.length>0)&&(Wi=[]);return yM(e)}unpackMultiple(t,e){let i,r=0;try{gc=!0;let s=t.length,n=this?this.unpack(t,s):vM.unpack(t,s);if(!e){for(i=[n];ft<s;)r=ft,i.push(yM());return i}if(e(n,r,ft)===!1)return;for(;ft<s;)if(r=ft,e(yM(),r,ft)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{gc=!1,X8()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,r=t.length;i<r;i++){let s=t[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let r=t[i],s=e[i];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[i]=r),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},Pmt=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,Z8=(t,e)=>function(){let i=pe[ft++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=Wi[r]||Smt()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=$8(s,t)),s.read()},n4=qw,Rmt=qw,Dmt=qw,Nmt=qw,Tn=String.fromCharCode,Q8=new Array(4096),J8=(t,e)=>{let i=Ys().map(Amt),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=Wi[t];return s&&(s.isShared||gc)&&((Wi.restoreStructures||(Wi.restoreStructures=[]))[t]=s),Wi[t]=i,i.read=$8(i,r),(i.read0||i.read)()},Ma[0]=()=>{},Ma[0].noBuffer=!0,Ma[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let r=1;r<e;r++)i<<=BigInt(8),i+=BigInt(t[r]);if(t.byteLength!==e){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=(n,a)=>{let o=a-n;if(o<=40){let d=r.getBigUint64(n);for(let c=n+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=n+(o>>4<<3),u=s(n,l),h=s(l,a);return u<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},ZN={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},Ma[101]=()=>{let t=Ys();if(!ZN[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return ZN[t[0]](t[1],{cause:t[2]})},Ma[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4);fc||(fc=new Map);let i,r=pe[ft];i=r>=144&&r<160||r==220||r==221?[]:r>=128&&r<144||r==222||r==223?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&pe[ft+1]===115?new Set:{};let s={target:i};fc.set(e,s);let n=Ys();if(!s.used)return s.target=n;if(Object.assign(i,n),i instanceof Map)for(let[a,o]of n.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(n))i.add(a);return i},Ma[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4),i=fc.get(e);return i.used=!0,i.target},Ma[115]=()=>new Set(Ys()),$$=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),X$=typeof globalThis=="object"?globalThis:window,Ma[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=$$[e];if(!r){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 X$[r](i)},Ma[120]=()=>{let t=Ys();return new RegExp(t[0],t[1])},Y$=[],Ma[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=ft;return ft+=e-t.length,Da=Y$,(Da=[G$(),G$()]).position0=0,Da.position1=0,Da.postBundlePosition=ft,ft=i,Ys()},Ma[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"),tU=new Array(147);for(let t=0;t<256;t++)tU[t]=+("1e"+Math.floor(45.15-.30103*t));(vM=new Hw({useRecords:!1})).unpack,vM.unpackMultiple,vM.unpack,K$=new Float32Array(1),new Uint8Array(K$.buffer,0,4)}),jMt=j(()=>{UMt(),iG(),P5(),s0(),E5(),r0(),Z$=[{Class:Be.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Be.prototype),t)},{Class:ye.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ye.prototype),t)},{Class:In.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,In.prototype),t)},{Class:t4.prototype.constructor,type:4,write:t=>t.id,read:t=>new t4(t)},{Class:W8.prototype.constructor,type:5,write:t=>t.data,read:t=>new W8(t)},{Class:As.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,As.prototype),t)}];for(let t of Z$)FMt(t);Q$=new Hw({structuredClone:!0}),(eU||(eU={})).deserialize=function(t){return Q$.unpack(t)}}),GMt=j(()=>{jMt(),QN=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},ES={deserialize:eU.deserialize,serialize:QN("CollabSerialize.serialize"),checksum:QN("CollabSerialize.checksum")}}),Fi=j(()=>{N5(),BMt(),rG(),r0(),E5(),sG(),s0(),kMt(),zMt(),wmt(),LMt(),iG(),GMt(),ymt(),P5()});function iU(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var J$,rU,G2,bM,JN,tX,eX,iX,sU,nU,rX,sX,nX,aX,oX,aU,oU,lX,hX,uX,dX,Omt=j(()=>{var t,e,i;Fi(),dt(),(t=J$||(J$={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},t.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},rU={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"]},(r=>{r.is=function(s){return s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"},r.defaultData=function(s){return s==="MouseDown"||s==="MouseUp"||s==="MousePress"?{type:s,mode:"Object",disabled:!1,name:"",actions:new ye}:{type:s,disabled:!1,name:"",key:void 0,actions:new ye}}})(G2||(G2={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(bM||(bM={})),(e=JN||(JN={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:bM.propertyDefaultData(r),rOperand:{...bM.valueDefaultData}}},e.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},e.stateDefaultData=function(r,s){return{type:"State",object:r??null,state:s??null}},(tX||(tX={})).isConditionalSubActions=function(r){return r.find(s=>s==="ifActions"||s==="elseActions")!==void 0},(r=>{r.is=function(s){return s.type==="Conditional"},r.defaultData=function(s){return{type:"Conditional",disabled:!1,name:"",inActions:new ye,outActions:new ye,condition:JN.distanceDefaultData(s)}}})(eX||(eX={})),(iX||(iX={})).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 ye,drop:new ye}},(sU||(sU={})).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 ye},(nU||(nU={})).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},(r=>{r.is=function(s){return s.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new ye}}})(rX||(rX={})),(r=>{r.is=function(s){return s.type==="Scroll"},r.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ye}}})(sX||(sX={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ye}}})(nX||(nX={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ye}}})(aX||(aX={})),(r=>{r.is=function(s){return s.type==="Trigger"},r.defaultData=function(s,n){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new ye,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(oX||(oX={})),(i=aU||(aU={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(r){return r.type==="Resize"},i.sizeToDevice=function(r){return typeof r=="string"?r:"custom"},i.deviceToSize=function(r){return typeof r=="string"?[...i.defaultSizes[r]]:[...r]},i.defaultData=function(){let r={size:"mobile",operator:"<",actions:new ye},s={size:"tablet",operator:"<",actions:new ye},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ye},a=new ye;return a.push({id:qt.generateUUID(),fi:0,data:r},{id:qt.generateUUID(),fi:1,data:s},{id:qt.generateUUID(),fi:2,data:n}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new ye}},(r=>{r.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"]},r.is=function(s){return s.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new ye,variableId:"",objectId:null,property:"Position X"}}})(oU||(oU={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ye,errorActions:new ye,userAPIId:""}}})(lX||(lX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ye,userWebhookId:""}}})(hX||(hX={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ye,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(uX||(uX={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ye}}})(dX||(dX={}))});function cX(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function pX(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 n0,lv,Imt,Jg,mX,qu,dm,PS,fX,hv,an,qi,lU,gX,em,Ov,yX,vX,bX,_X,xX,wX,SX,TX,tO,MX,AX,eO,CX,EX,PX,iO,RX,rO,DX,NX,sO,OX,hU,IX,BX,VX,kX,zX,LX,t0,yc,im,uU,dU,a4,o4,l4,h4,u4,cU,pU,d4,mU,uv,FX,nO,aO,fU,UX,c4,jX,GX,gU,WX,qX,HX,$X,XX,YX,KX,ZX,QX,O5,lG,Hs,cs,M1,Bmt,RS,p4,mg,yU,hG,m4,f4,vU,hc,OP,ia,oO,Yp,wl=j(()=>{var t,e,i,r,s,n,a,o;n0="personal camera",lv="a218fcc3-276b-49b9-b485-49037fd14f5f",Imt=2500134,Jg=5526619,(t=mX||{}).x="x",t.y="y",t.z="z",mX=t,(l=>{function u(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function h(c,p){return Math.sqrt(u(c,p))}function d(c,p,m){let f=l.sub(p,c),g=l.sub(m,c),y=l.dot(f,g)/l.dot(f,f),v=l.scalarMultiply(f,y);return l.add(c,v)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,m){return[c[0]+(p[0]-c[0])*m,c[1]+(p[1]-c[1])*m]},l.add=function(c,p){return[c[0]+p[0],c[1]+p[1]]},l.sub=function(c,p){return[c[0]-p[0],c[1]-p[1]]},l.multiply=function(c,p){return[c[0]*p[0],c[1]*p[1]]},l.divide=function(c,p){return[c[0]/p[0],c[1]/p[1]]},l.distanceSquared=u,l.distance=h,l.dot=function(c,p){return c[0]*p[0]+c[1]*p[1]},l.scalarMultiply=function(c,p){return[c[0]*p,c[1]*p]},l.projectionOnto=d,l.projectionOntoDistance=function(c,p,m){return h(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(qu||(qu={})),(e=dm||(dm={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]},e.add=function(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]},e.sub=function(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]},e.div=function(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]},e.mul=function(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]},e.dist=function(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])},e.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h]},(i=PS||(PS={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]&&l[3]===u[3]},i.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h,l[3]+(u[3]-l[3])*h]},(l=>{let u=180/Math.PI,h=Math.PI/180;function d(p){return typeof p=="number"?p*u:p}function c(p){return typeof p=="number"?p*h:p}l.radToDeg=function(p){return[d(p[0]),d(p[1]),d(p[2])]},l.degToRad=function(p){return[c(p[0]),c(p[1]),c(p[2])]}})(fX||(fX={})),(r=hv||(hv={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,u){for(let h=0;h<16;h++)if(l[h]!==u[h])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,u){let h=u.slice(0);for(let d=0,c=u.length;d<c;d+=3){let p=l[3]*u[d]+l[7]*u[d+1]+l[11]*u[d+2]+l[15];h[d]=(l[0]*u[d]+l[4]*u[d+1]+l[8]*u[d+2]+l[12])/p,h[d+1]=(l[1]*u[d]+l[5]*u[d+1]+l[9]*u[d+2]+l[13])/p,h[d+2]=(l[2]*u[d]+l[6]*u[d+1]+l[10]*u[d+2]+l[14])/p}return h},(s=an||(an={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},s.clone=function(l){return{r:l.r,g:l.g,b:l.b}},s.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},s.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},s.equals=function(l,u){return l.r===u.r&&l.g===u.g&&l.b===u.b},s.equalsFixed=function(l,u){return l.r.toFixed(2)===u.r.toFixed(2)&&l.g.toFixed(2)===u.g.toFixed(2)&&l.b.toFixed(2)===u.b.toFixed(2)},s.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h}},s.is=function(l){return!!cX(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=qi||(qi={})).white={...an.white,a:1},n.is=function(l){return!!cX(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...an.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,u){return{...an.fromHex(l),a:u}},n.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}},n.equals=function(l,u){return an.equals(l,u)&&l.a===u.a},n.equalsFixed=function(l,u){return an.equalsFixed(l,u)&&l.a.toFixed(2)===u.a.toFixed(2)},n.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h,a:l.a+(u.a-l.a)*h}},n.toStyle=function({r:l,g:u,b:h,a:d}=n.white){return`rgba(${255*l}, ${255*u}, ${255*h}, ${d})`},(lU||(lU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=gX||{})[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",gX=a,(em||(em={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Ov||(Ov={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=yX||(yX={})).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]}),WMt=j(()=>{var t,e;Fi(),Omt(),(vX||(vX={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(bX||(bX={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(_X||(_X={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(xX||(xX={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(wX||(wX={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(SX||(SX={})).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"},(TX||(TX={})).defaultData={type:"Reset",name:"",delay:0},(tO||(tO={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=MX||(MX={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=AX||(AX={})).defaultData={type:"Audio",name:"",...tO.defaultData},e.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),e.hasAudioByEvents=i=>e.getAudiosByEvents(i).length>0,e.getAudiosByActions=i=>{let r=[];return i.forEach(s=>{let n=s.data;n.type==="Audio"&&n.interaction==="play"&&n.audio&&r.push(s),n.type==="Conditional"&&(r.push(...e.getAudiosByActions(n.ifActions)),r.push(...e.getAudiosByActions(n.elseActions)))}),r},e.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:s})=>{G2.is(s)||s.type==="Collision"||s.type==="Start"||s.type==="Trigger"||s.type==="VariableChange"||s.type==="WEBHOOK"||s.type==="AIAssistantTrigger"?r.push(...e.getAudiosByActions(s.actions)):s.type==="Conditional"?(r.push(...e.getAudiosByActions(s.inActions)),r.push(...e.getAudiosByActions(s.outActions))):s.type==="GameControl"?Object.values(s.gameActions).forEach(n=>{r.push(...e.getAudiosByActions(n))}):s.type==="DragDrop"?(r.push(...e.getAudiosByActions(s.dragDropActions.drag)),r.push(...e.getAudiosByActions(s.dragDropActions.drop))):s.type==="Resize"?s.breakpoints.forEach(({data:n})=>{r.push(...e.getAudiosByActions(n.actions))}):s.type==="API"&&(r.push(...e.getAudiosByActions(s.successActions)),r.push(...e.getAudiosByActions(s.errorActions)))}),r},(eO||(eO={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(CX||(CX={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...eO.defaultData},i.hasVideoByActions=r=>r.some(({data:s})=>s.type==="Video"&&s.interaction==="play"&&s.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:s}of r.events)if((G2.is(s)||s.type==="Start")&&i.hasVideoByActions(s.actions))return!0}},i.getVideosByActions=r=>{let s=[];return r.forEach(n=>{let a=n.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&s.push(n)}),s},i.getVideosByEvents=r=>{let s=[];return r.forEach(({data:n})=>{(G2.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(EX||(EX={})),(PX||(PX={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(iO||(iO={})).defaultData=function(){return{tweens:new ye,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(RX||(RX={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...iO.defaultData()}},(rO||(rO={})).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}})(DX||(DX={})),(NX||(NX={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...rO.defaultData(i)}},(sO||(sO={})).defaultData=function(i,r,s){return{interaction:"play",object:i,clipId:r,crop:s,crop2:s,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(OX||(OX={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...sO.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(hU||(hU={})),(IX||(IX={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(BX||(BX={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ye,elseActions:new ye,condition:[]}),(VX||(VX={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(kX||(kX={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(zX||(zX={})).defaultData={name:"",type:"UserAPI"}}),qMt=j(()=>{var t;(t=LX||(LX={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),Vmt=j(()=>{var t;(t=t0||(t0={})).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(n){return n===void 0||!Number.isFinite(n)||n<e.MinTargetOffset?e.DefaultTargetOffset:n},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,r=e.DefaultElevation*Math.PI/180,s=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(r),e.DefaultTargetOffset*Math.sin(r),e.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],e.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*s,Math.asin(Math.sin(i)*Math.cos(r))*s,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*s],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(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}})(yc||(yc={}))}),kmt=j(()=>{var t;(t=im||(im={})).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(r=>(typeof r=="number"?r: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 r={...e};if(dU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;a4.forEach(a=>{Object.assign(r.radial,{[a]:n[a]??s[a]})})}if(r.linear={...e.linear},i.linear){let s=e.linear,n=i.linear;o4.forEach(a=>{Object.assign(r.linear,{[a]:n[a]??s[a]})})}if(r.grid={...e.grid},i.grid){let s=e.grid,n=i.grid;l4.forEach(a=>{Object.assign(r.grid,{[a]:n[a]??s[a]})})}if(r.toObject={...e.toObject},i.toObject){let s=e.toObject,n=i.toObject;h4.forEach(a=>{Object.assign(r.toObject,{[a]:n[a]??s[a]})})}if(r.randomnessObject={...e.randomnessObject},i.randomnessObject){let s=e.randomnessObject,n=i.randomnessObject;u4.forEach(a=>{Object.assign(r.randomnessObject,{[a]:n[a]??s[a]})})}return r},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(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}})(uU||(uU={})),dU=["count"],a4=["radius","start","end","position","scale","rotation"],o4=["position","scale","rotation"],l4=["count","size"],h4=["count","position","scale","rotation"],u4=["strength","scale","rotation","position","movement","seed","freqScale"]}),zmt=j(()=>{var t;wl(),(t=cU||(cU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(pU||(pU={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:qi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:qi.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:qi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),Lmt=j(()=>{var t;(t=d4||(d4={})).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}}),Fmt=j(()=>{var t;(t=mU||(mU={})).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"]}),uG=j(()=>{(uv||(uv={})).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]}}),Umt=j(()=>{var t,e;(t=FX||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",FX=t,(e=nO||(nO={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(r,s){return r.flatShading===s.flatShading&&r.side===s.side&&r.wireframe===s.wireframe&&(r.shadowCatcher??!1)===(s.shadowCatcher??!1)}})(aO||(aO={})),(fU||(fU={})).defaultData={...aO.defaultData,...nO.defaultData},(UX||(UX={})).getMaterialData=function(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}}),jmt=j(()=>{var t;(t=c4||(c4={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),KS=j(()=>{var t,e,i,r;Fi(),wl(),jmt(),wl(),(jX||(jX={})).is=function(s){return s==="texture"||s==="video"||s==="color"||s==="depth"||s==="normal"||s==="gradient"||s==="noise"||s==="fresnel"||s==="cavity"||s==="dust"||s==="rainbow"||s==="toon"||s==="outline"||s==="particle"||s==="transmission"||s==="reflection"||s==="matcap"||s==="displace"||s==="pattern"||s==="vertexColor"||s==="light"},(GX||(GX={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(gU||(gU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(WX||(WX={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(r=qX||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",qX=r,HX=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(HX||{}),$X=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))($X||{}),(i=XX||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",XX=i,(e=YX||{})[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",YX=e,(t=KX||{})[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",KX=t,ZX=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(ZX||{}),QX=(s=>(s[s.Circle=0]="Circle",s[s.Ring=1]="Ring",s[s.Polygon=2]="Polygon",s[s.Cross=3]="Cross",s[s.Diamond=4]="Diamond",s[s.Checkerboard=5]="Checkerboard",s[s.Line=6]="Line",s[s.Wave=7]="Wave",s))(QX||{}),O5=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],lG=["wrapping","image","video","name","minFilter","magFilter"],(s=>{s.patch=function(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let u=n.texture;u&&Object.assign(u,o)}},s.defaultColorLayer=function(n){return{...s.defaultData("color"),color:n}},s.defaultData=function(n,a){return n==="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:c4.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:an.fromHex(Jg)};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:{...an.fromHex(6710886),a:1},colorB:{...an.fromHex(6710886),a:1},colorC:{...an.fromHex(16777215),a:1},colorD:{...an.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:qi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:qi.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:qi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:qi.fromHexAndA(0,1),contourColor:qi.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:{...an.fromHex(0),a:1},colorB:{...an.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}}}(n)}})(Hs||(Hs={})),(s=>{function n(a,o="layer1",l="layer2",u=an.fromHex(16777215)){let h=new ye;return h.push({fi:0,data:Hs.defaultData("light",a),id:o}),h.push({fi:1,data:Hs.defaultData("color"),id:l}),{layers:h}}s.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")},s.getHash=function(a){let o="";return a.layers.forEach(l=>{Object.entries(l.data).forEach(([u,h])=>{o+=`${u}${h}`,Array.isArray(h)?h.forEach(d=>o+=`${d}`):typeof h=="object"?Object.values(h).forEach(d=>{o+=typeof d=="number"?`${d.toFixed(4)}`:`${d}`}):o+=`${h}`})}),o},s.defaultEmptyData=function(){return{layers:new ye}},s.defaultData=function(a="layer1",o="layer2"){return n("physical",a,o)},s.withName=function(a,o){return{...a,name:o}},s.defaultTwoLayerData=n,s.defaultColorMaterial=function(a,o,l="layer1",u="layer2"){let h=new ye;return h.push({fi:0,data:Hs.defaultData("light",o),id:l}),h.push({fi:1,data:Hs.defaultColorLayer(a),id:u}),{layers:h}},s.defaultUIObjectMaterial=function(a){let o=Hs.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new ye;return l.push({fi:0,data:o,id:"layer1"}),l.push({fi:1,data:{...Hs.defaultData("transmission"),alpha:1},id:"layer2"}),l.push({fi:2,data:{...Hs.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:l}},s.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Hs.defaultData("texture");Object.assign(h.texture,{image:a});let d=new ye;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Hs.defaultData("light",o),id:u}),{layers:d}},s.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Hs.defaultData("video");Object.assign(h.texture,{video:a});let d=new ye;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Hs.defaultData("light",o),id:u}),{layers:d}}})(cs||(cs={}))}),HMt=j(()=>{M1="Roboto_regular",Bmt="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),$Mt=j(()=>{HMt()}),Gmt=j(()=>{Fi(),(RS||(RS={})).defaultData=function(){return{points:new ye,roundness:0,shapeHoles:[],isClosed:!1}}}),Wmt=j(()=>{Fi(),(p4||(p4={})).defaultData=function(){return{points:new ye,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},mg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(yU||(yU={})).merge=function(t,e){let i={...t};return m4.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},hG={shape:mg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},m4=["depth","offset","angle","twist","startScale","endScale"]}),dG=j(()=>{var t,e;Gmt(),Wmt(),(t=f4||(f4={})).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"},(vU||(vU={})).merge=function(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,yU.merge(s.extrusion,r.extrusion))),s},(e=hc||(hc={})).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:p4.defaultData(),extrusion:hG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:RS.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")},OP=["width","height","depth"]}),qmt=j(()=>{wl(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:an.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let r=e(i);return r==="height"?1:r==="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}})(ia||(ia={}))}),cG=j(()=>{(oO||(oO={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Yp||(Yp={})).defaultData={enabled:!1,mode:"hdri",hdri:oO.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function XMt(t){let e=typeof t=="string"?Number.parseInt(t,10):t;return typeof e=="number"&&Number.isFinite(e)?Math.min(5,Math.max(0,Math.round(e))):3}var g4,dv,lO,hO,uO,cv,dO,bU,_U,JX,z0,Hmt,nn,y4,tY,eY,iY,rY,Bu,W2,v4,b4,vc,Ug,sY,rm,_4,bc,cO,pO,wg,e0,Sg,q2,xU,nY,Na,mO,aY,oY,uc,Zl,pv,wU,$mt=j(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(g4||(g4={})).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}}})()}),pG=j(()=>{var t;qmt(),cG(),$mt(),wl(),(t=dv||(dv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(lO||(lO={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(hO||(hO={})).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}})(uO||(uO={})),(cv||(cv={})).defaultData={usePhysics:!1,gravity:-10},(dO||(dO={})).defaultData={playCamera:n0,gameControlObject:null},(bU||(bU={})).defaultData={backgroundColor:qi.fromHexAndA(Imt,1),postprocessing:g4.defaultData,fog:ia.defaultData,sky:Yp.defaultData,globalPhysics:cv.defaultData,ambient:lO.defaultData,ao:hO.defaultData,shadow:dv.defaultData,publish:dO.defaultData,grading:uO.defaultData}}),YMt=j(()=>{(_U||(_U={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),I5=j(()=>{var t,e,i;Fi(),Vmt(),zmt(),Lmt(),Fmt(),uG(),Umt(),wl(),KS(),dG(),kmt(),hn(),pG(),YMt(),(t=JX||(JX={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=z0||(z0={})).identity={...lU.identity,hiddenMatrix:hv.identity},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,hiddenMatrix:r.hiddenMatrix}},e.merge=function(r,s){return{position:s?.position||r.position,rotation:s?.rotation||r.rotation,pivot:s?.pivot||r.pivot,pivotRotation:s?.pivotRotation||r.pivotRotation,scale:s?.scale||r.scale,hiddenMatrix:s?.hiddenMatrix||r.hiddenMatrix}},e.diff=function(r,s){return pmt({position:dm.isEqual(r.position,s.position)?void 0:s.position,rotation:dm.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:dm.isEqual(r.scale,s.scale)?null:s.scale,hiddenMatrix:hv.isEqual(r.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})},Hmt=["slide","offset"],(nn||(nn={})).defaultData={states:new ye,events:new ye,visible:!0,raycastLock:!1,physics:uv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...z0.identity,cloner:null},(y4||(y4={})).defaultData={type:"Empty",...nn.defaultData},(tY||(tY={})).defaultData={type:"ParticleCollider",..._U.defaultData,...nn.defaultData},(eY||(eY={})).defaultData={type:"Component",...nn.defaultData},(iY||(iY={})).defaultData={type:"Particle",...nn.defaultData,...d4.defaultData},(rY||(rY={})).defaultData={type:"Hair",...nn.defaultData,...mU.defaultData},(Bu||(Bu={})).defaultData={type:"Mesh",...nn.defaultData,...fU.defaultData},(W2||(W2={})).defaultData={...nn.defaultData,...z0.identity,position:yc.DefaultPosition,rotation:yc.DefaultRotation,...yc.defaultData},(r=>{r.defaultData=function(s){return{...nn.defaultData,...pU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(v4||(v4={})),(r=>{function s(n,a,o=0){for(;o<a.length;){let l=n?n[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;n=l.descendants,o+=1}}r.resolveWithDes=s,r.resolve=function(n,a,o=0){let l=s(n,a,o);if(l){let u=Object.keys(l);if(u.length===1&&u[0]==="descendants")return}return l}})(b4||(b4={})),(r=>{function s(n,a){return{...nn.defaultData,...a,component:n,overrides:new As,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=s,r.fromComponentData=function(n){let a=z0.fromObject(n.data);return s(n.id,a)}})(vc||(vc={})),(r=>{r.defaultData={type:"Page",...nn.defaultData,physics:{...uv.defaultData,fusedBody:!1},...bU.defaultData,camera:W2.defaultData,timelines:new Be},r.isUIPage=function(s){return s.uiScene!==void 0}})(Ug||(Ug={})),(i=sY||(sY={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:hv.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:uv.defaultData,states:new ye,events:new ye,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...yc.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",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("RectangleGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("BooleanGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("ShapeBlendGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("TextGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...nn.defaultData,...Bu.defaultData,geometry:hc.defaultData("InputGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(s,n){let a={name:n};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new As}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new As})))):t0.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[c,p]of Object.entries(d.layers)){let{texture:m,...f}=p;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...h,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...h,"layers",c],props:f,type:0};o.push(g)}}}for(let[h,d]of Object.entries(n)){let c=d;if(h!=="name")if(h==="cloner")o.push(...uU.toOps(c,["cloner"]));else if(h==="pathSnapping")o.push({path:[h],props:{slide:c.slide,offset:c.offset},type:0});else if(h==="material")u(["material"],c);else if(h==="materials")for(let[p,m]of Object.entries(c))u(["materials",p],m);else if(l[h]===0){if(h==="geometry"&&c.extrusion!==void 0){let p={path:[h,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[h],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[h]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,z0.merge(a,n)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:n.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??a.pathSnapping?.offset??0})}),t0.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=n;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(s.type==="Mesh")"geometry"in n&&Object.assign(a,{geometry:vU.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let u={...o};return"material"in u&&"material"in l&&l.material&&(u.material=i4(u.material,h=>{if(typeof h!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=h.layers.data(d);p&&Hs.patch(p,c)}}).data),u.materials&&l.materials&&(u.materials=i4(u.materials,h=>{for(let d=0;d<u.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=h[d]?.layers?.data(p);f&&Hs.patch(f,m)}}}).data),u}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:im.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:im.merge(a.cloner,n.cloner)});else if(cU.is(s.type)){let o=n;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=an.clone(o.color))}return a}})(rm||(rm={}))}),mG=j(()=>{(_4||(_4={})).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}}),B5=j(()=>{mG(),wl(),(bc||(bc={})).defaultData={orbitControls:_4.defaultData,playPage:lv,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,r=0;return e<5?r=-30:e<10&&(r=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,r],"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}}),Xmt=j(()=>{var t;(cO||(cO={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(pO||(pO={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=wg||(wg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...cO.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:pO.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),fG=j(()=>{I5(),Fi(),B5(),wl(),hn(),Xmt(),(t=>{function e(i,r){let s=i.scene.objects.get(r);if(s&&s.data.type==="Component")return s;{let n=i.shared.lib.components[r];if(n)return{...n.asset,id:r}}}t.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,r){let s=i.find(n=>n.data.type==="Page"&&n.data.timelines?.[r]!==void 0);return s&&s.data.timelines?.[r]},t.getComponentData=e,t.traverseModuleInstances=function(i,r,s){i.scene.objects.traverseFrom(r,(n,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&s(n,a,o.events)}else s(n,a,a.events)})}})(e0||(e0={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new In;return a.push({fi:1,id:lv,data:{...Ug.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:$a(r,In.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:v4.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:bc.defaultData,styles:wg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new In,publish:bc.defaultData,styles:wg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:bc.defaultData,styles:wg.defaultData()}},t.emptyData=function(){return{objects:new In,publish:{...bc.defaultData},styles:wg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(Sg||(Sg={}))}),Ymt=j(()=>{(q2||(q2={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),gG=j(()=>{var t,e;Fi(),hn(),(t=xU||(xU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ye}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(nY||(nY={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ye,queries:new ye,autoStart:!0}),(i=>{function r(n){return n.textValue!==void 0}function s(n){return typeof n=="boolean"}i.isTextValue=r,i.isNumber=function(n){return typeof n=="number"},i.isBoolean=s,i.typeOfVariable=function(n){return r(n)?"string":s(n)?"boolean":"number"},i.getDisplayedValue=function(n){return i.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(a=>a.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():i.isBoolean(n)?n?"True":"False":i.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}})(Na||(Na={})),(mO||(mO={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(aY||(aY={})).all=[...mO.all,"components"],(oY||(oY={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(uc||(uc={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(e=Zl||(Zl={})).defaultColors=function(){return $a({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Be.prototype)},e.defaultImages=function(){return $a({},Be.prototype)},e.emptyData=function(){return{catelogs:new Be,materials:new Be,images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,variables:new ye,userAPIs:new Be,userWebhooks:new Be,lib:uc.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 r=[0,0,0];return{name:"Time",value:{textValue:r,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:r,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,r){if(r.format==="HH:mm:ss"){let s=Math.floor(i/3600),n=Math.floor((i-3600*s)/60);return{textValue:[s,n,Math.round(i-3600*s-60*n)]}}if(r.format==="mm:ss"){let s=Math.floor(i/60);return{textValue:[s,Math.round(i-60*s)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),KMt=j(()=>{}),Kmt=j(()=>{var t;Fi(),fG(),Ymt(),gG(),(t=pv||(pv={})).defaultData={schema:132,scene:Sg.defaultData,frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",q2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors()}},t.createDefaultData=function(){return ES.deserialize(ES.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:132,scene:Sg.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",q2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors(),images:Zl.defaultImages()}}},t.emptyData=function(){return{schema:132,scene:Sg.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",q2.defaultData),shared:Zl.emptyData()}},t.clipboard2dData=function(){return{schema:132,scene:Sg.emptyData(),frames:new Be,shared:Zl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:uc.defaultData()}}},t.getComponentData=function(e,i){return e0.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let r of i){let s=r.headers;for(let n of s)if(n.data.key.toLowerCase()==="authorization"&&n.data.value!=="")return!0}return!1}}),ZMt=j(()=>{(wU||(wU={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function jg(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function s_(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:r,control2:s}=e??{...Ov.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...em.defaultData},o=new Zmt(r,s,n,a),l=o.solve(1);return()=>u=>o.solve(u)/l}case 8:return()=>r=>Math.floor(r)}}var lY,hY,Gg,DS,Zmt,x4,w4,Qmt=j(()=>{Fi(),wl(),(lY||(lY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new Be}},(hY||(hY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(h,d){let c=[0,0],p=[1,1];if(h?.cubicControls)c=jg(h.cubicControls.control1,c);else switch(h?.type){case 2:case 4:c=[.42,0];break;case 3:case 0:c=[0,0];break;case 1:c=[.25,.1];break;case 7:c=[.25,1]}if(d?.cubicControls)p=jg(d.cubicControls.control2,p);else switch(d?.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:c,control2:p}}function i(h){if(!t.BEZIER_PRESETS.includes(h))return;let d={type:h};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(h,d){return Math.abs(h[0]-d[0])<.001&&Math.abs(h[1]-d[1])<.001}function s(h){let d=t.ROOT_PROPERTY_ORDER.indexOf(h[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(h){return h.layerId??h.path.join(".")}function a(h){let d=h[h.length-1];return DS.includes(d)?d: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 u(h,d,c){return{id:h,data:{id:h,time:c?.time??0,path:d,value:{},layerId:c?.layerId,index:c?.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(d=>{let c=i(d);return c!==void 0&&r(c.control1,h.control1)&&r(c.control2,h.control2)})},t.defaultData=function(h){return{id:h,keyframes:new ye}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=s,t.propertyKey=n,t.groupKeyframes=function(h,d){let c=new Map;for(let p of h){let m=p.data;if(d?.(m))continue;let f=n(m),g=c.get(f);g||(g={id:f,path:m.path,keyframes:[],layerId:m.layerId,index:m.index},c.set(f,g)),m.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,m)=>{let f=s(p.path)-s(m.path);return f!==0?f:(p.index??0)-(m.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(h){let d=new Map;for(let c of h){let p=a(c.path),m=p?c.path.slice(0,-1):c.path,f=o(c),g=d.get(f);g||(g={id:f,path:m,layerId:c.layerId,index:c.index,tracks:[]},d.set(f,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},t.sortedKeyframes=function(h){return[...h].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(h,d){return h.map(({data:c,id:p},m)=>u(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=u,t.createName=function(h){return Object.entries(h).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:s_(3),duration:1e3},opacity:{value:[0,1],easing:s_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:s_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:s_(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:s_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Gg||(Gg={})),DS=["x","y","z"],Zmt=class{constructor(t=1,e=100,i=10,r=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=r,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-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+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}}}),yG=j(()=>{var t;wl(),Fi(),(x4||(x4={})).list=["idle","move","jump","run"],(t=w4||(w4={})).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 ye,move:new ye,jump:new ye,run:new ye},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:qi.fromHexAndA(3728051,1)}}});function sg(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function uY(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,r=e.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...sg(qs(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:s,steps:n,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={...qs(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Zd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function Qd(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=cs.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==As.prototype&&e(s.material)})})}function dY(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("lambert"))}function fO(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 r=[...e.steps];r.push(e.steps[9]);let s={...qs(e),colors:i,steps:r};Object.assign(e,s)}})}function cY(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&fO(r)}):"material"in i&&typeof i.material!="string"&&fO(i.material)}),Object.values(t.shared.materials).forEach(e=>fO(e))}function pY(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 mY(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 fY(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Hs.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function gY(t){Zd(t,fY),Qd(t,fY)}function yY(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function vY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var QMt=j(()=>{KS(),wl(),mG(),I5(),Fi(),B5(),hn(),dt(),dG(),yG(),Xmt(),fG(),uG(),pG()}),Jmt={};function bY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function tft(t){let e=t.geometry;e!==void 0&&nft.has(e.type)&&e.extrusionVersion===void 0&&(e.extrusionVersion=1)}function _Y(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s),d=[o*u,n*h+a*u*l,a*h-n*u*l],c=Math.hypot(e[0],e[1],e[2])||1;return Math.abs((d[0]*e[0]+d[1]*e[1]+d[2]*e[2])/c)}function eft(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*Op)})(t),t.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(s,n){let a=Array.isArray(n)&&n.length>=3&&n.every(u=>typeof u=="number"&&Number.isFinite(u))?n:[0,1,0],o=_Y(s,a),l=_Y(s.map(u=>u*aft),a);return Math.abs(o-l)<1e-6?s.some(u=>Math.abs(u)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*Op)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Op))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*Op),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*Op),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=Op,e.extrusion.twist*=Op),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(qs(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 JMt(t){t.scene.objects.traverse((e,i)=>{})}function t3t(t){let e=t.schema??104;e!==132&&e<130&&(S4(t.asset),t.schema=130)}function fg(t,e){e(t.data);for(let i of t.children)fg(i,e)}function ift(t){let e=t.schema??104;e!==132&&(e<105&&(fg(t.asset,eft),t.schema=105),e<118&&(fg(t.asset,sft),t.schema=118),e<121&&(fg(t.asset,TU),t.schema=121),e<130&&(fg(t.asset,e3t),t.schema=130),e<132&&(fg(t.asset,tft),t.schema=132))}function rft(t,e){Qd(t,e),Zd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function S4(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("phong"))}function e3t(t){"materials"in t?t.materials.forEach(e=>{e!==void 0&&typeof e!="string"&&S4(e)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&S4(t.material)}function sft(t){t.timelineAnimations=$a({},Be.prototype)}function i3t(t){let e=[];return t?(t.forEach((i,r)=>{let{path:s,keyframes:n}=i.data,a=s[0]==="material"?i.id:void 0;n?.length?n.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:s,layerId:a,index:r}})}):e.push(Gg.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ye(...e.map((i,r)=>({...i,fi:r})))):new ye}function r3t(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!oft.includes(r))continue;let s=SU(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let u of l){let h=qt.generateUUID();t.insertBefore(null,[{id:h,data:{...i,id:h,path:[r,u],value:a[u],easing:s3t(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function SU(t){return t===null||typeof t!="object"?[]:DS.filter(e=>e in t)}function s3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function n3t(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function a3t(t){let e=function(n){let a=[];for(let o of Gg.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(h=>SU(h.data.value))),u=l.size?[...l].map(h=>o.keyframes.filter(d=>SU(d.data.value).includes(h))):[o.keyframes];for(let h of u){let d=[...h].sort((c,p)=>c.data.time-p.data.time);for(let c=0;c+1<d.length;c++)a.push({left:d[c],right:d[c+1]})}}return a}([...t.unproxy()]),i=new Map,r=new Set;for(let{left:n,right:a}of e){let o=n.data.easing?.type,l=(o===void 0?void 0:Gg.presetHandles(o))?.control2??(o===5?jg(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let u=i.get(a.id);u?n3t(u,l)||r.add(a.id):i.set(a.id,l)}let s=new Map;for(let{id:n,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Gg.presetHandles(o);l&&s.set(n,l.control1)}for(let{left:n,right:a}of e)r.has(a.id)&&s.delete(n.id);for(let[n,a]of s){let o=t.data(n);!o?.easing||(o.easing.cubicControls={control1:a,control2:jg(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:n,right:a}of e){if(!s.has(n.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:jg(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function xY(t,e){t.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="Page"&&s.timelines)for(let n of Object.values(s.timelines))for(let a of Object.values(n.objectTimelines??{}))e(a.keyframes)})}function TU(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function o3t(t){}function l3t(t){let e=t.schema??0;if(e!==132){if(e>132)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 132). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",132),function(i,r){if(r<1&&(Qd(i,uY),Zd(i,uY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{..._4.defaultData,...qs(s.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(s){function n(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,u]of Object.entries(o))if((O5.includes(l)||typeof u=="boolean")&&delete o[l],l==="texture")for(let[h,d]of Object.entries(u))(lG.includes(h)||typeof d=="boolean")&&delete u[h]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let u=l;u.material?n(u.material):u.materials&&u.materials.forEach(h=>{n(h)})})})}(i),i.schema=3),r<4&&(function(s){s.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(s){s.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(s){s.scene.objects.traverse((n,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),r<7&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&(cY(i),i.schema=9),r<10&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(s){s.scene.environment.ambientLight.softShadows=!1,s.scene.environment.ambientLight.softShadowQuality="low",s.scene.objects.traverse((n,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),s.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(cY(i),i.schema=12),r<13&&(function(s){s.shared.audios=$a({},Be.prototype)}(i),i.schema=13),r<14&&(function(s){let n=s.shared.materials;Object.entries(n).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(n,{[a]:l})}})}(i),i.schema=14),r<15&&(function(s){Object.entries(qs(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(qs(s.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.audios[n]})}(i),i.schema=15),r<16&&(function(s){s.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Qd(i,pY),Zd(i,pY),i.schema=17),r<18&&(Qd(i,dY),Zd(i,dY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...bc.defaultData.settings.video,...qs(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=$a({},Be.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let u=cs.defaultTwoLayerData("phong"),h=typeof l.color=="string"?s.shared.colors[l.color]:l.color;u.layers[1].data.color={r:h.r,g:h.g,b:h.b},u.layers[1].data.alpha=l.alpha;let d=function(m){return m.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(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}(l.font);s.shared.fonts[d]===void 0&&(s.shared.fonts[d]={name:d});let c={name:l.name,...nn.defaultData,...Bu.defaultData,flatShading:!1,wireframe:!1,geometry:{...hc.defaultData("TextGeometry"),width:l.width,height:l.height,font:d,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:u,states:qs(l.states),events:qs(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=qs(s.scene.objects).parent(a);s.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),n.push(a)}}),n.forEach(a=>{s.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(s){let n={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};s.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(n[Number(l.type)])if(Object.assign(l,{type:n[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 ye,move:new ye,jump:new ye}});else{let u=new ye;Object.assign(l,{actions:u}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&u.push({fi:0,id:qt.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((h,d,c)=>{let p={easing:h.easing,duration:h.duration};h.easing===6?Object.assign(p,sg(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let m={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},f={state:h.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ye({fi:0,id:qt.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:qt.generateUUID(),data:f})};u.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,u){let h=new ye,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===u){let f;d.push(p),c.interaction==="play"?f={...sg(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(f={...sg(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&h.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),h.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,h):a.events.insertBefore(null,[{id:qt.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),r<22&&(gY(i),i.schema=22),r<23&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(s){s.scene.objects.traverse((n,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),(r<25||i.shared.videos===void 0)&&(function(s){s.shared.videos=$a({},Be.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(s){s.scene.objects.traverse((n,a)=>{let o=s.scene.objects.unproxy().parent(n);if(o){let l=qs(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=qs(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(s){s.scene.objects.traverse((n,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),r<28&&(gY(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,As.prototype),o.texture&&Object.setPrototypeOf(o.texture,As.prototype)}function a(o){Object.setPrototypeOf(o,As.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(u=>{let h=u;if(h.material){let d=qs(h.material).layers;a(d),h.material.layers=d}if(h.materials)for(let d=0;d<h.materials.length;d++){let c=h.materials[d],p=qs(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=cs.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(s){s.scene.publish.orbitControls.autoZoom===void 0&&(s.scene.publish.orbitControls.autoZoom=!1),s.scene.objects.traverse((n,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),r<33&&(function(s){s.scene.objects.traverse((n,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),r<34&&(function(s){s.scene.publish.mouseEventTarget===void 0&&(s.scene.publish.mouseEventTarget="canvas"),s.scene.publish.settings.web.hint===void 0&&(s.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(s){let{video:n}=s.scene.publish.settings;n.format==="gif"&&n.fps>48&&(n.fps=15)}(i),i.schema=35),r<36&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(s){let n=s.scene.environment.usePhysics;s.scene.objects.traverse((a,o)=>{n&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Qd(i,mY),Zd(i,mY),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=w4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=wg.defaultData())}(i),i.schema=40),r<41&&(function(s){s.scene.environment.ambientLight.occlusion===void 0&&(s.scene.environment.ambientLight.occlusion=!1),s.scene.environment.ambientLight.aoFullRes===void 0&&(s.scene.environment.ambientLight.aoFullRes=!1),s.scene.environment.ambientLight.radius===void 0&&(s.scene.environment.ambientLight.radius=256),s.scene.environment.ambientLight.bias===void 0&&(s.scene.environment.ambientLight.bias=.5),s.scene.environment.ambientLight.aoColor===void 0&&(s.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Qd(s,yY),Zd(s,yY)}(i),i.schema=41),r<42&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new ye})})})}(i),i.schema=42),r<43&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Qd(i,vY),Zd(i,vY),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=n0);let s=qs(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=lv,n.insertBefore(null,null,[{id:lv,data:{...Ug.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:sg(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:sg(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...cv.defaultData,...sg(i.scene.environment,"usePhysics","gravity")},camera:qs(i.scene.ownerCamera)??Ug.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==Sg.TRASH_CAN_ID&&n.move(lv,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,u)=>{u.type==="DirectionalLight"?(u.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):u.type==="SpotLight"&&(u.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(u.physics===void 0||u.physics===null)&&u.type!=="Instance"&&(u.physics={},Object.assign(u.physics,uv.defaultData)),u.physics!==void 0&&u.physics!==null&&(u.physics.enabled=u.collision??"visibility",delete u.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=bc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(Qd(t,bY),Zd(t,bY),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new Be,t.shared.lib=uc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=$a({},Be.prototype)}(t),t.scene.objects.traverse((i,r)=>{eft(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))ift(i);e<106&&(function(i){let r=qs(i.shared.variables);i.shared.variables=$a(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ye.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=uc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.particles=uc.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Particle"&&typeof s.renderMaterial.size=="number"&&Object.assign(s.renderMaterial,{size:[s.renderMaterial.size,s.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,r)=>{(function(s){Array.isArray(qs(s.events))&&s.events?.forEach(n=>{"disabled"in n||(n.disabled=!1),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress")&&(n.mode=n.mode||"Object")})})(r)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Page"&&(s.postprocessing.depthOfField.focusDistance=100,s.postprocessing.depthOfField.focalLength=20,s.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((r,s)=>{Array.isArray(qs(s.events))!==!1&&s.events?.forEach(n=>{let a=n.runMode;n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="Collision"||n.type==="Trigger"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):n.type==="MouseHover"||n.type==="MousePress"||n.type==="KeyPress"?n.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):n.type==="GameControl"?(delete n.actions,Object.keys(n.gameActions).forEach(o=>{n.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):n.type==="DragDrop"?(delete n.actions,n.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),n.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):n.type==="Resize"?(delete n.actions,n.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):n.type==="Start"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="VariableChange"||n.type==="Scroll"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="Conditional"&&(delete n.actions,n.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),n.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||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=$a({},Be.prototype),i.shared.userWebhooks=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.userAPIs=uc.defaultData().userAPIs,i.shared.lib.userWebhooks=uc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=bc.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=$a({},Be.prototype),t.scene.objects.traverse((i,r)=>{sft(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=pv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=pv.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,r)=>{TU(r),r.type==="Page"&&r.camera!==void 0&&TU(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=pv.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=Yp.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(typeof s.exposure=="number"&&(s.exposure=Math.round(s.exposure/5e-4*1e4)/1e4),s.lighting===void 0&&(s.lighting=Yp.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingIntensity===void 0&&(s.lightingIntensity=Yp.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(s.mode===void 0&&(s.mode="physical"),s.hdri===void 0?s.hdri={...Yp.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=Yp.defaultData.hdri.blur),Array.isArray(s.hdri.rotation)&&(s.hdri.rotation=s.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s?.hdri!==void 0&&s.hdri.showBackground===void 0&&(s.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingQuality===void 0&&(s.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=Ug.defaultData.camera);let s=r.camera;s.far=1e5,s.perspective?s.perspective.near=70:s.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(rft(t,S4),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.states;if(!n)return;let a=s.timelineAnimations,o=[];n.forEach((l,u)=>{(l.isAnimation||a?.[u])&&o.push(u)}),o.forEach(l=>n.delete(l))})}(t),function(i){let r=i.shared,s=r.timelineAnimations;if(!s)return;let n=i.scene.objects,a=n.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(s)){let u=$a({},Be.prototype),h=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(h=Math.max(h,g.to??0),d=d||Boolean(g.loop),u[m]={id:m,keyframes:i3t(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=$a({},Be.prototype)))[o]={id:o,name:l.name,duration:h||5,...d?{loop:d}:{},objectTimelines:u})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),xY(t,r3t),xY(t,a3t),t.schema=131),e<132&&(t.scene.objects.traverse((i,r)=>tft(r)),t.schema=132)}}XS(Jmt,{updateAllMaterials:()=>rft,updateDocumentSchema:()=>l3t,updateLibSchema:()=>o3t,updateMaterialSchema:()=>t3t,updateObjectStateRec:()=>fg,updateObjectsSchema:()=>ift,updateTextValues:()=>JMt});var nft,Op,aft,oft,wY,_M,gO,SY,xM,Tg,n_,L0,wM,yO,IP,vO,bO,TY,BP,_O,Wg,MU,V5=j(()=>{dt(),Kmt(),Fi(),Qmt(),QMt(),B5(),KS(),hn(),gG(),I5(),cG(),nft=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),Op=180/Math.PI,aft=Math.PI/180,oft=["position","rotation","scale","shape size"]}),h3t=j(()=>{var t,e,i;wl(),Fi(),hn(),(wY||(wY={})).is=function(r){return!0},(t=_M||(_M={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}},t.diff=function(r,s){return pmt({position:qu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:qu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&qu.isEqual(r.shear,s.shear)?void 0:s.shear})},(gO||(gO={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(SY||(SY={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(xM||(xM={})).defaultData={opacity:1,fill:{color:qi.fromHexAndA(Jg,1),enabled:!0},stroke:{color:qi.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:qi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:qi.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=Tg||(Tg={})).newEmpty=function(r,s){return{name:s}},e.patch=function(r,s){if(s===void 0)return r;let n={...r};return Object.assign(n,_M.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let h of u)h in l&&h in o&&o[h]!==void 0&&Object.assign(l,{[h]:o[h]});return l}(n,s),n=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}(n,s),n},e.toOps=function(r,s){let n,a=[];for(let[o,l]of Object.entries(s))o!=="name"&&(n===void 0&&(n={path:[],props:{},type:0},a.push(n)),n.props[o]=l);return a},(n_||(n_={})).defaultData={..._M.defaultData,...gO.defaultData,states:new ye,events:new ye,visible:!0,raycastLock:!1},(L0||(L0={})).defaultData={...n_.defaultData,...xM.defaultData},(wM||(wM={})).defaultData={cornerRadius:[0,0,0,0]},(yO||(yO={})).defaultData={...L0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(IP||(IP={})).defaultData={...L0.defaultData,...wM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(vO||(vO={})).defaultData={...L0.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"},(bO||(bO={})).defaultData={...L0.defaultData,type:"path2d",path:"",name:"Path"},(TY||(TY={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(BP||(BP={})).defaultData={...n_.defaultData,name:"Group",type:"group2d"},(_O||(_O={})).defaultData=()=>({...n_.defaultData,...wM.defaultData,...xM.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:qi.fromHexAndA(4737101,1),enabled:!0},stroke:{color:qi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(s){switch(s){case"rectangle2d":case"vector2d":return{...IP.defaultData};case"ellipse2d":return{...yO.defaultData};case"text2d":return{...vO.defaultData};case"path2d":return{...bO.defaultData};case"frame2d":return{..._O.defaultData()};case"group2d":return{...BP.defaultData}}},r.getPivot=function(s){return"width"in s&&"height"in s?[typeof s.width=="number"?.5*s.width:0,typeof s.height=="number"?.5*s.height:0]:[0,0]},r.isResizeable=function(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"},r.isAutoLayoutable=function(s){return s.type==="frame2d"&&s.autoLayout!==void 0},r.hasCorners=function(s){return s.type==="rectangle2d"||s.type==="frame2d"}})(Wg||(Wg={})),(i=MU||(MU={})).defaultData={name:"UI",type:"scene2d",objects:new In},i.emptyData=function(){return{type:"scene2d",objects:new In}}}),u3t=j(()=>{WMt(),qMt(),Vmt(),kmt(),Kmt(),Omt(),ZMt(),jmt(),qmt(),cG(),V5(),Ymt(),dG(),uG(),zmt(),KS(),Umt(),$mt(),wl(),B5(),I5(),mG(),Wmt(),gG(),fG(),$Mt(),Gmt(),yG(),pG(),Lmt(),Fmt(),h3t()});function Mg(t,e=!1){let i=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),n={},a={},o=t[0].morphTargetsRelative,l=new ge,u=0;for(let h=0;h<t.length;++h){let d=t[h],c=0;if(i!==(d.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 d.attributes){if(!r.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;n[p]===void 0&&(n[p]=[]),n[p].push(d.attributes[p]),c++}if(c!==r.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!==d.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 d.morphAttributes){if(!s.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(d.morphAttributes[p])}if(e){let p;if(i)p=d.index.count;else{if(d.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=d.attributes.position.count}l.addGroup(u,p,h),u+=p}}if(i){let h=0,d=[];for(let c=0;c<t.length;++c){let p=t[c].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+h);h+=t[c].attributes.position.count}l.setIndex(d)}for(let h in n){let d=MY(n[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(let h in a){let d=a[h][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[h].length;++f)p.push(a[h][f][c]);let m=MY(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}}return l}function MY(t){let e,i,r,s=-1,n=0;for(let u=0;u<t.length;++u){let h=t[u];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(r===void 0&&(r=h.normalized),r!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=h.gpuType),s!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=h.count*i}let a=new e(n),o=new _e(a,i,r),l=0;for(let u=0;u<t.length;++u){let h=t[u];if(h.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=h.count;c<p;c++)for(let m=0;m<i;m++){let f=h.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(h.array,l);l+=h.count*i}return s!==void 0&&(o.gpuType=s),o}var ZS=j(()=>{dt()});function lft(t){let e=t.points.length/7,i=new ye;for(let r=0;r<e;r++){let s=7*r,n=t.points[s+0],a=t.points[s+1],o=t.points[s+2],l=t.points[s+3],u=t.points[s+4],h=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:qt.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[u,h]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>lft(r))??[]}}function hft(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:u}=a,h=u?.groups,d=u?.attributes??{},c=u?.morphAttributes??{},p=u?.interleavedBuffers,m=u?.arrayBuffers,f=u?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(y){let v=1/0,b=1/0,_=1/0,x=-1/0,S=-1/0,w=-1/0;for(let T=0;T<y.length;T+=3){let C=y[T],M=y[T+1],A=y[T+2];v=Math.min(v,C),b=Math.min(b,M),_=Math.min(_,A),x=Math.max(x,C),S=Math.max(S,M),w=Math.max(w,A)}return{width:x-v,height:S-b,depth:w-_}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:m},...o===void 0?{}:o,type:"NonParametricGeometry"};return f!==void 0&&Object.assign(g.data,{index:f}),h!==void 0&&Object.assign(g.data,{groups:h.map(y=>({...y,materialIndex:y.materialIndex??0}))}),g}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let u=new ge;if(o?.position===void 0||o?.faceMap===void 0)return null;let h=o.position.array,d=o.faceMap.array,c=r.data.index.array;u.setAttribute("position",new fe(h,3)),u.setIndex(new hm(c,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let b={},_=y.getIndex(),x=y.getAttribute("position"),S=_?_.count:x.count,w=0,T=Object.keys(y.attributes),C={},M={},A=[],R=["getX","getY","getZ","getW"],O=["setX","setY","setZ","setW"];for(let V=0,H=T.length;V<H;V++){let W=T[V],X=y.attributes[W];C[W]=new X.constructor(new X.array.constructor(X.count*X.itemSize),X.itemSize,X.normalized);let st=y.morphAttributes[W];st&&(M[W]||(M[W]=[]),st.forEach((nt,xt)=>{let pt=new nt.array.constructor(nt.count*nt.itemSize);M[W][xt]=new nt.constructor(pt,nt.itemSize,nt.normalized)}))}let N=.5*v,B=Math.log10(1/v),L=Math.pow(10,B),z=N*L;for(let V=0;V<S;V++){let H=_?_.getX(V):V,W="";for(let X=0,st=T.length;X<st;X++){let nt=T[X],xt=y.getAttribute(nt),pt=xt.itemSize;for(let K=0;K<pt;K++)W+=~~(xt[R[K]](H)*L+z)+","}if(W in b)A.push(b[W]);else{for(let X=0,st=T.length;X<st;X++){let nt=T[X],xt=y.getAttribute(nt),pt=y.morphAttributes[nt],K=xt.itemSize,ct=C[nt],St=M[nt];for(let wt=0;wt<K;wt++){let Tt=R[wt],yt=O[wt];if(ct[yt](w,xt[Tt](H)),pt)for(let Ot=0,Ft=pt.length;Ot<Ft;Ot++)St[Ot][yt](w,pt[Ot][Tt](H))}}b[W]=w,A.push(w),w++}}let k=y.clone();for(let V in y.attributes){let H=C[V];if(k.setAttribute(V,new H.constructor(H.array.slice(0,w*H.itemSize),H.itemSize,H.normalized)),V in M)for(let W=0;W<M[V].length;W++){let X=M[V][W];k.morphAttributes[V][W]=new X.constructor(X.array.slice(0,w*X.itemSize),X.itemSize,X.normalized)}}return k.setIndex(A),k}(u),m=[],f=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let y=0,v=d.length;y<v;)d[y]===d[y+1]?(f[d[y]]++,m.push(...new Set(g.slice(3*y,3*y+6))),y+=2):(m.push(...g.slice(3*y,3*y+3)),y++);o.indexWASM={array:m},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:f}}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,...d3t(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let u in o)u==="positionWASM"?l[u]=new Float32Array(o[u].array):u==="indexWASM"?l[u]=new Int32Array(o[u].array):u==="verticesPerFaceWASM"&&(l[u]=new Int8Array(o[u].array));return l.scaleBaked=[1,1,1],l}let s=e.type,n=e.parameters;return s==="VectorGeometry"?(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,width:100,height:100,shape:lft(e.shape),type:s}):s==="LatheGeometry"?{...e.parameters,type:s,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,type:s})}function d3t(t){return AU.setFromArray(t),AU.getSize($w),{width:$w.x,height:$w.y,depth:$w.z}}var AU,$w,xO,c3t=j(()=>{Fi(),dt(),ZS(),new _t,new Se,new Qi,new P,new P,AU=new pr,$w=new P}),p3t=j(()=>{var t;(t=xO||{}).view="view",t.edit="edit",((xO=t)||(xO={})).canWrite=function(e){return e!=="view"},class extends Error{constructor(e,i){super(`This is a ${e.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=e,this.expected=i,this.name="DocumentKindMismatchError"}}}),uft,CU,VP,dft,cft,Xv,a_,SM,wO,Yv,AY,SO,CY,TO,Iv,Hc,$c,dd,MO,EY,PY,AO,EU,_c,pft=j(()=>{p3t()}),m3t=j(()=>{}),f3t=j(()=>{Fi(),V5(),pft()}),g3t=j(()=>{KS(),[...O5],new Set(lG)}),ke=j(()=>{u3t(),m3t(),KMt(),V5(),f3t(),pft(),Qmt(),g3t(),yG(),Fi()}),k5=j(()=>{uft=[3,4,8,9],CU=5,VP=3,dft=32,cft=.98}),QS=j(()=>{dt(),Xv=t=>{var e;return(e=class extends t{}).geometryHelper=new Zh(30,30,30),e}}),JS=j(()=>{dt(),a_=new mc,SM=new ta,wO=new _t,Yv=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),SM.copy(a.boundingSphere),SM.applyMatrix4(o),i.ray.intersectsSphere(SM)===!1||(wO.copy(o).invert(),a_.copy(i.ray).applyMatrix4(wO),a.boundingBox!==null&&a_.intersectsBox(a.boundingBox)===!1))return;let l,u,h,d,c,p,m=a.index,f=a.attributes.position,g=a.drawRange;if(s===!1){for(c=Math.max(0,g.start),p=Math.min(m.count,g.start+g.count);c<p;c+=3)if(u=m.getX(c),h=m.getX(c+1),d=m.getX(c+2),l=y(t,i,a_,f,u,h,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new P,_=new P,x=new P,S=new P,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T;for(let M=Math.max(0,g.start),A=Math.min(v.count,g.start+g.count)-1;M<A;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),a_.distanceSqToSegment(b,_,S,x)>C)continue;S.applyMatrix4(n.matrixWorld);let R=i.ray.origin.distanceTo(S);R<i.near||R>i.far||r.push({distance:R,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let C=new P,M=new P,A=new P,R=new P,O=new P;if(C.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),A.fromBufferAttribute(x,T),_.intersectTriangle(C,M,A,!1,R)===null)return null;O.copy(R),O.applyMatrix4(v.matrixWorld);let N=b.ray.origin.distanceTo(O);return N<b.near||N>b.far?null:{faceIndex:1,distance:N,point:O.clone(),object:v}}}}),z5=j(()=>{dt(),QS(),JS(),AY=new P(1,1,1),SO=new P,CY=new P,TO=new Se,Iv=class extends Xv(nmt){constructor(t,e=15){super(e),this.object=t,this.dummy=new $v,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){Yv(this.object,Iv.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(SO,TO,CY),this.matrix.compose(SO,TO,AY),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),y3t=j(()=>{dt(),Hc=new P,$c=new P,dd=new _t,MO=[new P(-1,1,1),new P(-1,-1,1),new P(1,-1,1),new P(1,1,1),new P(-1,1,-1),new P(-1,-1,-1),new P(1,-1,-1),new P(1,1,-1)],EY=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],PY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],AO=(t,e,i)=>{t.updateEntityBoxSize(Hc,$c),dd.copy(e).multiply(t.matrixWorld),$c.x===0&&$c.y===0&&$c.z===0?i.push(new P(Hc.x,Hc.y,Hc.z).applyMatrix4(dd)):MO.forEach(r=>{i.push(r.clone().multiply($c).add(Hc).applyMatrix4(dd))})},EU=class extends pr{constructor(){super(...arguments),this.matrix=new _t,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 _t().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let r=[];if(i===!0){let s=[];t.traverseEntity(n=>{if(n.visible||n.cloner&&n.data.visible){if(!("geometry"in n))return dd.copy(e).multiply(n.matrixWorld),void s.push(new P().applyMatrix4(dd));AO(n,e,r)}}),r.length===0&&r.push(...s)}else AO(t,e,r);return this.setFromPoints(r)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(dd.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize($c).multiplyScalar(.5),this.getCenter(Hc),dd.copy(this.matrix).setPosition(Hc),this.vertices=MO.map(t=>t.clone().multiply($c).applyMatrix4(dd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=EY.map(([t,e])=>new yl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=PY.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),T4=j(()=>{_c={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function H2(t){return t?.isParticleSystem===!0}function i0(t){return t?.isHairSystem===!0}function Ec(t){return t?.isShapeBlendEntity===!0}function L5(t){return t?.isPathObject===!0}function jo(t){return t?.isObject2D===!0}function Ya(t){return t?.isUIObject===!0}function $1(t){return t?.isCloner===!0}function Ag(t){return t?.isClone===!0}function kP(t){return t?.isComponentObject===!0}var ns=j(()=>{});function Or(t){vG.add(t)}function Nn(t,e){let i=`${t}:${e}`;DU.has(i)||DU.add(i)}function M4(t,e){bG.set(t,e)}function CO(t){return bG.get(t)}function Kv(t,e){_G.set(t,e)}function EO(t){return _G.get(t)}function PU(t,e){xG.set(t,e)}function mft(t){return xG.get(t)}function RU(){return F5}var vG,DU,bG,_G,xG,F5,A4,Ii=j(()=>{vG=new Set,DU=new Set,bG=new Map,_G=new Map,xG=new Map,F5=null,A4=null});function fft(t){let e=t.elements;Uh.set(e[0],e[1],e[2]),jh.set(e[4],e[5],e[6]),ku.set(e[8],e[9],e[10])}function gft(){let t=Math.max(Uh.lengthSq(),jh.lengthSq(),ku.lengthSq());Uh.lengthSq()>Xw*t?ml.copy(Uh).normalize():ml.set(1,0,0),fl.crossVectors(ku,ml),fl.lengthSq()<=Xw*t&&(fl.copy(jh).addScaledVector(ml,-jh.dot(ml)),fl.lengthSq()<=Xw*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=Xw&&e.set(0,1,0).cross(i),e.normalize()}(fl,ml)),fl.normalize(),Cg.crossVectors(ml,fl)}var Uh,jh,ku,ml,fl,Cg,yft,Xw,Yw,TM,Eg,U5,vft=j(()=>{dt(),Uh=new P,jh=new P,ku=new P,ml=new P,fl=new P,Cg=new P,yft=new _t,Xw=1e-12,Yw=.01}),tT=j(()=>{dt(),vft(),TM=new _t,(Eg||(Eg={})).is=function(t){return t&&t.__isSPEObject},U5=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new _t,this.copyPreviousMatrix=!0,this.hiddenMatrix=new _t,this.pivotMatrix=new _t,this.matrixWorldRigid=new _t,this.shearScale=new _t,this.shearScaleInv=new _t}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(TM.copy(this.parent.matrixWorld).invert()),e.premultiply(TM.copy(this.hiddenMatrix).invert()),e.multiply(TM.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof dr&&(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 r=this.parent;if(e&&r!==null&&r.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 s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let r of this.children)Eg.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Eg.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(e,i,r){return fft(e),gft(),i.makeBasis(ml,fl,Cg),r.set(ml.dot(Uh),ml.dot(jh),ml.dot(ku),0,fl.dot(Uh),fl.dot(jh),fl.dot(ku),0,Cg.dot(Uh),Cg.dot(jh),Cg.dot(ku),0,0,0,0,1),function(){let s=Uh.length(),n=jh.length(),a=ku.length(),o=Math.max(s,n,a);if(o-s>Yw||o-n>Yw||o-a>Yw)return!0;let l=Yw*o*o;return Math.abs(Uh.dot(jh))>l||Math.abs(Uh.dot(ku))>l||Math.abs(jh.dot(ku))>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 r=new _t().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),r.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof _t?e.hiddenMatrix.premultiply(r):e.applyMatrix4(r),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,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function RY(t,e,i){return Kp.subVectors(e,t),NS.subVectors(e,i),Kp.cross(NS).length()<=$2}function bft(t){let e=IU.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(r){let s=r.points,n=[s[0]],a=[new P(...s[0].data.position)];ng.copy(a[0]);for(let y=0;y<s.length-1;y++)Kp.fromArray(s[y].data.position),NS.fromArray(s[y+1].data.position),A1.subVectors(Kp,ng),C1.subVectors(Kp,NS),A1.cross(C1).length()>$2&&(n.push(s[y]),a.push(new P().copy(Kp)),ng.copy(Kp));let o=s[s.length-1];n.push(o),a.push(new P(...o.data.position));let l=r.isClosed,u=n.length-(l?0:1),h=n.length,d=[],c=[];for(let y=0;y<h;y++){let v=n[y].data;d.push(new P(...v.controlPrevious.position)),c.push(new P(...v.controlNext.position))}let p=[];for(let y=0;y<u;y++){let v=y===h-1?0:y+1;p.push(RY(a[y],c[y],a[v])&&RY(a[y],d[v],a[v]))}let m=[];for(let y=0;y<h;y++){let v=n[y].data,b=a[y],_={position:b,prevDir:void 0,nextDir:void 0,controlPrevious:d[y],controlNext:c[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(m.push(_),v.roundness===0||!l&&(y===0||y===h-1))continue;let x=l&&y==0?h-1:y-1,S=l&&y==h-1?0:y+1,w=new P().subVectors(a[x],b).normalize(),T=new P().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let C=p[l&&y===0?h-1:y-1],M=p[y];if(C&&M){ag.addVectors(w,T).normalize();let A=ng.crossVectors(ag,w).length()/w.dot(ag);_.tan=A,_.removedLength=v.roundness/A}}for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v];if(b.removedLength!==0||_.removedLength!==0){let x=b.position.distanceTo(_.position);b.removedLength=Math.min(b.removedLength,x/2),_.removedLength=Math.min(_.removedLength,x/2)}}let f=new Array(2*h).fill(null);for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v],x=null;if(p[y]){let S=b.position.clone(),w=_.position.clone();(b.removedLength!==0||_.removedLength!==0)&&(b.nextDir&&S.add(ng.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(ng.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>$2&&(x=new z2(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>$2&&(x=new z2(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<h;y++){let v=m[y];if(v.removedLength===0)continue;let b=v.position,_=v.prevDir.clone().multiplyScalar(v.removedLength).add(b),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(b),S=v.tan*v.removedLength;ag.addVectors(v.prevDir,v.nextDir).normalize(),A1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;OU.copy(ag).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(A1),zP.copy(ag).multiplyScalar(-S).add(OU);let T=b.distanceTo(zP)/b.distanceTo(A1);C1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),NU.copy(C1).lerp(zP,2);let C=_.clone().lerp(C1,4/3),M=x.clone().lerp(NU,4/3);f[2*y]=new z2(_,C,M,x)}let g=new _ft;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return IU.set(t.points,{isClosed:t.isClosed,curve:i}),i}var _ft,$2,Kp,NS,ng,ag,A1,zP,C1,NU,OU,IU,E1,BU,LP,xft,wft,Sft,Mi,Vu,DY,NY,o_,PO,MM,RO,DO,j5,VU,a0,zu,Tft=j(()=>{dt(),_ft=class extends E8{constructor(){super()}getPoints(t=12){let e,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],u=Math.ceil(t*l/s),h=o.getPoints(u);for(let d=0;d<h.length;d++){let c=h[d];e&&e.equals(c)||(i.push(c),e=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},$2=.001,Kp=new P,NS=new P,ng=new P,ag=new P,A1=new P,zP=new P,C1=new P,NU=new P,OU=new P,IU=new WeakMap}),v3t=j(()=>{dt(),E1=new _t,BU=new Se,LP=new Se,xft=new Qi,wft=new P,Sft=new P(0,1,0)}),vo=j(()=>{dt(),ke(),y3t(),Fi(),T4(),ns(),Ii(),tT(),Tft(),v3t(),ir(),(Mi||(Mi={})).is=function(t){return t&&t.__isEntity},Vu=t=>Mi.is(t),DY={type:"completeState",isfromEntity:!0},NY=["x","y","z"],o_=new P,PO=new P(1,1,1),MM=new Se,RO=new Qi,DO=new _t,j5=t=>class extends U5(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 EU,this._recursiveBBox=new EU,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(Mi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Mi.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(!Mi.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,r=!1){if(this.data.states.length!==0||r){for(let s of this.data.states)rm.toOps(this.data,s.data).forEach(n=>{let a=e4.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let s=this.data.states.data(e);s&&(this.dataPatched=rm.patch(this.data,s),rm.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&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=>{Vu(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(r=>{r.uuid===e&&(i=r)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,r=i.indexOf(this)+1;if(Mi.is(i[r]))return i[r];if(Mi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Mi.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,r=this;for(;r!==e;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Vu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{Mi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Vu(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=>Vu(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),G8({position:this.position.toArray(),rotation:[this.rotation.x*qt.RAD2DEG,this.rotation.y*qt.RAD2DEG,this.rotation.z*qt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,r){return i[e].map((s,n)=>r?.shared.getVariable(s,[this.uuid,e,NY[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(o_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(qt.DEG2RAD),this.rotation.setFromVector3(o_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??hv.identity)),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(o_.fromArray(e.pivot).negate(),MM.setFromEuler(RO.fromArray(e.pivotRotation.map(s=>s*qt.DEG2RAD))).invert(),PO);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 s=o_.setFromMatrixPosition(this.pivotMatrix);MM.setFromEuler(RO.fromArray(e.pivotRotation.map(n=>n*qt.DEG2RAD))).invert(),this.pivotMatrix.compose(s,MM,PO)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}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)Mi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Mi.is(e)&&e.disposeRecursively()})}toState(e=[]){return G8({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,r,s){let n=this.data;this.data=i;let a=e,o=er(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let u={...e.props};if(delete u.name,Object.values(e.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let d=Dn.zoom(h,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(u[c]=d[c])}}a={...e,props:u,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,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:h,...d}=l;l=d}let u=Dn.removeOverridden(e.path,e.props,l);a={...e,props:u}}}if(this.updateByPatchedOpBase(a,rm.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),er(e.path,["overrides"])){let l=[],u=[...e.path];for(l.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)l.push(u[1]),u.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 d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[h],d.updateState(um.apply(d.component.data,d.overrideData),r))}}else{let h=r.scene.findInstance([this.uuid,...l]);if(h){let d=Dn.zoom(h.component.data,u);if((e={...e,path:u}).type===0){let c=e.props;if(d)for(let[p,m]of Object.entries(e.props))m===void 0&&(c===e.props&&(c={...e.props}),c[p]=d[p]);e={...e,props:c}}h.overrideData=b4.resolve(i.overrides,l),h.updateByOp(e,ea.applySimple(h.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let u;for(let h of vc.rootOverrideProps)h in e.props&&(u===void 0&&(u={}),u[h]=e.props[h]);u&&(l={...e,props:u})}else for(let u of vc.rootOverrideProps)if(er(e.path,[u])){l=e;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let h=um.filterOp(u.overrideData,l);h&&u.updateByOp(h,ea.applySimple(u.data,h),r,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let h=um.filterOp(u.overrideData,e);if(h){let d;d=n===u.data&&e===h?i:ea.applySimple(u.data,h),u.updateByOp(h,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!t0.is(e.props.type)&&_c.changeEntityProptotype(this,i,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){_c.changeEntityProptotype(this,i,r);for(let s of this.children)Mi.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(e,i,r)}updateByPatchedOp(e,i,r){if(e.path.length===0&&e.type===0?this.updateState(e.props,r):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,r),e.path[0]==="morphTargetInfluences"&&e.type===0){let s=i.morphTargetInfluences.get(e.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",s]))}if(er(e.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),er(e.path,["cloner"])!==null){let s=ea.drop(e,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.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,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,n=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=bft(o.geometry.path),u=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),h=null;try{h=l.curves.length?l.getPointAt(u):null}catch{}if(h===null)return;a.updateMatrixWorld();let d=this.parent?DO.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):DO.copy(this.hiddenMatrix),c=function(p,m,f,g){BU.setFromRotationMatrix(E1.extractRotation(g));let y=p.clone().applyMatrix4(E1.copy(g).invert().multiply(f));if(m===null)LP.setFromRotationMatrix(E1.extractRotation(f));else{let v=m.clone().applyMatrix4(E1.extractRotation(f));LP.setFromRotationMatrix(E1.lookAt(wft.set(0,0,0),v,Sft))}return{position:y,rotation:new P().setFromEuler(xft.setFromQuaternion(BU.invert().multiply(LP))).multiplyScalar(qt.RAD2DEG)}}(h,n==="tangential"?l.getTangentAt(u):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(DY)})}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(r=>{if(r.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=>$1(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(_c.Cloner===null)return void Nn("cloners","a cloner");this.cloner=new _c.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"})}}}),o0=j(()=>{dt(),vo(),(VU||(VU={})).is=t=>"objectHelper"in t,a0=(t,e)=>class extends j5(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof TS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Zh?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof TS&&(r.visible=!1)}}}}),G5=j(()=>{dt(),z5(),o0(),zu=class extends a0($v,Iv){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 hh(t,e,i,r,s,n,a){Kw.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let u=0,h=o.length;u<h;u++)l.setXYZ(o[u],Kw.x,Kw.y,Kw.z)}}var Kw,Xo,OY,Mft,b3t=j(()=>{dt(),QS(),JS(),Kw=new P,Xo=new xg,OY=class extends x1{constructor(t){let e=new ge,i=new zh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new ae(15711266),o=new ae(15711266),l=new ae(2857471);function u(d,c,p){h(d,p),h(c,p)}function h(d,c){r.push(0,0,0),s.push(c.r,c.g,c.b),n[d]===void 0&&(n[d]=[]),n[d].push(r.length/3-1)}u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",o),u("p","n2",o),u("p","n3",o),u("p","n4",o),u("u1","u2",l),u("u2","u3",l),u("u3","u1",l),e.setAttribute("position",new fe(r,3)),e.setAttribute("color",new fe(s,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=n,this.update()}update(){let t=this.geometry,e=this.pointMap;Xo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;hh("n1",e,t,Xo,-1,-1,i),hh("n2",e,t,Xo,1,-1,i),hh("n3",e,t,Xo,-1,1,i),hh("n4",e,t,Xo,1,1,i);let r=i;hh("f1",e,t,Xo,-1,-1,r),hh("f2",e,t,Xo,1,-1,r),hh("f3",e,t,Xo,-1,1,r),hh("f4",e,t,Xo,1,1,r);let s=r;hh("u1",e,t,Xo,.35,1.1,s),hh("u2",e,t,Xo,-.35,1.1,s),hh("u3",e,t,Xo,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},Mft=class extends Xv(OY){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){Yv(this.object,this.geometry,t,e,!0)}}});function IY(t){return 1-Math.pow(1-t,3)}var ef,AM,CM,EM,F0,PM,uu,ks,Qh=j(()=>{dt(),b3t(),ke(),o0(),ir(),ef=new P,AM=new P,CM=new Se,EM=new P,F0=new P,PM=new P,uu=class extends a0(xg,Mft){constructor(t="",e={...W2.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=yc.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let s=this._projectionTransition;if(s===void 0)return;if(this.disposed)return void this._endProjectionTransition();s.raf=requestAnimationFrame(this._tickProjectionTransition);let n=uu.projectionTransitionRequestRender??s.requestRender;this.updateProjectionMatrix(),n?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new _t,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Dv(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new kh(45,i/r,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=uu.projectionTransitionsEnabled;uu.projectionTransitionsEnabled=!1;try{return t()}finally{uu.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 P(t,e,i)),super.lookAt(t),this.getWorldPosition(ef),this.targetOffset=ef.distanceTo(t)}getTarget(t=new P){return this.getWorldDirection(AM),this.getWorldPosition(ef),AM.multiplyScalar(this.targetOffset),t.copy(ef).add(AM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(ef),ef.distanceTo(t)}updateUp(){this.getWorldQuaternion(CM),EM.set(0,0,1).applyQuaternion(CM),F0.copy(dr.DEFAULT_UP),this.isUpVectorFlipped&&F0.negate(),F0.applyQuaternion(CM),PM.copy(dr.DEFAULT_UP).projectOnPlane(EM),this.angleOffsetFromUp=PM.angleTo(F0),this.angleOffsetFromUp*=PM.cross(F0).dot(EM)>=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 P),i=t.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new P;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let r=t>e?this.aspect:1,s=t>e?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/s*395,this.bottom=1/s*-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:IY(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return uu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=uu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new _t,blend:new _t,blendInverse:new _t,start:0,duration:uu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=uu.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=IY(e),r=t.from.elements,s=this._activeSubCamera.projectionMatrix.elements,n=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*a));for(let u=0;u<16;u++)n[u]=r[u]+(s[u]-r[u])*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 _t,blend:new _t,blendInverse:new _t,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,r,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,r,s,n):this.orthoCamera.setViewOffset(t,e,i,r,s,n),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=yc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return G8({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=yc.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}}},(ks=uu).projectionTransitionsEnabled=!1,ks.projectionTransitionDuration=350,ks.projectionTransitionMinAgeMs=1e3});function Aft(t){return t.type==="TorusGeometry"&&t.arc===360}var Cft,RM,kU,OS=j(()=>{dt(),Cft=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),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,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:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:u,cornerRadius:h,cornerSegments:d}=t.parameters,c=new kU(!1,e,i,r,s,n,a,o,l,u,h,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},RM=new hm([0,0,0],1),kU=class extends ge{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,u=1,h=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),h>100&&(h=100),h===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new P,S=new P,w=x(),T=x(),C=x(),M=x(),A=x(),R=x(),O=x(),N=x(),B=x(),L=x(),z=x(),k=i-2*o+.001,V=k/n,H=Math.ceil(a*n),W=H+1,X=k/H,st=-k/2,nt=u+1,xt=2*Math.PI/u,pt=Math.PI/2/d,K=Math.min((1-h/100)*o,o-.01),ct=o-K,St=0,wt=2*d+2,Tt=nt*wt/2,yt=Tt+nt*W,Ot=Math.max(0,nt*(W+wt)),[Ft,Bt,zt]=[3,3,2].map(Ve=>Array(Ot*Ve).fill(0)),Vt=[],Wt=s-o;function $t(Ve,ie){let oi=Math.PI/2;v=ie*X,_=2*Math.PI*(v%V)/V+oi,v+=st,b=Math.sin(_)*Wt,y=Math.cos(_)*Wt,t?Ve.set(y,b,v):Ve.set(y,v,b)}$t(S,-1e-10),$t(w,0),M.copy(S),$t(S,1);let Pt=S.distanceTo(w),oe=c?0:ct+K,jt=Pt*H+2*oe,Zt=K,Jt=jt-oe;for(let Ve=0;Ve<=H;Ve++){$t(T,Ve),z.subVectors(T,M).normalize(),M.copy(T),B.copy(T).setComponent(+t+1,0).normalize(),L.crossVectors(z,B).normalize();let ie=Ve===0,oi=Ve===H,xi=ie?3*Math.PI/2:pt,Ks=ie?Zt:Jt,Hi=ie?nt:yt,li=ie?0:Ot-nt,Ur=z.clone().multiplyScalar(ie?-ct:ct).add(T),Jr=z.clone().multiplyScalar(ie?-1:1).normalize();for(let jr=0;jr<nt;jr++){let Ui=jr*xt;if(A.addVectors(S.copy(B).multiplyScalar(o*Math.cos(Ui)),w.copy(L).multiplyScalar(o*Math.sin(Ui))),R.copy(A).normalize(),ie||oi){c||(St=li+jr,[0,1,2].forEach(Ci=>{Ft[3*St+Ci]=Ur.getComponent(Ci),Bt[3*St+Ci]=Jr.getComponent(Ci)}),zt[2*St]=+oi,zt[2*St+1]=jr/u),w.copy(R).multiplyScalar(K),C.addVectors(T,w);for(let Ci=0;Ci<d;Ci++){let Zs=Ci*pt+xi;O.addVectors(S.copy(z).multiplyScalar(ct*Math.sin(Zs)),w.copy(R).multiplyScalar(ct*Math.cos(Zs))),N.copy(O).normalize(),w.addVectors(C,O),O.normalize(),St=Hi+Ci*nt+jr,[0,1,2].forEach(_r=>{Ft[3*St+_r]=w.getComponent(_r),Bt[3*St+_r]=N.getComponent(_r)});let ps=+ie+Math.sin(Zs);zt[2*St]=(Ks+ct*ps)/jt,zt[2*St+1]=jr/u}}w.addVectors(T,A),St=Tt+Ve*nt+jr,[0,1,2].forEach(Ci=>{Ft[3*St+Ci]=w.getComponent(Ci),Bt[3*St+Ci]=R.getComponent(Ci)}),zt[2*St]=(oe+Ve*Pt)/jt,zt[2*St+1]=jr/u}}let $=W+2*d+2,[se,Pe]=[+c,$-1];for(let Ve=se;Ve<=Pe-1;Ve++){let ie=c&&Ve===Pe-1;for(let oi=0;oi<nt-1;oi++)p=Ve*nt+oi,m=p+1,f=(ie?oi:p)+nt,g=(ie?oi+1:m)+nt,Ve===0?Vt.push(m,g,f):Ve===$-2?Vt.push(p,m,f):Vt.push(p,m,f,m,g,f)}this.setIndex(Vt),this.setAttribute("position",new fe(Ft,3)),this.setAttribute("normal",new fe(Bt,3)),this.setAttribute("uv",new fe(zt,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,r,s=this.userData.parameters,n=Math.ceil(s.tubularSegments),a=s.radialSegments,o=a+1,l=[];for(let u=1;u<n;u++)for(let h=0;h<a;h++)t=u*o+h,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let u=0;u<a;u++)t=n*o+u,e=t+1,i=u+o,r=u+1+o,l.push(t,e,i,e,r,i);return RM.array=new Uint32Array(l),RM.count=l.length,RM}}});function _3t(t){return VY||(VY=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),IS=r}())}function C4(){if(IS===void 0)throw new Error("boolean-wasm is not loaded");return IS}function wG(t){let e=BS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function SG(t){return BS.set(++zU,t),zU}function x3t(t,e,i){if(IS===void 0)return-1;let{positions:r,indices:s,normals:n}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,m=[];for(let f=0,g=0;f<p.verticesPerFace.length;f++){let y=p.verticesPerFace[f];for(let v=1;v<y-1;v++)m.push(p.indices[g],p.indices[g+v],p.indices[g+v+1]);g+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(m)}}let l;l=Aft(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let u,h=a.getAttribute("position");if(l===null){u=new Uint32Array(h.count);for(let p=0;p<u.length;p++)u[p]=p}else u=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===h.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:h.array,indices:u,normals:c}}(t,e);return SG(new IS.CsgMesh(r,s,n))}function BY(t,e){let i=C4(),r=Pft[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(wG);if(s.length===1)return i.clone_mesh(s[0]);let n,a=[];if(e===2&&s.length>2){let o=s[0];for(let l=1;l<s.length-1;l++)o=i.boolean_mesh(o,s[l],0),a.push(o);n=i.boolean_mesh(s[s.length-1],o,2)}else if(e===2)n=i.boolean_mesh(s[1],s[0],2);else{let o=s[s.length-1];for(let l=0;l<s.length-1&&(o=i.boolean_mesh(o,s[l],r),a.push(o),o.tri_count()!==0);l++);n=o,a.pop()}for(let o of a)o.free();return n}function NO(t,e){wG(t).transform(new Float32Array(e.elements))}function Eft(t){let e=BS.get(t);e!==void 0&&(e.free(),BS.delete(t))}var IS,BS,zU,VY,Pft,W5=j(()=>{dt(),OS(),BS=new Map,zU=0,Pft={0:0,1:1,2:2}});function rf(t){return t!==null&&"booleanOp"in t}var LU,Rft,w3t=j(()=>{dt(),vo(),W5(),LU=class extends j5(vr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new _t}updateVisible(t){super.updateVisible(t),this.visible=!rf(this.parent)&&this.visible,rf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){rf(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Eft(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof LU&&(t.freeBooleanPointer(),rf(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&rf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),rf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),S3t=j(()=>{Rft=null});function TG(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,u=-1/0,h=-1/0;for(let d=e;d<i;d++){let c=t.getX(d),p=t.getY(d),m=t.getZ(d);c<n&&(n=c),p<a&&(a=p),m<o&&(o=m),c>l&&(l=c),p>u&&(u=p),m>h&&(h=m)}Zw.min.set(n,a,o),Zw.max.set(l,u,h),Zw.getCenter(r),Zw.getSize(s).multiplyScalar(.5)}var Zw,kY,zY,Vs,la=j(()=>{dt(),w3t(),S3t(),Zw=new pr,kY=new ge,zY=new Uo,Vs=class extends LU{constructor(t,e){super(kY,zY),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){if(this.raycastDeformed(t,e))return;let i=Rft;i===null?super.raycast(t,e):i(this,t,e)}raycastDeformed(t,e){return!1}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?TG(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function E4(t){return t?.isClassicNodeMaterial===!0}var Dr,FU,Dft,Nft,X2,Oft,Ift,Bft,MG=j(()=>{}),Dc=j(()=>{dt(),Dr=class extends ae{constructor(t,e,i,r){super(t,e,i),this.isColorA=!0,this.a=r}setRGBA(t,e,i,r){super.setRGB(t,e,i),this.a=r}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 r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[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}}}),T3t=j(()=>{Dc(),FU=class extends Dr{}}),M3t=j(()=>{Dft=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}}}),Vft=j(()=>{M3t(),Nft=class extends Dft{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),kft=j(()=>{Oft=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}},Ift=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}}}),A3t=j(()=>{dt(),Bft=class extends Kpt{constructor(t){super(t),this.type=ai}parse(t){let e=function(p,m){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},i=function(p,m,f){m=m||1024;let g=p.pos,y=-1,v=0,b="",_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(y=_.indexOf(`
|
|
348
348
|
`))&&v<m&&g<p.byteLength;)b+=_,v+=_.length,g+=128,_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));return-1<y&&(f!==!1&&(p.pos+=v+y+1),b+_.slice(0,y))},r=function(p,m,f,g){let y=p[m+3],v=Math.pow(2,y-128)/255;f[g+0]=p[m+0]*v,f[g+1]=p[m+1]*v,f[g+2]=p[m+2]*v,f[g+3]=1},s=function(p,m,f,g){let y=p[m+3],v=Math.pow(2,y-128)/255;f[g+0]=Kh.toHalfFloat(Math.min(p[m+0]*v,65504)),f[g+1]=Kh.toHalfFloat(Math.min(p[m+1]*v,65504)),f[g+2]=Kh.toHalfFloat(Math.min(p[m+2]*v,65504)),f[g+3]=Kh.toHalfFloat(1)},n=new Uint8Array(t);n.pos=0;let a,o,l,u=function(p){let m,f,g=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,v=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*FORMAT=(\S+)\s*$/,_=/^\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||!(m=i(p)))&&e(1,"no header found"),(f=m.match(g))||e(3,"bad initial token"),x.valid|=1,x.programtype=f[1],x.string+=m+`
|
|
349
349
|
`;m=i(p),m!==!1;)if(x.string+=m+`
|
|
350
350
|
`,m.charAt(0)!=="#"){if((f=m.match(y))&&(x.gamma=parseFloat(f[1])),(f=m.match(v))&&(x.exposure=parseFloat(f[1])),(f=m.match(b))&&(x.valid|=2,x.format=f[1]),(f=m.match(_))&&(x.valid|=4,x.height=parseInt(f[1],10),x.width=parseInt(f[2],10)),2&x.valid&&4&x.valid)break}else x.comments+=m+`
|
|
351
|
-
`;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),h=u.width,d=u.height,c=function(p,m,f){let g=m;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*m*f);y.length||e(4,"unable to allocate buffer space");let v=0,b=0,_=4*g,x=new Uint8Array(4),S=new Uint8Array(_),w=f;for(;w>0&&b<p.byteLength;){b+4>p.byteLength&&e(1),x[0]=p[b++],x[1]=p[b++],x[2]=p[b++],x[3]=p[b++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&e(3,"bad rgbe scanline format");let T,C=0;for(;C<_&&b<p.byteLength;){T=p[b++];let A=T>128;if(A&&(T-=128),(T===0||C+T>_)&&e(3,"bad scanline data"),A){let R=p[b++];for(let O=0;O<T;O++)S[C++]=R}else S.set(p.subarray(b,b+T),C),C+=T,b+=T}let M=g;for(let A=0;A<M;A++){let R=0;y[v]=S[A+R],R+=g,y[v+1]=S[A+R],R+=g,y[v+2]=S[A+R],R+=g,y[v+3]=S[A+R],v+=4}w--}return y}(n.subarray(n.pos),h,d);switch(this.type){case Qe:l=c.length/4;let p=new Float32Array(4*l);for(let f=0;f<l;f++)r(c,4*f,p,4*f);a=p,o=Qe;break;case ai:l=c.length/4;let m=new Uint16Array(4*l);for(let f=0;f<l;f++)s(c,4*f,m,4*f);a=m,o=ai;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:a,header:u.string,gamma:u.gamma,exposure:u.exposure,type:o,colorSpace:Xu,minFilter:me,magFilter:me,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function LY(t){return t.length>2&&t[0]===35&&t[1]===63}function OO(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function zft(t){let e=new br(t.data,t.width,t.height,on,ai);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var FY,AG,gg,Lft=j(()=>{dt(),A3t()}),Fft=j(()=>{dt(),Vft(),kft(),Lft(),FY=0,AG=class extends Oft{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++FY,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 r of Object.values(this._cache))for(let s of Object.values(r))for(let n of Object.values(s))n&&(n.image=this.img,n.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 r,s=new FileReader;s.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(n=>{s.onloadend=a=>{r=a.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?LY(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let r=t instanceof Uint8Array?t:null;if(r===null)try{r=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{r=null}let s=r!==null&&LY(r)?function(n){try{let a=new Bft().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,u=a.data,h=new Uint16Array(u.length),d=4*o,c=f=>Kh.toHalfFloat(Math.pow(Math.max(Kh.fromHalfFloat(f),0),1/2.2)),p=new Map,m=f=>{let g=p.get(f);return g===void 0&&(g=c(f),p.set(f,g)),g};for(let f=0;f<l;f++){let g=f*d,y=(l-1-f)*d;for(let v=0;v<d;v+=4)h[y+v]=m(u[g+v]),h[y+v+1]=m(u[g+v+1]),h[y+v+2]=m(u[g+v+2]),h[y+v+3]=u[g+v+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(r):null;s!==null&&(this.isHdr=!0,this.img=s,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:(X2||(X2=new Nft),X2.load(i)),this.img.onload=e,await new Promise(r=>{this.img.onload=()=>{e(),r(null)}});var i}getTexture(t,e=1008,i=1006){let r=this._cache[t]?.[e]?.[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new q7(this.img,void 0,t,t):this.isHdr?(s=zft(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new pi(this.img,void 0,t,t,i,e),this.isBuffer||(s.anisotropy=8,s.generateMipmaps=e===1008),this.loaded&&(s.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]=s,s}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let r of Object.values(i))r&&(r.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,r]of Object.entries(e))for(let[s,n]of Object.entries(r))n?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),Uft=j(()=>{Fft(),gg=class extends AG{}});function C3t(t){if(typeof t=="string")return t;let e=UU.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},UU.set(t,e)),e.url}var UU,E3t=j(()=>{UU=new Map});function P3t(){if(!jU)return UY||(UY=async function(){await Promise.resolve().then(()=>(bq(),Oxt)),jft(window!==void 0?window:global),jU=!0}())}var jft,Gft,jU,UY,Wft=j(()=>{Gft=new Promise(t=>{jft=t}),jU=!1});function jY(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(r=>{e.push(...r.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(e.push(...r.data.ifActions),e.push(...r.data.elseActions))}))})}function R3t(t){let e=!1,i=[];return t.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((n,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;jY(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;jY(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var GY,X1,CG=j(()=>{E3t(),Wft(),Gft.then(t=>GY=t),X1=class{constructor({src:t,volume:e,delay:i,loop:r}){let s;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)},s=typeof t=="string"?{src:t}:{src:C3t(t),format:"wav"},this.sound=new GY.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}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 WY(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(e=!0)}),e}var EG,PG=j(()=>{EG=null});function qY(t){return new Q(t.y,-t.x)}var RG,GU,qft,Hft,DM,HY,P4,$ft,IO,R4=j(()=>{dt(),RG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,r=t.parameters?.radiusBottom,s=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);s.thetaLength=qt.clamp(s.thetaLength,0,360),s.hollow=qt.clamp(s.hollow??0,0,1);let n=s.width/2,a=s.radiusTop??n,o=s.radiusBottom??n;if(a===o?(a=n,o=n):a>o?(a=n,o=o*n/a):(a=a*n/o,o=n),s.shapeBlendNode){a=i??n,o=r??n;let l=2*Math.max(a,o);s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;u===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=c||m?new GU(h,d,s,n,a,o,l,u*Math.PI/180,c,c,p,m):new k2(h,d,s,n,a,o,l,u*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},GU=class extends ge{constructor(t,e,i,r,s,n,a,o,l,u,h,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0&&n,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,n&&(l=0,u=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=u);let m=new Q(t,p),f=new Q(e,-p),g=null,y=null,v=null,b=null,_=m.clone().sub(f),x=0,S=0,w=0;d>0&&(x=Math.min(t,e)*(1-d),S=t-x,w=e-x);let T=m.clone();T.x-=x;let C=Math.PI-_.angle(),M=_.angle(),A=Math.tan(M/2),R=Math.tan(C/2),O=A+R,N=d?O:R,B=d?O:A;if(l=Math.min(l,(t-S)/N,_.length()/O),u=Math.min(u,(e-w)/B,_.length()/O),l>0){let Vt=l/A;g=m.clone().sub(new Q(Vt,l)),d&&(v=g.clone(),v.x-=x-O*l),m.sub(_.clone().setLength(Vt))}if(u>0){let Vt=u/R;y=f.clone().sub(new Q(Vt,-u)),f.add(_.clone().setLength(Vt)),d&&(b=y.clone(),b.x-=x-O*u,T.sub(_.clone().setLength(Vt)))}_=m.clone().sub(f);let L=_.length()<.5,z=[],k=[],V=[],H=[],W=[],X=[],st=(Vt,Wt,$t,Pt,oe)=>{for(let jt=0;jt<h+1;jt++){let Zt=jt/h,Jt=Pt<0?Zt:1-Zt;oe&&(Jt-=1),Jt*=Vt;let $=Math.sin(Jt),se=Math.cos(Jt)*Pt,Pe=se*Wt+$t.y;z.push($*Wt+$t.x),k.push(Pe),V.push($),H.push(se),W.push(.5+Pe/i),X.push(!1)}},nt=(Vt,Wt,$t)=>{let Pt=[Vt,Wt];$t<0&&Pt.reverse();for(let oe of Pt)z.push(oe),k.push(p*$t),V.push(0),H.push($t),W.push(.5),X.push(!0)};if(b&&y?(st(C,u,b,-1,!0),st(M,u,y,-1,!1)):y?(nt(y.x,0,-1),st(M,u,y,-1,!1)):n||nt(e,w,-1),!L){let Vt=qY(_).normalize();for(let Wt=0;Wt<=s;Wt++){let $t=Wt/s,Pt=_.y*$t+f.y;z.push(_.x*$t+f.x),k.push(Pt),V.push(Vt.x),H.push(Vt.y),W.push(.5+Pt/i),X.push(!1)}}if(v&&g?(st(C,l,g,1,!1),st(M,l,v,1,!0)):g?(st(C,l,g,1,!1),nt(g.x,0,1)):n||nt(t,S,1),d&&!L){let Vt=qY(_).multiplyScalar(-1).normalize();for(let Wt=0;Wt<=s;Wt++){let $t=Wt/s,Pt=_.y*-$t+T.y;z.push(_.x*-$t+T.x),k.push(Pt),V.push(Vt.x),H.push(Vt.y),W.push(.5+Pt/i),X.push(!1)}}let xt=z.length,pt=xt+(d&&!n?1:0),K=(Vt,Wt)=>Vt*xt+(Wt===xt?0:Wt),ct=o<2*Math.PI,St=(r+1)*xt+(ct?2*(1+pt):0),wt=new Float32Array(3*St),Tt=new Float32Array(3*St),yt=new Float32Array(2*St),Ot=St-1>65535?new Uint32Array(r*Math.max(0,pt-1)*6+(ct?2*(pt+1)*3:0)):new Uint16Array(r*Math.max(0,pt-1)*6+(ct?2*(pt+1)*3:0)),Ft=0,Bt=0;for(let Vt=0;Vt<=r;Vt++){let Wt=Vt/r,$t=Wt*o+a,Pt=Math.sin($t),oe=Math.cos($t);for(let jt=0;jt<xt;jt++){let Zt=3*Bt,Jt=2*Bt,$=z[jt],se=V[jt];wt[Zt]=$*Pt,wt[Zt+1]=k[jt],wt[Zt+2]=$*oe,Tt[Zt]=se*Pt,Tt[Zt+1]=H[jt],Tt[Zt+2]=se*oe,X[jt]?(yt[Jt]=.5,yt[Jt+1]=.5):(yt[Jt]=Wt,yt[Jt+1]=W[jt]),Bt++}}for(let Vt=0;Vt<r;Vt++)for(let Wt=0;Wt<pt-1;Wt++){if(n&&d&&Wt==s)continue;let $t=K(Vt,Wt),Pt=K(Vt+1,Wt),oe=K(Vt+1,Wt+1),jt=K(Vt,Wt+1),Zt=wt[3*oe+0],Jt=wt[3*oe+2];Ot[Ft++]=$t,Ot[Ft++]=Pt,Ot[Ft++]=jt,(Zt!=0||Jt!=0)&&(Ot[Ft++]=Pt,Ot[Ft++]=oe,Ot[Ft++]=jt)}function zt(Vt,Wt,$t){let Pt=Math.sin($t),oe=Math.cos($t),jt=-oe,Zt=Pt,Jt=Vt<0?(ie,oi,xi)=>{Ot[Ft++]=ie,Ot[Ft++]=oi,Ot[Ft++]=xi}:(ie,oi,xi)=>{Ot[Ft++]=ie,Ot[Ft++]=xi,Ot[Ft++]=oi},$=(t+e+S+w)/4,se=3*Bt,Pe=2*Bt;wt[se]=$*Pt,wt[se+1]=0,wt[se+2]=$*oe,Tt[se]=jt,Tt[se+1]=0,Tt[se+2]=Zt,yt[Pe]=.5,yt[Pe+1]=.5;let Ve=Bt++;for(let ie=0;ie<pt;ie++){let oi=3*(Wt+(ie===xt?0:ie));se=3*Bt,Pe=2*Bt,wt[se]=wt[oi],wt[se+1]=wt[oi+1],wt[se+2]=wt[oi+2],Tt[se]=jt,Tt[se+1]=0,Tt[se+2]=Zt;let xi=oi/3*2|0;yt[Pe]=yt[xi],yt[Pe+1]=yt[xi+1],Bt++}for(let ie=Ve+1;ie<Bt-1;ie++)Jt(Ve,ie,ie+1);Jt(Ve,Bt-1,Ve+1)}ct&&(zt(-1,0,a),zt(1,r*xt,a+o)),this.setIndex(new _e(Ot.slice(0,Ft),1)),this.setAttribute("position",new _e(wt,3)),this.setAttribute("normal",new _e(Tt,3)),this.setAttribute("uv",new _e(yt,2))}}}),$Y=j(()=>{dt(),R4(),qft=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=qt.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:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;u===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=h>0||d>0||u<360?new GU(0,i/2,s,n,a,o,l,u*Math.PI/180,h,d,c,0,!0):new KR(i/2,s,n,a,o);let p=r/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),XY=j(()=>{dt(),Hft=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:r,depth:s,widthSegments:n,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:u}=t.parameters;return e=l===0?new Zh(i,r,s,n,a,o):new HY(i,r,s,n,a,o,l,u),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},DM=Math.PI/2,HY=class extends ge{constructor(t=1,e=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,u=o+1,h=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*u*(n+1+(r+1)+(s+1))+u*(u+1)/2*8:0),d=2*(n*s+r*n+r*s)+(l?4*o*(n+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*h),m=new Float32Array(3*h),f=new Float32Array(2*h),g=h-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(u),_=new Float64Array(u),x=new Float64Array(u),S=new Float64Array(u);for(let O=0;O<u;O++){let N=O/o*DM;b[O]=Math.sin(N)*a,_[O]=(1-Math.cos(N))*a,x[O]=Math.sin(N),S[O]=Math.cos(N)}let w=u*(u+1)/2,T=new Float64Array(3*w),C=new Float64Array(3*w);{let O=new P(t/2,e/2,i/2);O.subScalar(a);let N=0;for(let B=0;B<=o;B++){let L=DM*(1-B/o),z=Math.cos(L),k=Math.sin(L),V=0;for(let H=0;H<=B;H++){let W=z*Math.cos(V),X=k,st=z*Math.sin(V);T[3*N]=W,T[3*N+1]=X,T[3*N+2]=st,C[3*N]=O.x+W*a,C[3*N+1]=O.y+X*a,C[3*N+2]=O.z+st*a,N++,V+=DM/B}}}function M(O,N,B,L,z,k,V,H,W,X){let st=(k-2*a)/W,nt=(V-2*a)/X,xt=k/2-a,pt=V/2-a,K=H/2,ct=W+1,St=X+1,wt=0,Tt=new P;for(let yt=0;yt<St;yt++){let Ot=yt*nt-pt;for(let Ft=0;Ft<ct;Ft++){let Bt=Ft*st-xt,zt=3*(y+wt),Vt=2*(y+wt);Tt[O]=Bt*L,Tt[N]=Ot*z,Tt[B]=K,p[zt]=Tt.x,p[zt+1]=Tt.y,p[zt+2]=Tt.z,Tt[O]=0,Tt[N]=0,Tt[B]=H>0?1:-1,m[zt]=Tt.x,m[zt+1]=Tt.y,m[zt+2]=Tt.z,f[Vt]=Ft/W,f[Vt+1]=1-yt/X,wt+=1}}for(let yt=0;yt<X;yt++)for(let Ot=0;Ot<W;Ot++){let Ft=y+Ot+ct*yt,Bt=y+Ot+ct*(yt+1),zt=y+(Ot+1)+ct*(yt+1),Vt=y+(Ot+1)+ct*yt;g[v++]=Ft,g[v++]=Bt,g[v++]=Vt,g[v++]=Bt,g[v++]=zt,g[v++]=Vt}y+=wt}function A(O,N,B,L,z,k,V,H,W,X){let st=(V-2*a)/X,nt=V/2-a,xt=H/2-a,pt=W/2,K=X+1,ct=0,St=new P,wt=new P;for(let Tt=0;Tt<o+1;Tt++){St[N]=(xt+b[Tt])*z,St[B]=(pt-_[Tt])*k,wt[O]=0,wt[N]=x[Tt]*Math.sign(St[N]),wt[B]=S[Tt]*Math.sign(St[B]);for(let yt=0;yt<K;yt++){let Ot=yt*st-nt;St[O]=Ot*L;let Ft=3*(y+ct),Bt=2*(y+ct);p[Ft]=St.x,p[Ft+1]=St.y,p[Ft+2]=St.z,m[Ft]=wt.x,m[Ft+1]=wt.y,m[Ft+2]=wt.z,f[Bt]=yt/X,f[Bt+1]=0,ct+=1}}for(let Tt=0;Tt<o;Tt++)for(let yt=0;yt<X;yt++){let Ot=y+yt+K*Tt,Ft=y+yt+K*(Tt+1),Bt=y+(yt+1)+K*(Tt+1),zt=y+(yt+1)+K*Tt;g[v++]=Ot,g[v++]=Ft,g[v++]=zt,g[v++]=Ft,g[v++]=Bt,g[v++]=zt}y+=ct}function R(O,N,B){let L=O*N*B>0?(k,V,H)=>{g[v++]=k,g[v++]=V,g[v++]=H}:(k,V,H)=>{g[v++]=k,g[v++]=H,g[v++]=V},z=y;for(let k=0;k<w;k++){let V=3*k,H=3*y,W=2*y;p[H]=O*C[V],p[H+1]=N*C[V+1],p[H+2]=B*C[V+2],m[H]=O*T[V],m[H+1]=N*T[V+1],m[H+2]=B*T[V+2],f[W]=0,f[W+1]=0,y++}for(let k=0;k<o;k++){let V=z+k*(k+1)/2,H=z+(k+1)*(k+2)/2;L(V,H+1,H);for(let W=1;W<=k;W++)L(V+W-1,V+W,H+W),L(V+W,H+W+1,H+W)}}M("z","y","x",-1,-1,i,e,t,n,s),M("z","y","x",1,-1,i,e,-t,n,s),M("x","z","y",1,1,t,i,e,r,n),M("x","z","y",1,-1,t,i,-e,r,n),M("x","y","z",1,-1,t,e,i,r,s),M("x","y","z",-1,-1,t,e,-i,r,s),a>0&&(A("z","y","x",-1,-1,1,i,e,t,n),A("z","y","x",1,-1,-1,i,e,t,n),A("z","y","x",-1,1,-1,i,e,t,n),A("z","y","x",1,1,1,i,e,t,n),A("x","y","z",-1,-1,-1,t,e,i,r),A("x","y","z",1,-1,1,t,e,i,r),A("x","y","z",-1,1,1,t,e,i,r),A("x","y","z",1,1,-1,t,e,i,r),A("y","x","z",-1,-1,1,e,t,i,s),A("y","x","z",1,-1,-1,e,t,i,s),A("y","x","z",1,1,1,e,t,i,s),A("y","x","z",-1,1,-1,e,t,i,s),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 _e(g,1)),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(m,3)),this.setAttribute("uv",new _e(f,2))}}}),Xft=j(()=>{dt(),P4=class extends ge{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,u=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new Is,m=s*r,f=r-m,g=n+1,y=new P,v=(K,ct)=>y.subVectors(K,ct).normalize(),b=(K,ct)=>Array(K).fill(void 0).map(ct),_=b(t.length/3,(K,ct)=>new P().fromArray(t,3*ct).setLength(r)),x=[],S=1e6;for(let K=0;K<_.length;K++){let ct,St,wt,Tt=_[K],yt=[],Ot=1e10,Ft=-1;for(;(Ft=e.indexOf(K,Ft+1))!=-1;){let Wt=Ft-Ft%3;ct=e[Wt+(Ft+1)%3],St=e[Wt+(Ft+2)%3],wt=Tt.distanceToSquared(_[ct]),Ot=Math.min(Ot,wt),yt.push([ct,St,wt])}Ot+=1e-6;let Bt=[],zt=0,Vt=yt.length;for(let Wt=0;Wt<Vt;Wt++){[ct,St,wt]=yt[zt];let $t=x[ct]?.includes(K)==1;wt<=Ot&&Bt.push(ct+ +$t*S),zt=yt.findIndex(Pt=>Pt[0]==St)}x.push(Bt)}let w=[];{let K,ct,St=0,wt=0,Tt=h==3;for(let yt=0;yt<=n;yt++){K=yt*(yt+1)/2,ct=(yt+1)*(yt+2)/2;for(let Ot=0;Ot<n-yt;Ot++)[St,wt]=[K+Ot+yt+2,ct+Ot+yt+3],w.push(K,ct,...Tt?[wt,K]:[St,ct],wt,St),[K,ct]=[St,wt];w.push(K,ct,K+n+2)}}let T=0;for(let K=0;K<x.length;K++)for(let ct=0;ct<h;ct++)x[K][ct]<S&&T++;let C=_.length*h*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(C),o=new Float64Array(C),l=new Float64Array(C/3*2);let M=(K,ct,St)=>{let wt=u/3*2;l[wt]=Math.atan2(St,-K)/2/Math.PI+.5,l[wt+1]=1-(Math.atan2(-ct,Math.sqrt(K*K+St*St))/Math.PI+.5)},A=K=>{a[u]=K.x,a[u+1]=K.y,a[u+2]=K.z,o[u]=y.x,o[u+1]=y.y,o[u+2]=y.z,M(K.x,K.y,K.z),u+=3},R=K=>{a[u]=K[0].x,a[u+1]=K[0].y,a[u+2]=K[0].z,o[u]=K[1].x,o[u+1]=K[1].y,o[u+2]=K[1].z,M(K[0].x,K[0].y,K[0].z),u+=3},O=(n+2)*(n+3)/2,N=new Float64Array(3*O),B=new Float64Array(3*O),L=new Float64Array(2*O),z=b(2*h*g,()=>new P),k=b(n*Math.max(0,n-1)/2,()=>new P),V=d.clone(),H=d.clone(),W=d.clone(),X=d.clone(),st=d.clone(),nt=[],xt=b(_.length,()=>b(h,()=>d.clone()));for(let K=0;K<_.length;K++){d.copy(_[K]).normalize(),V.copy(d).multiplyScalar(f);let ct=x[K];for(let Bt=0;Bt<ct.length;Bt++){let zt=ct[Bt],Vt=ct[(Bt+1)%h];p.setFromPointsAndIndices(_,K,zt%S,Vt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(V,xt[K][Bt])}let St=0,wt=[],Tt=[],yt=new P;n==0&&[...xt[K]].reduce((Bt,zt)=>Bt.add(zt),yt).multiplyScalar(1/h);for(let Bt=0;Bt<h;Bt++){let zt=[],Vt=(Bt-1+h)%h,Wt=xt[K][Vt],$t=xt[K][Bt];d.copy(Wt).sub(V),c.copy($t).sub(V);let Pt=V.angleTo(d),oe=d.angleTo(c),jt=Math.cos(Pt)*m;n==0?H.copy(yt):H.copy(V).setLength(f+jt),wt.push(jt);let Zt=[H,Wt,$t];for(let Jt=0;Jt<2;Jt++){let $=Zt[Jt],se=Zt[Jt+1];X.subVectors($,V),st.subVectors(se,V),W.crossVectors(X,st).normalize();for(let Pe=0;Pe<g;Pe++){let Ve=[Pt,oe][Jt]*Pe/g;d.copy(X).applyAxisAngle(W,Ve).add(V),z[St++].copy(d),Jt&&(v(d,V),zt.push([Pe==0?$:d.clone(),y.clone()]))}Jt&&(v(se,V),zt.push([se,y.clone()]))}Tt.push(zt)}nt.push(Tt);let Ot=2*g,Ft=2;for(let Bt=0;Bt<h;Bt++){let zt=Ot*Bt,Vt=Ot*((Bt+1)%h),Wt=0,$t=[z[zt]];for(let Pt=1;Pt<g;Pt++){let oe=z[zt+Pt],jt=z[Vt+Pt];$t.push(oe);for(let Zt=1,Jt=Pt-Ft+1;Zt<=Jt;Zt++)d.lerpVectors(oe,jt,Zt/(Jt+1)),d.sub(V).setLength(wt[Bt]).add(V),$t.push(k[Wt++].copy(d));$t.push(jt)}for(let Pt=0;Pt<g;Pt++)$t.push(z[Pt+g+zt]);$t.push(z[Vt+g]);for(let Pt=0,oe=$t.length;Pt<oe;Pt++){let jt=$t[Pt],Zt=3*Pt,Jt=2*Pt;N[Zt]=jt.x,N[Zt+1]=jt.y,N[Zt+2]=jt.z,v(jt,V),B[Zt]=y.x,B[Zt+1]=y.y,B[Zt+2]=y.z,L[Jt]=Math.atan2(jt.z,-jt.x)/2/Math.PI+.5,L[Jt+1]=1-(Math.atan2(-jt.y,Math.sqrt(jt.x*jt.x+jt.z*jt.z))/Math.PI+.5)}for(let Pt=0,oe=w.length;Pt<oe;Pt++){let jt=3*w[Pt],Zt=2*w[Pt],Jt=u/3*2;a[u]=N[jt],a[u+1]=N[jt+1],a[u+2]=N[jt+2],o[u]=B[jt],o[u+1]=B[jt+1],o[u+2]=B[jt+2],l[Jt]=L[Zt],l[Jt+1]=L[Zt+1],u+=3}}}let pt=[];for(let K=0;K<x.length;K++)for(let ct=0;ct<h;ct++){let St=x[K][ct];if(St<S){let wt=x[St].findIndex(Ot=>Ot%S==K),Tt=nt[K][ct],yt=nt[St][wt];for(let Ot=0;Ot<g;Ot++){let Ft=Tt[Ot],Bt=yt[g-Ot],zt=Tt[Ot+1],Vt=yt[g-(Ot+1)];R(Ft),R(Bt),R(zt),R(zt),R(Bt),R(Vt)}pt.push(Tt[0][0],yt[g][0],Tt[g][0],yt[0][0])}}for(;pt.length;){let K,ct,St,[wt,Tt]=pt.splice(0,2);K=Tt;let yt=[wt];for(;wt!=K;)yt.push(K),ct=pt.indexOf(K),St=ct%2,K=pt.splice(ct-St,2)[1-St];y.subVectors(yt[0],yt[1]).cross(d.subVectors(yt[0],yt[2])).normalize();let Ot=y.dot(yt[0])<0;Ot&&y.negate();for(let Ft=1;Ft<=yt.length-2;Ft++)A(yt[Ft+ +Ot]),A(yt[Ft+1-+Ot]),A(yt[0])}}(),function(){let h=new P,d=new P,c=new P,p=new P,m=new Q,f=new Q,g=new Q,y=(_,x,S,w)=>{w<0&&_.x===1&&(l[x]=_.x-1),S.x===0&&S.z===0&&(l[x]=w/2/Math.PI+.5)};for(let _=0,x=0;_<u;_+=9,x+=6){h.set(a[_+0],a[_+1],a[_+2]),d.set(a[_+3],a[_+4],a[_+5]),c.set(a[_+6],a[_+7],a[_+8]),m.set(l[x+0],l[x+1]),f.set(l[x+2],l[x+3]),g.set(l[x+4],l[x+5]),p.copy(h).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,h,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=u/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),C=Math.min(x,S,w);T>.9&&C<.1&&(x<.2&&(l[_+0]+=1),S<.2&&(l[_+2]+=1),w<.2&&(l[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}}(),this.setAttribute("position",new _e(new Float32Array(a.subarray(0,u)),3)),this.setAttribute("normal",new _e(new Float32Array(o.subarray(0,u)),3)),void this.setAttribute("uv",new _e(new Float32Array(l.subarray(0,u/3*2)),2))}static fromJSON(t){return new P4(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),YY=j(()=>{Xft(),dt(),$ft=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:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new IO(.5*e,n,a):new A8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},IO=class extends P4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n="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,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[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],n,t,e,i),this.type=n}static fromJSON(t){return new IO(t.radius,t.corner,t.cornerSides)}}});function KY(t,e=new Q){let i=t.length();return e.set(-t.y/i,t.x/i)}function D3t(t){let e=new Q;e.addVectors(t.v0,Rg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Q;return i.addVectors(t.v2,VS.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Kl(t.v0,e,i,t.v2)}function Qw(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function N3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function O3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function Yft(t,e,i){let r=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function I3t(t,e,i){return QY(t,e)&&QY(e,i)&&WU(t.position,e.position,i.position)}function WU(t,e,i){return Rg.copy(e).sub(t).cross(VS.copy(i).sub(t))===0}function B3t(t,e,i,r,s){let n=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(n/2,2))*(t.y-e.y)/n,u=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+u),s.set(o-l,a-u),[r,s]}function V3t(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function k3t(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,u=i.x-t.x,h=i.y-t.y,d=Math.sqrt((o+u)*(o+u)+(l+h)*(l+h));return Yft(e,t,i)>Math.PI&&(d*=-1),a=Qw(h,l)?(l+h)*(r/d-.5)*8/3/(o-u):(o+u)*(r/d-.5)*8/3/(h-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*h,i.y-a*u),[s,n]}function ZY(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function QY(t,e){return WU(t.position,t.controls[1].position,e.position)&&WU(t.position,e.controls[0].position,e.position)}function JY(t,e=12,i=!1){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Pg(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Pg(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Pg(t[0].roundedCurveCorner,e)),r}function Pg(t,e=12){return t&&t instanceof jw?2*e:t&&(t instanceof cl||t instanceof C8)?1:t&&t instanceof CP?e*t.points.length:e}var P1,NM,OM,qg,FP,Rg,VS,Kft,Zft,Qft,Jft,qU,HU,IM,tK,eK,iK,rK,sK,ds,tgt=j(()=>{dt(),P1=1e-12,NM=class{constructor(t){this.position=new Q,this.startPosition=new Q,this.uuid=qt.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 NM(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},OM=class extends NM{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new OM(this.parent).copy(this)}},qg=class extends NM{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new OM(this),new OM(this))}static create(t,e){let i=new qg(t,new Q(...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,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=e?s.position.copy(this.position):s.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 qg(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 Q,e=new Q){let[i,r]=this.computeTangents();return i&&r&&(KY(i,t),KY(r,e)),[t,e]}computeTangent(t=new Q){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Q){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},FP=t=>t,Rg=new Q,VS=new Q,Kft=new Q,Zft=new Q,Qft=new Q,Jft=new Q,qU=new P,HU=new P}),wm=j(()=>{dt(),tgt(),IM=new Q,tK=new Q,eK=new Q,iK=new Q,rK=new Q,sK=new Q,ds=class extends _S{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ra(new P(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=qt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ds;return r.isClosed=t.isClosed,r.points=t.points.map(s=>qg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ds.createFromState(s)),e!==void 0&&i!==void 0&&r.applySize(e,i),r.update(),r}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(r=>r.uuid===t);if(i<0){let r=e;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+r;r+=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,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=t-e;if(n<=s.points.length-1)return s.points[n];e+=s.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,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(t);if(n>=0)return e+n;e+=s.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=IM.set(t,e);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(t,e);this._update()}createPoint(t,e=0,i=qt.generateUUID()){let r;r=t instanceof Q?t:new Q(t,e);let s=new qg(i,r);return s.roundness=this.roundness,s}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 r=this.points[e];if(r.uuid===t)return r}for(let e=0,i=this.shapeHoles.length;e<i;e++){let r=this.shapeHoles[e].getPointByUuid(t);if(r)return r}}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 r=i?this.roundedCurveDivisions:this.curveDivisions;return function(s,n,a=12,o=!0){let l,u=HU.set(0,0,0),h=0,d=[];for(let c=0;c<n.length;c++){let p=FP(n[c]),m=Rg,f=Pg(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof cl){if(p.getPoint(g/f,m),u.set(m.x,m.y,0),l!==void 0&&O3t(l,u))continue;l===void 0&&(l=qU),l.copy(u),s.setXYZ(h,u.x,u.y,u.z),h++}}o&&h>1&&(s.getX(h-1)!==s.getX(0)||s.getY(h-1)!==s.getY(0)||s.getZ(h-1)!==s.getZ(0))&&(s.setXYZ(h,s.getX(0),s.getY(0),s.getZ(0)),h++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=JY(this.points,t,!1),this.roundedCurveDivisions=JY(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=HU.set(0,0,0),u=0,h=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=FP(s[d]),m=Rg,f=Pg(p,a);h.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof cl){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=qU:(r.setXYZ(u,c.x,c.y,c.z),u++,r.setXYZ(u,l.x,l.y,l.z),u++),c.copy(l)}}return o&&u>1&&!(r.getX(u-1)===r.getX(0)&&r.getY(u-1)===r.getY(0)&&r.getZ(u-1)===r.getZ(0))&&(r.setXYZ(u,r.getX(0),r.getY(0),r.getZ(0)),u++),h}(t,this.curves,e,i,this.autoClose).reduce((r,s)=>r+s,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,r,s=12,n=!0){let a,o=0;for(let l=0;l<r.length;l++){let u=FP(r[l]),h=Pg(u,s),d=Rg;for(let c=0;c<=h;c++)if(u instanceof Kl||u instanceof lc||u instanceof cl){if(u.getPoint(c/h,d),a!==void 0&&N3t(a,d,P1))continue;a===void 0&&(a=VS),a.copy(d),i.push(d.x,d.y),o++}}return Qw(i[0],i[i.length-2],P1)&&Qw(i[1],i[i.length-1],P1)&&(i.pop(),i.pop()),n&&o>1&&!(Qw(i[o-1],i[1],P1)&&Qw(i[o-2],i[0],P1))&&(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 r=e?this.roundedCurveDivisions:this.curveDivisions,s=0;e&&this.points[0].roundedCurveCorner!==void 0&&(s=.5*Pg(this.points[0].roundedCurveCorner,this.subdivision));let n=t-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let r=this.points[t],s=this.points[t>=this.points.length-1?0:t+1],n=this.curveDivisions,a=n[t];if(ZY(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(IM.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=n[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){ZY(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 r=i.clone();t.roundedCurveBefore=r,e.roundedCurveAfter=r,t.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(e===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[e-1];this._applyCurveForPoint(r,s)}}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,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&I3t(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let u=s.curveBefore,h=s.curveAfter;if(u===void 0||h===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=u instanceof cl?u.v1.distanceTo(u.v2):u.getLength(),f=h instanceof cl?h.v1.distanceTo(h.v2):h.getLength(),g=Math.min(o,.499*m),y=Math.min(o,.499*f),v=Math.min(g,y),b=1-v/m,_=v/f,x=u.getPointAt(b,IM),S=h.getPointAt(_,tK);if(this._subSplitCurve(u,c,b,x,void 0),this._subSplitCurve(h,p,_,void 0,S),this.useCubicForRoundedCorners){let w=Yft(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[C,M]=B3t(x,S,T,eK,iK),A=V3t(C,M,s.position),[R,O]=k3t(A,x,S,T,rK,sK);d=new Kl(x.clone(),R.clone(),O.clone(),S.clone())}else d=new lc(x.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=d,this.roundedCurves.splice(i+e,0,d),e++}}}}_subSplitCurve(t,e,i,r,s){if(!(t instanceof cl)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(u,h,d,c,p=.5){let m=Rg.subVectors(h,u).multiplyScalar(p).add(u),f=VS.subVectors(d,h).multiplyScalar(p).add(h),g=Kft.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=Zft.subVectors(f,m).multiplyScalar(p).add(m),b=Qft.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=Jft.subVectors(b,v).multiplyScalar(p).add(v);return[u.x,u.y,y.x,y.y,v.x,v.y,x.x,x.y,b.x,b.y,_.x,_.y,c.x,c.y]}(n.v0,n.v1,n.v2,n.v3,o);return r!==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])),s!==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 r!==void 0&&e.v2.copy(r),s!==void 0&&e.v1.copy(s),e}clone(){let t=new ds(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 r=7*i,s=t.points[r+0],n=t.points[r+1],a=t.points[r+2],o=t.points[r+3],l=t.points[r+4],u=t.points[r+5],h=t.points[r+6],d=new qg(qt.generateUUID(),new Q(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,u),d.roundness=h,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ds;return r.fromJSON(i),r}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(r,s)=>{s instanceof Kl&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)};return this.points=(r=>{let s,n,a=[];for(s=0,n=r.length;s<n;s++)r[s]instanceof lc&&(r[s]=D3t(r[s]));for(s=0,n=r.length;s<n;s++){let u,h=r[s],d=s>0?r[s-1]:null;h instanceof Kl?(u=this.createPoint(h.v0),u.controls[1].position.copy(h.v1)):h instanceof cl&&(u=this.createPoint(h.v1)),u!==void 0&&(d!==null&&i(u,d),a.push(u))}let o=r[r.length-1],l=!1;return o instanceof Kl?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof cl&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof _S&&(this.shapeHoles=t.holes.map(r=>{let s=new ds;return s.fromShape(r),s})),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 BO({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function z3t(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(t),s=Math.sin(t),n=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function nK(t,e,i,r){let s=t*r-e*i<0?-1:1,n=Math.min(1,Math.max(-1,t*i+e*r));return s*Math.acos(n)}var UP,L3t=j(()=>{UP=2*Math.PI});function Xe(t,e){if(!t)throw e||"Assertion Failed!"}function Y2(t){var e=t.windingRule,i=e===void 0?ss.ODD:e,r=t.elementType,s=r===void 0?Ea.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,u=t.normal,h=u===void 0?[0,0,1]:u,d=t.contours,c=d===void 0?[]:d,p=t.strict,m=p===void 0||p,f=t.debug,g=f!==void 0&&f;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new egt;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,a,l,h,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var ss,Ea,je,U0,l_,sf,VO,kO,zO,aK,BM,LO,oK,lK,egt,eT=j(()=>{var t;(t=ss||(ss={}))[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"}(Ea||(Ea={})),je=function(){function e(){}return e.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},e.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},e.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.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,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},e.edgeEval=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?n<a?r.t-i.t+(i.t-s.t)*(n/(n+a)):r.t-s.t+(s.t-i.t)*(a/(n+a)):0},e.edgeSign=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?(r.t-s.t)*n+(r.t-i.t)*a:0},e.transEval=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?n<a?r.s-i.s+(i.s-s.s)*(n/(n+a)):r.s-s.s+(s.s-i.s)*(a/(n+a)):0},e.transSign=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?(r.s-s.s)*n+(r.s-i.s)*a:0},e.vertCCW=function(i,r,s){return i.s*(r.t-s.t)+r.s*(s.t-i.t)+s.s*(i.t-r.t)>=0},e.interpolate=function(i,r,s,n){return(i=i<0?0:i)<=(s=s<0?0:s)?s===0?(r+n)/2:r+i/(i+s)*(n-r):n+s/(i+s)*(r-n)},e.intersect=function(i,r,s,n,a){var o,l,u;e.vertLeq(i,r)||(u=i,i=r,r=u),e.vertLeq(s,n)||(u=s,s=n,n=u),e.vertLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.vertLeq(s,r)?e.vertLeq(r,n)?((o=e.edgeEval(i,s,r))+(l=e.edgeEval(s,r,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,r.s)):((o=e.edgeSign(i,s,r))+(l=-e.edgeSign(i,n,r))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,n.s)):a.s=(s.s+r.s)/2,e.transLeq(i,r)||(u=i,i=r,r=u),e.transLeq(s,n)||(u=s,s=n,n=u),e.transLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.transLeq(s,r)?e.transLeq(r,n)?((o=e.transEval(i,s,r))+(l=e.transEval(s,r,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,r.t)):((o=e.transSign(i,s,r))+(l=-e.transSign(i,n,r))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,n.t)):a.t=(s.t+r.t)/2},e}(),U0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},l_=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}(),sf=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},VO=function(){function e(){var i=new sf,r=new U0,s=new l_(0),n=new l_(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,s.next=s,s.Sym=n,n.next=n,n.Sym=s,this.vHead=i,this.fHead=r,this.eHead=s,this.eHeadSym=n}return e.prototype.makeEdge_=function(i){var r=new l_(0),s=new l_(1);i.Sym.side<i.side&&(i=i.Sym);var n=i.Sym.next;return s.next=n,n.Sym.next=r,r.next=i,i.Sym.next=s,r.Sym=s,r.Onext=r,r.Lnext=s,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,s.Sym=r,s.Onext=s,s.Lnext=r,s.Org=null,s.Lface=null,s.winding=0,s.activeRegion=null,r},e.prototype.splice_=function(i,r){var s=i.Onext,n=r.Onext;s.Sym.Lnext=r,n.Sym.Lnext=i,i.Onext=n,r.Onext=s},e.prototype.makeVertex_=function(i,r,s){var n=i;Xe(n,"Vertex can't be null!");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r;var o=r;do o.Org=n,o=o.Onext;while(o!==r)},e.prototype.makeFace_=function(i,r,s){var n=i;Xe(n,"Face can't be null");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r,n.trail=null,n.marked=!1,n.inside=s.inside;var o=r;do o.Lface=n,o=o.Lnext;while(o!==r)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,s=i.Sym.next;r.Sym.next=s,s.Sym.next=r},e.prototype.killVertex_=function(i,r){var s=i.anEdge,n=s;do n.Org=r,n=n.Onext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,r){var s=i.anEdge,n=s;do n.Lface=r,n=n.Lnext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new sf,r=new sf,s=new U0,n=this.makeEdge_(this.eHead);return this.makeVertex_(i,n,this.vHead),this.makeVertex_(r,n.Sym,this.vHead),this.makeFace_(s,n,this.fHead),n},e.prototype.splice=function(i,r){var s=!1,n=!1;if(i!==r){if(r.Org!==i.Org&&(n=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!n){var a=new sf;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new U0;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var r=i.Sym,s=!1;if(i.Lface!==i.Rface&&(s=!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),!s){var n=new U0;this.makeFace_(n,i,i.Lface)}r.Onext===r?(this.killVertex_(r.Org,null),this.killFace_(r.Lface,null)):(i.Lface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),s=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var n=new sf;return this.makeVertex_(n,s,r.Org),r.Lface=s.Lface=i.Lface,r},e.prototype.splitEdge=function(i){var r=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,r),i.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=i.Rface,r.winding=i.winding,r.Sym.winding=i.Sym.winding,r.idx=i.idx,r.Sym.idx=i.Sym.idx,r},e.prototype.connect=function(i,r){var s=!1,n=this.makeEdge_(i),a=n.Sym;if(r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(n,i.Lnext),this.splice_(a,r),n.Org=i.Dst,a.Org=r.Org,n.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!s){var o=new U0;this.makeFace_(o,n,i.Lface)}return n},e.prototype.zapFace=function(i){var r,s,n,a,o,l=i.anEdge;s=l.Lnext;do s=(r=s).Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),(n=r.Sym).Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var r=i.anEdge,s=0;do s++,r=r.Lnext;while(r!==i.anEdge);return s},e.prototype.mergeConvexFaces=function(i){var r,s,n,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(s=r.anEdge).Org;n=s.Lnext,(a=s.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&je.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&je.vertCCW(a.Lprev.Org,a.Org,s.Lnext.Lnext.Org)&&(n=a.Lnext,this.delete(a),s=null,a=null),!s||s.Lnext.Org!==o;)s=n;return!0},e.prototype.check=function(){var i,r,s,n,a,o,l=this.fHead,u=this.vHead,h=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Xe(i.prev===r),a=i.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Xe(i.prev===r&&i.anEdge===null),n=u,n=u;(s=n.next)!==u;n=s){Xe(s.prev===n),a=s.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(Xe(s.prev===n&&s.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)Xe(a.Sym.next===o.Sym),Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Org!==null),Xe(a.Dst!==null),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a);Xe(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}(),kO=function(){this.handle=null},zO=function(){this.key=null,this.node=0},aK=function(){function e(i,r){this.leq=r,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 s=0;s<i+1;s++)this.nodes[s]=new kO,this.handles[s]=new zO;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((n=i<<1)<this.size&&this.leq(o[a[n+1].handle].key,o[a[n].handle].key)&&++n,Xe(n<=this.max),s=a[n].handle,n>this.size||this.leq(o[r].key,o[s].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.floatUp_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(s=a[n=i>>1].handle,n===0||this.leq(o[s].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},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 r,s;if(2*(r=++this.size)>this.max){var n,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,n=a;n<this.nodes.length;n++)this.nodes[n]=new kO;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new zO}return this.freeList===0?s=r:(s=this.freeList,this.freeList=this.handles[s].node),this.nodes[r].handle=s,this.handles[s].node=r,this.handles[s].key=i,this.initialized&&this.floatUp_(r),s},e.prototype.extractMin=function(){var i=this.nodes,r=this.handles,s=i[1].handle,n=r[s].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[s].key=null,r[s].node=this.freeList,this.freeList=s,--this.size,this.size>0&&this.floatDown_(1)),n},e.prototype.delete=function(i){var r,s=this.nodes,n=this.handles;Xe(i>=1&&i<=this.max&&n[i].key!==null),s[r=n[i].node].handle=s[this.size].handle,n[s[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[s[r>>1].handle].key,n[s[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[i].key=null,n[i].node=this.freeList,this.freeList=i},e}(),BM=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},LO=function(){this.key=null,this.next=null,this.prev=null},oK=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new LO,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 r=this.head;do r=r.next;while(r.key!==null&&!this.leq(this.frame,i,r.key));return r},e.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var s=new LO;return s.key=r,s.next=i.next,i.next.prev=s,s.prev=i,i.next=s,s},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),lK=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,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.edgeLeq=function(i,r,s){var n=i.event,a=r.eUp,o=s.eUp;return a.Dst===n?o.Dst===n?je.vertLeq(a.Org,o.Org)?je.edgeSign(o.Dst,a.Org,o.Org)<=0:je.edgeSign(a.Dst,o.Org,a.Org)>=0:je.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?je.edgeSign(a.Dst,n,a.Org)>=0:je.edgeEval(a.Dst,n,a.Org)>=je.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&Xe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){Xe(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=s,s.activeRegion=r},e.topLeftRegion=function(i,r){var s,n=r.eUp.Org;do r=e.regionAbove(r);while(r.eUp.Org===n);if(r.fixUpperEdge){if((s=i.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;e.fixUpperEdge(i,r,s),r=e.regionAbove(r)}return r},e.topRightRegion=function(i){var r=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===r);return i},e.addRegionBelow=function(i,r,s){var n=new BM;return n.eUp=s,n.nodeUp=i.dict.insertBefore(r.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,s.activeRegion=n,n},e.isWindingInside=function(i,r){switch(i.windingRule){case ss.ODD:return!!(1&r);case ss.NONZERO:return r!==0;case ss.POSITIVE:return r>0;case ss.NEGATIVE:return r<0;case ss.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(i,r.windingNumber)},e.finishRegion=function(i,r){var s=r.eUp,n=s.Lface;n.inside=r.inside,n.anEdge=s,e.deleteRegion(i,r)},e.finishLeftRegions=function(i,r,s){for(var n,a=null,o=r,l=r.eUp;o!==s;){if(o.fixUpperEdge=!1,(n=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}n=i.mesh.connect(l.Lprev,n.Sym),e.fixUpperEdge(i,a,n)}l.Onext!==n&&(i.mesh.splice(n.Oprev,n),i.mesh.splice(l,n)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,r,s,n,a,o){var l,u,h,d,c=!0;h=s;do Xe(je.vertLeq(h.Org,h.Dst)),e.addRegionBelow(i,r,h.Sym),h=h.Onext;while(h!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),u=r,d=a;(h=(l=e.regionBelow(u)).eUp.Sym).Org===d.Org;)h.Onext!==d&&(i.mesh.splice(h.Oprev,h),i.mesh.splice(d.Oprev,h)),l.windingNumber=u.windingNumber-h.winding,l.inside=e.isWindingInside(i,l.windingNumber),u.dirty=!0,!c&&e.checkForRightSplice(i,u)&&(e.addWinding(h,d),e.deleteRegion(i,u),i.mesh.delete(d)),c=!1,u=l,d=h;u.dirty=!0,Xe(u.windingNumber-h.winding===l.windingNumber),o&&e.walkDirtyRegions(i,u)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=je.vertL1dist(r,i),a=je.vertL1dist(s,i),o=.5*a/(n+a),l=.5*n/(n+a);i.coords[0]+=o*r.coords[0]+l*s.coords[0],i.coords[1]+=o*r.coords[1]+l*s.coords[1],i.coords[2]+=o*r.coords[2]+l*s.coords[2]},e.getIntersectData=function(i,r,s,n,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,s,n),e.vertexWeights(r,a,o)},e.checkForRightSplice=function(i,r){var s=e.regionBelow(r),n=r.eUp,a=s.eUp;if(je.vertLeq(n.Org,a.Org)){if(je.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;je.vertEq(n.Org,a.Org)?n.Org!==a.Org&&(i.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,n)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(n,a.Oprev),r.dirty=s.dirty=!0)}else{if(je.edgeSign(n.Dst,a.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(n.Sym),i.mesh.splice(a.Oprev,n)}return!0},e.checkForLeftSplice=function(i,r){var s,n=e.regionBelow(r),a=r.eUp,o=n.eUp;if(Xe(!je.vertEq(a.Dst,o.Dst)),je.vertLeq(a.Dst,o.Dst)){if(je.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,s=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,s),s.Lface.inside=r.inside}else{if(je.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,s=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),s.Rface.inside=r.inside}return!0},e.checkForIntersect=function(i,r){var s,n,a=e.regionBelow(r),o=r.eUp,l=a.eUp,u=o.Org,h=l.Org,d=o.Dst,c=l.Dst,p=new sf;if(Xe(!je.vertEq(c,d)),Xe(je.edgeSign(d,i.event,u)<=0),Xe(je.edgeSign(c,i.event,h)>=0),Xe(u!==i.event&&h!==i.event),Xe(!r.fixUpperEdge&&!a.fixUpperEdge),u===h||Math.min(u.t,d.t)>Math.max(h.t,c.t))return!1;if(je.vertLeq(u,h)){if(je.edgeSign(c,u,h)>0)return!1}else if(je.edgeSign(d,h,u)<0)return!1;return e.debugEvent(i),je.intersect(d,u,c,h,p),Xe(Math.min(u.t,d.t)<=p.t),Xe(p.t<=Math.max(h.t,c.t)),Xe(Math.min(c.s,d.s)<=p.s),Xe(p.s<=Math.max(h.s,u.s)),je.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=je.vertLeq(u,h)?u:h,je.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),je.vertEq(p,u)||je.vertEq(p,h)?(e.checkForRightSplice(i,r),!1):!je.vertEq(d,i.event)&&je.edgeSign(d,i.event,p)>=0||!je.vertEq(c,i.event)&&je.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=e.topLeftRegion(i,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),a),e.addRightEdges(i,r,o.Oprev,o,o,!0),!0):d===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,r,l.Onext,o.Rprev,n,!0),!0):(je.edgeSign(d,i.event,p)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),je.edgeSign(c,i.event,p)<=0&&(r.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,u,d,h,c),e.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,r){for(var s,n,a=e.regionBelow(r);;){for(;a.dirty;)r=a,a=e.regionBelow(a);if(!r.dirty&&(a=r,(r=e.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,s=r.eUp,n=a.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(n),n=(a=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(i,r),i.mesh.delete(s),s=(r=e.regionAbove(a)).eUp)),s.Org!==n.Org){if(s.Dst===n.Dst||r.fixUpperEdge||a.fixUpperEdge||s.Dst!==i.event&&n.Dst!==i.event)e.checkForRightSplice(i,r);else if(e.checkForIntersect(i,r))return}s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(i,r),i.mesh.delete(s),r=e.regionAbove(a))}},e.connectRightVertex=function(i,r,s){var n,a=s.Onext,o=e.regionBelow(r),l=r.eUp,u=o.eUp,h=!1;l.Dst!==u.Dst&&e.checkForIntersect(i,r),je.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=e.topLeftRegion(i,r),a=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),o),h=!0),je.vertEq(u.Org,i.event)&&(i.mesh.splice(s,u.Oprev),s=e.finishLeftRegions(i,o,null),h=!0),h?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=je.vertLeq(u.Org,l.Org)?u.Oprev:l,n=i.mesh.connect(s.Lprev,n),e.addRightEdges(i,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,r))},e.connectLeftDegenerate=function(i,r,s){var n,a,o,l,u;return n=r.eUp,je.vertEq(n.Org,s)?(Xe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):je.vertEq(n.Dst,s)?(Xe(!1),r=e.topRightRegion(r),a=l=(o=(u=e.regionBelow(r)).eUp.Sym).Onext,u.fixUpperEdge&&(Xe(a!==o),e.deleteRegion(i,u),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),je.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(i.mesh.delete(n.Onext),r.fixUpperEdge=!1),i.mesh.splice(s.anEdge,n),void e.sweepEvent(i,s))},e.connectLeftVertex=function(i,r){var s,n,a,o,l,u,h=new BM;if(h.eUp=r.anEdge.Sym,s=i.dict.search(h).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,je.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=je.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(u=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,u):e.computeWinding(i,e.addRegionBelow(i,s,u)),e.sweepEvent(i,r)):e.addRightEdges(i,s,r.anEdge,r.anEdge,null,!0)}},e.sweepEvent=function(i,r){i.event=r,e.debugEvent(i);for(var s=r.anEdge;s.activeRegion===null;)if((s=s.Onext)===r.anEdge)return void e.connectLeftVertex(i,r);var n=e.topLeftRegion(i,s.activeRegion);Xe(n!==null);var a=e.regionBelow(n),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,n,l):e.addRightEdges(i,n,l.Onext,o,o,!0)},e.addSentinel=function(i,r,s,n){var a=new BM,o=i.mesh.makeEdge();o.Org.s=s,o.Org.t=n,o.Dst.s=r,o.Dst.t=n,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 oK(i,e.edgeLeq);var r=i.bmax[0]-i.bmin[0],s=i.bmax[1]-i.bmin[1],n=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-s,l=i.bmax[1]+s;e.addSentinel(i,n,a,o),e.addSentinel(i,n,a,l)},e.doneEdgeDict=function(i){for(var r,s=0;(r=i.dict.min().key)!==null;)r.sentinel||(Xe(r.fixUpperEdge),Xe(++s===1)),Xe(r.windingNumber===0),e.deleteRegion(i,r)},e.removeDegenerateEdges=function(i){var r,s,n,a=i.mesh.eHead;for(r=a.next;r!==a;r=s)s=r.next,n=r.Lnext,je.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(i,n,r),i.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&((n===s||n===s.Sym)&&(s=s.next),i.mesh.delete(n)),(r===s||r===s.Sym)&&(s=s.next),i.mesh.delete(r))},e.initPriorityQ=function(i){var r,s,n,a=0;for(s=(n=i.mesh.vHead).next;s!==n;s=s.next)a++;for(a+=8,r=i.pq=new aK(a,je.vertLeq),s=(n=i.mesh.vHead).next;s!==n;s=s.next)s.pqHandle=r.insert(s);return s===n&&(r.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,r){var s,n,a;for(s=r.fHead.next;s!==r.fHead;s=n)n=s.next,Xe((a=s.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,r){var s,n;if(r===void 0&&(r=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(s=i.pq.extractMin())!==null;){for(;(n=i.pq.min())!==null&&je.vertEq(n,s);)n=i.pq.extractMin(),e.spliceMergeVertices(i,s.anEdge,n.anEdge);e.sweepEvent(i,s)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},e}(),egt=function(){function e(){this.mesh=new VO,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=ss.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,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},e.prototype.normalize_=function(i){var r=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!r)throw"Zero-size vector!";r=Math.sqrt(r),i[0]/=r,i[1]/=r,i[2]/=r},e.prototype.longAxis_=function(i){var r=0;return Math.abs(i[1])>Math.abs(i[0])&&(r=1),Math.abs(i[2])>Math.abs(i[r])&&(r=2),r},e.prototype.computeNormal_=function(i){var r,s,n,a,o,l,u=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],g=this.mesh.vHead;r=g.next;for(var y=0;y<3;++y)a=r.coords[y],h[y]=a,f[y]=r,u[y]=a,m[y]=r;for(r=g.next;r!==g;r=r.next)for(var v=0;v<3;++v)(a=r.coords[v])<h[v]&&(h[v]=a,f[v]=r),a>u[v]&&(u[v]=a,m[v]=r);var b=0;if(u[1]-h[1]>u[0]-h[0]&&(b=1),u[2]-h[2]>u[b]-h[b]&&(b=2),h[b]>=u[b])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,s=f[b],n=m[b],d[0]=s.coords[0]-n.coords[0],d[1]=s.coords[1]-n.coords[1],d[2]=s.coords[2]-n.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],p[0]=d[1]*c[2]-d[2]*c[1],p[1]=d[2]*c[0]-d[0]*c[2],p[2]=d[0]*c[1]-d[1]*c[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_(d)]=1)},e.prototype.checkOrientation_=function(){for(var i,r,s=this.mesh.fHead,n=this.mesh.vHead,a=0,o=s.next;o!==s;o=o.next)if(!((r=o.anEdge).winding<=0))do a+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(a<0){for(i=n.next;i!==n;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,r,s=this.mesh.vHead,n=[0,0,0],a=!1;n[0]=this.normal[0],n[1]=this.normal[1],n[2]=this.normal[2],!n[0]&&!n[1]&&!n[2]&&(this.computeNormal_(n),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(n);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=n[o]>0?1:-1;for(var l=s.next;l!==s;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,r);a&&this.checkOrientation_();for(var u=!0,h=s.next;h!==s;h=h.next)u?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,u=!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,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,r){var s,n;if((s=r.anEdge).Lnext===s||s.Lnext.Lnext===s)throw"Mono region invalid";for(;je.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;je.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(je.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(je.edgeGoesLeft(n.Lnext)||je.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(je.edgeGoesRight(s.Lprev)||je.edgeSign(s.Dst,s.Org,s.Lprev.Org)>=0);)s=i.connect(s,s.Lprev).Sym;s=s.Lnext}if(n.Lnext===s)throw"Mono region invalid";for(;n.Lnext.Lnext!==s;)n=i.connect(n.Lnext,n).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)if(r=s.next,s.inside&&!this.tessellateMonoRegion_(i,s))return!1;return!0},e.prototype.discardExterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)r=s.next,s.inside||i.zapFace(s)},e.prototype.setWindingNumber_=function(i,r,s){for(var n,a=i.eHead.next;a!==i.eHead;a=n)n=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:s?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,r,s,n){var a,o,l=0,u=0;s>3&&i.mergeConvexFaces(s);for(var h=i.vHead.next;h!==i.vHead;h=h.next)h.n=-1;for(var d=i.fHead.next;d!==i.fHead;d=d.next)if(d.n=-1,d.inside){a=d.anEdge,o=0;do(h=a.Org).n===-1&&(h.n=u,u++),o++,a=a.Lnext;while(a!==d.anEdge);if(o>s)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===Ea.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=u,this.vertices=[],this.vertices.length=u*n,this.vertexIndices=[],this.vertexIndices.length=u,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var c=h.n*n;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],n>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do h=a.Org,this.elements[p++]=h.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ea.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=o;f<s;++f)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,r){var s,n,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){n=s=l.anEdge;do this.vertexCount++,s=s.Lnext;while(s!==n);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*r,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var u=0,h=0,d=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,n=s=l.anEdge;do this.vertices[u++]=s.Org.coords[0],this.vertices[u++]=s.Org.coords[1],r>2&&(this.vertices[u++]=s.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(s):s.Org.idx,o++,s=s.Lnext;while(s!==n);this.elements[d++]=a,this.elements[d++]=o,a+=o}},e.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new VO),i<2&&(i=2),i>3&&(i=3);for(var s=null,n=0;n<r.length;n+=i)s===null?(s=this.mesh.makeEdge(),this.mesh.splice(s,s.Sym)):(this.mesh.splitEdge(s),s=s.Lnext),s.Org.coords[0]=r[n+0],s.Org.coords[1]=r[n+1],s.Org.coords[2]=i>2?r[n+2]:0,s.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(s),s.winding=1,s.Sym.winding=-1},e.prototype.tesselate=function(i,r,s,n,a,o){if(i===void 0&&(i=ss.ODD),r===void 0&&(r=Ea.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,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),lK.computeInterior(this,o);var l=this.mesh;return r===Ea.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ea.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),ss.ODD,ss.NONZERO,ss.POSITIVE,ss.NEGATIVE,ss.ABS_GEQ_TWO,Ea.POLYGONS,Ea.CONNECTED_POLYGONS,Ea.BOUNDARY_CONTOURS});function igt(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let u=(l+1)%i;r+=t[2*l]*t[2*u+1]-t[2*u]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let u=(l+1)%i,h=t[2*u]-t[2*l],d=t[2*u+1]-t[2*l+1],c=Math.hypot(h,d);n.push(c>0?[s*d/c,-s*h/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,u)=>{if(l[0]*u[0]+l[1]*u[1]<=a)return l;let[h,d]=[l[0]+u[0],l[1]+u[1]],c=Math.hypot(h,d);return c>0?[h/c,d/c]:l};return n.map((l,u)=>[o(l,n[(u+i-1)%i]),o(l,n[(u+1)%i])])}function rgt(t,e,i){let r=t.length/2,s=new Float32Array(r+1);if(!(e>0)||!(i>0)||r<2)return{u:s,vScale:0};let n=0;for(let a=0;a<r;a++){let o=(a+1)%r;n+=Math.hypot((t[2*o]-t[2*a])/e,(t[2*o+1]-t[2*a+1])/i),s[a+1]=n}return{u:s,vScale:Math.sqrt(e*i)}}function sgt(t,e,i){for(let r=0;r<i.length;r+=3){let s=3*i[r],n=3*i[r+1],a=3*i[r+2],o=t[n]-t[s],l=t[n+1]-t[s+1],u=t[n+2]-t[s+2],h=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=u*h-o*c,m=o*d-l*h;if((l*c-u*d)*(e[s]+e[n]+e[a])+p*(e[s+1]+e[n+1]+e[a+1])+m*(e[s+2]+e[n+2]+e[a+2])<0){let f=i[r+1];i[r+1]=i[r+2],i[r+2]=f}}}var DG,ngt,NG,agt=j(()=>{}),OG=j(()=>{DG={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},ngt={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},NG={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}});function ogt(t,e){return t.normals[3*e+2]<.9999}function lgt(t){let e=$U.get(t);if(e!==void 0)return e;if(!(t.rise>0))return t;let i=new Float32Array(t.normals),r=t.positions.length/3;for(let n=0;n<r;n++){if(!ogt(t,n))continue;let a=i[3*n],o=i[3*n+1],l=Math.hypot(a,o);if(l===0)continue;let u=t.rise-t.positions[3*n+2],h=Math.min(1,Math.max(0,1-u/t.rise)),d=Math.sqrt(1-h*h);i[3*n]=a/l*d,i[3*n+1]=o/l*d,i[3*n+2]=h}let s={...t,normals:i};return $U.set(t,s),s}function hgt(t,e,i,r){let s=(e-t.minX)/t.spanX,n=(i-t.minY)/t.spanY;return r?[n,s]:[s,n]}var $U,D4,XU,IG=j(()=>{$U=new WeakMap}),F3t=j(()=>{dt(),eT(),ir(),agt(),OG(),IG(),D4=class extends ge{constructor(t,e,i=12,r=ss.ODD,s,n=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=t,this._depth=e,this._curveSegments=i,this._windingRule=r,this._uvPitch=n?void 0:s,this._legacy=n;let a,o=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(z=>z.extractShapePointsToFlatArray([],i))];try{a=Y2({contours:o,windingRule:r,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=NG}let l=a?.vertexCount??0,u=a?.elementCount??0,h=1/0,d=1/0,c=-1/0,p=-1/0;for(let z of o)for(let k=0;k<z.length;k+=2)z[k]<h&&(h=z[k]),z[k]>c&&(c=z[k]),z[k+1]<d&&(d=z[k+1]),z[k+1]>p&&(p=z[k+1]);let m=this._uvPitch,f=m??(c-h||1),g=m??(p-d||1),y=m===void 0?h:0,v=m===void 0?d:0,b=o.map((z,k)=>igt(z,k>0)),_=0;for(let z of b)_+=z.length;let x=2*l+4*_,S=3*u*2+6*_,w=new Float32Array(3*x),T=new Float32Array(3*x),C=new Float32Array(2*x),M=new Uint32Array(S),A=new Uint8Array(x),R=0,O=0,N=0,B=!1,L=(z,k,V,H,W,X,st=(z-y)/f,nt=(k-v)/g)=>{let xt=3*O;w[xt]=z,w[xt+1]=k,w[xt+2]=V,T[xt]=H,T[xt+1]=W,T[xt+2]=X,A[O]=V===e?B?2:1:0,C[2*O]=st,C[2*O+1]=nt,O++};if(a!==void 0)for(let[z,k]of[[e,1],[0,-1]]){let V=O;for(let H=0;H<l;H++)L(a.vertices[2*H],a.vertices[2*H+1],z,0,0,k);for(let H=0;H<u;H++){let[W,X,st]=[a.elements[3*H],a.elements[3*H+1],a.elements[3*H+2]];M[N++]=V+W,M[N++]=V+(k>0?X:st),M[N++]=V+(k>0?st:X)}}B=!0;for(let z=0;z<o.length;z++){let k=o[z],V=b[z],H=k.length/2,{u:W,vScale:X}=n?{u:new Float32Array(H+1),vScale:0}:rgt(k,f,g);R=X;let st=X===0?0:e/X,nt={minX:y,minY:v,spanX:f,spanY:g},xt=(pt,[K,ct],St,wt)=>{let Tt=k[2*pt],yt=k[2*pt+1],[Ot,Ft]=n?hgt(nt,Tt,yt,St):[wt,St?0:st];L(Tt,yt,St?0:e,K,ct,0,Ot,Ft)};for(let pt=0;pt<V.length;pt++){let K=(pt+1)%H,[ct,St]=V[pt],[wt,Tt]=[W[pt],W[pt+1]],yt=O;xt(pt,ct,!1,wt),xt(pt,ct,!0,wt),xt(K,St,!1,Tt),xt(K,St,!0,Tt),M[N++]=yt,M[N++]=yt+1,M[N++]=yt+2,M[N++]=yt+3,M[N++]=yt+2,M[N++]=yt+1}}sgt(w,T,M),this.setAttribute("position",new _e(w,3)),this.setAttribute("normal",new _e(T,3)),this.setAttribute("uv",new _e(C,2)),this.setIndex(new _e(M,1)),this._nearSide=A,this._vScale=R}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale)}canShiftDepthTo(t){return this._nearSide.length>0&&this._depth>0&&t>0}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=new D4(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return t.userData=C5(this.userData),t}}}),ugt=j(()=>{dt(),eT(),ir(),OG(),XU=class extends ge{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=ss.ODD,this.elementType=Ea.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:ss.ODD,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,n,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,u=!0;for(let c=0,p=a.length/2;c<p;c++){let m=2*c,f=a[m+0],g=a[m+1];if(s!==void 0&&f!==s&&(l=!1),n!==void 0&&g!==n&&(u=!1),s=f,n=g,!l&&!u)break}if(!l&&!u)try{r=Y2({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=DG}let h=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new _e(new Float32Array(3*h),3),this._normalAttribute=new _e(new Float32Array(3*h),3),this._uvAttribute=new _e(new Float32Array(2*h),2),this._indexAttribute=new _e(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1];x<c&&(c=x),x>p&&(p=x),S<m&&(m=S),S>f&&(f=S)}let g=p-c,y=f-m;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1],w=(x-c)/g,T=(S-m)/y;this._positionAttribute.setXYZ(v,x,S,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,w,T)}for(let v=0,b=d;v<b;v++){let _=3*v,x=r.elements[_+0],S=r.elements[_+1],w=r.elements[_+2];this._indexAttribute.setX(_+0,x),this._indexAttribute.setX(_+1,S),this._indexAttribute.setX(_+2,w)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let t=new XU(this._shape,this._curveSegments);return t.userData=C5(this.userData),t}}});function U3t(t){return hK||(hK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.80/build",i=Promise.resolve().then(()=>(Mq(),Tq)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),iT=r}())}function j3t(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(mgt.has(s.type)&&s.depth!==void 0&&s.depth>0&&(s.extrudeBevelSize??0)>0&&(e=!0),s.type==="PathGeometry")){let n=s.extrusion;n!==void 0&&n.capType==="round"&&(n.bevel??0)>0&&(e=!0)}}),e}function dgt(t,e){let i=[t.extractShapePointsToFlatArray([],e)];for(let o of t.shapeHoles)i.push(o.extractShapePointsToFlatArray([],e));let r=0;for(let o of i)r+=o.length>>1;let s=new Float64Array(2*r),n=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)s.set(i[o],2*a),a+=i[o].length>>1,n[o]=a;return{points:s,ends:n}}function N4(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=fgt.getNormalMatrix(s).elements;for(let h=0;h<a;h++){let d=3*h,c=3*(i+h),p=t.positions[d],m=t.positions[d+1],f=t.positions[d+2];e.positions[c]=o[0]*p+o[4]*m+o[8]*f+o[12],e.positions[c+1]=o[1]*p+o[5]*m+o[9]*f+o[13],e.positions[c+2]=o[2]*p+o[6]*m+o[10]*f+o[14];let g=t.normals[d],y=t.normals[d+1],v=t.normals[d+2];e.normals[c]=l[0]*g+l[3]*y+l[6]*v,e.normals[c+1]=l[1]*g+l[4]*y+l[7]*v,e.normals[c+2]=l[2]*g+l[5]*y+l[8]*v;let b=2*(i+h);if(n===void 0)e.uvs[b]=t.uvs[2*h],e.uvs[b+1]=t.uvs[2*h+1];else{let[_,x]=n(p,m,t.uvs[2*h],t.uvs[2*h+1],h);e.uvs[b]=_,e.uvs[b+1]=x}}let u=s.determinant()<0;for(let h=0;h<t.indices.length;h+=3)e.indices[r+h]=t.indices[h]+i,e.indices[r+h+1]=t.indices[h+(u?2:1)]+i,e.indices[r+h+2]=t.indices[h+(u?1:2)]+i}function cgt(t){let{owner:e,shape:i,curveSegments:r,assembledAt:s,bevel:n,bevelSegments:a}=t,o=function(c,p){let m=[p],f=g=>{m.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let y of g.points){m.push(y.roundness??0,y.position.x,y.position.y);for(let v of y.controls)m.push(v.position.x,v.position.y)}m.push(g.shapeHoles.length);for(let y of g.shapeHoles)f(y)};return f(c),function(g){let y=2166136261;for(let v=0;v<g.length;v++)y^=g[v],y=Math.imul(y,16777619)>>>0;return y}(new Uint8Array(new Float64Array(m).buffer))}(i,r),l=e??`outline:${o}`,u=`${n}/${a}`,h=O4.get(l);if(h!==void 0&&h.outlineVersion===o&&h.capKey===u&&(t.stillServes?.(h)??1))return YU.placements++,h.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=dgt(c,p);return iT.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),pgt,40)}(i,r,s,n,a);YU.assemblies++;try{let c=function(p,m){return function(f,g,y,v,b){let _=1/0;for(let x=2;x<f.length;x+=3)f[x]<_&&(_=f[x]);if(_===1/0&&(_=0),_!==0)for(let x=2;x<f.length;x+=3)f[x]-=_;return{positions:f,normals:g,uvs:y,indices:v,rise:b-_}}(p.positions(),p.normals(),p.uvs(),p.indices(),m)}(d,s);return O4.set(l,{outlineVersion:o,capKey:u,assembledAt:s,cap:c}),c}finally{d.free()}}function Y1(t,e){return .5*e>1.001*t}var iT,pgt,hK,mgt,fgt,uK,dK,cK,O4,YU,KU,Sm,Zv=j(()=>{dt(),ir(),agt(),IG(),pgt=.4,mgt=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),fgt=new Ts,uK=new _t,dK=new _t,cK=new _t().makeScale(1,1,-1),O4=new Map,YU={assemblies:0,placements:0},KU=class extends ge{constructor(t,e,i=0,r=12,s=3,n,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,iT===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._legacy=o,this._depth=e,this._bevel=i,this._curveSegments=r,this._bevelSegments=s,this._ownerId=n,this.rebuild()}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length>0&&Y1(this._effectiveBevel,t)&&Y1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}setDepth(t){t!==this._depth&&(this._depth=t,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let t=cgt({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>Y1(a.cap.rise,this._depth)&&Y1(a.cap.rise,a.assembledAt)}),e=function(a,o,l,u,h,d=!1){let c=u.positions.length/3,p=l-u.rise,m=u.rise,{points:f,ends:g}=dgt(a,o),y=1/0,v=1/0,b=-1/0,_=-1/0;for(let nt=0;nt<f.length;nt+=2)f[nt]<y&&(y=f[nt]),f[nt]>b&&(b=f[nt]),f[nt+1]<v&&(v=f[nt+1]),f[nt+1]>_&&(_=f[nt+1]);d&&(h=void 0);let x=h??b-y,S=h??_-v,w={minX:y,minY:v,spanX:b-y||1,spanY:_-v||1},T=[],C=0;for(let nt of g)T.push({at:C,count:nt-C}),C=nt;let M=0;for(let nt of T)M+=nt.count;let A=2*c+4*M,R=new Float32Array(3*A),O=new Float32Array(3*A),N=new Float32Array(2*A),B=new Uint32Array(2*u.indices.length+6*M),L=new Uint8Array(A),z=0,k=h===void 0?void 0:(nt,xt)=>[nt/h,xt/h],V=d?(nt,xt,pt,K,ct)=>ogt(u,ct)?[K,pt]:[pt,K]:k,H=d?lgt(u):u,W={positions:R,normals:O,uvs:N,indices:B};N4(H,W,0,0,uK.makeTranslation(0,0,p),k),N4(H,W,c,u.indices.length,dK.makeTranslation(0,0,m).multiply(cK),V),L.fill(1,0,c);let X=2*c,st=2*u.indices.length;for(let nt=0;nt<T.length;nt++){let{at:xt,count:pt}=T[nt],K=f.subarray(2*xt,2*(xt+pt)),ct=igt(K,nt>0),St=d?{u:new Float32Array(pt+1),vScale:0}:rgt(K,x,S),wt=St.u;z=St.vScale;for(let Tt=0;Tt<pt;Tt++){let yt=(Tt+1)%pt,[Ot,Ft]=ct[Tt],Bt=X;for(let[zt,Vt,Wt,$t,Pt,oe]of[[K[2*Tt],K[2*Tt+1],Ot,p,wt[Tt],2],[K[2*yt],K[2*yt+1],Ft,p,wt[Tt+1],2],[K[2*yt],K[2*yt+1],Ft,m,wt[Tt+1],0],[K[2*Tt],K[2*Tt+1],Ot,m,wt[Tt],0]]){let jt=3*X;if(R[jt]=zt,R[jt+1]=Vt,R[jt+2]=$t,O[jt]=Wt[0],O[jt+1]=Wt[1],O[jt+2]=0,d){let[Zt,Jt]=hgt(w,zt,Vt,oe===0);N[2*X]=Zt,N[2*X+1]=Jt}else N[2*X]=Pt,N[2*X+1]=z===0?0:($t-m)/z;L[X]=oe,X++}B[st++]=Bt,B[st++]=Bt+1,B[st++]=Bt+2,B[st++]=Bt,B[st++]=Bt+2,B[st++]=Bt+3}}return sgt(R,O,B),{positions:R,normals:O,uvs:N,indices:B,nearSide:L,vScale:z}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch,this._legacy);this._nearSide=e.nearSide,this._vScale=e.vScale,this._effectiveBevel=t.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),s=this.getAttribute("uv"),n=this.getIndex();if(i!==void 0&&r!==void 0&&s!==void 0&&n!==null&&i.array.length===e.positions.length&&r.array.length===e.normals.length&&s.array.length===e.uvs.length&&n.array.length===e.indices.length)return i.array.set(e.positions),r.array.set(e.normals),s.array.set(e.uvs),n.array.set(e.indices),i.needsUpdate=!0,r.needsUpdate=!0,s.needsUpdate=!0,void(n.needsUpdate=!0);this.setAttribute("position",new _e(e.positions,3)),this.setAttribute("normal",new _e(e.normals,3)),this.setAttribute("uv",new _e(e.uvs,2)),this.setIndex(new _e(e.indices,1))}clone(){let t=new KU(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return t.userData=C5(this.userData),t}}}),ym=j(()=>{wm(),F3t(),ugt(),Zv(),eT(),Sm=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:ss.ODD},t.parameters),s=Math.abs(r.width),n=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=t.shape??e?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ds?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ds(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let u=i??new ds(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:u,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:u}=t.parameters,h=u===1;return t.shape.roundness=a,i<=0?e=new XU(t.shape,n,{windingRule:o}):r<=0?e=new D4(t.shape,i,n,o,l,h):iT!==void 0?e=new KU(t.shape,i,r,n,s,t.ownerId,l,h):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new D4(t.shape,i,n,o,l,h)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function G3t(t,e,i,r,s,n){if(r>=BG)return s>30||s%4==0?(function(h,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;h.addPoint(VM(m-d,f,m-d,f-v,m-d,f+v)),h.addPoint(VM(m,f+c,m-y,f+c,m+y,f+c)),h.addPoint(VM(m+d,f,m+d,f+v,m+d,f-v)),h.addPoint(VM(m,f-c,m+y,f-c,m-y,f-c)),p>0&&ygt(h,d,c,p)}(t,e,i,n),Math.round(s/4)):pK(t,r,s,e,i,n);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},u=function({px:h,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(h-c)/2,_=(d-p)/2;if(b===0&&_===0)return[];m=Math.abs(m),f=Math.abs(f);let x=Math.pow(b,2)/Math.pow(m,2)+Math.pow(_,2)/Math.pow(f,2);x>1&&(m*=Math.sqrt(x),f*=Math.sqrt(x));let S=function(O,N,B,L,z,k,V,H,W,X){let st=Math.pow(z,2),nt=Math.pow(k,2),xt=Math.pow(V,2),pt=Math.pow(H,2),K=st*nt-st*pt-nt*xt;K<0&&(K=0),K/=st*pt+nt*xt,K=Math.sqrt(K)*(W===X?-1:1);let ct=K*z/k*H,St=K*-k/z*V,wt=ct+(O+B)/2,Tt=St+(N+L)/2,yt=(V-ct)/z,Ot=(H-St)/k,Ft=(-V-ct)/z,Bt=(-H-St)/k,zt=nK(1,0,yt,Ot),Vt=nK(yt,Ot,Ft,Bt);return!X&&Vt>0&&(Vt-=UP),X&&Vt<0&&(Vt+=UP),{centerx:wt,centery:Tt,ang1:zt,ang2:Vt}}(h,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:C,centery:M}=S,A=Math.abs(T)/(UP/4);Math.abs(1-A)<1e-7&&(A=1);let R=Math.max(Math.ceil(A),1);T/=R;for(let O=0;O<R;O++)v.push(z3t(w,T)),w+=T;return v.map(O=>{let{x:N,y:B}=BO(O[0],m,f,C,M),{x:L,y:z}=BO(O[1],m,f,C,M),{x:k,y:V}=BO(O[2],m,f,C,M);return{x1:N,y1:B,x2:L,y2:z,x:k,y:V}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%u.length===0?function(h,d,c,p,m,f,g,y){let v=Math.round(m/p.length);h.addPoint(mv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=h.points[b],w=mv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),h.addPoint(w)}return y>0?ggt(h,f,g,y):h.addPoint(mv(0,0)),v}(t,a.x,a.y,u,s,e,i,n):pK(t,r,s,e,i,n)}function pK(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,u=Math.sin(l)*r,h=Math.cos(l)*s;t.addPoint(mv(u,h))}return e<BG?n>0?ggt(t,r,s,n):t.addPoint(mv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&ygt(t,r,s,n)),1}function mv(t,e){return new qg(qt.generateUUID(),new Q(t,e))}function VM(t,e,i,r,s,n){let a=mv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function ggt(t,e,i,r){vgt(t,e,i,r).forEach(s=>t.addPoint(s))}function ygt(t,e,i,r){let s=vgt(t,e,i,r),n=new ds;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function vgt(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Q(s/e,n/i),o=t.points.map(l=>{let u=l.clone();return u.uuid=qt.generateUUID(),u}).reverse();return o.forEach(l=>{l.position.multiply(a);let u=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(u)}),o}var BG,q5,bgt,FO,_gt,I4=j(()=>{wm(),tgt(),L3t(),ym(),dt(),BG=2*Math.PI,q5=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=qt.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,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:r,spikes:s,angle:n,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=t.parameters,d=t.shape,c=G3t(d,.5*i,.5*r,n*Math.PI/180,s,a);return d.isClosed=!0,d.update(),n===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=Sm.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),mK=j(()=>{dt(),Xft(),bgt=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:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new FO(.5*e,n,a):new R8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},FO=class extends P4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,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],s,t,e,i),this.type=s}static fromJSON(t){return new FO(t.radius,t.corner,t.cornerSides)}}}),fK=j(()=>{dt(),_gt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[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:r}=t.parameters,s=new _S;s.moveTo(e[0].x,e[0].y),s.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new D8(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function j0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function W3t(t){let{positions:e,faces:i,materialIndices:r,uvs:s}=t,n=e.length/3,a=i.length/3,o=s!==null&&a>0,l=3*a,u=new Uint32Array(l),h=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,f=8;for(;f<2*l;)f*=2;let g=f-1,y=new Int32Array(f).fill(-1),v=(N,B)=>{let L=(Math.imul(N,2654435761)^B)&g;for(;;){let z=y[L];if(z===-1)return y[L]=m,u[m]=N,h[m]=B,m++;if(u[z]===N&&h[z]===B)return z;L=L+1&g}},b=(N,B)=>{let L=N<B?N:B,z=N<B?B:N,k=(Math.imul(L,2654435761)^z)&g;for(;;){let V=y[k];if(u[V]===L&&h[V]===z)return V;k=k+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(N,B,L)=>{let z=N<B?v(N,B):v(B,N),k=++d[z];k===1?c[z]=L:k===2&&(p[z]=L),_[N]++,_[B]++,x[3*N]+=e[3*B],x[3*N+1]+=e[3*B+1],x[3*N+2]+=e[3*B+2],x[3*B]+=e[3*N],x[3*B+1]+=e[3*N+1],x[3*B+2]+=e[3*N+2]};for(let N=0;N<a;N++){let B=i[3*N],L=i[3*N+1],z=i[3*N+2];S(B,L,z),S(L,z,B),S(z,B,L)}let w=new Float64Array(3*m);for(let N=0;N<m;N++){let B=3*u[N],L=3*h[N];if(d[N]===2){let z=3*c[N],k=3*p[N];w[3*N]=.375*(e[B]+e[L])+.125*(e[z]+e[k]),w[3*N+1]=.375*(e[B+1]+e[L+1])+.125*(e[z+1]+e[k+1]),w[3*N+2]=.375*(e[B+2]+e[L+2])+.125*(e[z+2]+e[k+2])}else w[3*N]=.5*(e[B]+e[L]),w[3*N+1]=.5*(e[B+1]+e[L+1]),w[3*N+2]=.5*(e[B+2]+e[L+2])}let T,C=new Float64Array(3*n);for(let N=0;N<n;N++){let B=_[N];B===3?T=3/16:B>3&&(T=3/(8*B));let L=1-B*Number(T),z=Number(T);B===2&&(L=3/4,z=1/8),C[3*N]=e[3*N]*L+x[3*N]*z,C[3*N+1]=e[3*N+1]*L+x[3*N+1]*z,C[3*N+2]=e[3*N+2]*L+x[3*N+2]*z}let M=new Float64Array(3*(n+m));M.set(C),M.set(w,3*n);let A=new Uint32Array(12*a),R=new Array(4*a),O=o?new Float64Array(24*a):null;for(let N=0;N<a;N++){let B=i[3*N],L=i[3*N+1],z=i[3*N+2],k=b(B,L)+n,V=b(L,z)+n,H=b(z,B)+n,W=12*N;A[W++]=k,A[W++]=V,A[W++]=H,A[W++]=B,A[W++]=k,A[W++]=H,A[W++]=L,A[W++]=V,A[W++]=k,A[W++]=z,A[W++]=H,A[W++]=V;let X=r[N];if(R[4*N]=X,R[4*N+1]=X,R[4*N+2]=X,R[4*N+3]=X,O!==null){let st=6*N,nt=s[st],xt=s[st+1],pt=s[st+2],K=s[st+3],ct=s[st+4],St=s[st+5],wt=j0(nt,pt),Tt=j0(xt,K),yt=j0(pt,ct),Ot=j0(K,St),Ft=j0(nt,ct),Bt=j0(xt,St),zt=24*N;O[zt++]=wt,O[zt++]=Tt,O[zt++]=yt,O[zt++]=Ot,O[zt++]=Ft,O[zt++]=Bt,O[zt++]=nt,O[zt++]=xt,O[zt++]=wt,O[zt++]=Tt,O[zt++]=Ft,O[zt++]=Bt,O[zt++]=pt,O[zt++]=K,O[zt++]=yt,O[zt++]=Ot,O[zt++]=wt,O[zt++]=Tt,O[zt++]=ct,O[zt++]=St,O[zt++]=Ft,O[zt++]=Bt,O[zt++]=yt,O[zt++]=Ot}}return{positions:M,faces:A,materialIndices:R,uvs:O}}var kM,xgt,en,wgt,VG,q3t=j(()=>{dt(),kM=1e4,xgt=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(r){let s=r.getAttribute("position");if(s===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let n=r.getAttribute("uv"),a=r.getIndex(),o=s.count,l=new Map,u=new Uint32Array(o),h=[],d=0;for(let v=0;v<o;v++){let b=s.getX(v),_=s.getY(v),x=s.getZ(v),S=Math.round(b*kM),w=Math.round(_*kM),T=Math.round(x*kM),C=l.get(S);C===void 0&&(C=new Map,l.set(S,C));let M=C.get(w);M===void 0&&(M=new Map,C.set(w,M));let A=M.get(T);A===void 0&&(A=d++,M.set(T,A),h.push(b,_,x)),u[v]=A}let c=[],p=[],m=n===void 0?null:[],f=a!==null?a.count:o,g=(v,b)=>{let _=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,S=a!==null?a.getX(v+2):v+2;if(!(_<o&&x<o&&S<o))return;let w=u[_],T=u[x],C=u[S];w===T||T===C||C===w||(c.push(w,T,C),p.push(b),m!==null&&m.push(n.getX(_),n.getY(_),n.getX(x),n.getY(x),n.getX(S),n.getY(S)))},y=r.groups;if(y.length>0)for(let v=0;v<y.length;v++){let b=y[v],_=b.materialIndex===void 0?0:b.materialIndex,x=Math.max(b.start,0),S=Math.min(b.start+b.count,f);for(let w=x;w<S&&w+2<f;w+=3)g(w,_)}else for(let v=0;v+2<f;v+=3)g(v,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=W3t(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,u=n.length/3,h=a.length/3,d=new Float64Array(3*u);for(let y=0;y<h;y++){let v=3*a[3*y],b=3*a[3*y+1],_=3*a[3*y+2],x=n[_]-n[b],S=n[_+1]-n[b+1],w=n[_+2]-n[b+2],T=n[v]-n[b],C=n[v+1]-n[b+1],M=n[v+2]-n[b+2],A=S*M-w*C,R=w*T-x*M,O=x*C-S*T;d[v]+=A,d[v+1]+=R,d[v+2]+=O,d[b]+=A,d[b+1]+=R,d[b+2]+=O,d[_]+=A,d[_+1]+=R,d[_+2]+=O}for(let y=0;y<u;y++){let v=d[3*y],b=d[3*y+1],_=d[3*y+2],x=Math.sqrt(v*v+b*b+_*_)||1;d[3*y]=v/x,d[3*y+1]=b/x,d[3*y+2]=_/x}let c=3*h,p=new Float32Array(3*c),m=new Float32Array(3*c),f=l!==null&&l.length>0?new Float32Array(2*c):null;for(let y=0;y<c;y++){let v=3*a[y];p[3*y]=n[v],p[3*y+1]=n[v+1],p[3*y+2]=n[v+2],m[3*y]=d[v],m[3*y+1]=d[v+1],m[3*y+2]=d[v+2]}f!==null&&f.set(l.subarray(0,2*c));let g=new ge;g.setAttribute("position",new _e(p,3)),c>0&&(g.setAttribute("normal",new _e(m,3)),g.setAttribute("color",new _e(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new _e(f,2));for(let y=0;y<h;){let v=o[y],b=y;do y++;while(y<h&&o[y]===v);g.addGroup(3*b,3*(y-b),v)}return s.boundingBox!==null&&(g.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(g.boundingSphere=s.boundingSphere.clone()),g}(e,t)}}}),gK=j(()=>{dt(),q3t(),en=new P,wgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new ge().copy(new Zh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(en),i={width:en.x,height:en.y,depth:en.z,subdivisions:0}):i=e.parameters;let s={...i,...t.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(t){let{width:e,height:i,depth:r,subdivisions:s}=t.parameters,n=t.geometry??new ge().copy(new Zh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let u=new pr,h=l.attributes.position;return h?(u.setFromBufferAttribute(h),u):(u.makeEmpty(),u)}(n),n.boundingBox.getSize(en)):en.set(a.width,a.height,a.depth),(e!==en.x||i!==en.y||r!==en.z)&&n.scale(en.x===0?1:e/en.x,en.y===0?1:i/en.y,en.z===0?1:r/en.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new xgt(s).modify(o)):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete t.geometry,Object.assign(n,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new $7(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(en);let n=100/en.x;Object.assign(s.parameters,{width:100,height:en.y*n,depth:en.z*n}),e(this.build(s))})}}}),ZU=j(()=>{wm(),ym(),VG=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 ds?t.shape:new ds,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:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=t.parameters,u=t.shape,h=.5*e,d=.5*i,c=2*Math.PI/r;for(let m=0;m<r;m++){let f=c*m,g=0+Math.sin(f)*h,y=0+Math.cos(f)*d;u.addPoint(u.createPoint(g,y))}u.isClosed=!0;for(let m=0,f=u.points.length;m<f;m++)u.points[m].roundness=s;u.roundness=s,u.update();let p=Sm.create({shape:u,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...t,type:"PolygonGeometry"}})}}});function h_(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function UO(t,e,i,r,s,n){let a=Tgt.copy(e).sub(t),o=Mgt.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let u=a.add(o).normalize();n.copy(t).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(u)),n.addScaledVector(o,r/Math.sin(u))}}function H3t(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var Sgt,Tgt,Mgt,yK,H5,Agt,Cgt,Egt,vK,kG,Pgt,Rgt,Dgt,Ngt,bK=j(()=>{dt(),Sgt=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:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=new yK(.5*e,i,s,n,a,o,l),h=r/e;return h!==1&&u.scale(1,1,h),Object.assign(u,{userData:{...t,type:"PyramidGeometry"}})}},Tgt=new P,Mgt=new P,yK=class extends ge{constructor(t=.5,e=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o,l=[],u=[],h=[],d=[],c=0,p=e/2,m=Math.PI/i,f=t*Math.cos(Math.PI/i),g=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new P(0,-p,0),_=new P(0,p,0),x=new Q(t,-p),S=new Q(f,-p),w=new Q(0,_.y).sub(S),T=new Q(0,_.y).sub(x),C=new Q(w.y,-w.x).normalize(),M=new Q(T.y,-T.x).normalize(),A=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,A);{let k=new P(C.x,C.y,0),V=new P(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);o=k.angleTo(V)}let R=n/Math.tan((Math.PI-w.angle())/2),O=n/Math.tan((Math.PI-o)/2),N=new P;if(!s){u.push(b.x,b.y,b.z),h.push(0,-1,0),d.push(0,0);let k=c++,V=[],H=x.clone(),W=R/Math.cos(Math.PI/i);H.x-=W;for(let X=0;X<i;X++){let st=X/i*Math.PI*2+m;h_(H,new Q(Math.sin(st),Math.cos(st)),N),u.push(N.x,N.y,N.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let X=0;X<V.length;X++)l.push(V[X],k,V[(X+1)%V.length])}let B=[];{let k=new P,V=new P,H=new P,W=new P,X=new P,st=new P;for(let nt=0;nt<i;nt++){let xt=nt/i*Math.PI*2+m,pt=(nt+.5)/i*Math.PI*2+m,K=(nt+1)/i*Math.PI*2+m,ct=new Q(Math.sin(xt),Math.cos(xt)),St=new Q(Math.sin(pt),Math.cos(pt)),wt=new Q(Math.sin(K),Math.cos(K));h_(x,ct,V),h_(x,wt,H),h_(C,St,k),UO(_,V,H,O,O,W),u.push(W.x,W.y,W.z),UO(V,_,H,O,R,X),u.push(X.x,X.y,X.z),UO(H,V,_,R,O,st),u.push(st.x,st.y,st.z),h.push(k.x,k.y,k.z),h.push(k.x,k.y,k.z),h.push(k.x,k.y,k.z),d.push(0,0),d.push(0,0),d.push(0,0);let Tt=c++,yt=c++,Ot=c++;if(l.push(Tt,yt,Ot),n>0){{let zt=V.clone().add(H).multiplyScalar(.5),Vt=_.clone().sub(zt).normalize(),Wt=b.clone().sub(zt).normalize().add(Vt).normalize().multiplyScalar(-1);L(zt,st.clone().sub(X),Wt,w.angle())}let Ft,Bt;{let zt=new P;h_(M,wt,zt);let Vt=st.clone().add(W).multiplyScalar(.5);Vt=H3t(Vt,H,_);let Wt=st.clone().sub(W);[Ft,Bt]=L(Vt,Wt,zt,o,W.y)}{let zt=Ft,Vt=zt.clone().setY(0).normalize(),Wt=new P(0,-1,0),$t=Vt.clone().cross(Wt);z(zt,Vt,Wt,$t)}B.concat(Bt);{let zt=w.angle(),Vt=Math.PI-zt,Wt=_.clone();Wt.y-=n/Math.sin(zt-Math.PI/2);let $t=new P,Pt=[];for(let jt=0;jt<a;jt++){let Zt=[],Jt=Math.PI/2-Vt*jt/a,$=Math.cos(Jt),se=Math.sin(Jt),Pe=pt;for(let Ve=0;Ve<=jt;Ve++){let ie=Math.cos(Pe),oi=Math.sin(Pe);k.x=$*oi,k.y=se,k.z=$*ie,$t.copy(Wt).addScaledVector(k,n),u.push($t.x,$t.y,$t.z),h.push(k.x,k.y,k.z),d.push(0,0),Zt.push(c++),Pe+=2*Math.PI/jt/i}Pt.push(Zt)}Bt.reverse(),Pt.push(Bt);let oe=Pt.length-1;for(let jt=0;jt<oe;jt++){let Zt=Pt[jt],Jt=Pt[jt+1],$=Zt.length-1;l.push(Jt[1],Zt[0],Jt[0]);for(let se=1;se<=$;se++)l.push(Zt[se],Zt[se-1],Jt[se]),l.push(Jt[se+1],Zt[se],Jt[se])}}}}}function L(k,V,H,W,X){let st=-W/2,nt=(Math.PI-W)/2,xt=V.clone().normalize().cross(H);k.addScaledVector(H,-n/Math.sin(nt));let pt=new P,K=new P,ct=c,St=[];for(let wt=0;wt<=a;wt++){let Tt=st+wt/a*W;K.set(0,0,0),K.addScaledVector(xt,Math.sin(Tt)),K.addScaledVector(H,Math.cos(Tt));for(let yt=0;yt<=1;yt++){let Ot=yt/1-.5;if(pt.copy(k),pt.addScaledVector(V,Ot),pt.addScaledVector(K,n),X!=null){let Ft=Math.max(0,pt.y-X);pt.addScaledVector(V,-Ft/V.y)}u.push(pt.x,pt.y,pt.z),h.push(K.x,K.y,K.z),d.push(0,0),yt===0&&St.push(c),c++}}for(let wt=0;wt<a;wt++)for(let Tt=0;Tt<1;Tt++){let yt=ct+Tt+2*wt,Ot=yt+2,Ft=Ot+1,Bt=yt+1;l.push(yt,Ot,Bt),l.push(Ot,Ft,Bt)}return[k.clone().addScaledVector(V,.5),St]}function z(k,V,H,W){let X=Math.PI/2,st=T.angle()-X,nt=[],xt=new P,pt=new P;for(let ct=0;ct<=a;ct++){let St=[],wt=ct/a;for(let Tt=0;Tt<=ct;Tt++){let yt=((ct?Tt/ct:0)-.5)*v,Ot=Math.cos(yt),Ft=Math.sin(yt),Bt=(X+Math.atan(Math.tan(st)*Ot))*wt,zt=Math.cos(Bt),Vt=Math.sin(Bt);xt.set(0,0,0),xt.addScaledVector(V,Vt*Ot),xt.addScaledVector(H,zt),xt.addScaledVector(W,Vt*Ft),pt.copy(k).addScaledVector(xt,n),u.push(pt.x,pt.y,pt.z),h.push(xt.x,xt.y,xt.z),d.push(0,0),St.push(c++)}nt.push(St)}let K=nt.length-1;for(let ct=0;ct<K;ct++){let St=nt[ct],wt=nt[ct+1],Tt=St.length-1;l.push(St[0],wt[1],wt[0]);for(let yt=1;yt<=Tt;yt++)l.push(St[yt-1],St[yt],wt[yt]),l.push(St[yt],wt[yt+1],wt[yt])}}this.setIndex(l),this.setAttribute("position",new fe(u,3)),this.setAttribute("normal",new fe(h,3)),this.setAttribute("uv",new fe(d,2))}}}),B4=j(()=>{wm(),ym(),H5=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),r=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(t){let e=t.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}=t.parameters,h={x:.5*i,y:.5*r},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function p(x,S,w){return S>i&&w>r?Math.min(x*i/S,x*r/w):S>i?x*i/S:w>r?x*r/w:x}let m=[];m[0]=s[0]===0?0:p(s[0],s[0]+s[3],s[0]+s[1]),m[1]=s[1]===0?0:p(s[1],s[1]+s[2],s[1]+s[0]),m[2]=s[2]===0?0:p(s[2],s[2]+s[1],s[2]+s[3]),m[3]=s[3]===0?0:p(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,g=c.x,y=c.y,v=d.y;e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(g,v)),e.addPoint(e.createPoint(f,v)),e.isClosed=!0;let b=!0;for(let x=0,S=e.points.length;x<S;x++)e.points[x].roundness=m[x],x>0&&m[x]!==m[x-1]&&(b=!1);b&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let _=Sm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),_K=j(()=>{dt(),Agt=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=qt.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:r=i,depth:s=i,widthSegments:n=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:u,thetaLength:h}=t.parameters;return h===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=new Mc(.5*i,n,a,o,l,u,h*qt.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),xK=j(()=>{dt(),Cgt=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:r=8,heightSegments:s=8}=t.parameters,n=new Cc(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),wK=j(()=>{dt(),Egt=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:r,angle:s,cornerRadius:n,cornerSegments:a}=t.parameters,o=new vK(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},vK=class extends ge{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],u=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-u,r),r*=Math.PI/180;let h=[],d=Math.PI/2,c=(pt=0,K=0,ct=0)=>new P(pt,K,ct),p=c(),m=c(),[f,g,y]=[e/2,t/2,i/2],v=-g,b=+g,[_,x,S]=[c(v,-f,+y),c(v,-f,-y),c(v,+f,-y)],w=(pt,K=!1)=>Math.sin(pt-Math.PI/(+K+1)),T=(pt,K=!1)=>Math.cos(pt-Math.PI/(+K+1));S.y=Math.sin(r)*e-f;let C=Math.cos(r)*e-y,M=_.z-u;r<=d?(S.z=Math.min(C,M),S.z==M&&(S.y-=(C-M)/Math.tan(d-r))):x.z=Math.min(x.z-C-y,_.z-u),p.subVectors(_,x),m.subVectors(S,x);let A=Math.min(p.length(),m.length())*s/100,R=A*Math.tan(r/2),O=A/Math.cos(r/2),N=p.clone().normalize().add(m.normalize()).setLength(O).add(x);p.set(0,w(r,!0),T(r,!0)),h.push([S,p.clone()]);let B=(Math.PI-r)/n;for(let pt=0;pt<=n;pt++){let K=d+r+pt*B;p.set(0,Math.sin(K)*R,Math.cos(K)*R),p.add(N),m.set(0,w(K),T(K)),h.push([p.clone(),m.clone()])}h.push([_,c(0,1,0)]);let L=Math.sin(B/2)*R*2,z=h.length-1,k=h[0][0].distanceTo(h[1][0]),V=k+L*n+h[z-1][0].distanceTo(h[z][0]);h[0].push(1);for(let pt=0;pt<=n;pt++)h[pt+1].push(1-(k+pt*L)/V);h[z].push(0);let H,W,X,[st,nt,xt]=h[0];for(let pt=1;pt<h.length;pt++)[H,W,X]=h[pt],a.push(v,st.y,st.z,v,H.y,H.z,b,st.y,st.z,b,st.y,st.z,v,H.y,H.z,b,H.y,H.z),o.push(0,nt.y,nt.z,0,W.y,W.z,0,nt.y,nt.z,0,nt.y,nt.z,0,W.y,W.z,0,W.y,W.z),l.push(0,xt,0,X,1,xt,1,xt,0,X,1,X),[st,nt,xt]=[H,W,X];this.setAttribute("position",new fe(a,3)),this.setAttribute("normal",new fe(o,3)),this.setAttribute("uv",new fe(l,2))}}}),QU=j(()=>{wm(),ym(),kG=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 ds?t.shape:new ds,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:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=t.parameters,d=t.shape,c=.5*e,p=.5*i,m=a*Math.PI/360/s,f=Math.PI/2*3*-1,g=c*r/100,y=p*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let _=m*b,x=0+Math.sin(_)*c,S=0+Math.cos(_)*p;d.addPoint(d.createPoint(x,S))}}else for(let b=0;b<s;b++){let _=0+Math.cos(f)*c,x=0+Math.sin(f)*p;d.addPoint(d.createPoint(_,x)),f+=m,_=0+Math.cos(f)*g,x=0+Math.sin(f)*y,d.addPoint(d.createPoint(_,x)),f+=m}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let v=Sm.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}});return Object.assign(v,{userData:{...t,type:"StarGeometry"}})}}}),SK=j(()=>{dt(),Pgt=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,r=new Cc(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),TK=j(()=>{dt(),OS(),Rgt=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),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let n=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=function(h,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=qt.clamp(m/360,0,1);if(x===0){let S=new ge;return S.setAttribute("position",new fe([],3)),S}return x===1&&(b=0),new kU(!0,h,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return u.scale(1,i/e,1),Object.assign(u,{userData:{...t,type:"TorusGeometry"}})}}}),MK=j(()=>{dt(),Dgt=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:r,radialSegments:s,p:n,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new N8(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),AK=j(()=>{wm(),ym(),Ngt=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 ds?t.shape:new ds,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:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=t.parameters,u=t.shape,h=.5*e,d=.5*i;o?(u.addPoint(u.createPoint(-h,d)),u.addPoint(u.createPoint(h,-d)),u.addPoint(u.createPoint(-h,-d))):(u.addPoint(u.createPoint(0,d)),u.addPoint(u.createPoint(h,-d)),u.addPoint(u.createPoint(-h,-d))),u.isClosed=!0;for(let p=0,m=u.points.length;p<m;p++)u.points[p].roundness=r;u.roundness=r,u.update();let c=Sm.create({shape:u,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...t,type:"TriangleGeometry"}})}}}),$3t=j(()=>{dt()}),X3t=j(()=>{dt(),new ta,new _t,new mc,new P,new P,new P,new P});function CK(){let t=new ge;return t.setAttribute("position",new _e(new Float32Array([]),3)),t.setIndex(new _e(new Uint16Array([]),1)),t}var EK,JU,Ogt=j(()=>{hn(),ke(),eT(),dt(),ZS(),wm(),ym(),Zv(),EK=CK().attributes,JU=class extends ge{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this._nearSide=new Uint8Array(0),this._depth=0,this._effectiveBevel=0,this._vScale=0,Object.assign(this.attributes,EK),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:r,height:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:u,fontSize:h,extrusionVersion:d}=t,c=Na.getDisplayedValue(l),p=function(S,w,T,C){let M=typeof S.width=="string"?Number(C.getVariable(S.width)):S.width,A=[""],R="";for(let O of T)R+=O,O===" "||O===`
|
|
351
|
+
`;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),h=u.width,d=u.height,c=function(p,m,f){let g=m;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*m*f);y.length||e(4,"unable to allocate buffer space");let v=0,b=0,_=4*g,x=new Uint8Array(4),S=new Uint8Array(_),w=f;for(;w>0&&b<p.byteLength;){b+4>p.byteLength&&e(1),x[0]=p[b++],x[1]=p[b++],x[2]=p[b++],x[3]=p[b++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&e(3,"bad rgbe scanline format");let T,C=0;for(;C<_&&b<p.byteLength;){T=p[b++];let A=T>128;if(A&&(T-=128),(T===0||C+T>_)&&e(3,"bad scanline data"),A){let R=p[b++];for(let O=0;O<T;O++)S[C++]=R}else S.set(p.subarray(b,b+T),C),C+=T,b+=T}let M=g;for(let A=0;A<M;A++){let R=0;y[v]=S[A+R],R+=g,y[v+1]=S[A+R],R+=g,y[v+2]=S[A+R],R+=g,y[v+3]=S[A+R],v+=4}w--}return y}(n.subarray(n.pos),h,d);switch(this.type){case Qe:l=c.length/4;let p=new Float32Array(4*l);for(let f=0;f<l;f++)r(c,4*f,p,4*f);a=p,o=Qe;break;case ai:l=c.length/4;let m=new Uint16Array(4*l);for(let f=0;f<l;f++)s(c,4*f,m,4*f);a=m,o=ai;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:a,header:u.string,gamma:u.gamma,exposure:u.exposure,type:o,colorSpace:Xu,minFilter:me,magFilter:me,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function LY(t){return t.length>2&&t[0]===35&&t[1]===63}function OO(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function zft(t){let e=new br(t.data,t.width,t.height,on,ai);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var FY,AG,gg,Lft=j(()=>{dt(),A3t()}),Fft=j(()=>{dt(),Vft(),kft(),Lft(),FY=0,AG=class extends Oft{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++FY,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 r of Object.values(this._cache))for(let s of Object.values(r))for(let n of Object.values(s))n&&(n.image=this.img,n.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 r,s=new FileReader;s.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(n=>{s.onloadend=a=>{r=a.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?LY(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let r=t instanceof Uint8Array?t:null;if(r===null)try{r=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{r=null}let s=r!==null&&LY(r)?function(n){try{let a=new Bft().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,u=a.data,h=new Uint16Array(u.length),d=4*o,c=f=>Kh.toHalfFloat(Math.pow(Math.max(Kh.fromHalfFloat(f),0),1/2.2)),p=new Map,m=f=>{let g=p.get(f);return g===void 0&&(g=c(f),p.set(f,g)),g};for(let f=0;f<l;f++){let g=f*d,y=(l-1-f)*d;for(let v=0;v<d;v+=4)h[y+v]=m(u[g+v]),h[y+v+1]=m(u[g+v+1]),h[y+v+2]=m(u[g+v+2]),h[y+v+3]=u[g+v+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(r):null;s!==null&&(this.isHdr=!0,this.img=s,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:(X2||(X2=new Nft),X2.load(i)),this.img.onload=e,await new Promise(r=>{this.img.onload=()=>{e(),r(null)}});var i}getTexture(t,e=1008,i=1006){let r=this._cache[t]?.[e]?.[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new q7(this.img,void 0,t,t):this.isHdr?(s=zft(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new pi(this.img,void 0,t,t,i,e),this.isBuffer||(s.anisotropy=8,s.generateMipmaps=e===1008),this.loaded&&(s.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]=s,s}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let r of Object.values(i))r&&(r.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,r]of Object.entries(e))for(let[s,n]of Object.entries(r))n?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),Uft=j(()=>{Fft(),gg=class extends AG{}});function C3t(t){if(typeof t=="string")return t;let e=UU.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},UU.set(t,e)),e.url}var UU,E3t=j(()=>{UU=new Map});function P3t(){if(!jU)return UY||(UY=async function(){await Promise.resolve().then(()=>(bq(),Oxt)),jft(window!==void 0?window:global),jU=!0}())}var jft,Gft,jU,UY,Wft=j(()=>{Gft=new Promise(t=>{jft=t}),jU=!1});function jY(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(r=>{e.push(...r.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(e.push(...r.data.ifActions),e.push(...r.data.elseActions))}))})}function R3t(t){let e=!1,i=[];return t.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((n,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;jY(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;jY(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var GY,X1,CG=j(()=>{E3t(),Wft(),Gft.then(t=>GY=t),X1=class{constructor({src:t,volume:e,delay:i,loop:r}){let s;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)},s=typeof t=="string"?{src:t}:{src:C3t(t),format:"wav"},this.sound=new GY.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}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 WY(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(e=!0)}),e}var EG,PG=j(()=>{EG=null});function qY(t){return new Q(t.y,-t.x)}var RG,GU,qft,Hft,DM,HY,P4,$ft,IO,R4=j(()=>{dt(),RG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,r=t.parameters?.radiusBottom,s=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);s.thetaLength=qt.clamp(s.thetaLength,0,360),s.hollow=qt.clamp(s.hollow??0,0,1);let n=s.width/2,a=s.radiusTop??n,o=s.radiusBottom??n;if(a===o?(a=n,o=n):a>o?(a=n,o=o*n/a):(a=a*n/o,o=n),s.shapeBlendNode){a=i??n,o=r??n;let l=2*Math.max(a,o);s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;u===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=c||m?new GU(h,d,s,n,a,o,l,u*Math.PI/180,c,c,p,m):new k2(h,d,s,n,a,o,l,u*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},GU=class extends ge{constructor(t,e,i,r,s,n,a,o,l,u,h,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0&&n,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,n&&(l=0,u=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=u);let m=new Q(t,p),f=new Q(e,-p),g=null,y=null,v=null,b=null,_=m.clone().sub(f),x=0,S=0,w=0;d>0&&(x=Math.min(t,e)*(1-d),S=t-x,w=e-x);let T=m.clone();T.x-=x;let C=Math.PI-_.angle(),M=_.angle(),A=Math.tan(M/2),R=Math.tan(C/2),O=A+R,N=d?O:R,B=d?O:A;if(l=Math.min(l,(t-S)/N,_.length()/O),u=Math.min(u,(e-w)/B,_.length()/O),l>0){let Vt=l/A;g=m.clone().sub(new Q(Vt,l)),d&&(v=g.clone(),v.x-=x-O*l),m.sub(_.clone().setLength(Vt))}if(u>0){let Vt=u/R;y=f.clone().sub(new Q(Vt,-u)),f.add(_.clone().setLength(Vt)),d&&(b=y.clone(),b.x-=x-O*u,T.sub(_.clone().setLength(Vt)))}_=m.clone().sub(f);let L=_.length()<.5,z=[],k=[],V=[],H=[],W=[],X=[],st=(Vt,Wt,$t,Pt,oe)=>{for(let jt=0;jt<h+1;jt++){let Zt=jt/h,Jt=Pt<0?Zt:1-Zt;oe&&(Jt-=1),Jt*=Vt;let $=Math.sin(Jt),se=Math.cos(Jt)*Pt,Pe=se*Wt+$t.y;z.push($*Wt+$t.x),k.push(Pe),V.push($),H.push(se),W.push(.5+Pe/i),X.push(!1)}},nt=(Vt,Wt,$t)=>{let Pt=[Vt,Wt];$t<0&&Pt.reverse();for(let oe of Pt)z.push(oe),k.push(p*$t),V.push(0),H.push($t),W.push(.5),X.push(!0)};if(b&&y?(st(C,u,b,-1,!0),st(M,u,y,-1,!1)):y?(nt(y.x,0,-1),st(M,u,y,-1,!1)):n||nt(e,w,-1),!L){let Vt=qY(_).normalize();for(let Wt=0;Wt<=s;Wt++){let $t=Wt/s,Pt=_.y*$t+f.y;z.push(_.x*$t+f.x),k.push(Pt),V.push(Vt.x),H.push(Vt.y),W.push(.5+Pt/i),X.push(!1)}}if(v&&g?(st(C,l,g,1,!1),st(M,l,v,1,!0)):g?(st(C,l,g,1,!1),nt(g.x,0,1)):n||nt(t,S,1),d&&!L){let Vt=qY(_).multiplyScalar(-1).normalize();for(let Wt=0;Wt<=s;Wt++){let $t=Wt/s,Pt=_.y*-$t+T.y;z.push(_.x*-$t+T.x),k.push(Pt),V.push(Vt.x),H.push(Vt.y),W.push(.5+Pt/i),X.push(!1)}}let xt=z.length,pt=xt+(d&&!n?1:0),K=(Vt,Wt)=>Vt*xt+(Wt===xt?0:Wt),ct=o<2*Math.PI,St=(r+1)*xt+(ct?2*(1+pt):0),wt=new Float32Array(3*St),Tt=new Float32Array(3*St),yt=new Float32Array(2*St),Ot=St-1>65535?new Uint32Array(r*Math.max(0,pt-1)*6+(ct?2*(pt+1)*3:0)):new Uint16Array(r*Math.max(0,pt-1)*6+(ct?2*(pt+1)*3:0)),Ft=0,Bt=0;for(let Vt=0;Vt<=r;Vt++){let Wt=Vt/r,$t=Wt*o+a,Pt=Math.sin($t),oe=Math.cos($t);for(let jt=0;jt<xt;jt++){let Zt=3*Bt,Jt=2*Bt,$=z[jt],se=V[jt];wt[Zt]=$*Pt,wt[Zt+1]=k[jt],wt[Zt+2]=$*oe,Tt[Zt]=se*Pt,Tt[Zt+1]=H[jt],Tt[Zt+2]=se*oe,X[jt]?(yt[Jt]=.5,yt[Jt+1]=.5):(yt[Jt]=Wt,yt[Jt+1]=W[jt]),Bt++}}for(let Vt=0;Vt<r;Vt++)for(let Wt=0;Wt<pt-1;Wt++){if(n&&d&&Wt==s)continue;let $t=K(Vt,Wt),Pt=K(Vt+1,Wt),oe=K(Vt+1,Wt+1),jt=K(Vt,Wt+1),Zt=wt[3*oe+0],Jt=wt[3*oe+2];Ot[Ft++]=$t,Ot[Ft++]=Pt,Ot[Ft++]=jt,(Zt!=0||Jt!=0)&&(Ot[Ft++]=Pt,Ot[Ft++]=oe,Ot[Ft++]=jt)}function zt(Vt,Wt,$t){let Pt=Math.sin($t),oe=Math.cos($t),jt=-oe,Zt=Pt,Jt=Vt<0?(ie,oi,xi)=>{Ot[Ft++]=ie,Ot[Ft++]=oi,Ot[Ft++]=xi}:(ie,oi,xi)=>{Ot[Ft++]=ie,Ot[Ft++]=xi,Ot[Ft++]=oi},$=(t+e+S+w)/4,se=3*Bt,Pe=2*Bt;wt[se]=$*Pt,wt[se+1]=0,wt[se+2]=$*oe,Tt[se]=jt,Tt[se+1]=0,Tt[se+2]=Zt,yt[Pe]=.5,yt[Pe+1]=.5;let Ve=Bt++;for(let ie=0;ie<pt;ie++){let oi=3*(Wt+(ie===xt?0:ie));se=3*Bt,Pe=2*Bt,wt[se]=wt[oi],wt[se+1]=wt[oi+1],wt[se+2]=wt[oi+2],Tt[se]=jt,Tt[se+1]=0,Tt[se+2]=Zt;let xi=oi/3*2|0;yt[Pe]=yt[xi],yt[Pe+1]=yt[xi+1],Bt++}for(let ie=Ve+1;ie<Bt-1;ie++)Jt(Ve,ie,ie+1);Jt(Ve,Bt-1,Ve+1)}ct&&(zt(-1,0,a),zt(1,r*xt,a+o)),this.setIndex(new _e(Ot.slice(0,Ft),1)),this.setAttribute("position",new _e(wt,3)),this.setAttribute("normal",new _e(Tt,3)),this.setAttribute("uv",new _e(yt,2))}}}),$Y=j(()=>{dt(),R4(),qft=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=qt.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:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;u===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=h>0||d>0||u<360?new GU(0,i/2,s,n,a,o,l,u*Math.PI/180,h,d,c,0,!0):new KR(i/2,s,n,a,o);let p=r/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),XY=j(()=>{dt(),Hft=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:r,depth:s,widthSegments:n,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:u}=t.parameters;return e=l===0?new Zh(i,r,s,n,a,o):new HY(i,r,s,n,a,o,l,u),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},DM=Math.PI/2,HY=class extends ge{constructor(t=1,e=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,u=o+1,h=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*u*(n+1+(r+1)+(s+1))+u*(u+1)/2*8:0),d=2*(n*s+r*n+r*s)+(l?4*o*(n+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*h),m=new Float32Array(3*h),f=new Float32Array(2*h),g=h-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(u),_=new Float64Array(u),x=new Float64Array(u),S=new Float64Array(u);for(let O=0;O<u;O++){let N=O/o*DM;b[O]=Math.sin(N)*a,_[O]=(1-Math.cos(N))*a,x[O]=Math.sin(N),S[O]=Math.cos(N)}let w=u*(u+1)/2,T=new Float64Array(3*w),C=new Float64Array(3*w);{let O=new P(t/2,e/2,i/2);O.subScalar(a);let N=0;for(let B=0;B<=o;B++){let L=DM*(1-B/o),z=Math.cos(L),k=Math.sin(L),V=0;for(let H=0;H<=B;H++){let W=z*Math.cos(V),X=k,st=z*Math.sin(V);T[3*N]=W,T[3*N+1]=X,T[3*N+2]=st,C[3*N]=O.x+W*a,C[3*N+1]=O.y+X*a,C[3*N+2]=O.z+st*a,N++,V+=DM/B}}}function M(O,N,B,L,z,k,V,H,W,X){let st=(k-2*a)/W,nt=(V-2*a)/X,xt=k/2-a,pt=V/2-a,K=H/2,ct=W+1,St=X+1,wt=0,Tt=new P;for(let yt=0;yt<St;yt++){let Ot=yt*nt-pt;for(let Ft=0;Ft<ct;Ft++){let Bt=Ft*st-xt,zt=3*(y+wt),Vt=2*(y+wt);Tt[O]=Bt*L,Tt[N]=Ot*z,Tt[B]=K,p[zt]=Tt.x,p[zt+1]=Tt.y,p[zt+2]=Tt.z,Tt[O]=0,Tt[N]=0,Tt[B]=H>0?1:-1,m[zt]=Tt.x,m[zt+1]=Tt.y,m[zt+2]=Tt.z,f[Vt]=Ft/W,f[Vt+1]=1-yt/X,wt+=1}}for(let yt=0;yt<X;yt++)for(let Ot=0;Ot<W;Ot++){let Ft=y+Ot+ct*yt,Bt=y+Ot+ct*(yt+1),zt=y+(Ot+1)+ct*(yt+1),Vt=y+(Ot+1)+ct*yt;g[v++]=Ft,g[v++]=Bt,g[v++]=Vt,g[v++]=Bt,g[v++]=zt,g[v++]=Vt}y+=wt}function A(O,N,B,L,z,k,V,H,W,X){let st=(V-2*a)/X,nt=V/2-a,xt=H/2-a,pt=W/2,K=X+1,ct=0,St=new P,wt=new P;for(let Tt=0;Tt<o+1;Tt++){St[N]=(xt+b[Tt])*z,St[B]=(pt-_[Tt])*k,wt[O]=0,wt[N]=x[Tt]*Math.sign(St[N]),wt[B]=S[Tt]*Math.sign(St[B]);for(let yt=0;yt<K;yt++){let Ot=yt*st-nt;St[O]=Ot*L;let Ft=3*(y+ct),Bt=2*(y+ct);p[Ft]=St.x,p[Ft+1]=St.y,p[Ft+2]=St.z,m[Ft]=wt.x,m[Ft+1]=wt.y,m[Ft+2]=wt.z,f[Bt]=yt/X,f[Bt+1]=0,ct+=1}}for(let Tt=0;Tt<o;Tt++)for(let yt=0;yt<X;yt++){let Ot=y+yt+K*Tt,Ft=y+yt+K*(Tt+1),Bt=y+(yt+1)+K*(Tt+1),zt=y+(yt+1)+K*Tt;g[v++]=Ot,g[v++]=Ft,g[v++]=zt,g[v++]=Ft,g[v++]=Bt,g[v++]=zt}y+=ct}function R(O,N,B){let L=O*N*B>0?(k,V,H)=>{g[v++]=k,g[v++]=V,g[v++]=H}:(k,V,H)=>{g[v++]=k,g[v++]=H,g[v++]=V},z=y;for(let k=0;k<w;k++){let V=3*k,H=3*y,W=2*y;p[H]=O*C[V],p[H+1]=N*C[V+1],p[H+2]=B*C[V+2],m[H]=O*T[V],m[H+1]=N*T[V+1],m[H+2]=B*T[V+2],f[W]=0,f[W+1]=0,y++}for(let k=0;k<o;k++){let V=z+k*(k+1)/2,H=z+(k+1)*(k+2)/2;L(V,H+1,H);for(let W=1;W<=k;W++)L(V+W-1,V+W,H+W),L(V+W,H+W+1,H+W)}}M("z","y","x",-1,-1,i,e,t,n,s),M("z","y","x",1,-1,i,e,-t,n,s),M("x","z","y",1,1,t,i,e,r,n),M("x","z","y",1,-1,t,i,-e,r,n),M("x","y","z",1,-1,t,e,i,r,s),M("x","y","z",-1,-1,t,e,-i,r,s),a>0&&(A("z","y","x",-1,-1,1,i,e,t,n),A("z","y","x",1,-1,-1,i,e,t,n),A("z","y","x",-1,1,-1,i,e,t,n),A("z","y","x",1,1,1,i,e,t,n),A("x","y","z",-1,-1,-1,t,e,i,r),A("x","y","z",1,-1,1,t,e,i,r),A("x","y","z",-1,1,1,t,e,i,r),A("x","y","z",1,1,-1,t,e,i,r),A("y","x","z",-1,-1,1,e,t,i,s),A("y","x","z",1,-1,-1,e,t,i,s),A("y","x","z",1,1,1,e,t,i,s),A("y","x","z",-1,1,-1,e,t,i,s),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 _e(g,1)),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(m,3)),this.setAttribute("uv",new _e(f,2))}}}),Xft=j(()=>{dt(),P4=class extends ge{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,u=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new Is,m=s*r,f=r-m,g=n+1,y=new P,v=(K,ct)=>y.subVectors(K,ct).normalize(),b=(K,ct)=>Array(K).fill(void 0).map(ct),_=b(t.length/3,(K,ct)=>new P().fromArray(t,3*ct).setLength(r)),x=[],S=1e6;for(let K=0;K<_.length;K++){let ct,St,wt,Tt=_[K],yt=[],Ot=1e10,Ft=-1;for(;(Ft=e.indexOf(K,Ft+1))!=-1;){let Wt=Ft-Ft%3;ct=e[Wt+(Ft+1)%3],St=e[Wt+(Ft+2)%3],wt=Tt.distanceToSquared(_[ct]),Ot=Math.min(Ot,wt),yt.push([ct,St,wt])}Ot+=1e-6;let Bt=[],zt=0,Vt=yt.length;for(let Wt=0;Wt<Vt;Wt++){[ct,St,wt]=yt[zt];let $t=x[ct]?.includes(K)==1;wt<=Ot&&Bt.push(ct+ +$t*S),zt=yt.findIndex(Pt=>Pt[0]==St)}x.push(Bt)}let w=[];{let K,ct,St=0,wt=0,Tt=h==3;for(let yt=0;yt<=n;yt++){K=yt*(yt+1)/2,ct=(yt+1)*(yt+2)/2;for(let Ot=0;Ot<n-yt;Ot++)[St,wt]=[K+Ot+yt+2,ct+Ot+yt+3],w.push(K,ct,...Tt?[wt,K]:[St,ct],wt,St),[K,ct]=[St,wt];w.push(K,ct,K+n+2)}}let T=0;for(let K=0;K<x.length;K++)for(let ct=0;ct<h;ct++)x[K][ct]<S&&T++;let C=_.length*h*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(C),o=new Float64Array(C),l=new Float64Array(C/3*2);let M=(K,ct,St)=>{let wt=u/3*2;l[wt]=Math.atan2(St,-K)/2/Math.PI+.5,l[wt+1]=1-(Math.atan2(-ct,Math.sqrt(K*K+St*St))/Math.PI+.5)},A=K=>{a[u]=K.x,a[u+1]=K.y,a[u+2]=K.z,o[u]=y.x,o[u+1]=y.y,o[u+2]=y.z,M(K.x,K.y,K.z),u+=3},R=K=>{a[u]=K[0].x,a[u+1]=K[0].y,a[u+2]=K[0].z,o[u]=K[1].x,o[u+1]=K[1].y,o[u+2]=K[1].z,M(K[0].x,K[0].y,K[0].z),u+=3},O=(n+2)*(n+3)/2,N=new Float64Array(3*O),B=new Float64Array(3*O),L=new Float64Array(2*O),z=b(2*h*g,()=>new P),k=b(n*Math.max(0,n-1)/2,()=>new P),V=d.clone(),H=d.clone(),W=d.clone(),X=d.clone(),st=d.clone(),nt=[],xt=b(_.length,()=>b(h,()=>d.clone()));for(let K=0;K<_.length;K++){d.copy(_[K]).normalize(),V.copy(d).multiplyScalar(f);let ct=x[K];for(let Bt=0;Bt<ct.length;Bt++){let zt=ct[Bt],Vt=ct[(Bt+1)%h];p.setFromPointsAndIndices(_,K,zt%S,Vt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(V,xt[K][Bt])}let St=0,wt=[],Tt=[],yt=new P;n==0&&[...xt[K]].reduce((Bt,zt)=>Bt.add(zt),yt).multiplyScalar(1/h);for(let Bt=0;Bt<h;Bt++){let zt=[],Vt=(Bt-1+h)%h,Wt=xt[K][Vt],$t=xt[K][Bt];d.copy(Wt).sub(V),c.copy($t).sub(V);let Pt=V.angleTo(d),oe=d.angleTo(c),jt=Math.cos(Pt)*m;n==0?H.copy(yt):H.copy(V).setLength(f+jt),wt.push(jt);let Zt=[H,Wt,$t];for(let Jt=0;Jt<2;Jt++){let $=Zt[Jt],se=Zt[Jt+1];X.subVectors($,V),st.subVectors(se,V),W.crossVectors(X,st).normalize();for(let Pe=0;Pe<g;Pe++){let Ve=[Pt,oe][Jt]*Pe/g;d.copy(X).applyAxisAngle(W,Ve).add(V),z[St++].copy(d),Jt&&(v(d,V),zt.push([Pe==0?$:d.clone(),y.clone()]))}Jt&&(v(se,V),zt.push([se,y.clone()]))}Tt.push(zt)}nt.push(Tt);let Ot=2*g,Ft=2;for(let Bt=0;Bt<h;Bt++){let zt=Ot*Bt,Vt=Ot*((Bt+1)%h),Wt=0,$t=[z[zt]];for(let Pt=1;Pt<g;Pt++){let oe=z[zt+Pt],jt=z[Vt+Pt];$t.push(oe);for(let Zt=1,Jt=Pt-Ft+1;Zt<=Jt;Zt++)d.lerpVectors(oe,jt,Zt/(Jt+1)),d.sub(V).setLength(wt[Bt]).add(V),$t.push(k[Wt++].copy(d));$t.push(jt)}for(let Pt=0;Pt<g;Pt++)$t.push(z[Pt+g+zt]);$t.push(z[Vt+g]);for(let Pt=0,oe=$t.length;Pt<oe;Pt++){let jt=$t[Pt],Zt=3*Pt,Jt=2*Pt;N[Zt]=jt.x,N[Zt+1]=jt.y,N[Zt+2]=jt.z,v(jt,V),B[Zt]=y.x,B[Zt+1]=y.y,B[Zt+2]=y.z,L[Jt]=Math.atan2(jt.z,-jt.x)/2/Math.PI+.5,L[Jt+1]=1-(Math.atan2(-jt.y,Math.sqrt(jt.x*jt.x+jt.z*jt.z))/Math.PI+.5)}for(let Pt=0,oe=w.length;Pt<oe;Pt++){let jt=3*w[Pt],Zt=2*w[Pt],Jt=u/3*2;a[u]=N[jt],a[u+1]=N[jt+1],a[u+2]=N[jt+2],o[u]=B[jt],o[u+1]=B[jt+1],o[u+2]=B[jt+2],l[Jt]=L[Zt],l[Jt+1]=L[Zt+1],u+=3}}}let pt=[];for(let K=0;K<x.length;K++)for(let ct=0;ct<h;ct++){let St=x[K][ct];if(St<S){let wt=x[St].findIndex(Ot=>Ot%S==K),Tt=nt[K][ct],yt=nt[St][wt];for(let Ot=0;Ot<g;Ot++){let Ft=Tt[Ot],Bt=yt[g-Ot],zt=Tt[Ot+1],Vt=yt[g-(Ot+1)];R(Ft),R(Bt),R(zt),R(zt),R(Bt),R(Vt)}pt.push(Tt[0][0],yt[g][0],Tt[g][0],yt[0][0])}}for(;pt.length;){let K,ct,St,[wt,Tt]=pt.splice(0,2);K=Tt;let yt=[wt];for(;wt!=K;)yt.push(K),ct=pt.indexOf(K),St=ct%2,K=pt.splice(ct-St,2)[1-St];y.subVectors(yt[0],yt[1]).cross(d.subVectors(yt[0],yt[2])).normalize();let Ot=y.dot(yt[0])<0;Ot&&y.negate();for(let Ft=1;Ft<=yt.length-2;Ft++)A(yt[Ft+ +Ot]),A(yt[Ft+1-+Ot]),A(yt[0])}}(),function(){let h=new P,d=new P,c=new P,p=new P,m=new Q,f=new Q,g=new Q,y=(_,x,S,w)=>{w<0&&_.x===1&&(l[x]=_.x-1),S.x===0&&S.z===0&&(l[x]=w/2/Math.PI+.5)};for(let _=0,x=0;_<u;_+=9,x+=6){h.set(a[_+0],a[_+1],a[_+2]),d.set(a[_+3],a[_+4],a[_+5]),c.set(a[_+6],a[_+7],a[_+8]),m.set(l[x+0],l[x+1]),f.set(l[x+2],l[x+3]),g.set(l[x+4],l[x+5]),p.copy(h).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,h,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=u/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),C=Math.min(x,S,w);T>.9&&C<.1&&(x<.2&&(l[_+0]+=1),S<.2&&(l[_+2]+=1),w<.2&&(l[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}}(),this.setAttribute("position",new _e(new Float32Array(a.subarray(0,u)),3)),this.setAttribute("normal",new _e(new Float32Array(o.subarray(0,u)),3)),void this.setAttribute("uv",new _e(new Float32Array(l.subarray(0,u/3*2)),2))}static fromJSON(t){return new P4(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),YY=j(()=>{Xft(),dt(),$ft=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:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new IO(.5*e,n,a):new A8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},IO=class extends P4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n="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,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[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],n,t,e,i),this.type=n}static fromJSON(t){return new IO(t.radius,t.corner,t.cornerSides)}}});function KY(t,e=new Q){let i=t.length();return e.set(-t.y/i,t.x/i)}function D3t(t){let e=new Q;e.addVectors(t.v0,Rg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Q;return i.addVectors(t.v2,VS.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Kl(t.v0,e,i,t.v2)}function Qw(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function N3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function O3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function Yft(t,e,i){let r=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function I3t(t,e,i){return QY(t,e)&&QY(e,i)&&WU(t.position,e.position,i.position)}function WU(t,e,i){return Rg.copy(e).sub(t).cross(VS.copy(i).sub(t))===0}function B3t(t,e,i,r,s){let n=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(n/2,2))*(t.y-e.y)/n,u=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+u),s.set(o-l,a-u),[r,s]}function V3t(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function k3t(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,u=i.x-t.x,h=i.y-t.y,d=Math.sqrt((o+u)*(o+u)+(l+h)*(l+h));return Yft(e,t,i)>Math.PI&&(d*=-1),a=Qw(h,l)?(l+h)*(r/d-.5)*8/3/(o-u):(o+u)*(r/d-.5)*8/3/(h-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*h,i.y-a*u),[s,n]}function ZY(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function QY(t,e){return WU(t.position,t.controls[1].position,e.position)&&WU(t.position,e.controls[0].position,e.position)}function JY(t,e=12,i=!1){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Pg(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Pg(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Pg(t[0].roundedCurveCorner,e)),r}function Pg(t,e=12){return t&&t instanceof jw?2*e:t&&(t instanceof cl||t instanceof C8)?1:t&&t instanceof CP?e*t.points.length:e}var P1,NM,OM,qg,FP,Rg,VS,Kft,Zft,Qft,Jft,qU,HU,IM,tK,eK,iK,rK,sK,ds,tgt=j(()=>{dt(),P1=1e-12,NM=class{constructor(t){this.position=new Q,this.startPosition=new Q,this.uuid=qt.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 NM(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},OM=class extends NM{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new OM(this.parent).copy(this)}},qg=class extends NM{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new OM(this),new OM(this))}static create(t,e){let i=new qg(t,new Q(...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,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=e?s.position.copy(this.position):s.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 qg(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 Q,e=new Q){let[i,r]=this.computeTangents();return i&&r&&(KY(i,t),KY(r,e)),[t,e]}computeTangent(t=new Q){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Q){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},FP=t=>t,Rg=new Q,VS=new Q,Kft=new Q,Zft=new Q,Qft=new Q,Jft=new Q,qU=new P,HU=new P}),wm=j(()=>{dt(),tgt(),IM=new Q,tK=new Q,eK=new Q,iK=new Q,rK=new Q,sK=new Q,ds=class extends _S{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ra(new P(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=qt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ds;return r.isClosed=t.isClosed,r.points=t.points.map(s=>qg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ds.createFromState(s)),e!==void 0&&i!==void 0&&r.applySize(e,i),r.update(),r}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(r=>r.uuid===t);if(i<0){let r=e;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+r;r+=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,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=t-e;if(n<=s.points.length-1)return s.points[n];e+=s.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,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(t);if(n>=0)return e+n;e+=s.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=IM.set(t,e);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(t,e);this._update()}createPoint(t,e=0,i=qt.generateUUID()){let r;r=t instanceof Q?t:new Q(t,e);let s=new qg(i,r);return s.roundness=this.roundness,s}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 r=this.points[e];if(r.uuid===t)return r}for(let e=0,i=this.shapeHoles.length;e<i;e++){let r=this.shapeHoles[e].getPointByUuid(t);if(r)return r}}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 r=i?this.roundedCurveDivisions:this.curveDivisions;return function(s,n,a=12,o=!0){let l,u=HU.set(0,0,0),h=0,d=[];for(let c=0;c<n.length;c++){let p=FP(n[c]),m=Rg,f=Pg(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof cl){if(p.getPoint(g/f,m),u.set(m.x,m.y,0),l!==void 0&&O3t(l,u))continue;l===void 0&&(l=qU),l.copy(u),s.setXYZ(h,u.x,u.y,u.z),h++}}o&&h>1&&(s.getX(h-1)!==s.getX(0)||s.getY(h-1)!==s.getY(0)||s.getZ(h-1)!==s.getZ(0))&&(s.setXYZ(h,s.getX(0),s.getY(0),s.getZ(0)),h++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=JY(this.points,t,!1),this.roundedCurveDivisions=JY(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=HU.set(0,0,0),u=0,h=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=FP(s[d]),m=Rg,f=Pg(p,a);h.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof cl){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=qU:(r.setXYZ(u,c.x,c.y,c.z),u++,r.setXYZ(u,l.x,l.y,l.z),u++),c.copy(l)}}return o&&u>1&&!(r.getX(u-1)===r.getX(0)&&r.getY(u-1)===r.getY(0)&&r.getZ(u-1)===r.getZ(0))&&(r.setXYZ(u,r.getX(0),r.getY(0),r.getZ(0)),u++),h}(t,this.curves,e,i,this.autoClose).reduce((r,s)=>r+s,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,r,s=12,n=!0){let a,o=0;for(let l=0;l<r.length;l++){let u=FP(r[l]),h=Pg(u,s),d=Rg;for(let c=0;c<=h;c++)if(u instanceof Kl||u instanceof lc||u instanceof cl){if(u.getPoint(c/h,d),a!==void 0&&N3t(a,d,P1))continue;a===void 0&&(a=VS),a.copy(d),i.push(d.x,d.y),o++}}return Qw(i[0],i[i.length-2],P1)&&Qw(i[1],i[i.length-1],P1)&&(i.pop(),i.pop()),n&&o>1&&!(Qw(i[o-1],i[1],P1)&&Qw(i[o-2],i[0],P1))&&(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 r=e?this.roundedCurveDivisions:this.curveDivisions,s=0;e&&this.points[0].roundedCurveCorner!==void 0&&(s=.5*Pg(this.points[0].roundedCurveCorner,this.subdivision));let n=t-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let r=this.points[t],s=this.points[t>=this.points.length-1?0:t+1],n=this.curveDivisions,a=n[t];if(ZY(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(IM.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=n[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){ZY(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 r=i.clone();t.roundedCurveBefore=r,e.roundedCurveAfter=r,t.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(e===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[e-1];this._applyCurveForPoint(r,s)}}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,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&I3t(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let u=s.curveBefore,h=s.curveAfter;if(u===void 0||h===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=u instanceof cl?u.v1.distanceTo(u.v2):u.getLength(),f=h instanceof cl?h.v1.distanceTo(h.v2):h.getLength(),g=Math.min(o,.499*m),y=Math.min(o,.499*f),v=Math.min(g,y),b=1-v/m,_=v/f,x=u.getPointAt(b,IM),S=h.getPointAt(_,tK);if(this._subSplitCurve(u,c,b,x,void 0),this._subSplitCurve(h,p,_,void 0,S),this.useCubicForRoundedCorners){let w=Yft(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[C,M]=B3t(x,S,T,eK,iK),A=V3t(C,M,s.position),[R,O]=k3t(A,x,S,T,rK,sK);d=new Kl(x.clone(),R.clone(),O.clone(),S.clone())}else d=new lc(x.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=d,this.roundedCurves.splice(i+e,0,d),e++}}}}_subSplitCurve(t,e,i,r,s){if(!(t instanceof cl)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(u,h,d,c,p=.5){let m=Rg.subVectors(h,u).multiplyScalar(p).add(u),f=VS.subVectors(d,h).multiplyScalar(p).add(h),g=Kft.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=Zft.subVectors(f,m).multiplyScalar(p).add(m),b=Qft.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=Jft.subVectors(b,v).multiplyScalar(p).add(v);return[u.x,u.y,y.x,y.y,v.x,v.y,x.x,x.y,b.x,b.y,_.x,_.y,c.x,c.y]}(n.v0,n.v1,n.v2,n.v3,o);return r!==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])),s!==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 r!==void 0&&e.v2.copy(r),s!==void 0&&e.v1.copy(s),e}clone(){let t=new ds(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 r=7*i,s=t.points[r+0],n=t.points[r+1],a=t.points[r+2],o=t.points[r+3],l=t.points[r+4],u=t.points[r+5],h=t.points[r+6],d=new qg(qt.generateUUID(),new Q(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,u),d.roundness=h,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ds;return r.fromJSON(i),r}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(r,s)=>{s instanceof Kl&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)};return this.points=(r=>{let s,n,a=[];for(s=0,n=r.length;s<n;s++)r[s]instanceof lc&&(r[s]=D3t(r[s]));for(s=0,n=r.length;s<n;s++){let u,h=r[s],d=s>0?r[s-1]:null;h instanceof Kl?(u=this.createPoint(h.v0),u.controls[1].position.copy(h.v1)):h instanceof cl&&(u=this.createPoint(h.v1)),u!==void 0&&(d!==null&&i(u,d),a.push(u))}let o=r[r.length-1],l=!1;return o instanceof Kl?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof cl&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof _S&&(this.shapeHoles=t.holes.map(r=>{let s=new ds;return s.fromShape(r),s})),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 BO({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function z3t(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(t),s=Math.sin(t),n=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function nK(t,e,i,r){let s=t*r-e*i<0?-1:1,n=Math.min(1,Math.max(-1,t*i+e*r));return s*Math.acos(n)}var UP,L3t=j(()=>{UP=2*Math.PI});function Xe(t,e){if(!t)throw e||"Assertion Failed!"}function Y2(t){var e=t.windingRule,i=e===void 0?ss.ODD:e,r=t.elementType,s=r===void 0?Ea.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,u=t.normal,h=u===void 0?[0,0,1]:u,d=t.contours,c=d===void 0?[]:d,p=t.strict,m=p===void 0||p,f=t.debug,g=f!==void 0&&f;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new egt;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,a,l,h,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var ss,Ea,je,U0,l_,sf,VO,kO,zO,aK,BM,LO,oK,lK,egt,eT=j(()=>{var t;(t=ss||(ss={}))[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"}(Ea||(Ea={})),je=function(){function e(){}return e.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},e.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},e.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.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,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},e.edgeEval=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?n<a?r.t-i.t+(i.t-s.t)*(n/(n+a)):r.t-s.t+(s.t-i.t)*(a/(n+a)):0},e.edgeSign=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?(r.t-s.t)*n+(r.t-i.t)*a:0},e.transEval=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?n<a?r.s-i.s+(i.s-s.s)*(n/(n+a)):r.s-s.s+(s.s-i.s)*(a/(n+a)):0},e.transSign=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?(r.s-s.s)*n+(r.s-i.s)*a:0},e.vertCCW=function(i,r,s){return i.s*(r.t-s.t)+r.s*(s.t-i.t)+s.s*(i.t-r.t)>=0},e.interpolate=function(i,r,s,n){return(i=i<0?0:i)<=(s=s<0?0:s)?s===0?(r+n)/2:r+i/(i+s)*(n-r):n+s/(i+s)*(r-n)},e.intersect=function(i,r,s,n,a){var o,l,u;e.vertLeq(i,r)||(u=i,i=r,r=u),e.vertLeq(s,n)||(u=s,s=n,n=u),e.vertLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.vertLeq(s,r)?e.vertLeq(r,n)?((o=e.edgeEval(i,s,r))+(l=e.edgeEval(s,r,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,r.s)):((o=e.edgeSign(i,s,r))+(l=-e.edgeSign(i,n,r))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,n.s)):a.s=(s.s+r.s)/2,e.transLeq(i,r)||(u=i,i=r,r=u),e.transLeq(s,n)||(u=s,s=n,n=u),e.transLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.transLeq(s,r)?e.transLeq(r,n)?((o=e.transEval(i,s,r))+(l=e.transEval(s,r,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,r.t)):((o=e.transSign(i,s,r))+(l=-e.transSign(i,n,r))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,n.t)):a.t=(s.t+r.t)/2},e}(),U0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},l_=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}(),sf=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},VO=function(){function e(){var i=new sf,r=new U0,s=new l_(0),n=new l_(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,s.next=s,s.Sym=n,n.next=n,n.Sym=s,this.vHead=i,this.fHead=r,this.eHead=s,this.eHeadSym=n}return e.prototype.makeEdge_=function(i){var r=new l_(0),s=new l_(1);i.Sym.side<i.side&&(i=i.Sym);var n=i.Sym.next;return s.next=n,n.Sym.next=r,r.next=i,i.Sym.next=s,r.Sym=s,r.Onext=r,r.Lnext=s,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,s.Sym=r,s.Onext=s,s.Lnext=r,s.Org=null,s.Lface=null,s.winding=0,s.activeRegion=null,r},e.prototype.splice_=function(i,r){var s=i.Onext,n=r.Onext;s.Sym.Lnext=r,n.Sym.Lnext=i,i.Onext=n,r.Onext=s},e.prototype.makeVertex_=function(i,r,s){var n=i;Xe(n,"Vertex can't be null!");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r;var o=r;do o.Org=n,o=o.Onext;while(o!==r)},e.prototype.makeFace_=function(i,r,s){var n=i;Xe(n,"Face can't be null");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r,n.trail=null,n.marked=!1,n.inside=s.inside;var o=r;do o.Lface=n,o=o.Lnext;while(o!==r)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,s=i.Sym.next;r.Sym.next=s,s.Sym.next=r},e.prototype.killVertex_=function(i,r){var s=i.anEdge,n=s;do n.Org=r,n=n.Onext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,r){var s=i.anEdge,n=s;do n.Lface=r,n=n.Lnext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new sf,r=new sf,s=new U0,n=this.makeEdge_(this.eHead);return this.makeVertex_(i,n,this.vHead),this.makeVertex_(r,n.Sym,this.vHead),this.makeFace_(s,n,this.fHead),n},e.prototype.splice=function(i,r){var s=!1,n=!1;if(i!==r){if(r.Org!==i.Org&&(n=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!n){var a=new sf;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new U0;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var r=i.Sym,s=!1;if(i.Lface!==i.Rface&&(s=!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),!s){var n=new U0;this.makeFace_(n,i,i.Lface)}r.Onext===r?(this.killVertex_(r.Org,null),this.killFace_(r.Lface,null)):(i.Lface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),s=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var n=new sf;return this.makeVertex_(n,s,r.Org),r.Lface=s.Lface=i.Lface,r},e.prototype.splitEdge=function(i){var r=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,r),i.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=i.Rface,r.winding=i.winding,r.Sym.winding=i.Sym.winding,r.idx=i.idx,r.Sym.idx=i.Sym.idx,r},e.prototype.connect=function(i,r){var s=!1,n=this.makeEdge_(i),a=n.Sym;if(r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(n,i.Lnext),this.splice_(a,r),n.Org=i.Dst,a.Org=r.Org,n.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!s){var o=new U0;this.makeFace_(o,n,i.Lface)}return n},e.prototype.zapFace=function(i){var r,s,n,a,o,l=i.anEdge;s=l.Lnext;do s=(r=s).Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),(n=r.Sym).Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var r=i.anEdge,s=0;do s++,r=r.Lnext;while(r!==i.anEdge);return s},e.prototype.mergeConvexFaces=function(i){var r,s,n,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(s=r.anEdge).Org;n=s.Lnext,(a=s.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&je.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&je.vertCCW(a.Lprev.Org,a.Org,s.Lnext.Lnext.Org)&&(n=a.Lnext,this.delete(a),s=null,a=null),!s||s.Lnext.Org!==o;)s=n;return!0},e.prototype.check=function(){var i,r,s,n,a,o,l=this.fHead,u=this.vHead,h=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Xe(i.prev===r),a=i.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Xe(i.prev===r&&i.anEdge===null),n=u,n=u;(s=n.next)!==u;n=s){Xe(s.prev===n),a=s.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(Xe(s.prev===n&&s.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)Xe(a.Sym.next===o.Sym),Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Org!==null),Xe(a.Dst!==null),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a);Xe(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}(),kO=function(){this.handle=null},zO=function(){this.key=null,this.node=0},aK=function(){function e(i,r){this.leq=r,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 s=0;s<i+1;s++)this.nodes[s]=new kO,this.handles[s]=new zO;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((n=i<<1)<this.size&&this.leq(o[a[n+1].handle].key,o[a[n].handle].key)&&++n,Xe(n<=this.max),s=a[n].handle,n>this.size||this.leq(o[r].key,o[s].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.floatUp_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(s=a[n=i>>1].handle,n===0||this.leq(o[s].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},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 r,s;if(2*(r=++this.size)>this.max){var n,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,n=a;n<this.nodes.length;n++)this.nodes[n]=new kO;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new zO}return this.freeList===0?s=r:(s=this.freeList,this.freeList=this.handles[s].node),this.nodes[r].handle=s,this.handles[s].node=r,this.handles[s].key=i,this.initialized&&this.floatUp_(r),s},e.prototype.extractMin=function(){var i=this.nodes,r=this.handles,s=i[1].handle,n=r[s].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[s].key=null,r[s].node=this.freeList,this.freeList=s,--this.size,this.size>0&&this.floatDown_(1)),n},e.prototype.delete=function(i){var r,s=this.nodes,n=this.handles;Xe(i>=1&&i<=this.max&&n[i].key!==null),s[r=n[i].node].handle=s[this.size].handle,n[s[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[s[r>>1].handle].key,n[s[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[i].key=null,n[i].node=this.freeList,this.freeList=i},e}(),BM=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},LO=function(){this.key=null,this.next=null,this.prev=null},oK=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new LO,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 r=this.head;do r=r.next;while(r.key!==null&&!this.leq(this.frame,i,r.key));return r},e.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var s=new LO;return s.key=r,s.next=i.next,i.next.prev=s,s.prev=i,i.next=s,s},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),lK=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,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.edgeLeq=function(i,r,s){var n=i.event,a=r.eUp,o=s.eUp;return a.Dst===n?o.Dst===n?je.vertLeq(a.Org,o.Org)?je.edgeSign(o.Dst,a.Org,o.Org)<=0:je.edgeSign(a.Dst,o.Org,a.Org)>=0:je.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?je.edgeSign(a.Dst,n,a.Org)>=0:je.edgeEval(a.Dst,n,a.Org)>=je.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&Xe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){Xe(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=s,s.activeRegion=r},e.topLeftRegion=function(i,r){var s,n=r.eUp.Org;do r=e.regionAbove(r);while(r.eUp.Org===n);if(r.fixUpperEdge){if((s=i.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;e.fixUpperEdge(i,r,s),r=e.regionAbove(r)}return r},e.topRightRegion=function(i){var r=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===r);return i},e.addRegionBelow=function(i,r,s){var n=new BM;return n.eUp=s,n.nodeUp=i.dict.insertBefore(r.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,s.activeRegion=n,n},e.isWindingInside=function(i,r){switch(i.windingRule){case ss.ODD:return!!(1&r);case ss.NONZERO:return r!==0;case ss.POSITIVE:return r>0;case ss.NEGATIVE:return r<0;case ss.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(i,r.windingNumber)},e.finishRegion=function(i,r){var s=r.eUp,n=s.Lface;n.inside=r.inside,n.anEdge=s,e.deleteRegion(i,r)},e.finishLeftRegions=function(i,r,s){for(var n,a=null,o=r,l=r.eUp;o!==s;){if(o.fixUpperEdge=!1,(n=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}n=i.mesh.connect(l.Lprev,n.Sym),e.fixUpperEdge(i,a,n)}l.Onext!==n&&(i.mesh.splice(n.Oprev,n),i.mesh.splice(l,n)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,r,s,n,a,o){var l,u,h,d,c=!0;h=s;do Xe(je.vertLeq(h.Org,h.Dst)),e.addRegionBelow(i,r,h.Sym),h=h.Onext;while(h!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),u=r,d=a;(h=(l=e.regionBelow(u)).eUp.Sym).Org===d.Org;)h.Onext!==d&&(i.mesh.splice(h.Oprev,h),i.mesh.splice(d.Oprev,h)),l.windingNumber=u.windingNumber-h.winding,l.inside=e.isWindingInside(i,l.windingNumber),u.dirty=!0,!c&&e.checkForRightSplice(i,u)&&(e.addWinding(h,d),e.deleteRegion(i,u),i.mesh.delete(d)),c=!1,u=l,d=h;u.dirty=!0,Xe(u.windingNumber-h.winding===l.windingNumber),o&&e.walkDirtyRegions(i,u)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=je.vertL1dist(r,i),a=je.vertL1dist(s,i),o=.5*a/(n+a),l=.5*n/(n+a);i.coords[0]+=o*r.coords[0]+l*s.coords[0],i.coords[1]+=o*r.coords[1]+l*s.coords[1],i.coords[2]+=o*r.coords[2]+l*s.coords[2]},e.getIntersectData=function(i,r,s,n,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,s,n),e.vertexWeights(r,a,o)},e.checkForRightSplice=function(i,r){var s=e.regionBelow(r),n=r.eUp,a=s.eUp;if(je.vertLeq(n.Org,a.Org)){if(je.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;je.vertEq(n.Org,a.Org)?n.Org!==a.Org&&(i.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,n)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(n,a.Oprev),r.dirty=s.dirty=!0)}else{if(je.edgeSign(n.Dst,a.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(n.Sym),i.mesh.splice(a.Oprev,n)}return!0},e.checkForLeftSplice=function(i,r){var s,n=e.regionBelow(r),a=r.eUp,o=n.eUp;if(Xe(!je.vertEq(a.Dst,o.Dst)),je.vertLeq(a.Dst,o.Dst)){if(je.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,s=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,s),s.Lface.inside=r.inside}else{if(je.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,s=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),s.Rface.inside=r.inside}return!0},e.checkForIntersect=function(i,r){var s,n,a=e.regionBelow(r),o=r.eUp,l=a.eUp,u=o.Org,h=l.Org,d=o.Dst,c=l.Dst,p=new sf;if(Xe(!je.vertEq(c,d)),Xe(je.edgeSign(d,i.event,u)<=0),Xe(je.edgeSign(c,i.event,h)>=0),Xe(u!==i.event&&h!==i.event),Xe(!r.fixUpperEdge&&!a.fixUpperEdge),u===h||Math.min(u.t,d.t)>Math.max(h.t,c.t))return!1;if(je.vertLeq(u,h)){if(je.edgeSign(c,u,h)>0)return!1}else if(je.edgeSign(d,h,u)<0)return!1;return e.debugEvent(i),je.intersect(d,u,c,h,p),Xe(Math.min(u.t,d.t)<=p.t),Xe(p.t<=Math.max(h.t,c.t)),Xe(Math.min(c.s,d.s)<=p.s),Xe(p.s<=Math.max(h.s,u.s)),je.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=je.vertLeq(u,h)?u:h,je.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),je.vertEq(p,u)||je.vertEq(p,h)?(e.checkForRightSplice(i,r),!1):!je.vertEq(d,i.event)&&je.edgeSign(d,i.event,p)>=0||!je.vertEq(c,i.event)&&je.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=e.topLeftRegion(i,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),a),e.addRightEdges(i,r,o.Oprev,o,o,!0),!0):d===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,r,l.Onext,o.Rprev,n,!0),!0):(je.edgeSign(d,i.event,p)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),je.edgeSign(c,i.event,p)<=0&&(r.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,u,d,h,c),e.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,r){for(var s,n,a=e.regionBelow(r);;){for(;a.dirty;)r=a,a=e.regionBelow(a);if(!r.dirty&&(a=r,(r=e.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,s=r.eUp,n=a.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(n),n=(a=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(i,r),i.mesh.delete(s),s=(r=e.regionAbove(a)).eUp)),s.Org!==n.Org){if(s.Dst===n.Dst||r.fixUpperEdge||a.fixUpperEdge||s.Dst!==i.event&&n.Dst!==i.event)e.checkForRightSplice(i,r);else if(e.checkForIntersect(i,r))return}s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(i,r),i.mesh.delete(s),r=e.regionAbove(a))}},e.connectRightVertex=function(i,r,s){var n,a=s.Onext,o=e.regionBelow(r),l=r.eUp,u=o.eUp,h=!1;l.Dst!==u.Dst&&e.checkForIntersect(i,r),je.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=e.topLeftRegion(i,r),a=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),o),h=!0),je.vertEq(u.Org,i.event)&&(i.mesh.splice(s,u.Oprev),s=e.finishLeftRegions(i,o,null),h=!0),h?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=je.vertLeq(u.Org,l.Org)?u.Oprev:l,n=i.mesh.connect(s.Lprev,n),e.addRightEdges(i,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,r))},e.connectLeftDegenerate=function(i,r,s){var n,a,o,l,u;return n=r.eUp,je.vertEq(n.Org,s)?(Xe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):je.vertEq(n.Dst,s)?(Xe(!1),r=e.topRightRegion(r),a=l=(o=(u=e.regionBelow(r)).eUp.Sym).Onext,u.fixUpperEdge&&(Xe(a!==o),e.deleteRegion(i,u),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),je.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(i.mesh.delete(n.Onext),r.fixUpperEdge=!1),i.mesh.splice(s.anEdge,n),void e.sweepEvent(i,s))},e.connectLeftVertex=function(i,r){var s,n,a,o,l,u,h=new BM;if(h.eUp=r.anEdge.Sym,s=i.dict.search(h).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,je.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=je.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(u=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,u):e.computeWinding(i,e.addRegionBelow(i,s,u)),e.sweepEvent(i,r)):e.addRightEdges(i,s,r.anEdge,r.anEdge,null,!0)}},e.sweepEvent=function(i,r){i.event=r,e.debugEvent(i);for(var s=r.anEdge;s.activeRegion===null;)if((s=s.Onext)===r.anEdge)return void e.connectLeftVertex(i,r);var n=e.topLeftRegion(i,s.activeRegion);Xe(n!==null);var a=e.regionBelow(n),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,n,l):e.addRightEdges(i,n,l.Onext,o,o,!0)},e.addSentinel=function(i,r,s,n){var a=new BM,o=i.mesh.makeEdge();o.Org.s=s,o.Org.t=n,o.Dst.s=r,o.Dst.t=n,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 oK(i,e.edgeLeq);var r=i.bmax[0]-i.bmin[0],s=i.bmax[1]-i.bmin[1],n=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-s,l=i.bmax[1]+s;e.addSentinel(i,n,a,o),e.addSentinel(i,n,a,l)},e.doneEdgeDict=function(i){for(var r,s=0;(r=i.dict.min().key)!==null;)r.sentinel||(Xe(r.fixUpperEdge),Xe(++s===1)),Xe(r.windingNumber===0),e.deleteRegion(i,r)},e.removeDegenerateEdges=function(i){var r,s,n,a=i.mesh.eHead;for(r=a.next;r!==a;r=s)s=r.next,n=r.Lnext,je.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(i,n,r),i.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&((n===s||n===s.Sym)&&(s=s.next),i.mesh.delete(n)),(r===s||r===s.Sym)&&(s=s.next),i.mesh.delete(r))},e.initPriorityQ=function(i){var r,s,n,a=0;for(s=(n=i.mesh.vHead).next;s!==n;s=s.next)a++;for(a+=8,r=i.pq=new aK(a,je.vertLeq),s=(n=i.mesh.vHead).next;s!==n;s=s.next)s.pqHandle=r.insert(s);return s===n&&(r.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,r){var s,n,a;for(s=r.fHead.next;s!==r.fHead;s=n)n=s.next,Xe((a=s.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,r){var s,n;if(r===void 0&&(r=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(s=i.pq.extractMin())!==null;){for(;(n=i.pq.min())!==null&&je.vertEq(n,s);)n=i.pq.extractMin(),e.spliceMergeVertices(i,s.anEdge,n.anEdge);e.sweepEvent(i,s)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},e}(),egt=function(){function e(){this.mesh=new VO,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=ss.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,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},e.prototype.normalize_=function(i){var r=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!r)throw"Zero-size vector!";r=Math.sqrt(r),i[0]/=r,i[1]/=r,i[2]/=r},e.prototype.longAxis_=function(i){var r=0;return Math.abs(i[1])>Math.abs(i[0])&&(r=1),Math.abs(i[2])>Math.abs(i[r])&&(r=2),r},e.prototype.computeNormal_=function(i){var r,s,n,a,o,l,u=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],g=this.mesh.vHead;r=g.next;for(var y=0;y<3;++y)a=r.coords[y],h[y]=a,f[y]=r,u[y]=a,m[y]=r;for(r=g.next;r!==g;r=r.next)for(var v=0;v<3;++v)(a=r.coords[v])<h[v]&&(h[v]=a,f[v]=r),a>u[v]&&(u[v]=a,m[v]=r);var b=0;if(u[1]-h[1]>u[0]-h[0]&&(b=1),u[2]-h[2]>u[b]-h[b]&&(b=2),h[b]>=u[b])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,s=f[b],n=m[b],d[0]=s.coords[0]-n.coords[0],d[1]=s.coords[1]-n.coords[1],d[2]=s.coords[2]-n.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],p[0]=d[1]*c[2]-d[2]*c[1],p[1]=d[2]*c[0]-d[0]*c[2],p[2]=d[0]*c[1]-d[1]*c[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_(d)]=1)},e.prototype.checkOrientation_=function(){for(var i,r,s=this.mesh.fHead,n=this.mesh.vHead,a=0,o=s.next;o!==s;o=o.next)if(!((r=o.anEdge).winding<=0))do a+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(a<0){for(i=n.next;i!==n;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,r,s=this.mesh.vHead,n=[0,0,0],a=!1;n[0]=this.normal[0],n[1]=this.normal[1],n[2]=this.normal[2],!n[0]&&!n[1]&&!n[2]&&(this.computeNormal_(n),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(n);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=n[o]>0?1:-1;for(var l=s.next;l!==s;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,r);a&&this.checkOrientation_();for(var u=!0,h=s.next;h!==s;h=h.next)u?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,u=!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,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,r){var s,n;if((s=r.anEdge).Lnext===s||s.Lnext.Lnext===s)throw"Mono region invalid";for(;je.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;je.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(je.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(je.edgeGoesLeft(n.Lnext)||je.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(je.edgeGoesRight(s.Lprev)||je.edgeSign(s.Dst,s.Org,s.Lprev.Org)>=0);)s=i.connect(s,s.Lprev).Sym;s=s.Lnext}if(n.Lnext===s)throw"Mono region invalid";for(;n.Lnext.Lnext!==s;)n=i.connect(n.Lnext,n).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)if(r=s.next,s.inside&&!this.tessellateMonoRegion_(i,s))return!1;return!0},e.prototype.discardExterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)r=s.next,s.inside||i.zapFace(s)},e.prototype.setWindingNumber_=function(i,r,s){for(var n,a=i.eHead.next;a!==i.eHead;a=n)n=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:s?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,r,s,n){var a,o,l=0,u=0;s>3&&i.mergeConvexFaces(s);for(var h=i.vHead.next;h!==i.vHead;h=h.next)h.n=-1;for(var d=i.fHead.next;d!==i.fHead;d=d.next)if(d.n=-1,d.inside){a=d.anEdge,o=0;do(h=a.Org).n===-1&&(h.n=u,u++),o++,a=a.Lnext;while(a!==d.anEdge);if(o>s)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===Ea.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=u,this.vertices=[],this.vertices.length=u*n,this.vertexIndices=[],this.vertexIndices.length=u,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var c=h.n*n;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],n>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do h=a.Org,this.elements[p++]=h.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ea.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=o;f<s;++f)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,r){var s,n,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){n=s=l.anEdge;do this.vertexCount++,s=s.Lnext;while(s!==n);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*r,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var u=0,h=0,d=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,n=s=l.anEdge;do this.vertices[u++]=s.Org.coords[0],this.vertices[u++]=s.Org.coords[1],r>2&&(this.vertices[u++]=s.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(s):s.Org.idx,o++,s=s.Lnext;while(s!==n);this.elements[d++]=a,this.elements[d++]=o,a+=o}},e.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new VO),i<2&&(i=2),i>3&&(i=3);for(var s=null,n=0;n<r.length;n+=i)s===null?(s=this.mesh.makeEdge(),this.mesh.splice(s,s.Sym)):(this.mesh.splitEdge(s),s=s.Lnext),s.Org.coords[0]=r[n+0],s.Org.coords[1]=r[n+1],s.Org.coords[2]=i>2?r[n+2]:0,s.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(s),s.winding=1,s.Sym.winding=-1},e.prototype.tesselate=function(i,r,s,n,a,o){if(i===void 0&&(i=ss.ODD),r===void 0&&(r=Ea.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,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),lK.computeInterior(this,o);var l=this.mesh;return r===Ea.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ea.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),ss.ODD,ss.NONZERO,ss.POSITIVE,ss.NEGATIVE,ss.ABS_GEQ_TWO,Ea.POLYGONS,Ea.CONNECTED_POLYGONS,Ea.BOUNDARY_CONTOURS});function igt(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let u=(l+1)%i;r+=t[2*l]*t[2*u+1]-t[2*u]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let u=(l+1)%i,h=t[2*u]-t[2*l],d=t[2*u+1]-t[2*l+1],c=Math.hypot(h,d);n.push(c>0?[s*d/c,-s*h/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,u)=>{if(l[0]*u[0]+l[1]*u[1]<=a)return l;let[h,d]=[l[0]+u[0],l[1]+u[1]],c=Math.hypot(h,d);return c>0?[h/c,d/c]:l};return n.map((l,u)=>[o(l,n[(u+i-1)%i]),o(l,n[(u+1)%i])])}function rgt(t,e,i){let r=t.length/2,s=new Float32Array(r+1);if(!(e>0)||!(i>0)||r<2)return{u:s,vScale:0};let n=0;for(let a=0;a<r;a++){let o=(a+1)%r;n+=Math.hypot((t[2*o]-t[2*a])/e,(t[2*o+1]-t[2*a+1])/i),s[a+1]=n}return{u:s,vScale:Math.sqrt(e*i)}}function sgt(t,e,i){for(let r=0;r<i.length;r+=3){let s=3*i[r],n=3*i[r+1],a=3*i[r+2],o=t[n]-t[s],l=t[n+1]-t[s+1],u=t[n+2]-t[s+2],h=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=u*h-o*c,m=o*d-l*h;if((l*c-u*d)*(e[s]+e[n]+e[a])+p*(e[s+1]+e[n+1]+e[a+1])+m*(e[s+2]+e[n+2]+e[a+2])<0){let f=i[r+1];i[r+1]=i[r+2],i[r+2]=f}}}var DG,ngt,NG,agt=j(()=>{}),OG=j(()=>{DG={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},ngt={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},NG={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}});function ogt(t,e){return t.normals[3*e+2]<.9999}function lgt(t){let e=$U.get(t);if(e!==void 0)return e;if(!(t.rise>0))return t;let i=new Float32Array(t.normals),r=t.positions.length/3;for(let n=0;n<r;n++){if(!ogt(t,n))continue;let a=i[3*n],o=i[3*n+1],l=Math.hypot(a,o);if(l===0)continue;let u=t.rise-t.positions[3*n+2],h=Math.min(1,Math.max(0,1-u/t.rise)),d=Math.sqrt(1-h*h);i[3*n]=a/l*d,i[3*n+1]=o/l*d,i[3*n+2]=h}let s={...t,normals:i};return $U.set(t,s),s}function hgt(t,e,i,r){let s=(e-t.minX)/t.spanX,n=(i-t.minY)/t.spanY;return r?[n,s]:[s,n]}var $U,D4,XU,IG=j(()=>{$U=new WeakMap}),F3t=j(()=>{dt(),eT(),ir(),agt(),OG(),IG(),D4=class extends ge{constructor(t,e,i=12,r=ss.ODD,s,n=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=t,this._depth=e,this._curveSegments=i,this._windingRule=r,this._uvPitch=n?void 0:s,this._legacy=n;let a,o=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(z=>z.extractShapePointsToFlatArray([],i))];try{a=Y2({contours:o,windingRule:r,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=NG}let l=a?.vertexCount??0,u=a?.elementCount??0,h=1/0,d=1/0,c=-1/0,p=-1/0;for(let z of o)for(let k=0;k<z.length;k+=2)z[k]<h&&(h=z[k]),z[k]>c&&(c=z[k]),z[k+1]<d&&(d=z[k+1]),z[k+1]>p&&(p=z[k+1]);let m=this._uvPitch,f=m??(c-h||1),g=m??(p-d||1),y=m===void 0?h:0,v=m===void 0?d:0,b=o.map((z,k)=>igt(z,k>0)),_=0;for(let z of b)_+=z.length;let x=2*l+4*_,S=3*u*2+6*_,w=new Float32Array(3*x),T=new Float32Array(3*x),C=new Float32Array(2*x),M=new Uint32Array(S),A=new Uint8Array(x),R=0,O=0,N=0,B=!1,L=(z,k,V,H,W,X,st=(z-y)/f,nt=(k-v)/g)=>{let xt=3*O;w[xt]=z,w[xt+1]=k,w[xt+2]=V,T[xt]=H,T[xt+1]=W,T[xt+2]=X,A[O]=V===e?B?2:1:0,C[2*O]=st,C[2*O+1]=nt,O++};if(a!==void 0)for(let[z,k]of[[e,1],[0,-1]]){let V=O;for(let H=0;H<l;H++)L(a.vertices[2*H],a.vertices[2*H+1],z,0,0,k);for(let H=0;H<u;H++){let[W,X,st]=[a.elements[3*H],a.elements[3*H+1],a.elements[3*H+2]];M[N++]=V+W,M[N++]=V+(k>0?X:st),M[N++]=V+(k>0?st:X)}}B=!0;for(let z=0;z<o.length;z++){let k=o[z],V=b[z],H=k.length/2,{u:W,vScale:X}=n?{u:new Float32Array(H+1),vScale:0}:rgt(k,f,g);R=X;let st=X===0?0:e/X,nt={minX:y,minY:v,spanX:f,spanY:g},xt=(pt,[K,ct],St,wt)=>{let Tt=k[2*pt],yt=k[2*pt+1],[Ot,Ft]=n?hgt(nt,Tt,yt,St):[wt,St?0:st];L(Tt,yt,St?0:e,K,ct,0,Ot,Ft)};for(let pt=0;pt<V.length;pt++){let K=(pt+1)%H,[ct,St]=V[pt],[wt,Tt]=[W[pt],W[pt+1]],yt=O;xt(pt,ct,!1,wt),xt(pt,ct,!0,wt),xt(K,St,!1,Tt),xt(K,St,!0,Tt),M[N++]=yt,M[N++]=yt+1,M[N++]=yt+2,M[N++]=yt+3,M[N++]=yt+2,M[N++]=yt+1}}sgt(w,T,M),this.setAttribute("position",new _e(w,3)),this.setAttribute("normal",new _e(T,3)),this.setAttribute("uv",new _e(C,2)),this.setIndex(new _e(M,1)),this._nearSide=A,this._vScale=R}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale)}canShiftDepthTo(t){return this._nearSide.length>0&&this._depth>0&&t>0}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=new D4(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return t.userData=C5(this.userData),t}}}),ugt=j(()=>{dt(),eT(),ir(),OG(),XU=class extends ge{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=ss.ODD,this.elementType=Ea.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:ss.ODD,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,n,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,u=!0;for(let c=0,p=a.length/2;c<p;c++){let m=2*c,f=a[m+0],g=a[m+1];if(s!==void 0&&f!==s&&(l=!1),n!==void 0&&g!==n&&(u=!1),s=f,n=g,!l&&!u)break}if(!l&&!u)try{r=Y2({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=DG}let h=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new _e(new Float32Array(3*h),3),this._normalAttribute=new _e(new Float32Array(3*h),3),this._uvAttribute=new _e(new Float32Array(2*h),2),this._indexAttribute=new _e(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1];x<c&&(c=x),x>p&&(p=x),S<m&&(m=S),S>f&&(f=S)}let g=p-c,y=f-m;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1],w=(x-c)/g,T=(S-m)/y;this._positionAttribute.setXYZ(v,x,S,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,w,T)}for(let v=0,b=d;v<b;v++){let _=3*v,x=r.elements[_+0],S=r.elements[_+1],w=r.elements[_+2];this._indexAttribute.setX(_+0,x),this._indexAttribute.setX(_+1,S),this._indexAttribute.setX(_+2,w)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let t=new XU(this._shape,this._curveSegments);return t.userData=C5(this.userData),t}}});function U3t(t){return hK||(hK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.82/build",i=Promise.resolve().then(()=>(Mq(),Tq)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),iT=r}())}function j3t(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(mgt.has(s.type)&&s.depth!==void 0&&s.depth>0&&(s.extrudeBevelSize??0)>0&&(e=!0),s.type==="PathGeometry")){let n=s.extrusion;n!==void 0&&n.capType==="round"&&(n.bevel??0)>0&&(e=!0)}}),e}function dgt(t,e){let i=[t.extractShapePointsToFlatArray([],e)];for(let o of t.shapeHoles)i.push(o.extractShapePointsToFlatArray([],e));let r=0;for(let o of i)r+=o.length>>1;let s=new Float64Array(2*r),n=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)s.set(i[o],2*a),a+=i[o].length>>1,n[o]=a;return{points:s,ends:n}}function N4(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=fgt.getNormalMatrix(s).elements;for(let h=0;h<a;h++){let d=3*h,c=3*(i+h),p=t.positions[d],m=t.positions[d+1],f=t.positions[d+2];e.positions[c]=o[0]*p+o[4]*m+o[8]*f+o[12],e.positions[c+1]=o[1]*p+o[5]*m+o[9]*f+o[13],e.positions[c+2]=o[2]*p+o[6]*m+o[10]*f+o[14];let g=t.normals[d],y=t.normals[d+1],v=t.normals[d+2];e.normals[c]=l[0]*g+l[3]*y+l[6]*v,e.normals[c+1]=l[1]*g+l[4]*y+l[7]*v,e.normals[c+2]=l[2]*g+l[5]*y+l[8]*v;let b=2*(i+h);if(n===void 0)e.uvs[b]=t.uvs[2*h],e.uvs[b+1]=t.uvs[2*h+1];else{let[_,x]=n(p,m,t.uvs[2*h],t.uvs[2*h+1],h);e.uvs[b]=_,e.uvs[b+1]=x}}let u=s.determinant()<0;for(let h=0;h<t.indices.length;h+=3)e.indices[r+h]=t.indices[h]+i,e.indices[r+h+1]=t.indices[h+(u?2:1)]+i,e.indices[r+h+2]=t.indices[h+(u?1:2)]+i}function cgt(t){let{owner:e,shape:i,curveSegments:r,assembledAt:s,bevel:n,bevelSegments:a}=t,o=function(c,p){let m=[p],f=g=>{m.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let y of g.points){m.push(y.roundness??0,y.position.x,y.position.y);for(let v of y.controls)m.push(v.position.x,v.position.y)}m.push(g.shapeHoles.length);for(let y of g.shapeHoles)f(y)};return f(c),function(g){let y=2166136261;for(let v=0;v<g.length;v++)y^=g[v],y=Math.imul(y,16777619)>>>0;return y}(new Uint8Array(new Float64Array(m).buffer))}(i,r),l=e??`outline:${o}`,u=`${n}/${a}`,h=O4.get(l);if(h!==void 0&&h.outlineVersion===o&&h.capKey===u&&(t.stillServes?.(h)??1))return YU.placements++,h.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=dgt(c,p);return iT.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),pgt,40)}(i,r,s,n,a);YU.assemblies++;try{let c=function(p,m){return function(f,g,y,v,b){let _=1/0;for(let x=2;x<f.length;x+=3)f[x]<_&&(_=f[x]);if(_===1/0&&(_=0),_!==0)for(let x=2;x<f.length;x+=3)f[x]-=_;return{positions:f,normals:g,uvs:y,indices:v,rise:b-_}}(p.positions(),p.normals(),p.uvs(),p.indices(),m)}(d,s);return O4.set(l,{outlineVersion:o,capKey:u,assembledAt:s,cap:c}),c}finally{d.free()}}function Y1(t,e){return .5*e>1.001*t}var iT,pgt,hK,mgt,fgt,uK,dK,cK,O4,YU,KU,Sm,Zv=j(()=>{dt(),ir(),agt(),IG(),pgt=.4,mgt=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),fgt=new Ts,uK=new _t,dK=new _t,cK=new _t().makeScale(1,1,-1),O4=new Map,YU={assemblies:0,placements:0},KU=class extends ge{constructor(t,e,i=0,r=12,s=3,n,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,iT===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._legacy=o,this._depth=e,this._bevel=i,this._curveSegments=r,this._bevelSegments=s,this._ownerId=n,this.rebuild()}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length>0&&Y1(this._effectiveBevel,t)&&Y1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}setDepth(t){t!==this._depth&&(this._depth=t,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let t=cgt({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>Y1(a.cap.rise,this._depth)&&Y1(a.cap.rise,a.assembledAt)}),e=function(a,o,l,u,h,d=!1){let c=u.positions.length/3,p=l-u.rise,m=u.rise,{points:f,ends:g}=dgt(a,o),y=1/0,v=1/0,b=-1/0,_=-1/0;for(let nt=0;nt<f.length;nt+=2)f[nt]<y&&(y=f[nt]),f[nt]>b&&(b=f[nt]),f[nt+1]<v&&(v=f[nt+1]),f[nt+1]>_&&(_=f[nt+1]);d&&(h=void 0);let x=h??b-y,S=h??_-v,w={minX:y,minY:v,spanX:b-y||1,spanY:_-v||1},T=[],C=0;for(let nt of g)T.push({at:C,count:nt-C}),C=nt;let M=0;for(let nt of T)M+=nt.count;let A=2*c+4*M,R=new Float32Array(3*A),O=new Float32Array(3*A),N=new Float32Array(2*A),B=new Uint32Array(2*u.indices.length+6*M),L=new Uint8Array(A),z=0,k=h===void 0?void 0:(nt,xt)=>[nt/h,xt/h],V=d?(nt,xt,pt,K,ct)=>ogt(u,ct)?[K,pt]:[pt,K]:k,H=d?lgt(u):u,W={positions:R,normals:O,uvs:N,indices:B};N4(H,W,0,0,uK.makeTranslation(0,0,p),k),N4(H,W,c,u.indices.length,dK.makeTranslation(0,0,m).multiply(cK),V),L.fill(1,0,c);let X=2*c,st=2*u.indices.length;for(let nt=0;nt<T.length;nt++){let{at:xt,count:pt}=T[nt],K=f.subarray(2*xt,2*(xt+pt)),ct=igt(K,nt>0),St=d?{u:new Float32Array(pt+1),vScale:0}:rgt(K,x,S),wt=St.u;z=St.vScale;for(let Tt=0;Tt<pt;Tt++){let yt=(Tt+1)%pt,[Ot,Ft]=ct[Tt],Bt=X;for(let[zt,Vt,Wt,$t,Pt,oe]of[[K[2*Tt],K[2*Tt+1],Ot,p,wt[Tt],2],[K[2*yt],K[2*yt+1],Ft,p,wt[Tt+1],2],[K[2*yt],K[2*yt+1],Ft,m,wt[Tt+1],0],[K[2*Tt],K[2*Tt+1],Ot,m,wt[Tt],0]]){let jt=3*X;if(R[jt]=zt,R[jt+1]=Vt,R[jt+2]=$t,O[jt]=Wt[0],O[jt+1]=Wt[1],O[jt+2]=0,d){let[Zt,Jt]=hgt(w,zt,Vt,oe===0);N[2*X]=Zt,N[2*X+1]=Jt}else N[2*X]=Pt,N[2*X+1]=z===0?0:($t-m)/z;L[X]=oe,X++}B[st++]=Bt,B[st++]=Bt+1,B[st++]=Bt+2,B[st++]=Bt,B[st++]=Bt+2,B[st++]=Bt+3}}return sgt(R,O,B),{positions:R,normals:O,uvs:N,indices:B,nearSide:L,vScale:z}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch,this._legacy);this._nearSide=e.nearSide,this._vScale=e.vScale,this._effectiveBevel=t.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),s=this.getAttribute("uv"),n=this.getIndex();if(i!==void 0&&r!==void 0&&s!==void 0&&n!==null&&i.array.length===e.positions.length&&r.array.length===e.normals.length&&s.array.length===e.uvs.length&&n.array.length===e.indices.length)return i.array.set(e.positions),r.array.set(e.normals),s.array.set(e.uvs),n.array.set(e.indices),i.needsUpdate=!0,r.needsUpdate=!0,s.needsUpdate=!0,void(n.needsUpdate=!0);this.setAttribute("position",new _e(e.positions,3)),this.setAttribute("normal",new _e(e.normals,3)),this.setAttribute("uv",new _e(e.uvs,2)),this.setIndex(new _e(e.indices,1))}clone(){let t=new KU(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return t.userData=C5(this.userData),t}}}),ym=j(()=>{wm(),F3t(),ugt(),Zv(),eT(),Sm=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:ss.ODD},t.parameters),s=Math.abs(r.width),n=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=t.shape??e?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ds?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ds(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let u=i??new ds(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:u,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:u}=t.parameters,h=u===1;return t.shape.roundness=a,i<=0?e=new XU(t.shape,n,{windingRule:o}):r<=0?e=new D4(t.shape,i,n,o,l,h):iT!==void 0?e=new KU(t.shape,i,r,n,s,t.ownerId,l,h):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new D4(t.shape,i,n,o,l,h)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function G3t(t,e,i,r,s,n){if(r>=BG)return s>30||s%4==0?(function(h,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;h.addPoint(VM(m-d,f,m-d,f-v,m-d,f+v)),h.addPoint(VM(m,f+c,m-y,f+c,m+y,f+c)),h.addPoint(VM(m+d,f,m+d,f+v,m+d,f-v)),h.addPoint(VM(m,f-c,m+y,f-c,m-y,f-c)),p>0&&ygt(h,d,c,p)}(t,e,i,n),Math.round(s/4)):pK(t,r,s,e,i,n);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},u=function({px:h,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(h-c)/2,_=(d-p)/2;if(b===0&&_===0)return[];m=Math.abs(m),f=Math.abs(f);let x=Math.pow(b,2)/Math.pow(m,2)+Math.pow(_,2)/Math.pow(f,2);x>1&&(m*=Math.sqrt(x),f*=Math.sqrt(x));let S=function(O,N,B,L,z,k,V,H,W,X){let st=Math.pow(z,2),nt=Math.pow(k,2),xt=Math.pow(V,2),pt=Math.pow(H,2),K=st*nt-st*pt-nt*xt;K<0&&(K=0),K/=st*pt+nt*xt,K=Math.sqrt(K)*(W===X?-1:1);let ct=K*z/k*H,St=K*-k/z*V,wt=ct+(O+B)/2,Tt=St+(N+L)/2,yt=(V-ct)/z,Ot=(H-St)/k,Ft=(-V-ct)/z,Bt=(-H-St)/k,zt=nK(1,0,yt,Ot),Vt=nK(yt,Ot,Ft,Bt);return!X&&Vt>0&&(Vt-=UP),X&&Vt<0&&(Vt+=UP),{centerx:wt,centery:Tt,ang1:zt,ang2:Vt}}(h,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:C,centery:M}=S,A=Math.abs(T)/(UP/4);Math.abs(1-A)<1e-7&&(A=1);let R=Math.max(Math.ceil(A),1);T/=R;for(let O=0;O<R;O++)v.push(z3t(w,T)),w+=T;return v.map(O=>{let{x:N,y:B}=BO(O[0],m,f,C,M),{x:L,y:z}=BO(O[1],m,f,C,M),{x:k,y:V}=BO(O[2],m,f,C,M);return{x1:N,y1:B,x2:L,y2:z,x:k,y:V}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%u.length===0?function(h,d,c,p,m,f,g,y){let v=Math.round(m/p.length);h.addPoint(mv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=h.points[b],w=mv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),h.addPoint(w)}return y>0?ggt(h,f,g,y):h.addPoint(mv(0,0)),v}(t,a.x,a.y,u,s,e,i,n):pK(t,r,s,e,i,n)}function pK(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,u=Math.sin(l)*r,h=Math.cos(l)*s;t.addPoint(mv(u,h))}return e<BG?n>0?ggt(t,r,s,n):t.addPoint(mv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&ygt(t,r,s,n)),1}function mv(t,e){return new qg(qt.generateUUID(),new Q(t,e))}function VM(t,e,i,r,s,n){let a=mv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function ggt(t,e,i,r){vgt(t,e,i,r).forEach(s=>t.addPoint(s))}function ygt(t,e,i,r){let s=vgt(t,e,i,r),n=new ds;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function vgt(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Q(s/e,n/i),o=t.points.map(l=>{let u=l.clone();return u.uuid=qt.generateUUID(),u}).reverse();return o.forEach(l=>{l.position.multiply(a);let u=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(u)}),o}var BG,q5,bgt,FO,_gt,I4=j(()=>{wm(),tgt(),L3t(),ym(),dt(),BG=2*Math.PI,q5=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=qt.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,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:r,spikes:s,angle:n,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=t.parameters,d=t.shape,c=G3t(d,.5*i,.5*r,n*Math.PI/180,s,a);return d.isClosed=!0,d.update(),n===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=Sm.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),mK=j(()=>{dt(),Xft(),bgt=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:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new FO(.5*e,n,a):new R8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},FO=class extends P4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,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],s,t,e,i),this.type=s}static fromJSON(t){return new FO(t.radius,t.corner,t.cornerSides)}}}),fK=j(()=>{dt(),_gt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[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:r}=t.parameters,s=new _S;s.moveTo(e[0].x,e[0].y),s.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new D8(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function j0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function W3t(t){let{positions:e,faces:i,materialIndices:r,uvs:s}=t,n=e.length/3,a=i.length/3,o=s!==null&&a>0,l=3*a,u=new Uint32Array(l),h=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,f=8;for(;f<2*l;)f*=2;let g=f-1,y=new Int32Array(f).fill(-1),v=(N,B)=>{let L=(Math.imul(N,2654435761)^B)&g;for(;;){let z=y[L];if(z===-1)return y[L]=m,u[m]=N,h[m]=B,m++;if(u[z]===N&&h[z]===B)return z;L=L+1&g}},b=(N,B)=>{let L=N<B?N:B,z=N<B?B:N,k=(Math.imul(L,2654435761)^z)&g;for(;;){let V=y[k];if(u[V]===L&&h[V]===z)return V;k=k+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(N,B,L)=>{let z=N<B?v(N,B):v(B,N),k=++d[z];k===1?c[z]=L:k===2&&(p[z]=L),_[N]++,_[B]++,x[3*N]+=e[3*B],x[3*N+1]+=e[3*B+1],x[3*N+2]+=e[3*B+2],x[3*B]+=e[3*N],x[3*B+1]+=e[3*N+1],x[3*B+2]+=e[3*N+2]};for(let N=0;N<a;N++){let B=i[3*N],L=i[3*N+1],z=i[3*N+2];S(B,L,z),S(L,z,B),S(z,B,L)}let w=new Float64Array(3*m);for(let N=0;N<m;N++){let B=3*u[N],L=3*h[N];if(d[N]===2){let z=3*c[N],k=3*p[N];w[3*N]=.375*(e[B]+e[L])+.125*(e[z]+e[k]),w[3*N+1]=.375*(e[B+1]+e[L+1])+.125*(e[z+1]+e[k+1]),w[3*N+2]=.375*(e[B+2]+e[L+2])+.125*(e[z+2]+e[k+2])}else w[3*N]=.5*(e[B]+e[L]),w[3*N+1]=.5*(e[B+1]+e[L+1]),w[3*N+2]=.5*(e[B+2]+e[L+2])}let T,C=new Float64Array(3*n);for(let N=0;N<n;N++){let B=_[N];B===3?T=3/16:B>3&&(T=3/(8*B));let L=1-B*Number(T),z=Number(T);B===2&&(L=3/4,z=1/8),C[3*N]=e[3*N]*L+x[3*N]*z,C[3*N+1]=e[3*N+1]*L+x[3*N+1]*z,C[3*N+2]=e[3*N+2]*L+x[3*N+2]*z}let M=new Float64Array(3*(n+m));M.set(C),M.set(w,3*n);let A=new Uint32Array(12*a),R=new Array(4*a),O=o?new Float64Array(24*a):null;for(let N=0;N<a;N++){let B=i[3*N],L=i[3*N+1],z=i[3*N+2],k=b(B,L)+n,V=b(L,z)+n,H=b(z,B)+n,W=12*N;A[W++]=k,A[W++]=V,A[W++]=H,A[W++]=B,A[W++]=k,A[W++]=H,A[W++]=L,A[W++]=V,A[W++]=k,A[W++]=z,A[W++]=H,A[W++]=V;let X=r[N];if(R[4*N]=X,R[4*N+1]=X,R[4*N+2]=X,R[4*N+3]=X,O!==null){let st=6*N,nt=s[st],xt=s[st+1],pt=s[st+2],K=s[st+3],ct=s[st+4],St=s[st+5],wt=j0(nt,pt),Tt=j0(xt,K),yt=j0(pt,ct),Ot=j0(K,St),Ft=j0(nt,ct),Bt=j0(xt,St),zt=24*N;O[zt++]=wt,O[zt++]=Tt,O[zt++]=yt,O[zt++]=Ot,O[zt++]=Ft,O[zt++]=Bt,O[zt++]=nt,O[zt++]=xt,O[zt++]=wt,O[zt++]=Tt,O[zt++]=Ft,O[zt++]=Bt,O[zt++]=pt,O[zt++]=K,O[zt++]=yt,O[zt++]=Ot,O[zt++]=wt,O[zt++]=Tt,O[zt++]=ct,O[zt++]=St,O[zt++]=Ft,O[zt++]=Bt,O[zt++]=yt,O[zt++]=Ot}}return{positions:M,faces:A,materialIndices:R,uvs:O}}var kM,xgt,en,wgt,VG,q3t=j(()=>{dt(),kM=1e4,xgt=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(r){let s=r.getAttribute("position");if(s===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let n=r.getAttribute("uv"),a=r.getIndex(),o=s.count,l=new Map,u=new Uint32Array(o),h=[],d=0;for(let v=0;v<o;v++){let b=s.getX(v),_=s.getY(v),x=s.getZ(v),S=Math.round(b*kM),w=Math.round(_*kM),T=Math.round(x*kM),C=l.get(S);C===void 0&&(C=new Map,l.set(S,C));let M=C.get(w);M===void 0&&(M=new Map,C.set(w,M));let A=M.get(T);A===void 0&&(A=d++,M.set(T,A),h.push(b,_,x)),u[v]=A}let c=[],p=[],m=n===void 0?null:[],f=a!==null?a.count:o,g=(v,b)=>{let _=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,S=a!==null?a.getX(v+2):v+2;if(!(_<o&&x<o&&S<o))return;let w=u[_],T=u[x],C=u[S];w===T||T===C||C===w||(c.push(w,T,C),p.push(b),m!==null&&m.push(n.getX(_),n.getY(_),n.getX(x),n.getY(x),n.getX(S),n.getY(S)))},y=r.groups;if(y.length>0)for(let v=0;v<y.length;v++){let b=y[v],_=b.materialIndex===void 0?0:b.materialIndex,x=Math.max(b.start,0),S=Math.min(b.start+b.count,f);for(let w=x;w<S&&w+2<f;w+=3)g(w,_)}else for(let v=0;v+2<f;v+=3)g(v,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=W3t(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,u=n.length/3,h=a.length/3,d=new Float64Array(3*u);for(let y=0;y<h;y++){let v=3*a[3*y],b=3*a[3*y+1],_=3*a[3*y+2],x=n[_]-n[b],S=n[_+1]-n[b+1],w=n[_+2]-n[b+2],T=n[v]-n[b],C=n[v+1]-n[b+1],M=n[v+2]-n[b+2],A=S*M-w*C,R=w*T-x*M,O=x*C-S*T;d[v]+=A,d[v+1]+=R,d[v+2]+=O,d[b]+=A,d[b+1]+=R,d[b+2]+=O,d[_]+=A,d[_+1]+=R,d[_+2]+=O}for(let y=0;y<u;y++){let v=d[3*y],b=d[3*y+1],_=d[3*y+2],x=Math.sqrt(v*v+b*b+_*_)||1;d[3*y]=v/x,d[3*y+1]=b/x,d[3*y+2]=_/x}let c=3*h,p=new Float32Array(3*c),m=new Float32Array(3*c),f=l!==null&&l.length>0?new Float32Array(2*c):null;for(let y=0;y<c;y++){let v=3*a[y];p[3*y]=n[v],p[3*y+1]=n[v+1],p[3*y+2]=n[v+2],m[3*y]=d[v],m[3*y+1]=d[v+1],m[3*y+2]=d[v+2]}f!==null&&f.set(l.subarray(0,2*c));let g=new ge;g.setAttribute("position",new _e(p,3)),c>0&&(g.setAttribute("normal",new _e(m,3)),g.setAttribute("color",new _e(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new _e(f,2));for(let y=0;y<h;){let v=o[y],b=y;do y++;while(y<h&&o[y]===v);g.addGroup(3*b,3*(y-b),v)}return s.boundingBox!==null&&(g.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(g.boundingSphere=s.boundingSphere.clone()),g}(e,t)}}}),gK=j(()=>{dt(),q3t(),en=new P,wgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new ge().copy(new Zh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(en),i={width:en.x,height:en.y,depth:en.z,subdivisions:0}):i=e.parameters;let s={...i,...t.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(t){let{width:e,height:i,depth:r,subdivisions:s}=t.parameters,n=t.geometry??new ge().copy(new Zh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let u=new pr,h=l.attributes.position;return h?(u.setFromBufferAttribute(h),u):(u.makeEmpty(),u)}(n),n.boundingBox.getSize(en)):en.set(a.width,a.height,a.depth),(e!==en.x||i!==en.y||r!==en.z)&&n.scale(en.x===0?1:e/en.x,en.y===0?1:i/en.y,en.z===0?1:r/en.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new xgt(s).modify(o)):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete t.geometry,Object.assign(n,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new $7(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(en);let n=100/en.x;Object.assign(s.parameters,{width:100,height:en.y*n,depth:en.z*n}),e(this.build(s))})}}}),ZU=j(()=>{wm(),ym(),VG=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 ds?t.shape:new ds,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:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=t.parameters,u=t.shape,h=.5*e,d=.5*i,c=2*Math.PI/r;for(let m=0;m<r;m++){let f=c*m,g=0+Math.sin(f)*h,y=0+Math.cos(f)*d;u.addPoint(u.createPoint(g,y))}u.isClosed=!0;for(let m=0,f=u.points.length;m<f;m++)u.points[m].roundness=s;u.roundness=s,u.update();let p=Sm.create({shape:u,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...t,type:"PolygonGeometry"}})}}});function h_(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function UO(t,e,i,r,s,n){let a=Tgt.copy(e).sub(t),o=Mgt.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let u=a.add(o).normalize();n.copy(t).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(u)),n.addScaledVector(o,r/Math.sin(u))}}function H3t(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var Sgt,Tgt,Mgt,yK,H5,Agt,Cgt,Egt,vK,kG,Pgt,Rgt,Dgt,Ngt,bK=j(()=>{dt(),Sgt=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:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=new yK(.5*e,i,s,n,a,o,l),h=r/e;return h!==1&&u.scale(1,1,h),Object.assign(u,{userData:{...t,type:"PyramidGeometry"}})}},Tgt=new P,Mgt=new P,yK=class extends ge{constructor(t=.5,e=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o,l=[],u=[],h=[],d=[],c=0,p=e/2,m=Math.PI/i,f=t*Math.cos(Math.PI/i),g=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new P(0,-p,0),_=new P(0,p,0),x=new Q(t,-p),S=new Q(f,-p),w=new Q(0,_.y).sub(S),T=new Q(0,_.y).sub(x),C=new Q(w.y,-w.x).normalize(),M=new Q(T.y,-T.x).normalize(),A=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,A);{let k=new P(C.x,C.y,0),V=new P(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);o=k.angleTo(V)}let R=n/Math.tan((Math.PI-w.angle())/2),O=n/Math.tan((Math.PI-o)/2),N=new P;if(!s){u.push(b.x,b.y,b.z),h.push(0,-1,0),d.push(0,0);let k=c++,V=[],H=x.clone(),W=R/Math.cos(Math.PI/i);H.x-=W;for(let X=0;X<i;X++){let st=X/i*Math.PI*2+m;h_(H,new Q(Math.sin(st),Math.cos(st)),N),u.push(N.x,N.y,N.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let X=0;X<V.length;X++)l.push(V[X],k,V[(X+1)%V.length])}let B=[];{let k=new P,V=new P,H=new P,W=new P,X=new P,st=new P;for(let nt=0;nt<i;nt++){let xt=nt/i*Math.PI*2+m,pt=(nt+.5)/i*Math.PI*2+m,K=(nt+1)/i*Math.PI*2+m,ct=new Q(Math.sin(xt),Math.cos(xt)),St=new Q(Math.sin(pt),Math.cos(pt)),wt=new Q(Math.sin(K),Math.cos(K));h_(x,ct,V),h_(x,wt,H),h_(C,St,k),UO(_,V,H,O,O,W),u.push(W.x,W.y,W.z),UO(V,_,H,O,R,X),u.push(X.x,X.y,X.z),UO(H,V,_,R,O,st),u.push(st.x,st.y,st.z),h.push(k.x,k.y,k.z),h.push(k.x,k.y,k.z),h.push(k.x,k.y,k.z),d.push(0,0),d.push(0,0),d.push(0,0);let Tt=c++,yt=c++,Ot=c++;if(l.push(Tt,yt,Ot),n>0){{let zt=V.clone().add(H).multiplyScalar(.5),Vt=_.clone().sub(zt).normalize(),Wt=b.clone().sub(zt).normalize().add(Vt).normalize().multiplyScalar(-1);L(zt,st.clone().sub(X),Wt,w.angle())}let Ft,Bt;{let zt=new P;h_(M,wt,zt);let Vt=st.clone().add(W).multiplyScalar(.5);Vt=H3t(Vt,H,_);let Wt=st.clone().sub(W);[Ft,Bt]=L(Vt,Wt,zt,o,W.y)}{let zt=Ft,Vt=zt.clone().setY(0).normalize(),Wt=new P(0,-1,0),$t=Vt.clone().cross(Wt);z(zt,Vt,Wt,$t)}B.concat(Bt);{let zt=w.angle(),Vt=Math.PI-zt,Wt=_.clone();Wt.y-=n/Math.sin(zt-Math.PI/2);let $t=new P,Pt=[];for(let jt=0;jt<a;jt++){let Zt=[],Jt=Math.PI/2-Vt*jt/a,$=Math.cos(Jt),se=Math.sin(Jt),Pe=pt;for(let Ve=0;Ve<=jt;Ve++){let ie=Math.cos(Pe),oi=Math.sin(Pe);k.x=$*oi,k.y=se,k.z=$*ie,$t.copy(Wt).addScaledVector(k,n),u.push($t.x,$t.y,$t.z),h.push(k.x,k.y,k.z),d.push(0,0),Zt.push(c++),Pe+=2*Math.PI/jt/i}Pt.push(Zt)}Bt.reverse(),Pt.push(Bt);let oe=Pt.length-1;for(let jt=0;jt<oe;jt++){let Zt=Pt[jt],Jt=Pt[jt+1],$=Zt.length-1;l.push(Jt[1],Zt[0],Jt[0]);for(let se=1;se<=$;se++)l.push(Zt[se],Zt[se-1],Jt[se]),l.push(Jt[se+1],Zt[se],Jt[se])}}}}}function L(k,V,H,W,X){let st=-W/2,nt=(Math.PI-W)/2,xt=V.clone().normalize().cross(H);k.addScaledVector(H,-n/Math.sin(nt));let pt=new P,K=new P,ct=c,St=[];for(let wt=0;wt<=a;wt++){let Tt=st+wt/a*W;K.set(0,0,0),K.addScaledVector(xt,Math.sin(Tt)),K.addScaledVector(H,Math.cos(Tt));for(let yt=0;yt<=1;yt++){let Ot=yt/1-.5;if(pt.copy(k),pt.addScaledVector(V,Ot),pt.addScaledVector(K,n),X!=null){let Ft=Math.max(0,pt.y-X);pt.addScaledVector(V,-Ft/V.y)}u.push(pt.x,pt.y,pt.z),h.push(K.x,K.y,K.z),d.push(0,0),yt===0&&St.push(c),c++}}for(let wt=0;wt<a;wt++)for(let Tt=0;Tt<1;Tt++){let yt=ct+Tt+2*wt,Ot=yt+2,Ft=Ot+1,Bt=yt+1;l.push(yt,Ot,Bt),l.push(Ot,Ft,Bt)}return[k.clone().addScaledVector(V,.5),St]}function z(k,V,H,W){let X=Math.PI/2,st=T.angle()-X,nt=[],xt=new P,pt=new P;for(let ct=0;ct<=a;ct++){let St=[],wt=ct/a;for(let Tt=0;Tt<=ct;Tt++){let yt=((ct?Tt/ct:0)-.5)*v,Ot=Math.cos(yt),Ft=Math.sin(yt),Bt=(X+Math.atan(Math.tan(st)*Ot))*wt,zt=Math.cos(Bt),Vt=Math.sin(Bt);xt.set(0,0,0),xt.addScaledVector(V,Vt*Ot),xt.addScaledVector(H,zt),xt.addScaledVector(W,Vt*Ft),pt.copy(k).addScaledVector(xt,n),u.push(pt.x,pt.y,pt.z),h.push(xt.x,xt.y,xt.z),d.push(0,0),St.push(c++)}nt.push(St)}let K=nt.length-1;for(let ct=0;ct<K;ct++){let St=nt[ct],wt=nt[ct+1],Tt=St.length-1;l.push(St[0],wt[1],wt[0]);for(let yt=1;yt<=Tt;yt++)l.push(St[yt-1],St[yt],wt[yt]),l.push(St[yt],wt[yt+1],wt[yt])}}this.setIndex(l),this.setAttribute("position",new fe(u,3)),this.setAttribute("normal",new fe(h,3)),this.setAttribute("uv",new fe(d,2))}}}),B4=j(()=>{wm(),ym(),H5=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),r=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(t){let e=t.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}=t.parameters,h={x:.5*i,y:.5*r},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function p(x,S,w){return S>i&&w>r?Math.min(x*i/S,x*r/w):S>i?x*i/S:w>r?x*r/w:x}let m=[];m[0]=s[0]===0?0:p(s[0],s[0]+s[3],s[0]+s[1]),m[1]=s[1]===0?0:p(s[1],s[1]+s[2],s[1]+s[0]),m[2]=s[2]===0?0:p(s[2],s[2]+s[1],s[2]+s[3]),m[3]=s[3]===0?0:p(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,g=c.x,y=c.y,v=d.y;e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(g,v)),e.addPoint(e.createPoint(f,v)),e.isClosed=!0;let b=!0;for(let x=0,S=e.points.length;x<S;x++)e.points[x].roundness=m[x],x>0&&m[x]!==m[x-1]&&(b=!1);b&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let _=Sm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),_K=j(()=>{dt(),Agt=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=qt.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:r=i,depth:s=i,widthSegments:n=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:u,thetaLength:h}=t.parameters;return h===0?(e=new ge,e.setAttribute("position",new fe([],3))):e=new Mc(.5*i,n,a,o,l,u,h*qt.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),xK=j(()=>{dt(),Cgt=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:r=8,heightSegments:s=8}=t.parameters,n=new Cc(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),wK=j(()=>{dt(),Egt=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:r,angle:s,cornerRadius:n,cornerSegments:a}=t.parameters,o=new vK(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},vK=class extends ge{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],u=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-u,r),r*=Math.PI/180;let h=[],d=Math.PI/2,c=(pt=0,K=0,ct=0)=>new P(pt,K,ct),p=c(),m=c(),[f,g,y]=[e/2,t/2,i/2],v=-g,b=+g,[_,x,S]=[c(v,-f,+y),c(v,-f,-y),c(v,+f,-y)],w=(pt,K=!1)=>Math.sin(pt-Math.PI/(+K+1)),T=(pt,K=!1)=>Math.cos(pt-Math.PI/(+K+1));S.y=Math.sin(r)*e-f;let C=Math.cos(r)*e-y,M=_.z-u;r<=d?(S.z=Math.min(C,M),S.z==M&&(S.y-=(C-M)/Math.tan(d-r))):x.z=Math.min(x.z-C-y,_.z-u),p.subVectors(_,x),m.subVectors(S,x);let A=Math.min(p.length(),m.length())*s/100,R=A*Math.tan(r/2),O=A/Math.cos(r/2),N=p.clone().normalize().add(m.normalize()).setLength(O).add(x);p.set(0,w(r,!0),T(r,!0)),h.push([S,p.clone()]);let B=(Math.PI-r)/n;for(let pt=0;pt<=n;pt++){let K=d+r+pt*B;p.set(0,Math.sin(K)*R,Math.cos(K)*R),p.add(N),m.set(0,w(K),T(K)),h.push([p.clone(),m.clone()])}h.push([_,c(0,1,0)]);let L=Math.sin(B/2)*R*2,z=h.length-1,k=h[0][0].distanceTo(h[1][0]),V=k+L*n+h[z-1][0].distanceTo(h[z][0]);h[0].push(1);for(let pt=0;pt<=n;pt++)h[pt+1].push(1-(k+pt*L)/V);h[z].push(0);let H,W,X,[st,nt,xt]=h[0];for(let pt=1;pt<h.length;pt++)[H,W,X]=h[pt],a.push(v,st.y,st.z,v,H.y,H.z,b,st.y,st.z,b,st.y,st.z,v,H.y,H.z,b,H.y,H.z),o.push(0,nt.y,nt.z,0,W.y,W.z,0,nt.y,nt.z,0,nt.y,nt.z,0,W.y,W.z,0,W.y,W.z),l.push(0,xt,0,X,1,xt,1,xt,0,X,1,X),[st,nt,xt]=[H,W,X];this.setAttribute("position",new fe(a,3)),this.setAttribute("normal",new fe(o,3)),this.setAttribute("uv",new fe(l,2))}}}),QU=j(()=>{wm(),ym(),kG=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 ds?t.shape:new ds,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:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=t.parameters,d=t.shape,c=.5*e,p=.5*i,m=a*Math.PI/360/s,f=Math.PI/2*3*-1,g=c*r/100,y=p*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let _=m*b,x=0+Math.sin(_)*c,S=0+Math.cos(_)*p;d.addPoint(d.createPoint(x,S))}}else for(let b=0;b<s;b++){let _=0+Math.cos(f)*c,x=0+Math.sin(f)*p;d.addPoint(d.createPoint(_,x)),f+=m,_=0+Math.cos(f)*g,x=0+Math.sin(f)*y,d.addPoint(d.createPoint(_,x)),f+=m}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let v=Sm.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}});return Object.assign(v,{userData:{...t,type:"StarGeometry"}})}}}),SK=j(()=>{dt(),Pgt=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,r=new Cc(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),TK=j(()=>{dt(),OS(),Rgt=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),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let n=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=function(h,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=qt.clamp(m/360,0,1);if(x===0){let S=new ge;return S.setAttribute("position",new fe([],3)),S}return x===1&&(b=0),new kU(!0,h,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return u.scale(1,i/e,1),Object.assign(u,{userData:{...t,type:"TorusGeometry"}})}}}),MK=j(()=>{dt(),Dgt=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:r,radialSegments:s,p:n,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new N8(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),AK=j(()=>{wm(),ym(),Ngt=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 ds?t.shape:new ds,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:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=t.parameters,u=t.shape,h=.5*e,d=.5*i;o?(u.addPoint(u.createPoint(-h,d)),u.addPoint(u.createPoint(h,-d)),u.addPoint(u.createPoint(-h,-d))):(u.addPoint(u.createPoint(0,d)),u.addPoint(u.createPoint(h,-d)),u.addPoint(u.createPoint(-h,-d))),u.isClosed=!0;for(let p=0,m=u.points.length;p<m;p++)u.points[p].roundness=r;u.roundness=r,u.update();let c=Sm.create({shape:u,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...t,type:"TriangleGeometry"}})}}}),$3t=j(()=>{dt()}),X3t=j(()=>{dt(),new ta,new _t,new mc,new P,new P,new P,new P});function CK(){let t=new ge;return t.setAttribute("position",new _e(new Float32Array([]),3)),t.setIndex(new _e(new Uint16Array([]),1)),t}var EK,JU,Ogt=j(()=>{hn(),ke(),eT(),dt(),ZS(),wm(),ym(),Zv(),EK=CK().attributes,JU=class extends ge{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this._nearSide=new Uint8Array(0),this._depth=0,this._effectiveBevel=0,this._vScale=0,Object.assign(this.attributes,EK),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:r,height:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:u,fontSize:h,extrusionVersion:d}=t,c=Na.getDisplayedValue(l),p=function(S,w,T,C){let M=typeof S.width=="string"?Number(C.getVariable(S.width)):S.width,A=[""],R="";for(let O of T)R+=O,O===" "||O===`
|
|
352
352
|
`?(A[A.length-1]+=R,R="",O===`
|
|
353
|
-
`&&A.push("")):w.getTextWidth(A[A.length-1]+R,S)>M&&(A[A.length-1].length&&A.push(""),w.getTextWidth(A[A.length-1]+R,S)>M&&(R.length===1?(A[A.length-1]+=R,R=""):(A[A.length-1]+=R.slice(0,-1),R=R[R.length-1],A.push(""))));return A[A.length-1]+=R,A}(t,i,u===2?c.toUpperCase():u===3?c.toLowerCase():c,e),{shapes:m,charWidths:f,charCoords:g}=i.generateShapes(p,t,e),y=.5*(typeof r=="number"?r:Number(e.getVariable(r))),v=.5*(typeof s=="number"?s:Number(e.getVariable(s))),b=m.map(S=>new ds().fromShape(S,!0));this.vectorShapes=b;let _=b.map(S=>Sm.create({shape:S,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:h,extrusionVersion:d,windingRule:n<=0?ss.NONZERO:ss.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),x=_.length?Mg(_):CK();x.translate(-y,v,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([S,w])=>{this.setAttribute(S,w)}),this.setIndex(x.index),this.adoptNearSide(_,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,u=l._nearSide;if(u===void 0||u.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=u.length,r=Math.max(r,l._effectiveBevel??0),s=l._vScale??s}this._effectiveBevel=r,this._vScale=s;let n=new Uint8Array(i),a=0;for(let o of t){let l=o._nearSide;n.set(l,a),a+=l.length}this._nearSide=n}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length===this.getAttribute("position")?.count&&Y1(this._effectiveBevel,t)&&Y1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position"),r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=$a(new ge,JU.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 Y3t(t){if(!tj)return PK||(PK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});Igt(a),tj=!0}())}var Igt,zG,tj,PK,$5=j(()=>{zG=new Promise(t=>{Igt=t}),tj=!1});function jO(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),r=Object.keys(e.attributes);if(i.length!==r.length)return!1;for(let l of r){let u=t.attributes[l],h=e.attributes[l];if(u===void 0||u.isInterleavedBufferAttribute===!0||h.isInterleavedBufferAttribute===!0||u.itemSize!==h.itemSize||u.normalized!==h.normalized||u.array.constructor!==h.array.constructor||u.array.length!==h.array.length)return!1}let s=t.index,n=e.index;if(s===null!=(n===null))return!1;let a=!1;if(s!==null&&n!==null){if(s.array.length!==n.array.length)return!1;let l=s.array.constructor,u=n.array.constructor;if(l!==u){if(l!==Uint32Array||u!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let u=t.groups[l],h=e.groups[l];if(u.start!==h.start||u.count!==h.count||u.materialIndex!==h.materialIndex)return!1}for(let l of r){let u=t.attributes[l],h=e.attributes[l];u.array.set(h.array),u.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,u=n.array;for(let h=0,d=u.length;h<d;h++){let c=u[h];l[h]=c===65535?4294967295:c}}else s.array.set(n.array);s.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 ej(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,u=Bgt.makeScale(e,i,r).invert().elements;for(let h=0,d=o.length;h<d;h+=3)o[h]*=e,o[h+1]*=i,o[h+2]*=r,s=l[h],n=l[h+1],a=l[h+2],l[h]=u[0]*s+u[4]*n+u[8]*a,l[h+1]=u[1]*s+u[5]*n+u[9]*a,l[h+2]=u[2]*s+u[6]*n+u[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var Bgt,Vgt=j(()=>{dt(),Bgt=new _t});function ij(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function zM(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),r=0;for(let n of i){let a=ij(n);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let s=new Array(r);for(let n=0;n<r;n++){let a=e[n];if(typeof a!="number")return;s[n]=a}return s}(t)}}function GO(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=>ij(l)===-1),r=0;for(let l of e){let u=ij(l);u>=r&&(r=u+1)}let s=t,n=-1,a=-1;for(let l=0;l<r;l++)l in s?typeof s[l]!="number"&&a===-1&&(a=l):n===-1&&(n=l);let o=[`${e.length} keys`,"max index "+(r-1)];return n!==-1&&o.push(`first missing index ${n}`),a!==-1&&o.push(`non-number at ${a} (${typeof s[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function kgt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function LG(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let d=e?e.getX(h):h,c=t.getX(d),p=t.getY(d),m=t.getZ(d),f=Math.round(c*s),g=Math.round(p*s),y=Math.round(m*s),v=n.get(f);v===void 0&&(v=new Map,n.set(f,v));let b=v.get(g);b===void 0&&(b=new Map,v.set(g,b));let _=b.get(y);_===void 0&&(_=r++,b.set(y,_),o.push(c,p,m)),a[h]=_}let l=[],u=[];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]),u.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:u}}var u_,nf,Ie,WO,qO,HO,us,d_,LM,FM,UM,rj,jP,Qv=j(()=>{dt(),$5(),ke(),X5(),Vgt(),OS(),u_=new pr,nf=new P,zG.then(t=>{Ie=t}),WO=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),qO=new Uint32Array([0,1,2,3]),HO=new Uint8Array([4]),us=class extends ge{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),r=dm.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&ej(this.subdividedGeometry.attributes,...r),this.originalGeometry&&ej(this.originalGeometry.attributes,...r),this.data=t;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(nf.fromArray(r));let n=nf.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/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 s=0;try{s=us.allocate(t),i=us.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&us.freeSubdivPointer(s)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Zh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(us.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new ta,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;u_.setFromBufferAttribute(e),u_.getCenter(i),t.boundingSphere.radius=i.distanceTo(u_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),u_.getSize(nf);let r={width:nf.x,height:nf.y,depth:nf.z};return this.userData.parameters=r,r}static build(t,e,i,r){let s,n,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Ie.free_bvh(e),Ie.free_subdivision_surface(e));try{s=us.allocate(t,r)}catch(l){console.error(l,t),s=us.allocate({positionWASM:WO,indexWASM:qO,verticesPerFaceWASM:HO},r)}Ie.set_destination_refinement_level(s,0);let o=us.buildLevel(s,!0,a);return n=t.subdivisions>0?us.buildRefined(s,t.subdivisions,a):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:n}}static buildRefined(t,e,i){try{return Ie.set_destination_refinement_level(t,e),us.buildLevel(t,!1,i)??null}catch{try{return Ie.set_destination_refinement_level(t,e-1),us.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 r,s=t.shape!==void 0||t.path!==void 0?e.geometry:sm(t,i,!1,e);r=Aft(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=LG(s.getAttribute("position"),r);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let c=t.radialSegments*t.heightSegments*3*2;n=[c,c+3*t.radialSegments]}let{indices:u,verticesPerFace:h,uvs:d}=function(c,p,m,f,g){let y=[],v=[],b=g?m.getAttribute("uv"):void 0,_=b&&b.itemSize===2?[]:void 0,x=T=>{if(_){let C=g[T];_.push(b.getX(C),b.getY(C))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),C=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&C<=24&&C%4==0&&m.userData.parameters.angle>=360){let R=T.length/2/C;T=T.filter((O,N)=>Math.floor(N/2)%R===0)}let M=0;for(let R=0;R<T.length;R+=2)M+=(T[R]-T[(R===0?T.length:R)-2])*(T[R+1]+T[(R===0?T.length:R)-1]);c.length=0;let A=0;if(M<0)for(let R=0;R<T.length;R+=2)c.push(T[R],T[R+1],0),y.push(A++);else for(let R=T.length-2;R>=0;R-=2)c.push(T[R],T[R+1],0),y.push(A++);return v.push(A),{indices:y,verticesPerFace:v}}let S=new Float32Array([m.userData.parameters.depth])[0],w=0;for(;w<p.length;){if(m.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[w]+2]===S||c[3*p[w]+2]===0)&&T++,(c[3*p[w+1]+2]===S||c[3*p[w+1]+2]===0)&&T++,(c[3*p[w+2]+2]===S||c[3*p[w+2]+2]===0)&&T++,T===3)break}if(p[w+1]===p[w+3]&&p[w+2]===p[w+5]||p[w+0]===p[w+3]&&p[w+2]===p[w+4]){d_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),LM.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),FM.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),UM.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),LM.sub(d_).normalize(),FM.sub(d_).normalize(),UM.sub(d_).normalize();let T=LM.cross(FM).dot(UM),C=w;Math.abs(T)>.005||f&&f.some((M,A)=>A%2!=1&&C>=f[A]&&C<f[A+1])?(y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3):(y.push(p[w],p[w+1],p[w+4],p[w+5]),x(w),x(w+1),x(w+4),x(w+5),v.push(4),w+=6)}else y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3}if(m.useNgonForTopBottomFaceDuringBake){let T=[],C=[],M=0;for(let A=0,R=0;A<c.length;A+=3,R++)c[A+2]===0&&(T.push(R),M++),c[A+2]===S&&C.push(R);if(m.userData.parameters.extrudeBevelSize===0){let A=C[0];C[0]=C[1],C[1]=A}T.reverse(),y.push(...T,...C),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:u,verticesPerFace:h,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=zM(t.positionWASM),l=zM(t.indexWASM),u=zM(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${GO(t.positionWASM)}, indexWASM ${GO(t.indexWASM)}, verticesPerFaceWASM ${GO(t.verticesPerFaceWASM)}`);i=o,r=l,s=u;let w=zM(t.uvWASM);Ie.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=WO,r=qO,s=HO;let h=i.length,d=r.length,c=s.length,p=i.length+n.length+a.length,m=r.length+s.length,f=p*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,y=Ie._malloc(f);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${f}) failed`);let v,b=new Float32Array(Ie.HEAPF32.buffer,y,p),_=new Uint32Array(Ie.HEAPU32.buffer,y+g,m);b.set(i,0),b.set(n,i.length),b.set(a,i.length+n.length),_.set(r,0),_.set(s,r.length),t?.scaleBaked?.some(w=>w!==1)&&(v=new _t().makeScale(...t.scaleBaked.map(w=>typeof w=="number"?w:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+n.length)*Float32Array.BYTES_PER_ELEMENT,S=a.length?v?Ie.alloc_subdivision_surface_uvs2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ie.alloc_subdivision_surface_uvs(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ie.alloc_subdivision_surface2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ie.alloc_subdivision_surface(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return Ie._free(y),S}static buildLevel(t,e,i,r,s,n=!1){let a=s?Ie.get_mesh_data2(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i,s.elements):Ie.get_mesh_data(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i),o=Ie.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),u=0,h=Ie.HEAPU32[o[u]>>2],d=Ie.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let c=Ie.HEAPU32[o[u]>>2],p=Ie.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let m=Ie.HEAPU32[o[u]>>2],f=Ie.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g,y=Ie.HEAPU32[o[u]>>2],v=Ie.HEAPU32.subarray(y>>2,(y>>2)+l[u]);if(u++,Ie.alloc_subdivision_surface_uvs){let _=o[9];if(_>0){let x=Ie.HEAPU32[o[8]>>2];g=Ie.HEAPF32.subarray(x>>2,(x>>2)+_)}}if(r===void 0){let _=new ge;if(_.setIndex(new hm(v,1)),_.setAttribute("position",new fe(d,3)),_.setAttribute("normal",new fe(p,3)),g&&_.setAttribute("uv",new fe(g,2)),e){_.setAttribute("faceMap",new hm(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new _e(x,4))}return Ie.free_mesh_data(a),_.userData.type="SubdivGeometry",_}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,n){let _=r.getIndex();_!==null&&_.array.length===v.length&&(_.copyArray(v),_.needsUpdate=!0)}let b=r.getAttribute("uv");g&&b&&b.array.length===g.length&&(b.copyArray(g),b.needsUpdate=!0),Ie.free_mesh_data(a)}static freeSubdivPointer(t){Ie.free_bvh(t),Ie.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let r=Ie.get_wireframe_data_for_base_level(t),s=Ie.HEAPU32.subarray(r>>2,4+(r>>2)),n=s.subarray(2,4),a=0,o=Ie.HEAPU32[s[a]>>2],l=Ie.HEAPF32.subarray(o>>2,(o>>2)+n[a]);a++;let u=Ie.HEAPU32[s[a]>>2],h=Ie.HEAPU32.subarray(u>>2,(u>>2)+n[a]);if(e===void 0){let d=new ge;d.setAttribute("position",new fe(l,3));let c=new Float32Array(l.length);for(let p=0,m=l.length;p<m;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new _e(c,3)),d.setIndex(new hm(h,1)),Ie.free_wireframe_data_for_base_level(r),d}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Ie.free_wireframe_data_for_base_level(r)}static updateCollabMesh(t,e,i){let r=e===0;r||Ie.set_destination_refinement_level(t,e);let s=i?Ie.get_topological_data2(t,r?Ie.Level.CONTROL:Ie.Level.REFINED,i.elements):Ie.get_topological_data(t,r?Ie.Level.CONTROL:Ie.Level.REFINED),n=Ie.HEAPU32.subarray(s>>2,8+(s>>2)),a=n.subarray(3,6),o=0,l=Ie.HEAPU32[n[o]>>2],u=new Float32Array(Ie.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=Ie.HEAPU32[n[o]>>2],d=new Uint32Array(Ie.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let c,p=Ie.HEAPU32[n[o]>>2],m=new Uint8Array(Ie.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Ie.alloc_subdivision_surface_uvs){let f=n[7];if(f>0){let g=Ie.HEAPU32[n[6]>>2];c=new Float32Array(Ie.HEAPF32.subarray(g>>2,(g>>2)+f))}}return Ie.free_topological_data(s),{positions:u,indices:d,verticesPerFace:m,uvs:c}}},d_=new P,LM=new P,FM=new P,UM=new P}),zgt=j(()=>{$Y(),XY(),R4(),YY(),I4(),OS(),mK(),fK(),gK(),ZU(),bK(),B4(),_K(),xK(),wK(),QU(),SK(),TK(),MK(),AK(),ym(),Ii(),$Y(),XY(),R4(),YY(),I4(),$3t(),OS(),mK(),fK(),gK(),ZU(),bK(),B4(),_K(),xK(),wK(),QU(),SK(),TK(),MK(),AK(),ym(),X3t(),ugt(),Ogt(),Qv(),$5(),W5(),Zv(),rj={ConeGeometry:qft,CubeGeometry:Hft,CylinderGeometry:RG,DodecahedronGeometry:$ft,EllipseGeometry:q5,HelixGeometry:Cft,IcosahedronGeometry:bgt,LatheGeometry:_gt,NonParametricGeometry:wgt,PolygonGeometry:VG,PyramidGeometry:Sgt,RectangleGeometry:H5,SphereGeometry:Agt,PlaneGeometry:Cgt,BackdropGeometry:Egt,StarGeometry:kG,TextFrameGeometry:Pgt,TorusGeometry:Rgt,TorusKnotGeometry:Dgt,TriangleGeometry:Ngt,VectorGeometry:Sm},jP=t=>{let e=rj[t.type]??mft(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 sm(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let u of a){let h=n;for(let d of u)h=h[d];for(s in h){let d=h[s];pX(d)&&!Lgt.includes(s)&&(h[s]=e.getVariable(d,[r.uuid,"geometry",...u,s]),pX(h[s])&&(h[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let u=r.profileShape;u!==void 0&&(l.shapeData=u),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let u=ds.createFromState(n.shape,n.width,n.height);l.shape=u,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),l.geometry=new $7().parse(n),l.geometry.groups.length===0){let u=l.geometry;u.addGroup(0,Math.max(u.getIndex()?.count??0,u.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let u=new us(n,i);return u.data=t,u}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let u=mft(n.type);if(u)return u.create(n,e);Nn("text",`a ${n.type}`);let h=ds.createFromState(RS.defaultData(),100,100);return jP({...n,shape:h,type:"VectorGeometry"})}if(n.type==="UIGeometry")return H5.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=jP(l)}catch(u){console.error(u),console.error(`Error generating geometry with inputs: ${l}`);let h=ds.createFromState(RS.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=jP(l)}return o}var Lgt,RK,sj,X5=j(()=>{ke(),dt(),zgt(),Ii(),B4(),wm(),Qv(),Lgt=["font"]}),K3t=j(()=>{X5(),RK=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 r=this.objects.get(t);return r===void 0?(r=this.createObject(t,e,i),this.objects.set(t,r)):r.isShared=!0,r}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()}},sj=class extends RK{constructor(t){super(),this.flatShading=t}disposeObject(t){t.dispose()}createObject(t,e,i){let r=sm(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}}});function V4(){return rT}function Fgt(){if(rT==="webgpu"){if(aj!==void 0)return aj;oj||(oj=!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(OK===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 OK}function Ugt(t,e){return Fgt().createRootMaterial(t,e)}function DK(t,e,i){return Fgt().createSharedMaterial(t,e,i)}function NK(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function nj(){return jgt}var rT,aj,OK,oj,lj,jgt,Ggt,Tm=j(()=>{rT="webgl",oj=!1}),Z3t=j(()=>{Ggt={markNeedsUpdateRendererDirty:()=>{}}});function Dg(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(s=>s.data.type==="light");if(r){let s=r.data,n=Number(e.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?n/100:s.alphaOverride)<1)return!0}for(let s of t.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="cavity"&&s.data.type!=="dust"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let n=s.data.visible?s.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(e.getVariable(n)??100)/100))),n===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let a of s.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&s.data.type==="noise"){let a=e.color(s.data.colorA).a,o=e.color(s.data.colorB).a,l=e.color(s.data.colorC).a,u=e.color(s.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,u)));h<1&&(n=h)}i+=(1-i)*n}}return i<1}var FG=j(()=>{});function fv(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Bv,Mn,sT,Wgt,IK,BK,_l,Jv=j(()=>{Bv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,Mn=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),sT={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"]},Wgt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),tb=j(()=>{dt(),tT(),IK=class extends U5(dr){},BK=t=>t.type==="Mesh",_l=class extends IK{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 _l(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 BK(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 VK(){return UG}var UG,jG,GG=j(()=>{UG=null,jG=null});function hj(t){return"variable_"+t}var $O,XO,YO,kK,KO,zK,ZO,LK,k4,WG=j(()=>{ke(),T3t(),Fft(),Uft(),Dc(),CG(),PG(),K3t(),Tm(),kft(),Z3t(),FG(),Jv(),vo(),tb(),Fi(),dt(),GG(),Ii(),$O=new _t,XO=new P,YO=new Se,kK=new P,KO=new Qi,zK=class extends Ift{constructor(t){super(),this.shared=t}create(t){return new AG(t,this.shared)}},ZO=new Set,(k4=LK=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new sj(!0),this.geometryCache2=new sj(!1),this.imageHolderCache=new zK(this),this.thisContext={scene:Ggt,shared:this},this.deletedImage=new gg(wU.emptyImage,this),this.deletedVideo=new gg(c4.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[s,n]of Object.entries(e.images))this.addImage(s,n);if(e.videos)for(let[s,n]of Object.entries(e.videos))this.addVideo(s,n);if(e.audios)for(let[s,n]of Object.entries(e.audios))this.addAudio(s,n);if(e.particles)for(let[s,n]of Object.entries(e.particles))this.addParticle(s,n);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=DK(cs.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:r,data:s}of t.variables)this.addVariableHolder(r,s),e&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(t.userAPIs??{}))this.addUserAPI(r,s);for(let[r,s]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(t.images))this.addImage(r,s);for(let[r,s]of Object.entries(t.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(t.colors))this.addColor(r,s);for(let[r,s]of Object.entries(t.lib.materials))this.addMaterial(r,s.asset);for(let[r,s]of Object.entries(t.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(t.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(t.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(t.fonts))this.addFont(r,s)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:cs.defaultTwoLayerData("phong").layers}),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=DK(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:cs.defaultTwoLayerData("phong").layers}),Ugt(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 gg(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 gg(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let i=t.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let s=r.root??r;for(let n of s?.data?.layers??[]){let a=n?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||e.layer!==void 0&&n.id!==e.layer&&a.type!==e.layer)continue;let o=a.texture?.image;if(o==null)continue;let l=(typeof o=="string"?this.uiBuffer(o):void 0)??this.image(o);if(!l)continue;let u=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),h=l.img;return{texture:u,width:h?.width??0,height:h?.height??0,layerId:n.id,layerType:a.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new gg(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 FU(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 Dr(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 Dr(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof X1)return e;{let i=new X1({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 X1&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=EG;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):Nn("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 X1&&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 r=localStorage.getItem(hj(t));i=r!==null?JSON.parse(r):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(hj(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let o=a[1],l=i,u={scene:r,shared:this},h=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(h,l,u)});let d=this.materials[o];d&&d.onVariableUpdate(h,l,u)}else{let o=r.find(a[0]);if(o===void 0){this.variables[t].locations.splice(n,1);continue}if(s=!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*qt.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),Mi.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 u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(h=>{let d=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(d.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||typeof s.type!="string"||s.type==="VectorGeometry"||s.type==="PathGeometry")return!1;let n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let u of Object.keys(s))a.set(n(u),u);let o={};for(let[u,h]of Object.entries(e??{})){let d=a.get(n(u));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof h=="string"||typeof h=="number")&&(o[d]={textValue:String(h)});continue}let c=s[d];typeof h=="number"&&isFinite(h)&&(typeof c=="number"||typeof c=="string")&&(o[d]=h)}if(Object.keys(o).length===0)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.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 r=i.dataPatched,s=r?.geometry;if(!s||s.type!=="NonParametricGeometry")return!1;let n=e?.vertices;if(n===void 0||typeof n.length!="number"||n.length<9||n.length%3!=0||n.length/3>LK.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,u=n instanceof Float32Array?n:Float32Array.from(n),h=u.length/3;if(e.normals!==void 0){if(e.normals.length!==u.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 S=0;S<x.length;S++)if(x[S]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=s.data,S=x?.index;if(S?.array?.length){let w=(x?.attributes?.position?.array?.length??0)/3;if(h!==w)return function(T,C){let M=`${T}/${C}`;ZO.has(M)||(ZO.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${C}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}(h,w),!1;l=S}}let d=1/0,c=1/0,p=1/0,m=-1/0,f=-1/0,g=-1/0;for(let x=0;x<u.length;x+=3){let S=u[x],w=u[x+1],T=u[x+2];S<d&&(d=S),S>m&&(m=S),w<c&&(c=w),w>f&&(f=w),T<p&&(p=T),T>g&&(g=T)}let y=(x,S)=>({array:x,itemSize:S,type:"Float32Array",normalized:!1}),v={position:y(u,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:f-c,depth:g-p,data:{attributes:v,...l?{index:l}:{}}},_=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,_),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let s=r.children,n=Math.PI/180,a=!1;if(e===null)for(let o of s)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return s.length;{let o=Math.min(e.length,s.length);for(let l=0;l<o;l++){let u=e[l],h=s[l];if(u==null){h.transformOverride!==void 0&&(h.transformOverride=void 0,a=!0);continue}let d=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]};u.position&&(typeof u.position.x=="number"&&(d.position[0]=u.position.x),typeof u.position.y=="number"&&(d.position[1]=u.position.y),typeof u.position.z=="number"&&(d.position[2]=u.position.z)),u.rotation&&(typeof u.rotation.x=="number"&&(d.rotation[0]=u.rotation.x*n),typeof u.rotation.y=="number"&&(d.rotation[1]=u.rotation.y*n),typeof u.rotation.z=="number"&&(d.rotation[2]=u.rotation.z*n)),u.scale&&(typeof u.scale.x=="number"&&(d.scale[0]=u.scale.x),typeof u.scale.y=="number"&&(d.scale[1]=u.scale.y),typeof u.scale.z=="number"&&(d.scale[2]=u.scale.z)),h.transformOverride=d,h.position.fromArray(d.position),h.rotation.fromArray(d.rotation),h.scale.fromArray(d.scale),h.updateMatrix(),h.hasNonUniformScale&&(h.updateMatrixWorld(),h.updateMatrixWorldRigid())}}}return a?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let r=new _l(t);r.playModeVisible=e.visible!==!1,r.expand(),typeof e.name=="string"&&(r.name=e.name);let s=Math.PI/180;return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(r.position.x=e.position.x),typeof e.position.y=="number"&&(r.position.y=e.position.y),typeof e.position.z=="number"&&(r.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(r.rotation.x=e.rotation.x*s),typeof e.rotation.y=="number"&&(r.rotation.y=e.rotation.y*s),typeof e.rotation.z=="number"&&(r.rotation.z=e.rotation.z*s)),e.scale&&(typeof e.scale.x=="number"&&(r.scale.x=e.scale.x),typeof e.scale.y=="number"&&(r.scale.y=e.scale.y),typeof e.scale.z=="number"&&(r.scale.z=e.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let r=[];for(let u of Array.isArray(i)?i:[i]){let h=u.root??u;h&&Array.isArray(h.layers)&&h.data&&!r.includes(h)&&r.push(h)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=u=>{if(typeof u=="string"){let h=new Dr(1,1,1,1);try{h.set(u)}catch{return null}return{r:h.r,g:h.g,b:h.b,a:void 0}}if(u&&typeof u=="object"&&"r"in u){let h=u;if([h.r,h.g,h.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(h.r,h.g,h.b)>1?1/255:1;return{r:h.r*d,g:h.g*d,b:h.b*d,a:typeof h.a=="number"?Math.max(0,Math.min(h.a,1)):void 0}}return null},o=(u,h,d)=>{if(!u.hasValue(h))return!1;let c=u.getValue(h);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof FU?u.setValue(h,new Dr(d.r,d.g,d.b,p)):typeof c.setRGBA=="function"?c.setRGBA(d.r,d.g,d.b,p):c.setRGB(d.r,d.g,d.b),!0},l=!1;for(let u of r){let h=u.data.layers??[],d=c=>u.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=h.find(f=>f.data.type==="color"),m=p&&d(p.id);if(c&&m&&o(m,"color",c)&&(l=!0,c.a!==void 0)){let f=c.a<1||Dg(u.data,this);u.setTransparent?u.setTransparent(f,s.scene):u.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(u.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),s),l=!0);for(let c of e.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?h.find(y=>y.id===c.id):typeof c.index=="number"?h[c.index]:typeof c.type=="string"?h.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=sT[p.data.type]??[],g=Object.keys(p.data);for(let[y,v]of Object.entries(c)){if(y==="id"||y==="index"||y==="type")continue;let b=g.find(x=>x===y)??g.find(x=>n(x)===n(y))??y;if(f.includes(b))continue;let _=a(v);if(_&&o(m,b,_))l=!0;else if(typeof v=="number"&&isFinite(v))u.onVariableUpdate?.(["layer",p.id,b],v,s),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((S,w)=>{u.onVariableUpdate?.(["layer",p.id,b,x[w]],S,s)}),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?.($O))return $O.decompose(XO,YO,kK),t[1]==="position"?XO[t[2]]:(KO.setFromQuaternion(YO,i.rotation.order),KO[t[2]]*qt.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=qt.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let r=this.variables[i],s=r.locations?.findIndex(n=>Dn.equal(n,e));s!==void 0&&s!==-1&&r.locations.splice(s,1)}if(typeof t=="string"){let i=t,r=t;do{if(r=i,this.variables[i]===void 0)break;let s=this.variables[i].value;e&&this.variables[r]!==void 0&&this.variables[r].locations.push(e),i=s}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(ea.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 r=e.userAPIs[t.path[1]];if(r){let s=t.type===0&&t.props.debounce===void 0,n=this.getUserAPI(t.path[1]);n!==void 0&&n===this.openAIRealtime?n.update(r):n?.update(r,this,s)}}}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 r=e.userWebhooks[t.path[1]];r&&this.getUserWebhook(t.path[1])?.update(r)}}else t.path[0]==="lib"&&this.updateLibByOp(ea.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let r=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};r.update(s),r.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=jG;return i===null?(Nn("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=VK();return i===null?(Nn("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=VK();return i===null?(Nn("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 k4(Zl.emptyData())});function qgt(t){return E4(t)||t?.isTSLNodeMaterial===!0}var yo,QO,JO,tI,FK,eI,cd,UK,jK,c_,Fr,Hgt=j(()=>{MG()}),l0=j(()=>{ke(),la(),Tm(),Hgt(),Fi(),hn(),yo=class extends Vs{setMaterialOverride(t,e){this.materialOverride=NK(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),er(t.path,["geometry"])&&this.syncShadowCatcher(i),function(r,s){let n=[];if(s.length!==r.length)return null;{let a=0;for(;a<r.length;){if(s[a]==="*")n.push(r[a]);else if(r[a]!==s[a])return null;a+=1}}return n}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(t.props)){let n=this.material[Number(r)],a=i.shared.material(s);a!==n&&yo.disposeOneMaterial(n),this.material[Number(r)]=a}else if(er(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(ea.drop(t,1),e.material,i)}else if(er(t.path,["materials","*"])&&Array.isArray(this.material)){let r=t.path[1];if("materials"in e&&r<this.material.length){let s=e.materials[r];typeof s!="string"&&this.material[r].updateByOp(ea.drop(t,2),s,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,r=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 s=this.materialOverride!==void 0;!s&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!s&&(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(r.flatShading,r.side,r.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let n=this.data;if(!s&&n.geometry?.type!=="NonParametricGeometry"&&"materials"in n&&n.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(n.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(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(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.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=function(){let r=rT==="webgpu"&&lj!==void 0?lj:void 0;return r===void 0?null:NK(r())}();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;qgt(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&cmt(this.material).forEach(t=>{yo.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),bo=j(()=>{ke(),Fi(),WG(),l0(),dt(),X5(),Zv(),Qv(),Vgt(),QO=new P,JO=new Me,tI=new Me,FK=new P,eI=new _t,cd=new vr,UK=cd.geometry,jK=cd.material,c_=new P,Fr=class extends yo{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 _t().fromArray(e.bindMatrix),this.bindMatrixInverse=new _t)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof ge&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof ge?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof k4){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 f4.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return f4.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.updateByPatchedOpGeometry(ea.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,O4.delete(t),this._posed=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 r,s,n,a=t;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=sm(d,e,this.data.flatShading,this)}a.scaleBaked?[r,s,n]=a.scaleBaked:{width:r,height:s,depth:n}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,u=typeof s=="number"?s:1,h=typeof n=="number"?n:1;o.sxPrev!==void 0&&ej(this.localGeometry.attributes,l/o.sxPrev,u/o.syPrev,h/o.szPrev),o.sxPrev=l,o.syPrev=u,o.szPrev=h}else if(!this.absorbDepthInteraction(t)){let r=sm({...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&jO(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(t){let e=this.localGeometry;if(e?.shiftDepthTo===void 0)return!1;let i=t;if(typeof i.depth!="number")return!1;let r=e.userData?.parameters;if(r===void 0)return!1;for(let s of Object.keys(i))if(s!=="depth"&&i[s]!==r[s])return!1;return!!e.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}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 r=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&kgt(t.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof ge&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=i.shared,n=this.chooseGeoemtryCache(s),a=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=sm(o,s,this.data.flatShading,this);jO(a,l)?(l.dispose(),a.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(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,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof ge&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=this.chooseGeoemtryCache(i),n=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===n&&n.isShared!==!0){let a=sm(r,i,this.data.flatShading,this);return jO(n,a)?(a.dispose(),n.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,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:r,value:s}}of i)this.updateMorphInfluences(r,e.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}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.posedGeometry()?.boundingBox;if(i)return i.getCenter(t),void i.getSize(e).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*r.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?t.fromArray(r.centerOffset):t.setScalar(0),e.set(r.width,r.height,r.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 Me,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){e.fromBufferAttribute(i,r);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),i.setXYZW(r,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;JO.fromBufferAttribute(r.attributes.skinIndex,t),tI.fromBufferAttribute(r.attributes.skinWeight,t),QO.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=tI.getComponent(s);if(n!==0){let a=JO.getComponent(s);eI.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(FK.copy(QO).applyMatrix4(eI),n)}}return e.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(t,e){let i=this.posedGeometry();if(i===void 0)return!1;cd.geometry=i,cd.material=this.material,cd.matrixWorld.copy(this.matrixWorld);let r=e.length;cd.raycast(t,e);for(let s=r;s<e.length;s++)e[s].object=this;return cd.geometry=UK,cd.material=jK,!0}posedGeometry(){let t=this.skeleton;if(!this.isSkinnedMesh||t===void 0)return;let e=this.geometry,{position:i,skinIndex:r,skinWeight:s}=e.attributes;if(!i||!r||!s)return;let n=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<t.bones.length;d++){let c=t.bones[d];if(!c||!t.boneInverses[d])return;n.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===e&&a.version===i.version&&a.pose.length===n.length&&a.pose.every((d,c)=>d===n[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,u=l?.count===o?l:new _e(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,c_)),u.setXYZ(d,c_.x,c_.y,c_.z);let h=new ge;h.setAttribute("position",u);for(let d of["normal","uv","uv1"]){let c=e.attributes[d];c&&h.setAttribute(d,c)}return h.setIndex(e.index),h.groups=e.groups,h.drawRange=e.drawRange,h.computeBoundingSphere(),h.computeBoundingBox(),this._posed={source:e,version:i.version,pose:n,geometry:h},h}}});function gv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!E4(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Fr&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,r=new Float32Array(i.length),s=new P;for(let n=0;n<i.length;n+=3)s.set(i[n],i[n+1],i[n+2]).normalize(),r[n]=s.x,r[n+1]=s.y,r[n+2]=s.z;e.geometry.setAttribute("extrudeNormal",new fe(r,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,r=e.geometry.attributes,s=r.position.array,n=r.normal.array,a=new Float32Array(s.length);for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=new P(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(u):i.set(l,{normals:[u],result:new P})}i.forEach((o,l)=>{for(let u of o.normals)o.result.add(u);o.result.divideScalar(o.normals.length)});for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=i.get(l)?.result;u&&(a[o]=u.x,a[o+1]=u.y,a[o+2]=u.z)}e.geometry.setAttribute("extrudeNormal",new fe(a,3))}(t)}function iI(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function yv(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,r=e.randomColor;if(r!==void 0&&3*r.count===i.length)return;let s=new Float32Array(i.length),n=parseInt(t.uuid.replace(/\D/g,"")),a=[iI(qt.seededRandom(n)),iI(qt.seededRandom(n+1e4)),iI(qt.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new _e(s,3))}var Y5=j(()=>{dt(),MG(),bo()});function GK(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function Q3t(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function WK(t,e,i,r){let s=16*(e.children.length+1);Jw.length<s&&(Jw=new Float32Array(s));let n=0,a=l=>{l.toArray(Jw,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),uj.multiplyMatrices(t.hiddenMatrix,t.matrix);for(let l of e.children)!Ag(l)||l.playModeVisible===!1||(dj.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),GP.multiplyMatrices(uj,dj),(!o||!GP.equals(r))&&a(GP));try{return n===0?0:function(l,u){return SG(C4().instanced_union(wG(l),u))}(i,Jw.subarray(0,16*n))}finally{Eft(i)}}var pd,qK,uj,dj,GP,Jw,cm,z4,K5,Hh,Hu,L4,nT=j(()=>{la(),dt(),W5(),Y5(),l0(),ns(),pd=new _t,qK=new _t,uj=new _t,dj=new _t,GP=new _t,Jw=new Float32Array(0),cm=class extends yo{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new ge,this.onAfterRender=(r,s,n,a,o,l)=>{super.onAfterRender(r,s,n,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 r=0;r<this.children.length;r++){let s=this.children[r];s instanceof cm&&s.dataPatched.visible===!0&&s.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let s=this.children[r];if(s instanceof Vs&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){pd.multiplyMatrices(s.hiddenMatrix,s.matrix).multiply(s.pivotMatrix);try{let n=Q3t(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=x3t(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:WK(s,n,a,pd)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&NO(s.booleanMeshSetAddress,pd),s.booleanMatrixInvOld.copy(pd).invert(),s.booleanWasTransformed=!1}else s instanceof cm&&s.needsTransformForDownstream===!0?(n===void 0?NO(s.booleanMeshSetAddress,pd):s.booleanMeshSetAddress=WK(s,n,s.booleanMeshSetAddress,pd),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(NO(s.booleanMeshSetAddress,qK.multiplyMatrices(pd,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(pd).invert(),s.booleanWasTransformed=!1)}catch(n){console.error(n),s.booleanMeshSetAddress=0,s.geometry.userData.booleanOperationDidFail=!0;continue}if(s.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let r=this.geometry;r.dispose(),this.geometry=new ge,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new fe([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=C4(),a=BY(r,s),o=n.mesh_topological_data(a),l=o.positions(),u=o.indices();return o.free(),a.free(),{positions:l,indices:u,verticesPerFace:new Uint8Array(u.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new ge,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=C4(),l=BY(r,s),u=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new fe(u.positions(),3)),n.setAttribute("normal",new fe(u.normals(),3)),u.free(),n.boundingSphere===null&&(n.boundingSphere=new ta),l.tri_count()===0)n.boundingSphere.center.set(0,0,0),n.boundingSphere.radius=0,n.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();n.boundingSphere.center.set(h[0],h[1],h[2]),n.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,n.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return SG(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(r){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(r)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,gv(this),yv(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),aT=j(()=>{dt(),vo(),o0(),(z4||(z4={})).is=function(t){return Mi.is(t)&&t instanceof Hd},K5=(t,e)=>class extends a0(t,e){updateState_Light(i,r){if(this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let s=this.shadow;s.camera.far=i.depth,s.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),Mm=j(()=>{dt(),nT(),la(),o0(),Hh=t=>t instanceof Vs,Hu=t=>t!==null&&t instanceof cm,L4=t=>VU.is(t)});function Sa(t,e){return e.color(t)}function HK(t=new Date,e){let i=e.format,r=t.getSeconds(),s=t;e&&e.timeZone!==null&&(s=function(d,c){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(d),m=f=>Number(p.find(g=>g.type===f)?.value);return new Date(m("year"),m("month")-1,m("day"),m("hour"),m("minute"),m("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let n,a=s.getHours(),o=s.getMinutes();e.format12h24h==="12ampm"&&(n=a>=12?"PM":"AM");let l,u,h=a;switch(e.format12h24h!=="24"&&(h=a%12,h===0&&(h=12)),i){case"HH:mm:ss":l=[h,o,r];break;case"HH:mm":l=[h,o];break;case"HH":l=[h],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":u=s.getFullYear();break;case"month":u=s.getMonth()+1;break;case"dayOfYear":u=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=s.getDate();break;case"secondOfDay":u=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),u=0}return l!==void 0?{textValue:l,suffix:n}:u}var cj,eb,qG=j(()=>{}),J3t=j(()=>{dt(),QS(),JS(),cj=class extends Xv(smt){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){Yv(this.object,cj.geometryHelper,t,e)}}}),Z5=j(()=>{dt(),J3t(),aT(),eb=class extends K5(wS,cj){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 r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new SS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof SS&&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(r,s){r.shadow.camera.right=s/2,r.shadow.camera.left=-s/2,r.shadow.camera.top=s/2,r.shadow.camera.bottom=-s/2,r.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 HG(t){return t instanceof yo&&t.needsAO&&!Ec(t)&&t.isDecalObject!==!0}function $G(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 XG(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function tAt(t){let e=1/0,i=-1/0;for(let r of t.getLayersOfType("reflection")){let s=r.data;if(!s.visible||s.mirror===1)continue;let n=typeof s.blur=="number"?s.blur:null;e=Math.min(e,n??0),i=Math.max(i,n??10)}return e===1/0?null:{min:e,max:i}}function eAt(t){for(let e of t.getLayersOfType("reflection")){let i=e.data;if(!i.visible)continue;let{blur:r,thickness:s,steps:n,stepSize:a}=i;return typeof r!="number"||typeof s!="number"||typeof n!="number"||typeof a!="number"?"variable":{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function $K(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&Q5,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=XG(e),o=e.getLayersOfType("cavity");return(n.length>0||o.length>0)&&(t.layers.set(8),s.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=n.length>0,i.cavity=o.length>0,yv(t),gv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&HG(t)&&t.layers.enable(5),$G(t),i}function XK(t,e){if(!e.layers)return!1;let i=t.layers.mask&Q5,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=XG(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return s.length>0&&(t.layers.set(3),(n.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),r=!0),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&HG(t)&&t.layers.enable(5),$G(t),r}function YK(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&Q5,s=!1,n=XG(e),a=e.getLayersOfType("transmission").filter(u=>u.data.visible),o=e.getLayersOfType("outline").filter(u=>u.data.visible),l=e.getLayersOfType("cavity").filter(u=>u.data.visible);return n>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),s=!0),n===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),r&&t.layers.set(9),!r&&HG(t)&&t.layers.enable(5),$G(t),s}function pj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if((t.raycast===vr.prototype.raycast||t.raycast===Vs.prototype.raycast)&&t.isSkinnedMesh!==!0){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&(mj.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(mj)))continue;let o=Xgt.copy(a.matrixWorld).invert(),l=Ygt.copy(e.ray).applyMatrix4(o),u=t.matrixWorld;l.applyMatrix4(u);let h=$gt;h.set(l.origin,l.direction),h.near=e.near,h.far=e.far,h.layers.mask=e.layers.mask;let d=h.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var Q5,$gt,Xgt,Ygt,mj,jM,Kgt,rI,sI,nI,ib,Xs,YG=j(()=>{ns(),Y5(),la(),l0(),dt(),Q5=512,$gt=new A5,Xgt=new _t,Ygt=new mc,mj=new ta}),iAt=j(()=>{dt(),QS(),JS(),jM=class extends Xv(imt){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){Yv(this.object,jM.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=jM._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 r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},(Kgt=jM)._vector=new P}),J5=j(()=>{dt(),iAt(),aT(),rI=new P,sI=new P,nI=new Se,ib=class extends K5(Lg,Kgt){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 r=this.shadow.camera;r.fov=2*qt.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new SS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof SS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),sI.setFromMatrixPosition(this.matrixWorld),nI.setFromRotationMatrix(this.matrixWorld),rI.copy(this.up).applyQuaternion(nI).negate().multiplyScalar(this.distance),this.target.position.copy(sI).add(rI),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))}}}),Nc=j(()=>{ke(),Qh(),dt(),vo(),Dc(),qG(),k5(),Z5(),Fi(),Tm(),dt(),l0(),Mm(),YG(),J5(),Ii(),nT(),Xs=class extends j5(Yu){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new g8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ia.getDensity({}),this.fogHeightFalloff=ia.getHeightFalloff({}),this.fogHeightBase=ia.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ae,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new ks(n0,{...W2.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new M5(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 r=RU();r===null?Nn("ui-2d","a page's 2D scene"):this.uiScene=new r.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=RU();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()})):Nn("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=Sa(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 cm&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof yo)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;dv.isSoft(e)}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=Sa(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ia.getMode(t),this.fogDensity=ia.getDensity(t),this.fogHeightFalloff=ia.getHeightFalloff(t),this.fogHeightBase=ia.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=Sa(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;er(t.path,["fog"])?this.updateFog(n.fog,i.shared):er(t.path,["sky"])?this.updateSky(n.sky,i.shared):er(t.path,["grading"])?this.gradingState=n.grading??null:er(t.path,["ao"])?this.updateAo(n.ao,i.shared):er(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):er(t.path,["shadow"])?this.updateShadow(n.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||s!==n.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(Sa(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 instanceof ks&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){let t=this.scene?.find(this.data.publish.playCamera);return t instanceof ks?t:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(CU).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof eb&&i.visible&&t<VP&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof ib&&i.visible&&t<CU-VP&&(this.penumbraSizeArrayCache[VP+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;Mi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||L4(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),pj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function KK(){return KG}function aI(){if(fj===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 fj}function oI(t){return t?.isWebGPUSplineRenderer===!0}var KG,fj,Zgt=j(()=>{KG=null,fj=null});function gj(){return QG}var ZG,QG,JG=j(()=>{ZG=null,QG=null});function ZK(t,e,i){return t2.setRGB(t,e,i,Ns),{r:t2.r,g:t2.g,b:t2.b}}function rAt(t,e,i){let r,s=kS(t.angle,0),[n,a]=yj(t.offset),[o,l]=yj(t.morph),u=t.colors??[],h=t.steps??[],d=Math.min(10,u.length,h.length);if(d===0)return[1,1,1,1];if(t.gradientType===1){let g=3*(e+o)-(e+n)-1,y=3*(i+l)-(i+a)-1;r=Math.hypot(g,y)+s}else if(t.gradientType===2){let g=-1*Math.atan2(e+o-.5+n,i+l-.5+a),y=s/Math.PI/-2+.5*g/Math.PI;r=y-Math.floor(y)}else{let g=.5+o/(e!==0?e:1e-6),y=l/(i!==0?i:1e-6),v=Math.cos(s)*g-Math.sin(s)*y,b=Math.sin(s)*g+Math.cos(s)*y,_=v*v+b*b;r=_>1e-12?(((e-.5+n)/2+v/2)*v+((i-.5+a)/2+b/2)*b)/_:0}let c=u[0][0],p=u[0][1],m=u[0][2],f=u[0][3];for(let g=1;g<d;g++){let y=h[g-1],v=h[g]-y,b=v!==0?Math.min(1,Math.max(0,(r-y)/v)):r>=y?1:0;t.smooth&&(b=b*b*(3-2*b)),c+=(u[g][0]-c)*b,p+=(u[g][1]-p)*b,m+=(u[g][2]-m)*b,f+=(u[g][3]-f)*b}return[c,p,m,f]}function sAt(t,e){let i=t,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let s=e,n=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=kS(o.alpha,1);if(!(l<=0))if(o.type==="color"){let u,h=o.color;typeof h=="string"?u=typeof s?.color=="function"?s.color(h):void 0:h&&typeof h.r=="number"&&(u=h),u&&n.push({kind:"color",layer:o,rgb:{...ZK(u.r,u.g,u.b),a:u.a??1},alpha:l})}else o.type==="gradient"&&n.push({kind:"gradient",layer:o,alpha:l})}),n.length===0?null:(a,o)=>{let l=1,u=1,h=1,d=!0;for(let c of n){let p,m,f,g;if(c.kind==="color")({r:p,g:m,b:f}=c.rgb),g=c.rgb.a;else{let[v,b,_,x]=rAt(c.layer,a,o);({r:p,g:m,b:f}=ZK(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,u+=(m-u)*y,h+=(f-h)*y,d=!1}return{r:l,g:u,b:h}}}if(i?.color&&i.color.isColor===!0){let{r:s,g:n,b:a}=i.color;return()=>({r:s,g:n,b:a})}return null}var t2,kS,yj,nAt=j(()=>{dt(),t2=new ae,kS=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,yj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function aAt(t,e){if(t==="torus"){let l=e()*Math.PI*2,u=e()*Math.PI*2,h=Math.cos(l),d=Math.sin(l),c=Math.cos(u),p=Math.sin(u);return{x:(1.4+.7*c)*h,y:-(1.4+.7*c)*d,z:.7*p,nx:c*h,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,u=Math.cos(l),h=Math.sin(l);return{x:.8*u,y:1.6*(e()-.5),z:.8*h,nx:u,ny:0,nz:h,cr:1,cg:1,cb:1}}let i=e()*Math.PI*2,r=2*e()-1,s=Math.acos(r),n=Math.sin(s)*Math.cos(i),a=Math.cos(s),o=Math.sin(s)*Math.sin(i);return{x:n,y:a,z:o,nx:n,ny:a,nz:o,cr:1,cg:1,cb:1}}function oAt(t){let{geometry:e,matrix:i}=t,r=e.getAttribute("position");if(!r||r.count<3)return null;let s=e.getAttribute("normal"),n=e.getAttribute("uv"),a=e.getAttribute("color"),o=e.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let u=(y,v)=>o?o.getX(3*y+v):3*y+v,h=i?i.elements:null,d=i?new Ts().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[0]*v+h[4]*b+h[8]*_+h[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[1]*v+h[5]*b+h[9]*_+h[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[2]*v+h[6]*b+h[10]*_+h[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=u(y,0),b=u(y,1),_=u(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,C=p(b)-S,M=m(b)-w,A=c(_)-x,R=p(_)-S,O=m(_)-w,N=C*O-M*R,B=M*A-T*O,L=T*R-C*A;g+=.5*Math.sqrt(N*N+B*B+L*L),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let X=b+_>>1;f[X]<y?b=X+1:_=X}let x=b,S=u(x,0),w=u(x,1),T=u(x,2),C=v(),M=v();C+M>1&&(C=1-C,M=1-M);let A,R,O,N=1-C-M,B=c(S)*N+c(w)*C+c(T)*M,L=p(S)*N+p(w)*C+p(T)*M,z=m(S)*N+m(w)*C+m(T)*M;if(s){if(A=s.getX(S)*N+s.getX(w)*C+s.getX(T)*M,R=s.getY(S)*N+s.getY(w)*C+s.getY(T)*M,O=s.getZ(S)*N+s.getZ(w)*C+s.getZ(T)*M,d){let X=d[0]*A+d[3]*R+d[6]*O,st=d[1]*A+d[4]*R+d[7]*O,nt=d[2]*A+d[5]*R+d[8]*O;A=X,R=st,O=nt}}else{let X=c(S),st=p(S),nt=m(S),xt=c(w)-X,pt=p(w)-st,K=m(w)-nt,ct=c(T)-X,St=p(T)-st,wt=m(T)-nt;A=pt*wt-K*St,R=K*ct-xt*wt,O=xt*St-pt*ct}let k=Math.sqrt(A*A+R*R+O*O)||1,V=1,H=1,W=1;if(a)V=a.getX(S)*N+a.getX(w)*C+a.getX(T)*M,H=a.getY(S)*N+a.getY(w)*C+a.getY(T)*M,W=a.getZ(S)*N+a.getZ(w)*C+a.getZ(T)*M;else if(t.sampleColor){let X=n?n.getX(S)*N+n.getX(w)*C+n.getX(T)*M:.5,st=n?n.getY(S)*N+n.getY(w)*C+n.getY(T)*M:.5,nt=t.sampleColor(X,st);nt&&(V=nt.r,H=nt.g,W=nt.b)}return{x:B,y:L,z,nx:A/k,ny:R/k,nz:O/k,cr:V,cg:H,cb:W}}}}function QK(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),vv),i=function(l){let u=l>>>0;return()=>{u|=0,u=u+1831565813|0;let h=Math.imul(u^u>>>15,1|u);return h=h+Math.imul(h^h>>>7,61|h)^h,((h^h>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Lh:Lh,n=new Float32Array(4*ic),a=new Float32Array(ic),o=new Float32Array(4*vv).fill(1);for(let l=0;l<e;l++){let u=r?t.sampler(i):aAt(t.shape,i),h=r?u.x:u.x*s,d=r?u.y:u.y*s,c=r?u.z:u.z*s,{nx:p,ny:m,nz:f}=u;o[4*l+0]=u.cr,o[4*l+1]=u.cg,o[4*l+2]=u.cb;let g,y,v,b=l*yg,_=(1.8+.8*i())*t.hairLength*s/(yg-1),x=.5+1.5*i(),S=(.02+.06*i())*s;Math.abs(m)<.99?(g=-f,y=0,v=p):(g=1,y=0,v=0);let w=Math.sqrt(g*g+y*y+v*v)||1;for(let T=0;T<yg;T++){let C=T/(yg-1),M=C*C*.4*s,A=S*Math.sin(C*x*Math.PI*2),R=4*(b+T);n[R+0]=h+p*_*T+A*g/w,n[R+1]=d+m*_*T-M+A*y/w,n[R+2]=c+f*_*T+A*v/w,n[R+3]=T===0?0:1,T<yg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var yg,vv,ic,Lh,Gp,p_,G0,af,W0,WP,Qgt=j(()=>{dt(),ic=(vv=16384)*(yg=32),Lh=100}),Jgt=j(()=>{dt(),la(),JG(),nAt(),Qgt(),Gp=1/60,p_=new _t,G0=new Se,af=new P,W0=new P,WP=class extends Vs{constructor(t,e,i){super(t,e),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.settledSimSeconds=0,this.lastMotionFingerprint=0,this.lastBoneQuat=new Se,this.lastBonePos=new P,this.hasLastBone=!1,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=i,this.data=e,this.geometry.setAttribute("position",new _e(new Float32Array(0),3)),this.material=new Uo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new vr(new Mc(Lh,48,32),new Uo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new QR;r.setAttribute("position",new _e(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new vr(r,new Uo({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=e.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:e.guideStrands,hairLength:e.hairLength,spreadRadius:e.spreadRadius,headShape:e.headShape,baseObjectId:e.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(t){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+t/1e3,4*Gp*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(G0,af);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(G0))<.9999995||this.lastBonePos.distanceToSquared(af)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(G0),this.lastBonePos.copy(af),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+t}motionFingerprint(){let t=this.data;return t.gravity+2*t.damping+3*t.localStiffness+4*t.globalStiffness+5*t.globalRange+6*t.stiffnessFalloff+7*t.windStrength+8*t.vspCoefficient+9*t.kink+10*t.kinkFrequency+11*t.clumpStrength+12*t.clumpSize+13*t.clumpTipScale}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>6}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(t){this.playModeActive=t,t&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(t,e){super.updateState(t,e),this.updateHairState(t)}updateHairState(t){if((t.guideStrands!==void 0||t.hairLength!==void 0||t.spreadRadius!==void 0||t.headShape!==void 0||t.baseObjectId!==void 0)&&this.regenerate(),(t.headShape!==void 0||t.baseObjectId!==void 0)&&this.applyScalpState(),t.headColor!==void 0){let e=this.scalpMesh.material;e.isMeshBasicMaterial===!0&&e.color.setRGB(t.headColor.r,t.headColor.g,t.headColor.b,Ns)}(t.castShadow!==void 0||t.receiveShadow!==void 0)&&this.applyShadowState(),t.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let t=this.data.castShadow??!0,e=this.data.receiveShadow??!0;this.castShadow=t,this.receiveShadow=e,this.scalpMesh.castShadow=t,this.scalpMesh.receiveShadow=e,this.ribbonMesh.castShadow=t,this.ribbonMesh.receiveShadow=e}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let t=this.data,e=this.regenSnapshot;if(e===null||e.guideStrands!==t.guideStrands||e.hairLength!==t.hairLength||e.spreadRadius!==t.spreadRadius||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId){let i=e===null||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:t,baseObjectId:e,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,t==="object"&&e){let s=this.context.scene.find(e);if(s){this.baseFoundAtRegen=!0,s.updateWorldMatrix(!0,!0);let n=this.collectBaseSources(s),a=n?function(o){let l=[];for(let d of o){let c=oAt(d);c&&l.push(c)}if(l.length===0)return null;let u=new Float64Array(l.length),h=0;for(let d=0;d<l.length;d++)h+=l[d].total,u[d]=h;return h<=0?null:d=>{let c=d()*h,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;u[g]<c?p=g+1:m=g}let f=p===0?c:c-u[p-1];return l[p].sample(f,d)}}(n.sources):null;if(this.baseSourceGeomsAtRegen=n?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=n?.hashes??[],this.baseColorHashAtRegen=n?.colorHash??0,n&&a){let o=this.baseWorldScale(s),l=Math.max(n.radius*o,.001);this.baseScaleAtRegen=o;let u=o;return QK({shape:"object",guideStrands:i,hairLength:r,sampler:h=>{let d=a(h);return{...d,x:d.x*u,y:d.y*u,z:d.z*u}},samplerRadius:l})}}}return QK({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;p_.copy(t.matrixWorld).invert();let n=p_.clone(),a=o=>{if(o.isHairSystem===!0||o!==t&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let u=o===t?void 0:new _t().multiplyMatrices(n,o.matrixWorld),h=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:u,sampleColor:sAt(h,this.context.shared)??void 0}),i.push(WP.matrixHash(u)),s+=function(c,p){let m=c,f=0,g=1,y=b=>{f+=b*g,g+=1},v=m?.data?.layers;if(v&&typeof v.forEach=="function"){let b=p;v.forEach(_=>{let x=_.data;if(x.visible!==!1){if(x.type==="color"){let S=x.color,w=typeof S=="string"?typeof b?.color=="function"?b.color(S):void 0:S;w&&typeof w.r=="number"&&(y(w.r),y(w.g),y(w.b)),y(kS(x.alpha,1))}else if(x.type==="gradient"){let S=x;for(let w of S.colors??[])y(w[0]),y(w[1]),y(w[2]),y(w[3]);for(let w of S.steps??[])y(w);y(kS(S.angle,0)),y(S.gradientType),y(S.smooth?1:0)}}})}else m?.color&&m.color.isColor===!0&&(y(m.color.r),y(m.color.g),y(m.color.b));return f}(h,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;u?(af.copy(d.center).applyMatrix4(u),c=af.length(),p=WP.matrixMaxScale(u)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let u of o.children)a(u)};return a(t),e.length===0?null:{sources:e,hashes:i,radius:Math.max(r,.001),colorHash:s}}static matrixHash(t){if(!t)return 0;let e=t.elements,i=0;for(let r=0;r<16;r++)i+=e[r]*(r+1);return i}static matrixMaxScale(t){let e=t.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);return Math.max(i,r,s,1e-6)}baseWorldScale(t){return p_.copy(t.matrixWorld).decompose(af,G0,W0),Math.max(Math.abs(W0.x),Math.abs(W0.y),Math.abs(W0.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let t=this.context.scene.find(this.data.baseObjectId);if(!t)return;if(!this.baseFoundAtRegen)return void this.regenerate();t.updateWorldMatrix(!0,!0);let e=this.collectBaseSources(t),i=e?.sources??[],r=e?.hashes??[],s=this.baseSourceGeomsAtRegen,n=this.baseSourceHashesAtRegen,a=i.length!==s.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==s[o]||Math.abs(r[o]-n[o])>1e-4*Math.max(Math.abs(n[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(e?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(t);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let t=this.data.headShape,e=t==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!e,!e&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=t==="torus"?new ZR(1.4*Lh,.7*Lh,24,48):t==="cylinder"?new k2(.8*Lh,.8*Lh,1.6*Lh,48,1):new Mc(Lh,48,32))}boneTransform(t,e){let i=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let r=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;r&&(i=r)}p_.copy(i).decompose(e,t,W0)}raycast(t,e){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(t,i);for(let r of i)r.object=this,e.push(r)}get shadowBoundsRadius(){let t=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(t+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(t){return this.boneTransform(G0,t),t}updateEntityBoxSize(t,e){let i=this.shadowBoundsRadius;t.set(0,0,0),e.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),gj()?.release(this)}}});function qP(){return{shapeInput:()=>`
|
|
353
|
+
`&&A.push("")):w.getTextWidth(A[A.length-1]+R,S)>M&&(A[A.length-1].length&&A.push(""),w.getTextWidth(A[A.length-1]+R,S)>M&&(R.length===1?(A[A.length-1]+=R,R=""):(A[A.length-1]+=R.slice(0,-1),R=R[R.length-1],A.push(""))));return A[A.length-1]+=R,A}(t,i,u===2?c.toUpperCase():u===3?c.toLowerCase():c,e),{shapes:m,charWidths:f,charCoords:g}=i.generateShapes(p,t,e),y=.5*(typeof r=="number"?r:Number(e.getVariable(r))),v=.5*(typeof s=="number"?s:Number(e.getVariable(s))),b=m.map(S=>new ds().fromShape(S,!0));this.vectorShapes=b;let _=b.map(S=>Sm.create({shape:S,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:h,extrusionVersion:d,windingRule:n<=0?ss.NONZERO:ss.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),x=_.length?Mg(_):CK();x.translate(-y,v,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([S,w])=>{this.setAttribute(S,w)}),this.setIndex(x.index),this.adoptNearSide(_,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,u=l._nearSide;if(u===void 0||u.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=u.length,r=Math.max(r,l._effectiveBevel??0),s=l._vScale??s}this._effectiveBevel=r,this._vScale=s;let n=new Uint8Array(i),a=0;for(let o of t){let l=o._nearSide;n.set(l,a),a+=l.length}this._nearSide=n}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length===this.getAttribute("position")?.count&&Y1(this._effectiveBevel,t)&&Y1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position"),r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=$a(new ge,JU.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 Y3t(t){if(!tj)return PK||(PK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});Igt(a),tj=!0}())}var Igt,zG,tj,PK,$5=j(()=>{zG=new Promise(t=>{Igt=t}),tj=!1});function jO(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),r=Object.keys(e.attributes);if(i.length!==r.length)return!1;for(let l of r){let u=t.attributes[l],h=e.attributes[l];if(u===void 0||u.isInterleavedBufferAttribute===!0||h.isInterleavedBufferAttribute===!0||u.itemSize!==h.itemSize||u.normalized!==h.normalized||u.array.constructor!==h.array.constructor||u.array.length!==h.array.length)return!1}let s=t.index,n=e.index;if(s===null!=(n===null))return!1;let a=!1;if(s!==null&&n!==null){if(s.array.length!==n.array.length)return!1;let l=s.array.constructor,u=n.array.constructor;if(l!==u){if(l!==Uint32Array||u!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let u=t.groups[l],h=e.groups[l];if(u.start!==h.start||u.count!==h.count||u.materialIndex!==h.materialIndex)return!1}for(let l of r){let u=t.attributes[l],h=e.attributes[l];u.array.set(h.array),u.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,u=n.array;for(let h=0,d=u.length;h<d;h++){let c=u[h];l[h]=c===65535?4294967295:c}}else s.array.set(n.array);s.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 ej(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,u=Bgt.makeScale(e,i,r).invert().elements;for(let h=0,d=o.length;h<d;h+=3)o[h]*=e,o[h+1]*=i,o[h+2]*=r,s=l[h],n=l[h+1],a=l[h+2],l[h]=u[0]*s+u[4]*n+u[8]*a,l[h+1]=u[1]*s+u[5]*n+u[9]*a,l[h+2]=u[2]*s+u[6]*n+u[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var Bgt,Vgt=j(()=>{dt(),Bgt=new _t});function ij(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function zM(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),r=0;for(let n of i){let a=ij(n);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let s=new Array(r);for(let n=0;n<r;n++){let a=e[n];if(typeof a!="number")return;s[n]=a}return s}(t)}}function GO(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=>ij(l)===-1),r=0;for(let l of e){let u=ij(l);u>=r&&(r=u+1)}let s=t,n=-1,a=-1;for(let l=0;l<r;l++)l in s?typeof s[l]!="number"&&a===-1&&(a=l):n===-1&&(n=l);let o=[`${e.length} keys`,"max index "+(r-1)];return n!==-1&&o.push(`first missing index ${n}`),a!==-1&&o.push(`non-number at ${a} (${typeof s[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function kgt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function LG(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let d=e?e.getX(h):h,c=t.getX(d),p=t.getY(d),m=t.getZ(d),f=Math.round(c*s),g=Math.round(p*s),y=Math.round(m*s),v=n.get(f);v===void 0&&(v=new Map,n.set(f,v));let b=v.get(g);b===void 0&&(b=new Map,v.set(g,b));let _=b.get(y);_===void 0&&(_=r++,b.set(y,_),o.push(c,p,m)),a[h]=_}let l=[],u=[];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]),u.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:u}}var u_,nf,Ie,WO,qO,HO,us,d_,LM,FM,UM,rj,jP,Qv=j(()=>{dt(),$5(),ke(),X5(),Vgt(),OS(),u_=new pr,nf=new P,zG.then(t=>{Ie=t}),WO=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),qO=new Uint32Array([0,1,2,3]),HO=new Uint8Array([4]),us=class extends ge{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),r=dm.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&ej(this.subdividedGeometry.attributes,...r),this.originalGeometry&&ej(this.originalGeometry.attributes,...r),this.data=t;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(nf.fromArray(r));let n=nf.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/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 s=0;try{s=us.allocate(t),i=us.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&us.freeSubdivPointer(s)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Zh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(us.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new ta,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;u_.setFromBufferAttribute(e),u_.getCenter(i),t.boundingSphere.radius=i.distanceTo(u_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),u_.getSize(nf);let r={width:nf.x,height:nf.y,depth:nf.z};return this.userData.parameters=r,r}static build(t,e,i,r){let s,n,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Ie.free_bvh(e),Ie.free_subdivision_surface(e));try{s=us.allocate(t,r)}catch(l){console.error(l,t),s=us.allocate({positionWASM:WO,indexWASM:qO,verticesPerFaceWASM:HO},r)}Ie.set_destination_refinement_level(s,0);let o=us.buildLevel(s,!0,a);return n=t.subdivisions>0?us.buildRefined(s,t.subdivisions,a):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:n}}static buildRefined(t,e,i){try{return Ie.set_destination_refinement_level(t,e),us.buildLevel(t,!1,i)??null}catch{try{return Ie.set_destination_refinement_level(t,e-1),us.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 r,s=t.shape!==void 0||t.path!==void 0?e.geometry:sm(t,i,!1,e);r=Aft(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=LG(s.getAttribute("position"),r);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let c=t.radialSegments*t.heightSegments*3*2;n=[c,c+3*t.radialSegments]}let{indices:u,verticesPerFace:h,uvs:d}=function(c,p,m,f,g){let y=[],v=[],b=g?m.getAttribute("uv"):void 0,_=b&&b.itemSize===2?[]:void 0,x=T=>{if(_){let C=g[T];_.push(b.getX(C),b.getY(C))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),C=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&C<=24&&C%4==0&&m.userData.parameters.angle>=360){let R=T.length/2/C;T=T.filter((O,N)=>Math.floor(N/2)%R===0)}let M=0;for(let R=0;R<T.length;R+=2)M+=(T[R]-T[(R===0?T.length:R)-2])*(T[R+1]+T[(R===0?T.length:R)-1]);c.length=0;let A=0;if(M<0)for(let R=0;R<T.length;R+=2)c.push(T[R],T[R+1],0),y.push(A++);else for(let R=T.length-2;R>=0;R-=2)c.push(T[R],T[R+1],0),y.push(A++);return v.push(A),{indices:y,verticesPerFace:v}}let S=new Float32Array([m.userData.parameters.depth])[0],w=0;for(;w<p.length;){if(m.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[w]+2]===S||c[3*p[w]+2]===0)&&T++,(c[3*p[w+1]+2]===S||c[3*p[w+1]+2]===0)&&T++,(c[3*p[w+2]+2]===S||c[3*p[w+2]+2]===0)&&T++,T===3)break}if(p[w+1]===p[w+3]&&p[w+2]===p[w+5]||p[w+0]===p[w+3]&&p[w+2]===p[w+4]){d_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),LM.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),FM.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),UM.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),LM.sub(d_).normalize(),FM.sub(d_).normalize(),UM.sub(d_).normalize();let T=LM.cross(FM).dot(UM),C=w;Math.abs(T)>.005||f&&f.some((M,A)=>A%2!=1&&C>=f[A]&&C<f[A+1])?(y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3):(y.push(p[w],p[w+1],p[w+4],p[w+5]),x(w),x(w+1),x(w+4),x(w+5),v.push(4),w+=6)}else y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3}if(m.useNgonForTopBottomFaceDuringBake){let T=[],C=[],M=0;for(let A=0,R=0;A<c.length;A+=3,R++)c[A+2]===0&&(T.push(R),M++),c[A+2]===S&&C.push(R);if(m.userData.parameters.extrudeBevelSize===0){let A=C[0];C[0]=C[1],C[1]=A}T.reverse(),y.push(...T,...C),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:u,verticesPerFace:h,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=zM(t.positionWASM),l=zM(t.indexWASM),u=zM(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${GO(t.positionWASM)}, indexWASM ${GO(t.indexWASM)}, verticesPerFaceWASM ${GO(t.verticesPerFaceWASM)}`);i=o,r=l,s=u;let w=zM(t.uvWASM);Ie.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=WO,r=qO,s=HO;let h=i.length,d=r.length,c=s.length,p=i.length+n.length+a.length,m=r.length+s.length,f=p*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,y=Ie._malloc(f);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${f}) failed`);let v,b=new Float32Array(Ie.HEAPF32.buffer,y,p),_=new Uint32Array(Ie.HEAPU32.buffer,y+g,m);b.set(i,0),b.set(n,i.length),b.set(a,i.length+n.length),_.set(r,0),_.set(s,r.length),t?.scaleBaked?.some(w=>w!==1)&&(v=new _t().makeScale(...t.scaleBaked.map(w=>typeof w=="number"?w:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+n.length)*Float32Array.BYTES_PER_ELEMENT,S=a.length?v?Ie.alloc_subdivision_surface_uvs2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ie.alloc_subdivision_surface_uvs(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ie.alloc_subdivision_surface2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ie.alloc_subdivision_surface(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return Ie._free(y),S}static buildLevel(t,e,i,r,s,n=!1){let a=s?Ie.get_mesh_data2(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i,s.elements):Ie.get_mesh_data(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i),o=Ie.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),u=0,h=Ie.HEAPU32[o[u]>>2],d=Ie.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let c=Ie.HEAPU32[o[u]>>2],p=Ie.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let m=Ie.HEAPU32[o[u]>>2],f=Ie.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g,y=Ie.HEAPU32[o[u]>>2],v=Ie.HEAPU32.subarray(y>>2,(y>>2)+l[u]);if(u++,Ie.alloc_subdivision_surface_uvs){let _=o[9];if(_>0){let x=Ie.HEAPU32[o[8]>>2];g=Ie.HEAPF32.subarray(x>>2,(x>>2)+_)}}if(r===void 0){let _=new ge;if(_.setIndex(new hm(v,1)),_.setAttribute("position",new fe(d,3)),_.setAttribute("normal",new fe(p,3)),g&&_.setAttribute("uv",new fe(g,2)),e){_.setAttribute("faceMap",new hm(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new _e(x,4))}return Ie.free_mesh_data(a),_.userData.type="SubdivGeometry",_}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,n){let _=r.getIndex();_!==null&&_.array.length===v.length&&(_.copyArray(v),_.needsUpdate=!0)}let b=r.getAttribute("uv");g&&b&&b.array.length===g.length&&(b.copyArray(g),b.needsUpdate=!0),Ie.free_mesh_data(a)}static freeSubdivPointer(t){Ie.free_bvh(t),Ie.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let r=Ie.get_wireframe_data_for_base_level(t),s=Ie.HEAPU32.subarray(r>>2,4+(r>>2)),n=s.subarray(2,4),a=0,o=Ie.HEAPU32[s[a]>>2],l=Ie.HEAPF32.subarray(o>>2,(o>>2)+n[a]);a++;let u=Ie.HEAPU32[s[a]>>2],h=Ie.HEAPU32.subarray(u>>2,(u>>2)+n[a]);if(e===void 0){let d=new ge;d.setAttribute("position",new fe(l,3));let c=new Float32Array(l.length);for(let p=0,m=l.length;p<m;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new _e(c,3)),d.setIndex(new hm(h,1)),Ie.free_wireframe_data_for_base_level(r),d}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Ie.free_wireframe_data_for_base_level(r)}static updateCollabMesh(t,e,i){let r=e===0;r||Ie.set_destination_refinement_level(t,e);let s=i?Ie.get_topological_data2(t,r?Ie.Level.CONTROL:Ie.Level.REFINED,i.elements):Ie.get_topological_data(t,r?Ie.Level.CONTROL:Ie.Level.REFINED),n=Ie.HEAPU32.subarray(s>>2,8+(s>>2)),a=n.subarray(3,6),o=0,l=Ie.HEAPU32[n[o]>>2],u=new Float32Array(Ie.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=Ie.HEAPU32[n[o]>>2],d=new Uint32Array(Ie.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let c,p=Ie.HEAPU32[n[o]>>2],m=new Uint8Array(Ie.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Ie.alloc_subdivision_surface_uvs){let f=n[7];if(f>0){let g=Ie.HEAPU32[n[6]>>2];c=new Float32Array(Ie.HEAPF32.subarray(g>>2,(g>>2)+f))}}return Ie.free_topological_data(s),{positions:u,indices:d,verticesPerFace:m,uvs:c}}},d_=new P,LM=new P,FM=new P,UM=new P}),zgt=j(()=>{$Y(),XY(),R4(),YY(),I4(),OS(),mK(),fK(),gK(),ZU(),bK(),B4(),_K(),xK(),wK(),QU(),SK(),TK(),MK(),AK(),ym(),Ii(),$Y(),XY(),R4(),YY(),I4(),$3t(),OS(),mK(),fK(),gK(),ZU(),bK(),B4(),_K(),xK(),wK(),QU(),SK(),TK(),MK(),AK(),ym(),X3t(),ugt(),Ogt(),Qv(),$5(),W5(),Zv(),rj={ConeGeometry:qft,CubeGeometry:Hft,CylinderGeometry:RG,DodecahedronGeometry:$ft,EllipseGeometry:q5,HelixGeometry:Cft,IcosahedronGeometry:bgt,LatheGeometry:_gt,NonParametricGeometry:wgt,PolygonGeometry:VG,PyramidGeometry:Sgt,RectangleGeometry:H5,SphereGeometry:Agt,PlaneGeometry:Cgt,BackdropGeometry:Egt,StarGeometry:kG,TextFrameGeometry:Pgt,TorusGeometry:Rgt,TorusKnotGeometry:Dgt,TriangleGeometry:Ngt,VectorGeometry:Sm},jP=t=>{let e=rj[t.type]??mft(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 sm(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let u of a){let h=n;for(let d of u)h=h[d];for(s in h){let d=h[s];pX(d)&&!Lgt.includes(s)&&(h[s]=e.getVariable(d,[r.uuid,"geometry",...u,s]),pX(h[s])&&(h[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let u=r.profileShape;u!==void 0&&(l.shapeData=u),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let u=ds.createFromState(n.shape,n.width,n.height);l.shape=u,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),l.geometry=new $7().parse(n),l.geometry.groups.length===0){let u=l.geometry;u.addGroup(0,Math.max(u.getIndex()?.count??0,u.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let u=new us(n,i);return u.data=t,u}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let u=mft(n.type);if(u)return u.create(n,e);Nn("text",`a ${n.type}`);let h=ds.createFromState(RS.defaultData(),100,100);return jP({...n,shape:h,type:"VectorGeometry"})}if(n.type==="UIGeometry")return H5.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=jP(l)}catch(u){console.error(u),console.error(`Error generating geometry with inputs: ${l}`);let h=ds.createFromState(RS.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=jP(l)}return o}var Lgt,RK,sj,X5=j(()=>{ke(),dt(),zgt(),Ii(),B4(),wm(),Qv(),Lgt=["font"]}),K3t=j(()=>{X5(),RK=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 r=this.objects.get(t);return r===void 0?(r=this.createObject(t,e,i),this.objects.set(t,r)):r.isShared=!0,r}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()}},sj=class extends RK{constructor(t){super(),this.flatShading=t}disposeObject(t){t.dispose()}createObject(t,e,i){let r=sm(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}}});function V4(){return rT}function Fgt(){if(rT==="webgpu"){if(aj!==void 0)return aj;oj||(oj=!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(OK===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 OK}function Ugt(t,e){return Fgt().createRootMaterial(t,e)}function DK(t,e,i){return Fgt().createSharedMaterial(t,e,i)}function NK(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function nj(){return jgt}var rT,aj,OK,oj,lj,jgt,Ggt,Tm=j(()=>{rT="webgl",oj=!1}),Z3t=j(()=>{Ggt={markNeedsUpdateRendererDirty:()=>{}}});function Dg(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(s=>s.data.type==="light");if(r){let s=r.data,n=Number(e.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?n/100:s.alphaOverride)<1)return!0}for(let s of t.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="cavity"&&s.data.type!=="dust"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let n=s.data.visible?s.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(e.getVariable(n)??100)/100))),n===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let a of s.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&s.data.type==="noise"){let a=e.color(s.data.colorA).a,o=e.color(s.data.colorB).a,l=e.color(s.data.colorC).a,u=e.color(s.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,u)));h<1&&(n=h)}i+=(1-i)*n}}return i<1}var FG=j(()=>{});function fv(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Bv,Mn,sT,Wgt,IK,BK,_l,Jv=j(()=>{Bv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,Mn=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),sT={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"]},Wgt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),tb=j(()=>{dt(),tT(),IK=class extends U5(dr){},BK=t=>t.type==="Mesh",_l=class extends IK{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 _l(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 BK(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 VK(){return UG}var UG,jG,GG=j(()=>{UG=null,jG=null});function hj(t){return"variable_"+t}var $O,XO,YO,kK,KO,zK,ZO,LK,k4,WG=j(()=>{ke(),T3t(),Fft(),Uft(),Dc(),CG(),PG(),K3t(),Tm(),kft(),Z3t(),FG(),Jv(),vo(),tb(),Fi(),dt(),GG(),Ii(),$O=new _t,XO=new P,YO=new Se,kK=new P,KO=new Qi,zK=class extends Ift{constructor(t){super(),this.shared=t}create(t){return new AG(t,this.shared)}},ZO=new Set,(k4=LK=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new sj(!0),this.geometryCache2=new sj(!1),this.imageHolderCache=new zK(this),this.thisContext={scene:Ggt,shared:this},this.deletedImage=new gg(wU.emptyImage,this),this.deletedVideo=new gg(c4.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[s,n]of Object.entries(e.images))this.addImage(s,n);if(e.videos)for(let[s,n]of Object.entries(e.videos))this.addVideo(s,n);if(e.audios)for(let[s,n]of Object.entries(e.audios))this.addAudio(s,n);if(e.particles)for(let[s,n]of Object.entries(e.particles))this.addParticle(s,n);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=DK(cs.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:r,data:s}of t.variables)this.addVariableHolder(r,s),e&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(t.userAPIs??{}))this.addUserAPI(r,s);for(let[r,s]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(t.images))this.addImage(r,s);for(let[r,s]of Object.entries(t.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(t.colors))this.addColor(r,s);for(let[r,s]of Object.entries(t.lib.materials))this.addMaterial(r,s.asset);for(let[r,s]of Object.entries(t.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(t.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(t.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(t.fonts))this.addFont(r,s)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:cs.defaultTwoLayerData("phong").layers}),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=DK(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:cs.defaultTwoLayerData("phong").layers}),Ugt(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 gg(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 gg(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let i=t.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let s=r.root??r;for(let n of s?.data?.layers??[]){let a=n?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||e.layer!==void 0&&n.id!==e.layer&&a.type!==e.layer)continue;let o=a.texture?.image;if(o==null)continue;let l=(typeof o=="string"?this.uiBuffer(o):void 0)??this.image(o);if(!l)continue;let u=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),h=l.img;return{texture:u,width:h?.width??0,height:h?.height??0,layerId:n.id,layerType:a.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new gg(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 FU(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 Dr(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 Dr(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof X1)return e;{let i=new X1({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 X1&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=EG;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):Nn("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 X1&&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 r=localStorage.getItem(hj(t));i=r!==null?JSON.parse(r):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(hj(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let o=a[1],l=i,u={scene:r,shared:this},h=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(h,l,u)});let d=this.materials[o];d&&d.onVariableUpdate(h,l,u)}else{let o=r.find(a[0]);if(o===void 0){this.variables[t].locations.splice(n,1);continue}if(s=!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*qt.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),Mi.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 u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(h=>{let d=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(d.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||typeof s.type!="string"||s.type==="VectorGeometry"||s.type==="PathGeometry")return!1;let n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let u of Object.keys(s))a.set(n(u),u);let o={};for(let[u,h]of Object.entries(e??{})){let d=a.get(n(u));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof h=="string"||typeof h=="number")&&(o[d]={textValue:String(h)});continue}let c=s[d];typeof h=="number"&&isFinite(h)&&(typeof c=="number"||typeof c=="string")&&(o[d]=h)}if(Object.keys(o).length===0)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.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 r=i.dataPatched,s=r?.geometry;if(!s||s.type!=="NonParametricGeometry")return!1;let n=e?.vertices;if(n===void 0||typeof n.length!="number"||n.length<9||n.length%3!=0||n.length/3>LK.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,u=n instanceof Float32Array?n:Float32Array.from(n),h=u.length/3;if(e.normals!==void 0){if(e.normals.length!==u.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 S=0;S<x.length;S++)if(x[S]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=s.data,S=x?.index;if(S?.array?.length){let w=(x?.attributes?.position?.array?.length??0)/3;if(h!==w)return function(T,C){let M=`${T}/${C}`;ZO.has(M)||(ZO.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${C}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}(h,w),!1;l=S}}let d=1/0,c=1/0,p=1/0,m=-1/0,f=-1/0,g=-1/0;for(let x=0;x<u.length;x+=3){let S=u[x],w=u[x+1],T=u[x+2];S<d&&(d=S),S>m&&(m=S),w<c&&(c=w),w>f&&(f=w),T<p&&(p=T),T>g&&(g=T)}let y=(x,S)=>({array:x,itemSize:S,type:"Float32Array",normalized:!1}),v={position:y(u,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:f-c,depth:g-p,data:{attributes:v,...l?{index:l}:{}}},_=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,_),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let s=r.children,n=Math.PI/180,a=!1;if(e===null)for(let o of s)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return s.length;{let o=Math.min(e.length,s.length);for(let l=0;l<o;l++){let u=e[l],h=s[l];if(u==null){h.transformOverride!==void 0&&(h.transformOverride=void 0,a=!0);continue}let d=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]};u.position&&(typeof u.position.x=="number"&&(d.position[0]=u.position.x),typeof u.position.y=="number"&&(d.position[1]=u.position.y),typeof u.position.z=="number"&&(d.position[2]=u.position.z)),u.rotation&&(typeof u.rotation.x=="number"&&(d.rotation[0]=u.rotation.x*n),typeof u.rotation.y=="number"&&(d.rotation[1]=u.rotation.y*n),typeof u.rotation.z=="number"&&(d.rotation[2]=u.rotation.z*n)),u.scale&&(typeof u.scale.x=="number"&&(d.scale[0]=u.scale.x),typeof u.scale.y=="number"&&(d.scale[1]=u.scale.y),typeof u.scale.z=="number"&&(d.scale[2]=u.scale.z)),h.transformOverride=d,h.position.fromArray(d.position),h.rotation.fromArray(d.rotation),h.scale.fromArray(d.scale),h.updateMatrix(),h.hasNonUniformScale&&(h.updateMatrixWorld(),h.updateMatrixWorldRigid())}}}return a?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let r=new _l(t);r.playModeVisible=e.visible!==!1,r.expand(),typeof e.name=="string"&&(r.name=e.name);let s=Math.PI/180;return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(r.position.x=e.position.x),typeof e.position.y=="number"&&(r.position.y=e.position.y),typeof e.position.z=="number"&&(r.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(r.rotation.x=e.rotation.x*s),typeof e.rotation.y=="number"&&(r.rotation.y=e.rotation.y*s),typeof e.rotation.z=="number"&&(r.rotation.z=e.rotation.z*s)),e.scale&&(typeof e.scale.x=="number"&&(r.scale.x=e.scale.x),typeof e.scale.y=="number"&&(r.scale.y=e.scale.y),typeof e.scale.z=="number"&&(r.scale.z=e.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let r=[];for(let u of Array.isArray(i)?i:[i]){let h=u.root??u;h&&Array.isArray(h.layers)&&h.data&&!r.includes(h)&&r.push(h)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=u=>{if(typeof u=="string"){let h=new Dr(1,1,1,1);try{h.set(u)}catch{return null}return{r:h.r,g:h.g,b:h.b,a:void 0}}if(u&&typeof u=="object"&&"r"in u){let h=u;if([h.r,h.g,h.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(h.r,h.g,h.b)>1?1/255:1;return{r:h.r*d,g:h.g*d,b:h.b*d,a:typeof h.a=="number"?Math.max(0,Math.min(h.a,1)):void 0}}return null},o=(u,h,d)=>{if(!u.hasValue(h))return!1;let c=u.getValue(h);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof FU?u.setValue(h,new Dr(d.r,d.g,d.b,p)):typeof c.setRGBA=="function"?c.setRGBA(d.r,d.g,d.b,p):c.setRGB(d.r,d.g,d.b),!0},l=!1;for(let u of r){let h=u.data.layers??[],d=c=>u.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=h.find(f=>f.data.type==="color"),m=p&&d(p.id);if(c&&m&&o(m,"color",c)&&(l=!0,c.a!==void 0)){let f=c.a<1||Dg(u.data,this);u.setTransparent?u.setTransparent(f,s.scene):u.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(u.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),s),l=!0);for(let c of e.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?h.find(y=>y.id===c.id):typeof c.index=="number"?h[c.index]:typeof c.type=="string"?h.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=sT[p.data.type]??[],g=Object.keys(p.data);for(let[y,v]of Object.entries(c)){if(y==="id"||y==="index"||y==="type")continue;let b=g.find(x=>x===y)??g.find(x=>n(x)===n(y))??y;if(f.includes(b))continue;let _=a(v);if(_&&o(m,b,_))l=!0;else if(typeof v=="number"&&isFinite(v))u.onVariableUpdate?.(["layer",p.id,b],v,s),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((S,w)=>{u.onVariableUpdate?.(["layer",p.id,b,x[w]],S,s)}),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?.($O))return $O.decompose(XO,YO,kK),t[1]==="position"?XO[t[2]]:(KO.setFromQuaternion(YO,i.rotation.order),KO[t[2]]*qt.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=qt.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let r=this.variables[i],s=r.locations?.findIndex(n=>Dn.equal(n,e));s!==void 0&&s!==-1&&r.locations.splice(s,1)}if(typeof t=="string"){let i=t,r=t;do{if(r=i,this.variables[i]===void 0)break;let s=this.variables[i].value;e&&this.variables[r]!==void 0&&this.variables[r].locations.push(e),i=s}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(ea.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 r=e.userAPIs[t.path[1]];if(r){let s=t.type===0&&t.props.debounce===void 0,n=this.getUserAPI(t.path[1]);n!==void 0&&n===this.openAIRealtime?n.update(r):n?.update(r,this,s)}}}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 r=e.userWebhooks[t.path[1]];r&&this.getUserWebhook(t.path[1])?.update(r)}}else t.path[0]==="lib"&&this.updateLibByOp(ea.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let r=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};r.update(s),r.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=jG;return i===null?(Nn("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=VK();return i===null?(Nn("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=VK();return i===null?(Nn("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 k4(Zl.emptyData())});function qgt(t){return E4(t)||t?.isTSLNodeMaterial===!0}var yo,QO,JO,tI,FK,eI,cd,UK,jK,c_,Fr,Hgt=j(()=>{MG()}),l0=j(()=>{ke(),la(),Tm(),Hgt(),Fi(),hn(),yo=class extends Vs{setMaterialOverride(t,e){this.materialOverride=NK(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),er(t.path,["geometry"])&&this.syncShadowCatcher(i),function(r,s){let n=[];if(s.length!==r.length)return null;{let a=0;for(;a<r.length;){if(s[a]==="*")n.push(r[a]);else if(r[a]!==s[a])return null;a+=1}}return n}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(t.props)){let n=this.material[Number(r)],a=i.shared.material(s);a!==n&&yo.disposeOneMaterial(n),this.material[Number(r)]=a}else if(er(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(ea.drop(t,1),e.material,i)}else if(er(t.path,["materials","*"])&&Array.isArray(this.material)){let r=t.path[1];if("materials"in e&&r<this.material.length){let s=e.materials[r];typeof s!="string"&&this.material[r].updateByOp(ea.drop(t,2),s,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,r=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 s=this.materialOverride!==void 0;!s&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!s&&(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(r.flatShading,r.side,r.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let n=this.data;if(!s&&n.geometry?.type!=="NonParametricGeometry"&&"materials"in n&&n.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(n.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(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(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.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=function(){let r=rT==="webgpu"&&lj!==void 0?lj:void 0;return r===void 0?null:NK(r())}();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;qgt(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&cmt(this.material).forEach(t=>{yo.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),bo=j(()=>{ke(),Fi(),WG(),l0(),dt(),X5(),Zv(),Qv(),Vgt(),QO=new P,JO=new Me,tI=new Me,FK=new P,eI=new _t,cd=new vr,UK=cd.geometry,jK=cd.material,c_=new P,Fr=class extends yo{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 _t().fromArray(e.bindMatrix),this.bindMatrixInverse=new _t)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof ge&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof ge?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof k4){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 f4.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return f4.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.updateByPatchedOpGeometry(ea.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,O4.delete(t),this._posed=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 r,s,n,a=t;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=sm(d,e,this.data.flatShading,this)}a.scaleBaked?[r,s,n]=a.scaleBaked:{width:r,height:s,depth:n}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,u=typeof s=="number"?s:1,h=typeof n=="number"?n:1;o.sxPrev!==void 0&&ej(this.localGeometry.attributes,l/o.sxPrev,u/o.syPrev,h/o.szPrev),o.sxPrev=l,o.syPrev=u,o.szPrev=h}else if(!this.absorbDepthInteraction(t)){let r=sm({...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&jO(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(t){let e=this.localGeometry;if(e?.shiftDepthTo===void 0)return!1;let i=t;if(typeof i.depth!="number")return!1;let r=e.userData?.parameters;if(r===void 0)return!1;for(let s of Object.keys(i))if(s!=="depth"&&i[s]!==r[s])return!1;return!!e.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}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 r=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&kgt(t.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof ge&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=i.shared,n=this.chooseGeoemtryCache(s),a=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=sm(o,s,this.data.flatShading,this);jO(a,l)?(l.dispose(),a.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(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,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof ge&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=this.chooseGeoemtryCache(i),n=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===n&&n.isShared!==!0){let a=sm(r,i,this.data.flatShading,this);return jO(n,a)?(a.dispose(),n.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,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:r,value:s}}of i)this.updateMorphInfluences(r,e.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}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.posedGeometry()?.boundingBox;if(i)return i.getCenter(t),void i.getSize(e).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*r.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?t.fromArray(r.centerOffset):t.setScalar(0),e.set(r.width,r.height,r.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 Me,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){e.fromBufferAttribute(i,r);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),i.setXYZW(r,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;JO.fromBufferAttribute(r.attributes.skinIndex,t),tI.fromBufferAttribute(r.attributes.skinWeight,t),QO.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=tI.getComponent(s);if(n!==0){let a=JO.getComponent(s);eI.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(FK.copy(QO).applyMatrix4(eI),n)}}return e.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(t,e){let i=this.posedGeometry();if(i===void 0)return!1;cd.geometry=i,cd.material=this.material,cd.matrixWorld.copy(this.matrixWorld);let r=e.length;cd.raycast(t,e);for(let s=r;s<e.length;s++)e[s].object=this;return cd.geometry=UK,cd.material=jK,!0}posedGeometry(){let t=this.skeleton;if(!this.isSkinnedMesh||t===void 0)return;let e=this.geometry,{position:i,skinIndex:r,skinWeight:s}=e.attributes;if(!i||!r||!s)return;let n=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<t.bones.length;d++){let c=t.bones[d];if(!c||!t.boneInverses[d])return;n.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===e&&a.version===i.version&&a.pose.length===n.length&&a.pose.every((d,c)=>d===n[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,u=l?.count===o?l:new _e(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,c_)),u.setXYZ(d,c_.x,c_.y,c_.z);let h=new ge;h.setAttribute("position",u);for(let d of["normal","uv","uv1"]){let c=e.attributes[d];c&&h.setAttribute(d,c)}return h.setIndex(e.index),h.groups=e.groups,h.drawRange=e.drawRange,h.computeBoundingSphere(),h.computeBoundingBox(),this._posed={source:e,version:i.version,pose:n,geometry:h},h}}});function gv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!E4(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Fr&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,r=new Float32Array(i.length),s=new P;for(let n=0;n<i.length;n+=3)s.set(i[n],i[n+1],i[n+2]).normalize(),r[n]=s.x,r[n+1]=s.y,r[n+2]=s.z;e.geometry.setAttribute("extrudeNormal",new fe(r,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,r=e.geometry.attributes,s=r.position.array,n=r.normal.array,a=new Float32Array(s.length);for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=new P(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(u):i.set(l,{normals:[u],result:new P})}i.forEach((o,l)=>{for(let u of o.normals)o.result.add(u);o.result.divideScalar(o.normals.length)});for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=i.get(l)?.result;u&&(a[o]=u.x,a[o+1]=u.y,a[o+2]=u.z)}e.geometry.setAttribute("extrudeNormal",new fe(a,3))}(t)}function iI(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function yv(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,r=e.randomColor;if(r!==void 0&&3*r.count===i.length)return;let s=new Float32Array(i.length),n=parseInt(t.uuid.replace(/\D/g,"")),a=[iI(qt.seededRandom(n)),iI(qt.seededRandom(n+1e4)),iI(qt.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new _e(s,3))}var Y5=j(()=>{dt(),MG(),bo()});function GK(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function Q3t(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function WK(t,e,i,r){let s=16*(e.children.length+1);Jw.length<s&&(Jw=new Float32Array(s));let n=0,a=l=>{l.toArray(Jw,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),uj.multiplyMatrices(t.hiddenMatrix,t.matrix);for(let l of e.children)!Ag(l)||l.playModeVisible===!1||(dj.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),GP.multiplyMatrices(uj,dj),(!o||!GP.equals(r))&&a(GP));try{return n===0?0:function(l,u){return SG(C4().instanced_union(wG(l),u))}(i,Jw.subarray(0,16*n))}finally{Eft(i)}}var pd,qK,uj,dj,GP,Jw,cm,z4,K5,Hh,Hu,L4,nT=j(()=>{la(),dt(),W5(),Y5(),l0(),ns(),pd=new _t,qK=new _t,uj=new _t,dj=new _t,GP=new _t,Jw=new Float32Array(0),cm=class extends yo{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new ge,this.onAfterRender=(r,s,n,a,o,l)=>{super.onAfterRender(r,s,n,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 r=0;r<this.children.length;r++){let s=this.children[r];s instanceof cm&&s.dataPatched.visible===!0&&s.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let s=this.children[r];if(s instanceof Vs&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){pd.multiplyMatrices(s.hiddenMatrix,s.matrix).multiply(s.pivotMatrix);try{let n=Q3t(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=x3t(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:WK(s,n,a,pd)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&NO(s.booleanMeshSetAddress,pd),s.booleanMatrixInvOld.copy(pd).invert(),s.booleanWasTransformed=!1}else s instanceof cm&&s.needsTransformForDownstream===!0?(n===void 0?NO(s.booleanMeshSetAddress,pd):s.booleanMeshSetAddress=WK(s,n,s.booleanMeshSetAddress,pd),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(NO(s.booleanMeshSetAddress,qK.multiplyMatrices(pd,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(pd).invert(),s.booleanWasTransformed=!1)}catch(n){console.error(n),s.booleanMeshSetAddress=0,s.geometry.userData.booleanOperationDidFail=!0;continue}if(s.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let r=this.geometry;r.dispose(),this.geometry=new ge,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new fe([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=C4(),a=BY(r,s),o=n.mesh_topological_data(a),l=o.positions(),u=o.indices();return o.free(),a.free(),{positions:l,indices:u,verticesPerFace:new Uint8Array(u.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new ge,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=C4(),l=BY(r,s),u=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new fe(u.positions(),3)),n.setAttribute("normal",new fe(u.normals(),3)),u.free(),n.boundingSphere===null&&(n.boundingSphere=new ta),l.tri_count()===0)n.boundingSphere.center.set(0,0,0),n.boundingSphere.radius=0,n.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();n.boundingSphere.center.set(h[0],h[1],h[2]),n.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,n.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return SG(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(r){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(r)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,gv(this),yv(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),aT=j(()=>{dt(),vo(),o0(),(z4||(z4={})).is=function(t){return Mi.is(t)&&t instanceof Hd},K5=(t,e)=>class extends a0(t,e){updateState_Light(i,r){if(this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let s=this.shadow;s.camera.far=i.depth,s.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),Mm=j(()=>{dt(),nT(),la(),o0(),Hh=t=>t instanceof Vs,Hu=t=>t!==null&&t instanceof cm,L4=t=>VU.is(t)});function Sa(t,e){return e.color(t)}function HK(t=new Date,e){let i=e.format,r=t.getSeconds(),s=t;e&&e.timeZone!==null&&(s=function(d,c){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(d),m=f=>Number(p.find(g=>g.type===f)?.value);return new Date(m("year"),m("month")-1,m("day"),m("hour"),m("minute"),m("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let n,a=s.getHours(),o=s.getMinutes();e.format12h24h==="12ampm"&&(n=a>=12?"PM":"AM");let l,u,h=a;switch(e.format12h24h!=="24"&&(h=a%12,h===0&&(h=12)),i){case"HH:mm:ss":l=[h,o,r];break;case"HH:mm":l=[h,o];break;case"HH":l=[h],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":u=s.getFullYear();break;case"month":u=s.getMonth()+1;break;case"dayOfYear":u=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=s.getDate();break;case"secondOfDay":u=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),u=0}return l!==void 0?{textValue:l,suffix:n}:u}var cj,eb,qG=j(()=>{}),J3t=j(()=>{dt(),QS(),JS(),cj=class extends Xv(smt){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){Yv(this.object,cj.geometryHelper,t,e)}}}),Z5=j(()=>{dt(),J3t(),aT(),eb=class extends K5(wS,cj){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 r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new SS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof SS&&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(r,s){r.shadow.camera.right=s/2,r.shadow.camera.left=-s/2,r.shadow.camera.top=s/2,r.shadow.camera.bottom=-s/2,r.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 HG(t){return t instanceof yo&&t.needsAO&&!Ec(t)&&t.isDecalObject!==!0}function $G(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 XG(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function tAt(t){let e=1/0,i=-1/0;for(let r of t.getLayersOfType("reflection")){let s=r.data;if(!s.visible||s.mirror===1)continue;let n=typeof s.blur=="number"?s.blur:null;e=Math.min(e,n??0),i=Math.max(i,n??10)}return e===1/0?null:{min:e,max:i}}function eAt(t){for(let e of t.getLayersOfType("reflection")){let i=e.data;if(!i.visible)continue;let{blur:r,thickness:s,steps:n,stepSize:a}=i;return typeof r!="number"||typeof s!="number"||typeof n!="number"||typeof a!="number"?"variable":{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function $K(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&Q5,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=XG(e),o=e.getLayersOfType("cavity");return(n.length>0||o.length>0)&&(t.layers.set(8),s.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=n.length>0,i.cavity=o.length>0,yv(t),gv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&HG(t)&&t.layers.enable(5),$G(t),i}function XK(t,e){if(!e.layers)return!1;let i=t.layers.mask&Q5,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=XG(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return s.length>0&&(t.layers.set(3),(n.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),r=!0),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&HG(t)&&t.layers.enable(5),$G(t),r}function YK(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&Q5,s=!1,n=XG(e),a=e.getLayersOfType("transmission").filter(u=>u.data.visible),o=e.getLayersOfType("outline").filter(u=>u.data.visible),l=e.getLayersOfType("cavity").filter(u=>u.data.visible);return n>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),s=!0),n===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),r&&t.layers.set(9),!r&&HG(t)&&t.layers.enable(5),$G(t),s}function pj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if((t.raycast===vr.prototype.raycast||t.raycast===Vs.prototype.raycast)&&t.isSkinnedMesh!==!0){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&(mj.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(mj)))continue;let o=Xgt.copy(a.matrixWorld).invert(),l=Ygt.copy(e.ray).applyMatrix4(o),u=t.matrixWorld;l.applyMatrix4(u);let h=$gt;h.set(l.origin,l.direction),h.near=e.near,h.far=e.far,h.layers.mask=e.layers.mask;let d=h.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var Q5,$gt,Xgt,Ygt,mj,jM,Kgt,rI,sI,nI,ib,Xs,YG=j(()=>{ns(),Y5(),la(),l0(),dt(),Q5=512,$gt=new A5,Xgt=new _t,Ygt=new mc,mj=new ta}),iAt=j(()=>{dt(),QS(),JS(),jM=class extends Xv(imt){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){Yv(this.object,jM.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=jM._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 r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},(Kgt=jM)._vector=new P}),J5=j(()=>{dt(),iAt(),aT(),rI=new P,sI=new P,nI=new Se,ib=class extends K5(Lg,Kgt){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 r=this.shadow.camera;r.fov=2*qt.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new SS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof SS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),sI.setFromMatrixPosition(this.matrixWorld),nI.setFromRotationMatrix(this.matrixWorld),rI.copy(this.up).applyQuaternion(nI).negate().multiplyScalar(this.distance),this.target.position.copy(sI).add(rI),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))}}}),Nc=j(()=>{ke(),Qh(),dt(),vo(),Dc(),qG(),k5(),Z5(),Fi(),Tm(),dt(),l0(),Mm(),YG(),J5(),Ii(),nT(),Xs=class extends j5(Yu){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new g8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ia.getDensity({}),this.fogHeightFalloff=ia.getHeightFalloff({}),this.fogHeightBase=ia.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ae,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new ks(n0,{...W2.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new M5(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 r=RU();r===null?Nn("ui-2d","a page's 2D scene"):this.uiScene=new r.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=RU();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()})):Nn("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=Sa(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 cm&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof yo)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;dv.isSoft(e)}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=Sa(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ia.getMode(t),this.fogDensity=ia.getDensity(t),this.fogHeightFalloff=ia.getHeightFalloff(t),this.fogHeightBase=ia.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=Sa(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;er(t.path,["fog"])?this.updateFog(n.fog,i.shared):er(t.path,["sky"])?this.updateSky(n.sky,i.shared):er(t.path,["grading"])?this.gradingState=n.grading??null:er(t.path,["ao"])?this.updateAo(n.ao,i.shared):er(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):er(t.path,["shadow"])?this.updateShadow(n.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||s!==n.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(Sa(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 instanceof ks&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){let t=this.scene?.find(this.data.publish.playCamera);return t instanceof ks?t:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(CU).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof eb&&i.visible&&t<VP&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof ib&&i.visible&&t<CU-VP&&(this.penumbraSizeArrayCache[VP+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;Mi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||L4(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),pj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function KK(){return KG}function aI(){if(fj===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 fj}function oI(t){return t?.isWebGPUSplineRenderer===!0}var KG,fj,Zgt=j(()=>{KG=null,fj=null});function gj(){return QG}var ZG,QG,JG=j(()=>{ZG=null,QG=null});function ZK(t,e,i){return t2.setRGB(t,e,i,Ns),{r:t2.r,g:t2.g,b:t2.b}}function rAt(t,e,i){let r,s=kS(t.angle,0),[n,a]=yj(t.offset),[o,l]=yj(t.morph),u=t.colors??[],h=t.steps??[],d=Math.min(10,u.length,h.length);if(d===0)return[1,1,1,1];if(t.gradientType===1){let g=3*(e+o)-(e+n)-1,y=3*(i+l)-(i+a)-1;r=Math.hypot(g,y)+s}else if(t.gradientType===2){let g=-1*Math.atan2(e+o-.5+n,i+l-.5+a),y=s/Math.PI/-2+.5*g/Math.PI;r=y-Math.floor(y)}else{let g=.5+o/(e!==0?e:1e-6),y=l/(i!==0?i:1e-6),v=Math.cos(s)*g-Math.sin(s)*y,b=Math.sin(s)*g+Math.cos(s)*y,_=v*v+b*b;r=_>1e-12?(((e-.5+n)/2+v/2)*v+((i-.5+a)/2+b/2)*b)/_:0}let c=u[0][0],p=u[0][1],m=u[0][2],f=u[0][3];for(let g=1;g<d;g++){let y=h[g-1],v=h[g]-y,b=v!==0?Math.min(1,Math.max(0,(r-y)/v)):r>=y?1:0;t.smooth&&(b=b*b*(3-2*b)),c+=(u[g][0]-c)*b,p+=(u[g][1]-p)*b,m+=(u[g][2]-m)*b,f+=(u[g][3]-f)*b}return[c,p,m,f]}function sAt(t,e){let i=t,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let s=e,n=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=kS(o.alpha,1);if(!(l<=0))if(o.type==="color"){let u,h=o.color;typeof h=="string"?u=typeof s?.color=="function"?s.color(h):void 0:h&&typeof h.r=="number"&&(u=h),u&&n.push({kind:"color",layer:o,rgb:{...ZK(u.r,u.g,u.b),a:u.a??1},alpha:l})}else o.type==="gradient"&&n.push({kind:"gradient",layer:o,alpha:l})}),n.length===0?null:(a,o)=>{let l=1,u=1,h=1,d=!0;for(let c of n){let p,m,f,g;if(c.kind==="color")({r:p,g:m,b:f}=c.rgb),g=c.rgb.a;else{let[v,b,_,x]=rAt(c.layer,a,o);({r:p,g:m,b:f}=ZK(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,u+=(m-u)*y,h+=(f-h)*y,d=!1}return{r:l,g:u,b:h}}}if(i?.color&&i.color.isColor===!0){let{r:s,g:n,b:a}=i.color;return()=>({r:s,g:n,b:a})}return null}var t2,kS,yj,nAt=j(()=>{dt(),t2=new ae,kS=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,yj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function aAt(t,e){if(t==="torus"){let l=e()*Math.PI*2,u=e()*Math.PI*2,h=Math.cos(l),d=Math.sin(l),c=Math.cos(u),p=Math.sin(u);return{x:(1.4+.7*c)*h,y:-(1.4+.7*c)*d,z:.7*p,nx:c*h,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,u=Math.cos(l),h=Math.sin(l);return{x:.8*u,y:1.6*(e()-.5),z:.8*h,nx:u,ny:0,nz:h,cr:1,cg:1,cb:1}}let i=e()*Math.PI*2,r=2*e()-1,s=Math.acos(r),n=Math.sin(s)*Math.cos(i),a=Math.cos(s),o=Math.sin(s)*Math.sin(i);return{x:n,y:a,z:o,nx:n,ny:a,nz:o,cr:1,cg:1,cb:1}}function oAt(t){let{geometry:e,matrix:i}=t,r=e.getAttribute("position");if(!r||r.count<3)return null;let s=e.getAttribute("normal"),n=e.getAttribute("uv"),a=e.getAttribute("color"),o=e.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let u=(y,v)=>o?o.getX(3*y+v):3*y+v,h=i?i.elements:null,d=i?new Ts().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[0]*v+h[4]*b+h[8]*_+h[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[1]*v+h[5]*b+h[9]*_+h[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[2]*v+h[6]*b+h[10]*_+h[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=u(y,0),b=u(y,1),_=u(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,C=p(b)-S,M=m(b)-w,A=c(_)-x,R=p(_)-S,O=m(_)-w,N=C*O-M*R,B=M*A-T*O,L=T*R-C*A;g+=.5*Math.sqrt(N*N+B*B+L*L),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let X=b+_>>1;f[X]<y?b=X+1:_=X}let x=b,S=u(x,0),w=u(x,1),T=u(x,2),C=v(),M=v();C+M>1&&(C=1-C,M=1-M);let A,R,O,N=1-C-M,B=c(S)*N+c(w)*C+c(T)*M,L=p(S)*N+p(w)*C+p(T)*M,z=m(S)*N+m(w)*C+m(T)*M;if(s){if(A=s.getX(S)*N+s.getX(w)*C+s.getX(T)*M,R=s.getY(S)*N+s.getY(w)*C+s.getY(T)*M,O=s.getZ(S)*N+s.getZ(w)*C+s.getZ(T)*M,d){let X=d[0]*A+d[3]*R+d[6]*O,st=d[1]*A+d[4]*R+d[7]*O,nt=d[2]*A+d[5]*R+d[8]*O;A=X,R=st,O=nt}}else{let X=c(S),st=p(S),nt=m(S),xt=c(w)-X,pt=p(w)-st,K=m(w)-nt,ct=c(T)-X,St=p(T)-st,wt=m(T)-nt;A=pt*wt-K*St,R=K*ct-xt*wt,O=xt*St-pt*ct}let k=Math.sqrt(A*A+R*R+O*O)||1,V=1,H=1,W=1;if(a)V=a.getX(S)*N+a.getX(w)*C+a.getX(T)*M,H=a.getY(S)*N+a.getY(w)*C+a.getY(T)*M,W=a.getZ(S)*N+a.getZ(w)*C+a.getZ(T)*M;else if(t.sampleColor){let X=n?n.getX(S)*N+n.getX(w)*C+n.getX(T)*M:.5,st=n?n.getY(S)*N+n.getY(w)*C+n.getY(T)*M:.5,nt=t.sampleColor(X,st);nt&&(V=nt.r,H=nt.g,W=nt.b)}return{x:B,y:L,z,nx:A/k,ny:R/k,nz:O/k,cr:V,cg:H,cb:W}}}}function QK(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),vv),i=function(l){let u=l>>>0;return()=>{u|=0,u=u+1831565813|0;let h=Math.imul(u^u>>>15,1|u);return h=h+Math.imul(h^h>>>7,61|h)^h,((h^h>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Lh:Lh,n=new Float32Array(4*ic),a=new Float32Array(ic),o=new Float32Array(4*vv).fill(1);for(let l=0;l<e;l++){let u=r?t.sampler(i):aAt(t.shape,i),h=r?u.x:u.x*s,d=r?u.y:u.y*s,c=r?u.z:u.z*s,{nx:p,ny:m,nz:f}=u;o[4*l+0]=u.cr,o[4*l+1]=u.cg,o[4*l+2]=u.cb;let g,y,v,b=l*yg,_=(1.8+.8*i())*t.hairLength*s/(yg-1),x=.5+1.5*i(),S=(.02+.06*i())*s;Math.abs(m)<.99?(g=-f,y=0,v=p):(g=1,y=0,v=0);let w=Math.sqrt(g*g+y*y+v*v)||1;for(let T=0;T<yg;T++){let C=T/(yg-1),M=C*C*.4*s,A=S*Math.sin(C*x*Math.PI*2),R=4*(b+T);n[R+0]=h+p*_*T+A*g/w,n[R+1]=d+m*_*T-M+A*y/w,n[R+2]=c+f*_*T+A*v/w,n[R+3]=T===0?0:1,T<yg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var yg,vv,ic,Lh,Gp,p_,G0,af,W0,WP,Qgt=j(()=>{dt(),ic=(vv=16384)*(yg=32),Lh=100}),Jgt=j(()=>{dt(),la(),JG(),nAt(),Qgt(),Gp=1/60,p_=new _t,G0=new Se,af=new P,W0=new P,WP=class extends Vs{constructor(t,e,i){super(t,e),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.settledSimSeconds=0,this.lastMotionFingerprint=0,this.lastBoneQuat=new Se,this.lastBonePos=new P,this.hasLastBone=!1,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=i,this.data=e,this.geometry.setAttribute("position",new _e(new Float32Array(0),3)),this.material=new Uo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new vr(new Mc(Lh,48,32),new Uo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new QR;r.setAttribute("position",new _e(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new vr(r,new Uo({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=e.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:e.guideStrands,hairLength:e.hairLength,spreadRadius:e.spreadRadius,headShape:e.headShape,baseObjectId:e.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(t){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+t/1e3,4*Gp*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(G0,af);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(G0))<.9999995||this.lastBonePos.distanceToSquared(af)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(G0),this.lastBonePos.copy(af),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+t}motionFingerprint(){let t=this.data;return t.gravity+2*t.damping+3*t.localStiffness+4*t.globalStiffness+5*t.globalRange+6*t.stiffnessFalloff+7*t.windStrength+8*t.vspCoefficient+9*t.kink+10*t.kinkFrequency+11*t.clumpStrength+12*t.clumpSize+13*t.clumpTipScale}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>6}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(t){this.playModeActive=t,t&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(t,e){super.updateState(t,e),this.updateHairState(t)}updateHairState(t){if((t.guideStrands!==void 0||t.hairLength!==void 0||t.spreadRadius!==void 0||t.headShape!==void 0||t.baseObjectId!==void 0)&&this.regenerate(),(t.headShape!==void 0||t.baseObjectId!==void 0)&&this.applyScalpState(),t.headColor!==void 0){let e=this.scalpMesh.material;e.isMeshBasicMaterial===!0&&e.color.setRGB(t.headColor.r,t.headColor.g,t.headColor.b,Ns)}(t.castShadow!==void 0||t.receiveShadow!==void 0)&&this.applyShadowState(),t.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let t=this.data.castShadow??!0,e=this.data.receiveShadow??!0;this.castShadow=t,this.receiveShadow=e,this.scalpMesh.castShadow=t,this.scalpMesh.receiveShadow=e,this.ribbonMesh.castShadow=t,this.ribbonMesh.receiveShadow=e}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let t=this.data,e=this.regenSnapshot;if(e===null||e.guideStrands!==t.guideStrands||e.hairLength!==t.hairLength||e.spreadRadius!==t.spreadRadius||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId){let i=e===null||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:t,baseObjectId:e,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,t==="object"&&e){let s=this.context.scene.find(e);if(s){this.baseFoundAtRegen=!0,s.updateWorldMatrix(!0,!0);let n=this.collectBaseSources(s),a=n?function(o){let l=[];for(let d of o){let c=oAt(d);c&&l.push(c)}if(l.length===0)return null;let u=new Float64Array(l.length),h=0;for(let d=0;d<l.length;d++)h+=l[d].total,u[d]=h;return h<=0?null:d=>{let c=d()*h,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;u[g]<c?p=g+1:m=g}let f=p===0?c:c-u[p-1];return l[p].sample(f,d)}}(n.sources):null;if(this.baseSourceGeomsAtRegen=n?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=n?.hashes??[],this.baseColorHashAtRegen=n?.colorHash??0,n&&a){let o=this.baseWorldScale(s),l=Math.max(n.radius*o,.001);this.baseScaleAtRegen=o;let u=o;return QK({shape:"object",guideStrands:i,hairLength:r,sampler:h=>{let d=a(h);return{...d,x:d.x*u,y:d.y*u,z:d.z*u}},samplerRadius:l})}}}return QK({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;p_.copy(t.matrixWorld).invert();let n=p_.clone(),a=o=>{if(o.isHairSystem===!0||o!==t&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let u=o===t?void 0:new _t().multiplyMatrices(n,o.matrixWorld),h=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:u,sampleColor:sAt(h,this.context.shared)??void 0}),i.push(WP.matrixHash(u)),s+=function(c,p){let m=c,f=0,g=1,y=b=>{f+=b*g,g+=1},v=m?.data?.layers;if(v&&typeof v.forEach=="function"){let b=p;v.forEach(_=>{let x=_.data;if(x.visible!==!1){if(x.type==="color"){let S=x.color,w=typeof S=="string"?typeof b?.color=="function"?b.color(S):void 0:S;w&&typeof w.r=="number"&&(y(w.r),y(w.g),y(w.b)),y(kS(x.alpha,1))}else if(x.type==="gradient"){let S=x;for(let w of S.colors??[])y(w[0]),y(w[1]),y(w[2]),y(w[3]);for(let w of S.steps??[])y(w);y(kS(S.angle,0)),y(S.gradientType),y(S.smooth?1:0)}}})}else m?.color&&m.color.isColor===!0&&(y(m.color.r),y(m.color.g),y(m.color.b));return f}(h,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;u?(af.copy(d.center).applyMatrix4(u),c=af.length(),p=WP.matrixMaxScale(u)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let u of o.children)a(u)};return a(t),e.length===0?null:{sources:e,hashes:i,radius:Math.max(r,.001),colorHash:s}}static matrixHash(t){if(!t)return 0;let e=t.elements,i=0;for(let r=0;r<16;r++)i+=e[r]*(r+1);return i}static matrixMaxScale(t){let e=t.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);return Math.max(i,r,s,1e-6)}baseWorldScale(t){return p_.copy(t.matrixWorld).decompose(af,G0,W0),Math.max(Math.abs(W0.x),Math.abs(W0.y),Math.abs(W0.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let t=this.context.scene.find(this.data.baseObjectId);if(!t)return;if(!this.baseFoundAtRegen)return void this.regenerate();t.updateWorldMatrix(!0,!0);let e=this.collectBaseSources(t),i=e?.sources??[],r=e?.hashes??[],s=this.baseSourceGeomsAtRegen,n=this.baseSourceHashesAtRegen,a=i.length!==s.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==s[o]||Math.abs(r[o]-n[o])>1e-4*Math.max(Math.abs(n[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(e?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(t);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let t=this.data.headShape,e=t==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!e,!e&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=t==="torus"?new ZR(1.4*Lh,.7*Lh,24,48):t==="cylinder"?new k2(.8*Lh,.8*Lh,1.6*Lh,48,1):new Mc(Lh,48,32))}boneTransform(t,e){let i=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let r=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;r&&(i=r)}p_.copy(i).decompose(e,t,W0)}raycast(t,e){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(t,i);for(let r of i)r.object=this,e.push(r)}get shadowBoundsRadius(){let t=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(t+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(t){return this.boneTransform(G0,t),t}updateEntityBoxSize(t,e){let i=this.shadowBoundsRadius;t.set(0,0,0),e.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),gj()?.release(this)}}});function qP(){return{shapeInput:()=>`
|
|
354
354
|
const float posRowCoord = ${.5/dc};
|
|
355
355
|
const float quatRowCoord = ${1.5/dc};
|
|
356
356
|
const float param1RowCoord = ${2.5/dc};
|
|
@@ -1547,7 +1547,7 @@ function sortWorker(self) {
|
|
|
1547
1547
|
gl_FragColor = vec4(color.rgb, A);
|
|
1548
1548
|
gVelocity = vec4(0.0);
|
|
1549
1549
|
}`,transparent:!0,alphaTest:1,blending:Fh,depthTest:!0,depthWrite:!1,side:Rn})}static buildGeomtery(t){let e=new ge;e.setIndex([0,1,2,0,2,3]);let i=new Float32Array(12),r=new _e(i,3);e.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new QR().copy(e),n=new Uint32Array(t),a=new po(n,1,!1);return a.setUsage(Yh),s.setAttribute("splatIndex",a),s.instanceCount=t,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(6*this.splatCount),this.colors=new Uint8Array(4*this.splatCount),this.centers=new Float32Array(3*this.splatCount);let t=0,e=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(t,t+4*s).set(r.colorsA),t+=4*s,this.centers.subarray(e,e+3*s).set(r.decoded.xyz.denormDequant().data),e+=3*s,this.covariances.subarray(i,i+6*s).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=6*s}}allocateAndStoreLocalSplatDataInTextures(){let t=this.splatCount,e=new Q(4096,1024);for(;e.x*e.y*2<6*t;)e.y*=2;let i,r,s=new Q(4096,1024);for(;s.x*s.y*4<4*t;)s.y*=2;if(this.halfPrecisionCovariancesOnGPU){r=new Uint16Array(e.x*e.y*2);for(let u=0;u<this.covariances.length;u++)r[u]=Kh.toHalfFloat(this.covariances[u]);i=new br(r,e.x,e.y,Bo,ai)}else r=new Float32Array(e.x*e.y*2),r.set(this.covariances),i=new br(r,e.x,e.y,Bo,Qe);i.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=i,this.material.uniforms.covariancesTextureSize.value.copy(e);let n=new Uint32Array(s.x*s.y*4);for(let u=0;u<t;u++){let h=4*u,d=3*u,c=4*u;n[c]=O0t(this.colors[h],this.colors[h+1],this.colors[h+2],this.colors[h+3]),n[c+1]=YP(this.centers[d]),n[c+2]=YP(this.centers[d+1]),n[c+3]=YP(this.centers[d+2])}let a=new br(n,s.x,s.y,j7,En);V4()!=="webgpu"&&(a.internalFormat="RGBA32UI"),a.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=a,this.material.uniforms.centersColorsTextureSize.value.copy(s);let o=new Float32Array(4096);for(let u=0;u<this.meshMatrixWorlds.length;u++)o.set(this.meshMatrixWorlds[u].elements,16*u);let l=new br(o,1024,1,on,Qe);l.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=l,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:r,texture:i,size:e},centerColors:{data:n,texture:a,size:s},meshMatrixWorlds:{data:o,texture:l}}}updateIndexes(t){let e=this.geometry;e.attributes.splatIndex.set(t),e.attributes.splatIndex.needsUpdate=!0,e.instanceCount=t.length}updateUniforms(t,e,i,r){this.splatCount>0&&(g_.set(t.x*this.devicePixelRatio,t.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(g_),this.material.uniforms.basisViewport.value.set(2/g_.x,2/g_.y),this.material.uniforms.focal.value.set(e,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}}});function OAt(){if(!Aj)return dZ||(dZ=async function(){let t=await Promise.resolve().then(()=>(tH(),Jq));V0t(t),Aj=!0}())}var V0t,k0t,Aj,dZ,cZ,z0t,L0t,AI,Ng,F0t=j(()=>{k0t=new Promise(t=>{V0t=t}),Aj=!1}),IAt=j(()=>{DAt(),dt(),B0t(),F0t(),k0t.then(t=>cZ=t),z0t=class{constructor(t={}){pc(this,"updateView",function(){let e=new _t,i=[],r=new P(0,0,-1),s=new P(0,0,-1),n=new P,a=new P;return function(o=!1,l){let u=this.updateMatrixWorldsInWorkerIfNeeded(),h=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(l.quaternion);let c=!1,p=!1;if(s.dot(r)<=.95&&(c=!0),a.copy(l.position).sub(n).length()>=1&&(p=!0),!(c||p||u||h||this.needsInitialRender))return}this.needsInitialRender=!1,n.copy(l.position),r.copy(s),e.copy(l.matrixWorld).invert(),e.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:e.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...u?{newMatrixWorlds:this.meshMatrixWorlds}:{},...h?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}()),this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new _t().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let i=new Q;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(t.getSize(i),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new P().fromArray(t.position)),t.orientation&&(t.orientation=new Se().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(n=>{n.data.type==="Splat"&&e.push(n)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(n=>n.matrixWorld),this.meshMatrixWorldsOld=e.map(n=>n.matrixWorld.clone()),this.cropsArray=e.map(n=>n.data.crops.map(a=>a.data)),this._splatBufferCache??(this._splatBufferCache=new WeakMap);let i=e.map(n=>{let a=this._splatBufferCache.get(n.data.buffer);return a===void 0&&(a=new cZ.GSplineBuffer(new Uint8Array(n.data.buffer).buffer),this._splatBufferCache.set(n.data.buffer,a)),a}),r=0,s=[0];for(let n of i)r+=n.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,16*e);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,!this.meshMatrixWorlds.every((e,i)=>e.equals(this.meshMatrixWorldsOld[i]))&&(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,i)=>{e.data.crops.forEach((r,s)=>{this.cropsArray[i][s]===void 0?(t=!0,this.cropsArray[i][s]=r.data):Object.entries(r.data).forEach(([n,a])=>{(Array.isArray(a)&&a.some((o,l)=>o!==this.cropsArray[i][s][n][l])||a!==this.cropsArray[i][s]?.[n])&&(t=!0,this.cropsArray[i][s][n]=a)})}),e.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,i=new P,r=new Se,s=!1,n=1,a,o){this.splatMesh=o2.buildMesh(t,e,s,n,a,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(l,u,h)=>this.update(l,h)}setupSortWorker(t){this.sortWorker=function(e){let i=new Worker(URL.createObjectURL(new Blob(["(",N0t,")(self)"],{type:"application/javascript"}))),r=atob(D0t),s=new Uint8Array(r.length);for(let n=0;n<r.length;n++)s[n]=r.charCodeAt(n);return i.postMessage({init:{sorterWasmBytes:s.buffer,splatCount:e,Constants:{BytesPerFloat:nm.BytesPerFloat,BytesPerInt:nm.BytesPerInt,DepthMapRange:nm.DepthMapRange,MemoryPageSize:nm.MemoryPageSize}}}),i}(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}}}),uW=j(()=>{dt(),Qh(),vo(),Mm(),ke(),M0t(),Fi(),YG(),MG(),la(),nT(),CAt(),G5(),bo(),ns(),Nc(),b0t(),ns(),hn(),tT(),EAt(),IAt(),(L0t=new Uo).wireframe=!0,AI=new P,Ng=class extends Yu{constructor(t,e){super(),this.data=t,this.sharedAssets=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this._normalPassNeeds={outline:!1,cavity:!1},this._needsReflection=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.hairInstances=[],this.shadowsDirty=!0,this.instanceGroupsDirty=!0,this._autoInstancing=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new R0t,this.invisibleObjects=new zu("jflkdsafjasdifjaslk",{...y4.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(t,e),this.matrixAutoUpdate=!1,this.errorPage=new Xs("fdasfa",{...Ug.defaultData,name:""},{shared:e,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markShadowsDirty(){this.shadowsDirty=!0}markInstanceGroupsDirty(){this.instanceGroupsDirty=!0}get autoInstancing(){return this._autoInstancing}updateInstanceGroups(t,e){let i=this._autoInstancing;(i===null||i.minGroupSize!==e)&&(i?.dispose(),i=new T0t(e),this._autoInstancing=i);let r=this.instanceGroupsDirty;return this.instanceGroupsDirty=!1,i.update(t,r),i.stats}releaseInstanceGroups(){this._autoInstancing?.teardown(),this.instanceGroupsDirty=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this.shadowsDirty=!0,this.instanceGroupsDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=function(t){let e=!1;return t.traverseEntity(i=>{if(i instanceof yo)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)XK(i,i.material[r])&&(e=!0);else XK(i,i.material)&&(e=!0)}),e}(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._normalPassNeeds=function(t){let e={outline:!1,cavity:!1},i=r=>{e.outline=e.outline||r.outline,e.cavity=e.cavity||r.cavity};return t.traverseEntity(r=>{if(r instanceof yo)if(Array.isArray(r.material))for(let s=0;s<r.material.length;s++)i($K(r,r.material[s]));else i($K(r,r.material))}),e}(this),this._needsNormal=this._normalPassNeeds.outline||this._normalPassNeeds.cavity,this.needsNormalDirty=!1),this._needsNormal}normalPassNeeds(){return this.needsNormal(),this._normalPassNeeds}needsReflection(){return this.needsReflectionDirty&&(this._needsReflection=function(t){let e=!1;return t.traverseEntity(i=>{if(i instanceof yo)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)YK(i,i.material[r])&&(e=!0);else YK(i,i.material)&&(e=!0)}),e}(this),this.needsReflectionDirty=!1),this._needsReflection}registerInstanceAndSetUuid(t){let e=t.identity.join("-"),i=this.entityIdentityToEntity[e];i&&(t.uuid=i.uuid),this.entityIdentityToEntity[e]=t,this.entityByUuid[t.uuid]=t}markPenumbraSizeDirty(){for(let t of this.children)t instanceof Xs&&(t.penumbraSizeArrayCache=null)}findInstance(t){return this.entityIdentityToEntity[t.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let i=[],r=e;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:e,sortKey:i}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push(r)}return e.sort((i,r)=>JR(i.sortKey,r.sortKey)),e.map(i=>i.entity)}nonExistOrDescendantOf(t,e){let i=this.find(t);if(i===void 0)return!0;for(;i;){if(i.uuid===e)return!0;i=i.parent}return!1}find(t){if(this.activePage&&this.activePage.personalCamera.parent){if(t==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(t===n0)return this.activePage.personalCamera}if(t===""||t===void 0)return;let e=this.entityByUuid[t];return e===void 0?this.getObjectByProperty("uuid",t):e}find2D(t){for(let e of this.children)if(e instanceof Xs&&e.uiScene){let i=e.uiScene.find(t);if(i)return i}}findScene2DfromObject2D(t){for(let e of this.children)if(e instanceof Xs&&e.uiScene&&e.uiScene.find(t))return e.uiScene}find2DInUIObjects(t){let e;return this.traverseEntity(i=>{e===void 0&&Ya(i)&&(e=i.uiCanvas.find(t))}),e}traverse2D(t){for(let e of this.children)e instanceof Xs&&e.uiScene&&e.uiScene.traverse(t)}debugEnsureEntity(t){let e=this.find(t);e?Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0&&console.error("not found instance"):console.error("not found")}addPendingExpandCloner(t){this.toExpandCloner.add(t)}addPendingUpdateCloner(t){this.toUpdateCloner.add(t)}markToExpandCloner(t){this.toExpandCloner.add(t),t.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(t){this.toExpandCloner.forEach(e=>{e.expandCloner(t)}),this.toExpandCloner.clear()}doPendingUpdateCloner(t){this.toUpdateCloner.forEach(e=>{e.cloner?.update(t)}),this.toUpdateCloner.clear()}doPendingUpdates(t){this.doPendingExpandCloner(t),this.doPendingUpdateCloner(t),this.applyPendingCommands()}addPendingCommand(t){this.pendingCommands.push(t)}applyPendingCommands(){this.pendingCommands.forEach(t=>t()),this.pendingCommands.length=0}updateByLibOp(t,e){t.path.length===1&&t.path[0]==="components"&&t.type===1&&this.createChildrenObjects([{...t.data.asset,id:t.id}],this.invisibleObjects,e)}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let i=t.parent===null?this:this.find(t.parent);if(i===void 0)throw new Error(`scene tree add: parent ${t.parent} not found for object ${t.id}`);let r=this.createObject(t.id,t.data,t.children,i,t.localIndex,e);r.updateVisible(this),r.resetBBoxNeedsUpdate(),Hh(r)&&Hu(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(t.path.length===0&&t.type===8){let i=this.find(t.id);if(i===void 0)throw new Error(`scene tree delete: object ${t.id} not found`);i.traverseEntity(s=>{Ec(s)&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(n=>n!==s)),i0(s)&&(this.hairInstances=this.hairInstances.filter(n=>n!==s))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Hu(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Hh(i)&&(i.freeBooleanPointer(),r instanceof cm&&r.invalidateDownstreamBooleanData().recomputeBoolean()),L5(i)&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(t.path.length===0&&t.type===9){let i=this.find(t.id);if(i===void 0)throw new Error(`scene tree move: object ${t.id} not found`);this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=t.parent===null?this:this.find(t.parent);if(s===void 0)throw new Error(`scene tree move: new parent ${t.parent} not found for object ${t.id}`);s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=t.localIndex;s.children.splice(n,0,s.children.pop()),Hh(i)&&(i.invalidateUpstreamBooleanData(),Hu(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof cm&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(t){this.shadowsDirty=!0,this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let e of this.children)e instanceof Xs&&(e.visible=e.uuid===t,e.visible&&(this.activePage=e,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(t,e,i,r){if(this.shadowsDirty=!0,e.type===0){if(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),"visible"in e.props&&this.markPenumbraSizeDirty(),e.path.includes("overrides")&&"states"in e.props){let{rest:n}=e.props;e={...e,props:n},this.markNeedsRecomputeInstances()}e.path[0]==="pathSnapping"&&e.props.pathId!==void 0&&this.pathConstraints.setConstraint(t,e.props.pathId)}let s=this.find(t);if(s)try{(function(n,a,o,l){n.updateByOp(a,o,l,!1)})(s,e,i,{scene:this,shared:r}),s instanceof Fr&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}updateEntity2DByOp(t,e,i,r,s,n=[]){t.updateEntityByOp(e,i,r,s),this.traverseEntity(a=>{(Ya(a)||a instanceof Xs)&&(n.includes(a.frameId??"")||a.frameId===e)&&a.updateEntity2DByOp(e,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(t){this.activePage.switchActiveCamera(t)}isInvisibleObjects(t){return t===this.invisibleObjects||t.hasAnccestor(this.invisibleObjects)}init(t,e){let i=Object.entries(e.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:e}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,e),this.createChildrenObjects(t.objects,this,e),this.updatePage(t.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(e,!0),this.traverseEntity(r=>{r instanceof ks&&r.updateUp()}),this.doPendingExpandCloner({scene:this,shared:e}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(t){t.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(t){Mi.is(t)&&(t.data.type==="Component"&&this.markNeedsRecomputeInstances(),t.traverseAncestors(e=>{Mi.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(t,e,i,r,s,n,a){if(t){let o=r.find(t);o&&o!==r&&s.forInstancesRec(l=>{l.data=i4(l.data,u=>{let h=u.events.data(a.id),d=l.goUp(n);if(d){let c=[...cmt(d.identity),t].join("-"),p=this.entityIdentityToEntity[c];if(p){let m=p.uuid;Dn.zoom(h,e)[i]=m}else console.warn("cannot find instance")}}).data})}}rewriteActions(t,e,i,r,s,n){t.forEach(a=>{a.data.type==="Transition"||a.data.type==="Animation"&&a.data.object?this.relativeizeInner(a.data.object,[...e,a.id],"object",i,r,s,n):a.data.type==="Conditional"&&(this.rewriteActions(a.data.ifActions,[...e,a.id,"ifActions"],i,r,s,n),this.rewriteActions(a.data.elseActions,[...e,a.id,"elseActions"],i,r,s,n))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(t=>{if(kP(t)&&typeof t.identity=="string"&&t.data.type==="Component")return t.traverseEntity((e,i)=>{e.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(e.forInstancesRec(n=>{n.data=i4(n.data,a=>{n.isInstanceRoot||(a.events.delete(r.id),s=!0)}).data}),s===!1)for(let n of x4.list)this.rewriteActions(r.data.gameActions[n],["gameActions",n],t,e,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",t,e,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",t,e,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",t,e,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,t,e,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,t,e,i,r)),this.rewriteActions(r.data.inActions,["inActions"],t,e,i,r),this.rewriteActions(r.data.outActions,["outActions"],t,e,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],t,e,i,r)})}),!0})}expandInstances(t,e,i){let r=new Set;this.traverseEntity(s=>{if(kP(s)&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:t,pendingDeletes:r}),e||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(n=>{i.addClip(n)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),aW(s)}recomputeInstances(t,e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{kP(i)&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(t,!1,e))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(t){t.traverseEntity(e=>{let i=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[i]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[i]),e.dispose()})}clearScene(){this._autoInstancing?.dispose(),this._autoInstancing=null,this.instanceGroupsDirty=!0;for(let t of this.children)Mi.is(t)&&t.disposeRecursively();this.children.length=0}resetAfterClear(t,e){this.init(t,e)}raycast(t){return this.raycast1(t,!1)}raycast1(t,e){let i=[],r=s=>{for(let n of s.children){let a=n.cloner;if(Mi.is(n)&&!n.raycastLock&&(n.visible||a?.object.data.visible))if(e===!0&&n.isInstanceRoot){let o=[];if(t.intersectObject(n,!0,o),o.length){let l=o[0];l.object=n,l.point.applyMatrix4(l.object.matrixWorld);let u=n.matrixWorld.clone().invert();l.point.applyMatrix4(u),i.push(l)}}else(Hh(n)||L4(n)&&this.enableHelpers&&n.objectHelper.visible)&&(t.intersectObject(n,!1,i),pj(n,t,i)),r(n)}};return r(this.activePage),i}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;Mi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||L4(s)&&this.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),pj(s,t,e,!0)),i(s))}};return i(this),e}forEachEntity(t){for(let e of this.children)Mi.is(e)&&t(e)}traverseConcreteEntity(t){for(let e of this.children)Mi.is(e)&&e.isConcreteEntity&&e.traverseEntity(t)}traverseEntity(t){for(let e of this.children)Mi.is(e)&&e.traverseEntity(t)}updateFont(t,e){this.traverseEntity(i=>{if(i instanceof Fr&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===t){let r=i.geometry,s=i.data.geometry;r.updateFont(t,e).then(()=>{r.update(s,e);let n=i.invalidateDownstreamBooleanData();Hu(n)&&n.recomputeBoolean()})}})}traverseObject(t){for(let e of this.children)Eg.is(e)&&e.traverseObject(t)}traverseVisibleEntity(t){for(let e of this.children)Mi.is(e)&&e.visible&&e.traverseVisibleEntity(t)}dispose(){this.clearScene()}createChildrenObjects(t,e,i){let r=0;for(let s of t)this.createObject(s.id,s.data,s.children,e,r,i),r+=1}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let e of t.children)this.unregisterObject(e)}createObject(t,e,i,r,s,n){let a={scene:this,shared:n},o=hW(t,e,a);return Ec(o)&&this.shapeBlendIntances.push(o),i0(o)&&this.hairInstances.push(o),o&&(this.entityByUuid[t]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(e,a),o instanceof Fr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),e.pathSnapping?.pathId&&this.pathConstraints.setConstraint(t,e.pathSnapping.pathId)),e.type==="Empty"&&e.animations&&o.traverseEntity(l=>{let u=l.dataPatched;if(l instanceof Fr&&u.bones&&u.boneInverses){let h=u.bones.map(p=>this.find(p)),d=u.boneInverses.map(p=>new _t().fromArray(p)),c=new YR(h,d);l.bind(c,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(t){let e=[];for(let r=0,s=t.length;r<s;++r){let{id:n,recursive:a}=t[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;e.push(...l.vertices)}let i=new pr;return i.setFromPoints(e),i.getCenter(AI),AI}copyMatrixWorld(t,e){if(t===null)return void e.identity();let i=this.find(t);i?(i.updateWorldMatrix(!0,!1),e.copy(i.matrixWorld)):e.identity()}copyParentMatrixWorld(t,e){if(t===null)return void e.identity();let i=this.find(t)?.parent;i?(i.updateWorldMatrix(!0,!1),e.copy(i.matrixWorld)):e.identity()}traverseMaterial(t){this.traverseEntity(e=>{if(e instanceof Vs)if(Array.isArray(e.material))for(let i=0;i<e.material.length;i++)E4(e.material[i])&&t(e.material[i]);else E4(e.material)&&t(e.material)})}updateViewPlaneSize(t,e,i=!1){this.traverseConcreteEntity(r=>{r instanceof ks&&r.setViewplaneSize(t,e,i)})}initializeSplatViewer(){this.splatViewer=new z0t({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}}}),U0t={};function BAt(){let t,e;function i(r,s,n,a,o,l){let u=n.num_points(),h=l.num_components(),d=function(_,x){switch(x){case Float32Array:return _.DT_FLOAT32;case Int8Array:return _.DT_INT8;case Int16Array:return _.DT_INT16;case Int32Array:return _.DT_INT32;case Uint8Array:return _.DT_UINT8;case Uint16Array:return _.DT_UINT16;case Uint32Array:return _.DT_UINT32}}(r,o),c=h*o.BYTES_PER_ELEMENT,p=4*Math.ceil(c/4),m=p/o.BYTES_PER_ELEMENT,f=u*c,g=u*p,y=r._malloc(f);s.GetAttributeDataArrayForAllPoints(n,l,d,f,y);let v,b=new o(r.HEAPF32.buffer,y,f/o.BYTES_PER_ELEMENT);if(c===p)v=b.slice();else{v=new o(g/o.BYTES_PER_ELEMENT);let _=0;for(let x=0,S=b.length;x<S;x++){for(let w=0;w<h;w++)v[_+w]=b[x*h+w];_+=m}}return r._free(y),{name:a,count:u,itemSize:h,array:v,stride:m}}onmessage=function(r){let s=r.data;switch(s.type){case"init":t=s.decoderConfig,e=new Promise(function(o){t.onModuleLoaded=function(l){o({draco:l})},DracoDecoderModule(t)});break;case"decode":let n=s.buffer,a=s.taskConfig;e.then(o=>{let l=o.draco,u=new l.Decoder;try{let h=function(c,p,m,f){let g,y,v=f.attributeIDs,b=f.attributeTypes,_=p.GetEncodedGeometryType(m);if(_===c.TRIANGULAR_MESH)g=new c.Mesh,y=p.DecodeArrayToMesh(m,m.byteLength,g);else{if(_!==c.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");g=new c.PointCloud,y=p.DecodeArrayToPointCloud(m,m.byteLength,g)}if(!y.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());let x={index:null,attributes:[]};for(let S in v){let w,T,C=self[b[S]];if(f.useUniqueIDs)T=v[S],w=p.GetAttributeByUniqueId(g,T);else{if(T=p.GetAttributeId(g,c[v[S]]),T===-1)continue;w=p.GetAttribute(g,T)}let M=i(c,p,g,S,C,w);S==="color"&&(M.vertexColorSpace=f.vertexColorSpace),x.attributes.push(M)}return _===c.TRIANGULAR_MESH&&(x.index=function(S,w,T){let C=3*T.num_faces(),M=4*C,A=S._malloc(M);w.GetTrianglesUInt32Array(T,M,A);let R=new Uint32Array(S.HEAPF32.buffer,A,C).slice();return S._free(A),{array:R,itemSize:1}}(c,p,g)),c.destroy(g),x}(l,u,new Int8Array(n),a),d=h.attributes.map(c=>c.array.buffer);h.index&&d.push(h.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:h},d)}catch(h){console.error(h),self.postMessage({type:"error",id:s.id,error:h.message})}finally{l.destroy(u)}})}}}XS(U0t,{DRACOLoader:()=>G0t,DRACO_GLTF_CONFIG:()=>j0t});var ZM,j0t,G0t,VAt=j(()=>{dt(),ZM=new WeakMap,j0t={js:"",wasm:""},G0t=class extends rg{constructor(t){super(t),this.decoderPaths={js:"",wasm:"",dep_js:""},this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){let{decoderPaths:e}=this;return typeof t=="object"?(e.js=t.js,e.wasm=t.wasm,e.dep_js=null):(e.js=PP.resolveURL("draco_wasm_wrapper.js",t),e.wasm=PP.resolveURL("draco_decoder.wasm",t),e.dep_js=PP.resolveURL("draco_decoder.js",t)),this}setDecoderConfig(t){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,r){let s=new F2(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,n=>{this.parse(n,e,r)},i,r)}parse(t,e,i=()=>{}){this.decodeDracoFile(t,e,null,null,Ns,i).catch(i)}decodeDracoFile(t,e,i,r,s=Xu,n=()=>{}){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(t,a).then(e).catch(n)}decodeGeometry(t,e){let i=JSON.stringify(e);if(ZM.has(t)){let o=ZM.get(t);if(o.key===i)return o.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,n=t.byteLength,a=this._getWorker(s,n).then(o=>(r=o,new Promise((l,u)=>{r._callbacks[s]={resolve:l,reject:u},r.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),ZM.set(t,{key:i,promise:a}),a}_createGeometry(t){let e=new ge;t.index&&e.setIndex(new _e(t.index.array,1));for(let i=0;i<t.attributes.length;i++){let r,{name:s,array:n,itemSize:a,stride:o,vertexColorSpace:l}=t.attributes[i];if(a===o)r=new _e(n,a);else{let u=new q1(n,o);r=new Up(u,a,0)}s==="color"&&(this._assignVertexColorSpace(r,l),r.normalized=!(n instanceof Float32Array)),e.setAttribute(s,r)}return e}_assignVertexColorSpace(t,e){if(e!==Ns)return;let i=new ae;for(let r=0,s=t.count;r<s;r++)i.fromBufferAttribute(t,r),Zi.colorSpaceToWorking(i,Ns),t.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(t,e){let i=new F2(this.manager);return i.setResponseType(e),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(t,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[],{decoderPaths:i}=this;if(t){if(i.dep_js===null)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");e.push(this._loadLibrary(i.dep_js,"text"))}else e.push(this._loadLibrary(i.js,"text")),e.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(e).then(r=>{let s=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let n=BAt.toString(),a=["/* draco decoder */",s,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
|
|
1550
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),kAt=j(()=>{});function W0t(t){return function(e,{basePath:i,moduleUrl:r,cdnBuild:s}){if(i!==void 0)return{url:`${i}/${e}`};let n=`${s}/${e}`;if(r===void 0||r.startsWith("file:"))return{url:n};let a=r.slice(0,r.lastIndexOf("/")+1)+e;return a===n?{url:a}:{url:a,fallback:n}}(t,{basePath:q0t,moduleUrl:typeof import.meta.url=="string"?import.meta.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.80/build"})}function pZ(t,e){let{url:i,fallback:r}=W0t(e);r!==void 0&&t.addEventListener("error",()=>{t.src=r},{once:!0}),t.src=i}var q0t,dW=j(()=>{kAt()});function H0t(t,e){cW.set(t,e)}function mZ(t){return cW.get(t)}function fZ(t,e){let i=`${e}:${t}`;Cj.has(i)||Cj.add(i)}var cW,Cj,pW=j(()=>{cW=new Map,Cj=new Set});function CI(t,e=0){let i=3735928559^e,r=1103547991^e;if(Array.isArray(t))for(let s,n=0;n<t.length;n++)s=t[n],i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);else for(let s,n=0;n<t.length;n++)s=t.charCodeAt(n),i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function gZ(t){return eyt.get(t)}function QM(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function yZ(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?9:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new ws)}function zAt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?12:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new ws)}function LAt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)||/vec4/.test(t)?4:/mat2/.test(t)?2:/mat3/.test(t)||/mat4/.test(t)?4:void Xt(`TSL: Unsupported type: ${t}`,new ws)}function Xc(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function EI(t,...e){let i=t?t.slice(-4):void 0;return e.length===1&&(i==="vec2"?e=[e[0],e[0]]:i==="vec3"?e=[e[0],e[0],e[0]]:i==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new ae(...e):i==="vec2"?new Q(...e):i==="vec3"?new P(...e):i==="vec4"?new Me(...e):i==="mat2"?new Y7(...e):i==="mat3"?new Ts(...e):i==="mat4"?new _t(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?function(r){return Uint8Array.from(atob(r),s=>s.charCodeAt(0)).buffer}(e[0]):null}function vZ(t){let e=Pj.get(t);return e===void 0&&(e={},Pj.set(t,e)),e}function At(t,e){if(W4.has(t))ne(`TSL: Redefinition of method chaining '${t}'.`);else{if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);W4.set(t,e),t!=="assign"&&(Ee.prototype[t]=function(...i){return this.isStackNode?this.addToStack(e(...i)):e(this,...i)},Ee.prototype[t+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],e(...i)):this.assign(e(this,...i))})}}function JM(t,e,i){_v[t]=_v[e]=_v[i]={get(){this._cache=this._cache||{};let a=this._cache[t];return a===void 0&&(a=new Rj(this,t),this._cache[t]=a),a},set(a){this[t].assign(ve(a))}};let r=t.toUpperCase(),s=e.toUpperCase(),n=i.toUpperCase();Ee.prototype["set"+r]=Ee.prototype["set"+s]=Ee.prototype["set"+n]=function(a){let o=Dj(t);return new iyt(this,o,ve(a))},Ee.prototype["flip"+r]=Ee.prototype["flip"+s]=Ee.prototype["flip"+n]=function(){let a=Dj(t);return new ryt(this,a)}}function bZ(t){return t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)}function X0(t){return t&&t.isNode&&t.traverse(e=>{e.isConstNode&&(t=e.value)}),Boolean(t)}function Y0(t,e){return new syt(t,e)}function it(t,e=null){let i=new nyt(t,e);return new Proxy(()=>{},{apply:(r,s,n)=>i.call(...n),get:(r,s,n)=>Reflect.get(i,s,n),set:(r,s,n,a)=>Reflect.set(i,s,n,a)})}function t3(t){return Jd&&Jd.addToStack(t),t}function _Z(t,e,i=null){return rc(i,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(t):s})}function xZ(t,e=null){return rc(e,{getAO:(i,{material:r})=>r.transparent===!0?i:i!==null?i.mul(t):t})}function wZ(t,e){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),ZP(t,e)}function SZ(t,e){let i=Nj.get(t);return i===void 0&&(i=new q1(t,e),Nj.set(t,i)),i}function e3(t,e=null,i=0,r=0,s=_g,n=!1){return e==="mat3"||e===null&&t.itemSize===9?xn(new Yd(t,"vec3",9,0).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,3).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&t.itemSize===16?tc(new Yd(t,"vec4",16,0).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,4).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,8).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,12).setUsage(s).setInstanced(n)):new Yd(t,e,i,r).setUsage(s)}function TZ(t,e=!0){return ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),lg(t).setParent(e)}function MZ(t,e,i,r=U(0),s=U(1)){return Oj(t,e,i,r,s,!0)}function AZ(t,e="",i=null){return(t=ve(t)).before(new ayt(t,e,i))}function FAt(t){ne("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}function CZ(t,e,i){let r;if(e.isStorageInstancedBufferAttribute===!0)r=Kd(e,"mat4",Math.max(i,1)).element(Xl);else if(16*i*4<=t.getUniformBufferLimit())r=vg(e.array,"mat4",Math.max(i,1)).element(Xl);else{let s=q4.get(e);s||(s=new X7(e.array,16,1),q4.set(e,s));let n=e.usage===Yh?QP:l2,a=[n(s,"vec4",16,0),n(s,"vec4",16,4),n(s,"vec4",16,8),n(s,"vec4",16,12)];r=tc(...a)}return r}function Ej(t,e,i,r,s,n){let a=t.element(s.x),o=t.element(s.y),l=t.element(s.z),u=t.element(s.w),h=i.mul(e),d=Ds(a.mul(n.x).mul(h),o.mul(n.y).mul(h),l.mul(n.z).mul(h),u.mul(n.w).mul(h));return r.mul(d).xyz}function EZ(t,e,i,r,s,n,a){let o=t.element(n.x),l=t.element(n.y),u=t.element(n.z),h=t.element(n.w),d=Ds(a.x.mul(o),a.y.mul(l),a.z.mul(u),a.w.mul(h));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(e).xyz,skinTangent:d.transformDirection(i).xyz}}function PZ(t,e,i,r,s){let n=t.skeleton,a=eS.get(n);if(a===void 0){n.update();let o=new Float32Array(n.boneMatrices);a={previousBoneMatrices:o,node:vg(o,"mat4",n.bones.length)},eS.set(n,a)}return Ej(a.node,kp,e,i,r,s)}function $0t(t){let e=t.target;e.removeEventListener("dispose",$0t);let i=K1.get(e);i!==void 0&&(K1.delete(e),i.dispose())}function RZ(t,e){e===jR?t.mapping=kg:e===GR&&(t.mapping=P2)}function DZ(t,e,i){let r=new ri(t,e,{magFilter:me,minFilter:me,generateMipmaps:!1,type:ai,format:on,colorSpace:Xu,depthBuffer:i});return r.texture.mapping=R2,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function G4(t){let e=new Re;return e.depthTest=!1,e.depthWrite=!1,e.blending=cr,e.name=`PMREM_${t}`,e}function NZ(t){let e=G4("cubemap");return e.fragmentNode=Ha(t,iS),e}function OZ(t){let e=G4("equirect");return e.fragmentNode=Di(t,JP(iS),0),e}function IZ(t){return Object.freeze({isMaterial:!0,isDrawState:!0,id:t.id,name:t.name,type:t.type,transparent:t.transparent,blending:t.blending,premultipliedAlpha:t.premultipliedAlpha,blendSrc:t.blendSrc,blendDst:t.blendDst,blendEquation:t.blendEquation,blendSrcAlpha:t.blendSrcAlpha,blendDstAlpha:t.blendDstAlpha,blendEquationAlpha:t.blendEquationAlpha,blendColor:t.blendColor,blendAlpha:t.blendAlpha,colorWrite:t.colorWrite,depthWrite:t.depthWrite,depthTest:t.depthTest,depthFunc:t.depthFunc,stencilWrite:t.stencilWrite,stencilFunc:t.stencilFunc,stencilRef:t.stencilRef,stencilFail:t.stencilFail,stencilZFail:t.stencilZFail,stencilZPass:t.stencilZPass,stencilFuncMask:t.stencilFuncMask,stencilWriteMask:t.stencilWriteMask,side:t.side,wireframe:t.wireframe===!0,alphaToCoverage:t.alphaToCoverage,forceSinglePass:t.forceSinglePass,polygonOffset:t.polygonOffset,polygonOffsetFactor:t.polygonOffsetFactor,polygonOffsetUnits:t.polygonOffsetUnits})}function BZ(t,e){if(t===null||e===null)return t===e;for(let i in t)if(t[i]!==e[i])return!1;return!0}function X0t(t){return t.index!==null?t.index.version:t.attributes.position.version}function Y0t(t){return t.index!==null?t.index.id:t.attributes.position.id}function VZ(t){let e=[],i=t.index,r=t.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],u=n[a+1],h=n[a+2];e.push(l,u,u,h,h,l)}}else for(let n=0,a=r.array.length/3-1;n<a;n+=3){let o=n+0,l=n+1,u=n+2;e.push(o,l,l,u,u,o)}let s=new(r.count>=65535?hm:y8)(e,1);return s.version=X0t(t),s.__id=Y0t(t),s}function UAt(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?t.z-e.z:t.id-e.id}function kZ(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function zZ(t){return!!(t.transparent===!0||t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode||t.backdropNode&&t.backdropNode.isNode)}function LZ(t){return(t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode)&&t.side===Rn&&t.forceSinglePass===!1}function FZ(t,e=null,i=null){if(e&&e.isNode){let r=e;e=()=>r}return new gW(new Map([[t,e]]),i)}function UZ(t,e=null){let i=new Map;for(let[r,s]of t){let n=s!==null?typeof s=="function"?s:()=>s:null;i.set(r,n)}return new gW(i,e)}function jZ(t,e){for(let i=0;i<t.length;i++)if(t[i].name===e)return i;return-1}function jAt(t,e=null){return rc(e,{getUV:typeof t=="function"?t:()=>t})}function K0t(t){let e=qj.get(t);return e===void 0&&(e={},qj.set(t,e)),e}function GZ(t,e=0){let i=K0t(t),r=i[e];return r===void 0&&(i[e]=r=new _t,i[e].copy(t.matrixWorld)),r}function PI(t){let e,i=t.context.getViewZ;return i!==void 0&&(e=i(this)),(e||xs.z).negate()}function rD(t){let e=(qz=qz||new WeakMap).get(t);return e===void 0&&qz.set(t,e={}),e}function KP(t){let e=rD(t);return e.shadowMatrix||(e.shadowMatrix=we("mat4").setGroup(Ce).onRenderUpdate(i=>((t.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(t.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(t.shadow.camera.coordinateSystem=i.camera.coordinateSystem,t.shadow.camera.updateProjectionMatrix()),t.shadow.updateMatrices(t)),t.shadow.matrix)))}function WZ(t,e=Nh){let i=KP(t).mul(e);return i.xyz.div(i.w)}function RI(t){let e=rD(t);return e.position||(e.position=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.matrixWorld)))}function qZ(t){let e=rD(t);return e.targetPosition||(e.targetPosition=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.target.matrixWorld)))}function DI(t){let e=rD(t);return e.viewPosition||(e.viewPosition=we(new P).setGroup(Ce).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new P,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}))}function mW(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new ae),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function Z0t(t,e){return e=mW(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function Q0t(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function fW(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function J0t(t,e){return e=fW(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function tyt(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function GAt(t,e,i={}){return fW(e,i=mW(t,i))}function HZ(t,e,i){return J0t(e,i=Z0t(t,i))}function $Z(t,e,i){Q0t(t,i),tyt(e,i)}function XZ(t){return t+(sc-t%sc)%sc}function K0(){return rR===null&&((rR=new br(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),rR}function du(t,e){sR[0]=e,t.queue.submit(sR),sR[0]=null}function YZ(t,e,i,r,s,n,a,o,l,u){Aa.texture=e,Aa.mipLevel=i,Aa.origin.z=r,Uu.offset=r*n,Uu.bytesPerRow=a,Uu.rowsPerImage=o,Ta.width=l,Ta.height=u,t.queue.writeTexture(Aa,s.data,Uu,Ta),Aa.reset(),Uu.reset(),Ta.reset()}function NI(t,e){let i,r=t.format,s=t.type,n=t.normalized,a=t.colorSpace,o=Zi.getTransfer(a),l=!1;if(n&&(l=e.features.has(rS.TextureFormatsTier1),l===!1&&ne("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),t.isCompressedTexture===!0||t.isCompressedArrayTexture===!0)switch(r){case kct:case zct:i=o===Sr?tt.BC1RGBAUnormSRGB:tt.BC1RGBAUnorm;break;case Lct:i=o===Sr?tt.BC2RGBAUnormSRGB:tt.BC2RGBAUnorm;break;case Fct:i=o===Sr?tt.BC3RGBAUnormSRGB:tt.BC3RGBAUnorm;break;case upt:i=tt.BC4RUnorm;break;case dpt:i=tt.BC4RSnorm;break;case W7:i=tt.BC5RGUnorm;break;case cpt:i=tt.BC5RGSnorm;break;case opt:i=o===Sr?tt.BC7RGBAUnormSRGB:tt.BC7RGBAUnorm;break;case lpt:i=tt.BC6HRGBFloat;break;case hpt:i=tt.BC6HRGBUFloat;break;case jct:case Uct:i=o===Sr?tt.ETC2RGB8UnormSRGB:tt.ETC2RGB8Unorm;break;case Gct:i=o===Sr?tt.ETC2RGBA8UnormSRGB:tt.ETC2RGBA8Unorm;break;case Wct:i=tt.EACR11Unorm;break;case qct:i=tt.EACR11Snorm;break;case G7:i=tt.EACRG11Unorm;break;case Hct:i=tt.EACRG11Snorm;break;case $ct:i=o===Sr?tt.ASTC4x4UnormSRGB:tt.ASTC4x4Unorm;break;case Xct:i=o===Sr?tt.ASTC5x4UnormSRGB:tt.ASTC5x4Unorm;break;case Yct:i=o===Sr?tt.ASTC5x5UnormSRGB:tt.ASTC5x5Unorm;break;case Kct:i=o===Sr?tt.ASTC6x5UnormSRGB:tt.ASTC6x5Unorm;break;case Zct:i=o===Sr?tt.ASTC6x6UnormSRGB:tt.ASTC6x6Unorm;break;case Qct:i=o===Sr?tt.ASTC8x5UnormSRGB:tt.ASTC8x5Unorm;break;case Jct:i=o===Sr?tt.ASTC8x6UnormSRGB:tt.ASTC8x6Unorm;break;case tpt:i=o===Sr?tt.ASTC8x8UnormSRGB:tt.ASTC8x8Unorm;break;case ept:i=o===Sr?tt.ASTC10x5UnormSRGB:tt.ASTC10x5Unorm;break;case ipt:i=o===Sr?tt.ASTC10x6UnormSRGB:tt.ASTC10x6Unorm;break;case rpt:i=o===Sr?tt.ASTC10x8UnormSRGB:tt.ASTC10x8Unorm;break;case spt:i=o===Sr?tt.ASTC10x10UnormSRGB:tt.ASTC10x10Unorm;break;case npt:i=o===Sr?tt.ASTC12x10UnormSRGB:tt.ASTC12x10Unorm;break;case apt:i=o===Sr?tt.ASTC12x12UnormSRGB:tt.ASTC12x12Unorm;break;case on:i=o===Sr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case on:switch(s){case D2:i=tt.RGBA8Snorm;break;case N2:i=l?tt.RGBA16Snorm:tt.RGBA16Sint;break;case W1:i=l?tt.RGBA16Unorm:tt.RGBA16Uint;break;case En:i=tt.RGBA32Uint;break;case gl:i=tt.RGBA32Sint;break;case bl:i=o===Sr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;case ai:i=tt.RGBA16Float;break;case Qe:i=tt.RGBA32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case WR:switch(s){case F7:i=tt.RGB9E5UFloat;break;case U7:i=tt.RG11B10UFloat;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Qa:switch(s){case D2:i=tt.R8Snorm;break;case N2:i=l?tt.R16Snorm:tt.R16Sint;break;case W1:i=l?tt.R16Unorm:tt.R16Uint;break;case En:i=tt.R32Uint;break;case gl:i=tt.R32Sint;break;case bl:i=tt.R8Unorm;break;case ai:i=tt.R16Float;break;case Qe:i=tt.R32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case Bo:switch(s){case D2:i=tt.RG8Snorm;break;case N2:i=l?tt.RG16Snorm:tt.RG16Sint;break;case W1:i=l?tt.RG16Unorm:tt.RG16Uint;break;case En:i=tt.RG32Uint;break;case gl:i=tt.RG32Sint;break;case bl:i=tt.RG8Unorm;break;case ai:i=tt.RG16Float;break;case Qe:i=tt.RG32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case Qp:switch(s){case W1:i=tt.Depth16Unorm;break;case En:i=tt.Depth24Plus;break;case Qe:i=tt.Depth32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case nv:switch(s){case O2:i=tt.Depth24PlusStencil8;break;case Qe:e&&e.features.has(rS.Depth32FloatStencil8)===!1&&Xt('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=tt.Depth32FloatStencil8;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case qR:switch(s){case gl:i=tt.R32Sint;break;case En:i=tt.R32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case HR:switch(s){case gl:i=tt.RG32Sint;break;case En:i=tt.RG32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case j7:switch(s){case gl:i=tt.RGBA32Sint;break;case En:i=tt.RGBA32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}return i}var KZ,OI,II,BI,ZZ,QZ,ws,of,Z0,Q0,eyt,Pj,lf,Ue,JZ,Fn,VI,y_,v_,hf,tQ,eQ,Ee,Yc,kI,Cr,iQ,rQ,Rj,iyt,ryt,i3,zI,ch,sQ,Jd,W4,nQ,Dj,_v,ph,mh,fh,aQ,oQ,lQ,LI,hQ,uQ,syt,dQ,cQ,pQ,FI,r3,s3,n3,b_,__,UI,a3,js,jI,ve,J0,x_,Kc,ui,te,Gt,o3,mQ,nyt,ty,l3,Te,fQ,GI,U,J,Ut,So,Kt,is,h3,WI,rt,u3,Zc,d3,he,c3,p3,qI,w_,xn,tc,HI,$I,gQ,yQ,ji,cu,Qc,Ei,Jc,m3,gh,pu,S_,uf,To,gd,T_,M_,A_,C_,yd,ey,tp,vd,ep,ip,E_,df,rp,iy,vQ,ry,P_,f3,g3,y3,v3,b3,XI,YI,_3,bQ,Ce,KI,sy,we,ZI,QI,_Q,xQ,wQ,SQ,ys,Ds,Ti,We,Mo,R_,JI,tB,eB,x3,iB,rB,sB,nB,aB,oB,lB,hB,uB,dB,cB,pB,mB,fB,gB,yB,ut,D_,TQ,N_,MQ,AQ,CQ,vB,bB,_B,xB,w3,cf,O_,yh,ka,S3,vh,I_,pa,Ol,za,wB,Il,SB,TB,MB,AB,CB,T3,EB,M3,PB,wr,A3,bh,C3,RB,E3,P3,DB,NB,R3,D3,OB,IB,BB,no,rs,sp,VB,kB,zB,Yo,mu,Ko,N3,LB,O3,FB,UB,jB,GB,I3,vi,Bl,B_,B3,Ao,V3,WB,qB,HB,$B,EQ,PQ,La,k3,rc,XB,ZP,z3,L3,RQ,YB,KB,DQ,np,bd,ZB,QB,JB,F3,U3,NQ,V_,OQ,IQ,tV,BQ,VQ,eV,kQ,iV,rV,Nj,Yd,j3,zQ,l2,QP,hs,sV,Xl,LQ,FQ,UQ,nV,jQ,G3,GQ,tS,lg,WQ,Oj,W3,Co,qQ,HQ,q3,aV,$Q,oV,XQ,YQ,lV,ayt,hV,Fa,$i,ap,H3,uV,$3,_d,KQ,Di,ZQ,vs,QQ,JQ,tJ,X3,vg,eJ,iJ,Un,fu,k_,z_,Hr,Y3,Vl,op,lp,pf,K3,dV,rJ,sJ,Z3,L_,Q3,F_,J3,U_,tA,j_,eA,G_,iA,W_,rA,q_,xd,wd,Sd,Ua,cV,Td,ny,nJ,pV,aJ,mV,Bi,oJ,lJ,hJ,uJ,dJ,cJ,kl,pJ,Zo,mJ,fJ,gJ,yJ,fV,vJ,_h,gV,sA,nA,yV,jn,$r,kp,Nh,aA,xs,gr,vV,oA,hp,bJ,H_,ma,bV,mf,_V,Pi,Md,Ad,xV,lA,_J,xJ,wJ,hA,wV,$_,X_,SV,TV,MV,AV,CV,uA,Ha,SJ,TJ,Y_,Ar,EV,MJ,gu,PV,AJ,CJ,RV,DV,NV,OV,IV,dA,cA,BV,VV,EJ,PJ,K_,Cd,Z_,kV,Q_,RJ,DJ,zV,NJ,up,LV,OJ,FV,pA,UV,mA,IJ,BJ,fA,VJ,kJ,gA,jV,Rt,GV,WV,qV,HV,yA,$V,vA,XV,ay,J_,YV,KV,ZV,QV,JV,tk,ek,ik,rk,sk,nk,ak,ok,lk,hk,uk,dk,ck,bA,_A,xA,tx,wA,pk,mk,SA,fk,ff,gk,Ps,dp,ex,zJ,yk,LJ,FJ,UJ,jJ,GJ,WJ,Kd,q4,vk,TA,MA,bk,_k,qJ,HJ,AA,xk,ix,eS,wk,$J,XJ,Xi,YJ,Sk,CA,Eo,Tk,Mk,Ak,gf,KJ,Ck,ZJ,cp,EA,QJ,PA,JJ,RA,DA,NA,Qo,pp,ttt,Ek,OA,Pk,rx,sx,ett,Rk,IA,nx,itt,xh,rtt,stt,ntt,Dk,Nk,att,ott,Ok,Re,ltt,Ij,htt,Bj,utt,ax,BA,Ik,mp,Bk,dtt,ctt,ptt,oyt,mtt,Vj,JP,VA,Vk,K1,kk,kA,ftt,bg,zk,gtt,kj,yf,fp,ytt,vtt,btt,xv,_tt,zj,xtt,Lj,Lk,zA,Fk,wtt,Uk,Stt,Ttt,LA,Mtt,yu,oy,Att,jk,FA,Ctt,Ett,Ptt,Gk,Rtt,ox,UA,lx,Wk,jA,qk,GA,Hk,$k,Xk,Yk,Kk,WA,Dtt,Zk,Ntt,Ott,Itt,Qk,Jk,Btt,Vtt,ktt,tz,ztt,ez,ly,hy,hx,tR,iz,qA,ux,HA,dx,$A,cx,XA,rz,Ltt,sz,Ftt,Utt,jtt,Gtt,nz,az,uy,YA,oz,Wtt,qtt,Htt,lz,hz,dy,cy,$tt,uz,KA,ZA,QA,Xtt,px,Ytt,JA,iS,Ktt,dz,tC,cz,Fj,pz,Ztt,Qtt,eR,Jtt,Uj,tet,eet,iet,jj,mz,ret,Gj,py,set,iR,net,aet,zS,oet,het,uet,Wj,det,Ed,cet,fz,pet,met,fet,get,yet,gz,vet,Pd,Jo,sc,bet,_et,xet,yz,vz,wet,Tet,bz,Met,Aet,Cet,mx,Eet,vf,Pet,Ret,Det,Net,Oet,Iet,eC,gW,_z,Bet,fx,Vet,ket,zet,Let,Fet,Uet,jet,Get,Wet,xz,gx,wz,qet,Sz,Het,$et,yx,zl,Xet,Yet,Ket,Zet,iC,Qet,Jet,tit,Tz,eit,iit,rit,Mz,sit,nit,ait,vu,oit,lit,hit,Gn,bf,uit,Az,dit,cit,pit,mit,fit,git,yit,vit,bit,Cz,_it,_f,gp,xf,rC,my,vx,wh,fy,bx,gy,_x,xx,xit,wx,Ez,wit,Sit,sC,Tit,Pr,Mit,Ait,Pz,Cit,wf,Eit,Pit,nC,Ll,Rit,Dit,Nit,Oit,Iit,Bit,Vit,aC,Rz,oC,Dz,kit,Nz,zit,Lit,Fit,lC,Uit,jit,Git,Wit,qj,lyt,qit,Hit,$it,Xit,Yit,Kit,Zit,Qit,Jit,trt,hC,ert,irt,Sx,rrt,Tx,Oz,Iz,bu,srt,nrt,art,ort,lrt,Bz,Vz,kz,hrt,zz,urt,drt,crt,Lz,Fz,Xr,Mx,prt,mrt,frt,Uz,jz,grt,yrt,Gz,Wz,vrt,uC,yp,vp,brt,_rt,Ax,xrt,wrt,Srt,Trt,Mrt,dC,Art,Crt,Ert,Prt,Rrt,Drt,vn,Nrt,Sh,Ort,Irt,Brt,Vrt,krt,zrt,Lrt,Frt,Urt,le,jrt,Grt,Wrt,qrt,Hrt,$rt,Xrt,Yrt,Krt,Zrt,Qrt,Jrt,tst,est,ist,rst,sst,nst,ast,ost,lst,hst,ust,dst,cst,qz,cC,pst,mst,fst,gst,yst,pC,yy,mC,vst,bst,fC,Hj,Cx,Hz,$z,Xz,Yz,Kz,Zz,Qz,Sf,Jz,_st,xst,wst,t6,Ex,e6,i6,Sst,r6,vy,gC,Tst,Mst,Ast,Cst,s6,n6,Est,Pst,a6,bp,yC,o6,$j,Rst,Dst,by,Px,Rs,Yr,Nst,Ost,l6,Ist,Bst,h6,Vst,kst,bn,zst,Lst,tl,Fst,Ust,jst,u6,Gst,d6,Po,c6,_y,fa,Th,Wst,qst,Hst,$st,Xst,nr,Yst,Kst,el,Zst,Qst,vC,Jst,tnt,xy,ent,int,rnt,snt,nnt,ant,ont,lnt,hnt,Rx,Dx,Nx,unt,dnt,cnt,pnt,Tf,mnt,fnt,gnt,ynt,vnt,bnt,_nt,xnt,bC,wnt,Snt,Tnt,Mnt,Ant,p6,m6,Cnt,Ent,Pnt,f6,Rnt,Dnt,Nnt,Ont,Int,Bnt,Vnt,knt,znt,Lnt,Fnt,Unt,jnt,Gnt,Wnt,qnt,Hnt,$nt,Xnt,Ynt,Knt,Znt,Qnt,Jnt,tat,eat,iat,rat,sat,nat,aat,oat,lat,hat,uat,dat,cat,g6,D,Fl,pat,mat,_C,fat,y6,gat,v6,yat,vat,bat,xC,_at,Rd,xat,wat,Sat,Tat,Mat,Aat,Cat,Eat,Pat,Rat,Dat,Nat,Oat,Iat,Bat,Vat,kat,b6,_6,zat,Lat,Ox,x6,Fat,w6,Uat,jat,Xj,Yj,h2,Gat,Wat,qat,Hat,wC,Ix,wy,$at,Xat,Yat,il,_u,S6,Kat,SC,TC,Zat,Dd,Qat,T6,Jat,M6,tot,eot,A6,Mf,MC,Bx,Vx,Af,xu,iot,rot,C6,E6,P6,sot,not,aot,oot,lot,R6,hot,uot,rR,AC,dot,D6,CC,Cf,cot,pot,Ef,Mh,Wn,ja,Yi,N6,O6,EC,tt,PC,rl,Ri,_p,I6,Nd,B6,RC,V6,xp,k6,qn,mot,kx,rS,z6,fot,got,yot,vot,sR,bot,L6,Pf,Sy,F6,Ty,My,U6,_ot,j6,DC,NC,Od,Id,zx,OC,IC,Rf,Ay,Lx,Df,bs,xot,wot,Fx,Sot,Tot,Mot,Aot,G6,Ux,Cot,ga,Aa,jx,Uu,Gx,Nf,Bd,Ta,Eot,Pot,Rot,Dot,Not,W6,Oot,Iot,Bot,Vot,q6,BC,H6,kot,zot,$6,Cy,Lot,X6,Fot,ya,VC,Y6,Uot,jot,Got,Ga,Ey,Of,Wot,qot,Hot,$ot,Xot,Py,If,Bf,Ro,Yot,K6,Ah,Kot,Ry,Zot,Qot,Wx,Jot,Ul,Do,Wa,qx,Dy,Hx,$x,sl,Ch,Kr,wu,tlt,elt,ilt,rlt,hyt,uyt,dyt,Hg,sa,nR,Et,bt,Ji,cyt,Kj,pyt,yr,Le,aR,yW,vW,xc,ll,hg,No,oR,vm,myt,fyt,gyt,yyt,Pc,rb,vyt,eh,H4,Ae,byt,_yt,bW,xyt,wyt,Ka,Zr,Syt,kv,zv,sD,Vo,Tyt,kt,Zj,nD,O1,aD,I,ce,Myt,Oi,Ayt,Qj,Ac,bm,_W,uo,Pn,Qr,Wp,Cyt,mt,xW,lR,Eyt,Pyt,Ryt,Zn,Qn,mi,Dyt,Nyt,hR,Lv,oD,mm,wW,Oyt,uR,Iyt,Qt,Byt,ii,Yt,$h,Vyt,kyt,zyt,dR,lD,Lyt,Fv,Fyt,Jj,Uyt,jyt,SW,Oa,LS,Gyt,xe,TW,Rr,Wyt,qyt,Hyt,$yt,Xyt,Yyt,Kyt,hD,Uv,uD,Rc,jv,Go,Lo,Zyt,Qyt,MW,Jyt,FS,t1t,I1,AW,e1t,Og,Ja,Jl,fi,i1t,r1t,$4,Ku,Bn,tr,Z1,t9,xl,Ai,s1t,qp,u2,n1t,a1t,ee,wc,o1t,l1t,CW,X4,Li,gt,US,Hp,bi,h1t,Lr,at,G,lt,u1t,sS,e9,i9,Ig,cc,d1t,B1,cR,mr=j(()=>{dt(),dt(),KZ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],OI=new WeakMap,II=new WeakMap,BI=new WeakMap,ZZ=class{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=KZ,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1&&(this.getRenderObjectData(t),!0)}needsVelocity(t){let e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){let{geometry:i,object:r}=t;if(e={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(e.center=r.center.clone()),r.morphTargetInfluences&&(e.morphTargetInfluences=r.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),t.material.transmission>0){let{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}let{environmentIntensity:s,environmentRotation:n}=t.scene;e.environmentIntensity=s,e.environmentRotation=n.clone(),e.lights=this.getLightsData(t.lightsNode.getLights(),[]),this.renderObjects.set(t,e)}return e}getAttributesData(t){let e={};for(let i in t){let r=t[i];e[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return e}containsNode(t){let e=t.material;for(let i in e)if(e[i]&&e[i].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getGeometryData(t){let e=BI.get(t);return e===void 0&&(e={_renderId:-1,_equal:!1,attributes:this.getAttributesData(t.attributes),indexId:t.index?t.index.id:null,indexVersion:t.index?t.index.version:null,drawRange:{start:t.drawRange.start,count:t.drawRange.count}},BI.set(t,e)),e}getMaterialData(t){let e=II.get(t);if(e===void 0){e={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=t[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?e[i]={id:r.id,version:0}:e[i]=r.clone():e[i]=r)}II.set(t,e)}return e}equals(t,e,i){let{object:r,material:s,geometry:n}=t,a=this.getRenderObjectData(t);if(a.worldMatrix.equals(r.matrixWorld)!==!0)return a.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(t.material);if(o._renderId!==i){o._renderId=i;for(let h in o){let d=o[h],c=s[h];if(h!=="_renderId"&&h!=="_equal"){if(d.equals!==void 0){if(d.equals(c)===!1)return d.copy(c),o._equal=!1,!1}else if(c.isTexture===!0){if(d.id!==c.id||d.version!==c.version)return d.id=c.id,d.version=c.version,o._equal=!1,!1}else if(d!==c)return o[h]=c,o._equal=!1,!1}}if(o.transmission>0){let{width:h,height:d}=t.context;if(a.bufferWidth!==h||a.bufferHeight!==d)return a.bufferWidth=h,a.bufferHeight=d,o._equal=!1,!1}o._equal=!0}else if(o._equal===!1)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;let l=this.getGeometryData(t.geometry);if(l._renderId!==i){l._renderId=i;let h=n.attributes,d=l.attributes,c=0,p=0;for(let b in h)c++;for(let b in d){p++;let _=d[b],x=h[b];if(x===void 0)return delete d[b],l._equal=!1,!1;let S=x.isInterleavedBufferAttribute?x.data.uuid:x.id,w=x.isInterleavedBufferAttribute?x.data.version:x.version;if(_.id!==S||_.version!==w)return _.id=S,_.version=w,l._equal=!1,!1}if(p!==c)return l.attributes=this.getAttributesData(h),l._equal=!1,!1;let m=n.index,f=l.indexId,g=l.indexVersion,y=m?m.id:null,v=m?m.version:null;if(f!==y||g!==v)return l.indexId=y,l.indexVersion=v,l._equal=!1,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let h=!1;for(let d=0;d<a.morphTargetInfluences.length;d++)a.morphTargetInfluences[d]!==r.morphTargetInfluences[d]&&(a.morphTargetInfluences[d]=r.morphTargetInfluences[d],h=!0);if(h)return!1}if(a.lights){for(let h=0;h<e.length;h++)if(a.lights[h].map!==e[h].map)return!1}let u=t.scene;return u.environment===null||s.envMap!==null||a.environmentIntensity===u.environmentIntensity&&a.environmentRotation.equals(u.environmentRotation)!==!1?a.center&&a.center.equals(r.center)===!1?(a.center.copy(r.center),!1):(t.bundle!==null&&(a.version=t.bundle.version),!0):(a.environmentIntensity=u.environmentIntensity,a.environmentRotation.copy(u.environmentRotation),!1)}getLightsData(t,e){e.length=0;for(let i of t)i.isSpotLight===!0&&i.map!==null&&e.push({map:i.map.version});return e}getLights(t,e){let i=OI.get(t);return i===void 0&&(i={renderId:-1,lightsData:[]},OI.set(t,i)),i.renderId===e||(i.renderId=e,this.getLightsData(t.getLights(),i.lightsData)),i.lightsData}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;let{renderId:i}=e;if(this.renderId!==i){this.renderId=i;let a=this.getRenderObjectData(t);if(a.worldMatrix.copy(t.object.matrixWorld),a.morphTargetInfluences){let o=t.object.morphTargetInfluences;for(let l=0;l<a.morphTargetInfluences.length;l++)a.morphTargetInfluences[l]=o[l]}return a.center&&t.object.center&&a.center.copy(t.object.center),!0}let r=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(r||s)return!1;let n=this.getLights(t.lightsNode,i);return this.equals(t,n,i)!==!0}},QZ=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],ws=class{constructor(t=null){this.isStackTrace=!0,this.stack=function(e){let i=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
1550
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),kAt=j(()=>{});function W0t(t){return function(e,{basePath:i,moduleUrl:r,cdnBuild:s}){if(i!==void 0)return{url:`${i}/${e}`};let n=`${s}/${e}`;if(r===void 0||r.startsWith("file:"))return{url:n};let a=r.slice(0,r.lastIndexOf("/")+1)+e;return a===n?{url:a}:{url:a,fallback:n}}(t,{basePath:q0t,moduleUrl:typeof import.meta.url=="string"?import.meta.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.82/build"})}function pZ(t,e){let{url:i,fallback:r}=W0t(e);r!==void 0&&t.addEventListener("error",()=>{t.src=r},{once:!0}),t.src=i}var q0t,dW=j(()=>{kAt()});function H0t(t,e){cW.set(t,e)}function mZ(t){return cW.get(t)}function fZ(t,e){let i=`${e}:${t}`;Cj.has(i)||Cj.add(i)}var cW,Cj,pW=j(()=>{cW=new Map,Cj=new Set});function CI(t,e=0){let i=3735928559^e,r=1103547991^e;if(Array.isArray(t))for(let s,n=0;n<t.length;n++)s=t[n],i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);else for(let s,n=0;n<t.length;n++)s=t.charCodeAt(n),i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function gZ(t){return eyt.get(t)}function QM(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function yZ(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?9:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new ws)}function zAt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?12:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new ws)}function LAt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)||/vec4/.test(t)?4:/mat2/.test(t)?2:/mat3/.test(t)||/mat4/.test(t)?4:void Xt(`TSL: Unsupported type: ${t}`,new ws)}function Xc(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function EI(t,...e){let i=t?t.slice(-4):void 0;return e.length===1&&(i==="vec2"?e=[e[0],e[0]]:i==="vec3"?e=[e[0],e[0],e[0]]:i==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new ae(...e):i==="vec2"?new Q(...e):i==="vec3"?new P(...e):i==="vec4"?new Me(...e):i==="mat2"?new Y7(...e):i==="mat3"?new Ts(...e):i==="mat4"?new _t(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?function(r){return Uint8Array.from(atob(r),s=>s.charCodeAt(0)).buffer}(e[0]):null}function vZ(t){let e=Pj.get(t);return e===void 0&&(e={},Pj.set(t,e)),e}function At(t,e){if(W4.has(t))ne(`TSL: Redefinition of method chaining '${t}'.`);else{if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);W4.set(t,e),t!=="assign"&&(Ee.prototype[t]=function(...i){return this.isStackNode?this.addToStack(e(...i)):e(this,...i)},Ee.prototype[t+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],e(...i)):this.assign(e(this,...i))})}}function JM(t,e,i){_v[t]=_v[e]=_v[i]={get(){this._cache=this._cache||{};let a=this._cache[t];return a===void 0&&(a=new Rj(this,t),this._cache[t]=a),a},set(a){this[t].assign(ve(a))}};let r=t.toUpperCase(),s=e.toUpperCase(),n=i.toUpperCase();Ee.prototype["set"+r]=Ee.prototype["set"+s]=Ee.prototype["set"+n]=function(a){let o=Dj(t);return new iyt(this,o,ve(a))},Ee.prototype["flip"+r]=Ee.prototype["flip"+s]=Ee.prototype["flip"+n]=function(){let a=Dj(t);return new ryt(this,a)}}function bZ(t){return t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)}function X0(t){return t&&t.isNode&&t.traverse(e=>{e.isConstNode&&(t=e.value)}),Boolean(t)}function Y0(t,e){return new syt(t,e)}function it(t,e=null){let i=new nyt(t,e);return new Proxy(()=>{},{apply:(r,s,n)=>i.call(...n),get:(r,s,n)=>Reflect.get(i,s,n),set:(r,s,n,a)=>Reflect.set(i,s,n,a)})}function t3(t){return Jd&&Jd.addToStack(t),t}function _Z(t,e,i=null){return rc(i,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(t):s})}function xZ(t,e=null){return rc(e,{getAO:(i,{material:r})=>r.transparent===!0?i:i!==null?i.mul(t):t})}function wZ(t,e){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),ZP(t,e)}function SZ(t,e){let i=Nj.get(t);return i===void 0&&(i=new q1(t,e),Nj.set(t,i)),i}function e3(t,e=null,i=0,r=0,s=_g,n=!1){return e==="mat3"||e===null&&t.itemSize===9?xn(new Yd(t,"vec3",9,0).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,3).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&t.itemSize===16?tc(new Yd(t,"vec4",16,0).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,4).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,8).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,12).setUsage(s).setInstanced(n)):new Yd(t,e,i,r).setUsage(s)}function TZ(t,e=!0){return ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),lg(t).setParent(e)}function MZ(t,e,i,r=U(0),s=U(1)){return Oj(t,e,i,r,s,!0)}function AZ(t,e="",i=null){return(t=ve(t)).before(new ayt(t,e,i))}function FAt(t){ne("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}function CZ(t,e,i){let r;if(e.isStorageInstancedBufferAttribute===!0)r=Kd(e,"mat4",Math.max(i,1)).element(Xl);else if(16*i*4<=t.getUniformBufferLimit())r=vg(e.array,"mat4",Math.max(i,1)).element(Xl);else{let s=q4.get(e);s||(s=new X7(e.array,16,1),q4.set(e,s));let n=e.usage===Yh?QP:l2,a=[n(s,"vec4",16,0),n(s,"vec4",16,4),n(s,"vec4",16,8),n(s,"vec4",16,12)];r=tc(...a)}return r}function Ej(t,e,i,r,s,n){let a=t.element(s.x),o=t.element(s.y),l=t.element(s.z),u=t.element(s.w),h=i.mul(e),d=Ds(a.mul(n.x).mul(h),o.mul(n.y).mul(h),l.mul(n.z).mul(h),u.mul(n.w).mul(h));return r.mul(d).xyz}function EZ(t,e,i,r,s,n,a){let o=t.element(n.x),l=t.element(n.y),u=t.element(n.z),h=t.element(n.w),d=Ds(a.x.mul(o),a.y.mul(l),a.z.mul(u),a.w.mul(h));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(e).xyz,skinTangent:d.transformDirection(i).xyz}}function PZ(t,e,i,r,s){let n=t.skeleton,a=eS.get(n);if(a===void 0){n.update();let o=new Float32Array(n.boneMatrices);a={previousBoneMatrices:o,node:vg(o,"mat4",n.bones.length)},eS.set(n,a)}return Ej(a.node,kp,e,i,r,s)}function $0t(t){let e=t.target;e.removeEventListener("dispose",$0t);let i=K1.get(e);i!==void 0&&(K1.delete(e),i.dispose())}function RZ(t,e){e===jR?t.mapping=kg:e===GR&&(t.mapping=P2)}function DZ(t,e,i){let r=new ri(t,e,{magFilter:me,minFilter:me,generateMipmaps:!1,type:ai,format:on,colorSpace:Xu,depthBuffer:i});return r.texture.mapping=R2,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function G4(t){let e=new Re;return e.depthTest=!1,e.depthWrite=!1,e.blending=cr,e.name=`PMREM_${t}`,e}function NZ(t){let e=G4("cubemap");return e.fragmentNode=Ha(t,iS),e}function OZ(t){let e=G4("equirect");return e.fragmentNode=Di(t,JP(iS),0),e}function IZ(t){return Object.freeze({isMaterial:!0,isDrawState:!0,id:t.id,name:t.name,type:t.type,transparent:t.transparent,blending:t.blending,premultipliedAlpha:t.premultipliedAlpha,blendSrc:t.blendSrc,blendDst:t.blendDst,blendEquation:t.blendEquation,blendSrcAlpha:t.blendSrcAlpha,blendDstAlpha:t.blendDstAlpha,blendEquationAlpha:t.blendEquationAlpha,blendColor:t.blendColor,blendAlpha:t.blendAlpha,colorWrite:t.colorWrite,depthWrite:t.depthWrite,depthTest:t.depthTest,depthFunc:t.depthFunc,stencilWrite:t.stencilWrite,stencilFunc:t.stencilFunc,stencilRef:t.stencilRef,stencilFail:t.stencilFail,stencilZFail:t.stencilZFail,stencilZPass:t.stencilZPass,stencilFuncMask:t.stencilFuncMask,stencilWriteMask:t.stencilWriteMask,side:t.side,wireframe:t.wireframe===!0,alphaToCoverage:t.alphaToCoverage,forceSinglePass:t.forceSinglePass,polygonOffset:t.polygonOffset,polygonOffsetFactor:t.polygonOffsetFactor,polygonOffsetUnits:t.polygonOffsetUnits})}function BZ(t,e){if(t===null||e===null)return t===e;for(let i in t)if(t[i]!==e[i])return!1;return!0}function X0t(t){return t.index!==null?t.index.version:t.attributes.position.version}function Y0t(t){return t.index!==null?t.index.id:t.attributes.position.id}function VZ(t){let e=[],i=t.index,r=t.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],u=n[a+1],h=n[a+2];e.push(l,u,u,h,h,l)}}else for(let n=0,a=r.array.length/3-1;n<a;n+=3){let o=n+0,l=n+1,u=n+2;e.push(o,l,l,u,u,o)}let s=new(r.count>=65535?hm:y8)(e,1);return s.version=X0t(t),s.__id=Y0t(t),s}function UAt(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?t.z-e.z:t.id-e.id}function kZ(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function zZ(t){return!!(t.transparent===!0||t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode||t.backdropNode&&t.backdropNode.isNode)}function LZ(t){return(t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode)&&t.side===Rn&&t.forceSinglePass===!1}function FZ(t,e=null,i=null){if(e&&e.isNode){let r=e;e=()=>r}return new gW(new Map([[t,e]]),i)}function UZ(t,e=null){let i=new Map;for(let[r,s]of t){let n=s!==null?typeof s=="function"?s:()=>s:null;i.set(r,n)}return new gW(i,e)}function jZ(t,e){for(let i=0;i<t.length;i++)if(t[i].name===e)return i;return-1}function jAt(t,e=null){return rc(e,{getUV:typeof t=="function"?t:()=>t})}function K0t(t){let e=qj.get(t);return e===void 0&&(e={},qj.set(t,e)),e}function GZ(t,e=0){let i=K0t(t),r=i[e];return r===void 0&&(i[e]=r=new _t,i[e].copy(t.matrixWorld)),r}function PI(t){let e,i=t.context.getViewZ;return i!==void 0&&(e=i(this)),(e||xs.z).negate()}function rD(t){let e=(qz=qz||new WeakMap).get(t);return e===void 0&&qz.set(t,e={}),e}function KP(t){let e=rD(t);return e.shadowMatrix||(e.shadowMatrix=we("mat4").setGroup(Ce).onRenderUpdate(i=>((t.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(t.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(t.shadow.camera.coordinateSystem=i.camera.coordinateSystem,t.shadow.camera.updateProjectionMatrix()),t.shadow.updateMatrices(t)),t.shadow.matrix)))}function WZ(t,e=Nh){let i=KP(t).mul(e);return i.xyz.div(i.w)}function RI(t){let e=rD(t);return e.position||(e.position=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.matrixWorld)))}function qZ(t){let e=rD(t);return e.targetPosition||(e.targetPosition=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.target.matrixWorld)))}function DI(t){let e=rD(t);return e.viewPosition||(e.viewPosition=we(new P).setGroup(Ce).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new P,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}))}function mW(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new ae),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function Z0t(t,e){return e=mW(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function Q0t(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function fW(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function J0t(t,e){return e=fW(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function tyt(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function GAt(t,e,i={}){return fW(e,i=mW(t,i))}function HZ(t,e,i){return J0t(e,i=Z0t(t,i))}function $Z(t,e,i){Q0t(t,i),tyt(e,i)}function XZ(t){return t+(sc-t%sc)%sc}function K0(){return rR===null&&((rR=new br(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),rR}function du(t,e){sR[0]=e,t.queue.submit(sR),sR[0]=null}function YZ(t,e,i,r,s,n,a,o,l,u){Aa.texture=e,Aa.mipLevel=i,Aa.origin.z=r,Uu.offset=r*n,Uu.bytesPerRow=a,Uu.rowsPerImage=o,Ta.width=l,Ta.height=u,t.queue.writeTexture(Aa,s.data,Uu,Ta),Aa.reset(),Uu.reset(),Ta.reset()}function NI(t,e){let i,r=t.format,s=t.type,n=t.normalized,a=t.colorSpace,o=Zi.getTransfer(a),l=!1;if(n&&(l=e.features.has(rS.TextureFormatsTier1),l===!1&&ne("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),t.isCompressedTexture===!0||t.isCompressedArrayTexture===!0)switch(r){case kct:case zct:i=o===Sr?tt.BC1RGBAUnormSRGB:tt.BC1RGBAUnorm;break;case Lct:i=o===Sr?tt.BC2RGBAUnormSRGB:tt.BC2RGBAUnorm;break;case Fct:i=o===Sr?tt.BC3RGBAUnormSRGB:tt.BC3RGBAUnorm;break;case upt:i=tt.BC4RUnorm;break;case dpt:i=tt.BC4RSnorm;break;case W7:i=tt.BC5RGUnorm;break;case cpt:i=tt.BC5RGSnorm;break;case opt:i=o===Sr?tt.BC7RGBAUnormSRGB:tt.BC7RGBAUnorm;break;case lpt:i=tt.BC6HRGBFloat;break;case hpt:i=tt.BC6HRGBUFloat;break;case jct:case Uct:i=o===Sr?tt.ETC2RGB8UnormSRGB:tt.ETC2RGB8Unorm;break;case Gct:i=o===Sr?tt.ETC2RGBA8UnormSRGB:tt.ETC2RGBA8Unorm;break;case Wct:i=tt.EACR11Unorm;break;case qct:i=tt.EACR11Snorm;break;case G7:i=tt.EACRG11Unorm;break;case Hct:i=tt.EACRG11Snorm;break;case $ct:i=o===Sr?tt.ASTC4x4UnormSRGB:tt.ASTC4x4Unorm;break;case Xct:i=o===Sr?tt.ASTC5x4UnormSRGB:tt.ASTC5x4Unorm;break;case Yct:i=o===Sr?tt.ASTC5x5UnormSRGB:tt.ASTC5x5Unorm;break;case Kct:i=o===Sr?tt.ASTC6x5UnormSRGB:tt.ASTC6x5Unorm;break;case Zct:i=o===Sr?tt.ASTC6x6UnormSRGB:tt.ASTC6x6Unorm;break;case Qct:i=o===Sr?tt.ASTC8x5UnormSRGB:tt.ASTC8x5Unorm;break;case Jct:i=o===Sr?tt.ASTC8x6UnormSRGB:tt.ASTC8x6Unorm;break;case tpt:i=o===Sr?tt.ASTC8x8UnormSRGB:tt.ASTC8x8Unorm;break;case ept:i=o===Sr?tt.ASTC10x5UnormSRGB:tt.ASTC10x5Unorm;break;case ipt:i=o===Sr?tt.ASTC10x6UnormSRGB:tt.ASTC10x6Unorm;break;case rpt:i=o===Sr?tt.ASTC10x8UnormSRGB:tt.ASTC10x8Unorm;break;case spt:i=o===Sr?tt.ASTC10x10UnormSRGB:tt.ASTC10x10Unorm;break;case npt:i=o===Sr?tt.ASTC12x10UnormSRGB:tt.ASTC12x10Unorm;break;case apt:i=o===Sr?tt.ASTC12x12UnormSRGB:tt.ASTC12x12Unorm;break;case on:i=o===Sr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case on:switch(s){case D2:i=tt.RGBA8Snorm;break;case N2:i=l?tt.RGBA16Snorm:tt.RGBA16Sint;break;case W1:i=l?tt.RGBA16Unorm:tt.RGBA16Uint;break;case En:i=tt.RGBA32Uint;break;case gl:i=tt.RGBA32Sint;break;case bl:i=o===Sr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;case ai:i=tt.RGBA16Float;break;case Qe:i=tt.RGBA32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case WR:switch(s){case F7:i=tt.RGB9E5UFloat;break;case U7:i=tt.RG11B10UFloat;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Qa:switch(s){case D2:i=tt.R8Snorm;break;case N2:i=l?tt.R16Snorm:tt.R16Sint;break;case W1:i=l?tt.R16Unorm:tt.R16Uint;break;case En:i=tt.R32Uint;break;case gl:i=tt.R32Sint;break;case bl:i=tt.R8Unorm;break;case ai:i=tt.R16Float;break;case Qe:i=tt.R32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case Bo:switch(s){case D2:i=tt.RG8Snorm;break;case N2:i=l?tt.RG16Snorm:tt.RG16Sint;break;case W1:i=l?tt.RG16Unorm:tt.RG16Uint;break;case En:i=tt.RG32Uint;break;case gl:i=tt.RG32Sint;break;case bl:i=tt.RG8Unorm;break;case ai:i=tt.RG16Float;break;case Qe:i=tt.RG32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case Qp:switch(s){case W1:i=tt.Depth16Unorm;break;case En:i=tt.Depth24Plus;break;case Qe:i=tt.Depth32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case nv:switch(s){case O2:i=tt.Depth24PlusStencil8;break;case Qe:e&&e.features.has(rS.Depth32FloatStencil8)===!1&&Xt('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=tt.Depth32FloatStencil8;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case qR:switch(s){case gl:i=tt.R32Sint;break;case En:i=tt.R32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case HR:switch(s){case gl:i=tt.RG32Sint;break;case En:i=tt.RG32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case j7:switch(s){case gl:i=tt.RGBA32Sint;break;case En:i=tt.RGBA32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}return i}var KZ,OI,II,BI,ZZ,QZ,ws,of,Z0,Q0,eyt,Pj,lf,Ue,JZ,Fn,VI,y_,v_,hf,tQ,eQ,Ee,Yc,kI,Cr,iQ,rQ,Rj,iyt,ryt,i3,zI,ch,sQ,Jd,W4,nQ,Dj,_v,ph,mh,fh,aQ,oQ,lQ,LI,hQ,uQ,syt,dQ,cQ,pQ,FI,r3,s3,n3,b_,__,UI,a3,js,jI,ve,J0,x_,Kc,ui,te,Gt,o3,mQ,nyt,ty,l3,Te,fQ,GI,U,J,Ut,So,Kt,is,h3,WI,rt,u3,Zc,d3,he,c3,p3,qI,w_,xn,tc,HI,$I,gQ,yQ,ji,cu,Qc,Ei,Jc,m3,gh,pu,S_,uf,To,gd,T_,M_,A_,C_,yd,ey,tp,vd,ep,ip,E_,df,rp,iy,vQ,ry,P_,f3,g3,y3,v3,b3,XI,YI,_3,bQ,Ce,KI,sy,we,ZI,QI,_Q,xQ,wQ,SQ,ys,Ds,Ti,We,Mo,R_,JI,tB,eB,x3,iB,rB,sB,nB,aB,oB,lB,hB,uB,dB,cB,pB,mB,fB,gB,yB,ut,D_,TQ,N_,MQ,AQ,CQ,vB,bB,_B,xB,w3,cf,O_,yh,ka,S3,vh,I_,pa,Ol,za,wB,Il,SB,TB,MB,AB,CB,T3,EB,M3,PB,wr,A3,bh,C3,RB,E3,P3,DB,NB,R3,D3,OB,IB,BB,no,rs,sp,VB,kB,zB,Yo,mu,Ko,N3,LB,O3,FB,UB,jB,GB,I3,vi,Bl,B_,B3,Ao,V3,WB,qB,HB,$B,EQ,PQ,La,k3,rc,XB,ZP,z3,L3,RQ,YB,KB,DQ,np,bd,ZB,QB,JB,F3,U3,NQ,V_,OQ,IQ,tV,BQ,VQ,eV,kQ,iV,rV,Nj,Yd,j3,zQ,l2,QP,hs,sV,Xl,LQ,FQ,UQ,nV,jQ,G3,GQ,tS,lg,WQ,Oj,W3,Co,qQ,HQ,q3,aV,$Q,oV,XQ,YQ,lV,ayt,hV,Fa,$i,ap,H3,uV,$3,_d,KQ,Di,ZQ,vs,QQ,JQ,tJ,X3,vg,eJ,iJ,Un,fu,k_,z_,Hr,Y3,Vl,op,lp,pf,K3,dV,rJ,sJ,Z3,L_,Q3,F_,J3,U_,tA,j_,eA,G_,iA,W_,rA,q_,xd,wd,Sd,Ua,cV,Td,ny,nJ,pV,aJ,mV,Bi,oJ,lJ,hJ,uJ,dJ,cJ,kl,pJ,Zo,mJ,fJ,gJ,yJ,fV,vJ,_h,gV,sA,nA,yV,jn,$r,kp,Nh,aA,xs,gr,vV,oA,hp,bJ,H_,ma,bV,mf,_V,Pi,Md,Ad,xV,lA,_J,xJ,wJ,hA,wV,$_,X_,SV,TV,MV,AV,CV,uA,Ha,SJ,TJ,Y_,Ar,EV,MJ,gu,PV,AJ,CJ,RV,DV,NV,OV,IV,dA,cA,BV,VV,EJ,PJ,K_,Cd,Z_,kV,Q_,RJ,DJ,zV,NJ,up,LV,OJ,FV,pA,UV,mA,IJ,BJ,fA,VJ,kJ,gA,jV,Rt,GV,WV,qV,HV,yA,$V,vA,XV,ay,J_,YV,KV,ZV,QV,JV,tk,ek,ik,rk,sk,nk,ak,ok,lk,hk,uk,dk,ck,bA,_A,xA,tx,wA,pk,mk,SA,fk,ff,gk,Ps,dp,ex,zJ,yk,LJ,FJ,UJ,jJ,GJ,WJ,Kd,q4,vk,TA,MA,bk,_k,qJ,HJ,AA,xk,ix,eS,wk,$J,XJ,Xi,YJ,Sk,CA,Eo,Tk,Mk,Ak,gf,KJ,Ck,ZJ,cp,EA,QJ,PA,JJ,RA,DA,NA,Qo,pp,ttt,Ek,OA,Pk,rx,sx,ett,Rk,IA,nx,itt,xh,rtt,stt,ntt,Dk,Nk,att,ott,Ok,Re,ltt,Ij,htt,Bj,utt,ax,BA,Ik,mp,Bk,dtt,ctt,ptt,oyt,mtt,Vj,JP,VA,Vk,K1,kk,kA,ftt,bg,zk,gtt,kj,yf,fp,ytt,vtt,btt,xv,_tt,zj,xtt,Lj,Lk,zA,Fk,wtt,Uk,Stt,Ttt,LA,Mtt,yu,oy,Att,jk,FA,Ctt,Ett,Ptt,Gk,Rtt,ox,UA,lx,Wk,jA,qk,GA,Hk,$k,Xk,Yk,Kk,WA,Dtt,Zk,Ntt,Ott,Itt,Qk,Jk,Btt,Vtt,ktt,tz,ztt,ez,ly,hy,hx,tR,iz,qA,ux,HA,dx,$A,cx,XA,rz,Ltt,sz,Ftt,Utt,jtt,Gtt,nz,az,uy,YA,oz,Wtt,qtt,Htt,lz,hz,dy,cy,$tt,uz,KA,ZA,QA,Xtt,px,Ytt,JA,iS,Ktt,dz,tC,cz,Fj,pz,Ztt,Qtt,eR,Jtt,Uj,tet,eet,iet,jj,mz,ret,Gj,py,set,iR,net,aet,zS,oet,het,uet,Wj,det,Ed,cet,fz,pet,met,fet,get,yet,gz,vet,Pd,Jo,sc,bet,_et,xet,yz,vz,wet,Tet,bz,Met,Aet,Cet,mx,Eet,vf,Pet,Ret,Det,Net,Oet,Iet,eC,gW,_z,Bet,fx,Vet,ket,zet,Let,Fet,Uet,jet,Get,Wet,xz,gx,wz,qet,Sz,Het,$et,yx,zl,Xet,Yet,Ket,Zet,iC,Qet,Jet,tit,Tz,eit,iit,rit,Mz,sit,nit,ait,vu,oit,lit,hit,Gn,bf,uit,Az,dit,cit,pit,mit,fit,git,yit,vit,bit,Cz,_it,_f,gp,xf,rC,my,vx,wh,fy,bx,gy,_x,xx,xit,wx,Ez,wit,Sit,sC,Tit,Pr,Mit,Ait,Pz,Cit,wf,Eit,Pit,nC,Ll,Rit,Dit,Nit,Oit,Iit,Bit,Vit,aC,Rz,oC,Dz,kit,Nz,zit,Lit,Fit,lC,Uit,jit,Git,Wit,qj,lyt,qit,Hit,$it,Xit,Yit,Kit,Zit,Qit,Jit,trt,hC,ert,irt,Sx,rrt,Tx,Oz,Iz,bu,srt,nrt,art,ort,lrt,Bz,Vz,kz,hrt,zz,urt,drt,crt,Lz,Fz,Xr,Mx,prt,mrt,frt,Uz,jz,grt,yrt,Gz,Wz,vrt,uC,yp,vp,brt,_rt,Ax,xrt,wrt,Srt,Trt,Mrt,dC,Art,Crt,Ert,Prt,Rrt,Drt,vn,Nrt,Sh,Ort,Irt,Brt,Vrt,krt,zrt,Lrt,Frt,Urt,le,jrt,Grt,Wrt,qrt,Hrt,$rt,Xrt,Yrt,Krt,Zrt,Qrt,Jrt,tst,est,ist,rst,sst,nst,ast,ost,lst,hst,ust,dst,cst,qz,cC,pst,mst,fst,gst,yst,pC,yy,mC,vst,bst,fC,Hj,Cx,Hz,$z,Xz,Yz,Kz,Zz,Qz,Sf,Jz,_st,xst,wst,t6,Ex,e6,i6,Sst,r6,vy,gC,Tst,Mst,Ast,Cst,s6,n6,Est,Pst,a6,bp,yC,o6,$j,Rst,Dst,by,Px,Rs,Yr,Nst,Ost,l6,Ist,Bst,h6,Vst,kst,bn,zst,Lst,tl,Fst,Ust,jst,u6,Gst,d6,Po,c6,_y,fa,Th,Wst,qst,Hst,$st,Xst,nr,Yst,Kst,el,Zst,Qst,vC,Jst,tnt,xy,ent,int,rnt,snt,nnt,ant,ont,lnt,hnt,Rx,Dx,Nx,unt,dnt,cnt,pnt,Tf,mnt,fnt,gnt,ynt,vnt,bnt,_nt,xnt,bC,wnt,Snt,Tnt,Mnt,Ant,p6,m6,Cnt,Ent,Pnt,f6,Rnt,Dnt,Nnt,Ont,Int,Bnt,Vnt,knt,znt,Lnt,Fnt,Unt,jnt,Gnt,Wnt,qnt,Hnt,$nt,Xnt,Ynt,Knt,Znt,Qnt,Jnt,tat,eat,iat,rat,sat,nat,aat,oat,lat,hat,uat,dat,cat,g6,D,Fl,pat,mat,_C,fat,y6,gat,v6,yat,vat,bat,xC,_at,Rd,xat,wat,Sat,Tat,Mat,Aat,Cat,Eat,Pat,Rat,Dat,Nat,Oat,Iat,Bat,Vat,kat,b6,_6,zat,Lat,Ox,x6,Fat,w6,Uat,jat,Xj,Yj,h2,Gat,Wat,qat,Hat,wC,Ix,wy,$at,Xat,Yat,il,_u,S6,Kat,SC,TC,Zat,Dd,Qat,T6,Jat,M6,tot,eot,A6,Mf,MC,Bx,Vx,Af,xu,iot,rot,C6,E6,P6,sot,not,aot,oot,lot,R6,hot,uot,rR,AC,dot,D6,CC,Cf,cot,pot,Ef,Mh,Wn,ja,Yi,N6,O6,EC,tt,PC,rl,Ri,_p,I6,Nd,B6,RC,V6,xp,k6,qn,mot,kx,rS,z6,fot,got,yot,vot,sR,bot,L6,Pf,Sy,F6,Ty,My,U6,_ot,j6,DC,NC,Od,Id,zx,OC,IC,Rf,Ay,Lx,Df,bs,xot,wot,Fx,Sot,Tot,Mot,Aot,G6,Ux,Cot,ga,Aa,jx,Uu,Gx,Nf,Bd,Ta,Eot,Pot,Rot,Dot,Not,W6,Oot,Iot,Bot,Vot,q6,BC,H6,kot,zot,$6,Cy,Lot,X6,Fot,ya,VC,Y6,Uot,jot,Got,Ga,Ey,Of,Wot,qot,Hot,$ot,Xot,Py,If,Bf,Ro,Yot,K6,Ah,Kot,Ry,Zot,Qot,Wx,Jot,Ul,Do,Wa,qx,Dy,Hx,$x,sl,Ch,Kr,wu,tlt,elt,ilt,rlt,hyt,uyt,dyt,Hg,sa,nR,Et,bt,Ji,cyt,Kj,pyt,yr,Le,aR,yW,vW,xc,ll,hg,No,oR,vm,myt,fyt,gyt,yyt,Pc,rb,vyt,eh,H4,Ae,byt,_yt,bW,xyt,wyt,Ka,Zr,Syt,kv,zv,sD,Vo,Tyt,kt,Zj,nD,O1,aD,I,ce,Myt,Oi,Ayt,Qj,Ac,bm,_W,uo,Pn,Qr,Wp,Cyt,mt,xW,lR,Eyt,Pyt,Ryt,Zn,Qn,mi,Dyt,Nyt,hR,Lv,oD,mm,wW,Oyt,uR,Iyt,Qt,Byt,ii,Yt,$h,Vyt,kyt,zyt,dR,lD,Lyt,Fv,Fyt,Jj,Uyt,jyt,SW,Oa,LS,Gyt,xe,TW,Rr,Wyt,qyt,Hyt,$yt,Xyt,Yyt,Kyt,hD,Uv,uD,Rc,jv,Go,Lo,Zyt,Qyt,MW,Jyt,FS,t1t,I1,AW,e1t,Og,Ja,Jl,fi,i1t,r1t,$4,Ku,Bn,tr,Z1,t9,xl,Ai,s1t,qp,u2,n1t,a1t,ee,wc,o1t,l1t,CW,X4,Li,gt,US,Hp,bi,h1t,Lr,at,G,lt,u1t,sS,e9,i9,Ig,cc,d1t,B1,cR,mr=j(()=>{dt(),dt(),KZ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],OI=new WeakMap,II=new WeakMap,BI=new WeakMap,ZZ=class{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=KZ,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1&&(this.getRenderObjectData(t),!0)}needsVelocity(t){let e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){let{geometry:i,object:r}=t;if(e={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(e.center=r.center.clone()),r.morphTargetInfluences&&(e.morphTargetInfluences=r.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),t.material.transmission>0){let{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}let{environmentIntensity:s,environmentRotation:n}=t.scene;e.environmentIntensity=s,e.environmentRotation=n.clone(),e.lights=this.getLightsData(t.lightsNode.getLights(),[]),this.renderObjects.set(t,e)}return e}getAttributesData(t){let e={};for(let i in t){let r=t[i];e[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return e}containsNode(t){let e=t.material;for(let i in e)if(e[i]&&e[i].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getGeometryData(t){let e=BI.get(t);return e===void 0&&(e={_renderId:-1,_equal:!1,attributes:this.getAttributesData(t.attributes),indexId:t.index?t.index.id:null,indexVersion:t.index?t.index.version:null,drawRange:{start:t.drawRange.start,count:t.drawRange.count}},BI.set(t,e)),e}getMaterialData(t){let e=II.get(t);if(e===void 0){e={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=t[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?e[i]={id:r.id,version:0}:e[i]=r.clone():e[i]=r)}II.set(t,e)}return e}equals(t,e,i){let{object:r,material:s,geometry:n}=t,a=this.getRenderObjectData(t);if(a.worldMatrix.equals(r.matrixWorld)!==!0)return a.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(t.material);if(o._renderId!==i){o._renderId=i;for(let h in o){let d=o[h],c=s[h];if(h!=="_renderId"&&h!=="_equal"){if(d.equals!==void 0){if(d.equals(c)===!1)return d.copy(c),o._equal=!1,!1}else if(c.isTexture===!0){if(d.id!==c.id||d.version!==c.version)return d.id=c.id,d.version=c.version,o._equal=!1,!1}else if(d!==c)return o[h]=c,o._equal=!1,!1}}if(o.transmission>0){let{width:h,height:d}=t.context;if(a.bufferWidth!==h||a.bufferHeight!==d)return a.bufferWidth=h,a.bufferHeight=d,o._equal=!1,!1}o._equal=!0}else if(o._equal===!1)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;let l=this.getGeometryData(t.geometry);if(l._renderId!==i){l._renderId=i;let h=n.attributes,d=l.attributes,c=0,p=0;for(let b in h)c++;for(let b in d){p++;let _=d[b],x=h[b];if(x===void 0)return delete d[b],l._equal=!1,!1;let S=x.isInterleavedBufferAttribute?x.data.uuid:x.id,w=x.isInterleavedBufferAttribute?x.data.version:x.version;if(_.id!==S||_.version!==w)return _.id=S,_.version=w,l._equal=!1,!1}if(p!==c)return l.attributes=this.getAttributesData(h),l._equal=!1,!1;let m=n.index,f=l.indexId,g=l.indexVersion,y=m?m.id:null,v=m?m.version:null;if(f!==y||g!==v)return l.indexId=y,l.indexVersion=v,l._equal=!1,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let h=!1;for(let d=0;d<a.morphTargetInfluences.length;d++)a.morphTargetInfluences[d]!==r.morphTargetInfluences[d]&&(a.morphTargetInfluences[d]=r.morphTargetInfluences[d],h=!0);if(h)return!1}if(a.lights){for(let h=0;h<e.length;h++)if(a.lights[h].map!==e[h].map)return!1}let u=t.scene;return u.environment===null||s.envMap!==null||a.environmentIntensity===u.environmentIntensity&&a.environmentRotation.equals(u.environmentRotation)!==!1?a.center&&a.center.equals(r.center)===!1?(a.center.copy(r.center),!1):(t.bundle!==null&&(a.version=t.bundle.version),!0):(a.environmentIntensity=u.environmentIntensity,a.environmentRotation.copy(u.environmentRotation),!1)}getLightsData(t,e){e.length=0;for(let i of t)i.isSpotLight===!0&&i.map!==null&&e.push({map:i.map.version});return e}getLights(t,e){let i=OI.get(t);return i===void 0&&(i={renderId:-1,lightsData:[]},OI.set(t,i)),i.renderId===e||(i.renderId=e,this.getLightsData(t.getLights(),i.lightsData)),i.lightsData}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;let{renderId:i}=e;if(this.renderId!==i){this.renderId=i;let a=this.getRenderObjectData(t);if(a.worldMatrix.copy(t.object.matrixWorld),a.morphTargetInfluences){let o=t.object.morphTargetInfluences;for(let l=0;l<a.morphTargetInfluences.length;l++)a.morphTargetInfluences[l]=o[l]}return a.center&&t.object.center&&a.center.copy(t.object.center),!0}let r=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(r||s)return!1;let n=this.getLights(t.lightsNode,i);return this.equals(t,n,i)!==!0}},QZ=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],ws=class{constructor(t=null){this.isStackTrace=!0,this.stack=function(e){let i=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
1551
1551
|
`).map(r=>{let s=r.match(i);if(!s)return null;let n=s[1]||s[2]||"",a=s[3].split("?")[0],o=parseInt(s[4],10),l=parseInt(s[5],10);return{fn:n,file:a.split("/").pop(),line:o,column:l}}).filter(r=>r&&!QZ.some(s=>s.test(r.file)))}(t||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";let t=this.stack[0],e=t.fn;return`${e?`"${e}()" at `:""}"${t.file}:${t.line}"`}getError(t){return this.stack.length===0?t:`${t}
|
|
1552
1552
|
${this.stack.map(e=>{let i=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${i})`:` at ${i}`}).join(`
|
|
1553
1553
|
`)}`}},of=t=>CI(t),Z0=t=>CI(t),Q0=(...t)=>CI(t),eyt=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Pj=new WeakMap,lf={VERTEX:"vertex",FRAGMENT:"fragment"},Ue={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},JZ={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Fn={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},VI=["fragment","vertex"],y_=["setup","analyze","generate"],v_=[...VI,"compute"],hf=["x","y","z","w"],tQ={analyze:"setup",generate:"analyze"},eQ=0,(Ee=class extends Jn{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=Ue.NONE,this.updateBeforeType=Ue.NONE,this.updateAfterType=Ue.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=eQ++,this.stackTrace=null,Ee.captureStackTrace===!0&&(this.stackTrace=new ws)}set needsUpdate(t){t===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=qt.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,Ue.FRAME)}onRenderUpdate(t){return this.onUpdate(t,Ue.RENDER)}onObjectUpdate(t){return this.onUpdate(t,Ue.OBJECT)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let e of this.getChildren())e.traverse(t)}_getChildren(t=new Set){let e=[];t.add(this);for(let i of Object.getOwnPropertyNames(this)){let r=this[i];if(i.startsWith("_")!==!0&&!t.has(r)){if(Array.isArray(r)===!0)for(let s=0;s<r.length;s++){let n=r[s];n&&n.isNode===!0&&e.push({property:i,index:s,childNode:n})}else if(r&&r.isNode===!0)e.push({property:i,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let s in r){if(s.startsWith("_")===!0)continue;let n=r[s];n&&n.isNode===!0&&e.push({property:i,index:s,childNode:n})}}}return e}getCacheKey(t=!1,e=null){if((t=t||this.version!==this._cacheKeyVersion)===!0||this._cacheKey===null){e===null&&(e=new Set);let i=[];for(let{property:r,childNode:s}of this._getChildren(e))i.push(of(r.slice(0,-4)),s.getCacheKey(t,e));this._cacheKey=Q0(Z0(i),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){let e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t,e=null){let i,r=t.getDataFromNode(this);return e!==null?(r.typeFromOutput=r.typeFromOutput||{},i=r.typeFromOutput[e],i===void 0&&(i=this.generateNodeType(t,e),r.typeFromOutput[e]=i)):(i=r.type,i===void 0&&(i=this.generateNodeType(t),r.type=i)),i}generateNodeType(t,e=null){let i=t.getNodeProperties(this);return i.outputNode?i.outputNode.getNodeType(t,e):this.nodeType}getShared(t){let e=this.getHash(t),i=t.getNodeFromHash(e),r=null;if(i&&i!==this)r=i;else if(t.context.overrideNodes){let s=t.context.overrideNodes.get(this);if(s){let n=t.getDataFromNode(this);n.isOverwritten!==!0?(n.isOverwritten=!0,r=s(t).overrideNode(this,null),n.sharedNode=r):r=n.sharedNode}}return r||this}getArrayCount(){return null}setup(t){let e=t.getNodeProperties(this),i=0;for(let r of this.getChildren())e["node"+i++]=r;return e.outputNode||null}analyze(t,e=null){let i=t.increaseUsage(this);if(this.parents===!0){let r=t.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[t.shaderStage]=r.stages[t.shaderStage]||[],r.stages[t.shaderStage].push(e)}if(i===1){let r=t.getNodeProperties(this);for(let s of Object.values(r))s&&s.isNode===!0&&s.build(t,this)}}generate(t,e){let{outputNode:i}=t.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(t,e)}updateBefore(){ne("Abstract function.")}updateAfter(){ne("Abstract function.")}update(){ne("Abstract function.")}before(t){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,e=null){let i=this.getShared(t);if(this!==i)return i.build(t,e);if(this._beforeNodes!==null){let o=this._beforeNodes;this._beforeNodes=null;for(let l of o)l.build(t,e);this._beforeNodes=o}let r=t.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[t.buildStage]=!0;let s=tQ[t.buildStage];if(s&&r.buildStages[s]!==!0){let o=t.getBuildStage();t.setBuildStage(s),this.build(t),t.setBuildStage(o)}t.addChain(this);let n=null,a=t.getBuildStage();if(a==="setup"){t.addNode(this),this.updateReference(t);let o=t.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(t)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let u=t.getNodeProperties(l);u.parents=u.parents||[],u.parents.push(this)}l.build(t)}t.addSequentialNode(this)}n=o.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate"){if(this.generate.length<2){let o=this.getNodeType(t),l=t.getDataFromNode(this);n=l.snippet,n===void 0?l.generated===void 0?(l.generated=!0,n=this.generate(t)||"",l.snippet=n):(ne("Node: Recursion detected.",this),n="/* Recursion detected. */"):l.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,o,e)}else n=this.generate(t,e)||"";n===""&&e!==null&&e!=="void"&&e!=="OutputType"&&(Xt(`TSL: Invalid generated code, expected a "${e}".`),n=t.generateConst(e))}return t.removeChain(this),n}getSerializeChildren(){return this._getChildren()}serialize(t){let e=this.getSerializeChildren(),i={};for(let{property:r,index:s,childNode:n}of e)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=n.toJSON(t.meta).uuid):i[r]=n.toJSON(t.meta).uuid;Object.keys(i).length>0&&(t.inputNodes=i)}deserialize(t){if(t.inputNodes!==void 0){let e=t.meta.nodes;for(let i in t.inputNodes)if(Array.isArray(t.inputNodes[i])){let r=[];for(let s of t.inputNodes[i])r.push(e[s]);this[i]=r}else if(typeof t.inputNodes[i]=="object"){let r={};for(let s in t.inputNodes[i]){let n=t.inputNodes[i][s];r[s]=e[n]}this[i]=r}else{let r=t.inputNodes[i];this[i]=e[r]}}}toJSON(t){let{uuid:e,type:i}=this,r=t===void 0||typeof t=="string";r&&(t={textures:{},images:{},nodes:{}});let s=t.nodes[e];function n(a){let o=[];for(let l in a){let u=a[l];delete u.metadata,o.push(u)}return o}if(s===void 0&&(s={uuid:e,type:i,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(t.nodes[s.uuid]=s),this.serialize(s),delete s.meta),r){let a=n(t.textures),o=n(t.images),l=n(t.nodes);a.length>0&&(s.textures=a),o.length>0&&(s.images=o),l.length>0&&(s.nodes=l)}return s}}).captureStackTrace=!1,Yc=class extends Ee{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}generateNodeType(t){return this.node.getElementType(t)}getMemberType(t,e){return this.node.getMemberType(t,e)}generate(t){let e=this.indexNode.getNodeType(t);return`${this.node.build(t)}[ ${this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint")} ]`}},kI=class extends Ee{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}generateNodeType(t){let e=this.node.getNodeType(t),i=null;for(let r of this.convertTo.split("|"))(i===null||t.getTypeLength(e)===t.getTypeLength(r))&&(i=r);return i}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){let i=this.node,r=this.getNodeType(t),s=i.build(t,r);return t.format(s,r,e)}},Cr=class extends Ee{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){let i=t.getVectorType(this.getNodeType(t,e)),r=t.getDataFromNode(this);if(r.propertyName!==void 0)return t.format(r.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){let s=super.build(t,i),n=t.getVarFromNode(this,null,i),a=t.getPropertyName(n);return t.addLineFlowCode(`${a} = ${s}`,this),r.snippet=s,r.propertyName=a,t.format(r.propertyName,i,e)}}return super.build(t,e)}},iQ=class extends Cr{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}generateNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,i)=>e+t.getTypeLength(i.getNodeType(t)),0))}generate(t,e){let i=this.getNodeType(t),r=t.getTypeLength(i),s=this.nodes,n=t.getComponentType(i),a=[],o=0;for(let u of s){if(o>=r){Xt(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let h,d=u.getNodeType(t),c=t.getTypeLength(d);if(o+c>r&&(Xt(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-o,d=t.getTypeFromLength(c)),o+=c,h=u.build(t,d),t.getComponentType(d)!==n){let p=t.getTypeFromLength(c,n);h=t.format(h,d,p)}a.push(h)}let l=`${t.getType(i)}( ${a.join(", ")} )`;return t.format(l,i,e)}},rQ=hf.join(""),Rj=class extends Ee{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(let e of this.components)t=Math.max(hf.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}generateNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}getScope(){return this.node.getScope()}generate(t,e){let i=this.node,r=t.getTypeLength(i.getNodeType(t)),s=null;if(r>1){let n=null;this.getVectorLength()>=r&&(n=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));let a=i.build(t,n);s=this.components.length===r&&this.components===rQ.slice(0,this.components.length)?t.format(a,n,e):t.format(`${a}.${this.components}`,this.getNodeType(t),e)}else s=i.build(t,e);return s}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}},iyt=class extends Cr{static get type(){return"SetNode"}constructor(t,e,i){super(),this.sourceNode=t,this.components=e,this.targetNode=i}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:i,targetNode:r}=this,s=this.getNodeType(t),n=t.getComponentType(r.getNodeType(t)),a=t.getTypeFromLength(i.length,n),o=r.build(t,a),l=e.build(t,s),u=t.getTypeLength(s),h=[];for(let d=0;d<u;d++){let c=hf[d];c===i[0]?(h.push(o),d+=i.length-1):h.push(l+"."+c)}return`${t.getType(s)}( ${h.join(", ")} )`}},ryt=class extends Cr{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{components:e,sourceNode:i}=this,r=this.getNodeType(t),s=i.build(t),n=t.getVarFromNode(this),a=t.getPropertyName(n);t.addLineFlowCode(a+" = "+s,this);let o=t.getTypeLength(r),l=[],u=0;for(let h=0;h<o;h++){let d=hf[h];d===e[u]?(l.push("1.0 - "+a+"."+d),u++):l.push(a+"."+d)}return`${t.getType(r)}( ${l.join(", ")} )`}},i3=class extends Ee{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}generateNodeType(){return this.nodeType===null?Xc(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Xc(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=function(e){let i="",r=new Uint8Array(e);for(let s=0;s<r.length;s++)i+=String.fromCharCode(r[s]);return btoa(i)}(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?EI(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){ne("Abstract function.")}},zI=/float|u?int/,ch=class extends i3{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let i=this.getNodeType(t);return zI.test(i)&&zI.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),i,e)}},sQ=class extends Ee{static get type(){return"MemberNode"}constructor(t,e){super(),this.structNode=t,this.property=e,this.isMemberNode=!0}hasMember(t){return(!this.structNode.isMemberNode||this.structNode.hasMember(t)!==!1)&&this.structNode.getMemberType(t,this.property)!=="void"}generateNodeType(t){return this.hasMember(t)===!1?"float":this.structNode.getMemberType(t,this.property)}getMemberType(t,e){if(this.hasMember(t)===!1)return"float";let i=this.getNodeType(t);return t.getStructTypeNode(i).getMemberType(t,e)}generate(t){if(this.hasMember(t)===!1){ne(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let e=this.getNodeType(t);return t.generateConst(e)}return this.structNode.build(t)+"."+this.property}},Jd=null,W4=new Map,nQ=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Dj=t=>nQ(t).split("").sort().join(""),Ee.prototype.assign=function(...t){if(this.isStackNode!==!0)return Jd!==null?Jd.assign(this,...t):Xt("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new ws),this;{let e=W4.get("assign");return this.addToStack(e(...t))}},Ee.prototype.toVarIntent=function(){return this},Ee.prototype.get=function(t){return new sQ(this,t)},_v={},ph=["x","y","z","w"],mh=["r","g","b","a"],fh=["s","t","p","q"];for(let t=0;t<4;t++){let e=ph[t],i=mh[t],r=fh[t];JM(e,i,r);for(let s=0;s<4;s++){e=ph[t]+ph[s],i=mh[t]+mh[s],r=fh[t]+fh[s],JM(e,i,r);for(let n=0;n<4;n++){e=ph[t]+ph[s]+ph[n],i=mh[t]+mh[s]+mh[n],r=fh[t]+fh[s]+fh[n],JM(e,i,r);for(let a=0;a<4;a++)e=ph[t]+ph[s]+ph[n]+ph[a],i=mh[t]+mh[s]+mh[n]+mh[a],r=fh[t]+fh[s]+fh[n]+fh[a],JM(e,i,r)}}}for(let t=0;t<32;t++)_v[t]={get(){this._cache=this._cache||{};let e=this._cache[t];return e===void 0&&(e=new Yc(this,new ch(t,"uint")),this._cache[t]=e),e},set(e){this[t].assign(ve(e))}};Object.defineProperties(Ee.prototype,_v),aQ=function(t,e=null){let i=Xc(t);return i==="node"?t:e===null&&(i==="float"||i==="boolean")||i&&i!=="shader"&&i!=="string"?ve(a3(t,e)):i==="shader"?t.isFn?t:it(t):t},oQ=function(t,e=null){for(let i in t)t[i]=ve(t[i],e);return t},lQ=function(t,e=null){let i=t.length;for(let r=0;r<i;r++)t[r]=ve(t[r],e);return t},LI=function(t,e=null,i=null,r=null){function s(h){return r!==null?(h=ve(Object.assign(h,r)),r.intent===!0&&(h=h.toVarIntent())):h=ve(h),h}let n,a,o,l=e;function u(h){let d;return d=l?/[a-z]/i.test(l)?l+"()":l:t.type,a!==void 0&&h.length<a?(Xt(`TSL: "${d}" parameter length is less than minimum required.`,new ws),h.concat(new Array(a-h.length).fill(0))):o!==void 0&&h.length>o?(Xt(`TSL: "${d}" parameter length exceeds limit.`,new ws),h.slice(0,o)):h}return e===null?n=(...h)=>s(new t(...Kc(u(h)))):i!==null?(i=ve(i),n=(...h)=>s(new t(e,...Kc(u(h)),i))):n=(...h)=>s(new t(e,...Kc(u(h)))),n.setParameterLength=(...h)=>(h.length===1?a=o=h[0]:h.length===2&&([a,o]=h),n),n.setName=h=>(l=h,n),n},hQ=function(t,...e){return new t(...Kc(e))},uQ=class extends Ee{constructor(t,e){super(),this.shaderNode=t,this.rawInputs=e,this.isShaderCallNodeInternal=!0}generateNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getElementType(t){return this.getOutputNode(t).getElementType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,rawInputs:i}=this,r=t.getNodeProperties(e),s=t.getClosestSubBuild(e.subBuilds)||"",n=s||"default";if(r[n])return r[n];let a=t.subBuildFn,o=t.fnCall;t.subBuildFn=s,t.fnCall=this;let l=null;if(e.layout){if(i){let d=e.layout.inputs;if(bZ(i)){let c=i;for(let p=0;p<d.length;p++){let m=c[p];m&&m.isNode&&m.build(t)}}else{let c=i[0];for(let p of d){let m=c[p.name];m&&m.isNode&&m.build(t)}}}let u=t.buildFunctionNode(e);t.addInclude(u);let h=i?function(d){let c;return x_(d),c=bZ(d)?[...d]:d[0],c}(i):null;l=u.call(h)}else{let u=new Proxy(t,{get:(m,f,g)=>{let y;return y=Symbol.iterator===f?function*(){yield}:Reflect.get(m,f,g),y}}),h=i?function(m){let f=0;return x_(m),new Proxy(m,{get:(g,y,v)=>{let b;if(y==="length")return b=m.length,b;if(Symbol.iterator===y)b=function*(){for(let _ of m)yield ve(_)};else{if(m.length>0)if(Object.getPrototypeOf(m[0])===Object.prototype){let _=m[0];b=_[y]===void 0?_[f++]:Reflect.get(_,y,v)}else m[0]instanceof Ee&&(b=m[y]===void 0?m[f++]:Reflect.get(m,y,v));else b=Reflect.get(g,y,v);b=ve(b)}return b}})}(i):null,d=Array.isArray(i)?i.length>0:i!==null,c=e.jsFunc,p=d||c.length>1?c(h,u):c(u);l=ve(p)}return t.subBuildFn=a,t.fnCall=o,e.once&&(r[n]=l),l}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),i=t.getSubBuildOutput(this);return e[i]=e[i]||this.setupOutput(t),e[i].subBuild=t.getClosestSubBuild(this),e[i]}build(t,e=null){let i=null,r=t.getBuildStage(),s=t.getNodeProperties(this),n=t.getSubBuildOutput(this),a=this.getOutputNode(t),o=t.fnCall;if(t.fnCall=this,r==="setup"){let l=t.getSubBuildProperty("initialized",this);if(s[l]!==!0&&(s[l]=!0,s[n]=this.getOutputNode(t),s[n].build(t),this.shaderNode.subBuilds))for(let u of t.chaining){let h=t.getDataFromNode(u,"any");h.subBuilds=h.subBuilds||new Set;for(let d of this.shaderNode.subBuilds)h.subBuilds.add(d)}i=s[n]}else r==="analyze"?a.build(t,e):r==="generate"&&(i=a.build(t,e)||"");return t.fnCall=o,i}},syt=class extends Ee{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}getLayout(){return this.layout}call(t=null){return new uQ(this,t)}setup(){return this.call()}},dQ=[!1,!0],cQ=[0,1,2,3],pQ=[-1,-2],FI=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],r3=new Map;for(let t of dQ)r3.set(t,new ch(t));s3=new Map;for(let t of cQ)s3.set(t,new ch(t,"uint"));n3=new Map([...s3].map(t=>new ch(t.value,"int")));for(let t of pQ)n3.set(t,new ch(t,"int"));b_=new Map([...n3].map(t=>new ch(t.value)));for(let t of FI)b_.set(t,new ch(t));for(let t of FI)b_.set(-t,new ch(-t));__={bool:r3,uint:s3,ints:n3,float:b_},UI=new Map([...r3,...b_]),a3=(t,e)=>UI.has(t)?UI.get(t):t.isNode===!0?t:new ch(t,e),js=function(t,e=null){return(...i)=>{for(let s of i)if(s===void 0)return Xt(`TSL: Invalid parameter for the type "${t}".`,new ws),new ch(0,t);if((i.length===0||!["bool","float","int","uint"].includes(t)&&i.every(s=>{let n=typeof s;return n!=="object"&&n!=="function"}))&&(i=[EI(t,...i)]),i.length===1&&e!==null&&e.has(i[0]))return J0(e.get(i[0]));if(i.length===1){let s=a3(i[0],t);return s.nodeType===t?J0(s):J0(new kI(s,t))}let r=i.map(s=>a3(s));return J0(new iQ(r,t))}},jI=t=>t!=null?t.nodeType||t.convertTo||(typeof t=="string"?t:null):null,ve=(t,e=null)=>aQ(t,e),J0=(t,e=null)=>ve(t,e).toVarIntent(),x_=(t,e=null)=>new oQ(t,e),Kc=(t,e=null)=>new lQ(t,e),ui=(t,e=null,i=null,r=null)=>new LI(t,e,i,r),te=(t,...e)=>new hQ(t,...e),Gt=(t,e=null,i=null,r={})=>new LI(t,e,i,{...r,intent:!0}),o3=(t,e)=>new Proxy(t,{get:(i,r,s)=>Reflect.get(e,r,s),set:(i,r,s)=>Reflect.set(e,r,s)}),mQ=0,nyt=class extends Ee{constructor(t,e=null){super();let i=null;e!==null&&(typeof e=="object"?i=e.return:(typeof e=="string"?i=e:Xt("TSL: Invalid layout type.",new ws),e=null)),this.shaderNode=new Y0(t,i),e!==null&&this.setLayout(e),this.isFn=!0}setLayout(t){let e=this.shaderNode.nodeType;if(typeof t.inputs!="object"){let i={name:"fn"+mQ++,type:e,inputs:[]};for(let r in t)r!=="return"&&i.inputs.push({name:r,type:t[r]});t=i}return this.shaderNode.setLayout(t),this}generateNodeType(t){return this.shaderNode.getNodeType(t)||"float"}call(...t){let e=this.shaderNode.call(t);return this.shaderNode.nodeType==="void"&&e.toStack(),e.toVarIntent()}once(t=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=t,this}generate(t){let e=this.getNodeType(t);return Xt('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),t.generateConst(e)}},ty=t=>{Jd=t},l3=()=>Jd,Te=(...t)=>Jd.If(...t),fQ=(...t)=>Jd.Switch(...t),At("toStack",t3),GI=new js("color"),U=new js("float",__.float),J=new js("int",__.ints),Ut=new js("uint",__.uint),So=new js("bool",__.bool),Kt=new js("vec2"),is=new js("ivec2"),h3=new js("uvec2"),WI=new js("bvec2"),rt=new js("vec3"),u3=new js("ivec3"),Zc=new js("uvec3"),d3=new js("bvec3"),he=new js("vec4"),c3=new js("ivec4"),p3=new js("uvec4"),qI=new js("bvec4"),w_=new js("mat2"),xn=new js("mat3"),tc=new js("mat4"),At("toColor",GI),At("toFloat",U),At("toInt",J),At("toUint",Ut),At("toBool",So),At("toVec2",Kt),At("toIVec2",is),At("toUVec2",h3),At("toBVec2",WI),At("toVec3",rt),At("toIVec3",u3),At("toUVec3",Zc),At("toBVec3",d3),At("toVec4",he),At("toIVec4",c3),At("toUVec4",p3),At("toBVec4",qI),At("toMat2",w_),At("toMat3",xn),At("toMat4",tc),HI=ui(Yc).setParameterLength(2),$I=(t,e)=>new kI(ve(t),e),gQ=(t,e)=>new Rj(ve(t),e),At("element",HI),At("convert",$I),yQ=t=>(ne("TSL: append() has been renamed to Stack().",new ws),t3(t)),At("append",t=>(ne("TSL: .append() has been renamed to .toStack().",new ws),t3(t))),cu=(t,e,i=null)=>new ji(t,e,!1,i),Qc=(t,e,i=null)=>new ji(t,e,!0,i),Ei=te(ji=class extends Ee{static get type(){return"PropertyNode"}constructor(t,e=null,i=!1,r=null){super(t),this.name=e,this.varying=i,this.placeholderNode=ve(r),this.isPropertyNode=!0,this.global=!0}getNodeType(t){let e=super.getNodeType(t);return e==="output"?t.getOutputType():e}customCacheKey(){return of(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(t){return this.name||super.getHash(t)}generate(t){let e;if(this.varying===!0)e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0;else if(e=t.getVarFromNode(this,this.name),this.placeholderNode!==null&&t.hasWriteUsage(this)===!1){let i=this.placeholderNode.build(t,this.getNodeType(t));t.addLineFlowCode(`${t.getPropertyName(e)} = ${i}`,this)}return t.getPropertyName(e)}},"vec4","DiffuseColor"),Jc=te(ji,"vec3","DiffuseContribution"),m3=te(ji,"vec3","EmissiveColor"),gh=te(ji,"float","Roughness"),pu=te(ji,"float","Metalness"),S_=te(ji,"float","Clearcoat"),uf=te(ji,"float","ClearcoatRoughness"),To=te(ji,"vec3","Sheen"),gd=te(ji,"float","SheenRoughness"),T_=te(ji,"float","Iridescence"),M_=te(ji,"float","IridescenceIOR"),A_=te(ji,"float","IridescenceThickness"),C_=te(ji,"float","AlphaT"),yd=te(ji,"float","Anisotropy"),ey=te(ji,"vec3","AnisotropyT"),tp=te(ji,"vec3","AnisotropyB"),vd=te(ji,"color","SpecularColor"),ep=te(ji,"color","SpecularColorBlended"),ip=te(ji,"float","SpecularF90"),E_=te(ji,"float","Shininess"),df=te(ji,"output","Output"),rp=te(ji,"float","dashSize"),iy=te(ji,"float","gapSize"),vQ=te(ji,"float","pointWidth"),ry=te(ji,"float","IOR"),P_=te(ji,"float","Transmission"),f3=te(ji,"float","Thickness"),g3=te(ji,"float","AttenuationDistance"),y3=te(ji,"color","AttenuationColor"),v3=te(ji,"float","Dispersion"),b3=te(ji,"float","AmbientOcclusion",!1,1),XI=class extends Ee{static get type(){return"UniformGroupNode"}constructor(t,e=!1,i=1,r=null){super("string"),this.name=t,this.shared=e,this.order=i,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}},YI=(t,e=1,i=null)=>new XI(t,!1,e,i),bQ=(_3=(t,e=0,i=null)=>new XI(t,!0,e,i))("frame",0,Ue.FRAME),Ce=_3("render",0,Ue.RENDER),KI=YI("object",1,Ue.OBJECT),sy=class extends i3{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=KI}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new ws),this.setName(t)}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){return t=t.bind(this),super.onUpdate(i=>{let r=t(i,this);r!==void 0&&(this.value=r)},e)}getInputType(t){let e=super.getInputType(t);return e==="bool"&&(e="uint"),e}generate(t,e){let i=this.getNodeType(t),r=this.getUniformHash(t),s=t.getNodeFromHash(r);s===void 0&&(t.setHashNode(this,r),s=this);let n=s.getInputType(t),a=t.getUniformFromNode(s,n,t.shaderStage,this.name||t.context.nodeName),o=t.getPropertyName(a);t.context.nodeName!==void 0&&delete t.context.nodeName;let l=o;if(i==="bool"){let u=t.getDataFromNode(this),h=u.propertyName;if(h===void 0){let d=t.getVarFromNode(this,null,"bool");h=t.getPropertyName(d),u.propertyName=h,l=t.format(o,n,i),t.addLineFlowCode(`${h} = ${l}`,this)}l=h}return t.format(l,i,e)}},we=(t,e)=>{let i=jI(e||t);if(i===t&&(t=EI(i)),t&&t.isNode===!0){let r=t.value;t.traverse(s=>{s.isConstNode===!0&&(r=s.value)}),t=r}return new sy(t,i)},ZI=class extends Cr{static get type(){return"ArrayNode"}constructor(t,e,i=null){super(t),this.count=e,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(t){return this.nodeType===null?this.values[0].getNodeType(t):this.nodeType}getElementType(t){return this.getNodeType(t)}getMemberType(t,e){return this.nodeType===null?this.values[0].getMemberType(t,e):super.getMemberType(t,e)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}},QI=(...t)=>{let e;if(t.length===1){let i=t[0];e=new ZI(null,i.length,i)}else{let i=t[0],r=t[1];e=new ZI(i,r)}return ve(e)},At("toArray",(t,e)=>QI(Array(e).fill(t))),At("assign",_Q=ui(class extends Cr{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let i=t.getTypeLength(e.node.getNodeType(t));return hf.join("").slice(0,i)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:i}=this,r=e.getScope();t.getDataFromNode(r).assign=!0;let s=t.getNodeProperties(this);s.sourceNode=i,s.targetNode=e.context({assign:!0})}generate(t,e){let i,{targetNode:r,sourceNode:s}=t.getNodeProperties(this),n=this.needsSplitAssign(t),a=r.build(t),o=r.getNodeType(t),l=s.build(t,o),u=s.getNodeType(t),h=t.getDataFromNode(this);if(h.initialized===!0)e!=="void"&&(i=a);else if(n){let d=t.getVarFromNode(this,null,o),c=t.getPropertyName(d);t.addLineFlowCode(`${c} = ${l}`,this);let p=r.node,m=p.node.context({assign:!0}).build(t);for(let f=0;f<p.components.length;f++){let g=p.components[f];t.addLineFlowCode(`${m}.${g} = ${c}[ ${f} ]`,this)}e!=="void"&&(i=a)}else i=`${a} = ${l}`,(e==="void"||u==="void")&&(t.addLineFlowCode(i,this),e!=="void"&&(i=a));return h.initialized=!0,t.format(i,o,e)}}).setParameterLength(2)),xQ=class extends Cr{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}generateNodeType(t){return this.functionNode.getNodeType(t)}getMemberType(t,e){return this.functionNode.getMemberType(t,e)}generate(t){let e=[],i=this.functionNode,r=i.getInputs(t),s=this.parameters,n=(a,o)=>{let l,u=o.type;return l=u==="pointer"?"&"+a.build(t):a.build(t,u),l};if(Array.isArray(s)){if(s.length>r.length)Xt("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length<r.length)for(Xt("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<r.length;)s.push(U(0));for(let a=0;a<s.length;a++)e.push(n(s[a],r[a]))}else for(let a of r){let o=s[a.name];o!==void 0?e.push(n(o,a)):(Xt(`TSL: Input '${a.name}' not found in 'Fn()'.`),e.push(n(U(0),a)))}return`${i.build(t,"property")}( ${e.join(", ")} )`}},At("call",wQ=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Kc(e):x_(e[0]),new xQ(ve(t),e))),SQ={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},Ds=Gt(ys=class extends Cr{static get type(){return"OperatorNode"}constructor(t,e,i,...r){if(super(),r.length>0){let s=new ys(t,e,i);for(let n=0;n<r.length-1;n++)s=new ys(t,s,r[n]);e=s,i=r[r.length-1]}this.op=t,this.aNode=e,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(SQ[this.op],e)}generateNodeType(t,e=null){let i=this.op,r=this.aNode,s=this.bNode,n=r.getNodeType(t),a=s?s.getNodeType(t):null;if(n==="void"||a==="void")return e||"void";if(i==="%")return n;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return t.getIntegerType(n);if(i==="&&"||i==="||"||i==="^^")return"bool";if(i==="!"){let o=t.getTypeLength(n);return o>1?`bvec${o}`:"bool"}if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}generate(t,e){let i=this.op,{aNode:r,bNode:s}=this,n=this.getNodeType(t,e),a=null,o=null;n!=="void"?(a=r.getNodeType(t),o=s?s.getNodeType(t):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?t.isVector(a)?o=a:t.isVector(o)?a=o:a!==o&&(a=o="float"):i===">>"||i==="<<"?(a=n,o=t.changeComponentType(o,"uint")):i==="%"?(a=n,o=t.isInteger(a)&&t.isInteger(o)?o:a):t.isMatrix(a)?o==="float"?o="float":t.isVector(o)?o=t.getVectorFromMatrix(a):t.isMatrix(o)||(a=o=n):a=t.isMatrix(o)?a==="float"?"float":t.isVector(a)?t.getVectorFromMatrix(o):o=n:o=n):a=o=n;let l=r.build(t,a),u=s?s.build(t,o):null,h=t.getFunctionOperator(i);if(e!=="void"){let d=t.renderer.coordinateSystem===Io;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return d&&t.isVector(a)?t.format(`${this.getOperatorMethod(t,e)}( ${l}, ${u} )`,n,e):t.format(`( ${l} ${i} ${u} )`,n,e);if(i==="%")return t.isInteger(o)?t.format(`( ${l} % ${u} )`,n,e):t.format(`${this.getOperatorMethod(t,n)}( ${l}, ${u} )`,n,e);if(i==="!")return d&&t.isVector(a)?t.format(`not( ${l} )`,e):t.format(`( ${i} ${l} )`,a,e);if(i==="~")return t.format(`( ${i} ${l} )`,a,e);if(h)return t.format(`${h}( ${l}, ${u} )`,n,e);if(t.isMatrix(a)&&o==="float")return t.format(`( ${u} ${i} ${l} )`,n,e);if(a==="float"&&t.isMatrix(o))return t.format(`${l} ${i} ${u}`,n,e);{let c=`( ${l} ${i} ${u} )`;return!d&&n==="bool"&&t.isVector(a)&&t.isVector(o)&&(c=`all${c}`),t.format(c,n,e)}}if(a!=="void")return h?t.format(`${h}( ${l}, ${u} )`,n,e):t.isMatrix(a)&&o==="float"?t.format(`${u} ${i} ${l}`,n,e):t.format(`${l} ${i} ${u}`,n,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}},"+").setParameterLength(2,1/0).setName("add"),Ti=Gt(ys,"-").setParameterLength(2,1/0).setName("sub"),We=Gt(ys,"*").setParameterLength(2,1/0).setName("mul"),Mo=Gt(ys,"/").setParameterLength(2,1/0).setName("div"),R_=Gt(ys,"%").setParameterLength(2).setName("mod"),JI=Gt(ys,"==").setParameterLength(2).setName("equal"),tB=Gt(ys,"!=").setParameterLength(2).setName("notEqual"),eB=Gt(ys,"<").setParameterLength(2).setName("lessThan"),x3=Gt(ys,">").setParameterLength(2).setName("greaterThan"),iB=Gt(ys,"<=").setParameterLength(2).setName("lessThanEqual"),rB=Gt(ys,">=").setParameterLength(2).setName("greaterThanEqual"),sB=Gt(ys,"&&").setParameterLength(2,1/0).setName("and"),nB=Gt(ys,"||").setParameterLength(2,1/0).setName("or"),aB=Gt(ys,"!").setParameterLength(1).setName("not"),oB=Gt(ys,"^^").setParameterLength(2).setName("xor"),lB=Gt(ys,"&").setParameterLength(2).setName("bitAnd"),hB=Gt(ys,"~").setParameterLength(1).setName("bitNot"),uB=Gt(ys,"|").setParameterLength(2).setName("bitOr"),dB=Gt(ys,"^").setParameterLength(2).setName("bitXor"),cB=Gt(ys,"<<").setParameterLength(2).setName("shiftLeft"),pB=Gt(ys,">>").setParameterLength(2).setName("shiftRight"),mB=it(([t])=>(t.addAssign(1),t)),fB=it(([t])=>(t.subAssign(1),t)),gB=it(([t])=>{let e=J(t).toConst();return t.addAssign(1),e}),yB=it(([t])=>{let e=J(t).toConst();return t.subAssign(1),e}),At("add",Ds),At("sub",Ti),At("mul",We),At("div",Mo),At("mod",R_),At("equal",JI),At("notEqual",tB),At("lessThan",eB),At("greaterThan",x3),At("lessThanEqual",iB),At("greaterThanEqual",rB),At("and",sB),At("or",nB),At("not",aB),At("xor",oB),At("bitAnd",lB),At("bitNot",hB),At("bitOr",uB),At("bitXor",dB),At("shiftLeft",cB),At("shiftRight",pB),At("incrementBefore",mB),At("decrementBefore",fB),At("increment",gB),At("decrement",yB),(ut=class extends Cr{static get type(){return"MathNode"}constructor(t,e,i=null,r=null){if(super(),(t===ut.MAX||t===ut.MIN)&&arguments.length>3){let s=new ut(t,e,i);for(let n=3;n<arguments.length-1;n++)s=new ut(t,s,arguments[n]);e=s,i=arguments[arguments.length-1],r=null}this.method=t,this.aNode=e,this.bNode=i,this.cNode=r,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),i=this.bNode?this.bNode.getNodeType(t):null,r=this.cNode?this.cNode.getNodeType(t):null,s=t.isMatrix(e)?0:t.getTypeLength(e),n=t.isMatrix(i)?0:t.getTypeLength(i),a=t.isMatrix(r)?0:t.getTypeLength(r);return s>n&&s>a?e:n>a?i:a>s?r:e}generateNodeType(t){let e=this.method;return e===ut.LENGTH||e===ut.DISTANCE||e===ut.DOT?"float":e===ut.CROSS?"vec3":e===ut.ALL||e===ut.ANY?"bool":e===ut.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:i,method:r}=this,s=null;if(r===ut.ONE_MINUS)s=Ti(1,e);else if(r===ut.RECIPROCAL)s=Mo(1,e);else if(r===ut.DIFFERENCE)s=wr(Ti(e,i));else if(r===ut.TRANSFORM_DIRECTION){let n,a;t.isMatrix(e.getNodeType(t))?(n=e,a=i):(n=i,a=e),s=pa(We(n,he(rt(a),0)).xyz)}return s!==null?s:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,r=this.getNodeType(t),s=this.getInputType(t),n=this.aNode,a=this.bNode,o=this.cNode,l=t.renderer.coordinateSystem;if(i===ut.NEGATE)return t.format("( - "+n.build(t,s)+" )",r,e);{let u=[];return i===ut.CROSS?u.push(n.build(t,r),a.build(t,r)):l===Io&&i===ut.STEP?u.push(n.build(t,t.getTypeLength(n.getNodeType(t))===1?"float":s),a.build(t,s)):l!==Io||i!==ut.MIN&&i!==ut.MAX?i===ut.REFRACT?u.push(n.build(t,s),a.build(t,s),o.build(t,"float")):i===ut.MIX?u.push(n.build(t,s),a.build(t,s),o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":s)):(l===zo&&i===ut.ATAN&&a!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===ut.DFDX||i===ut.DFDY)&&(ne(`TSL: '${i}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),u.push(n.build(t,s)),a!==null&&u.push(a.build(t,s)),o!==null&&u.push(o.build(t,s))):u.push(n.build(t,s),a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":s)),t.format(`${t.getMethod(i,r)}( ${u.join(", ")} )`,r,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}).ALL="all",ut.ANY="any",ut.RADIANS="radians",ut.DEGREES="degrees",ut.EXP="exp",ut.EXP2="exp2",ut.LOG="log",ut.LOG2="log2",ut.SQRT="sqrt",ut.INVERSE_SQRT="inversesqrt",ut.FLOOR="floor",ut.CEIL="ceil",ut.NORMALIZE="normalize",ut.FRACT="fract",ut.SIN="sin",ut.SINH="sinh",ut.COS="cos",ut.COSH="cosh",ut.TAN="tan",ut.TANH="tanh",ut.ASIN="asin",ut.ASINH="asinh",ut.ACOS="acos",ut.ACOSH="acosh",ut.ATAN="atan",ut.ATANH="atanh",ut.ABS="abs",ut.SIGN="sign",ut.LENGTH="length",ut.NEGATE="negate",ut.ONE_MINUS="oneMinus",ut.DFDX="dFdx",ut.DFDY="dFdy",ut.ROUND="round",ut.RECIPROCAL="reciprocal",ut.TRUNC="trunc",ut.FWIDTH="fwidth",ut.TRANSPOSE="transpose",ut.DETERMINANT="determinant",ut.INVERSE="inverse",ut.EQUALS="equals",ut.MIN="min",ut.MAX="max",ut.STEP="step",ut.REFLECT="reflect",ut.DISTANCE="distance",ut.DIFFERENCE="difference",ut.DOT="dot",ut.CROSS="cross",ut.POW="pow",ut.TRANSFORM_DIRECTION="transformDirection",ut.MIX="mix",ut.CLAMP="clamp",ut.REFRACT="refract",ut.SMOOTHSTEP="smoothstep",ut.FACEFORWARD="faceforward",D_=U(1e-6),TQ=U(1e6),N_=U(Math.PI),MQ=U(2*Math.PI),AQ=U(2*Math.PI),CQ=U(.5*Math.PI),vB=Gt(ut,ut.ALL).setParameterLength(1),bB=Gt(ut,ut.ANY).setParameterLength(1),_B=Gt(ut,ut.RADIANS).setParameterLength(1),xB=Gt(ut,ut.DEGREES).setParameterLength(1),w3=Gt(ut,ut.EXP).setParameterLength(1),cf=Gt(ut,ut.EXP2).setParameterLength(1),O_=Gt(ut,ut.LOG).setParameterLength(1),yh=Gt(ut,ut.LOG2).setParameterLength(1),ka=Gt(ut,ut.SQRT).setParameterLength(1),S3=Gt(ut,ut.INVERSE_SQRT).setParameterLength(1),vh=Gt(ut,ut.FLOOR).setParameterLength(1),I_=Gt(ut,ut.CEIL).setParameterLength(1),pa=Gt(ut,ut.NORMALIZE).setParameterLength(1),Ol=Gt(ut,ut.FRACT).setParameterLength(1),za=Gt(ut,ut.SIN).setParameterLength(1),wB=Gt(ut,ut.SINH).setParameterLength(1),Il=Gt(ut,ut.COS).setParameterLength(1),SB=Gt(ut,ut.COSH).setParameterLength(1),TB=Gt(ut,ut.TAN).setParameterLength(1),MB=Gt(ut,ut.TANH).setParameterLength(1),AB=Gt(ut,ut.ASIN).setParameterLength(1),CB=Gt(ut,ut.ASINH).setParameterLength(1),T3=Gt(ut,ut.ACOS).setParameterLength(1),EB=Gt(ut,ut.ACOSH).setParameterLength(1),M3=Gt(ut,ut.ATAN).setParameterLength(1,2),PB=Gt(ut,ut.ATANH).setParameterLength(1),wr=Gt(ut,ut.ABS).setParameterLength(1),A3=Gt(ut,ut.SIGN).setParameterLength(1),bh=Gt(ut,ut.LENGTH).setParameterLength(1),C3=Gt(ut,ut.NEGATE).setParameterLength(1),RB=Gt(ut,ut.ONE_MINUS).setParameterLength(1),E3=Gt(ut,ut.DFDX).setParameterLength(1),P3=Gt(ut,ut.DFDY).setParameterLength(1),DB=Gt(ut,ut.ROUND).setParameterLength(1),NB=Gt(ut,ut.RECIPROCAL).setParameterLength(1),R3=Gt(ut,ut.TRUNC).setParameterLength(1),D3=Gt(ut,ut.FWIDTH).setParameterLength(1),OB=Gt(ut,ut.TRANSPOSE).setParameterLength(1),IB=Gt(ut,ut.DETERMINANT).setParameterLength(1),BB=Gt(ut,ut.INVERSE).setParameterLength(1),no=Gt(ut,ut.MIN).setParameterLength(2,1/0),rs=Gt(ut,ut.MAX).setParameterLength(2,1/0),sp=Gt(ut,ut.STEP).setParameterLength(2),VB=Gt(ut,ut.REFLECT).setParameterLength(2),kB=Gt(ut,ut.DISTANCE).setParameterLength(2),zB=Gt(ut,ut.DIFFERENCE).setParameterLength(2),Yo=Gt(ut,ut.DOT).setParameterLength(2),mu=Gt(ut,ut.CROSS).setParameterLength(2),Ko=Gt(ut,ut.POW).setParameterLength(2),N3=t=>We(t,t),LB=t=>We(t,t,t),O3=t=>We(t,t,t,t),FB=Gt(ut,ut.TRANSFORM_DIRECTION).setParameterLength(2),UB=(t,e)=>pa(We(e,he(rt(t),0)).xyz),jB=(t,e)=>pa(he(rt(t),0).mul(e).xyz),GB=t=>We(A3(t),Ko(wr(t),1/3)),I3=t=>Yo(t,t),vi=Gt(ut,ut.MIX).setParameterLength(3),Bl=(t,e=0,i=1)=>new ut(ut.CLAMP,ve(t),ve(e),ve(i)),B_=t=>Bl(t),B3=Gt(ut,ut.REFRACT).setParameterLength(3),Ao=Gt(ut,ut.SMOOTHSTEP).setParameterLength(3),V3=Gt(ut,ut.FACEFORWARD).setParameterLength(3),WB=it(([t])=>{let e=Yo(t.xy,Kt(12.9898,78.233)),i=R_(e,N_);return Ol(za(i).mul(43758.5453))}),qB=(t,e,i)=>vi(e,i,t),HB=(t,e,i)=>Ao(e,i,t),$B=(t,e)=>sp(e,t),EQ=V3,PQ=S3,At("all",vB),At("any",bB),At("radians",_B),At("degrees",xB),At("exp",w3),At("exp2",cf),At("log",O_),At("log2",yh),At("sqrt",ka),At("inverseSqrt",S3),At("floor",vh),At("ceil",I_),At("normalize",pa),At("fract",Ol),At("sin",za),At("sinh",wB),At("cos",Il),At("cosh",SB),At("tan",TB),At("tanh",MB),At("asin",AB),At("asinh",CB),At("acos",T3),At("acosh",EB),At("atan",M3),At("atanh",PB),At("abs",wr),At("sign",A3),At("length",bh),At("lengthSq",I3),At("negate",C3),At("oneMinus",RB),At("dFdx",E3),At("dFdy",P3),At("round",DB),At("reciprocal",NB),At("trunc",R3),At("fwidth",D3),At("min",no),At("max",rs),At("step",$B),At("reflect",VB),At("distance",kB),At("dot",Yo),At("cross",mu),At("pow",Ko),At("pow2",N3),At("pow3",LB),At("pow4",O3),At("transformDirection",FB),At("transformNormalByViewMatrix",UB),At("transformNormalByInverseViewMatrix",jB),At("mix",qB),At("clamp",Bl),At("refract",B3),At("smoothstep",HB),At("faceForward",V3),At("difference",zB),At("saturate",B_),At("cbrt",GB),At("transpose",OB),At("determinant",IB),At("inverse",BB),At("rand",WB),At("select",La=ui(class extends Ee{static get type(){return"ConditionalNode"}constructor(t,e,i=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=i}generateNodeType(t){let{ifNode:e,elseNode:i}=t.getNodeProperties(this);if(e===void 0)return t.flowBuildStage(this,"setup"),this.getNodeType(t);let r=e.getNodeType(t);if(i!==null){let s=i.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(r))return s}return r}setup(t){let e=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=t.context.nodeBlock;t.getDataFromNode(i).parentNodeBlock=s,r!==null&&(t.getDataFromNode(r).parentNodeBlock=s);let n=t.context.uniformFlow,a=t.getNodeProperties(this);a.condNode=e,a.ifNode=n?i:i.context({nodeBlock:i}),a.elseNode=r?n?r:r.context({nodeBlock:r}):null}generate(t,e){let i=this.getNodeType(t),r=t.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",u=l?cu(i).build(t):"";r.nodeProperty=u;let h=s.build(t,"bool");if(t.context.uniformFlow&&a!==null){let c=n.build(t,i),p=a.build(t,i),m=t.getTernary(h,c,p);return t.format(m,i,e)}t.addFlowCode(`
|
|
@@ -1980,7 +1980,7 @@ var<${i}> ${t} : ${n};`}},ya=new Pf,VC=new Sy,Y6=new Map([[Int8Array,["sint8","s
|
|
|
1980
1980
|
`).slice(2,9).join(`
|
|
1981
1981
|
`)}),wv.length>M1t&&wv.shift()}var m9,M1t,wv,f9,K4,g9,y9,sCt=j(()=>{m9=(()=>{try{return new URLSearchParams(window.location.search).get("dbgdestroys")==="1"}catch{return!1}})(),M1t=32,wv=[],f9=6,K4=()=>-1,g9=!1,y9=null}),nCt=j(()=>{});function v9(t,e){let i=new ri(t,e,{depthBuffer:!1,type:Qe,format:Bo});return i.texture.generateMipmaps=!1,i.texture.minFilter=De,i.texture.magFilter=De,i}function b9(){return $g===null&&(($g=v9(Sc*Z4,Sc)).texture.name="SplinePCSSPyramidAtlas"),$g.texture}function flt(t,e,i,r,s,n){let a=new Re,o=ee(e),l=Et(()=>{let u=Ja,h=n!==0?p2(u.x).sub(n):p2(u.x),d=mt(h).mul(i).toVar(),c=mt(u.y).mul(i).toVar(),p=I(1e9).toVar(),m=I(-1e9).toVar();return Ji(x9("ly",i),x9("lx",i),f=>{let{lx:g,ly:y}=f,v=_9(w9(d.add(g),mt(0),mt(r))),b=_9(w9(c.add(y),mt(0),mt(r))),_=o.load(Zn(v,b));p.assign(ii(p,p2(_.x))),m.assign(Qt(m,p2(s?_.y:_.x)))}),lt(p,m,0,1)})();return a.fragmentNode=l,a.name=t,a.lights=!1,a.blending=cr,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,a}function glt(t){let e=t;if(!e.__spePcssPyramid){e.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null};for(let i of Sv)i.deref()===void 0&&Sv.delete(i);Sv.add(new WeakRef(e.__spePcssPyramid))}return e.__spePcssPyramid}function ylt(t){return t.__spePcssPyramid?.fresh===!0}function aCt(t){return t.__spePcssPyramid?.slot??-1}var Sc,Z4,V1,p2,_9,x9,w9,$g,Sv,mR,fR,S9,A1t=j(()=>{dt(),mr(),He(),dn(),Sc=8,Z4=8,V1=64,p2=t=>t,_9=t=>t,x9=(t,e)=>({start:mt(0),end:mt(e),type:"int",condition:"<",name:t}),w9=Ae,$g=null,Sv=new Set,mR=new Array(Z4).fill(null),fR=!1,S9=new P});function Tv(t){let e=t;return e.__spePcssKnobs||(e.__spePcssKnobs={mapSize:gt(2048),radius:gt(1),penumbraSize:gt(.5),depthEps:gt(1e-4),penumbraFrameScale:gt(1),penumbraFrameOffset:gt(0),pyramidEnabled:gt(0),pyramidSlot:gt(0),maskChannel:gt(new Me(0,0,0,0)),planeNormalMat:gt(new Ts().set(0,0,0,0,0,0,0,0,0))}),e.__spePcssKnobs}function C1t(t,e){Tv(t).maskChannel.value.set(e===0?1:0,e===1?1:0,e===2?1:0,e===3?1:0)}function vlt(t,e,i){let r=t,s=Tv(t);s.mapSize.value=r.mapSize?.x??2048,s.radius.value=r.radius??1,s.penumbraSize.value=e??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?s.planeNormalMat.value.getNormalMatrix(r.matrix):s.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let n=typeof r.camera?.far=="number"&&typeof r.camera?.near=="number"?r.camera.far-r.camera.near:0;s.depthEps.value=n>.001?N1t/n:1e-4;let a=t.__speRangeEnvelope,o=a?a.far-a.near:0;a&&o>.001&&n>.001&&r.camera?(s.penumbraFrameScale.value=n/o,s.penumbraFrameOffset.value=(r.camera.near-a.near)/o):(s.penumbraFrameScale.value=1,s.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&Q4()){let u=s.mapSize.value;DW/1024+(2*s.radius.value+2)/Math.max(1,u)<=1/Sc&&(l=1)}return s.pyramidEnabled.value=O1t??l,s.pyramidSlot.value=Math.max(0,i?.slot??0),s.pyramidEnabled.value===1}function E1t(t,e){let i=k1(t.planeNormalMat.mul(e)).toVar(),r=Ye(i.z),s=Ye(Ku(r).add(Ai(Le(r),I(0))).mul(Qt(Le(r),I(1e-4))));return zr(at(Ye(i.x).negate().div(s),Ye(i.y).div(s))).toVar()}function T9(t,e,i,r,s,n,a){let o=R1t(),l=D1t(),u=M9(),h=Tv(e),d=Ye(h.mapSize),c=zr(at(d,d)),p=Ye(h.radius),m=Ye(h.penumbraSize),f=ee(t),g=S=>Ye(f.load(Zn(Ae(S,at(0),at(1)).mul(c))).x),y=I(1).div(c.x).toVar(),v=I(DW).div(y.mul(1024)).toVar(),b=Ye(h.depthEps),_=E1t(h,a),x=()=>{let S=I(0).toVar(),w=I(0).toVar();for(let M=0;M<l;M++){let A=zr(bm(mt(M),mt(l),s)).mul(y).mul(v),R=g(zr(i.add(A))).toVar();bt(R.lessThan(r.add(J4(_,A)).add(b)),()=>{S.addAssign(R),w.addAssign(1)})}let T=I(0).toVar();bt(w.greaterThan(0),()=>{let M=S.div(w).toVar(),A=Ye(h.penumbraFrameScale),R=Ye(h.penumbraFrameOffset),O=r.sub(M).mul(A).div(M.mul(A).add(R)).toVar();T.assign(Ae(O.mul(O).mul(200).mul(m),I(0),I(1)))});let C=I(0).toVar();for(let M=0;M<o;M++){let A=zr(bm(mt(M),mt(o),s)).mul(y),R=zr(A.mul(p.mul(2)).add(A.mul(T.mul(v)))),O=Ye(r.add(J4(_,R)));u?C.addAssign(Ye(ee(t,zr(i.add(R))).compare(O))):C.addAssign(Ai(O,g(zr(i.add(R)))))}n.assign(C.div(o))};if(Q4()){let S=ee(b9()),w=Ye(h.pyramidEnabled),T=Ye(h.pyramidSlot),C=I(Sc),M=I(0).toVar();bt(w.greaterThan(.5),()=>{let A=zr(Ae(i,at(0),at(1))),R=Ye(A.x.mul(C)).toVar(),O=Ye(A.y.mul(C)).toVar(),N=T.mul(C),B=I(1e9).toVar(),L=I(-1e9).toVar();for(let V=-1;V<=1;V++)for(let H=-1;H<=1;H++){let W=Ae(R.add(I(H)),I(0),C.sub(1)),X=Ae(O.add(I(V)),I(0),C.sub(1)),st=zr(at(W.add(N),X)),nt=S.load(Zn(st));B.assign(ii(B,Ye(nt.x))),L.assign(Qt(L,Ye(nt.y)))}let z=Ye(y.mul(p.mul(2).add(v))),k=Ye(ii(mi(_).mul(z),I(.05))).toVar();bt(B.greaterThanEqual(r.add(b).add(k)),()=>{M.assign(1)}).ElseIf(L.lessThan(r.sub(k)),()=>{M.assign(2)})}),bt(M.equal(1),()=>{n.assign(1)}).ElseIf(M.equal(2),()=>{n.assign(0)}).Else(x)}else x()}function oCt(t,e){let i=e;return i.isPointLight?(Ke.pcssHookServes++,e5):i.isSpotLight||i.isDirectionalLight?(Ke.pcssHookServes++,t5):null}function blt(t){NW.value=t?1:0}function _lt(t,e){return i=>{let r=function(a){let o=a,l={};if(o==null)return l;for(let u of I1t){let h=o[u];h!==void 0&&(l[u]=h)}return l}(i),s=Ye(E9(t,r)),n=Ye(E9(e,r));return Et(()=>{let a=I(1).toVar();return bt(Ye(NW).greaterThan(.5),()=>{a.assign(s)}).Else(()=>{a.assign(n)}),a})()}}var Ye,zr,k1,GC,WC,qC,HC,m2,M9,Q4,iL,A9,C9,P1t,DW,nc,R1t,D1t,N1t,O1t,J4,xlt,wlt,Slt,NW,E9,I1t,t5,e5,$C,Tlt,Mlt,B1t,XC,i5,V1t=j(()=>{He(),dt(),dn(),A1t(),Ye=t=>t,zr=t=>t,k1=t=>t,GC=!0,WC=!0,qC=!0,HC=!0;try{let t=new URLSearchParams(window.location.search),e=t.get("dbgpcss");e==="classic"||e==="0"?(GC=!1,WC=!1,qC=!1,HC=!1):(GC=t.get("dbgpcsssplit")!=="0",WC=t.get("dbgpcsshw")!=="0",qC=t.get("dbgpcsshiz")!=="0",HC=t.get("dbgshadowmask")!=="0")}catch{}m2=!1,M9=()=>WC&&m2,Q4=()=>qC&&m2,iL=()=>HC&&m2,A9=()=>Q4(),C9=()=>iL(),P1t=[[0,-.333334],[-.5,.333334],[.5,-.777778],[-.75,-.111112],[.25,.555556],[-.25,-.555556],[.75,.111112],[-.875,.777778],[.125,-.925926],[-.375,-.25926],[.625,.407408],[-.625,-.703704],[.375,-.037038],[-.125,.62963],[.875,-.481482],[-.9375,.185186]],DW=80,nc=16,R1t=()=>M9()?Math.max(4,nc>>1):nc,D1t=()=>GC?Math.max(4,nc>>1):nc,N1t=1.25,O1t=null,J4=(t,e)=>Ye(Ae(kt(t,e),I(-.05),I(.05))),xlt=Et(t=>{let{depthTexture:e,shadowCoord:i,shadow:r}=t,s=Tv(r),n=zr(i.xy).toVar(),a=Ye(i.z).toVar(),o=k1(LS).toVar(),l=zr(Lt.pcssHalton),u=Ye(Ac(Ja.xy.add(l))).mul(6.28318530718).toVar(),h=I(1).toVar();if(iL()){let d=s.maskChannel,c=Ye(Lt.shadowMaskEnabled),p=Lt.shadowMaskGBuffer,m=Lt.shadowMaskTexture,f=I(0).toVar(),g=I(1).toVar();bt(c.greaterThan(.5).and(Ye(kt(d,lt(1,1,1,1))).greaterThan(.5)),()=>{let y=zr(Jl),v=zr(Lt.shadowMaskResolution),b=zr(Lt.shadowMaskFullResolution),_=Ye(Rc.z),x=zr(y.mul(v).sub(at(.5,.5))).toVar(),S=zr(ce(x)).toVar(),w=zr(x.sub(S)).toVar(),T=Ye(Qt(Le(_).mul(.02),I(.05))),C=I(0).toVar(),M=I(0).toVar();for(let A=0;A<=1;A++)for(let R=0;R<=1;R++){let O=zr(Ae(S.add(at(R,A)),at(0,0),v.sub(at(1,1)))),N=zr(O.add(at(.5,.5)).div(v)),B=zr(ce(N.mul(b)).add(at(.5,.5)).div(b)),L=Ye(p.sample(B).w),z=Ye(kt(m.sample(N),d)),k=Ye(R===0?I(1).sub(w.x):Ye(w.x)),V=Ye(A===0?I(1).sub(w.y):Ye(w.y)),H=Ye(Ai(Le(L.sub(_)),T)),W=Ye(k.mul(V).mul(H)).toVar();C.addAssign(W),M.addAssign(z.mul(W))}bt(C.greaterThan(.001),()=>{f.assign(1),g.assign(M.div(C))})}),bt(f.greaterThan(.5),()=>{h.assign(g)}).Else(()=>{T9(e,r,n,a,u,h,o)})}else T9(e,r,n,a,u,h,o);return h}),wlt=Et(t=>{let{depthTexture:e,shadowCoord:i,shadow:r}=t,s=Tv(r),n=zr(i.xy).toVar(),a=Ye(i.z).toVar(),o=E1t(s,k1(LS).toVar()),l=Ye(s.mapSize),u=Ye(s.radius),h=Ye(u.mul(I(1).div(l))).toVar(),d=Ye(Ac(Ja.xy)).mul(6.28318530718).toVar(),c=I(0).toVar();for(let p=0;p<5;p++){let m=zr(bm(mt(p),mt(5),d)).mul(h).toVar();c.addAssign(Ye(ee(e,zr(n.add(m))).compare(a.add(J4(o,m)))))}return c.mul(.2)}),Slt=Et(t=>{let{depthTexture:e,bd3D:i,dp:r,shadow:s}=t,n=nc,a=Tv(s),o=Ye(a.mapSize),l=Ye(a.radius),u=I(1).div(o).toVar(),h=zr(Lt.pcssHalton),d=Ye(Ac(Ja.xy.add(h))).mul(6.28318530718).toVar(),c=Ye(l.add(5)).toVar(),p=I(0).toVar();for(let m=0;m<n;m++){let f=zr(bm(mt(m),mt(n),d)).mul(u).toVar(),g=k1(G(f.x,f.y,Ye(f.x).negate()).mul(c)),y=k1(i.add(g));p.addAssign(Ye(Syt(e,y).compare(r)))}return p.div(n)}),NW=gt(1),E9=(t,e)=>t(e),I1t=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],t5=_lt(xlt,wlt),e5=_lt(Slt,pyt)}),lCt=j(()=>{dt(),mr(),He(),dn(),V1t(),$C=new Pr,Tlt=new ae,Mlt=new Q,B1t=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=gt(new _t),this._projInv=gt(new _t),this._lightRows=[];let t=new Re;t.name="SplineShadowMask.gbuffer",t.fragmentNode=lt(Oa,Rc.z),t.lights=!1,t.blending=cr,t.needsUpdate=!0,this._gBufferMaterial=t}_ensureTarget(t,e,i,r){return t&&t.width===e&&t.height===i?{target:t,changed:!1}:(t?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(t){let e=new Re;e.name="SplineShadowMask.resolve";let i=ee(this._gBuffer.depthTexture),r=ee(this._gBuffer.texture),s=this._cameraWorld,n=this._projInv,a=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=t.map(()=>({matrix:gt(new _t),bias:gt(0),normalBias:gt(0)}));let l=this._lightRows,u=Et(()=>{let h=bi(),d=ce(h.mul(at(a,o))).add(at(.5,.5)).div(at(a,o)).toVar(),c=i.sample(d),p=_W(d,c,n).toVar(),m=r.sample(d).toVar(),f=s,g=f.mul(lt(p,1)).xyz.toVar(),y=xe(f.mul(lt(m.xyz,0)).xyz).toVar(),v=Lt.pcssHalton,b=Ac(Ja.xy.add(v)).mul(6.28318530718).toVar(),_=[I(1).toVar(),I(1).toVar(),I(1).toVar(),I(1).toVar()];return t.forEach((x,S)=>{let w=l[S],T=g.add(y.mul(w.normalBias)),C=w.matrix.mul(lt(T,1)).toVar(),M=C.xyz.div(C.w),A=G(M.x,I(1).sub(M.y),M.z).toVar(),R=A.z.add(w.bias).toVar(),O=A.x.greaterThanEqual(0).and(A.x.lessThanEqual(1)).and(A.y.greaterThanEqual(0)).and(A.y.lessThanEqual(1)).and(R.lessThanEqual(1));bt(O,()=>{T9(x.shadow.map.depthTexture,x.shadow,A.xy,R,b,_[S],y)})}),lt(_[0],_[1],_[2],_[3])})();return e.fragmentNode=u,e.lights=!1,e.blending=cr,e.depthTest=!1,e.depthWrite=!1,e.needsUpdate=!0,e}render(t,e,i,r,s){let n=s??t.getDrawingBufferSize(Mlt),a=Math.max(1,Math.round(n.x)),o=Math.max(1,Math.round(n.y)),l=Math.max(1,Math.round(a/2)),u=Math.max(1,Math.round(o/2)),h=!1,d=this._ensureTarget(this._gBuffer,a,o,()=>{let C=new ri(a,o,{type:ai,depthTexture:new Xa(a,o),minFilter:me,magFilter:me});return C.texture.name="SplineShadowMask.gbuffer",C});this._gBuffer=d.target,h=h||d.changed;let c=this._ensureTarget(this._maskTarget,l,u,()=>{let C=new ri(l,u,{depthBuffer:!1,minFilter:me,magFilter:me});return C.texture.name="SplineShadowMask.mask",C});this._maskTarget=c.target,h=h||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(C=>C.shadow.map?.depthTexture?.uuid??"none").join(",")}`;(this._resolveMaterial===null||this._resolveKey!==p)&&(this._resolveMaterial?.dispose(),this._resolveMaterial=this._buildResolveMaterial(r),this._resolveKey=p),this._cameraWorld.value.copy(i.matrixWorld),this._projInv.value.copy(i.projectionMatrix).invert(),r.forEach((C,M)=>{C.shadow.updateMatrices?.(C.light);let A=this._lightRows[M];C.shadow.matrix&&A.matrix.value.copy(C.shadow.matrix),A.bias.value=C.shadow.bias??0,A.normalBias.value=C.shadow.normalBias??0});let m=e,f=m.isScene===!0,g=[],y=[];m.traverse(C=>{let M=C;if(M.isMesh===!0&&M.visible!==!1){if((Array.isArray(M.material)?M.material:[M.material]).some(A=>A?.transparent===!0))g.push(M),M.visible=!1;else if(!f){let A=M;y.push({obj:A,material:A.material}),A.material=this._gBufferMaterial}}});let v=m.overrideMaterial,b=t.getRenderTarget(),_=t.getMRT(),x=t.getClearColor(Tlt),S=t.getClearAlpha(),w=i.layers,T=w.mask;w.disable(3),m.overrideMaterial=this._gBufferMaterial,t.setMRT(null),t.setClearColor(0,0),t.setRenderTarget(this._gBuffer),t.render(e,i),m.overrideMaterial=v,w.mask=T;for(let C of g)C.visible=!0;for(let C of y)C.obj.material=C.material;return $C.material=this._resolveMaterial,$C.name="SplineShadowMask.resolve",t.setRenderTarget(this._maskTarget),$C.render(t),t.setRenderTarget(b),t.setMRT(_),t.setClearColor(x,S),Lt.shadowMaskTexture.value=this._maskTarget.texture,Lt.shadowMaskGBuffer.value=this._gBuffer.texture,Lt.shadowMaskResolution.value.set(l,u),Lt.shadowMaskFullResolution.value.set(a,o),r.forEach((C,M)=>{C1t(C.shadow,M)}),Ke.shadowMaskResolves++,{targetsChanged:h}}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._maskTarget?.dispose(),this._maskTarget=null,this._gBufferMaterial.dispose(),this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._resolveKey=""}}}),k1t=j(()=>{He(),mr(),XC=new WeakMap,i5=Uyt(class extends lyt{update(t){super.update(t);let{frameId:e,object:i}=t,r=XC.get(i);r===void 0?(r={frameId:e,prev:i.matrixWorld.clone(),last:i.matrixWorld.clone()},XC.set(i,r)):r.frameId!==e&&(r.frameId=e,r.prev.copy(r.last)),this.previousModelWorldMatrix.value.copy(r.prev)}updateAfter(t){let{object:e}=t;XC.get(e)?.last.copy(e.matrixWorld)}})});function r5(t,e){let i=0,r=1,s=t;for(;s>0;)r/=e,i+=r*(s%e),s=Math.floor(s/e);return i}function rL(t){return G(t.x.div(4).add(t.y.div(2)).add(t.z.div(4)),t.x.div(2).sub(t.z.div(2)),t.x.div(-4).add(t.y.div(2)).sub(t.z.div(4)))}function Alt(t,e=!0){let i=G(t.x.add(t.y).sub(t.z),t.x.add(t.z),t.x.sub(t.y).sub(t.z));return e?Ae(i,G(0),G(1)):Qt(i,G(0))}function z1t(){let t=!1;try{let c=new URLSearchParams(window.location.search).get("dbgfp16");t=c==="1"||c==="hist"||c==="st"}catch{}let e=!1,i=()=>t||e,r=(c,p,m)=>{let f=new ri(c,p,{minFilter:me,magFilter:me,depthBuffer:!1});return i()?f.texture.type=ai:dD()&&(f.texture.internalFormat="rgba8unorm-srgb"),f.texture.name=m,f},s=r(1,1,"SplineTAA.A"),n=r(1,1,"SplineTAA.B"),a=null,o=!1,l=0,u=0,h=0,d=0;return{rtA:s,rtB:n,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new _t,jitterOffsetUV:new Q(0,0),beginJitter(c,p,m){if(o)return;let f,g;if(o=!0,(a===null||a.cam!==c)&&(a?.clearViewOffset(),a=new L1t(c)),this.unjitteredProjection.copy(c.projectionMatrix),Lt.unjitteredProjection.value.copy(c.projectionMatrix),Q1==="r2"){let y=++this.jitterIndex;f=(.5+F1t*y)%1,g=(.5+U1t*y)%1}else if(Q1==="white")this.jitterIndex++,f=Math.random(),g=Math.random();else if(Q1==="h64")f=r5(this.jitterIndex%64+1,2),g=r5(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if(Q1==="half"){let[y,v]=f2[this.jitterIndex];f=.5+.5*(y-.5),g=.5+.5*(v-.5),this.jitterIndex=(this.jitterIndex+1)%f2.length}else[f,g]=f2[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%f2.length;l=p,u=m,h=f-.5,d=g-.5,Lt.cameraJitterPx.value.set(2*h,2*d),a.setViewOffset(p,m,h,d),this.jitterOffsetUV.set(-(f-.5)/p,-(g-.5)/m),Ke.taaJitterIndex=this.jitterIndex,Ke.taaJitterApplies++},suspendJitter(){o&&a?.clearViewOffset()},resumeJitter(){o&&a!==null&&a.setViewOffset(l,u,h,d)},endJitter(){o=!1,this.jitterOffsetUV.set(0,0),a?.clearViewOffset()},resize(c,p){this.rtA.dispose(),this.rtB.dispose(),this.rtA=r(c,p,"SplineTAA.A"),this.rtB=r(c,p,"SplineTAA.B"),this.valid=!1},setHdr(c){if(e===c)return;let p=i();e=c,i()!==p&&this.resize(this.rtA.width,this.rtA.height)},dispose(){this.rtA.dispose(),this.rtB.dispose(),this.valid=!1,o=!1,a?.clearViewOffset(),a=null}}}var Clt,Elt,YC,L1t,f2,Q1,F1t,U1t,j1t,G1t,Lf,Plt,sL,Rlt,W1t,KC,nL,q1t,H1t=j(()=>{dt(),k1t(),dn(),mr(),He(),Clt=t=>t,Elt=t=>t,YC=new Pr,L1t=class{constructor(t){this.cam=t,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(t,e,i,r){this.clearViewOffset();let s=this.cam.projectionMatrix.elements,n=-2*i/t,a=2*r/e;this._savedSkewX=s[8],this._savedSkewY=s[9],this._savedShiftX=s[12],this._savedShiftY=s[13],s[8]+=n*s[11],s[9]+=a*s[11],s[12]+=n*s[15],s[13]+=a*s[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let t=this.cam.projectionMatrix.elements;t[8]=this._savedSkewX,t[9]=this._savedSkewY,t[12]=this._savedShiftX,t[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},f2=Array.from({length:16},(t,e)=>[r5(e+1,2),r5(e+1,3)]),Q1="h16";try{let t=new URLSearchParams(window.location.search).get("dbgjitseq");(t==="r2"||t==="h64"||t==="white"||t==="half")&&(Q1=t)}catch{}F1t=.7548776662466927,U1t=.5698402909980532,j1t=class extends Cr{constructor(t,e,i,r,s=!1){super("vec4"),this._resolution=gt(new Q(1,1)),this._historyValid=gt(0),this._jitterUV=gt(new Q(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=t,this.depthNode=e,this.velocityNode=i,this._hdr=s,this._history=r??z1t(),this._ownsHistory=r===void 0,this._outputTexNode=ee(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(t){i5.setProjectionMatrix(this._history.unjitteredProjection);let e=this.beautyNode.passNode.renderTarget,i=e.texture.width,r=e.texture.height,s=this._history;(s.rtA.width!==i||s.rtA.height!==r)&&(s.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=s.valid?1:0,this._jitterUV.value.copy(s.jitterOffsetUV);let n=s.flip?s.rtB:s.rtA,a=this._resolveMaterials?this._resolveMaterials[s.flip?1:0]:null,o=t.getRenderTarget(),l=t.getMRT();t.setMRT(null),s.valid||(t.setRenderTarget(s.rtA),t.clear(!0,!1,!1),t.setRenderTarget(s.rtB),t.clear(!0,!1,!1)),t.setRenderTarget(n),a&&(YC.material=a,YC.name="SplineTAA.resolve",YC.render(t)),t.setRenderTarget(o),t.setMRT(l),this._outputTexNode.value=n.texture,s.valid=!0,s.flip=!s.flip,Ke.taaResolves++,Ke.taaJitterIndex=s.jitterIndex,Ke.taaHistoryValid=!0,Ke.taaResolveSize=`${i}x${r}`}setup(t){let e=t.renderer.reversedDepthBuffer===!0,i=t.renderer.backend?.isWebGLBackend===!0,r=!1,s=!1,n=!1,a=!1,o=!1,l=!1,u=!1,h=!1,d=!1,c=!1;try{let x=new URLSearchParams(window.location.search).get("dbgtaa");r=x==="1",s=x==="zv",n=x==="nc",a=x==="err",o=x==="hist",l=x==="red",u=x==="ns",h=x==="fb90",d=new URLSearchParams(window.location.search).get("dbgjit")==="mark",c=x==="hold"}catch{}let p=this.beautyNode,m=this.velocityNode,f=this.depthNode,g=this._resolution,y=this._historyValid,v=this._jitterUV,b=x=>{let S=p.sample(x);return lt(rL(S.rgb),S.a)},_=x=>{let S=Et(()=>{let T=bi().toVar();if(d)return lt(v.x.mul(400).add(.5),v.y.mul(400).add(.5),I(.5),I(1));let C=T,M=at(I(1).div(g.x),I(1).div(g.y)).toVar(),A=[[-1,1],[0,1],[1,1],[-1,0],[0,0],[1,0],[-1,-1],[0,-1],[1,-1]].map(([Hi,li])=>T.add(at(M.x.mul(Hi),M.y.mul(li))).toVar()),R=A,O=I(e?-1e3:1e3).toVar(),N=at(A[4]).toVar();for(let Hi=0;Hi<9;Hi++){let li=Clt(f.load(Zn(A[Hi].mul(Elt(g)))).r).toVar(),Ur=e?li.greaterThan(O):li.lessThan(O);O.assign(Ur.select(li,O)),N.assign(Ur.select(A[Hi],N))}let B=m.load(Zn(N.mul(g))).xy.mul(at(.5,-.5)).toVar();s&&B.assign(at(0,0));let L=T.sub(B).toVar(),z=i?at(L.x,I(1).sub(L.y)).toVar():L,k=b(C).toVar();if(r)return lt(B.x.mul(20).add(.5),B.y.mul(20).add(.5),y,I(1));if(l){let Hi=new br(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return Hi.needsUpdate=!0,ee(Hi).sample(T)}if(o){let Hi=i?at(T.x,I(1).sub(T.y)):T;return x.sample(Hi)}if(a){let Hi=i?at(T.x,I(1).sub(T.y)):T,li=x.sample(z),Ur=x.sample(Hi),Jr=k.x,jr=Ui=>rL(Ui.rgb).x;return lt(jr(li).sub(Jr).abs().mul(8),jr(Ur).sub(Jr).abs().mul(8),I(0),I(1))}let V=z.mul(g).toVar(),H=ce(V.sub(.5)).add(.5).toVar(),W=V.sub(H).toVar(),X=W.mul(W.mul(W.mul(-.5).add(1)).add(-.5)).toVar(),st=W.mul(W).mul(W.mul(1.5).add(-2.5)).add(1).toVar(),nt=W.mul(W.mul(W.mul(-1.5).add(2)).add(.5)).toVar(),xt=W.mul(W).mul(W.mul(.5).add(-.5)).toVar(),pt=st.add(nt).toVar(),K=nt.div(pt).toVar(),ct=H.sub(1).div(g).toVar(),St=H.add(2).div(g).toVar(),wt=H.add(K).div(g).toVar(),Tt=lt(0).toVar();Tt.addAssign(x.sample(at(wt.x,ct.y)).mul(pt.x.mul(X.y))),Tt.addAssign(x.sample(at(ct.x,wt.y)).mul(X.x.mul(pt.y))),Tt.addAssign(x.sample(at(wt.x,wt.y)).mul(pt.x.mul(pt.y))),Tt.addAssign(x.sample(at(St.x,wt.y)).mul(xt.x.mul(pt.y))),Tt.addAssign(x.sample(at(wt.x,St.y)).mul(pt.x.mul(xt.y)));let yt=lt(rL(Tt.rgb),Tt.a).toVar();if(c)return lt(Alt(yt.rgb).mul(G(1,.55,.55)),Tt.a);let Ot=b(R[0]).toVar(),Ft=b(R[1]).toVar(),Bt=b(R[2]).toVar(),zt=b(R[3]).toVar(),Vt=b(R[4]).toVar(),Wt=b(R[5]).toVar(),$t=b(R[6]).toVar(),Pt=b(R[7]).toVar(),oe=b(R[8]).toVar(),jt=lt(ii(Ot,ii(Ft,ii(Bt,ii(zt,ii(Vt,ii(Wt,ii($t,ii(Pt,oe))))))))).toVar(),Zt=lt(Qt(Ot,Qt(Ft,Qt(Bt,Qt(zt,Qt(Vt,Qt(Wt,Qt($t,Qt(Pt,oe))))))))).toVar(),Jt=lt(ii(Ft,ii(zt,ii(Vt,ii(Wt,Pt))))).toVar(),$=lt(Qt(Ft,Qt(zt,Qt(Vt,Qt(Wt,Pt))))).toVar();jt.assign(jt.add(Jt).mul(.5)),Zt.assign(Zt.add($).mul(.5));let se=Zt.r.sub(jt.r).mul(.25).mul(.5).toVar(),Pe=k.gb.toVar();u||(jt.y.assign(Pe.x.sub(se)),jt.z.assign(Pe.y.sub(se)),Zt.y.assign(Pe.x.add(se)),Zt.z.assign(Pe.y.add(se)));let Ve=lt(n?yt:Ae(yt,jt,Zt)).toVar(),ie=h||n?I(.9):I(.9).mul(y),oi=lt(Yt(k,Ve,ie)).toVar(),xi=Lt.tapAngle,Ks=MW(T.mul(g).add(at(xi.mul(127.1),xi.mul(311.7)))).sub(.5).mul(1/255);return lt(Alt(oi.rgb,!this._hdr).add(G(Ks)),oi.a)}),w=new Re;return w.name="SplineTAA.resolve",w.colorNode=S(),w.depthTest=!1,w.depthWrite=!1,w.blending=cr,w.needsUpdate=!0,w};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[_(ee(this._history.rtB.texture)),_(ee(this._history.rtA.texture))]},this._rebuildResolveMaterials(),this._outputTexNode}dispose(){this._ownsHistory&&this._history.dispose(),this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose(),this._resolveMaterials=null),i5.setProjectionMatrix(null)}}}),hCt=j(()=>{G1t=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(t,e){this._frames=t>0&&!e?this._frames+1:0}}}),uCt=j(()=>{}),dCt=j(()=>{dW(),mr(),He(),Lf=new Pr,Plt=new Q,Rlt=class extends Cr{static get type(){return"SMAANode"}constructor(t){super("vec4"),this.textureNode=t,this.updateBeforeType=cyt.FRAME,this._renderTargetEdges=new ri(1,1,{depthBuffer:!1,type:ai}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new ri(1,1,{depthBuffer:!1,type:ai}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new ri(1,1,{depthBuffer:!1,type:ai}),this._renderTargetBlend.texture.name="SMAANode.blend";let e=this,i=new Image;i.crossOrigin="anonymous",pZ(i,"smaa-node-area.png"),i.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new pi,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=me,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",pZ(r,"smaa-node-search.png"),r.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new pi,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=De,this._searchTexture.minFilter=De,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=gt(new Q),this._areaTextureUniform=ee(this._areaTexture),this._searchTextureUniform=ee(this._searchTexture),this._edgesTextureUniform=ee(this._renderTargetEdges.texture),this._weightsTextureUniform=ee(this._renderTargetWeights.texture),this._materialEdges=new Re,this._materialEdges.name="SMAANode.edges",this._materialWeights=new Re,this._materialWeights.name="SMAANode.weights",this._materialBlend=new Re,this._materialBlend.name="SMAANode.blend",this._textureNode=Xyt(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(t,e){this._invSize.value.set(1/t,1/e),this._renderTargetEdges.setSize(t,e),this._renderTargetWeights.setSize(t,e),this._renderTargetBlend.setSize(t,e)}updateBefore(t){let{renderer:e}=t;sL=Hj.resetRendererState(e,sL);let i=e.getDrawingBufferSize(Plt);this.setSize(i.width,i.height),e.setRenderTarget(this._renderTargetEdges),Lf.material=this._materialEdges,Lf.render(e),e.setRenderTarget(this._renderTargetWeights),Lf.material=this._materialWeights,Lf.render(e),e.setRenderTarget(this._renderTargetBlend),Lf.material=this._materialBlend,Lf.render(e),Hj.restoreRendererState(e,sL)}setup(t){let e=at(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||bi(),s=Et(()=>{let g=lt(r.xy,r.xy).add(lt(this._invSize.xy,this._invSize.xy).mul(lt(-1,0,0,-1))),y=lt(r.xy,r.xy).add(lt(this._invSize.xy,this._invSize.xy).mul(lt(1,0,0,1))),v=lt(r.xy,r.xy).add(lt(this._invSize.xy,this._invSize.xy).mul(lt(-2,0,0,-2)));return Lr("vec4","vOffset0").assign(g),Lr("vec4","vOffset1").assign(y),Lr("vec4","vOffset2").assign(v),dR}),n=Et(()=>{let g=Lr("vec4","vOffset0"),y=Lr("vec4","vOffset1"),v=Lr("vec4","vOffset2"),b=at(.1,.1),_=lt().toVar(),x=this.textureNode.sample(r).rgb.toVar(),S=this.textureNode.sample(g.xy).rgb.toVar(),w=Le(x.sub(S));_.x=Qt(w.r,w.g,w.b);let T=this.textureNode.sample(g.zw).rgb.toVar();w=Le(x.sub(T)),_.y=Qt(w.r,w.g,w.b);let C=Ai(b,_.xy).toVar();kt(C,at(1,1)).equal(0).discard();let M=this.textureNode.sample(y.xy).rgb.toVar();w=Le(x.sub(M)),_.z=Qt(w.r,w.g,w.b);let A=this.textureNode.sample(y.zw).rgb.toVar();w=Le(x.sub(A)),_.w=Qt(w.r,w.g,w.b);let R=Qt(_.x,_.y,_.z,_.w).toVar(),O=this.textureNode.sample(v.xy).rgb.toVar();w=Le(x.sub(O)),_.z=Qt(w.r,w.g,w.b);let N=this.textureNode.sample(v.zw).rgb.toVar();return w=Le(x.sub(N)),_.w=Qt(w.r,w.g,w.b),R=Qt(R,_.z,_.w),C.xy.mulAssign(at(Ai(I(.5).mul(R),_.xy))),lt(C,0,0)}),a=Et(([g,y,v,b])=>{let _=at(y).toVar();return _.r=v.add(_.r.mul(b)),I(255).mul(g.sample(_)).r}),o=Et(([g,y,v,b,_])=>{let x=I(16).mul(I(4).mul(at(v,b)).round()).add(y);return x=e.mul(x).add(I(.5).mul(e)),x.y.addAssign(I(i).mul(_)),g.sample(x).rg}),l=Et(([g,y,v,b])=>{let _=at(0,1).toVar(),x=at(v).toVar();return Ji({start:mt(0),end:mt(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.subAssign(at(2,0).mul(this._invSize)),bt(x.x.lessThanEqual(b).or(_.g.lessThanEqual(I(.8281)).or(_.r.notEqual(I(0)))),()=>{sa()})}),x.x.addAssign(I(.25).mul(this._invSize.x)),x.x.addAssign(this._invSize.x),x.x.addAssign(I(2).mul(this._invSize.x)),x.x.subAssign(this._invSize.x.mul(a(y,_,0,.5))),x.x}),u=Et(([g,y,v,b])=>{let _=at(0,1).toVar(),x=at(v).toVar();return Ji({start:mt(0),end:mt(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.addAssign(at(2,0).mul(this._invSize)),bt(x.x.greaterThanEqual(b).or(_.g.lessThanEqual(I(.8281)).or(_.r.notEqual(I(0)))),()=>{sa()})}),x.x.subAssign(I(.25).mul(this._invSize.x)),x.x.subAssign(this._invSize.x),x.x.subAssign(I(2).mul(this._invSize.x)),x.x.addAssign(this._invSize.x.mul(a(y,_,.5,.5))),x.x}),h=Et(([g,y,v,b])=>{let _=at(1,0).toVar(),x=at(v).toVar();return Ji({start:mt(0),end:mt(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.addAssign(at(0,-2).mul(this._invSize)),bt(x.y.lessThanEqual(b).or(_.r.lessThanEqual(I(.8281)).or(_.g.notEqual(I(0)))),()=>{sa()})}),x.y.addAssign(I(.25).mul(this._invSize.y)),x.y.addAssign(this._invSize.y),x.y.addAssign(I(2).mul(this._invSize.y)),x.y.subAssign(this._invSize.y.mul(a(y,_.gr,0,.5))),x.y}),d=Et(([g,y,v,b])=>{let _=at(1,0).toVar(),x=at(v).toVar();return Ji({start:mt(0),end:mt(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.subAssign(at(0,-2).mul(this._invSize)),bt(x.y.greaterThanEqual(b).or(_.r.lessThanEqual(I(.8281)).or(_.g.notEqual(I(0)))),()=>{sa()})}),x.y.subAssign(I(.25).mul(this._invSize.y)),x.y.subAssign(this._invSize.y),x.y.subAssign(I(2).mul(this._invSize.y)),x.y.addAssign(this._invSize.y.mul(a(y,_.gr,.5,.5))),x.y}),c=Et(()=>{let g=r.xy.div(this._invSize),y=lt(r.xy,r.xy).add(lt(this._invSize.xy,this._invSize.xy).mul(lt(-.25,-.125,1.25,-.125))).toVar(),v=lt(r.xy,r.xy).add(lt(this._invSize.xy,this._invSize.xy).mul(lt(-.125,-.25,-.125,1.25))).toVar(),b=lt(y.xz,v.yw).add(lt(-2,2,-2,2).mul(lt(this._invSize.xx,this._invSize.yy)).mul(I(8))).toVar();return Lr("vec2","vPixcoord").assign(g),Lr("vec4","vOffset0").assign(y),Lr("vec4","vOffset1").assign(v),Lr("vec4","vOffset2").assign(b),dR}),p=Et(()=>{let g=Lr("vec2","vPixcoord"),y=Lr("vec4","vOffset0"),v=Lr("vec4","vOffset1"),b=Lr("vec4","vOffset2"),_=lt(0,0,0,0).toVar(),x=lt(0,0,0,0).toVar(),S=this._edgesTextureUniform.sample(r).rg.toVar();return bt(S.g.greaterThan(I(0)),()=>{let w=at().toVar(),T=at().toVar();T.x=l(this._edgesTextureUniform,this._searchTextureUniform,y.xy,b.x),T.y=v.y,w.x=T.x;let C=this._edgesTextureUniform.sample(T).r.toVar(),M=at().toVar();M.x=u(this._edgesTextureUniform,this._searchTextureUniform,y.zw,b.y),M.y=v.y,w.y=M.x,w=w.div(this._invSize.x).sub(g.x);let A=xl(Le(w)),R=this._edgesTextureUniform.sample(M.add(at(1,0).mul(this._invSize))).r.toVar();_.r=R,_.rg=o(this._areaTextureUniform,A,C,R,I(x.y))}),bt(S.r.greaterThan(I(0)),()=>{let w=at().toVar(),T=at().toVar();T.y=h(this._edgesTextureUniform,this._searchTextureUniform,v.xy,b.z),T.x=y.x,w.x=T.y;let C=this._edgesTextureUniform.sample(T).g.toVar(),M=at().toVar();M.y=d(this._edgesTextureUniform,this._searchTextureUniform,v.zw,b.w),M.x=y.x,w.y=M.y,w=w.div(this._invSize.y).sub(g.y);let A=xl(Le(w)),R=this._edgesTextureUniform.sample(M.add(at(0,1).mul(this._invSize))).g.toVar();_.ba=o(this._areaTextureUniform,A,C,R,I(x.x))}),_}),m=Et(()=>{let g=lt(r.xy,r.xy).add(lt(this._invSize.xy,this._invSize.xy).mul(lt(1,0,0,1)));return Lr("vec4","vOffset1").assign(g),dR}),f=Et(()=>{let g=Lr("vec4","vOffset1"),y=lt().toVar(),v=lt().toVar();return v.xz=this._weightsTextureUniform.sample(r).xz,v.y=this._weightsTextureUniform.sample(g.zw).g,v.w=this._weightsTextureUniform.sample(g.xy).a,bt(kt(v,lt(1)).lessThan(1e-5),()=>{y.assign(this.textureNode.sample(r))}).Else(()=>{let b=at().toVar();b.x=v.a.greaterThan(v.b).select(v.a,v.b.negate()),b.y=v.g.greaterThan(v.r).select(v.g,v.r.negate()),bt(Le(b.x).greaterThan(Le(b.y)),()=>{b.y.assign(0)}).Else(()=>{b.x.assign(0)});let _=this.textureNode.sample(r).toVar(),x=at(r).toVar();x.addAssign(Ku(b).mul(this._invSize));let S=this.textureNode.sample(x).toVar(),w=Le(b.x).greaterThan(Le(b.y)).select(Le(b.x),Le(b.y)).toVar(),T=Yt(_,S,w);y.assign(T)}),y});return this._materialEdges.vertexNode=s().context(t.getSharedContext()),this._materialEdges.fragmentNode=n().context(t.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(t.getSharedContext()),this._materialWeights.fragmentNode=p().context(t.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=m().context(t.getSharedContext()),this._materialBlend.fragmentNode=f().context(t.getSharedContext()),this._materialBlend.needsUpdate=!0,this._textureNode}dispose(){this._renderTargetEdges.dispose(),this._renderTargetWeights.dispose(),this._renderTargetBlend.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose()}_getAreaTexture(){return""}_getSearchTexture(){return""}},W1t=t=>new Rlt(wyt(t))}),cCt=j(()=>{dt(),mr(),He(),dCt(),dn(),KC=new Q,nL=new ae,q1t=class{constructor(){this._rt=null,this._texNode=null,this._smaaNode=null,this._material=null,this._quad=null,this._depthTexNode=null,this._seedMaterial=null,this._seedQuad=null}_ensureTarget(t,e,i){if(this._rt===null||this._rt.width!==t||this._rt.height!==e){this._rt?.dispose();let r=new ri(t,e,{depthBuffer:!0,stencilBuffer:!1,samples:0});r.texture.name="SplineHelperOverlay.color",this._rt=r}if(this._texNode===null){this._texNode=ee(this._rt.texture),this._smaaNode=W1t(this._texNode);let r=new Re;r.name="SplineHelperOverlayComposite",r.fragmentNode=this._smaaNode,r.transparent=!0,r.blending=FR,r.blendEquation=sv,r.blendSrc=UR,r.blendDst=Vg,r.blendSrcAlpha=UR,r.blendDstAlpha=Vg,r.depthTest=!1,r.depthWrite=!1,this._material=r,this._quad=new Pr(r);let s=new Re;s.name="SplineHelperOverlayDepthSeed",this._depthTexNode=ee(i),s.depthNode=this._depthTexNode.x,s.fragmentNode=lt(0),s.colorWrite=!1,s.depthTest=!1,s.depthWrite=!0,this._seedMaterial=s,this._seedQuad=new Pr(s)}else this._texNode.value!==this._rt.texture&&(this._texNode.value=this._rt.texture),this._depthTexNode.value!==i&&(this._depthTexNode.value=i);return this._rt}render(t,e,i,r,s){t.getDrawingBufferSize(KC);let n=this._ensureTarget(KC.x,KC.y,s),a=t.getRenderTarget(),o=t.autoClear;t.getClearColor(nL);let l=t.getClearAlpha();if(t.autoClear=!1,t.setRenderTarget(n),t.setClearColor(0,0),t.clear(!0,!0,!1),this._seedQuad.render(t),e&&t.render(e,r),t.clear(!1,!0,!1),i&&t.render(i,r),t.setRenderTarget(a),t.setClearColor(nL,l),function(){try{return new URLSearchParams(window.location.search).get("dbgoutguard")!=="0"}catch{return!0}}()){let u=t.toneMapping,h=t.outputColorSpace;t.toneMapping=dl,t.outputColorSpace=Zi.workingColorSpace,this._quad.render(t),t.toneMapping=u,t.outputColorSpace=h}else this._quad.render(t);t.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}}),P9,gR,yR,pCt=j(()=>{mr(),P9=new WeakMap,gR=new Set,yR=0});function Dlt(t){let e=t.parent?.selectedTexture;return e&&e.isTexture===!0?e:null}function ZC(t){let e=t.src.array,i=t.attr.array;for(let r=0,s=Math.min(e.length,i.length);r<s;r++)i[r]=e[r];t.attr.needsUpdate=!0}var R9,g2,z1,D9,mCt=j(()=>{dt(),mr(),He(),R9=new WeakMap,g2=new Set,z1=0,D9=new WeakMap}),fCt=j(()=>{});function $1t(t,e,i,r){let s=t.num(0),n=t.num(1),a=t.num(.5),o=t.num(2),l=t.num(X1t),u=h=>t.sub(n,h);switch(e){case 0:return i;case 1:return t.min(t.add(i,r),n);case 3:return t.mul(t.add(i,r),a);case 4:{let h=t.max(u(t.div(u(i),t.max(r,l))),s);return t.mix(r,h,t.step(l,r))}case 5:{let h=t.min(t.div(i,t.max(u(r),l)),n);return t.mix(h,r,t.step(n,r))}case 6:return t.min(i,r);case 7:return t.abs(t.sub(i,r));case 8:return t.sub(t.add(i,r),t.mul(o,t.mul(i,r)));case 9:return t.max(i,r);case 10:return t.mul(i,r);case 11:{let h=t.min(t.div(i,t.max(r,l)),n);return t.mix(n,h,t.step(l,r))}case 12:return u(t.abs(t.sub(u(i),r)));case 14:{let h=t.mul(o,t.mul(i,r)),d=u(t.mul(o,t.mul(u(i),u(r))));return t.mix(h,d,t.step(a,i))}case 15:{let h=t.min(t.div(t.mul(i,i),t.max(u(r),l)),n);return t.mix(h,r,t.step(n,r))}case 16:return u(t.mul(u(i),u(r)));case 17:{let h=t.mul(o,r),d=t.add(t.mul(i,h),t.mul(t.mul(i,i),u(h))),c=t.add(t.mul(t.sqrt(t.max(i,s)),t.sub(h,n)),t.mul(t.mul(o,i),u(r)));return t.mix(d,c,t.step(a,r))}case 18:return t.max(t.sub(t.add(i,r),n),s);default:return r}}var X1t,gCt=j(()=>{X1t=1e-6});function Ff(t,e,i,r,s){if(i===0)return t;if(i===2)return Yt(t,e,ii(s,r));let n=$1t(Y1t,i,t,e);return Yt(t,n,r)}function aL(t,e,i,r){if(i===0)return t;if(i===2)return Qt(t,ii(e,r));let s=$1t(K1t,i,t,e);return Yt(t,s,r)}function oL(){return bR===null&&(bR=Fv({output:qyt,velocity:i5})),bR}var Oh,vR,Y1t,K1t,bR,_R,N9,xR,lL,O9,I9,OW,yCt=j(()=>{dt(),mr(),He(),H1t(),k1t(),p1t(),fCt(),pW(),dn(),gCt(),ke(),Oh=t=>t,vR=t=>t,K1t=Y1t={num:t=>I(t),add:(t,e)=>t.add(e),sub:(t,e)=>t.sub(e),mul:(t,e)=>t.mul(e),div:(t,e)=>t.div(e),min:(t,e)=>ii(t,e),max:(t,e)=>Qt(t,e),abs:t=>Le(t),sqrt:t=>xl(t),step:(t,e)=>Ai(t,e),mix:(t,e,i)=>Yt(t,e,i)},bR=null}),vCt=j(()=>{_R={enabled:!1},N9=new WeakMap,xR=new WeakSet}),bCt=j(()=>{dt(),mr(),He(),lW(),J5(),Z5(),lL=Et(t=>{let e=t.lightDistance,i=t.cutoffDistance,r=t.decayExponent,s=i.greaterThan(0).and(r.greaterThan(0));return fi(s,e.div(i).oneMinus().clamp().pow(r),I(1))}),O9=class extends $j{static get type(){return"SplinePointLightNode"}setupDirect(t){let e=this.getLightVector(t),i=e.normalize(),r=lL({lightDistance:e.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},I9=class extends h2{static get type(){return"SplineSpotLightNode"}setupDirect(t){let e,i,r=this.light,s=this.getLightVector(t),n=s.normalize(),a=n.dot(Dyt(r)),o=this.getSpotAttenuation(t,a),l=lL({lightDistance:s.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),u=this.colorNode.mul(o).mul(l),h=r;if(h.colorNode?(i=this.getLightCoord(t),e=h.colorNode(i)):h.map&&(i=this.getLightCoord(t),e=ee(h.map,i.xy).onRenderUpdate(()=>h.map)),e&&i){let d=i.mul(2).sub(1).abs().lessThan(1).all();u=fi(d,u.mul(e),u)}return{lightColor:u,lightDirection:n}}}}),Z1t=j(()=>{OW=null});function _Ct(){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.hidden===!0?Promise.resolve():new Promise(t=>{let e=!1,i=()=>{e||(e=!0,clearTimeout(r),t())},r=setTimeout(i,250);requestAnimationFrame(i)})}var Nlt,Ny,Olt,Ilt,Blt,hL,uL,Vlt,klt,zlt,Llt,Vd,wp,Zx,Sp,QC,dL,Qx,Uf,Su,Oy,Flt,jf,Tu,Jx,Iy,JC,Gf,Mu,cL,pL,mL,tE,fL,gL,eE,iE,Tp,yL,vL,bL,_L,xL,wL,SL,TL,IW,Ult=j(()=>{dt(),mr(),He(),eCt(),_1t(),uW(),tD(),EW(),JG(),Qh(),iCt(),ke(),w1t(),_0t(),YG(),S1t(),T1t(),sCt(),nCt(),dn(),V1t(),A1t(),lCt(),H1t(),hCt(),uCt(),cCt(),pCt(),mCt(),yCt(),vCt(),bCt(),Z1t(),Nlt=new P,Ny=new P,Olt=new ae,Ilt=new ae,Blt=new ae,hL=new P,uL=new P,Vlt=new Q,klt=new P(1,0,0),zlt=new P(0,1,0),Llt=new P(0,0,1),Vd=new P,wp=new P,Zx=new P,Sp=new P,QC=new _t,dL=new P,Qx=new P,Uf=new Ra,Su=new Me,Oy=new Me,Flt=new Q,jf=new Q,Tu=new P,Jx=new P,Iy=new P,JC=new P,Gf=new P,Mu=[],cL=!1,pL=!1,mL=!1,tE="full",fL="g16",gL=!1,eE=!1,iE=!1,Tp="default",yL=!1,vL=!0,bL=!0,_L=!0,xL=!0,wL=!0,SL=Tj;try{let t=new URLSearchParams(window.location.search),e=t.get("instancing");if(e!==null)if(e==="off"||e==="0"||e==="false"||e==="no")wL=!1;else{let s=Number.parseInt(e,10);Number.isFinite(s)&&s>1&&(SL=s)}cL=t.get("dbgao")==="0",pL=t.get("dbgshadow")==="0",mL=t.get("dbgfp16")==="1",gL=t.get("dbgsky")==="0",eE=t.get("dbgssr")==="0",iE=t.get("dbgibl")==="0";let i=t.get("pbrcolor");i==="0"?Tp="off":(i==="linear"||i==="aces"||i==="agx"||i==="neutral")&&(Tp=i),yL=t.get("dbgplanar")==="0",vL=t.get("dbgplanarpyr")!=="0",bL=t.get("dbgssrpyr")!=="0",_L=t.get("dbgssrhalf")!=="0",xL=t.get("dbgssrresolve")!=="0";let r=t.get("dbgprefilter");r==="0"?tE="off":r==="base"?tE="base":r==="k4"&&(fL="k4")}catch{}(IW=TL=class extends hyt{constructor(t={}){var e;super({canvas:t.canvas,alpha:t.alpha??!0,antialias:t.antialias??!1,forceWebGL:t.forceWebGL??!1,powerPreference:t.powerPreference,trackTimestamp:t.trackTimestamp??globalThis.__SPLINE_TRACK_TIMESTAMP__===!0,stencil:!1,requiredLimits:t.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:mL?ai:bl,asyncCompilation:t.asyncCompilation===!0||t.asyncCompilation==="load"}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new Q,this.dummyCamera=new ks,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this._shadowMapMissingAtSync=!1,this._shadowSyncPromotions=-1,this._lightShadowStateDirty=!1,this._lightShadowSignatures=new WeakMap,this._shadowMapIds=new WeakMap,this._shadowMapIdSeq=0,this.temporalAAEnabled=!0,this.hdrChainActive=!1,this.isWebGPUSplineRenderer=!0,this.shadowFilterHook=oCt,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new G1t,this._stallWarned=!1,this._asyncCompilationMode=!1,this._asyncLoadWarmupsInFlight=0,this.sceneBundlesEnabled=!1,this.sceneBundlesForceRerecord=!1,this._appliedWidth=-1,this._appliedHeight=-1,this._appliedRatio=-1,this._bundleStates=new WeakMap,this._skySystem=null,this._skyFeatureWarned=!1,this.skyAnimationAllowed=!1,this.skyEnvironmentNeeded=!0,this._bundledPages=new Set,this._bundleValveArmed=!1,this._destroyedSubmitErrors=0,this._destroyedSubmitLastFrame=-10,this._warmupTarget=null,this.renderStarted=!1,this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._grabWarmupTarget=null,this._warnedHelperIncompat=new WeakSet,this._maskLights=[],this._maskBlocked=!1,this.suppressShadowMask=!1,this._grabTargetEpoch=0,this._retiredGrabTargets=[],this._retiredGpuBuffers=[],this._bundleEpochDirty=!1,this._encodeMaterials={},this._transmissionChain=[],this._reflectionColorChain=[],this._reflectionDepthChain=[],this._reflectionPassesKey="",this._reflectionResolveMarchKey="",this._planarChain=[],this._frameSerial=0,this._asyncCompilationMode=t.asyncCompilation??!1,this._updateCompilationBurst(),m9&&function(){if(!g9){if(g9=!0,K4=()=>Lt.frameIndex.value,typeof GPUBuffer<"u"){let i=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return mlt("buffer",this.label,this.size),i.call(this)}}if(typeof GPUTexture<"u"){let i=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return mlt("texture",this.label,`${this.width}x${this.height}`),i.call(this)}}console.info("[spline/webgpu] ?dbgdestroys=1 \u2014 GPU resource destroy logging armed; reproduce the error and read the [dbgdestroys] dumps")}}(),this.pipeline=new RW(this),this.library.addLight(x1t,Y4),this.shadowMap.enabled=!0,this.shadowMap.type=VR,e=this.backend?.isWebGPUBackend===!0,m2=e,this._deferGpuBufferDestruction(),function(i){let r=i;if(r==null||typeof r._draw!="function"||r.__splineDrawGuardInstalled===!0)return;r.__splineDrawGuardInstalled=!0;let s=r._draw.bind(r);r._draw=function(n,a,o,l,u,h,d,c,p){if(d.vertexCount>0&&n.getIndex()===null&&n.getIndirect()===null&&n.object.isBatchedMesh!==!0){let m=d.firstVertex+d.vertexCount;for(let f=0;f<h.length;f++){let g=h[f];if(g.isInstancedBufferAttribute!==!0&&g.isInstancedInterleavedBuffer!==!0&&g.count!==void 0&&g.count<m)return}}return s(n,a,o,l,u,h,d,c,p)}}(this.backend),this.outputColorSpace=Xu,this.toneMapping=dl,function(i){let r=i.library;r.addLight(O9,lT),r.addLight(I9,ib),r.addLight(Xj,eb),r.lightNodes.delete(xS),r.lightNodes.delete(Lg),r.addLight(O9,xS),r.addLight(I9,Lg)}(this),this.sceneBundlesEnabled=t.sceneBundles===!0||t.sceneBundles==="rerecord",this.sceneBundlesForceRerecord=t.sceneBundles==="rerecord",this.auxiliary=t.auxiliary===!0,this.domElement.removeAttribute?.("data-engine")}advanceFrame(){let t=this._nodes,e=this.info;e.autoReset===!0&&e.reset(),t.nodeFrame.update(),e.frame=t.nodeFrame.frameId}get lastFrameIncomplete(){return!!(this._warmupInFlight||this._compilationHasWork&&!this._gaugesStalled)||(this._skippedAsyncDraws??0)!==0&&!this._skipStalls.stalled}get _gaugesStalled(){return this._gaugeChangedAt>0&&performance.now()-this._gaugeChangedAt>TL._GAUGE_STALL_MS}_trackGaugeStall(){let t=this._asyncCompilationGauges,e=t!==void 0&&(t.queued>0||t.pipelines>0),i=e?`${t.queued}/${t.pipelines}`:"";return e?i!==this._gaugeSnapshot?(this._gaugeSnapshot=i,void(this._gaugeChangedAt=performance.now())):void(this._gaugesStalled&&!this._gaugeStallWarned&&(this._gaugeStallWarned=!0,console.warn(`[spline/webgpu] async pipeline driver stalled (${i} in flight, no movement for ${TL._GAUGE_STALL_MS}ms) \u2014 treating frames as final so screenshots, thumbnails and the on-demand render loop keep working.`))):(this._gaugeSnapshot="",void(this._gaugeChangedAt=0))}_trackStalledSkips(t){let e=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(t,e),Ke.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${t} draw(s) are permanently skipped \u2014 their render pipelines never became ready (look for "pipeline creation failed" above). Those objects will not appear; the frame is treated as final so screenshots, thumbnails and the on-demand render loop keep working.`))}get _asyncCompilationGauges(){return this.info.asyncCompilation}get _compilationHasWork(){let t=this._asyncCompilationGauges;return t!==void 0&&(t.queued>0||t.pipelines>0)}get asyncCompilationEnabled(){return this._asyncCompilation===!0}get taaHistory(){return this._taaHistory||(this._taaHistory=z1t()),this._taaHistory}async init(){await super.init();let t=this.backend.gl;if(t&&"drawingBufferColorSpace"in t)try{t.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}return this.backend.device?.lost?.then(e=>{Ke.deviceLost=`${e?.reason??"unknown"}: ${e?.message??""}`.trim()}),this}setSize(t,e,i=!0){if(this._appliedWidth!==t||this._appliedHeight!==e||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=t,this._appliedHeight=e,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==t||this.viewportHeight!==e;this.viewportWidth=t,this.viewportHeight=e,super.setSize(t,e,i),r&&this.pipeline.resize(t,e,i)}return this}setPixelRatio(t=1){return this.getPixelRatio()!==t&&super.setPixelRatio(t),this}get hdTransmission(){return Lt.transmissionLod.value===1}set hdTransmission(t){Lt.transmissionLod.value=t===!0?1:2}renderScenePass(t,e){this.render(t,e)}_renderObjects(t,e,i,r,s=null){let n=this,a=s===null&&i.overrideMaterial===null;for(let o=0,l=t.length;o<l;o++){let{object:u,geometry:h,material:d,group:c,clippingContext:p}=t[o];a&&rCt(d)?this._renderWithDepthPrepass(u,i,e,h,d,c,r,p):n._currentRenderObjectFunction(u,i,e,h,d,c,r,p,s)}}_renderWithDepthPrepass(t,e,i,r,s,n,a,o){let l=this,u=(d,c)=>l._handleObjectFunction(t,d,e,i,a,n,o,c),h=n;t.onBeforeRender(this,e,i,r,s,h),s.side===Rn&&s.forceSinglePass===!1?(u(s.getDepthPrepassTwin($n),null),s.side=$n,u(s,"backSide"),u(s.getDepthPrepassTwin(vl),null),s.side=vl,u(s,null),s.side=Rn,Ke.depthPrepassDraws+=2):(u(s.getDepthPrepassTwin(s.side),null),u(s,null),Ke.depthPrepassDraws++),t.onAfterRender(this,e,i,r,s,h)}get skySystem(){return this._skySystem}get skyAnimationActive(){return this._skySystem?.animationActive===!0}*_liveBundledPages(){for(let t of this._bundledPages){let e=t.deref();e===void 0?this._bundledPages.delete(t):yield e}}_armBundleValve(){if(this._bundleValveArmed)return;let t=this.backend.device;typeof t?.addEventListener=="function"&&(this._bundleValveArmed=!0,t.addEventListener("uncapturederror",e=>{if(!this.sceneBundlesEnabled||!(e?.error?.message??"").toLowerCase().includes("destroyed"))return;let i=Lt.frameIndex.value,r=(i-this._destroyedSubmitLastFrame+16)%16;if(this._destroyedSubmitErrors=r<=2?this._destroyedSubmitErrors+1:1,this._destroyedSubmitLastFrame=i,!(this._destroyedSubmitErrors<4)){this.sceneBundlesEnabled=!1,Ke.bundleDisabled=!0;for(let s of this._liveBundledPages()){let n=this._bundleStates.get(s);n&&(n.disabled=!0),s.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(t,e){if(this.backend.beginBundle===void 0)return;let i=this._bundleStates.get(t);if(i===void 0){let d={signature:-1,rebuilds:0,resourceRebuilds:0,checks:0,disabled:!1,camHash:0,prevCamHash:0,epoch:0,lastEpoch:0,bufferIds:new WeakMap,bufferIdSeq:0,watched:new WeakSet,onResourceDispose:()=>{d.epoch++}};i=d,this._bundleStates.set(t,i),this._bundledPages.add(new WeakRef(t)),this._armBundleValve()}let r=t;if(i.disabled)return;{let d=e.matrixWorld.elements,c=e.projectionMatrix.elements,p=-2128831035;for(let m=0;m<16;m++)p^=1e4*d[m]|0,p=Math.imul(p,16777619),p^=1e4*c[m]|0,p=Math.imul(p,16777619);i.camHash=p}let s=-2128831035,n=d=>{s^=0|d,s=Math.imul(s,16777619)};n(this._grabTargetEpoch),n(t.fog!==null?1:0);let a=i,o=d=>{let c=d;!c||typeof c.addEventListener!="function"||a.watched.has(c)||(a.watched.add(c),c.addEventListener("dispose",a.onResourceDispose))},l=d=>{if(!d)return 0;let c=a.bufferIds.get(d);return c===void 0&&(c=++a.bufferIdSeq,a.bufferIds.set(d,c)),c},u=d=>{o(d),n(d.id),n(d.version),n(d.transparent===!0?1:0),typeof d.assetsLoaded=="function"&&n(d.assetsLoaded()?1:0)},h=!1;if(t.traverse(d=>{let c=d;if(c.isMesh===!0||c.isLine===!0||c.isPoints===!0||c.isSprite===!0){let p=c;p.isDecalObject===!0&&typeof p.updateDecal=="function"&&p.updateDecal()&&(h=!0),c.frustumCulled&&(c.frustumCulled=!1),n(c.id),n(c.visible?1:0),n(c.layers.mask),n(c.renderOrder),n(c.matrixWorld.determinantAffine()<0?1:0);let m=c.geometry;o(m),n(m.id),n(m.drawRange.start),n(m.drawRange.count===1/0?-1:m.drawRange.count),n(l(m.index)),n(l(m.attributes.position)),n(m.instanceCount??-1),n(c.count===void 0?-1:c.count);let f=c.material;if(Array.isArray(f))for(let g of f)u(g);else f&&u(f)}else d.isLight===!0?(n(d.id),n(d.visible?1:0),n(d.castShadow?1:0)):(n(d.id),n(d.visible?1:0))}),n(i.epoch),i.checks++,Ke.bundleChecks=i.checks,i.checks%600==0){let d=this._bundleDebug;Ke.bundleIncompleteRecords=d?.incompleteRecords??0,Ke.bundleRecords=d?.records??0,Ke.bundleReplays=d?.replays??0,i.prevCamHash=i.camHash}if(r.isBundleGroup!==!0)return function(d){let c=d;Object.getOwnPropertyDescriptor(c,"needsUpdate")?.set||Object.defineProperty(c,"needsUpdate",{configurable:!0,enumerable:!1,get:()=>!1,set(p){p===!0&&(this.version=(this.version??0)+1)}}),c.isBundleGroup=!0,c.static=!0,typeof c.version!="number"&&(c.version=0)}(t),void(i.signature=s);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=s);if(s!==i.signature){if(i.signature=s,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch||h)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(Ke.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,Ke.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,Ke.bundleDisabled=!0)}}_ensureWarmupTarget(){if(this._warmupTarget===null){let t=new ri(2,2,{count:2});t.textures[0].name="output",t.textures[0].type=bl,t.textures[1].name="velocity",t.textures[1].type=ai;let e=new Xa(2,2);e.isRenderTargetTexture=!0,t.depthTexture=e,this._warmupTarget=t}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(t,e=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[t,e,i]:super.setRenderTarget(t,e,i)}setMRT(t){return this._warmupInFlight?(this._warmupPendingMRT=[t],this):(super.setMRT(t),this)}async compileSceneAsync(t,e){if(!e)return;{let s=t instanceof Ng?t.activePage:t;blt(dv.isSoft(s?.data?.shadow)),s&&alt(s)}if(this._asyncCompilationMode!==!1)return this._asyncCompilationMode==="load"&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(t,e);if(this.renderStarted||this._warmupInFlight)return;let i=this.getRenderTarget(),r=this.getMRT();this._warmupInFlight=!0,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst();try{this.normalizeCameraCoordinateSystem(e),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(oL())),await this.compileAsync(t,e)}catch(s){console.warn("[spline/webgpu] pipeline warm-up failed:",s)}finally{let s=this._warmupPendingTarget,n=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),s!==null?super.setRenderTarget(s[0],s[1],s[2]):super.setRenderTarget(i),n!==null?super.setMRT(n[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(t,e){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(e);let i,r=this.getRenderTarget(),s=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(oL())),i=this.compileAsync(t,e)}finally{super.setRenderTarget(r),super.setMRT(s)}let n=this._warmupGrabContext(t,e);await i,await n}catch(i){console.warn("[spline/webgpu] pipeline warm-up failed:",i)}finally{this._asyncLoadWarmupsInFlight--,this._updateCompilationBurst(),this._maybeCloseAsyncLoadWindow()}}_disposeWarmupTargets(){this._warmupTarget?.depthTexture?.dispose(),this._warmupTarget?.dispose(),this._warmupTarget=null,this._grabWarmupTarget?.depthTexture?.dispose(),this._grabWarmupTarget?.dispose(),this._grabWarmupTarget=null}_warmupGrabContext(t,e){let i=t instanceof Ng?t:t.scene;if(i.needsTransmission?.()!==!0&&i.needsReflection?.()!==!0)return null;if(this._grabWarmupTarget===null){let n=new ri(2,2);n.texture.type=bl;let a=new Xa(2,2);a.isRenderTargetTexture=!0,n.depthTexture=a,this._grabWarmupTarget=n}let r=this.getRenderTarget(),s=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(t,e)}finally{super.setRenderTarget(r),super.setMRT(s)}}_setThreeAsyncCompilation(t){this.setAsyncCompilation(t)}_updateCompilationBurst(){let t=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||this._asyncCompilationMode==="load"&&this.asyncCompilationEnabled;this.setCompilationBurst(t),Ke.compilationBurst=t}_maybeCloseAsyncLoadWindow(){this._asyncCompilationMode==="load"&&(!this.asyncCompilationEnabled||this._asyncLoadWarmupsInFlight>0||this._frameSerial!==0&&((this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled||this._compilationHasWork||(this._setThreeAsyncCompilation(!1),this._updateCompilationBurst())))}normalizeCameraCoordinateSystem(t){let e=t;(e.coordinateSystem!==this.coordinateSystem||e.perspCamera!==void 0&&e.perspCamera.coordinateSystem!==this.coordinateSystem||e.orthoCamera!==void 0&&e.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(e.coordinateSystem=this.coordinateSystem,e.perspCamera!==void 0&&(e.perspCamera.coordinateSystem=this.coordinateSystem),e.orthoCamera!==void 0&&(e.orthoCamera.coordinateSystem=this.coordinateSystem),t.updateProjectionMatrix?.())}_prepareHelpers(t,e,i){t.traverse(r=>{let s=r;if(r.isPoints===!0){let l=function(u){if(Array.isArray(u.material)||u.parent===null||u.geometry.getAttribute("position")===void 0)return null;let h=u.material;return h.isNodeMaterial===!0?null:h.isPointsMaterial===!0?function(d,c){if(c.size<=1)return null;let p=R9.get(d);return p&&(p.epoch!==z1||p.srcMaterial!==c||p.geometry!==d.geometry||p.position.src!==d.geometry.getAttribute("position")||p.map!==c.map||p.selectedMap!==Dlt(d))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(m,f){let g=m.geometry,y=g.getAttribute("position"),v=g.getAttribute("aSelection"),b=g.getAttribute("aVisibility"),_=f.map,x=Dlt(m),S=new po(y.array,3);S.setUsage(Yh);let w={src:y,attr:S,version:y.version},T=[],C=z=>{let k=new po(new Float32Array(z.count),1);k.setUsage(Yh);let V={src:z,attr:k,version:z.version};return ZC(V),T.push(V),V},M=v?C(v):null,A=b?C(b):null,R=new zS;R.name=`SplinePointsTwin(${f.name||f.type})`,R.positionNode=Wp(w.attr,"vec3"),R.size=f.size,R.sizeAttenuation=f.sizeAttenuation,R.transparent=f.transparent,R.depthTest=f.depthTest,R.depthWrite=f.depthWrite,R.blending=f.blending,R.fog=!1;let O=M?Wp(M.attr,"float"):null,N=A?Wp(A.attr,"float"):null;R.colorNode=Et(()=>{N!==null?nR(N.lessThan(.5)):O!==null&&nR(O.greaterThan(.5));let z=_!==null?ee(_,bi()):lt(1);return(O!==null&&_!==null&&x!==null?Yt(z,ee(x,bi()),O):z).mul(lt(Oyt,1))})();let B=new x8(R);B.name=`SplinePointsTwin(${m.name||m.type})`,B.frustumCulled=!1,B.raycast=()=>{};let L={sprite:B,material:R,srcMaterial:f,geometry:g,map:_,selectedMap:x,position:w,mirrors:T,epoch:z1};return g2.add(new WeakRef(L)),L}(d,c),R9.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(m,f){let{sprite:g,position:y,srcMaterial:v}=f;y.version!==y.src.version&&(f.position.attr.needsUpdate=!0,y.version=y.src.version);for(let _ of f.mirrors)_.version!==_.src.version&&(ZC(_),_.version=_.src.version);let b=Math.max(0,Math.min(f.geometry.drawRange.count,y.src.count));g.count=b,f.material.size=v.size,f.material.opacity=v.opacity,f.material.color.copy(v.color),g.layers.mask=m.layers.mask,g.renderOrder=m.renderOrder}(d,p),p.sprite}(u,h):function(d,c){if(c.isShaderMaterial!==!0)return!1;let p=c.uniforms,m=p?.pointSize?.value,f=p?.color?.value;return typeof m=="number"&&m>1&&Array.isArray(f)&&f.length>=3&&d.geometry.getAttribute("hover")!==void 0&&d.geometry.getAttribute("selected")!==void 0}(u,h)?function(d,c){let p=D9.get(d);return p&&(p.epoch!==z1||p.srcMaterial!==c||p.geometry!==d.geometry||!function(m,f){let g=[[m.position,"position"],[m.hover,"hover"],[m.selected,"selected"]];for(let[y,v]of g){let b=f.getAttribute(v);if(b===void 0)return!1;if(y.src!==b){if(b.count!==y.attr.count)return!1;y.src=b,y.version=-1}}return!0}(p,d.geometry))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(m,f){let g=m.geometry,y=f.uniforms,v=(O,N)=>{let B=new po(new Float32Array(O.count*N),N);B.setUsage(Yh);let L={src:O,attr:B,version:O.version};return ZC(L),L},b=v(g.getAttribute("position"),3),_=v(g.getAttribute("hover"),1),x=v(g.getAttribute("selected"),1),S=gt(y.pointSize.value),w=gt(new ae().fromArray(y.color.value)),T=new zS;T.name=`SplinePointsTwin(${f.name||f.type})`,T.positionNode=Wp(b.attr,"vec3");let C=Wp(_.attr,"float"),M=Wp(x.attr,"float");T.sizeNode=S.add(C.mul(4)),T.sizeAttenuation=!1,T.transparent=f.transparent,T.depthTest=f.depthTest,T.depthWrite=f.depthWrite,T.blending=f.blending,T.fog=!1,T.colorNode=Et(()=>{let O=mi(bi().mul(2).sub(1)).toVar();nR(O.greaterThan(1));let N=fi(M.equal(1),G(.22,.9,.7),w.add(C.mul(.25)));return lt(fi(O.greaterThan(.75),G(1),N),1)})();let A=new x8(T);A.name=`SplinePointsTwin(${m.name||m.type})`,A.frustumCulled=!1,A.raycast=()=>{};let R={sprite:A,material:T,srcMaterial:f,geometry:g,pointSize:S,color:w,position:b,hover:_,selected:x,epoch:z1};return g2.add(new WeakRef(R)),R}(d,c),D9.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(m,f){for(let v of[f.position,f.hover,f.selected])v.version!==v.src.version&&(ZC(v),v.version=v.src.version);let g=f.srcMaterial.uniforms;f.pointSize.value=g.pointSize.value,f.color.value.fromArray(g.color.value);let y=Math.max(0,Math.min(f.geometry.drawRange.count,f.position.src.count));f.sprite.count=y,f.material.opacity=f.srcMaterial.opacity,f.sprite.layers.mask=m.layers.mask,f.sprite.renderOrder=m.renderOrder}(d,p),p.sprite}(u,h):null}(r);if(l!==null)return l.visible=s.visible,void(s.visible&&(e.push(s),s.visible=!1))}let n=!1,a="",o=Array.isArray(s.material)?s.material:s.material?[s.material]:[];for(let l of o){let u=l;if(u.isShaderMaterial===!0&&u.isNodeMaterial!==!0){n=!0,a=`WebGL-only material "${u.type}"`;break}}if(n&&!Array.isArray(s.material)){let l=function(u){return u.isLineMaterial===!0?function(h){let d=P9.get(h);if(!d||d.epoch!==yR){let g=new oyt;g.name=`SplineHelperTwin(${h.name||h.type})`,g.worldUnits=!1,d={twin:g,epoch:yR},P9.set(h,d),gR.add(new WeakRef(g))}let c=d.twin,p=h;c.color.copy(p.color),c.linewidth=p.linewidth,c.opacity=p.opacity,c.transparent=p.transparent,c.depthTest=p.depthTest,c.depthWrite=p.depthWrite,c.side=p.side;let m=p.dashed===!0;if(c.dashed!==m&&(c.dashed=m,c.needsUpdate=!0),m){let g=c;g.dashScale=p.dashScale??1,g.dashSize=p.dashSize??1,g.gapSize=p.gapSize??1}let f=p.vertexColors===!0||p.vertexColors===2;return c.vertexColors!==f&&(c.vertexColors=f,c.needsUpdate=!0),c}(u):null}(s.material);if(l)return i.push({object:s,original:s.material}),void(s.material=l)}!n&&s.geometry?.isInstancedBufferGeometry===!0&&!Number.isFinite(s.geometry.instanceCount??0)&&(n=!0,a="infinite instanceCount geometry"),n&&s.visible&&(this._warnedHelperIncompat.has(r)||this._warnedHelperIncompat.add(r),e.push(s),s.visible=!1)})}renderHelperOverlay(t,e,i,r){let s=[],n=[];if(t&&this._prepareHelpers(t,s,n),e&&this._prepareHelpers(e,s,n),r)this._helperOverlay??(this._helperOverlay=new q1t),this._helperOverlay.render(this,t,e,i,r),Ke.helperOverlayMode="smaa";else{let a=this.autoClear;this.autoClear=!1,t&&this.render(t,i),e&&(this.clearDepth(),this.render(e,i)),this.autoClear=a,Ke.helperOverlayMode="direct"}for(let a of n)a.object.material=a.original;for(let a of s)a.visible=!0}createEffectChain(){return function(t){let e=t.pipeline,i=e.postprocessingState,r=i.enabled===!0,s=$yt(e.scene,e.camera),n=t.hdrChainActive;try{let M=new URLSearchParams(window.location.search).get("dbgfp16");(M==="scene"||M==="st")&&(n=!0)}catch{}let a=s.getTextureNode(),o=a,l=null;if(t.temporalAAEnabled){s.setMRT(oL()),l=function(M,A,R,O,N=!1){return new j1t(M,A,R,O,N)}(a,s.getTextureNode("depth"),s.getTextureNode("velocity"),t.taaHistory,n),o=l,s.getTexture("velocity").type=ai;try{if(new URLSearchParams(window.location.search).get("dbgvel")==="1"){let M=Oh(s.getTextureNode("velocity"));o=lt(vR(M.x).mul(20).add(.5),vR(M.y).mul(20).add(.5),I(.5),I(1))}}catch{}}n?s.getTexture("output").type=ai:dD()&&(s.getTexture("output").internalFormat="rgba8unorm-srgb");let u=(M,A)=>typeof M=="number"&&Number.isFinite(M)?M:A,h={bloomIntensity:gt(1),caOffset:gt(new Q(0,0)),caAspect:gt(1),vignetteOffset:gt(0),vignetteDarkness:gt(0),hueVector:gt(new P(1,0,0)),saturationFactor:gt(0),brightness:gt(0),bcContrastScale:gt(1),dofFocusDistance:gt(0),dofFocalLength:gt(0),dofBokehScale:gt(1),dofCameraNear:gt(50),dofCameraFar:gt(1e4),dofOrtho:gt(0),pixelCells:gt(new Q(1,1)),bloomOpacity:gt(1),caOpacity:gt(1),vignetteOpacity:gt(1),noiseOpacity:gt(1),hueSaturationOpacity:gt(1),brightnessContrastOpacity:gt(1),dofOpacity:gt(1)},d=M=>vR(M),c=(M,A)=>{h.bloomIntensity.value=u(M.bloom.intensity,1),h.bloomOpacity.value=u(M.bloom.opacity,1),h.caOffset.value.set(u(M.chromaticAberration.offset?.[0],10),u(M.chromaticAberration.offset?.[1],10)),h.caOpacity.value=u(M.chromaticAberration.opacity,1),h.vignetteOffset.value=u(M.vignette.offset,.5),h.vignetteDarkness.value=u(M.vignette.darkness,.5),h.vignetteOpacity.value=u(M.vignette.opacity,1),h.noiseOpacity.value=u(M.noise.opacity,1),h.hueVector.value.fromArray(function(V){let H=Math.sin(V),W=Math.cos(V);return[(2*W+1)/3,(-Math.sqrt(3)*H-W+1)/3,(Math.sqrt(3)*H-W+1)/3]}(u(M.hueSaturation.hue,0))),h.saturationFactor.value=function(V){return V>0?1-1/(1.001-V):-V}(u(M.hueSaturation.saturation,0)),h.hueSaturationOpacity.value=u(M.hueSaturation.opacity,1),h.brightness.value=u(M.brightnessContrast.brightness,0);let R=Math.min(u(M.brightnessContrast.contrast,0),.9999);h.bcContrastScale.value=R>0?1/(1-R):1+R,h.brightnessContrastOpacity.value=u(M.brightnessContrast.opacity,1);let O=e.camera,N=O?.isPerspectiveCamera===!0,B=function(V,H,W){return{focusDistance:W?V/2e3:(V+992)/2e3,focusRange:Math.max(H/2e3,1e-6)}}(u(M.depthOfField.focusDistance,pR.focusDistance),u(M.depthOfField.focalLength,pR.focalLength),N);h.dofFocusDistance.value=B.focusDistance,h.dofFocalLength.value=B.focusRange,h.dofBokehScale.value=u(M.depthOfField.bokehScale,pR.bokehScale),h.dofOpacity.value=u(M.depthOfField.opacity,1),h.dofCameraNear.value=u(O?.near,50),h.dofCameraFar.value=u(O?.far,1e4),h.dofOrtho.value=N?0:1;let L=A.resolution.x?A.resolution:new Q(A.viewportWidth*A.getPixelRatio(),A.viewportHeight*A.getPixelRatio());h.caAspect.value=L.y>0?L.x/L.y:1;let z=Math.floor(u(M.pixelation.granularity,30));z%2>0&&(z+=1);let k=z>0;h.pixelCells.value.set(k?L.x/z:L.x,k?L.y/z:L.y)};c(i,t);let p=Oh(o),m=p.rgb,f=p.a,g=r&&i.pixelation.enabled,y=h.pixelCells,v=M=>M.mul(y).floor().add(.5).div(y),b=l?l.outputTextureNode:a;if(g){let M=Oh(b.sample(v(bi())));m=Yt(m,M.rgb,1),f=Yt(f,M.a,1)}if(r&&i.chromaticAberration.enabled){let M=i.chromaticAberration,A=h.caOffset.mul(.001).mul(at(1,d(h.caAspect))),R=L=>g?v(L):L,O=Oh(b.sample(R(bi().add(A)))),N=Oh(b.sample(R(bi().sub(A)))),B=Qt(Qt(O.a,N.a),f);m=Ff(m,G(O.r,m.g,N.b),M.blendFunction,d(h.caOpacity),B),f=aL(f,B,M.blendFunction,d(h.caOpacity))}let _=null;if(r&&i.depthOfField.enabled){let M=mZ("depthOfField");if(M){let A=i.depthOfField;_=M(lt(m,f),b,s.getTextureNode("depth"),{focusDistance:d(h.dofFocusDistance),focusRange:d(h.dofFocalLength),bokehScale:d(h.dofBokehScale),cameraNear:d(h.dofCameraNear),cameraFar:d(h.dofCameraFar),orthographic:d(h.dofOrtho)},{halfFloat:n,inputUv:g?v:void 0});let R=Oh(_);m=Ff(m,R.rgb,A.blendFunction,d(h.dofOpacity),R.a),f=aL(f,R.a,A.blendFunction,d(h.dofOpacity))}else fZ("depthOfField","webgpu")}let x=null;if(r&&i.bloom.enabled){let M=mZ("bloom");if(M){let A=i.bloom;x=M(l?l.outputTextureNode:a,{kernelSize:XMt(A.kernelSize),blurScale:u(A.blurScale,1),luminanceThreshold:u(A.luminanceThreshold,.9),luminanceSmoothing:u(A.luminanceSmoothing,.025)});let R=Ae(Oh(x).mul(d(h.bloomIntensity)),0,1);m=Ff(m,R.rgb,A.blendFunction,d(h.bloomOpacity),R.a),f=aL(f,R.a,A.blendFunction,d(h.bloomOpacity))}else fZ("bloom","webgpu")}if(r&&i.hueSaturation.enabled){let M=i.hueSaturation,A=h.hueVector,R=G(kt(m,A),kt(m,A.zxy),kt(m,A.yzx)),O=R.r.add(R.g).add(R.b).div(3);m=Ff(m,R.add(G(O).sub(R).mul(d(h.saturationFactor))).min(1),M.blendFunction,d(h.hueSaturationOpacity),f)}if(r&&i.brightnessContrast.enabled){let M=i.brightnessContrast,A=m.add(G(d(h.brightness)));A=A.sub(.5).mul(d(h.bcContrastScale)).add(.5),m=Ff(m,A.min(1),M.blendFunction,d(h.brightnessContrastOpacity),f)}if(r&&i.vignette.enabled){let M=i.vignette,A=mi(bi().sub(.5)).mul(d(h.vignetteDarkness).add(d(h.vignetteOffset))),R=tr(d(h.vignetteOffset).mul(.799),I(.8),A).oneMinus();m=Ff(m,m.mul(R),M.blendFunction,d(h.vignetteOpacity),f)}if(r&&i.noise.enabled){let M=i.noise,A=Oi(Bn($h(kt(bi().mul(l1t),at(12.9898,78.233)),Math.PI)).mul(43758.5453));m=Ff(m,G(A),M.blendFunction,d(h.noiseOpacity),f)}r&&(n?m=m.max(0):(m=Ae(m,0,1),f=Ae(f,0,1)));let S=lt(m,f);if(e.uiOverlayEnabled&&e.uiCanvasTexture){let M=Oh(ee(e.uiCanvasTexture,bi().flipY())),A=Yt(S.rgb,M.rgb,M.a),R=Ae(S.a.add(M.a),0,1);S=lt(A,R)}let w=e.sceneTransitionFromTexture;if(w){let M=Oh(ee(w,bi())),A=e.sceneTransitionPass.uniforms.mixRatio;S=Yt(M,S,A)}let T=e.watermarkTexture;if(T){let M=T.image,A=M?.width||128,R=M?.height||32,O=new Q(t.viewportWidth*t.getPixelRatio(),t.viewportHeight*t.getPixelRatio()),N=12*t.getPixelRatio(),B=.5*A*t.getPixelRatio(),L=.5*R*t.getPixelRatio(),z=at((O.x-B-N)/O.x,N/O.y),k=at(B/O.x,L/O.y),V=bi().flipY().sub(z).div(k),H=V.x.greaterThanEqual(0).and(V.x.lessThanEqual(1)).and(V.y.greaterThanEqual(0)).and(V.y.lessThanEqual(1)),W=Ae(V,0,1),X=Oh(ee(T,W)),st=X.a.mul(H.select(I(1),I(0)));S=lt(Yt(S.rgb,X.rgb,st),Ae(S.a.add(st),0,1))}let C=new uyt(t,S);return{syncValues:c,render(){s.scene=e.scene,s.camera=e.camera,C.render()},renderTAAResolve:l?M=>{s.scene=e.scene,s.camera=e.camera,l.renderResolve(M)}:null,renderBloomPasses:x?M=>{s.scene=e.scene,s.camera=e.camera,x.renderBloom(M)}:null,renderDoFPasses:_?M=>{s.scene=e.scene,s.camera=e.camera,_.renderDoF(M)}:null,resize(){},sceneDepthTexture:()=>s.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),_?.dispose(),s.dispose(),C.dispose()}}}(this)}renderSplineSceneWithDummyCamera(t,e,i=1){this.dummyCamera.updateCameraState(e.dataPatched),this.dummyCamera.matrix.copy(e.matrixWorld);let r=e.height,s=e.width,n=this.viewportWidth/this.viewportHeight;s<r?s=r*n:r=s/n,this.dummyCamera.setViewplaneSize(s,r);for(let a=0;a<i;a++)this.renderSplineScene(t,this.dummyCamera)}renderSplineScene(t,e,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(gj()?.drainRetired()??0)+(vj()?.drainRetired()??0)>0&&this._retireBundleRecords(),m9&&function(y){if(y==null||y===y9)return;let v=y;typeof v.addEventListener=="function"&&(y9=y,v.addEventListener("uncapturederror",b=>{let _=b?.error?.message??"";!_.toLowerCase().includes("destroyed")||f9<=0||(f9--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${K4()} (t=${Math.round(performance.now())}ms):
|
|
1982
1982
|
${_.slice(0,400)}
|
|
1983
|
-
\u2014 last ${wv.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,wv.map(x=>({...x}))))}))}(this.backend.device);let s=this._skippedAsyncDraws??0;Ke.skippedAsyncDraws=s,this._skippedAsyncDraws=0,this._trackStalledSkips(s),this._trackGaugeStall(),function(y){if(J2.size===0)return;let v=Array.from(J2);J2.clear();for(let b of v)b.render(y)}(this);let n=t instanceof Ng?t.activePage:t,a=n.visible;n.visible=!0;let o=n.scene;if(alt(n),this.renderStarted=!0,wL&&t instanceof Ng){let y=t.updateInstanceGroups(n,SL);Ke.instancingGroups=y.instancingGroups,Ke.instancedDrawsSaved=y.instancedDrawsSaved,Ke.instancingRegroups=y.instancingRegroups,Ke.instancingParks=y.instancingParks,Ke.instancingIneligible=y.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(n,e)),this.normalizeCameraCoordinateSystem(e),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(n.bgColor,n.bgColor.a),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride);let l=gL?null:n.skyState;if(l?.enabled===!0){if(this.skyEnvironmentNeeded=!this.auxiliary&&(!eE&&(o.needsReflectionDirty||o.needsReflection())||!iE&&l.lighting===!0),this._skySystem===null){let y=OW;y===null?this._skyFeatureWarned||(this._skyFeatureWarned=!0,console.warn("[spline] scene uses the atmospheric sky, but the sky feature is compiled out of this build")):this._skySystem=y(this)}this._skySystem?.update(n,e)}else this._skySystem?.attached&&this._skySystem.detach();if(!this.auxiliary){let y=null,v=0;!iE&&l?.enabled===!0&&this._skySystem&&(y=this._skySystem.iblTexture??null,v=this._skySystem.iblRotationY??0),function(b){if(Gh.quality===b)return!1;Gh.quality=b;for(let _ of jS)nS(_)}(l?.lightingQuality==="low"?"low":"full"),function(b){if(Gh.texture===b)return!1;Gh.texture=b,Gh.version++;for(let _ of jS)nS(_)}(y),Gh.rotation.set(0,-v,0),n.environmentIntensity=l?.enabled===!0?l.lightingIntensity??1:1}{let y=Tp==="off"?null:n.gradingState,v=Tp!=="default"&&Tp!=="off",b=v||y?.pipeline==="linear",_=v?Tp==="linear"?"none":Tp:y?.toneMapping??"aces";this.toneMapping=b?_==="aces"?k7:_==="agx"?z7:_==="neutral"?L7:dl:dl,this.toneMappingExposure=b?y?.exposure??1:1,this.outputColorSpace=b?Ns:Xu,this.hdrChainActive=b,this.temporalAAEnabled&&this.taaHistory.setHdr(b)}Lt.pixelRatio.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Lt.resolution.value.set(this.resolution.x,this.resolution.y):Lt.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let u=(Lt.frameIndex.value+1)%16;Lt.frameIndex.value=u;let h=P1t[u];Lt.pcssHalton.value.set(h[0],h[1]),Lt.tapAngle.value=Math.random()*Math.PI*2,Lt.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(n),this.sceneBundlesEnabled&&this._lightShadowStateDirty&&(this._lightShadowStateDirty=!1,this._updateSceneBundle(n,e)),Lt.unjitteredProjection.value.copy(e.projectionMatrix);let d=this.temporalAAEnabled?this.taaHistory:null;if(d){let y=this.getDrawingBufferSize(jf);d.beginJitter(e,y.x,y.y)}this._renderShadowMaskPass(n,e),Lt.orthographicUniform.value=e.projectionMatrix.elements[11]===0?1:0;let c=o.shapeBlendIntances.length>0?eW:null;if(c!==null)for(let y of o.shapeBlendIntances)c(y).update(y,this,e);let p=o.hairInstances.length>0?ZG:null;if(p!==null)for(let y of o.hairInstances)p(y).update(y,this);o.needsTransmission()&&this._renderTransmissionPass(n,e),o.needsNormal()&&this._renderNormalPass(n,e,o.normalPassNeeds()),n.overrideMaterial=o.wireframeState?L0t:null,e.layers.enable(3),e.layers.enable(8),e.layers.enable(4);let m=n.data.ao,f=m.occlusion&&!cL&&!_R.enabled;if(Lt.aoEnabled.value=f,Lt.aoEnabledUniform.value=f?1:0,f){let y=this,v=y._skippedAsyncDraws??0;this._renderAOPass(n,e,m),(y._skippedAsyncDraws??0)>v&&(Lt.aoEnabledUniform.value=0)}if(!eE&&o.needsReflection()?(this._renderReflectionPass(n,e),yL?Lt.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(n,e),this._renderReflectionResolvePass(n,e)):Lt.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(n,e),this.pipeline.isUIOverlayEnabled&&n.uiCanvas?.enabled&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0){let y=this.getPixelRatio();(n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight||n.uiCanvas.dpr!==y)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},y),n.uiCanvas.render(this),this.pipeline.uiCanvasTexture=n.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=e;let g=function(y){if(!_R.enabled)return y;let v=N9.get(y);return v||(v={...y,bloom:{...y.bloom,kernelSize:0},depthOfField:{...y.depthOfField,enabled:!1}},N9.set(y,v)),v}(n.postprocessing);if(this.pipeline.postprocessingState!==g&&this.pipeline.updatePostprocessing(g),this.pipeline.render(),d?.endJitter(),this._skySystem?.endFrame?.(),Ke.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates){let y=(this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled,v=this.info.asyncCompilation?.promotions??0,b=v!==this._shadowSyncPromotions;this._shadowSyncPromotions=v,o.shadowsDirty=this._shadowMapMissingAtSync||this._warmupInFlight||y||b}e instanceof ks&&e.copyHistory(),n.visible=a}_fitDirectionalShadowRange(t,e,i){if(i===0)return;let r=t.shadow.camera,s=t.shadow;s.__speRangeEnvelope||(s.__speRangeEnvelope={near:r.near,far:r.far});let n=s.__speRangeEnvelope.near,a=t.data?.depth??s.__speRangeEnvelope.far;if(s.__speRangeEnvelope.far=a,Iy.setFromMatrixPosition(t.matrixWorld),t.target?(t.target.updateMatrixWorld(),JC.setFromMatrixPosition(t.target.matrixWorld)):JC.set(0,0,0),Gf.subVectors(JC,Iy),Gf.lengthSq()<1e-10)return;Gf.normalize();let o=1/0,l=-1/0;for(let c=0;c<i;c++){let p=4*c,m=(e[p]-Iy.x)*Gf.x+(e[p+1]-Iy.y)*Gf.y+(e[p+2]-Iy.z)*Gf.z,f=e[p+3];m-f<o&&(o=m-f),m+f>l&&(l=m+f)}let u=Math.max(10,.05*(l-o)),h=25*Math.floor((o-u)/25),d=25*Math.ceil((l+u)/25);h=Math.max(h,n),d=Math.min(d,a),d-h>=1&&(r.near!==h||r.far!==d)&&(r.near=h,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(t){let e=0;return t.traverseVisible(i=>{let r=i;if(r.castShadow!==!0&&r.receiveShadow!==!0)return;if(r.isHairSystem===!0){let l=r.shadowBoundsRadius??0;if(l>0){r.getShadowBoundsCenter?r.getShadowBoundsCenter(Tu):Tu.setFromMatrixPosition(r.matrixWorld);let u=4*e;Mu[u]=Tu.x,Mu[u+1]=Tu.y,Mu[u+2]=Tu.z,Mu[u+3]=l,e++}return}if(r.isMesh!==!0||!r.geometry||r.isInstanceGroup===!0)return;let s=r.geometry.boundingSphere;s===null&&(r.geometry.computeBoundingSphere(),s=r.geometry.boundingSphere);let n=r;if(n.isInstancedMesh===!0&&(n.boundingSphere===null&&n.computeBoundingSphere(),s=n.boundingSphere??s),!s||!Number.isFinite(s.radius)||s.radius<=0)return;Tu.copy(s.center).applyMatrix4(r.matrixWorld),Jx.setFromMatrixScale(r.matrixWorld);let a=s.radius*Math.max(Math.abs(Jx.x),Math.abs(Jx.y),Math.abs(Jx.z)),o=4*e;Mu[o]=Tu.x,Mu[o+1]=Tu.y,Mu[o+2]=Tu.z,Mu[o+3]=a,e++}),e}_syncLightState(t){let e=dv.isSoft(t.data.shadow);blt(e),Ke.shadowTypeSoft=e,function(d){switch(d){case"low":nc=8;break;case"high":nc=32;break;default:nc=16}}(t.data.shadow?.softShadowQuality),e&&A9()&&(fR||(this.initTexture?.(b9()),fR=!0));let i=-1;Ke.pcssLights=0,Ke.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,Ke.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,s=Lt.toonLightData.array,n=0,a=this.manageShadowUpdates,o=t.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1;let l=-2128831035,u=d=>{l^=0|d,l=Math.imul(l,16777619)};t.traverseVisible(d=>{let c=d;if(function(p){if(!p.isPointLight&&!p.isSpotLight&&!p.isDirectionalLight)return!1;if(_R.enabled){if(p.castShadow===!0)return p.castShadow=!1,xR.add(p),!0}else if(xR.has(p)&&(xR.delete(p),p.castShadow===!1))return p.castShadow=!0,!0;return!1}(c)&&(t.scene.shadowsDirty=!0),a&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.shadow&&(c.shadow.autoUpdate=o,o&&c.castShadow===!0&&c.shadow.map==null&&(this._shadowMapMissingAtSync=!0)),pL&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&(c.castShadow=!1),(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&(u(d.id),u(c.castShadow===!0?1:0),u(this._shadowMapId(c.shadow?.map))),c.isPointLight&&c.castShadow&&c.shadow&&(function(p){p.filterNode!==void 0&&p.filterNode!==null?p.filterNode!==e5&&Ke.pcssForeignFilter++:(p.filterNode=e5,Ke.pcssInstalled++)}(c.shadow),vlt(c.shadow),Ke.pcssLights++),(c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&c.shadow){c.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(t)),this._fitDirectionalShadowRange(c,Mu,i)),function(f){f.filterNode!==void 0&&f.filterNode!==null?f.filterNode!==t5&&Ke.pcssForeignFilter++:(Object.defineProperty(f,"penumbraSize",{get:()=>c.data?.penumbraSize??.5,configurable:!0}),f.filterNode=t5,Ke.pcssInstalled++)}(c.shadow);let p,m=!a||o||c.shadow.needsUpdate===!0;if(e&&A9()&&(m?function(f){let g=f;g.__spePcssPyramid&&(g.__spePcssPyramid.fresh=!1)}(c.shadow):ylt(c.shadow)||function(f,g){let y=g,v=y.map?.depthTexture??null;if(v==null)return!1;let b=glt(g);if(function(T){let C=glt(T);if(C.slot>=0)return C.slot;for(let M=0;M<Z4;M++){let A=mR[M];if(A===null||A.deref()===void 0)return mR[M]=new WeakRef(T),C.slot=M,M}return-1}(g)<0)return!1;let _=Math.max(1,Math.round(y.mapSize?.x??2048)),x=b.slot*Sc,S=`${v.uuid}:${_}`;b.passKey!==S&&(b.toMid?.material?.dispose(),b.toSmall?.material?.dispose(),b.mid===null&&(b.mid=v9(V1,V1),b.mid.texture.name="SplinePCSSPyramidMid"),b.small===null&&(b.small=v9(Sc,Sc),b.small.texture.name="SplinePCSSPyramidSmall"),b.toMid=new Pr(flt(`SplinePCSSPyramidToMid${_}`,v,Math.ceil(_/V1),_-1,!1,0)),b.toSmall=new Pr(flt("SplinePCSSPyramidToSmall",b.mid.texture,V1/Sc,V1-1,!0,0)),b.passKey=S),b9();let w=f.getRenderTarget();f.setRenderTarget(b.mid),b.toMid.render(f),f.setRenderTarget(b.small),b.toSmall.render(f),f.setRenderTarget(w),S9.set(x,0,0),f.copyTextureToTexture(b.small.texture,$g.texture,null,S9),b.fresh=!0,Ke.pcssPyramidBuilds++}(this,c.shadow),p={slot:aCt(c.shadow),fresh:ylt(c.shadow)}),e&&C9()&&(C1t(c.shadow,-1),this._maskLights.push({light:c,shadow:c.shadow}),(m||c.shadow.map==null)&&(this._maskBlocked=!0)),vlt(c.shadow,c.data?.penumbraSize??.5,p)&&Ke.pcssPyramidActive++,!r){r=!0;let f=c.shadow;Ke.pcssRadius0=f.radius??-1,Ke.pcssPenumbra0=f.penumbraSize??-1}Ke.pcssLights++}if(!(n>=r9)){if(c.isPointLight||c.isSpotLight)Ny.setFromMatrixPosition(c.matrixWorld),s[n].set(Ny.x,Ny.y,Ny.z,0),n++;else if(c.isDirectionalLight&&c.target){c.target.updateMatrixWorld();let p=Ny;p.setFromMatrixPosition(c.matrixWorld),p.sub(Nlt.setFromMatrixPosition(c.target.matrixWorld)).normalize(),s[n].set(p.x,p.y,p.z,1),n++}}}),Lt.toonLightCount.value=n;let h=this._lightShadowSignatures.get(t);this._lightShadowSignatures.set(t,l),this._lightShadowStateDirty=h!==void 0&&h!==l}_shadowMapId(t){if(t==null)return 0;let e=this._shadowMapIds.get(t);return e===void 0&&(e=++this._shadowMapIdSeq,this._shadowMapIds.set(t,e)),e}_renderShadowMaskPass(t,e){let i=0;if(C9()&&!this.suppressShadowMask&&this.manageShadowUpdates&&!this._maskBlocked&&this._maskLights.length>=1&&this._maskLights.length<=4&&this._maskLights.every(r=>r.shadow.map?.depthTexture!=null)){this._shadowMask??(this._shadowMask=new B1t);let{targetsChanged:r}=this._shadowMask.render(this,t,e,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}Lt.shadowMaskEnabled.value=i>0?1:0,Ke.shadowMaskActive=i}retireRenderTarget(t){t&&this._retiredGrabTargets.push(t),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let t of this._retiredGrabTargets)t.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let t of this._retiredGpuBuffers)try{t.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let t of this._liveBundledPages())this._bundleStates.get(t)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let t=this.backend,e=this._retiredGpuBuffers;t.destroyUniformBuffer=r=>{let s=t.get(r);s?.buffer&&e.push(s.buffer),t.delete(r),this._retireBundleRecords()};let i=t.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=s=>{let n=t.get(r(s));n?.buffer&&e.push(n.buffer),t.delete(s),this._retireBundleRecords()}}}_reallocGrabTarget(t,e,i,r){return t&&t.width===e&&t.height===i?t:(this.retireRenderTarget(t),r())}_withShadowUpdatesSuspended(t,e){let i=[];t.traverse(r=>{let s=r;if(s.isLight&&s.shadow){if(s.shadow.map==null)return;i.push({shadow:s.shadow,auto:s.shadow.autoUpdate,needs:s.shadow.needsUpdate}),s.shadow.autoUpdate=!1,s.shadow.needsUpdate=!1}});try{e()}finally{for(let r of i)r.shadow.autoUpdate=r.auto,r.shadow.needsUpdate=r.needs}}_renderPrepass(t,e){this._withShadowUpdatesSuspended(t,()=>{this.render(t,e)})}_renderAOPass(t,e,i){let r=this.getDrawingBufferSize(jf),s=Math.max(1,Math.round(r.x)),n=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,s,n,()=>new ri(s,n,{depthBuffer:!1})),Lt.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new b1t);let a=t;this._hbao.render(this,t,e,{radius:i.radius,bias:i.bias??.5,aoFullRes:i.aoFullRes===!0,aoColor:a.aoColor??{r:0,g:0,b:0},fogEnabled:(a.fog??null)!==null,fogNear:a.backupFog?.near??1,fogFar:a.backupFog?.far??1e3,fogMode:ia.getModeIndex({mode:t.fogMode}),fogDensity:t.fogDensity??ia.getDensity({}),fogHeightFalloff:t.fogHeightFalloff??ia.getHeightFalloff({}),fogHeightBase:t.fogHeightBase??ia.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(t,e,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",s=this.getDrawingBufferSize(jf),n=Math.max(1,Math.round(s.x)),a=Math.max(1,Math.round(s.y));this._normalTarget!==void 0&&this._normalTargetFlavor!==r&&(this.retireRenderTarget(this._normalTarget),this._normalTarget=void 0),this._normalTargetFlavor=r,this._normalTarget=this._reallocGrabTarget(this._normalTarget,n,a,()=>{let p=new ri(n,a,{count:r==="both"?2:1,type:r==="normals"?ai:Qe,depthTexture:new Xa(n,a)});r==="both"&&(p.textures[0].name="g0",p.textures[1].name="g1",p.textures[1].type=ai);for(let m of p.textures)m.minFilter=De,m.magFilter=De;return p});let o=this._encodeMaterials[r];if(o===void 0){this._depthContrastUniform??(this._depthContrastUniform=gt(1));let p=new Re;p.name=`SplineNormalPassEncode_${r}`;let m=vm("randomColor","vec3"),f=()=>{let y=xe(LS),v=sD.sub(.5).mul(this._depthContrastUniform).add(.5),b=Yt(Yt(m,y,.2),G(v),.4);return lt(b,m.x)},g=()=>{let y=xe(Oa),v=fi(Ayt,y,y.negate());return lt(v,m.x)};p.fragmentNode=r==="both"?Fv({g0:f(),g1:g()}):r==="normals"?g():f(),p.lights=!1,p.blending=cr,p.needsUpdate=!0,this._encodeMaterials[r]=p,o=p}this._depthContrastUniform.value=e instanceof ks?(e.far-e.near)/1e4:1;let l=t.overrideMaterial,u=this.getRenderTarget(),h=this.getClearColor(Olt),d=this.getClearAlpha();e.layers.enable(8),e.layers.disable(0),e.layers.disable(3),t.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(t,e),this.setRenderTarget(u),this.setClearColor(h,d),t.overrideMaterial=l,e.layers.enable(0),e.layers.enable(3);let c=this._normalTarget.textures;Lt.normalRenderTarget.value=r==="normals"?ko:c[0],Lt.normalRenderTargetDepth.value=this._normalTarget.depthTexture,Lt.normalViewRenderTarget.value=r==="both"?c[1]:r==="normals"?c[0]:ko}blitTextureToTarget(t,e){let i=this._uiBlitPass;if(!i){let n=ee(ko),a=new Re;a.name="SplineUICanvasBlit",a.fragmentNode=n.sample(bi()),a.lights=!1,a.blending=cr,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,i={quad:new Pr(a),input:n},this._uiBlitPass=i}let r=this.getRenderTarget(),s=this.getMRT();i.input.value=t,this.setMRT(null),this.setRenderTarget(e),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(s)}_getPrefilterPass(t){this._prefilterPasses||(this._prefilterPasses=[]);let e=this._prefilterPasses[t];if(e)return e;let i=ee(ko),r=gt(new Q(1,0)),s=new Re;s.name="SplineTransmissionPrefilter";let n=bi(),a=r,o=u=>i.sample(n.add(a.mul(u))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return s.fragmentNode=lt(l,1),s.lights=!1,s.blending=cr,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,e={quad:new Pr(s),input:i,step:r},this._prefilterPasses[t]=e,e}_getDownsamplePass(t){this._downsamplePasses||(this._downsamplePasses=[]);let e=this._downsamplePasses[t];return e||(e=this._buildDownsamplePassEntry(fL,"SplineTransmissionDownsample"),this._downsamplePasses[t]=e,e)}_buildDownsamplePassEntry(t,e){let i=ee(ko),r=gt(new Q(1,1)),s=new Re;s.name=e;let n=bi(),a=r,o=(u,h)=>i.sample(n.add(at(u,h).mul(a))).rgb,l=null;if(t==="k4")for(let u=-1;u<=1;u++)for(let h=-1;h<=1;h++){let d=(h===0?2:1)*(u===0?2:1)/16,c=o(h,u).mul(d);l=l?l.add(c):c}else{let u=[-1.5,-.5,.5,1.5],h=[.1665,.3335,.3335,.1665];for(let d=0;d<4;d++)for(let c=0;c<4;c++){let p=h[c]*h[d],m=o(u[c],u[d]).mul(p);l=l?l.add(m):m}}return s.fragmentNode=lt(l,1),s.lights=!1,s.blending=cr,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,{quad:new Pr(s),input:i,step:r}}_getPlanarDownsamplePass(t){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let e=this._planarDownsamplePasses[t];return e||(e=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[t]=e,e)}_batchedMipCopies(t){let e=this.backend,i=e?.device;if(!i||typeof e?.get!="function"){for(let n of t)this.copyTextureToTexture(n.src,n.dst,null,null,0,n.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),s=0;for(let n of t){let a=e.get(n.src)?.texture,o=e.get(n.dst)?.texture;a&&o?(r.copyTextureToTexture({texture:a,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:o,mipLevel:n.dstLevel,origin:{x:0,y:0,z:0}},{width:n.width,height:n.height,depthOrArrayLayers:1}),s++):this.copyTextureToTexture(n.src,n.dst,null,null,0,n.dstLevel)}s>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(t){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let e=this._reflectionDownsamplePasses[t];return e||(e=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[t]=e,e)}_renderTransmissionPass(t,e){let i=this.getDrawingBufferSize(jf),r=this.hdTransmission?1:2,s=Math.max(1,Math.round(i.x/r)),n=Math.max(1,Math.round(i.y/r)),a=this.backend?.isWebGPUBackend===!0?tE:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,s,n,()=>{let h=new ri(s,n,{depthBuffer:!0}),d=h.texture;return a==="off"?(d.generateMipmaps=!0,d.minFilter=ra):(d.generateMipmaps=!1,d.minFilter=me),d.magFilter=me,h});let o=[];t.traverse(h=>{let d=h;if(!(d.isMesh||d.isLine||d.isPoints||d.isSprite))return;let c=d.layers;c&&8&c.mask&&c.mask!==8&&(o.push({layers:c,mask:c.mask}),c.mask=8)});let l=this.getRenderTarget();e.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(t,e),this.setRenderTarget(l),e.layers.enable(3);for(let h of o)h.layers.mask=h.mask;let u=this._transmissionTarget.texture;if(a!=="off"){let h=(f,g)=>{let y=new ri(f,g,{depthBuffer:!1});return y.texture.generateMipmaps=!1,y.texture.minFilter=me,y.texture.magFilter=me,y};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,s,n,()=>h(s,n));let d=Math.floor(Math.log2(Math.max(s,n)))+1,c=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,s,n,()=>{let f=new ri(s,n,{depthBuffer:!1}),g=f.texture;return g.minFilter=ra,g.magFilter=me,a==="base"?g.generateMipmaps=!0:(g.generateMipmaps=!1,g.mipmaps=Array.from({length:d},(y,v)=>({width:Math.max(1,s>>v),height:Math.max(1,n>>v)}))),f}),a==="full"&&this._transmissionBlurTarget!==c&&this.initTexture(this._transmissionBlurTarget.texture);let p=this._getPrefilterPass(0);p.input.value=this._transmissionTarget.texture,p.step.value.set(1/s,0),this.setRenderTarget(this._transmissionBlurTmp),p.quad.render(this);let m=this._getPrefilterPass(1);if(m.input.value=this._transmissionBlurTmp.texture,m.step.value.set(0,1/n),a==="base")this.setRenderTarget(this._transmissionBlurTarget),m.quad.render(this);else{for(let f=0;f<d;f++)this._transmissionChain[f]=this._reallocGrabTarget(this._transmissionChain[f],Math.max(1,s>>f),Math.max(1,n>>f),()=>h(Math.max(1,s>>f),Math.max(1,n>>f)));for(let f=d;f<this._transmissionChain.length;f++)this._transmissionChain[f]?.dispose(),this._transmissionChain[f]=void 0;this._transmissionChain.length=d,this.setRenderTarget(this._transmissionChain[0]),m.quad.render(this);for(let f=1;f<d;f++){let g=this._transmissionChain[f-1],y=this._getDownsamplePass(f-1);y.input.value=g.texture,y.step.value.set(1/g.width,1/g.height),this.setRenderTarget(this._transmissionChain[f]),y.quad.render(this)}for(let f=0;f<d;f++)this.copyTextureToTexture(this._transmissionChain[f].texture,this._transmissionBlurTarget.texture,null,null,0,f)}this.setRenderTarget(l),u=this._transmissionBlurTarget.texture}Lt.transmissionRenderTarget.value=u,Lt.transmissionActualSize.value.set(s,n),Lt.aspectRatio.value=i.x>=i.y?Lt.aspectRatio.value.set(i.y/i.x,1):Lt.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(t,e,i){if(this._reflectionDepthPasses)for(let s of this._reflectionDepthPasses)s?.quad.material?.dispose();let r=[];{let s=new Re;s.name="SplineReflectionDepthBlit";let n=ee(this._reflectionTarget.depthTexture);s.fragmentNode=lt(G(n.sample(bi())),1),s.lights=!1,s.blending=cr,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,r.push({quad:new Pr(s)})}for(let s=1;s<i;s++){let n=Math.max(1,t>>s-1),a=Math.max(1,e>>s-1),o=new Re;o.name=`SplineReflectionDepthMin${s}`;let l=ee(this._reflectionDepthChain[s-1].texture),u=Ja,h=mt(u.x).mul(2),d=mt(u.y).mul(2),c=(y,v)=>l.load(Zn(h.add(y),d.add(v))).x,p=(y,v)=>ii(y,v),m=p(p(c(0,0),c(1,0)),p(c(1,1),c(0,1))),f=!!(1&n),g=!!(1&a);f&&(m=p(m,p(c(2,0),c(2,1)))),g&&(m=p(m,p(c(0,2),c(1,2)))),f&&g&&(m=p(m,c(2,2))),o.fragmentNode=lt(G(m),1),o.lights=!1,o.blending=cr,o.depthTest=!1,o.depthWrite=!1,o.needsUpdate=!0,r.push({quad:new Pr(o)})}this._reflectionDepthPasses=r}_renderReflectionPass(t,e){let i=this.getDrawingBufferSize(jf),r=1/0,s=0,n=0;t.traverse(x=>{let S=x;if(!(S.isMesh&&16&S.layers.mask))return;let w=this._reflectiveMeshCoverage(S,e,i.y),T=Array.isArray(S.material)?S.material:[S.material];for(let C of T){if(!C?.layers)continue;let M=tAt(C);!M||(r=Math.min(r,M.min*w.scale),s=Math.max(s,M.max*w.scale),M.max*w.scale>.45&&(n=Math.max(n,w.diameterPx)))}});let a=1;if(_L&&r!==1/0)for(r>=6?a=4:r>=2&&(a=2);a>1&&n>0&&n/a<128;)a>>=1;let o=Math.max(1,Math.round(i.x/a)),l=Math.max(1,Math.round(i.y/a)),u=Math.floor(Math.log2(Math.max(o,l)))+1,h=this.backend?.isWebGPUBackend===!0&&bL;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let x=new ri(o,l,{depthTexture:new Xa(o,l)});return h?(x.texture.generateMipmaps=!1,x.texture.minFilter=me):(x.texture.generateMipmaps=!0,x.texture.minFilter=ra),x.texture.magFilter=me,x});let d=(x,S)=>{let w=new ri(x,S,{depthBuffer:!1,type:Qe,format:Qa});return w.texture.generateMipmaps=!1,w.texture.minFilter=De,w.texture.magFilter=De,w},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let x=d(o,l);return x.texture.mipmaps=Array.from({length:u},(S,w)=>({width:Math.max(1,o>>w),height:Math.max(1,l>>w)})),x}),this._reflectionDepthPyramid!==c&&this.initTexture(this._reflectionDepthPyramid.texture);for(let x=0;x<u;x++)this._reflectionDepthChain[x]=this._reallocGrabTarget(this._reflectionDepthChain[x],Math.max(1,o>>x),Math.max(1,l>>x),()=>d(Math.max(1,o>>x),Math.max(1,l>>x)));for(let x=u;x<this._reflectionDepthChain.length;x++)this._reflectionDepthChain[x]?.dispose(),this._reflectionDepthChain[x]=void 0;this._reflectionDepthChain.length=u;let p=this.auxiliary||this._skySystem?.attached!==!0?null:this._skySystem.environmentTexture??null,m=Lt.reflectionEnvMap,f=p??ju;!this.auxiliary&&m.value!==f&&(m.value=f,this._grabTargetEpoch++),Lt.reflectionEnvEnabled.value=p!==null?1:0;let g=this.getClearColor(Ilt);Lt.reflectionMissColor.value.set(g.r,g.g,g.b);let y=[];t.traverse(x=>{let S=x;if(!(S.isMesh||S.isLine||S.isPoints||S.isSprite))return;let w=S.layers;w&&16&w.mask&&w.mask!==16&&(y.push({layers:w,mask:w.mask}),w.mask=16)});let v=this.getRenderTarget();e.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(t,e),e.layers.enable(4);for(let x of y)x.layers.mask=x.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,u),this._reflectionPassesKey=`${o}x${l}`);let b=this._reflectionDepthPasses;for(let x=0;x<u;x++)this.setRenderTarget(this._reflectionDepthChain[x]),b[x].quad.render(this);this._batchedMipCopies(Array.from({length:u},(x,S)=>({src:this._reflectionDepthChain[S].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:S,width:Math.max(1,o>>S),height:Math.max(1,l>>S)})));let _=this._reflectionTarget.texture;if(h){let x=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let T=new ri(o,l,{depthBuffer:!1}),C=T.texture;return C.minFilter=ra,C.magFilter=me,C.generateMipmaps=!1,C.mipmaps=Array.from({length:u},(M,A)=>({width:Math.max(1,o>>A),height:Math.max(1,l>>A)})),T}),this._reflectionColorPyramid!==x&&this.initTexture(this._reflectionColorPyramid.texture);let S=s>0?u:1,w=(T,C)=>{let M=new ri(T,C,{depthBuffer:!1});return M.texture.generateMipmaps=!1,M.texture.minFilter=me,M.texture.magFilter=me,M};for(let T=1;T<S;T++)this._reflectionColorChain[T]=this._reallocGrabTarget(this._reflectionColorChain[T],Math.max(1,o>>T),Math.max(1,l>>T),()=>w(Math.max(1,o>>T),Math.max(1,l>>T)));for(let T=S;T<this._reflectionColorChain.length;T++)this._reflectionColorChain[T]?.dispose(),this._reflectionColorChain[T]=void 0;this._reflectionColorChain.length=S;for(let T=1;T<S;T++){let C=T===1?this._reflectionTarget:this._reflectionColorChain[T-1],M=this._getReflectionDownsamplePass(T-1);M.input.value=C.texture,M.step.value.set(1/C.width,1/C.height),this.setRenderTarget(this._reflectionColorChain[T]),M.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:S-1},(T,C)=>({src:this._reflectionColorChain[C+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:C+1,width:Math.max(1,o>>C+1),height:Math.max(1,l>>C+1)}))]),_=this._reflectionColorPyramid.texture}this.setRenderTarget(v),Lt.reflectionRenderTarget.value=_,Lt.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,Lt.reflectionDepthSize.value.set(o,l),Lt.reflectionDepthLevels.value=u,this._reflectionGrabInfo={div:a,w:o,h:l,minBlur:r,maxBlur:s}}_reflectiveMeshCoverage(t,e,i){let r=t.geometry;if(!r)return{diameterPx:i,scale:1};r.boundingSphere===null&&r.computeBoundingSphere();let s=r.boundingSphere;if(!s)return{diameterPx:i,scale:1};let n=t.matrixWorld.elements,a=Math.sqrt(Math.max(n[0]*n[0]+n[1]*n[1]+n[2]*n[2],n[4]*n[4]+n[5]*n[5]+n[6]*n[6],n[8]*n[8]+n[9]*n[9]+n[10]*n[10])),o=s.radius*a;hL.copy(s.center).applyMatrix4(t.matrixWorld);let l=e.projectionMatrix.elements[5]*i/2,u=1;e.isPerspectiveCamera===!0&&(uL.setFromMatrixPosition(e.matrixWorld),u=Math.max(hL.distanceTo(uL),e.near??.1));let h=2*o*l/u;return{diameterPx:h,scale:Math.min(1,h/(.66*i))}}_renderReflectionResolvePass(t,e){let i=this._reflectionGrabInfo,r=this.backend?.isWebGPUBackend===!0&&xL&&i!==void 0&&i.maxBlur>.45;if(r){let _=!0;t.traverse(x=>{let S=x;if(!(S.isMesh&&16&S.layers.mask))return;let w=Array.isArray(S.material)?S.material:[S.material],T=null;for(let C of w)if(C?.layers&&(T=eAt(C),T!==null))break;T!=="variable"?T!==null?(S.userData.__srMode=T.blur>.45?1+T.tracingMode:0,S.userData.__srBlur=T.blur*this._reflectiveMeshCoverage(S,e,this.getDrawingBufferSize(Vlt).y).scale,S.userData.__srThickness=T.thickness,S.userData.__srStepSize=T.stepSize,S.userData.__srSteps=T.steps):S.userData.__srMode=0:_=!1}),r=_}let s=r?i.w:4,n=r?i.h:4,a=(_,x)=>()=>{let S=new ri(_,x,{type:ai,depthBuffer:!1});return S.texture.generateMipmaps=!1,S.texture.minFilter=me,S.texture.magFilter=me,S};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,s,n,a(s,n)),Lt.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(Lt.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let _=new ri(o,l,{count:2,type:ai,depthTexture:new Xa(o,l)});for(let x of _.textures)x.generateMipmaps=!1,x.minFilter=De,x.magFilter=De;return _.textures[0].name="g0",_.textures[1].name="g1",_}),this._reflectionResolveMarchTarget=this._reallocGrabTarget(this._reflectionResolveMarchTarget,o,l,a(o,l)),this._reflectionResolveBlurTmp=this._reallocGrabTarget(this._reflectionResolveBlurTmp,o,l,a(o,l)),!this._reflectionGBufferMaterial){let _=new Re;_.name="SplineReflectionGBuffer";let x=Hp("__splinePlanarMirror","float"),S=Lt.reflectionPlanarEnabled.greaterThan(.5),w=Hp("__srMode","float"),T=fi(x.greaterThan(.5).and(S),I(0),w);_.fragmentNode=Fv({g0:lt(xe(Oa),T),g1:lt(Hp("__srBlur","float"),Hp("__srThickness","float"),Hp("__srStepSize","float"),Hp("__srSteps","float"))}),_.lights=!1,_.blending=cr,_.needsUpdate=!0,this._reflectionGBufferMaterial=_}let u=this._skippedAsyncDraws??0,h=t.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(Blt),p=this.getClearAlpha(),m=e.layers.mask;t.overrideMaterial=this._reflectionGBufferMaterial,e.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(t,e),t.overrideMaterial=h,e.layers.mask=m,this.setClearColor(c,p);let f=Lt.reflectionRenderTarget.value,g=Lt.reflectionEnvMap.value,y=this._reflectionGBufferTarget,v=`${o}x${l}|${y.textures[0].uuid}|${f.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${g.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;v!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(f,g,o,l),this._reflectionResolveMarchKey=v);let b=this._reflectionResolveMarch;b.proj.value.copy(e.projectionMatrix),b.projInv.value.copy(e.projectionMatrix).invert(),b.camWorld.value.copy(e.matrixWorld),b.near.value=e.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),b.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),Lt.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>u&&(Lt.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(t,e,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let s=gt(new _t),n=gt(new _t),a=gt(new _t),o=gt(.1),l=this._reflectionGBufferTarget,u=ee(l.textures[0]),h=ee(l.textures[1]),d=ee(l.depthTexture),c=ee(t),p=ee(this._reflectionDepthPyramid.texture),m=ee(e),f=new Re;f.name="SplineReflectionResolve";let g=Et(()=>{let _=Ja,x=Zn(mt(_.x),mt(_.y)),S=bi(),w=u.load(x).toVar(),T=d.sample(S).toVar(),C=lt(0).toVar(),M=I(0).toVar();return bt(w.w.greaterThan(.5),()=>{let A=h.load(x).toVar(),R=ug(n,S.x,S.y,T),O=PW({dials:{blur:A.x,thickness:A.y,stepSize:A.z,steps:mt(A.w),tracingMode:w.w.sub(1)},surface:{originView:R,normalV:xe(w.xyz),screenUv:S,fragWindowZ:T},camera:{projectionMatrix:s,projectionMatrixInverse:n,worldMatrix:a,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:m},usePlanar:fyt(!1),noisePixel:at(x),singleRay:{footprintOut:M}});C.assign(lt(O,M.add(1)))}),C});f.fragmentNode=g(),f.lights=!1,f.blending=cr,f.depthTest=!1,f.depthWrite=!1,f.needsUpdate=!0,this._reflectionResolveMarch={quad:new Pr(f),proj:s,projInv:n,camWorld:a,near:o};let y=ee(this._reflectionResolveMarchTarget.texture),v=ee(this._reflectionResolveBlurTmp.texture),b=_=>{let x=new Re;x.name=`SplineReflectionResolveBlur${_.toUpperCase()}`;let S=_==="x"?y:v,w=_==="x"?1/i:1/r,T=Et(()=>{let C=bi(),M=y.sample(C).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),A=lt(0).toVar(),R=0;for(let O=-6;O<=6;O++){let N=Math.exp(O/3*-.5*(O/3));R+=N;let B=_==="x"?at(M.mul(O/6*w),0):at(0,M.mul(O/6*w)),L=S.sample(C.add(B)).toVar(),z=_==="x"?L.w.min(1):L.w;A.addAssign(lt(L.rgb,z).mul(N))}return A.div(R)});return x.fragmentNode=T(),x.lights=!1,x.blending=cr,x.depthTest=!1,x.depthWrite=!1,x.needsUpdate=!0,new Pr(x)};this._reflectionResolveBlur={h:b("x"),v:b("y")}}_renderPlanarReflectionPass(t,e){let i=null;if(t.traverse(m=>{let f=m;if(!(f.isMesh&&16&f.layers.mask&&(f.userData.__splinePlanarMirror=0,(Array.isArray(f.material)?f.material:[f.material]).some(A=>A?.layers&&A.getLayersOfType("reflection").some(R=>R.data.visible&&R.data.mirror===1)))))return;let g=f.geometry;if(!g)return;g.boundingBox===null&&g.computeBoundingBox();let y,v,b=g.boundingBox,_=b.max.x-b.min.x,x=b.max.y-b.min.y,S=b.max.z-b.min.z,w=f.matrixWorld.elements,T=Math.hypot(w[0],w[1],w[2]),C=Math.hypot(w[4],w[5],w[6]),M=Math.hypot(w[8],w[9],w[10]);_<=x&&_<=S?(y=klt,v=x*C*(S*M)):x<=_&&x<=S?(y=zlt,v=_*T*(S*M)):(y=Llt,v=_*T*(x*C)),(!i||v>i.area)&&(i={mesh:f,normalAxis:y,area:v})}),!i)return void(Lt.reflectionPlanarEnabled.value=0);let r=i.mesh,s=i.mesh.matrixWorld;if(Vd.copy(i.normalAxis).transformDirection(s),wp.setFromMatrixPosition(s),Zx.setFromMatrixPosition(e.matrixWorld),Sp.subVectors(wp,Zx),Sp.dot(Vd)>0&&Vd.negate(),Sp.dot(Vd)>0)return void(Lt.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==e.type)&&(this._planarVirtualCamera=e.clone());let n=this._planarVirtualCamera;if(Sp.subVectors(wp,Zx),Sp.reflect(Vd).negate(),Sp.add(wp),QC.extractRotation(e.matrixWorld),dL.set(0,0,-1).applyMatrix4(QC).add(Zx),Qx.subVectors(wp,dL),Qx.reflect(Vd).negate(),Qx.add(wp),n.position.copy(Sp),n.up.set(0,1,0).applyMatrix4(QC),n.up.reflect(Vd),n.lookAt(Qx),n.updateMatrixWorld(),n.projectionMatrix.copy(e.projectionMatrix),n.projectionMatrixInverse.copy(n.projectionMatrix).invert(),e.isPerspectiveCamera===!0){Uf.setFromNormalAndCoplanarPoint(Vd,wp),Uf.applyMatrix4(n.matrixWorldInverse),Su.set(Uf.normal.x,Uf.normal.y,Uf.normal.z,Uf.constant);let m=n.projectionMatrix.elements;Oy.x=(Math.sign(Su.x)+m[8])/m[0],Oy.y=(Math.sign(Su.y)+m[9])/m[5],Oy.z=-1,Oy.w=(1+m[10])/m[14],Su.multiplyScalar(1/Su.dot(Oy)),m[2]=Su.x,m[6]=Su.y,m[10]=Su.z,m[14]=Su.w}let a=this.getDrawingBufferSize(Flt),o=Math.max(1,Math.round(a.x)),l=Math.max(1,Math.round(a.y)),u=this.backend?.isWebGPUBackend===!0&&vL;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let m=new ri(o,l);return u?(m.texture.generateMipmaps=!1,m.texture.minFilter=me):(m.texture.generateMipmaps=!0,m.texture.minFilter=ra),m.texture.magFilter=me,m});let h=[];t.traverse(m=>{let f=m;if(!(f.isMesh||f.isLine||f.isPoints||f.isSprite))return;let g=f.layers;g&&16&g.mask&&g.mask!==16&&(h.push({layers:g,mask:g.mask}),g.mask=16)}),n.layers.mask=-17&e.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(t,n),this.setRenderTarget(d);for(let m of h)m.layers.mask=m.mask;let c=this._planarTarget.texture;if(u){let m=Math.floor(Math.log2(Math.max(o,l)))+1,f=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let y=new ri(o,l,{depthBuffer:!1}),v=y.texture;return v.minFilter=ra,v.magFilter=me,v.generateMipmaps=!1,v.mipmaps=Array.from({length:m},(b,_)=>({width:Math.max(1,o>>_),height:Math.max(1,l>>_)})),y}),this._planarPyramid!==f&&this.initTexture(this._planarPyramid.texture);let g=(y,v)=>{let b=new ri(y,v,{depthBuffer:!1});return b.texture.generateMipmaps=!1,b.texture.minFilter=me,b.texture.magFilter=me,b};for(let y=1;y<m;y++)this._planarChain[y]=this._reallocGrabTarget(this._planarChain[y],Math.max(1,o>>y),Math.max(1,l>>y),()=>g(Math.max(1,o>>y),Math.max(1,l>>y)));for(let y=m;y<this._planarChain.length;y++)this._planarChain[y]?.dispose(),this._planarChain[y]=void 0;this._planarChain.length=m;for(let y=1;y<m;y++){let v=y===1?this._planarTarget:this._planarChain[y-1],b=this._getPlanarDownsamplePass(y-1);b.input.value=v.texture,b.step.value.set(1/v.width,1/v.height),this.setRenderTarget(this._planarChain[y]),b.quad.render(this)}this.setRenderTarget(d),this._batchedMipCopies([{src:this._planarTarget.texture,dst:this._planarPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:m-1},(y,v)=>({src:this._planarChain[v+1].texture,dst:this._planarPyramid.texture,dstLevel:v+1,width:Math.max(1,o>>v+1),height:Math.max(1,l>>v+1)}))]),c=this._planarPyramid.texture}let p=Lt.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),Lt.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(t,e,i){let r=this.getDrawingBufferSize(jf),s=Math.max(1,Math.round(r.x)),n=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,s,n,()=>new ri(s,n,{depthBuffer:!0}));let a=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget);try{this.renderSplineScene(t,e)}finally{this.setRenderTarget(a)}this.pipeline.sceneTransitionFromTexture=this._transitionCaptureTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i;let o=this.pipeline.sceneTransitionPass.uniforms;o.uDPR.value=this.getPixelRatio(),o.uResolution.value.set(r.x,r.y).divideScalar(this.getPixelRatio())}async captureFrame(t,{includeHelpers:e=!1,settleFrames:i=0}={}){if(this.xr?.isPresenting===!0)return null;let r=this._frameSerial,s=this.getRenderTarget(),n=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled,o=this.suppressShadowMask;this.suppressShadowMask=!0,e||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{for(let g=0;g<i;g++)t(),await _Ct();t()}finally{this.suppressShadowMask=o,this.pipeline.renderToScreen=n,this.setRenderTarget(s),a&&this.pipeline.enableHelpers()}if(this._frameSerial===r||this.lastFrameIncomplete)return null;let l=this.pipeline.lastOutputTarget;if(!l||!this.backend.get(l.textures[0])?.textureDescriptorGPU)return null;let u=l.width,h=l.height,d=this,c=new Uint8Array(u*h*4),p=4*u,m=256*Math.ceil(p/256),f=Math.max(1,Math.min(h,Math.floor((1<<20)/m)));for(let g=0;g<h;g+=f){let y=Math.min(f,h-g),v=await d.readRenderTargetPixelsAsync(l,0,g,u,y);if(m===p)c.set(v.subarray(0,y*p),g*p);else for(let b=0;b<y;b++){let _=b*m;c.set(v.subarray(_,_+p),(g+b)*p)}}return{pixels:c,width:u,height:h}}_applyCIOffscreenTargetIfRequested(){if(globalThis.__SPLINE_RENDER_OFFSCREEN__!==!0)return;let t=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),e=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==t||this._ciOffscreenTarget.height!==e)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new ri(t,e,{depthBuffer:!0})):(this._ciOffscreenTarget=new ri(t,e,{depthBuffer:!0}),globalThis.__splineReadOffscreenPixels=async()=>{let i=this._ciOffscreenTarget,r=await this.readRenderTargetPixelsAsync(i,0,0,i.width,i.height);return{width:i.width,height:i.height,pixels:Array.from(r)}}),this.getRenderTarget()===null&&this.setRenderTarget(this._ciOffscreenTarget)}dispose(){this._disposeRetiredGrabTargets(),this._disposeWarmupTargets(),gj()?.drainRetired(),vj()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let t of Sv){let e=t.deref();e!==void 0&&(e.mid?.dispose(),e.mid=null,e.small?.dispose(),e.small=null,e.toMid?.material?.dispose(),e.toSmall?.material?.dispose(),e.toMid=null,e.toSmall=null,e.passKey="",e.fresh=!1,e.slot=-1)}Sv.clear(),mR.fill(null),$g?.dispose(),$g=null,fR=!1}(),this._aoRenderTarget?.dispose(),this._aoRenderTarget=void 0,this._normalTarget?.dispose(),this._normalTarget=void 0,this._ciOffscreenTarget?.dispose(),this._ciOffscreenTarget=void 0,this._transitionCaptureTarget?.dispose(),this._transitionCaptureTarget=void 0,this._transmissionTarget?.dispose(),this._transmissionTarget=void 0,this._transmissionBlurTmp?.dispose(),this._transmissionBlurTmp=void 0,this._transmissionBlurTarget?.dispose(),this._transmissionBlurTarget=void 0;for(let t of this._transmissionChain)t?.dispose();this._transmissionChain.length=0,this._reflectionTarget?.depthTexture?.dispose(),this._reflectionTarget?.dispose(),this._reflectionTarget=void 0,this._reflectionColorPyramid?.dispose(),this._reflectionColorPyramid=void 0;for(let t of this._reflectionColorChain)t?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let t of this._reflectionDownsamplePasses)t?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let t of this._planarChain)t?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let t of this._planarDownsamplePasses)t?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let t of this._reflectionDepthChain)t?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let t of this._reflectionDepthPasses)t?.quad.material?.dispose();this._reflectionDepthPasses=void 0}if(this._reflectionPassesKey="",this._reflectionGBufferTarget?.depthTexture?.dispose(),this._reflectionGBufferTarget?.dispose(),this._reflectionGBufferTarget=void 0,this._reflectionResolveMarchTarget?.dispose(),this._reflectionResolveMarchTarget=void 0,this._reflectionResolveBlurTmp?.dispose(),this._reflectionResolveBlurTmp=void 0,this._reflectionResolveTarget?.dispose(),this._reflectionResolveTarget=void 0,this._reflectionGBufferMaterial?.dispose(),this._reflectionGBufferMaterial=void 0,this._reflectionResolveMarch&&(this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveMarch=void 0),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose(),this._reflectionResolveBlur=void 0),this._reflectionResolveMarchKey="",this._reflectionGrabInfo=void 0,this._prefilterPasses){for(let t of this._prefilterPasses)t?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let t of this._downsamplePasses)t?.quad.material?.dispose();this._downsamplePasses=void 0}this._uiBlitPass&&(this._uiBlitPass.quad.material.dispose(),this._uiBlitPass=void 0),this._helperOverlay?.dispose(),this._helperOverlay=void 0,function(){for(let t of gR)t.deref()?.dispose();gR.clear(),yR++}(),function(){for(let t of g2){let e=t.deref();e!==void 0&&(e.sprite.removeFromParent(),e.material.dispose())}g2.clear(),z1++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let t of Object.values(this._encodeMaterials))t?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),Lt.transmissionRenderTarget.value=ko,Lt.normalRenderTarget.value=ko,Lt.aoRenderTarget.value=ko,Lt.reflectionRenderTarget.value=ju,Lt.reflectionDepthPyramid.value=ju,Lt.reflectionEnvMap.value=ju,Lt.reflectionPlanarTarget.value=ju,Lt.reflectionPlanarEnabled.value=0,Lt.reflectionResolveTarget.value=s9,Lt.reflectionResolveEnabled.value=0}})._GAUGE_STALL_MS=3e3});function xCt(t){return{type:t.type}}function ao(t,e){let{alpha:i,mode:r,isMask:s}=t,n=typeof i=="string"?Number(e.getVariable(i)??100)/100:i;return{...xCt(t),alpha:n,mode:r,isMask:s}}var wCt=j(()=>{dt(),qG(),Jv()});function By(t){let e=t;return e!=null&&e.isInstancedMesh===!0&&e.instanceMatrix!=null&&e.instanceMatrix.isInstancedBufferAttribute===!0}function rE(t){return Wh(Wh(lD).mul(function(e){let i=e.spInstanceMatrixNode;if(i!==void 0)return Wh(i);let r=e.object,s=r.instanceMatrix,n=Math.max(r.count??1,1);if(s.isStorageInstancedBufferAttribute===!0)return Wh(s5(s1t(s,"mat4",n),Pn));if(16*n*4<=e.getUniformBufferLimit())return Wh(s5(gyt(s.array,"mat4",n),Pn));let a=B9.get(s);a===void 0&&(a=new X7(s.array,16,1),B9.set(s,a));let o=s.usage===Yh?Cyt:Wp;return Wh(wW(o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)))}(t)))}var Wh,s5,B9,Za,hT,Q1t,J1t=j(()=>{dt(),He(),Wh=t=>t,s5=(t,e)=>t.element(e),B9=new WeakMap,Za=Et(t=>By(t.object)?hD:Uv).once()().toVar("speObjectPosition"),hT=Et(t=>t.material?.shapeBlendObjectNormal||(By(t.object)?t.geometry.hasAttribute("normal")?jyt:G(0,1,0):SW)).once()().toVar("speObjectNormal"),Wh(Et(t=>Wh(By(t.object)?rE(t):lD)).once()()),Q1t=Et(t=>{if(!By(t.object))return kyt;let e=rE(t),i=r=>s5(e,r).xyz;return G(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),Et(t=>By(t.object)?mm(rE(t)).inverse().transpose():Vyt).once()(),Wh(Et(t=>Wh(By(t.object)?rE(t).inverse():Lyt)).once()())});function BW(t){if(GS.has(t))return;let e={own:t.value,render:t.value};GS.set(t,e),Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get:()=>e.render,set:i=>{e.render=i,e.own=i}})}function V9(t){let e=GS.get(t);return e!==void 0?e.own:t.value}function VW(t,e){let i=GS.get(t);i!==void 0?i.render=e:t.value=e}var GS,kW,tvt=j(()=>{GS=new WeakMap}),SCt=j(()=>{tvt(),kW=class{constructor(t){this.layerId=t,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(t,e,i){return this.byName.set(t,e),this.uniforms[`f${this.layerId}_${t}`]=e,i!==void 0&&this.liveValues.set(t,i),this}has(t){return this.byName.has(t)}names(){return[...this.byName.keys()]}get(t){let e=this.byName.get(t);if(e===void 0)throw new Error(`TSLLayerParams: unknown param "${t}" (layer f${this.layerId})`);return e}getFloat(t){return this.get(t)}getInt(t){return this.get(t)}getBool(t){return this.get(t)}getVec2(t){return this.get(t)}getVec3(t){return this.get(t)}getVec4(t){return this.get(t)}getColor(t){return this.get(t)}getValue(t){if(this.liveValues.has(t))return this.liveValues.get(t);let e=this.byName.get(t);return e===void 0?void 0:V9(e)}getLiveValue(t){return this.liveValues.get(t)}getNodeValue(t){let e=this.byName.get(t);return e===void 0?void 0:V9(e)}setValue(t,e){let i=this.byName.get(t);i===void 0||e===void 0||(this.liveValues.has(t)&&this.liveValues.set(t,e),i.value=e)}}});function Ju(t,e,i){let r=I(t).toVar(),s=I(Yt(r.div(Ae(r.add(e.accumAlpha),I(1e-5),I(1))),r,i)).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(r).mul(Rr(i))),s}function sb(t,e){let i=I(t).toVar(),r=I(i.div(Ae(i.add(e.accumAlpha),I(1e-5),I(1)))).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(i)),r}function wR(t,e,i,r){return ivt({a:t,b:e,alpha:i,mode:r})}function Vn(t,e){cD.set(t,e)}function evt(t){let e=cD.get(t);return e!==void 0?e:(U9.has(t)||(U9.add(t),console.warn(`[spe] Material layer type "${t}" is not available in this runtime build (no WebGPU port, or compiled out) \u2014 rendering flat red.`)),zW)}function TCt(t){return cD.has(t)}var k9,z9,L9,F9,ivt,cD,U9,zW,cn=j(()=>{He(),J1t(),SCt(),tvt(),k9=0,z9=1,L9=2,F9=3,ivt=Et(t=>{let e=t.a.toVar(),i=t.b.toVar(),r=t.alpha.toVar(),s=t.mode,n=G(1).toVar();return bt(s.equal(mt(k9)),()=>{n.assign(Yt(e,i,r))}).ElseIf(s.equal(mt(z9)),()=>{n.assign(Yt(e,e.mul(i),r))}).ElseIf(s.equal(mt(L9)),()=>{n.assign(Yt(e,Rr(Rr(e).mul(Rr(i))),r))}).ElseIf(s.equal(mt(F9)),()=>{let a=Ai(e,G(.5)),o=Yt(Rr(Rr(e).mul(Rr(i)).mul(2)),e.mul(i).mul(2),a);n.assign(Yt(e,o,r).clamp(0,1))}),n}),cD=new Map,U9=new Set,zW=(t,e,i)=>{let r=e.alpha.mul(e.mask);return{color:G(1,0,0),calpha:sb(r,i)}}});function rvt(t){let e=co(Lt.aoRenderTarget.sample(Jl).rgb),i=Wv(Lt.aoEnabledUniform);return t!==null&&(i=Wv(i.mul(fi(t,I(1),I(0))))),co(Yt(G(1),e,i))}var j9,G9,co,Wv,jlt,Glt,svt,nvt,avt=j(()=>{var t;mr(),He(),dn(),cn(),{diffuseContribution:j9,specularColorBlended:G9}=D,co=e=>e,Wv=e=>e,jlt=Et(e=>{let i=Oa.dot(co(e.lightDirection)),r=at(i.mul(.5).add(.5),0),s=r.fwidth().mul(.5);return Yt(G(.7),G(1),tr(I(.7).sub(s.x),I(.7).add(s.x),r.x))}),Glt=Et(e=>{let i=co(e.lightDirection).add(jv).normalize(),r=Oa.dot(i).clamp(),s=jv.dot(i).clamp(),n=s.mul(-5.55473).sub(6.98316).mul(s).exp2(),a=Z1.mul(n.oneMinus()).add(n),o=I(.25),l=$4.mul(.5).add(1).mul(1/Math.PI).mul(r.pow($4));return a.mul(o).mul(l)}),t=class extends xv{direct(e){let{lightDirection:i,lightColor:r,reflectedLight:s}=e,n=co(jlt({lightDirection:i})).mul(r);s.directDiffuse.addAssign(n.mul(co(Vo.rgb).mul(1/Math.PI))),s.directSpecular.addAssign(n.mul(Wv(Glt({lightDirection:i}))))}},svt=class extends t{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(e,...i){super.finish?.call(this,e,...i);let{reflectedLight:r,outgoingLight:s}=e.context,n=rvt(this.aoOcclusionGate),a=co(r.directDiffuse.add(r.indirectDiffuse));s.subAssign(a.mul(Rr(n)))}},nvt=class extends tR{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(e,i){let r=e;if(r.lightNode?.light?.userData?.splineDiffuseOnly===!0){if(this.envIrradianceActive)return;let s=co(Oa).dot(r.lightDirection).clamp().mul(r.lightColor),n=D.BRDF_Lambert({diffuseColor:j9});return void r.reflectedLight.directDiffuse.addAssign(s.mul(n))}super.direct(e,i)}}});function Vy(t,e){return $u(e==="x"?t.x:e==="y"?t.y:t.z)}function tw(t,e){return Xn(Fyt(t,G(e,1)).div(2).add(.5).xy)}function MCt(t,e,i){let r=I(t.div(Ae(t.add(e.accumAlpha),I(1e-5),I(1)))).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(t).mul(Rr(i))),r}function aS(t){let e=t.getValue("projection")??0,i=t.getValue("axis")??0,r=i>=0&&i<=2?i:0,s=t.getValue("projectionAxis")??-1,n=s>=0&&s<=2?s:1,a=ovt(t.get("mat")),o=t.getVec2("size");if(e===1){let u=Za,h=r===0?u.zy:r===1?u.xz:u.xy,d=at(h.add(1).div(2)).toVar(),c=at(tw(a,Xn(d.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[Xn(c)],weights:null}}if(e===2){let u=G(xe(Za)).toVar(),{a:h,b:d,pole:c}=W9[n],p=I(xc(Vy(u,h),Vy(u,d)).div(6.283).add(.5)).toVar(),m=I(vW(Vy(u,c)).div(3.1415).add(.5)).toVar(),f=at(p,m).toVar(),g=at(tw(a,Xn(f.mul(2).sub(1)))).toVar();return{uvs:[Xn(g)],weights:null}}if(e===3){let u=G(xe(Za)).toVar(),{a:h,b:d,pole:c}=W9[n],p=I(xc(Vy(u,h),Vy(u,d)).div(6.283).add(.5)).toVar(),m=I(Vy(ur(Za),c).div(o.y.mul(.5))).toVar(),f=I(m.div(2).add(.5)).toVar(),g=at(p,f).toVar(),y=at(tw(a,Xn(g.mul(2).sub(1)))).toVar();return{uvs:[Xn(y)],weights:null}}if(e===4){let u=t.getFloat("blending"),h=G(Za).toVar(),d=at(h.xy.add(1).div(2)).toVar(),c=at(h.zy.add(1).div(2)).toVar(),p=at(h.xz.add(1).div(2)).toVar();for(let y of[d,c,p])y.assign(tw(a,Xn(y.mul(2).sub(1).div(o.mul(.5)))));let m=I(Rr(u).mul(125).add(3)).toVar(),f=G(hT).toVar(),g=G(Le(xe(f))).toVar();return g.assign(Lo(g,G(m))),g.divAssign(kt(g,G(1))),{uvs:[Xn(d),Xn(c),Xn(p)],weights:ur(g)}}let l=at(tw(a,Xn(bi().mul(2).sub(1)))).toVar();return{uvs:[Xn(l)],weights:null}}function sE(t,e,i){let r=at(e).toVar(),s=at(kv(r)).toVar(),n=at(zv(r)).toVar(),a=h=>$u(i.mul(oD(Pa(t.sample(h)).rgb))),o=I(a(Xn(r))).toVar(),l=I(a(Xn(r.add(s))).sub(o)).toVar(),u=I(a(Xn(r.add(n))).sub(o)).toVar();return Xn(at(l,u))}function nE(t,e,i){let r=G(kv(t)).toVar(),s=G(zv(t)).toVar(),n=G(xe(e)).toVar(),a=G(xe(Zr(s,n))).toVar(),o=G(xe(Zr(n,r))).toVar(),l=I(kt(r,a).mul(aD)).toVar(),u=G(Ku(l).mul(i.x.mul(a).add(i.y.mul(o)))).toVar();return ur(xe(Le(l).mul(n).sub(u)))}function ML(t,e){let i,r=t.get("texture"),s=t.has("loaded")?t.getFloat("loaded"):I(1),n=l=>{let u=Pa(r.sample(l)),h=e==="luminance"?oD(u.rgb):u[e];return I(h).toVar()},{uvs:a,weights:o}=aS(t);if(o!==null){let l=n(a[0]),u=n(a[1]),h=n(a[2]);i=$u(l.mul(o.z).add(u.mul(o.x)).add(h.mul(o.y)))}else i=$u(n(a[0]));return $u(Yt(I(1),i,s))}var $u,Xn,ur,Pa,ovt,W9,Wlt,lvt=j(()=>{mr(),He(),cn(),$u=t=>t,Xn=t=>t,ur=t=>t,Pa=t=>t,ovt=t=>t,W9=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],Vn("texture",Wlt=(t,e,i)=>{let r,s=t.getValue("projection")??0,n=t.getValue("axis")??0,a=n>=0&&n<=2?n:0,o=t.getValue("side")??0,l=t.get("texture"),u=t.getFloat("crop"),{uvs:h,weights:d}=aS(t),c=[...h],p=null;if(s===1){if(r=Pa(l.sample(h[0])),o!==2){let v=a===0?G(1,0,0):a===1?G(0,1,0):G(0,0,1),b=kt(hT,v);p=$u(Ai(I(0),o===1?b.mul(-1):b))}}else if(s===2||s===3)r=function(v,b){if(v.value.minFilter===De&&v.value.magFilter===De)return Pa(v.sample(b));let _=at(kv(b)).toVar(),x=at(zv(b)).toVar();return _.x.subAssign(ce(_.x.add(.5))),x.x.subAssign(ce(x.x.add(.5))),Pa(v.sample(b).grad(_,x))}(l,h[0]);else if(s===4){let v=d,b=Pa(l.sample(h[0])),_=Pa(l.sample(h[1])),x=Pa(l.sample(h[2]));r=Pa(b.mul(v.z).add(_.mul(v.x)).add(x.mul(v.y)))}else r=Pa(l.sample(h[0]));let m=t.has("loaded")?t.getFloat("loaded"):I(1),f=lt(Yt(lt(0,0,0,1),Pa(r),m)).toVar(),g=G(f.rgb).toVar(),y=I(e.alpha.mul(f.a)).toVar();return p!==null&&y.mulAssign(p),function(v,b,_){bt(v.greaterThan(.5),()=>{for(let x of _)bt(x.x.lessThan(0).or(x.x.greaterThan(1)).or(x.y.lessThan(0)).or(x.y.greaterThan(1)),()=>{b.assign(0)})})}(u,$u(y),c),y.mulAssign(e.mask),{color:ur(g),calpha:MCt($u(y),i,e.isMask)}}),Vn("video",Wlt)});function aE(t){return cvt({c:t})}function Zp(t){return pvt({p:t})}function ACt(t){return mvt({m:t})}function Wf(t){return fvt({x:t})}function AL(t){return gvt({r:t})}function Mv(t){return yvt({v:t})}function oE(t){return vvt({x:t})}function CCt(t){return bvt({x:t})}function SR(t){return _vt({P:t})}function CL(t){return xvt({p3:t})}function oS(t,e,i){return wvt({a:t,b:e,k:i})}function hvt(t,e,i){return Svt({a:t,b:e,k:i})}function uvt(t,e,i,r,s){return Tvt({value:t,input_min:e,input_max:i,output_min:r,output_max:s})}function dvt(t,e,i,r,s){return Mvt({x:t,style:e,smoothness:i,seed:r,quality:s})}var qlt,EL,ew,cvt,pvt,mvt,fvt,gvt,yvt,Hlt,vvt,$lt,bvt,Xlt,_vt,Ylt,xvt,wvt,Svt,Tvt,Mvt,WS,uT=j(()=>{He(),qlt=TW,EL=Ji,ew=.1666667,cvt=Et(t=>{let e=t.c,i=Bn(kt(e,G(17,59.4,15))).mul(4096),r=Oi(i.mul(512)),s=i.mul(.125),n=Oi(s.mul(512)),a=s.mul(.125),o=Oi(a.mul(512));return G(n,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),pvt=Et(t=>{let e=t.p,i=ce(e.add(kt(e,G(.3333333)))).toVar(),r=e.sub(i).add(kt(i,G(ew))).toVar(),s=Ai(G(0),r.sub(r.yzx)).toVar(),n=s.mul(Rr(s.zxy)).toVar(),a=Rr(s.zxy.mul(Rr(s))).toVar(),o=r.sub(n).add(ew).toVar(),l=r.sub(a).add(2*ew).toVar(),u=r.sub(1).add(3*ew).toVar(),h=lt(kt(r,r),kt(o,o),kt(l,l),kt(u,u)).toVar();h.assign(lt(.6).sub(h).max(0));let d=lt(kt(aE(i),r),kt(aE(i.add(n)),o),kt(aE(i.add(a)),l),kt(aE(i.add(1)),u)).toVar();return h.mulAssign(h),h.mulAssign(h),d.mulAssign(h),kt(d,lt(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),mvt=Et(t=>{let e=t.m,i=mm(G(-.37,.36,.85),G(-.14,-.93,.34),G(.92,.01,.4)),r=mm(G(-.55,-.39,.74),G(.33,-.91,-.24),G(.77,.12,.63)),s=mm(G(-.71,.52,-.47),G(-.08,-.72,-.68),G(-.7,-.45,.56));return Zp(e.mul(i)).mul(.5333333).add(Zp(e.mul(2).mul(r)).mul(.2666667)).add(Zp(e.mul(4).mul(s)).mul(.1333333)).add(Zp(e.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),fvt=Et(t=>{let e=t.x;return $h(e.mul(34).add(1).mul(e),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),gvt=Et(t=>u2(1.79284291400159,t.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),yvt=Et(t=>{let e=t.v,i=at(1/6,1/3),r=lt(0,.5,1,2),s=ce(e.add(kt(e,i.yyy))).toVar(),n=e.sub(s).add(kt(s,i.xxx)).toVar(),a=Ai(n.yzx,n.xyz).toVar(),o=Rr(a).toVar(),l=ii(a.xyz,o.zxy).toVar(),u=Qt(a.xyz,o.zxy).toVar(),h=n.sub(l).add(i.xxx.mul(1)).toVar(),d=n.sub(u).add(i.xxx.mul(2)).toVar(),c=n.sub(1).add(i.xxx.mul(3)).toVar();s.assign($h(s,289));let p=Wf(Wf(Wf(s.z.add(lt(0,l.z,u.z,1))).add(s.y).add(lt(0,l.y,u.y,1))).add(s.x).add(lt(0,l.x,u.x,1))).toVar(),m=r.wyz.mul(1/7).sub(r.xzx).toVar(),f=p.sub(ce(p.mul(m.z).mul(m.z)).mul(49)).toVar(),g=ce(f.mul(m.z)).toVar(),y=ce(f.sub(g.mul(7))).toVar(),v=g.mul(m.x).add(m.yyyy).toVar(),b=y.mul(m.x).add(m.yyyy).toVar(),_=u2(1,Le(v)).sub(Le(b)).toVar(),x=lt(v.xy,b.xy).toVar(),S=lt(v.zw,b.zw).toVar(),w=ce(x).mul(2).add(1).toVar(),T=ce(S).mul(2).add(1).toVar(),C=Ai(_,lt(0)).negate().toVar(),M=x.xzyw.add(w.xzyw.mul(C.xxyy)).toVar(),A=S.xzyw.add(T.xzyw.mul(C.zzww)).toVar(),R=G(M.xy,_.x).toVar(),O=G(M.zw,_.y).toVar(),N=G(A.xy,_.z).toVar(),B=G(A.zw,_.w).toVar(),L=AL(lt(kt(R,R),kt(O,O),kt(N,N),kt(B,B))).toVar();R.mulAssign(L.x),O.mulAssign(L.y),N.mulAssign(L.z),B.mulAssign(L.w);let z=Qt(u2(.6,lt(kt(n,n),kt(h,h),kt(d,d),kt(c,c))),0).toVar();return z.mulAssign(z),kt(z.mul(z),lt(kt(R,n),kt(O,h),kt(N,d),kt(B,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Hlt=Et(t=>{let e=t.x;return e.sub(ce(e.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),vvt=Et(t=>{let e=t.x;return Hlt({x:e.mul(34).add(1).mul(e)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),$lt=Et(t=>{let e=t.p,i=ce(e).toVar(),r=e.sub(i).toVar();r.assign(r.mul(r).mul(u2(3,r.mul(2))));let s=i.xxyy.add(lt(0,1,0,1)).toVar(),n=oE(s.xyxy).toVar(),a=oE(n.xyxy.add(s.zzww)).toVar().add(i.zzzz).toVar(),o=oE(a).toVar(),l=oE(a.add(1)).toVar(),u=Oi(o.mul(1/41)).toVar(),h=Oi(l.mul(1/41)).toVar().mul(r.z).add(u.mul(Rr(r.z))).toVar(),d=h.yw.mul(r.x).add(h.xz.mul(Rr(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(Rr(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),bvt=Et(t=>{let e=G(t.x).toVar(),i=I(0).toVar(),r=I(.5).toVar(),s=G(100).toVar();return Ji(5,()=>{i.addAssign(r.mul(function(n){return $lt({p:n})}(e))),e.assign(e.mul(2).add(s)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),Xlt=Et(t=>{let e=t.t;return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),_vt=Et(t=>{let e=t.P,i=ce(e).toVar(),r=i.add(G(1)).toVar();i.assign($h(i,289)),r.assign($h(r,289));let s=Oi(e).toVar(),n=s.sub(G(1)).toVar(),a=lt(i.x,r.x,i.x,r.x).toVar(),o=lt(i.yy,r.yy).toVar(),l=lt(i.zzzz).toVar(),u=lt(r.zzzz).toVar(),h=Wf(Wf(a).add(o)).toVar(),d=Wf(h.add(l)).toVar(),c=Wf(h.add(u)).toVar(),p=d.div(7).toVar(),m=Oi(ce(p).div(7)).sub(.5).toVar();p.assign(Oi(p));let f=lt(.5).sub(Le(p)).sub(Le(m)).toVar(),g=Ai(f,lt(0)).toVar();p.subAssign(g.mul(Ai(0,p).sub(.5))),m.subAssign(g.mul(Ai(0,m).sub(.5)));let y=c.div(7).toVar(),v=Oi(ce(y).div(7)).sub(.5).toVar();y.assign(Oi(y));let b=lt(.5).sub(Le(y)).sub(Le(v)).toVar(),_=Ai(b,lt(0)).toVar();y.subAssign(_.mul(Ai(0,y).sub(.5))),v.subAssign(_.mul(Ai(0,v).sub(.5)));let x=G(p.x,m.x,f.x).toVar(),S=G(p.y,m.y,f.y).toVar(),w=G(p.z,m.z,f.z).toVar(),T=G(p.w,m.w,f.w).toVar(),C=G(y.x,v.x,b.x).toVar(),M=G(y.y,v.y,b.y).toVar(),A=G(y.z,v.z,b.z).toVar(),R=G(y.w,v.w,b.w).toVar(),O=AL(lt(kt(x,x),kt(w,w),kt(S,S),kt(T,T))).toVar();x.mulAssign(O.x),w.mulAssign(O.y),S.mulAssign(O.z),T.mulAssign(O.w);let N=AL(lt(kt(C,C),kt(A,A),kt(M,M),kt(R,R))).toVar();C.mulAssign(N.x),A.mulAssign(N.y),M.mulAssign(N.z),R.mulAssign(N.w);let B=kt(x,s).toVar(),L=kt(S,G(n.x,s.yz)).toVar(),z=kt(w,G(s.x,n.y,s.z)).toVar(),k=kt(T,G(n.xy,s.z)).toVar(),V=kt(C,G(s.xy,n.z)).toVar(),H=kt(M,G(n.x,s.y,n.z)).toVar(),W=kt(A,G(s.x,n.yz)).toVar(),X=kt(R,n).toVar(),st=function(pt){return Xlt({t:pt})}(s).toVar(),nt=Yt(lt(B,L,z,k),lt(V,H,W,X),st.z).toVar(),xt=Yt(nt.xy,nt.zw,st.y).toVar();return Yt(xt.x,xt.y,st.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Ylt=Et(t=>{let e=Oi(t.p3.mul(.1031)).toVar();return e.addAssign(kt(e,e.yzx.add(33.33))),Oi(e.x.add(e.y).mul(e.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),xvt=Et(t=>{let e=Oi(t.p3.mul(G(.1031,.103,.0973))).toVar();return e.addAssign(kt(e,e.yxz.add(33.33))),Oi(e.xxy.add(e.yxx).mul(e.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),wvt=Et(t=>{let{a:e,b:i,k:r}=t,s=tr(0,1,i.sub(e).mul(.5).div(r).add(.5)).toVar(),n=r.mul(s).mul(Rr(s)).toVar();return Yt(i,e,s).sub(n)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),Svt=Et(t=>{let{a:e,b:i,k:r}=t,s=tr(1,0,e.sub(i).mul(.5).div(r).add(.5)).toVar(),n=r.mul(s).mul(Rr(s)).toVar();return Yt(e,i,s).add(n)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),Tvt=Et(t=>{let{value:e,input_min:i,input_max:r,output_min:s,output_max:n}=t,a=r.sub(i).toVar(),o=n.sub(s).toVar(),l=e.sub(i).div(a).toVar();return s.add(l.mul(o))}).setLayout({name:"spe_remap",type:"float",inputs:[{name:"value",type:"float"},{name:"input_min",type:"float"},{name:"input_max",type:"float"},{name:"output_min",type:"float"},{name:"output_max",type:"float"}]}),Mvt=Et(t=>{let{x:e,style:i,smoothness:r,seed:s,quality:n}=t,a=Qn(ce(e)).toVar(),o=Oi(e).toVar(),l=I(8).toVar(),u=I(8).toVar(),h=I(8).toVar(),d=I(8).toVar(),c=I(8).toVar(),p=I(8).toVar(),m=Qn(0).toVar(),f=G(0).toVar(),g=mt(n).toVar(),y=()=>({start:g.negate(),end:g,condition:"<=",type:"int"});EL(y(),y(),y(),({i:b,j:_,k:x})=>{let S=Qn(b,_,x).toVar(),w=G(S).add(CL(G(a.add(S)).add(s))).sub(o).toVar(),T=mi(w).toVar();l.assign(oS(T,l,r)),bt(T.lessThan(u),()=>{d.assign(u),u.assign(T),m.assign(Qn(b,_,x)),f.assign(w)}).ElseIf(T.lessThan(d),()=>{d.assign(T)})}),bt(i.notEqual(mt(0)).and(i.notEqual(mt(5))).and(i.notEqual(mt(7))),()=>{EL(y(),y(),y(),({i:b,j:_,k:x})=>{let S=m.add(Qn(b,_,x)).toVar(),w=G(S).add(CL(G(a.add(S)).add(s))).sub(o).toVar(),T=kt(f.add(w).mul(.5),w.sub(f)).toVar(),C=kt(f.add(w).mul(.5),xe(w.sub(f))).toVar();c.assign(oS(T,c,r)),p.assign(ii(p,C));let M=Qn(b,_,x).toVar();bt(yW(qlt(M,m)),()=>{let A=G(M).add(CL(G(a.add(M)).add(s))).sub(o).toVar(),R=mi(A).toVar();h.assign(oS(R,h,r))})})});let v=I(0).toVar();return bt(i.equal(mt(0)),()=>{v.assign(l)}).ElseIf(i.equal(mt(1)),()=>{v.assign(h)}).ElseIf(i.equal(mt(2)),()=>{v.assign(h.sub(l))}).ElseIf(i.equal(mt(3)),()=>{let b=I(3).toVar(),_=Qt(b.sub(Le(u.sub(d))),0).div(b).toVar();v.assign(ii(u,d).sub(_.mul(_).mul(b).mul(1/4)))}).ElseIf(i.equal(mt(4)),()=>{v.assign(nD(c.mul(5)))}).ElseIf(i.equal(mt(5)),()=>{v.assign(Lo(l,3))}).ElseIf(i.equal(mt(6)),()=>{let b=r.mul(.25).add(.0125).toVar(),_=Lo(r,3).mul(.25).add(.0125).toVar();v.assign(tr(b.sub(b.mul(_)),b.add(b.mul(_)),p))}).ElseIf(i.equal(mt(7)),()=>{v.assign(function(b){return Ylt({p3:b})}(G(a.add(m)).add(s)))}),v}).setLayout({name:"spe_voronoi",type:"float",inputs:[{name:"x",type:"vec3"},{name:"style",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"quality",type:"int"}]}),WS=[Zp,ACt,Mv,CCt,SR]});function Avt(t,e,i,r){return mo(t.add(e).mul(i).mul(.001).add(Cvt).add(r.mul(.1)))}function ECt(t,e,i){let r=function(u,h){let d=Math.trunc(u.getValue("noiseType")??0),c={n:h,scale:u.getFloat("scale"),intensity:u.getFloat("intensity"),offset:u.getVec3("offset"),movement:u.getFloat("movement")};if(d===5)return m=>mo(Pvt({...c,p:m,voronoiStyle:u.getInt("voronoiStyle"),smoothness:u.getFloat("smoothness"),seed:u.getFloat("seed"),highCut:u.getFloat("highCut"),lowCut:u.getFloat("lowCut"),quality:u.getInt("quality")}));let p=function(m){let f=q9.get(m);if(f===void 0){let g=WS[m]??WS[0];f=Et(y=>{let{n:v,scale:b,intensity:_,offset:x,movement:S}=y,w=mo(y.p);return w.add(v.mul(g(Avt(w,x,b,S))).mul(_))}).setLayout({name:`spe_displaceScalar${m}`,type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"}]}),q9.set(m,f)}return f}(d);return m=>mo(p({...c,p:m}))}(t,i),s=G(r(e)).toVar(),n=G(function(u){return Evt({v:u})}(i)).toVar(),a=xe(Zr(i,n)).toVar(),o=G(r(mo(e.add(n)))).toVar(),l=G(r(mo(e.add(a)))).toVar();return{position:s,normal:mo(xe(Zr(o.sub(s),l.sub(s))))}}var mo,Cvt,Evt,q9,Pvt,PL,Klt,h0,iw,lE,Zlt,PCt=j(()=>{He(),uT(),mo=t=>t,Cvt=1e-4,Evt=Et(t=>{let e=mo(t.v);return xe(mo(fi(Le(e.x).greaterThan(Le(e.z)),G(e.y.negate(),e.x,0),G(0,e.z.negate(),e.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),q9=new Map,Pvt=Et(t=>{let{n:e,scale:i,intensity:r,offset:s,movement:n,smoothness:a}=t,o=mo(t.p),l=I(dvt(Avt(o,s,i,n),t.voronoiStyle,a,t.seed,t.quality)).toVar();return l.assign(uvt(l,t.lowCut,t.highCut,I(0),I(1))),l.assign(hvt(l,I(0),a.mul(.25))),l.assign(oS(l,I(1),a.mul(.25))),o.add(e.mul(l).mul(r))}).setLayout({name:"spe_displaceVoronoi",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"},{name:"voronoiStyle",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"highCut",type:"float"},{name:"lowCut",type:"float"},{name:"quality",type:"int"}]})}),RCt=j(()=>{cn(),Vn("color",(t,e,i)=>{let r=e.alpha.mul(e.mask);return{color:t.getColor("color"),calpha:sb(r,i)}})}),DCt=j(()=>{He(),cn(),PL=t=>t,Klt=t=>t,Vn("depth",(t,e,i)=>{let r,s=t.get("colors"),n=t.get("steps"),a=(t.getValue("colors")??s.array).length,o=t.getValue("smooth")===!0,l=(t.getValue("isVector")??1)>.5,u=(t.getValue("gradientType")??0)===0,h=(t.getValue("isWorldSpace")??0)>.5,d=t.getFloat("near"),c=t.getFloat("far");if(l){let g=t.getVec3("origin"),y=h?Go:Za;if(u){let v=xe(t.getVec3("direction"));r=kt(v,y.sub(g))}else r=mi(y.sub(g))}else r=mi(Go.sub(Pc));let p=r.sub(d).div(c.sub(d)).toVar(),m=lt(s.element(0)).toVar();for(let g=1;g<a;g++){let y=PL(n.element(g-1)),v=PL(n.element(g)),b=Ae(p.sub(y).div(v.sub(y)),I(0),I(1)),_=o?tr(I(0),I(1),b):b;m.assign(Yt(m,Klt(s.element(g)),_))}let f=e.alpha.mul(m.a).mul(e.mask);return{color:m.rgb,calpha:Ju(f,i,e.isMask)}})}),NCt=j(()=>{He(),cn(),dn(),Vn("cavity",(t,e,i)=>{let r=Ae(t.getFloat("ridge"),0,2),s=Ae(t.getFloat("valley"),0,2),n=Lt.normalViewRenderTarget,a=Lt.resolution,o=vm("randomColor","vec3").x.toVar(),l=Jl.toVar(),u=at(I(1).div(a.x),I(1).div(a.y)).toVar(),h=(M,A)=>n.sample(l.add(at(M,A)).toVar()).toVar(),d=h(I(0),u.y.negate()),c=h(I(0),u.y),p=h(u.x.negate(),I(0)),m=h(u.x,I(0)),f=M=>M.a.equal(o).and(kt(M.xyz,M.xyz).greaterThan(.5)),g=f(d).and(f(c)).and(f(p)).and(f(m)),y=d.y.sub(c.y).add(m.x.sub(p.x)).toVar(),v=I(.5).div(Qt(r.mul(r),I(1e-4))).toVar(),b=I(.7).div(Qt(s.mul(s),I(1e-4))).toVar(),_=(M,A)=>fi(M.lessThan(I(.5).div(A)),M.mul(I(1).sub(M.mul(A))),I(.25).div(A)),x=fi(g,fi(y.greaterThan(0),_(y,v).mul(2),_(y.negate(),b).mul(-2)),I(0)).toVar(),S=fi(x.abs().lessThan(.001),I(0),x).toVar(),w=G(Ae(S.mul(.5).add(.5),0,1)),T=fi(S.notEqual(0),I(1),I(0)),C=fi(e.isMask,I(1),T);return{color:w,calpha:Ju(e.alpha.mul(e.mask).mul(C),i,e.isMask)}})}),nb=j(()=>{He(),h0=Et(t=>{let e=t.material?.vertexObjectNormal??null;return e?X4(e).transformNormalByInverseViewMatrix(eh).normalize():Gyt}).once()().toVar("speVertexNormalWorld")}),OCt=j(()=>{He(),nb(),cn(),uT(),Vn("dust",(t,e,i)=>{let r=t.getFloat("coverage"),s=t.getFloat("softness"),n=t.getFloat("noiseStrength"),a=t.getFloat("noiseScale"),o=kt(xe(h0),G(0,1,0)),l=I(0).toVar();bt(n.notEqual(0),()=>{let c=Zp(Za.div(a).toVar().add(G(1.7,9.2,1)));l.assign(c.mul(n))});let u=Qt(s,1e-4).toVar(),h=Yt(u.add(1),u.add(1).negate(),Ae(r,0,1)).toVar(),d=tr(h.sub(u),h.add(u),o.add(l)).mul(e.alpha).mul(e.mask);return{color:t.getColor("color"),calpha:Ju(d,i,e.isMask)}})}),ICt=j(()=>{He(),nb(),cn(),iw=(t,e)=>t.element(e),Vn("fresnel",(t,e,i)=>{let r=iw(rb,2).w.equal(-1),s=G(iw(eh,0).z,iw(eh,1).z,iw(eh,2).z).negate(),n=Go.sub(Pc),a=fi(r,n,s),o=t.getFloat("bias").add(t.getFloat("scale").mul(Lo(Le(t.getFloat("factor").add(kt(xe(a),xe(h0)))),t.getFloat("intensity")))),l=Ae(o,0,1).mul(e.alpha).mul(e.mask);return{color:t.getColor("color"),calpha:Ju(l,i,e.isMask)}})}),BCt=j(()=>{He(),cn(),lE=t=>t,Zlt=t=>t,Vn("gradient",(t,e,i)=>{let r=t.get("colors"),s=t.get("steps"),n=(t.getValue("colors")??r.array).length,a=(t.getValue("steps")??s.array).length,o=Math.min(10,n,a),l=t.getInt("gradientType"),u=t.getBool("smooth"),h=t.getVec2("offset"),d=t.getVec2("morph"),c=t.getFloat("angle"),p=bi(),m=lt(r.element(0)).toVar(),f=at(d.div(p)).toVar(),g=at(I(.5).add(f.x),f.y).toVar(),y=at(Ka(c).mul(g.x).sub(Bn(c).mul(g.y)),Bn(c).mul(g.x).add(Ka(c).mul(g.y))).toVar(),v=at(p.sub(.5).add(h).div(2).add(y.div(2))),b=I(kt(v,y).div(kt(y,y))).toVar();bt(l.equal(mt(1)),()=>{b.assign(Tyt(p.add(d).mul(3),p.add(h).add(1)).add(c))}).ElseIf(l.equal(mt(2)),()=>{let x=xc(p.x.add(d.x).sub(.5).add(h.x),p.y.add(d.y).sub(.5).add(h.y)).mul(-1);b.assign(Oi(c.div(Kj).div(-2).add(x.div(Kj).mul(.5))))});for(let x=1;x<o;x++){let S=lE(s.element(x-1)),w=lE(s.element(x)),T=Ae(b.sub(S).div(w.sub(S)),I(0),I(1)),C=lE(fi(u,tr(I(0),I(1),T),T));m.assign(Yt(m,Zlt(r.element(x)),C))}let _=e.alpha.mul(m.a).mul(e.mask);return{color:m.rgb,calpha:Ju(_,i,e.isMask)}})}),VCt=j(()=>{He(),cn(),Vn("matcap",(t,e,i)=>{let r=t.getFloat("rotation"),s=xe(Rc.negate()),n=xe(G(s.z,0,s.x.negate())),a=Zr(s,n),o=at(kt(n,Oa),kt(a,Oa)),l=Ka(r),u=Bn(r),h=at(l.mul(o.x).sub(u.mul(o.y)),u.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=t.get("texture").sample(h),c=e.alpha.mul(e.mask);return{color:d.rgb,calpha:Ju(c,i,e.isMask)}})}),kCt=j(()=>{He(),cn(),uT(),Vn("noise",(t,e,i)=>{try{if(new URLSearchParams(window.location.search).get("dbgnoise")==="0")return{color:G(0),calpha:I(0)}}catch{}let r=Math.trunc(t.getValue("noiseType")??0),s=I(Qt(Le(t.getFloat("scale")),.001)).toVar(),n=G(Za.div(t.getVec3("size"))).toVar();n.divAssign(s);let a=t.getFloat("move"),o=t.getVec4("colorA"),l=t.getVec4("colorC"),u=lt(0).toVar();if(r===5){let d=t.getFloat("smoothness"),c=I(dvt(n.add(a),t.getInt("voronoiStyle"),d,t.getFloat("seed"),t.getInt("quality"))).toVar();c.assign(uvt(c,t.getFloat("lowCut"),t.getFloat("highCut"),I(0),I(1))),c.assign(hvt(c,I(0),d.mul(.25))),c.assign(oS(c,I(1),d.mul(.25))),u.assign(Yt(o,l,c))}else{let d=WS[r]??WS[0],c=t.getVec4("colorB"),p=t.getVec4("colorD"),m=G(t.getVec2("distortion"),1).toVar(),f=G(t.getVec2("fA"),1).toVar(),g=G(t.getVec2("fB"),1).toVar(),y=G(d(n),d(n.add(G(1))),d(n.add(G(1)))).toVar(),v=G(d(n.add(m.mul(y)).add(f).add(a)),d(n.add(m.mul(y)).add(g).add(a)),d(n.mul(y))).toVar(),b=I(d(n.add(v))).toVar();u.assign(Yt(o,c,Ae(b.mul(b).mul(4),I(0),I(1)))),u.assign(Yt(u,l,Ae(mi(y),I(0),I(1)))),u.assign(Yt(u,p,Ae(mi(v.x),I(0),I(1))))}let h=e.alpha.mul(u.a).mul(e.mask);return{color:Ae(u,I(0),I(1)).rgb,calpha:Ju(h,i,e.isMask)}})}),zCt=j(()=>{He(),cn(),Vn("normal",(t,e,i)=>({color:Hyt(xe(Oa)).mul(Ai(G(.5),t.getVec3("cnormal"))),calpha:sb(e.alpha.mul(e.mask),i)}))});function RL(t){return Rvt({p:t})}function hE(t,e){return Dvt({uv:t,a:e})}function ky(t,e,i,r,s){return Nvt({uv:t,frequency:e,variation:i,zigzag:r,rotation:s})}function uE(t,e){let i={uv:e.uv,frequency:e.frequency,size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation};switch(t){case 1:return Ivt(i);case 2:return Bvt({...i,sides:e.sides});case 3:return Vvt(i);case 4:return kvt(i);case 5:return zvt(i);case 6:return Lvt(i);case 7:return Fvt(i);default:return Ovt(i)}}var zy,Qlt,Rvt,Dvt,Nvt,Ovt,Ivt,Jlt,Bvt,tht,Vvt,eht,kvt,zvt,Lvt,iht,Fvt,rw,DL,rht,sht,nht,aht,oht,NL,lht,qf,hht,uht,OL,dht,LCt=j(()=>{He(),cn(),zy=2*Math.PI,Qlt=Math.PI/180,Rvt=Et(t=>{let e=Oi(t.p.xyx.mul(.1031)).toVar();return e.addAssign(kt(e,e.yzx.add(33.33))),Oi(e.x.add(e.y).mul(e.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),Dvt=Et(t=>{let e=t.uv,i=.5,r=I(t.a.mul(Qlt)).toVar(),s=at(Ka(r).mul(e.x.sub(i)).add(Bn(r).mul(e.y.sub(i))).add(i),Ka(r).mul(e.y.sub(i)).sub(Bn(r).mul(e.x.sub(i))).add(i));return Oi(s)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),Nvt=Et(t=>{let e=at(t.uv.mul(t.frequency)).toVar(),i=at(ce(e)).toVar(),r=I($h(i.y,2)).toVar();e.x.addAssign(r.mul(t.zigzag));let s=at(Oi(e)).toVar();s.assign(s.mul(2).sub(1)),i.assign(ce(e));let n=I(RL(i).mul(5).add(1)).toVar(),a=I(Yt(I(1),n,t.variation)).toVar();return s.mulAssign(a),s}).setLayout({name:"spe_pattern_tile_and_center",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"variation",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ovt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,mi(e).sub(t.size))}).setLayout({name:"spe_pattern_circle",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ivt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar(),i=I(mi(e)).toVar(),r=I(tr(t.smoothness.negate(),t.smoothness,i.sub(t.size))).toVar(),s=I(tr(t.smoothness.negate(),t.smoothness,i.sub(t.size.mul(.5)))).toVar();return r.add(Rr(s))}).setLayout({name:"spe_pattern_ring",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Jlt=Et(t=>{let e=I(I(zy).div(I(t.n))).toVar(),i=I(t.r.mul(a1t(e.mul(.5)))).toVar(),r=at(t.p.yx.negate()).toVar(),s=I(e.mul(ce(xc(r.y,r.x).add(e.mul(.5)).div(e)))).toVar(),n=at(Ka(s),Bn(s)).toVar();return r.assign(at(n.x.mul(r.x).add(n.y.mul(r.y)),n.y.negate().mul(r.x).add(n.x.mul(r.y)))),mi(r.sub(at(t.r,Ae(r.y,i.negate(),i)))).mul(Ku(r.x.sub(t.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),Bvt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,Jlt({p:e,r:t.size,n:t.sides}))}).setLayout({name:"spe_pattern_polygon",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"},{name:"sides",type:"int"}]}),tht=Et(t=>{let e=t.b,i=at(Le(t.p)).toVar();i.assign(fi(i.y.greaterThan(i.x),i.yx,i.xy));let r=at(i.sub(e)).toVar(),s=I(Qt(r.y,r.x)).toVar(),n=at(fi(s.greaterThan(0),r,at(e.y.sub(i.x),s.negate()))).toVar();return Ku(s).mul(mi(Qt(n,at(0)))).add(t.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),Vvt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,tht({p:e,b:at(t.size,t.size.mul(.25)),r:t.smoothness}))}).setLayout({name:"spe_pattern_xcross",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),eht=Et(t=>{let e=t.b,i=at(Le(t.p)).toVar(),r=at(e.sub(i.mul(2))).toVar(),s=r.x.mul(e.x).sub(r.y.mul(e.y)),n=I(Ae(s.div(kt(e,e)),I(-1),I(1))).toVar();return I(mi(i.sub(e.mul(.5).mul(at(Rr(n),n.add(1)))))).toVar().mul(Ku(i.x.mul(e.y).add(i.y.mul(e.x)).sub(e.x.mul(e.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),kvt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,eht({p:e,b:at(t.size)}))}).setLayout({name:"spe_pattern_diamond",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),zvt=Et(t=>{let e=at(t.uv.mul(t.frequency)).toVar(),i=at(ce(e)).toVar(),r=I($h(i.y,2)).toVar();e.x.addAssign(r.add(t.zigzag.mul(r)));let s=I(ce(e.x)).toVar();return $h(s,2)}).setLayout({name:"spe_pattern_checkerboard",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Lvt=Et(t=>{let e=at(ky(t.uv,t.frequency,I(0),t.zigzag,t.rotation)).toVar(),i=I(ce(t.uv.mul(t.frequency)).y).toVar(),r=I(RL(at(i))).toVar(),s=I(Yt(t.size,t.size.mul(r),t.variation)).toVar();return tr(s.sub(t.smoothness),s.add(t.smoothness),Le(e.y))}).setLayout({name:"spe_pattern_line",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),iht=Et(t=>{let{a:e,b:i,c:r,d:s}=t,n=at(t.p.sub(at(s,e)).mul(r)).toVar();n.x.assign($h(n.x,zy)),bt(n.x.greaterThan(Math.PI),()=>{n.x.assign(I(zy).sub(n.x))});let a=I(0).toVar(),o=I(zy).toVar();Ji(24,()=>{let h=I(a.add(o).mul(.5)).toVar(),d=I(h.sub(n.x).add(i.mul(r).mul(Bn(h)).mul(n.y.sub(i.mul(r).mul(Ka(h)))))).toVar();bt(d.lessThan(0),()=>{a.assign(h)}).Else(()=>{o.assign(h)})});let l=I(a.add(o).mul(.5)).toVar(),u=at(l,i.mul(r).mul(Ka(l))).toVar();return mi(n.sub(u)).div(r)}).setLayout({name:"spe_pattern_udf_cos",type:"float",inputs:[{name:"p",type:"vec2"},{name:"a",type:"float"},{name:"b",type:"float"},{name:"c",type:"float"},{name:"d",type:"float"}]}),Fvt=Et(t=>{let e=I(t.frequency.x).toVar(),i=at(t.uv.mul(e)).toVar(),r=at(ce(i)).toVar(),s=I($h(r.y,2)).toVar();i.x.addAssign(s.mul(t.zigzag));let n=at(i.x,Oi(i.y)).toVar(),a=I(t.frequency.y.mul(.1)).toVar(),o=I(iht({p:n,a:I(.5),b:I(.125),c:a.mul(zy),d:I(0)})).toVar(),l=I(RL(at(r.y))).toVar(),u=I(Yt(t.size,t.size.mul(l),t.variation)).toVar();return tr(t.smoothness.negate(),t.smoothness,o.sub(u.mul(.5)))}).setLayout({name:"spe_pattern_wave",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Vn("pattern",(t,e,i)=>{let r,s,n=t.getValue("style")??0,a=t.getValue("projection")??0,o=t.getValue("axis")??0,l=t.getFloat("blending"),u=t.getVec2("offset"),h=t.getVec4("colorA"),d=t.getVec4("colorB"),c=t.getVec2("frequency"),p=t.getFloat("size"),m=t.getFloat("variation"),f=t.getFloat("smoothness"),g=t.getFloat("zigzag"),y=t.getFloat("rotation"),v=t.getVec2("vertical"),b=t.getVec2("horizontal"),_=t.getInt("sides"),x={frequency:c,size:p,variation:m,smoothness:I(Lo(f,5)).toVar(),zigzag:g,rotation:y,sides:_};if(a===4){let T=G(Za).toVar(),C=I(.0125).toVar(),M=at(Oi(T.xy.mul(C))).toVar(),A=at(Oi(T.zy.mul(C))).toVar(),R=at(Oi(T.xz.mul(C))).toVar();M.assign(hE(M.add(u),y)),A.assign(hE(A.add(u),y)),R.assign(hE(R.add(u),y));let O=I(uE(n,{uv:M,...x})).toVar(),N=I(uE(n,{uv:A,...x})).toVar(),B=I(uE(n,{uv:R,...x})).toVar(),L=I(Rr(l).mul(125).add(3)).toVar(),z=G(hT).toVar(),k=G(Le(xe(z))).toVar();k.assign(Lo(k,G(L))),k.divAssign(kt(k,G(1))),O.mulAssign(k.z),N.mulAssign(k.x),B.mulAssign(k.y),r=I(O.add(N).add(B)).toVar(),s=at(M.mul(k.z).add(A.mul(k.x)).add(R.mul(k.y))).toVar()}else{let T=at(0).toVar();if(a===0)T.assign(bi());else if(a===2){let C,M,A=G(Za).toVar(),R=I(mi(A)).toVar();o===0?(C=I(xc(A.y,A.z)).toVar(),M=I(aR(A.x.div(R))).toVar()):o===1?(C=I(xc(A.x,A.z)).toVar(),M=I(aR(A.y.div(R))).toVar()):(C=I(xc(A.y,A.x)).toVar(),M=I(aR(A.z.div(R))).toVar()),T.assign(at(C,M).div(Math.PI))}T.addAssign(u),T.assign(Oi(T)),T.assign(hE(T,y)),r=uE(n,{uv:T,...x}),s=T}let S=lt(Yt(h,d,r)).toVar();S.a.assign(Ae(S.a,I(0),I(1))),S.a.mulAssign(Ai(v.x,s.y).mul(Ai(s.y,v.y))),S.a.mulAssign(Ai(b.x,Le(s.x)).mul(Ai(Le(s.x),b.y)));let w=e.alpha.mul(Ae(S.a,I(0),I(1))).mul(e.mask);return{color:Ae(S,lt(0),lt(1)).rgb,calpha:Ju(w,i,e.isMask)}})}),FCt=j(()=>{He(),nb(),cn(),uT(),rw=(t,e)=>t.element(e),Vn("rainbow",(t,e,i)=>{let r=t.getFloat("filmThickness"),s=t.getFloat("movement"),n=t.getVec3("wavelengths"),a=t.getFloat("noiseStrength"),o=t.getFloat("noiseScale"),l=t.getVec3("offset"),u=I(0).toVar();e.noiseCompiledIn!==!1&&bt(a.notEqual(0),()=>{let b=Za.div(o).toVar(),_=Zp(b.mul(1.6).add(G(1.8,1.5,1.9).mul(Zp(b))).add(G(1.7,9.2,1)));u.assign(_.mul(a))});let h=n.mul(G(1,.8,.6)).add(1),d=rw(rb,2).w.equal(-1),c=G(rw(eh,0).z,rw(eh,1).z,rw(eh,2).z).negate(),p=Go.sub(Pc),m=fi(d,p,c),f=kt(xe(m.add(l.mul(-.001))),xe(h0)),g=Ka(r.add(u).div(h).mul(f).add(s)).mul(.5).add(.5),y=G(Ae(g,0,2)).toVar(),v=Ae(y.r.add(y.g).add(y.b),0,1);return{color:y,calpha:Ju(e.alpha.mul(v).mul(e.mask),i,e.isMask)}})}),UCt=j(()=>{He(),nb(),cn(),dn(),DL=t=>t,rht=t=>t,sht=Ji,nht=Ji,aht=Et(t=>{let e=t.x,i=G(kt(e,G(127.1,311.7,74.7)),kt(e,G(269.5,183.3,246.1)),kt(e,G(113.5,271.9,124.6)));return Oi(Bn(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),oht=Et(t=>{let e=t.x,i=ce(e).toVar(),r=Oi(e).toVar(),s=I(100).toVar(),n=()=>({start:mt(-1),end:mt(1),condition:"<=",type:"int"});return nht(n(),n(),n(),({i:a,j:o,k:l})=>{let u=G(a,o,l).toVar(),h=u.sub(r).add(function(c){return aht({x:c})}(i.add(u))).toVar(),d=kt(h,h).toVar();bt(d.lessThan(s),()=>{s.assign(d)})}),s.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),Vn("toon",(t,e,i)=>{let r=t.getInt("positioning"),s=t.get("colors"),n=t.get("steps"),a=t.getVec3("source"),o=t.getBool("isWorldSpace"),l=t.getFloat("noiseStrength"),u=t.getFloat("noiseScale"),h=t.getVec4("shadowColor"),d=t.getVec3("offset"),c=xe(h0).toVar(),p=I(0).toVar();i.lightsAvailable===!0&&bt(r.equal(mt(0)),()=>{sht({start:mt(0),end:Lt.toonLightCount,condition:"<",type:"int"},({i:b})=>{let _=Lt.toonLightData.element(b).toVar(),x=_.xyz,S=_.w,w=fi(S.greaterThan(.5),xe(x),xe(x.sub(Go))),T=kt(w,c).mul(.5).add(.5);p.assign(Qt(p,T))}),p.assign(Ae(p,0,1))}),bt(r.equal(mt(1)),()=>{let b=Yt(Za,Go,fi(o,I(1),I(0))),_=xe(a.sub(b));p.assign(kt(_,c).mul(.5).add(.5))}).ElseIf(r.equal(mt(2)),()=>{let b=Pc.sub(d),_=xe(b.sub(Go));p.assign(kt(_,c).mul(.5).add(.5))}),bt(l.greaterThan(0),()=>{let b=Za.div(u),_=I(1).sub(oht({x:b}));p.addAssign(_.mul(l))}),p.assign(Ae(p,0,1));let m=(t.getValue("colors")??s.array).length,f=(t.getValue("steps")??n.array).length,g=Math.min(10,m,f),y=lt(s.element(0)).toVar();for(let b=1;b<g;b++){let _=DL(n.element(b-1)),x=DL(n.element(b)),S=Ae(p.sub(_).div(x.sub(_)),I(0),I(1));y.assign(Yt(y,rht(s.element(b)),tr(0,1,S)))}i.lightsAvailable===!0&&bt(r.equal(mt(0)),()=>{let b=I(1),_=Yt(y.rgb,h.rgb,h.a);y.rgb.assign(Yt(_,y.rgb,b))});let v=e.alpha.mul(y.a).mul(e.mask);return{color:y.rgb,calpha:sb(v,i)}})}),jCt=j(()=>{He(),nb(),cn(),J1t(),dn(),NL=t=>t,lht=(t,e)=>t.element(e),qf=t=>t,hht=t=>t,uht=t=>t,Vn("transmission",(t,e,i)=>{let r=t.getFloat("thickness"),s=t.getFloat("ior"),n=t.getFloat("roughness"),a=Lt.transmissionRenderTarget,o=Lt.transmissionSamplerSize,l=V=>lht(eh,V),u=xe(G(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),h=xe(Go.sub(Pc)),d=Lt.orthographicUniform,c=fi(d.greaterThan(.5),u,h).toVar(),p=xe(h0).toVar(),m=t1t(c,p,I(1).div(s)).toVar(),f=xe(m).mul(r).mul(Q1t).toVar(),g=V=>{let H=Lt.unjitteredProjection.mul(eh).mul(lt(V,1)),W=H.xy.div(H.w);return at(W.x.mul(.5).add(.5),W.y.mul(-.5).add(.5))},y=g(Go.add(f).toVar()).toVar(),v=(g(Go).toVar(),n.mul(Ae(s.mul(2).sub(2),I(0),I(1))).toVar()),b=Lv(o.x).mul(v).toVar(),_=v,x=ii(b.div(5.5),I(8.5)).toVar(),S=null,w="fit",T=!0,C=!1,M=12,A="white",R=1;try{let V=new URLSearchParams(window.location.search),H=V.get("dbglod");H!==null&&(S=Number(H));let W=V.get("dbgtap");W==="ring"&&(w="ring"),(W==="single"||W==="1")&&(w="single"),(W==="r50"||W==="r75"||W==="full")&&(w=W),W==="singlewide"&&(w="singlewide"),(W==="fit"||W==="singlefit")&&(w="fit");let X=V.get("dbgwidth");X!==null&&Number.isFinite(Number(X))&&(R=Math.max(0,Number(X))),W==="6"&&(w="ring",M=6),V.get("dbgwarp")==="0"&&(T=!1),V.get("dbgdither")==="1"&&(C=!0);let st=V.get("dbgangle");(st==="classic"||st==="0")&&(A=st)}catch{}S!==null&&Number.isFinite(S)&&x.assign(I(S));let O,N=(()=>{if(w==="singlewide")return ii(x.add(1),I(8.5)).toVar();if(w!=="fit")return x;let V=Lt.transmissionActualSize.x.div(Lt.resolution.x),H=_.mul(x).mul(5*R).mul(V).toVar();return ii(Lv(O1(x.mul(2)).add(H.mul(H).mul(3))).mul(.5),I(8.5)).toVar()})(),B=V=>a.sample(T?(H=>{let W=Lt.transmissionActualSize.div(O1(ce(N))),X=H.mul(W).sub(.5),st=ce(X),nt=X.sub(st),xt=nt.mul(nt).mul(at(3,3).sub(nt.mul(2)));return st.add(.5).add(xt).div(W)})(V):V).level(N).rgb,L=w==="r50"?.5:w==="r75"?.75:1;if(w==="single"||w==="singlewide"||w==="fit")if(w==="fit"){let V=ce(N).toVar(),H=N.sub(V).toVar(),W=xl(O1(H.mul(2)).sub(1)).mul(1.1547).toVar(),X=at(O1(V)).div(Lt.transmissionActualSize).mul(W).toVar(),st=G(0).toVar(),nt=12;for(let xt=0;xt<nt;xt++){let pt=qf(bm(xt,nt,I(0))),K=qf(y.add(pt.mul(X)));st.addAssign(hht(uht(a.sample(K).level(V)).rgb))}O=st.div(nt).toVar()}else O=B(y).toVar();else{let V=at(I(1).div(Lt.resolution.x),I(1).div(Lt.resolution.y)).toVar(),H=Ac(A==="classic"?Ja.xy.add(Lt.cameraJitterPx):Ja.xy).mul(6.28318530718);A==="white"&&(H=H.add(Lt.tapAngle));let W=H.toVar(),X=Lt.tapAngle.mul(13.7).toVar(),st=Lt.tapAngle2.mul(5.3).toVar(),nt=at(O1(ce(N).add(1))).div(Lt.transmissionActualSize).toVar(),xt=Ac(Ja.xy.add(at(X,st))).toVar(),pt=Ac(Ja.xy.add(at(st.mul(1.71),X.mul(2.39)))).toVar(),K=G(0).toVar();for(let ct=0;ct<M;ct++){let St=qf(bm(ct,M,W)).mul(V).mul(_).mul(x.mul(10)).mul(L),wt=qf(y.add(St));if(C){let Tt=NL(Oi(xt.add(.7548776662*ct))),yt=NL(Oi(pt.add(.5698402911*ct))),Ot=qf(at(Tt.sub(.5),yt.sub(.5)).mul(nt));wt=qf(wt.add(Ot))}K.addAssign(B(wt))}O=K.div(M).toVar()}if(t.has("attenuationDistance")){let V=t.getFloat("attenuationDistance"),H=G(t.getColor("attenuationColor")).toVar();bt(V.greaterThan(0),()=>{let W=Lo(Qt(H,G(1e-4)),G(r.div(V)));O.mulAssign(W)})}let z=e.alpha.mul(e.mask).toVar(),k=z.div(Ae(z.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(e.alpha)),{color:O,calpha:k}})}),GCt=j(()=>{He(),cn(),dn(),S1t(),Vn("reflection",(t,e,i)=>{let r=t.getFloat("blur"),s=t.getFloat("thickness"),n=t.getInt("steps"),a=t.getFloat("stepSize"),o=t.getValue("tracingMode")??0,l=Lt.reflectionRenderTarget,u=Lt.reflectionDepthPyramid,h=Lt.reflectionDepthPyramid,d=Lt.reflectionDepthLevels,c=Lt.reflectionEnvMap,p=Lt.reflectionPlanarTarget,m=Lt.reflectionPlanarEnabled,f=Hp("__splinePlanarMirror","float"),g=m.greaterThan(.5).and(f.greaterThan(.5)),y=Lt.reflectionResolveTarget,v=Lt.reflectionResolveEnabled,b=Lt.orthographicUniform.greaterThan(.5),_=fi(b,G(0,0,-1),xe(Rc)).toVar(),x=xe(Oa).toVar(),S=FS(_,x).toVar(),w=Ae(r.mul(.1),I(0),I(1)).toVar(),T=Lt.resolution,C=G(0).toVar(),M=v.greaterThan(.5).and(w.greaterThan(.05)).and(g.not()),A=xe(CW(S,H4)).toVar(),R=p9(c,A,w).toVar(),O=y.sample(Jl).level(I(0)).toVar();bt(M,()=>{let L=O.a.toVar();C.assign(Yt(R,O.rgb.div(L.max(1e-4)),Ae(L.mul(2),I(0),I(1))))}).Else(()=>{C.assign(PW({dials:{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:o},surface:{originView:Rc,normalV:x,screenUv:Jl,fragWindowZ:sD},camera:{projectionMatrix:rb,projectionMatrixInverse:vyt,worldMatrix:H4,near:yyt},resources:{colorMap:l,depthPyramid:u,depthPyramidNode:h,envMap:c},usePlanar:g,noisePixel:Jl.mul(T).floor()}))}),bt(g,()=>{let L=at(I(1).sub(Jl.x),Jl.y).toVar(),z=I(d.sub(1)),k=ii(Lv(w.mul(T.y).mul(d9).add(1)),z).toVar(),V=k.sub(1).max(0).floor().toVar(),H=I(2).pow(k).sub(1).max(0).toVar(),W=H.mul(.75).div(T.y).toVar();C.assign(c9(p,L,W,H.mul(.75),V))});let N=e.alpha.mul(e.mask).toVar(),B=N.div(Ae(N.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(N)),{color:C,calpha:B}})}),WCt=j(()=>{He(),nb(),cn(),dn(),OL=t=>t,dht=t=>t,Vn("outline",(t,e,i)=>{let r=t.getColor("outlineColor"),s=t.getColor("contourColor"),n=t.getFloat("outlineWidth"),a=t.getFloat("contourWidth"),o=t.getFloat("outlineThreshold"),l=t.getFloat("contourThreshold"),u=t.getFloat("outlineSmoothing"),h=t.getFloat("contourFrequency"),d=t.getVec3("contourDirection"),c=t.getBool("positionalLines"),p=t.getBool("compensation"),m=Lt.normalRenderTarget,f=Lt.normalRenderTargetDepth,g=Lt.resolution,y=Lt.pixelRatio,v=vm("randomColor","vec3").x.toVar(),b=sD.toVar(),_=Jl.toVar(),x=at(I(1).div(g.x),I(1).div(g.y)).toVar(),S=Lt.pcssHalton,w=Ac(Ja.xy.add(S)).mul(6.28318530718).toVar(),T=p.select(n.div(2),n),C=x.mul(T).mul(y).toVar(),M=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=st=>bm(st,9,w).mul(x),R=[],O=I(0).toVar();for(let st=0;st<9;st++){let[nt,xt]=M[st],pt=st===4?_:OL(_.add(at(C.x.mul(nt),C.y.mul(xt))).add(A(st))),K=OL(pt).toVar(),ct=dht(m.sample(K)).toVar();R.push(ct),bt(ct.a.notEqual(v).and(ct.a.notEqual(0)),()=>{let St=f.sample(K).r.add(1e-4);bt(b.greaterThan(St),()=>{O.assign(1)})})}let N=R[2].rgb.add(R[5].rgb.mul(2)).add(R[8].rgb).sub(R[0].rgb.add(R[3].rgb.mul(2)).add(R[6].rgb)),B=R[0].rgb.add(R[1].rgb.mul(2)).add(R[2].rgb).sub(R[6].rgb.add(R[7].rgb.mul(2)).add(R[8].rgb)),L=xl(kt(N,N).add(kt(B,B))).mul(O.oneMinus()).toVar(),z=G(r).toVar(),k=tr(o.sub(u),o.add(u),L).toVar(),V=xe(h0).toVar(),H=I(1).sub(l).toVar();bt(c,()=>{let st=Za.mul(d),nt=st.x.add(st.y).add(st.z).toVar(),xt=Oi(nt.mul(h).mul(.01)),pt=Qj(nt.mul(h)),K=tr(pt.mul(a.mul(.01)),pt.mul(a.mul(.02)),xt).toVar();bt(K.lessThan(1).and(k.equal(0)),()=>{z.assign(s),k.assign(1)})}).Else(()=>{let st=V.mul(d),nt=st.x.add(st.y).add(st.z).toVar(),xt=Qj(nt.mul(l)).toVar(),pt=Bn(nt.mul(h)).toVar(),K=tr(I(0),xt.mul(a),I(1).sub(pt)).toVar();bt(xt.greaterThan(H.mul(.5)).and(K.lessThan(1)).and(k.equal(0)),()=>{z.assign(s),k.assign(I(1).sub(K))})});let W=e.alpha.mul(k).mul(e.mask).toVar(),X=W.div(Ae(W.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(W)),{color:z,calpha:X}})}),qCt=j(()=>{He(),cn(),Vn("vertexColor",(t,e,i)=>{let r=u1t(),s=e.alpha.mul(e.mask).mul(r.a);return{color:r.rgb,calpha:sb(s,i)}})}),Uvt=j(()=>{RCt(),DCt(),NCt(),OCt(),ICt(),BCt(),VCt(),kCt(),zCt(),LCt(),FCt(),lvt(),UCt(),jCt(),GCt(),WCt(),qCt(),avt()});function cht(t){let e=t.data,i=[t.kind,t.type,`v=${!!e.visible}`,`m=${!!e.isMask}`,`p=${t.params.names().join(",")}`];if(t.type!=="light"){let r=sT[t.type];if(r!==void 0)for(let s of r)i.push(`${s}=${String(e[s])}`)}for(let[r,s]of t.uniformKinds)(s==="vec4array"||s==="floatArray")&&i.push(`${r}#${(t.params.getValue(r)??[]).length}`);if(t.type==="rainbow"&&i.push(`noise=${t.noiseCompiledIn!==!1}`,`forced=${t.noiseForced===!0}`),t.type==="displace"&&i.push(`dt=${String(e.displacementType)}`),t.type==="texture"||t.type==="video"||t.type==="matcap"){if(t.holders.length===0)throw new Error(`structuralKey: ${t.type} layer has no holder`);let r=e.texture??{};i.push(`holder=${t.holders.map(s=>s.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var HCt=j(()=>{Jv()});function Kn(t,e=1){let i=new ae(t);return new Dr(i.r,i.g,i.b,e)}function H9(t,e){if(t instanceof Dr)return t;if(t instanceof ae)return new Dr(t.r,t.g,t.b,1);if(typeof t=="number")return Kn(t);if(typeof t=="object"&&t!==null&&"r"in t&&"g"in t&&"b"in t){let i=t;return new Dr(i.r,i.g,i.b,i.a??1)}return e()}function pht(){let t=new Array(10).fill(new Me(0,0,0,1)).map(e=>e.clone());return t[1]=new Me(1,1,1,1),t}function mht(){let t=new Array(10).fill(1);return t[0]=0,t}function y2(t,e){let i=t.material;if((i==null||i.isTSLNodeMaterial!==!0)&&(i=t.object?.material,i==null||i.isTSLNodeMaterial!==!0))return e;if(e.kind==="light"){let s=i.lightLayer;if(s==null)return e;let n=s.data?.category,a=e.data?.category;return n===a?s:e}let r=i.layers?.[e.structIndex];return r!==void 0&&r.type===e.type?r:e}function fht(t,e){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`[spe] ${t}.element() needs a build-time constant index (got ${String(e)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return e}function qe(t,e,i,r){let s,n,a=t.params;switch(i){case"float":s=gt(Number(r??0));break;case"int":s=gt(Number(r??0),"int");break;case"axis":s=gt(["x","y","z"].indexOf(String(r)),"int");break;case"bool":s=gt(!!r);break;case"vec2":s=gt(r instanceof Q?r:new Q);break;case"vec3":s=gt(r instanceof P?r:new P);break;case"vec4":s=gt(r instanceof Me?r:new Me);break;case"color":{let o=H9(r,()=>Kn(16777215));s=gt(o),n=o;break}case"colorVec4":{let o=H9(r,()=>new Dr(1,1,1,1)),l=new Me(o.r,o.g,o.b,o.a),u=gt(l);u.onObjectUpdate(h=>{let d=y2(h,t).params.getLiveValue(e)??o;l.set(d.r,d.g,d.b,d.a)}),s=u,n=o;break}case"vec4array":{let o=Array.isArray(r)?r:[];s=function(l,u,h){let d=new Map;return{element(c){let p=fht(u,c),m=d.get(p);if(m===void 0){let f=gt(h[p]??new Me);f.onObjectUpdate(g=>(y2(g,l).params.getValue(u)??h)[p]??qvt),m=f,d.set(p,m)}return m},array:h,get value(){return h},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(h.length,c.length);p++){let m=c[p];Array.isArray(m)?h[p].set(m[0]??0,m[1]??0,m[2]??0,m[3]??1):m&&typeof m=="object"&&h[p].set(m.x??0,m.y??0,m.z??0,m.w??1)}}}}(t,e,o.length>0?o:[new Me]),n=o;break}case"floatArray":{let o=Array.isArray(r)?r:[0];s=function(l,u,h){let d=new Map;return{element(c){let p=fht(u,c),m=d.get(p);if(m===void 0){let f=gt(h[p]??0);f.onObjectUpdate(g=>{let y=y2(g,l).params.getValue(u);return Number((y??h)[p]??0)}),m=f,d.set(p,m)}return m},array:h,get value(){return h},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(h.length,c.length);p++)h[p]=Number(c[p])}}}(t,e,o.length>0?o:[0]),n=o;break}}i!=="vec4array"&&i!=="floatArray"&&i!=="colorVec4"&&(BW(s),s.onObjectUpdate(o=>{let l=y2(o,t).params.getValue(e);l!==void 0&&VW(s,l)})),a.set(e,s,n),t.uniformKinds.set(e,i)}function qS(t,e){let i=t.data;i.type!=="displace"?("alpha"in i&&t.params.has("alpha")&&t.params.setValue("alpha",Bv(i.alpha,e)*(i.visible?1:0)),i.type==="outline"&&t.params.has("compensation")&&t.params.setValue("compensation",!!i.compensation&&!!i.visible)):t.params.has("intensity")&&t.params.setValue("intensity",(Mn(i.intensity,e)??1)*(i.visible?1:0))}function jvt(t,e){qe(t,"alpha","float",e.alpha??1),qe(t,"mode","int",e.mode??0),qe(t,"isMask","float",e.isMask?1:0)}function Gvt(t,e,i,r){let s=new v2(t,e,i),n=i;if(qe(s,"alpha","float",Bv(n.alpha,r)),qe(s,"mode","int",n.mode??0),qe(s,"bumpMapIntensity","float",n.bumpMapIntensity??5),qe(s,"alphaOverride","float",Bv(n.alphaOverride,r)),i.visible)if(n.category==="lambert")qe(s,"emissive","color",r.color(n.emissive)??Kn(0)),qe(s,"occlusion","bool",n.occlusion??!0);else if(n.category==="toon")qe(s,"shininess","float",n.shininess??30),qe(s,"specular","color",r.color(n.specular)??Kn(1118481));else if(n.category==="physical"){qe(s,"roughness","float",n.roughness??.3),qe(s,"metalness","float",n.metalness??0),qe(s,"reflectivity","float",n.reflectivity??.5),qe(s,"occlusion","bool",n.occlusion??!0),qe(s,"normalScale","float",n.normalScale??1),qe(s,"aoMapIntensity","float",n.aoMapIntensity??1),qe(s,"emissive","color",n.emissive!==void 0?r.color(n.emissive)??Kn(0):Kn(0)),qe(s,"emissiveIntensity","float",n.emissiveIntensity??1);let a=n;a.clearcoat!==void 0&&(qe(s,"clearcoat","float",a.clearcoat),qe(s,"clearcoatRoughness","float",a.clearcoatRoughness??.1)),a.sheen!==void 0&&(qe(s,"sheen","float",a.sheen),qe(s,"sheenColor","color",a.sheenColor!==void 0?r.color(a.sheenColor)??Kn(16777215):Kn(16777215)),qe(s,"sheenRoughness","float",a.sheenRoughness??.5)),a.ior!==void 0&&(qe(s,"ior","float",a.ior),qe(s,"specularIntensity","float",a.specularIntensity??1),qe(s,"specularColor","color",a.specularColor!==void 0?r.color(a.specularColor)??Kn(16777215):Kn(16777215))),a.iridescence!==void 0&&(qe(s,"iridescence","float",a.iridescence),qe(s,"iridescenceIOR","float",a.iridescenceIOR??1.3),qe(s,"iridescenceThickness","float",a.iridescenceThickness??400))}else qe(s,"shininess","float",n.shininess??30),qe(s,"specular","color",n.specular!==void 0?r.color(n.specular)??Kn(1118481):Kn(1118481)),qe(s,"occlusion","bool",n.occlusion??!0);return s.node.alphaOverride=s.params.get("alphaOverride"),qS(s,r),s}function Wvt(t,e,i,r){let s=new HS("fragment",t,e,i),n=i.type==="texture"?i.texture.image!=null?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):i.type==="video"?r.video(i.texture.video):i.texture.image!=null?r.image(i.texture.image):r.getImage("");s.holders.push(n);let a=i.texture.wrapping??(i.type==="texture"?1e3:1001),o=function(u,h,d,c){let p=ee(u.getTexture(h,d,c));return p.onRenderUpdate(()=>u.getTexture(h,d,c)),p}(n,a,i.texture.minFilter??1008,i.texture.magFilter??1006);s.params.set("texture",o);let l=Mn(i.texture.rotation??0,r)??0;if(i.type==="matcap")qe(s,"rotation","float",l*qt.DEG2RAD);else{let u=gt(new Q(1,1));u.onRenderUpdate(()=>{let f=n.getTexture(a,i.texture.minFilter??1008,i.texture.magFilter??1006).image;u.value.set(f?.width??1,f?.height??1)}),s.params.set("textureSize",u),s.uniformKinds.set("textureSize","vec2");let h=gt(n.loaded||n.isBuffer?1:0);h.onRenderUpdate(()=>n.loaded||n.isBuffer?1:0),s.params.set("loaded",h),s.uniformKinds.set("loaded","float"),qe(s,"crop","float",i.crop?1:0),qe(s,"projection","int",i.projection??0),qe(s,"axis","axis",i.axis),qe(s,"projectionAxis","axis",i.projectionAxis),qe(s,"side","int",i.side??0);let d=i.size?new Q(Mn(i.size[0],r)??0,Mn(i.size[1],r)??0):new Q(100,100);qe(s,"size","vec2",d),qe(s,"blending","float",i.blending??0);let c=new Ts,p=new Hvt([Mn(i.texture.repeat?.[0]??1,r)??1,Mn(i.texture.repeat?.[1]??1,r)??1],[Mn(i.texture.offset?.[0]??0,r)??0,Mn(i.texture.offset?.[1]??0,r)??0],l,c),m=gt(c);BW(m),m.onObjectUpdate(f=>{let g=y2(f,s).params.getNodeValue("mat");g!==void 0&&VW(m,g)}),s.params.set("mat",m,p)}return jvt(s,{alpha:Bv(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),qS(s,r),s}function $Ct(t,e,i,r){if(i.type==="light")return Gvt(t,e,i,r);if(i.type==="texture"||i.type==="video"||i.type==="matcap")return Wvt(t,e,i,r);if(i.type==="displace")return function(o,l,u,h){if(u.displacementType!=="noise")throw new Error;let d=new HS("vertex",o,l,u),c=(p,m)=>Mn(p,h)??m;return qe(d,"offset","vec3",new P(...u.offset.map(p=>c(p,0)))),qe(d,"scale","float",c(u.scale,10)),qe(d,"intensity","float",c(u.intensity,8)),qe(d,"movement","float",c(u.movement,1)),qe(d,"noiseType","int",u.noiseType??0),qe(d,"voronoiStyle","int",u.voronoiStyle??0),qe(d,"smoothness","float",c(u.smoothness,.5)),qe(d,"seed","float",c(u.seed,0)),qe(d,"highCut","float",c(u.highCut,1)),qe(d,"lowCut","float",c(u.lowCut,0)),qe(d,"quality","int",Mn(u.quality,h)??1),qS(d,h),d}(t,e,i,r);let s=new HS("fragment",t,e,i),n=function(o,l){switch(o.type){case"cavity":return function(u,h){return{...ao(u,h),ridge:u.ridge,valley:u.valley}}(o,l);case"dust":return function(u,h){return{...ao(u,h),color:Sa(u.color,h),coverage:Mn(u.coverage,h)??.2,softness:Mn(u.softness,h)??.2,noiseStrength:Mn(u.noiseStrength,h)??.2,noiseScale:Mn(u.noiseScale,h)??1}}(o,l);case"fresnel":return function(u,h){let{bias:d,scale:c,intensity:p,factor:m,color:f}=u;return{...ao(u,h),color:Sa(f,h),bias:d,scale:c,intensity:p,factor:m}}(o,l);case"gradient":return function(u,h){let{gradientType:d,smooth:c,colors:p,steps:m,angle:f,offset:g,morph:y}=u;return{...ao(u,h),gradientType:d,smooth:c,colors:p.map(v=>new Me(v[0],v[1],v[2],v[3])),num:p.length,steps:m,offset:new Q(...g.map(v=>typeof v=="number"?v:0)),morph:new Q(...y.map(v=>typeof v=="number"?v:0)),angle:f}}(o,l);case"depth":return function(u,h){let{gradientType:d,near:c,far:p,isVector:m,isWorldSpace:f,origin:g,direction:y,colors:v,steps:b,smooth:_}=u;return{...ao(u,h),gradientType:d,near:c,far:p,isVector:m,isWorldSpace:f,origin:new P(...g),direction:y?new P(...y):new P(1,0,0),colors:v.map(x=>x!==void 0?new Me(x[0],x[1],x[2],x[3]):new Me(0,0,0,0)),steps:b.slice(0,v.length),smooth:_}}(o,l);case"normal":return function(u,h){let{cnormal:d}=u;return{...ao(u,h),cnormal:new P(d[0],d[1],d[2])}}(o,l);case"noise":return function(u,h){return{...ao(u,h),scale:u.scale,move:u.move,fA:new Q(...u.fA.map(d=>typeof d=="number"?d:0)),fB:new Q(...u.fB.map(d=>typeof d=="number"?d:0)),size:new P(...u.size),distortion:new Q(...u.distortion.map(d=>typeof d=="number"?d:0)),colorA:Sa(u.colorA,h),colorB:Sa(u.colorB,h),colorC:Sa(u.colorC,h),colorD:Sa(u.colorD,h),noiseType:u.noiseType,voronoiStyle:u.voronoiStyle,highCut:u.highCut,lowCut:u.lowCut,smoothness:u.smoothness,seed:u.seed,quality:u.quality}}(o,l);case"rainbow":return function(u,h){return{...ao(u,h),filmThickness:u.filmThickness,movement:u.movement,wavelengths:new P(...u.wavelengths),noiseStrength:u.noiseStrength,noiseScale:u.noiseScale,offset:new P(...u.offset)}}(o,l);case"toon":return function(u,h){return{...ao(u,h),positioning:u.positioning,colors:u.colors.map(d=>new Me(d[0],d[1],d[2],d[3])),num:u.colors.length,steps:u.steps,source:new P(...u.source),isWorldSpace:u.isWorldSpace,noiseStrength:u.noiseStrength,noiseScale:u.noiseScale,shadowColor:Sa(u.shadowColor,h),offset:new P(...u.offset)}}(o,l);case"outline":return function(u,h){return{...ao(u,h),outlineColor:Sa(u.outlineColor,h),contourColor:Sa(u.contourColor,h),outlineWidth:u.outlineWidth,contourWidth:u.contourWidth,outlineThreshold:u.outlineThreshold,contourThreshold:u.contourThreshold,outlineSmoothing:u.outlineSmoothing,contourFrequency:u.contourFrequency,contourDirection:new P(...u.contourDirection),positionalLines:u.positionalLines,compensation:u.compensation}}(o,l);case"transmission":return function(u,h){return{...ao(u,h),thickness:u.thickness,ior:u.ior,roughness:u.roughness,attenuationColor:u.attenuationColor!==void 0?Sa(u.attenuationColor,h):{r:1,g:1,b:1,a:1},attenuationDistance:u.attenuationDistance??0}}(o,l);case"reflection":return function(u,h){return{...ao(u,h),blur:Mn(u.blur,h)??0,thickness:Mn(u.thickness,h)??.001,steps:Mn(u.steps,h)??60,stepSize:Mn(u.stepSize,h)??.005,tracingMode:u.tracingMode,mirror:u.mirror??0}}(o,l);case"pattern":return function(u,h){return{...ao(u,h),style:u.style,projection:u.projection,axis:u.axis,blending:u.blending,offset:new Q(...u.offset.map(d=>typeof d=="number"?d:0)),colorA:Sa(u.colorA,h),colorB:Sa(u.colorB,h),frequency:new Q(...u.frequency.map(d=>typeof d=="number"?d:0)),size:u.size,variation:u.variation,smoothness:u.smoothness,zigzag:u.zigzag,rotation:u.rotation,vertical:new Q(...u.vertical.map(d=>typeof d=="number"?d:0)),horizontal:new Q(...u.horizontal.map(d=>typeof d=="number"?d:0)),sides:u.sides}}(o,l);case"vertexColor":return ao(o,l);default:return function(u,h){return{...ao(u,h),color:Sa(u.color,h)}}(o,l)}}(i,r),a=$9[i.type]??$9.color;for(let[o,l]of Object.entries(a))qe(s,o,l.kind,n[o]??l.def());if(i.type==="transmission"){let o=typeof window<"u"?window.innerWidth:1,l=typeof window<"u"?window.innerHeight:1;qe(s,"aspectRatio","vec2",o>=l?new Q(l/o,1):new Q(1,o/l))}return jvt(s,n),qS(s,r),s}var ght,IL,$9,qvt,Hvt,HS,v2,yht,$p,LW,XCt=j(()=>{dt(),mr(),k5(),w1t(),He(),ke(),FG(),wCt(),Jv(),Dc(),Uft(),cn(),avt(),EW(),lvt(),PCt(),Uvt(),tD(),HCt(),ght=t=>t,IL=t=>t,$9={color:{color:{kind:"color",def:()=>Kn(Jg)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>Kn(16777215)},bias:{kind:"float",def:()=>.1},scale:{kind:"float",def:()=>1},intensity:{kind:"float",def:()=>2},factor:{kind:"float",def:()=>1}},dust:{color:{kind:"color",def:()=>Kn(10323813)},coverage:{kind:"float",def:()=>.2},softness:{kind:"float",def:()=>.2},noiseStrength:{kind:"float",def:()=>.2},noiseScale:{kind:"float",def:()=>1}},rainbow:{filmThickness:{kind:"float",def:()=>30},movement:{kind:"float",def:()=>0},wavelengths:{kind:"vec3",def:()=>new P},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new P}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>Kn(16777215)},attenuationDistance:{kind:"float",def:()=>0}},reflection:{blur:{kind:"float",def:()=>0},thickness:{kind:"float",def:()=>.001},steps:{kind:"int",def:()=>60},stepSize:{kind:"float",def:()=>.005},tracingMode:{kind:"int",def:()=>1}},toon:{positioning:{kind:"int",def:()=>0},colors:{kind:"vec4array",def:pht},steps:{kind:"floatArray",def:mht},source:{kind:"vec3",def:()=>new P},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new Dr(0,0,0,0)},offset:{kind:"vec3",def:()=>new P}},outline:{outlineColor:{kind:"color",def:()=>Kn(16777215)},contourColor:{kind:"color",def:()=>Kn(16777215)},outlineWidth:{kind:"float",def:()=>.1},contourWidth:{kind:"float",def:()=>.1},outlineThreshold:{kind:"float",def:()=>.1},contourThreshold:{kind:"float",def:()=>.1},outlineSmoothing:{kind:"float",def:()=>.1},contourFrequency:{kind:"float",def:()=>.1},contourDirection:{kind:"vec3",def:()=>new P(0,1,0)},positionalLines:{kind:"bool",def:()=>!1},compensation:{kind:"bool",def:()=>!0}},depth:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},near:{kind:"float",def:()=>50},far:{kind:"float",def:()=>200},isVector:{kind:"float",def:()=>1},isWorldSpace:{kind:"float",def:()=>0},origin:{kind:"vec3",def:()=>new P},direction:{kind:"vec3",def:()=>new P(1,0,0)},colors:{kind:"vec4array",def:()=>[new Me(0,0,0,1),new Me(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new P(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new Q(1.7,9.2)},fB:{kind:"vec2",def:()=>new Q(8.3,2.8)},distortion:{kind:"vec2",def:()=>new Q(1,1)},colorA:{kind:"colorVec4",def:()=>new Dr(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new Dr(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},noiseType:{kind:"int",def:()=>0},voronoiStyle:{kind:"int",def:()=>0},highCut:{kind:"float",def:()=>1},lowCut:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},seed:{kind:"float",def:()=>.5},quality:{kind:"int",def:()=>1}},normal:{cnormal:{kind:"vec3",def:()=>new P(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:pht},steps:{kind:"floatArray",def:mht},offset:{kind:"vec2",def:()=>new Q},morph:{kind:"vec2",def:()=>new Q},angle:{kind:"float",def:()=>0}},pattern:{style:{kind:"int",def:()=>0},projection:{kind:"int",def:()=>0},axis:{kind:"axis",def:()=>"x"},blending:{kind:"float",def:()=>0},offset:{kind:"vec2",def:()=>new Q},colorA:{kind:"colorVec4",def:()=>new Dr(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},frequency:{kind:"vec2",def:()=>new Q(10,10)},size:{kind:"float",def:()=>.5},variation:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},zigzag:{kind:"float",def:()=>0},rotation:{kind:"float",def:()=>0},vertical:{kind:"vec2",def:()=>new Q(0,1)},horizontal:{kind:"vec2",def:()=>new Q(0,1)},sides:{kind:"int",def:()=>6}}},qvt=new Me,Hvt=class{constructor(t,e,i,r){this.repeat=t,this.offset=e,this.rotation=i,this.target=r,this.updateMatrix()}updateMatrix(){this.target.setUvTransform(this.offset[0],this.offset[1],this.repeat[0],this.repeat[1],0,0,0).premultiply(new Ts().makeRotation(this.rotation*qt.DEG2RAD))}},HS=class{constructor(t,e,i,r){this.kind=t,this.id=e,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new kW(e)}get type(){return this.data.type}get uniforms(){return this.params.uniforms}get alphaNode(){return this.params.getFloat("alpha")}get modeNode(){return this.params.getInt("mode")}get isMaskNode(){return this.params.getFloat("isMask")}get isMaskEnabled(){return"isMask"in this.data&&!!this.data.isMask}hasValue(t){return this.params.has(t)}setValue(t,e){if(t==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof e=="number"&&e!==0&&this.onNoiseMismatch!==void 0){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(t,e),void(i(e)&&(this.noiseCompiledIn=!0))}this.params.setValue(t,e)}getNode(t){return this.params.has(t)?this.params.get(t):void 0}getValue(t){return this.params.getValue(t)}getName(t){let e=/f\d+_(.*)/.exec(t);if(e&&e.length>1)return e[1];console.log(`Layer.getName: error ${t}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(t=>t.loaded)}dispose(){for(let t of this.holders)t instanceof gg||t.deref();this.holders.length=0}},v2=class extends HS{constructor(t,e,i){super("light",t,e,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},yht={displace_noise:[{nums:["intensity","scale","movement","smoothness","seed","highCut","lowCut"],vecs:["offset"]}],displace_map:[{nums:["intensity"],vecs:[]}],depth:[{nums:["near","far"],vecs:["origin","direction"]}],cavity:[{nums:["ridge","valley"],vecs:[]}],fresnel:[{nums:["bias","scale","intensity","factor"],vecs:[]}],dust:[{nums:["coverage","softness","noiseStrength","noiseScale"],vecs:[]}],rainbow:[{nums:["filmThickness","movement","noiseStrength","noiseScale"],vecs:["offset","wavelengths"]}],noise:[{nums:["scale","move","seed","highCut","lowCut","smoothness"],vecs:["size","distortion","fA","fB"]}],pattern:[{nums:["blending","size","variation","smoothness","zigzag","rotation"],vecs:["offset","frequency","vertical","horizontal"]}],outline:[{nums:["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],vecs:["contourDirection"]}],toon:[{nums:["noiseStrength","noiseScale"],vecs:["offset","source"]}],transmission:[{nums:["roughness","thickness","ior"],vecs:[]}],reflection:[{nums:["blur","thickness","steps","stepSize"],vecs:[]}],texture:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],video:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],gradient:[{nums:["angle"],vecs:["offset","morph"]}],matcap:[{nums:["rotation"],vecs:[],path:["texture"]}]},$p=class extends Re{constructor(t,e,i=!0,r,s=!1){super(),this.allowVariableSaves=i,this.isTSLNodeMaterial=!0,this.layerIdGen=0,this.layers=[],this.flavors=[],this.depthTwins=[],this.depthPrepass=!1,this.depthPrepassCutoff=0,this.depthPrepassTwins=[],this.flatShading=!1,this.wireframe=!1,this.emissiveNode=null,this.shapeBlendOptions=null,this.envMapRotation=Gh.rotation,this._shapeBlendResources=null,this._shapeBlendColorNode=null,this.shapeBlendObjectNormal=null,this.displacedObjectNormal=null,this.syntheticMapLayers=new Map,this._structuralKey=null,this._structuralKeyVersion=-1,this.forceRainbowNoise=new Set,this.root=r??this,this.isDepthPrepassTwin=s,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(t,e),jS.add(this),this.addEventListener("dispose",()=>function(n){jS.delete(n)}(this))}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let t=this._structuralKey;if(t===null||this._structuralKeyVersion!==this.version){try{t=function(r){let s=r.lightLayer,n=s.data,a=u=>{if(!u)return-1;if(typeof u!="string"){let c=r.syntheticMapLayers?.get(u);return c!==void 0?`img(${cht(c)};o=${JSON.stringify(u.offset??null)};r=${JSON.stringify(u.repeat??null)})`:"img"}let h=r.layers.findIndex(c=>c.uuid===u);if(h===-1||r.layers[h].kind!=="fragment")return-1;let d=r.layers[h].type;return d==="texture"||d==="video"?h:-1},o=r.category==="physical",l=["spe-tsl-v1",`lights=${r.lights}`,`cat=${r.category}`,`lvis=${n.visible===!0}`,`lidx=${r.layers.indexOf(s)}`,`bump=${a(n.bumpMap)}`,`rough=${o?a(n.roughnessMap):-1}`,`metal=${o?a(n.metalnessMap):-1}`,`nrm=${o?a(n.normalMap):-1}`,`ao=${o?a(n.aoMap):-1}`,`emis=${o?a(n.emissiveMap):-1}`,`rch=${o?n.roughnessMapChannel??"luminance":""}`,`mch=${o?n.metalnessMapChannel??"b":""}`,`ach=${o?n.aoMapChannel??"r":""}`];for(let u of r.layers)l.push(cht(u));return l.join("|")}(this),this.shapeBlendOptions!==null&&(t+=`|sb:${this.uuid}:${this._shapeBlendResources!==null?1:0}`)}catch{t=super.customProgramCacheKey()}this._structuralKey=t,this._structuralKeyVersion=this.version}let e=this.envNode instanceof Gv?Gh.version:0,i=this.physicalLobes();return`${t}|env${e}|lobes${(i.clearcoat?1:0)|(i.sheen?2:0)|(i.iridescence?4:0)}`}get isRoot(){return this.root===this}applyDepthPrepassPolicy(){if(this.isDepthPrepassTwin)return this.depthPrepass=!1,this.colorWrite=!1,void(this.depthWrite=!0);let t=(e={transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.shapeBlendOptions!==null,data:this.root.data},u9&&e.transparent&&e.depthTest&&!e.wireframe&&!e.shapeBlend&&!function(i){let r=i?.layers;if(!r)return!1;for(let s of r)if(s.data.type==="transmission"&&s.data.visible)return!0;return!1}(e.data));var e;this.depthPrepass=t,this.depthWrite=!t}getDepthPrepassTwin(t){let e=this.depthPrepassTwins[t];if(e===void 0){let i=this.root;e=new $p(i.data,i.lastContext,i.allowVariableSaves,i,!0),e.flatShading=this.flatShading,e.side=t,e.wireframe=!1,e.depthPrepassCutoff=cft,e.applyDepthPrepassPolicy(),this.depthPrepassTwins[t]=e,i.depthTwins.push(e)}return e}get vertexObjectNormal(){return this.shapeBlendObjectNormal??this.root.displacedObjectNormal}get category(){return this.lightLayer.category}envReflectiveInLow(){let t=!1;for(let e of this.layers){let i=e.data;if(i?.category==="physical"&&(t=!0,i.roughnessMap!==void 0||i.metalnessMap!==void 0||typeof i.roughness!="number"||typeof i.metalness!="number"||i.clearcoat!==void 0||i.sheen!==void 0||i.iridescence!==void 0||i.ior!==void 0||i.metalness>.3||i.roughness<.4))return!0}return!t}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(t,e,i=!1){(this.data!==t||i)&&this.reset0(t,e)}reset0(t,e){this.lastContext=e,this.data=t;let i=t.layers??cs.defaultTwoLayerData("phong").layers;for(let n of this.layers)n.dispose();for(let n of this.syntheticMapLayers.values())n.dispose();this.syntheticMapLayers.clear();let r=[];for(let n of i)try{let a=$Ct(this.layerIdGen++,n.id,n.data,e.shared);a.type==="rainbow"&&this.armRainbowNoiseSpecialization(a),r.push(a)}catch(a){console.warn(`[spe] material layer '${n.data.type}' (${n.id}) failed to build \u2014 skipping this layer`,a)}this.layers=r,this.layers.reverse();for(let n=0;n<this.layers.length;n++)this.layers[n].structIndex=n;this.name=t.name??"Untitled Material";let s=this.layers.find(n=>n instanceof v2);if(s===void 0&&(s=Gvt(0,"",{...Hs.defaultData("light","phong"),visible:!1},e.shared)),this.lightLayer=s,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:I(0).toVar("accumAlpha"),lightsAvailable:this.lights&&(this.category==="phong"||this.category==="lambert"||this.category==="physical")},this.colorNode=Et(()=>this.buildColorStack())(),this.buildVertexStack(),this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=this.lights&&this.category==="lambert"&&this.lightLayer.params.has("emissive")?this.lightLayer.params.get("emissive"):null,this.aoNode=null,this.lights&&this.category==="physical"){let n=this.lightLayer.params,a=this.lightLayer.lightData;if(n.has("emissive")){let l=this.findTextureMapLayer(a.emissiveMap);this.emissiveNode=Et(()=>{let u=G(n.getColor("emissive")).mul(n.getFloat("emissiveIntensity"));return l!==null&&(u=u.mul(function(h){let d,c=h.get("texture"),p=h.has("loaded")?h.getFloat("loaded"):I(1),{uvs:m,weights:f}=aS(h);if(f!==null){let g=G(Pa(c.sample(m[0])).rgb).toVar(),y=G(Pa(c.sample(m[1])).rgb).toVar(),v=G(Pa(c.sample(m[2])).rgb).toVar();d=ur(g.mul(f.z).add(y.mul(f.x)).add(v.mul(f.y)))}else d=ur(G(Pa(c.sample(m[0])).rgb));return ur(Yt(G(0),d,p))}(l.params))),u})()}let o=this.findTextureMapLayer(a.aoMap);o!==null&&(this.aoNode=Et(()=>Yt(I(1),ML(o.params,a.aoMapChannel??"r"),n.getFloat("aoMapIntensity")))())}this.transparent=Dg(t,e.shared),this.applyDepthPrepassPolicy(),nS(this),this.needsUpdate=!0;for(let n of this.flavors)n?.syncFromRoot();for(let n of this.depthTwins)n.syncFromRoot();this.saveVariableLocations(e)}setTransparent(t,e){if(!this.isRoot)return void this.root.setTransparent(t,e);let i=this.transparent!==t;if(i){this.transparent=t,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=t,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=t,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||e?.markNeedsUpdateRendererDirty()}syncFromRoot(){let t=this.root;this.data=t.data,this.layers=t.layers,this.lightLayer=t.lightLayer,this.ctx=t.ctx,this.name=t.name,this.lights=t.lights,this.colorNode=t.colorNode,this.positionNode=t.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=t.emissiveNode,this.aoNode=t.aoNode,this.transparent=t.transparent,this.applyDepthPrepassPolicy(),this._applyShapeBlendGraph(),nS(this),this.needsUpdate=!0}getFlavor(t,e,i,r){if(!this.isRoot)return this.root.getFlavor(t,e,i,r);let s=i?6:(t?3:0)+e;if(s+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),s===0)return this;s-=1;let n=this.flavors[s];return n===void 0&&(n=new $p(this.data,this.lastContext,this.allowVariableSaves,this),n.flatShading=t,n.side=e,n.wireframe=i,r&&(n.shapeBlendOptions={...r},n.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},n._invalidateStructuralKey()),n.applyDepthPrepassPolicy(),this.flavors[s]=n),n}getShapeBlendBaseColor(){let t=this.layers.find(r=>r.kind==="fragment"&&r.type==="color"),e=t?.getValue("color"),i=t?.getValue("alpha");return{r:e?.r??1,g:e?.g??1,b:e?.b??1,a:i??1}}setShapeBlendResources(t){this._shapeBlendResources=t,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources||F4===null)return;let t=F4(this._shapeBlendResources);this.positionNode=t.position,this.shapeBlendObjectNormal=t.normal,this.normalNode=this.buildNormalNode(Jj(X4(t.normal))),this.castShadowPositionNode=t.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=t.color,this.colorNode=Et(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(t=>t instanceof v2)}findTextureMapLayer(t){if(!t)return null;if(typeof t!="string")return gU.is(t)?this.syntheticMapLayer(t):null;let e=this.layers.find(i=>i.uuid===t);return e===void 0||e.kind!=="fragment"?null:e.type==="texture"||e.type==="video"?e:null}syntheticMapLayer(t){if(!this.isRoot)return this.root.syntheticMapLayer(t);let e=this.syntheticMapLayers.get(t);if(e!==void 0)return e;try{let i=Hs.defaultData("texture"),r={...i,visible:!1,texture:{...i.texture,image:t.image,wrapping:t.wrapping??1e3,offset:t.offset??[0,0],repeat:t.repeat??[1,1],minFilter:t.minFilter??1008,magFilter:t.magFilter??1006}},s=Wvt(this.layerIdGen++,`mapImage${this.layerIdGen}`,r,this.lastContext.shared);return this.syntheticMapLayers.set(t,s),s}catch(i){return console.warn("[spe] light-layer map image failed to build \u2014 skipped",i),null}}buildNormalNode(t){if(this.lights&&this.category==="physical"&&!this.wireframe){let s=this.lightLayer.lightData,n=this.findTextureMapLayer(s.normalMap);if(n!==null){let a=this.lightLayer.params.getFloat("normalScale");return Et(()=>function(o,l,u){let h=G(u??Oa).toVar(),d=ur(Rc),c=o.get("texture"),p=o.has("loaded")?o.getFloat("loaded"):I(1),m=y=>{let v=at(y).toVar(),b=G(Pa(c.sample(v)).rgb.mul(2).sub(1)).toVar(),_=G(Yt(G(0,0,1),ur(b),p)).toVar();_.xy.mulAssign(l);let x=G(kv(d)).toVar(),S=G(zv(d)).toVar(),w=at(kv(v)).toVar(),T=at(zv(v)).toVar(),C=G(xe(ur(h))).toVar(),M=G(Zr(ur(S),C)).toVar(),A=G(Zr(C,ur(x))).toVar(),R=G(ur(M).mul(w.x).add(ur(A).mul(T.x))).toVar(),O=G(ur(M).mul(w.y).add(ur(A).mul(T.y))).toVar(),N=I(Qt(kt(ur(R),ur(R)),kt(ur(O),ur(O)))).toVar(),B=I(fi(N.equal(0),I(0),$u(aD).mul(xW(N)))).toVar();return ur(xe(ur(R).mul(_.x.mul(B)).add(ur(O).mul(_.y.mul(B))).add(C.mul(_.z))))},{uvs:f,weights:g}=aS(o);if(g!==null){let y=m(f[0]),v=m(f[1]),b=m(f[2]);return ur(xe(y.mul(g.z).add(v.mul(g.x)).add(b.mul(g.y))))}return m(f[0])}(n.params,a,t))()}}let e=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&this.category!=="lambert";if(e===null||!i||this.wireframe)return t;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return Et(()=>function(s,n,a){let o=G(a??Oa).toVar(),l=ur(Rc),u=s.get("texture"),{uvs:h,weights:d}=aS(s);if(d!==null){let c=nE(l,ur(o),sE(u,h[0],n)),p=nE(l,ur(o),sE(u,h[1],n)),m=nE(l,ur(o),sE(u,h[2],n));return ur(xe(c.mul(d.z).add(p.mul(d.x)).add(m.mul(d.y))))}return nE(l,ur(o),sE(u,h[0],n))}(e.params,r,t))()}buildVertexStack(){let t=this.layers.filter(i=>i.kind==="vertex");if(t.length===0)return this.positionNode=null,void(this.displacedObjectNormal=null);let e=function(i){let r=Lr("vec3","vDisplacedNormal");return{position:Et(s=>{let n=mo(Uv),a=mo(SW);for(let l=0;l<i.length;l++){let u=ECt(i[l],mo(Uv),a);n=l===0?u.position:mo(n.add(u.position).mul(.5)),a=u.normal}let o=G(n).toVar();return r.assign(a),s.needsPreviousData?.()===!0&&uD.assign(o),o})(),normal:r}}(t.map(i=>i.params));this.positionNode=e.position,this.displacedObjectNormal=e.normal}displacedNormalView(){let t=this.root.displacedObjectNormal;return t===null?null:Jj(X4(t))}maskSourceFor(t){let e=this.layers[t];if(e.kind==="fragment"&&e.isMaskEnabled)return null;let i=this.layers[t+1];return i!==void 0&&i.kind==="fragment"&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(t,e,i){let r=I(1);e!==null&&(r=this.evaluateMask(e));let s={alpha:i?.alpha??t.alphaNode,isMask:t.isMaskNode,mask:r,mode:t.modeNode,noiseCompiledIn:t.noiseCompiledIn},n=evt(t.type)(t.params,s,this.ctx);return i?.color?{...n,color:i.color}:n}evaluateMask(t){let e=this.runLayerBuilder(t,null);return oD(e.color.mul(e.calpha))}buildColorStack(){let t=this.lightLayerIndex(),e=t===-1?0:t,i=null;for(let r=0;r<e;r++){let s=this.layers[r];if(s.kind!=="fragment")continue;if(i===null){let a=this._shapeBlendColorNode;i=IL(this.runLayerBuilder(s,this.maskSourceFor(r),a?{color:IL(a.rgb),alpha:ght(a.w)}:void 0).color);continue}if(s.isMaskEnabled)continue;let n=this.runLayerBuilder(s,this.maskSourceFor(r));i=wR(i,n.color,n.calpha,s.modeNode)}return i??xyt(Jg)}setup(t){t.context.setupClearcoatNormal=()=>n1t(Oa,"NORMAL","vec3"),super.setup(t)}setupLightingModel(){let t=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(e,i=null,r=null,s=!1){switch(e){case"physical":{let n=new nvt(r?.clearcoat===!0,r?.sheen===!0,r?.iridescence===!0,!1,!1,!1);return n.envIrradianceActive=s,n}case"lambert":return new xv(!1);case"toon":{let n=new svt;return n.aoOcclusionGate=i,n}default:return new xv}}(this.category,t,this.physicalLobes(),this.envNode instanceof Gv)}physicalLobes(){let t=this.lightLayer.params;return{clearcoat:t.has("clearcoat"),sheen:t.has("sheen"),iridescence:t.has("iridescence")}}setupVariants(t){if(!this.lights)return;let e=null,i=null;if(this.category==="physical"){let r=this.lightLayer.lightData,s=this.findTextureMapLayer(r.roughnessMap);s!==null&&(e=Et(()=>ML(s.params,r.roughnessMapChannel??"luminance"))());let n=this.findTextureMapLayer(r.metalnessMap);n!==null&&(i=Et(()=>ML(n.params,r.metalnessMapChannel??"b"))())}(function(r,s,n=null,a=null){if(r==="phong"||r==="toon")$4.assign(s.getFloat("shininess").max(1e-4)),Z1.assign(s.getColor("specular"));else if(r==="physical"){let o=s.getFloat("metalness"),l=s.getFloat("roughness"),u=s.getFloat("reflectivity");if(n!==null&&(l=Wv(n.mul(l))),a!==null&&(o=Wv(Ae(a.mul(o),I(0),I(1)))),Byt.assign(o),AW.assign(Ae(l,I(.0525),I(1))),s.has("ior")){let h=s.getFloat("ior"),d=s.has("specularColor")?G(s.getColor("specularColor")):G(1),c=s.has("specularIntensity")?s.getFloat("specularIntensity"):I(1);lR.assign(h),Z1.assign(ii(Zyt(lR.sub(1).div(lR.add(1))).mul(d),G(1)).mul(c)),G9.assign(Yt(co(Z1),co(Vo.rgb),o)),t9.assign(Yt(c,I(1),o))}else{let h=G(u.pow(2).mul(.16));Z1.assign(h),G9.assign(Yt(h,co(Vo.rgb),o)),t9.assign(I(1))}if(j9.assign(co(Vo.rgb).mul(Rr(o))),s.has("clearcoat")&&(byt.assign(s.getFloat("clearcoat")),bW.assign(Ae(s.getFloat("clearcoatRoughness"),I(.0525),I(1)))),s.has("sheen")){let h=s.has("sheenColor")?G(s.getColor("sheenColor")):G(1);i1t.assign(h.mul(s.getFloat("sheen"))),r1t.assign(Ae(s.getFloat("sheenRoughness"),I(.07),I(1)))}s.has("iridescence")&&(Eyt.assign(s.getFloat("iridescence")),Pyt.assign(s.getFloat("iridescenceIOR")),Ryt.assign(s.getFloat("iridescenceThickness")))}})(this.category,this.lightLayer.params,e,i)}setupLighting(t){let e=this.lights===!0||this.lightsNode!==null,i=this.lights===!0?this.setupMaterialLightings(t):[],r=e?this.lightsNode??t.lightsNode:null,s=this.lights===!0?G(0):Vo.rgb,n=G(0),a=G(0);if(r&&(i.length>0||r.getScope().hasLights)){let o=this.setupLightingModel()||null,l=Nyt(r,o,i,this.backdropNode,this.backdropAlphaNode),u=l,h=u._value??(u._value=u.getContext());n=h.reflectedLight.directSpecular,a=h.reflectedLight.indirectSpecular,s=l}return this.emissiveNode!==null&&this.emissiveNode!==void 0&&(Zj.assign(G(this.emissiveNode)),s=s.add(Zj)),Et(()=>this.applyPostLighting(s,n,a))()}applyPostLighting(t,e,i){let r,s=this.ctx.accumAlpha,n=this.lights===!0,a=this.lightLayerIndex(),o=a===-1?0:a+1,l=I(1);if(n){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p)),r=function(m){let{outgoing:f,directSpecular:g,indirectSpecular:y,shadingAlpha:v,shadingBlend:b,mask:_,occlusion:x=null,ctx:S}=m,w=G(f).toVar();return bt(yW(TW(w,co(Vo.rgb))),()=>{let T=Ae(mi(g.add(y)),I(0),I(1));S.accumAlpha.addAssign(Rr(S.accumAlpha).mul(v).mul(_).mul(T)),w.assign(wR(co(Vo.rgb),w,v.mul(_),b)),w.mulAssign(rvt(x))}),w}({outgoing:t,directSpecular:e,indirectSpecular:i,shadingAlpha:this.lightLayer.alphaNode,shadingBlend:this.lightLayer.modeNode,mask:l,occlusion:this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null,ctx:this.ctx})}else r=G(t).toVar();let u=r,h=!1;for(let p=o;p<this.layers.length;p++){let m=this.layers[p];if(m.kind!=="fragment"||m.isMaskEnabled)continue;let f=this.runLayerBuilder(m,this.maskSourceFor(p));u=wR(u,f.color,f.calpha,m.modeNode),h=!0}if(h&&r.assign(u),!n){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p))}let d=this.lightLayer.params.has("alphaOverride")?this.lightLayer.params.getFloat("alphaOverride"):I(1),c=n?s:s.mul(l);if(Vo.a.assign(c.mul(d)),Vo.a.lessThanEqual(Iyt("depthPrepassCutoff","float")).discard(),this.dithering){let p=MW(Ja.xy),m=G(.25/255,-.25/255,.25/255),f=Yt(m.mul(2),m.mul(-2),p);r.assign(r.add(f))}return r}getLayersOfType(t){return this.layers.filter(e=>e.type===t)}getLayerByUuid(t){return this.layers.find(e=>e.uuid===t)}armRainbowNoiseSpecialization(t){let e=this.root.forceRainbowNoise.has(t.uuid),i=t.data;if(t.noiseForced=e,t.noiseCompiledIn=e||fv(i.noiseStrength),t.noiseCompiledIn===!1){let r=t.uuid;t.onNoiseMismatch=s=>this.root.ensureRainbowNoiseCompiled(r,s)}}ensureRainbowNoiseCompiled(t,e){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(t,e);let i=this.data.layers?.data(t);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(t)&&!fv(i.noiseStrength)||this.getLayerByUuid(t)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(t),this.reset0(this.data,this.lastContext),e!==void 0&&this.getLayerByUuid(t)?.setValue("noiseStrength",e),!0)}updateByOp(t,e,i){if(this.isRoot)if(e!==void 0?this.data=e:e=this.data,this.setTransparent(Dg(e,i.shared),i.scene),t.path[0]==="layers"){let r=t.path[1];if(r===void 0)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(e,i);t.type===0&&t.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(a=>a.uuid===r);if(!s)return;let n=e.layers.data(r);if(!n)return;this.updateLayerByOp(s,{...t,path:t.path.slice(2)},n,i)?this.reset0(e,i):nS(this)}else this.reset0(e,i);else this.root.updateByOp(t,e,i)}static hasVariableString(t){return typeof t=="string"||Array.isArray(t)&&t.some(e=>typeof e=="string")}updateLayerTextureByOp(t,e,i){if(e.path.length!==1||e.type!==0)return!0;let r=e.props,s=i.texture;if(!s)return!0;let n=t.data.texture;for(let o of Object.keys(r))if(o!=="repeat"&&o!=="offset"&&o!=="rotation"||$p.hasVariableString(s[o])||$p.hasVariableString(n?.[o]))return!0;if(t.type==="matcap")return"repeat"in r||"offset"in r||(t.data=i,t.setValue("rotation",(s.rotation??0)*qt.DEG2RAD),!1);let a=t.getValue("mat");if(!a)return!0;if(t.data=i,"repeat"in r){let o=s.repeat;a.repeat=[o?.[0]??1,o?.[1]??1]}if("offset"in r){let o=s.offset;a.offset=[o?.[0]??0,o?.[1]??0]}return"rotation"in r&&(a.rotation=s.rotation??0),a.updateMatrix(),!1}updateLayerByOp(t,e,i,r){if(e.path[0]==="texture")return this.updateLayerTextureByOp(t,e,i);if(e.path[0]!==void 0||e.type!==0)return!0;let s=e.props;if("type"in s||"category"in s||"visible"in s||"noiseType"in s)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let n of Object.keys(s)){if(n==="isMask")return!0;if(t.type==="rainbow"&&n==="noiseStrength"&&t.noiseCompiledIn!==void 0){let h=i[n];if((t.noiseForced===!0||fv(h))!==t.noiseCompiledIn)return!0}let a=sT[t.type];if(a!==void 0&&a.includes(n))return!0;let o=Wgt[t.type];if(o!==void 0&&o.includes(n)){let h=t.getValue(n),d=s[n];if(Array.isArray(h)&&Array.isArray(d)&&h.length!==d.length)return!0}let l=i[n],u=t.data[n];if(n!=="axis"&&(typeof l=="string"||typeof u=="string")||Array.isArray(l)&&l.some(h=>typeof h=="string")||Array.isArray(u)&&u.some(h=>typeof h=="string"))return!0}t.data=i;for(let n of Object.keys(s))this.applyLayerValue(t,n,i,r.shared);return!1}applyLayerValue(t,e,i,r){let s=i;if((e==="alpha"||e==="visible"||e==="intensity")&&(qS(t,r),e!=="intensity"||t.type==="displace"))return;if(e==="alphaOverride"&&t instanceof v2)return void t.setValue("alphaOverride",Bv(s[e],r));if(!t.hasValue(e))return;let n=t.uniformKinds.get(e),a=s[e];switch(n){case"color":case"colorVec4":{let o=t.getValue(e),l=typeof a=="string"?r.color(a):H9(a,()=>o??new Dr(1,1,1,1));o&&l&&o.setRGBA(l.r,l.g,l.b,"a"in l?l.a:1);break}case"vec2":{let o=t.getValue(e);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y));break}case"vec3":{let o=t.getValue(e);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y),Number(a[2]??o.z));break}case"vec4array":{let o=t.getValue(e);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++){let u=a[l];o[l].set(u[0],u[1],u[2],u[3])}break}case"floatArray":{let o=t.getValue(e);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++)o[l]=Number(a[l]);break}case"axis":t.setValue(e,["x","y","z"].indexOf(String(a)));break;case"bool":t.setValue(e,!!a);break;default:(typeof a=="number"||typeof a=="boolean")&&t.setValue(e,a)}}onVariableUpdate(t,e,i){if(t[0]==="alphaOverride")return this.setTransparent(Dg(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(e)/100,1)));if(t[0]!=="layer")return;let r=t[1],s=t[2];if(!r||!s)return;let n=this.layers.find(l=>l.uuid===r);if(!n?.hasValue(s))return;if(s==="alpha")return this.setTransparent(Dg(this.data,i.shared),i.scene),void n.setValue(s,Math.max(0,Math.min(Number(e)/100,1)));let a=n.getValue(s),o=t[3];(o==="x"||o==="y"||o==="z")&&a?.isVector3||(o==="x"||o==="y")&&a?.isVector2?a[o]=Number(e):a instanceof pi||n.setValue(s,e)}saveVariableLocations(t){if(!this.allowVariableSaves)return;let e=this.data.layers?.find(i=>i.data.type==="light");e&&t.shared.getVariable(e.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{let r=i.data;"alpha"in r&&typeof r.alpha=="string"&&t.shared.getVariable(r.alpha,["material",this.uuid,"layer",i.id,"alpha"]);let s=i.data.type==="displace"?r.displacementType==="noise"?"displace_noise":"displace_map":i.data.type,n=yht[s];if(n)for(let a of n){let o=r;for(let l of a.path??[])l in o&&(o=o[l]);for(let l of a.nums)l in o&&t.shared.getVariable(o[l],["material",this.uuid,"layer",i.id,...a.path??[],l]);for(let l of a.vecs)l in o&&o[l].forEach((u,h)=>{t.shared.getVariable(u,["material",this.uuid,"layer",i.id,...a.path??[],l,h===0?"x":h===1?"y":"z"])})}})}clampUniformsForPreview(t,e){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=r.uniforms[`f${r.id}_intensity`];s.value=i(s.value,t,e)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(t=>t.assetsLoaded))return!1;for(let t of this.root.syntheticMapLayers.values())if(!t.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let t of this.layers)t.dispose();for(let t of this.syntheticMapLayers.values())t.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let t of this.flavors)t?.dispose();for(let t of this.depthTwins)t.dispose()}},LW=class extends $p{constructor(t,e,i){super(t,e,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(e)}}});function jl(t,e){let i=ci(t.xyz);return ci(e.add(Zr(i,Zr(i,e).add(e.mul(t.w))).mul(2)))}function Ly(t){let e=Mv(t),i=Mv(G(t.y.sub(19.1),t.z.add(33.4),t.x.add(47.2))),r=Mv(G(t.z.add(74.2),t.x.sub(124.5),t.y.add(99.4)));return G(e,i,r)}function vht(t,e){return $vt({p:t,seed:e})}function bht(t,e,i){return G(SR(ci(t.add(G(i)).mul(e))),SR(ci(t.add(G(i.add(20))).mul(e))),SR(ci(t.add(G(i.sub(30))).mul(e))))}function BL(t){return{f:(e,i=0)=>hl(t.node(e)??t.getUniform(e,i)),v3:e=>ci(t.node(e)??t.getUniform(e,null)),v4:e=>Oo(t.node(e)??t.getUniform(e,null)),tex:e=>t.node(e)??t.getTexture(e,null)}}function YCt(t,e){switch(t){case"position":return function(i){let r=BL(i.registry);return Et(()=>{let s=bi(),n=i.depTexture("uCurrentPosition"),a=i.depTexture("uCurrentVelocity"),o=i.depTexture("uCurrentEmissionRate"),l=Oo(n.sample(s)).toVar(),u=ci(l.xyz).toVar(),h=Oo(o.sample(s)).toVar(),d=hl(h.x).toVar(),c=hl(h.y).toVar(),p=hl(h.z).toVar(),m=ci(Oo(r.tex("uOriginalPosition").sample(s)).xyz.mul(r.v3("uEmitterSize"))).toVar(),f=Oo(a.sample(s)).toVar(),g=ci(f.xyz).toVar(),y=hl(f.w).toVar(),v=r.f("uMaxLifeTime",1),b=Ai(.5,y),_=I(3).mul(b),x=g.mul(I(1).add(_)),S=g.mul(ii(r.f("uFPSRatio",1),I(5)));u.addAssign(Yt(S,x,b));let w=jl(r.v4("uWorldQuaternion"),m).add(r.v3("uWorldOffset"));u.assign(Yt(u,w,d)),p.assign(Yt(p,r.f("uTime"),d));let T=Qt(v.sub(r.f("uTime").sub(p)),I(0)).div(v);return Yt(lt(0),lt(u,T),c)})()}(e);case"velocity":return function(i){let r=BL(i.registry),s=i.features;return Et(()=>{let n=bi(),a=i.depTexture("uCurrentPosition"),o=i.depTexture("uCurrentVelocity"),l=i.depTexture("uCurrentEmissionRate"),u=ci(Oo(a.sample(n)).xyz).toVar(),h=ci(Oo(r.tex("uOriginalPosition").sample(n)).xyz).toVar(),d=ci(Oo(r.tex("uDirections").sample(n)).xyz).toVar(),c=ci(Oo(o.sample(n)).xyz).toVar(),p=Oo(l.sample(n)).toVar(),m=hl(p.x).toVar(),f=hl(p.y).toVar(),g=hl(Oo(o.sample(n)).w).toVar(),y=I(1).sub(r.f("uRandomMassFactor").mul(function(w){return hl(w.dot(at(12.9898,78.233)).sin().mul(43758.5453).fract())}(function(w){return w.xy}(h)).mul(.5).add(.5))).toVar(),v=r.f("uSpeed",1),b=r.f("uNoiseStrength"),_=r.f("uNoiseScale"),x=r.f("uNoiseSeed");bt(f.equal(1),()=>{s.USE_CURL_NOISE&&(bt(_.greaterThan(0),()=>{c.assign(vht(ci(u.mul(_).mul(.002)),x).mul(b.add(1)).mul(.05).mul(v))}),bt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(vht(u,x).mul(b).mul(.05).mul(v))})),s.USE_SIMPLEX_NOISE&&(bt(_.greaterThan(0),()=>{c.assign(G(Mv(ci(u.mul(_).mul(.001))).mul(b.add(1)).mul(.1)).mul(v))}),bt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(G(Mv(ci(u.mul(b).mul(.001))).mul(.05)).mul(v))})),s.USE_FBM_NOISE&&(bt(_.greaterThan(0),()=>{c.assign(bht(ci(u.mul(_).mul(.001)),b.add(1),x).mul(v))}),bt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(bht(ci(u.mul(b).mul(.001)),b.add(1),x).mul(.1).mul(v))})),function(w,T,C,M,A){if(!w.features.USE_COLLIDER)return;let R=Qt(T.f("uBounce").mul(2),I(.01)).toVar(),O=T.f("particleSize");if(w.features.USE_SPHERE_COLLIDER){let N=T.v3("uColliderSize"),B=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))).toVar(),L=ci(B.div(N)).toVar(),z=mi(L).toVar();bt(z.lessThanEqual(I(1).add(O.div(mi(N)))).and(A.equal(0)),()=>{let k=L.mul(I(1).add(O.div(mi(N)))),V=xe(ci(k.div(N.mul(N))));V=jl(T.v4("uColliderQuaternion"),V),M.assign(FS(M,V).mul(R)),A.assign(1)}).Else(()=>{A.assign(0)})}if(w.features.USE_BOX_COLLIDER){let N=ci(T.v3("uColliderSize").div(2)),B=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))).toVar(),L=ci(Le(B).sub(N)).toVar(),z=Qt(L.x,Qt(L.y,L.z)).toVar();bt(z.lessThanEqual(O.mul(.5)).and(A.equal(0)),()=>{let k=G(0).toVar();bt(L.x.greaterThan(L.y).and(L.x.greaterThan(L.z)),()=>{k.assign(G(Ku(B.x),0,0))}).ElseIf(L.y.greaterThan(L.z),()=>{k.assign(G(0,Ku(B.y),0))}).Else(()=>{k.assign(G(0,0,Ku(B.z)))});let V=jl(T.v4("uColliderQuaternion"),ci(k));M.assign(FS(M,V).mul(R)),A.assign(1)}).Else(()=>{A.assign(0)})}}(i,r,u,c,g),function(w,T,C,M){if(!w.features.USE_ATTRACTOR)return;let A=T.f("uForceIntensity"),R=T.f("uForceDamping");if(w.features.USE_FORCE_LOCAL_SPACE){let O,N,B=T.f("particleSize");if(w.features.USE_SPHERE_COLLIDER){let L=T.v3("uColliderSize"),z=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos"))));O=mi(ci(z.div(L))).toVar(),N=I(1)}else{let L=ci(T.v3("uColliderSize").div(2)),z=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))),k=ci(Le(z).sub(L));O=Qt(k.x,Qt(k.y,k.z)).toVar(),N=B}bt(O.lessThanEqual(N),()=>{let L=w.features.USE_SPHERE_COLLIDER?I(1).sub(O).mul(A):Qt(I(1).sub(N.div(O)),I(0)).mul(A),z=ci(C.sub(T.v3("uColliderPos"))),k=xe(z).mul(L);M.subAssign(k),M.mulAssign(R)})}else{let O=ci(C.sub(T.v3("uColliderPos"))),N=xe(O).mul(A);M.subAssign(N),M.mulAssign(R)}}(i,r,u,c),function(w,T,C,M,A,R,O){if(!w.features.USE_VORTEX)return;let N=T.f("particleSize"),B=ci(T.v3("uColliderSize").div(2)),L=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))).toVar(),z=ci(Le(L).sub(B)).toVar(),k=Qt(z.x,Qt(z.y,z.z)).toVar();bt(k.lessThanEqual(N),()=>{let V=T.f("uForceIntensity"),H=T.v3("uColliderPos").add(jl(T.v4("uColliderQuaternion"),G(0))),W=ci(H.sub(C)).toVar(),X=G(0,1,.01),st=xe(Zr(X,jl(T.v4("uColliderQuaternion"),W))).toVar(),nt=mi(W.mul(V).mul(3)).toVar();M.assign(st.mul(nt).mul(.005));let xt=jl(T.v4("uWorldQuaternion"),A);M.addAssign(xt.mul(O).mul(I(1).sub(T.f("uForceDamping"))).div(R.mul(.5)))})}(i,r,u,c,d,y,v)});let S=s.USE_NORMALS?d:r.v3("uDirectionsAxis");return c.assign(Yt(c,jl(r.v4("uWorldQuaternion"),S).mul(v),m)),c.addAssign(r.v3("uGravity").div(y.mul(.5)).mul(I(1).sub(g))),lt(c,g)})()}(e);case"emissionRate":return function(i){let r=BL(i.registry);return Et(()=>{let s=bi(),n=i.depTexture("uCurrentEmissionRate"),a=hl(Oo(r.tex("uIndex").sample(s)).x).toVar(),o=Oo(n.sample(s)).toVar(),l=hl(o.y).toVar(),u=hl(o.z).toVar(),h=r.f("uLastIndexEmitted"),d=r.f("uParticlesToEmit"),c=Ai(h,a),p=Ai(a,h.add(d).sub(1)),m=c.mul(p);return u.assign(Yt(u,r.f("uTime"),m)),lt(m,Yt(l,I(1),m),u,1)})()}(e)}}var hl,ci,Oo,$vt,_ht,xht,VL,Xvt,KCt=j(()=>{He(),uT(),hl=t=>t,ci=t=>t,Oo=t=>t,$vt=Et(t=>{let e=ci(t.p.add(t.seed)).toVar(),i=G(.1,0,0),r=G(0,.1,0),s=G(0,0,.1),n=Ly(ci(e.sub(i))).toVar(),a=Ly(ci(e.add(i))).toVar(),o=Ly(ci(e.sub(r))).toVar(),l=Ly(ci(e.add(r))).toVar(),u=Ly(ci(e.sub(s))).toVar(),h=Ly(ci(e.add(s))).toVar(),d=l.z.sub(o.z).sub(h.y).add(u.y),c=h.x.sub(u.x).sub(a.z).add(n.z),p=a.y.sub(n.y).sub(l.x).add(o.x);return xe(G(d,c,p).mul(5))})}),ZCt=j(()=>{dt(),mr(),He(),KCt(),_ht=class{constructor(){this.nodes=new Map,this.textureNodes=new Map}getUniform(t,e){let i=this.nodes.get(t);return i||(i=gt(e),this.nodes.set(t,i)),i}getTexture(t,e){let i=this.textureNodes.get(t);return i||(i=ee(e??new pi),this.textureNodes.set(t,i)),i}node(t){return this.nodes.get(t)??this.textureNodes.get(t)}adopt(t){for(let e of Object.keys(t)){let i=t[e].value;if(i instanceof pi||i&&typeof i=="object"&&i.isTexture){let r=this.getTexture(e,i);r.value=i,Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(s){r.value=s}}})}else{let r=this.getUniform(e,i);r.value=i,Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(s){r.value=s}}})}}}},xht=class{constructor(t,e,i,r){this.name=t,this.kind=e,this.initialTexture=i,this.currentIndex=0,this.registry=new _ht,this.depTextureNodes=new Map,this.dependencies=[],this.nodeMaterial=null,this._uniformsStore={};let s=()=>new ri(r,r,{type:Qe,minFilter:De,magFilter:De,wrapS:Cn,wrapT:Cn,depthBuffer:!1});this.renderTargets=[s(),s()],this.material=Object.defineProperty({},"uniforms",{get:()=>this._uniformsStore,set:n=>{this.registry.adopt(n),this._uniformsStore=n}})}get currentRenderTarget(){return this.renderTargets[this.currentIndex]}get nextRenderTarget(){return this.renderTargets[1-this.currentIndex]}advance(){this.currentIndex=1-this.currentIndex}dispose(){this.renderTargets[0].dispose(),this.renderTargets[1].dispose(),this.nodeMaterial?.dispose()}},VL=new Pr,Xvt=class{constructor(t,e,i,r){this.sizeX=t,this.sizeY=e,this.renderer=i,this.features=r,this.variables=[],this._copyMaterial=null,this._copyTextureNode=ee(new pi)}addVariable(t,e,i){let r=new xht(t,t==="uCurrentPosition"?"position":t==="uCurrentVelocity"?"velocity":"emissionRate",i,this.sizeX);return this.variables.push(r),r}setVariableDependencies(t,e){t.dependencies=e;for(let i of e)t.depTextureNodes.has(i.name)||t.depTextureNodes.set(i.name,ee(i.currentRenderTarget.texture))}init(){if(!this._copyMaterial){let t=new Re;t.name="WebGPUComputation.copy",t.fragmentNode=lt(this._copyTextureNode),t.depthTest=!1,t.depthWrite=!1,t.blending=cr,this._copyMaterial=t}for(let t of this.variables){this._copyTextureNode.value=t.initialTexture;for(let i of t.renderTargets)this._renderQuad(this._copyMaterial,i);let e=new Re;e.name=`WebGPUComputation.${t.kind}`,e.fragmentNode=YCt(t.kind,{features:this.features,registry:t.registry,depTexture:i=>{let r=t.depTextureNodes.get(i);if(!r)throw new Error(`WebGPUComputationRenderer: variable "${t.name}" reads undeclared dependency "${i}"`);return r},resolution:new Q(this.sizeX,this.sizeY)}),e.depthTest=!1,e.depthWrite=!1,e.blending=cr,e.needsUpdate=!0,t.nodeMaterial=e}}compute(){for(let t of this.variables)if(t.nodeMaterial){for(let e of t.dependencies)t.depTextureNodes.get(e.name).value=e.currentRenderTarget.texture;this._renderQuad(t.nodeMaterial,t.nextRenderTarget)}for(let t of this.variables)t.advance()}getCurrentRenderTarget(t){return t.currentRenderTarget}_renderQuad(t,e){let i=this.renderer,r=i.getRenderTarget(),s=i.getMRT();i.setMRT(null),i.setRenderTarget(e),VL.material=t,VL.render(i),i.setRenderTarget(r),i.setMRT(s)}dispose(){for(let t of this.variables)t.dispose();this._copyMaterial?.dispose()}}});function wht(t,e){switch(t){case"linearFadeOut":return ul(I(1).sub(e));case"linearInOut":return ul(e.lessThan(.5).select(e,I(1).sub(e)));case"exponentialInOut":return ul(e.lessThan(.4).select(e.div(.4),e.greaterThan(.6).select(I(1).sub(e.sub(.6).div(.4)),I(1))));case"constant":return I(1);default:return e}}function Sht(t){return ul(t.dot(at(12.9898,78.233)).sin().mul(43758.5453).fract())}var ul,Yvt,QCt=j(()=>{dt(),mr(),He(),ul=t=>t,Yvt=class extends Re{constructor(t,e){super(),this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this._uniformsStore={},this._uPosition=ee(new pi),this._uTexture=ee(new pi),this._uColor=gt(new Me(1,1,1,1)),this._uColor2=gt(new Me(1,1,1,1)),this._uSize=gt(1),this._uSizeEnd=gt(1),this._uWorldOffset=gt(new P),this._uWorldQuaternion=gt(new Me(0,0,0,1)),this._uRotation=gt(0),this._uRotationEnd=gt(0),this._center=gt(new Q(.5,.5)),this._uRandScaleFactor=gt(0),this._uRandRotationFactor=gt(0),this.context=e,this.name="WebGPUParticleMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.lights=!1;let i=n=>({get value(){return n.value},set value(a){n.value=a}}),r=n=>({get value(){return n.value},set value(a){((o,l)=>{if(Array.isArray(o))l.set(Number(o[0]??1),Number(o[1]??1),Number(o[2]??1),Number(o[3]??1));else if(o&&typeof o=="object"&&"r"in o){let u=o;l.set(u.r,u.g,u.b,u.a??1)}})(a,n.value)}}),s=n=>({get value(){return n.value},set value(a){a&&a.isTexture&&(n.value=a)}});this._binders={uPosition:s(this._uPosition),uTexture:s(this._uTexture),uColor:r(this._uColor),uColor2:r(this._uColor2),uSize:i(this._uSize),uSizeEnd:i(this._uSizeEnd),uWorldOffset:i(this._uWorldOffset),uWorldQuaternion:i(this._uWorldQuaternion),uRotation:i(this._uRotation),uRotationEnd:i(this._uRotationEnd),center:i(this._center),uRandScaleFactor:i(this._uRandScaleFactor),uRandRotationFactor:i(this._uRandRotationFactor)},this._uniformsStore={...this._binders},this.updateState(t),this._rebuildGraph()}get uniforms(){return this._uniformsStore}set uniforms(t){for(let e of Object.keys(t)){let i=this._binders[e];if(!i)continue;let r=t[e]?.value;Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:i}),r!==void 0&&(i.value=r)}this._uniformsStore=t}updateState(t){let e=!1;if(t.coloring!==void 0){let i=t.coloring==="random";e||(e=i!==this.isColoringRandom),this.isColoringRandom=i}if(t.color!==void 0&&(this.uniforms.uColor.value=Array.isArray(t.color)?t.color:this.context.shared.color(t.color)),t.color2!==void 0&&(this.uniforms.uColor2.value=Array.isArray(t.color2)?t.color2:this.context.shared.color(t.color2)),t.size!==void 0){this.uniforms.uSize.value=t.size[0],this.uniforms.uSizeEnd.value=t.size[1];let i=t.size[0]!==t.size[1];e||(e=i!==this.useSizeEnd),this.useSizeEnd=i}t.ease!==void 0&&t.ease!==this.easeOpacity&&(this.easeOpacity=t.ease,e=!0),t.easeSize!==void 0&&t.easeSize!==this.easeSize&&(this.easeSize=t.easeSize,e=!0),e&&this._rebuildGraph(),this.needsUpdate=!0}_rebuildGraph(){let t=vm("particleRef","vec2"),e=this._uPosition,i=Et(()=>{let s=e.sample(t).toVar(),n=ul(s.w).toVar(),a=s.xyz.sub(this._uWorldOffset);a=function(C,M){let A=C.xyz;return M.add(A.cross(A.cross(M).add(M.mul(C.w))).mul(2))}(this._uWorldQuaternion,a);let o=vm("position","vec3"),l=I(1).sub(n),u=this.useSizeEnd?o.mul(G(Yt(this._uSize,this._uSizeEnd,l))):o.mul(G(ul(this._uSize).mul(wht(this.easeSize,l)))),h=lD,d=h.element(0).xyz.length(),c=h.element(1).xyz.length(),p=Sht(t).toVar(),m=I(1).sub(ul(this._uRandScaleFactor).mul(p)),f=at(d,c).mul(m).toVar(),g=2*Math.PI,y=p.mul(ul(this._uRandRotationFactor)).mul(g),v=I(1).sub(ul(this._uRotation)).mul(g),b=I(1).sub(ul(this._uRotationEnd)).mul(g),_=Yt(v.add(y),b.add(y),n).toVar(),x=this._center,S=u.xy.sub(x.sub(at(.5))).mul(f).toVar(),w=at(Ka(_).mul(S.x).sub(Bn(_).mul(S.y)),Bn(_).mul(S.x).add(Ka(_).mul(S.y))).toVar(),T=zyt.mul(lt(a,1)).toVar();return T.xy.addAssign(w),rb.mul(T)}),r=Et(()=>{let s=e.sample(t),n=ul(s.w).toVar();n.lessThanEqual(.005).discard();let a=I(1).sub(n),o=this.isColoringRandom?Sht(t):a,l=Yt(this._uColor,this._uColor2,o).toVar(),u=wht(this.easeOpacity,a).toVar(),h=this._uTexture.sample(bi()).toVar();return lt(h.rgb.mul(l.rgb),ul(l.a).mul(h.a).mul(u))});this.vertexNode=i(),this.colorNode=r(),this.needsUpdate=!0}nodeMaterialDispose(){this.dispose()}}}),JCt=j(()=>{Zgt(),ZCt(),QCt(),KG={createComputation:(t,e,i,r)=>new Xvt(t,e,i,r),createMaterial:(t,e)=>new Yvt(t,e)}});function Kvt(t,e){return(i,r,s,n)=>{let a=s.mod(e).add(i.add(.5).div(t)).div(e),o=ce(s.div(e)).add(r.add(.5).div(t)).div(e);return J1(n.sample(at(a,o)))}}function Tht(t){let e=Li(hr(t.x).mul(65535).add(.5)),i=e.bitAnd(Li(255)).toFloat().mul(.00392156862),r=e.shiftRight(Li(8)).bitAnd(Li(255)).toFloat().mul(.00392156862);return lt(r,i,t.y,t.z)}function Zvt(t){let{levelShiftX:e,scale:i,originOffset:r}=function(f){switch(f){case 5:return{levelShiftX:[4,6,12,24,48,96,192],scale:8*b2,originOffset:16};case 7:return{levelShiftX:[4,6,12,24,48,96,192,384,768,1536],scale:2*b2,originOffset:64};case 8:return{levelShiftX:[4,8,16,32,64,128,256,512,1024,2048,4096],scale:b2,originOffset:128};default:return{levelShiftX:[4,8,16,32,64,128,256,512],scale:4*b2,originOffset:32}}}(t.resolutionLevel),s=t.pyramidLevelSizes.length,n=s%2==0?s-3:s-2,a=s%2==0,o=Math.pow(2,t.resolutionLevel),l=t.pyramidLevelSizes[s-1]/o,u=Kvt(o,l),h=t.pyramid1Size.width,d=t.pyramid1Size.height,c=t.pyramid2Size.width,p=t.pyramid2Size.height,m=US(FW.map(([f,g,y])=>new P(f,g,y)));return f=>{let g=G(0).toVar(),y=G(0,0,1).toVar(),v=lt(0).toVar(),b=f.toVar(),_=ce(b.div(3)).toVar(),x=(A,R)=>at(hr(A.x).add(R).add(.5).div(h),hr(A.y).add(.5).div(d)),S=(A,R)=>at(hr(A.x).add(R).add(.5).div(c),hr(A.y).add(.5).div(p)),w=h-2,T=c-1,C=at(0,0).toVar(),M=J1(t.pyramid2.sample(S(TR(C),T))).toVar();return bt(_.lessThan(hr(M.x)),()=>{let A=I(0).toVar(),R=K=>{let ct=J1(M.add(lt(A))).toVar(),St=lt(ec(ct.yzw),A),wt=J1(lt(lt(_).greaterThanEqual(St)).mul(lt(lt(_).lessThan(ct)))).toVar();C.mulAssign(2),C.addAssign(at(0,1).mul(hr(wt.x)).add(at(1,1).mul(hr(wt.y))).add(at(1,0).mul(hr(wt.z)))),A.assign(wt.dot(St)),K?.()};for(let K=0;K<n;){let ct=e[K];R(()=>{T-=ct,M.assign(t.pyramid1.sample(x(TR(C),w)))}),K++;let St=e[K];R(()=>{w-=St,M.assign(t.pyramid2.sample(S(TR(C),T)))}),K++}a&&R(null);let O=hr(C.x).mod(o).toVar(),N=hr(C.y).mod(o).toVar(),B=ce(hr(C.x).div(o)).add(ce(hr(C.y).div(o)).mul(l)).toVar(),L=b.sub(A.mul(3)).mul(.0625).add(.03125),z=u(O,N,B,t.voxel).toVar(),k=hr(z.w).add(.5).mul(.00390625),V=hr(J1(t.triTable.sample(at(L,k))).x).mul(2).toInt().toVar(),H=G(O,N,B).add(ec(m.element(V))).toVar(),W=G(O,N,B).add(ec(m.element(V.add(1)))).toVar(),X=u(hr(H.x),hr(H.y),hr(H.z),t.potential).toVar(),st=u(hr(W.x),hr(W.y),hr(W.z),t.potential).toVar(),nt=hr(X.x).div(hr(X.x).sub(hr(st.x)));v.assign(Yt(Tht(ec(X.yzw)),Tht(ec(st.yzw)),nt)),g.assign(H.add(W.sub(H).mul(nt)).sub(G(r)).mul(i));let xt=u(hr(H.x),hr(H.y),hr(H.z),t.voxel),pt=u(hr(W.x),hr(W.y),hr(W.z),t.voxel);y.assign(xe(Yt(ec(xt.xyz),ec(pt.xyz),nt)))}),{position:g,normal:y,color:v}}}function Mht(t,e){t.needsPreviousData?.()===!0&&uD.assign(e)}function tEt(t){if(t.cached)return function(s){let n=()=>s.drawIndex?s.drawIndex.element(sS):sS;return{position:Et(a=>{let o=ec(s.positions.element(n()).xyz).toVar();return Mht(a,o),o})(),normal:e9(s.normals.element(n()).xyz),color:e9(s.colors.element(n()))}}(t.cached);let e=Zvt(t),i=Lr("vec3","vShapeBlendNormal"),r=Lr("vec4","vShapeBlendColor");return{position:Et(s=>{let{position:n,normal:a,color:o}=e(sS.toFloat());return i.assign(a),r.assign(o),Mht(s,n),n})(),normal:i,color:r}}var hr,TR,ec,J1,b2,FW,UW=j(()=>{dt(),He(),hr=t=>t,TR=t=>t,ec=t=>t,J1=t=>t,b2=2,FW=[[0,0,0],[1,0,0],[1,0,0],[1,1,0],[0,1,0],[1,1,0],[0,0,0],[0,1,0],[0,0,1],[1,0,1],[1,0,1],[1,1,1],[0,1,1],[1,1,1],[0,0,1],[0,1,1],[0,0,0],[0,0,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1],[0,1,0],[0,1,1]]});function Qvt(t,e){let i=ue(t.xyz);return ue(e.add(i.cross(i.cross(e).add(e.mul(ot(t.w)))).mul(2)))}function Jvt(t,e,i,r){let s=Ae(t,-1,1),n=t.sub(s).mul(2).add(1),a=Ae(I(.5).add(s.mul(.5).mul(e.sub(s.mul(n).mul(i))).div(r)),0,1);return ot(Yt(e,s.mul(n).mul(i),a).sub(s.mul(r).mul(a).mul(I(1).sub(a))))}function tbt(t,e,i,r,s){let n=I(0).toVar(),a=ot(i.y),o=ot(i.z),l=ot(i.w),u=bt(t.lessThan(.5),()=>{n.assign(mi(e).sub(a))}).ElseIf(t.lessThan(1.5),()=>{let d=G(a,o,l),c=mi(e.div(d)),p=mi(e.div(d.mul(d)));n.assign(c.mul(c.sub(1)).div(p))}).ElseIf(t.lessThan(2.5),()=>{let d=G(a,o,l),c=Le(e).sub(d).toVar();n.assign(mi(Qt(c,G(0))).add(ii(Qt(ot(c.x),Qt(ot(c.y),ot(c.z))),0)))}).ElseIf(t.lessThan(3.5),()=>{let d=Le(at(mi(MR(e.xz)),ot(e.y))).sub(at(o,a)).toVar();n.assign(ii(Qt(ot(d.x),ot(d.y)),0).add(mi(Qt(d,at(0)))))}).ElseIf(t.lessThan(4.5),()=>{let d=a,c=o,p=l,m=at(mi(MR(e.xz)),ot(e.y)).toVar(),f=at(p,d),g=at(p.sub(c),d.mul(2)),y=at(ot(m.x).sub(ii(ot(m.x),ot(m.y).lessThan(0).select(c,p))),Le(ot(m.y)).sub(d)).toVar(),v=m.sub(f).add(g.mul(Ae(kt(f.sub(m),g).div(kt(g,g)),0,1))).toVar(),b=ot(v.x).lessThan(0).and(ot(y.y).lessThan(0)).select(I(-1),I(1));n.assign(b.mul(xl(ii(kt(y,y),kt(v,v)))))}).ElseIf(t.lessThan(5.5),()=>{let d=at(mi(MR(e.xy)).sub(a),ot(e.z));n.assign(mi(d).sub(o))}),h=()=>{let d=Le(ot(e.x)).toVar(),c=at(a,o),p=l,m=ot(r.w),f=ot(c.y).mul(d).greaterThan(ot(c.x).mul(ot(e.y))).select(kt(at(d,ot(e.y)),c),mi(at(d,ot(e.y)))),g=G(d,ot(e.y),ot(e.z));n.assign(xl(kt(g,g).add(p.mul(p)).sub(p.mul(f).mul(2))).sub(m))};return s?u.ElseIf(t.lessThan(6.5),h).Else(()=>{n.assign(s(e,i,r))}):u.Else(h),n}function X9(t,e=!0){let i=t.spatialDivisions,r=t.spatialn;return(s,n)=>{let a=e?lt(0).toVar():lt(0),o=I(1e3).toVar(),l=e?I(0).toVar():I(0),u=e?I(0).toVar():I(0),h=ot(n.y).add(ot(n.z).mul(i)).add(.5).div(i*i),d=(m,f)=>{let g=f.toVar();Ji(L1,({i:y})=>{bt(g.lessThan(1),()=>{sa()}),g.mulAssign(.5),bt(Oi(g).greaterThanEqual(.5),()=>{let v=I(y).add(m).add(.5).mul(1/n5),b=t.shapeRow(v,0).toVar(),_=t.shapeRow(v,1).toVar(),x=t.shapeRow(v,2).toVar(),S=t.shapeRow(v,3).toVar(),w=Qvt(Ca(_),ue(s.sub(ue(b.xyz)))).div(ot(S.z)).toVar(),T=tbt(ot(x.x),ue(w),Ca(x),Ca(S),t.meshSdf).sub(ot(S.y)).mul(ot(S.z)).toVar(),C=ot(S.x).toVar(),M=ot(b.w);if(o.assign(Jvt(M,o,T,C)),e){let A=Ai(-1.5,M).mul(Ai(M,-.5)),R=tr(u,0,T.negate()),O=Yt(I(1),R,A);a.mulAssign(O),l.mulAssign(O),u.assign(Qt(u,C)),C.addAssign(t.colorKBump);let N=t.shapeRow(v,4).toVar(),B=tr(C,0,T).mul(ot(N.a).greaterThanEqual(0).toFloat()).toVar();l.addAssign(B),a.addAssign(N.mul(B))}})})},c=m=>{let f=m.mul(4*L1).toVar(),g=Ca(t.spatialTex.sample(at(ot(n.x).mul(r).add(m).add(.5).div(r*i),h))).toVar();d(ot(f),ot(g.x)),d(ot(f.add(L1)),ot(g.y)),d(ot(f.add(2*L1)),ot(g.z)),d(ot(f.add(3*L1)),ot(g.w))};r===1?c(I(0)):Ji(r,({i:m})=>{c(I(m).toVar())}),e&&a.divAssign(l);let p=Yt(o,I(0),Ai(1e20,o)).toVar();return{sdf:ot(p),color:Ca(a),colorDivisor:ot(l)}}}function Aht(t){let e=t.resolution,i=e-1,r=t.colorResolution,s=t.capacity,n=e/4,a=n-1,o=gt(t.bboxHalf),l=gt(t.bboxOffset),u=gt(1e30),h=gt(new P(0,0,0)),d=gt(new P(n,n,n)),c=t.env.spatialDivisions,p=I(t.buildSeq).mul(0),m=t.sparseStorage??null,f=m?m.poolBricks:0,g=m?Math.ceil(f/4096):0,y=m?.meshlet??null,v=y?y.drawIndex:null,b=y?Math.floor(s/24):0,_=y?y.vertexBlocks:0,x=(F,et,vt,ht)=>{let It=new Hg(F,et,vt);return It.format=Qa,It.type=Qe,It.minFilter=De,It.magFilter=De,It.name=ht,It},S=m?x(256,256,4*Math.max(g,1),"SplineShapeBlend.ultraSdfPool"):t.reuseTextures?.sdfTexture??x(e,e,e,"SplineShapeBlend.ultraSdf");S.format=Qa,S.type=Qe,S.minFilter=De,S.magFilter=De;let w=t.reuseTextures?.colorTexture??new Hg(r,r,r);w.name="SplineShapeBlend.ultraColor";let T=t.reuseTextures?.coarseTexture??new Hg(n,n,n);T.format=Qa,T.type=Qe,T.minFilter=De,T.magFilter=De,T.name="SplineShapeBlend.ultraCoarse";let C=Qr(8,"uint").toAtomic(),M=(F=0)=>C.element(F),A=m?Qr(y?12:4,"int").toAtomic():null,R=F=>A.element(F),O=m?Qr(Math.max(f,1),"float"):null,N=n*n*n,B=m?Qr(N*(y?4:1),"float"):null,L=F=>mt(ot(F.x).add(ot(F.y).mul(n)).add(ot(F.z).mul(n*n))),z=F=>B.element(L(F)),k=F=>B.element(L(F).add(mt(N))),V=F=>B.element(L(F).add(mt(2*N))),H=F=>B.element(L(F).add(mt(3*N))),W=F=>B.element(F.add(mt(3*N))),X=m?Qr(Math.max(f,1),"float"):null,st=y?Qr(3*Math.max(b,1),"float"):null,nt=F=>st.element(F),xt=F=>nt(mt(F)),pt=F=>nt(mt(F.add(b))),K=F=>nt(F.add(mt(2*b))),ct=y?Qr(Math.max(_,1),"float"):null,St=F=>ct.element(F),wt=y?Qr(24*Math.max(b,1),"uint"):null,Tt=F=>wt.element(F),yt=y?gt(0):null,Ot=y?gt(new _t):null,Ft=y?gt(2):null,Bt=US(Array.from(t.numTrisTable)),zt=US(FW.map(([F,et,vt])=>new P(F,et,vt))),Vt=X9(t.env,!1),Wt=X9(t.env),$t=(F,et)=>ue(F.div(et).mul(2).sub(1)),Pt=(F,et)=>ue(F.div(et).mul(c-1).floor()),oe=Et(()=>{for(let F=0;F<8;F++)No(M(F),Li(0))})(),jt=Et(()=>{bt(mt(Pn).greaterThanEqual(mt(s)),()=>{yr()}),t.buffers.positions.element(mt(Pn)).assign(lt(0))})(),Zt=y?Et(()=>{bt(mt(Pn).greaterThanEqual(mt(s)),()=>{yr()}),v.element(mt(Pn)).assign(Li(p))})():null,Jt=wc(T),$=F=>ot(Ca(Jt.load(Qn(Ae(F,G(0),G(a))))).x),se=F=>ot(z(ue(Ae(F,G(0),G(a))))),Pe=(F,et)=>{let vt=Qt(F,0),ht=ce(vt.div(4096)),It=vt.sub(ht.mul(4096)),de=ce(It.div(64)),be=It.sub(de.mul(64));return ue(G(be,de,ht).mul(4).add(et))},Ve=Et(()=>{let F=G(uo).add(h).toVar();bt(ot(F.x).greaterThan(a).or(ot(F.y).greaterThan(a)).or(ot(F.z).greaterThan(a)),()=>{yr()});let et=ue(F.mul(4).add(G(1.5))),vt=(ht=>{let It=I(1e3).toVar();return Ji(n5,({i:de})=>{bt(I(de).greaterThanEqual(ot(t.npart)),()=>{sa()});let be=I(de).add(.5).mul(1/n5),Ht=t.env.shapeRow(be,0).toVar(),Ct=t.env.shapeRow(be,1).toVar(),re=t.env.shapeRow(be,2).toVar(),$e=t.env.shapeRow(be,3).toVar(),ts=Qvt(Ca(Ct),ue(ht.sub(ue(Ht.xyz)))).div(ot($e.z)).toVar(),Vr=tbt(ot(re.x),ue(ts),Ca(re),Ca($e),t.env.meshSdf).sub(ot($e.y)).mul(ot($e.z)).toVar();It.assign(Jvt(ot(Ht.w),It,Vr,ot($e.x)))}),ot(It)})($t(et,i));qp(T,Qn(F),lt(ot(vt.add(p)),0,0,0)).toStack()})(),ie=F=>{bt(ot(F.x).greaterThan(a).or(ot(F.y).greaterThan(a)).or(ot(F.z).greaterThan(a)),()=>{yr()})},oi=m?Et(()=>{let F=G(uo).toVar();ie(ue(F)),z(ue(F)).assign(ot(I(-1).add(p))),y&&(k(ue(F)).assign(ot(I(-1).add(p))),V(ue(F)).assign(ot(I(-1).add(p))))})():null,xi=m?Et(()=>{let F=G(uo).add(h).toVar();ie(ue(F));let et=$(ue(F)).toVar(),vt=se(ue(F)).toVar();bt(Le(et).greaterThan(u).and(vt.greaterThan(-.5)),()=>{let ht=ll(R(1),mt(1)).toVar();O.element(ht).assign(vt),z(ue(F)).assign(ot(I(-1).add(p)))})})():null,Ks=m?Et(()=>{let F=G(uo).add(h).toVar();ie(ue(F));let et=$(ue(F)).toVar(),vt=se(ue(F)).toVar();bt(Le(et).lessThanEqual(u).and(vt.lessThan(-.5)),()=>{let ht=I(-1).toVar(),It=oR(R(1),mt(1)).toVar();bt(It.greaterThanEqual(1),()=>{ht.assign(ot(O.element(It.sub(1))))}).Else(()=>{ll(R(1),mt(1));let de=ll(R(0),mt(1)).toVar();bt(de.lessThan(mt(f)),()=>{ht.assign(de.toFloat())}).Else(()=>{No(R(2),mt(1))})}),bt(ht.greaterThan(-.5),()=>{X.element(mt(ht)).assign((de=>ot(ot(de.x).add(ot(de.y).mul(256)).add(ot(de.z).mul(65536))))(ue(F))),z(ue(F)).assign(ot(ht.add(p)))})})})():null,Hi=m?Et(()=>{let F=hg(R(0)).toVar(),et=hg(R(2)).toVar();if(No(M(1),Li(F)),No(M(2),Li(et)),No(R(2),mt(0)),y){let vt=hg(R(3)).toVar(),ht=hg(R(5)).toVar();No(M(4),Li(vt)),No(M(5),Li(ht)),No(R(5),mt(0));let It=hg(R(6)).toVar(),de=hg(R(8)).toVar();No(M(6),Li(It)),No(M(7),Li(de)),No(R(8),mt(0))}})():null,li=y?Et(()=>{let F=G(uo).toVar();bt(ot(F.x).greaterThanEqual(ot(d.x)).or(ot(F.y).greaterThanEqual(ot(d.y))).or(ot(F.z).greaterThanEqual(ot(d.z))),()=>{yr()});let et=ue(F.add(h)).toVar();ie(ue(et));let vt=ot(V(ue(et))).toVar();bt(vt.greaterThan(-.5),()=>{let It=ll(R(7),mt(1)).toVar();St(It).assign(vt),V(ue(et)).assign(ot(I(-1).add(p)))});let ht=ot(k(ue(et))).toVar();bt(ht.lessThan(-.5),()=>{yr()}),k(ue(et)).assign(ot(I(-1).add(p))),Ji(48,()=>{bt(ht.lessThan(-.5),()=>{sa()});let It=ll(R(4),mt(1)).toVar();K(It).assign(ht),ht.assign(ot(xt(ht)))})})():null,Ur=y?Et(()=>{let F=G(uo).add(h).toVar();ie(ue(F));let et=I(0).toVar();bt(se(ue(F)).greaterThan(-.5),()=>{let vt=ue(F.mul(4)).toVar(),ht=ih.map(([Ht,Ct,re])=>Ir(ue(G(ot(vt.x).add(4*Ht),ot(vt.y).add(4*Ct),ot(vt.z).add(4*re)))).toVar()),It=ht[0];for(let Ht=1;Ht<8;Ht++)It=It.add(ht[Ht]);let de=xe(It).toVar(),be=kt(ht[0],de);for(let Ht=1;Ht<8;Ht++)be=ii(be,kt(ht[Ht],de));bt(ot(be).greaterThan(ot(Ft)),()=>{et.assign(I(1))})}),H(ue(F)).assign(ot(et.add(p)))})():null,Jr=Math.min(4096,Math.max(f,1)),jr=()=>{let F=G(uo).toVar(),et=ce(ot(F.x).mul(.25)).toVar(),vt=ce(ot(F.y).mul(.25)).toVar(),ht=vt.mul(Jr).add(et).toVar(),It=G(ot(F.x).sub(et.mul(4)),ot(F.y).sub(vt.mul(4)),ot(F.z)).toVar();return{slot:ot(ht),local:ue(It)}},Ui=F=>(et=>{let vt=ce(et.div(65536)),ht=et.sub(vt.mul(65536)),It=ce(ht.div(256)),de=ht.sub(It.mul(256));return ue(G(de,It,vt))})(ot(X.element(mt(F)))),Ci=m?Et(()=>{let F=G(uo).add(h.mul(4)).toVar(),et=ue(F.mul(.25).floor()).toVar(),vt=se(et).toVar();bt(vt.lessThan(-.5),()=>{yr()});let{sdf:ht}=Vt($t(ue(F),i),Pt(ue(F),i));qp(S,Qn(Pe(vt,ue(F.sub(et.mul(4))))),lt(ot(ht.add(p)),0,0,0)).toStack()})():null,Zs=m?Et(()=>{let{slot:F,local:et}=jr();bt(F.greaterThanEqual(f),()=>{yr()});let vt=Ui(F).toVar();bt(se(ue(vt)).notEqual(F),()=>{yr()});let ht=ue(vt.mul(4).add(et)).toVar(),{sdf:It}=Vt($t(ue(ht),i),Pt(ue(ht),i));qp(S,Qn(Pe(F,ue(et))),lt(ot(It.add(p)),0,0,0)).toStack()})():Et(()=>{let F=G(uo).add(h.mul(4)).toVar(),et=$(ue(F.mul(.25).floor())).toVar();bt(Le(et).greaterThan(u),()=>{qp(S,Qn(F),lt(ot(et.add(p)),0,0,0)).toStack(),yr()});let{sdf:vt}=Vt($t(ue(F),i),Pt(ue(F),i));qp(S,Qn(F),lt(ot(vt.add(p)),0,0,0)).toStack()})(),ps=Et(()=>{let F=G(uo).add(h.mul(2)).toVar();bt(ot(F.x).greaterThan(r-1).or(ot(F.y).greaterThan(r-1)).or(ot(F.z).greaterThan(r-1)),()=>{yr()}),bt(Le($(ue(F.mul(.5).floor()))).greaterThan(u),()=>{yr()});let{color:et,colorDivisor:vt}=Wt($t(ue(F),r-1),Pt(ue(F),r-1)),ht=Ca(vt.greaterThan(0).select(et,lt(0)));qp(w,Qn(F),Ae(Ca(ht.add(p)),lt(0),lt(1))).toStack()})(),_r=wc(S),rr=m?(F,et,vt)=>{let ht=Ae(G(F,et,vt),G(0),G(i)),It=ht.mul(.25).floor(),de=se(ue(It)),be=ot(Ca(_r.load(Qn(Pe(de,ue(ht.sub(It.mul(4))))))).x);return ot(de.lessThan(-.5).select($(ue(It)),be))}:(F,et,vt)=>ot(Ca(_r.load(Qn(Ae(G(F,et,vt),G(0),G(i))))).x),Ir=F=>{let et=ot(F.x),vt=ot(F.y),ht=ot(F.z),It=rr(et.add(1),vt,ht).sub(rr(et.sub(1),vt,ht)),de=rr(et,vt.add(1),ht).sub(rr(et,vt.sub(1),ht)),be=rr(et,vt,ht.add(1)).sub(rr(et,vt,ht.sub(1))),Ht=It.equal(0).and(de.equal(0)).and(be.equal(0));return ue(Ht.select(G(.199,.299,.399),xe(G(It,de,be))))},Jh=(F,et,vt)=>{let ht=((be,Ht,Ct)=>{let re=($e,ts,Vr,xr)=>rr(be.add($e),Ht.add(ts),Ct.add(Vr)).lessThan(0).toFloat().mul(xr);return re(0,0,0,1).add(re(1,0,0,2)).add(re(0,1,0,8)).add(re(1,1,0,4)).add(re(0,0,1,16)).add(re(1,0,1,32)).add(re(0,1,1,128)).add(re(1,1,1,64))})(F,et,vt).toVar(),It=ot(Bt.element(mt(ht))).toVar();bt(It.lessThan(.5),()=>{yr()});let de=ll(M(),Li(It)).toVar();bt(I(de).add(It).mul(3).lessThanEqual(s),()=>{let be=ot(ht).add(.5).mul(.00390625);Ji(5,({i:Ht})=>{bt(I(Ht).greaterThanEqual(It),()=>{sa()});let Ct=I(Ht).toVar();Ji(3,({i:re})=>{let $e=I(re).toVar();((ts,Vr,xr,os,zn,Wo)=>{let Ln=zn.mul(.0625).add(.03125),es=ot(Ca(t.triTable.sample(at(Ln,os))).x).mul(2).toInt().toVar(),ms=G(ts,Vr,xr).add(ue(zt.element(es))).toVar(),Tr=G(ts,Vr,xr).add(ue(zt.element(es.add(1)))).toVar(),Qs=rr(ot(ms.x),ot(ms.y),ot(ms.z)).toVar(),ua=rr(ot(Tr.x),ot(Tr.y),ot(Tr.z)).toVar(),fr=Qs.div(Qs.sub(ua)).toVar(),zs=ms.add(Tr.sub(ms).mul(fr)).toVar(),pn=ue(zs.div(i).mul(2).sub(1)).toVar(),da=pn.mul(o).add(G(l)),Gr=xe(Yt(Ir(ue(ms)),Ir(ue(Tr)),fr)),mn=pn.add(1).mul(.5),Wr=Ca(wc(w,mn,mt(0))),Js=Wo.toVar();t.buffers.positions.element(Js).assign(lt(da,1)),t.buffers.normals.element(Js).assign(lt(Gr,0)),t.buffers.colors.element(Js).assign(Wr)})(F,et,vt,be,Ct.mul(3).add($e),mt(de).add(mt(Ct)).mul(3).add(mt($e)))})})})},tu=m?Et(()=>{let{slot:F,local:et}=jr();bt(F.greaterThanEqual(f),()=>{yr()});let vt=Ui(F).toVar();bt(se(ue(vt)).notEqual(F),()=>{yr()});let ht=ot(vt.x).mul(4).add(ot(et.x)).toVar(),It=ot(vt.y).mul(4).add(ot(et.y)).toVar(),de=ot(vt.z).mul(4).add(ot(et.z)).toVar();bt(ht.greaterThanEqual(i).or(It.greaterThanEqual(i)).or(de.greaterThanEqual(i)),()=>{yr()}),Jh(ht,It,de)})():Et(()=>{let F=ot(G(uo).x).toVar(),et=ot(G(uo).y).toVar(),vt=ot(G(uo).z).toVar();bt(F.greaterThanEqual(i).or(et.greaterThanEqual(i)).or(vt.greaterThanEqual(i)),()=>{yr()}),bt(Le($(ue(G(F,et,vt).mul(.25).floor()))).greaterThan(u),()=>{yr()}),Jh(F,et,vt)})(),Em=()=>{let F=G(cR).toVar(),et=ot(F.y).mul(Jr).add(ot(F.x)).toVar(),vt=G(0).toVar(),ht=I(0).toVar();return bt(et.lessThan(f),()=>{vt.assign(Ui(et)),bt(se(ue(vt)).equal(et),()=>{ht.assign(I(1))})}),{brick:ue(vt),valid:ot(ht)}},sr=()=>{let F=G(cR).add(h).toVar(),et=I(0).toVar();return bt(ot(F.x).lessThanEqual(a).and(ot(F.y).lessThanEqual(a)).and(ot(F.z).lessThanEqual(a)),()=>{bt(se(ue(F)).greaterThan(-.5),()=>{et.assign(I(1))})}),{brick:ue(F),valid:ot(et)}},ih=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],g0=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Pm=F=>Et(()=>{let et=zp("float",64),vt=zp("float",1),ht=G(hR).toVar(),It=mt(ot(ht.x).add(ot(ht.y).mul(4)).add(ot(ht.z).mul(16))).toVar(),{brick:de,valid:be}=F(),Ht=ot(H(ue(de))).toVar(),Ct=I(1).add(Ht).toVar(),re=Ht.greaterThan(.5),$e=re.and(ot(ht.x).lessThan(2).and(ot(ht.y).lessThan(2)).and(ot(ht.z).lessThan(2))).or(re.not()),ts=ot(de.x).mul(4).add(ot(ht.x).mul(Ct)).toVar(),Vr=ot(de.y).mul(4).add(ot(ht.y).mul(Ct)).toVar(),xr=ot(de.z).mul(4).add(ot(ht.z).mul(Ct)).toVar(),os=ih.map(([Tr,Qs,ua])=>rr(ts.add(Ct.mul(Tr)),Vr.add(Ct.mul(Qs)),xr.add(Ct.mul(ua))).toVar()),zn=os[0].lessThan(0).toFloat();for(let Tr=1;Tr<8;Tr++)zn=zn.add(os[Tr].lessThan(0).toFloat());let Wo=zn.toVar(),Ln=I(0).toVar();bt(be.greaterThan(.5).and($e).and(ts.add(Ct).lessThanEqual(i)).and(Vr.add(Ct).lessThanEqual(i)).and(xr.add(Ct).lessThanEqual(i)).and(Wo.greaterThan(.5)).and(Wo.lessThan(7.5)),()=>{Ln.assign(I(1))}),et.element(It).assign(Ln.add(p)),B1(),bt(It.equal(mt(0)).and(be.greaterThan(.5)),()=>{let Tr=I(0).toVar();Ji(64,({i:ua})=>{Tr.addAssign(ot(et.element(ua)))});let Qs=I(-1).toVar();bt(Tr.greaterThan(.5),()=>{let ua=oR(R(7),mt(1)).toVar();bt(ua.greaterThanEqual(1),()=>{Qs.assign(ot(St(ua.sub(1))))}).Else(()=>{ll(R(7),mt(1));let fr=ll(R(6),mt(1)).toVar();bt(fr.lessThan(mt(_)),()=>{Qs.assign(fr.toFloat())}).Else(()=>{No(R(8),mt(1))})}),bt(Qs.greaterThan(-.5),()=>{V(ue(de)).assign(ot(Qs.add(p)))})}),vt.element(mt(0)).assign(Qs)}),B1();let es=ot(vt.element(mt(0))).toVar(),ms=Ln.greaterThan(.5).or(re.and($e).and(be.greaterThan(.5)).and(ts.add(Ct).lessThanEqual(i)).and(Vr.add(Ct).lessThanEqual(i)).and(xr.add(Ct).lessThanEqual(i)));bt(ms.and(es.greaterThan(-.5)),()=>{let Tr=G(0).toVar(),Qs=I(0).toVar();for(let[Ml,eu]of g0)bt(os[Ml].lessThan(0).toFloat().notEqual(os[eu].lessThan(0).toFloat()),()=>{let _T=os[Ml].div(os[Ml].sub(os[eu])),[hb,xT,wT]=ih[Ml],[TD,Rxt,Dxt]=ih[eu];Tr.addAssign(G(hb,xT,wT).add(G(TD-hb,Rxt-xT,Dxt-wT).mul(_T)).mul(Ct)),Qs.addAssign(1)});let ua=ue(Tr.div(Qt(Qs,1))).toVar();bt(Qs.lessThan(.5),()=>{ua.assign(G(Ct.mul(.5)))});let fr=G(ts,Vr,xr).add(ua).toVar(),zs=ue(fr.div(i).mul(2).sub(1)).toVar(),pn=zs.mul(o).add(G(l)),da=G(0).toVar(),Gr=ue(ua.div(Ct)).toVar();for(let Ml=0;Ml<8;Ml++){let[eu,_T,hb]=ih[Ml],xT=eu?ot(Gr.x):I(1).sub(ot(Gr.x)),wT=_T?ot(Gr.y):I(1).sub(ot(Gr.y)),TD=hb?ot(Gr.z):I(1).sub(ot(Gr.z));da.addAssign(Ir(ue(G(ts.add(Ct.mul(eu)),Vr.add(Ct.mul(_T)),xr.add(Ct.mul(hb))))).mul(xT.mul(wT).mul(TD)))}let mn=xe(da),Wr=zs.add(1).mul(.5),Js=Ca(wc(w,Wr,mt(0))),fn=mt(re.select(ot(ht.x).add(ot(ht.y).mul(2)).add(ot(ht.z).mul(4)),I(It))).toVar(),Ia=mt(es.mul(64)).add(fn).toVar();t.buffers.positions.element(Ia).assign(lt(pn,1)),t.buffers.normals.element(Ia).assign(lt(mn,0)),t.buffers.colors.element(Ia).assign(Js)})})(),Rm=y?Pm(Em):null,rh=y?Pm(sr):null,_i=F=>Et(()=>{let et=zp("float",64),vt=zp("float",64),ht=zp("float",48),It=G(hR).toVar(),de=mt(ot(It.x).add(ot(It.y).mul(4)).add(ot(It.z).mul(16))).toVar(),{brick:be,valid:Ht}=F(),Ct=ot(be.x).mul(4).add(ot(It.x)).toVar(),re=ot(be.y).mul(4).add(ot(It.y)).toVar(),$e=ot(be.z).mul(4).add(ot(It.z)).toVar(),ts=rr(Ct,re,$e).lessThan(0).toFloat().toVar(),Vr=(fr,zs,pn)=>ot(W(mt(ce(fr.mul(.25))).add(mt(ce(zs.mul(.25))).mul(n)).add(mt(ce(pn.mul(.25))).mul(n*n)))),xr=fr=>fr.mul(.5).fract().lessThan(.25),os=(fr,zs)=>fr.greaterThanEqual(zs).and(fr.add(zs).lessThanEqual(i)),zn=I(0).toVar(),Wo=I(0).toVar(),Ln=I(0).toVar(),es=I(1).toVar(),ms=I(1).toVar(),Tr=I(1).toVar(),Qs=(fr,zs,pn,da,Gr,mn,Wr,Js,fn)=>{let Ia=Vr(...fn[0]).add(Vr(...fn[1])).add(Vr(...fn[2])).add(Vr(...fn[3])).greaterThan(3.5).toVar(),Ml=rr(Ct.add(pn),re.add(da),$e.add(Gr)).lessThan(0).toFloat(),eu=rr(Ct.add(2*pn),re.add(2*da),$e.add(2*Gr)).lessThan(0).toFloat();bt(Ht.greaterThan(.5).and(Ia.not()).and(Js.add(1).lessThanEqual(i)).and(os(mn,I(1))).and(os(Wr,I(1))).and(ts.notEqual(Ml)),()=>{fr.assign(I(1)),zs.assign(I(1))}),bt(Ht.greaterThan(.5).and(Ia).and(xr(Ct)).and(xr(re)).and(xr($e)).and(Js.add(2).lessThanEqual(i)).and(os(mn,I(2))).and(os(Wr,I(2))).and(ts.notEqual(eu)),()=>{fr.assign(I(1)),zs.assign(I(2))})};Qs(zn,es,1,0,0,re,$e,Ct,[[Ct,re.sub(1),$e.sub(1)],[Ct,re,$e.sub(1)],[Ct,re,$e],[Ct,re.sub(1),$e]]),Qs(Wo,ms,0,1,0,$e,Ct,re,[[Ct.sub(1),re,$e.sub(1)],[Ct.sub(1),re,$e],[Ct,re,$e],[Ct,re,$e.sub(1)]]),Qs(Ln,Tr,0,0,1,Ct,re,$e,[[Ct.sub(1),re.sub(1),$e],[Ct,re.sub(1),$e],[Ct,re,$e],[Ct.sub(1),re,$e]]);let ua=zn.add(Wo).add(Ln).mul(2).toVar();et.element(de).assign(ua.add(p)),B1(),bt(de.equal(mt(0)).and(Ht.greaterThan(.5)),()=>{let fr=I(0).toVar();Ji(64,({i:Gr})=>{vt.element(Gr).assign(fr),fr.addAssign(ot(et.element(Gr)))}),ll(M(0),Li(fr));let zs=ce(fr.add(7).mul(1/8)).toVar(),pn=I(-1).toVar(),da=I(-1).toVar();Ji(48,({i:Gr})=>{bt(I(Gr).greaterThanEqual(zs),()=>{sa()});let mn=I(Gr).toVar(),Wr=I(-1).toVar(),Js=oR(R(4),mt(1)).toVar();bt(Js.greaterThanEqual(1),()=>{Wr.assign(ot(K(Js.sub(1))))}).Else(()=>{ll(R(4),mt(1));let fn=ll(R(3),mt(1)).toVar();bt(fn.lessThan(mt(b)),()=>{Wr.assign(fn.toFloat())}).Else(()=>{No(R(5),mt(1))})}),ht.element(mt(mn)).assign(Wr),bt(Wr.greaterThan(-.5),()=>{pt(Wr).assign(ii(fr.sub(mn.mul(8)),8)),xt(Wr).assign(I(-1)),bt(da.greaterThan(-.5),()=>{xt(da).assign(Wr)}).Else(()=>{pn.assign(Wr)}),da.assign(Wr)})}),k(ue(be)).assign(pn)}),B1(),bt(ua.greaterThan(.5),()=>{let fr=(Gr,mn,Wr)=>{let Js=ce(Gr.mul(.25)),fn=ce(mn.mul(.25)),Ia=ce(Wr.mul(.25)),Ml=mt(Js).add(mt(fn).mul(n)).add(mt(Ia).mul(n*n)),eu=mt(Gr.sub(Js.mul(4))).add(mt(mn.sub(fn.mul(4))).mul(4)).add(mt(Wr.sub(Ia.mul(4))).mul(16));return Li(Ml.mul(64).add(eu))},zs=ot(vt.element(de)).toVar(),pn=(Gr,mn,Wr)=>{let Js=ot(ht.element(mt(ce(zs.mul(.125))))).toVar();bt(Js.greaterThan(-.5),()=>{let fn=zs.sub(ce(zs.mul(.125)).mul(8)),Ia=mt(Js.mul(24).add(fn.mul(3))).toVar();Tt(Ia).assign(Gr),Tt(Ia.add(mt(1))).assign(mn),Tt(Ia.add(mt(2))).assign(Wr)}),zs.addAssign(1)},da=(Gr,mn)=>{bt(Gr.greaterThan(.5),()=>{let Wr=fr(...mn[0]).toVar(),Js=fr(...mn[1]).toVar(),fn=fr(...mn[2]).toVar(),Ia=fr(...mn[3]).toVar();bt(ts.greaterThan(.5),()=>{pn(Wr,Js,fn),pn(Wr,fn,Ia)}).Else(()=>{pn(Wr,Ia,fn),pn(Wr,fn,Js)})})};da(zn,[[Ct,re.sub(es),$e.sub(es)],[Ct,re,$e.sub(es)],[Ct,re,$e],[Ct,re.sub(es),$e]]),da(Wo,[[Ct.sub(ms),re,$e.sub(ms)],[Ct.sub(ms),re,$e],[Ct,re,$e],[Ct,re,$e.sub(ms)]]),da(Ln,[[Ct.sub(Tr),re.sub(Tr),$e],[Ct,re.sub(Tr),$e],[Ct,re,$e],[Ct.sub(Tr),re,$e]])})})(),Dm=y?_i(Em):null,Nm=y?_i(sr):null,y0=y?Et(()=>{let F=zp("float",48),et=zp("float",2),vt=G(hR).toVar(),ht=mt(ot(vt.x).add(ot(vt.y).mul(4)).add(ot(vt.z).mul(16))).toVar(),It=G(cR).toVar(),de=ot(It.y).mul(Jr).add(ot(It.x)).toVar();bt(ht.equal(mt(0)),()=>{let re=I(0).toVar();bt(de.lessThan(f),()=>{let ts=Ui(de).toVar();bt(se(ue(ts)).equal(de),()=>{let Vr=I(0).toVar();bt(ot(yt).greaterThan(.5),()=>{let xr=G(0).toVar(),os=G(0).toVar();for(let zn=0;zn<8;zn++){let Wo=ue(ts.mul(4).add(G(4*(1&zn),4*(zn>>1&1),4*(zn>>2&1)))),Ln=ue(Wo.div(i).mul(2).sub(1)).mul(o).add(G(l)),es=Ot.mul(lt(Ln,1)).toVar(),ms=ot(es.w);xr.addAssign(G(ot(es.x).lessThan(ms.negate()).toFloat(),ot(es.y).lessThan(ms.negate()).toFloat(),ot(es.z).lessThan(0).toFloat())),os.addAssign(G(ot(es.x).greaterThan(ms).toFloat(),ot(es.y).greaterThan(ms).toFloat(),ot(es.z).greaterThan(ms).toFloat()))}bt(Qt(Qt(ot(xr.x),Qt(ot(xr.y),ot(xr.z))),Qt(ot(os.x),Qt(ot(os.y),ot(os.z)))).greaterThan(7.5),()=>{Vr.assign(I(1))})}),bt(Vr.lessThan(.5),()=>{let xr=ot(k(ue(ts))).toVar();Ji(48,({i:os})=>{bt(xr.lessThan(-.5),()=>{sa()}),F.element(os).assign(xr),re.addAssign(ot(pt(xr))),xr.assign(ot(xt(xr)))})})})});let $e=I(0).toVar();bt(re.greaterThan(.5),()=>{let ts=ll(M(3),Li(re.mul(3))).toVar();$e.assign(I(ts))}),et.element(mt(0)).assign($e.add(p)),et.element(mt(1)).assign(re)}),B1();let be=ot(et.element(mt(1))).toVar(),Ht=ot(et.element(mt(0))).toVar(),Ct=I(ht).toVar();Ji(6,()=>{bt(Ct.greaterThanEqual(be),()=>{sa()});let re=ot(F.element(mt(ce(Ct.mul(1/8))))).toVar(),$e=Ct.sub(ce(Ct.mul(1/8)).mul(8)),ts=mt(re.mul(24).add($e.mul(3))).toVar(),Vr=mt(Ht.add(Ct.mul(3))).toVar(),xr=Ln=>{let es=Tt(Ln===0?ts:ts.add(mt(Ln))).toVar(),ms=mt(es.shiftRight(Li(6))).toVar(),Tr=mt(es.bitAnd(Li(63))).toVar(),Qs=ot((Gr=>B.element(Gr.add(mt(2*N))))(ms)).toVar(),ua=ot(W(ms)),fr=Tr.bitAnd(mt(3)),zs=Tr.shiftRight(mt(2)).bitAnd(mt(3)),pn=Tr.shiftRight(mt(4)).bitAnd(mt(3)),da=fr.shiftRight(mt(1)).add(zs.shiftRight(mt(1)).mul(mt(2))).add(pn.shiftRight(mt(1)).mul(mt(4)));return{blockF:Qs,li:mt(ua.greaterThan(.5).select(da,Tr)).toVar()}},os=xr(0),zn=xr(1),Wo=xr(2);bt(os.blockF.greaterThan(-.5).and(zn.blockF.greaterThan(-.5)).and(Wo.blockF.greaterThan(-.5)),()=>{let Ln=es=>Li(mt(es.blockF.mul(64)).add(es.li));v.element(Vr).assign(Ln(os)),v.element(Vr.add(mt(1))).assign(Ln(zn)),v.element(Vr.add(mt(2))).assign(Ln(Wo))}).Else(()=>{v.element(Vr).assign(Li(0)),v.element(Vr.add(mt(1))).assign(Li(0)),v.element(Vr.add(mt(2))).assign(Li(0))}),Ct.addAssign(64)})})():null,kn=Math.ceil(e/_2[0]),Ic=Math.ceil(r/_2[0]),Br=Math.ceil(n/_2[0]),Z=(F,et)=>F.compute(et,Array.isArray(et)?_2:void 0),Mt=[Jr,Math.max(1,Math.ceil(f/Jr)),1];return{resolution:e,sparse:m!==null,poolBricks:f,meshlet:y!==null,vertexBlocks:_,needsInit:m!==null,sdfTexture:S,colorTexture:w,coarseTexture:T,counterAttribute:C.value,storageAttributes:[C,A,O,B,X,st,ct,wt].filter(F=>F!==null).map(F=>F.value),uniforms:{bboxHalf:o,bboxOffset:l,activeThreshold:u,windowOrigin:h,...y?{windowSize:d,cullEnabled:yt,cullMVP:Ot,adaptCos:Ft}:{}},kernels:{zero:Z(oe,1),clear:jt.compute([Math.ceil(s/256),1,1],[256,1,1]),coarse:Z(Ve,[Br,Br,Br]),...oi?{init:Z(oi,[Br,Br,Br])}:{},...xi?{release:Z(xi,[Br,Br,Br])}:{},...Ks?{alloc:Z(Ks,[Br,Br,Br])}:{},...Hi?{stats:Z(Hi,1)}:{},sdf:Z(Zs,m?Mt:[kn,kn,kn]),...Ci?{sdfWindow:Z(Ci,[kn,kn,kn])}:{},color:Z(ps,[Ic,Ic,Ic]),extract:y?Z(Dm,Mt):Z(tu,m?Mt:[kn,kn,kn]),...y?{clearDraw:Zt.compute([Math.ceil(s/256),1,1],[256,1,1]),meshRelease:Z(li,[Br,Br,Br]),verts:Z(Rm,Mt),vertsWindow:Z(rh,[n,n,n]),extractWindow:Z(Nm,[n,n,n]),classify:Z(Ur,[Br,Br,Br]),gather:Z(y0,Mt)}:{}}}}var ot,MR,ue,Ca,L1,n5,_2,zp,eEt=j(()=>{dt(),mr(),He(),nW(),UW(),ot=t=>t,MR=t=>t,ue=t=>t,Ca=t=>t,L1=24,n5=sW,_2=[4,4,4],zp=(t,e)=>d1t(t,e)});function iEt(t){let e=t.getAttribute("position");if(!e||e.count<3)return null;let i=t.getIndex(),r=Math.floor((i?i.count:e.count)/3);if(r===0)return null;let s=Math.max(1,Math.ceil(r/a5));s>1&&console.warn(`Spline shape blend: mesh child has ${r} triangles \u2014 baking every ${s}th (SDF detail reduced).`);let n=Math.floor(r/s),a=new Float32Array(12*n),o=new P(0,0,0),l=new P,u=0;for(let d=0;d<n;d++){let c=d*s*3;for(let p=0;p<3;p++){let m=i?i.getX(c+p):c+p;l.fromBufferAttribute(e,m),a[u++]=l.x,a[u++]=l.y,a[u++]=l.z,a[u++]=0,o.x=Math.max(o.x,Math.abs(l.x)),o.y=Math.max(o.y,Math.abs(l.y)),o.z=Math.max(o.z,Math.abs(l.z))}}if(o.x===0&&o.y===0&&o.z===0)return null;let h=Math.max(o.x,o.y,o.z);return o.x=Math.max(o.x,.05*h)*(1+AR),o.y=Math.max(o.y,.05*h)*(1+AR),o.z=Math.max(o.z,.05*h)*(1+AR),{data:a,triCount:n,boxHalf:o}}function rEt(t){let e=wc(t),i=pD;return(r,s,n)=>{let a=Qt(G($s(s.z),$s(s.w),$s(n.w)),G(1e-5)).toVar(),o=$s(s.y),l=G(o.mod(Tc).mul(i),ce(o.div(Tc)).mul(i),0).toVar(),u=Ae(lS(r.div(a).mul(.5).add(.5)),G(0),G(1)).mul(i-1).toVar(),h=ii(ce(u),G(i-2)).toVar(),d=u.sub(h).toVar(),c=l.add(h).toVar(),p=(C,M,A)=>$s(ebt(e.load(Qn(c.add(G(C,M,A))))).x),m=$s(d.x),f=$s(d.y),g=$s(d.z),y=Yt(p(0,0,0),p(1,0,0),m),v=Yt(p(0,1,0),p(1,1,0),m),b=Yt(p(0,0,1),p(1,0,1),m),_=Yt(p(0,1,1),p(1,1,1),m),x=Yt(Yt(y,v,f),Yt(b,_,f),g),S=Qt($s(a.x),Qt($s(a.y),$s(a.z))),w=Le(r).sub(a),T=mi(Qt(w,G(0)));return $s(x.mul(S).add(T))}}function sEt(t){let e=pD;return new P(t%Tc*e,Math.floor(t/Tc)*e,0)}var $s,lS,ebt,pD,Tc,AR,a5,nEt=j(()=>{dt(),dt(),mr(),He(),$s=t=>t,lS=t=>t,ebt=t=>t,pD=48,Tc=4,AR=.08,a5=24576});function aEt(){if(CR!==null)return CR;let t=Et(()=>{let i=at(Ze(Y9),Ze(K9)),r=at(1).div(i),s=bi().mul(Ze(Z9)).sub(at(.5)).mul(2).add(at(.5)).toVar();s.x.addAssign(Ze(x2));let n=s.div(i).toVar(),a=Ze(tv.sample(n).x).toVar();n.x.addAssign(Ze(r.x));let o=Ze(tv.sample(n).x).toVar();n.y.addAssign(Ze(r.y));let l=Ze(tv.sample(n).x).toVar();n.x.subAssign(Ze(r.x));let u=Ze(tv.sample(n).x).toVar(),h=a,d=h.add(o),c=d.add(l),p=c.add(u);return lt(p,c,d,h)})(),e=new Re;return e.name="SplineShapeBlend.pyramid",e.fragmentNode=t,e.depthTest=!1,e.depthWrite=!1,e.blending=cr,e.needsUpdate=!0,CR=e,e}function sw(t,e,i=1){return new ri(t,e,{count:i,format:on,type:Qe,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:De,magFilter:De,wrapS:Cn,wrapT:Cn})}function oEt(){let t=Av.length;if(t>0){for(let e of Av)e.dispose();Av.length=0}return t}var Ze,Cht,kd,tv,Y9,K9,x2,Fy,Z9,CR,kL,zL,Mp,dE,LL,FL,UL,jL,GL,WL,qL,cE,ar,nw,Eht,Q9,F1,w2,Av,lEt=j(()=>{dt(),mr(),He(),nW(),e0t(),UW(),eEt(),nEt(),dn(),Ze=t=>t,Cht=t=>t,kd=new Pr,tv=ee(new pi),Y9=gt(1),K9=gt(1),x2=gt(0),Fy=gt(0),Z9=gt(1),CR=null,kL=!1,zL=!1,Mp="",dE=!1,LL=!1,FL=!1,UL=!1,jL=!1,GL=!1,WL=!1,qL=!1,cE=!1;try{let t=new URLSearchParams(window.location.search);kL=t.get("dbgsbmarch")==="vertex",zL=t.get("dbgsbultra")==="0",Mp=t.get("dbgsbchain")??"",dE=t.get("dbgsbnoclear")==="1",LL=t.get("dbgsbsparse")==="0",FL=t.get("dbgsbincr")==="0",UL=t.get("dbgsblod")==="1",jL=t.get("dbgsbpool")==="1",GL=t.get("dbgsbpool")==="0",WL=t.get("dbgsbmesh")==="0",qL=t.get("dbgsbadapt")==="0",cE=t.get("dbgsbcull")==="1"}catch{}ar={updates:0,skips:0,computes:0,readbacksResolved:0,readbackErrors:0,fieldsFull:0,fieldsWindowed:0,lastWindowBricks:0,refines:0,lastDispatchRes:0,regathers:0,readbackPending:!1,lastTotal:-1,lastPass:"",staleConfigSkips:0,marchPositions:null},nw=24576,Eht=Math.cos(8*Math.PI/180),Q9=class{constructor(t=0,e=0,i=0){this.wantsReplacement=!1,this.capacityHint=0,this._builtOnce=!1,this.level=-1,this.spatialnAtBuild=-1,this._passesRenderer=null,this._marchCapacity=0,this._marchBuffers=null,this._computeNode=null,this._computeNodeKey="",this._legacyMaterialsLevel=-1,this._computeDirty=!1,this._cachedAtBuild=!1,this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,this._lastFieldChangeMs=0,this._ultraResAtBuild=0,this._ultraReadbackPending=!1,this._ultraReadbackQueued=!1,this._ultraWantedCapacity=0,this._poolAtBuild=0,this._ultraWantedPoolBricks=0,this.poolHint=0,this._drawIndex=null,this._vertexBuffers=null,this._vertBlocksAtBuild=0,this._ultraWantedVertexBlocks=0,this.vertHint=0,this._cullCamera=null,this._lastGatherMVP=new _t,this._hasGatherMVP=!1,this._ultraRetired=[],this._retiredStorage=[],this._ultraBuildSeq=0,this._lastRenderer=null,this._meshBaker=null,this._meshAtBuild=!1,this._meshSlots=new Map,this._meshBakeFailed=new Map,this._meshWarnedFull=!1,this.shapesTex=ee(new pi),this.spatialTexNode=ee(new pi),this.potentialTexNode=ee(new pi),this.voxelTexNode=ee(new pi),this.pyramid1TexNode=ee(new pi),this.pyramid2TexNode=ee(new pi),this.npartUniform=gt(0),this.spatialnUniform=gt(1),this.spanUniform=gt(0),this.spatialMaterial=null,this.potentialMaterial=null,this.voxelMaterial=null,this.spatialTargets=[],this.potentialTargets=[],this.voxelTargets=[],this.pyramidTargets=[],this.retired=!1,this._onSettled=[],this.capacityHint=t,this.poolHint=e,this.vertHint=i;let r=qP(),s=new br(r.triTable,16,256,Qa,Qe);s.needsUpdate=!0;let n=new br(r.numTrisTable,256,1,Qa,Qe);n.needsUpdate=!0,this.triTableTexNode=ee(s),this.numTrisTableTexNode=ee(n)}shapeRow(t,e){return this.shapesTex.sample(at(t,(e+.5)/5))}_quadMaterial(t,e){let i=new Re;return i.name=t,i.fragmentNode=e,i.depthTest=!1,i.depthWrite=!1,i.blending=cr,i.needsUpdate=!0,i}_buildSpatialMaterial(t){let e=t.spatialDivisions,i=sW,r=this.npartUniform,s=this.spatialnUniform,n=this.spanUniform,a=t.spatialn,o=Et(()=>{let l=at(e*a,e**2),u=ce(bi().mul(l)).toVar(),h=Ze(u.y).toVar(),d=h.sub(ce(h.div(e)).mul(e)).toVar();h.assign(ce(h.div(e)));let c=h,p=Ze(u.x).toVar(),m=p.sub(ce(p.div(s)).mul(Ze(s))).toVar().mul(96).toVar();p.assign(ce(p.div(s)));let f=G(p,d,c),g=f.div(e).mul(2).sub(1).sub(Ze(n)).toVar(),y=f.add(1).div(e).mul(2).sub(1).add(Ze(n)).toVar(),v=b=>{let _=I(0).toVar();for(let x=23;x>=0;x--){let S=b.add(x),w=S.add(.5).div(i),T=this.shapeRow(w,0),C=Cht(T.xyz),M=Ze(T.w);_.mulAssign(2);let A=Ze(g.x).lessThan(Ze(C.x)).and(Ze(C.x).lessThan(Ze(y.x))).and(Ze(g.y).lessThan(Ze(C.y))).and(Ze(C.y).lessThan(Ze(y.y))).and(Ze(g.z).lessThan(Ze(C.z))).and(Ze(C.z).lessThan(Ze(y.z))).and(S.lessThan(Ze(r))).or(M.equal(-2));_.addAssign(A.select(I(1),I(0)))}return _};return lt(v(m),v(m.add(24)),v(m.add(48)),v(m.add(72)))})();return this._quadMaterial("SplineShapeBlend.spatial",o)}_fieldEnv(t,e){return{shapeRow:(i,r)=>this.shapeRow(i,r),spatialTex:this.spatialTexNode,spatialDivisions:t.spatialDivisions,spatialn:t.spatialn,colorKBump:e,meshSdf:this._meshBaker?rEt(this._meshBaker.atlas):void 0}}_buildPotentialMaterial(t){let e=t.spatialDivisions,i=t.resolution,r=i-1,s=1/i,n=t.zLayersPerRow,a=t.basePyramidSize,o=X9(this._fieldEnv(t,2*s)),l=Et(()=>{let u=ce(bi().mul(at(a,a))).toVar(),h=Ze(u.x).mod(i),d=Ze(u.y).mod(i),c=ce(Ze(u.x).mul(s)).add(ce(Ze(u.y).mul(s)).mul(n)),p=G(h,d,c),m=p.div(r).mul(2).sub(1).toVar(),f=ce(p.div(r).mul(e-1)).toVar(),{sdf:g,color:y}=o(m,f),v=Li(Ze(y.x).mul(255)),b=Li(Ze(y.y).mul(255)),_=v.shiftLeft(Li(8)).bitOr(b);return lt(g,_.toFloat().mul(1525902e-11),Ze(y.z),Ze(y.w))})();return this._quadMaterial("SplineShapeBlend.potential",l)}_buildVoxelMaterial(t){let e=t.resolution,i=e-1,r=1/e,s=t.zLayersPerRow,n=t.basePyramidSize,a=Kvt(e,s),o=this.potentialTexNode,l=()=>{let c=ce(bi().mul(at(n,n))).toVar();return{xi:Ze(c.x).mod(e).toVar(),yi:Ze(c.y).mod(e).toVar(),zi:ce(Ze(c.x).mul(r)).add(ce(Ze(c.y).mul(r)).mul(s)).toVar()}},u=(c,p,m)=>{let f=(g,y,v,b)=>Ze(a(c.add(g),p.add(y),m.add(v),o).x).lessThan(0).toFloat().mul(b);return f(0,0,0,1).add(f(1,0,0,2)).add(f(0,1,0,8)).add(f(1,1,0,4)).add(f(0,0,1,16)).add(f(1,0,1,32)).add(f(0,1,1,128)).add(f(1,1,1,64))},h=Et(()=>{let{xi:c,yi:p,zi:m}=l(),f=((v,b,_)=>{let x=Ze(a(v.add(1),b,_,o).x).sub(Ze(a(v.sub(1),b,_,o).x)),S=Ze(a(v,b.add(1),_,o).x).sub(Ze(a(v,b.sub(1),_,o).x)),w=Ze(a(v,b,_.add(1),o).x).sub(Ze(a(v,b,_.sub(1),o).x));return x.equal(0).and(S.equal(0)).and(w.equal(0)).select(G(.199,.299,.399),xe(G(x,S,w)))})(c,p,m).toVar(),g=lt(f,0).toVar(),y=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(m.greaterThanEqual(i));return bt(y.not(),()=>{g.assign(lt(f,u(c,p,m)))}),g})(),d=Et(()=>{let{xi:c,yi:p,zi:m}=l(),f=lt(0).toVar(),g=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(m.greaterThanEqual(i));return bt(g.not(),()=>{let y=u(c,p,m);f.assign(this.numTrisTableTexNode.sample(at(y.add(.5).div(256),.5)))}),f})();return this._quadMaterial("SplineShapeBlend.voxel",Fv({output:h,numTris:d}))}_spatialTargetFor(t){let e=t.resolutionLevel,i=this.spatialTargets[e];return i||(i=sw(t.spatialDivisions*t.spatialn,t.spatialDivisions**2),this.spatialTargets[e]=i),i}_targetsFor(t){let e=t.resolutionLevel,i=this._spatialTargetFor(t),r=this.potentialTargets[e];r||(r=sw(t.basePyramidSize,t.basePyramidSize),this.potentialTargets[e]=r);let s=this.voxelTargets[e];s||(s=sw(t.basePyramidSize,t.basePyramidSize,2),s.textures[0].name="output",s.textures[1].name="numTris",s.textures[1].format=Qa,this.voxelTargets[e]=s);let n=this.pyramidTargets[e];return n||(n=[sw(t.pyramidTexture1Width,t.pyramidTexture1Height),sw(t.pyramidTexture2Width,t.pyramidTexture2Height)],this.pyramidTargets[e]=n),{spatial:i,potential:r,voxel:s,pyramid:n}}_marchResources(t){let e=this._targetsFor(t),i=t.pyramidLevelSizes.length%2==0?0:1,r=1-i;return{resolutionLevel:t.resolutionLevel,pyramidLevelSizes:t.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:e.pyramid[r].width,height:e.pyramid[r].height},pyramid2Size:{width:e.pyramid[i].width,height:e.pyramid[i].height}}}_maxMarchSlots(t){let e=t.backend?.device?.limits,i=Math.min(e?.maxStorageBufferBindingSize??134217728,e?.maxBufferSize??268435456);return 192*Math.floor(i/16/192)}_ensureMarchCapacity(t,e){if(this._marchBuffers!==null&&t<=this._marchCapacity)return!1;let i=Math.min(Math.max(e,nw),192*Math.ceil(1.5*t/192));if(this._marchBuffers!==null&&i<=this._marchCapacity)return!1;if(this._marchBuffers!==null)for(let r of[this._marchBuffers.positions,this._marchBuffers.normals,this._marchBuffers.colors]){let s=r.value;s&&this._retiredStorage.push(s)}return this._marchBuffers={positions:Qr(i,"vec4"),normals:Qr(i,"vec4"),colors:Qr(i,"vec4")},this._marchCapacity=i,this._computeNode=null,!0}update(t,e,i){if(ar.updates++,this._lastRenderer=e,i!==void 0&&(this._cullCamera=i),t._meshSdfBaked.size>0)for(let[T,C]of t._meshSdfBaked)C.owner!==this&&t._meshSdfBaked.delete(T);let r=(n=t,m0t.call(n)),s=e.backend?.isWebGPUBackend===!0;var n;if(s&&t._meshSdfWanted.size>0&&this._meshBaker===null&&(this._meshBaker=function(T,C){let M=pD,A=new Hg(Tc*M,Math.ceil(T/Tc)*M,M);A.format=Qa,A.type=Qe,A.minFilter=De,A.magFilter=De,A.name="SplineShapeBlend.meshSdfAtlas";let R=I(C).mul(0),O=gt(new P(0,0,0)),N=gt(0),B=gt(new P(1,1,1)),L=Qr(3*a5,"vec4"),z=W=>L.element(W),k=Et(()=>{let W=G(uo).toVar();bt($s(W.x).greaterThanEqual(M).or($s(W.y).greaterThanEqual(M)).or($s(W.z).greaterThanEqual(M)),()=>{yr()});let X=W.div(M-1).mul(2).sub(1).mul(B).toVar(),st=I(1e30).toVar(),nt=I(1e15).toVar();Ji(a5,({i:pt})=>{bt(I(pt).greaterThanEqual($s(N)),()=>{sa()});let K=mt(I(pt).toVar()).mul(3).toVar(),ct=lS(z(K).xyz).toVar(),St=lS(z(K.add(mt(1))).xyz).toVar(),wt=lS(z(K.add(mt(2))).xyz).toVar(),Tt=St.sub(ct).toVar(),yt=wt.sub(ct).toVar(),Ot=X.sub(ct).toVar(),Ft=kt(Tt,Ot).toVar(),Bt=kt(yt,Ot).toVar(),zt=X.sub(St).toVar(),Vt=kt(Tt,zt).toVar(),Wt=kt(yt,zt).toVar(),$t=X.sub(wt).toVar(),Pt=kt(Tt,$t).toVar(),oe=kt(yt,$t).toVar(),jt=G(0).toVar(),Zt=Vt.mul(oe).sub(Pt.mul(Wt)).toVar(),Jt=Pt.mul(Bt).sub(Ft.mul(oe)).toVar(),$=Ft.mul(Wt).sub(Vt.mul(Bt)).toVar();bt(Ft.lessThanEqual(0).and(Bt.lessThanEqual(0)),()=>{jt.assign(ct)}).ElseIf(Vt.greaterThanEqual(0).and(Wt.lessThanEqual(Vt)),()=>{jt.assign(St)}).ElseIf(oe.greaterThanEqual(0).and(Pt.lessThanEqual(oe)),()=>{jt.assign(wt)}).ElseIf($.lessThanEqual(0).and(Ft.greaterThanEqual(0)).and(Vt.lessThanEqual(0)),()=>{let Ve=Ft.div(Ft.sub(Vt));jt.assign(ct.add(Tt.mul(Ve)))}).ElseIf(Jt.lessThanEqual(0).and(Bt.greaterThanEqual(0)).and(oe.lessThanEqual(0)),()=>{let Ve=Bt.div(Bt.sub(oe));jt.assign(ct.add(yt.mul(Ve)))}).ElseIf(Zt.lessThanEqual(0).and(Wt.sub(Vt).greaterThanEqual(0)).and(Pt.sub(oe).greaterThanEqual(0)),()=>{let Ve=Wt.sub(Vt).div(Wt.sub(Vt).add(Pt.sub(oe)));jt.assign(St.add(wt.sub(St).mul(Ve)))}).Else(()=>{let Ve=I(1).div(Zt.add(Jt).add($)),ie=Jt.mul(Ve),oi=$.mul(Ve);jt.assign(ct.add(Tt.mul(ie)).add(yt.mul(oi)))});let se=X.sub(jt).toVar(),Pe=kt(se,se).toVar();bt(Pe.lessThan(st),()=>{st.assign(Pe);let Ve=Zr(Tt,yt),ie=kt(se,Ve).greaterThanEqual(0).select(I(1),I(-1));nt.assign(xl(Pe).mul(ie))})});let xt=Qt($s(B.x),Qt($s(B.y),$s(B.z)));qp(A,Qn(W.add(O)),lt($s(nt.div(xt).add(R)),0,0,0)).toStack()})(),V=Math.ceil(M/4),H=k.compute([V,V,V],[4,4,4]);return{atlas:A,slots:T,kernel:H,uniforms:{slotOrigin:O,triCount:N,boxHalf:B},setTriangles(W,X){let st=L.value;st.array.set(W.subarray(0,12*X)),st.needsUpdate=!0}}}(Tc*Tc,++this._ultraBuildSeq)),t.npart===0)return this._meshBaker!==null&&t._meshSdfWanted.size>0&&this._bakeNextMeshChild(t,e),void(t.geometry.drawRange.count=0);this.npartUniform.value=t.npart,this.spatialnUniform.value=t.spatialn,this.spanUniform.value=t.spatialPassUniforms.span.value,t.shapesDataTexture.value&&(this.shapesTex.value=t.shapesDataTexture.value);let a=!kL&&s,o=a&&!zL&&t.ultraFieldResolution>0,l=o&&!GL&&(jL||t.ultraFieldResolution>=512)?Math.min(Math.pow(t.ultraFieldResolution/4,3),Math.max(function(T){let C=T/4;return Math.min(C*C*C,Math.max(8192,16*C*C))}(t.ultraFieldResolution),this._ultraWantedPoolBricks,this.poolHint)):0,u=l>0&&!WL,h=this._maxMarchSlots(e),d=u?Math.min(Math.floor(h/64),Math.max(function(T){let C=T/4;return Math.min(262144,Math.max(2048,2*C*C))}(t.ultraFieldResolution),this._ultraWantedVertexBlocks,this.vertHint)):0,c=this._meshBaker!==null,p=t.needsRebuild||this.level!==t.resolutionLevel||this.spatialnAtBuild!==t.spatialn||this._cachedAtBuild!==a||this._ultraResAtBuild!==(o?t.ultraFieldResolution:0)||this._poolAtBuild!==l||this._vertBlocksAtBuild!==d||this._meshAtBuild!==c;if(p&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let m=a&&this._ensureMarchCapacity(Math.min(Math.max(h,nw),Math.max(t.geometry.drawRange.count,this.capacityHint,o?Math.max(function(T){return Math.max(nw,192*Math.ceil(16*T*T/192))}(t.ultraFieldResolution),this._ultraWantedCapacity):nw)),h);if(m&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let f=this._spatialTargetFor(t),g=o?null:this._targetsFor(t),y=p||m,v=o&&this._ultra!==null&&this._ultraResAtBuild===t.ultraFieldResolution&&!m&&this.level===t.resolutionLevel&&this.spatialnAtBuild===t.spatialn&&this._cachedAtBuild===a;if(y&&v)t.needsRebuild=!1,this._ultra.uniforms.bboxHalf.value=t.bboxSize/2,this._ultra.uniforms.bboxOffset.value=t.bboxOffset,this._ultraDrag&&(this._ultraDrag.uniforms.bboxHalf.value=t.bboxSize/2,this._ultraDrag.uniforms.bboxOffset.value=t.bboxOffset);else if(y){t.needsRebuild=!1;let T=this.spatialnAtBuild!==t.spatialn;this.level=t.resolutionLevel,this.spatialnAtBuild=t.spatialn,this._meshAtBuild=c,(T||this.spatialMaterial===null)&&(this.spatialMaterial?.dispose(),this.spatialMaterial=this._buildSpatialMaterial(t)),this.spatialTexNode.value=f.texture;let C=this._ultra,M=this._ultraDrag;if(this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,o){let O=t.ultraFieldResolution,N=C!==null&&this._ultraResAtBuild===O;if(N&&!m)this._ultra=C,C.uniforms.bboxHalf.value=t.bboxSize/2,C.uniforms.bboxOffset.value=t.bboxOffset,this._ultraDrag=M,M&&(M.uniforms.bboxHalf.value=t.bboxSize/2,M.uniforms.bboxOffset.value=t.bboxOffset);else{let B=N&&l===0&&!C.sparse;C&&!B&&this._ultraRetired.push(C.sdfTexture,C.colorTexture,C.coarseTexture),u&&this._drawIndex===null&&(this._drawIndex=Qr(this._marchCapacity,"uint")),u&&this._vertexBuffers===null&&(this._vertexBuffers={positions:Qr(64*d,"vec4"),normals:Qr(64*d,"vec4"),colors:Qr(64*d,"vec4")}),this._ultra=Aht({resolution:O,colorResolution:O/2,bboxHalf:t.bboxSize/2,bboxOffset:t.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(t,2/(O/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:qP().numTrisTable,buffers:u?this._vertexBuffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,sparseStorage:l>0?{poolBricks:l,meshlet:u?{drawIndex:this._drawIndex,vertexBlocks:d}:void 0}:void 0,reuseTextures:B?{sdfTexture:C.sdfTexture,colorTexture:C.colorTexture,coarseTexture:C.coarseTexture}:void 0}),this._poolAtBuild=l,this._vertBlocksAtBuild=d;let L=UL&&O>=128&&!u?O/2:0;M&&(!N||L===0)&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),L>0&&(this._ultraDrag=Aht({resolution:L,colorResolution:L/2,bboxHalf:t.bboxSize/2,bboxOffset:t.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(t,2/(L/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:qP().numTrisTable,buffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,reuseTextures:N&&M?{sdfTexture:M.sdfTexture,colorTexture:M.colorTexture,coarseTexture:M.coarseTexture}:void 0}))}this._ultraResAtBuild=O}else{C&&this._ultraRetired.push(C.sdfTexture,C.colorTexture,C.coarseTexture),M&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),(this._legacyMaterialsLevel!==t.resolutionLevel||T||this.potentialMaterial===null||this.voxelMaterial===null)&&(this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose(),this.potentialMaterial=this._buildPotentialMaterial(t),this.voxelMaterial=this._buildVoxelMaterial(t),this._legacyMaterialsLevel=t.resolutionLevel),this.potentialTexNode.value=g.potential.texture,this.voxelTexNode.value=g.voxel.textures[0];let O=t.pyramidLevelSizes.length%2==0?0:1,N=1-O;this.pyramid1TexNode.value=g.pyramid[N].texture,this.pyramid2TexNode.value=g.pyramid[O].texture,this._ultraResAtBuild=0}let A=t.material;A.defines===void 0&&(A.defines={}),Mp.includes("nomat")||(A.defines.SHAPEBLEND=t.resolutionLevel),Mp.includes("nomat")||A.setShapeBlendResources?.(o?{resolutionLevel:t.resolutionLevel,pyramidLevelSizes:t.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:1,height:1},pyramid2Size:{width:1,height:1},cached:u?{...this._vertexBuffers,drawIndex:this._drawIndex}:this._marchBuffers}:{...this._marchResources(t),cached:a?this._marchBuffers:void 0}),this._cachedAtBuild=a;let R=`${t.resolutionLevel}:${this._marchCapacity}`;this._computeNodeKey!==R&&(this._computeNode=null,this._computeNodeKey=R)}if(y)return this._builtOnce=!0,void(this._computeDirty=!0);this._meshBaker!==null&&t._meshSdfWanted.size>0&&this._bakeNextMeshChild(t,e);let b=this._passesRenderer!==e,_=r&&!FL&&!this._computeDirty&&!b&&!t._fieldDirtyFull;if(!(r||this._computeDirty||b)){if(o&&this._refinePending&&this._ultra!==null&&performance.now()-this._lastFieldChangeMs>250)return this._refinePending=!1,this._passesRenderer=e,ar.refines++,void this._runUltra(t,e,!1,this._ultra);if(o&&cE&&this._ultra!==null&&this._ultra.meshlet&&this._lastDispatched===this._ultra&&!this._ultraReadbackPending&&this._updateCullUniforms(t,this._ultra)&&(!this._hasGatherMVP||!this._lastGatherMVP.equals(this._ultra.uniforms.cullMVP.value))){this._lastGatherMVP.copy(this._ultra.uniforms.cullMVP.value),this._hasGatherMVP=!0,ar.regathers++;let T=e;return T.compute(this._ultra.kernels.zero),dE||T.compute(this._ultra.kernels.clearDraw),T.compute(this._ultra.kernels.gather),this._ultra.kernels.stats&&T.compute(this._ultra.kernels.stats),void this._runUltraReadback(t,e)}if(!t.drawRangeNeedsForceUpdate)return void ar.skips++;if(o)return void(this._ultraReadbackPending||this._runUltraReadback(t,e))}if(this._passesRenderer=e,Mp.includes("none")&&ar.readbacksResolved>0)return void(this._computeDirty=!1);let x=e.getRenderTarget(),S=e.getMRT(),w=e.autoClear;if(e.setMRT(null),e.autoClear=!1,ar.lastPass="spatial",e.setRenderTarget(f),kd.material=this.spatialMaterial,kd.render(e),o){e.autoClear=w,e.setRenderTarget(x),e.setMRT(S);let T=this._ultraDrag!==null&&r&&!this._computeDirty;return this._refinePending=T,this._lastFieldChangeMs=performance.now(),this._runUltra(t,e,_,T?this._ultraDrag:this._ultra),void(this._computeDirty=!1)}return Mp==="spatial"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="potential",e.setRenderTarget(g.potential),kd.material=this.potentialMaterial,kd.render(e),Mp==="potential"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="voxel",e.setRenderTarget(g.voxel),kd.material=this.voxelMaterial,kd.render(e),Mp==="voxel"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="pyramid",this._renderPyramid(t,e,g.voxel,g.pyramid),e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),ar.lastPass="march",a&&(this._computeNode===null&&(this._computeNode=function(T,C,M){let A=Zvt(T);return Et(()=>{let{position:R,normal:O,color:N}=A(Pn.toFloat());C.positions.element(Pn).assign(lt(R,1)),C.normals.element(Pn).assign(lt(O,0)),C.colors.element(Pn).assign(N)})().compute(M)}(this._marchResources(t),this._marchBuffers,this._marchCapacity)),e.compute(this._computeNode),ar.computes++),void(this._computeDirty=!1))))}_bakeNextMeshChild(t,e){let i=this._meshBaker;for(let[r,s]of t._meshSdfWanted){let n=c0t(s);if(this._meshBakeFailed.get(r)===n)continue;let a=this._meshSlots.get(r);if(a===void 0){if(this._meshSlots.size>=i.slots)for(let u of this._meshSlots.keys())!t._meshSdfBaked.has(u)&&!t._meshSdfWanted.has(u)&&(this._meshSlots.delete(u),this._meshBakeFailed.delete(u));if(this._meshSlots.size>=i.slots){this._meshWarnedFull||(this._meshWarnedFull=!0,console.warn(`Spline shape blend: more than ${i.slots} distinct mesh children \u2014 the extra meshes are left out of the blend.`));continue}let l=new Set(this._meshSlots.values());for(a=0;l.has(a);)a++;this._meshSlots.set(r,a)}let o=iEt(s);if(o!==null)return i.setTriangles(o.data,o.triCount),i.uniforms.slotOrigin.value.copy(sEt(a)),i.uniforms.triCount.value=o.triCount,i.uniforms.boxHalf.value.copy(o.boxHalf),e.compute(i.kernel),t._meshSdfBaked.set(r,{slot:a,boxHalf:o.boxHalf.clone(),posVersion:n,owner:this}),void t._meshSdfWanted.delete(r);this._meshBakeFailed.set(r,n)}}_updateCullUniforms(t,e){if(!e.meshlet)return!1;let i=this._cullCamera;return cE&&i&&i.projectionMatrix!==void 0&&i.matrixWorldInverse!==void 0?(e.uniforms.cullMVP.value.multiplyMatrices(Lt.unjitteredProjection.value,i.matrixWorldInverse).multiply(t.matrixWorld),e.uniforms.cullEnabled.value=1,!0):(e.uniforms.cullEnabled.value=0,!1)}_runUltra(t,e,i,r){let s=e;ar.lastPass="ultra-kernels",ar.lastDispatchRes=r.resolution,ar.marchPositions=(r.meshlet?this._vertexBuffers:this._marchBuffers).positions.value,this._lastDispatched=r;let n=r.resolution,a=n/4,o=2/(n-1);r.uniforms.activeThreshold.value=LL?1e30:(3*Math.sqrt(3)+4)*o+.25*t._maxBlendK;let l=r.meshlet&&!qL;r.meshlet&&(r.uniforms.adaptCos.value=l?Eht:2);let u=0,h=0,d=0,c=a,p=a,m=a;if(i){let y=r.uniforms.activeThreshold.value+2/(t.spatialDivisions-1)+4/(n-1),v=x=>Math.floor(.5*(x+1)*(n-1)/4),b=x=>Math.min(a-1,Math.max(0,v(x))),_=x=>Math.min(a,Math.max(1,v(x)+1));if(u=b(t._fieldDirtyMin.x-y),h=b(t._fieldDirtyMin.y-y),d=b(t._fieldDirtyMin.z-y),c=_(t._fieldDirtyMax.x+y)-u,p=_(t._fieldDirtyMax.y+y)-h,m=_(t._fieldDirtyMax.z+y)-d,ar.fieldsWindowed++,l){let x=Math.min(a,u+c+1),S=Math.min(a,h+p+1),w=Math.min(a,d+m+1);u=Math.max(0,u-1),h=Math.max(0,h-1),d=Math.max(0,d-1),c=x-u,p=S-h,m=w-d}}else ar.fieldsFull++;ar.lastWindowBricks=c*p*m,r.uniforms.windowOrigin.value.set(u,h,d),r.uniforms.windowSize?.value.set(c,p,m);let f=u===0&&h===0&&d===0&&c===a&&p===a&&m===a,g=[Math.ceil(c/4),Math.ceil(p/4),Math.ceil(m/4)];r.meshlet&&this._updateCullUniforms(t,r)&&(this._lastGatherMVP.copy(r.uniforms.cullMVP.value),this._hasGatherMVP=!0),s.compute(r.kernels.zero),dE||s.compute(r.meshlet?r.kernels.clearDraw:r.kernels.clear),r.needsInit&&r.kernels.init&&(s.compute(r.kernels.init),r.needsInit=!1),s.compute(r.kernels.coarse,g),r.kernels.release&&s.compute(r.kernels.release,g),r.kernels.alloc&&s.compute(r.kernels.alloc,g),r.kernels.meshRelease&&s.compute(r.kernels.meshRelease,g),r.sparse?f?s.compute(r.kernels.sdf):s.compute(r.kernels.sdfWindow,[c,p,m]):s.compute(r.kernels.sdf,[c,p,m]),r.kernels.classify&&s.compute(r.kernels.classify,g),s.compute(r.kernels.color,[Math.ceil(c/2),Math.ceil(p/2),Math.ceil(m/2)]),r.meshlet?(f?(s.compute(r.kernels.verts),s.compute(r.kernels.extract)):(s.compute(r.kernels.vertsWindow,[c,p,m]),s.compute(r.kernels.extractWindow,[c,p,m])),s.compute(r.kernels.gather)):s.compute(r.kernels.extract),r.kernels.stats&&s.compute(r.kernels.stats),ar.computes++,this._ultraReadbackPending?this._ultraReadbackQueued=!0:this._runUltraReadback(t,e)}_disposeRetired(){for(let t of this._ultraRetired)t.dispose();if(this._ultraRetired.length=0,this._retiredStorage.length>0){let t=this._lastRenderer?.backend?.attributeUtils;if(t)for(let e of this._retiredStorage)t.destroyAttribute(e);this._retiredStorage.length=0}for(let t of this._onSettled)t();this._onSettled.length=0}runWhenSettled(t){this._onSettled.push(t)}transferSettleQueue(t){t._onSettled.push(...this._onSettled),this._onSettled.length=0}_runUltraReadback(t,e){let i=this._lastDispatched??this._ultra,r=e;this._ultraReadbackPending=!0,ar.readbackPending=!0,r.getArrayBufferAsync(i.counterAttribute).then(s=>{if(this._ultraReadbackPending=!1,ar.readbackPending=!1,this.retired)return;this._disposeRetired();let n=new Uint32Array(s),a=i.meshlet?Math.floor(n[3]/3):n[0];if(ar.readbacksResolved++,ar.lastTotal=a,i.sparse&&n.length>2&&n[2]>0&&(this._ultraWantedPoolBricks=Math.ceil(1.5*Math.max(n[1],i.poolBricks)),this._computeDirty=!0),i.meshlet&&n.length>5&&n[5]>0){let l=Math.min(24*n[4],this._maxMarchSlots(e));l>this._marchCapacity&&(this._ultraWantedCapacity=Math.max(this._ultraWantedCapacity,l),this._computeDirty=!0)}if(i.meshlet&&n.length>7&&n[7]>0){let l=Math.min(Math.ceil(1.5*n[6]),Math.floor(this._maxMarchSlots(e)/64));l>i.vertexBlocks&&(this._ultraWantedVertexBlocks=Math.max(this._ultraWantedVertexBlocks,l),this._computeDirty=!0)}let o=Math.floor(this._marchCapacity/3);if(t.geometry.drawRange.count=3*Math.min(Math.ceil(1.25*a),o),t.markSceneShadowsDirty(),t.drawRangeNeedsForceUpdate=!1,this._ultraReadbackQueued&&(this._ultraReadbackQueued=!1,this._runUltraReadback(t,e)),a>o){let l=Math.min(3*a,this._maxMarchSlots(e));l>this._marchCapacity&&(this._ultraWantedCapacity=l,this._computeDirty=!0)}}).catch(()=>{ar.readbackErrors++,this._ultraReadbackPending=!1,ar.readbackPending=!1})}_renderPyramid(t,e,i,r){let s=t.pyramidLevelSizes,n=s.length-1-1;x2.value=0,Fy.value=0;for(let o=n;o>=0;o--){let l=o%2==n%2?r[0]:r[1],u=o===n?i:o%2==n%2?r[1]:r[0];tv.value=u.textures.length>1?u.textures[1]:u.texture,Y9.value=u.width,K9.value=u.height;let h=s[o];o===2&&t.resolutionLevel%2!=0&&(h=3),Z9.value=h,l.viewport.set(Fy.value,0,h,h),e.setRenderTarget(l),kd.material=aEt(),kd.render(e),l.viewport.set(0,0,l.width,l.height);let d=x2.value;x2.value=Fy.value,Fy.value=d,o<n&&(Fy.value+=s[o+1])}ar.lastPass="pyramid-readback";let a=s.length%2==0?0:1;e.readRenderTargetPixelsAsync(r[a],r[a].width-1,0,1,1).then(o=>{let l=o[0];ar.readbacksResolved++,ar.lastTotal=l,!this.retired&&(this._disposeRetired(),(3*l>t.geometry.drawRange.count||t.drawRangeNeedsForceUpdate)&&(t.geometry.drawRange.count=3*Math.floor(1.2*l)),t.drawRangeNeedsForceUpdate=!1,this._marchBuffers!==null&&t.geometry.drawRange.count>this._marchCapacity&&(this._computeDirty=!0))}).catch(()=>{})}dispose(){for(let s of[...this.spatialTargets,...this.potentialTargets,...this.voxelTargets,...this.pyramidTargets.flat()])s?.dispose();this.spatialMaterial?.dispose(),this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose();let t=this._lastRenderer?.backend?.attributeUtils,e=s=>{if(t&&s!==null)for(let n of[s.positions,s.normals,s.colors]){let a=n.value;a&&t.destroyAttribute(a)}},i=s=>{if(s!==null){for(let n of Object.values(s.kernels))n?.dispose?.();if(t)for(let n of s.storageAttributes)t.destroyAttribute(n)}};e(this._marchBuffers),e(this._vertexBuffers);let r=this._drawIndex?.value;t&&r&&t.destroyAttribute(r),this._drawIndex=null,this._computeNode?.dispose?.(),this._marchBuffers=null,this._vertexBuffers=null,this._computeNode=null,this._computeNodeKey="",this._marchCapacity=0,i(this._ultra),this._ultra?.sdfTexture.dispose(),this._ultra?.colorTexture.dispose(),this._ultra?.coarseTexture.dispose(),this._ultra=null,i(this._ultraDrag),this._ultraDrag?.sdfTexture.dispose(),this._ultraDrag?.colorTexture.dispose(),this._ultraDrag?.coarseTexture.dispose(),this._ultraDrag=null,this._meshBaker?.atlas.dispose(),this._meshBaker=null,this._lastDispatched=null,this._disposeRetired(),this._lastRenderer=null}},F1=new WeakMap,w2=new WeakMap,Av=[]}),hEt=j(()=>{tD(),UW(),lEt(),F4=tEt,eW=t=>function(e){let i=F1.get(e);if(i?.wantsReplacement){let r=w2.get(e);w2.set(e,i),i.retired=!0;let s=new Q9(i.capacityHint,i.poolHint,i.vertHint);i.transferSettleQueue(s),r&&s.runWhenSettled(()=>r.dispose()),i=s,F1.set(e,i)}return i||(i=new Q9,F1.set(e,i)),i}(t),function(t){iW=t}({release:t=>function(e){let i=F1.get(e),r=w2.get(e);F1.delete(e),w2.delete(e),r&&Av.push(r),i&&(i.retired=!0,Av.push(i))}(t),drainRetired:oEt})});function uEt(){let t=hS.length;if(t>0){for(let e of hS)e.dispose();hS.length=0}return t}var oo,va,Gl,Je,Eh,Pht,HL,Rht,Dht,pE,Nht,mE,Oht,Iht,$L,zd,Uy,aw,ibt,S2,hS,o5,jy,rbt,sbt,nbt,abt,obt,lbt,dEt=j(()=>{dt(),mr(),He(),Jgt(),Qgt(),oo=[64,1,1],Gl=(va=yg)-1,Je=(t,e)=>e!==void 0?gt(t,e):gt(t),Eh=(t,e)=>{let i=t.xyz,r=Zr(i,e),s=Zr(i,r);return e.add(r.mul(t.w).mul(2)).add(s.mul(2))},Pht=t=>{let e=kt(t,t);return e.lessThan(1e-10).select(lt(0,0,0,1),t.mul(xW(Qt(e,1e-20))))},HL=Et(([t,e])=>{let i=t,r=e,s=kt(i,r).add(1).toVar(),n=G(0).toVar();return bt(s.lessThan(1e-7),()=>{s.assign(0),bt(Le(i.x).greaterThan(Le(i.z)),()=>{n.assign(G(i.y.negate(),i.x,0))}).Else(()=>{n.assign(G(0,i.z.negate(),i.y))})}).Else(()=>{n.assign(Zr(i,r))}),Pht(lt(n,s))}),Rht=t=>t.sub(ce(t.mul(1/289)).mul(289)),Dht=t=>t.sub(ce(t.mul(1/289)).mul(289)),pE=t=>Dht(t.mul(34).add(10).mul(t)),Nht=t=>lt(1.79284291400159).sub(t.mul(.85373472095314)),mE=Et(([t])=>{let e=t,i=1/6,r=1/3,s=ce(e.add(kt(e,G(r)))).toVar(),n=e.sub(s).add(kt(s,G(i))).toVar(),a=Ai(n.yzx,n.xyz).toVar(),o=G(1).sub(a).toVar(),l=ii(a,o.zxy).toVar(),u=Qt(a,o.zxy).toVar(),h=n.sub(l).add(i).toVar(),d=n.sub(u).add(r).toVar(),c=n.sub(.5).toVar();s.assign(Rht(s));let p=pE(pE(pE(lt(0,l.z,u.z,1).add(s.z)).add(s.y).add(lt(0,l.y,u.y,1))).add(s.x).add(lt(0,l.x,u.x,1))).toVar(),m=.142857142857,f=2*m,g=.5*m-1,y=m,v=p.sub(ce(p.mul(y*y)).mul(49)).toVar(),b=ce(v.mul(y)).toVar(),_=ce(v.sub(b.mul(7))).toVar(),x=b.mul(f).add(g).toVar(),S=_.mul(f).add(g).toVar(),w=lt(1).sub(Le(x)).sub(Le(S)).toVar(),T=lt(x.xy,S.xy).toVar(),C=lt(x.zw,S.zw).toVar(),M=ce(T).mul(2).add(1).toVar(),A=ce(C).mul(2).add(1).toVar(),R=Ai(w,lt(0)).negate().toVar(),O=T.xzyw.add(M.xzyw.mul(R.xxyy)).toVar(),N=C.xzyw.add(A.xzyw.mul(R.zzww)).toVar(),B=G(O.xy,w.x).toVar(),L=G(O.zw,w.y).toVar(),z=G(N.xy,w.z).toVar(),k=G(N.zw,w.w).toVar(),V=Nht(lt(kt(B,B),kt(L,L),kt(z,z),kt(k,k))).toVar();B.assign(B.mul(V.x)),L.assign(L.mul(V.y)),z.assign(z.mul(V.z)),k.assign(k.mul(V.w));let H=Qt(lt(.5).sub(lt(kt(n,n),kt(h,h),kt(d,d),kt(c,c))),lt(0)).toVar();return H.assign(H.mul(H)),kt(H.mul(H),lt(kt(B,n),kt(L,h),kt(z,d),kt(k,c))).mul(105)}),Oht=class extends bg{constructor(t,e,i,r,s){super(),this.tangentWorld=t,this.specularPower=e,this.specularIntensity=i,this.diffuseIntensity=r,this.ambientFloor=s}direct(t){let{lightDirection:e,lightColor:i,reflectedLight:r}=t,s=xe(eh.mul(lt(this.tangentWorld,0)).xyz),n=e,a=jv,o=xe(n.add(a)),l=Qt(mi(Zr(s,n)),0),u=Qt(mi(Zr(s,o)),0);r.directDiffuse.addAssign(i.mul(l).mul(this.diffuseIntensity).mul(Vo.rgb)),r.directSpecular.addAssign(i.mul(Lo(u,this.specularPower)).mul(this.specularIntensity).mul(G(1,.95,.9)))}indirect(t){let{irradiance:e,ambientOcclusion:i,reflectedLight:r}=t.context;r.indirectDiffuse.addAssign(e.mul(1/Math.PI).add(this.ambientFloor).mul(Vo.rgb)),r.indirectDiffuse.mulAssign(i)}},Iht=class extends bg{direct(t){let{lightDirection:e,lightColor:i,reflectedLight:r}=t,s=e,n=Oa,a=jv,o=xe(s.add(a)),l=kt(n,s).clamp(),u=kt(n,o).clamp();r.directDiffuse.addAssign(i.mul(l).mul(.85).mul(Vo.rgb)),r.directSpecular.addAssign(i.mul(Lo(u,60)).mul(.3).mul(G(.3,.28,.25)))}indirect(t){let{irradiance:e,ambientOcclusion:i,reflectedLight:r}=t.context;r.indirectDiffuse.addAssign(e.mul(1/Math.PI).add(.15).mul(Vo.rgb)),r.indirectDiffuse.mulAssign(i)}},$L=class extends Re{constructor(t){super(),this.model=t,this.lights=!0}setupLightingModel(){return this.model}},zd=new Se,Uy=new Se,aw=new P,ibt=class{constructor(){this.uNumStrands=Je(0,"int"),this.uNumVerts=Je(0,"int"),this.uDamping=Je(.03),this.uLocalStiffness=Je(.67),this.uGlobalStiffness=Je(.5),this.uGlobalRange=Je(.15),this.uStiffnessFalloff=Je(.1),this.uGravity=Je(0),this.uVspCoeff=Je(.01),this.uVspThreshold=Je(50),this.uKink=Je(0),this.uKinkFreq=Je(0),this.uUnitScale=Je(100),this.uClumpStrength=Je(0),this.uClumpSize=Je(32,"int"),this.uClumpTipScale=Je(1.5),this.uReset=Je(1),this.uHasWind=Je(0),this.uWind0=Je(new P),this.uWind1=Je(new P),this.uWind2=Je(new P),this.uWind3=Je(new P),this.uBoneQuat=Je(new Me(0,0,0,1)),this.uBoneTrans=Je(new P),this.uDeltaQuat=Je(new Me(0,0,0,1)),this.uPrevBoneTrans=Je(new P),this.uHairRoot=Je(new ae),this.uHairMid=Je(new ae),this.uHairTip=Je(new ae),this.uHeadColor=Je(new ae),this.uNoiseA=Je(new ae),this.uNoiseB=Je(new ae),this.uNoiseC=Je(new ae),this.uNoiseD=Je(new ae),this.uNoiseScale=Je(.018),this.uNoiseMixHair=Je(0),this.uNoiseMixHead=Je(0),this.uWidth=Je(.525),this.uSpecPow=Je(40),this.uSpecInt=Je(.4),this.uDiffInt=Je(.6),this.uAmbInt=Je(.25),this.uOpacity=Je(1),this.uTipFade=Je(.4),this.uColorSource=Je(0),this.uShadeRoot=Je(.6),this.uShadeTip=Je(1.15),this.uShadowTexelWorld=Je(0),this._armed=!1,this._uploadedGeneration=-1,this._prevBoneQuat=new Se,this._prevBonePos=new P,this._hasPrevBone=!1,this._renderer=null,this.initialPos=Qr(ic,"vec4"),this.rootColors=Qr(vv,"vec4"),this.positions=Qr(ic,"vec4"),this.positionsPrev=Qr(ic,"vec4"),this.positionsPrevPrev=Qr(ic,"vec4"),this.tangents=Qr(ic,"vec4"),this.restLengths=Qr(ic,"float"),this.vspQuats=Qr(vv,"vec4"),this.vspTrans=Qr(vv,"vec4"),this.kIntegrate=this._buildIntegrate(),this.kStrandLevel=this._buildStrandLevel(),this.kVsp=this._buildVsp(),this.kLocalShape=this._buildLocalShape(),this.kLengthWind=this._buildLengthWind(),this.kClump=this._buildClump(),this.kRigidFollow=this._buildRigidFollow(),this.ribbonMaterial=this._buildRibbonMaterial(),this.scalpMaterial=this._buildScalpMaterial()}boneQuatNode(){return this.uBoneQuat}boneTransNode(){return this.uBoneTrans}_buildIntegrate(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumVerts),()=>{yr()});let e=t.div(va).toVar(),i=t.sub(e.mul(va)).toVar(),r=this.boneQuatNode(),s=this.boneTransNode(),n=this.initialPos.element(t).toVar(),a=lt(Eh(r,n.xyz).add(s),n.w).toVar(),o=this.positions.element(t).toVar(),l=this.positionsPrev.element(t).toVar(),u=l.toVar();bt(this.uReset.greaterThan(.5),()=>{o.assign(a),u.assign(a)});let h=a.toVar();bt(o.w.greaterThan(0),()=>{let d=I(Gp),c=nD(this.uDamping.negate().mul(d).mul(60)),p=o.xyz.add(o.xyz.sub(u.xyz).mul(c)).add(G(0,-1,0).mul(this.uGravity).mul(d).mul(d));h.assign(lt(p,o.w))}),bt(this.uGlobalStiffness.greaterThan(0).and(this.uGlobalRange.greaterThan(0)).and(h.w.greaterThan(0)).and(i.toFloat().lessThan(this.uGlobalRange.mul(va))),()=>{let d=t.sub(i),c=this.initialPos.element(d),p=xe(Eh(r,c.xyz)).y.mul(.5).add(.5),m=this.uGlobalStiffness.mul(Lo(Qt(p,0),this.uStiffnessFalloff)),f=a.xyz.sub(h.xyz).mul(m);h.assign(lt(h.xyz.add(f),h.w))}),bt(this.uKink.greaterThan(0).and(h.w.greaterThan(0)),()=>{let d=i.toFloat().div(va),c=e.sub(e.div(256).mul(256)).toFloat().mul(.0245),p=d.mul(this.uKinkFreq).mul(6.2831853).add(c),m=this.uKink.mul(d).mul(.15).mul(this.uUnitScale),f=xe(a.xyz.sub(s)).toVar(),g=G(0).toVar();bt(Le(f.y).lessThan(.99),()=>{g.assign(xe(Zr(f,G(0,1,0))))}).Else(()=>{g.assign(xe(Zr(f,G(1,0,0))))});let y=xe(Zr(f,g)),v=g.mul(Bn(p)).mul(m).add(y.mul(Ka(p.mul(1.3).add(c))).mul(m).mul(.7));h.assign(lt(h.xyz.add(v),h.w))}),this.positionsPrevPrev.element(t).assign(l),this.positionsPrev.element(t).assign(o),this.positions.element(t).assign(h)})().compute(oo[0],oo)}_buildStrandLevel(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=t.mul(va).toVar(),i=this.positionsPrevPrev.element(e.add(1)),r=this.positionsPrev.element(e),s=this.positionsPrev.element(e.add(1)),n=this.positions.element(e),a=this.positions.element(e.add(1)),o=s.xyz.sub(r.xyz),l=a.xyz.sub(n.xyz),u=o.div(Qt(mi(o),1e-7)),h=l.div(Qt(mi(l),1e-7)),d=HL(u,h).toVar(),c=n.xyz.sub(Eh(d,r.xyz)),p=this.uVspCoeff.toVar(),m=mi(a.xyz.sub(s.xyz.mul(2)).add(i.xyz));bt(m.greaterThan(this.uVspThreshold),()=>{p.assign(1)}),this.vspQuats.element(t).assign(d),this.vspTrans.element(t).assign(lt(c,p))})().compute(oo[0],oo)}_buildVsp(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumVerts),()=>{yr()});let e=t.div(va).toVar(),i=t.sub(e.mul(va)).toVar();bt(i.lessThan(2),()=>{yr()});let r=this.vspQuats.element(e),s=this.vspTrans.element(e),n=s.w,a=this.positions.element(t).toVar(),o=this.positionsPrev.element(t).toVar(),l=u=>lt(u.xyz.mul(I(1).sub(n)).add(Eh(r,u.xyz).add(s.xyz).mul(n)),u.w);this.positions.element(t).assign(l(a)),this.positionsPrev.element(t).assign(l(o))})().compute(oo[0],oo)}_buildLocalShape(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=t.mul(va).toVar(),i=ii(this.uLocalStiffness,.95).mul(.5),r=this.boneQuatNode();Ji(Gl-1,({i:s})=>{let n=e.add(s).add(1).toVar(),a=this.positions.element(n).toVar(),o=this.positions.element(n.add(1)).toVar(),l=this.positions.element(n.sub(1)),u=Eh(r,this.initialPos.element(n).xyz),h=Eh(r,this.initialPos.element(n.add(1)).xyz),d=Eh(r,this.initialPos.element(n.sub(1)).xyz),c=a.xyz.sub(l.xyz),p=h.sub(u),m=u.sub(d),f=HL(m.div(Qt(mi(m),1e-7)),c.div(Qt(mi(c),1e-7))),g=Eh(f,p).add(a.xyz).sub(o.xyz).mul(i);bt(a.w.greaterThan(0),()=>{a.assign(lt(a.xyz.sub(g),a.w))}),bt(o.w.greaterThan(0),()=>{o.assign(lt(o.xyz.add(g),o.w))}),this.positions.element(n).assign(a),this.positions.element(n.add(1)).assign(o)})})().compute(oo[0],oo)}_buildLengthWind(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=t.mul(va).toVar();bt(this.uHasWind.greaterThan(.5),()=>{let i=t.sub(t.div(20).mul(20)).toFloat().div(20),r=this.uWind0.mul(i).add(this.uWind1.mul(I(1).sub(i))).add(this.uWind2.mul(i)).add(this.uWind3.mul(I(1).sub(i))).toVar();Ji(Gl-2,({i:s})=>{let n=e.add(s).add(2).toVar(),a=this.positions.element(n).toVar(),o=this.positions.element(n.add(1)),l=a.xyz.sub(o.xyz),u=Zr(Zr(l,r),l).negate();a.assign(lt(a.xyz.add(u.mul(Gp).mul(.1)),a.w)),this.positions.element(n).assign(a)})}),Ji(5,()=>{Ji(Gl,({i})=>{let r=e.add(i).toVar(),s=this.positions.element(r).toVar(),n=this.positions.element(r.add(1)).toVar(),a=this.restLengths.element(r),o=n.xyz.sub(s.xyz),l=Qt(mi(o),1e-7),u=I(1).sub(a.div(l)),h=o.mul(u),d=s.w.greaterThan(0),c=n.w.greaterThan(0),p=d.select(c.select(I(.5),I(1)),I(0)),m=c.select(d.select(I(.5),I(1)),I(0));s.assign(lt(s.xyz.add(h.mul(p)),s.w)),n.assign(lt(n.xyz.sub(h.mul(m)),n.w)),this.positions.element(r).assign(s),this.positions.element(r.add(1)).assign(n)})}),Ji(Gl,({i})=>{let r=e.add(i).add(1).toVar(),s=this.positions.element(r.sub(1)),n=this.positions.element(r).toVar(),a=n.xyz.sub(s.xyz),o=Qt(mi(a),1e-7),l=this.restLengths.element(r.sub(1));bt(o.greaterThan(l),()=>{n.assign(lt(s.xyz.add(a.div(o).mul(l)),n.w)),this.positions.element(r).assign(n)})}),Ji(va,({i})=>{let r=e.add(i).toVar(),s=i.equal(va-1).select(r.sub(1),r).toVar(),n=xe(this.positions.element(s.add(1)).xyz.sub(this.positions.element(s).xyz));this.tangents.element(r).assign(lt(n,0))})})().compute(oo[0],oo)}_buildClump(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=this.uClumpSize.toVar(),i=t.div(e).mul(e).toVar();bt(t.equal(i),()=>{yr()}),bt(i.greaterThanEqual(this.uNumStrands),()=>{yr()});let r=t.mul(va).toVar(),s=i.mul(va).toVar();Ji(Gl,({i:n})=>{let a=n.add(1).toVar(),o=a.toFloat().div(Gl),l=this.uClumpStrength.mul(Lo(o,I(1).div(Qt(this.uClumpTipScale,.5)))),u=r.add(a).toVar(),h=this.positions.element(u).toVar(),d=this.positions.element(s.add(a));h.assign(lt(Yt(h.xyz,d.xyz,l),h.w)),this.positions.element(u).assign(h)})})().compute(oo[0],oo)}_buildRigidFollow(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumVerts),()=>{yr()});let e=this.uDeltaQuat,i=this.uPrevBoneTrans,r=this.boneTransNode(),s=a=>{let o=a.element(t).toVar();o.assign(lt(Eh(e,o.xyz.sub(i)).add(r),o.w)),a.element(t).assign(o)};s(this.positions),s(this.positionsPrev),s(this.positionsPrevPrev);let n=this.tangents.element(t).toVar();n.assign(lt(Eh(e,n.xyz),0)),this.tangents.element(t).assign(n)})().compute(oo[0],oo)}pastelNoise(t){let e=t.sub(this.boneTransNode()).mul(this.uNoiseScale),i=mE(e).mul(.5).add(.5),r=mE(e.add(G(31.7,17.3,53.1))).mul(.5).add(.5),s=mE(e.mul(.7).add(G(71.9,11.2,43.8))).mul(.5).add(.5),n=Yt(this.uNoiseA,this.uNoiseB,i);return n=Yt(n,this.uNoiseC,r.mul(.6)),n=Yt(n,this.uNoiseD,s.mul(.25)),n}_buildRibbonMaterial(){let t=Lr("vec3","vHairTangent"),e=Lr("vec3","vHairNormal"),i=Lr("vec2","vHairUv"),r=Lr("float","vHairRand"),s=Lr("vec3","vHairInherit"),n=new $L(new Oht(t,this.uSpecPow,this.uSpecInt,this.uDiffInt,this.uAmbInt));n.name="SplineHairRibbons",n.userData.hairShadowVariant="texel-floor-v6",n.transparent=!1,n.depthTest=!0,n.depthWrite=!0,n.side=Rn;let a=l=>Et(()=>{let u=mt(Pn).toVar(),h=u.div(Gl).toVar(),d=u.sub(h.mul(Gl)).toVar(),c=h.mul(va).add(d).toVar(),p=mt(sS).toVar(),m=p.bitAnd(1).toFloat().toVar(),f=p.shiftRight(1).bitAnd(1).toFloat().toVar(),g=this.positions.element(c).xyz.toVar(),y=this.positions.element(c.add(1)).xyz.toVar(),v=this.tangents.element(c).xyz,b=this.tangents.element(c.add(1)).xyz,_=Yt(g,y,f).toVar(),x=Yt(v,b,f).toVar(),S=xe(Pc.sub(_)),w=Zr(x,S).toVar(),T=mi(w).toVar();w.assign(T.greaterThan(1e-7).select(w.div(T),G(1,0,0)));let C=d.toFloat().div(Gl),M=d.add(1).toFloat().div(Gl),A=Yt(C,M,f).toVar(),R=this.uWidth.mul(I(1).sub(A.mul(this.uTipFade))).toVar(),O=l?(()=>{let V=this.uShadowTexelWorld,H=V.greaterThan(0).select(V.mul(1.5).clamp(I(2),I(8)),I(0));return Qt(H.sub(R),0).toVar()})():null;O&&R.addAssign(O);let N=m.mul(2).sub(1),B=_.add(w.mul(R).mul(N)).toVar();O&&B.assign(B.sub(S.mul(O)));let L=this.positionsPrev.element(c).xyz,z=this.positionsPrev.element(c.add(1)).xyz;uD.assign(Yt(L,z,f).add(w.mul(R).mul(N)));let k=Oi(Bn(h.toFloat().mul(12.9898)).mul(43758.5453));return r.assign(k),s.assign(this.rootColors.element(h).xyz),t.assign(x),e.assign(xe(S.sub(x.mul(kt(x,S))))),i.assign(at(m,A)),B}),o=Et(()=>{let l=i.y,u=Yt(this.uHairRoot,this.uHairMid,ii(l.mul(2),1)),h=l.lessThan(.5).select(u,Yt(this.uHairMid,this.uHairTip,l.sub(.5).mul(2))).toVar(),d=s.mul(Yt(this.uShadeRoot,this.uShadeTip,l));h.assign(this.uColorSource.greaterThan(.5).select(d,h)),h.assign(Yt(h,this.pastelNoise(Go),this.uNoiseMixHair));let c=I(1).sub(Le(i.x.sub(.5)).mul(2));return I(1).sub(l.mul(this.uTipFade)).mul(Lo(Qt(c,0),.5)).toVar().lessThan(.25).discard(),r.greaterThanEqual(this.uOpacity).discard(),lt(h,1)});return n.positionNode=a(!1)(),n.castShadowPositionNode=a(!0)(),n.normalNode=e,n.colorNode=o(),n.needsUpdate=!0,n}_buildScalpMaterial(){let t=new $L(new Iht);t.name="SplineHairScalp";let e=Et(()=>{let i=Yt(this.uHeadColor,this.pastelNoise(Go),this.uNoiseMixHead);return lt(i,1)});return t.colorNode=e(),t.needsUpdate=!0,t}update(t,e){let i=e;if(i.backend?.isWebGPUBackend!==!0||(this._renderer=i,t.visible===!1))return;if(!this._armed){this._armed=!0;let o=t.ribbonMesh.material;t.ribbonMesh.material=this.ribbonMaterial,o.dispose?.();let l=t.scalpMesh.material;t.scalpMesh.material=this.scalpMaterial,l.dispose?.(),t.ribbonMesh.visible=!0}t.checkDataDrift();let r=t.activeGuideStrands,s=r*va;t.generation!==this._uploadedGeneration&&(this._uploadedGeneration=t.generation,this.initialPos.value.array.set(t.roots.initialPositions),this.initialPos.value.needsUpdate=!0,this.restLengths.value.array.set(t.roots.restLengths),this.restLengths.value.needsUpdate=!0,this.rootColors.value.array.set(t.roots.rootColors),this.rootColors.value.needsUpdate=!0,t.ribbonMesh.geometry.instanceCount=r*Gl,t.resetRequested=!0),this._syncUniforms(t),t.boneTransform(zd,aw),this.uBoneQuat.value.set(zd.x,zd.y,zd.z,zd.w),this.uBoneTrans.value.copy(aw);let n=this._hasPrevBone&&(Math.abs(this._prevBoneQuat.dot(zd))<.9999995||this._prevBonePos.distanceToSquared(aw)>1e-8),a=Math.floor(t.pendingSimSeconds/Gp);a>4&&(a=4),t.pendingSimSeconds=Math.max(0,Math.min(t.pendingSimSeconds-a*Gp,Gp)),t.resetRequested&&a<1&&(a=1),a<1&&n&&(Uy.copy(this._prevBoneQuat).invert().premultiply(zd),this.uDeltaQuat.value.set(Uy.x,Uy.y,Uy.z,Uy.w),this.uPrevBoneTrans.value.copy(this._prevBonePos),this._dispatch(i,this.kRigidFollow,s));for(let o=0;o<a;o++){this.uReset.value=t.resetRequested&&o===0?1:0,t.simTime+=Gp,this._updateWind(t),this._dispatch(i,this.kIntegrate,s),this._dispatch(i,this.kStrandLevel,r),this._dispatch(i,this.kVsp,s);for(let l=0;l<2;l++)this._dispatch(i,this.kLocalShape,r);this._dispatch(i,this.kLengthWind,r),t.data.clumpStrength>.001&&this._dispatch(i,this.kClump,r)}a>0&&(t.resetRequested=!1),this._prevBoneQuat.copy(zd),this._prevBonePos.copy(aw),this._hasPrevBone=!0}_dispatch(t,e,i){e.count=i,t.compute(e)}_updateWind(t){let e=t.data,i=Math.max(t.roots.unitScale,.001),r=e.windStrength/i;this.uHasWind.value=e.windStrength>.001?1:0;let s=.7*t.simTime,n=Math.sin(s)*r,a=Math.cos(s)*r*.5;this.uWind0.value.set(n,0,a),this.uWind1.value.set(.7*n,.5*r,1.2*a),this.uWind2.value.set(.3*-n,0,.5*a),this.uWind3.value.set(.5*n,-.3*r,.8*-a)}_shadowTexelWorld(t){let e=t;for(;e.parent;)e=e.parent;let i=e;if(!i?.traverse)return 0;let r=0;return i.traverse(s=>{let n=s;if(n.isDirectionalLight!==!0||n.castShadow!==!0||n.visible===!1)return;let a=n.shadow?.camera,o=n.shadow?.mapSize?.x??0;typeof a?.right!="number"||typeof a?.left!="number"||o<=0||(r=Math.max(r,(a.right-a.left)/o))}),r}_syncUniforms(t){let e=t.data,i=t.roots.unitScale;this.uNumStrands.value=t.activeGuideStrands,this.uNumVerts.value=t.activeGuideStrands*va,this.uDamping.value=e.damping,this.uLocalStiffness.value=e.localStiffness,this.uGlobalStiffness.value=e.globalStiffness,this.uGlobalRange.value=e.globalRange,this.uStiffnessFalloff.value=e.stiffnessFalloff,this.uGravity.value=e.gravity*i,this.uVspCoeff.value=e.vspCoefficient,this.uVspThreshold.value=.5*i,this.uKink.value=e.kink,this.uKinkFreq.value=e.kinkFrequency,this.uUnitScale.value=i,this.uClumpStrength.value=e.clumpStrength,this.uClumpSize.value=Math.max(1,Math.round(e.clumpSize)),this.uClumpTipScale.value=e.clumpTipScale;let r=(n,a)=>{n.value.setRGB(a.r,a.g,a.b,Ns)};r(this.uHairRoot,e.hairRootColor),r(this.uHairMid,e.hairMidColor),r(this.uHairTip,e.hairTipColor),r(this.uHeadColor,e.headColor),r(this.uNoiseA,e.noiseColorA),r(this.uNoiseB,e.noiseColorB),r(this.uNoiseC,e.noiseColorC),r(this.uNoiseD,e.noiseColorD);let s=e.noiseEnabled?1:0;this.uNoiseScale.value=e.noiseScale/Math.max(i,.001),this.uNoiseMixHair.value=e.noiseMixHair*s,this.uNoiseMixHead.value=e.noiseMixHead*s,this.uWidth.value=.003*e.hairWidth*Lh*t.widthWorldScale,this.uShadowTexelWorld.value=this._shadowTexelWorld(t),this.uColorSource.value=e.hairColorSource==="object"&&e.headShape==="object"&&e.baseObjectId?1:0,this.uShadeRoot.value=e.hairShadeRoot??.6,this.uShadeTip.value=e.hairShadeTip??1.15,this.uSpecPow.value=e.specularPower,this.uSpecInt.value=e.specularIntensity,this.uDiffInt.value=e.diffuseIntensity,this.uAmbInt.value=e.ambientIntensity,this.uOpacity.value=e.opacity,this.uTipFade.value=e.tipFade}dispose(){for(let e of[this.kIntegrate,this.kStrandLevel,this.kVsp,this.kLocalShape,this.kLengthWind,this.kClump,this.kRigidFollow])e.dispose();this.ribbonMaterial.dispose(),this.scalpMaterial.dispose();let t=this._renderer?.backend?.attributeUtils;if(t)for(let e of[this.initialPos,this.rootColors,this.positions,this.positionsPrev,this.positionsPrevPrev,this.tangents,this.restLengths,this.vspQuats,this.vspTrans])t.destroyAttribute(e.value);this._renderer=null}},S2=new WeakMap,hS=[]}),cEt=j(()=>{JG(),dEt(),ZG=t=>function(e){let i=S2.get(e);return i===void 0&&(i=new ibt,S2.set(e,i)),i}(t),function(t){QG=t}({release:t=>function(e){let i=S2.get(e);i!==void 0&&(S2.delete(e),hS.push(i))}(t),drainRetired:uEt})}),hbt=j(()=>{o5=`
|
|
1983
|
+
\u2014 last ${wv.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,wv.map(x=>({...x}))))}))}(this.backend.device);let s=this._skippedAsyncDraws??0;Ke.skippedAsyncDraws=s,this._skippedAsyncDraws=0,this._trackStalledSkips(s),this._trackGaugeStall(),function(y){if(J2.size===0)return;let v=Array.from(J2);J2.clear();for(let b of v)b.render(y)}(this);let n=t instanceof Ng?t.activePage:t,a=n.visible;n.visible=!0;let o=n.scene;if(alt(n),this.renderStarted=!0,wL&&t instanceof Ng){let y=t.updateInstanceGroups(n,SL);Ke.instancingGroups=y.instancingGroups,Ke.instancedDrawsSaved=y.instancedDrawsSaved,Ke.instancingRegroups=y.instancingRegroups,Ke.instancingParks=y.instancingParks,Ke.instancingIneligible=y.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(n,e)),this.normalizeCameraCoordinateSystem(e),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(n.bgColor,n.bgColor.a),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride);let l=gL?null:n.skyState;if(l?.enabled===!0){if(this.skyEnvironmentNeeded=!this.auxiliary&&(!eE&&(o.needsReflectionDirty||o.needsReflection())||!iE&&l.lighting===!0),this._skySystem===null){let y=OW;y===null?this._skyFeatureWarned||(this._skyFeatureWarned=!0,console.warn("[spline] scene uses the atmospheric sky, but the sky feature is compiled out of this build")):this._skySystem=y(this)}this._skySystem?.update(n,e)}else this._skySystem?.attached&&this._skySystem.detach();if(!this.auxiliary){let y=null,v=0;!iE&&l?.enabled===!0&&this._skySystem&&(y=this._skySystem.iblTexture??null,v=this._skySystem.iblRotationY??0),function(b){if(Gh.quality===b)return!1;Gh.quality=b;for(let _ of jS)nS(_)}(l?.lightingQuality==="low"?"low":"full"),function(b){if(Gh.texture===b)return!1;Gh.texture=b,Gh.version++;for(let _ of jS)nS(_)}(y),Gh.rotation.set(0,-v,0),n.environmentIntensity=l?.enabled===!0?l.lightingIntensity??1:1}{let y=Tp==="off"?null:n.gradingState,v=Tp!=="default"&&Tp!=="off",b=v||y?.pipeline==="linear",_=v?Tp==="linear"?"none":Tp:y?.toneMapping??"aces";this.toneMapping=b?_==="aces"?k7:_==="agx"?z7:_==="neutral"?L7:dl:dl,this.toneMappingExposure=b?y?.exposure??1:1,this.outputColorSpace=b?Ns:Xu,this.hdrChainActive=b,this.temporalAAEnabled&&this.taaHistory.setHdr(b)}Lt.pixelRatio.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Lt.resolution.value.set(this.resolution.x,this.resolution.y):Lt.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let u=(Lt.frameIndex.value+1)%16;Lt.frameIndex.value=u;let h=P1t[u];Lt.pcssHalton.value.set(h[0],h[1]),Lt.tapAngle.value=Math.random()*Math.PI*2,Lt.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(n),this.sceneBundlesEnabled&&this._lightShadowStateDirty&&(this._lightShadowStateDirty=!1,this._updateSceneBundle(n,e)),Lt.unjitteredProjection.value.copy(e.projectionMatrix);let d=this.temporalAAEnabled?this.taaHistory:null;if(d){let y=this.getDrawingBufferSize(jf);d.beginJitter(e,y.x,y.y)}this._renderShadowMaskPass(n,e),Lt.orthographicUniform.value=e.projectionMatrix.elements[11]===0?1:0;let c=o.shapeBlendIntances.length>0?eW:null;if(c!==null)for(let y of o.shapeBlendIntances)c(y).update(y,this,e);let p=o.hairInstances.length>0?ZG:null;if(p!==null)for(let y of o.hairInstances)p(y).update(y,this);o.needsTransmission()&&this._renderTransmissionPass(n,e),o.needsNormal()&&this._renderNormalPass(n,e,o.normalPassNeeds()),n.overrideMaterial=o.wireframeState?L0t:null,e.layers.enable(3),e.layers.enable(8),e.layers.enable(4);let m=n.data.ao,f=m.occlusion&&!cL&&!_R.enabled;if(Lt.aoEnabled.value=f,Lt.aoEnabledUniform.value=f?1:0,f){let y=this,v=y._skippedAsyncDraws??0;this._renderAOPass(n,e,m),(y._skippedAsyncDraws??0)>v&&(Lt.aoEnabledUniform.value=0)}if(!eE&&o.needsReflection()?(this._renderReflectionPass(n,e),yL?Lt.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(n,e),this._renderReflectionResolvePass(n,e)):Lt.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(n,e),this.pipeline.isUIOverlayEnabled&&n.uiCanvas?.enabled&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0){let y=this.getPixelRatio();(n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight||n.uiCanvas.dpr!==y)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},y),n.uiCanvas.render(this),this.pipeline.uiCanvasTexture=n.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=e;let g=function(y){if(!_R.enabled)return y;let v=N9.get(y);return v||(v={...y,bloom:{...y.bloom,kernelSize:0},depthOfField:{...y.depthOfField,enabled:!1}},N9.set(y,v)),v}(n.postprocessing);if(this.pipeline.postprocessingState!==g&&this.pipeline.updatePostprocessing(g),this.pipeline.render(),d?.endJitter(),this._skySystem?.endFrame?.(),Ke.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates){let y=(this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled,v=this.info.asyncCompilation?.promotions??0,b=v!==this._shadowSyncPromotions;this._shadowSyncPromotions=v,o.shadowsDirty=this._shadowMapMissingAtSync||this._warmupInFlight||y||b}e instanceof ks&&e.copyHistory(),n.visible=a}_fitDirectionalShadowRange(t,e,i){if(i===0)return;let r=t.shadow.camera,s=t.shadow;s.__speRangeEnvelope||(s.__speRangeEnvelope={near:r.near,far:r.far});let n=s.__speRangeEnvelope.near,a=t.data?.depth??s.__speRangeEnvelope.far;if(s.__speRangeEnvelope.far=a,Iy.setFromMatrixPosition(t.matrixWorld),t.target?(t.target.updateMatrixWorld(),JC.setFromMatrixPosition(t.target.matrixWorld)):JC.set(0,0,0),Gf.subVectors(JC,Iy),Gf.lengthSq()<1e-10)return;Gf.normalize();let o=1/0,l=-1/0;for(let c=0;c<i;c++){let p=4*c,m=(e[p]-Iy.x)*Gf.x+(e[p+1]-Iy.y)*Gf.y+(e[p+2]-Iy.z)*Gf.z,f=e[p+3];m-f<o&&(o=m-f),m+f>l&&(l=m+f)}let u=Math.max(10,.05*(l-o)),h=25*Math.floor((o-u)/25),d=25*Math.ceil((l+u)/25);h=Math.max(h,n),d=Math.min(d,a),d-h>=1&&(r.near!==h||r.far!==d)&&(r.near=h,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(t){let e=0;return t.traverseVisible(i=>{let r=i;if(r.castShadow!==!0&&r.receiveShadow!==!0)return;if(r.isHairSystem===!0){let l=r.shadowBoundsRadius??0;if(l>0){r.getShadowBoundsCenter?r.getShadowBoundsCenter(Tu):Tu.setFromMatrixPosition(r.matrixWorld);let u=4*e;Mu[u]=Tu.x,Mu[u+1]=Tu.y,Mu[u+2]=Tu.z,Mu[u+3]=l,e++}return}if(r.isMesh!==!0||!r.geometry||r.isInstanceGroup===!0)return;let s=r.geometry.boundingSphere;s===null&&(r.geometry.computeBoundingSphere(),s=r.geometry.boundingSphere);let n=r;if(n.isInstancedMesh===!0&&(n.boundingSphere===null&&n.computeBoundingSphere(),s=n.boundingSphere??s),!s||!Number.isFinite(s.radius)||s.radius<=0)return;Tu.copy(s.center).applyMatrix4(r.matrixWorld),Jx.setFromMatrixScale(r.matrixWorld);let a=s.radius*Math.max(Math.abs(Jx.x),Math.abs(Jx.y),Math.abs(Jx.z)),o=4*e;Mu[o]=Tu.x,Mu[o+1]=Tu.y,Mu[o+2]=Tu.z,Mu[o+3]=a,e++}),e}_syncLightState(t){let e=dv.isSoft(t.data.shadow);blt(e),Ke.shadowTypeSoft=e,function(d){switch(d){case"low":nc=8;break;case"high":nc=32;break;default:nc=16}}(t.data.shadow?.softShadowQuality),e&&A9()&&(fR||(this.initTexture?.(b9()),fR=!0));let i=-1;Ke.pcssLights=0,Ke.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,Ke.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,s=Lt.toonLightData.array,n=0,a=this.manageShadowUpdates,o=t.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1;let l=-2128831035,u=d=>{l^=0|d,l=Math.imul(l,16777619)};t.traverseVisible(d=>{let c=d;if(function(p){if(!p.isPointLight&&!p.isSpotLight&&!p.isDirectionalLight)return!1;if(_R.enabled){if(p.castShadow===!0)return p.castShadow=!1,xR.add(p),!0}else if(xR.has(p)&&(xR.delete(p),p.castShadow===!1))return p.castShadow=!0,!0;return!1}(c)&&(t.scene.shadowsDirty=!0),a&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.shadow&&(c.shadow.autoUpdate=o,o&&c.castShadow===!0&&c.shadow.map==null&&(this._shadowMapMissingAtSync=!0)),pL&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&(c.castShadow=!1),(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&(u(d.id),u(c.castShadow===!0?1:0),u(this._shadowMapId(c.shadow?.map))),c.isPointLight&&c.castShadow&&c.shadow&&(function(p){p.filterNode!==void 0&&p.filterNode!==null?p.filterNode!==e5&&Ke.pcssForeignFilter++:(p.filterNode=e5,Ke.pcssInstalled++)}(c.shadow),vlt(c.shadow),Ke.pcssLights++),(c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&c.shadow){c.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(t)),this._fitDirectionalShadowRange(c,Mu,i)),function(f){f.filterNode!==void 0&&f.filterNode!==null?f.filterNode!==t5&&Ke.pcssForeignFilter++:(Object.defineProperty(f,"penumbraSize",{get:()=>c.data?.penumbraSize??.5,configurable:!0}),f.filterNode=t5,Ke.pcssInstalled++)}(c.shadow);let p,m=!a||o||c.shadow.needsUpdate===!0;if(e&&A9()&&(m?function(f){let g=f;g.__spePcssPyramid&&(g.__spePcssPyramid.fresh=!1)}(c.shadow):ylt(c.shadow)||function(f,g){let y=g,v=y.map?.depthTexture??null;if(v==null)return!1;let b=glt(g);if(function(T){let C=glt(T);if(C.slot>=0)return C.slot;for(let M=0;M<Z4;M++){let A=mR[M];if(A===null||A.deref()===void 0)return mR[M]=new WeakRef(T),C.slot=M,M}return-1}(g)<0)return!1;let _=Math.max(1,Math.round(y.mapSize?.x??2048)),x=b.slot*Sc,S=`${v.uuid}:${_}`;b.passKey!==S&&(b.toMid?.material?.dispose(),b.toSmall?.material?.dispose(),b.mid===null&&(b.mid=v9(V1,V1),b.mid.texture.name="SplinePCSSPyramidMid"),b.small===null&&(b.small=v9(Sc,Sc),b.small.texture.name="SplinePCSSPyramidSmall"),b.toMid=new Pr(flt(`SplinePCSSPyramidToMid${_}`,v,Math.ceil(_/V1),_-1,!1,0)),b.toSmall=new Pr(flt("SplinePCSSPyramidToSmall",b.mid.texture,V1/Sc,V1-1,!0,0)),b.passKey=S),b9();let w=f.getRenderTarget();f.setRenderTarget(b.mid),b.toMid.render(f),f.setRenderTarget(b.small),b.toSmall.render(f),f.setRenderTarget(w),S9.set(x,0,0),f.copyTextureToTexture(b.small.texture,$g.texture,null,S9),b.fresh=!0,Ke.pcssPyramidBuilds++}(this,c.shadow),p={slot:aCt(c.shadow),fresh:ylt(c.shadow)}),e&&C9()&&(C1t(c.shadow,-1),this._maskLights.push({light:c,shadow:c.shadow}),(m||c.shadow.map==null)&&(this._maskBlocked=!0)),vlt(c.shadow,c.data?.penumbraSize??.5,p)&&Ke.pcssPyramidActive++,!r){r=!0;let f=c.shadow;Ke.pcssRadius0=f.radius??-1,Ke.pcssPenumbra0=f.penumbraSize??-1}Ke.pcssLights++}if(!(n>=r9)){if(c.isPointLight||c.isSpotLight)Ny.setFromMatrixPosition(c.matrixWorld),s[n].set(Ny.x,Ny.y,Ny.z,0),n++;else if(c.isDirectionalLight&&c.target){c.target.updateMatrixWorld();let p=Ny;p.setFromMatrixPosition(c.matrixWorld),p.sub(Nlt.setFromMatrixPosition(c.target.matrixWorld)).normalize(),s[n].set(p.x,p.y,p.z,1),n++}}}),Lt.toonLightCount.value=n;let h=this._lightShadowSignatures.get(t);this._lightShadowSignatures.set(t,l),this._lightShadowStateDirty=h!==void 0&&h!==l}_shadowMapId(t){if(t==null)return 0;let e=this._shadowMapIds.get(t);return e===void 0&&(e=++this._shadowMapIdSeq,this._shadowMapIds.set(t,e)),e}_renderShadowMaskPass(t,e){let i=0;if(C9()&&!this.suppressShadowMask&&this.manageShadowUpdates&&!this._maskBlocked&&this._maskLights.length>=1&&this._maskLights.length<=4&&this._maskLights.every(r=>r.shadow.map?.depthTexture!=null)){this._shadowMask??(this._shadowMask=new B1t);let{targetsChanged:r}=this._shadowMask.render(this,t,e,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}Lt.shadowMaskEnabled.value=i>0?1:0,Ke.shadowMaskActive=i}retireRenderTarget(t){t&&this._retiredGrabTargets.push(t),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let t of this._retiredGrabTargets)t.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let t of this._retiredGpuBuffers)try{t.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let t of this._liveBundledPages())this._bundleStates.get(t)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let t=this.backend,e=this._retiredGpuBuffers;t.destroyUniformBuffer=r=>{let s=t.get(r);s?.buffer&&e.push(s.buffer),t.delete(r),this._retireBundleRecords()};let i=t.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=s=>{let n=t.get(r(s));n?.buffer&&e.push(n.buffer),t.delete(s),this._retireBundleRecords()}}}_reallocGrabTarget(t,e,i,r){return t&&t.width===e&&t.height===i?t:(this.retireRenderTarget(t),r())}_withShadowUpdatesSuspended(t,e){let i=[];t.traverse(r=>{let s=r;if(s.isLight&&s.shadow){if(s.shadow.map==null)return;i.push({shadow:s.shadow,auto:s.shadow.autoUpdate,needs:s.shadow.needsUpdate}),s.shadow.autoUpdate=!1,s.shadow.needsUpdate=!1}});try{e()}finally{for(let r of i)r.shadow.autoUpdate=r.auto,r.shadow.needsUpdate=r.needs}}_renderPrepass(t,e){this._withShadowUpdatesSuspended(t,()=>{this.render(t,e)})}_renderAOPass(t,e,i){let r=this.getDrawingBufferSize(jf),s=Math.max(1,Math.round(r.x)),n=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,s,n,()=>new ri(s,n,{depthBuffer:!1})),Lt.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new b1t);let a=t;this._hbao.render(this,t,e,{radius:i.radius,bias:i.bias??.5,aoFullRes:i.aoFullRes===!0,aoColor:a.aoColor??{r:0,g:0,b:0},fogEnabled:(a.fog??null)!==null,fogNear:a.backupFog?.near??1,fogFar:a.backupFog?.far??1e3,fogMode:ia.getModeIndex({mode:t.fogMode}),fogDensity:t.fogDensity??ia.getDensity({}),fogHeightFalloff:t.fogHeightFalloff??ia.getHeightFalloff({}),fogHeightBase:t.fogHeightBase??ia.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(t,e,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",s=this.getDrawingBufferSize(jf),n=Math.max(1,Math.round(s.x)),a=Math.max(1,Math.round(s.y));this._normalTarget!==void 0&&this._normalTargetFlavor!==r&&(this.retireRenderTarget(this._normalTarget),this._normalTarget=void 0),this._normalTargetFlavor=r,this._normalTarget=this._reallocGrabTarget(this._normalTarget,n,a,()=>{let p=new ri(n,a,{count:r==="both"?2:1,type:r==="normals"?ai:Qe,depthTexture:new Xa(n,a)});r==="both"&&(p.textures[0].name="g0",p.textures[1].name="g1",p.textures[1].type=ai);for(let m of p.textures)m.minFilter=De,m.magFilter=De;return p});let o=this._encodeMaterials[r];if(o===void 0){this._depthContrastUniform??(this._depthContrastUniform=gt(1));let p=new Re;p.name=`SplineNormalPassEncode_${r}`;let m=vm("randomColor","vec3"),f=()=>{let y=xe(LS),v=sD.sub(.5).mul(this._depthContrastUniform).add(.5),b=Yt(Yt(m,y,.2),G(v),.4);return lt(b,m.x)},g=()=>{let y=xe(Oa),v=fi(Ayt,y,y.negate());return lt(v,m.x)};p.fragmentNode=r==="both"?Fv({g0:f(),g1:g()}):r==="normals"?g():f(),p.lights=!1,p.blending=cr,p.needsUpdate=!0,this._encodeMaterials[r]=p,o=p}this._depthContrastUniform.value=e instanceof ks?(e.far-e.near)/1e4:1;let l=t.overrideMaterial,u=this.getRenderTarget(),h=this.getClearColor(Olt),d=this.getClearAlpha();e.layers.enable(8),e.layers.disable(0),e.layers.disable(3),t.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(t,e),this.setRenderTarget(u),this.setClearColor(h,d),t.overrideMaterial=l,e.layers.enable(0),e.layers.enable(3);let c=this._normalTarget.textures;Lt.normalRenderTarget.value=r==="normals"?ko:c[0],Lt.normalRenderTargetDepth.value=this._normalTarget.depthTexture,Lt.normalViewRenderTarget.value=r==="both"?c[1]:r==="normals"?c[0]:ko}blitTextureToTarget(t,e){let i=this._uiBlitPass;if(!i){let n=ee(ko),a=new Re;a.name="SplineUICanvasBlit",a.fragmentNode=n.sample(bi()),a.lights=!1,a.blending=cr,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,i={quad:new Pr(a),input:n},this._uiBlitPass=i}let r=this.getRenderTarget(),s=this.getMRT();i.input.value=t,this.setMRT(null),this.setRenderTarget(e),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(s)}_getPrefilterPass(t){this._prefilterPasses||(this._prefilterPasses=[]);let e=this._prefilterPasses[t];if(e)return e;let i=ee(ko),r=gt(new Q(1,0)),s=new Re;s.name="SplineTransmissionPrefilter";let n=bi(),a=r,o=u=>i.sample(n.add(a.mul(u))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return s.fragmentNode=lt(l,1),s.lights=!1,s.blending=cr,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,e={quad:new Pr(s),input:i,step:r},this._prefilterPasses[t]=e,e}_getDownsamplePass(t){this._downsamplePasses||(this._downsamplePasses=[]);let e=this._downsamplePasses[t];return e||(e=this._buildDownsamplePassEntry(fL,"SplineTransmissionDownsample"),this._downsamplePasses[t]=e,e)}_buildDownsamplePassEntry(t,e){let i=ee(ko),r=gt(new Q(1,1)),s=new Re;s.name=e;let n=bi(),a=r,o=(u,h)=>i.sample(n.add(at(u,h).mul(a))).rgb,l=null;if(t==="k4")for(let u=-1;u<=1;u++)for(let h=-1;h<=1;h++){let d=(h===0?2:1)*(u===0?2:1)/16,c=o(h,u).mul(d);l=l?l.add(c):c}else{let u=[-1.5,-.5,.5,1.5],h=[.1665,.3335,.3335,.1665];for(let d=0;d<4;d++)for(let c=0;c<4;c++){let p=h[c]*h[d],m=o(u[c],u[d]).mul(p);l=l?l.add(m):m}}return s.fragmentNode=lt(l,1),s.lights=!1,s.blending=cr,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,{quad:new Pr(s),input:i,step:r}}_getPlanarDownsamplePass(t){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let e=this._planarDownsamplePasses[t];return e||(e=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[t]=e,e)}_batchedMipCopies(t){let e=this.backend,i=e?.device;if(!i||typeof e?.get!="function"){for(let n of t)this.copyTextureToTexture(n.src,n.dst,null,null,0,n.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),s=0;for(let n of t){let a=e.get(n.src)?.texture,o=e.get(n.dst)?.texture;a&&o?(r.copyTextureToTexture({texture:a,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:o,mipLevel:n.dstLevel,origin:{x:0,y:0,z:0}},{width:n.width,height:n.height,depthOrArrayLayers:1}),s++):this.copyTextureToTexture(n.src,n.dst,null,null,0,n.dstLevel)}s>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(t){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let e=this._reflectionDownsamplePasses[t];return e||(e=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[t]=e,e)}_renderTransmissionPass(t,e){let i=this.getDrawingBufferSize(jf),r=this.hdTransmission?1:2,s=Math.max(1,Math.round(i.x/r)),n=Math.max(1,Math.round(i.y/r)),a=this.backend?.isWebGPUBackend===!0?tE:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,s,n,()=>{let h=new ri(s,n,{depthBuffer:!0}),d=h.texture;return a==="off"?(d.generateMipmaps=!0,d.minFilter=ra):(d.generateMipmaps=!1,d.minFilter=me),d.magFilter=me,h});let o=[];t.traverse(h=>{let d=h;if(!(d.isMesh||d.isLine||d.isPoints||d.isSprite))return;let c=d.layers;c&&8&c.mask&&c.mask!==8&&(o.push({layers:c,mask:c.mask}),c.mask=8)});let l=this.getRenderTarget();e.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(t,e),this.setRenderTarget(l),e.layers.enable(3);for(let h of o)h.layers.mask=h.mask;let u=this._transmissionTarget.texture;if(a!=="off"){let h=(f,g)=>{let y=new ri(f,g,{depthBuffer:!1});return y.texture.generateMipmaps=!1,y.texture.minFilter=me,y.texture.magFilter=me,y};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,s,n,()=>h(s,n));let d=Math.floor(Math.log2(Math.max(s,n)))+1,c=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,s,n,()=>{let f=new ri(s,n,{depthBuffer:!1}),g=f.texture;return g.minFilter=ra,g.magFilter=me,a==="base"?g.generateMipmaps=!0:(g.generateMipmaps=!1,g.mipmaps=Array.from({length:d},(y,v)=>({width:Math.max(1,s>>v),height:Math.max(1,n>>v)}))),f}),a==="full"&&this._transmissionBlurTarget!==c&&this.initTexture(this._transmissionBlurTarget.texture);let p=this._getPrefilterPass(0);p.input.value=this._transmissionTarget.texture,p.step.value.set(1/s,0),this.setRenderTarget(this._transmissionBlurTmp),p.quad.render(this);let m=this._getPrefilterPass(1);if(m.input.value=this._transmissionBlurTmp.texture,m.step.value.set(0,1/n),a==="base")this.setRenderTarget(this._transmissionBlurTarget),m.quad.render(this);else{for(let f=0;f<d;f++)this._transmissionChain[f]=this._reallocGrabTarget(this._transmissionChain[f],Math.max(1,s>>f),Math.max(1,n>>f),()=>h(Math.max(1,s>>f),Math.max(1,n>>f)));for(let f=d;f<this._transmissionChain.length;f++)this._transmissionChain[f]?.dispose(),this._transmissionChain[f]=void 0;this._transmissionChain.length=d,this.setRenderTarget(this._transmissionChain[0]),m.quad.render(this);for(let f=1;f<d;f++){let g=this._transmissionChain[f-1],y=this._getDownsamplePass(f-1);y.input.value=g.texture,y.step.value.set(1/g.width,1/g.height),this.setRenderTarget(this._transmissionChain[f]),y.quad.render(this)}for(let f=0;f<d;f++)this.copyTextureToTexture(this._transmissionChain[f].texture,this._transmissionBlurTarget.texture,null,null,0,f)}this.setRenderTarget(l),u=this._transmissionBlurTarget.texture}Lt.transmissionRenderTarget.value=u,Lt.transmissionActualSize.value.set(s,n),Lt.aspectRatio.value=i.x>=i.y?Lt.aspectRatio.value.set(i.y/i.x,1):Lt.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(t,e,i){if(this._reflectionDepthPasses)for(let s of this._reflectionDepthPasses)s?.quad.material?.dispose();let r=[];{let s=new Re;s.name="SplineReflectionDepthBlit";let n=ee(this._reflectionTarget.depthTexture);s.fragmentNode=lt(G(n.sample(bi())),1),s.lights=!1,s.blending=cr,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,r.push({quad:new Pr(s)})}for(let s=1;s<i;s++){let n=Math.max(1,t>>s-1),a=Math.max(1,e>>s-1),o=new Re;o.name=`SplineReflectionDepthMin${s}`;let l=ee(this._reflectionDepthChain[s-1].texture),u=Ja,h=mt(u.x).mul(2),d=mt(u.y).mul(2),c=(y,v)=>l.load(Zn(h.add(y),d.add(v))).x,p=(y,v)=>ii(y,v),m=p(p(c(0,0),c(1,0)),p(c(1,1),c(0,1))),f=!!(1&n),g=!!(1&a);f&&(m=p(m,p(c(2,0),c(2,1)))),g&&(m=p(m,p(c(0,2),c(1,2)))),f&&g&&(m=p(m,c(2,2))),o.fragmentNode=lt(G(m),1),o.lights=!1,o.blending=cr,o.depthTest=!1,o.depthWrite=!1,o.needsUpdate=!0,r.push({quad:new Pr(o)})}this._reflectionDepthPasses=r}_renderReflectionPass(t,e){let i=this.getDrawingBufferSize(jf),r=1/0,s=0,n=0;t.traverse(x=>{let S=x;if(!(S.isMesh&&16&S.layers.mask))return;let w=this._reflectiveMeshCoverage(S,e,i.y),T=Array.isArray(S.material)?S.material:[S.material];for(let C of T){if(!C?.layers)continue;let M=tAt(C);!M||(r=Math.min(r,M.min*w.scale),s=Math.max(s,M.max*w.scale),M.max*w.scale>.45&&(n=Math.max(n,w.diameterPx)))}});let a=1;if(_L&&r!==1/0)for(r>=6?a=4:r>=2&&(a=2);a>1&&n>0&&n/a<128;)a>>=1;let o=Math.max(1,Math.round(i.x/a)),l=Math.max(1,Math.round(i.y/a)),u=Math.floor(Math.log2(Math.max(o,l)))+1,h=this.backend?.isWebGPUBackend===!0&&bL;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let x=new ri(o,l,{depthTexture:new Xa(o,l)});return h?(x.texture.generateMipmaps=!1,x.texture.minFilter=me):(x.texture.generateMipmaps=!0,x.texture.minFilter=ra),x.texture.magFilter=me,x});let d=(x,S)=>{let w=new ri(x,S,{depthBuffer:!1,type:Qe,format:Qa});return w.texture.generateMipmaps=!1,w.texture.minFilter=De,w.texture.magFilter=De,w},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let x=d(o,l);return x.texture.mipmaps=Array.from({length:u},(S,w)=>({width:Math.max(1,o>>w),height:Math.max(1,l>>w)})),x}),this._reflectionDepthPyramid!==c&&this.initTexture(this._reflectionDepthPyramid.texture);for(let x=0;x<u;x++)this._reflectionDepthChain[x]=this._reallocGrabTarget(this._reflectionDepthChain[x],Math.max(1,o>>x),Math.max(1,l>>x),()=>d(Math.max(1,o>>x),Math.max(1,l>>x)));for(let x=u;x<this._reflectionDepthChain.length;x++)this._reflectionDepthChain[x]?.dispose(),this._reflectionDepthChain[x]=void 0;this._reflectionDepthChain.length=u;let p=this.auxiliary||this._skySystem?.attached!==!0?null:this._skySystem.environmentTexture??null,m=Lt.reflectionEnvMap,f=p??ju;!this.auxiliary&&m.value!==f&&(m.value=f,this._grabTargetEpoch++),Lt.reflectionEnvEnabled.value=p!==null?1:0;let g=this.getClearColor(Ilt);Lt.reflectionMissColor.value.set(g.r,g.g,g.b);let y=[];t.traverse(x=>{let S=x;if(!(S.isMesh||S.isLine||S.isPoints||S.isSprite))return;let w=S.layers;w&&16&w.mask&&w.mask!==16&&(y.push({layers:w,mask:w.mask}),w.mask=16)});let v=this.getRenderTarget();e.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(t,e),e.layers.enable(4);for(let x of y)x.layers.mask=x.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,u),this._reflectionPassesKey=`${o}x${l}`);let b=this._reflectionDepthPasses;for(let x=0;x<u;x++)this.setRenderTarget(this._reflectionDepthChain[x]),b[x].quad.render(this);this._batchedMipCopies(Array.from({length:u},(x,S)=>({src:this._reflectionDepthChain[S].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:S,width:Math.max(1,o>>S),height:Math.max(1,l>>S)})));let _=this._reflectionTarget.texture;if(h){let x=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let T=new ri(o,l,{depthBuffer:!1}),C=T.texture;return C.minFilter=ra,C.magFilter=me,C.generateMipmaps=!1,C.mipmaps=Array.from({length:u},(M,A)=>({width:Math.max(1,o>>A),height:Math.max(1,l>>A)})),T}),this._reflectionColorPyramid!==x&&this.initTexture(this._reflectionColorPyramid.texture);let S=s>0?u:1,w=(T,C)=>{let M=new ri(T,C,{depthBuffer:!1});return M.texture.generateMipmaps=!1,M.texture.minFilter=me,M.texture.magFilter=me,M};for(let T=1;T<S;T++)this._reflectionColorChain[T]=this._reallocGrabTarget(this._reflectionColorChain[T],Math.max(1,o>>T),Math.max(1,l>>T),()=>w(Math.max(1,o>>T),Math.max(1,l>>T)));for(let T=S;T<this._reflectionColorChain.length;T++)this._reflectionColorChain[T]?.dispose(),this._reflectionColorChain[T]=void 0;this._reflectionColorChain.length=S;for(let T=1;T<S;T++){let C=T===1?this._reflectionTarget:this._reflectionColorChain[T-1],M=this._getReflectionDownsamplePass(T-1);M.input.value=C.texture,M.step.value.set(1/C.width,1/C.height),this.setRenderTarget(this._reflectionColorChain[T]),M.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:S-1},(T,C)=>({src:this._reflectionColorChain[C+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:C+1,width:Math.max(1,o>>C+1),height:Math.max(1,l>>C+1)}))]),_=this._reflectionColorPyramid.texture}this.setRenderTarget(v),Lt.reflectionRenderTarget.value=_,Lt.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,Lt.reflectionDepthSize.value.set(o,l),Lt.reflectionDepthLevels.value=u,this._reflectionGrabInfo={div:a,w:o,h:l,minBlur:r,maxBlur:s}}_reflectiveMeshCoverage(t,e,i){let r=t.geometry;if(!r)return{diameterPx:i,scale:1};r.boundingSphere===null&&r.computeBoundingSphere();let s=r.boundingSphere;if(!s)return{diameterPx:i,scale:1};let n=t.matrixWorld.elements,a=Math.sqrt(Math.max(n[0]*n[0]+n[1]*n[1]+n[2]*n[2],n[4]*n[4]+n[5]*n[5]+n[6]*n[6],n[8]*n[8]+n[9]*n[9]+n[10]*n[10])),o=s.radius*a;hL.copy(s.center).applyMatrix4(t.matrixWorld);let l=e.projectionMatrix.elements[5]*i/2,u=1;e.isPerspectiveCamera===!0&&(uL.setFromMatrixPosition(e.matrixWorld),u=Math.max(hL.distanceTo(uL),e.near??.1));let h=2*o*l/u;return{diameterPx:h,scale:Math.min(1,h/(.66*i))}}_renderReflectionResolvePass(t,e){let i=this._reflectionGrabInfo,r=this.backend?.isWebGPUBackend===!0&&xL&&i!==void 0&&i.maxBlur>.45;if(r){let _=!0;t.traverse(x=>{let S=x;if(!(S.isMesh&&16&S.layers.mask))return;let w=Array.isArray(S.material)?S.material:[S.material],T=null;for(let C of w)if(C?.layers&&(T=eAt(C),T!==null))break;T!=="variable"?T!==null?(S.userData.__srMode=T.blur>.45?1+T.tracingMode:0,S.userData.__srBlur=T.blur*this._reflectiveMeshCoverage(S,e,this.getDrawingBufferSize(Vlt).y).scale,S.userData.__srThickness=T.thickness,S.userData.__srStepSize=T.stepSize,S.userData.__srSteps=T.steps):S.userData.__srMode=0:_=!1}),r=_}let s=r?i.w:4,n=r?i.h:4,a=(_,x)=>()=>{let S=new ri(_,x,{type:ai,depthBuffer:!1});return S.texture.generateMipmaps=!1,S.texture.minFilter=me,S.texture.magFilter=me,S};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,s,n,a(s,n)),Lt.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(Lt.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let _=new ri(o,l,{count:2,type:ai,depthTexture:new Xa(o,l)});for(let x of _.textures)x.generateMipmaps=!1,x.minFilter=De,x.magFilter=De;return _.textures[0].name="g0",_.textures[1].name="g1",_}),this._reflectionResolveMarchTarget=this._reallocGrabTarget(this._reflectionResolveMarchTarget,o,l,a(o,l)),this._reflectionResolveBlurTmp=this._reallocGrabTarget(this._reflectionResolveBlurTmp,o,l,a(o,l)),!this._reflectionGBufferMaterial){let _=new Re;_.name="SplineReflectionGBuffer";let x=Hp("__splinePlanarMirror","float"),S=Lt.reflectionPlanarEnabled.greaterThan(.5),w=Hp("__srMode","float"),T=fi(x.greaterThan(.5).and(S),I(0),w);_.fragmentNode=Fv({g0:lt(xe(Oa),T),g1:lt(Hp("__srBlur","float"),Hp("__srThickness","float"),Hp("__srStepSize","float"),Hp("__srSteps","float"))}),_.lights=!1,_.blending=cr,_.needsUpdate=!0,this._reflectionGBufferMaterial=_}let u=this._skippedAsyncDraws??0,h=t.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(Blt),p=this.getClearAlpha(),m=e.layers.mask;t.overrideMaterial=this._reflectionGBufferMaterial,e.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(t,e),t.overrideMaterial=h,e.layers.mask=m,this.setClearColor(c,p);let f=Lt.reflectionRenderTarget.value,g=Lt.reflectionEnvMap.value,y=this._reflectionGBufferTarget,v=`${o}x${l}|${y.textures[0].uuid}|${f.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${g.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;v!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(f,g,o,l),this._reflectionResolveMarchKey=v);let b=this._reflectionResolveMarch;b.proj.value.copy(e.projectionMatrix),b.projInv.value.copy(e.projectionMatrix).invert(),b.camWorld.value.copy(e.matrixWorld),b.near.value=e.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),b.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),Lt.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>u&&(Lt.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(t,e,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let s=gt(new _t),n=gt(new _t),a=gt(new _t),o=gt(.1),l=this._reflectionGBufferTarget,u=ee(l.textures[0]),h=ee(l.textures[1]),d=ee(l.depthTexture),c=ee(t),p=ee(this._reflectionDepthPyramid.texture),m=ee(e),f=new Re;f.name="SplineReflectionResolve";let g=Et(()=>{let _=Ja,x=Zn(mt(_.x),mt(_.y)),S=bi(),w=u.load(x).toVar(),T=d.sample(S).toVar(),C=lt(0).toVar(),M=I(0).toVar();return bt(w.w.greaterThan(.5),()=>{let A=h.load(x).toVar(),R=ug(n,S.x,S.y,T),O=PW({dials:{blur:A.x,thickness:A.y,stepSize:A.z,steps:mt(A.w),tracingMode:w.w.sub(1)},surface:{originView:R,normalV:xe(w.xyz),screenUv:S,fragWindowZ:T},camera:{projectionMatrix:s,projectionMatrixInverse:n,worldMatrix:a,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:m},usePlanar:fyt(!1),noisePixel:at(x),singleRay:{footprintOut:M}});C.assign(lt(O,M.add(1)))}),C});f.fragmentNode=g(),f.lights=!1,f.blending=cr,f.depthTest=!1,f.depthWrite=!1,f.needsUpdate=!0,this._reflectionResolveMarch={quad:new Pr(f),proj:s,projInv:n,camWorld:a,near:o};let y=ee(this._reflectionResolveMarchTarget.texture),v=ee(this._reflectionResolveBlurTmp.texture),b=_=>{let x=new Re;x.name=`SplineReflectionResolveBlur${_.toUpperCase()}`;let S=_==="x"?y:v,w=_==="x"?1/i:1/r,T=Et(()=>{let C=bi(),M=y.sample(C).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),A=lt(0).toVar(),R=0;for(let O=-6;O<=6;O++){let N=Math.exp(O/3*-.5*(O/3));R+=N;let B=_==="x"?at(M.mul(O/6*w),0):at(0,M.mul(O/6*w)),L=S.sample(C.add(B)).toVar(),z=_==="x"?L.w.min(1):L.w;A.addAssign(lt(L.rgb,z).mul(N))}return A.div(R)});return x.fragmentNode=T(),x.lights=!1,x.blending=cr,x.depthTest=!1,x.depthWrite=!1,x.needsUpdate=!0,new Pr(x)};this._reflectionResolveBlur={h:b("x"),v:b("y")}}_renderPlanarReflectionPass(t,e){let i=null;if(t.traverse(m=>{let f=m;if(!(f.isMesh&&16&f.layers.mask&&(f.userData.__splinePlanarMirror=0,(Array.isArray(f.material)?f.material:[f.material]).some(A=>A?.layers&&A.getLayersOfType("reflection").some(R=>R.data.visible&&R.data.mirror===1)))))return;let g=f.geometry;if(!g)return;g.boundingBox===null&&g.computeBoundingBox();let y,v,b=g.boundingBox,_=b.max.x-b.min.x,x=b.max.y-b.min.y,S=b.max.z-b.min.z,w=f.matrixWorld.elements,T=Math.hypot(w[0],w[1],w[2]),C=Math.hypot(w[4],w[5],w[6]),M=Math.hypot(w[8],w[9],w[10]);_<=x&&_<=S?(y=klt,v=x*C*(S*M)):x<=_&&x<=S?(y=zlt,v=_*T*(S*M)):(y=Llt,v=_*T*(x*C)),(!i||v>i.area)&&(i={mesh:f,normalAxis:y,area:v})}),!i)return void(Lt.reflectionPlanarEnabled.value=0);let r=i.mesh,s=i.mesh.matrixWorld;if(Vd.copy(i.normalAxis).transformDirection(s),wp.setFromMatrixPosition(s),Zx.setFromMatrixPosition(e.matrixWorld),Sp.subVectors(wp,Zx),Sp.dot(Vd)>0&&Vd.negate(),Sp.dot(Vd)>0)return void(Lt.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==e.type)&&(this._planarVirtualCamera=e.clone());let n=this._planarVirtualCamera;if(Sp.subVectors(wp,Zx),Sp.reflect(Vd).negate(),Sp.add(wp),QC.extractRotation(e.matrixWorld),dL.set(0,0,-1).applyMatrix4(QC).add(Zx),Qx.subVectors(wp,dL),Qx.reflect(Vd).negate(),Qx.add(wp),n.position.copy(Sp),n.up.set(0,1,0).applyMatrix4(QC),n.up.reflect(Vd),n.lookAt(Qx),n.updateMatrixWorld(),n.projectionMatrix.copy(e.projectionMatrix),n.projectionMatrixInverse.copy(n.projectionMatrix).invert(),e.isPerspectiveCamera===!0){Uf.setFromNormalAndCoplanarPoint(Vd,wp),Uf.applyMatrix4(n.matrixWorldInverse),Su.set(Uf.normal.x,Uf.normal.y,Uf.normal.z,Uf.constant);let m=n.projectionMatrix.elements;Oy.x=(Math.sign(Su.x)+m[8])/m[0],Oy.y=(Math.sign(Su.y)+m[9])/m[5],Oy.z=-1,Oy.w=(1+m[10])/m[14],Su.multiplyScalar(1/Su.dot(Oy)),m[2]=Su.x,m[6]=Su.y,m[10]=Su.z,m[14]=Su.w}let a=this.getDrawingBufferSize(Flt),o=Math.max(1,Math.round(a.x)),l=Math.max(1,Math.round(a.y)),u=this.backend?.isWebGPUBackend===!0&&vL;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let m=new ri(o,l);return u?(m.texture.generateMipmaps=!1,m.texture.minFilter=me):(m.texture.generateMipmaps=!0,m.texture.minFilter=ra),m.texture.magFilter=me,m});let h=[];t.traverse(m=>{let f=m;if(!(f.isMesh||f.isLine||f.isPoints||f.isSprite))return;let g=f.layers;g&&16&g.mask&&g.mask!==16&&(h.push({layers:g,mask:g.mask}),g.mask=16)}),n.layers.mask=-17&e.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(t,n),this.setRenderTarget(d);for(let m of h)m.layers.mask=m.mask;let c=this._planarTarget.texture;if(u){let m=Math.floor(Math.log2(Math.max(o,l)))+1,f=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let y=new ri(o,l,{depthBuffer:!1}),v=y.texture;return v.minFilter=ra,v.magFilter=me,v.generateMipmaps=!1,v.mipmaps=Array.from({length:m},(b,_)=>({width:Math.max(1,o>>_),height:Math.max(1,l>>_)})),y}),this._planarPyramid!==f&&this.initTexture(this._planarPyramid.texture);let g=(y,v)=>{let b=new ri(y,v,{depthBuffer:!1});return b.texture.generateMipmaps=!1,b.texture.minFilter=me,b.texture.magFilter=me,b};for(let y=1;y<m;y++)this._planarChain[y]=this._reallocGrabTarget(this._planarChain[y],Math.max(1,o>>y),Math.max(1,l>>y),()=>g(Math.max(1,o>>y),Math.max(1,l>>y)));for(let y=m;y<this._planarChain.length;y++)this._planarChain[y]?.dispose(),this._planarChain[y]=void 0;this._planarChain.length=m;for(let y=1;y<m;y++){let v=y===1?this._planarTarget:this._planarChain[y-1],b=this._getPlanarDownsamplePass(y-1);b.input.value=v.texture,b.step.value.set(1/v.width,1/v.height),this.setRenderTarget(this._planarChain[y]),b.quad.render(this)}this.setRenderTarget(d),this._batchedMipCopies([{src:this._planarTarget.texture,dst:this._planarPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:m-1},(y,v)=>({src:this._planarChain[v+1].texture,dst:this._planarPyramid.texture,dstLevel:v+1,width:Math.max(1,o>>v+1),height:Math.max(1,l>>v+1)}))]),c=this._planarPyramid.texture}let p=Lt.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),Lt.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(t,e,i){let r=this.getDrawingBufferSize(jf),s=Math.max(1,Math.round(r.x)),n=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,s,n,()=>new ri(s,n,{depthBuffer:!0}));let a=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget);try{this.renderSplineScene(t,e)}finally{this.setRenderTarget(a)}this.pipeline.sceneTransitionFromTexture=this._transitionCaptureTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i;let o=this.pipeline.sceneTransitionPass.uniforms;o.uDPR.value=this.getPixelRatio(),o.uResolution.value.set(r.x,r.y).divideScalar(this.getPixelRatio())}async captureFrame(t,{includeHelpers:e=!1,settleFrames:i=0}={}){if(this.xr?.isPresenting===!0)return null;let r=this._frameSerial,s=this.getRenderTarget(),n=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled,o=this.suppressShadowMask;this.suppressShadowMask=!0,e||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{for(let g=0;g<i;g++)t(),await _Ct();t()}finally{this.suppressShadowMask=o,this.pipeline.renderToScreen=n,this.setRenderTarget(s),a&&this.pipeline.enableHelpers()}if(this._frameSerial===r||this.lastFrameIncomplete)return null;let l=this.pipeline.lastOutputTarget;if(!l||!this.backend.get(l.textures[0])?.textureDescriptorGPU)return null;let u=l.width,h=l.height,d=this,c=new Uint8Array(u*h*4),p=4*u,m=256*Math.ceil(p/256),f=Math.max(1,Math.min(h,Math.floor((1<<20)/m)));for(let g=0;g<h;g+=f){let y=Math.min(f,h-g),v=await d.readRenderTargetPixelsAsync(l,0,g,u,y);if(m===p)c.set(v.subarray(0,y*p),g*p);else for(let b=0;b<y;b++){let _=b*m;c.set(v.subarray(_,_+p),(g+b)*p)}}return{pixels:c,width:u,height:h}}_applyCIOffscreenTargetIfRequested(){if(globalThis.__SPLINE_RENDER_OFFSCREEN__!==!0)return;let t=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),e=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==t||this._ciOffscreenTarget.height!==e)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new ri(t,e,{depthBuffer:!0})):(this._ciOffscreenTarget=new ri(t,e,{depthBuffer:!0}),globalThis.__splineReadOffscreenPixels=async()=>{let i=this._ciOffscreenTarget,r=await this.readRenderTargetPixelsAsync(i,0,0,i.width,i.height);return{width:i.width,height:i.height,pixels:Array.from(r)}}),this.getRenderTarget()===null&&this.setRenderTarget(this._ciOffscreenTarget)}dispose(){this._disposeRetiredGrabTargets(),this._disposeWarmupTargets(),gj()?.drainRetired(),vj()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let t of Sv){let e=t.deref();e!==void 0&&(e.mid?.dispose(),e.mid=null,e.small?.dispose(),e.small=null,e.toMid?.material?.dispose(),e.toSmall?.material?.dispose(),e.toMid=null,e.toSmall=null,e.passKey="",e.fresh=!1,e.slot=-1)}Sv.clear(),mR.fill(null),$g?.dispose(),$g=null,fR=!1}(),this._aoRenderTarget?.dispose(),this._aoRenderTarget=void 0,this._normalTarget?.dispose(),this._normalTarget=void 0,this._ciOffscreenTarget?.dispose(),this._ciOffscreenTarget=void 0,this._transitionCaptureTarget?.dispose(),this._transitionCaptureTarget=void 0,this._transmissionTarget?.dispose(),this._transmissionTarget=void 0,this._transmissionBlurTmp?.dispose(),this._transmissionBlurTmp=void 0,this._transmissionBlurTarget?.dispose(),this._transmissionBlurTarget=void 0;for(let t of this._transmissionChain)t?.dispose();this._transmissionChain.length=0,this._reflectionTarget?.depthTexture?.dispose(),this._reflectionTarget?.dispose(),this._reflectionTarget=void 0,this._reflectionColorPyramid?.dispose(),this._reflectionColorPyramid=void 0;for(let t of this._reflectionColorChain)t?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let t of this._reflectionDownsamplePasses)t?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let t of this._planarChain)t?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let t of this._planarDownsamplePasses)t?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let t of this._reflectionDepthChain)t?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let t of this._reflectionDepthPasses)t?.quad.material?.dispose();this._reflectionDepthPasses=void 0}if(this._reflectionPassesKey="",this._reflectionGBufferTarget?.depthTexture?.dispose(),this._reflectionGBufferTarget?.dispose(),this._reflectionGBufferTarget=void 0,this._reflectionResolveMarchTarget?.dispose(),this._reflectionResolveMarchTarget=void 0,this._reflectionResolveBlurTmp?.dispose(),this._reflectionResolveBlurTmp=void 0,this._reflectionResolveTarget?.dispose(),this._reflectionResolveTarget=void 0,this._reflectionGBufferMaterial?.dispose(),this._reflectionGBufferMaterial=void 0,this._reflectionResolveMarch&&(this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveMarch=void 0),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose(),this._reflectionResolveBlur=void 0),this._reflectionResolveMarchKey="",this._reflectionGrabInfo=void 0,this._prefilterPasses){for(let t of this._prefilterPasses)t?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let t of this._downsamplePasses)t?.quad.material?.dispose();this._downsamplePasses=void 0}this._uiBlitPass&&(this._uiBlitPass.quad.material.dispose(),this._uiBlitPass=void 0),this._helperOverlay?.dispose(),this._helperOverlay=void 0,function(){for(let t of gR)t.deref()?.dispose();gR.clear(),yR++}(),function(){for(let t of g2){let e=t.deref();e!==void 0&&(e.sprite.removeFromParent(),e.material.dispose())}g2.clear(),z1++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let t of Object.values(this._encodeMaterials))t?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),Lt.transmissionRenderTarget.value=ko,Lt.normalRenderTarget.value=ko,Lt.aoRenderTarget.value=ko,Lt.reflectionRenderTarget.value=ju,Lt.reflectionDepthPyramid.value=ju,Lt.reflectionEnvMap.value=ju,Lt.reflectionPlanarTarget.value=ju,Lt.reflectionPlanarEnabled.value=0,Lt.reflectionResolveTarget.value=s9,Lt.reflectionResolveEnabled.value=0}})._GAUGE_STALL_MS=3e3});function xCt(t){return{type:t.type}}function ao(t,e){let{alpha:i,mode:r,isMask:s}=t,n=typeof i=="string"?Number(e.getVariable(i)??100)/100:i;return{...xCt(t),alpha:n,mode:r,isMask:s}}var wCt=j(()=>{dt(),qG(),Jv()});function By(t){let e=t;return e!=null&&e.isInstancedMesh===!0&&e.instanceMatrix!=null&&e.instanceMatrix.isInstancedBufferAttribute===!0}function rE(t){return Wh(Wh(lD).mul(function(e){let i=e.spInstanceMatrixNode;if(i!==void 0)return Wh(i);let r=e.object,s=r.instanceMatrix,n=Math.max(r.count??1,1);if(s.isStorageInstancedBufferAttribute===!0)return Wh(s5(s1t(s,"mat4",n),Pn));if(16*n*4<=e.getUniformBufferLimit())return Wh(s5(gyt(s.array,"mat4",n),Pn));let a=B9.get(s);a===void 0&&(a=new X7(s.array,16,1),B9.set(s,a));let o=s.usage===Yh?Cyt:Wp;return Wh(wW(o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)))}(t)))}var Wh,s5,B9,Za,hT,Q1t,J1t=j(()=>{dt(),He(),Wh=t=>t,s5=(t,e)=>t.element(e),B9=new WeakMap,Za=Et(t=>By(t.object)?hD:Uv).once()().toVar("speObjectPosition"),hT=Et(t=>t.material?.shapeBlendObjectNormal||(By(t.object)?t.geometry.hasAttribute("normal")?jyt:G(0,1,0):SW)).once()().toVar("speObjectNormal"),Wh(Et(t=>Wh(By(t.object)?rE(t):lD)).once()()),Q1t=Et(t=>{if(!By(t.object))return kyt;let e=rE(t),i=r=>s5(e,r).xyz;return G(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),Et(t=>By(t.object)?mm(rE(t)).inverse().transpose():Vyt).once()(),Wh(Et(t=>Wh(By(t.object)?rE(t).inverse():Lyt)).once()())});function BW(t){if(GS.has(t))return;let e={own:t.value,render:t.value};GS.set(t,e),Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get:()=>e.render,set:i=>{e.render=i,e.own=i}})}function V9(t){let e=GS.get(t);return e!==void 0?e.own:t.value}function VW(t,e){let i=GS.get(t);i!==void 0?i.render=e:t.value=e}var GS,kW,tvt=j(()=>{GS=new WeakMap}),SCt=j(()=>{tvt(),kW=class{constructor(t){this.layerId=t,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(t,e,i){return this.byName.set(t,e),this.uniforms[`f${this.layerId}_${t}`]=e,i!==void 0&&this.liveValues.set(t,i),this}has(t){return this.byName.has(t)}names(){return[...this.byName.keys()]}get(t){let e=this.byName.get(t);if(e===void 0)throw new Error(`TSLLayerParams: unknown param "${t}" (layer f${this.layerId})`);return e}getFloat(t){return this.get(t)}getInt(t){return this.get(t)}getBool(t){return this.get(t)}getVec2(t){return this.get(t)}getVec3(t){return this.get(t)}getVec4(t){return this.get(t)}getColor(t){return this.get(t)}getValue(t){if(this.liveValues.has(t))return this.liveValues.get(t);let e=this.byName.get(t);return e===void 0?void 0:V9(e)}getLiveValue(t){return this.liveValues.get(t)}getNodeValue(t){let e=this.byName.get(t);return e===void 0?void 0:V9(e)}setValue(t,e){let i=this.byName.get(t);i===void 0||e===void 0||(this.liveValues.has(t)&&this.liveValues.set(t,e),i.value=e)}}});function Ju(t,e,i){let r=I(t).toVar(),s=I(Yt(r.div(Ae(r.add(e.accumAlpha),I(1e-5),I(1))),r,i)).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(r).mul(Rr(i))),s}function sb(t,e){let i=I(t).toVar(),r=I(i.div(Ae(i.add(e.accumAlpha),I(1e-5),I(1)))).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(i)),r}function wR(t,e,i,r){return ivt({a:t,b:e,alpha:i,mode:r})}function Vn(t,e){cD.set(t,e)}function evt(t){let e=cD.get(t);return e!==void 0?e:(U9.has(t)||(U9.add(t),console.warn(`[spe] Material layer type "${t}" is not available in this runtime build (no WebGPU port, or compiled out) \u2014 rendering flat red.`)),zW)}function TCt(t){return cD.has(t)}var k9,z9,L9,F9,ivt,cD,U9,zW,cn=j(()=>{He(),J1t(),SCt(),tvt(),k9=0,z9=1,L9=2,F9=3,ivt=Et(t=>{let e=t.a.toVar(),i=t.b.toVar(),r=t.alpha.toVar(),s=t.mode,n=G(1).toVar();return bt(s.equal(mt(k9)),()=>{n.assign(Yt(e,i,r))}).ElseIf(s.equal(mt(z9)),()=>{n.assign(Yt(e,e.mul(i),r))}).ElseIf(s.equal(mt(L9)),()=>{n.assign(Yt(e,Rr(Rr(e).mul(Rr(i))),r))}).ElseIf(s.equal(mt(F9)),()=>{let a=Ai(e,G(.5)),o=Yt(Rr(Rr(e).mul(Rr(i)).mul(2)),e.mul(i).mul(2),a);n.assign(Yt(e,o,r).clamp(0,1))}),n}),cD=new Map,U9=new Set,zW=(t,e,i)=>{let r=e.alpha.mul(e.mask);return{color:G(1,0,0),calpha:sb(r,i)}}});function rvt(t){let e=co(Lt.aoRenderTarget.sample(Jl).rgb),i=Wv(Lt.aoEnabledUniform);return t!==null&&(i=Wv(i.mul(fi(t,I(1),I(0))))),co(Yt(G(1),e,i))}var j9,G9,co,Wv,jlt,Glt,svt,nvt,avt=j(()=>{var t;mr(),He(),dn(),cn(),{diffuseContribution:j9,specularColorBlended:G9}=D,co=e=>e,Wv=e=>e,jlt=Et(e=>{let i=Oa.dot(co(e.lightDirection)),r=at(i.mul(.5).add(.5),0),s=r.fwidth().mul(.5);return Yt(G(.7),G(1),tr(I(.7).sub(s.x),I(.7).add(s.x),r.x))}),Glt=Et(e=>{let i=co(e.lightDirection).add(jv).normalize(),r=Oa.dot(i).clamp(),s=jv.dot(i).clamp(),n=s.mul(-5.55473).sub(6.98316).mul(s).exp2(),a=Z1.mul(n.oneMinus()).add(n),o=I(.25),l=$4.mul(.5).add(1).mul(1/Math.PI).mul(r.pow($4));return a.mul(o).mul(l)}),t=class extends xv{direct(e){let{lightDirection:i,lightColor:r,reflectedLight:s}=e,n=co(jlt({lightDirection:i})).mul(r);s.directDiffuse.addAssign(n.mul(co(Vo.rgb).mul(1/Math.PI))),s.directSpecular.addAssign(n.mul(Wv(Glt({lightDirection:i}))))}},svt=class extends t{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(e,...i){super.finish?.call(this,e,...i);let{reflectedLight:r,outgoingLight:s}=e.context,n=rvt(this.aoOcclusionGate),a=co(r.directDiffuse.add(r.indirectDiffuse));s.subAssign(a.mul(Rr(n)))}},nvt=class extends tR{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(e,i){let r=e;if(r.lightNode?.light?.userData?.splineDiffuseOnly===!0){if(this.envIrradianceActive)return;let s=co(Oa).dot(r.lightDirection).clamp().mul(r.lightColor),n=D.BRDF_Lambert({diffuseColor:j9});return void r.reflectedLight.directDiffuse.addAssign(s.mul(n))}super.direct(e,i)}}});function Vy(t,e){return $u(e==="x"?t.x:e==="y"?t.y:t.z)}function tw(t,e){return Xn(Fyt(t,G(e,1)).div(2).add(.5).xy)}function MCt(t,e,i){let r=I(t.div(Ae(t.add(e.accumAlpha),I(1e-5),I(1)))).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(t).mul(Rr(i))),r}function aS(t){let e=t.getValue("projection")??0,i=t.getValue("axis")??0,r=i>=0&&i<=2?i:0,s=t.getValue("projectionAxis")??-1,n=s>=0&&s<=2?s:1,a=ovt(t.get("mat")),o=t.getVec2("size");if(e===1){let u=Za,h=r===0?u.zy:r===1?u.xz:u.xy,d=at(h.add(1).div(2)).toVar(),c=at(tw(a,Xn(d.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[Xn(c)],weights:null}}if(e===2){let u=G(xe(Za)).toVar(),{a:h,b:d,pole:c}=W9[n],p=I(xc(Vy(u,h),Vy(u,d)).div(6.283).add(.5)).toVar(),m=I(vW(Vy(u,c)).div(3.1415).add(.5)).toVar(),f=at(p,m).toVar(),g=at(tw(a,Xn(f.mul(2).sub(1)))).toVar();return{uvs:[Xn(g)],weights:null}}if(e===3){let u=G(xe(Za)).toVar(),{a:h,b:d,pole:c}=W9[n],p=I(xc(Vy(u,h),Vy(u,d)).div(6.283).add(.5)).toVar(),m=I(Vy(ur(Za),c).div(o.y.mul(.5))).toVar(),f=I(m.div(2).add(.5)).toVar(),g=at(p,f).toVar(),y=at(tw(a,Xn(g.mul(2).sub(1)))).toVar();return{uvs:[Xn(y)],weights:null}}if(e===4){let u=t.getFloat("blending"),h=G(Za).toVar(),d=at(h.xy.add(1).div(2)).toVar(),c=at(h.zy.add(1).div(2)).toVar(),p=at(h.xz.add(1).div(2)).toVar();for(let y of[d,c,p])y.assign(tw(a,Xn(y.mul(2).sub(1).div(o.mul(.5)))));let m=I(Rr(u).mul(125).add(3)).toVar(),f=G(hT).toVar(),g=G(Le(xe(f))).toVar();return g.assign(Lo(g,G(m))),g.divAssign(kt(g,G(1))),{uvs:[Xn(d),Xn(c),Xn(p)],weights:ur(g)}}let l=at(tw(a,Xn(bi().mul(2).sub(1)))).toVar();return{uvs:[Xn(l)],weights:null}}function sE(t,e,i){let r=at(e).toVar(),s=at(kv(r)).toVar(),n=at(zv(r)).toVar(),a=h=>$u(i.mul(oD(Pa(t.sample(h)).rgb))),o=I(a(Xn(r))).toVar(),l=I(a(Xn(r.add(s))).sub(o)).toVar(),u=I(a(Xn(r.add(n))).sub(o)).toVar();return Xn(at(l,u))}function nE(t,e,i){let r=G(kv(t)).toVar(),s=G(zv(t)).toVar(),n=G(xe(e)).toVar(),a=G(xe(Zr(s,n))).toVar(),o=G(xe(Zr(n,r))).toVar(),l=I(kt(r,a).mul(aD)).toVar(),u=G(Ku(l).mul(i.x.mul(a).add(i.y.mul(o)))).toVar();return ur(xe(Le(l).mul(n).sub(u)))}function ML(t,e){let i,r=t.get("texture"),s=t.has("loaded")?t.getFloat("loaded"):I(1),n=l=>{let u=Pa(r.sample(l)),h=e==="luminance"?oD(u.rgb):u[e];return I(h).toVar()},{uvs:a,weights:o}=aS(t);if(o!==null){let l=n(a[0]),u=n(a[1]),h=n(a[2]);i=$u(l.mul(o.z).add(u.mul(o.x)).add(h.mul(o.y)))}else i=$u(n(a[0]));return $u(Yt(I(1),i,s))}var $u,Xn,ur,Pa,ovt,W9,Wlt,lvt=j(()=>{mr(),He(),cn(),$u=t=>t,Xn=t=>t,ur=t=>t,Pa=t=>t,ovt=t=>t,W9=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],Vn("texture",Wlt=(t,e,i)=>{let r,s=t.getValue("projection")??0,n=t.getValue("axis")??0,a=n>=0&&n<=2?n:0,o=t.getValue("side")??0,l=t.get("texture"),u=t.getFloat("crop"),{uvs:h,weights:d}=aS(t),c=[...h],p=null;if(s===1){if(r=Pa(l.sample(h[0])),o!==2){let v=a===0?G(1,0,0):a===1?G(0,1,0):G(0,0,1),b=kt(hT,v);p=$u(Ai(I(0),o===1?b.mul(-1):b))}}else if(s===2||s===3)r=function(v,b){if(v.value.minFilter===De&&v.value.magFilter===De)return Pa(v.sample(b));let _=at(kv(b)).toVar(),x=at(zv(b)).toVar();return _.x.subAssign(ce(_.x.add(.5))),x.x.subAssign(ce(x.x.add(.5))),Pa(v.sample(b).grad(_,x))}(l,h[0]);else if(s===4){let v=d,b=Pa(l.sample(h[0])),_=Pa(l.sample(h[1])),x=Pa(l.sample(h[2]));r=Pa(b.mul(v.z).add(_.mul(v.x)).add(x.mul(v.y)))}else r=Pa(l.sample(h[0]));let m=t.has("loaded")?t.getFloat("loaded"):I(1),f=lt(Yt(lt(0,0,0,1),Pa(r),m)).toVar(),g=G(f.rgb).toVar(),y=I(e.alpha.mul(f.a)).toVar();return p!==null&&y.mulAssign(p),function(v,b,_){bt(v.greaterThan(.5),()=>{for(let x of _)bt(x.x.lessThan(0).or(x.x.greaterThan(1)).or(x.y.lessThan(0)).or(x.y.greaterThan(1)),()=>{b.assign(0)})})}(u,$u(y),c),y.mulAssign(e.mask),{color:ur(g),calpha:MCt($u(y),i,e.isMask)}}),Vn("video",Wlt)});function aE(t){return cvt({c:t})}function Zp(t){return pvt({p:t})}function ACt(t){return mvt({m:t})}function Wf(t){return fvt({x:t})}function AL(t){return gvt({r:t})}function Mv(t){return yvt({v:t})}function oE(t){return vvt({x:t})}function CCt(t){return bvt({x:t})}function SR(t){return _vt({P:t})}function CL(t){return xvt({p3:t})}function oS(t,e,i){return wvt({a:t,b:e,k:i})}function hvt(t,e,i){return Svt({a:t,b:e,k:i})}function uvt(t,e,i,r,s){return Tvt({value:t,input_min:e,input_max:i,output_min:r,output_max:s})}function dvt(t,e,i,r,s){return Mvt({x:t,style:e,smoothness:i,seed:r,quality:s})}var qlt,EL,ew,cvt,pvt,mvt,fvt,gvt,yvt,Hlt,vvt,$lt,bvt,Xlt,_vt,Ylt,xvt,wvt,Svt,Tvt,Mvt,WS,uT=j(()=>{He(),qlt=TW,EL=Ji,ew=.1666667,cvt=Et(t=>{let e=t.c,i=Bn(kt(e,G(17,59.4,15))).mul(4096),r=Oi(i.mul(512)),s=i.mul(.125),n=Oi(s.mul(512)),a=s.mul(.125),o=Oi(a.mul(512));return G(n,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),pvt=Et(t=>{let e=t.p,i=ce(e.add(kt(e,G(.3333333)))).toVar(),r=e.sub(i).add(kt(i,G(ew))).toVar(),s=Ai(G(0),r.sub(r.yzx)).toVar(),n=s.mul(Rr(s.zxy)).toVar(),a=Rr(s.zxy.mul(Rr(s))).toVar(),o=r.sub(n).add(ew).toVar(),l=r.sub(a).add(2*ew).toVar(),u=r.sub(1).add(3*ew).toVar(),h=lt(kt(r,r),kt(o,o),kt(l,l),kt(u,u)).toVar();h.assign(lt(.6).sub(h).max(0));let d=lt(kt(aE(i),r),kt(aE(i.add(n)),o),kt(aE(i.add(a)),l),kt(aE(i.add(1)),u)).toVar();return h.mulAssign(h),h.mulAssign(h),d.mulAssign(h),kt(d,lt(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),mvt=Et(t=>{let e=t.m,i=mm(G(-.37,.36,.85),G(-.14,-.93,.34),G(.92,.01,.4)),r=mm(G(-.55,-.39,.74),G(.33,-.91,-.24),G(.77,.12,.63)),s=mm(G(-.71,.52,-.47),G(-.08,-.72,-.68),G(-.7,-.45,.56));return Zp(e.mul(i)).mul(.5333333).add(Zp(e.mul(2).mul(r)).mul(.2666667)).add(Zp(e.mul(4).mul(s)).mul(.1333333)).add(Zp(e.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),fvt=Et(t=>{let e=t.x;return $h(e.mul(34).add(1).mul(e),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),gvt=Et(t=>u2(1.79284291400159,t.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),yvt=Et(t=>{let e=t.v,i=at(1/6,1/3),r=lt(0,.5,1,2),s=ce(e.add(kt(e,i.yyy))).toVar(),n=e.sub(s).add(kt(s,i.xxx)).toVar(),a=Ai(n.yzx,n.xyz).toVar(),o=Rr(a).toVar(),l=ii(a.xyz,o.zxy).toVar(),u=Qt(a.xyz,o.zxy).toVar(),h=n.sub(l).add(i.xxx.mul(1)).toVar(),d=n.sub(u).add(i.xxx.mul(2)).toVar(),c=n.sub(1).add(i.xxx.mul(3)).toVar();s.assign($h(s,289));let p=Wf(Wf(Wf(s.z.add(lt(0,l.z,u.z,1))).add(s.y).add(lt(0,l.y,u.y,1))).add(s.x).add(lt(0,l.x,u.x,1))).toVar(),m=r.wyz.mul(1/7).sub(r.xzx).toVar(),f=p.sub(ce(p.mul(m.z).mul(m.z)).mul(49)).toVar(),g=ce(f.mul(m.z)).toVar(),y=ce(f.sub(g.mul(7))).toVar(),v=g.mul(m.x).add(m.yyyy).toVar(),b=y.mul(m.x).add(m.yyyy).toVar(),_=u2(1,Le(v)).sub(Le(b)).toVar(),x=lt(v.xy,b.xy).toVar(),S=lt(v.zw,b.zw).toVar(),w=ce(x).mul(2).add(1).toVar(),T=ce(S).mul(2).add(1).toVar(),C=Ai(_,lt(0)).negate().toVar(),M=x.xzyw.add(w.xzyw.mul(C.xxyy)).toVar(),A=S.xzyw.add(T.xzyw.mul(C.zzww)).toVar(),R=G(M.xy,_.x).toVar(),O=G(M.zw,_.y).toVar(),N=G(A.xy,_.z).toVar(),B=G(A.zw,_.w).toVar(),L=AL(lt(kt(R,R),kt(O,O),kt(N,N),kt(B,B))).toVar();R.mulAssign(L.x),O.mulAssign(L.y),N.mulAssign(L.z),B.mulAssign(L.w);let z=Qt(u2(.6,lt(kt(n,n),kt(h,h),kt(d,d),kt(c,c))),0).toVar();return z.mulAssign(z),kt(z.mul(z),lt(kt(R,n),kt(O,h),kt(N,d),kt(B,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Hlt=Et(t=>{let e=t.x;return e.sub(ce(e.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),vvt=Et(t=>{let e=t.x;return Hlt({x:e.mul(34).add(1).mul(e)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),$lt=Et(t=>{let e=t.p,i=ce(e).toVar(),r=e.sub(i).toVar();r.assign(r.mul(r).mul(u2(3,r.mul(2))));let s=i.xxyy.add(lt(0,1,0,1)).toVar(),n=oE(s.xyxy).toVar(),a=oE(n.xyxy.add(s.zzww)).toVar().add(i.zzzz).toVar(),o=oE(a).toVar(),l=oE(a.add(1)).toVar(),u=Oi(o.mul(1/41)).toVar(),h=Oi(l.mul(1/41)).toVar().mul(r.z).add(u.mul(Rr(r.z))).toVar(),d=h.yw.mul(r.x).add(h.xz.mul(Rr(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(Rr(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),bvt=Et(t=>{let e=G(t.x).toVar(),i=I(0).toVar(),r=I(.5).toVar(),s=G(100).toVar();return Ji(5,()=>{i.addAssign(r.mul(function(n){return $lt({p:n})}(e))),e.assign(e.mul(2).add(s)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),Xlt=Et(t=>{let e=t.t;return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),_vt=Et(t=>{let e=t.P,i=ce(e).toVar(),r=i.add(G(1)).toVar();i.assign($h(i,289)),r.assign($h(r,289));let s=Oi(e).toVar(),n=s.sub(G(1)).toVar(),a=lt(i.x,r.x,i.x,r.x).toVar(),o=lt(i.yy,r.yy).toVar(),l=lt(i.zzzz).toVar(),u=lt(r.zzzz).toVar(),h=Wf(Wf(a).add(o)).toVar(),d=Wf(h.add(l)).toVar(),c=Wf(h.add(u)).toVar(),p=d.div(7).toVar(),m=Oi(ce(p).div(7)).sub(.5).toVar();p.assign(Oi(p));let f=lt(.5).sub(Le(p)).sub(Le(m)).toVar(),g=Ai(f,lt(0)).toVar();p.subAssign(g.mul(Ai(0,p).sub(.5))),m.subAssign(g.mul(Ai(0,m).sub(.5)));let y=c.div(7).toVar(),v=Oi(ce(y).div(7)).sub(.5).toVar();y.assign(Oi(y));let b=lt(.5).sub(Le(y)).sub(Le(v)).toVar(),_=Ai(b,lt(0)).toVar();y.subAssign(_.mul(Ai(0,y).sub(.5))),v.subAssign(_.mul(Ai(0,v).sub(.5)));let x=G(p.x,m.x,f.x).toVar(),S=G(p.y,m.y,f.y).toVar(),w=G(p.z,m.z,f.z).toVar(),T=G(p.w,m.w,f.w).toVar(),C=G(y.x,v.x,b.x).toVar(),M=G(y.y,v.y,b.y).toVar(),A=G(y.z,v.z,b.z).toVar(),R=G(y.w,v.w,b.w).toVar(),O=AL(lt(kt(x,x),kt(w,w),kt(S,S),kt(T,T))).toVar();x.mulAssign(O.x),w.mulAssign(O.y),S.mulAssign(O.z),T.mulAssign(O.w);let N=AL(lt(kt(C,C),kt(A,A),kt(M,M),kt(R,R))).toVar();C.mulAssign(N.x),A.mulAssign(N.y),M.mulAssign(N.z),R.mulAssign(N.w);let B=kt(x,s).toVar(),L=kt(S,G(n.x,s.yz)).toVar(),z=kt(w,G(s.x,n.y,s.z)).toVar(),k=kt(T,G(n.xy,s.z)).toVar(),V=kt(C,G(s.xy,n.z)).toVar(),H=kt(M,G(n.x,s.y,n.z)).toVar(),W=kt(A,G(s.x,n.yz)).toVar(),X=kt(R,n).toVar(),st=function(pt){return Xlt({t:pt})}(s).toVar(),nt=Yt(lt(B,L,z,k),lt(V,H,W,X),st.z).toVar(),xt=Yt(nt.xy,nt.zw,st.y).toVar();return Yt(xt.x,xt.y,st.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Ylt=Et(t=>{let e=Oi(t.p3.mul(.1031)).toVar();return e.addAssign(kt(e,e.yzx.add(33.33))),Oi(e.x.add(e.y).mul(e.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),xvt=Et(t=>{let e=Oi(t.p3.mul(G(.1031,.103,.0973))).toVar();return e.addAssign(kt(e,e.yxz.add(33.33))),Oi(e.xxy.add(e.yxx).mul(e.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),wvt=Et(t=>{let{a:e,b:i,k:r}=t,s=tr(0,1,i.sub(e).mul(.5).div(r).add(.5)).toVar(),n=r.mul(s).mul(Rr(s)).toVar();return Yt(i,e,s).sub(n)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),Svt=Et(t=>{let{a:e,b:i,k:r}=t,s=tr(1,0,e.sub(i).mul(.5).div(r).add(.5)).toVar(),n=r.mul(s).mul(Rr(s)).toVar();return Yt(e,i,s).add(n)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),Tvt=Et(t=>{let{value:e,input_min:i,input_max:r,output_min:s,output_max:n}=t,a=r.sub(i).toVar(),o=n.sub(s).toVar(),l=e.sub(i).div(a).toVar();return s.add(l.mul(o))}).setLayout({name:"spe_remap",type:"float",inputs:[{name:"value",type:"float"},{name:"input_min",type:"float"},{name:"input_max",type:"float"},{name:"output_min",type:"float"},{name:"output_max",type:"float"}]}),Mvt=Et(t=>{let{x:e,style:i,smoothness:r,seed:s,quality:n}=t,a=Qn(ce(e)).toVar(),o=Oi(e).toVar(),l=I(8).toVar(),u=I(8).toVar(),h=I(8).toVar(),d=I(8).toVar(),c=I(8).toVar(),p=I(8).toVar(),m=Qn(0).toVar(),f=G(0).toVar(),g=mt(n).toVar(),y=()=>({start:g.negate(),end:g,condition:"<=",type:"int"});EL(y(),y(),y(),({i:b,j:_,k:x})=>{let S=Qn(b,_,x).toVar(),w=G(S).add(CL(G(a.add(S)).add(s))).sub(o).toVar(),T=mi(w).toVar();l.assign(oS(T,l,r)),bt(T.lessThan(u),()=>{d.assign(u),u.assign(T),m.assign(Qn(b,_,x)),f.assign(w)}).ElseIf(T.lessThan(d),()=>{d.assign(T)})}),bt(i.notEqual(mt(0)).and(i.notEqual(mt(5))).and(i.notEqual(mt(7))),()=>{EL(y(),y(),y(),({i:b,j:_,k:x})=>{let S=m.add(Qn(b,_,x)).toVar(),w=G(S).add(CL(G(a.add(S)).add(s))).sub(o).toVar(),T=kt(f.add(w).mul(.5),w.sub(f)).toVar(),C=kt(f.add(w).mul(.5),xe(w.sub(f))).toVar();c.assign(oS(T,c,r)),p.assign(ii(p,C));let M=Qn(b,_,x).toVar();bt(yW(qlt(M,m)),()=>{let A=G(M).add(CL(G(a.add(M)).add(s))).sub(o).toVar(),R=mi(A).toVar();h.assign(oS(R,h,r))})})});let v=I(0).toVar();return bt(i.equal(mt(0)),()=>{v.assign(l)}).ElseIf(i.equal(mt(1)),()=>{v.assign(h)}).ElseIf(i.equal(mt(2)),()=>{v.assign(h.sub(l))}).ElseIf(i.equal(mt(3)),()=>{let b=I(3).toVar(),_=Qt(b.sub(Le(u.sub(d))),0).div(b).toVar();v.assign(ii(u,d).sub(_.mul(_).mul(b).mul(1/4)))}).ElseIf(i.equal(mt(4)),()=>{v.assign(nD(c.mul(5)))}).ElseIf(i.equal(mt(5)),()=>{v.assign(Lo(l,3))}).ElseIf(i.equal(mt(6)),()=>{let b=r.mul(.25).add(.0125).toVar(),_=Lo(r,3).mul(.25).add(.0125).toVar();v.assign(tr(b.sub(b.mul(_)),b.add(b.mul(_)),p))}).ElseIf(i.equal(mt(7)),()=>{v.assign(function(b){return Ylt({p3:b})}(G(a.add(m)).add(s)))}),v}).setLayout({name:"spe_voronoi",type:"float",inputs:[{name:"x",type:"vec3"},{name:"style",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"quality",type:"int"}]}),WS=[Zp,ACt,Mv,CCt,SR]});function Avt(t,e,i,r){return mo(t.add(e).mul(i).mul(.001).add(Cvt).add(r.mul(.1)))}function ECt(t,e,i){let r=function(u,h){let d=Math.trunc(u.getValue("noiseType")??0),c={n:h,scale:u.getFloat("scale"),intensity:u.getFloat("intensity"),offset:u.getVec3("offset"),movement:u.getFloat("movement")};if(d===5)return m=>mo(Pvt({...c,p:m,voronoiStyle:u.getInt("voronoiStyle"),smoothness:u.getFloat("smoothness"),seed:u.getFloat("seed"),highCut:u.getFloat("highCut"),lowCut:u.getFloat("lowCut"),quality:u.getInt("quality")}));let p=function(m){let f=q9.get(m);if(f===void 0){let g=WS[m]??WS[0];f=Et(y=>{let{n:v,scale:b,intensity:_,offset:x,movement:S}=y,w=mo(y.p);return w.add(v.mul(g(Avt(w,x,b,S))).mul(_))}).setLayout({name:`spe_displaceScalar${m}`,type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"}]}),q9.set(m,f)}return f}(d);return m=>mo(p({...c,p:m}))}(t,i),s=G(r(e)).toVar(),n=G(function(u){return Evt({v:u})}(i)).toVar(),a=xe(Zr(i,n)).toVar(),o=G(r(mo(e.add(n)))).toVar(),l=G(r(mo(e.add(a)))).toVar();return{position:s,normal:mo(xe(Zr(o.sub(s),l.sub(s))))}}var mo,Cvt,Evt,q9,Pvt,PL,Klt,h0,iw,lE,Zlt,PCt=j(()=>{He(),uT(),mo=t=>t,Cvt=1e-4,Evt=Et(t=>{let e=mo(t.v);return xe(mo(fi(Le(e.x).greaterThan(Le(e.z)),G(e.y.negate(),e.x,0),G(0,e.z.negate(),e.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),q9=new Map,Pvt=Et(t=>{let{n:e,scale:i,intensity:r,offset:s,movement:n,smoothness:a}=t,o=mo(t.p),l=I(dvt(Avt(o,s,i,n),t.voronoiStyle,a,t.seed,t.quality)).toVar();return l.assign(uvt(l,t.lowCut,t.highCut,I(0),I(1))),l.assign(hvt(l,I(0),a.mul(.25))),l.assign(oS(l,I(1),a.mul(.25))),o.add(e.mul(l).mul(r))}).setLayout({name:"spe_displaceVoronoi",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"},{name:"voronoiStyle",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"highCut",type:"float"},{name:"lowCut",type:"float"},{name:"quality",type:"int"}]})}),RCt=j(()=>{cn(),Vn("color",(t,e,i)=>{let r=e.alpha.mul(e.mask);return{color:t.getColor("color"),calpha:sb(r,i)}})}),DCt=j(()=>{He(),cn(),PL=t=>t,Klt=t=>t,Vn("depth",(t,e,i)=>{let r,s=t.get("colors"),n=t.get("steps"),a=(t.getValue("colors")??s.array).length,o=t.getValue("smooth")===!0,l=(t.getValue("isVector")??1)>.5,u=(t.getValue("gradientType")??0)===0,h=(t.getValue("isWorldSpace")??0)>.5,d=t.getFloat("near"),c=t.getFloat("far");if(l){let g=t.getVec3("origin"),y=h?Go:Za;if(u){let v=xe(t.getVec3("direction"));r=kt(v,y.sub(g))}else r=mi(y.sub(g))}else r=mi(Go.sub(Pc));let p=r.sub(d).div(c.sub(d)).toVar(),m=lt(s.element(0)).toVar();for(let g=1;g<a;g++){let y=PL(n.element(g-1)),v=PL(n.element(g)),b=Ae(p.sub(y).div(v.sub(y)),I(0),I(1)),_=o?tr(I(0),I(1),b):b;m.assign(Yt(m,Klt(s.element(g)),_))}let f=e.alpha.mul(m.a).mul(e.mask);return{color:m.rgb,calpha:Ju(f,i,e.isMask)}})}),NCt=j(()=>{He(),cn(),dn(),Vn("cavity",(t,e,i)=>{let r=Ae(t.getFloat("ridge"),0,2),s=Ae(t.getFloat("valley"),0,2),n=Lt.normalViewRenderTarget,a=Lt.resolution,o=vm("randomColor","vec3").x.toVar(),l=Jl.toVar(),u=at(I(1).div(a.x),I(1).div(a.y)).toVar(),h=(M,A)=>n.sample(l.add(at(M,A)).toVar()).toVar(),d=h(I(0),u.y.negate()),c=h(I(0),u.y),p=h(u.x.negate(),I(0)),m=h(u.x,I(0)),f=M=>M.a.equal(o).and(kt(M.xyz,M.xyz).greaterThan(.5)),g=f(d).and(f(c)).and(f(p)).and(f(m)),y=d.y.sub(c.y).add(m.x.sub(p.x)).toVar(),v=I(.5).div(Qt(r.mul(r),I(1e-4))).toVar(),b=I(.7).div(Qt(s.mul(s),I(1e-4))).toVar(),_=(M,A)=>fi(M.lessThan(I(.5).div(A)),M.mul(I(1).sub(M.mul(A))),I(.25).div(A)),x=fi(g,fi(y.greaterThan(0),_(y,v).mul(2),_(y.negate(),b).mul(-2)),I(0)).toVar(),S=fi(x.abs().lessThan(.001),I(0),x).toVar(),w=G(Ae(S.mul(.5).add(.5),0,1)),T=fi(S.notEqual(0),I(1),I(0)),C=fi(e.isMask,I(1),T);return{color:w,calpha:Ju(e.alpha.mul(e.mask).mul(C),i,e.isMask)}})}),nb=j(()=>{He(),h0=Et(t=>{let e=t.material?.vertexObjectNormal??null;return e?X4(e).transformNormalByInverseViewMatrix(eh).normalize():Gyt}).once()().toVar("speVertexNormalWorld")}),OCt=j(()=>{He(),nb(),cn(),uT(),Vn("dust",(t,e,i)=>{let r=t.getFloat("coverage"),s=t.getFloat("softness"),n=t.getFloat("noiseStrength"),a=t.getFloat("noiseScale"),o=kt(xe(h0),G(0,1,0)),l=I(0).toVar();bt(n.notEqual(0),()=>{let c=Zp(Za.div(a).toVar().add(G(1.7,9.2,1)));l.assign(c.mul(n))});let u=Qt(s,1e-4).toVar(),h=Yt(u.add(1),u.add(1).negate(),Ae(r,0,1)).toVar(),d=tr(h.sub(u),h.add(u),o.add(l)).mul(e.alpha).mul(e.mask);return{color:t.getColor("color"),calpha:Ju(d,i,e.isMask)}})}),ICt=j(()=>{He(),nb(),cn(),iw=(t,e)=>t.element(e),Vn("fresnel",(t,e,i)=>{let r=iw(rb,2).w.equal(-1),s=G(iw(eh,0).z,iw(eh,1).z,iw(eh,2).z).negate(),n=Go.sub(Pc),a=fi(r,n,s),o=t.getFloat("bias").add(t.getFloat("scale").mul(Lo(Le(t.getFloat("factor").add(kt(xe(a),xe(h0)))),t.getFloat("intensity")))),l=Ae(o,0,1).mul(e.alpha).mul(e.mask);return{color:t.getColor("color"),calpha:Ju(l,i,e.isMask)}})}),BCt=j(()=>{He(),cn(),lE=t=>t,Zlt=t=>t,Vn("gradient",(t,e,i)=>{let r=t.get("colors"),s=t.get("steps"),n=(t.getValue("colors")??r.array).length,a=(t.getValue("steps")??s.array).length,o=Math.min(10,n,a),l=t.getInt("gradientType"),u=t.getBool("smooth"),h=t.getVec2("offset"),d=t.getVec2("morph"),c=t.getFloat("angle"),p=bi(),m=lt(r.element(0)).toVar(),f=at(d.div(p)).toVar(),g=at(I(.5).add(f.x),f.y).toVar(),y=at(Ka(c).mul(g.x).sub(Bn(c).mul(g.y)),Bn(c).mul(g.x).add(Ka(c).mul(g.y))).toVar(),v=at(p.sub(.5).add(h).div(2).add(y.div(2))),b=I(kt(v,y).div(kt(y,y))).toVar();bt(l.equal(mt(1)),()=>{b.assign(Tyt(p.add(d).mul(3),p.add(h).add(1)).add(c))}).ElseIf(l.equal(mt(2)),()=>{let x=xc(p.x.add(d.x).sub(.5).add(h.x),p.y.add(d.y).sub(.5).add(h.y)).mul(-1);b.assign(Oi(c.div(Kj).div(-2).add(x.div(Kj).mul(.5))))});for(let x=1;x<o;x++){let S=lE(s.element(x-1)),w=lE(s.element(x)),T=Ae(b.sub(S).div(w.sub(S)),I(0),I(1)),C=lE(fi(u,tr(I(0),I(1),T),T));m.assign(Yt(m,Zlt(r.element(x)),C))}let _=e.alpha.mul(m.a).mul(e.mask);return{color:m.rgb,calpha:Ju(_,i,e.isMask)}})}),VCt=j(()=>{He(),cn(),Vn("matcap",(t,e,i)=>{let r=t.getFloat("rotation"),s=xe(Rc.negate()),n=xe(G(s.z,0,s.x.negate())),a=Zr(s,n),o=at(kt(n,Oa),kt(a,Oa)),l=Ka(r),u=Bn(r),h=at(l.mul(o.x).sub(u.mul(o.y)),u.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=t.get("texture").sample(h),c=e.alpha.mul(e.mask);return{color:d.rgb,calpha:Ju(c,i,e.isMask)}})}),kCt=j(()=>{He(),cn(),uT(),Vn("noise",(t,e,i)=>{try{if(new URLSearchParams(window.location.search).get("dbgnoise")==="0")return{color:G(0),calpha:I(0)}}catch{}let r=Math.trunc(t.getValue("noiseType")??0),s=I(Qt(Le(t.getFloat("scale")),.001)).toVar(),n=G(Za.div(t.getVec3("size"))).toVar();n.divAssign(s);let a=t.getFloat("move"),o=t.getVec4("colorA"),l=t.getVec4("colorC"),u=lt(0).toVar();if(r===5){let d=t.getFloat("smoothness"),c=I(dvt(n.add(a),t.getInt("voronoiStyle"),d,t.getFloat("seed"),t.getInt("quality"))).toVar();c.assign(uvt(c,t.getFloat("lowCut"),t.getFloat("highCut"),I(0),I(1))),c.assign(hvt(c,I(0),d.mul(.25))),c.assign(oS(c,I(1),d.mul(.25))),u.assign(Yt(o,l,c))}else{let d=WS[r]??WS[0],c=t.getVec4("colorB"),p=t.getVec4("colorD"),m=G(t.getVec2("distortion"),1).toVar(),f=G(t.getVec2("fA"),1).toVar(),g=G(t.getVec2("fB"),1).toVar(),y=G(d(n),d(n.add(G(1))),d(n.add(G(1)))).toVar(),v=G(d(n.add(m.mul(y)).add(f).add(a)),d(n.add(m.mul(y)).add(g).add(a)),d(n.mul(y))).toVar(),b=I(d(n.add(v))).toVar();u.assign(Yt(o,c,Ae(b.mul(b).mul(4),I(0),I(1)))),u.assign(Yt(u,l,Ae(mi(y),I(0),I(1)))),u.assign(Yt(u,p,Ae(mi(v.x),I(0),I(1))))}let h=e.alpha.mul(u.a).mul(e.mask);return{color:Ae(u,I(0),I(1)).rgb,calpha:Ju(h,i,e.isMask)}})}),zCt=j(()=>{He(),cn(),Vn("normal",(t,e,i)=>({color:Hyt(xe(Oa)).mul(Ai(G(.5),t.getVec3("cnormal"))),calpha:sb(e.alpha.mul(e.mask),i)}))});function RL(t){return Rvt({p:t})}function hE(t,e){return Dvt({uv:t,a:e})}function ky(t,e,i,r,s){return Nvt({uv:t,frequency:e,variation:i,zigzag:r,rotation:s})}function uE(t,e){let i={uv:e.uv,frequency:e.frequency,size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation};switch(t){case 1:return Ivt(i);case 2:return Bvt({...i,sides:e.sides});case 3:return Vvt(i);case 4:return kvt(i);case 5:return zvt(i);case 6:return Lvt(i);case 7:return Fvt(i);default:return Ovt(i)}}var zy,Qlt,Rvt,Dvt,Nvt,Ovt,Ivt,Jlt,Bvt,tht,Vvt,eht,kvt,zvt,Lvt,iht,Fvt,rw,DL,rht,sht,nht,aht,oht,NL,lht,qf,hht,uht,OL,dht,LCt=j(()=>{He(),cn(),zy=2*Math.PI,Qlt=Math.PI/180,Rvt=Et(t=>{let e=Oi(t.p.xyx.mul(.1031)).toVar();return e.addAssign(kt(e,e.yzx.add(33.33))),Oi(e.x.add(e.y).mul(e.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),Dvt=Et(t=>{let e=t.uv,i=.5,r=I(t.a.mul(Qlt)).toVar(),s=at(Ka(r).mul(e.x.sub(i)).add(Bn(r).mul(e.y.sub(i))).add(i),Ka(r).mul(e.y.sub(i)).sub(Bn(r).mul(e.x.sub(i))).add(i));return Oi(s)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),Nvt=Et(t=>{let e=at(t.uv.mul(t.frequency)).toVar(),i=at(ce(e)).toVar(),r=I($h(i.y,2)).toVar();e.x.addAssign(r.mul(t.zigzag));let s=at(Oi(e)).toVar();s.assign(s.mul(2).sub(1)),i.assign(ce(e));let n=I(RL(i).mul(5).add(1)).toVar(),a=I(Yt(I(1),n,t.variation)).toVar();return s.mulAssign(a),s}).setLayout({name:"spe_pattern_tile_and_center",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"variation",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ovt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,mi(e).sub(t.size))}).setLayout({name:"spe_pattern_circle",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ivt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar(),i=I(mi(e)).toVar(),r=I(tr(t.smoothness.negate(),t.smoothness,i.sub(t.size))).toVar(),s=I(tr(t.smoothness.negate(),t.smoothness,i.sub(t.size.mul(.5)))).toVar();return r.add(Rr(s))}).setLayout({name:"spe_pattern_ring",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Jlt=Et(t=>{let e=I(I(zy).div(I(t.n))).toVar(),i=I(t.r.mul(a1t(e.mul(.5)))).toVar(),r=at(t.p.yx.negate()).toVar(),s=I(e.mul(ce(xc(r.y,r.x).add(e.mul(.5)).div(e)))).toVar(),n=at(Ka(s),Bn(s)).toVar();return r.assign(at(n.x.mul(r.x).add(n.y.mul(r.y)),n.y.negate().mul(r.x).add(n.x.mul(r.y)))),mi(r.sub(at(t.r,Ae(r.y,i.negate(),i)))).mul(Ku(r.x.sub(t.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),Bvt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,Jlt({p:e,r:t.size,n:t.sides}))}).setLayout({name:"spe_pattern_polygon",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"},{name:"sides",type:"int"}]}),tht=Et(t=>{let e=t.b,i=at(Le(t.p)).toVar();i.assign(fi(i.y.greaterThan(i.x),i.yx,i.xy));let r=at(i.sub(e)).toVar(),s=I(Qt(r.y,r.x)).toVar(),n=at(fi(s.greaterThan(0),r,at(e.y.sub(i.x),s.negate()))).toVar();return Ku(s).mul(mi(Qt(n,at(0)))).add(t.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),Vvt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,tht({p:e,b:at(t.size,t.size.mul(.25)),r:t.smoothness}))}).setLayout({name:"spe_pattern_xcross",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),eht=Et(t=>{let e=t.b,i=at(Le(t.p)).toVar(),r=at(e.sub(i.mul(2))).toVar(),s=r.x.mul(e.x).sub(r.y.mul(e.y)),n=I(Ae(s.div(kt(e,e)),I(-1),I(1))).toVar();return I(mi(i.sub(e.mul(.5).mul(at(Rr(n),n.add(1)))))).toVar().mul(Ku(i.x.mul(e.y).add(i.y.mul(e.x)).sub(e.x.mul(e.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),kvt=Et(t=>{let e=at(ky(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return tr(t.smoothness.negate(),t.smoothness,eht({p:e,b:at(t.size)}))}).setLayout({name:"spe_pattern_diamond",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),zvt=Et(t=>{let e=at(t.uv.mul(t.frequency)).toVar(),i=at(ce(e)).toVar(),r=I($h(i.y,2)).toVar();e.x.addAssign(r.add(t.zigzag.mul(r)));let s=I(ce(e.x)).toVar();return $h(s,2)}).setLayout({name:"spe_pattern_checkerboard",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Lvt=Et(t=>{let e=at(ky(t.uv,t.frequency,I(0),t.zigzag,t.rotation)).toVar(),i=I(ce(t.uv.mul(t.frequency)).y).toVar(),r=I(RL(at(i))).toVar(),s=I(Yt(t.size,t.size.mul(r),t.variation)).toVar();return tr(s.sub(t.smoothness),s.add(t.smoothness),Le(e.y))}).setLayout({name:"spe_pattern_line",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),iht=Et(t=>{let{a:e,b:i,c:r,d:s}=t,n=at(t.p.sub(at(s,e)).mul(r)).toVar();n.x.assign($h(n.x,zy)),bt(n.x.greaterThan(Math.PI),()=>{n.x.assign(I(zy).sub(n.x))});let a=I(0).toVar(),o=I(zy).toVar();Ji(24,()=>{let h=I(a.add(o).mul(.5)).toVar(),d=I(h.sub(n.x).add(i.mul(r).mul(Bn(h)).mul(n.y.sub(i.mul(r).mul(Ka(h)))))).toVar();bt(d.lessThan(0),()=>{a.assign(h)}).Else(()=>{o.assign(h)})});let l=I(a.add(o).mul(.5)).toVar(),u=at(l,i.mul(r).mul(Ka(l))).toVar();return mi(n.sub(u)).div(r)}).setLayout({name:"spe_pattern_udf_cos",type:"float",inputs:[{name:"p",type:"vec2"},{name:"a",type:"float"},{name:"b",type:"float"},{name:"c",type:"float"},{name:"d",type:"float"}]}),Fvt=Et(t=>{let e=I(t.frequency.x).toVar(),i=at(t.uv.mul(e)).toVar(),r=at(ce(i)).toVar(),s=I($h(r.y,2)).toVar();i.x.addAssign(s.mul(t.zigzag));let n=at(i.x,Oi(i.y)).toVar(),a=I(t.frequency.y.mul(.1)).toVar(),o=I(iht({p:n,a:I(.5),b:I(.125),c:a.mul(zy),d:I(0)})).toVar(),l=I(RL(at(r.y))).toVar(),u=I(Yt(t.size,t.size.mul(l),t.variation)).toVar();return tr(t.smoothness.negate(),t.smoothness,o.sub(u.mul(.5)))}).setLayout({name:"spe_pattern_wave",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Vn("pattern",(t,e,i)=>{let r,s,n=t.getValue("style")??0,a=t.getValue("projection")??0,o=t.getValue("axis")??0,l=t.getFloat("blending"),u=t.getVec2("offset"),h=t.getVec4("colorA"),d=t.getVec4("colorB"),c=t.getVec2("frequency"),p=t.getFloat("size"),m=t.getFloat("variation"),f=t.getFloat("smoothness"),g=t.getFloat("zigzag"),y=t.getFloat("rotation"),v=t.getVec2("vertical"),b=t.getVec2("horizontal"),_=t.getInt("sides"),x={frequency:c,size:p,variation:m,smoothness:I(Lo(f,5)).toVar(),zigzag:g,rotation:y,sides:_};if(a===4){let T=G(Za).toVar(),C=I(.0125).toVar(),M=at(Oi(T.xy.mul(C))).toVar(),A=at(Oi(T.zy.mul(C))).toVar(),R=at(Oi(T.xz.mul(C))).toVar();M.assign(hE(M.add(u),y)),A.assign(hE(A.add(u),y)),R.assign(hE(R.add(u),y));let O=I(uE(n,{uv:M,...x})).toVar(),N=I(uE(n,{uv:A,...x})).toVar(),B=I(uE(n,{uv:R,...x})).toVar(),L=I(Rr(l).mul(125).add(3)).toVar(),z=G(hT).toVar(),k=G(Le(xe(z))).toVar();k.assign(Lo(k,G(L))),k.divAssign(kt(k,G(1))),O.mulAssign(k.z),N.mulAssign(k.x),B.mulAssign(k.y),r=I(O.add(N).add(B)).toVar(),s=at(M.mul(k.z).add(A.mul(k.x)).add(R.mul(k.y))).toVar()}else{let T=at(0).toVar();if(a===0)T.assign(bi());else if(a===2){let C,M,A=G(Za).toVar(),R=I(mi(A)).toVar();o===0?(C=I(xc(A.y,A.z)).toVar(),M=I(aR(A.x.div(R))).toVar()):o===1?(C=I(xc(A.x,A.z)).toVar(),M=I(aR(A.y.div(R))).toVar()):(C=I(xc(A.y,A.x)).toVar(),M=I(aR(A.z.div(R))).toVar()),T.assign(at(C,M).div(Math.PI))}T.addAssign(u),T.assign(Oi(T)),T.assign(hE(T,y)),r=uE(n,{uv:T,...x}),s=T}let S=lt(Yt(h,d,r)).toVar();S.a.assign(Ae(S.a,I(0),I(1))),S.a.mulAssign(Ai(v.x,s.y).mul(Ai(s.y,v.y))),S.a.mulAssign(Ai(b.x,Le(s.x)).mul(Ai(Le(s.x),b.y)));let w=e.alpha.mul(Ae(S.a,I(0),I(1))).mul(e.mask);return{color:Ae(S,lt(0),lt(1)).rgb,calpha:Ju(w,i,e.isMask)}})}),FCt=j(()=>{He(),nb(),cn(),uT(),rw=(t,e)=>t.element(e),Vn("rainbow",(t,e,i)=>{let r=t.getFloat("filmThickness"),s=t.getFloat("movement"),n=t.getVec3("wavelengths"),a=t.getFloat("noiseStrength"),o=t.getFloat("noiseScale"),l=t.getVec3("offset"),u=I(0).toVar();e.noiseCompiledIn!==!1&&bt(a.notEqual(0),()=>{let b=Za.div(o).toVar(),_=Zp(b.mul(1.6).add(G(1.8,1.5,1.9).mul(Zp(b))).add(G(1.7,9.2,1)));u.assign(_.mul(a))});let h=n.mul(G(1,.8,.6)).add(1),d=rw(rb,2).w.equal(-1),c=G(rw(eh,0).z,rw(eh,1).z,rw(eh,2).z).negate(),p=Go.sub(Pc),m=fi(d,p,c),f=kt(xe(m.add(l.mul(-.001))),xe(h0)),g=Ka(r.add(u).div(h).mul(f).add(s)).mul(.5).add(.5),y=G(Ae(g,0,2)).toVar(),v=Ae(y.r.add(y.g).add(y.b),0,1);return{color:y,calpha:Ju(e.alpha.mul(v).mul(e.mask),i,e.isMask)}})}),UCt=j(()=>{He(),nb(),cn(),dn(),DL=t=>t,rht=t=>t,sht=Ji,nht=Ji,aht=Et(t=>{let e=t.x,i=G(kt(e,G(127.1,311.7,74.7)),kt(e,G(269.5,183.3,246.1)),kt(e,G(113.5,271.9,124.6)));return Oi(Bn(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),oht=Et(t=>{let e=t.x,i=ce(e).toVar(),r=Oi(e).toVar(),s=I(100).toVar(),n=()=>({start:mt(-1),end:mt(1),condition:"<=",type:"int"});return nht(n(),n(),n(),({i:a,j:o,k:l})=>{let u=G(a,o,l).toVar(),h=u.sub(r).add(function(c){return aht({x:c})}(i.add(u))).toVar(),d=kt(h,h).toVar();bt(d.lessThan(s),()=>{s.assign(d)})}),s.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),Vn("toon",(t,e,i)=>{let r=t.getInt("positioning"),s=t.get("colors"),n=t.get("steps"),a=t.getVec3("source"),o=t.getBool("isWorldSpace"),l=t.getFloat("noiseStrength"),u=t.getFloat("noiseScale"),h=t.getVec4("shadowColor"),d=t.getVec3("offset"),c=xe(h0).toVar(),p=I(0).toVar();i.lightsAvailable===!0&&bt(r.equal(mt(0)),()=>{sht({start:mt(0),end:Lt.toonLightCount,condition:"<",type:"int"},({i:b})=>{let _=Lt.toonLightData.element(b).toVar(),x=_.xyz,S=_.w,w=fi(S.greaterThan(.5),xe(x),xe(x.sub(Go))),T=kt(w,c).mul(.5).add(.5);p.assign(Qt(p,T))}),p.assign(Ae(p,0,1))}),bt(r.equal(mt(1)),()=>{let b=Yt(Za,Go,fi(o,I(1),I(0))),_=xe(a.sub(b));p.assign(kt(_,c).mul(.5).add(.5))}).ElseIf(r.equal(mt(2)),()=>{let b=Pc.sub(d),_=xe(b.sub(Go));p.assign(kt(_,c).mul(.5).add(.5))}),bt(l.greaterThan(0),()=>{let b=Za.div(u),_=I(1).sub(oht({x:b}));p.addAssign(_.mul(l))}),p.assign(Ae(p,0,1));let m=(t.getValue("colors")??s.array).length,f=(t.getValue("steps")??n.array).length,g=Math.min(10,m,f),y=lt(s.element(0)).toVar();for(let b=1;b<g;b++){let _=DL(n.element(b-1)),x=DL(n.element(b)),S=Ae(p.sub(_).div(x.sub(_)),I(0),I(1));y.assign(Yt(y,rht(s.element(b)),tr(0,1,S)))}i.lightsAvailable===!0&&bt(r.equal(mt(0)),()=>{let b=I(1),_=Yt(y.rgb,h.rgb,h.a);y.rgb.assign(Yt(_,y.rgb,b))});let v=e.alpha.mul(y.a).mul(e.mask);return{color:y.rgb,calpha:sb(v,i)}})}),jCt=j(()=>{He(),nb(),cn(),J1t(),dn(),NL=t=>t,lht=(t,e)=>t.element(e),qf=t=>t,hht=t=>t,uht=t=>t,Vn("transmission",(t,e,i)=>{let r=t.getFloat("thickness"),s=t.getFloat("ior"),n=t.getFloat("roughness"),a=Lt.transmissionRenderTarget,o=Lt.transmissionSamplerSize,l=V=>lht(eh,V),u=xe(G(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),h=xe(Go.sub(Pc)),d=Lt.orthographicUniform,c=fi(d.greaterThan(.5),u,h).toVar(),p=xe(h0).toVar(),m=t1t(c,p,I(1).div(s)).toVar(),f=xe(m).mul(r).mul(Q1t).toVar(),g=V=>{let H=Lt.unjitteredProjection.mul(eh).mul(lt(V,1)),W=H.xy.div(H.w);return at(W.x.mul(.5).add(.5),W.y.mul(-.5).add(.5))},y=g(Go.add(f).toVar()).toVar(),v=(g(Go).toVar(),n.mul(Ae(s.mul(2).sub(2),I(0),I(1))).toVar()),b=Lv(o.x).mul(v).toVar(),_=v,x=ii(b.div(5.5),I(8.5)).toVar(),S=null,w="fit",T=!0,C=!1,M=12,A="white",R=1;try{let V=new URLSearchParams(window.location.search),H=V.get("dbglod");H!==null&&(S=Number(H));let W=V.get("dbgtap");W==="ring"&&(w="ring"),(W==="single"||W==="1")&&(w="single"),(W==="r50"||W==="r75"||W==="full")&&(w=W),W==="singlewide"&&(w="singlewide"),(W==="fit"||W==="singlefit")&&(w="fit");let X=V.get("dbgwidth");X!==null&&Number.isFinite(Number(X))&&(R=Math.max(0,Number(X))),W==="6"&&(w="ring",M=6),V.get("dbgwarp")==="0"&&(T=!1),V.get("dbgdither")==="1"&&(C=!0);let st=V.get("dbgangle");(st==="classic"||st==="0")&&(A=st)}catch{}S!==null&&Number.isFinite(S)&&x.assign(I(S));let O,N=(()=>{if(w==="singlewide")return ii(x.add(1),I(8.5)).toVar();if(w!=="fit")return x;let V=Lt.transmissionActualSize.x.div(Lt.resolution.x),H=_.mul(x).mul(5*R).mul(V).toVar();return ii(Lv(O1(x.mul(2)).add(H.mul(H).mul(3))).mul(.5),I(8.5)).toVar()})(),B=V=>a.sample(T?(H=>{let W=Lt.transmissionActualSize.div(O1(ce(N))),X=H.mul(W).sub(.5),st=ce(X),nt=X.sub(st),xt=nt.mul(nt).mul(at(3,3).sub(nt.mul(2)));return st.add(.5).add(xt).div(W)})(V):V).level(N).rgb,L=w==="r50"?.5:w==="r75"?.75:1;if(w==="single"||w==="singlewide"||w==="fit")if(w==="fit"){let V=ce(N).toVar(),H=N.sub(V).toVar(),W=xl(O1(H.mul(2)).sub(1)).mul(1.1547).toVar(),X=at(O1(V)).div(Lt.transmissionActualSize).mul(W).toVar(),st=G(0).toVar(),nt=12;for(let xt=0;xt<nt;xt++){let pt=qf(bm(xt,nt,I(0))),K=qf(y.add(pt.mul(X)));st.addAssign(hht(uht(a.sample(K).level(V)).rgb))}O=st.div(nt).toVar()}else O=B(y).toVar();else{let V=at(I(1).div(Lt.resolution.x),I(1).div(Lt.resolution.y)).toVar(),H=Ac(A==="classic"?Ja.xy.add(Lt.cameraJitterPx):Ja.xy).mul(6.28318530718);A==="white"&&(H=H.add(Lt.tapAngle));let W=H.toVar(),X=Lt.tapAngle.mul(13.7).toVar(),st=Lt.tapAngle2.mul(5.3).toVar(),nt=at(O1(ce(N).add(1))).div(Lt.transmissionActualSize).toVar(),xt=Ac(Ja.xy.add(at(X,st))).toVar(),pt=Ac(Ja.xy.add(at(st.mul(1.71),X.mul(2.39)))).toVar(),K=G(0).toVar();for(let ct=0;ct<M;ct++){let St=qf(bm(ct,M,W)).mul(V).mul(_).mul(x.mul(10)).mul(L),wt=qf(y.add(St));if(C){let Tt=NL(Oi(xt.add(.7548776662*ct))),yt=NL(Oi(pt.add(.5698402911*ct))),Ot=qf(at(Tt.sub(.5),yt.sub(.5)).mul(nt));wt=qf(wt.add(Ot))}K.addAssign(B(wt))}O=K.div(M).toVar()}if(t.has("attenuationDistance")){let V=t.getFloat("attenuationDistance"),H=G(t.getColor("attenuationColor")).toVar();bt(V.greaterThan(0),()=>{let W=Lo(Qt(H,G(1e-4)),G(r.div(V)));O.mulAssign(W)})}let z=e.alpha.mul(e.mask).toVar(),k=z.div(Ae(z.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(e.alpha)),{color:O,calpha:k}})}),GCt=j(()=>{He(),cn(),dn(),S1t(),Vn("reflection",(t,e,i)=>{let r=t.getFloat("blur"),s=t.getFloat("thickness"),n=t.getInt("steps"),a=t.getFloat("stepSize"),o=t.getValue("tracingMode")??0,l=Lt.reflectionRenderTarget,u=Lt.reflectionDepthPyramid,h=Lt.reflectionDepthPyramid,d=Lt.reflectionDepthLevels,c=Lt.reflectionEnvMap,p=Lt.reflectionPlanarTarget,m=Lt.reflectionPlanarEnabled,f=Hp("__splinePlanarMirror","float"),g=m.greaterThan(.5).and(f.greaterThan(.5)),y=Lt.reflectionResolveTarget,v=Lt.reflectionResolveEnabled,b=Lt.orthographicUniform.greaterThan(.5),_=fi(b,G(0,0,-1),xe(Rc)).toVar(),x=xe(Oa).toVar(),S=FS(_,x).toVar(),w=Ae(r.mul(.1),I(0),I(1)).toVar(),T=Lt.resolution,C=G(0).toVar(),M=v.greaterThan(.5).and(w.greaterThan(.05)).and(g.not()),A=xe(CW(S,H4)).toVar(),R=p9(c,A,w).toVar(),O=y.sample(Jl).level(I(0)).toVar();bt(M,()=>{let L=O.a.toVar();C.assign(Yt(R,O.rgb.div(L.max(1e-4)),Ae(L.mul(2),I(0),I(1))))}).Else(()=>{C.assign(PW({dials:{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:o},surface:{originView:Rc,normalV:x,screenUv:Jl,fragWindowZ:sD},camera:{projectionMatrix:rb,projectionMatrixInverse:vyt,worldMatrix:H4,near:yyt},resources:{colorMap:l,depthPyramid:u,depthPyramidNode:h,envMap:c},usePlanar:g,noisePixel:Jl.mul(T).floor()}))}),bt(g,()=>{let L=at(I(1).sub(Jl.x),Jl.y).toVar(),z=I(d.sub(1)),k=ii(Lv(w.mul(T.y).mul(d9).add(1)),z).toVar(),V=k.sub(1).max(0).floor().toVar(),H=I(2).pow(k).sub(1).max(0).toVar(),W=H.mul(.75).div(T.y).toVar();C.assign(c9(p,L,W,H.mul(.75),V))});let N=e.alpha.mul(e.mask).toVar(),B=N.div(Ae(N.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(N)),{color:C,calpha:B}})}),WCt=j(()=>{He(),nb(),cn(),dn(),OL=t=>t,dht=t=>t,Vn("outline",(t,e,i)=>{let r=t.getColor("outlineColor"),s=t.getColor("contourColor"),n=t.getFloat("outlineWidth"),a=t.getFloat("contourWidth"),o=t.getFloat("outlineThreshold"),l=t.getFloat("contourThreshold"),u=t.getFloat("outlineSmoothing"),h=t.getFloat("contourFrequency"),d=t.getVec3("contourDirection"),c=t.getBool("positionalLines"),p=t.getBool("compensation"),m=Lt.normalRenderTarget,f=Lt.normalRenderTargetDepth,g=Lt.resolution,y=Lt.pixelRatio,v=vm("randomColor","vec3").x.toVar(),b=sD.toVar(),_=Jl.toVar(),x=at(I(1).div(g.x),I(1).div(g.y)).toVar(),S=Lt.pcssHalton,w=Ac(Ja.xy.add(S)).mul(6.28318530718).toVar(),T=p.select(n.div(2),n),C=x.mul(T).mul(y).toVar(),M=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=st=>bm(st,9,w).mul(x),R=[],O=I(0).toVar();for(let st=0;st<9;st++){let[nt,xt]=M[st],pt=st===4?_:OL(_.add(at(C.x.mul(nt),C.y.mul(xt))).add(A(st))),K=OL(pt).toVar(),ct=dht(m.sample(K)).toVar();R.push(ct),bt(ct.a.notEqual(v).and(ct.a.notEqual(0)),()=>{let St=f.sample(K).r.add(1e-4);bt(b.greaterThan(St),()=>{O.assign(1)})})}let N=R[2].rgb.add(R[5].rgb.mul(2)).add(R[8].rgb).sub(R[0].rgb.add(R[3].rgb.mul(2)).add(R[6].rgb)),B=R[0].rgb.add(R[1].rgb.mul(2)).add(R[2].rgb).sub(R[6].rgb.add(R[7].rgb.mul(2)).add(R[8].rgb)),L=xl(kt(N,N).add(kt(B,B))).mul(O.oneMinus()).toVar(),z=G(r).toVar(),k=tr(o.sub(u),o.add(u),L).toVar(),V=xe(h0).toVar(),H=I(1).sub(l).toVar();bt(c,()=>{let st=Za.mul(d),nt=st.x.add(st.y).add(st.z).toVar(),xt=Oi(nt.mul(h).mul(.01)),pt=Qj(nt.mul(h)),K=tr(pt.mul(a.mul(.01)),pt.mul(a.mul(.02)),xt).toVar();bt(K.lessThan(1).and(k.equal(0)),()=>{z.assign(s),k.assign(1)})}).Else(()=>{let st=V.mul(d),nt=st.x.add(st.y).add(st.z).toVar(),xt=Qj(nt.mul(l)).toVar(),pt=Bn(nt.mul(h)).toVar(),K=tr(I(0),xt.mul(a),I(1).sub(pt)).toVar();bt(xt.greaterThan(H.mul(.5)).and(K.lessThan(1)).and(k.equal(0)),()=>{z.assign(s),k.assign(I(1).sub(K))})});let W=e.alpha.mul(k).mul(e.mask).toVar(),X=W.div(Ae(W.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(W)),{color:z,calpha:X}})}),qCt=j(()=>{He(),cn(),Vn("vertexColor",(t,e,i)=>{let r=u1t(),s=e.alpha.mul(e.mask).mul(r.a);return{color:r.rgb,calpha:sb(s,i)}})}),Uvt=j(()=>{RCt(),DCt(),NCt(),OCt(),ICt(),BCt(),VCt(),kCt(),zCt(),LCt(),FCt(),lvt(),UCt(),jCt(),GCt(),WCt(),qCt(),avt()});function cht(t){let e=t.data,i=[t.kind,t.type,`v=${!!e.visible}`,`m=${!!e.isMask}`,`p=${t.params.names().join(",")}`];if(t.type!=="light"){let r=sT[t.type];if(r!==void 0)for(let s of r)i.push(`${s}=${String(e[s])}`)}for(let[r,s]of t.uniformKinds)(s==="vec4array"||s==="floatArray")&&i.push(`${r}#${(t.params.getValue(r)??[]).length}`);if(t.type==="rainbow"&&i.push(`noise=${t.noiseCompiledIn!==!1}`,`forced=${t.noiseForced===!0}`),t.type==="displace"&&i.push(`dt=${String(e.displacementType)}`),t.type==="texture"||t.type==="video"||t.type==="matcap"){if(t.holders.length===0)throw new Error(`structuralKey: ${t.type} layer has no holder`);let r=e.texture??{};i.push(`holder=${t.holders.map(s=>s.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var HCt=j(()=>{Jv()});function Kn(t,e=1){let i=new ae(t);return new Dr(i.r,i.g,i.b,e)}function H9(t,e){if(t instanceof Dr)return t;if(t instanceof ae)return new Dr(t.r,t.g,t.b,1);if(typeof t=="number")return Kn(t);if(typeof t=="object"&&t!==null&&"r"in t&&"g"in t&&"b"in t){let i=t;return new Dr(i.r,i.g,i.b,i.a??1)}return e()}function pht(){let t=new Array(10).fill(new Me(0,0,0,1)).map(e=>e.clone());return t[1]=new Me(1,1,1,1),t}function mht(){let t=new Array(10).fill(1);return t[0]=0,t}function y2(t,e){let i=t.material;if((i==null||i.isTSLNodeMaterial!==!0)&&(i=t.object?.material,i==null||i.isTSLNodeMaterial!==!0))return e;if(e.kind==="light"){let s=i.lightLayer;if(s==null)return e;let n=s.data?.category,a=e.data?.category;return n===a?s:e}let r=i.layers?.[e.structIndex];return r!==void 0&&r.type===e.type?r:e}function fht(t,e){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`[spe] ${t}.element() needs a build-time constant index (got ${String(e)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return e}function qe(t,e,i,r){let s,n,a=t.params;switch(i){case"float":s=gt(Number(r??0));break;case"int":s=gt(Number(r??0),"int");break;case"axis":s=gt(["x","y","z"].indexOf(String(r)),"int");break;case"bool":s=gt(!!r);break;case"vec2":s=gt(r instanceof Q?r:new Q);break;case"vec3":s=gt(r instanceof P?r:new P);break;case"vec4":s=gt(r instanceof Me?r:new Me);break;case"color":{let o=H9(r,()=>Kn(16777215));s=gt(o),n=o;break}case"colorVec4":{let o=H9(r,()=>new Dr(1,1,1,1)),l=new Me(o.r,o.g,o.b,o.a),u=gt(l);u.onObjectUpdate(h=>{let d=y2(h,t).params.getLiveValue(e)??o;l.set(d.r,d.g,d.b,d.a)}),s=u,n=o;break}case"vec4array":{let o=Array.isArray(r)?r:[];s=function(l,u,h){let d=new Map;return{element(c){let p=fht(u,c),m=d.get(p);if(m===void 0){let f=gt(h[p]??new Me);f.onObjectUpdate(g=>(y2(g,l).params.getValue(u)??h)[p]??qvt),m=f,d.set(p,m)}return m},array:h,get value(){return h},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(h.length,c.length);p++){let m=c[p];Array.isArray(m)?h[p].set(m[0]??0,m[1]??0,m[2]??0,m[3]??1):m&&typeof m=="object"&&h[p].set(m.x??0,m.y??0,m.z??0,m.w??1)}}}}(t,e,o.length>0?o:[new Me]),n=o;break}case"floatArray":{let o=Array.isArray(r)?r:[0];s=function(l,u,h){let d=new Map;return{element(c){let p=fht(u,c),m=d.get(p);if(m===void 0){let f=gt(h[p]??0);f.onObjectUpdate(g=>{let y=y2(g,l).params.getValue(u);return Number((y??h)[p]??0)}),m=f,d.set(p,m)}return m},array:h,get value(){return h},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(h.length,c.length);p++)h[p]=Number(c[p])}}}(t,e,o.length>0?o:[0]),n=o;break}}i!=="vec4array"&&i!=="floatArray"&&i!=="colorVec4"&&(BW(s),s.onObjectUpdate(o=>{let l=y2(o,t).params.getValue(e);l!==void 0&&VW(s,l)})),a.set(e,s,n),t.uniformKinds.set(e,i)}function qS(t,e){let i=t.data;i.type!=="displace"?("alpha"in i&&t.params.has("alpha")&&t.params.setValue("alpha",Bv(i.alpha,e)*(i.visible?1:0)),i.type==="outline"&&t.params.has("compensation")&&t.params.setValue("compensation",!!i.compensation&&!!i.visible)):t.params.has("intensity")&&t.params.setValue("intensity",(Mn(i.intensity,e)??1)*(i.visible?1:0))}function jvt(t,e){qe(t,"alpha","float",e.alpha??1),qe(t,"mode","int",e.mode??0),qe(t,"isMask","float",e.isMask?1:0)}function Gvt(t,e,i,r){let s=new v2(t,e,i),n=i;if(qe(s,"alpha","float",Bv(n.alpha,r)),qe(s,"mode","int",n.mode??0),qe(s,"bumpMapIntensity","float",n.bumpMapIntensity??5),qe(s,"alphaOverride","float",Bv(n.alphaOverride,r)),i.visible)if(n.category==="lambert")qe(s,"emissive","color",r.color(n.emissive)??Kn(0)),qe(s,"occlusion","bool",n.occlusion??!0);else if(n.category==="toon")qe(s,"shininess","float",n.shininess??30),qe(s,"specular","color",r.color(n.specular)??Kn(1118481));else if(n.category==="physical"){qe(s,"roughness","float",n.roughness??.3),qe(s,"metalness","float",n.metalness??0),qe(s,"reflectivity","float",n.reflectivity??.5),qe(s,"occlusion","bool",n.occlusion??!0),qe(s,"normalScale","float",n.normalScale??1),qe(s,"aoMapIntensity","float",n.aoMapIntensity??1),qe(s,"emissive","color",n.emissive!==void 0?r.color(n.emissive)??Kn(0):Kn(0)),qe(s,"emissiveIntensity","float",n.emissiveIntensity??1);let a=n;a.clearcoat!==void 0&&(qe(s,"clearcoat","float",a.clearcoat),qe(s,"clearcoatRoughness","float",a.clearcoatRoughness??.1)),a.sheen!==void 0&&(qe(s,"sheen","float",a.sheen),qe(s,"sheenColor","color",a.sheenColor!==void 0?r.color(a.sheenColor)??Kn(16777215):Kn(16777215)),qe(s,"sheenRoughness","float",a.sheenRoughness??.5)),a.ior!==void 0&&(qe(s,"ior","float",a.ior),qe(s,"specularIntensity","float",a.specularIntensity??1),qe(s,"specularColor","color",a.specularColor!==void 0?r.color(a.specularColor)??Kn(16777215):Kn(16777215))),a.iridescence!==void 0&&(qe(s,"iridescence","float",a.iridescence),qe(s,"iridescenceIOR","float",a.iridescenceIOR??1.3),qe(s,"iridescenceThickness","float",a.iridescenceThickness??400))}else qe(s,"shininess","float",n.shininess??30),qe(s,"specular","color",n.specular!==void 0?r.color(n.specular)??Kn(1118481):Kn(1118481)),qe(s,"occlusion","bool",n.occlusion??!0);return s.node.alphaOverride=s.params.get("alphaOverride"),qS(s,r),s}function Wvt(t,e,i,r){let s=new HS("fragment",t,e,i),n=i.type==="texture"?i.texture.image!=null?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):i.type==="video"?r.video(i.texture.video):i.texture.image!=null?r.image(i.texture.image):r.getImage("");s.holders.push(n);let a=i.texture.wrapping??(i.type==="texture"?1e3:1001),o=function(u,h,d,c){let p=ee(u.getTexture(h,d,c));return p.onRenderUpdate(()=>u.getTexture(h,d,c)),p}(n,a,i.texture.minFilter??1008,i.texture.magFilter??1006);s.params.set("texture",o);let l=Mn(i.texture.rotation??0,r)??0;if(i.type==="matcap")qe(s,"rotation","float",l*qt.DEG2RAD);else{let u=gt(new Q(1,1));u.onRenderUpdate(()=>{let f=n.getTexture(a,i.texture.minFilter??1008,i.texture.magFilter??1006).image;u.value.set(f?.width??1,f?.height??1)}),s.params.set("textureSize",u),s.uniformKinds.set("textureSize","vec2");let h=gt(n.loaded||n.isBuffer?1:0);h.onRenderUpdate(()=>n.loaded||n.isBuffer?1:0),s.params.set("loaded",h),s.uniformKinds.set("loaded","float"),qe(s,"crop","float",i.crop?1:0),qe(s,"projection","int",i.projection??0),qe(s,"axis","axis",i.axis),qe(s,"projectionAxis","axis",i.projectionAxis),qe(s,"side","int",i.side??0);let d=i.size?new Q(Mn(i.size[0],r)??0,Mn(i.size[1],r)??0):new Q(100,100);qe(s,"size","vec2",d),qe(s,"blending","float",i.blending??0);let c=new Ts,p=new Hvt([Mn(i.texture.repeat?.[0]??1,r)??1,Mn(i.texture.repeat?.[1]??1,r)??1],[Mn(i.texture.offset?.[0]??0,r)??0,Mn(i.texture.offset?.[1]??0,r)??0],l,c),m=gt(c);BW(m),m.onObjectUpdate(f=>{let g=y2(f,s).params.getNodeValue("mat");g!==void 0&&VW(m,g)}),s.params.set("mat",m,p)}return jvt(s,{alpha:Bv(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),qS(s,r),s}function $Ct(t,e,i,r){if(i.type==="light")return Gvt(t,e,i,r);if(i.type==="texture"||i.type==="video"||i.type==="matcap")return Wvt(t,e,i,r);if(i.type==="displace")return function(o,l,u,h){if(u.displacementType!=="noise")throw new Error;let d=new HS("vertex",o,l,u),c=(p,m)=>Mn(p,h)??m;return qe(d,"offset","vec3",new P(...u.offset.map(p=>c(p,0)))),qe(d,"scale","float",c(u.scale,10)),qe(d,"intensity","float",c(u.intensity,8)),qe(d,"movement","float",c(u.movement,1)),qe(d,"noiseType","int",u.noiseType??0),qe(d,"voronoiStyle","int",u.voronoiStyle??0),qe(d,"smoothness","float",c(u.smoothness,.5)),qe(d,"seed","float",c(u.seed,0)),qe(d,"highCut","float",c(u.highCut,1)),qe(d,"lowCut","float",c(u.lowCut,0)),qe(d,"quality","int",Mn(u.quality,h)??1),qS(d,h),d}(t,e,i,r);let s=new HS("fragment",t,e,i),n=function(o,l){switch(o.type){case"cavity":return function(u,h){return{...ao(u,h),ridge:u.ridge,valley:u.valley}}(o,l);case"dust":return function(u,h){return{...ao(u,h),color:Sa(u.color,h),coverage:Mn(u.coverage,h)??.2,softness:Mn(u.softness,h)??.2,noiseStrength:Mn(u.noiseStrength,h)??.2,noiseScale:Mn(u.noiseScale,h)??1}}(o,l);case"fresnel":return function(u,h){let{bias:d,scale:c,intensity:p,factor:m,color:f}=u;return{...ao(u,h),color:Sa(f,h),bias:d,scale:c,intensity:p,factor:m}}(o,l);case"gradient":return function(u,h){let{gradientType:d,smooth:c,colors:p,steps:m,angle:f,offset:g,morph:y}=u;return{...ao(u,h),gradientType:d,smooth:c,colors:p.map(v=>new Me(v[0],v[1],v[2],v[3])),num:p.length,steps:m,offset:new Q(...g.map(v=>typeof v=="number"?v:0)),morph:new Q(...y.map(v=>typeof v=="number"?v:0)),angle:f}}(o,l);case"depth":return function(u,h){let{gradientType:d,near:c,far:p,isVector:m,isWorldSpace:f,origin:g,direction:y,colors:v,steps:b,smooth:_}=u;return{...ao(u,h),gradientType:d,near:c,far:p,isVector:m,isWorldSpace:f,origin:new P(...g),direction:y?new P(...y):new P(1,0,0),colors:v.map(x=>x!==void 0?new Me(x[0],x[1],x[2],x[3]):new Me(0,0,0,0)),steps:b.slice(0,v.length),smooth:_}}(o,l);case"normal":return function(u,h){let{cnormal:d}=u;return{...ao(u,h),cnormal:new P(d[0],d[1],d[2])}}(o,l);case"noise":return function(u,h){return{...ao(u,h),scale:u.scale,move:u.move,fA:new Q(...u.fA.map(d=>typeof d=="number"?d:0)),fB:new Q(...u.fB.map(d=>typeof d=="number"?d:0)),size:new P(...u.size),distortion:new Q(...u.distortion.map(d=>typeof d=="number"?d:0)),colorA:Sa(u.colorA,h),colorB:Sa(u.colorB,h),colorC:Sa(u.colorC,h),colorD:Sa(u.colorD,h),noiseType:u.noiseType,voronoiStyle:u.voronoiStyle,highCut:u.highCut,lowCut:u.lowCut,smoothness:u.smoothness,seed:u.seed,quality:u.quality}}(o,l);case"rainbow":return function(u,h){return{...ao(u,h),filmThickness:u.filmThickness,movement:u.movement,wavelengths:new P(...u.wavelengths),noiseStrength:u.noiseStrength,noiseScale:u.noiseScale,offset:new P(...u.offset)}}(o,l);case"toon":return function(u,h){return{...ao(u,h),positioning:u.positioning,colors:u.colors.map(d=>new Me(d[0],d[1],d[2],d[3])),num:u.colors.length,steps:u.steps,source:new P(...u.source),isWorldSpace:u.isWorldSpace,noiseStrength:u.noiseStrength,noiseScale:u.noiseScale,shadowColor:Sa(u.shadowColor,h),offset:new P(...u.offset)}}(o,l);case"outline":return function(u,h){return{...ao(u,h),outlineColor:Sa(u.outlineColor,h),contourColor:Sa(u.contourColor,h),outlineWidth:u.outlineWidth,contourWidth:u.contourWidth,outlineThreshold:u.outlineThreshold,contourThreshold:u.contourThreshold,outlineSmoothing:u.outlineSmoothing,contourFrequency:u.contourFrequency,contourDirection:new P(...u.contourDirection),positionalLines:u.positionalLines,compensation:u.compensation}}(o,l);case"transmission":return function(u,h){return{...ao(u,h),thickness:u.thickness,ior:u.ior,roughness:u.roughness,attenuationColor:u.attenuationColor!==void 0?Sa(u.attenuationColor,h):{r:1,g:1,b:1,a:1},attenuationDistance:u.attenuationDistance??0}}(o,l);case"reflection":return function(u,h){return{...ao(u,h),blur:Mn(u.blur,h)??0,thickness:Mn(u.thickness,h)??.001,steps:Mn(u.steps,h)??60,stepSize:Mn(u.stepSize,h)??.005,tracingMode:u.tracingMode,mirror:u.mirror??0}}(o,l);case"pattern":return function(u,h){return{...ao(u,h),style:u.style,projection:u.projection,axis:u.axis,blending:u.blending,offset:new Q(...u.offset.map(d=>typeof d=="number"?d:0)),colorA:Sa(u.colorA,h),colorB:Sa(u.colorB,h),frequency:new Q(...u.frequency.map(d=>typeof d=="number"?d:0)),size:u.size,variation:u.variation,smoothness:u.smoothness,zigzag:u.zigzag,rotation:u.rotation,vertical:new Q(...u.vertical.map(d=>typeof d=="number"?d:0)),horizontal:new Q(...u.horizontal.map(d=>typeof d=="number"?d:0)),sides:u.sides}}(o,l);case"vertexColor":return ao(o,l);default:return function(u,h){return{...ao(u,h),color:Sa(u.color,h)}}(o,l)}}(i,r),a=$9[i.type]??$9.color;for(let[o,l]of Object.entries(a))qe(s,o,l.kind,n[o]??l.def());if(i.type==="transmission"){let o=typeof window<"u"?window.innerWidth:1,l=typeof window<"u"?window.innerHeight:1;qe(s,"aspectRatio","vec2",o>=l?new Q(l/o,1):new Q(1,o/l))}return jvt(s,n),qS(s,r),s}var ght,IL,$9,qvt,Hvt,HS,v2,yht,$p,LW,XCt=j(()=>{dt(),mr(),k5(),w1t(),He(),ke(),FG(),wCt(),Jv(),Dc(),Uft(),cn(),avt(),EW(),lvt(),PCt(),Uvt(),tD(),HCt(),ght=t=>t,IL=t=>t,$9={color:{color:{kind:"color",def:()=>Kn(Jg)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>Kn(16777215)},bias:{kind:"float",def:()=>.1},scale:{kind:"float",def:()=>1},intensity:{kind:"float",def:()=>2},factor:{kind:"float",def:()=>1}},dust:{color:{kind:"color",def:()=>Kn(10323813)},coverage:{kind:"float",def:()=>.2},softness:{kind:"float",def:()=>.2},noiseStrength:{kind:"float",def:()=>.2},noiseScale:{kind:"float",def:()=>1}},rainbow:{filmThickness:{kind:"float",def:()=>30},movement:{kind:"float",def:()=>0},wavelengths:{kind:"vec3",def:()=>new P},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new P}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>Kn(16777215)},attenuationDistance:{kind:"float",def:()=>0}},reflection:{blur:{kind:"float",def:()=>0},thickness:{kind:"float",def:()=>.001},steps:{kind:"int",def:()=>60},stepSize:{kind:"float",def:()=>.005},tracingMode:{kind:"int",def:()=>1}},toon:{positioning:{kind:"int",def:()=>0},colors:{kind:"vec4array",def:pht},steps:{kind:"floatArray",def:mht},source:{kind:"vec3",def:()=>new P},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new Dr(0,0,0,0)},offset:{kind:"vec3",def:()=>new P}},outline:{outlineColor:{kind:"color",def:()=>Kn(16777215)},contourColor:{kind:"color",def:()=>Kn(16777215)},outlineWidth:{kind:"float",def:()=>.1},contourWidth:{kind:"float",def:()=>.1},outlineThreshold:{kind:"float",def:()=>.1},contourThreshold:{kind:"float",def:()=>.1},outlineSmoothing:{kind:"float",def:()=>.1},contourFrequency:{kind:"float",def:()=>.1},contourDirection:{kind:"vec3",def:()=>new P(0,1,0)},positionalLines:{kind:"bool",def:()=>!1},compensation:{kind:"bool",def:()=>!0}},depth:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},near:{kind:"float",def:()=>50},far:{kind:"float",def:()=>200},isVector:{kind:"float",def:()=>1},isWorldSpace:{kind:"float",def:()=>0},origin:{kind:"vec3",def:()=>new P},direction:{kind:"vec3",def:()=>new P(1,0,0)},colors:{kind:"vec4array",def:()=>[new Me(0,0,0,1),new Me(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new P(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new Q(1.7,9.2)},fB:{kind:"vec2",def:()=>new Q(8.3,2.8)},distortion:{kind:"vec2",def:()=>new Q(1,1)},colorA:{kind:"colorVec4",def:()=>new Dr(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new Dr(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},noiseType:{kind:"int",def:()=>0},voronoiStyle:{kind:"int",def:()=>0},highCut:{kind:"float",def:()=>1},lowCut:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},seed:{kind:"float",def:()=>.5},quality:{kind:"int",def:()=>1}},normal:{cnormal:{kind:"vec3",def:()=>new P(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:pht},steps:{kind:"floatArray",def:mht},offset:{kind:"vec2",def:()=>new Q},morph:{kind:"vec2",def:()=>new Q},angle:{kind:"float",def:()=>0}},pattern:{style:{kind:"int",def:()=>0},projection:{kind:"int",def:()=>0},axis:{kind:"axis",def:()=>"x"},blending:{kind:"float",def:()=>0},offset:{kind:"vec2",def:()=>new Q},colorA:{kind:"colorVec4",def:()=>new Dr(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},frequency:{kind:"vec2",def:()=>new Q(10,10)},size:{kind:"float",def:()=>.5},variation:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},zigzag:{kind:"float",def:()=>0},rotation:{kind:"float",def:()=>0},vertical:{kind:"vec2",def:()=>new Q(0,1)},horizontal:{kind:"vec2",def:()=>new Q(0,1)},sides:{kind:"int",def:()=>6}}},qvt=new Me,Hvt=class{constructor(t,e,i,r){this.repeat=t,this.offset=e,this.rotation=i,this.target=r,this.updateMatrix()}updateMatrix(){this.target.setUvTransform(this.offset[0],this.offset[1],this.repeat[0],this.repeat[1],0,0,0).premultiply(new Ts().makeRotation(this.rotation*qt.DEG2RAD))}},HS=class{constructor(t,e,i,r){this.kind=t,this.id=e,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new kW(e)}get type(){return this.data.type}get uniforms(){return this.params.uniforms}get alphaNode(){return this.params.getFloat("alpha")}get modeNode(){return this.params.getInt("mode")}get isMaskNode(){return this.params.getFloat("isMask")}get isMaskEnabled(){return"isMask"in this.data&&!!this.data.isMask}hasValue(t){return this.params.has(t)}setValue(t,e){if(t==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof e=="number"&&e!==0&&this.onNoiseMismatch!==void 0){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(t,e),void(i(e)&&(this.noiseCompiledIn=!0))}this.params.setValue(t,e)}getNode(t){return this.params.has(t)?this.params.get(t):void 0}getValue(t){return this.params.getValue(t)}getName(t){let e=/f\d+_(.*)/.exec(t);if(e&&e.length>1)return e[1];console.log(`Layer.getName: error ${t}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(t=>t.loaded)}dispose(){for(let t of this.holders)t instanceof gg||t.deref();this.holders.length=0}},v2=class extends HS{constructor(t,e,i){super("light",t,e,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},yht={displace_noise:[{nums:["intensity","scale","movement","smoothness","seed","highCut","lowCut"],vecs:["offset"]}],displace_map:[{nums:["intensity"],vecs:[]}],depth:[{nums:["near","far"],vecs:["origin","direction"]}],cavity:[{nums:["ridge","valley"],vecs:[]}],fresnel:[{nums:["bias","scale","intensity","factor"],vecs:[]}],dust:[{nums:["coverage","softness","noiseStrength","noiseScale"],vecs:[]}],rainbow:[{nums:["filmThickness","movement","noiseStrength","noiseScale"],vecs:["offset","wavelengths"]}],noise:[{nums:["scale","move","seed","highCut","lowCut","smoothness"],vecs:["size","distortion","fA","fB"]}],pattern:[{nums:["blending","size","variation","smoothness","zigzag","rotation"],vecs:["offset","frequency","vertical","horizontal"]}],outline:[{nums:["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],vecs:["contourDirection"]}],toon:[{nums:["noiseStrength","noiseScale"],vecs:["offset","source"]}],transmission:[{nums:["roughness","thickness","ior"],vecs:[]}],reflection:[{nums:["blur","thickness","steps","stepSize"],vecs:[]}],texture:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],video:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],gradient:[{nums:["angle"],vecs:["offset","morph"]}],matcap:[{nums:["rotation"],vecs:[],path:["texture"]}]},$p=class extends Re{constructor(t,e,i=!0,r,s=!1){super(),this.allowVariableSaves=i,this.isTSLNodeMaterial=!0,this.layerIdGen=0,this.layers=[],this.flavors=[],this.depthTwins=[],this.depthPrepass=!1,this.depthPrepassCutoff=0,this.depthPrepassTwins=[],this.flatShading=!1,this.wireframe=!1,this.emissiveNode=null,this.shapeBlendOptions=null,this.envMapRotation=Gh.rotation,this._shapeBlendResources=null,this._shapeBlendColorNode=null,this.shapeBlendObjectNormal=null,this.displacedObjectNormal=null,this.syntheticMapLayers=new Map,this._structuralKey=null,this._structuralKeyVersion=-1,this.forceRainbowNoise=new Set,this.root=r??this,this.isDepthPrepassTwin=s,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(t,e),jS.add(this),this.addEventListener("dispose",()=>function(n){jS.delete(n)}(this))}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let t=this._structuralKey;if(t===null||this._structuralKeyVersion!==this.version){try{t=function(r){let s=r.lightLayer,n=s.data,a=u=>{if(!u)return-1;if(typeof u!="string"){let c=r.syntheticMapLayers?.get(u);return c!==void 0?`img(${cht(c)};o=${JSON.stringify(u.offset??null)};r=${JSON.stringify(u.repeat??null)};rot=${JSON.stringify(u.rotation??null)})`:"img"}let h=r.layers.findIndex(c=>c.uuid===u);if(h===-1||r.layers[h].kind!=="fragment")return-1;let d=r.layers[h].type;return d==="texture"||d==="video"?h:-1},o=r.category==="physical",l=["spe-tsl-v1",`lights=${r.lights}`,`cat=${r.category}`,`lvis=${n.visible===!0}`,`lidx=${r.layers.indexOf(s)}`,`bump=${a(n.bumpMap)}`,`rough=${o?a(n.roughnessMap):-1}`,`metal=${o?a(n.metalnessMap):-1}`,`nrm=${o?a(n.normalMap):-1}`,`ao=${o?a(n.aoMap):-1}`,`emis=${o?a(n.emissiveMap):-1}`,`rch=${o?n.roughnessMapChannel??"luminance":""}`,`mch=${o?n.metalnessMapChannel??"b":""}`,`ach=${o?n.aoMapChannel??"r":""}`];for(let u of r.layers)l.push(cht(u));return l.join("|")}(this),this.shapeBlendOptions!==null&&(t+=`|sb:${this.uuid}:${this._shapeBlendResources!==null?1:0}`)}catch{t=super.customProgramCacheKey()}this._structuralKey=t,this._structuralKeyVersion=this.version}let e=this.envNode instanceof Gv?Gh.version:0,i=this.physicalLobes();return`${t}|env${e}|lobes${(i.clearcoat?1:0)|(i.sheen?2:0)|(i.iridescence?4:0)}`}get isRoot(){return this.root===this}applyDepthPrepassPolicy(){if(this.isDepthPrepassTwin)return this.depthPrepass=!1,this.colorWrite=!1,void(this.depthWrite=!0);let t=(e={transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.shapeBlendOptions!==null,data:this.root.data},u9&&e.transparent&&e.depthTest&&!e.wireframe&&!e.shapeBlend&&!function(i){let r=i?.layers;if(!r)return!1;for(let s of r)if(s.data.type==="transmission"&&s.data.visible)return!0;return!1}(e.data));var e;this.depthPrepass=t,this.depthWrite=!t}getDepthPrepassTwin(t){let e=this.depthPrepassTwins[t];if(e===void 0){let i=this.root;e=new $p(i.data,i.lastContext,i.allowVariableSaves,i,!0),e.flatShading=this.flatShading,e.side=t,e.wireframe=!1,e.depthPrepassCutoff=cft,e.applyDepthPrepassPolicy(),this.depthPrepassTwins[t]=e,i.depthTwins.push(e)}return e}get vertexObjectNormal(){return this.shapeBlendObjectNormal??this.root.displacedObjectNormal}get category(){return this.lightLayer.category}envReflectiveInLow(){let t=!1;for(let e of this.layers){let i=e.data;if(i?.category==="physical"&&(t=!0,i.roughnessMap!==void 0||i.metalnessMap!==void 0||typeof i.roughness!="number"||typeof i.metalness!="number"||i.clearcoat!==void 0||i.sheen!==void 0||i.iridescence!==void 0||i.ior!==void 0||i.metalness>.3||i.roughness<.4))return!0}return!t}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(t,e,i=!1){(this.data!==t||i)&&this.reset0(t,e)}reset0(t,e){this.lastContext=e,this.data=t;let i=t.layers??cs.defaultTwoLayerData("phong").layers;for(let n of this.layers)n.dispose();for(let n of this.syntheticMapLayers.values())n.dispose();this.syntheticMapLayers.clear();let r=[];for(let n of i)try{let a=$Ct(this.layerIdGen++,n.id,n.data,e.shared);a.type==="rainbow"&&this.armRainbowNoiseSpecialization(a),r.push(a)}catch(a){console.warn(`[spe] material layer '${n.data.type}' (${n.id}) failed to build \u2014 skipping this layer`,a)}this.layers=r,this.layers.reverse();for(let n=0;n<this.layers.length;n++)this.layers[n].structIndex=n;this.name=t.name??"Untitled Material";let s=this.layers.find(n=>n instanceof v2);if(s===void 0&&(s=Gvt(0,"",{...Hs.defaultData("light","phong"),visible:!1},e.shared)),this.lightLayer=s,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:I(0).toVar("accumAlpha"),lightsAvailable:this.lights&&(this.category==="phong"||this.category==="lambert"||this.category==="physical")},this.colorNode=Et(()=>this.buildColorStack())(),this.buildVertexStack(),this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=this.lights&&this.category==="lambert"&&this.lightLayer.params.has("emissive")?this.lightLayer.params.get("emissive"):null,this.aoNode=null,this.lights&&this.category==="physical"){let n=this.lightLayer.params,a=this.lightLayer.lightData;if(n.has("emissive")){let l=this.findTextureMapLayer(a.emissiveMap);this.emissiveNode=Et(()=>{let u=G(n.getColor("emissive")).mul(n.getFloat("emissiveIntensity"));return l!==null&&(u=u.mul(function(h){let d,c=h.get("texture"),p=h.has("loaded")?h.getFloat("loaded"):I(1),{uvs:m,weights:f}=aS(h);if(f!==null){let g=G(Pa(c.sample(m[0])).rgb).toVar(),y=G(Pa(c.sample(m[1])).rgb).toVar(),v=G(Pa(c.sample(m[2])).rgb).toVar();d=ur(g.mul(f.z).add(y.mul(f.x)).add(v.mul(f.y)))}else d=ur(G(Pa(c.sample(m[0])).rgb));return ur(Yt(G(0),d,p))}(l.params))),u})()}let o=this.findTextureMapLayer(a.aoMap);o!==null&&(this.aoNode=Et(()=>Yt(I(1),ML(o.params,a.aoMapChannel??"r"),n.getFloat("aoMapIntensity")))())}this.transparent=Dg(t,e.shared),this.applyDepthPrepassPolicy(),nS(this),this.needsUpdate=!0;for(let n of this.flavors)n?.syncFromRoot();for(let n of this.depthTwins)n.syncFromRoot();this.saveVariableLocations(e)}setTransparent(t,e){if(!this.isRoot)return void this.root.setTransparent(t,e);let i=this.transparent!==t;if(i){this.transparent=t,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=t,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=t,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||e?.markNeedsUpdateRendererDirty()}syncFromRoot(){let t=this.root;this.data=t.data,this.layers=t.layers,this.lightLayer=t.lightLayer,this.ctx=t.ctx,this.name=t.name,this.lights=t.lights,this.colorNode=t.colorNode,this.positionNode=t.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=t.emissiveNode,this.aoNode=t.aoNode,this.transparent=t.transparent,this.applyDepthPrepassPolicy(),this._applyShapeBlendGraph(),nS(this),this.needsUpdate=!0}getFlavor(t,e,i,r){if(!this.isRoot)return this.root.getFlavor(t,e,i,r);let s=i?6:(t?3:0)+e;if(s+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),s===0)return this;s-=1;let n=this.flavors[s];return n===void 0&&(n=new $p(this.data,this.lastContext,this.allowVariableSaves,this),n.flatShading=t,n.side=e,n.wireframe=i,r&&(n.shapeBlendOptions={...r},n.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},n._invalidateStructuralKey()),n.applyDepthPrepassPolicy(),this.flavors[s]=n),n}getShapeBlendBaseColor(){let t=this.layers.find(r=>r.kind==="fragment"&&r.type==="color"),e=t?.getValue("color"),i=t?.getValue("alpha");return{r:e?.r??1,g:e?.g??1,b:e?.b??1,a:i??1}}setShapeBlendResources(t){this._shapeBlendResources=t,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources||F4===null)return;let t=F4(this._shapeBlendResources);this.positionNode=t.position,this.shapeBlendObjectNormal=t.normal,this.normalNode=this.buildNormalNode(Jj(X4(t.normal))),this.castShadowPositionNode=t.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=t.color,this.colorNode=Et(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(t=>t instanceof v2)}findTextureMapLayer(t){if(!t)return null;if(typeof t!="string")return gU.is(t)?this.syntheticMapLayer(t):null;let e=this.layers.find(i=>i.uuid===t);return e===void 0||e.kind!=="fragment"?null:e.type==="texture"||e.type==="video"?e:null}syntheticMapLayer(t){if(!this.isRoot)return this.root.syntheticMapLayer(t);let e=this.syntheticMapLayers.get(t);if(e!==void 0)return e;try{let i=Hs.defaultData("texture"),r={...i,visible:!1,texture:{...i.texture,image:t.image,wrapping:t.wrapping??1e3,offset:t.offset??[0,0],repeat:t.repeat??[1,1],rotation:t.rotation??0,minFilter:t.minFilter??1008,magFilter:t.magFilter??1006}},s=Wvt(this.layerIdGen++,`mapImage${this.layerIdGen}`,r,this.lastContext.shared);return this.syntheticMapLayers.set(t,s),s}catch(i){return console.warn("[spe] light-layer map image failed to build \u2014 skipped",i),null}}buildNormalNode(t){if(this.lights&&this.category==="physical"&&!this.wireframe){let s=this.lightLayer.lightData,n=this.findTextureMapLayer(s.normalMap);if(n!==null){let a=this.lightLayer.params.getFloat("normalScale");return Et(()=>function(o,l,u){let h=G(u??Oa).toVar(),d=ur(Rc),c=o.get("texture"),p=o.has("loaded")?o.getFloat("loaded"):I(1),m=y=>{let v=at(y).toVar(),b=G(Pa(c.sample(v)).rgb.mul(2).sub(1)).toVar(),_=G(Yt(G(0,0,1),ur(b),p)).toVar();_.xy.mulAssign(l);let x=G(kv(d)).toVar(),S=G(zv(d)).toVar(),w=at(kv(v)).toVar(),T=at(zv(v)).toVar(),C=G(xe(ur(h))).toVar(),M=G(Zr(ur(S),C)).toVar(),A=G(Zr(C,ur(x))).toVar(),R=G(ur(M).mul(w.x).add(ur(A).mul(T.x))).toVar(),O=G(ur(M).mul(w.y).add(ur(A).mul(T.y))).toVar(),N=I(Qt(kt(ur(R),ur(R)),kt(ur(O),ur(O)))).toVar(),B=I(fi(N.equal(0),I(0),$u(aD).mul(xW(N)))).toVar();return ur(xe(ur(R).mul(_.x.mul(B)).add(ur(O).mul(_.y.mul(B))).add(C.mul(_.z))))},{uvs:f,weights:g}=aS(o);if(g!==null){let y=m(f[0]),v=m(f[1]),b=m(f[2]);return ur(xe(y.mul(g.z).add(v.mul(g.x)).add(b.mul(g.y))))}return m(f[0])}(n.params,a,t))()}}let e=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&this.category!=="lambert";if(e===null||!i||this.wireframe)return t;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return Et(()=>function(s,n,a){let o=G(a??Oa).toVar(),l=ur(Rc),u=s.get("texture"),{uvs:h,weights:d}=aS(s);if(d!==null){let c=nE(l,ur(o),sE(u,h[0],n)),p=nE(l,ur(o),sE(u,h[1],n)),m=nE(l,ur(o),sE(u,h[2],n));return ur(xe(c.mul(d.z).add(p.mul(d.x)).add(m.mul(d.y))))}return nE(l,ur(o),sE(u,h[0],n))}(e.params,r,t))()}buildVertexStack(){let t=this.layers.filter(i=>i.kind==="vertex");if(t.length===0)return this.positionNode=null,void(this.displacedObjectNormal=null);let e=function(i){let r=Lr("vec3","vDisplacedNormal");return{position:Et(s=>{let n=mo(Uv),a=mo(SW);for(let l=0;l<i.length;l++){let u=ECt(i[l],mo(Uv),a);n=l===0?u.position:mo(n.add(u.position).mul(.5)),a=u.normal}let o=G(n).toVar();return r.assign(a),s.needsPreviousData?.()===!0&&uD.assign(o),o})(),normal:r}}(t.map(i=>i.params));this.positionNode=e.position,this.displacedObjectNormal=e.normal}displacedNormalView(){let t=this.root.displacedObjectNormal;return t===null?null:Jj(X4(t))}maskSourceFor(t){let e=this.layers[t];if(e.kind==="fragment"&&e.isMaskEnabled)return null;let i=this.layers[t+1];return i!==void 0&&i.kind==="fragment"&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(t,e,i){let r=I(1);e!==null&&(r=this.evaluateMask(e));let s={alpha:i?.alpha??t.alphaNode,isMask:t.isMaskNode,mask:r,mode:t.modeNode,noiseCompiledIn:t.noiseCompiledIn},n=evt(t.type)(t.params,s,this.ctx);return i?.color?{...n,color:i.color}:n}evaluateMask(t){let e=this.runLayerBuilder(t,null);return oD(e.color.mul(e.calpha))}buildColorStack(){let t=this.lightLayerIndex(),e=t===-1?0:t,i=null;for(let r=0;r<e;r++){let s=this.layers[r];if(s.kind!=="fragment")continue;if(i===null){let a=this._shapeBlendColorNode;i=IL(this.runLayerBuilder(s,this.maskSourceFor(r),a?{color:IL(a.rgb),alpha:ght(a.w)}:void 0).color);continue}if(s.isMaskEnabled)continue;let n=this.runLayerBuilder(s,this.maskSourceFor(r));i=wR(i,n.color,n.calpha,s.modeNode)}return i??xyt(Jg)}setup(t){t.context.setupClearcoatNormal=()=>n1t(Oa,"NORMAL","vec3"),super.setup(t)}setupLightingModel(){let t=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(e,i=null,r=null,s=!1){switch(e){case"physical":{let n=new nvt(r?.clearcoat===!0,r?.sheen===!0,r?.iridescence===!0,!1,!1,!1);return n.envIrradianceActive=s,n}case"lambert":return new xv(!1);case"toon":{let n=new svt;return n.aoOcclusionGate=i,n}default:return new xv}}(this.category,t,this.physicalLobes(),this.envNode instanceof Gv)}physicalLobes(){let t=this.lightLayer.params;return{clearcoat:t.has("clearcoat"),sheen:t.has("sheen"),iridescence:t.has("iridescence")}}setupVariants(t){if(!this.lights)return;let e=null,i=null;if(this.category==="physical"){let r=this.lightLayer.lightData,s=this.findTextureMapLayer(r.roughnessMap);s!==null&&(e=Et(()=>ML(s.params,r.roughnessMapChannel??"luminance"))());let n=this.findTextureMapLayer(r.metalnessMap);n!==null&&(i=Et(()=>ML(n.params,r.metalnessMapChannel??"b"))())}(function(r,s,n=null,a=null){if(r==="phong"||r==="toon")$4.assign(s.getFloat("shininess").max(1e-4)),Z1.assign(s.getColor("specular"));else if(r==="physical"){let o=s.getFloat("metalness"),l=s.getFloat("roughness"),u=s.getFloat("reflectivity");if(n!==null&&(l=Wv(n.mul(l))),a!==null&&(o=Wv(Ae(a.mul(o),I(0),I(1)))),Byt.assign(o),AW.assign(Ae(l,I(.0525),I(1))),s.has("ior")){let h=s.getFloat("ior"),d=s.has("specularColor")?G(s.getColor("specularColor")):G(1),c=s.has("specularIntensity")?s.getFloat("specularIntensity"):I(1);lR.assign(h),Z1.assign(ii(Zyt(lR.sub(1).div(lR.add(1))).mul(d),G(1)).mul(c)),G9.assign(Yt(co(Z1),co(Vo.rgb),o)),t9.assign(Yt(c,I(1),o))}else{let h=G(u.pow(2).mul(.16));Z1.assign(h),G9.assign(Yt(h,co(Vo.rgb),o)),t9.assign(I(1))}if(j9.assign(co(Vo.rgb).mul(Rr(o))),s.has("clearcoat")&&(byt.assign(s.getFloat("clearcoat")),bW.assign(Ae(s.getFloat("clearcoatRoughness"),I(.0525),I(1)))),s.has("sheen")){let h=s.has("sheenColor")?G(s.getColor("sheenColor")):G(1);i1t.assign(h.mul(s.getFloat("sheen"))),r1t.assign(Ae(s.getFloat("sheenRoughness"),I(.07),I(1)))}s.has("iridescence")&&(Eyt.assign(s.getFloat("iridescence")),Pyt.assign(s.getFloat("iridescenceIOR")),Ryt.assign(s.getFloat("iridescenceThickness")))}})(this.category,this.lightLayer.params,e,i)}setupLighting(t){let e=this.lights===!0||this.lightsNode!==null,i=this.lights===!0?this.setupMaterialLightings(t):[],r=e?this.lightsNode??t.lightsNode:null,s=this.lights===!0?G(0):Vo.rgb,n=G(0),a=G(0);if(r&&(i.length>0||r.getScope().hasLights)){let o=this.setupLightingModel()||null,l=Nyt(r,o,i,this.backdropNode,this.backdropAlphaNode),u=l,h=u._value??(u._value=u.getContext());n=h.reflectedLight.directSpecular,a=h.reflectedLight.indirectSpecular,s=l}return this.emissiveNode!==null&&this.emissiveNode!==void 0&&(Zj.assign(G(this.emissiveNode)),s=s.add(Zj)),Et(()=>this.applyPostLighting(s,n,a))()}applyPostLighting(t,e,i){let r,s=this.ctx.accumAlpha,n=this.lights===!0,a=this.lightLayerIndex(),o=a===-1?0:a+1,l=I(1);if(n){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p)),r=function(m){let{outgoing:f,directSpecular:g,indirectSpecular:y,shadingAlpha:v,shadingBlend:b,mask:_,occlusion:x=null,ctx:S}=m,w=G(f).toVar();return bt(yW(TW(w,co(Vo.rgb))),()=>{let T=Ae(mi(g.add(y)),I(0),I(1));S.accumAlpha.addAssign(Rr(S.accumAlpha).mul(v).mul(_).mul(T)),w.assign(wR(co(Vo.rgb),w,v.mul(_),b)),w.mulAssign(rvt(x))}),w}({outgoing:t,directSpecular:e,indirectSpecular:i,shadingAlpha:this.lightLayer.alphaNode,shadingBlend:this.lightLayer.modeNode,mask:l,occlusion:this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null,ctx:this.ctx})}else r=G(t).toVar();let u=r,h=!1;for(let p=o;p<this.layers.length;p++){let m=this.layers[p];if(m.kind!=="fragment"||m.isMaskEnabled)continue;let f=this.runLayerBuilder(m,this.maskSourceFor(p));u=wR(u,f.color,f.calpha,m.modeNode),h=!0}if(h&&r.assign(u),!n){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p))}let d=this.lightLayer.params.has("alphaOverride")?this.lightLayer.params.getFloat("alphaOverride"):I(1),c=n?s:s.mul(l);if(Vo.a.assign(c.mul(d)),Vo.a.lessThanEqual(Iyt("depthPrepassCutoff","float")).discard(),this.dithering){let p=MW(Ja.xy),m=G(.25/255,-.25/255,.25/255),f=Yt(m.mul(2),m.mul(-2),p);r.assign(r.add(f))}return r}getLayersOfType(t){return this.layers.filter(e=>e.type===t)}getLayerByUuid(t){return this.layers.find(e=>e.uuid===t)}armRainbowNoiseSpecialization(t){let e=this.root.forceRainbowNoise.has(t.uuid),i=t.data;if(t.noiseForced=e,t.noiseCompiledIn=e||fv(i.noiseStrength),t.noiseCompiledIn===!1){let r=t.uuid;t.onNoiseMismatch=s=>this.root.ensureRainbowNoiseCompiled(r,s)}}ensureRainbowNoiseCompiled(t,e){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(t,e);let i=this.data.layers?.data(t);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(t)&&!fv(i.noiseStrength)||this.getLayerByUuid(t)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(t),this.reset0(this.data,this.lastContext),e!==void 0&&this.getLayerByUuid(t)?.setValue("noiseStrength",e),!0)}updateByOp(t,e,i){if(this.isRoot)if(e!==void 0?this.data=e:e=this.data,this.setTransparent(Dg(e,i.shared),i.scene),t.path[0]==="layers"){let r=t.path[1];if(r===void 0)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(e,i);t.type===0&&t.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(a=>a.uuid===r);if(!s)return;let n=e.layers.data(r);if(!n)return;this.updateLayerByOp(s,{...t,path:t.path.slice(2)},n,i)?this.reset0(e,i):nS(this)}else this.reset0(e,i);else this.root.updateByOp(t,e,i)}static hasVariableString(t){return typeof t=="string"||Array.isArray(t)&&t.some(e=>typeof e=="string")}updateLayerTextureByOp(t,e,i){if(e.path.length!==1||e.type!==0)return!0;let r=e.props,s=i.texture;if(!s)return!0;let n=t.data.texture;for(let o of Object.keys(r))if(o!=="repeat"&&o!=="offset"&&o!=="rotation"||$p.hasVariableString(s[o])||$p.hasVariableString(n?.[o]))return!0;if(t.type==="matcap")return"repeat"in r||"offset"in r||(t.data=i,t.setValue("rotation",(s.rotation??0)*qt.DEG2RAD),!1);let a=t.getValue("mat");if(!a)return!0;if(t.data=i,"repeat"in r){let o=s.repeat;a.repeat=[o?.[0]??1,o?.[1]??1]}if("offset"in r){let o=s.offset;a.offset=[o?.[0]??0,o?.[1]??0]}return"rotation"in r&&(a.rotation=s.rotation??0),a.updateMatrix(),!1}updateLayerByOp(t,e,i,r){if(e.path[0]==="texture")return this.updateLayerTextureByOp(t,e,i);if(e.path[0]!==void 0||e.type!==0)return!0;let s=e.props;if("type"in s||"category"in s||"visible"in s||"noiseType"in s)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let n of Object.keys(s)){if(n==="isMask")return!0;if(t.type==="rainbow"&&n==="noiseStrength"&&t.noiseCompiledIn!==void 0){let h=i[n];if((t.noiseForced===!0||fv(h))!==t.noiseCompiledIn)return!0}let a=sT[t.type];if(a!==void 0&&a.includes(n))return!0;let o=Wgt[t.type];if(o!==void 0&&o.includes(n)){let h=t.getValue(n),d=s[n];if(Array.isArray(h)&&Array.isArray(d)&&h.length!==d.length)return!0}let l=i[n],u=t.data[n];if(n!=="axis"&&(typeof l=="string"||typeof u=="string")||Array.isArray(l)&&l.some(h=>typeof h=="string")||Array.isArray(u)&&u.some(h=>typeof h=="string"))return!0}t.data=i;for(let n of Object.keys(s))this.applyLayerValue(t,n,i,r.shared);return!1}applyLayerValue(t,e,i,r){let s=i;if((e==="alpha"||e==="visible"||e==="intensity")&&(qS(t,r),e!=="intensity"||t.type==="displace"))return;if(e==="alphaOverride"&&t instanceof v2)return void t.setValue("alphaOverride",Bv(s[e],r));if(!t.hasValue(e))return;let n=t.uniformKinds.get(e),a=s[e];switch(n){case"color":case"colorVec4":{let o=t.getValue(e),l=typeof a=="string"?r.color(a):H9(a,()=>o??new Dr(1,1,1,1));o&&l&&o.setRGBA(l.r,l.g,l.b,"a"in l?l.a:1);break}case"vec2":{let o=t.getValue(e);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y));break}case"vec3":{let o=t.getValue(e);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y),Number(a[2]??o.z));break}case"vec4array":{let o=t.getValue(e);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++){let u=a[l];o[l].set(u[0],u[1],u[2],u[3])}break}case"floatArray":{let o=t.getValue(e);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++)o[l]=Number(a[l]);break}case"axis":t.setValue(e,["x","y","z"].indexOf(String(a)));break;case"bool":t.setValue(e,!!a);break;default:(typeof a=="number"||typeof a=="boolean")&&t.setValue(e,a)}}onVariableUpdate(t,e,i){if(t[0]==="alphaOverride")return this.setTransparent(Dg(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(e)/100,1)));if(t[0]!=="layer")return;let r=t[1],s=t[2];if(!r||!s)return;let n=this.layers.find(l=>l.uuid===r);if(!n?.hasValue(s))return;if(s==="alpha")return this.setTransparent(Dg(this.data,i.shared),i.scene),void n.setValue(s,Math.max(0,Math.min(Number(e)/100,1)));let a=n.getValue(s),o=t[3];(o==="x"||o==="y"||o==="z")&&a?.isVector3||(o==="x"||o==="y")&&a?.isVector2?a[o]=Number(e):a instanceof pi||n.setValue(s,e)}saveVariableLocations(t){if(!this.allowVariableSaves)return;let e=this.data.layers?.find(i=>i.data.type==="light");e&&t.shared.getVariable(e.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{let r=i.data;"alpha"in r&&typeof r.alpha=="string"&&t.shared.getVariable(r.alpha,["material",this.uuid,"layer",i.id,"alpha"]);let s=i.data.type==="displace"?r.displacementType==="noise"?"displace_noise":"displace_map":i.data.type,n=yht[s];if(n)for(let a of n){let o=r;for(let l of a.path??[])l in o&&(o=o[l]);for(let l of a.nums)l in o&&t.shared.getVariable(o[l],["material",this.uuid,"layer",i.id,...a.path??[],l]);for(let l of a.vecs)l in o&&o[l].forEach((u,h)=>{t.shared.getVariable(u,["material",this.uuid,"layer",i.id,...a.path??[],l,h===0?"x":h===1?"y":"z"])})}})}clampUniformsForPreview(t,e){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=r.uniforms[`f${r.id}_intensity`];s.value=i(s.value,t,e)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(t=>t.assetsLoaded))return!1;for(let t of this.root.syntheticMapLayers.values())if(!t.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let t of this.layers)t.dispose();for(let t of this.syntheticMapLayers.values())t.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let t of this.flavors)t?.dispose();for(let t of this.depthTwins)t.dispose()}},LW=class extends $p{constructor(t,e,i){super(t,e,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(e)}}});function jl(t,e){let i=ci(t.xyz);return ci(e.add(Zr(i,Zr(i,e).add(e.mul(t.w))).mul(2)))}function Ly(t){let e=Mv(t),i=Mv(G(t.y.sub(19.1),t.z.add(33.4),t.x.add(47.2))),r=Mv(G(t.z.add(74.2),t.x.sub(124.5),t.y.add(99.4)));return G(e,i,r)}function vht(t,e){return $vt({p:t,seed:e})}function bht(t,e,i){return G(SR(ci(t.add(G(i)).mul(e))),SR(ci(t.add(G(i.add(20))).mul(e))),SR(ci(t.add(G(i.sub(30))).mul(e))))}function BL(t){return{f:(e,i=0)=>hl(t.node(e)??t.getUniform(e,i)),v3:e=>ci(t.node(e)??t.getUniform(e,null)),v4:e=>Oo(t.node(e)??t.getUniform(e,null)),tex:e=>t.node(e)??t.getTexture(e,null)}}function YCt(t,e){switch(t){case"position":return function(i){let r=BL(i.registry);return Et(()=>{let s=bi(),n=i.depTexture("uCurrentPosition"),a=i.depTexture("uCurrentVelocity"),o=i.depTexture("uCurrentEmissionRate"),l=Oo(n.sample(s)).toVar(),u=ci(l.xyz).toVar(),h=Oo(o.sample(s)).toVar(),d=hl(h.x).toVar(),c=hl(h.y).toVar(),p=hl(h.z).toVar(),m=ci(Oo(r.tex("uOriginalPosition").sample(s)).xyz.mul(r.v3("uEmitterSize"))).toVar(),f=Oo(a.sample(s)).toVar(),g=ci(f.xyz).toVar(),y=hl(f.w).toVar(),v=r.f("uMaxLifeTime",1),b=Ai(.5,y),_=I(3).mul(b),x=g.mul(I(1).add(_)),S=g.mul(ii(r.f("uFPSRatio",1),I(5)));u.addAssign(Yt(S,x,b));let w=jl(r.v4("uWorldQuaternion"),m).add(r.v3("uWorldOffset"));u.assign(Yt(u,w,d)),p.assign(Yt(p,r.f("uTime"),d));let T=Qt(v.sub(r.f("uTime").sub(p)),I(0)).div(v);return Yt(lt(0),lt(u,T),c)})()}(e);case"velocity":return function(i){let r=BL(i.registry),s=i.features;return Et(()=>{let n=bi(),a=i.depTexture("uCurrentPosition"),o=i.depTexture("uCurrentVelocity"),l=i.depTexture("uCurrentEmissionRate"),u=ci(Oo(a.sample(n)).xyz).toVar(),h=ci(Oo(r.tex("uOriginalPosition").sample(n)).xyz).toVar(),d=ci(Oo(r.tex("uDirections").sample(n)).xyz).toVar(),c=ci(Oo(o.sample(n)).xyz).toVar(),p=Oo(l.sample(n)).toVar(),m=hl(p.x).toVar(),f=hl(p.y).toVar(),g=hl(Oo(o.sample(n)).w).toVar(),y=I(1).sub(r.f("uRandomMassFactor").mul(function(w){return hl(w.dot(at(12.9898,78.233)).sin().mul(43758.5453).fract())}(function(w){return w.xy}(h)).mul(.5).add(.5))).toVar(),v=r.f("uSpeed",1),b=r.f("uNoiseStrength"),_=r.f("uNoiseScale"),x=r.f("uNoiseSeed");bt(f.equal(1),()=>{s.USE_CURL_NOISE&&(bt(_.greaterThan(0),()=>{c.assign(vht(ci(u.mul(_).mul(.002)),x).mul(b.add(1)).mul(.05).mul(v))}),bt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(vht(u,x).mul(b).mul(.05).mul(v))})),s.USE_SIMPLEX_NOISE&&(bt(_.greaterThan(0),()=>{c.assign(G(Mv(ci(u.mul(_).mul(.001))).mul(b.add(1)).mul(.1)).mul(v))}),bt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(G(Mv(ci(u.mul(b).mul(.001))).mul(.05)).mul(v))})),s.USE_FBM_NOISE&&(bt(_.greaterThan(0),()=>{c.assign(bht(ci(u.mul(_).mul(.001)),b.add(1),x).mul(v))}),bt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(bht(ci(u.mul(b).mul(.001)),b.add(1),x).mul(.1).mul(v))})),function(w,T,C,M,A){if(!w.features.USE_COLLIDER)return;let R=Qt(T.f("uBounce").mul(2),I(.01)).toVar(),O=T.f("particleSize");if(w.features.USE_SPHERE_COLLIDER){let N=T.v3("uColliderSize"),B=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))).toVar(),L=ci(B.div(N)).toVar(),z=mi(L).toVar();bt(z.lessThanEqual(I(1).add(O.div(mi(N)))).and(A.equal(0)),()=>{let k=L.mul(I(1).add(O.div(mi(N)))),V=xe(ci(k.div(N.mul(N))));V=jl(T.v4("uColliderQuaternion"),V),M.assign(FS(M,V).mul(R)),A.assign(1)}).Else(()=>{A.assign(0)})}if(w.features.USE_BOX_COLLIDER){let N=ci(T.v3("uColliderSize").div(2)),B=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))).toVar(),L=ci(Le(B).sub(N)).toVar(),z=Qt(L.x,Qt(L.y,L.z)).toVar();bt(z.lessThanEqual(O.mul(.5)).and(A.equal(0)),()=>{let k=G(0).toVar();bt(L.x.greaterThan(L.y).and(L.x.greaterThan(L.z)),()=>{k.assign(G(Ku(B.x),0,0))}).ElseIf(L.y.greaterThan(L.z),()=>{k.assign(G(0,Ku(B.y),0))}).Else(()=>{k.assign(G(0,0,Ku(B.z)))});let V=jl(T.v4("uColliderQuaternion"),ci(k));M.assign(FS(M,V).mul(R)),A.assign(1)}).Else(()=>{A.assign(0)})}}(i,r,u,c,g),function(w,T,C,M){if(!w.features.USE_ATTRACTOR)return;let A=T.f("uForceIntensity"),R=T.f("uForceDamping");if(w.features.USE_FORCE_LOCAL_SPACE){let O,N,B=T.f("particleSize");if(w.features.USE_SPHERE_COLLIDER){let L=T.v3("uColliderSize"),z=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos"))));O=mi(ci(z.div(L))).toVar(),N=I(1)}else{let L=ci(T.v3("uColliderSize").div(2)),z=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))),k=ci(Le(z).sub(L));O=Qt(k.x,Qt(k.y,k.z)).toVar(),N=B}bt(O.lessThanEqual(N),()=>{let L=w.features.USE_SPHERE_COLLIDER?I(1).sub(O).mul(A):Qt(I(1).sub(N.div(O)),I(0)).mul(A),z=ci(C.sub(T.v3("uColliderPos"))),k=xe(z).mul(L);M.subAssign(k),M.mulAssign(R)})}else{let O=ci(C.sub(T.v3("uColliderPos"))),N=xe(O).mul(A);M.subAssign(N),M.mulAssign(R)}}(i,r,u,c),function(w,T,C,M,A,R,O){if(!w.features.USE_VORTEX)return;let N=T.f("particleSize"),B=ci(T.v3("uColliderSize").div(2)),L=jl(T.v4("uColliderQuaternionInvert"),ci(C.sub(T.v3("uColliderPos")))).toVar(),z=ci(Le(L).sub(B)).toVar(),k=Qt(z.x,Qt(z.y,z.z)).toVar();bt(k.lessThanEqual(N),()=>{let V=T.f("uForceIntensity"),H=T.v3("uColliderPos").add(jl(T.v4("uColliderQuaternion"),G(0))),W=ci(H.sub(C)).toVar(),X=G(0,1,.01),st=xe(Zr(X,jl(T.v4("uColliderQuaternion"),W))).toVar(),nt=mi(W.mul(V).mul(3)).toVar();M.assign(st.mul(nt).mul(.005));let xt=jl(T.v4("uWorldQuaternion"),A);M.addAssign(xt.mul(O).mul(I(1).sub(T.f("uForceDamping"))).div(R.mul(.5)))})}(i,r,u,c,d,y,v)});let S=s.USE_NORMALS?d:r.v3("uDirectionsAxis");return c.assign(Yt(c,jl(r.v4("uWorldQuaternion"),S).mul(v),m)),c.addAssign(r.v3("uGravity").div(y.mul(.5)).mul(I(1).sub(g))),lt(c,g)})()}(e);case"emissionRate":return function(i){let r=BL(i.registry);return Et(()=>{let s=bi(),n=i.depTexture("uCurrentEmissionRate"),a=hl(Oo(r.tex("uIndex").sample(s)).x).toVar(),o=Oo(n.sample(s)).toVar(),l=hl(o.y).toVar(),u=hl(o.z).toVar(),h=r.f("uLastIndexEmitted"),d=r.f("uParticlesToEmit"),c=Ai(h,a),p=Ai(a,h.add(d).sub(1)),m=c.mul(p);return u.assign(Yt(u,r.f("uTime"),m)),lt(m,Yt(l,I(1),m),u,1)})()}(e)}}var hl,ci,Oo,$vt,_ht,xht,VL,Xvt,KCt=j(()=>{He(),uT(),hl=t=>t,ci=t=>t,Oo=t=>t,$vt=Et(t=>{let e=ci(t.p.add(t.seed)).toVar(),i=G(.1,0,0),r=G(0,.1,0),s=G(0,0,.1),n=Ly(ci(e.sub(i))).toVar(),a=Ly(ci(e.add(i))).toVar(),o=Ly(ci(e.sub(r))).toVar(),l=Ly(ci(e.add(r))).toVar(),u=Ly(ci(e.sub(s))).toVar(),h=Ly(ci(e.add(s))).toVar(),d=l.z.sub(o.z).sub(h.y).add(u.y),c=h.x.sub(u.x).sub(a.z).add(n.z),p=a.y.sub(n.y).sub(l.x).add(o.x);return xe(G(d,c,p).mul(5))})}),ZCt=j(()=>{dt(),mr(),He(),KCt(),_ht=class{constructor(){this.nodes=new Map,this.textureNodes=new Map}getUniform(t,e){let i=this.nodes.get(t);return i||(i=gt(e),this.nodes.set(t,i)),i}getTexture(t,e){let i=this.textureNodes.get(t);return i||(i=ee(e??new pi),this.textureNodes.set(t,i)),i}node(t){return this.nodes.get(t)??this.textureNodes.get(t)}adopt(t){for(let e of Object.keys(t)){let i=t[e].value;if(i instanceof pi||i&&typeof i=="object"&&i.isTexture){let r=this.getTexture(e,i);r.value=i,Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(s){r.value=s}}})}else{let r=this.getUniform(e,i);r.value=i,Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(s){r.value=s}}})}}}},xht=class{constructor(t,e,i,r){this.name=t,this.kind=e,this.initialTexture=i,this.currentIndex=0,this.registry=new _ht,this.depTextureNodes=new Map,this.dependencies=[],this.nodeMaterial=null,this._uniformsStore={};let s=()=>new ri(r,r,{type:Qe,minFilter:De,magFilter:De,wrapS:Cn,wrapT:Cn,depthBuffer:!1});this.renderTargets=[s(),s()],this.material=Object.defineProperty({},"uniforms",{get:()=>this._uniformsStore,set:n=>{this.registry.adopt(n),this._uniformsStore=n}})}get currentRenderTarget(){return this.renderTargets[this.currentIndex]}get nextRenderTarget(){return this.renderTargets[1-this.currentIndex]}advance(){this.currentIndex=1-this.currentIndex}dispose(){this.renderTargets[0].dispose(),this.renderTargets[1].dispose(),this.nodeMaterial?.dispose()}},VL=new Pr,Xvt=class{constructor(t,e,i,r){this.sizeX=t,this.sizeY=e,this.renderer=i,this.features=r,this.variables=[],this._copyMaterial=null,this._copyTextureNode=ee(new pi)}addVariable(t,e,i){let r=new xht(t,t==="uCurrentPosition"?"position":t==="uCurrentVelocity"?"velocity":"emissionRate",i,this.sizeX);return this.variables.push(r),r}setVariableDependencies(t,e){t.dependencies=e;for(let i of e)t.depTextureNodes.has(i.name)||t.depTextureNodes.set(i.name,ee(i.currentRenderTarget.texture))}init(){if(!this._copyMaterial){let t=new Re;t.name="WebGPUComputation.copy",t.fragmentNode=lt(this._copyTextureNode),t.depthTest=!1,t.depthWrite=!1,t.blending=cr,this._copyMaterial=t}for(let t of this.variables){this._copyTextureNode.value=t.initialTexture;for(let i of t.renderTargets)this._renderQuad(this._copyMaterial,i);let e=new Re;e.name=`WebGPUComputation.${t.kind}`,e.fragmentNode=YCt(t.kind,{features:this.features,registry:t.registry,depTexture:i=>{let r=t.depTextureNodes.get(i);if(!r)throw new Error(`WebGPUComputationRenderer: variable "${t.name}" reads undeclared dependency "${i}"`);return r},resolution:new Q(this.sizeX,this.sizeY)}),e.depthTest=!1,e.depthWrite=!1,e.blending=cr,e.needsUpdate=!0,t.nodeMaterial=e}}compute(){for(let t of this.variables)if(t.nodeMaterial){for(let e of t.dependencies)t.depTextureNodes.get(e.name).value=e.currentRenderTarget.texture;this._renderQuad(t.nodeMaterial,t.nextRenderTarget)}for(let t of this.variables)t.advance()}getCurrentRenderTarget(t){return t.currentRenderTarget}_renderQuad(t,e){let i=this.renderer,r=i.getRenderTarget(),s=i.getMRT();i.setMRT(null),i.setRenderTarget(e),VL.material=t,VL.render(i),i.setRenderTarget(r),i.setMRT(s)}dispose(){for(let t of this.variables)t.dispose();this._copyMaterial?.dispose()}}});function wht(t,e){switch(t){case"linearFadeOut":return ul(I(1).sub(e));case"linearInOut":return ul(e.lessThan(.5).select(e,I(1).sub(e)));case"exponentialInOut":return ul(e.lessThan(.4).select(e.div(.4),e.greaterThan(.6).select(I(1).sub(e.sub(.6).div(.4)),I(1))));case"constant":return I(1);default:return e}}function Sht(t){return ul(t.dot(at(12.9898,78.233)).sin().mul(43758.5453).fract())}var ul,Yvt,QCt=j(()=>{dt(),mr(),He(),ul=t=>t,Yvt=class extends Re{constructor(t,e){super(),this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this._uniformsStore={},this._uPosition=ee(new pi),this._uTexture=ee(new pi),this._uColor=gt(new Me(1,1,1,1)),this._uColor2=gt(new Me(1,1,1,1)),this._uSize=gt(1),this._uSizeEnd=gt(1),this._uWorldOffset=gt(new P),this._uWorldQuaternion=gt(new Me(0,0,0,1)),this._uRotation=gt(0),this._uRotationEnd=gt(0),this._center=gt(new Q(.5,.5)),this._uRandScaleFactor=gt(0),this._uRandRotationFactor=gt(0),this.context=e,this.name="WebGPUParticleMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.lights=!1;let i=n=>({get value(){return n.value},set value(a){n.value=a}}),r=n=>({get value(){return n.value},set value(a){((o,l)=>{if(Array.isArray(o))l.set(Number(o[0]??1),Number(o[1]??1),Number(o[2]??1),Number(o[3]??1));else if(o&&typeof o=="object"&&"r"in o){let u=o;l.set(u.r,u.g,u.b,u.a??1)}})(a,n.value)}}),s=n=>({get value(){return n.value},set value(a){a&&a.isTexture&&(n.value=a)}});this._binders={uPosition:s(this._uPosition),uTexture:s(this._uTexture),uColor:r(this._uColor),uColor2:r(this._uColor2),uSize:i(this._uSize),uSizeEnd:i(this._uSizeEnd),uWorldOffset:i(this._uWorldOffset),uWorldQuaternion:i(this._uWorldQuaternion),uRotation:i(this._uRotation),uRotationEnd:i(this._uRotationEnd),center:i(this._center),uRandScaleFactor:i(this._uRandScaleFactor),uRandRotationFactor:i(this._uRandRotationFactor)},this._uniformsStore={...this._binders},this.updateState(t),this._rebuildGraph()}get uniforms(){return this._uniformsStore}set uniforms(t){for(let e of Object.keys(t)){let i=this._binders[e];if(!i)continue;let r=t[e]?.value;Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:i}),r!==void 0&&(i.value=r)}this._uniformsStore=t}updateState(t){let e=!1;if(t.coloring!==void 0){let i=t.coloring==="random";e||(e=i!==this.isColoringRandom),this.isColoringRandom=i}if(t.color!==void 0&&(this.uniforms.uColor.value=Array.isArray(t.color)?t.color:this.context.shared.color(t.color)),t.color2!==void 0&&(this.uniforms.uColor2.value=Array.isArray(t.color2)?t.color2:this.context.shared.color(t.color2)),t.size!==void 0){this.uniforms.uSize.value=t.size[0],this.uniforms.uSizeEnd.value=t.size[1];let i=t.size[0]!==t.size[1];e||(e=i!==this.useSizeEnd),this.useSizeEnd=i}t.ease!==void 0&&t.ease!==this.easeOpacity&&(this.easeOpacity=t.ease,e=!0),t.easeSize!==void 0&&t.easeSize!==this.easeSize&&(this.easeSize=t.easeSize,e=!0),e&&this._rebuildGraph(),this.needsUpdate=!0}_rebuildGraph(){let t=vm("particleRef","vec2"),e=this._uPosition,i=Et(()=>{let s=e.sample(t).toVar(),n=ul(s.w).toVar(),a=s.xyz.sub(this._uWorldOffset);a=function(C,M){let A=C.xyz;return M.add(A.cross(A.cross(M).add(M.mul(C.w))).mul(2))}(this._uWorldQuaternion,a);let o=vm("position","vec3"),l=I(1).sub(n),u=this.useSizeEnd?o.mul(G(Yt(this._uSize,this._uSizeEnd,l))):o.mul(G(ul(this._uSize).mul(wht(this.easeSize,l)))),h=lD,d=h.element(0).xyz.length(),c=h.element(1).xyz.length(),p=Sht(t).toVar(),m=I(1).sub(ul(this._uRandScaleFactor).mul(p)),f=at(d,c).mul(m).toVar(),g=2*Math.PI,y=p.mul(ul(this._uRandRotationFactor)).mul(g),v=I(1).sub(ul(this._uRotation)).mul(g),b=I(1).sub(ul(this._uRotationEnd)).mul(g),_=Yt(v.add(y),b.add(y),n).toVar(),x=this._center,S=u.xy.sub(x.sub(at(.5))).mul(f).toVar(),w=at(Ka(_).mul(S.x).sub(Bn(_).mul(S.y)),Bn(_).mul(S.x).add(Ka(_).mul(S.y))).toVar(),T=zyt.mul(lt(a,1)).toVar();return T.xy.addAssign(w),rb.mul(T)}),r=Et(()=>{let s=e.sample(t),n=ul(s.w).toVar();n.lessThanEqual(.005).discard();let a=I(1).sub(n),o=this.isColoringRandom?Sht(t):a,l=Yt(this._uColor,this._uColor2,o).toVar(),u=wht(this.easeOpacity,a).toVar(),h=this._uTexture.sample(bi()).toVar();return lt(h.rgb.mul(l.rgb),ul(l.a).mul(h.a).mul(u))});this.vertexNode=i(),this.colorNode=r(),this.needsUpdate=!0}nodeMaterialDispose(){this.dispose()}}}),JCt=j(()=>{Zgt(),ZCt(),QCt(),KG={createComputation:(t,e,i,r)=>new Xvt(t,e,i,r),createMaterial:(t,e)=>new Yvt(t,e)}});function Kvt(t,e){return(i,r,s,n)=>{let a=s.mod(e).add(i.add(.5).div(t)).div(e),o=ce(s.div(e)).add(r.add(.5).div(t)).div(e);return J1(n.sample(at(a,o)))}}function Tht(t){let e=Li(hr(t.x).mul(65535).add(.5)),i=e.bitAnd(Li(255)).toFloat().mul(.00392156862),r=e.shiftRight(Li(8)).bitAnd(Li(255)).toFloat().mul(.00392156862);return lt(r,i,t.y,t.z)}function Zvt(t){let{levelShiftX:e,scale:i,originOffset:r}=function(f){switch(f){case 5:return{levelShiftX:[4,6,12,24,48,96,192],scale:8*b2,originOffset:16};case 7:return{levelShiftX:[4,6,12,24,48,96,192,384,768,1536],scale:2*b2,originOffset:64};case 8:return{levelShiftX:[4,8,16,32,64,128,256,512,1024,2048,4096],scale:b2,originOffset:128};default:return{levelShiftX:[4,8,16,32,64,128,256,512],scale:4*b2,originOffset:32}}}(t.resolutionLevel),s=t.pyramidLevelSizes.length,n=s%2==0?s-3:s-2,a=s%2==0,o=Math.pow(2,t.resolutionLevel),l=t.pyramidLevelSizes[s-1]/o,u=Kvt(o,l),h=t.pyramid1Size.width,d=t.pyramid1Size.height,c=t.pyramid2Size.width,p=t.pyramid2Size.height,m=US(FW.map(([f,g,y])=>new P(f,g,y)));return f=>{let g=G(0).toVar(),y=G(0,0,1).toVar(),v=lt(0).toVar(),b=f.toVar(),_=ce(b.div(3)).toVar(),x=(A,R)=>at(hr(A.x).add(R).add(.5).div(h),hr(A.y).add(.5).div(d)),S=(A,R)=>at(hr(A.x).add(R).add(.5).div(c),hr(A.y).add(.5).div(p)),w=h-2,T=c-1,C=at(0,0).toVar(),M=J1(t.pyramid2.sample(S(TR(C),T))).toVar();return bt(_.lessThan(hr(M.x)),()=>{let A=I(0).toVar(),R=K=>{let ct=J1(M.add(lt(A))).toVar(),St=lt(ec(ct.yzw),A),wt=J1(lt(lt(_).greaterThanEqual(St)).mul(lt(lt(_).lessThan(ct)))).toVar();C.mulAssign(2),C.addAssign(at(0,1).mul(hr(wt.x)).add(at(1,1).mul(hr(wt.y))).add(at(1,0).mul(hr(wt.z)))),A.assign(wt.dot(St)),K?.()};for(let K=0;K<n;){let ct=e[K];R(()=>{T-=ct,M.assign(t.pyramid1.sample(x(TR(C),w)))}),K++;let St=e[K];R(()=>{w-=St,M.assign(t.pyramid2.sample(S(TR(C),T)))}),K++}a&&R(null);let O=hr(C.x).mod(o).toVar(),N=hr(C.y).mod(o).toVar(),B=ce(hr(C.x).div(o)).add(ce(hr(C.y).div(o)).mul(l)).toVar(),L=b.sub(A.mul(3)).mul(.0625).add(.03125),z=u(O,N,B,t.voxel).toVar(),k=hr(z.w).add(.5).mul(.00390625),V=hr(J1(t.triTable.sample(at(L,k))).x).mul(2).toInt().toVar(),H=G(O,N,B).add(ec(m.element(V))).toVar(),W=G(O,N,B).add(ec(m.element(V.add(1)))).toVar(),X=u(hr(H.x),hr(H.y),hr(H.z),t.potential).toVar(),st=u(hr(W.x),hr(W.y),hr(W.z),t.potential).toVar(),nt=hr(X.x).div(hr(X.x).sub(hr(st.x)));v.assign(Yt(Tht(ec(X.yzw)),Tht(ec(st.yzw)),nt)),g.assign(H.add(W.sub(H).mul(nt)).sub(G(r)).mul(i));let xt=u(hr(H.x),hr(H.y),hr(H.z),t.voxel),pt=u(hr(W.x),hr(W.y),hr(W.z),t.voxel);y.assign(xe(Yt(ec(xt.xyz),ec(pt.xyz),nt)))}),{position:g,normal:y,color:v}}}function Mht(t,e){t.needsPreviousData?.()===!0&&uD.assign(e)}function tEt(t){if(t.cached)return function(s){let n=()=>s.drawIndex?s.drawIndex.element(sS):sS;return{position:Et(a=>{let o=ec(s.positions.element(n()).xyz).toVar();return Mht(a,o),o})(),normal:e9(s.normals.element(n()).xyz),color:e9(s.colors.element(n()))}}(t.cached);let e=Zvt(t),i=Lr("vec3","vShapeBlendNormal"),r=Lr("vec4","vShapeBlendColor");return{position:Et(s=>{let{position:n,normal:a,color:o}=e(sS.toFloat());return i.assign(a),r.assign(o),Mht(s,n),n})(),normal:i,color:r}}var hr,TR,ec,J1,b2,FW,UW=j(()=>{dt(),He(),hr=t=>t,TR=t=>t,ec=t=>t,J1=t=>t,b2=2,FW=[[0,0,0],[1,0,0],[1,0,0],[1,1,0],[0,1,0],[1,1,0],[0,0,0],[0,1,0],[0,0,1],[1,0,1],[1,0,1],[1,1,1],[0,1,1],[1,1,1],[0,0,1],[0,1,1],[0,0,0],[0,0,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1],[0,1,0],[0,1,1]]});function Qvt(t,e){let i=ue(t.xyz);return ue(e.add(i.cross(i.cross(e).add(e.mul(ot(t.w)))).mul(2)))}function Jvt(t,e,i,r){let s=Ae(t,-1,1),n=t.sub(s).mul(2).add(1),a=Ae(I(.5).add(s.mul(.5).mul(e.sub(s.mul(n).mul(i))).div(r)),0,1);return ot(Yt(e,s.mul(n).mul(i),a).sub(s.mul(r).mul(a).mul(I(1).sub(a))))}function tbt(t,e,i,r,s){let n=I(0).toVar(),a=ot(i.y),o=ot(i.z),l=ot(i.w),u=bt(t.lessThan(.5),()=>{n.assign(mi(e).sub(a))}).ElseIf(t.lessThan(1.5),()=>{let d=G(a,o,l),c=mi(e.div(d)),p=mi(e.div(d.mul(d)));n.assign(c.mul(c.sub(1)).div(p))}).ElseIf(t.lessThan(2.5),()=>{let d=G(a,o,l),c=Le(e).sub(d).toVar();n.assign(mi(Qt(c,G(0))).add(ii(Qt(ot(c.x),Qt(ot(c.y),ot(c.z))),0)))}).ElseIf(t.lessThan(3.5),()=>{let d=Le(at(mi(MR(e.xz)),ot(e.y))).sub(at(o,a)).toVar();n.assign(ii(Qt(ot(d.x),ot(d.y)),0).add(mi(Qt(d,at(0)))))}).ElseIf(t.lessThan(4.5),()=>{let d=a,c=o,p=l,m=at(mi(MR(e.xz)),ot(e.y)).toVar(),f=at(p,d),g=at(p.sub(c),d.mul(2)),y=at(ot(m.x).sub(ii(ot(m.x),ot(m.y).lessThan(0).select(c,p))),Le(ot(m.y)).sub(d)).toVar(),v=m.sub(f).add(g.mul(Ae(kt(f.sub(m),g).div(kt(g,g)),0,1))).toVar(),b=ot(v.x).lessThan(0).and(ot(y.y).lessThan(0)).select(I(-1),I(1));n.assign(b.mul(xl(ii(kt(y,y),kt(v,v)))))}).ElseIf(t.lessThan(5.5),()=>{let d=at(mi(MR(e.xy)).sub(a),ot(e.z));n.assign(mi(d).sub(o))}),h=()=>{let d=Le(ot(e.x)).toVar(),c=at(a,o),p=l,m=ot(r.w),f=ot(c.y).mul(d).greaterThan(ot(c.x).mul(ot(e.y))).select(kt(at(d,ot(e.y)),c),mi(at(d,ot(e.y)))),g=G(d,ot(e.y),ot(e.z));n.assign(xl(kt(g,g).add(p.mul(p)).sub(p.mul(f).mul(2))).sub(m))};return s?u.ElseIf(t.lessThan(6.5),h).Else(()=>{n.assign(s(e,i,r))}):u.Else(h),n}function X9(t,e=!0){let i=t.spatialDivisions,r=t.spatialn;return(s,n)=>{let a=e?lt(0).toVar():lt(0),o=I(1e3).toVar(),l=e?I(0).toVar():I(0),u=e?I(0).toVar():I(0),h=ot(n.y).add(ot(n.z).mul(i)).add(.5).div(i*i),d=(m,f)=>{let g=f.toVar();Ji(L1,({i:y})=>{bt(g.lessThan(1),()=>{sa()}),g.mulAssign(.5),bt(Oi(g).greaterThanEqual(.5),()=>{let v=I(y).add(m).add(.5).mul(1/n5),b=t.shapeRow(v,0).toVar(),_=t.shapeRow(v,1).toVar(),x=t.shapeRow(v,2).toVar(),S=t.shapeRow(v,3).toVar(),w=Qvt(Ca(_),ue(s.sub(ue(b.xyz)))).div(ot(S.z)).toVar(),T=tbt(ot(x.x),ue(w),Ca(x),Ca(S),t.meshSdf).sub(ot(S.y)).mul(ot(S.z)).toVar(),C=ot(S.x).toVar(),M=ot(b.w);if(o.assign(Jvt(M,o,T,C)),e){let A=Ai(-1.5,M).mul(Ai(M,-.5)),R=tr(u,0,T.negate()),O=Yt(I(1),R,A);a.mulAssign(O),l.mulAssign(O),u.assign(Qt(u,C)),C.addAssign(t.colorKBump);let N=t.shapeRow(v,4).toVar(),B=tr(C,0,T).mul(ot(N.a).greaterThanEqual(0).toFloat()).toVar();l.addAssign(B),a.addAssign(N.mul(B))}})})},c=m=>{let f=m.mul(4*L1).toVar(),g=Ca(t.spatialTex.sample(at(ot(n.x).mul(r).add(m).add(.5).div(r*i),h))).toVar();d(ot(f),ot(g.x)),d(ot(f.add(L1)),ot(g.y)),d(ot(f.add(2*L1)),ot(g.z)),d(ot(f.add(3*L1)),ot(g.w))};r===1?c(I(0)):Ji(r,({i:m})=>{c(I(m).toVar())}),e&&a.divAssign(l);let p=Yt(o,I(0),Ai(1e20,o)).toVar();return{sdf:ot(p),color:Ca(a),colorDivisor:ot(l)}}}function Aht(t){let e=t.resolution,i=e-1,r=t.colorResolution,s=t.capacity,n=e/4,a=n-1,o=gt(t.bboxHalf),l=gt(t.bboxOffset),u=gt(1e30),h=gt(new P(0,0,0)),d=gt(new P(n,n,n)),c=t.env.spatialDivisions,p=I(t.buildSeq).mul(0),m=t.sparseStorage??null,f=m?m.poolBricks:0,g=m?Math.ceil(f/4096):0,y=m?.meshlet??null,v=y?y.drawIndex:null,b=y?Math.floor(s/24):0,_=y?y.vertexBlocks:0,x=(F,et,vt,ht)=>{let It=new Hg(F,et,vt);return It.format=Qa,It.type=Qe,It.minFilter=De,It.magFilter=De,It.name=ht,It},S=m?x(256,256,4*Math.max(g,1),"SplineShapeBlend.ultraSdfPool"):t.reuseTextures?.sdfTexture??x(e,e,e,"SplineShapeBlend.ultraSdf");S.format=Qa,S.type=Qe,S.minFilter=De,S.magFilter=De;let w=t.reuseTextures?.colorTexture??new Hg(r,r,r);w.name="SplineShapeBlend.ultraColor";let T=t.reuseTextures?.coarseTexture??new Hg(n,n,n);T.format=Qa,T.type=Qe,T.minFilter=De,T.magFilter=De,T.name="SplineShapeBlend.ultraCoarse";let C=Qr(8,"uint").toAtomic(),M=(F=0)=>C.element(F),A=m?Qr(y?12:4,"int").toAtomic():null,R=F=>A.element(F),O=m?Qr(Math.max(f,1),"float"):null,N=n*n*n,B=m?Qr(N*(y?4:1),"float"):null,L=F=>mt(ot(F.x).add(ot(F.y).mul(n)).add(ot(F.z).mul(n*n))),z=F=>B.element(L(F)),k=F=>B.element(L(F).add(mt(N))),V=F=>B.element(L(F).add(mt(2*N))),H=F=>B.element(L(F).add(mt(3*N))),W=F=>B.element(F.add(mt(3*N))),X=m?Qr(Math.max(f,1),"float"):null,st=y?Qr(3*Math.max(b,1),"float"):null,nt=F=>st.element(F),xt=F=>nt(mt(F)),pt=F=>nt(mt(F.add(b))),K=F=>nt(F.add(mt(2*b))),ct=y?Qr(Math.max(_,1),"float"):null,St=F=>ct.element(F),wt=y?Qr(24*Math.max(b,1),"uint"):null,Tt=F=>wt.element(F),yt=y?gt(0):null,Ot=y?gt(new _t):null,Ft=y?gt(2):null,Bt=US(Array.from(t.numTrisTable)),zt=US(FW.map(([F,et,vt])=>new P(F,et,vt))),Vt=X9(t.env,!1),Wt=X9(t.env),$t=(F,et)=>ue(F.div(et).mul(2).sub(1)),Pt=(F,et)=>ue(F.div(et).mul(c-1).floor()),oe=Et(()=>{for(let F=0;F<8;F++)No(M(F),Li(0))})(),jt=Et(()=>{bt(mt(Pn).greaterThanEqual(mt(s)),()=>{yr()}),t.buffers.positions.element(mt(Pn)).assign(lt(0))})(),Zt=y?Et(()=>{bt(mt(Pn).greaterThanEqual(mt(s)),()=>{yr()}),v.element(mt(Pn)).assign(Li(p))})():null,Jt=wc(T),$=F=>ot(Ca(Jt.load(Qn(Ae(F,G(0),G(a))))).x),se=F=>ot(z(ue(Ae(F,G(0),G(a))))),Pe=(F,et)=>{let vt=Qt(F,0),ht=ce(vt.div(4096)),It=vt.sub(ht.mul(4096)),de=ce(It.div(64)),be=It.sub(de.mul(64));return ue(G(be,de,ht).mul(4).add(et))},Ve=Et(()=>{let F=G(uo).add(h).toVar();bt(ot(F.x).greaterThan(a).or(ot(F.y).greaterThan(a)).or(ot(F.z).greaterThan(a)),()=>{yr()});let et=ue(F.mul(4).add(G(1.5))),vt=(ht=>{let It=I(1e3).toVar();return Ji(n5,({i:de})=>{bt(I(de).greaterThanEqual(ot(t.npart)),()=>{sa()});let be=I(de).add(.5).mul(1/n5),Ht=t.env.shapeRow(be,0).toVar(),Ct=t.env.shapeRow(be,1).toVar(),re=t.env.shapeRow(be,2).toVar(),$e=t.env.shapeRow(be,3).toVar(),ts=Qvt(Ca(Ct),ue(ht.sub(ue(Ht.xyz)))).div(ot($e.z)).toVar(),Vr=tbt(ot(re.x),ue(ts),Ca(re),Ca($e),t.env.meshSdf).sub(ot($e.y)).mul(ot($e.z)).toVar();It.assign(Jvt(ot(Ht.w),It,Vr,ot($e.x)))}),ot(It)})($t(et,i));qp(T,Qn(F),lt(ot(vt.add(p)),0,0,0)).toStack()})(),ie=F=>{bt(ot(F.x).greaterThan(a).or(ot(F.y).greaterThan(a)).or(ot(F.z).greaterThan(a)),()=>{yr()})},oi=m?Et(()=>{let F=G(uo).toVar();ie(ue(F)),z(ue(F)).assign(ot(I(-1).add(p))),y&&(k(ue(F)).assign(ot(I(-1).add(p))),V(ue(F)).assign(ot(I(-1).add(p))))})():null,xi=m?Et(()=>{let F=G(uo).add(h).toVar();ie(ue(F));let et=$(ue(F)).toVar(),vt=se(ue(F)).toVar();bt(Le(et).greaterThan(u).and(vt.greaterThan(-.5)),()=>{let ht=ll(R(1),mt(1)).toVar();O.element(ht).assign(vt),z(ue(F)).assign(ot(I(-1).add(p)))})})():null,Ks=m?Et(()=>{let F=G(uo).add(h).toVar();ie(ue(F));let et=$(ue(F)).toVar(),vt=se(ue(F)).toVar();bt(Le(et).lessThanEqual(u).and(vt.lessThan(-.5)),()=>{let ht=I(-1).toVar(),It=oR(R(1),mt(1)).toVar();bt(It.greaterThanEqual(1),()=>{ht.assign(ot(O.element(It.sub(1))))}).Else(()=>{ll(R(1),mt(1));let de=ll(R(0),mt(1)).toVar();bt(de.lessThan(mt(f)),()=>{ht.assign(de.toFloat())}).Else(()=>{No(R(2),mt(1))})}),bt(ht.greaterThan(-.5),()=>{X.element(mt(ht)).assign((de=>ot(ot(de.x).add(ot(de.y).mul(256)).add(ot(de.z).mul(65536))))(ue(F))),z(ue(F)).assign(ot(ht.add(p)))})})})():null,Hi=m?Et(()=>{let F=hg(R(0)).toVar(),et=hg(R(2)).toVar();if(No(M(1),Li(F)),No(M(2),Li(et)),No(R(2),mt(0)),y){let vt=hg(R(3)).toVar(),ht=hg(R(5)).toVar();No(M(4),Li(vt)),No(M(5),Li(ht)),No(R(5),mt(0));let It=hg(R(6)).toVar(),de=hg(R(8)).toVar();No(M(6),Li(It)),No(M(7),Li(de)),No(R(8),mt(0))}})():null,li=y?Et(()=>{let F=G(uo).toVar();bt(ot(F.x).greaterThanEqual(ot(d.x)).or(ot(F.y).greaterThanEqual(ot(d.y))).or(ot(F.z).greaterThanEqual(ot(d.z))),()=>{yr()});let et=ue(F.add(h)).toVar();ie(ue(et));let vt=ot(V(ue(et))).toVar();bt(vt.greaterThan(-.5),()=>{let It=ll(R(7),mt(1)).toVar();St(It).assign(vt),V(ue(et)).assign(ot(I(-1).add(p)))});let ht=ot(k(ue(et))).toVar();bt(ht.lessThan(-.5),()=>{yr()}),k(ue(et)).assign(ot(I(-1).add(p))),Ji(48,()=>{bt(ht.lessThan(-.5),()=>{sa()});let It=ll(R(4),mt(1)).toVar();K(It).assign(ht),ht.assign(ot(xt(ht)))})})():null,Ur=y?Et(()=>{let F=G(uo).add(h).toVar();ie(ue(F));let et=I(0).toVar();bt(se(ue(F)).greaterThan(-.5),()=>{let vt=ue(F.mul(4)).toVar(),ht=ih.map(([Ht,Ct,re])=>Ir(ue(G(ot(vt.x).add(4*Ht),ot(vt.y).add(4*Ct),ot(vt.z).add(4*re)))).toVar()),It=ht[0];for(let Ht=1;Ht<8;Ht++)It=It.add(ht[Ht]);let de=xe(It).toVar(),be=kt(ht[0],de);for(let Ht=1;Ht<8;Ht++)be=ii(be,kt(ht[Ht],de));bt(ot(be).greaterThan(ot(Ft)),()=>{et.assign(I(1))})}),H(ue(F)).assign(ot(et.add(p)))})():null,Jr=Math.min(4096,Math.max(f,1)),jr=()=>{let F=G(uo).toVar(),et=ce(ot(F.x).mul(.25)).toVar(),vt=ce(ot(F.y).mul(.25)).toVar(),ht=vt.mul(Jr).add(et).toVar(),It=G(ot(F.x).sub(et.mul(4)),ot(F.y).sub(vt.mul(4)),ot(F.z)).toVar();return{slot:ot(ht),local:ue(It)}},Ui=F=>(et=>{let vt=ce(et.div(65536)),ht=et.sub(vt.mul(65536)),It=ce(ht.div(256)),de=ht.sub(It.mul(256));return ue(G(de,It,vt))})(ot(X.element(mt(F)))),Ci=m?Et(()=>{let F=G(uo).add(h.mul(4)).toVar(),et=ue(F.mul(.25).floor()).toVar(),vt=se(et).toVar();bt(vt.lessThan(-.5),()=>{yr()});let{sdf:ht}=Vt($t(ue(F),i),Pt(ue(F),i));qp(S,Qn(Pe(vt,ue(F.sub(et.mul(4))))),lt(ot(ht.add(p)),0,0,0)).toStack()})():null,Zs=m?Et(()=>{let{slot:F,local:et}=jr();bt(F.greaterThanEqual(f),()=>{yr()});let vt=Ui(F).toVar();bt(se(ue(vt)).notEqual(F),()=>{yr()});let ht=ue(vt.mul(4).add(et)).toVar(),{sdf:It}=Vt($t(ue(ht),i),Pt(ue(ht),i));qp(S,Qn(Pe(F,ue(et))),lt(ot(It.add(p)),0,0,0)).toStack()})():Et(()=>{let F=G(uo).add(h.mul(4)).toVar(),et=$(ue(F.mul(.25).floor())).toVar();bt(Le(et).greaterThan(u),()=>{qp(S,Qn(F),lt(ot(et.add(p)),0,0,0)).toStack(),yr()});let{sdf:vt}=Vt($t(ue(F),i),Pt(ue(F),i));qp(S,Qn(F),lt(ot(vt.add(p)),0,0,0)).toStack()})(),ps=Et(()=>{let F=G(uo).add(h.mul(2)).toVar();bt(ot(F.x).greaterThan(r-1).or(ot(F.y).greaterThan(r-1)).or(ot(F.z).greaterThan(r-1)),()=>{yr()}),bt(Le($(ue(F.mul(.5).floor()))).greaterThan(u),()=>{yr()});let{color:et,colorDivisor:vt}=Wt($t(ue(F),r-1),Pt(ue(F),r-1)),ht=Ca(vt.greaterThan(0).select(et,lt(0)));qp(w,Qn(F),Ae(Ca(ht.add(p)),lt(0),lt(1))).toStack()})(),_r=wc(S),rr=m?(F,et,vt)=>{let ht=Ae(G(F,et,vt),G(0),G(i)),It=ht.mul(.25).floor(),de=se(ue(It)),be=ot(Ca(_r.load(Qn(Pe(de,ue(ht.sub(It.mul(4))))))).x);return ot(de.lessThan(-.5).select($(ue(It)),be))}:(F,et,vt)=>ot(Ca(_r.load(Qn(Ae(G(F,et,vt),G(0),G(i))))).x),Ir=F=>{let et=ot(F.x),vt=ot(F.y),ht=ot(F.z),It=rr(et.add(1),vt,ht).sub(rr(et.sub(1),vt,ht)),de=rr(et,vt.add(1),ht).sub(rr(et,vt.sub(1),ht)),be=rr(et,vt,ht.add(1)).sub(rr(et,vt,ht.sub(1))),Ht=It.equal(0).and(de.equal(0)).and(be.equal(0));return ue(Ht.select(G(.199,.299,.399),xe(G(It,de,be))))},Jh=(F,et,vt)=>{let ht=((be,Ht,Ct)=>{let re=($e,ts,Vr,xr)=>rr(be.add($e),Ht.add(ts),Ct.add(Vr)).lessThan(0).toFloat().mul(xr);return re(0,0,0,1).add(re(1,0,0,2)).add(re(0,1,0,8)).add(re(1,1,0,4)).add(re(0,0,1,16)).add(re(1,0,1,32)).add(re(0,1,1,128)).add(re(1,1,1,64))})(F,et,vt).toVar(),It=ot(Bt.element(mt(ht))).toVar();bt(It.lessThan(.5),()=>{yr()});let de=ll(M(),Li(It)).toVar();bt(I(de).add(It).mul(3).lessThanEqual(s),()=>{let be=ot(ht).add(.5).mul(.00390625);Ji(5,({i:Ht})=>{bt(I(Ht).greaterThanEqual(It),()=>{sa()});let Ct=I(Ht).toVar();Ji(3,({i:re})=>{let $e=I(re).toVar();((ts,Vr,xr,os,zn,Wo)=>{let Ln=zn.mul(.0625).add(.03125),es=ot(Ca(t.triTable.sample(at(Ln,os))).x).mul(2).toInt().toVar(),ms=G(ts,Vr,xr).add(ue(zt.element(es))).toVar(),Tr=G(ts,Vr,xr).add(ue(zt.element(es.add(1)))).toVar(),Qs=rr(ot(ms.x),ot(ms.y),ot(ms.z)).toVar(),ua=rr(ot(Tr.x),ot(Tr.y),ot(Tr.z)).toVar(),fr=Qs.div(Qs.sub(ua)).toVar(),zs=ms.add(Tr.sub(ms).mul(fr)).toVar(),pn=ue(zs.div(i).mul(2).sub(1)).toVar(),da=pn.mul(o).add(G(l)),Gr=xe(Yt(Ir(ue(ms)),Ir(ue(Tr)),fr)),mn=pn.add(1).mul(.5),Wr=Ca(wc(w,mn,mt(0))),Js=Wo.toVar();t.buffers.positions.element(Js).assign(lt(da,1)),t.buffers.normals.element(Js).assign(lt(Gr,0)),t.buffers.colors.element(Js).assign(Wr)})(F,et,vt,be,Ct.mul(3).add($e),mt(de).add(mt(Ct)).mul(3).add(mt($e)))})})})},tu=m?Et(()=>{let{slot:F,local:et}=jr();bt(F.greaterThanEqual(f),()=>{yr()});let vt=Ui(F).toVar();bt(se(ue(vt)).notEqual(F),()=>{yr()});let ht=ot(vt.x).mul(4).add(ot(et.x)).toVar(),It=ot(vt.y).mul(4).add(ot(et.y)).toVar(),de=ot(vt.z).mul(4).add(ot(et.z)).toVar();bt(ht.greaterThanEqual(i).or(It.greaterThanEqual(i)).or(de.greaterThanEqual(i)),()=>{yr()}),Jh(ht,It,de)})():Et(()=>{let F=ot(G(uo).x).toVar(),et=ot(G(uo).y).toVar(),vt=ot(G(uo).z).toVar();bt(F.greaterThanEqual(i).or(et.greaterThanEqual(i)).or(vt.greaterThanEqual(i)),()=>{yr()}),bt(Le($(ue(G(F,et,vt).mul(.25).floor()))).greaterThan(u),()=>{yr()}),Jh(F,et,vt)})(),Em=()=>{let F=G(cR).toVar(),et=ot(F.y).mul(Jr).add(ot(F.x)).toVar(),vt=G(0).toVar(),ht=I(0).toVar();return bt(et.lessThan(f),()=>{vt.assign(Ui(et)),bt(se(ue(vt)).equal(et),()=>{ht.assign(I(1))})}),{brick:ue(vt),valid:ot(ht)}},sr=()=>{let F=G(cR).add(h).toVar(),et=I(0).toVar();return bt(ot(F.x).lessThanEqual(a).and(ot(F.y).lessThanEqual(a)).and(ot(F.z).lessThanEqual(a)),()=>{bt(se(ue(F)).greaterThan(-.5),()=>{et.assign(I(1))})}),{brick:ue(F),valid:ot(et)}},ih=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],g0=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Pm=F=>Et(()=>{let et=zp("float",64),vt=zp("float",1),ht=G(hR).toVar(),It=mt(ot(ht.x).add(ot(ht.y).mul(4)).add(ot(ht.z).mul(16))).toVar(),{brick:de,valid:be}=F(),Ht=ot(H(ue(de))).toVar(),Ct=I(1).add(Ht).toVar(),re=Ht.greaterThan(.5),$e=re.and(ot(ht.x).lessThan(2).and(ot(ht.y).lessThan(2)).and(ot(ht.z).lessThan(2))).or(re.not()),ts=ot(de.x).mul(4).add(ot(ht.x).mul(Ct)).toVar(),Vr=ot(de.y).mul(4).add(ot(ht.y).mul(Ct)).toVar(),xr=ot(de.z).mul(4).add(ot(ht.z).mul(Ct)).toVar(),os=ih.map(([Tr,Qs,ua])=>rr(ts.add(Ct.mul(Tr)),Vr.add(Ct.mul(Qs)),xr.add(Ct.mul(ua))).toVar()),zn=os[0].lessThan(0).toFloat();for(let Tr=1;Tr<8;Tr++)zn=zn.add(os[Tr].lessThan(0).toFloat());let Wo=zn.toVar(),Ln=I(0).toVar();bt(be.greaterThan(.5).and($e).and(ts.add(Ct).lessThanEqual(i)).and(Vr.add(Ct).lessThanEqual(i)).and(xr.add(Ct).lessThanEqual(i)).and(Wo.greaterThan(.5)).and(Wo.lessThan(7.5)),()=>{Ln.assign(I(1))}),et.element(It).assign(Ln.add(p)),B1(),bt(It.equal(mt(0)).and(be.greaterThan(.5)),()=>{let Tr=I(0).toVar();Ji(64,({i:ua})=>{Tr.addAssign(ot(et.element(ua)))});let Qs=I(-1).toVar();bt(Tr.greaterThan(.5),()=>{let ua=oR(R(7),mt(1)).toVar();bt(ua.greaterThanEqual(1),()=>{Qs.assign(ot(St(ua.sub(1))))}).Else(()=>{ll(R(7),mt(1));let fr=ll(R(6),mt(1)).toVar();bt(fr.lessThan(mt(_)),()=>{Qs.assign(fr.toFloat())}).Else(()=>{No(R(8),mt(1))})}),bt(Qs.greaterThan(-.5),()=>{V(ue(de)).assign(ot(Qs.add(p)))})}),vt.element(mt(0)).assign(Qs)}),B1();let es=ot(vt.element(mt(0))).toVar(),ms=Ln.greaterThan(.5).or(re.and($e).and(be.greaterThan(.5)).and(ts.add(Ct).lessThanEqual(i)).and(Vr.add(Ct).lessThanEqual(i)).and(xr.add(Ct).lessThanEqual(i)));bt(ms.and(es.greaterThan(-.5)),()=>{let Tr=G(0).toVar(),Qs=I(0).toVar();for(let[Ml,eu]of g0)bt(os[Ml].lessThan(0).toFloat().notEqual(os[eu].lessThan(0).toFloat()),()=>{let _T=os[Ml].div(os[Ml].sub(os[eu])),[hb,xT,wT]=ih[Ml],[TD,Rxt,Dxt]=ih[eu];Tr.addAssign(G(hb,xT,wT).add(G(TD-hb,Rxt-xT,Dxt-wT).mul(_T)).mul(Ct)),Qs.addAssign(1)});let ua=ue(Tr.div(Qt(Qs,1))).toVar();bt(Qs.lessThan(.5),()=>{ua.assign(G(Ct.mul(.5)))});let fr=G(ts,Vr,xr).add(ua).toVar(),zs=ue(fr.div(i).mul(2).sub(1)).toVar(),pn=zs.mul(o).add(G(l)),da=G(0).toVar(),Gr=ue(ua.div(Ct)).toVar();for(let Ml=0;Ml<8;Ml++){let[eu,_T,hb]=ih[Ml],xT=eu?ot(Gr.x):I(1).sub(ot(Gr.x)),wT=_T?ot(Gr.y):I(1).sub(ot(Gr.y)),TD=hb?ot(Gr.z):I(1).sub(ot(Gr.z));da.addAssign(Ir(ue(G(ts.add(Ct.mul(eu)),Vr.add(Ct.mul(_T)),xr.add(Ct.mul(hb))))).mul(xT.mul(wT).mul(TD)))}let mn=xe(da),Wr=zs.add(1).mul(.5),Js=Ca(wc(w,Wr,mt(0))),fn=mt(re.select(ot(ht.x).add(ot(ht.y).mul(2)).add(ot(ht.z).mul(4)),I(It))).toVar(),Ia=mt(es.mul(64)).add(fn).toVar();t.buffers.positions.element(Ia).assign(lt(pn,1)),t.buffers.normals.element(Ia).assign(lt(mn,0)),t.buffers.colors.element(Ia).assign(Js)})})(),Rm=y?Pm(Em):null,rh=y?Pm(sr):null,_i=F=>Et(()=>{let et=zp("float",64),vt=zp("float",64),ht=zp("float",48),It=G(hR).toVar(),de=mt(ot(It.x).add(ot(It.y).mul(4)).add(ot(It.z).mul(16))).toVar(),{brick:be,valid:Ht}=F(),Ct=ot(be.x).mul(4).add(ot(It.x)).toVar(),re=ot(be.y).mul(4).add(ot(It.y)).toVar(),$e=ot(be.z).mul(4).add(ot(It.z)).toVar(),ts=rr(Ct,re,$e).lessThan(0).toFloat().toVar(),Vr=(fr,zs,pn)=>ot(W(mt(ce(fr.mul(.25))).add(mt(ce(zs.mul(.25))).mul(n)).add(mt(ce(pn.mul(.25))).mul(n*n)))),xr=fr=>fr.mul(.5).fract().lessThan(.25),os=(fr,zs)=>fr.greaterThanEqual(zs).and(fr.add(zs).lessThanEqual(i)),zn=I(0).toVar(),Wo=I(0).toVar(),Ln=I(0).toVar(),es=I(1).toVar(),ms=I(1).toVar(),Tr=I(1).toVar(),Qs=(fr,zs,pn,da,Gr,mn,Wr,Js,fn)=>{let Ia=Vr(...fn[0]).add(Vr(...fn[1])).add(Vr(...fn[2])).add(Vr(...fn[3])).greaterThan(3.5).toVar(),Ml=rr(Ct.add(pn),re.add(da),$e.add(Gr)).lessThan(0).toFloat(),eu=rr(Ct.add(2*pn),re.add(2*da),$e.add(2*Gr)).lessThan(0).toFloat();bt(Ht.greaterThan(.5).and(Ia.not()).and(Js.add(1).lessThanEqual(i)).and(os(mn,I(1))).and(os(Wr,I(1))).and(ts.notEqual(Ml)),()=>{fr.assign(I(1)),zs.assign(I(1))}),bt(Ht.greaterThan(.5).and(Ia).and(xr(Ct)).and(xr(re)).and(xr($e)).and(Js.add(2).lessThanEqual(i)).and(os(mn,I(2))).and(os(Wr,I(2))).and(ts.notEqual(eu)),()=>{fr.assign(I(1)),zs.assign(I(2))})};Qs(zn,es,1,0,0,re,$e,Ct,[[Ct,re.sub(1),$e.sub(1)],[Ct,re,$e.sub(1)],[Ct,re,$e],[Ct,re.sub(1),$e]]),Qs(Wo,ms,0,1,0,$e,Ct,re,[[Ct.sub(1),re,$e.sub(1)],[Ct.sub(1),re,$e],[Ct,re,$e],[Ct,re,$e.sub(1)]]),Qs(Ln,Tr,0,0,1,Ct,re,$e,[[Ct.sub(1),re.sub(1),$e],[Ct,re.sub(1),$e],[Ct,re,$e],[Ct.sub(1),re,$e]]);let ua=zn.add(Wo).add(Ln).mul(2).toVar();et.element(de).assign(ua.add(p)),B1(),bt(de.equal(mt(0)).and(Ht.greaterThan(.5)),()=>{let fr=I(0).toVar();Ji(64,({i:Gr})=>{vt.element(Gr).assign(fr),fr.addAssign(ot(et.element(Gr)))}),ll(M(0),Li(fr));let zs=ce(fr.add(7).mul(1/8)).toVar(),pn=I(-1).toVar(),da=I(-1).toVar();Ji(48,({i:Gr})=>{bt(I(Gr).greaterThanEqual(zs),()=>{sa()});let mn=I(Gr).toVar(),Wr=I(-1).toVar(),Js=oR(R(4),mt(1)).toVar();bt(Js.greaterThanEqual(1),()=>{Wr.assign(ot(K(Js.sub(1))))}).Else(()=>{ll(R(4),mt(1));let fn=ll(R(3),mt(1)).toVar();bt(fn.lessThan(mt(b)),()=>{Wr.assign(fn.toFloat())}).Else(()=>{No(R(5),mt(1))})}),ht.element(mt(mn)).assign(Wr),bt(Wr.greaterThan(-.5),()=>{pt(Wr).assign(ii(fr.sub(mn.mul(8)),8)),xt(Wr).assign(I(-1)),bt(da.greaterThan(-.5),()=>{xt(da).assign(Wr)}).Else(()=>{pn.assign(Wr)}),da.assign(Wr)})}),k(ue(be)).assign(pn)}),B1(),bt(ua.greaterThan(.5),()=>{let fr=(Gr,mn,Wr)=>{let Js=ce(Gr.mul(.25)),fn=ce(mn.mul(.25)),Ia=ce(Wr.mul(.25)),Ml=mt(Js).add(mt(fn).mul(n)).add(mt(Ia).mul(n*n)),eu=mt(Gr.sub(Js.mul(4))).add(mt(mn.sub(fn.mul(4))).mul(4)).add(mt(Wr.sub(Ia.mul(4))).mul(16));return Li(Ml.mul(64).add(eu))},zs=ot(vt.element(de)).toVar(),pn=(Gr,mn,Wr)=>{let Js=ot(ht.element(mt(ce(zs.mul(.125))))).toVar();bt(Js.greaterThan(-.5),()=>{let fn=zs.sub(ce(zs.mul(.125)).mul(8)),Ia=mt(Js.mul(24).add(fn.mul(3))).toVar();Tt(Ia).assign(Gr),Tt(Ia.add(mt(1))).assign(mn),Tt(Ia.add(mt(2))).assign(Wr)}),zs.addAssign(1)},da=(Gr,mn)=>{bt(Gr.greaterThan(.5),()=>{let Wr=fr(...mn[0]).toVar(),Js=fr(...mn[1]).toVar(),fn=fr(...mn[2]).toVar(),Ia=fr(...mn[3]).toVar();bt(ts.greaterThan(.5),()=>{pn(Wr,Js,fn),pn(Wr,fn,Ia)}).Else(()=>{pn(Wr,Ia,fn),pn(Wr,fn,Js)})})};da(zn,[[Ct,re.sub(es),$e.sub(es)],[Ct,re,$e.sub(es)],[Ct,re,$e],[Ct,re.sub(es),$e]]),da(Wo,[[Ct.sub(ms),re,$e.sub(ms)],[Ct.sub(ms),re,$e],[Ct,re,$e],[Ct,re,$e.sub(ms)]]),da(Ln,[[Ct.sub(Tr),re.sub(Tr),$e],[Ct,re.sub(Tr),$e],[Ct,re,$e],[Ct.sub(Tr),re,$e]])})})(),Dm=y?_i(Em):null,Nm=y?_i(sr):null,y0=y?Et(()=>{let F=zp("float",48),et=zp("float",2),vt=G(hR).toVar(),ht=mt(ot(vt.x).add(ot(vt.y).mul(4)).add(ot(vt.z).mul(16))).toVar(),It=G(cR).toVar(),de=ot(It.y).mul(Jr).add(ot(It.x)).toVar();bt(ht.equal(mt(0)),()=>{let re=I(0).toVar();bt(de.lessThan(f),()=>{let ts=Ui(de).toVar();bt(se(ue(ts)).equal(de),()=>{let Vr=I(0).toVar();bt(ot(yt).greaterThan(.5),()=>{let xr=G(0).toVar(),os=G(0).toVar();for(let zn=0;zn<8;zn++){let Wo=ue(ts.mul(4).add(G(4*(1&zn),4*(zn>>1&1),4*(zn>>2&1)))),Ln=ue(Wo.div(i).mul(2).sub(1)).mul(o).add(G(l)),es=Ot.mul(lt(Ln,1)).toVar(),ms=ot(es.w);xr.addAssign(G(ot(es.x).lessThan(ms.negate()).toFloat(),ot(es.y).lessThan(ms.negate()).toFloat(),ot(es.z).lessThan(0).toFloat())),os.addAssign(G(ot(es.x).greaterThan(ms).toFloat(),ot(es.y).greaterThan(ms).toFloat(),ot(es.z).greaterThan(ms).toFloat()))}bt(Qt(Qt(ot(xr.x),Qt(ot(xr.y),ot(xr.z))),Qt(ot(os.x),Qt(ot(os.y),ot(os.z)))).greaterThan(7.5),()=>{Vr.assign(I(1))})}),bt(Vr.lessThan(.5),()=>{let xr=ot(k(ue(ts))).toVar();Ji(48,({i:os})=>{bt(xr.lessThan(-.5),()=>{sa()}),F.element(os).assign(xr),re.addAssign(ot(pt(xr))),xr.assign(ot(xt(xr)))})})})});let $e=I(0).toVar();bt(re.greaterThan(.5),()=>{let ts=ll(M(3),Li(re.mul(3))).toVar();$e.assign(I(ts))}),et.element(mt(0)).assign($e.add(p)),et.element(mt(1)).assign(re)}),B1();let be=ot(et.element(mt(1))).toVar(),Ht=ot(et.element(mt(0))).toVar(),Ct=I(ht).toVar();Ji(6,()=>{bt(Ct.greaterThanEqual(be),()=>{sa()});let re=ot(F.element(mt(ce(Ct.mul(1/8))))).toVar(),$e=Ct.sub(ce(Ct.mul(1/8)).mul(8)),ts=mt(re.mul(24).add($e.mul(3))).toVar(),Vr=mt(Ht.add(Ct.mul(3))).toVar(),xr=Ln=>{let es=Tt(Ln===0?ts:ts.add(mt(Ln))).toVar(),ms=mt(es.shiftRight(Li(6))).toVar(),Tr=mt(es.bitAnd(Li(63))).toVar(),Qs=ot((Gr=>B.element(Gr.add(mt(2*N))))(ms)).toVar(),ua=ot(W(ms)),fr=Tr.bitAnd(mt(3)),zs=Tr.shiftRight(mt(2)).bitAnd(mt(3)),pn=Tr.shiftRight(mt(4)).bitAnd(mt(3)),da=fr.shiftRight(mt(1)).add(zs.shiftRight(mt(1)).mul(mt(2))).add(pn.shiftRight(mt(1)).mul(mt(4)));return{blockF:Qs,li:mt(ua.greaterThan(.5).select(da,Tr)).toVar()}},os=xr(0),zn=xr(1),Wo=xr(2);bt(os.blockF.greaterThan(-.5).and(zn.blockF.greaterThan(-.5)).and(Wo.blockF.greaterThan(-.5)),()=>{let Ln=es=>Li(mt(es.blockF.mul(64)).add(es.li));v.element(Vr).assign(Ln(os)),v.element(Vr.add(mt(1))).assign(Ln(zn)),v.element(Vr.add(mt(2))).assign(Ln(Wo))}).Else(()=>{v.element(Vr).assign(Li(0)),v.element(Vr.add(mt(1))).assign(Li(0)),v.element(Vr.add(mt(2))).assign(Li(0))}),Ct.addAssign(64)})})():null,kn=Math.ceil(e/_2[0]),Ic=Math.ceil(r/_2[0]),Br=Math.ceil(n/_2[0]),Z=(F,et)=>F.compute(et,Array.isArray(et)?_2:void 0),Mt=[Jr,Math.max(1,Math.ceil(f/Jr)),1];return{resolution:e,sparse:m!==null,poolBricks:f,meshlet:y!==null,vertexBlocks:_,needsInit:m!==null,sdfTexture:S,colorTexture:w,coarseTexture:T,counterAttribute:C.value,storageAttributes:[C,A,O,B,X,st,ct,wt].filter(F=>F!==null).map(F=>F.value),uniforms:{bboxHalf:o,bboxOffset:l,activeThreshold:u,windowOrigin:h,...y?{windowSize:d,cullEnabled:yt,cullMVP:Ot,adaptCos:Ft}:{}},kernels:{zero:Z(oe,1),clear:jt.compute([Math.ceil(s/256),1,1],[256,1,1]),coarse:Z(Ve,[Br,Br,Br]),...oi?{init:Z(oi,[Br,Br,Br])}:{},...xi?{release:Z(xi,[Br,Br,Br])}:{},...Ks?{alloc:Z(Ks,[Br,Br,Br])}:{},...Hi?{stats:Z(Hi,1)}:{},sdf:Z(Zs,m?Mt:[kn,kn,kn]),...Ci?{sdfWindow:Z(Ci,[kn,kn,kn])}:{},color:Z(ps,[Ic,Ic,Ic]),extract:y?Z(Dm,Mt):Z(tu,m?Mt:[kn,kn,kn]),...y?{clearDraw:Zt.compute([Math.ceil(s/256),1,1],[256,1,1]),meshRelease:Z(li,[Br,Br,Br]),verts:Z(Rm,Mt),vertsWindow:Z(rh,[n,n,n]),extractWindow:Z(Nm,[n,n,n]),classify:Z(Ur,[Br,Br,Br]),gather:Z(y0,Mt)}:{}}}}var ot,MR,ue,Ca,L1,n5,_2,zp,eEt=j(()=>{dt(),mr(),He(),nW(),UW(),ot=t=>t,MR=t=>t,ue=t=>t,Ca=t=>t,L1=24,n5=sW,_2=[4,4,4],zp=(t,e)=>d1t(t,e)});function iEt(t){let e=t.getAttribute("position");if(!e||e.count<3)return null;let i=t.getIndex(),r=Math.floor((i?i.count:e.count)/3);if(r===0)return null;let s=Math.max(1,Math.ceil(r/a5));s>1&&console.warn(`Spline shape blend: mesh child has ${r} triangles \u2014 baking every ${s}th (SDF detail reduced).`);let n=Math.floor(r/s),a=new Float32Array(12*n),o=new P(0,0,0),l=new P,u=0;for(let d=0;d<n;d++){let c=d*s*3;for(let p=0;p<3;p++){let m=i?i.getX(c+p):c+p;l.fromBufferAttribute(e,m),a[u++]=l.x,a[u++]=l.y,a[u++]=l.z,a[u++]=0,o.x=Math.max(o.x,Math.abs(l.x)),o.y=Math.max(o.y,Math.abs(l.y)),o.z=Math.max(o.z,Math.abs(l.z))}}if(o.x===0&&o.y===0&&o.z===0)return null;let h=Math.max(o.x,o.y,o.z);return o.x=Math.max(o.x,.05*h)*(1+AR),o.y=Math.max(o.y,.05*h)*(1+AR),o.z=Math.max(o.z,.05*h)*(1+AR),{data:a,triCount:n,boxHalf:o}}function rEt(t){let e=wc(t),i=pD;return(r,s,n)=>{let a=Qt(G($s(s.z),$s(s.w),$s(n.w)),G(1e-5)).toVar(),o=$s(s.y),l=G(o.mod(Tc).mul(i),ce(o.div(Tc)).mul(i),0).toVar(),u=Ae(lS(r.div(a).mul(.5).add(.5)),G(0),G(1)).mul(i-1).toVar(),h=ii(ce(u),G(i-2)).toVar(),d=u.sub(h).toVar(),c=l.add(h).toVar(),p=(C,M,A)=>$s(ebt(e.load(Qn(c.add(G(C,M,A))))).x),m=$s(d.x),f=$s(d.y),g=$s(d.z),y=Yt(p(0,0,0),p(1,0,0),m),v=Yt(p(0,1,0),p(1,1,0),m),b=Yt(p(0,0,1),p(1,0,1),m),_=Yt(p(0,1,1),p(1,1,1),m),x=Yt(Yt(y,v,f),Yt(b,_,f),g),S=Qt($s(a.x),Qt($s(a.y),$s(a.z))),w=Le(r).sub(a),T=mi(Qt(w,G(0)));return $s(x.mul(S).add(T))}}function sEt(t){let e=pD;return new P(t%Tc*e,Math.floor(t/Tc)*e,0)}var $s,lS,ebt,pD,Tc,AR,a5,nEt=j(()=>{dt(),dt(),mr(),He(),$s=t=>t,lS=t=>t,ebt=t=>t,pD=48,Tc=4,AR=.08,a5=24576});function aEt(){if(CR!==null)return CR;let t=Et(()=>{let i=at(Ze(Y9),Ze(K9)),r=at(1).div(i),s=bi().mul(Ze(Z9)).sub(at(.5)).mul(2).add(at(.5)).toVar();s.x.addAssign(Ze(x2));let n=s.div(i).toVar(),a=Ze(tv.sample(n).x).toVar();n.x.addAssign(Ze(r.x));let o=Ze(tv.sample(n).x).toVar();n.y.addAssign(Ze(r.y));let l=Ze(tv.sample(n).x).toVar();n.x.subAssign(Ze(r.x));let u=Ze(tv.sample(n).x).toVar(),h=a,d=h.add(o),c=d.add(l),p=c.add(u);return lt(p,c,d,h)})(),e=new Re;return e.name="SplineShapeBlend.pyramid",e.fragmentNode=t,e.depthTest=!1,e.depthWrite=!1,e.blending=cr,e.needsUpdate=!0,CR=e,e}function sw(t,e,i=1){return new ri(t,e,{count:i,format:on,type:Qe,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:De,magFilter:De,wrapS:Cn,wrapT:Cn})}function oEt(){let t=Av.length;if(t>0){for(let e of Av)e.dispose();Av.length=0}return t}var Ze,Cht,kd,tv,Y9,K9,x2,Fy,Z9,CR,kL,zL,Mp,dE,LL,FL,UL,jL,GL,WL,qL,cE,ar,nw,Eht,Q9,F1,w2,Av,lEt=j(()=>{dt(),mr(),He(),nW(),e0t(),UW(),eEt(),nEt(),dn(),Ze=t=>t,Cht=t=>t,kd=new Pr,tv=ee(new pi),Y9=gt(1),K9=gt(1),x2=gt(0),Fy=gt(0),Z9=gt(1),CR=null,kL=!1,zL=!1,Mp="",dE=!1,LL=!1,FL=!1,UL=!1,jL=!1,GL=!1,WL=!1,qL=!1,cE=!1;try{let t=new URLSearchParams(window.location.search);kL=t.get("dbgsbmarch")==="vertex",zL=t.get("dbgsbultra")==="0",Mp=t.get("dbgsbchain")??"",dE=t.get("dbgsbnoclear")==="1",LL=t.get("dbgsbsparse")==="0",FL=t.get("dbgsbincr")==="0",UL=t.get("dbgsblod")==="1",jL=t.get("dbgsbpool")==="1",GL=t.get("dbgsbpool")==="0",WL=t.get("dbgsbmesh")==="0",qL=t.get("dbgsbadapt")==="0",cE=t.get("dbgsbcull")==="1"}catch{}ar={updates:0,skips:0,computes:0,readbacksResolved:0,readbackErrors:0,fieldsFull:0,fieldsWindowed:0,lastWindowBricks:0,refines:0,lastDispatchRes:0,regathers:0,readbackPending:!1,lastTotal:-1,lastPass:"",staleConfigSkips:0,marchPositions:null},nw=24576,Eht=Math.cos(8*Math.PI/180),Q9=class{constructor(t=0,e=0,i=0){this.wantsReplacement=!1,this.capacityHint=0,this._builtOnce=!1,this.level=-1,this.spatialnAtBuild=-1,this._passesRenderer=null,this._marchCapacity=0,this._marchBuffers=null,this._computeNode=null,this._computeNodeKey="",this._legacyMaterialsLevel=-1,this._computeDirty=!1,this._cachedAtBuild=!1,this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,this._lastFieldChangeMs=0,this._ultraResAtBuild=0,this._ultraReadbackPending=!1,this._ultraReadbackQueued=!1,this._ultraWantedCapacity=0,this._poolAtBuild=0,this._ultraWantedPoolBricks=0,this.poolHint=0,this._drawIndex=null,this._vertexBuffers=null,this._vertBlocksAtBuild=0,this._ultraWantedVertexBlocks=0,this.vertHint=0,this._cullCamera=null,this._lastGatherMVP=new _t,this._hasGatherMVP=!1,this._ultraRetired=[],this._retiredStorage=[],this._ultraBuildSeq=0,this._lastRenderer=null,this._meshBaker=null,this._meshAtBuild=!1,this._meshSlots=new Map,this._meshBakeFailed=new Map,this._meshWarnedFull=!1,this.shapesTex=ee(new pi),this.spatialTexNode=ee(new pi),this.potentialTexNode=ee(new pi),this.voxelTexNode=ee(new pi),this.pyramid1TexNode=ee(new pi),this.pyramid2TexNode=ee(new pi),this.npartUniform=gt(0),this.spatialnUniform=gt(1),this.spanUniform=gt(0),this.spatialMaterial=null,this.potentialMaterial=null,this.voxelMaterial=null,this.spatialTargets=[],this.potentialTargets=[],this.voxelTargets=[],this.pyramidTargets=[],this.retired=!1,this._onSettled=[],this.capacityHint=t,this.poolHint=e,this.vertHint=i;let r=qP(),s=new br(r.triTable,16,256,Qa,Qe);s.needsUpdate=!0;let n=new br(r.numTrisTable,256,1,Qa,Qe);n.needsUpdate=!0,this.triTableTexNode=ee(s),this.numTrisTableTexNode=ee(n)}shapeRow(t,e){return this.shapesTex.sample(at(t,(e+.5)/5))}_quadMaterial(t,e){let i=new Re;return i.name=t,i.fragmentNode=e,i.depthTest=!1,i.depthWrite=!1,i.blending=cr,i.needsUpdate=!0,i}_buildSpatialMaterial(t){let e=t.spatialDivisions,i=sW,r=this.npartUniform,s=this.spatialnUniform,n=this.spanUniform,a=t.spatialn,o=Et(()=>{let l=at(e*a,e**2),u=ce(bi().mul(l)).toVar(),h=Ze(u.y).toVar(),d=h.sub(ce(h.div(e)).mul(e)).toVar();h.assign(ce(h.div(e)));let c=h,p=Ze(u.x).toVar(),m=p.sub(ce(p.div(s)).mul(Ze(s))).toVar().mul(96).toVar();p.assign(ce(p.div(s)));let f=G(p,d,c),g=f.div(e).mul(2).sub(1).sub(Ze(n)).toVar(),y=f.add(1).div(e).mul(2).sub(1).add(Ze(n)).toVar(),v=b=>{let _=I(0).toVar();for(let x=23;x>=0;x--){let S=b.add(x),w=S.add(.5).div(i),T=this.shapeRow(w,0),C=Cht(T.xyz),M=Ze(T.w);_.mulAssign(2);let A=Ze(g.x).lessThan(Ze(C.x)).and(Ze(C.x).lessThan(Ze(y.x))).and(Ze(g.y).lessThan(Ze(C.y))).and(Ze(C.y).lessThan(Ze(y.y))).and(Ze(g.z).lessThan(Ze(C.z))).and(Ze(C.z).lessThan(Ze(y.z))).and(S.lessThan(Ze(r))).or(M.equal(-2));_.addAssign(A.select(I(1),I(0)))}return _};return lt(v(m),v(m.add(24)),v(m.add(48)),v(m.add(72)))})();return this._quadMaterial("SplineShapeBlend.spatial",o)}_fieldEnv(t,e){return{shapeRow:(i,r)=>this.shapeRow(i,r),spatialTex:this.spatialTexNode,spatialDivisions:t.spatialDivisions,spatialn:t.spatialn,colorKBump:e,meshSdf:this._meshBaker?rEt(this._meshBaker.atlas):void 0}}_buildPotentialMaterial(t){let e=t.spatialDivisions,i=t.resolution,r=i-1,s=1/i,n=t.zLayersPerRow,a=t.basePyramidSize,o=X9(this._fieldEnv(t,2*s)),l=Et(()=>{let u=ce(bi().mul(at(a,a))).toVar(),h=Ze(u.x).mod(i),d=Ze(u.y).mod(i),c=ce(Ze(u.x).mul(s)).add(ce(Ze(u.y).mul(s)).mul(n)),p=G(h,d,c),m=p.div(r).mul(2).sub(1).toVar(),f=ce(p.div(r).mul(e-1)).toVar(),{sdf:g,color:y}=o(m,f),v=Li(Ze(y.x).mul(255)),b=Li(Ze(y.y).mul(255)),_=v.shiftLeft(Li(8)).bitOr(b);return lt(g,_.toFloat().mul(1525902e-11),Ze(y.z),Ze(y.w))})();return this._quadMaterial("SplineShapeBlend.potential",l)}_buildVoxelMaterial(t){let e=t.resolution,i=e-1,r=1/e,s=t.zLayersPerRow,n=t.basePyramidSize,a=Kvt(e,s),o=this.potentialTexNode,l=()=>{let c=ce(bi().mul(at(n,n))).toVar();return{xi:Ze(c.x).mod(e).toVar(),yi:Ze(c.y).mod(e).toVar(),zi:ce(Ze(c.x).mul(r)).add(ce(Ze(c.y).mul(r)).mul(s)).toVar()}},u=(c,p,m)=>{let f=(g,y,v,b)=>Ze(a(c.add(g),p.add(y),m.add(v),o).x).lessThan(0).toFloat().mul(b);return f(0,0,0,1).add(f(1,0,0,2)).add(f(0,1,0,8)).add(f(1,1,0,4)).add(f(0,0,1,16)).add(f(1,0,1,32)).add(f(0,1,1,128)).add(f(1,1,1,64))},h=Et(()=>{let{xi:c,yi:p,zi:m}=l(),f=((v,b,_)=>{let x=Ze(a(v.add(1),b,_,o).x).sub(Ze(a(v.sub(1),b,_,o).x)),S=Ze(a(v,b.add(1),_,o).x).sub(Ze(a(v,b.sub(1),_,o).x)),w=Ze(a(v,b,_.add(1),o).x).sub(Ze(a(v,b,_.sub(1),o).x));return x.equal(0).and(S.equal(0)).and(w.equal(0)).select(G(.199,.299,.399),xe(G(x,S,w)))})(c,p,m).toVar(),g=lt(f,0).toVar(),y=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(m.greaterThanEqual(i));return bt(y.not(),()=>{g.assign(lt(f,u(c,p,m)))}),g})(),d=Et(()=>{let{xi:c,yi:p,zi:m}=l(),f=lt(0).toVar(),g=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(m.greaterThanEqual(i));return bt(g.not(),()=>{let y=u(c,p,m);f.assign(this.numTrisTableTexNode.sample(at(y.add(.5).div(256),.5)))}),f})();return this._quadMaterial("SplineShapeBlend.voxel",Fv({output:h,numTris:d}))}_spatialTargetFor(t){let e=t.resolutionLevel,i=this.spatialTargets[e];return i||(i=sw(t.spatialDivisions*t.spatialn,t.spatialDivisions**2),this.spatialTargets[e]=i),i}_targetsFor(t){let e=t.resolutionLevel,i=this._spatialTargetFor(t),r=this.potentialTargets[e];r||(r=sw(t.basePyramidSize,t.basePyramidSize),this.potentialTargets[e]=r);let s=this.voxelTargets[e];s||(s=sw(t.basePyramidSize,t.basePyramidSize,2),s.textures[0].name="output",s.textures[1].name="numTris",s.textures[1].format=Qa,this.voxelTargets[e]=s);let n=this.pyramidTargets[e];return n||(n=[sw(t.pyramidTexture1Width,t.pyramidTexture1Height),sw(t.pyramidTexture2Width,t.pyramidTexture2Height)],this.pyramidTargets[e]=n),{spatial:i,potential:r,voxel:s,pyramid:n}}_marchResources(t){let e=this._targetsFor(t),i=t.pyramidLevelSizes.length%2==0?0:1,r=1-i;return{resolutionLevel:t.resolutionLevel,pyramidLevelSizes:t.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:e.pyramid[r].width,height:e.pyramid[r].height},pyramid2Size:{width:e.pyramid[i].width,height:e.pyramid[i].height}}}_maxMarchSlots(t){let e=t.backend?.device?.limits,i=Math.min(e?.maxStorageBufferBindingSize??134217728,e?.maxBufferSize??268435456);return 192*Math.floor(i/16/192)}_ensureMarchCapacity(t,e){if(this._marchBuffers!==null&&t<=this._marchCapacity)return!1;let i=Math.min(Math.max(e,nw),192*Math.ceil(1.5*t/192));if(this._marchBuffers!==null&&i<=this._marchCapacity)return!1;if(this._marchBuffers!==null)for(let r of[this._marchBuffers.positions,this._marchBuffers.normals,this._marchBuffers.colors]){let s=r.value;s&&this._retiredStorage.push(s)}return this._marchBuffers={positions:Qr(i,"vec4"),normals:Qr(i,"vec4"),colors:Qr(i,"vec4")},this._marchCapacity=i,this._computeNode=null,!0}update(t,e,i){if(ar.updates++,this._lastRenderer=e,i!==void 0&&(this._cullCamera=i),t._meshSdfBaked.size>0)for(let[T,C]of t._meshSdfBaked)C.owner!==this&&t._meshSdfBaked.delete(T);let r=(n=t,m0t.call(n)),s=e.backend?.isWebGPUBackend===!0;var n;if(s&&t._meshSdfWanted.size>0&&this._meshBaker===null&&(this._meshBaker=function(T,C){let M=pD,A=new Hg(Tc*M,Math.ceil(T/Tc)*M,M);A.format=Qa,A.type=Qe,A.minFilter=De,A.magFilter=De,A.name="SplineShapeBlend.meshSdfAtlas";let R=I(C).mul(0),O=gt(new P(0,0,0)),N=gt(0),B=gt(new P(1,1,1)),L=Qr(3*a5,"vec4"),z=W=>L.element(W),k=Et(()=>{let W=G(uo).toVar();bt($s(W.x).greaterThanEqual(M).or($s(W.y).greaterThanEqual(M)).or($s(W.z).greaterThanEqual(M)),()=>{yr()});let X=W.div(M-1).mul(2).sub(1).mul(B).toVar(),st=I(1e30).toVar(),nt=I(1e15).toVar();Ji(a5,({i:pt})=>{bt(I(pt).greaterThanEqual($s(N)),()=>{sa()});let K=mt(I(pt).toVar()).mul(3).toVar(),ct=lS(z(K).xyz).toVar(),St=lS(z(K.add(mt(1))).xyz).toVar(),wt=lS(z(K.add(mt(2))).xyz).toVar(),Tt=St.sub(ct).toVar(),yt=wt.sub(ct).toVar(),Ot=X.sub(ct).toVar(),Ft=kt(Tt,Ot).toVar(),Bt=kt(yt,Ot).toVar(),zt=X.sub(St).toVar(),Vt=kt(Tt,zt).toVar(),Wt=kt(yt,zt).toVar(),$t=X.sub(wt).toVar(),Pt=kt(Tt,$t).toVar(),oe=kt(yt,$t).toVar(),jt=G(0).toVar(),Zt=Vt.mul(oe).sub(Pt.mul(Wt)).toVar(),Jt=Pt.mul(Bt).sub(Ft.mul(oe)).toVar(),$=Ft.mul(Wt).sub(Vt.mul(Bt)).toVar();bt(Ft.lessThanEqual(0).and(Bt.lessThanEqual(0)),()=>{jt.assign(ct)}).ElseIf(Vt.greaterThanEqual(0).and(Wt.lessThanEqual(Vt)),()=>{jt.assign(St)}).ElseIf(oe.greaterThanEqual(0).and(Pt.lessThanEqual(oe)),()=>{jt.assign(wt)}).ElseIf($.lessThanEqual(0).and(Ft.greaterThanEqual(0)).and(Vt.lessThanEqual(0)),()=>{let Ve=Ft.div(Ft.sub(Vt));jt.assign(ct.add(Tt.mul(Ve)))}).ElseIf(Jt.lessThanEqual(0).and(Bt.greaterThanEqual(0)).and(oe.lessThanEqual(0)),()=>{let Ve=Bt.div(Bt.sub(oe));jt.assign(ct.add(yt.mul(Ve)))}).ElseIf(Zt.lessThanEqual(0).and(Wt.sub(Vt).greaterThanEqual(0)).and(Pt.sub(oe).greaterThanEqual(0)),()=>{let Ve=Wt.sub(Vt).div(Wt.sub(Vt).add(Pt.sub(oe)));jt.assign(St.add(wt.sub(St).mul(Ve)))}).Else(()=>{let Ve=I(1).div(Zt.add(Jt).add($)),ie=Jt.mul(Ve),oi=$.mul(Ve);jt.assign(ct.add(Tt.mul(ie)).add(yt.mul(oi)))});let se=X.sub(jt).toVar(),Pe=kt(se,se).toVar();bt(Pe.lessThan(st),()=>{st.assign(Pe);let Ve=Zr(Tt,yt),ie=kt(se,Ve).greaterThanEqual(0).select(I(1),I(-1));nt.assign(xl(Pe).mul(ie))})});let xt=Qt($s(B.x),Qt($s(B.y),$s(B.z)));qp(A,Qn(W.add(O)),lt($s(nt.div(xt).add(R)),0,0,0)).toStack()})(),V=Math.ceil(M/4),H=k.compute([V,V,V],[4,4,4]);return{atlas:A,slots:T,kernel:H,uniforms:{slotOrigin:O,triCount:N,boxHalf:B},setTriangles(W,X){let st=L.value;st.array.set(W.subarray(0,12*X)),st.needsUpdate=!0}}}(Tc*Tc,++this._ultraBuildSeq)),t.npart===0)return this._meshBaker!==null&&t._meshSdfWanted.size>0&&this._bakeNextMeshChild(t,e),void(t.geometry.drawRange.count=0);this.npartUniform.value=t.npart,this.spatialnUniform.value=t.spatialn,this.spanUniform.value=t.spatialPassUniforms.span.value,t.shapesDataTexture.value&&(this.shapesTex.value=t.shapesDataTexture.value);let a=!kL&&s,o=a&&!zL&&t.ultraFieldResolution>0,l=o&&!GL&&(jL||t.ultraFieldResolution>=512)?Math.min(Math.pow(t.ultraFieldResolution/4,3),Math.max(function(T){let C=T/4;return Math.min(C*C*C,Math.max(8192,16*C*C))}(t.ultraFieldResolution),this._ultraWantedPoolBricks,this.poolHint)):0,u=l>0&&!WL,h=this._maxMarchSlots(e),d=u?Math.min(Math.floor(h/64),Math.max(function(T){let C=T/4;return Math.min(262144,Math.max(2048,2*C*C))}(t.ultraFieldResolution),this._ultraWantedVertexBlocks,this.vertHint)):0,c=this._meshBaker!==null,p=t.needsRebuild||this.level!==t.resolutionLevel||this.spatialnAtBuild!==t.spatialn||this._cachedAtBuild!==a||this._ultraResAtBuild!==(o?t.ultraFieldResolution:0)||this._poolAtBuild!==l||this._vertBlocksAtBuild!==d||this._meshAtBuild!==c;if(p&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let m=a&&this._ensureMarchCapacity(Math.min(Math.max(h,nw),Math.max(t.geometry.drawRange.count,this.capacityHint,o?Math.max(function(T){return Math.max(nw,192*Math.ceil(16*T*T/192))}(t.ultraFieldResolution),this._ultraWantedCapacity):nw)),h);if(m&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let f=this._spatialTargetFor(t),g=o?null:this._targetsFor(t),y=p||m,v=o&&this._ultra!==null&&this._ultraResAtBuild===t.ultraFieldResolution&&!m&&this.level===t.resolutionLevel&&this.spatialnAtBuild===t.spatialn&&this._cachedAtBuild===a;if(y&&v)t.needsRebuild=!1,this._ultra.uniforms.bboxHalf.value=t.bboxSize/2,this._ultra.uniforms.bboxOffset.value=t.bboxOffset,this._ultraDrag&&(this._ultraDrag.uniforms.bboxHalf.value=t.bboxSize/2,this._ultraDrag.uniforms.bboxOffset.value=t.bboxOffset);else if(y){t.needsRebuild=!1;let T=this.spatialnAtBuild!==t.spatialn;this.level=t.resolutionLevel,this.spatialnAtBuild=t.spatialn,this._meshAtBuild=c,(T||this.spatialMaterial===null)&&(this.spatialMaterial?.dispose(),this.spatialMaterial=this._buildSpatialMaterial(t)),this.spatialTexNode.value=f.texture;let C=this._ultra,M=this._ultraDrag;if(this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,o){let O=t.ultraFieldResolution,N=C!==null&&this._ultraResAtBuild===O;if(N&&!m)this._ultra=C,C.uniforms.bboxHalf.value=t.bboxSize/2,C.uniforms.bboxOffset.value=t.bboxOffset,this._ultraDrag=M,M&&(M.uniforms.bboxHalf.value=t.bboxSize/2,M.uniforms.bboxOffset.value=t.bboxOffset);else{let B=N&&l===0&&!C.sparse;C&&!B&&this._ultraRetired.push(C.sdfTexture,C.colorTexture,C.coarseTexture),u&&this._drawIndex===null&&(this._drawIndex=Qr(this._marchCapacity,"uint")),u&&this._vertexBuffers===null&&(this._vertexBuffers={positions:Qr(64*d,"vec4"),normals:Qr(64*d,"vec4"),colors:Qr(64*d,"vec4")}),this._ultra=Aht({resolution:O,colorResolution:O/2,bboxHalf:t.bboxSize/2,bboxOffset:t.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(t,2/(O/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:qP().numTrisTable,buffers:u?this._vertexBuffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,sparseStorage:l>0?{poolBricks:l,meshlet:u?{drawIndex:this._drawIndex,vertexBlocks:d}:void 0}:void 0,reuseTextures:B?{sdfTexture:C.sdfTexture,colorTexture:C.colorTexture,coarseTexture:C.coarseTexture}:void 0}),this._poolAtBuild=l,this._vertBlocksAtBuild=d;let L=UL&&O>=128&&!u?O/2:0;M&&(!N||L===0)&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),L>0&&(this._ultraDrag=Aht({resolution:L,colorResolution:L/2,bboxHalf:t.bboxSize/2,bboxOffset:t.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(t,2/(L/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:qP().numTrisTable,buffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,reuseTextures:N&&M?{sdfTexture:M.sdfTexture,colorTexture:M.colorTexture,coarseTexture:M.coarseTexture}:void 0}))}this._ultraResAtBuild=O}else{C&&this._ultraRetired.push(C.sdfTexture,C.colorTexture,C.coarseTexture),M&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),(this._legacyMaterialsLevel!==t.resolutionLevel||T||this.potentialMaterial===null||this.voxelMaterial===null)&&(this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose(),this.potentialMaterial=this._buildPotentialMaterial(t),this.voxelMaterial=this._buildVoxelMaterial(t),this._legacyMaterialsLevel=t.resolutionLevel),this.potentialTexNode.value=g.potential.texture,this.voxelTexNode.value=g.voxel.textures[0];let O=t.pyramidLevelSizes.length%2==0?0:1,N=1-O;this.pyramid1TexNode.value=g.pyramid[N].texture,this.pyramid2TexNode.value=g.pyramid[O].texture,this._ultraResAtBuild=0}let A=t.material;A.defines===void 0&&(A.defines={}),Mp.includes("nomat")||(A.defines.SHAPEBLEND=t.resolutionLevel),Mp.includes("nomat")||A.setShapeBlendResources?.(o?{resolutionLevel:t.resolutionLevel,pyramidLevelSizes:t.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:1,height:1},pyramid2Size:{width:1,height:1},cached:u?{...this._vertexBuffers,drawIndex:this._drawIndex}:this._marchBuffers}:{...this._marchResources(t),cached:a?this._marchBuffers:void 0}),this._cachedAtBuild=a;let R=`${t.resolutionLevel}:${this._marchCapacity}`;this._computeNodeKey!==R&&(this._computeNode=null,this._computeNodeKey=R)}if(y)return this._builtOnce=!0,void(this._computeDirty=!0);this._meshBaker!==null&&t._meshSdfWanted.size>0&&this._bakeNextMeshChild(t,e);let b=this._passesRenderer!==e,_=r&&!FL&&!this._computeDirty&&!b&&!t._fieldDirtyFull;if(!(r||this._computeDirty||b)){if(o&&this._refinePending&&this._ultra!==null&&performance.now()-this._lastFieldChangeMs>250)return this._refinePending=!1,this._passesRenderer=e,ar.refines++,void this._runUltra(t,e,!1,this._ultra);if(o&&cE&&this._ultra!==null&&this._ultra.meshlet&&this._lastDispatched===this._ultra&&!this._ultraReadbackPending&&this._updateCullUniforms(t,this._ultra)&&(!this._hasGatherMVP||!this._lastGatherMVP.equals(this._ultra.uniforms.cullMVP.value))){this._lastGatherMVP.copy(this._ultra.uniforms.cullMVP.value),this._hasGatherMVP=!0,ar.regathers++;let T=e;return T.compute(this._ultra.kernels.zero),dE||T.compute(this._ultra.kernels.clearDraw),T.compute(this._ultra.kernels.gather),this._ultra.kernels.stats&&T.compute(this._ultra.kernels.stats),void this._runUltraReadback(t,e)}if(!t.drawRangeNeedsForceUpdate)return void ar.skips++;if(o)return void(this._ultraReadbackPending||this._runUltraReadback(t,e))}if(this._passesRenderer=e,Mp.includes("none")&&ar.readbacksResolved>0)return void(this._computeDirty=!1);let x=e.getRenderTarget(),S=e.getMRT(),w=e.autoClear;if(e.setMRT(null),e.autoClear=!1,ar.lastPass="spatial",e.setRenderTarget(f),kd.material=this.spatialMaterial,kd.render(e),o){e.autoClear=w,e.setRenderTarget(x),e.setMRT(S);let T=this._ultraDrag!==null&&r&&!this._computeDirty;return this._refinePending=T,this._lastFieldChangeMs=performance.now(),this._runUltra(t,e,_,T?this._ultraDrag:this._ultra),void(this._computeDirty=!1)}return Mp==="spatial"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="potential",e.setRenderTarget(g.potential),kd.material=this.potentialMaterial,kd.render(e),Mp==="potential"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="voxel",e.setRenderTarget(g.voxel),kd.material=this.voxelMaterial,kd.render(e),Mp==="voxel"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="pyramid",this._renderPyramid(t,e,g.voxel,g.pyramid),e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),ar.lastPass="march",a&&(this._computeNode===null&&(this._computeNode=function(T,C,M){let A=Zvt(T);return Et(()=>{let{position:R,normal:O,color:N}=A(Pn.toFloat());C.positions.element(Pn).assign(lt(R,1)),C.normals.element(Pn).assign(lt(O,0)),C.colors.element(Pn).assign(N)})().compute(M)}(this._marchResources(t),this._marchBuffers,this._marchCapacity)),e.compute(this._computeNode),ar.computes++),void(this._computeDirty=!1))))}_bakeNextMeshChild(t,e){let i=this._meshBaker;for(let[r,s]of t._meshSdfWanted){let n=c0t(s);if(this._meshBakeFailed.get(r)===n)continue;let a=this._meshSlots.get(r);if(a===void 0){if(this._meshSlots.size>=i.slots)for(let u of this._meshSlots.keys())!t._meshSdfBaked.has(u)&&!t._meshSdfWanted.has(u)&&(this._meshSlots.delete(u),this._meshBakeFailed.delete(u));if(this._meshSlots.size>=i.slots){this._meshWarnedFull||(this._meshWarnedFull=!0,console.warn(`Spline shape blend: more than ${i.slots} distinct mesh children \u2014 the extra meshes are left out of the blend.`));continue}let l=new Set(this._meshSlots.values());for(a=0;l.has(a);)a++;this._meshSlots.set(r,a)}let o=iEt(s);if(o!==null)return i.setTriangles(o.data,o.triCount),i.uniforms.slotOrigin.value.copy(sEt(a)),i.uniforms.triCount.value=o.triCount,i.uniforms.boxHalf.value.copy(o.boxHalf),e.compute(i.kernel),t._meshSdfBaked.set(r,{slot:a,boxHalf:o.boxHalf.clone(),posVersion:n,owner:this}),void t._meshSdfWanted.delete(r);this._meshBakeFailed.set(r,n)}}_updateCullUniforms(t,e){if(!e.meshlet)return!1;let i=this._cullCamera;return cE&&i&&i.projectionMatrix!==void 0&&i.matrixWorldInverse!==void 0?(e.uniforms.cullMVP.value.multiplyMatrices(Lt.unjitteredProjection.value,i.matrixWorldInverse).multiply(t.matrixWorld),e.uniforms.cullEnabled.value=1,!0):(e.uniforms.cullEnabled.value=0,!1)}_runUltra(t,e,i,r){let s=e;ar.lastPass="ultra-kernels",ar.lastDispatchRes=r.resolution,ar.marchPositions=(r.meshlet?this._vertexBuffers:this._marchBuffers).positions.value,this._lastDispatched=r;let n=r.resolution,a=n/4,o=2/(n-1);r.uniforms.activeThreshold.value=LL?1e30:(3*Math.sqrt(3)+4)*o+.25*t._maxBlendK;let l=r.meshlet&&!qL;r.meshlet&&(r.uniforms.adaptCos.value=l?Eht:2);let u=0,h=0,d=0,c=a,p=a,m=a;if(i){let y=r.uniforms.activeThreshold.value+2/(t.spatialDivisions-1)+4/(n-1),v=x=>Math.floor(.5*(x+1)*(n-1)/4),b=x=>Math.min(a-1,Math.max(0,v(x))),_=x=>Math.min(a,Math.max(1,v(x)+1));if(u=b(t._fieldDirtyMin.x-y),h=b(t._fieldDirtyMin.y-y),d=b(t._fieldDirtyMin.z-y),c=_(t._fieldDirtyMax.x+y)-u,p=_(t._fieldDirtyMax.y+y)-h,m=_(t._fieldDirtyMax.z+y)-d,ar.fieldsWindowed++,l){let x=Math.min(a,u+c+1),S=Math.min(a,h+p+1),w=Math.min(a,d+m+1);u=Math.max(0,u-1),h=Math.max(0,h-1),d=Math.max(0,d-1),c=x-u,p=S-h,m=w-d}}else ar.fieldsFull++;ar.lastWindowBricks=c*p*m,r.uniforms.windowOrigin.value.set(u,h,d),r.uniforms.windowSize?.value.set(c,p,m);let f=u===0&&h===0&&d===0&&c===a&&p===a&&m===a,g=[Math.ceil(c/4),Math.ceil(p/4),Math.ceil(m/4)];r.meshlet&&this._updateCullUniforms(t,r)&&(this._lastGatherMVP.copy(r.uniforms.cullMVP.value),this._hasGatherMVP=!0),s.compute(r.kernels.zero),dE||s.compute(r.meshlet?r.kernels.clearDraw:r.kernels.clear),r.needsInit&&r.kernels.init&&(s.compute(r.kernels.init),r.needsInit=!1),s.compute(r.kernels.coarse,g),r.kernels.release&&s.compute(r.kernels.release,g),r.kernels.alloc&&s.compute(r.kernels.alloc,g),r.kernels.meshRelease&&s.compute(r.kernels.meshRelease,g),r.sparse?f?s.compute(r.kernels.sdf):s.compute(r.kernels.sdfWindow,[c,p,m]):s.compute(r.kernels.sdf,[c,p,m]),r.kernels.classify&&s.compute(r.kernels.classify,g),s.compute(r.kernels.color,[Math.ceil(c/2),Math.ceil(p/2),Math.ceil(m/2)]),r.meshlet?(f?(s.compute(r.kernels.verts),s.compute(r.kernels.extract)):(s.compute(r.kernels.vertsWindow,[c,p,m]),s.compute(r.kernels.extractWindow,[c,p,m])),s.compute(r.kernels.gather)):s.compute(r.kernels.extract),r.kernels.stats&&s.compute(r.kernels.stats),ar.computes++,this._ultraReadbackPending?this._ultraReadbackQueued=!0:this._runUltraReadback(t,e)}_disposeRetired(){for(let t of this._ultraRetired)t.dispose();if(this._ultraRetired.length=0,this._retiredStorage.length>0){let t=this._lastRenderer?.backend?.attributeUtils;if(t)for(let e of this._retiredStorage)t.destroyAttribute(e);this._retiredStorage.length=0}for(let t of this._onSettled)t();this._onSettled.length=0}runWhenSettled(t){this._onSettled.push(t)}transferSettleQueue(t){t._onSettled.push(...this._onSettled),this._onSettled.length=0}_runUltraReadback(t,e){let i=this._lastDispatched??this._ultra,r=e;this._ultraReadbackPending=!0,ar.readbackPending=!0,r.getArrayBufferAsync(i.counterAttribute).then(s=>{if(this._ultraReadbackPending=!1,ar.readbackPending=!1,this.retired)return;this._disposeRetired();let n=new Uint32Array(s),a=i.meshlet?Math.floor(n[3]/3):n[0];if(ar.readbacksResolved++,ar.lastTotal=a,i.sparse&&n.length>2&&n[2]>0&&(this._ultraWantedPoolBricks=Math.ceil(1.5*Math.max(n[1],i.poolBricks)),this._computeDirty=!0),i.meshlet&&n.length>5&&n[5]>0){let l=Math.min(24*n[4],this._maxMarchSlots(e));l>this._marchCapacity&&(this._ultraWantedCapacity=Math.max(this._ultraWantedCapacity,l),this._computeDirty=!0)}if(i.meshlet&&n.length>7&&n[7]>0){let l=Math.min(Math.ceil(1.5*n[6]),Math.floor(this._maxMarchSlots(e)/64));l>i.vertexBlocks&&(this._ultraWantedVertexBlocks=Math.max(this._ultraWantedVertexBlocks,l),this._computeDirty=!0)}let o=Math.floor(this._marchCapacity/3);if(t.geometry.drawRange.count=3*Math.min(Math.ceil(1.25*a),o),t.markSceneShadowsDirty(),t.drawRangeNeedsForceUpdate=!1,this._ultraReadbackQueued&&(this._ultraReadbackQueued=!1,this._runUltraReadback(t,e)),a>o){let l=Math.min(3*a,this._maxMarchSlots(e));l>this._marchCapacity&&(this._ultraWantedCapacity=l,this._computeDirty=!0)}}).catch(()=>{ar.readbackErrors++,this._ultraReadbackPending=!1,ar.readbackPending=!1})}_renderPyramid(t,e,i,r){let s=t.pyramidLevelSizes,n=s.length-1-1;x2.value=0,Fy.value=0;for(let o=n;o>=0;o--){let l=o%2==n%2?r[0]:r[1],u=o===n?i:o%2==n%2?r[1]:r[0];tv.value=u.textures.length>1?u.textures[1]:u.texture,Y9.value=u.width,K9.value=u.height;let h=s[o];o===2&&t.resolutionLevel%2!=0&&(h=3),Z9.value=h,l.viewport.set(Fy.value,0,h,h),e.setRenderTarget(l),kd.material=aEt(),kd.render(e),l.viewport.set(0,0,l.width,l.height);let d=x2.value;x2.value=Fy.value,Fy.value=d,o<n&&(Fy.value+=s[o+1])}ar.lastPass="pyramid-readback";let a=s.length%2==0?0:1;e.readRenderTargetPixelsAsync(r[a],r[a].width-1,0,1,1).then(o=>{let l=o[0];ar.readbacksResolved++,ar.lastTotal=l,!this.retired&&(this._disposeRetired(),(3*l>t.geometry.drawRange.count||t.drawRangeNeedsForceUpdate)&&(t.geometry.drawRange.count=3*Math.floor(1.2*l)),t.drawRangeNeedsForceUpdate=!1,this._marchBuffers!==null&&t.geometry.drawRange.count>this._marchCapacity&&(this._computeDirty=!0))}).catch(()=>{})}dispose(){for(let s of[...this.spatialTargets,...this.potentialTargets,...this.voxelTargets,...this.pyramidTargets.flat()])s?.dispose();this.spatialMaterial?.dispose(),this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose();let t=this._lastRenderer?.backend?.attributeUtils,e=s=>{if(t&&s!==null)for(let n of[s.positions,s.normals,s.colors]){let a=n.value;a&&t.destroyAttribute(a)}},i=s=>{if(s!==null){for(let n of Object.values(s.kernels))n?.dispose?.();if(t)for(let n of s.storageAttributes)t.destroyAttribute(n)}};e(this._marchBuffers),e(this._vertexBuffers);let r=this._drawIndex?.value;t&&r&&t.destroyAttribute(r),this._drawIndex=null,this._computeNode?.dispose?.(),this._marchBuffers=null,this._vertexBuffers=null,this._computeNode=null,this._computeNodeKey="",this._marchCapacity=0,i(this._ultra),this._ultra?.sdfTexture.dispose(),this._ultra?.colorTexture.dispose(),this._ultra?.coarseTexture.dispose(),this._ultra=null,i(this._ultraDrag),this._ultraDrag?.sdfTexture.dispose(),this._ultraDrag?.colorTexture.dispose(),this._ultraDrag?.coarseTexture.dispose(),this._ultraDrag=null,this._meshBaker?.atlas.dispose(),this._meshBaker=null,this._lastDispatched=null,this._disposeRetired(),this._lastRenderer=null}},F1=new WeakMap,w2=new WeakMap,Av=[]}),hEt=j(()=>{tD(),UW(),lEt(),F4=tEt,eW=t=>function(e){let i=F1.get(e);if(i?.wantsReplacement){let r=w2.get(e);w2.set(e,i),i.retired=!0;let s=new Q9(i.capacityHint,i.poolHint,i.vertHint);i.transferSettleQueue(s),r&&s.runWhenSettled(()=>r.dispose()),i=s,F1.set(e,i)}return i||(i=new Q9,F1.set(e,i)),i}(t),function(t){iW=t}({release:t=>function(e){let i=F1.get(e),r=w2.get(e);F1.delete(e),w2.delete(e),r&&Av.push(r),i&&(i.retired=!0,Av.push(i))}(t),drainRetired:oEt})});function uEt(){let t=hS.length;if(t>0){for(let e of hS)e.dispose();hS.length=0}return t}var oo,va,Gl,Je,Eh,Pht,HL,Rht,Dht,pE,Nht,mE,Oht,Iht,$L,zd,Uy,aw,ibt,S2,hS,o5,jy,rbt,sbt,nbt,abt,obt,lbt,dEt=j(()=>{dt(),mr(),He(),Jgt(),Qgt(),oo=[64,1,1],Gl=(va=yg)-1,Je=(t,e)=>e!==void 0?gt(t,e):gt(t),Eh=(t,e)=>{let i=t.xyz,r=Zr(i,e),s=Zr(i,r);return e.add(r.mul(t.w).mul(2)).add(s.mul(2))},Pht=t=>{let e=kt(t,t);return e.lessThan(1e-10).select(lt(0,0,0,1),t.mul(xW(Qt(e,1e-20))))},HL=Et(([t,e])=>{let i=t,r=e,s=kt(i,r).add(1).toVar(),n=G(0).toVar();return bt(s.lessThan(1e-7),()=>{s.assign(0),bt(Le(i.x).greaterThan(Le(i.z)),()=>{n.assign(G(i.y.negate(),i.x,0))}).Else(()=>{n.assign(G(0,i.z.negate(),i.y))})}).Else(()=>{n.assign(Zr(i,r))}),Pht(lt(n,s))}),Rht=t=>t.sub(ce(t.mul(1/289)).mul(289)),Dht=t=>t.sub(ce(t.mul(1/289)).mul(289)),pE=t=>Dht(t.mul(34).add(10).mul(t)),Nht=t=>lt(1.79284291400159).sub(t.mul(.85373472095314)),mE=Et(([t])=>{let e=t,i=1/6,r=1/3,s=ce(e.add(kt(e,G(r)))).toVar(),n=e.sub(s).add(kt(s,G(i))).toVar(),a=Ai(n.yzx,n.xyz).toVar(),o=G(1).sub(a).toVar(),l=ii(a,o.zxy).toVar(),u=Qt(a,o.zxy).toVar(),h=n.sub(l).add(i).toVar(),d=n.sub(u).add(r).toVar(),c=n.sub(.5).toVar();s.assign(Rht(s));let p=pE(pE(pE(lt(0,l.z,u.z,1).add(s.z)).add(s.y).add(lt(0,l.y,u.y,1))).add(s.x).add(lt(0,l.x,u.x,1))).toVar(),m=.142857142857,f=2*m,g=.5*m-1,y=m,v=p.sub(ce(p.mul(y*y)).mul(49)).toVar(),b=ce(v.mul(y)).toVar(),_=ce(v.sub(b.mul(7))).toVar(),x=b.mul(f).add(g).toVar(),S=_.mul(f).add(g).toVar(),w=lt(1).sub(Le(x)).sub(Le(S)).toVar(),T=lt(x.xy,S.xy).toVar(),C=lt(x.zw,S.zw).toVar(),M=ce(T).mul(2).add(1).toVar(),A=ce(C).mul(2).add(1).toVar(),R=Ai(w,lt(0)).negate().toVar(),O=T.xzyw.add(M.xzyw.mul(R.xxyy)).toVar(),N=C.xzyw.add(A.xzyw.mul(R.zzww)).toVar(),B=G(O.xy,w.x).toVar(),L=G(O.zw,w.y).toVar(),z=G(N.xy,w.z).toVar(),k=G(N.zw,w.w).toVar(),V=Nht(lt(kt(B,B),kt(L,L),kt(z,z),kt(k,k))).toVar();B.assign(B.mul(V.x)),L.assign(L.mul(V.y)),z.assign(z.mul(V.z)),k.assign(k.mul(V.w));let H=Qt(lt(.5).sub(lt(kt(n,n),kt(h,h),kt(d,d),kt(c,c))),lt(0)).toVar();return H.assign(H.mul(H)),kt(H.mul(H),lt(kt(B,n),kt(L,h),kt(z,d),kt(k,c))).mul(105)}),Oht=class extends bg{constructor(t,e,i,r,s){super(),this.tangentWorld=t,this.specularPower=e,this.specularIntensity=i,this.diffuseIntensity=r,this.ambientFloor=s}direct(t){let{lightDirection:e,lightColor:i,reflectedLight:r}=t,s=xe(eh.mul(lt(this.tangentWorld,0)).xyz),n=e,a=jv,o=xe(n.add(a)),l=Qt(mi(Zr(s,n)),0),u=Qt(mi(Zr(s,o)),0);r.directDiffuse.addAssign(i.mul(l).mul(this.diffuseIntensity).mul(Vo.rgb)),r.directSpecular.addAssign(i.mul(Lo(u,this.specularPower)).mul(this.specularIntensity).mul(G(1,.95,.9)))}indirect(t){let{irradiance:e,ambientOcclusion:i,reflectedLight:r}=t.context;r.indirectDiffuse.addAssign(e.mul(1/Math.PI).add(this.ambientFloor).mul(Vo.rgb)),r.indirectDiffuse.mulAssign(i)}},Iht=class extends bg{direct(t){let{lightDirection:e,lightColor:i,reflectedLight:r}=t,s=e,n=Oa,a=jv,o=xe(s.add(a)),l=kt(n,s).clamp(),u=kt(n,o).clamp();r.directDiffuse.addAssign(i.mul(l).mul(.85).mul(Vo.rgb)),r.directSpecular.addAssign(i.mul(Lo(u,60)).mul(.3).mul(G(.3,.28,.25)))}indirect(t){let{irradiance:e,ambientOcclusion:i,reflectedLight:r}=t.context;r.indirectDiffuse.addAssign(e.mul(1/Math.PI).add(.15).mul(Vo.rgb)),r.indirectDiffuse.mulAssign(i)}},$L=class extends Re{constructor(t){super(),this.model=t,this.lights=!0}setupLightingModel(){return this.model}},zd=new Se,Uy=new Se,aw=new P,ibt=class{constructor(){this.uNumStrands=Je(0,"int"),this.uNumVerts=Je(0,"int"),this.uDamping=Je(.03),this.uLocalStiffness=Je(.67),this.uGlobalStiffness=Je(.5),this.uGlobalRange=Je(.15),this.uStiffnessFalloff=Je(.1),this.uGravity=Je(0),this.uVspCoeff=Je(.01),this.uVspThreshold=Je(50),this.uKink=Je(0),this.uKinkFreq=Je(0),this.uUnitScale=Je(100),this.uClumpStrength=Je(0),this.uClumpSize=Je(32,"int"),this.uClumpTipScale=Je(1.5),this.uReset=Je(1),this.uHasWind=Je(0),this.uWind0=Je(new P),this.uWind1=Je(new P),this.uWind2=Je(new P),this.uWind3=Je(new P),this.uBoneQuat=Je(new Me(0,0,0,1)),this.uBoneTrans=Je(new P),this.uDeltaQuat=Je(new Me(0,0,0,1)),this.uPrevBoneTrans=Je(new P),this.uHairRoot=Je(new ae),this.uHairMid=Je(new ae),this.uHairTip=Je(new ae),this.uHeadColor=Je(new ae),this.uNoiseA=Je(new ae),this.uNoiseB=Je(new ae),this.uNoiseC=Je(new ae),this.uNoiseD=Je(new ae),this.uNoiseScale=Je(.018),this.uNoiseMixHair=Je(0),this.uNoiseMixHead=Je(0),this.uWidth=Je(.525),this.uSpecPow=Je(40),this.uSpecInt=Je(.4),this.uDiffInt=Je(.6),this.uAmbInt=Je(.25),this.uOpacity=Je(1),this.uTipFade=Je(.4),this.uColorSource=Je(0),this.uShadeRoot=Je(.6),this.uShadeTip=Je(1.15),this.uShadowTexelWorld=Je(0),this._armed=!1,this._uploadedGeneration=-1,this._prevBoneQuat=new Se,this._prevBonePos=new P,this._hasPrevBone=!1,this._renderer=null,this.initialPos=Qr(ic,"vec4"),this.rootColors=Qr(vv,"vec4"),this.positions=Qr(ic,"vec4"),this.positionsPrev=Qr(ic,"vec4"),this.positionsPrevPrev=Qr(ic,"vec4"),this.tangents=Qr(ic,"vec4"),this.restLengths=Qr(ic,"float"),this.vspQuats=Qr(vv,"vec4"),this.vspTrans=Qr(vv,"vec4"),this.kIntegrate=this._buildIntegrate(),this.kStrandLevel=this._buildStrandLevel(),this.kVsp=this._buildVsp(),this.kLocalShape=this._buildLocalShape(),this.kLengthWind=this._buildLengthWind(),this.kClump=this._buildClump(),this.kRigidFollow=this._buildRigidFollow(),this.ribbonMaterial=this._buildRibbonMaterial(),this.scalpMaterial=this._buildScalpMaterial()}boneQuatNode(){return this.uBoneQuat}boneTransNode(){return this.uBoneTrans}_buildIntegrate(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumVerts),()=>{yr()});let e=t.div(va).toVar(),i=t.sub(e.mul(va)).toVar(),r=this.boneQuatNode(),s=this.boneTransNode(),n=this.initialPos.element(t).toVar(),a=lt(Eh(r,n.xyz).add(s),n.w).toVar(),o=this.positions.element(t).toVar(),l=this.positionsPrev.element(t).toVar(),u=l.toVar();bt(this.uReset.greaterThan(.5),()=>{o.assign(a),u.assign(a)});let h=a.toVar();bt(o.w.greaterThan(0),()=>{let d=I(Gp),c=nD(this.uDamping.negate().mul(d).mul(60)),p=o.xyz.add(o.xyz.sub(u.xyz).mul(c)).add(G(0,-1,0).mul(this.uGravity).mul(d).mul(d));h.assign(lt(p,o.w))}),bt(this.uGlobalStiffness.greaterThan(0).and(this.uGlobalRange.greaterThan(0)).and(h.w.greaterThan(0)).and(i.toFloat().lessThan(this.uGlobalRange.mul(va))),()=>{let d=t.sub(i),c=this.initialPos.element(d),p=xe(Eh(r,c.xyz)).y.mul(.5).add(.5),m=this.uGlobalStiffness.mul(Lo(Qt(p,0),this.uStiffnessFalloff)),f=a.xyz.sub(h.xyz).mul(m);h.assign(lt(h.xyz.add(f),h.w))}),bt(this.uKink.greaterThan(0).and(h.w.greaterThan(0)),()=>{let d=i.toFloat().div(va),c=e.sub(e.div(256).mul(256)).toFloat().mul(.0245),p=d.mul(this.uKinkFreq).mul(6.2831853).add(c),m=this.uKink.mul(d).mul(.15).mul(this.uUnitScale),f=xe(a.xyz.sub(s)).toVar(),g=G(0).toVar();bt(Le(f.y).lessThan(.99),()=>{g.assign(xe(Zr(f,G(0,1,0))))}).Else(()=>{g.assign(xe(Zr(f,G(1,0,0))))});let y=xe(Zr(f,g)),v=g.mul(Bn(p)).mul(m).add(y.mul(Ka(p.mul(1.3).add(c))).mul(m).mul(.7));h.assign(lt(h.xyz.add(v),h.w))}),this.positionsPrevPrev.element(t).assign(l),this.positionsPrev.element(t).assign(o),this.positions.element(t).assign(h)})().compute(oo[0],oo)}_buildStrandLevel(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=t.mul(va).toVar(),i=this.positionsPrevPrev.element(e.add(1)),r=this.positionsPrev.element(e),s=this.positionsPrev.element(e.add(1)),n=this.positions.element(e),a=this.positions.element(e.add(1)),o=s.xyz.sub(r.xyz),l=a.xyz.sub(n.xyz),u=o.div(Qt(mi(o),1e-7)),h=l.div(Qt(mi(l),1e-7)),d=HL(u,h).toVar(),c=n.xyz.sub(Eh(d,r.xyz)),p=this.uVspCoeff.toVar(),m=mi(a.xyz.sub(s.xyz.mul(2)).add(i.xyz));bt(m.greaterThan(this.uVspThreshold),()=>{p.assign(1)}),this.vspQuats.element(t).assign(d),this.vspTrans.element(t).assign(lt(c,p))})().compute(oo[0],oo)}_buildVsp(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumVerts),()=>{yr()});let e=t.div(va).toVar(),i=t.sub(e.mul(va)).toVar();bt(i.lessThan(2),()=>{yr()});let r=this.vspQuats.element(e),s=this.vspTrans.element(e),n=s.w,a=this.positions.element(t).toVar(),o=this.positionsPrev.element(t).toVar(),l=u=>lt(u.xyz.mul(I(1).sub(n)).add(Eh(r,u.xyz).add(s.xyz).mul(n)),u.w);this.positions.element(t).assign(l(a)),this.positionsPrev.element(t).assign(l(o))})().compute(oo[0],oo)}_buildLocalShape(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=t.mul(va).toVar(),i=ii(this.uLocalStiffness,.95).mul(.5),r=this.boneQuatNode();Ji(Gl-1,({i:s})=>{let n=e.add(s).add(1).toVar(),a=this.positions.element(n).toVar(),o=this.positions.element(n.add(1)).toVar(),l=this.positions.element(n.sub(1)),u=Eh(r,this.initialPos.element(n).xyz),h=Eh(r,this.initialPos.element(n.add(1)).xyz),d=Eh(r,this.initialPos.element(n.sub(1)).xyz),c=a.xyz.sub(l.xyz),p=h.sub(u),m=u.sub(d),f=HL(m.div(Qt(mi(m),1e-7)),c.div(Qt(mi(c),1e-7))),g=Eh(f,p).add(a.xyz).sub(o.xyz).mul(i);bt(a.w.greaterThan(0),()=>{a.assign(lt(a.xyz.sub(g),a.w))}),bt(o.w.greaterThan(0),()=>{o.assign(lt(o.xyz.add(g),o.w))}),this.positions.element(n).assign(a),this.positions.element(n.add(1)).assign(o)})})().compute(oo[0],oo)}_buildLengthWind(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=t.mul(va).toVar();bt(this.uHasWind.greaterThan(.5),()=>{let i=t.sub(t.div(20).mul(20)).toFloat().div(20),r=this.uWind0.mul(i).add(this.uWind1.mul(I(1).sub(i))).add(this.uWind2.mul(i)).add(this.uWind3.mul(I(1).sub(i))).toVar();Ji(Gl-2,({i:s})=>{let n=e.add(s).add(2).toVar(),a=this.positions.element(n).toVar(),o=this.positions.element(n.add(1)),l=a.xyz.sub(o.xyz),u=Zr(Zr(l,r),l).negate();a.assign(lt(a.xyz.add(u.mul(Gp).mul(.1)),a.w)),this.positions.element(n).assign(a)})}),Ji(5,()=>{Ji(Gl,({i})=>{let r=e.add(i).toVar(),s=this.positions.element(r).toVar(),n=this.positions.element(r.add(1)).toVar(),a=this.restLengths.element(r),o=n.xyz.sub(s.xyz),l=Qt(mi(o),1e-7),u=I(1).sub(a.div(l)),h=o.mul(u),d=s.w.greaterThan(0),c=n.w.greaterThan(0),p=d.select(c.select(I(.5),I(1)),I(0)),m=c.select(d.select(I(.5),I(1)),I(0));s.assign(lt(s.xyz.add(h.mul(p)),s.w)),n.assign(lt(n.xyz.sub(h.mul(m)),n.w)),this.positions.element(r).assign(s),this.positions.element(r.add(1)).assign(n)})}),Ji(Gl,({i})=>{let r=e.add(i).add(1).toVar(),s=this.positions.element(r.sub(1)),n=this.positions.element(r).toVar(),a=n.xyz.sub(s.xyz),o=Qt(mi(a),1e-7),l=this.restLengths.element(r.sub(1));bt(o.greaterThan(l),()=>{n.assign(lt(s.xyz.add(a.div(o).mul(l)),n.w)),this.positions.element(r).assign(n)})}),Ji(va,({i})=>{let r=e.add(i).toVar(),s=i.equal(va-1).select(r.sub(1),r).toVar(),n=xe(this.positions.element(s.add(1)).xyz.sub(this.positions.element(s).xyz));this.tangents.element(r).assign(lt(n,0))})})().compute(oo[0],oo)}_buildClump(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumStrands),()=>{yr()});let e=this.uClumpSize.toVar(),i=t.div(e).mul(e).toVar();bt(t.equal(i),()=>{yr()}),bt(i.greaterThanEqual(this.uNumStrands),()=>{yr()});let r=t.mul(va).toVar(),s=i.mul(va).toVar();Ji(Gl,({i:n})=>{let a=n.add(1).toVar(),o=a.toFloat().div(Gl),l=this.uClumpStrength.mul(Lo(o,I(1).div(Qt(this.uClumpTipScale,.5)))),u=r.add(a).toVar(),h=this.positions.element(u).toVar(),d=this.positions.element(s.add(a));h.assign(lt(Yt(h.xyz,d.xyz,l),h.w)),this.positions.element(u).assign(h)})})().compute(oo[0],oo)}_buildRigidFollow(){return Et(()=>{let t=mt(Pn).toVar();bt(t.greaterThanEqual(this.uNumVerts),()=>{yr()});let e=this.uDeltaQuat,i=this.uPrevBoneTrans,r=this.boneTransNode(),s=a=>{let o=a.element(t).toVar();o.assign(lt(Eh(e,o.xyz.sub(i)).add(r),o.w)),a.element(t).assign(o)};s(this.positions),s(this.positionsPrev),s(this.positionsPrevPrev);let n=this.tangents.element(t).toVar();n.assign(lt(Eh(e,n.xyz),0)),this.tangents.element(t).assign(n)})().compute(oo[0],oo)}pastelNoise(t){let e=t.sub(this.boneTransNode()).mul(this.uNoiseScale),i=mE(e).mul(.5).add(.5),r=mE(e.add(G(31.7,17.3,53.1))).mul(.5).add(.5),s=mE(e.mul(.7).add(G(71.9,11.2,43.8))).mul(.5).add(.5),n=Yt(this.uNoiseA,this.uNoiseB,i);return n=Yt(n,this.uNoiseC,r.mul(.6)),n=Yt(n,this.uNoiseD,s.mul(.25)),n}_buildRibbonMaterial(){let t=Lr("vec3","vHairTangent"),e=Lr("vec3","vHairNormal"),i=Lr("vec2","vHairUv"),r=Lr("float","vHairRand"),s=Lr("vec3","vHairInherit"),n=new $L(new Oht(t,this.uSpecPow,this.uSpecInt,this.uDiffInt,this.uAmbInt));n.name="SplineHairRibbons",n.userData.hairShadowVariant="texel-floor-v6",n.transparent=!1,n.depthTest=!0,n.depthWrite=!0,n.side=Rn;let a=l=>Et(()=>{let u=mt(Pn).toVar(),h=u.div(Gl).toVar(),d=u.sub(h.mul(Gl)).toVar(),c=h.mul(va).add(d).toVar(),p=mt(sS).toVar(),m=p.bitAnd(1).toFloat().toVar(),f=p.shiftRight(1).bitAnd(1).toFloat().toVar(),g=this.positions.element(c).xyz.toVar(),y=this.positions.element(c.add(1)).xyz.toVar(),v=this.tangents.element(c).xyz,b=this.tangents.element(c.add(1)).xyz,_=Yt(g,y,f).toVar(),x=Yt(v,b,f).toVar(),S=xe(Pc.sub(_)),w=Zr(x,S).toVar(),T=mi(w).toVar();w.assign(T.greaterThan(1e-7).select(w.div(T),G(1,0,0)));let C=d.toFloat().div(Gl),M=d.add(1).toFloat().div(Gl),A=Yt(C,M,f).toVar(),R=this.uWidth.mul(I(1).sub(A.mul(this.uTipFade))).toVar(),O=l?(()=>{let V=this.uShadowTexelWorld,H=V.greaterThan(0).select(V.mul(1.5).clamp(I(2),I(8)),I(0));return Qt(H.sub(R),0).toVar()})():null;O&&R.addAssign(O);let N=m.mul(2).sub(1),B=_.add(w.mul(R).mul(N)).toVar();O&&B.assign(B.sub(S.mul(O)));let L=this.positionsPrev.element(c).xyz,z=this.positionsPrev.element(c.add(1)).xyz;uD.assign(Yt(L,z,f).add(w.mul(R).mul(N)));let k=Oi(Bn(h.toFloat().mul(12.9898)).mul(43758.5453));return r.assign(k),s.assign(this.rootColors.element(h).xyz),t.assign(x),e.assign(xe(S.sub(x.mul(kt(x,S))))),i.assign(at(m,A)),B}),o=Et(()=>{let l=i.y,u=Yt(this.uHairRoot,this.uHairMid,ii(l.mul(2),1)),h=l.lessThan(.5).select(u,Yt(this.uHairMid,this.uHairTip,l.sub(.5).mul(2))).toVar(),d=s.mul(Yt(this.uShadeRoot,this.uShadeTip,l));h.assign(this.uColorSource.greaterThan(.5).select(d,h)),h.assign(Yt(h,this.pastelNoise(Go),this.uNoiseMixHair));let c=I(1).sub(Le(i.x.sub(.5)).mul(2));return I(1).sub(l.mul(this.uTipFade)).mul(Lo(Qt(c,0),.5)).toVar().lessThan(.25).discard(),r.greaterThanEqual(this.uOpacity).discard(),lt(h,1)});return n.positionNode=a(!1)(),n.castShadowPositionNode=a(!0)(),n.normalNode=e,n.colorNode=o(),n.needsUpdate=!0,n}_buildScalpMaterial(){let t=new $L(new Iht);t.name="SplineHairScalp";let e=Et(()=>{let i=Yt(this.uHeadColor,this.pastelNoise(Go),this.uNoiseMixHead);return lt(i,1)});return t.colorNode=e(),t.needsUpdate=!0,t}update(t,e){let i=e;if(i.backend?.isWebGPUBackend!==!0||(this._renderer=i,t.visible===!1))return;if(!this._armed){this._armed=!0;let o=t.ribbonMesh.material;t.ribbonMesh.material=this.ribbonMaterial,o.dispose?.();let l=t.scalpMesh.material;t.scalpMesh.material=this.scalpMaterial,l.dispose?.(),t.ribbonMesh.visible=!0}t.checkDataDrift();let r=t.activeGuideStrands,s=r*va;t.generation!==this._uploadedGeneration&&(this._uploadedGeneration=t.generation,this.initialPos.value.array.set(t.roots.initialPositions),this.initialPos.value.needsUpdate=!0,this.restLengths.value.array.set(t.roots.restLengths),this.restLengths.value.needsUpdate=!0,this.rootColors.value.array.set(t.roots.rootColors),this.rootColors.value.needsUpdate=!0,t.ribbonMesh.geometry.instanceCount=r*Gl,t.resetRequested=!0),this._syncUniforms(t),t.boneTransform(zd,aw),this.uBoneQuat.value.set(zd.x,zd.y,zd.z,zd.w),this.uBoneTrans.value.copy(aw);let n=this._hasPrevBone&&(Math.abs(this._prevBoneQuat.dot(zd))<.9999995||this._prevBonePos.distanceToSquared(aw)>1e-8),a=Math.floor(t.pendingSimSeconds/Gp);a>4&&(a=4),t.pendingSimSeconds=Math.max(0,Math.min(t.pendingSimSeconds-a*Gp,Gp)),t.resetRequested&&a<1&&(a=1),a<1&&n&&(Uy.copy(this._prevBoneQuat).invert().premultiply(zd),this.uDeltaQuat.value.set(Uy.x,Uy.y,Uy.z,Uy.w),this.uPrevBoneTrans.value.copy(this._prevBonePos),this._dispatch(i,this.kRigidFollow,s));for(let o=0;o<a;o++){this.uReset.value=t.resetRequested&&o===0?1:0,t.simTime+=Gp,this._updateWind(t),this._dispatch(i,this.kIntegrate,s),this._dispatch(i,this.kStrandLevel,r),this._dispatch(i,this.kVsp,s);for(let l=0;l<2;l++)this._dispatch(i,this.kLocalShape,r);this._dispatch(i,this.kLengthWind,r),t.data.clumpStrength>.001&&this._dispatch(i,this.kClump,r)}a>0&&(t.resetRequested=!1),this._prevBoneQuat.copy(zd),this._prevBonePos.copy(aw),this._hasPrevBone=!0}_dispatch(t,e,i){e.count=i,t.compute(e)}_updateWind(t){let e=t.data,i=Math.max(t.roots.unitScale,.001),r=e.windStrength/i;this.uHasWind.value=e.windStrength>.001?1:0;let s=.7*t.simTime,n=Math.sin(s)*r,a=Math.cos(s)*r*.5;this.uWind0.value.set(n,0,a),this.uWind1.value.set(.7*n,.5*r,1.2*a),this.uWind2.value.set(.3*-n,0,.5*a),this.uWind3.value.set(.5*n,-.3*r,.8*-a)}_shadowTexelWorld(t){let e=t;for(;e.parent;)e=e.parent;let i=e;if(!i?.traverse)return 0;let r=0;return i.traverse(s=>{let n=s;if(n.isDirectionalLight!==!0||n.castShadow!==!0||n.visible===!1)return;let a=n.shadow?.camera,o=n.shadow?.mapSize?.x??0;typeof a?.right!="number"||typeof a?.left!="number"||o<=0||(r=Math.max(r,(a.right-a.left)/o))}),r}_syncUniforms(t){let e=t.data,i=t.roots.unitScale;this.uNumStrands.value=t.activeGuideStrands,this.uNumVerts.value=t.activeGuideStrands*va,this.uDamping.value=e.damping,this.uLocalStiffness.value=e.localStiffness,this.uGlobalStiffness.value=e.globalStiffness,this.uGlobalRange.value=e.globalRange,this.uStiffnessFalloff.value=e.stiffnessFalloff,this.uGravity.value=e.gravity*i,this.uVspCoeff.value=e.vspCoefficient,this.uVspThreshold.value=.5*i,this.uKink.value=e.kink,this.uKinkFreq.value=e.kinkFrequency,this.uUnitScale.value=i,this.uClumpStrength.value=e.clumpStrength,this.uClumpSize.value=Math.max(1,Math.round(e.clumpSize)),this.uClumpTipScale.value=e.clumpTipScale;let r=(n,a)=>{n.value.setRGB(a.r,a.g,a.b,Ns)};r(this.uHairRoot,e.hairRootColor),r(this.uHairMid,e.hairMidColor),r(this.uHairTip,e.hairTipColor),r(this.uHeadColor,e.headColor),r(this.uNoiseA,e.noiseColorA),r(this.uNoiseB,e.noiseColorB),r(this.uNoiseC,e.noiseColorC),r(this.uNoiseD,e.noiseColorD);let s=e.noiseEnabled?1:0;this.uNoiseScale.value=e.noiseScale/Math.max(i,.001),this.uNoiseMixHair.value=e.noiseMixHair*s,this.uNoiseMixHead.value=e.noiseMixHead*s,this.uWidth.value=.003*e.hairWidth*Lh*t.widthWorldScale,this.uShadowTexelWorld.value=this._shadowTexelWorld(t),this.uColorSource.value=e.hairColorSource==="object"&&e.headShape==="object"&&e.baseObjectId?1:0,this.uShadeRoot.value=e.hairShadeRoot??.6,this.uShadeTip.value=e.hairShadeTip??1.15,this.uSpecPow.value=e.specularPower,this.uSpecInt.value=e.specularIntensity,this.uDiffInt.value=e.diffuseIntensity,this.uAmbInt.value=e.ambientIntensity,this.uOpacity.value=e.opacity,this.uTipFade.value=e.tipFade}dispose(){for(let e of[this.kIntegrate,this.kStrandLevel,this.kVsp,this.kLocalShape,this.kLengthWind,this.kClump,this.kRigidFollow])e.dispose();this.ribbonMaterial.dispose(),this.scalpMaterial.dispose();let t=this._renderer?.backend?.attributeUtils;if(t)for(let e of[this.initialPos,this.rootColors,this.positions,this.positionsPrev,this.positionsPrevPrev,this.tangents,this.restLengths,this.vspQuats,this.vspTrans])t.destroyAttribute(e.value);this._renderer=null}},S2=new WeakMap,hS=[]}),cEt=j(()=>{JG(),dEt(),ZG=t=>function(e){let i=S2.get(e);return i===void 0&&(i=new ibt,S2.set(e,i)),i}(t),function(t){QG=t}({release:t=>function(e){let i=S2.get(e);i!==void 0&&(S2.delete(e),hS.push(i))}(t),drainRetired:uEt})}),hbt=j(()=>{o5=`
|
|
1984
1984
|
const PI: f32 = 3.14159265358979323846;
|
|
1985
1985
|
|
|
1986
1986
|
const TRANSMITTANCE_TEXTURE_WIDTH: i32 = 256;
|
|
@@ -5085,11 +5085,11 @@ void main() {
|
|
|
5085
5085
|
void main() {
|
|
5086
5086
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
5087
5087
|
gl_FragColor = texel;
|
|
5088
|
-
}`}),UPt=new class{constructor(t){this._mesh=new vr(FPt,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,LPt)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(c_t),mF=null,fF=null,jPt=ei.identity(),p_t=class{constructor(t,e,i,r){var s;this.uuid=t,this.width=e,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||J2.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=Rut(n,a,this.dpr,this.isScreenSpace),this.renderer.setSize(n,a)},this.onFrameOverrideObjectEvent=n=>{if(n.target?.uuid!==void 0){let a=this.frameRoot?.find(n.target.uuid);a&&a.dispatchEvent({...n,target:a})}},this.scene2d=new HW(qt.generateUUID(),MU.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(mF===null&&(mF=document.createElement("canvas")),mF),this.renderer=(s=this.canvas,fF===null&&(fF=new NPt(s)),fF),this.promise=this.init(),this.renderTarget=new pg(1,1,{type:ai,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new H7(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{c_t.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),UPt.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,r){this.scene2d.updateEntityByOp(t,e,i,r),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=jPt,this.isScreenSpace&&(this.frameOverride.fill.color=qi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},m_t({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),r=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=r,this._innerApplySize();let s=function(n,a,o,l){let u=Rut(n,a,o,l),h=Math.max(o,512/Math.min(n,a)),d=Math.min(h,u);return{width:Math.max(1,Math.ceil(n*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,e,this.isScreenSpace);this.renderTarget.setSize(s.width,s.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 Zu)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 m_t({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Zu&&e instanceof Zu||t instanceof fm&&e instanceof fm)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],u=e.children[a];l&&u&&l.uuid===u.uuid&&GPt({objectOverride:l,objectRoot:u,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function GPt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(gF(d))return[d.width,d.height];if(d instanceof y5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof fm){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:u,position:h}=d_t({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=h,t.data={...t.data,position:h},t.states)for(let d in t.states)WPt({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(gF(t)||t instanceof fm)gF(t)&&(t.width=l,t.height=u,t.data={...t.data,width:l,height:u}),m_t({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:o});else if(t instanceof y5){let d=e,c=a!==0?l/a:1,p=o!==0?u/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(h_t(m))return console.warn("Cannot scale invalid path",m),pF([]);if(f===1&&g===1)return m;try{return pF((0,zPt.parseSVG)(m).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*f),"y"in v&&(v.y=v.y*g),"x1"in v&&(v.x1=v.x1*f),"x2"in v&&(v.x2=v.x2*f),"y1"in v&&(v.y1=v.y1*g),"y2"in v&&(v.y2=v.y2*g),"rx"in v&&(v.rx=v.rx*f),"ry"in v&&(v.ry=v.ry*g),v}))}catch(y){return console.warn("Error parsing SVG path",y),pF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function WPt({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:u,height:h,position:d}=d_t({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:Wg.isResizeable(l)?l.width:0,objectInitialHeight:Wg.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),Wg.isResizeable(o)&&Object.assign(e.states[t],{width:u,height:h})}}function gF(t){return t instanceof cT||t instanceof Zu||t instanceof WW||t instanceof qW}X5();var Dut,qPt=class extends Fr{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new p_t(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,r=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),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=sm(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,r){this.uiCanvas.updateEntity2DByOp(t,e,i,r),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):er(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}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=sm(i,e,this.data.flatShading,this)}};Ii(),Kv("UIGeometry",(t,e,i)=>new qPt(t,e,i)),F5=Dut={Scene2D:HW,UICanvas:p_t,loadHanaUIRUNTIME:function(){return m5||(m5=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(()=>(wH(),xH)),gut??function(){let t=typeof process<"u"?"2.0.80":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),o_t().then(()=>{})},setHanaUIWasmUrl:function(t){gut=t}},A4!==null&&Dut.setHanaUIWasmUrl(A4),Or("ui-2d"),rW(),Ogt(),dt();var f_t,yF,HPt=class{constructor(){this.type="ShapePath",this.color=new ae,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new L2,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,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,s,n){return this.currentPath?.bezierCurveTo(t,e,i,r,s,n),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(u,h,d,c){let p=u.x,m=h.x,f=d.x,g=c.x,y=u.y,v=h.y,b=d.y,_=c.y,x=(g-f)*(y-b)-(_-b)*(p-f),S=(_-b)*(m-p)-(g-f)*(v-y),w=x/S,T=((m-p)*(y-b)-(v-y)*(p-f))/S;if(S===0&&x!==0||w<=0||w>=1||T<0||T>1)return null;if(x===0&&S===0){for(let C=0;C<2;C++){if(i(C===0?d:c,u,h),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(m-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let C=0;C<2;C++)if(i(C===0?d:c,u,h),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}return{x:+(p+w*(m-p)).toPrecision(10),y:+(y+w*(v-y)).toPrecision(10),t:w}}function i(u,h,d){let c,p=d.x-h.x,m=d.y-h.y,f=u.x-h.x,g=u.y-h.y,y=p*g-f*m;return u.x===h.x&&u.y===h.y?(t.loc=0,void(t.t=0)):u.x===d.x&&u.y===d.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*f<0||m*g<0?t.loc=5:Math.sqrt(p*p+m*m)<Math.sqrt(f*f+g*g)?t.loc=6:(c=p!==0?f/p:g/m,t.loc=2,t.t=c))}let r=0,s=999999999,n=-999999999,a=[];this.subPaths.forEach(u=>{let h=u.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<h.length;f++){let g=h[f];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<m&&(m=g.x)}n<=p&&(n=p+1),s>=m&&(s=m-1),h.length&&a.push({curves:u.curves,points:h,isCW:P8.isClockWise(h),identifier:r++,boundingBox:new K7(new Q(m,c),new Q(p,d))})});let o=a.map(u=>function(h,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Q;h.boundingBox.getCenter(f);let g=function(S,w,T){let C=new Q;w.getCenter(C);let M=[];return T.forEach(A=>{A.boundingBox.containsPoint(C)&&function(R,O){let N=[],B=[];for(let L=1;L<R.length;L++){let z=R[L-1],k=R[L];for(let V=1;V<O.length;V++){let H=e(z,k,O[V-1],O[V]);H!==null&&N.find(W=>W.t<=H.t+Number.EPSILON&&W.t>=H.t-Number.EPSILON)===void 0&&(N.push(H),B.push(new Q(H.x,H.y)))}}return B}(S,A.points).forEach(R=>{M.push({identifier:A.identifier,isCW:A.isCW,point:R})})}),M.sort((A,R)=>A.point.x-R.point.x),M}([new Q(c,f.y),new Q(p,f.y)],h.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===h.identifier?y.push(S):v.push(S)});let b=y[0].point.x,_=[],x=0;for(;x<v.length&&v[x].point.x<b;)_.length>0&&_[_.length-1]===v[x].identifier?_.pop():_.push(v[x].identifier),x++;if(_.push(h.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:h.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let C=0;C<_.length;C++){let M=_[C];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:h.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(u,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(u=>{let h=o[u.identifier];if(h&&!h.isHole){let d=new _S;d.curves=u.curves,o.filter(c=>c?.isHole&&c.for===u.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new L2;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},g_t=!1,Nut=new Promise(t=>{f_t=t}),Out=!1;function Iut(){if(g_t=!0,!Out)return yF||(yF=async function(){let t=await import("./opentype.js");f_t(t),Out=!0}(),yF)}var $Pt=new class{async load(t,e,i=()=>{}){let{load:r}=await Nut;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await Nut;try{let r=e(t),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};function XPt(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}dt(),PG(),Ii(),Kv("TextGeometry",(t,e,i)=>new eD(t,e,i));var But={create:(t,e)=>new JU(t,e)};PU("TextGeometry",But),PU("InputGeometry",But),EG=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 r,s,n=!1;if(i.url?(r=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),s=i.url,n=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!g_t)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await $Pt.parse(r);if(a)return{font:a.font,url:s,intercepted:n,arr:r,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 r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let u=i[l].index,h=String.fromCharCode(i[l].unicode),d=s[a];if(XPt(u,d)||o)n.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",m=[d.state.glyphIndex],f=[],g=!1;for(;!g;)a++,p=e.charAt(a),c+=p,m.push(t.charToGlyphIndex(p)),f=t.stringToGlyphs(c),f.length===1&&f[0].index===u&&(g=!0),a>e.length&&(g=!0);n.push({char:h,index:u,replacements:m,replacementChars:Array.from(c)}),a++}}return n}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,s=e.fontSize/this.unitsPerEm,n=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,u=this.getCharWidth(`
|
|
5088
|
+
}`}),UPt=new class{constructor(t){this._mesh=new vr(FPt,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,LPt)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(c_t),mF=null,fF=null,jPt=ei.identity(),p_t=class{constructor(t,e,i,r){var s;this.uuid=t,this.width=e,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||J2.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=Rut(n,a,this.dpr,this.isScreenSpace),this.renderer.setSize(n,a)},this.onFrameOverrideObjectEvent=n=>{if(n.target?.uuid!==void 0){let a=this.frameRoot?.find(n.target.uuid);a&&a.dispatchEvent({...n,target:a})}},this.scene2d=new HW(qt.generateUUID(),MU.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(mF===null&&(mF=document.createElement("canvas")),mF),this.renderer=(s=this.canvas,fF===null&&(fF=new NPt(s)),fF),this.promise=this.init(),this.renderTarget=new pg(1,1,{type:ai,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new H7(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{c_t.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),UPt.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,r){this.scene2d.updateEntityByOp(t,e,i,r),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=jPt,this.isScreenSpace&&(this.frameOverride.fill.color=qi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},m_t({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),r=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=r,this._innerApplySize();let s=function(n,a,o,l){let u=Rut(n,a,o,l),h=Math.max(o,512/Math.min(n,a)),d=Math.min(h,u);return{width:Math.max(1,Math.ceil(n*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,e,this.isScreenSpace);this.renderTarget.setSize(s.width,s.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 Zu)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 m_t({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Zu&&e instanceof Zu||t instanceof fm&&e instanceof fm)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],u=e.children[a];l&&u&&l.uuid===u.uuid&&GPt({objectOverride:l,objectRoot:u,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function GPt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(gF(d))return[d.width,d.height];if(d instanceof y5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof fm){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:u,position:h}=d_t({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=h,t.data={...t.data,position:h},t.states)for(let d in t.states)WPt({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(gF(t)||t instanceof fm)gF(t)&&(t.width=l,t.height=u,t.data={...t.data,width:l,height:u}),m_t({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:o});else if(t instanceof y5){let d=e,c=a!==0?l/a:1,p=o!==0?u/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(h_t(m))return console.warn("Cannot scale invalid path",m),pF([]);if(f===1&&g===1)return m;try{return pF((0,zPt.parseSVG)(m).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*f),"y"in v&&(v.y=v.y*g),"x1"in v&&(v.x1=v.x1*f),"x2"in v&&(v.x2=v.x2*f),"y1"in v&&(v.y1=v.y1*g),"y2"in v&&(v.y2=v.y2*g),"rx"in v&&(v.rx=v.rx*f),"ry"in v&&(v.ry=v.ry*g),v}))}catch(y){return console.warn("Error parsing SVG path",y),pF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function WPt({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:u,height:h,position:d}=d_t({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:Wg.isResizeable(l)?l.width:0,objectInitialHeight:Wg.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),Wg.isResizeable(o)&&Object.assign(e.states[t],{width:u,height:h})}}function gF(t){return t instanceof cT||t instanceof Zu||t instanceof WW||t instanceof qW}X5();var Dut,qPt=class extends Fr{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new p_t(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,r=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),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=sm(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,r){this.uiCanvas.updateEntity2DByOp(t,e,i,r),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):er(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}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=sm(i,e,this.data.flatShading,this)}};Ii(),Kv("UIGeometry",(t,e,i)=>new qPt(t,e,i)),F5=Dut={Scene2D:HW,UICanvas:p_t,loadHanaUIRUNTIME:function(){return m5||(m5=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(()=>(wH(),xH)),gut??function(){let t=typeof process<"u"?"2.0.82":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),o_t().then(()=>{})},setHanaUIWasmUrl:function(t){gut=t}},A4!==null&&Dut.setHanaUIWasmUrl(A4),Or("ui-2d"),rW(),Ogt(),dt();var f_t,yF,HPt=class{constructor(){this.type="ShapePath",this.color=new ae,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new L2,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,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,s,n){return this.currentPath?.bezierCurveTo(t,e,i,r,s,n),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(u,h,d,c){let p=u.x,m=h.x,f=d.x,g=c.x,y=u.y,v=h.y,b=d.y,_=c.y,x=(g-f)*(y-b)-(_-b)*(p-f),S=(_-b)*(m-p)-(g-f)*(v-y),w=x/S,T=((m-p)*(y-b)-(v-y)*(p-f))/S;if(S===0&&x!==0||w<=0||w>=1||T<0||T>1)return null;if(x===0&&S===0){for(let C=0;C<2;C++){if(i(C===0?d:c,u,h),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(m-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let C=0;C<2;C++)if(i(C===0?d:c,u,h),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}return{x:+(p+w*(m-p)).toPrecision(10),y:+(y+w*(v-y)).toPrecision(10),t:w}}function i(u,h,d){let c,p=d.x-h.x,m=d.y-h.y,f=u.x-h.x,g=u.y-h.y,y=p*g-f*m;return u.x===h.x&&u.y===h.y?(t.loc=0,void(t.t=0)):u.x===d.x&&u.y===d.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*f<0||m*g<0?t.loc=5:Math.sqrt(p*p+m*m)<Math.sqrt(f*f+g*g)?t.loc=6:(c=p!==0?f/p:g/m,t.loc=2,t.t=c))}let r=0,s=999999999,n=-999999999,a=[];this.subPaths.forEach(u=>{let h=u.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<h.length;f++){let g=h[f];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<m&&(m=g.x)}n<=p&&(n=p+1),s>=m&&(s=m-1),h.length&&a.push({curves:u.curves,points:h,isCW:P8.isClockWise(h),identifier:r++,boundingBox:new K7(new Q(m,c),new Q(p,d))})});let o=a.map(u=>function(h,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Q;h.boundingBox.getCenter(f);let g=function(S,w,T){let C=new Q;w.getCenter(C);let M=[];return T.forEach(A=>{A.boundingBox.containsPoint(C)&&function(R,O){let N=[],B=[];for(let L=1;L<R.length;L++){let z=R[L-1],k=R[L];for(let V=1;V<O.length;V++){let H=e(z,k,O[V-1],O[V]);H!==null&&N.find(W=>W.t<=H.t+Number.EPSILON&&W.t>=H.t-Number.EPSILON)===void 0&&(N.push(H),B.push(new Q(H.x,H.y)))}}return B}(S,A.points).forEach(R=>{M.push({identifier:A.identifier,isCW:A.isCW,point:R})})}),M.sort((A,R)=>A.point.x-R.point.x),M}([new Q(c,f.y),new Q(p,f.y)],h.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===h.identifier?y.push(S):v.push(S)});let b=y[0].point.x,_=[],x=0;for(;x<v.length&&v[x].point.x<b;)_.length>0&&_[_.length-1]===v[x].identifier?_.pop():_.push(v[x].identifier),x++;if(_.push(h.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:h.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let C=0;C<_.length;C++){let M=_[C];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:h.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(u,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(u=>{let h=o[u.identifier];if(h&&!h.isHole){let d=new _S;d.curves=u.curves,o.filter(c=>c?.isHole&&c.for===u.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new L2;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},g_t=!1,Nut=new Promise(t=>{f_t=t}),Out=!1;function Iut(){if(g_t=!0,!Out)return yF||(yF=async function(){let t=await import("./opentype.js");f_t(t),Out=!0}(),yF)}var $Pt=new class{async load(t,e,i=()=>{}){let{load:r}=await Nut;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await Nut;try{let r=e(t),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};function XPt(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}dt(),PG(),Ii(),Kv("TextGeometry",(t,e,i)=>new eD(t,e,i));var But={create:(t,e)=>new JU(t,e)};PU("TextGeometry",But),PU("InputGeometry",But),EG=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 r,s,n=!1;if(i.url?(r=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),s=i.url,n=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!g_t)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await $Pt.parse(r);if(a)return{font:a.font,url:s,intercepted:n,arr:r,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 r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let u=i[l].index,h=String.fromCharCode(i[l].unicode),d=s[a];if(XPt(u,d)||o)n.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",m=[d.state.glyphIndex],f=[],g=!1;for(;!g;)a++,p=e.charAt(a),c+=p,m.push(t.charToGlyphIndex(p)),f=t.stringToGlyphs(c),f.length===1&&f[0].index===u&&(g=!0),a>e.length&&(g=!0);n.push({char:h,index:u,replacements:m,replacementChars:Array.from(c)}),a++}}return n}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,s=e.fontSize/this.unitsPerEm,n=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,u=this.getCharWidth(`
|
|
5089
5089
|
`,e),h=e.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(a[0],o,e.horizontalAlign,t[0],u),c=this.getLineInitialOffsetY(n,t.length,l,s,e.verticalAlign),p=[],m=t.map(()=>[]),f=t.map(()=>[]);for(let y=0;y<t.length;y++){let v=t[y],b={features:{liga:!0},letterSpacing:e.letterSpacing},_=[];try{_=r.stringToGlyphs(v,b)}catch(C){this.warnLayoutError(C)}d=this.getLineInitialOffsetX(a[y],o,e.horizontalAlign,v,u);let x=[];try{x=this.reverseLigaturesTable(r,v,_)}catch(C){this.warnLayoutError(C)}let S=this.computeSpaceWidthForLine(t,y,e,i),w=0,T=_[0];T&&e.horizontalAlign===2&&T.leftSideBearing!==void 0&&(d-=T.leftSideBearing*s);try{this.font?.forEachGlyph(v,d,c,e.fontSize,b,(C,M,A,R,O)=>{let N=C.index===0?`
|
|
5090
5090
|
`:C.unicode?String.fromCharCode(C.unicode):void 0,B=x[w],L=0;if(N===`
|
|
5091
5091
|
`)L=h;else if(N===" ")L=S;else{let z=this.createPath(C,s,M,A,e);z&&(L=z.offsetX,p.push(z.path))}if(B&&B.replacements.length!==1){let z=B.replacements.map(W=>(r.glyphs.get(W).advanceWidth??0)*s),k=z.reduce((W,X)=>W+X,0),V=z.map(W=>W/k),H=M;for(let W=0;W<V.length;W++){let X=L*V[W];f[y].push([H,A]),m[y].push(X),H+=X}}else f[y].push([M,A]),m[y].push(L);w++})}catch(C){this.warnLayoutError(C)}c-=n}let g=[];for(let y=0,v=p.length;y<v;y++)g.push(...p[y].toShapes());return{shapes:g,charWidths:m,lineWidths:a,charCoords:f}}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,r,s){return(i===3||i===2)&&r.indexOf(`
|
|
5092
|
-
`)>=0&&(t-=s),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,r,s){let n=e*t,a=t-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return s===3?-(i-n-o):s===2?-(.5*i-.5*n-o):o}createPath(t,e,i,r,s){let n=t.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!n)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new HPt,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let u=a.currentPath?.currentPoint;if(!u||l.type==="Z"||u.x!==l.x||-u.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 u=function(h){if(h.length){let d=h[0];if(d instanceof cl)return d.v1;if(d instanceof Kl||d instanceof lc)return d.v0}}(l.curves);u!==void 0&&l.currentPoint.distanceTo(u)>0&&l.lineTo(u.x,u.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,r){let s=this.getCharWidth(" ",i),n=t[e];if(n){let a=this.countSpaces(n.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(n,i)-a*s))/a}return s}countSpaces(t){return(t.match(/ /g)||[]).length}},Or("text"),ke();var y_t=null;function Vut(){return y_t}function YPt(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&e0.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ir();var NE=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},vF=t=>t*(Math.PI/180),OE=new Map,v5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.addEventListener?t.addEventListener(r,i,!1):t.attachEvent&&t.attachEvent(r,i)},b5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.removeEventListener?t.removeEventListener(r,i):t.detachEvent&&t.detachEvent(r,i)},v_t=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),kut=()=>{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}},bF=(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")},_F=(t,e,i)=>{let r=b_t(t);for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s))if(typeof e=="string")r[s]=e+" "+i;else{let n="";for(let a=0,o=e.length;a<o;a+=1)n+=e[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},b_t=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},xF=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},f7=(t,e)=>{if(t.length)for(let i=0,r=t.length;i<r;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(__t="ontouchstart"in window,x_t=!!window.PointerEvent,w_t=!!window.MSPointerEvent);var __t,x_t,w_t,Zy,zut={start:"mousedown",move:"mousemove",end:"mouseup"},gw={};function dg(){}x_t?Zy={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:w_t?Zy={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:__t?(Zy={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},gw=zut):Zy=zut,dg.prototype.on=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(e);return r},dg.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},dg.prototype.trigger=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},e)})},dg.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,r)=>{let s={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&Object.prototype.hasOwnProperty.call(r,n)?s[n]=r[n]:Object.prototype.hasOwnProperty.call(i,n)&&(s[n]=i[n]);return s})(e.options,t))},dg.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.')},v5(t,Zy[e],i._domHandlers_[e]),gw[e]&&v5(t,gw[e],i._domHandlers_[e]),i},dg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},b5(t,Zy[e],i._domHandlers_[e]),gw[e]&&b5(t,gw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var $W=dg;function Sn(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=Sn.id,Sn.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}Sn.prototype=new $W,Sn.constructor=Sn,Sn.id=0,Sn.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},Sn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=b_t("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=_F("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.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)"},r.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)"},xF(r.el,i),this.options.shape==="circle"&&xF(r.back,e),xF(r.front,e),this.applyStyles(r),this},Sn.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},Sn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Sn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Sn.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},Sn.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},Sn.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,r={};r.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},Sn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var r=i.options.fadeTime+"ms",s={};s.front=_F("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Sn.prototype.restCallback=function(){var t=this,e={};e.front=_F("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Sn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Sn.prototype.computeDirection=function(t){var e,i,r,s=t.angle.radian,n=Math.PI/4,a=Math.PI/2;if(s>n&&s<3*n&&!t.lockX?e="up":s>-n&&s<=n&&!t.lockY?e="left":s>3*-n&&s<=-n&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=s>-a&&s<a?"left":"right"),t.lockX||(r=s>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 u={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(u[o]=!0);if(u.x&&u.y&&u.angle)return t;(!u.x||!u.y)&&this.trigger("plain",t),u.x||this.trigger("plain:"+i,t),u.y||this.trigger("plain:"+r,t),u.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var KPt=Sn;function Ws(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=Ws.id,Ws.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 r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Ws.prototype=new $W,Ws.constructor=Ws,Ws.id=0,Ws.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 r=0,s=e.length;r<s;r+=1)if(e[r].identifier===i)return e[r];return!1}},Ws.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},Ws.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)}},Ws.prototype.createNipple=function(t,e){var i=this,r=i.manager.scroll,s={},n=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(t.x&&t.y)s={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",n.zone.appendChild(l);var u=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:u.left+r.x,y:u.top+r.y}}var h=new KPt(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:e,position:t,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(bF(h.ui.el,s),bF(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},Ws.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},Ws.prototype.bindNipple=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},Ws.prototype.pressureFn=function(t,e,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==s&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),s=n)}.bind(r),100)},Ws.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=v_t(t),e.updateBox(),f7(t,function(s){e.actives.length<i.maxNumberOfNipples?e.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(o){return o.identifier===n})<0){var a=[t[0]];a.identifier=n,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(s))}),e.manager.bindDocument(),!1},Ws.prototype.processOnStart=function(t){var e,i=this,r=i.options,s=i.manager.getIdentifier(t),n=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(s,a);o.identifier!==s&&i.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),i.trigger("start "+u.id+":start",u),u.show(),n>0&&i.pressureFn(t,u,u.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),r.mode!=="semi")l(o);else{if(!(NE(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},Ws.prototype.getOrCreate=function(t,e){var i,r=this,s=r.options;return/(semi|static)/.test(s.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):s.mode==="semi"?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(e,t)},Ws.prototype.processOnMove=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.scroll;if((b=>isNaN(b.buttons)?b.pressure!==0:b.buttons!==0)(t)){if(!s)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var u,h,d=NE(l,s.position),c=((b,_)=>{let x=_.x-b.x,S=_.y-b.y;return(w=>w*(180/Math.PI))(Math.atan2(S,x))})(l,s.position),p=vF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(u=Math.min(d,o),h=((b,_,x)=>{let S={x:0,y:0};return x=vF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,u,c)):(h=((b,_,x)=>({x:Math.min(Math.max(b.x,_.x-x),_.x+x),y:Math.min(Math.max(b.y,_.y-x),_.y+x)}))(l,s.position,o),u=NE(h,s.position)),i.follow){if(d>o){let b=l.x-h.x,_=l.y-h.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(e.box.top+n.y)+"px",s.el.style.left=s.position.x-(e.box.left+n.x)+"px",d=NE(l,s.position)}}else l=h,d=u;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||bF(s.ui.front,s.frontPosition);var v={identifier:s.identifier,position:l,force:m,pressure:t.force||t.pressure||t.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-y/o},raw:f,instance:s,lockX:i.lockX,lockY:i.lockY};(v=s.computeDirection(v)).angle={radian:vF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},Ws.prototype.processOnEnd=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),e.trigger("removed "+s.id+":removed",s),e.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(e.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),e.trigger("end "+s.id+":end",s),e.ids.indexOf(s.identifier)>=0&&e.ids.splice(e.ids.indexOf(s.identifier),1),e.actives.indexOf(s)>=0&&e.actives.splice(e.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?e.idles.push(s):e.nipples.indexOf(s)>=0&&e.nipples.splice(e.nipples.indexOf(s),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[n.id]=n.identifier))},Ws.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()},Ws.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 ZPt=Ws;function sn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=kut(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var r;e.collections.forEach(function(s){s.forEach(function(n){r=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+r.left,y:e.scroll.y+r.top}})})};return e._onResize=function(){(r=>{OE.has(r)&&clearTimeout(OE.get(r)),OE.set(r,setTimeout(function(){OE.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=kut()},e.collections}sn.prototype=new $W,sn.constructor=sn,sn.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(r){return!(i=r.get(e))}),i}},sn.prototype.create=function(t){return this.createCollection(t)},sn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,v5(window,"resize",t._onResize),v5(window,"scroll",t._onScroll))},sn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,b5(window,"resize",t._onResize),b5(window,"scroll",t._onScroll))},sn.prototype.createCollection=function(t){var e=this,i=new ZPt(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},sn.prototype.bindCollection=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},sn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},sn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},sn.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]},sn.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},sn.prototype.onmove=function(t){return this.onAny("move",t),!1},sn.prototype.onend=function(t){return this.onAny("end",t),!1},sn.prototype.oncancel=function(t){return this.onAny("end",t),!1},sn.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=v_t(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return f7(e,function(a){i=r.getIdentifier(a),f7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},sn.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()},sn.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 QPt=sn,Ev=null;function Lut(){return Ev||(Ev=new QPt),Ev}var JPt={create:function(t){return Lut().create(t)},destroy:function(){Ev&&(Ev.destroy(),Ev=null)},get factory(){return Lut()}},tRt=JPt;ir(),ke(),dt(),Qh(),vo(),ke();var S_t=null;function wF(){return S_t}var T_t,SF,eRt=new Promise(t=>{T_t=t});function iRt(t){return SF||(SF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),T_t(r)}(),SF)}function M_t(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,r=e[4]**2+e[5]**2+e[6]**2,s=e[8]**2+e[9]**2+e[10]**2,n=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||r<l||s<l||n<l||a<l||o<l}function oc(t,e){let i=new ge;if(e&&M_t(e))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=LG(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new fe(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}ns(),vo(),Ii(),tW(),dt(),dt(),Qv(),ZS();var ki,rRt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=un(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){na(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=>{"runMode"in e.data&&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()))}},Fut=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=un(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.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(){na(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()))}};ns(),eRt.then(t=>ki=t);var rn=new P,Wl=new Se,Ap=new P,Uut=(new Qi(0,0,0,"YXZ"),new Qi(0,0,0,"XYZ")),Ph=new P,TF=new P,MF=new P(1,1,1),Qy=new Se,IE=new _t,jut=new _t,sRt={type:"updateMatrix"},Gut=new Se,AF=new ta,CF=.01,g7={type:"beginEvent",eventName:"Collision"},nRt={type:"beginEvent",eventName:"Trigger"},_5=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 Jy(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(Ag(t)?t.object:t)}var aRt=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()!==ki.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r,s]=this.rigidBodyToMesh.get(e.handle);if(rn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Wl.copy(e.rotation()),i.matrixWorld.compose(rn,Wl,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(sRt),s){let n=i.cloner;if(n&&n.objectForSample===void 0){n.matrixWorld.copy(i.matrixWorld);for(let a of n.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,r)=>{if(r===!1)return;let s,n;if(this.sensorToTriggerEvent[e]?(s=this.sensorToTriggerEvent[e],n=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],n=this.sharedGameControlGlobals.colliderToEntity.get(e)),s&&n&&s.isValidTriggeringObject(n))s.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),u=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(u!==void 0)for(let h of u)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 r=i.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(r)for(let s of r.objects){let n=this.page.scene.find(s);n&&(n.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 r of i.data.objects){let s=this.page.scene.find(r);s&&(s.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(wF()===null)return void Nn("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof bv,n=H2(i);if($1(i)||s||n)return;r=Ag(i)?i.object:i;let a=r.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=r.userData.hasDestroy===!0,u=r.userData.hasDrag===!0;if(_5(a)||l||u||r.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 d of i.matrixWorld.elements)e.push(d)}}return!!Jy(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((n,a)=>n===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=Mg(t.map(n=>oc(n.geometry,n.matrixWorld)),!1),s=new(wF())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(M_t(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(oc(s,t.shearScale)),n.physics.fusedBody){let a=this.gatherChildrenGeom(t,r);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&n.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&n.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=ki.RigidBodyDesc.dynamic(),a.setLinearDamping(n.physics.damping).setAngularDamping(n.physics.damping).setAdditionalMass(1e-9).setGravityScale(n.physics.gravityScale).enabledRotations(...n.physics.enabledRotation).enabledTranslations(...n.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=ki.RigidBodyDesc.kinematicPositionBased(),o=!0):a=ki.RigidBodyDesc.fixed();let u=Mg(r);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(rn,Wl,Ap),t.position0=rn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Wl.clone(),rn.divideScalar(this.pixelsPerMeter),a.setTranslation(rn.x,rn.y,rn.z).setRotation(Wl),s?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Ap.x/this.pixelsPerMeter,Ap.y/this.pixelsPerMeter,Ap.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(n.geometry===void 0||n.geometry.type==="SubdivGeometry"||n.geometry.type==="NonParametricGeometry"||n.geometry.type==="BooleanGeometry"||n.geometry.type==="VectorGeometry"||n.geometry.type==="StarGeometry"||n.geometry.type==="RectangleGeometry"||n.geometry.type==="EllipseGeometry"||n.geometry.type==="TriangleGeometry"||n.geometry.type==="TorusGeometry"||n.geometry.type==="HelixGeometry");try{this.addCollider(h,n.physics,u,e,d)}catch{try{this.addCollider(h,n.physics,u,e,!1)}catch(c){console.error(c)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[t,Ap.clone(),n.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(oc(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Mg(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(wF())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,r,s=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let n;i&&(n=e.colliderType==="trimesh"?ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ki.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setRestitutionCombineRule(ki.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(n,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Jy(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if($1(r)){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;n=r.object}else if(Ag(r))n=r.object;else if(n=r,n.dataPatched.cloner?.hideBase)return!0;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;s===1?t.hasNonUniformScale?r.matrixWorld.multiplyMatrices(t.shearScale,r.hiddenMatrix):r.matrixWorld.copy(r.hiddenMatrix):r.matrixWorld.multiplyMatrices(r.parent.matrixWorld,r.hiddenMatrix),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(oc(o,r.matrixWorld)),!!Jy(r)||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 r=Vut();if(r!==null?i=r.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Nn("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:u,hoverRotatePanMode:h}=this.eventManager.publish.orbitControls;(a||o||l||u||h!==0)&&(this.orbitControls=new i_t(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 s=this.renderer.domElement.width/this.renderer.getPixelRatio(),n=this.renderer.domElement.height/this.renderer.getPixelRatio();Vut()?.createJoysticks(this,s,n),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 ki.World(new ki.Vector3(0,this.gravity,0)),this.events=new ki.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if($1(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(Ag(a))o=a.object;else{if(H2(a)||i0(a)||a instanceof bv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,u=o.dataPatched;for(let g of u.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldRigid();let h=_5(u),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of u.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new rRt(g.id,g.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!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){m=!0;let y=g.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=ki.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(rn,Wl,Ap),a.position0=rn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Wl.clone(),rn.divideScalar(this.pixelsPerMeter),g.setTranslation(rn.x,rn.y,rn.z).setRotation(Wl);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?ki.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?ki.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):ki.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(0).setRestitutionCombineRule(ki.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),rn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Ap.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(rn);let _=new Se().setFromEuler(new Qi().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else u.physics.rigidBody==="dynamic"||h||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,u.physics.fusedBody)):(f&&t.push(oc(f,a.matrixWorld)),u.physics.fusedBody&&!Jy(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if($1(g)){if(!g.objectForSample)return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(g.objectForSample.dataPatched.physics.fusedBody)return;v=g.object}else{if(H2(g)||i0(g)||g instanceof bv)return;if(Ag(g))v=g.object;else if(v=g,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;return _?.getAttribute("position")!==void 0&&t.push(oc(_,g.matrixWorld)),!!Jy(g)||void 0}),this.generateSensorColliderDescs(o,u.physics.fusedBody,e));return!(u.physics?.fusedBody!==!0&&!l&&!Jy(a))||void 0}),t.length===0)return;let i=Mg(t),r=i.getIndex().count>0;if(!r&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ki.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ki.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ki.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,n)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,n);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 Fut(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new _t().compose(Ph.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Qy.setFromEuler(Uut.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),MF);if(e.data.triggerZone==="box"){let s=new pr;s.min.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,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 r=t/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),n=0,a=6;for(;this.accumulator>=i&&n<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,n++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(rn,Wl,Ap);let e=t;e.prevQ===void 0?(e.prevQ=Wl.clone(),e.prevT=rn.clone()):(e.prevQ.copy(Wl),e.prevT.copy(rn))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,r]=this.fixedBodiesToWatch[t];e.rigidBody===i?(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(r)||(i.setBodyType(ki.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1)):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(),r=t.translation(),s=Math.hypot(i.x,i.z);for(let n=0;n<t.numColliders();n++){let a=t.collider(n);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let u=l.translation(),h=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(u.x-r.x)+v.y*(u.y-r.y)+v.z*(u.z-r.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let _=b*v.x,x=b*v.z,S=Math.hypot(_,x);if(S<1e-4)return;let w=(i.x*_+i.z*x)/S;w>h&&(h=w,d=_/S,c=x/S)}),h===-1/0)return;let p=i.x*d+i.z*c;if(p<-CF)return;let m=l.linvel();if(s>CF&&p>CF){let y=m.x*d+m.z*c;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:d*v,y:m.y,z:c*v},!0)}let f=m.x*d+m.z*c-Math.max(0,p);if(f<=0)return;let g=.5*f;l.setLinvel({x:m.x-d*g,y:m.y,z:m.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let t=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[e,i]of t)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(rn.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(Wl)):t.delete(e);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)e.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let n of e.cloner.children)if(n.rigidBody===s){r=n;break}}t.dispatch(r),e.dispatchEvent(g7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=jut.copy(t.matrixWorld).invert();t.traverseEntity((s,n)=>{if(e===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new Fut(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?ki.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):ki.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),Ph.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),Qy.setFromEuler(Uut.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),IE.compose(Ph,Qy,MF).premultiply(s.matrixWorld),i?(IE.decompose(Ph,Qy,TF),o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED)):(IE.premultiply(r).decompose(Ph,Qy,TF),t.rigidBody.bodyType()===ki.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ki.RigidBodyType.Fixed?o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ki.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ph.divideScalar(this.pixelsPerMeter),o.setTranslation(Ph.x,Ph.y,Ph.z),o.setRotation(Qy),i)i.push([o,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(Mi.is(o)?o:o.object)===!1)continue;let l=jut.copy(s.matrixWorld).decompose(Ph,Gut,TF).compose(Ph,Gut,MF).multiply(r),u=IE.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof pr?t=h.intersectsBox(i,u):(AF.radius=i,AF.center.setFromMatrixPosition(u),t=h.intersectsSphere(AF)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(nRt)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};tb(),dt(),R4(),Fi(),Tm();var EF=.02,Wut=new P,qut=new P,oRt=new P,qa=new P,Fd=new P,t1=new P,PF=new _t,Hut=new _t,lRt=new _t,nl=new Se,Xf=new Se,e1=new Qi(0,0,0,"YXZ"),hRt=new P(1,0,0),Eu=new P(0,1,0),uRt=new P(0,0,1),$ut=new P(1,1,1),Xut=[],Yut=t=>Xut[t]??(Xut[t]=new P),RF=new P,dRt=new P,cRt=new P,pRt=new P,Kut=new Se,mRt=new P,Zut=new Se,Hn=new yl,ql=new pr,fRt={type:"requestRender"},gRt={type:"updateMatrix"},y7=class extends Jn{constructor(t,e,i,r,s,n,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new _t,this.target0=new P,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Qi(0,0,0,"YXZ"),this.position0Cam=new P,this.quat0Cam=new Se,this.scale0Cam=new P,this.hiddenMatrix0Cam=new _t,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new yl(new P(0,-40,0),new P(0,40,0)),matrix:new _t,position:new P,rotation:new Se},this.euler=new Qi(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Se,this.lastCameraPosition=new P,this.PI_2=Math.PI/2,this.prevMouse=new Q,this.velocityTarget=new P,this.velocity=new P,this.directionXZ=new P,this.rotVelocityStick=new P,this.rotVelocityTarget=new P,this.rotVelocity=new P,this.rotDirection=new P,this.nonColliderRotOffset=new _t,this.nonColliderPosOffset=new _t,this.firstPointerId=-1,this.rot=new P,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 _t,this.objectToTarget=new P,this.objectToTarget0=new P,this.objectToCamXZ=new P,this.objectToCamXZ0=new P,this.targetToCamera=new P,this.targetToCamera0=new P,this.cameraPolarAxis0=new P,this.targetPos=new P,this.targetQuat=new Se,this.lerpFactorPos=new P().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Se,this.objXZQuatInv=new Se,this.objXZRotMat=new _t,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Se,this.colliderWorldQuat=new Se,this.groundNormal=new P,this.groundTilt=new Se,this.groundTiltInv=new Se,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Se,this.scale=new P,this.initialAction=!0,this.onPointerDown=m=>{!(m.target===this.domElement||m.target instanceof HTMLElement&&m.target.tagName==="SPLINE-VIEWER"&&m.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Fo&&!F8&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let f=m.clientX-this.prevMouse.x,g=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(F8&&lmt<15.5&&!Fo?(this.eulerDelta.y=-f*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-f*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?y7.isLocked=!0:y7.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let m in this.movementState)this.movementState[m]=0},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]){this.movementState[f[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=m=>{for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]||m.code.slice(3,m.code.length).toUpperCase()===f[1]){this.movementState[f[0]]=0;break}},this.copyVRGamePadValues=(m,f)=>{for(let g=2;g<4;g++){let y=m.axes[g];f===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.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 u=this.euler0.clone(),h=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,h,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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 m,f=new P(0,0,-1).applyQuaternion(this.camera.quaternion),g=new P().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(f.y)<1e-6?(g.y=0,f.y=0,m=g.projectOnVector(f)):m=g.y/f.y>0?f.multiplyScalar(g.y/f.y):f.multiplyScalar(g.length()),this.targetToCamera0.copy(m).negate();let y=this.camera.position.clone().add(m);this.objectToTarget0.subVectors(y,this.position);let v=new Qi().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 ks&&(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(m=>{let f=[m[0],m[1]];return f[1]==="\u25B2"?f[1]="ArrowUp":f[1]==="\u25C0"?f[1]="ArrowLeft":f[1]==="\u25BC"?f[1]="ArrowDown":f[1]==="\u25B6"?f[1]="ArrowRight":f[1]==="\u21E7"?f[1]="Shift":f[1]==="\u21B5"?f[1]="Enter":f[1]==="Space"?f[1]=" ":f[1]==="\u2318"?f[1]="Meta":f[1]==="Ctrl"?f[1]="Control":f[1]==="Esc"&&(f[1]="Escape"),f}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(f=>f[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][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??cv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??cv.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??w4.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*EF/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*EF/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*EF/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new P().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new Se().setFromEuler(new Qi().fromArray([...i.collider.rotation.map(m=>typeof m=="number"?m:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,$ut),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 m=new ye;m.push({fi:0,data:{...Hs.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Hs.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=Ugt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new vr(RG.create({parameters:{width:p,height:p/10,hollow:.7}}),f),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 Qi().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 ks?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={},x4.list.forEach(i=>{this.actions[i]=un({...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"),na(this.actions.idle),na(this.actions.move),na(this.actions.run),na(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 qa.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,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let n=Fd.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,n,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&&(r=!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,u=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&u?.userData.isFollowingObj!==this.object.uuid){let h=this.object.getWorldPosition(qa).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(h);this.groundVelocity.set(d.x,d.y,d.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 n=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=qa.subVectors(this.path[1],this.position),o=Fd.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),n.opacity=n.userData.opacity0}else n.opacity-=.05*n.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 s=oRt.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=Fd.copy(s);n.y=0,s.set(0,s.y,n.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 n=qa;this.camera.getWorldDirection(n);let a=t1.copy(Eu).multiplyScalar(n.dot(Eu));n.sub(a);let o=Fd.copy(this.directionXZ);o.x*=-1,this.rot.y=n.angleTo(o)*(n.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(e1.setFromVector3(this.rot),this.moveMode==="walk"&&(e1.x=0),s.applyEuler(e1),r&&(Xf.setFromUnitVectors(Eu,this.groundNormal),s.applyQuaternion(Xf)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let n=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(RF,Kut,dRt);let o=this.object.getWorldPosition(cRt).add(this.collider.position).sub(RF);Zut.copy(a.prevQ).invert().premultiply(Kut);let l=t1.subVectors(RF,a.prevT).add(pRt.copy(o).applyQuaternion(Zut).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),qa.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let h=Mi.is(a)?a:a.object;if(u!==null&&this.lastHitObj!==h){let d;a instanceof _l&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[h.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),h.dispatchEvent(g7));this.lastHitObj=h}u!==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),Yut(n++).copy(u.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=Yut(a),l=o.dot(s);l<0&&s.addScaledVector(o,-l)}s.add(this.pushedVelocity)}else s.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(Eu,this.euler.y-this.euler0.y);let n=Fd.copy(this.objectToCamXZ).normalize(),a=t1.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(qa.copy(n).multiplyScalar(a.dot(n))).cross(n).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=qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=qt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(e1.copy(this.euler),e1.y=0,this.nonColliderRotOffset.makeRotationFromEuler(e1)),nl.setFromAxisAngle(hRt,this.rot.x),Xf.setFromAxisAngle(Eu,this.rot.y),Xf.multiply(nl),nl.setFromAxisAngle(uRt,this.rot.z),Xf.multiply(nl),this.quaternion.copy(Xf),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 n=Fd.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let h=0;h<5;h++){let d=n.length(),c=t1.copy(n).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,c,this.object.rigidBody.collider(0).shape,0,d,!1,12,void 0,void 0,this.object.rigidBody),a===null){h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(n);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(b),p.dispatchEvent(g7)}}}let m=Wut.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=qut.copy(c).multiplyScalar(a.time_of_impact).dot(m),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),f>this.offset&&(g=a.time_of_impact*(f-this.offset)/f,o.addScaledVector(c,g)),n.copy(c).multiplyScalar(d-g),Math.acos(-m.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=t1.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let b=y.add(v);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);_!==null&&_.time_of_impact===0&&(m.y=0,m.normalize())}n.addScaledVector(m,-n.dot(m))}}this.position.addScaledVector(o,this.pixelsPerMeter),qa.copy(this.position).divideScalar(this.pixelsPerMeter),nl.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,u=l!==void 0&&mRt.copy(qa).sub(l.translation()).lengthSq()>1;l!==void 0&&(u?(l.setTranslation(qa,!0),l.setRotation(nl,!0)):(l.setNextKinematicTranslation(qa),l.setNextKinematicRotation(nl)))}else{let n=this.onObject?1:5,a=s.multiplyScalar(e/n);for(let o=0;o<n;o++)this.position.add(a),this.collisionAdjustment(e/n)}else this.position.addScaledVector(s,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 n=this.objectToTarget.add(this.position),a=this.targetToCamera.add(n);PF.lookAt(a,n,Eu).setPosition(a),PF.decompose(this.targetPos,this.targetQuat,qa),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=qt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=qt.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(gRt),!(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(fRt),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=nl.setFromAxisAngle(Eu,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?qt.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"?qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Xf.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Eu.angleTo(t)/Math.PI<15||180*Eu.angleTo(t)/Math.PI>85?nl.identity():nl.setFromUnitVectors(Eu,t),this.groundTilt.slerp(nl,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=qut.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=PF.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qa,nl,Fd).compose(qa,nl,$ut);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;ql.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=Hut.copy(n).invert(),o=lRt.copy(Hut).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=Wut.copy(this.position).applyMatrix4(a);ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(Hn.end),intersectsBounds:u=>u.intersectsBox(ql),intersectsTriangle:u=>{let h=qa,d=Fd,c=u.closestPointToSegment(Hn,h,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(h).normalize(),f=t1.copy(l);f.addScaledVector(m,p);let g=f.applyMatrix4(n).sub(this.position);e.add(g),Hn.start.addScaledVector(m,p),Hn.end.addScaledVector(m,p)}}})}),ql.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(ql),intersectsTriangle:s=>{let n=qa,a=Fd,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,u=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(u),e.addScaledVector(u,l),Hn.start.addScaledVector(u,l),Hn.end.addScaledVector(u,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(r),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()}},A_t=y7;A_t.isLocked=!1,dt(),ZS(),iD(),tb(),Qv();var C_t,E_t,DF,yRt=new Promise(t=>{C_t=t});function vRt(t){return DF||(DF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build";typeof window<"u"&&(E_t=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});C_t(a)}(),DF)}ir();var P_t,Ni,_a,bRt=t=>`
|
|
5092
|
+
`)>=0&&(t-=s),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,r,s){let n=e*t,a=t-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return s===3?-(i-n-o):s===2?-(.5*i-.5*n-o):o}createPath(t,e,i,r,s){let n=t.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!n)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new HPt,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let u=a.currentPath?.currentPoint;if(!u||l.type==="Z"||u.x!==l.x||-u.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 u=function(h){if(h.length){let d=h[0];if(d instanceof cl)return d.v1;if(d instanceof Kl||d instanceof lc)return d.v0}}(l.curves);u!==void 0&&l.currentPoint.distanceTo(u)>0&&l.lineTo(u.x,u.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,r){let s=this.getCharWidth(" ",i),n=t[e];if(n){let a=this.countSpaces(n.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(n,i)-a*s))/a}return s}countSpaces(t){return(t.match(/ /g)||[]).length}},Or("text"),ke();var y_t=null;function Vut(){return y_t}function YPt(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&e0.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ir();var NE=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},vF=t=>t*(Math.PI/180),OE=new Map,v5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.addEventListener?t.addEventListener(r,i,!1):t.attachEvent&&t.attachEvent(r,i)},b5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.removeEventListener?t.removeEventListener(r,i):t.detachEvent&&t.detachEvent(r,i)},v_t=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),kut=()=>{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}},bF=(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")},_F=(t,e,i)=>{let r=b_t(t);for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s))if(typeof e=="string")r[s]=e+" "+i;else{let n="";for(let a=0,o=e.length;a<o;a+=1)n+=e[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},b_t=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},xF=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},f7=(t,e)=>{if(t.length)for(let i=0,r=t.length;i<r;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(__t="ontouchstart"in window,x_t=!!window.PointerEvent,w_t=!!window.MSPointerEvent);var __t,x_t,w_t,Zy,zut={start:"mousedown",move:"mousemove",end:"mouseup"},gw={};function dg(){}x_t?Zy={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:w_t?Zy={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:__t?(Zy={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},gw=zut):Zy=zut,dg.prototype.on=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(e);return r},dg.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},dg.prototype.trigger=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},e)})},dg.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,r)=>{let s={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&Object.prototype.hasOwnProperty.call(r,n)?s[n]=r[n]:Object.prototype.hasOwnProperty.call(i,n)&&(s[n]=i[n]);return s})(e.options,t))},dg.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.')},v5(t,Zy[e],i._domHandlers_[e]),gw[e]&&v5(t,gw[e],i._domHandlers_[e]),i},dg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},b5(t,Zy[e],i._domHandlers_[e]),gw[e]&&b5(t,gw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var $W=dg;function Sn(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=Sn.id,Sn.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}Sn.prototype=new $W,Sn.constructor=Sn,Sn.id=0,Sn.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},Sn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=b_t("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=_F("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.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)"},r.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)"},xF(r.el,i),this.options.shape==="circle"&&xF(r.back,e),xF(r.front,e),this.applyStyles(r),this},Sn.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},Sn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Sn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Sn.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},Sn.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},Sn.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,r={};r.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},Sn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var r=i.options.fadeTime+"ms",s={};s.front=_F("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Sn.prototype.restCallback=function(){var t=this,e={};e.front=_F("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Sn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Sn.prototype.computeDirection=function(t){var e,i,r,s=t.angle.radian,n=Math.PI/4,a=Math.PI/2;if(s>n&&s<3*n&&!t.lockX?e="up":s>-n&&s<=n&&!t.lockY?e="left":s>3*-n&&s<=-n&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=s>-a&&s<a?"left":"right"),t.lockX||(r=s>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 u={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(u[o]=!0);if(u.x&&u.y&&u.angle)return t;(!u.x||!u.y)&&this.trigger("plain",t),u.x||this.trigger("plain:"+i,t),u.y||this.trigger("plain:"+r,t),u.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var KPt=Sn;function Ws(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=Ws.id,Ws.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 r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Ws.prototype=new $W,Ws.constructor=Ws,Ws.id=0,Ws.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 r=0,s=e.length;r<s;r+=1)if(e[r].identifier===i)return e[r];return!1}},Ws.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},Ws.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)}},Ws.prototype.createNipple=function(t,e){var i=this,r=i.manager.scroll,s={},n=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(t.x&&t.y)s={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",n.zone.appendChild(l);var u=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:u.left+r.x,y:u.top+r.y}}var h=new KPt(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:e,position:t,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(bF(h.ui.el,s),bF(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},Ws.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},Ws.prototype.bindNipple=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},Ws.prototype.pressureFn=function(t,e,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==s&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),s=n)}.bind(r),100)},Ws.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=v_t(t),e.updateBox(),f7(t,function(s){e.actives.length<i.maxNumberOfNipples?e.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(o){return o.identifier===n})<0){var a=[t[0]];a.identifier=n,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(s))}),e.manager.bindDocument(),!1},Ws.prototype.processOnStart=function(t){var e,i=this,r=i.options,s=i.manager.getIdentifier(t),n=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(s,a);o.identifier!==s&&i.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),i.trigger("start "+u.id+":start",u),u.show(),n>0&&i.pressureFn(t,u,u.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),r.mode!=="semi")l(o);else{if(!(NE(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},Ws.prototype.getOrCreate=function(t,e){var i,r=this,s=r.options;return/(semi|static)/.test(s.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):s.mode==="semi"?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(e,t)},Ws.prototype.processOnMove=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.scroll;if((b=>isNaN(b.buttons)?b.pressure!==0:b.buttons!==0)(t)){if(!s)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var u,h,d=NE(l,s.position),c=((b,_)=>{let x=_.x-b.x,S=_.y-b.y;return(w=>w*(180/Math.PI))(Math.atan2(S,x))})(l,s.position),p=vF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(u=Math.min(d,o),h=((b,_,x)=>{let S={x:0,y:0};return x=vF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,u,c)):(h=((b,_,x)=>({x:Math.min(Math.max(b.x,_.x-x),_.x+x),y:Math.min(Math.max(b.y,_.y-x),_.y+x)}))(l,s.position,o),u=NE(h,s.position)),i.follow){if(d>o){let b=l.x-h.x,_=l.y-h.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(e.box.top+n.y)+"px",s.el.style.left=s.position.x-(e.box.left+n.x)+"px",d=NE(l,s.position)}}else l=h,d=u;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||bF(s.ui.front,s.frontPosition);var v={identifier:s.identifier,position:l,force:m,pressure:t.force||t.pressure||t.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-y/o},raw:f,instance:s,lockX:i.lockX,lockY:i.lockY};(v=s.computeDirection(v)).angle={radian:vF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},Ws.prototype.processOnEnd=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),e.trigger("removed "+s.id+":removed",s),e.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(e.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),e.trigger("end "+s.id+":end",s),e.ids.indexOf(s.identifier)>=0&&e.ids.splice(e.ids.indexOf(s.identifier),1),e.actives.indexOf(s)>=0&&e.actives.splice(e.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?e.idles.push(s):e.nipples.indexOf(s)>=0&&e.nipples.splice(e.nipples.indexOf(s),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[n.id]=n.identifier))},Ws.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()},Ws.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 ZPt=Ws;function sn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=kut(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var r;e.collections.forEach(function(s){s.forEach(function(n){r=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+r.left,y:e.scroll.y+r.top}})})};return e._onResize=function(){(r=>{OE.has(r)&&clearTimeout(OE.get(r)),OE.set(r,setTimeout(function(){OE.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=kut()},e.collections}sn.prototype=new $W,sn.constructor=sn,sn.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(r){return!(i=r.get(e))}),i}},sn.prototype.create=function(t){return this.createCollection(t)},sn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,v5(window,"resize",t._onResize),v5(window,"scroll",t._onScroll))},sn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,b5(window,"resize",t._onResize),b5(window,"scroll",t._onScroll))},sn.prototype.createCollection=function(t){var e=this,i=new ZPt(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},sn.prototype.bindCollection=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},sn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},sn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},sn.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]},sn.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},sn.prototype.onmove=function(t){return this.onAny("move",t),!1},sn.prototype.onend=function(t){return this.onAny("end",t),!1},sn.prototype.oncancel=function(t){return this.onAny("end",t),!1},sn.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=v_t(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return f7(e,function(a){i=r.getIdentifier(a),f7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},sn.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()},sn.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 QPt=sn,Ev=null;function Lut(){return Ev||(Ev=new QPt),Ev}var JPt={create:function(t){return Lut().create(t)},destroy:function(){Ev&&(Ev.destroy(),Ev=null)},get factory(){return Lut()}},tRt=JPt;ir(),ke(),dt(),Qh(),vo(),ke();var S_t=null;function wF(){return S_t}var T_t,SF,eRt=new Promise(t=>{T_t=t});function iRt(t){return SF||(SF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),T_t(r)}(),SF)}function M_t(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,r=e[4]**2+e[5]**2+e[6]**2,s=e[8]**2+e[9]**2+e[10]**2,n=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||r<l||s<l||n<l||a<l||o<l}function oc(t,e){let i=new ge;if(e&&M_t(e))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=LG(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new fe(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}ns(),vo(),Ii(),tW(),dt(),dt(),Qv(),ZS();var ki,rRt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=un(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){na(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=>{"runMode"in e.data&&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()))}},Fut=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=un(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.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(){na(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()))}};ns(),eRt.then(t=>ki=t);var rn=new P,Wl=new Se,Ap=new P,Uut=(new Qi(0,0,0,"YXZ"),new Qi(0,0,0,"XYZ")),Ph=new P,TF=new P,MF=new P(1,1,1),Qy=new Se,IE=new _t,jut=new _t,sRt={type:"updateMatrix"},Gut=new Se,AF=new ta,CF=.01,g7={type:"beginEvent",eventName:"Collision"},nRt={type:"beginEvent",eventName:"Trigger"},_5=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 Jy(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(Ag(t)?t.object:t)}var aRt=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()!==ki.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r,s]=this.rigidBodyToMesh.get(e.handle);if(rn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Wl.copy(e.rotation()),i.matrixWorld.compose(rn,Wl,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(sRt),s){let n=i.cloner;if(n&&n.objectForSample===void 0){n.matrixWorld.copy(i.matrixWorld);for(let a of n.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,r)=>{if(r===!1)return;let s,n;if(this.sensorToTriggerEvent[e]?(s=this.sensorToTriggerEvent[e],n=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],n=this.sharedGameControlGlobals.colliderToEntity.get(e)),s&&n&&s.isValidTriggeringObject(n))s.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),u=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(u!==void 0)for(let h of u)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 r=i.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(r)for(let s of r.objects){let n=this.page.scene.find(s);n&&(n.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 r of i.data.objects){let s=this.page.scene.find(r);s&&(s.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(wF()===null)return void Nn("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof bv,n=H2(i);if($1(i)||s||n)return;r=Ag(i)?i.object:i;let a=r.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=r.userData.hasDestroy===!0,u=r.userData.hasDrag===!0;if(_5(a)||l||u||r.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 d of i.matrixWorld.elements)e.push(d)}}return!!Jy(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((n,a)=>n===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=Mg(t.map(n=>oc(n.geometry,n.matrixWorld)),!1),s=new(wF())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(M_t(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(oc(s,t.shearScale)),n.physics.fusedBody){let a=this.gatherChildrenGeom(t,r);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&n.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&n.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=ki.RigidBodyDesc.dynamic(),a.setLinearDamping(n.physics.damping).setAngularDamping(n.physics.damping).setAdditionalMass(1e-9).setGravityScale(n.physics.gravityScale).enabledRotations(...n.physics.enabledRotation).enabledTranslations(...n.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=ki.RigidBodyDesc.kinematicPositionBased(),o=!0):a=ki.RigidBodyDesc.fixed();let u=Mg(r);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(rn,Wl,Ap),t.position0=rn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Wl.clone(),rn.divideScalar(this.pixelsPerMeter),a.setTranslation(rn.x,rn.y,rn.z).setRotation(Wl),s?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Ap.x/this.pixelsPerMeter,Ap.y/this.pixelsPerMeter,Ap.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(n.geometry===void 0||n.geometry.type==="SubdivGeometry"||n.geometry.type==="NonParametricGeometry"||n.geometry.type==="BooleanGeometry"||n.geometry.type==="VectorGeometry"||n.geometry.type==="StarGeometry"||n.geometry.type==="RectangleGeometry"||n.geometry.type==="EllipseGeometry"||n.geometry.type==="TriangleGeometry"||n.geometry.type==="TorusGeometry"||n.geometry.type==="HelixGeometry");try{this.addCollider(h,n.physics,u,e,d)}catch{try{this.addCollider(h,n.physics,u,e,!1)}catch(c){console.error(c)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[t,Ap.clone(),n.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(oc(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Mg(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(wF())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,r,s=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let n;i&&(n=e.colliderType==="trimesh"?ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ki.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setRestitutionCombineRule(ki.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(n,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Jy(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if($1(r)){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;n=r.object}else if(Ag(r))n=r.object;else if(n=r,n.dataPatched.cloner?.hideBase)return!0;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;s===1?t.hasNonUniformScale?r.matrixWorld.multiplyMatrices(t.shearScale,r.hiddenMatrix):r.matrixWorld.copy(r.hiddenMatrix):r.matrixWorld.multiplyMatrices(r.parent.matrixWorld,r.hiddenMatrix),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(oc(o,r.matrixWorld)),!!Jy(r)||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 r=Vut();if(r!==null?i=r.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Nn("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:u,hoverRotatePanMode:h}=this.eventManager.publish.orbitControls;(a||o||l||u||h!==0)&&(this.orbitControls=new i_t(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 s=this.renderer.domElement.width/this.renderer.getPixelRatio(),n=this.renderer.domElement.height/this.renderer.getPixelRatio();Vut()?.createJoysticks(this,s,n),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 ki.World(new ki.Vector3(0,this.gravity,0)),this.events=new ki.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if($1(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(Ag(a))o=a.object;else{if(H2(a)||i0(a)||a instanceof bv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,u=o.dataPatched;for(let g of u.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldRigid();let h=_5(u),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of u.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new rRt(g.id,g.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!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){m=!0;let y=g.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=ki.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(rn,Wl,Ap),a.position0=rn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Wl.clone(),rn.divideScalar(this.pixelsPerMeter),g.setTranslation(rn.x,rn.y,rn.z).setRotation(Wl);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?ki.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?ki.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):ki.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(0).setRestitutionCombineRule(ki.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),rn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Ap.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(rn);let _=new Se().setFromEuler(new Qi().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else u.physics.rigidBody==="dynamic"||h||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,u.physics.fusedBody)):(f&&t.push(oc(f,a.matrixWorld)),u.physics.fusedBody&&!Jy(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if($1(g)){if(!g.objectForSample)return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(g.objectForSample.dataPatched.physics.fusedBody)return;v=g.object}else{if(H2(g)||i0(g)||g instanceof bv)return;if(Ag(g))v=g.object;else if(v=g,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;return _?.getAttribute("position")!==void 0&&t.push(oc(_,g.matrixWorld)),!!Jy(g)||void 0}),this.generateSensorColliderDescs(o,u.physics.fusedBody,e));return!(u.physics?.fusedBody!==!0&&!l&&!Jy(a))||void 0}),t.length===0)return;let i=Mg(t),r=i.getIndex().count>0;if(!r&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ki.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ki.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ki.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,n)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,n);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 Fut(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new _t().compose(Ph.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Qy.setFromEuler(Uut.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),MF);if(e.data.triggerZone==="box"){let s=new pr;s.min.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,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 r=t/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),n=0,a=6;for(;this.accumulator>=i&&n<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,n++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(rn,Wl,Ap);let e=t;e.prevQ===void 0?(e.prevQ=Wl.clone(),e.prevT=rn.clone()):(e.prevQ.copy(Wl),e.prevT.copy(rn))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,r]=this.fixedBodiesToWatch[t];e.rigidBody===i?(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(r)||(i.setBodyType(ki.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1)):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(),r=t.translation(),s=Math.hypot(i.x,i.z);for(let n=0;n<t.numColliders();n++){let a=t.collider(n);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let u=l.translation(),h=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(u.x-r.x)+v.y*(u.y-r.y)+v.z*(u.z-r.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let _=b*v.x,x=b*v.z,S=Math.hypot(_,x);if(S<1e-4)return;let w=(i.x*_+i.z*x)/S;w>h&&(h=w,d=_/S,c=x/S)}),h===-1/0)return;let p=i.x*d+i.z*c;if(p<-CF)return;let m=l.linvel();if(s>CF&&p>CF){let y=m.x*d+m.z*c;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:d*v,y:m.y,z:c*v},!0)}let f=m.x*d+m.z*c-Math.max(0,p);if(f<=0)return;let g=.5*f;l.setLinvel({x:m.x-d*g,y:m.y,z:m.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let t=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[e,i]of t)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(rn.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(Wl)):t.delete(e);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)e.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let n of e.cloner.children)if(n.rigidBody===s){r=n;break}}t.dispatch(r),e.dispatchEvent(g7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=jut.copy(t.matrixWorld).invert();t.traverseEntity((s,n)=>{if(e===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new Fut(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?ki.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):ki.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),Ph.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),Qy.setFromEuler(Uut.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),IE.compose(Ph,Qy,MF).premultiply(s.matrixWorld),i?(IE.decompose(Ph,Qy,TF),o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED)):(IE.premultiply(r).decompose(Ph,Qy,TF),t.rigidBody.bodyType()===ki.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ki.RigidBodyType.Fixed?o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ki.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ph.divideScalar(this.pixelsPerMeter),o.setTranslation(Ph.x,Ph.y,Ph.z),o.setRotation(Qy),i)i.push([o,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(Mi.is(o)?o:o.object)===!1)continue;let l=jut.copy(s.matrixWorld).decompose(Ph,Gut,TF).compose(Ph,Gut,MF).multiply(r),u=IE.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof pr?t=h.intersectsBox(i,u):(AF.radius=i,AF.center.setFromMatrixPosition(u),t=h.intersectsSphere(AF)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(nRt)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};tb(),dt(),R4(),Fi(),Tm();var EF=.02,Wut=new P,qut=new P,oRt=new P,qa=new P,Fd=new P,t1=new P,PF=new _t,Hut=new _t,lRt=new _t,nl=new Se,Xf=new Se,e1=new Qi(0,0,0,"YXZ"),hRt=new P(1,0,0),Eu=new P(0,1,0),uRt=new P(0,0,1),$ut=new P(1,1,1),Xut=[],Yut=t=>Xut[t]??(Xut[t]=new P),RF=new P,dRt=new P,cRt=new P,pRt=new P,Kut=new Se,mRt=new P,Zut=new Se,Hn=new yl,ql=new pr,fRt={type:"requestRender"},gRt={type:"updateMatrix"},y7=class extends Jn{constructor(t,e,i,r,s,n,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new _t,this.target0=new P,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Qi(0,0,0,"YXZ"),this.position0Cam=new P,this.quat0Cam=new Se,this.scale0Cam=new P,this.hiddenMatrix0Cam=new _t,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new yl(new P(0,-40,0),new P(0,40,0)),matrix:new _t,position:new P,rotation:new Se},this.euler=new Qi(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Se,this.lastCameraPosition=new P,this.PI_2=Math.PI/2,this.prevMouse=new Q,this.velocityTarget=new P,this.velocity=new P,this.directionXZ=new P,this.rotVelocityStick=new P,this.rotVelocityTarget=new P,this.rotVelocity=new P,this.rotDirection=new P,this.nonColliderRotOffset=new _t,this.nonColliderPosOffset=new _t,this.firstPointerId=-1,this.rot=new P,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 _t,this.objectToTarget=new P,this.objectToTarget0=new P,this.objectToCamXZ=new P,this.objectToCamXZ0=new P,this.targetToCamera=new P,this.targetToCamera0=new P,this.cameraPolarAxis0=new P,this.targetPos=new P,this.targetQuat=new Se,this.lerpFactorPos=new P().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Se,this.objXZQuatInv=new Se,this.objXZRotMat=new _t,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Se,this.colliderWorldQuat=new Se,this.groundNormal=new P,this.groundTilt=new Se,this.groundTiltInv=new Se,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Se,this.scale=new P,this.initialAction=!0,this.onPointerDown=m=>{!(m.target===this.domElement||m.target instanceof HTMLElement&&m.target.tagName==="SPLINE-VIEWER"&&m.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Fo&&!F8&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let f=m.clientX-this.prevMouse.x,g=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(F8&&lmt<15.5&&!Fo?(this.eulerDelta.y=-f*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-f*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?y7.isLocked=!0:y7.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let m in this.movementState)this.movementState[m]=0},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]){this.movementState[f[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=m=>{for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]||m.code.slice(3,m.code.length).toUpperCase()===f[1]){this.movementState[f[0]]=0;break}},this.copyVRGamePadValues=(m,f)=>{for(let g=2;g<4;g++){let y=m.axes[g];f===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.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 u=this.euler0.clone(),h=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,h,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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 m,f=new P(0,0,-1).applyQuaternion(this.camera.quaternion),g=new P().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(f.y)<1e-6?(g.y=0,f.y=0,m=g.projectOnVector(f)):m=g.y/f.y>0?f.multiplyScalar(g.y/f.y):f.multiplyScalar(g.length()),this.targetToCamera0.copy(m).negate();let y=this.camera.position.clone().add(m);this.objectToTarget0.subVectors(y,this.position);let v=new Qi().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 ks&&(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(m=>{let f=[m[0],m[1]];return f[1]==="\u25B2"?f[1]="ArrowUp":f[1]==="\u25C0"?f[1]="ArrowLeft":f[1]==="\u25BC"?f[1]="ArrowDown":f[1]==="\u25B6"?f[1]="ArrowRight":f[1]==="\u21E7"?f[1]="Shift":f[1]==="\u21B5"?f[1]="Enter":f[1]==="Space"?f[1]=" ":f[1]==="\u2318"?f[1]="Meta":f[1]==="Ctrl"?f[1]="Control":f[1]==="Esc"&&(f[1]="Escape"),f}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(f=>f[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][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??cv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??cv.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??w4.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*EF/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*EF/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*EF/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new P().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new Se().setFromEuler(new Qi().fromArray([...i.collider.rotation.map(m=>typeof m=="number"?m:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,$ut),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 m=new ye;m.push({fi:0,data:{...Hs.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Hs.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=Ugt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new vr(RG.create({parameters:{width:p,height:p/10,hollow:.7}}),f),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 Qi().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 ks?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={},x4.list.forEach(i=>{this.actions[i]=un({...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"),na(this.actions.idle),na(this.actions.move),na(this.actions.run),na(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 qa.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,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let n=Fd.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,n,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&&(r=!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,u=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&u?.userData.isFollowingObj!==this.object.uuid){let h=this.object.getWorldPosition(qa).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(h);this.groundVelocity.set(d.x,d.y,d.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 n=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=qa.subVectors(this.path[1],this.position),o=Fd.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),n.opacity=n.userData.opacity0}else n.opacity-=.05*n.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 s=oRt.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=Fd.copy(s);n.y=0,s.set(0,s.y,n.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 n=qa;this.camera.getWorldDirection(n);let a=t1.copy(Eu).multiplyScalar(n.dot(Eu));n.sub(a);let o=Fd.copy(this.directionXZ);o.x*=-1,this.rot.y=n.angleTo(o)*(n.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(e1.setFromVector3(this.rot),this.moveMode==="walk"&&(e1.x=0),s.applyEuler(e1),r&&(Xf.setFromUnitVectors(Eu,this.groundNormal),s.applyQuaternion(Xf)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let n=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(RF,Kut,dRt);let o=this.object.getWorldPosition(cRt).add(this.collider.position).sub(RF);Zut.copy(a.prevQ).invert().premultiply(Kut);let l=t1.subVectors(RF,a.prevT).add(pRt.copy(o).applyQuaternion(Zut).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),qa.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let h=Mi.is(a)?a:a.object;if(u!==null&&this.lastHitObj!==h){let d;a instanceof _l&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[h.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),h.dispatchEvent(g7));this.lastHitObj=h}u!==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),Yut(n++).copy(u.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=Yut(a),l=o.dot(s);l<0&&s.addScaledVector(o,-l)}s.add(this.pushedVelocity)}else s.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(Eu,this.euler.y-this.euler0.y);let n=Fd.copy(this.objectToCamXZ).normalize(),a=t1.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(qa.copy(n).multiplyScalar(a.dot(n))).cross(n).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=qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=qt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(e1.copy(this.euler),e1.y=0,this.nonColliderRotOffset.makeRotationFromEuler(e1)),nl.setFromAxisAngle(hRt,this.rot.x),Xf.setFromAxisAngle(Eu,this.rot.y),Xf.multiply(nl),nl.setFromAxisAngle(uRt,this.rot.z),Xf.multiply(nl),this.quaternion.copy(Xf),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 n=Fd.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let h=0;h<5;h++){let d=n.length(),c=t1.copy(n).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,c,this.object.rigidBody.collider(0).shape,0,d,!1,12,void 0,void 0,this.object.rigidBody),a===null){h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(n);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(b),p.dispatchEvent(g7)}}}let m=Wut.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=qut.copy(c).multiplyScalar(a.time_of_impact).dot(m),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),f>this.offset&&(g=a.time_of_impact*(f-this.offset)/f,o.addScaledVector(c,g)),n.copy(c).multiplyScalar(d-g),Math.acos(-m.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=t1.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let b=y.add(v);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);_!==null&&_.time_of_impact===0&&(m.y=0,m.normalize())}n.addScaledVector(m,-n.dot(m))}}this.position.addScaledVector(o,this.pixelsPerMeter),qa.copy(this.position).divideScalar(this.pixelsPerMeter),nl.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,u=l!==void 0&&mRt.copy(qa).sub(l.translation()).lengthSq()>1;l!==void 0&&(u?(l.setTranslation(qa,!0),l.setRotation(nl,!0)):(l.setNextKinematicTranslation(qa),l.setNextKinematicRotation(nl)))}else{let n=this.onObject?1:5,a=s.multiplyScalar(e/n);for(let o=0;o<n;o++)this.position.add(a),this.collisionAdjustment(e/n)}else this.position.addScaledVector(s,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 n=this.objectToTarget.add(this.position),a=this.targetToCamera.add(n);PF.lookAt(a,n,Eu).setPosition(a),PF.decompose(this.targetPos,this.targetQuat,qa),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=qt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=qt.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(gRt),!(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(fRt),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=nl.setFromAxisAngle(Eu,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?qt.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"?qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Xf.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Eu.angleTo(t)/Math.PI<15||180*Eu.angleTo(t)/Math.PI>85?nl.identity():nl.setFromUnitVectors(Eu,t),this.groundTilt.slerp(nl,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=qut.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=PF.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qa,nl,Fd).compose(qa,nl,$ut);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;ql.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=Hut.copy(n).invert(),o=lRt.copy(Hut).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=Wut.copy(this.position).applyMatrix4(a);ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(Hn.end),intersectsBounds:u=>u.intersectsBox(ql),intersectsTriangle:u=>{let h=qa,d=Fd,c=u.closestPointToSegment(Hn,h,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(h).normalize(),f=t1.copy(l);f.addScaledVector(m,p);let g=f.applyMatrix4(n).sub(this.position);e.add(g),Hn.start.addScaledVector(m,p),Hn.end.addScaledVector(m,p)}}})}),ql.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(ql),intersectsTriangle:s=>{let n=qa,a=Fd,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,u=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(u),e.addScaledVector(u,l),Hn.start.addScaledVector(u,l),Hn.end.addScaledVector(u,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(r),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()}},A_t=y7;A_t.isLocked=!1,dt(),ZS(),iD(),tb(),Qv();var C_t,E_t,DF,yRt=new Promise(t=>{C_t=t});function vRt(t){return DF||(DF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build";typeof window<"u"&&(E_t=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});C_t(a)}(),DF)}ir();var P_t,Ni,_a,bRt=t=>`
|
|
5093
5093
|
(async function() {
|
|
5094
5094
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
5095
5095
|
import('${t}' + 'navmesh.js'),
|
|
@@ -5099,7 +5099,7 @@ void main() {
|
|
|
5099
5099
|
self.module = await wasmModule({ wasmBinary });
|
|
5100
5100
|
postMessage('ready');
|
|
5101
5101
|
})();
|
|
5102
|
-
`,_Rt={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};yRt.then(t=>{P_t=t,Ni=new t.Vec3,_a=new t.Vec3});var xRt=new P,wRt=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ge.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let n=s.raycastWithClones(r);if(n.length!==0){if(this.gameControl){let a=xRt.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,n[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{let n;if(s instanceof pm){if(!s.objectForSample)return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else if(s instanceof _l)n=s.object;else if(n=s,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!n.userData.navmesh)return;let a=n.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;s.updateMatrixWorldRigid();let o=_5(a),l=n.userData.hasDestroy,u=n.userData.hasDrag,h=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?h=!0:c.data.type==="Follow"&&(d=!0));if(h||o||d||l||u)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in s&&s.geometry&&i.push(oc(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof pm){if(!c.objectForSample)return c.object.dataPatched.physics.fusedBody===!0&&c.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(c.objectForSample.dataPatched.physics.fusedBody)return;m=c.object}else if(c instanceof _l)m=c.object;else if(m=c,c.dataPatched.cloner?.hideBase)return!0;let f=m.dataPatched;if(!f.visible&&f.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(oc(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof pm)return;n=s instanceof _l?s.object:s;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!n.userData.navmesh)return;let o=s.geometry,l=n.userData.hasDestroy===!0,u=n.userData.hasDrag===!0;if(_5(a)||l||u||n.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(oc(o,s.matrixWorld))},this.navmeshWasm=P_t,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?bRt(E_t??"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
5102
|
+
`,_Rt={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};yRt.then(t=>{P_t=t,Ni=new t.Vec3,_a=new t.Vec3});var xRt=new P,wRt=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ge.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let n=s.raycastWithClones(r);if(n.length!==0){if(this.gameControl){let a=xRt.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,n[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{let n;if(s instanceof pm){if(!s.objectForSample)return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else if(s instanceof _l)n=s.object;else if(n=s,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!n.userData.navmesh)return;let a=n.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;s.updateMatrixWorldRigid();let o=_5(a),l=n.userData.hasDestroy,u=n.userData.hasDrag,h=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?h=!0:c.data.type==="Follow"&&(d=!0));if(h||o||d||l||u)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in s&&s.geometry&&i.push(oc(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof pm){if(!c.objectForSample)return c.object.dataPatched.physics.fusedBody===!0&&c.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(c.objectForSample.dataPatched.physics.fusedBody)return;m=c.object}else if(c instanceof _l)m=c.object;else if(m=c,c.dataPatched.cloner?.hideBase)return!0;let f=m.dataPatched;if(!f.visible&&f.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(oc(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof pm)return;n=s instanceof _l?s.object:s;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!n.userData.navmesh)return;let o=s.geometry,l=n.userData.hasDestroy===!0,u=n.userData.hasDrag===!0;if(_5(a)||l||u||n.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(oc(o,s.matrixWorld))},this.navmeshWasm=P_t,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?bRt(E_t??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build/"):`
|
|
5103
5103
|
(async function() {
|
|
5104
5104
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
5105
5105
|
import(self.location.origin + '/_libraries/navmesh.js'),
|
|
@@ -5174,7 +5174,7 @@ onmessage = function(messageEvent) {
|
|
|
5174
5174
|
[${IR}] { pointer-events: none; }
|
|
5175
5175
|
[${IR}] > * { pointer-events: auto; }
|
|
5176
5176
|
[${IR}] [data-spline-passthrough] { pointer-events: none; }
|
|
5177
|
-
`,rxt=class{constructor(t,e,i,r,s,n){this.container=t,this.host=e,this.observer=i,this.spline=r,this.previousSplineGlobal=s,this.removeLateLifecycleShim=n}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("div");n.setAttribute(IR,"");let a=n.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(s);let u=document.createElement("style");u.textContent=J5t,n.appendChild(u);let h=new DOMParser().parseFromString(i,"text/html"),d=Array.from(h.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(h.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;h.body.firstChild;)n.appendChild(h.body.firstChild);s.insertBefore(n,e.nextSibling);let c=new Map,p=new Q7(ext(t,e,r),(v,b)=>{v==="warn"?console.warn(`[spline html] ${b}`):v==="error"&&console.error(`[spline html] ${b}`)},(v,b)=>{let _=c.get(v);if(_)for(let x of _)try{x(b)}catch(S){console.error(S)}}),m=(v,b)=>{try{return Promise.resolve(p.execute(v,b))}catch(_){return Promise.reject(_)}},f={ready:Promise.resolve(),setVariable:(v,b)=>m("setVariable",[v,b]),setVariables:v=>m("setVariables",[v]),getVariable:v=>m("getVariable",[v]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:v=>m("findObjectByName",[v]),findObjectById:v=>m("findObjectById",[v]),getGeometry:(v,b)=>m("getGeometry",[v,b??{}]),updateObject:(v,b)=>m("updateObject",[v,b]),createObject:(v,b)=>m("createObject",[v,b??{}]),createCustomMaterial:v=>m("createCustomMaterial",[v]),getTexture:(v,b)=>m("getTexture",[v,b??{}]),setMaterial:(v,b)=>m("setMaterial",[v,b]),cloneObject:(v,b)=>m("cloneObject",[v,b??{}]),removeObject:v=>m("removeObject",[v]),spawnObject:(v,b)=>m("spawnObject",[v,b??{}]),destroyObject:v=>m("destroyObject",[v]),setInstanceTransforms:(v,b)=>m("setInstanceTransforms",[v,b??null]),emitEvent:(v,b)=>m("emitEvent",[v,b]),emitEventReverse:(v,b)=>m("emitEventReverse",[v,b]),requestRender:()=>m("requestRender",[]),addEventListener:(v,b)=>{if(typeof b!="function")return;let _=c.get(v);_||(_=new Set,c.set(v,_),m("listenEvent",[v])),_.add(b)},removeEventListener:(v,b)=>{let _=c.get(v);!_||(_.delete(b),_.size===0&&(c.delete(v),m("unlistenEvent",[v])))}},g=window.spline;window.spline=f;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],b=(x,S)=>{let w=new Set,T=x.addEventListener.bind(x),C=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{if(T(M,A,R),!S.includes(M)||A==null)return;let O={type:M,listener:A};w.add(O),queueMicrotask(()=>{!w.delete(O)||((N,B,L)=>{let z=new Event(L);try{typeof B=="function"?B.call(N,z):B.handleEvent?.(z)}catch(k){console.error(k)}})(x,O.listener,O.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{C(M,A,R);for(let O of w)O.type===M&&O.listener===A&&w.delete(O)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,w.clear()})};b(document,["DOMContentLoaded"]),b(window,["load"]);let _=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(S){console.error(S)}})}}),v.push(()=>{_?Object.defineProperty(window,"onload",_):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of d){let b=document.createElement("script");for(let _ of Array.from(v.attributes))b.setAttribute(_.name,_.value);v.src?b.async=!1:b.textContent=v.textContent,n.appendChild(b)}return new rxt(n,p,l,f,g,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function sxt(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function sct(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(!sxt(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=nj()?.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}}ke(),Fi(),dt(),zgt(),Dc(),Fi(),ke(),c3t(),Tm();var tDt=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),nct="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",eDt={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"},iDt={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},rDt={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')."},sDt={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"},nDt={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function $S(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 nxt(t){return typeof t=="number"?[t,t,t]:$S(t,[1,1,1])}function V7(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function act(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return cs.defaultColorMaterial(oct(Jg),"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)||ae.NAMES[o]!==void 0}(i))return cs.defaultColorMaterial(V7(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(sxt(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 r=i.color!==void 0?V7(i.color):oct(Jg),s=cs.defaultColorMaterial(r,"physical","layer1","layer2"),n=s.layers.find(a=>a.data.type==="light");if(n){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(n.data,a)}if(i.alpha!==void 0){let a=s.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return s}function oct(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function aDt(t){let e=hc.defaultData("TextGeometry"),{text:i,...r}=t,s=r.fontSize;return s!==void 0&&r.width===void 0&&(r.width=350*s/16),s!==void 0&&r.height===void 0&&(r.height=50*s/16),Object.assign(e,r),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function cP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function oDt(t,e){return hft({userData:{type:t,...rj[t].normalizeInputs({parameters:e})}})}function lDt(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let u={};for(let[h,d]of Object.entries(l))!tDt.has(h)&&d!==void 0&&(u[h]=d);return u}(e),a={states:new ye,events:new ye};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:u}=function(h){let d=cP(h.vertices);if(!d||d.length<9||d.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 c=d.length/3;if(c>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${c}); keep it under 60000.`);let p=cP(h.indices);if(p&&p.length){let b=p.find(_=>!Number.isInteger(_)||_<0||_>=c);if(b!==void 0)throw new Error(`createObject('CustomMesh'): index ${b} is out of range (mesh has ${c} vertices).`)}else p=null;let m=new ge;m.setAttribute("position",new fe(d,3));let f=cP(h.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new fe(f,3));let y=cP(h.uvs);y&&y.length===2*c&&m.setAttribute("uv",new fe(y,2));let v=!1;if(!g){let b=p??Array.from({length:c},(S,w)=>w),{closed:_,inverted:x}=function(S,w){let T=S.length/3,C=new Map,M=new Array(T);for(let N=0;N<T;N++){let B=`${Math.round(1e4*S[3*N])},${Math.round(1e4*S[3*N+1])},${Math.round(1e4*S[3*N+2])}`,L=C.get(B);L===void 0?(C.set(B,N),M[N]=N):M[N]=L}let A=new Map;for(let N=0;N+2<w.length;N+=3){let B=M[w[N]],L=M[w[N+1]],z=M[w[N+2]];for(let[k,V]of[[B,L],[L,z],[z,B]]){if(k===V)continue;let H=k<V?k+"_"+V:V+"_"+k;A.set(H,(A.get(H)??0)+1)}}let R=A.size>0;for(let N of A.values())if(N!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let O=0;for(let N=0;N+2<w.length;N+=3){let B=3*w[N],L=3*w[N+1],z=3*w[N+2],k=S[B],V=S[B+1],H=S[B+2],W=S[L],X=S[L+1],st=S[L+2],nt=S[z],xt=S[z+1],pt=S[z+2];O+=k*(X*pt-st*xt)+V*(st*nt-W*pt)+H*(W*xt-X*nt)}return{closed:!0,inverted:O<0}}(d,b);if(_&&x){for(let S=0;S+2<b.length;S+=3){let w=b[S+1];b[S+1]=b[S+2],b[S+2]=w}p=b}else _||(v=!0)}return p&&m.setIndex(p),g||m.computeVertexNormals(),{geometry:hft({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,Bu.defaultData,{geometry:l,materials:[act(e,i)]}),u&&(a.side=2)}else Object.assign(a,Bu.defaultData,{geometry:s==="TextGeometry"?aDt(n):oDt(s,n),material:act(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,y4.defaultData):(Object.assign(a,v4.defaultData(r),n),e.color!==void 0&&(a.color=V7(e.color)));a.visible=e.visible??!0,a.position=$S(e.position,[0,0,0]),a.rotation=$S(e.rotation,[0,0,0]),a.scale=nxt(e.scale);let o=(s&&sDt[s])??nDt[r]??r;return a.name=e.name??axt(o,i.scene.objects),a}function axt(t,e){let i=new Set;if(e.traverse((s,n)=>{i.add(n.name??"")}),!i.has(t))return t;let r=2;for(;i.has(`${t} ${r}`);)r++;return`${t} ${r}`}function oxt(t,e){let i=qt.generateUUID();if(t.data.type==="Component")return{data:{...vc.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let r=t.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:r.animations.map(([s,n,a])=>{let o=qt.generateUUID(),l=a.indexOf(s);return[o,n,l!==-1?a.slice(0,l)+o+a.slice(l+s.length):a]})}),{...t,id:i,data:r,children:t.children.map(s=>oxt(s,e))}}function hDt(t){let e={};return function(i,r){return av(i,r,null)??i}(oxt(t,e),e)}function uDt(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(dDt)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function dDt(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}Tm(),ns(),CG(),Dc();var Pw=new Dr(0,0,0,1),cDt={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:[]};ke(),ke();var pDt=new Q;function lct(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var lxt=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:n="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<dft?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),i0(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=pDt.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=CS(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=n,this.renderMode=e?"auto":i,r!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(r)),this._rendererBackend=s??"webgl",s===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=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"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(()=>(JAt(),f1t)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",I$,!0),a.addEventListener("pointerdown",fM,!0),a.addEventListener("pointermove",fM,!0),a.addEventListener("pointerup",V0,!0),a.addEventListener("pointercancel",V0,!0),a.addEventListener("pointerleave",V0,!0),window.addEventListener("keydown",B$,!0),window.addEventListener("keyup",V$,!0)}(t)}async _initRenderer(){if(this.disposed)return null;let t=await this._createRenderer();return this.disposed?(this._disposeRenderer(t),null):t}_disposeRenderer(t){let e=function(r){let s=r.backend;if(s!==void 0)return s.isWebGLBackend===!0?s.gl??null:null;let n=r.getContext,a=typeof n=="function"?n.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(t);if(e&&!function(r,s){return ict.get(r)===s}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(t)||t.dispose());let i=e?function(r,s){let n=s.getExtension("WEBGL_lose_context");if(!n||s.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=rct(r,"webglcontextlost",u=>{u.preventDefault(),l(n)})});return hP.set(r,{gl:s,lost:o,stopListening:a}),()=>{s.isContextLost()||n.loseContext()}}(this.canvas,e):void 0;try{t.dispose()}finally{i?.()}}async _createRenderer(){if(function(t,e){ict.set(t,e)}(this.canvas,this),await async function(t){let e=hP.get(t);if(e&&(e.restoring??(e.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let s,n=()=>{},a=r.lost.then(l=>new Promise(u=>{n=rct(i,"webglcontextrestored",()=>u()),l.restoreContext()})),o=new Promise(l=>{s=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(s),n(),r.stopListening()}(t,e).finally(()=>{e.restoring=void 0,!e.gl.isContextLost()&&hP.get(t)===e&&hP.delete(t)})),await e.restoring,e.gl.isContextLost()))throw new Error("[spline] The browser did not restore the WebGL context this canvas had before dispose(); the scene cannot render on it. Use a new canvas.")}(this.canvas),this._rendererBackend==="webgpu"&&this._rendererAuto)try{await navigator.gpu?.requestAdapter()||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if(this._rendererBackend==="webgpu")try{let{createWebGPUSplineRenderer:t,isWebGPUSupported:e}=await Promise.resolve().then(()=>(rF(),PR));e();let i=!0,r=!1,s=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let a=new URLSearchParams(window.location.search),o=a.get("bundles");o==="rerecord"?i="rerecord":(o==="off"||o==="0"||o==="false"||o==="no")&&(i=!1),r=a.get("forcegl")==="1";let l=a.get("asynccomp");l==="off"||l==="0"||l==="false"||l==="no"?s=!1:(l==="on"||l==="1"||l==="true"||l==="always")&&(s=!0)}catch{}let n=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&s});return n.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},n.skyAnimationAllowed=!0,n}catch(t){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",t),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_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 r=this.canvas.getContext("2d");r&&(r.scale(t,t),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.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(s){let n="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";s.endsWith(".spline")?console.warn(n+" The .spline files are only meant to be used by the Editor."):s.endsWith(".splinecode")||console.warn(n)})(t),this.disposed=!1;let r=await(await fetch(t,i)).arrayBuffer();await this.start(r,{variables:e})}async start(t,{interactive:e=!0,variables:i}={}){if(this.disposed)return;Bs.init();let r=await async function(c){let[p,m]=Ww(ES.deserialize(new Uint8Array(c)));if((p.schema??0)!==132){let{updateDocumentSchema:f}=await Promise.resolve().then(()=>(V5(),Jmt));f(p)}return m.result().data}(t);this._data=r;let s=function(c){let p=[];return c.scene.objects.traverse((m,f)=>{f.type==="Mesh"&&f.geometry.type==="NonParametricGeometry"&&f.geometry.data.draco!==void 0&&p.push(f)}),p}(r);r.version&&(0,Z5t.default)(r.version,"2.0.80")>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(c){q0t=c}(this._wasmPath));let n=async function(){}();await Promise.all([n,s.length&&Jdt(this._wasmPath),GK(r)&&_3t(this._wasmPath),j3t(r)&&U3t(this._wasmPath),dAt(r)&&Y3t(this._wasmPath),e0.physicsEnabled(r.scene.objects)&&iRt(this._wasmPath),WY(r)&&Iut(),uZ(r)&&OAt(),R3t(r)&&P3t(),Aut(r)&&n.then(()=>RU()?.loadHanaUIRUNTIME()),YPt(r)&&vRt(this._wasmPath)].filter(Boolean)),s.length&&await tct(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=r.scene.publish.renderer;if(this._rendererAuto&&a==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&a==="webgpu"){if(this._rendererBackend!=="webgpu"||!await navigator.gpu?.requestAdapter().catch(()=>null))return void this._failWebGPURequired();this._rendererAuto=!1}let o=function(c){let p=new Set;return c.scene.objects.traverse((m,f)=>{if(f.type!=="Page")return;let g=f.postprocessing;if(g&&typeof g=="object"&&g.enabled===!0)for(let[y,v]of Object.entries(g))y!=="enabled"&&v&&typeof v=="object"&&v.enabled===!0&&p.add(y)}),[...p]}(r);if(this._rendererBackend==="webgpu")try{if(await Promise.all([Promise.resolve().then(()=>(rF(),PR)),K5t(o)]),!this._renderer){let c=await this._initRenderer();if(!c)return;this._renderer=c}}catch(c){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",c),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(c){rT=c})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let l=new q5t(r);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:c}=await Promise.resolve().then(()=>(IEt(),Fbt)),p=performance.now();c(r,l.scene);let m=performance.now();console.log("Merged geometries in ",m-p," ms")}GK(r)&&this._scene.traverse(c=>{Hu(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{$1(c)&&c.pendingMediaLoad&&c.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop()),i0(c)&&c.setPlayMode(!0)});let u=Object.keys(r.shared.fonts).flatMap(c=>{let p=this._sharedAssetsManager.getFont(c);return p?[p.loadingPromise]:[]});if(Promise.all(u).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),WY(r)&&function(c){if(e0.physicsEnabled(c.scene.objects))return!0;let p=!1;return c.scene.objects.traverse((m,f)=>{if(f.events){if(Array.isArray(f.events)){for(let g of f.events)if(g.data.disabled!==!0&&g.data.type==="GameControl"&&g.data.collisionEnabled){p=!0;break}}else for(let g of Object.values(f.events))if(g.disabled!==!0&&g.type==="GameControl"&&g.collisionEnabled){p=!0;break}}}),p}(r)&&await Promise.all(u),Aut(r)){let c=[];this._scene.traverseEntity(p=>{(Ya(p)||p instanceof Xs)&&p.uiCanvas&&c.push(p.uiCanvas)}),await Promise.all(c.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),JW(this._scene.activePage,this._sharedAssetsManager),!this._renderer){let c=await this._initRenderer();if(!c)return;this._renderer=c}if(!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let c=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(c()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let m=this._sharedAssetsManager.getImage("SplineWatermark");await m.loadPromise;let f=m.getTexture(1001);this._renderer.pipeline.setWatermark(f)}}uZ(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let h=Object.values(r.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 fPt(this._renderer,this._camera,new Q(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),e){let c=new XEt(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new aRt(c),this._animationControls=new X5t(this._scene,this._requestRenderAutoMode),this._eventManager=new hPt(r.scene.publish,this._controls,this._animationControls,c,r.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),e&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let d=r.scene.publish.htmlContent?.html;if(e&&d&&this._htmlContentMode!=="none"){let c={shared:this._sharedAssetsManager,findEntity:p=>this._scene?.getObjectByProperty("uuid",p)??this._scene?.getObjectByName(p)};this._htmlContentOverlay=(this._htmlContentMode==="inline"?rxt.mount(this,this.canvas,d,c):ixt.mount(this,this.canvas,d,c))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,r]of e)this.setVariable(i,r)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){if(e==null)return void console.warn(`Variable ${t} was not updated: received ${e}. Pass a number, boolean or string.`);let r=e;if(typeof i.data.value=="number"){if(r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e),!Number.isFinite(r))return void console.warn(`Variable ${t} is a number variable and ${JSON.stringify(e)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),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"&&Na.isTextValue(t)?Na.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===n0||this._scene.isInvisibleObjects(e)||e instanceof Xs)){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 i_t&&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=lct(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,X2&&X2.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{sF.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer&&this._disposeRenderer(this._renderer),this._renderer=void 0,this._rendererConfigured=!1,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",I$,!0),t.removeEventListener("pointerdown",fM,!0),t.removeEventListener("pointermove",fM,!0),t.removeEventListener("pointerup",V0,!0),t.removeEventListener("pointercancel",V0,!0),t.removeEventListener("pointerleave",V0,!0),window.removeEventListener("keydown",B$,!0),window.removeEventListener("keyup",V$,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Bs.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 Xs&&(e=h.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=h=>{if(h===null||h==="Base State")return null;if(h&&t.data.states){let d=t.data.states.find(c=>c.data.name===h);return d?d.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?uDt(a):void 0),parentUuid:t.parent instanceof Xs||t instanceof Ng?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,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let h=t.stateSelection;if(h!==null)return t.data.states.find(({id:d})=>d===h)?.data.name},set state(h){let d;if(h!==void 0){let c=typeof h=="string"?t.data.states.find(({id:p})=>p===h):t.data.states[h];if(c)d=c.id;else{let p=typeof h=="string"?n(h):void 0;p&&(d=p)}}t.changeSelectedState(d??null,s),t.currentState=d??null,t.dispatchEvent({type:"completeState",state:d??null}),s.shared.requestRender()},transition(h){let d=txt;if(d===null)return Nn("transitions","obj.transition()"),{transition(_){return this},play(){return this},pause(){return this},reset(){return this},seek(_){return this}};let c,p,m=this,f=[],g=!1,y=()=>{p=new z_t({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Bs.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let C=n(_);C===void 0&&(C=c);let M=n(x);return c=M,f.push(new d(t,C,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?em.defaultData:T.easing===5?Ov.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&C||_==="Base State"&&!C)&&(m.state=C??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Bs.time),p.isPlaying&&Bs.add(v),this):this},pause(){return p?.stop(),Bs.remove(v),this},reset(){return this.pause(),g=!1,y(),p?.seek(0),this},seek(_){let x=f.reduce((S,w)=>S+w.runner.duration,0);return x>0&&p?.seek(_/1e3/x),this}};return b.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(h){let d=lct(h);if(z4.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof yo))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=t.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(h),s.shared.requestRender()))}let m=Array.isArray(t.material)?t.material[0]:t.material,f=m.data.layers.find(g=>g.data.type==="color")?.id;if(f)m.updateByOp({type:0,path:["layers",f],props:{color:{...c}}},m.data,s);else{let g=m.data,y=g.layers.find(w=>w.data.type==="light");if(!y)return;let v=g.layers.indexOf(y)===0?y:null,b=g.layers.at(v?g.layers.indexOf(v)+1:0),_={type:4,fi:v?v.fi+(b?(b.fi-v.fi)/2:1):b?b.fi/2:1,id:qt.generateUUID(),data:{...Hs.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(v?.id??null,1),S=g.layers.runOp({..._,fi:x[0]}).data;Object.assign(m.data,{layers:S}),m.updateByOp({..._,path:["layers"]},m.data,s)}}},u=sF(l,(h,d)=>{let c=t[h],p=function(m){return m.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(m,f,g){let y=Array.isArray(g)?g[0]:g;if(m[0]==="layers"){let v=parseInt(m[1]),b=y.layers[v],_=m[2];b&&_&&function(x,S,w){let T=x[0];try{if(function(C,M){return!!cDt[M]?.includes(C)}(T,w.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let C=parseInt(x[1]),M=w.getValue(T)?.[C];if(!M)throw new Error("Color index out of range");Pw.setStyle(S),M.set(Pw.r,Pw.g,Pw.b,Pw.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let C=w.color;(function(M,A,R,O){let N=M[0];if(N==="repeat"||N==="offset"||N==="rotation"){let B=O.getNode("mat"),L=B&&typeof B.updateMatrix=="function"?B:O.getValue("mat");if(!L)return;if(N==="rotation")L.rotation=parseFloat(A);else{let z=M[1];if(z===void 0)A instanceof Array&&A.length===2&&Object.assign(L,{[N]:A});else{let k=L[N],V=parseInt(z)===0?[parseFloat(A),k[1]]:[k[0],parseFloat(A)];Object.assign(L,{[N]:V})}}L.updateMatrix()}else N==="wrapping"||N==="minFilter"||N==="magFilter"?N==="wrapping"?R.texture.wrap=A:R.texture[N]=A:N==="image"&&M[1]==="data"&&R.texture.image.updateSrc(A)})(x.slice(1),S,C,w)}else{let C=x[1],M=w.getValue(T);M?.isVector3&&C!==void 0||M?.isVector2&&C!==void 0?M.setComponent(parseInt(C),S):w.setValue(T,S)}}catch(C){console.error("Error setting material value",C)}}(m.slice(2),f,b)}else m[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=f,f<1&&(y.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(t,h)?.writable&&(t[h]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,u),u}setUIWasmUrl(t){(function(e){A4=e,F5?.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 r=ES.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await Jdt(this._wasmPath);let n=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!n)return void console.warn(`Object ${t} not found`);if(n.data.type!=="Mesh"||!(n instanceof yo))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await tct([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 u={...l.data};a.states||(a.states={}),a.states[l.id]=rm.patch(o,u)}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=nj();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(rF(),PR)),e=nj()),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 r=typeof t=="string"?t:t.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(s instanceof yo))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let n=typeof e=="function"?await this.createCustomMaterial(e):e;if(V4()!=="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=sct({material:n});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let s=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${nct}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=iDt[y];if(v)return{objectType:v};let b=eDt[y];if(b)return{objectType:"Mesh",geometryType:b};let _=rDt[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${nct}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let n,a,{options:o,material:l}=sct(e);if(l!==void 0){if(s.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(V4()!=="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(s.geometryType==="TextGeometry"){if(!vG.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 Iut(),a=e.font??M1,r.shared.fonts[a]===void 0){if(a!==M1){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}n={name:M1,url:Bmt}}}let u=this._resolveParentId(e.parent),h=lDt(s,o,r),d=qt.generateUUID(),[c,p]=Ww(r);n&&(c.shared.fonts[M1]=n),c.scene.objects.insertAfter(u,null,[{id:d,data:h,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(M1,n),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(m);let f=i.find(d);return l!==void 0&&f.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(f)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let s=typeof t=="string"?t:t?.uuid,n=s?this._findEntity(s):void 0;if(!n)throw new Error(`cloneObject: '${s}' \u2014 no object with that name or uuid in the scene.`);if(n instanceof Xs)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(n.uuid);if(!a)throw new Error(`cloneObject: '${s}' 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,m,f){let g={...p.data};return m.position!==void 0&&(g.position=$S(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=$S(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=nxt(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??axt(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(hDt(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,u=e.parent!==void 0?null:n.uuid,[h,d]=Ww(r);h.scene.objects.insertAfter(l,u,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof Xs)throw new Error("removeObject: pages cannot be removed.");if(s.data.type==="PerspectiveCamera"||s.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(s.uuid)===void 0)throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let n=[];s.traverseEntity(l=>{n.push(l.uuid)});let[a,o]=Ww(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let u=this._proxyObjectCache.get(l);u&&(sF.unsubscribe(u),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var vD=window,bD=vD.ShadowRoot&&(vD.ShadyCSS===void 0||vD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,tq=Symbol(),hxt=new WeakMap,pT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==tq)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(bD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=hxt.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&hxt.set(i,e))}return e}toString(){return this.cssText}},uxt=t=>new pT(typeof t=="string"?t:t+"",void 0,tq),eq=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((r,s,n)=>r+(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.")})(s)+t[n+1],t[0]);return new pT(i,t,tq)},iq=(t,e)=>{bD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=vD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},_D=bD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return uxt(i)})(t):t;var rq,xD=window,dxt=xD.trustedTypes,mDt=dxt?dxt.emptyScript:"",cxt=xD.reactiveElementPolyfillSupport,nq={toAttribute(t,e){switch(e){case Boolean:t=t?mDt: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}},pxt=(t,e)=>e!==t&&(e==e||t==t),sq={attribute:!0,type:String,converter:nq,reflect:!1,hasChanged:pxt},aq="finalized",Oc=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,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),e.push(s))}),e}static createProperty(e,i=sq){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,i);s!==void 0&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,i,r){return{get(){return this[i]},set(s){let n=this[e];this[i]=s,this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||sq}static finalize(){if(this.hasOwnProperty(aq))return!1;this[aq]=!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,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)i.unshift(_D(s))}else e!==void 0&&i.push(_D(e));return i}static _$Ep(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r: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,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.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 iq(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 r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EO(e,i,r=sq){var s;let n=this.constructor._$Ep(e,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:nq).toAttribute(i,r.type);this._$El=e,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(e,i){var r;let s=this.constructor,n=s._$Ev.get(e);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:nq;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,r){let s=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||pxt)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(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((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(e=this._$ES)===null||e===void 0||e.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),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,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Oc[aq]=!0,Oc.elementProperties=new Map,Oc.elementStyles=[],Oc.shadowRootOptions={mode:"open"},cxt?.({ReactiveElement:Oc}),((rq=xD.reactiveElementVersions)!==null&&rq!==void 0?rq:xD.reactiveElementVersions=[]).push("1.6.3");var oq,wD=window,ab=wD.trustedTypes,mxt=ab?ab.createPolicy("lit-html",{createHTML:t=>t}):void 0,hq="$lit$",Am=`lit$${(Math.random()+"").slice(9)}$`,xxt="?"+Am,fDt=`<${xxt}>`,c0=document,fT=()=>c0.createComment(""),gT=t=>t===null||typeof t!="object"&&typeof t!="function",wxt=Array.isArray,gDt=t=>wxt(t)||typeof t?.[Symbol.iterator]=="function",lq=`[
|
|
5177
|
+
`,rxt=class{constructor(t,e,i,r,s,n){this.container=t,this.host=e,this.observer=i,this.spline=r,this.previousSplineGlobal=s,this.removeLateLifecycleShim=n}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("div");n.setAttribute(IR,"");let a=n.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(s);let u=document.createElement("style");u.textContent=J5t,n.appendChild(u);let h=new DOMParser().parseFromString(i,"text/html"),d=Array.from(h.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(h.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;h.body.firstChild;)n.appendChild(h.body.firstChild);s.insertBefore(n,e.nextSibling);let c=new Map,p=new Q7(ext(t,e,r),(v,b)=>{v==="warn"?console.warn(`[spline html] ${b}`):v==="error"&&console.error(`[spline html] ${b}`)},(v,b)=>{let _=c.get(v);if(_)for(let x of _)try{x(b)}catch(S){console.error(S)}}),m=(v,b)=>{try{return Promise.resolve(p.execute(v,b))}catch(_){return Promise.reject(_)}},f={ready:Promise.resolve(),setVariable:(v,b)=>m("setVariable",[v,b]),setVariables:v=>m("setVariables",[v]),getVariable:v=>m("getVariable",[v]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:v=>m("findObjectByName",[v]),findObjectById:v=>m("findObjectById",[v]),getGeometry:(v,b)=>m("getGeometry",[v,b??{}]),updateObject:(v,b)=>m("updateObject",[v,b]),createObject:(v,b)=>m("createObject",[v,b??{}]),createCustomMaterial:v=>m("createCustomMaterial",[v]),getTexture:(v,b)=>m("getTexture",[v,b??{}]),setMaterial:(v,b)=>m("setMaterial",[v,b]),cloneObject:(v,b)=>m("cloneObject",[v,b??{}]),removeObject:v=>m("removeObject",[v]),spawnObject:(v,b)=>m("spawnObject",[v,b??{}]),destroyObject:v=>m("destroyObject",[v]),setInstanceTransforms:(v,b)=>m("setInstanceTransforms",[v,b??null]),emitEvent:(v,b)=>m("emitEvent",[v,b]),emitEventReverse:(v,b)=>m("emitEventReverse",[v,b]),requestRender:()=>m("requestRender",[]),addEventListener:(v,b)=>{if(typeof b!="function")return;let _=c.get(v);_||(_=new Set,c.set(v,_),m("listenEvent",[v])),_.add(b)},removeEventListener:(v,b)=>{let _=c.get(v);!_||(_.delete(b),_.size===0&&(c.delete(v),m("unlistenEvent",[v])))}},g=window.spline;window.spline=f;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],b=(x,S)=>{let w=new Set,T=x.addEventListener.bind(x),C=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{if(T(M,A,R),!S.includes(M)||A==null)return;let O={type:M,listener:A};w.add(O),queueMicrotask(()=>{!w.delete(O)||((N,B,L)=>{let z=new Event(L);try{typeof B=="function"?B.call(N,z):B.handleEvent?.(z)}catch(k){console.error(k)}})(x,O.listener,O.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{C(M,A,R);for(let O of w)O.type===M&&O.listener===A&&w.delete(O)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,w.clear()})};b(document,["DOMContentLoaded"]),b(window,["load"]);let _=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(S){console.error(S)}})}}),v.push(()=>{_?Object.defineProperty(window,"onload",_):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of d){let b=document.createElement("script");for(let _ of Array.from(v.attributes))b.setAttribute(_.name,_.value);v.src?b.async=!1:b.textContent=v.textContent,n.appendChild(b)}return new rxt(n,p,l,f,g,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function sxt(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function sct(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(!sxt(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=nj()?.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}}ke(),Fi(),dt(),zgt(),Dc(),Fi(),ke(),c3t(),Tm();var tDt=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),nct="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",eDt={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"},iDt={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},rDt={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')."},sDt={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"},nDt={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function $S(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 nxt(t){return typeof t=="number"?[t,t,t]:$S(t,[1,1,1])}function V7(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function act(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return cs.defaultColorMaterial(oct(Jg),"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)||ae.NAMES[o]!==void 0}(i))return cs.defaultColorMaterial(V7(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(sxt(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 r=i.color!==void 0?V7(i.color):oct(Jg),s=cs.defaultColorMaterial(r,"physical","layer1","layer2"),n=s.layers.find(a=>a.data.type==="light");if(n){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(n.data,a)}if(i.alpha!==void 0){let a=s.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return s}function oct(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function aDt(t){let e=hc.defaultData("TextGeometry"),{text:i,...r}=t,s=r.fontSize;return s!==void 0&&r.width===void 0&&(r.width=350*s/16),s!==void 0&&r.height===void 0&&(r.height=50*s/16),Object.assign(e,r),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function cP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function oDt(t,e){return hft({userData:{type:t,...rj[t].normalizeInputs({parameters:e})}})}function lDt(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let u={};for(let[h,d]of Object.entries(l))!tDt.has(h)&&d!==void 0&&(u[h]=d);return u}(e),a={states:new ye,events:new ye};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:u}=function(h){let d=cP(h.vertices);if(!d||d.length<9||d.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 c=d.length/3;if(c>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${c}); keep it under 60000.`);let p=cP(h.indices);if(p&&p.length){let b=p.find(_=>!Number.isInteger(_)||_<0||_>=c);if(b!==void 0)throw new Error(`createObject('CustomMesh'): index ${b} is out of range (mesh has ${c} vertices).`)}else p=null;let m=new ge;m.setAttribute("position",new fe(d,3));let f=cP(h.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new fe(f,3));let y=cP(h.uvs);y&&y.length===2*c&&m.setAttribute("uv",new fe(y,2));let v=!1;if(!g){let b=p??Array.from({length:c},(S,w)=>w),{closed:_,inverted:x}=function(S,w){let T=S.length/3,C=new Map,M=new Array(T);for(let N=0;N<T;N++){let B=`${Math.round(1e4*S[3*N])},${Math.round(1e4*S[3*N+1])},${Math.round(1e4*S[3*N+2])}`,L=C.get(B);L===void 0?(C.set(B,N),M[N]=N):M[N]=L}let A=new Map;for(let N=0;N+2<w.length;N+=3){let B=M[w[N]],L=M[w[N+1]],z=M[w[N+2]];for(let[k,V]of[[B,L],[L,z],[z,B]]){if(k===V)continue;let H=k<V?k+"_"+V:V+"_"+k;A.set(H,(A.get(H)??0)+1)}}let R=A.size>0;for(let N of A.values())if(N!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let O=0;for(let N=0;N+2<w.length;N+=3){let B=3*w[N],L=3*w[N+1],z=3*w[N+2],k=S[B],V=S[B+1],H=S[B+2],W=S[L],X=S[L+1],st=S[L+2],nt=S[z],xt=S[z+1],pt=S[z+2];O+=k*(X*pt-st*xt)+V*(st*nt-W*pt)+H*(W*xt-X*nt)}return{closed:!0,inverted:O<0}}(d,b);if(_&&x){for(let S=0;S+2<b.length;S+=3){let w=b[S+1];b[S+1]=b[S+2],b[S+2]=w}p=b}else _||(v=!0)}return p&&m.setIndex(p),g||m.computeVertexNormals(),{geometry:hft({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,Bu.defaultData,{geometry:l,materials:[act(e,i)]}),u&&(a.side=2)}else Object.assign(a,Bu.defaultData,{geometry:s==="TextGeometry"?aDt(n):oDt(s,n),material:act(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,y4.defaultData):(Object.assign(a,v4.defaultData(r),n),e.color!==void 0&&(a.color=V7(e.color)));a.visible=e.visible??!0,a.position=$S(e.position,[0,0,0]),a.rotation=$S(e.rotation,[0,0,0]),a.scale=nxt(e.scale);let o=(s&&sDt[s])??nDt[r]??r;return a.name=e.name??axt(o,i.scene.objects),a}function axt(t,e){let i=new Set;if(e.traverse((s,n)=>{i.add(n.name??"")}),!i.has(t))return t;let r=2;for(;i.has(`${t} ${r}`);)r++;return`${t} ${r}`}function oxt(t,e){let i=qt.generateUUID();if(t.data.type==="Component")return{data:{...vc.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let r=t.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:r.animations.map(([s,n,a])=>{let o=qt.generateUUID(),l=a.indexOf(s);return[o,n,l!==-1?a.slice(0,l)+o+a.slice(l+s.length):a]})}),{...t,id:i,data:r,children:t.children.map(s=>oxt(s,e))}}function hDt(t){let e={};return function(i,r){return av(i,r,null)??i}(oxt(t,e),e)}function uDt(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(dDt)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function dDt(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}Tm(),ns(),CG(),Dc();var Pw=new Dr(0,0,0,1),cDt={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:[]};ke(),ke();var pDt=new Q;function lct(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var lxt=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:n="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<dft?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),i0(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=pDt.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=CS(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=n,this.renderMode=e?"auto":i,r!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(r)),this._rendererBackend=s??"webgl",s===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=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"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(()=>(JAt(),f1t)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",I$,!0),a.addEventListener("pointerdown",fM,!0),a.addEventListener("pointermove",fM,!0),a.addEventListener("pointerup",V0,!0),a.addEventListener("pointercancel",V0,!0),a.addEventListener("pointerleave",V0,!0),window.addEventListener("keydown",B$,!0),window.addEventListener("keyup",V$,!0)}(t)}async _initRenderer(){if(this.disposed)return null;let t=await this._createRenderer();return this.disposed?(this._disposeRenderer(t),null):t}_disposeRenderer(t){let e=function(r){let s=r.backend;if(s!==void 0)return s.isWebGLBackend===!0?s.gl??null:null;let n=r.getContext,a=typeof n=="function"?n.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(t);if(e&&!function(r,s){return ict.get(r)===s}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(t)||t.dispose());let i=e?function(r,s){let n=s.getExtension("WEBGL_lose_context");if(!n||s.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=rct(r,"webglcontextlost",u=>{u.preventDefault(),l(n)})});return hP.set(r,{gl:s,lost:o,stopListening:a}),()=>{s.isContextLost()||n.loseContext()}}(this.canvas,e):void 0;try{t.dispose()}finally{i?.()}}async _createRenderer(){if(function(t,e){ict.set(t,e)}(this.canvas,this),await async function(t){let e=hP.get(t);if(e&&(e.restoring??(e.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let s,n=()=>{},a=r.lost.then(l=>new Promise(u=>{n=rct(i,"webglcontextrestored",()=>u()),l.restoreContext()})),o=new Promise(l=>{s=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(s),n(),r.stopListening()}(t,e).finally(()=>{e.restoring=void 0,!e.gl.isContextLost()&&hP.get(t)===e&&hP.delete(t)})),await e.restoring,e.gl.isContextLost()))throw new Error("[spline] The browser did not restore the WebGL context this canvas had before dispose(); the scene cannot render on it. Use a new canvas.")}(this.canvas),this._rendererBackend==="webgpu"&&this._rendererAuto)try{await navigator.gpu?.requestAdapter()||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if(this._rendererBackend==="webgpu")try{let{createWebGPUSplineRenderer:t,isWebGPUSupported:e}=await Promise.resolve().then(()=>(rF(),PR));e();let i=!0,r=!1,s=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let a=new URLSearchParams(window.location.search),o=a.get("bundles");o==="rerecord"?i="rerecord":(o==="off"||o==="0"||o==="false"||o==="no")&&(i=!1),r=a.get("forcegl")==="1";let l=a.get("asynccomp");l==="off"||l==="0"||l==="false"||l==="no"?s=!1:(l==="on"||l==="1"||l==="true"||l==="always")&&(s=!0)}catch{}let n=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&s});return n.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},n.skyAnimationAllowed=!0,n}catch(t){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",t),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_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 r=this.canvas.getContext("2d");r&&(r.scale(t,t),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.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(s){let n="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";s.endsWith(".spline")?console.warn(n+" The .spline files are only meant to be used by the Editor."):s.endsWith(".splinecode")||console.warn(n)})(t),this.disposed=!1;let r=await(await fetch(t,i)).arrayBuffer();await this.start(r,{variables:e})}async start(t,{interactive:e=!0,variables:i}={}){if(this.disposed)return;Bs.init();let r=await async function(c){let[p,m]=Ww(ES.deserialize(new Uint8Array(c)));if((p.schema??0)!==132){let{updateDocumentSchema:f}=await Promise.resolve().then(()=>(V5(),Jmt));f(p)}return m.result().data}(t);this._data=r;let s=function(c){let p=[];return c.scene.objects.traverse((m,f)=>{f.type==="Mesh"&&f.geometry.type==="NonParametricGeometry"&&f.geometry.data.draco!==void 0&&p.push(f)}),p}(r);r.version&&(0,Z5t.default)(r.version,"2.0.82")>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(c){q0t=c}(this._wasmPath));let n=async function(){}();await Promise.all([n,s.length&&Jdt(this._wasmPath),GK(r)&&_3t(this._wasmPath),j3t(r)&&U3t(this._wasmPath),dAt(r)&&Y3t(this._wasmPath),e0.physicsEnabled(r.scene.objects)&&iRt(this._wasmPath),WY(r)&&Iut(),uZ(r)&&OAt(),R3t(r)&&P3t(),Aut(r)&&n.then(()=>RU()?.loadHanaUIRUNTIME()),YPt(r)&&vRt(this._wasmPath)].filter(Boolean)),s.length&&await tct(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=r.scene.publish.renderer;if(this._rendererAuto&&a==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&a==="webgpu"){if(this._rendererBackend!=="webgpu"||!await navigator.gpu?.requestAdapter().catch(()=>null))return void this._failWebGPURequired();this._rendererAuto=!1}let o=function(c){let p=new Set;return c.scene.objects.traverse((m,f)=>{if(f.type!=="Page")return;let g=f.postprocessing;if(g&&typeof g=="object"&&g.enabled===!0)for(let[y,v]of Object.entries(g))y!=="enabled"&&v&&typeof v=="object"&&v.enabled===!0&&p.add(y)}),[...p]}(r);if(this._rendererBackend==="webgpu")try{if(await Promise.all([Promise.resolve().then(()=>(rF(),PR)),K5t(o)]),!this._renderer){let c=await this._initRenderer();if(!c)return;this._renderer=c}}catch(c){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",c),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(c){rT=c})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let l=new q5t(r);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:c}=await Promise.resolve().then(()=>(IEt(),Fbt)),p=performance.now();c(r,l.scene);let m=performance.now();console.log("Merged geometries in ",m-p," ms")}GK(r)&&this._scene.traverse(c=>{Hu(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{$1(c)&&c.pendingMediaLoad&&c.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop()),i0(c)&&c.setPlayMode(!0)});let u=Object.keys(r.shared.fonts).flatMap(c=>{let p=this._sharedAssetsManager.getFont(c);return p?[p.loadingPromise]:[]});if(Promise.all(u).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),WY(r)&&function(c){if(e0.physicsEnabled(c.scene.objects))return!0;let p=!1;return c.scene.objects.traverse((m,f)=>{if(f.events){if(Array.isArray(f.events)){for(let g of f.events)if(g.data.disabled!==!0&&g.data.type==="GameControl"&&g.data.collisionEnabled){p=!0;break}}else for(let g of Object.values(f.events))if(g.disabled!==!0&&g.type==="GameControl"&&g.collisionEnabled){p=!0;break}}}),p}(r)&&await Promise.all(u),Aut(r)){let c=[];this._scene.traverseEntity(p=>{(Ya(p)||p instanceof Xs)&&p.uiCanvas&&c.push(p.uiCanvas)}),await Promise.all(c.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),JW(this._scene.activePage,this._sharedAssetsManager),!this._renderer){let c=await this._initRenderer();if(!c)return;this._renderer=c}if(!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let c=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(c()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let m=this._sharedAssetsManager.getImage("SplineWatermark");await m.loadPromise;let f=m.getTexture(1001);this._renderer.pipeline.setWatermark(f)}}uZ(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let h=Object.values(r.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 fPt(this._renderer,this._camera,new Q(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),e){let c=new XEt(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new aRt(c),this._animationControls=new X5t(this._scene,this._requestRenderAutoMode),this._eventManager=new hPt(r.scene.publish,this._controls,this._animationControls,c,r.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),e&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let d=r.scene.publish.htmlContent?.html;if(e&&d&&this._htmlContentMode!=="none"){let c={shared:this._sharedAssetsManager,findEntity:p=>this._scene?.getObjectByProperty("uuid",p)??this._scene?.getObjectByName(p)};this._htmlContentOverlay=(this._htmlContentMode==="inline"?rxt.mount(this,this.canvas,d,c):ixt.mount(this,this.canvas,d,c))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,r]of e)this.setVariable(i,r)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){if(e==null)return void console.warn(`Variable ${t} was not updated: received ${e}. Pass a number, boolean or string.`);let r=e;if(typeof i.data.value=="number"){if(r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e),!Number.isFinite(r))return void console.warn(`Variable ${t} is a number variable and ${JSON.stringify(e)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),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"&&Na.isTextValue(t)?Na.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===n0||this._scene.isInvisibleObjects(e)||e instanceof Xs)){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 i_t&&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=lct(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,X2&&X2.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{sF.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer&&this._disposeRenderer(this._renderer),this._renderer=void 0,this._rendererConfigured=!1,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",I$,!0),t.removeEventListener("pointerdown",fM,!0),t.removeEventListener("pointermove",fM,!0),t.removeEventListener("pointerup",V0,!0),t.removeEventListener("pointercancel",V0,!0),t.removeEventListener("pointerleave",V0,!0),window.removeEventListener("keydown",B$,!0),window.removeEventListener("keyup",V$,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Bs.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 Xs&&(e=h.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=h=>{if(h===null||h==="Base State")return null;if(h&&t.data.states){let d=t.data.states.find(c=>c.data.name===h);return d?d.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?uDt(a):void 0),parentUuid:t.parent instanceof Xs||t instanceof Ng?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,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let h=t.stateSelection;if(h!==null)return t.data.states.find(({id:d})=>d===h)?.data.name},set state(h){let d;if(h!==void 0){let c=typeof h=="string"?t.data.states.find(({id:p})=>p===h):t.data.states[h];if(c)d=c.id;else{let p=typeof h=="string"?n(h):void 0;p&&(d=p)}}t.changeSelectedState(d??null,s),t.currentState=d??null,t.dispatchEvent({type:"completeState",state:d??null}),s.shared.requestRender()},transition(h){let d=txt;if(d===null)return Nn("transitions","obj.transition()"),{transition(_){return this},play(){return this},pause(){return this},reset(){return this},seek(_){return this}};let c,p,m=this,f=[],g=!1,y=()=>{p=new z_t({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Bs.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let C=n(_);C===void 0&&(C=c);let M=n(x);return c=M,f.push(new d(t,C,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?em.defaultData:T.easing===5?Ov.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&C||_==="Base State"&&!C)&&(m.state=C??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Bs.time),p.isPlaying&&Bs.add(v),this):this},pause(){return p?.stop(),Bs.remove(v),this},reset(){return this.pause(),g=!1,y(),p?.seek(0),this},seek(_){let x=f.reduce((S,w)=>S+w.runner.duration,0);return x>0&&p?.seek(_/1e3/x),this}};return b.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(h){let d=lct(h);if(z4.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof yo))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=t.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(h),s.shared.requestRender()))}let m=Array.isArray(t.material)?t.material[0]:t.material,f=m.data.layers.find(g=>g.data.type==="color")?.id;if(f)m.updateByOp({type:0,path:["layers",f],props:{color:{...c}}},m.data,s);else{let g=m.data,y=g.layers.find(w=>w.data.type==="light");if(!y)return;let v=g.layers.indexOf(y)===0?y:null,b=g.layers.at(v?g.layers.indexOf(v)+1:0),_={type:4,fi:v?v.fi+(b?(b.fi-v.fi)/2:1):b?b.fi/2:1,id:qt.generateUUID(),data:{...Hs.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(v?.id??null,1),S=g.layers.runOp({..._,fi:x[0]}).data;Object.assign(m.data,{layers:S}),m.updateByOp({..._,path:["layers"]},m.data,s)}}},u=sF(l,(h,d)=>{let c=t[h],p=function(m){return m.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(m,f,g){let y=Array.isArray(g)?g[0]:g;if(m[0]==="layers"){let v=parseInt(m[1]),b=y.layers[v],_=m[2];b&&_&&function(x,S,w){let T=x[0];try{if(function(C,M){return!!cDt[M]?.includes(C)}(T,w.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let C=parseInt(x[1]),M=w.getValue(T)?.[C];if(!M)throw new Error("Color index out of range");Pw.setStyle(S),M.set(Pw.r,Pw.g,Pw.b,Pw.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let C=w.color;(function(M,A,R,O){let N=M[0];if(N==="repeat"||N==="offset"||N==="rotation"){let B=O.getNode("mat"),L=B&&typeof B.updateMatrix=="function"?B:O.getValue("mat");if(!L)return;if(N==="rotation")L.rotation=parseFloat(A);else{let z=M[1];if(z===void 0)A instanceof Array&&A.length===2&&Object.assign(L,{[N]:A});else{let k=L[N],V=parseInt(z)===0?[parseFloat(A),k[1]]:[k[0],parseFloat(A)];Object.assign(L,{[N]:V})}}L.updateMatrix()}else N==="wrapping"||N==="minFilter"||N==="magFilter"?N==="wrapping"?R.texture.wrap=A:R.texture[N]=A:N==="image"&&M[1]==="data"&&R.texture.image.updateSrc(A)})(x.slice(1),S,C,w)}else{let C=x[1],M=w.getValue(T);M?.isVector3&&C!==void 0||M?.isVector2&&C!==void 0?M.setComponent(parseInt(C),S):w.setValue(T,S)}}catch(C){console.error("Error setting material value",C)}}(m.slice(2),f,b)}else m[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=f,f<1&&(y.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(t,h)?.writable&&(t[h]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,u),u}setUIWasmUrl(t){(function(e){A4=e,F5?.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 r=ES.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await Jdt(this._wasmPath);let n=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!n)return void console.warn(`Object ${t} not found`);if(n.data.type!=="Mesh"||!(n instanceof yo))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await tct([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 u={...l.data};a.states||(a.states={}),a.states[l.id]=rm.patch(o,u)}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=nj();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(rF(),PR)),e=nj()),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 r=typeof t=="string"?t:t.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(s instanceof yo))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let n=typeof e=="function"?await this.createCustomMaterial(e):e;if(V4()!=="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=sct({material:n});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let s=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${nct}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=iDt[y];if(v)return{objectType:v};let b=eDt[y];if(b)return{objectType:"Mesh",geometryType:b};let _=rDt[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${nct}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let n,a,{options:o,material:l}=sct(e);if(l!==void 0){if(s.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(V4()!=="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(s.geometryType==="TextGeometry"){if(!vG.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 Iut(),a=e.font??M1,r.shared.fonts[a]===void 0){if(a!==M1){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}n={name:M1,url:Bmt}}}let u=this._resolveParentId(e.parent),h=lDt(s,o,r),d=qt.generateUUID(),[c,p]=Ww(r);n&&(c.shared.fonts[M1]=n),c.scene.objects.insertAfter(u,null,[{id:d,data:h,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(M1,n),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(m);let f=i.find(d);return l!==void 0&&f.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(f)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let s=typeof t=="string"?t:t?.uuid,n=s?this._findEntity(s):void 0;if(!n)throw new Error(`cloneObject: '${s}' \u2014 no object with that name or uuid in the scene.`);if(n instanceof Xs)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(n.uuid);if(!a)throw new Error(`cloneObject: '${s}' 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,m,f){let g={...p.data};return m.position!==void 0&&(g.position=$S(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=$S(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=nxt(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??axt(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(hDt(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,u=e.parent!==void 0?null:n.uuid,[h,d]=Ww(r);h.scene.objects.insertAfter(l,u,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof Xs)throw new Error("removeObject: pages cannot be removed.");if(s.data.type==="PerspectiveCamera"||s.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(s.uuid)===void 0)throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let n=[];s.traverseEntity(l=>{n.push(l.uuid)});let[a,o]=Ww(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let u=this._proxyObjectCache.get(l);u&&(sF.unsubscribe(u),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var vD=window,bD=vD.ShadowRoot&&(vD.ShadyCSS===void 0||vD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,tq=Symbol(),hxt=new WeakMap,pT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==tq)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(bD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=hxt.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&hxt.set(i,e))}return e}toString(){return this.cssText}},uxt=t=>new pT(typeof t=="string"?t:t+"",void 0,tq),eq=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((r,s,n)=>r+(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.")})(s)+t[n+1],t[0]);return new pT(i,t,tq)},iq=(t,e)=>{bD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=vD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},_D=bD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return uxt(i)})(t):t;var rq,xD=window,dxt=xD.trustedTypes,mDt=dxt?dxt.emptyScript:"",cxt=xD.reactiveElementPolyfillSupport,nq={toAttribute(t,e){switch(e){case Boolean:t=t?mDt: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}},pxt=(t,e)=>e!==t&&(e==e||t==t),sq={attribute:!0,type:String,converter:nq,reflect:!1,hasChanged:pxt},aq="finalized",Oc=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,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),e.push(s))}),e}static createProperty(e,i=sq){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,i);s!==void 0&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,i,r){return{get(){return this[i]},set(s){let n=this[e];this[i]=s,this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||sq}static finalize(){if(this.hasOwnProperty(aq))return!1;this[aq]=!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,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)i.unshift(_D(s))}else e!==void 0&&i.push(_D(e));return i}static _$Ep(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r: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,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.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 iq(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 r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EO(e,i,r=sq){var s;let n=this.constructor._$Ep(e,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:nq).toAttribute(i,r.type);this._$El=e,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(e,i){var r;let s=this.constructor,n=s._$Ev.get(e);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:nq;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,r){let s=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||pxt)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(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((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(e=this._$ES)===null||e===void 0||e.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),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,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Oc[aq]=!0,Oc.elementProperties=new Map,Oc.elementStyles=[],Oc.shadowRootOptions={mode:"open"},cxt?.({ReactiveElement:Oc}),((rq=xD.reactiveElementVersions)!==null&&rq!==void 0?rq:xD.reactiveElementVersions=[]).push("1.6.3");var oq,wD=window,ab=wD.trustedTypes,mxt=ab?ab.createPolicy("lit-html",{createHTML:t=>t}):void 0,hq="$lit$",Am=`lit$${(Math.random()+"").slice(9)}$`,xxt="?"+Am,fDt=`<${xxt}>`,c0=document,fT=()=>c0.createComment(""),gT=t=>t===null||typeof t!="object"&&typeof t!="function",wxt=Array.isArray,gDt=t=>wxt(t)||typeof t?.[Symbol.iterator]=="function",lq=`[
|
|
5178
5178
|
\f\r]`,mT=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,fxt=/-->/g,gxt=/>/g,u0=RegExp(`>|${lq}(?:([^\\s"'>=/]+)(${lq}*=${lq}*(?:[^
|
|
5179
5179
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),yxt=/'/g,vxt=/"/g,Sxt=/^(?:script|style|textarea|title)$/i,Txt=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),Mxt=Txt(1),C9t=Txt(2),p0=Symbol.for("lit-noChange"),ha=Symbol.for("lit-nothing"),bxt=new WeakMap,d0=c0.createTreeWalker(c0,129,null,!1);function Axt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return mxt!==void 0?mxt.createHTML(e):e}var yDt=(t,e)=>{let i=t.length-1,r=[],s,n=e===2?"<svg>":"",a=mT;for(let o=0;o<i;o++){let l=t[o],u,h,d=-1,c=0;for(;c<l.length&&(a.lastIndex=c,h=a.exec(l),h!==null);)c=a.lastIndex,a===mT?h[1]==="!--"?a=fxt:h[1]!==void 0?a=gxt:h[2]!==void 0?(Sxt.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=u0):h[3]!==void 0&&(a=u0):a===u0?h[0]===">"?(a=s??mT,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,u=h[1],a=h[3]===void 0?u0:h[3]==='"'?vxt:yxt):a===vxt||a===yxt?a=u0:a===fxt||a===gxt?a=mT:(a=u0,s=void 0);let p=a===u0&&t[o+1].startsWith("/>")?" ":"";n+=a===mT?l+fDt:d>=0?(r.push(u),l.slice(0,d)+hq+l.slice(d)+Am+p):l+Am+(d===-2?(r.push(void 0),o):p)}return[Axt(t,n+(t[i]||"<?>")+(e===2?"</svg>":"")),r]},m0=class{constructor({strings:e,_$litType$:i},r){let s;this.parts=[];let n=0,a=0,o=e.length-1,l=this.parts,[u,h]=yDt(e,i);if(this.el=m0.createElement(u,r),d0.currentNode=this.el.content,i===2){let d=this.el.content,c=d.firstChild;c.remove(),d.append(...c.childNodes)}for(;(s=d0.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){let d=[];for(let c of s.getAttributeNames())if(c.endsWith(hq)||c.startsWith(Am)){let p=h[a++];if(d.push(c),p!==void 0){let m=s.getAttribute(p.toLowerCase()+hq).split(Am),f=/([.?@])?(.*)/.exec(p);l.push({type:1,index:n,name:f[2],strings:m,ctor:f[1]==="."?dq:f[1]==="?"?cq:f[1]==="@"?pq:lb})}else l.push({type:6,index:n})}for(let c of d)s.removeAttribute(c)}if(Sxt.test(s.tagName)){let d=s.textContent.split(Am),c=d.length-1;if(c>0){s.textContent=ab?ab.emptyScript:"";for(let p=0;p<c;p++)s.append(d[p],fT()),d0.nextNode(),l.push({type:2,index:++n});s.append(d[c],fT())}}}else if(s.nodeType===8)if(s.data===xxt)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(Am,d+1))!==-1;)l.push({type:7,index:n}),d+=Am.length-1}n++}}static createElement(e,i){let r=c0.createElement("template");return r.innerHTML=e,r}};function ob(t,e,i=t,r){var s,n,a,o;if(e===p0)return e;let l=r!==void 0?(s=i._$Co)===null||s===void 0?void 0:s[r]:i._$Cl,u=gT(e)?void 0:e._$litDirective$;return l?.constructor!==u&&((n=l?._$AO)===null||n===void 0||n.call(l,!1),u===void 0?l=void 0:(l=new u(t),l._$AT(t,i,r)),r!==void 0?((a=(o=i)._$Co)!==null&&a!==void 0?a:o._$Co=[])[r]=l:i._$Cl=l),l!==void 0&&(e=ob(t,l._$AS(t,e.values),l,r)),e}var uq=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:r},parts:s}=this._$AD,n=((i=e?.creationScope)!==null&&i!==void 0?i:c0).importNode(r,!0);d0.currentNode=n;let a=d0.nextNode(),o=0,l=0,u=s[0];for(;u!==void 0;){if(o===u.index){let h;u.type===2?h=new f0(a,a.nextSibling,this,e):u.type===1?h=new u.ctor(a,u.name,u.strings,this,e):u.type===6&&(h=new mq(a,this,e)),this._$AV.push(h),u=s[++l]}o!==u?.index&&(a=d0.nextNode(),o++)}return d0.currentNode=c0,n}v(e){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,i),i+=r.strings.length-2):r._$AI(e[i])),i++}},f0=class{constructor(e,i,r,s){var n;this.type=2,this._$AH=ha,this._$AN=void 0,this._$AA=e,this._$AB=i,this._$AM=r,this.options=s,this._$Cp=(n=s?.isConnected)===null||n===void 0||n}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=ob(this,e,i),gT(e)?e===ha||e==null||e===""?(this._$AH!==ha&&this._$AR(),this._$AH=ha):e!==this._$AH&&e!==p0&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):gDt(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!==ha&&gT(this._$AH)?this._$AA.nextSibling.data=e:this.$(c0.createTextNode(e)),this._$AH=e}g(e){var i;let{values:r,_$litType$:s}=e,n=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=m0.createElement(Axt(s.h,s.h[0]),this.options)),s);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===n)this._$AH.v(r);else{let a=new uq(n,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(e){let i=bxt.get(e.strings);return i===void 0&&bxt.set(e.strings,i=new m0(e)),i}T(e){wxt(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,s=0;for(let n of e)s===i.length?i.push(r=new f0(this.k(fT()),this.k(fT()),this,this.options)):r=i[s],r._$AI(n),s++;s<i.length&&(this._$AR(r&&r._$AB.nextSibling,s),i.length=s)}_$AR(e=this._$AA.nextSibling,i){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,i);e&&e!==this._$AB;){let s=e.nextSibling;e.remove(),e=s}}setConnected(e){var i;this._$AM===void 0&&(this._$Cp=e,(i=this._$AP)===null||i===void 0||i.call(this,e))}},lb=class{constructor(e,i,r,s,n){this.type=1,this._$AH=ha,this._$AN=void 0,this.element=e,this.name=i,this._$AM=s,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ha}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,i=this,r,s){let n=this.strings,a=!1;if(n===void 0)e=ob(this,e,i,0),a=!gT(e)||e!==this._$AH&&e!==p0,a&&(this._$AH=e);else{let o=e,l,u;for(e=n[0],l=0;l<n.length-1;l++)u=ob(this,o[r+l],i,l),u===p0&&(u=this._$AH[l]),a||(a=!gT(u)||u!==this._$AH[l]),u===ha?e=ha:e!==ha&&(e+=(u??"")+n[l+1]),this._$AH[l]=u}a&&!s&&this.j(e)}j(e){e===ha?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},dq=class extends lb{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ha?void 0:e}},vDt=ab?ab.emptyScript:"",cq=class extends lb{constructor(){super(...arguments),this.type=4}j(e){e&&e!==ha?this.element.setAttribute(this.name,vDt):this.element.removeAttribute(this.name)}},pq=class extends lb{constructor(e,i,r,s,n){super(e,i,r,s,n),this.type=5}_$AI(e,i=this){var r;if((e=(r=ob(this,e,i,0))!==null&&r!==void 0?r:ha)===p0)return;let s=this._$AH,n=e===ha&&s!==ha||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,a=e!==ha&&(s===ha||n);n&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var i,r;typeof this._$AH=="function"?this._$AH.call((r=(i=this.options)===null||i===void 0?void 0:i.host)!==null&&r!==void 0?r:this.element,e):this._$AH.handleEvent(e)}},mq=class{constructor(e,i,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ob(this,e)}};var _xt=wD.litHtmlPolyfillSupport;_xt?.(m0,f0),((oq=wD.litHtmlVersions)!==null&&oq!==void 0?oq:wD.litHtmlVersions=[]).push("2.8.0");var yT=(t,e,i)=>{var r,s;let n=(r=i?.renderBefore)!==null&&r!==void 0?r:e,a=n._$litPart$;if(a===void 0){let o=(s=i?.renderBefore)!==null&&s!==void 0?s:null;n._$litPart$=a=new f0(e.insertBefore(fT(),o),o,void 0,i??{})}return a._$AI(t),a};var fq,gq;var Cm=class extends Oc{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,i;let r=super.createRenderRoot();return(e=(i=this.renderOptions).renderBefore)!==null&&e!==void 0||(i.renderBefore=r.firstChild),r}update(e){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=yT(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 p0}};Cm.finalized=!0,Cm._$litElement$=!0,(fq=globalThis.litElementHydrateSupport)===null||fq===void 0||fq.call(globalThis,{LitElement:Cm});var Cxt=globalThis.litElementPolyfillSupport;Cxt?.({LitElement:Cm});((gq=globalThis.litElementVersions)!==null&&gq!==void 0?gq:globalThis.litElementVersions=[]).push("3.3.3");var Ext=t=>e=>typeof e=="function"?((i,r)=>(customElements.define(i,r),r))(t,e):((i,r)=>{let{kind:s,elements:n}=r;return{kind:s,elements:n,finisher(a){customElements.define(i,a)}}})(t,e);var bDt=(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)}},_Dt=(t,e,i)=>{e.constructor.createProperty(i,t)};function Tl(t){return(e,i)=>i!==void 0?_Dt(t,e,i):bDt(t,e)}var yq,t7t=((yq=window.HTMLSlotElement)===null||yq===void 0?void 0:yq.prototype.assignedElements)!=null?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter(i=>i.nodeType===Node.ELEMENT_NODE);var SD=window.IntersectionObserver!=null;var Pxt=(t=32,e=2)=>{let i=t/2;return Mxt` <style>
|
|
5180
5180
|
:host {
|