@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.
package/build/spline-viewer.cjs
CHANGED
|
@@ -4169,13 +4169,13 @@ void main() {
|
|
|
4169
4169
|
}
|
|
4170
4170
|
post({ kind: 'ready' });
|
|
4171
4171
|
}, 250);
|
|
4172
|
-
})();`}),Q1e=U(()=>{OX=class{constructor(e,t,i){this.deps=e,this.onConsole=t,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let e of this.eventUnsubs.values())e();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(e,t){let i=this.deps;switch(e){case"setVariable":{let r=i.setVariable(String(t[0]),t[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=t[0]??{},n=!0;for(let[s,a]of Object.entries(r)){let o=i.setVariable(s,a);o.warning&&this.onConsole("warn",o.warning),n=n&&o.ok}return n}case"getVariable":return i.getVariable(String(t[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(t[0]));case"getGeometry":{let r=i.getGeometry(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(t[0]),t[1]??{});case"createObject":return i.createObject(String(t[0]),t[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(t[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(t[0]),t[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(t[0]),t[1]);case"cloneObject":return i.cloneObject(String(t[0]),t[1]??{});case"removeObject":return i.removeObject(String(t[0]));case"spawnObject":{let r=i.spawnObject(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(t[0]));case"setInstanceTransforms":{let r=t[1]===null||t[1]===void 0?null:t[1],n=i.setInstanceTransforms(String(t[0]),r);return n<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(t[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),n}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(t[0]),String(t[1]),e==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(t[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,n=>{this.onEvent(r,n)})),!0}case"unlistenEvent":{let r=String(t[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${e}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let e=this.deps.getVariables(),t=function(i,r){let n=[];for(let s of Object.keys(r))i[s]!==r[s]&&n.push({name:s,value:r[s]});return n}(this.lastVariables??{},e);this.lastVariables=e;for(let i of t)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function VOe(e,t,i,r){return[e[0]*t+e[4]*i+e[8]*r+e[12],e[1]*t+e[5]*i+e[9]*r+e[13],e[2]*t+e[6]*i+e[10]*r+e[14]]}var GOe=U(()=>{}),J1e,jOe=U(()=>{}),WOe=U(()=>{LX(),Q1e(),J1e=class{constructor(e,t,i){this.iframe=e,this.deps=t,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 n=r.data;var s;typeof(s=n)!="object"||s===null||s[pg]!==!0||typeof s.kind!="string"||this.handleMessage(n)},this.host=new OX(t,i,(r,n)=>{this.sendEvent(r,n)})}attach(){window.addEventListener("message",this.onMessage),this.send({[pg]:!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(e){switch(e.kind){case"ready":this.handshakeSeen=!0,this.send({[pg]:!0,kind:"ready-ack"});break;case"console":this.onConsole(e.level,e.text);break;case"call":{let t;try{t=Promise.resolve(this.host.execute(e.method,e.args))}catch(i){t=Promise.reject(i)}t.then(i=>{this.send({[pg]:!0,kind:"result",id:e.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[pg]:!0,kind:"result",id:e.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(e.event)}}send(e){this.iframe.contentWindow?.postMessage(e,"*")}sendEvent(e,t){this.send({[pg]:!0,kind:"event",eventName:e,payload:t})}dispatchInput(e){let t=this.deps.getCanvas();if(!t)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey};switch(e.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":t.dispatchEvent(new PointerEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons,pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,movementX:e.movementX,movementY:e.movementY}));break;case"click":case"dblclick":t.dispatchEvent(new MouseEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons}));break;case"wheel":{let n=new WheelEvent("wheel",{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode});typeof e.wheelDeltaX=="number"&&Object.defineProperty(n,"wheelDeltaX",{value:e.wheelDeltaX}),typeof e.wheelDeltaY=="number"&&Object.defineProperty(n,"wheelDeltaY",{value:e.wheelDeltaY}),t.dispatchEvent(n);break}case"keydown":case"keyup":t.dispatchEvent(new KeyboardEvent(e.type,{...r,key:e.key,code:e.code,repeat:e.repeat}))}}}}),Gr=U(()=>{IX(),EOe(),AOe(),COe(),ROe(),DOe(),NOe(),IOe(),OOe(),LOe(),BOe(),zOe(),LX(),kOe(),Q1e(),GOe(),jOe(),WOe()}),HOe=U(()=>{});function e_e(e){return Array.isArray(e)?e:[e]}function aL(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var qOe=U(()=>{});function Wo(e,t){return Object.setPrototypeOf(e,t),e}function yU(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Ag(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],n=1/(i+1);for(let s=0;s<i;s++){let a=e+(t-e)*(s+.75+.5*Math.random())*n;r.push(a)}return r}function Qy(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}var $Oe=U(()=>{});function BX(e){if(e.deepFreeze!==void 0)return void e.deepFreeze(e);let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&BX(r)}return Object.freeze(e)}function t_e(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}var _U,oL,lW,si,FX,XOe=U(()=>{}),la=U(()=>{HOe(),qOe(),$Oe(),XOe()}),UX=U(()=>{_U=class{},oL=class extends _U{constructor(e){super(),this.id=e}},lW=class extends _U{constructor(e){super(),this.data=e}}}),YOe=U(()=>{}),H4=U(()=>{si=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,si.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i,r=t[e.id];i=r===void 0?{type:2,id:e.id}:{type:1,id:e.id,data:r};let{id:n,data:s}=e,a={...t,[n]:s};return Object.setPrototypeOf(a,si.prototype),{data:a,actual:e,reverse:i}}if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let n={...t};return Object.setPrototypeOf(n,si.prototype),delete n[i],{data:n,actual:e,reverse:{type:1,id:i,data:r}}}}return null}}}),zX=U(()=>{FX=class extends Error{}});function i_e(e,t){for(let i of e)t(i.id,i.data)!==!0&&i_e(i.children,t)}function r_e(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)r_e(i,t)}var Ca,s3,Jx,It,s1=U(()=>{la(),zX(),la(),Ca=class extends Array{constructor(...e){super(...e),Lc(this,"partialObjectCaches"),Lc(this,"objCaches"),Lc(this,"parentCaches"),Object.setPrototypeOf(this,Ca.prototype)}deepFreeze(){let e=0;for(;e<this.length;)BX(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(!t)return e;e=t}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}partialCache(e){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let t=this.get(e);t!==void 0&&this.partialObjectCaches.set(e,t)}get(e){if(this.partialObjectCaches!==void 0){let t=this.partialObjectCaches.get(e);if(t!==void 0)return t}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&r_e(i,t)}}traverse(e){i_e(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),n=r.findIndex(o=>o.id===e);if(n<0)throw new Error("not expected");let s=r[n];r=[...r],r[n]={...s,data:t};let a=new Map;return a.set(e,r[n]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(e,t,i=void 0){let r=e,n=t;for(;r!==null;){let a=n,o=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let l=n.findIndex(u=>u.id===o);if(l<0)throw new Error;n=[...n],n[l]={...n[l],children:a},i&&i.set(o,n[l])}Object.setPrototypeOf(n,Ca.prototype);let s=n;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[a,o]of i)s.objCaches.set(a,o);s.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else s.fillCaches();return s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:n,children:s};return o=[...o,l],o.sort((u,h)=>u.fi-h.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),n=r.findIndex(a=>a.id===t);e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new FX("cyclic tree");d=this.parent(d)}}let n=this.parent(r);if(n===void 0)return null;let s=n,a=this.childrenArray(n),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],u=this.modifyArrayBy(n,a);n=t,a=u.childrenArray(n);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),e.localIndex=a.indexOf(l),u=u.modifyArrayBy(n,a),{data:u,actual:e,reverse:{type:9,parent:s,fi:h,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>aL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getAllIdSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i);r!==void 0&&t.push(r)}t.sort((i,r)=>aL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t.map(i=>i.id)}getWithSortKey(e){let t=e,i=[],r=this.get(t),n=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...n,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Ag(0,i,i);{let n=r[0].fi;return Ag(n-i,n,i)}}{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(a=>a.fi>n.fi);if(s===void 0){let a=r[r.length-1].fi;return Ag(a,a+i,i)}return Ag(n.fi,s.fi,i)}}}}),kX=U(()=>{var e;la(),s3=null,(e=Jx||(Jx={})).setPreservePrototype=function(t){s3=t},e.tryPreservePrototype=function(t,i){return Object.getPrototypeOf(t)===s3&&Object.setPrototypeOf(i,s3),i},e.runOp=function(t,i){if(i.type!==0)return null;if(Array.isArray(t)||Qy(t)){let r=i.props,n={},s=Qy(t)?t.slice():[...t],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");n[o]=s[l],s[l]=r[o],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:n}}:null}{let r=i.props,n={},s={...t},a=!1;if(r)for(let o of Object.keys(r)){n[o]=s[o];let l=r[o];l===void 0?delete s[o]:s[o]=l,a=!0}return a?{data:e.tryPreservePrototype(t,s),actual:i,reverse:{type:0,props:n}}:null}}}),a1=U(()=>{la(),la(),It=class extends Array{constructor(...e){super(...e),Lc(this,"objCaches"),Object.setPrototypeOf(this,It.prototype)}deepFreeze(){let e=0;for(;e<this.length;)BX(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let n=i[r];return i=[...i],i[r]={...n,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,It.prototype);let t=e;return typeof process<"u"||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,n=this,s={fi:t,id:i,data:r};return n=[...n,s],n.sort((a,o)=>a.fi-o.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let n=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...n}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let n=r.findIndex(o=>o.id===i);if(n===-1)return null;let s=r[n].fi,a={...r[n],fi:t};return r[n]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Ag(0,t,t);{let r=i[0].fi;return Ag(r-t,r,t)}}{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let n=i.find(s=>s.fi>r.fi);if(n===void 0){let s=i[i.length-1].fi;return Ag(s,s+t,t)}return Ag(r.fi,n.fi,t)}}}});function KOe(e,t){let i={cur:[],result:[],len:0};return[e=_x(e,t,i)??e,i.result]}function TI(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function MI(e){e&&(e.len-=1)}function n_e(e,t,i){let r=!1,n=e.map(s=>{let a=s.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=_x(s.data,t,TI(i,a));MI(i),r=r||l!==void 0,l===void 0&&(l=s.data);let u=n_e(s.children,t,i);return u!==void 0?r=!0:u=s.children,{...s,id:a,data:l,children:u}});if(r)return n}function _x(e,t,i){if(e instanceof Ca){let r=n_e(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}if(e instanceof It)return function(r,n,s){let a=!1,o=r.map(l=>{let u=l.id,h=n[u];if(h!==void 0&&typeof h=="string"&&(a=!0,u=h,s!==null))throw new Error("not supported");let d=_x(l.data,n,TI(s,u));return MI(s),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}(e,t,i);if(Array.isArray(e)){let r=!1,n=e.map((s,a)=>{let o=_x(s,t,TI(i,a));return MI(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(e)),n):void 0}if(e&&typeof e=="object"&&!Qy(e)){let r={},n=!1;for(let[s,a]of Object.entries(e))if(s!=="name"&&s!=="variableId"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");n=!0,s=o}let l=_x(a,t,TI(i,s));MI(i),n=n||l!==void 0,l===void 0&&(l=a),r[s]=l}else r[s]=a;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(typeof e=="string"){let r=t[e];return r!==void 0&&function(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}(i),r}}var s_e=U(()=>{s1(),a1(),la()});function bx(e){return e&&typeof e=="object"&&e instanceof Ts}function VX(e,t){if(t===void 0)return;let i=!1,r=e.map(n=>{let s=n.id,a=bE(n.data,t[s]);if(i=i||a!==void 0,a===void 0&&(a=n.data),n.children){let o=VX(n.children,t);return o!==void 0?i=!0:o=n.children,{...n,id:s,data:a,children:o}}return{...n,id:s,data:a}});return i?r:void 0}function bE(e,t){if(!bx(t))return t;if(e instanceof Ca){let i=VX(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}if(e instanceof It)return function(i,r){if(r===void 0)return;let n=!1,s=i.map(a=>{let o=a.id,l=bE(a.data,r[o]);return n=n||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return n?(Object.setPrototypeOf(s,Object.getPrototypeOf(i)),s):void 0}(e,t);if(Array.isArray(e)){let i=!1,r=e.map((n,s)=>{let a=bE(n,t[s]);return i=i||a!==void 0,a===void 0&&(a=n),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(e instanceof Ts)return GX(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[n,s]of Object.entries(e)){let a=bE(s,t[n]);r=r||a!==void 0,a===void 0&&(a=s),i[n]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}function GX(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!bx(t))return t;if(!bx(e))return Fg.apply(e,t);let i=new Set;for(let n of Object.keys(e))i.add(n);for(let n of Object.keys(t))i.add(n);let r=new Ts;for(let n of i){let s=GX(e===void 0?void 0:e[n],t===void 0?void 0:t[n]);r[n]=s}return r}var Ts,Fg,lL,Xa,YJ,q4=U(()=>{var e;s1(),a1(),Y4(),la(),Ts=class{unusedFunOverridesTable(t){}runOp(t){let i=[],r=this,n=0,s={};for(;n<t.path.length;){if(i.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!bx(r))return null;n+=1}r=r?yU(r):new Ts;for(let[a,o]of Object.entries(t.props)){let l=r[a];s[a]=l,o===void 0?delete r[a]:r[a]=o}for(;n>0;){if(Object.keys(r).length===0){let a=i[n-1];a&&(r=yU(a),delete r[t.path[n-1]])}else{let a=i[n-1];if(a){let o=yU(a);o[t.path[n-1]]=r,r=o}else{let o=new Ts;o[t.path[n-1]]=r,r=o}}n-=1}return{data:Object.setPrototypeOf(r,Ts.prototype),actual:t,reverse:{...t,props:s}}}},(e=Fg||(Fg={})).apply=function(t,i){return bE(t,i)??t},e.merge=function(t,i){return GX(t,i)},e.filterOp=function(t,i){let r=0,n=i.path,s=t;for(;r<n.length&&s!==void 0;){if(s=Ta.zoomOnce(s,n[r]),s===void 0)return i;if(!bx(s))return;r+=1}if(s===void 0)return i;if(bx(s)){if(i.type===0){let a={...i.props};for(let o of Object.keys(s))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=VX([i],s);return a?a[0]:i}return i}}}),ZOe=U(()=>{la(),Y4(),H4(),s1(),zX(),kX(),a1(),s_e(),q4(),(lL||(lL={})).replaceProps=function(e,t){let i=Ta.zoom(t,e.path);if(typeof i=="object"){let r={};for(let n of Object.keys(e.props))r[n]=i[n];return{...e,props:r}}return{...e,props:{}}},(e=>{function t(n,s){let a=s.path,o=[];for(;;){let l;if(n instanceof Ts&&s.type===0&&(l=n.runOp({...s,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=n instanceof Ca||n instanceof It||n instanceof si?n.runOp(s):Jx.runOp(n,s)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],f=o[c];if(f instanceof Ca){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof It){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof si){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof Ts){let m={...f,[p]:d};d=Object.setPrototypeOf(m,Ts.prototype)}else{if(typeof f!="object")return null;if(Array.isArray(f)||Qy(f)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let m=d;d=Qy(f)?f.slice():[...f],d[p]=m}else d=Jx.tryPreservePrototype(f,{...f,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let u,h=a[o.length];if(n instanceof Ca){if(typeof h=="number")throw new Error("");u=n.get(h)?.data}else if(n instanceof It){if(typeof h=="number")throw new Error("");u=n.get(h)?.data}else n!==null&&(u=n[h]);if(u===void 0)return null;o.push(n),n=u}}function i(n,s){for(let a=0;a<n.length&&a<s.length;a++)if(n[a]!==s[a])return!0;return!1}function r(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;a++)if(n[a]!==s[a])return!1;return!0}e.drop=function(n,s){return{...n,path:n.path.slice(s)}},e.applySimple=function(n,s){return t(n,s)?.data??n},e.apply=t,e.pathDisjoint=i,e.pathEq=r,e.commutative=function(n,s){return i(n.path,s.path)},e.subsumed=function(n,s){return!(n.type!==0||s.type!==0||!r(n.path,s.path))&&Object.keys(n.props).every(a=>s.props[a]!==void 0)}})(Xa||(Xa={})),(e=>{function t(i,r){let n=i,s=[],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=Ta.zoom(n,[...o.path,o.id]),h=Xa.apply(n,{...o,type:2})):(l=Ta.zoom(n,[...o.path,o.id,"value"]),h=Xa.apply(n,o)),h!==null){n=h.data;let[d,c]=KOe(n,{[o.id]:l});n=d;for(let p=0;p<c.length;p++){let f=c[p],m=f.pop();if(typeof m=="number"){let g=[m];for(let y=p+1;y<c.length;y++){let _=c[y],b=_[_.length-1];if(typeof b!="number"||!Ta.equal(f,_.slice(0,_.length-1)))break;g.push(b),c.splice(y,1)}let v=Ta.zoom(n,f);u=v.map((y,_)=>g.includes(_)?o.id:y),l=v,m=f.pop()}else{if(m==="alphaOverride"||m==="alpha"){l/=100;let g=l,v=Ta.zoom(n,f.slice(0,f.length-2)),y=v.layers.map(_=>_.id===f[f.length-1]?{..._,data:{..._.data,[m]:g}}:_);Object.setPrototypeOf(y,Object.getPrototypeOf(v.layers)),v.layers=y}u=o.id}s.push({type:0,path:f,props:{[m]:l}}),a.push({type:0,path:f,props:{[m]:u}})}a.push(h.reverse),s.push(h.actual)}}else{let l=Xa.apply(n,o);l!==null&&(s.push(l.actual),n=l.data,a.push(l.reverse))}}catch(l){if(l instanceof FX)return null;throw l}return{data:n,actual:s,reverse:a.reverse()}}e.empty=function(){return[]},e.removePrefix=function(i,r){let n=[];for(let s of i){let[a,...o]=s.path;a===r&&n.push({...s,path:o})}return n},e.addPrefix=function(i,r){return i.map(n=>({...n,path:[r,...n.path]}))},e.concat=function(i,r){return[...i,...r]},e.compress=function(i,r){return[...i.filter(n=>!r.some(s=>Xa.subsumed(n,s))),...r]},e.commutative=function(i,r){return i.every(n=>r.every(s=>Xa.commutative(n,s)))},e.applyAll=function(i,r){for(let n of r){let s=t(i,n);s!==null&&(i=s.data)}return i},e.apply=t})(YJ||(YJ={}))});function KJ(e,t){return e instanceof Ts?Object.setPrototypeOf(t,Ts.prototype):Jx.tryPreservePrototype(e,t)}function bU(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Ta.equal(r.path,i))return void Object.assign(r.props,t.props)}e.push({...t,path:i})}function EI(e,t,i){return i instanceof Ca?new $4(e,t,i):i instanceof It?new X4(e,t,i):i instanceof si?new Proxy(new o_e(e,t,i),h_e):i!==null&&typeof i=="object"?Qy(i)?i:new Proxy(new a_e(e,t,i),l_e):i}function EM(e){let t=new uW(e);return[EI(t,"",e),t]}function hL(e,t){let[i,r]=EM(e);return t(i),r.result()}function $s(e){return e instanceof $4||e instanceof X4?e._current:e!==null&&typeof e=="object"?e[hW]:e}var hW,ZJ,OS,V1,a_e,o_e,xU,l_e,h_e,$4,X4,uW,Ta,u_e=U(()=>{H4(),s1(),kX(),a1(),la(),Y4(),q4(),hW=Symbol(),ZJ=Symbol(),OS=Symbol(),V1=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let n=i;for(;!(r instanceof uW);){let s=r._path,a=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,a)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[OS];i&&i(),delete this._children[e]}}}},a_e=class extends V1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=KJ(this._current,{...this._current,[e]:t})}runOp(e){let t=Jx.runOp(this._current,e);t!==null&&(t.data=KJ(this._current,t.data)),this.reportOp(e,t,e.path)}},o_e=class extends V1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,si.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},xU={get(e,t){if(t===OS)return()=>{e._parent=null};if(t===hW)return e._current;if(t===ZJ)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=i[t],a=EI(e,t,s);return a!==s?(r===void 0&&(r={},e._children=r),r[t]=a,a):s},has:(e,t)=>t in e._current,ownKeys:e=>Reflect.ownKeys(e._current),defineProperty(){throw Error("not supported")},getPrototypeOf:e=>Object.getPrototypeOf(e._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},l_e={...xU,set(e,t,i){let r={type:0,props:{[t]:$s(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},h_e={...xU,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty:(e,t)=>(e.runOp({type:2,id:t}),!0)},$4=class extends V1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[OS]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=EI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}add(e,t,i,r,n){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:n})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},X4=class extends V1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[OS]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,n=this._current[i].fi;e(this.data(this._current[i].id),r,n,i)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}at(e){let{id:t,fi:i}=this._current.at(e);return{id:t,fi:i,data:this.data(t)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=EI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}},uW=class extends V1{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){bU(this.ts,t,e),bU(this.actual,i,e),bU(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),Y4=U(()=>{UX(),u_e(),a1(),s1(),la(),(e=>{function t(r,n){return(r instanceof Ca||r instanceof $4)&&typeof n=="string"||(r instanceof It||r instanceof X4)&&typeof n=="string"?r.data(n):typeof n=="number"&&Array.isArray(r)||typeof n=="string"&&typeof r=="object"&&r!==null?r[n]:void 0}function i(r,n,s=0){for(;s<n.length&&r!==void 0;)r=t(r,n[s]),s+=1;return r}e.equal=function(r,n){if(n.length!==r.length)return!1;{let s=0;for(;s<r.length;){if(r[s]!==n[s])return!1;s+=1}}return!0},e.removeOverridden=function(r,n,s){let a=i(s,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...n};return Object.keys(a).forEach(l=>{delete o[l]}),o}return n},e.zoomOnce=t,e.zoom=i,e.findPathes=function(r,n){let s=[];return function a(o,l){if(o instanceof oL&&o.id===n.id)s.push(l);else if(o instanceof It)for(let u=0;u<o.length;u++)a(o[u].data,[...l,o[u].id]);else if(o instanceof Ca)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(Qy(o))return;if(typeof o=="object"&&o!==null)for(let u in o)a(o[u],[...l,u])}}(r,[]),s}})(Ta||(Ta={}))}),QOe=U(()=>{});function Jr(e,t){let i=[];if(!(t.length<=e.length))return null;{let r=0;for(;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}}return i}var JOe=U(()=>{});function a3(e){try{if(!An.trusted&&!bf){let i=Fr.sharedLength||0;i<Fr.length&&(Fr.length=i)}let t;if(An.randomAccessStructure&&Pt[Le]<64&&Pt[Le]>=32&&ree?(t=ree(Pt,Le,mu,An),Pt=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),Le=mu):t=Zs(),Mo&&(Le=Mo.postBundlePosition,Mo=null),bf&&(Fr.restoreStructures=null),Le==mu)Fr&&Fr.restoreStructures&&QJ(),Fr=null,Pt=null,_f&&(_f=null);else{if(Le>mu)throw new Error("Unexpected end of MessagePack data");if(!bf){let i;try{i=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`${n}n`:n).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return t}catch(t){throw Fr&&Fr.restoreStructures&&QJ(),cW(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||Le>mu)&&(t.incomplete=!0),t}}function QJ(){for(let e in Fr.restoreStructures)Fr[e]=Fr.restoreStructures[e];Fr.restoreStructures=null}function Zs(){let e=Pt[Le++];if(e<160){if(e<128){if(e<64)return e;{let t=Fr[63&e]||An.getStructures&&d_e()[63&e];return t?(t.read||(t.read=dW(t,63&e)),t.read()):e}}if(e<144){if(e-=128,An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=p_e();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(gd>=Le)return Cg.slice(Le-Sh,(Le+=t)-Sh);if(gd==0&&mu<140){let i=t<16?jX(t):c_e(t);if(i!=null)return i}return cL(t)}{let t;switch(e){case 192:return null;case 193:return Mo?(t=Zs(),t>0?Mo[1].slice(Mo.position1,Mo.position1+=t):Mo[0].slice(Mo.position0,Mo.position0-=t)):g_e;case 194:return!1;case 195:return!0;case 196:if(t=Pt[Le++],t===void 0)throw new Error("Unexpected end of buffer");return wU(t);case 197:return t=Ar.getUint16(Le),Le+=2,wU(t);case 198:return t=Ar.getUint32(Le),Le+=4,wU(t);case 199:return P0(Pt[Le++]);case 200:return t=Ar.getUint16(Le),Le+=2,P0(t);case 201:return t=Ar.getUint32(Le),Le+=4,P0(t);case 202:if(t=Ar.getFloat32(Le),An.useFloat32>2){let i=yW[(127&Pt[Le])<<1|Pt[Le+1]>>7];return Le+=4,(i*t+(t>0?.5:-.5)|0)/i}return Le+=4,t;case 203:return t=Ar.getFloat64(Le),Le+=8,t;case 204:return Pt[Le++];case 205:return t=Ar.getUint16(Le),Le+=2,t;case 206:return t=Ar.getUint32(Le),Le+=4,t;case 207:return An.int64AsType==="number"?(t=4294967296*Ar.getUint32(Le),t+=Ar.getUint32(Le+4)):An.int64AsType==="string"?t=Ar.getBigUint64(Le).toString():An.int64AsType==="auto"?(t=Ar.getBigUint64(Le),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Ar.getBigUint64(Le),Le+=8,t;case 208:return Ar.getInt8(Le++);case 209:return t=Ar.getInt16(Le),Le+=2,t;case 210:return t=Ar.getInt32(Le),Le+=4,t;case 211:return An.int64AsType==="number"?(t=4294967296*Ar.getInt32(Le),t+=Ar.getUint32(Le+4)):An.int64AsType==="string"?t=Ar.getBigInt64(Le).toString():An.int64AsType==="auto"?(t=Ar.getBigInt64(Le),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Ar.getBigInt64(Le),Le+=8,t;case 212:if(t=Pt[Le++],t==114)return vW(63&Pt[Le++]);{let i=_o[t];if(i)return i.read?(Le++,i.read(Zs())):i.noBuffer?(Le++,i()):i(Pt.subarray(Le,++Le));throw new Error("Unknown extension "+t)}case 213:return t=Pt[Le],t==114?(Le++,vW(63&Pt[Le++],Pt[Le++])):P0(2);case 214:return P0(4);case 215:return P0(8);case 216:return P0(16);case 217:return t=Pt[Le++],gd>=Le?Cg.slice(Le-Sh,(Le+=t)-Sh):y_e(t);case 218:return t=Ar.getUint16(Le),gd>=(Le+=2)?Cg.slice(Le-Sh,(Le+=t)-Sh):__e(t);case 219:return t=Ar.getUint32(Le),gd>=(Le+=4)?Cg.slice(Le-Sh,(Le+=t)-Sh):b_e(t);case 220:return t=Ar.getUint16(Le),Le+=2,JJ(t);case 221:return t=Ar.getUint32(Le),Le+=4,JJ(t);case 222:return t=Ar.getUint16(Le),Le+=2,eee(t);case 223:return t=Ar.getUint32(Le),Le+=4,eee(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}function dW(e,t){function i(){if(i.count++>fW){let n;try{n=e.read=new Function("r","return function(){return "+(An.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":v_e.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(Zs)}catch{return fW=1/0,i()}return e.read0=n,e.highByte===0&&(e.read=mW(t,e.read)),n()}let r={};for(let n=0,s=e.length;n<s;n++){let a=e[n];a==="__proto__"&&(a="__proto_"),r[a]=Zs()}return An.freezeData?Object.freeze(r):r}return i.count=0,e.read0=i,e.highByte===0?mW(t,i):i}function d_e(){let e=m_e(()=>(Pt=null,An.getStructures()));return Fr=An._mergeStructures(e,Fr)}function AM(e){let t;if(e<16&&(t=jX(e)))return t;if(e>64&&pW)return pW.decode(Pt.subarray(Le,Le+=e));let i=Le+e,r=[];for(t="";Le<i;){let n=Pt[Le++];if(128&n)if((224&n)==192){let s=(31&n)<<6|63&Pt[Le++];s<128?r.push(65533):r.push(s)}else if((240&n)==224){let s=(31&n)<<12|(63&Pt[Le++])<<6|63&Pt[Le++];s<2048||s>=55296&&s<=57343?r.push(65533):r.push(s)}else if((248&n)==240){let s=(7&n)<<18|(63&Pt[Le++])<<12|(63&Pt[Le++])<<6|63&Pt[Le++];s<65536||s>1114111?r.push(65533):(s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s))}else r.push(65533);else r.push(n);r.length>=4096&&(t+=wa.apply(String,r),r.length=0)}return r.length>0&&(t+=wa.apply(String,r)),t}function JJ(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}function eee(e){if(An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=p_e();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}function c_e(e){let t=Le,i=new Array(e);for(let r=0;r<e;r++){let n=Pt[Le++];if((128&n)>0)return void(Le=t);i[r]=n}return wa.apply(String,i)}function jX(e){if(e<4){if(e<2){if(e===0)return"";{let t=Pt[Le++];return(128&t)>1?void(Le-=1):wa(t)}}{let t=Pt[Le++],i=Pt[Le++];if((128&t)>0||(128&i)>0)return void(Le-=2);if(e<3)return wa(t,i);let r=Pt[Le++];return(128&r)>0?void(Le-=3):wa(t,i,r)}}{let t=Pt[Le++],i=Pt[Le++],r=Pt[Le++],n=Pt[Le++];if((128&t)>0||(128&i)>0||(128&r)>0||(128&n)>0)return void(Le-=4);if(e<6){if(e===4)return wa(t,i,r,n);{let s=Pt[Le++];return(128&s)>0?void(Le-=5):wa(t,i,r,n,s)}}if(e<8){let s=Pt[Le++],a=Pt[Le++];if((128&s)>0||(128&a)>0)return void(Le-=6);if(e<7)return wa(t,i,r,n,s,a);let o=Pt[Le++];return(128&o)>0?void(Le-=7):wa(t,i,r,n,s,a,o)}{let s=Pt[Le++],a=Pt[Le++],o=Pt[Le++],l=Pt[Le++];if((128&s)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(Le-=8);if(e<10){if(e===8)return wa(t,i,r,n,s,a,o,l);{let u=Pt[Le++];return(128&u)>0?void(Le-=9):wa(t,i,r,n,s,a,o,l,u)}}if(e<12){let u=Pt[Le++],h=Pt[Le++];if((128&u)>0||(128&h)>0)return void(Le-=10);if(e<11)return wa(t,i,r,n,s,a,o,l,u,h);let d=Pt[Le++];return(128&d)>0?void(Le-=11):wa(t,i,r,n,s,a,o,l,u,h,d)}{let u=Pt[Le++],h=Pt[Le++],d=Pt[Le++],c=Pt[Le++];if((128&u)>0||(128&h)>0||(128&d)>0||(128&c)>0)return void(Le-=12);if(e<14){if(e===12)return wa(t,i,r,n,s,a,o,l,u,h,d,c);{let p=Pt[Le++];return(128&p)>0?void(Le-=13):wa(t,i,r,n,s,a,o,l,u,h,d,c,p)}}{let p=Pt[Le++],f=Pt[Le++];if((128&p)>0||(128&f)>0)return void(Le-=14);if(e<15)return wa(t,i,r,n,s,a,o,l,u,h,d,c,p,f);let m=Pt[Le++];return(128&m)>0?void(Le-=15):wa(t,i,r,n,s,a,o,l,u,h,d,c,p,f,m)}}}}}function tee(){let e,t=Pt[Le++];if(t<192)e=t-160;else switch(t){case 217:e=Pt[Le++];break;case 218:e=Ar.getUint16(Le),Le+=2;break;case 219:e=Ar.getUint32(Le),Le+=4;break;default:throw new Error("Expected string")}return AM(e)}function wU(e){return An.copyBuffers?Uint8Array.prototype.slice.call(Pt,Le,Le+=e):Pt.subarray(Le,Le+=e)}function P0(e){let t=Pt[Le++];if(_o[t]){let i;return _o[t](Pt.subarray(Le,i=Le+=e),r=>{Le=r;try{return Zs()}finally{Le=i}})}throw new Error("Unknown extension type "+t)}function p_e(){let e=Pt[Le++];if(!(e>=160&&e<192))return Le--,f_e(Zs());if(e-=160,gd>=Le)return Cg.slice(Le-Sh,(Le+=e)-Sh);if(!(gd==0&&mu<180))return cL(e);let t,i=4095&(e<<5^(e>1?Ar.getUint16(Le):e>0?Pt[Le]:0)),r=gW[i],n=Le,s=Le+e-3,a=0;if(r&&r.bytes==e){for(;n<s;){if(t=Ar.getUint32(n),t!=r[a++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(t=Pt[n++],t!=r[a++]){n=1879048192;break}if(n===s)return Le=n,r.string;s-=3,n=Le}for(r=[],gW[i]=r,r.bytes=e;n<s;)t=Ar.getUint32(n),r.push(t),n+=4;for(s+=3;n<s;)t=Pt[n++],r.push(t);let o=e<16?jX(e):c_e(e);return r.string=o??cL(e)}function f_e(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(An.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error("Invalid property type for record: "+typeof e)}function m_e(e){nee&&nee();let t=mu,i=Le,r=dL,n=Sh,s=gd,a=Cg,o=uL,l=_f,u=Mo,h=new Uint8Array(Pt.slice(0,mu)),d=Fr,c=Fr.slice(0,Fr.length),p=An,f=bf,m=e();return mu=t,Le=i,dL=r,Sh=n,gd=s,Cg=a,uL=o,_f=l,Mo=u,Pt=h,bf=f,(Fr=d).splice(0,Fr.length,...c),An=p,Ar=new DataView(Pt.buffer,Pt.byteOffset,Pt.byteLength),m}function cW(){Pt=null,_f=null,Fr=null}function eLe(e){e.unpack?_o[e.type]=e.unpack:_o[e.type]=e}var pW,Pt,mu,Le,iee,uL,dL,An,Fr,Cg,Sh,gd,Mo,_f,_o,Ar,SU,g_e,bf,fW,ree,nee,CM,v_e,mW,cL,y_e,__e,b_e,wa,gW,vW,TU,see,aee,oee,yW,o3,lee,hee,uee,_W,MU,mA,tLe=U(()=>{try{pW=new TextDecoder}catch{}Le=0,uL=iee=[],dL=0,An={},Sh=0,gd=0,_o=[],SU={useRecords:!1,mapsAsObjects:!0},(g_e=new class{}).name="MessagePack 0xC1",bf=!1,fW=2,CM=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(Pt)return m_e(()=>(cW(),this?this.unpack(e,t):CM.prototype.unpack.call(SU,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(mu=t.end||e.length,Le=t.start||0):(Le=0,mu=t>-1?t:e.length),dL=0,gd=0,Cg=null,uL=iee,Mo=null,Pt=e;try{Ar=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Pt=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof CM){if(An=this,this.structures)return Fr=this.structures,a3(t);(!Fr||Fr.length>0)&&(Fr=[])}else An=SU,(!Fr||Fr.length>0)&&(Fr=[]);return a3(t)}unpackMultiple(e,t){let i,r=0;try{bf=!0;let n=e.length,s=this?this.unpack(e,n):o3.unpack(e,n);if(!t){for(i=[s];Le<n;)r=Le,i.push(a3());return i}if(t(s,r,Le)===!1)return;for(;Le<n;)if(r=Le,t(a3(),r,Le)===!1)return}catch(n){throw n.lastPosition=r,n.values=i,n}finally{bf=!1,cW()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(i=>i.slice(0)));for(let i=0,r=e.length;i<r;i++){let n=e[i];n&&(n.isShared=!0,i>=32&&(n.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],n=t[i];n&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}},v_e=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,mW=(e,t)=>function(){let i=Pt[Le++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),n=Fr[r]||d_e()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=dW(n,e)),n.read()},cL=AM,y_e=AM,__e=AM,b_e=AM,wa=String.fromCharCode,gW=new Array(4096),vW=(e,t)=>{let i=Zs().map(f_e),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let n=Fr[e];return n&&(n.isShared||bf)&&((Fr.restoreStructures||(Fr.restoreStructures=[]))[e]=n),Fr[e]=i,i.read=dW(i,r),(i.read0||i.read)()},_o[0]=()=>{},_o[0].noBuffer=!0,_o[66]=e=>{let t=e.byteLength%8||8,i=BigInt(128&e[0]?e[0]-256:e[0]);for(let r=1;r<t;r++)i<<=BigInt(8),i+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(s,a)=>{let o=a-s;if(o<=40){let d=r.getBigUint64(s);for(let c=s+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=s+(o>>4<<3),u=n(s,l),h=n(l,a);return u<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(r.byteLength-t))|n(t,r.byteLength)}return i},TU={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},_o[101]=()=>{let e=Zs();if(!TU[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return TU[e[0]](e[1],{cause:e[2]})},_o[105]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Ar.getUint32(Le-4);_f||(_f=new Map);let i,r=Pt[Le];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)&&Pt[Le+1]===115?new Set:{};let n={target:i};_f.set(t,n);let s=Zs();if(!n.used)return n.target=s;if(Object.assign(i,s),i instanceof Map)for(let[a,o]of s.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(s))i.add(a);return i},_o[112]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Ar.getUint32(Le-4),i=_f.get(t);return i.used=!0,i.target},_o[115]=()=>new Set(Zs()),see=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),aee=typeof globalThis=="object"?globalThis:window,_o[116]=e=>{let t=e[0],i=Uint8Array.prototype.slice.call(e,1).buffer,r=see[t];if(!r){if(t===16)return i;if(t===17)return new DataView(i);throw new Error("Could not find typed array for code "+t)}return new aee[r](i)},_o[120]=()=>{let e=Zs();return new RegExp(e[0],e[1])},oee=[],_o[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Le;return Le+=t-e.length,Mo=oee,(Mo=[tee(),tee()]).position0=0,Mo.position1=0,Mo.postBundlePosition=Le,Le=i,Zs()},_o[255]=e=>e.length==4?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid"),yW=new Array(147);for(let e=0;e<256;e++)yW[e]=+("1e"+Math.floor(45.15-.30103*e));(o3=new CM({useRecords:!1})).unpack,o3.unpackMultiple,o3.unpack,lee=new Float32Array(1),new Uint8Array(lee.buffer,0,4)}),iLe=U(()=>{tLe(),UX(),q4(),a1(),H4(),s1(),hee=[{Class:si.prototype.constructor,type:1,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,si.prototype),e)},{Class:It.prototype.constructor,type:2,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,It.prototype),e)},{Class:Ca.prototype.constructor,type:3,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,Ca.prototype),e)},{Class:oL.prototype.constructor,type:4,write:e=>e.id,read:e=>new oL(e)},{Class:lW.prototype.constructor,type:5,write:e=>e.data,read:e=>new lW(e)},{Class:Ts.prototype.constructor,type:6,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,Ts.prototype),e)}];for(let e of hee)eLe(e);uee=new CM({structuredClone:!0}),(_W||(_W={})).deserialize=function(e){return uee.unpack(e)}}),rLe=U(()=>{iLe(),MU=e=>()=>{throw new Error(e+" is not available in the runtime build (decode-only CollabSerialize)")},mA={deserialize:_W.deserialize,serialize:MU("CollabSerialize.serialize"),checksum:MU("CollabSerialize.checksum")}}),Ir=U(()=>{Y4(),YOe(),zX(),s1(),H4(),kX(),a1(),ZOe(),QOe(),u_e(),JOe(),UX(),rLe(),s_e(),q4()});function bW(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var dee,xW,xE,l3,EU,cee,pee,fee,wW,SW,mee,gee,vee,yee,_ee,TW,MW,bee,xee,wee,See,x_e=U(()=>{var e,t,i;Ir(),oe(),(e=dee||(dee={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},e.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},xW={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(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"},r.defaultData=function(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,name:"",actions:new It}:{type:n,disabled:!1,name:"",key:void 0,actions:new It}}})(xE||(xE={})),(r=>{r.propertyDefaultData=function(n){return{type:"Property",value:[n??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(l3||(l3={})),(t=EU||(EU={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:l3.propertyDefaultData(r),rOperand:{...l3.valueDefaultData}}},t.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},t.stateDefaultData=function(r,n){return{type:"State",object:r??null,state:n??null}},(cee||(cee={})).isConditionalSubActions=function(r){return r.find(n=>n==="ifActions"||n==="elseActions")!==void 0},(r=>{r.is=function(n){return n.type==="Conditional"},r.defaultData=function(n){return{type:"Conditional",disabled:!1,name:"",inActions:new It,outActions:new It,condition:EU.distanceDefaultData(n)}}})(pee||(pee={})),(fee||(fee={})).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 It,drop:new It}},(wW||(wW={})).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 It},(SW||(SW={})).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(n){return n.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new It}}})(mee||(mee={})),(r=>{r.is=function(n){return n.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 It}}})(gee||(gee={})),(r=>{r.is=function(n){return n.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new It}}})(vee||(vee={})),(r=>{r.is=function(n){return n.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new It}}})(yee||(yee={})),(r=>{r.is=function(n){return n.type==="Trigger"},r.defaultData=function(n,s){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new It,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}})(_ee||(_ee={})),(i=TW||(TW={})).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 It},n={size:"tablet",operator:"<",actions:new It},s={size:[...i.defaultSizes.custom],operator:"<>",actions:new It},a=new It;return a.push({id:ht.generateUUID(),fi:0,data:r},{id:ht.generateUUID(),fi:1,data:n},{id:ht.generateUUID(),fi:2,data:s}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new It}},(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(n){return n.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new It,variableId:"",objectId:null,property:"Position X"}}})(MW||(MW={})),(r=>{r.is=function(n){return n.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new It,errorActions:new It,userAPIId:""}}})(bee||(bee={})),(r=>{r.is=function(n){return n.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new It,userWebhookId:""}}})(xee||(xee={})),(r=>{r.is=function(n){return n.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new It,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(wee||(wee={})),(r=>{r.is=function(n){return n.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new It}}})(See||(See={}))});function Tee(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function Mee(e){return typeof e=="string"&&e.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}var o1,xx,w_e,eo,Eee,Bc,Ug,gA,Aee,wx,sa,Vr,EW,Cee,Pg,ew,Pee,Ree,Dee,Nee,Iee,Oee,Lee,Bee,AU,Fee,Uee,CU,zee,kee,Vee,PU,Gee,RU,jee,Wee,DU,Hee,AW,qee,$ee,Xee,Yee,Kee,Zee,Jy,xf,Rg,CW,PW,pL,fL,mL,gL,vL,RW,DW,yL,NW,Sx,Qee,NU,IU,IW,Jee,_L,ete,tte,vA,ite,rte,nte,ste,ate,ote,lte,hte,ute,K4,WX,hs,ns,Rb,S_e,yA,bL,Vv,OW,HX,xL,wL,LW,df,AI,Xn,OU,xg,Nh=U(()=>{var e,t,i,r,n,s,a,o;o1="personal camera",xx="a218fcc3-276b-49b9-b485-49037fd14f5f",w_e=2500134,eo=5526619,(e=Eee||{}).x="x",e.y="y",e.z="z",Eee=e,(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,f){let m=l.sub(p,c),g=l.sub(f,c),v=l.dot(m,g)/l.dot(m,m),y=l.scalarMultiply(m,v);return l.add(c,y)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,f){return[c[0]+(p[0]-c[0])*f,c[1]+(p[1]-c[1])*f]},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,f){return h(c,d(c,p,f))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Bc||(Bc={})),(t=Ug||(Ug={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]},t.add=function(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]},t.sub=function(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]},t.div=function(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]},t.mul=function(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]},t.dist=function(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])},t.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=gA||(gA={})).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])]}})(Aee||(Aee={})),(r=wx||(wx={})).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},(n=sa||(sa={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},n.white={r:1,g:1,b:1},n.red={r:1,g:0,b:0},n.black={r:0,g:0,b:0},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},n.clone=function(l){return{r:l.r,g:l.g,b:l.b}},n.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},n.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},n.equals=function(l,u){return l.r===u.r&&l.g===u.g&&l.b===u.b},n.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)},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}},n.is=function(l){return!!Tee(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(s=Vr||(Vr={})).white={...sa.white,a:1},s.is=function(l){return!!Tee(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},s.transparent={...sa.white,a:0},s.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},s.fromHexAndA=function(l,u){return{...sa.fromHex(l),a:u}},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},s.equals=function(l,u){return sa.equals(l,u)&&l.a===u.a},s.equalsFixed=function(l,u){return sa.equalsFixed(l,u)&&l.a.toFixed(2)===u.a.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,a:l.a+(u.a-l.a)*h}},s.toStyle=function({r:l,g:u,b:h,a:d}=s.white){return`rgba(${255*l}, ${255*u}, ${255*h}, ${d})`},(EW||(EW={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=Cee||{})[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",Cee=a,(Pg||(Pg={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(ew||(ew={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=Pee||(Pee={})).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]}),nLe=U(()=>{var e,t;Ir(),x_e(),(Ree||(Ree={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(Dee||(Dee={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(Nee||(Nee={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(Iee||(Iee={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(Oee||(Oee={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(Lee||(Lee={})).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"},(Bee||(Bee={})).defaultData={type:"Reset",name:"",delay:0},(AU||(AU={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(e=Fee||(Fee={})).pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0},(t=Uee||(Uee={})).defaultData={type:"Audio",name:"",...AU.defaultData},t.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),t.hasAudioByEvents=i=>t.getAudiosByEvents(i).length>0,t.getAudiosByActions=i=>{let r=[];return i.forEach(n=>{let s=n.data;s.type==="Audio"&&s.interaction==="play"&&s.audio&&r.push(n),s.type==="Conditional"&&(r.push(...t.getAudiosByActions(s.ifActions)),r.push(...t.getAudiosByActions(s.elseActions)))}),r},t.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:n})=>{xE.is(n)||n.type==="Collision"||n.type==="Start"||n.type==="Trigger"||n.type==="VariableChange"||n.type==="WEBHOOK"||n.type==="AIAssistantTrigger"?r.push(...t.getAudiosByActions(n.actions)):n.type==="Conditional"?(r.push(...t.getAudiosByActions(n.inActions)),r.push(...t.getAudiosByActions(n.outActions))):n.type==="GameControl"?Object.values(n.gameActions).forEach(s=>{r.push(...t.getAudiosByActions(s))}):n.type==="DragDrop"?(r.push(...t.getAudiosByActions(n.dragDropActions.drag)),r.push(...t.getAudiosByActions(n.dragDropActions.drop))):n.type==="Resize"?n.breakpoints.forEach(({data:s})=>{r.push(...t.getAudiosByActions(s.actions))}):n.type==="API"&&(r.push(...t.getAudiosByActions(n.successActions)),r.push(...t.getAudiosByActions(n.errorActions)))}),r},(CU||(CU={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(zee||(zee={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...CU.defaultData},i.hasVideoByActions=r=>r.some(({data:n})=>n.type==="Video"&&n.interaction==="play"&&n.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:n}of r.events)if((xE.is(n)||n.type==="Start")&&i.hasVideoByActions(n.actions))return!0}},i.getVideosByActions=r=>{let n=[];return r.forEach(s=>{let a=s.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&n.push(s)}),n},i.getVideosByEvents=r=>{let n=[];return r.forEach(({data:s})=>{(xE.is(s)||s.type==="Start")&&n.push(...i.getVideosByActions(s.actions))}),n}})(kee||(kee={})),(Vee||(Vee={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(PU||(PU={})).defaultData=function(){return{tweens:new It,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(Gee||(Gee={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...PU.defaultData()}},(RU||(RU={})).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}})(jee||(jee={})),(Wee||(Wee={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...RU.defaultData(i)}},(DU||(DU={})).defaultData=function(i,r,n){return{interaction:"play",object:i,clipId:r,crop:n,crop2:n,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(Hee||(Hee={})),(i=>{i.defaultData=function(r,n,s){return{type:"Animation",name:"",...DU.defaultData(r,n,s)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(AW||(AW={})),(qee||(qee={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},($ee||($ee={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new It,elseActions:new It,condition:[]}),(Xee||(Xee={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(Yee||(Yee={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(Kee||(Kee={})).defaultData={name:"",type:"UserAPI"}}),sLe=U(()=>{var e;(e=Zee||(Zee={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),t=>t.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},e.maxSize=2e6}),T_e=U(()=>{var e;(e=Jy||(Jy={})).all=["PerspectiveCamera","OrthographicCamera"],e.is=function(t){return e.all.includes(t)},(t=>{t.DefaultUp=[0,1,0],t.DefaultTargetOffset=1e3,t.MinTargetOffset=.001,t.sanitizeTargetOffset=function(s){return s===void 0||!Number.isFinite(s)||s<t.MinTargetOffset?t.DefaultTargetOffset:s},t.DefaultAzimuth=-24,t.DefaultElevation=15;let i=t.DefaultAzimuth*Math.PI/180,r=t.DefaultElevation*Math.PI/180,n=180/Math.PI;t.DefaultPosition=[t.DefaultTargetOffset*Math.sin(i)*Math.cos(r),t.DefaultTargetOffset*Math.sin(r),t.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],t.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*n,Math.asin(Math.sin(i)*Math.cos(r))*n,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*n],t.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:t.DefaultUp,isUpVectorFlipped:!1,targetOffset:t.DefaultTargetOffset},t.getZoom=function(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}})(xf||(xf={}))}),M_e=U(()=>{var e;(e=Rg||(Rg={})).defaultData=function(t,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof t[0]=="number"?t[0]:1,typeof t[1]=="number"?t[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 t[0]=="number"?t[0]+t[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:t.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"}}},e.merge=function(t,i){let r={...t};if(PW.forEach(n=>{Object.assign(r,{[n]:i[n]??t[n]})}),r.radial={...t.radial},i.radial){let n=t.radial,s=i.radial;pL.forEach(a=>{Object.assign(r.radial,{[a]:s[a]??n[a]})})}if(r.linear={...t.linear},i.linear){let n=t.linear,s=i.linear;fL.forEach(a=>{Object.assign(r.linear,{[a]:s[a]??n[a]})})}if(r.grid={...t.grid},i.grid){let n=t.grid,s=i.grid;mL.forEach(a=>{Object.assign(r.grid,{[a]:s[a]??n[a]})})}if(r.toObject={...t.toObject},i.toObject){let n=t.toObject,s=i.toObject;gL.forEach(a=>{Object.assign(r.toObject,{[a]:s[a]??n[a]})})}if(r.randomnessObject={...t.randomnessObject},i.randomnessObject){let n=t.randomnessObject,s=i.randomnessObject;vL.forEach(a=>{Object.assign(r.randomnessObject,{[a]:s[a]??n[a]})})}return r},e.isPartial=function(t){return!(!t.randomnessObject&&!t.toObject)},(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];t.toOps=function(r,n){let s=[];r.count!==void 0&&s.push({type:0,path:n,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&s.push({type:0,path:[...n,a],props:o})}return s}})(CW||(CW={})),PW=["count"],pL=["radius","start","end","position","scale","rotation"],fL=["position","scale","rotation"],mL=["count","size"],gL=["count","position","scale","rotation"],vL=["strength","scale","rotation","position","movement","seed","freqScale"]}),E_e=U(()=>{var e;Nh(),(e=RW||(RW={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],e.is=function(t){return e.all.includes(t)},(DW||(DW={})).defaultData=function(t){return function(i){if(i==="PointLight")return{type:i,color:Vr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:Vr.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:Vr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(t)}}),A_e=U(()=>{var e;(e=yL||(yL={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.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:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}}),C_e=U(()=>{var e;(e=NW||(NW={})).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},e.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),qX=U(()=>{(Sx||(Sx={})).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]}}),P_e=U(()=>{var e,t;(e=Qee||{})[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",Qee=e,(t=NU||(NU={})).defaultData={castShadow:!0,receiveShadow:!0},t.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,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe&&(r.shadowCatcher??!1)===(n.shadowCatcher??!1)}})(IU||(IU={})),(IW||(IW={})).defaultData={...IU.defaultData,...NU.defaultData},(Jee||(Jee={})).getMaterialData=function(i,r){let n=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&n.push(s)}else if("materials"in i)for(let s of i.materials){let a=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;a&&n.push(a)}return n}}),R_e=U(()=>{var e;(e=_L||(_L={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7}),VA=U(()=>{var e,t,i,r;Ir(),Nh(),R_e(),Nh(),(ete||(ete={})).is=function(n){return n==="texture"||n==="video"||n==="color"||n==="depth"||n==="normal"||n==="gradient"||n==="noise"||n==="fresnel"||n==="cavity"||n==="dust"||n==="rainbow"||n==="toon"||n==="outline"||n==="particle"||n==="transmission"||n==="reflection"||n==="matcap"||n==="displace"||n==="pattern"||n==="vertexColor"||n==="light"},(tte||(tte={})).is=function(n){return n==="luminance"||n==="r"||n==="g"||n==="b"||n==="a"},(vA||(vA={})).is=function(n){return typeof n=="object"&&n!==null&&n.image!=null},(ite||(ite={})).is=function(n){return n==="phong"||n==="toon"||n==="lambert"||n==="physical"},(r=rte||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",rte=r,nte=(n=>(n[n.RepeatWrapping=1e3]="RepeatWrapping",n[n.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",n[n.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",n))(nte||{}),ste=(n=>(n[n.NearestFilter=1003]="NearestFilter",n[n.LinearFilter=1006]="LinearFilter",n[n.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",n))(ste||{}),(i=ate||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",ate=i,(t=ote||{})[t.Simplex=0]="Simplex",t[t.SimplexFractal=1]="SimplexFractal",t[t.Ashima=2]="Ashima",t[t.Fbm=3]="Fbm",t[t.Perlin=4]="Perlin",t[t.Voronoi=5]="Voronoi",ote=t,(e=lte||{})[e.F1=0]="F1",e[e.F2=1]="F2",e[e.F2MinusF1=2]="F2MinusF1",e[e.SmoothBlend=3]="SmoothBlend",e[e.Edge=4]="Edge",e[e.Power=5]="Power",e[e.Lines=6]="Lines",e[e.Cells=7]="Cells",lte=e,hte=(n=>(n[n.Lights=0]="Lights",n[n.Static=1]="Static",n[n.Camera=2]="Camera",n))(hte||{}),ute=(n=>(n[n.Circle=0]="Circle",n[n.Ring=1]="Ring",n[n.Polygon=2]="Polygon",n[n.Cross=3]="Cross",n[n.Diamond=4]="Diamond",n[n.Checkerboard=5]="Checkerboard",n[n.Line=6]="Line",n[n.Wave=7]="Wave",n))(ute||{}),K4=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],WX=["wrapping","image","video","name","minFilter","magFilter"],(n=>{n.patch=function(s,a){let{texture:o,...l}=a;if(Object.assign(s,l),o){let u=s.texture;u&&Object.assign(u,o)}},n.defaultColorLayer=function(s){return{...n.defaultData("color"),color:s}},n.defaultData=function(s,a){return s==="light"&&a?function(o){let l={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...l,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...l,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...l,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...l,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(a):function(o){let l={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...l,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...l,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:_L.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:sa.fromHex(eo)};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:{...sa.fromHex(6710886),a:1},colorB:{...sa.fromHex(6710886),a:1},colorC:{...sa.fromHex(16777215),a:1},colorD:{...sa.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:Vr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:Vr.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:Vr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:Vr.fromHexAndA(0,1),contourColor:Vr.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:{...sa.fromHex(0),a:1},colorB:{...sa.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(s)}})(hs||(hs={})),(n=>{function s(a,o="layer1",l="layer2",u=sa.fromHex(16777215)){let h=new It;return h.push({fi:0,data:hs.defaultData("light",a),id:o}),h.push({fi:1,data:hs.defaultData("color"),id:l}),{layers:h}}n.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")},n.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},n.defaultEmptyData=function(){return{layers:new It}},n.defaultData=function(a="layer1",o="layer2"){return s("physical",a,o)},n.withName=function(a,o){return{...a,name:o}},n.defaultTwoLayerData=s,n.defaultColorMaterial=function(a,o,l="layer1",u="layer2"){let h=new It;return h.push({fi:0,data:hs.defaultData("light",o),id:l}),h.push({fi:1,data:hs.defaultColorLayer(a),id:u}),{layers:h}},n.defaultUIObjectMaterial=function(a){let o=hs.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new It;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}},n.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=hs.defaultData("texture");Object.assign(h.texture,{image:a});let d=new It;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:hs.defaultData("light",o),id:u}),{layers:d}},n.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=hs.defaultData("video");Object.assign(h.texture,{video:a});let d=new It;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:hs.defaultData("light",o),id:u}),{layers:d}}})(ns||(ns={}))}),aLe=U(()=>{Rb="Roboto_regular",S_e="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),oLe=U(()=>{aLe()}),D_e=U(()=>{Ir(),(yA||(yA={})).defaultData=function(){return{points:new It,roundness:0,shapeHoles:[],isClosed:!1}}}),N_e=U(()=>{Ir(),(bL||(bL={})).defaultData=function(){return{points:new It,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},Vv={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(OW||(OW={})).merge=function(e,t){let i={...e};return xL.forEach(r=>{Object.assign(i,{[r]:t[r]??e[r]})}),i},HX={shape:Vv,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},xL=["depth","offset","angle","twist","startScale","endScale"]}),$X=U(()=>{var e,t;D_e(),N_e(),(e=wL||(wL={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},e.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"},e.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"},(LW||(LW={})).merge=function(i,r){let n={...i};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...i.extrusion},Object.assign(n.extrusion,OW.merge(n.extrusion,r.extrusion))),n},(t=df||(df={})).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:bL.defaultData(),extrusion:HX};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:yA.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{...t.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")},AI=["width","height","depth"]}),I_e=U(()=>{Nh(),(e=>{function t(i){return i.mode??"linear"}e.defaultData={enabled:!1,useBackgroundColor:!1,color:sa.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},e.getMode=t,e.getModeIndex=function(i){let r=t(i);return r==="height"?1:r==="both"?2:0},e.getDensity=function(i){return i.density??e.defaultData.density},e.getHeightFalloff=function(i){return i.heightFalloff??e.defaultData.heightFalloff},e.getHeightBase=function(i){return i.heightBase??e.defaultData.heightBase}})(Xn||(Xn={}))}),XX=U(()=>{(OU||(OU={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(xg||(xg={})).defaultData={enabled:!1,mode:"hdri",hdri:OU.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function lLe(e){let t=typeof e=="string"?Number.parseInt(e,10):e;return typeof t=="number"&&Number.isFinite(t)?Math.min(5,Math.max(0,Math.round(t))):3}var _A,fy,LU,BU,FU,Tx,UU,BW,FW,dte,G1,O_e,ra,SL,cte,pte,fte,mte,_c,wE,TL,ML,wf,my,gte,Dg,EL,Sf,zU,kU,Yv,e1,Kv,SE,UW,vte,Eo,VU,yte,_te,cf,fu,Mx,zW,L_e=U(()=>{(()=>{let e={opacity:1,blendFunction:13,enabled:!1};(_A||(_A={})).defaultData={enabled:!1,pixelation:{...e,blendFunction:16,granularity:15},bloom:{...e,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...e,offset:[2,2]},vignette:{...e,darkness:1,offset:0},hueSaturation:{...e,hue:3,saturation:0},brightnessContrast:{...e,brightness:.25,contrast:0},depthOfField:{...e,focusDistance:100,focalLength:20,bokehScale:5},noise:{...e,blendFunction:16}}})()}),YX=U(()=>{var e;I_e(),XX(),L_e(),Nh(),(e=fy||(fy={})).defaultData={type:"normal",softShadowQuality:"low"},e.isSoft=function(t){return t!=null&&(t.type===void 0||t.type==="soft")},(LU||(LU={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(BU||(BU={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(t=>{t.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},t.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(FU||(FU={})),(Tx||(Tx={})).defaultData={usePhysics:!1,gravity:-10},(UU||(UU={})).defaultData={playCamera:o1,gameControlObject:null},(BW||(BW={})).defaultData={backgroundColor:Vr.fromHexAndA(w_e,1),postprocessing:_A.defaultData,fog:Xn.defaultData,sky:xg.defaultData,globalPhysics:Tx.defaultData,ambient:LU.defaultData,ao:BU.defaultData,shadow:fy.defaultData,publish:UU.defaultData,grading:FU.defaultData}}),hLe=U(()=>{(FW||(FW={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),Z4=U(()=>{var e,t,i;Ir(),T_e(),E_e(),A_e(),C_e(),qX(),P_e(),Nh(),VA(),$X(),M_e(),la(),YX(),hLe(),(e=dte||(dte={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},e.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(t=G1||(G1={})).identity={...EW.identity,hiddenMatrix:wx.identity},t.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,hiddenMatrix:r.hiddenMatrix}},t.merge=function(r,n){return{position:n?.position||r.position,rotation:n?.rotation||r.rotation,pivot:n?.pivot||r.pivot,pivotRotation:n?.pivotRotation||r.pivotRotation,scale:n?.scale||r.scale,hiddenMatrix:n?.hiddenMatrix||r.hiddenMatrix}},t.diff=function(r,n){return t_e({position:Ug.isEqual(r.position,n.position)?void 0:n.position,rotation:Ug.isEqual(r.rotation,n.rotation)?void 0:n.rotation,scale:Ug.isEqual(r.scale,n.scale)?null:n.scale,hiddenMatrix:wx.isEqual(r.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})},O_e=["slide","offset"],(ra||(ra={})).defaultData={states:new It,events:new It,visible:!0,raycastLock:!1,physics:Sx.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...G1.identity,cloner:null},(SL||(SL={})).defaultData={type:"Empty",...ra.defaultData},(cte||(cte={})).defaultData={type:"ParticleCollider",...FW.defaultData,...ra.defaultData},(pte||(pte={})).defaultData={type:"Component",...ra.defaultData},(fte||(fte={})).defaultData={type:"Particle",...ra.defaultData,...yL.defaultData},(mte||(mte={})).defaultData={type:"Hair",...ra.defaultData,...NW.defaultData},(_c||(_c={})).defaultData={type:"Mesh",...ra.defaultData,...IW.defaultData},(wE||(wE={})).defaultData={...ra.defaultData,...G1.identity,position:xf.DefaultPosition,rotation:xf.DefaultRotation,...xf.defaultData},(r=>{r.defaultData=function(n){return{...ra.defaultData,...DW.defaultData(n)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(TL||(TL={})),(r=>{function n(s,a,o=0){for(;o<a.length;){let l=s?s[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;s=l.descendants,o+=1}}r.resolveWithDes=n,r.resolve=function(s,a,o=0){let l=n(s,a,o);if(l){let u=Object.keys(l);if(u.length===1&&u[0]==="descendants")return}return l}})(ML||(ML={})),(r=>{function n(s,a){return{...ra.defaultData,...a,component:s,overrides:new Ts,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=n,r.fromComponentData=function(s){let a=G1.fromObject(s.data);return n(s.id,a)}})(wf||(wf={})),(r=>{r.defaultData={type:"Page",...ra.defaultData,physics:{...Sx.defaultData,fusedBody:!1},...BW.defaultData,camera:wE.defaultData,timelines:new si},r.isUIPage=function(n){return n.uiScene!==void 0}})(my||(my={})),(i=gte||(gte={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:wx.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Sx.defaultData,states:new It,events:new It,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...xf.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",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("RectangleGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("BooleanGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("ShapeBlendGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("TextGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("InputGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(n,s){let a={name:s};return n.type==="Mesh"?(a.geometry={},"material"in n&&(a.material={layers:new Ts}),"materials"in n&&(a.materials=n.materials.map(o=>({layers:new Ts})))):Jy.is(n.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(n,s){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:f,...m}=p;if(f!==void 0&&Object.keys(f).length>0){let g={path:[...h,"layers",c,"texture"],props:f,type:0};o.push(g)}if(Object.keys(m).length>0){let g={path:[...h,"layers",c],props:m,type:0};o.push(g)}}}for(let[h,d]of Object.entries(s)){let c=d;if(h!=="name")if(h==="cloner")o.push(...CW.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,f]of Object.entries(c))u(["materials",p],f);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(n,s){if(s===void 0)return n;let a={...n};if(Object.assign(a,G1.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Jy.is(n.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=s;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(n.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:LW.merge(a.geometry,s.geometry)}),(s.material||s.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=hL(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=hL(u.materials,h=>{for(let d=0;d<u.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,f]of Object.entries(c.layers)){let m=h[d]?.layers?.data(p);m&&hs.patch(m,f)}}}).data),u}(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Rg.merge(a.cloner,s.cloner)});else if(n.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Rg.merge(a.cloner,s.cloner)});else if(RW.is(n.type)){let o=s;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=sa.clone(o.color))}return a}})(Dg||(Dg={}))}),KX=U(()=>{(EL||(EL={})).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}}),Q4=U(()=>{KX(),Nh(),(Sf||(Sf={})).defaultData={orbitControls:EL.defaultData,playPage:xx,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let i=0,r=0;return t<5?r=-30:t<10&&(r=30),t===0||t===10||t===5?i=30:(t===4||t===11||t===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}}),B_e=U(()=>{var e;(zU||(zU={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(kU||(kU={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(e=Yv||(Yv={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...zU.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:kU.defaultData}),e.generateSeed=()=>Math.round(1e5*Math.random())}),ZX=U(()=>{Z4(),Ir(),Q4(),Nh(),la(),B_e(),(e=>{function t(i,r){let n=i.scene.objects.get(r);if(n&&n.data.type==="Component")return n;{let s=i.shared.lib.components[r];if(s)return{...s.asset,id:r}}}e.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},e.findTimeline=function(i,r){let n=i.find(s=>s.data.type==="Page"&&s.data.timelines?.[r]!==void 0);return n&&n.data.timelines?.[r]},e.getComponentData=t,e.traverseModuleInstances=function(i,r,n){i.scene.objects.traverseFrom(r,(s,a)=>{if(a.type==="Instance"){let o=t(i,a.component)?.data;o&&n(s,a,o.events)}else n(s,a,a.events)})}})(e1||(e1={})),(e=>{function t(r=!0,n=[]){let s=[];r&&s.push({...e.defaultLight}),s.push(...n);let a=new Ca;return a.push({fi:1,id:xx,data:{...my.defaultData,name:"Scene 1"},children:s}),a}function i(r){return{...e.defaultData,objects:Wo(r,Ca.prototype)}}e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:TL.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Sf.defaultData,styles:Yv.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new Ca,publish:Sf.defaultData,styles:Yv.defaultData()}},e.emptyDataWithPage=function(r=!0){return{objects:t(r),publish:Sf.defaultData,styles:Yv.defaultData()}},e.emptyData=function(){return{objects:new Ca,publish:{...Sf.defaultData},styles:Yv.defaultData()}},e.withObjs=i,e.withObj=function(r,n){return i([{id:r,data:n,children:[],fi:0}])}})(Kv||(Kv={}))}),F_e=U(()=>{(SE||(SE={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),QX=U(()=>{var e,t;Ir(),la(),(e=UW||(UW={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new It}),e.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(vte||(vte={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new It,queries:new It,autoStart:!0}),(i=>{function r(s){return s.textValue!==void 0}function n(s){return typeof s=="boolean"}i.isTextValue=r,i.isNumber=function(s){return typeof s=="number"},i.isBoolean=n,i.typeOfVariable=function(s){return r(s)?"string":n(s)?"boolean":"number"},i.getDisplayedValue=function(s){return i.isTextValue(s)?Array.isArray(s.textValue)?s.textValue.map(a=>a.toString().padStart(s.padding??2,"0")).join(s.deliminator??":")+(s.suffix!==void 0?" "+s.suffix:""):s.textValue.toString():i.isBoolean(s)?s?"True":"False":i.isNumber(s)?parseFloat(s.toFixed(3)).toString():s.toString()}})(Eo||(Eo={})),(VU||(VU={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(yte||(yte={})).all=[...VU.all,"components"],(_te||(_te={})).defaultData=function(){return{images:new si,videos:new si,colors:new si,audios:new si,particles:new si,fonts:new si,materials:new si,components:new si,variables:new si,userAPIs:new si,userWebhooks:new si}},(cf||(cf={})).defaultData=function(){return{images:new si,videos:new si,colors:new si,audios:new si,particles:new si,fonts:new si,materials:new si,components:new si,variables:new si,userAPIs:new si,userWebhooks:new si}},(t=fu||(fu={})).defaultColors=function(){return Wo({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},si.prototype)},t.defaultImages=function(){return Wo({},si.prototype)},t.emptyData=function(){return{catelogs:new si,materials:new si,images:new si,videos:new si,colors:new si,audios:new si,particles:new si,fonts:new si,variables:new It,userAPIs:new si,userWebhooks:new si,lib:cf.defaultData()}},t.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)}},t.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let n=Math.floor(i/3600),s=Math.floor((i-3600*n)/60);return{textValue:[n,s,Math.round(i-3600*n-60*s)]}}if(r.format==="mm:ss"){let n=Math.floor(i/60);return{textValue:[n,Math.round(i-60*n)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),uLe=U(()=>{}),U_e=U(()=>{var e;Ir(),ZX(),F_e(),QX(),(e=Mx||(Mx={})).defaultData={schema:132,scene:Kv.defaultData,frames:new si().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",SE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors()}},e.createDefaultData=function(){return mA.deserialize(mA.serialize(e.defaultData))},e.emptyDataForImports=function(){return{schema:132,scene:Kv.emptyDataWithPage(),frames:new si().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",SE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors(),images:fu.defaultImages()}}},e.emptyData=function(){return{schema:132,scene:Kv.emptyDataWithPage(),frames:new si().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",SE.defaultData),shared:fu.emptyData()}},e.clipboard2dData=function(){return{schema:132,scene:Kv.emptyData(),frames:new si,shared:fu.emptyData()}},e.withoutLib=function(t){return{...t,shared:{...t.shared,lib:cf.defaultData()}}},e.getComponentData=function(t,i){return e1.getComponentData(t,i)},e.hasSensitiveData=function(t){let i=Object.values(t.shared.userAPIs);for(let r of i){let n=r.headers;for(let s of n)if(s.data.key.toLowerCase()==="authorization"&&s.data.value!=="")return!0}return!1}}),dLe=U(()=>{(zW||(zW={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function gy(e,t=[0,0]){return[e&&!isNaN(e[0])?e[0]:t[0],e&&!isNaN(e[1])?e[1]:t[1]]}function LS(e,t,i){switch(e){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:n}=t??{...ew.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${n[0]}, ${n[1]} )`}case 6:{let{mass:r,stiffness:n,damping:s,velocity:a}=i??{...Pg.defaultData},o=new z_e(r,n,s,a),l=o.solve(1);return()=>u=>o.solve(u)/l}case 8:return()=>r=>Math.floor(r)}}var bte,xte,vy,bA,z_e,AL,CL,k_e=U(()=>{Ir(),Nh(),(bte||(bte={})).defaultData=function(e,t){return{id:e,name:t,duration:5,objectTimelines:new si}},(xte||(xte={})).is=function(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"},(e=>{function t(h,d){let c=[0,0],p=[1,1];if(h?.cubicControls)c=gy(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=gy(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(!e.BEZIER_PRESETS.includes(h))return;let d={type:h};return{control1:t(d).control1,control2:t(void 0,d).control2}}function r(h,d){return Math.abs(h[0]-d[0])<.001&&Math.abs(h[1]-d[1])<.001}function n(h){let d=e.ROOT_PROPERTY_ORDER.indexOf(h[0]);return d===-1?e.ROOT_PROPERTY_ORDER.length:d}function s(h){return h.layerId??h.path.join(".")}function a(h){let d=h[h.length-1];return bA.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]}}}}}e.getControlsWithDefault=t,e.BEZIER_PRESETS=[0,1,2,3,4,7],e.presetHandles=i,e.presetForHandles=function(h){return e.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,h.control1)&&r(c.control2,h.control2)})},e.defaultData=function(h){return{id:h,keyframes:new It}},e.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],e.rowOrder=n,e.propertyKey=s,e.groupKeyframes=function(h,d){let c=new Map;for(let p of h){let f=p.data;if(d?.(f))continue;let m=s(f),g=c.get(m);g||(g={id:m,path:f.path,keyframes:[],layerId:f.layerId,index:f.index},c.set(m,g)),f.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,f)=>{let m=n(p.path)-n(f.path);return m!==0?m:(p.index??0)-(f.index??0)})},e.rowAxis=a,e.drawnRowKey=o,e.drawnRows=function(h){let d=new Map;for(let c of h){let p=a(c.path),f=p?c.path.slice(0,-1):c.path,m=o(c),g=d.get(m);g||(g={id:m,path:f,layerId:c.layerId,index:c.index,tracks:[]},d.set(m,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},e.sortedKeyframes=function(h){return[...h].sort((d,c)=>d.data.time-c.data.time)},e.materialLayerPath=l,e.createMaterialGroup=function(h,d){return h.map(({data:c,id:p},f)=>u(d(),l(c),{layerId:p,index:f}))},e.placeholderKeyframe=u,e.createName=function(h){return Object.entries(h).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:LS(3),duration:1e3},opacity:{value:[0,1],easing:LS(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:LS(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:LS(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:LS(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(vy||(vy={})),bA=["x","y","z"],z_e=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),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(e){return 1-(this.m_zeta<1?Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0))}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,this.solve(t)===1){if(i++,i>=16)break}else i=0;return t*e*1e3}}}),JX=U(()=>{var e;Nh(),Ir(),(AL||(AL={})).list=["idle","move","jump","run"],(e=CL||(CL={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.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:e.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 It,move:new It,jump:new It,run:new It},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Vr.fromHexAndA(3728051,1)}}});function Nv(e,...t){let i={};for(let r of t.flat())e!=null&&r in e&&(i[r]=e[r]);return i}function wte(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,n=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)n.push(n[1]),s.push(1);let a={...Nv($s(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...$s(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Kp(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Zp(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=ns.defaultTwoLayerData("phong"),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ns.defaultTwoLayerData("phong")),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ns.defaultTwoLayerData("phong")),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&Object.getPrototypeOf(n.material)!==Ts.prototype&&t(n.material)})})}function Ste(e){e.layers===void 0&&Object.assign(e,ns.defaultTwoLayerData("lambert"))}function GU(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...$s(t),colors:i,steps:r};Object.assign(t,n)}})}function Tte(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&GU(r)}):"material"in i&&typeof i.material!="string"&&GU(i.material)}),Object.values(e.shared.materials).forEach(t=>GU(t))}function Mte(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Ete(e){e.layers&&e.layers.forEach(t=>{(function(i){return i.type!=="displace"})(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function Ate(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=hs.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Cte(e){Kp(e,Ate),Zp(e,Ate)}function Pte(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Rte(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}var cLe=U(()=>{VA(),Nh(),KX(),Z4(),Ir(),Q4(),la(),oe(),$X(),JX(),B_e(),ZX(),qX(),YX()}),V_e={};function Dte(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function G_e(e){let t=e.geometry;t!==void 0&&$_e.has(t.type)&&t.extrusionVersion===void 0&&(t.extrusionVersion=1)}function Nte(e,t){let[i,r,n]=e,s=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),u=Math.cos(n),h=Math.sin(n),d=[o*u,s*h+a*u*l,a*h-s*u*l],c=Math.hypot(t[0],t[1],t[2])||1;return Math.abs((d[0]*t[0]+d[1]*t[1]+d[2]*t[2])/c)}function j_e(e){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*ng)})(e),e.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(n,s){let a=Array.isArray(s)&&s.length>=3&&s.every(u=>typeof u=="number"&&Number.isFinite(u))?s:[0,1,0],o=Nte(n,a),l=Nte(n.map(u=>u*X_e),a);return Math.abs(o-l)<1e-6?n.some(u=>Math.abs(u)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(n=>n*ng)}(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*ng))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ng),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ng),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ng,t.extrusion.twist*=ng),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray($s(e.events))&&e.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 pLe(e){e.scene.objects.traverse((t,i)=>{})}function fLe(e){let t=e.schema??104;t!==132&&t<130&&(PL(e.asset),e.schema=130)}function Gv(e,t){t(e.data);for(let i of e.children)Gv(i,t)}function W_e(e){let t=e.schema??104;t!==132&&(t<105&&(Gv(e.asset,j_e),e.schema=105),t<118&&(Gv(e.asset,q_e),e.schema=118),t<121&&(Gv(e.asset,VW),e.schema=121),t<130&&(Gv(e.asset,mLe),e.schema=130),t<132&&(Gv(e.asset,G_e),e.schema=132))}function H_e(e,t){Zp(e,t),Kp(e,t),Object.values(e.shared.lib.materials).forEach(i=>t(i.asset))}function PL(e){e.layers===void 0&&Object.assign(e,ns.defaultTwoLayerData("phong"))}function mLe(e){"materials"in e?e.materials.forEach(t=>{t!==void 0&&typeof t!="string"&&PL(t)}):"material"in e&&e.material!==void 0&&typeof e.material!="string"&&PL(e.material)}function q_e(e){e.timelineAnimations=Wo({},si.prototype)}function gLe(e){let t=[];return e?(e.forEach((i,r)=>{let{path:n,keyframes:s}=i.data,a=n[0]==="material"?i.id:void 0;s?.length?s.forEach(({id:o,data:l})=>{t.push({id:o,data:{...l,path:n,layerId:a,index:r}})}):t.push(vy.placeholderKeyframe(i.id,n,{layerId:a,index:r}))}),t.sort((i,r)=>i.data.time-r.data.time),new It(...t.map((i,r)=>({...i,fi:r})))):new It}function vLe(e){for(let{id:t,data:i}of[...e.unproxy()]){let r=i.path?.[0];if(!r||!Y_e.includes(r))continue;let n=kW(i.value);if(!n.length)continue;let s=e.data(t);if(!s)continue;let a=i.value,[o,...l]=n;for(let u of l){let h=ht.generateUUID();e.insertBefore(null,[{id:h,data:{...i,id:h,path:[r,u],value:a[u],easing:yLe(i.easing)}}])}s.path=[r,o],s.value=a[o]}}function kW(e){return e===null||typeof e!="object"?[]:bA.filter(t=>t in e)}function yLe(e){let t=e?.cubicControls;return{...e,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...e?.springParameters?{springParameters:{...e.springParameters}}:{}}}function _Le(e,t){return Math.abs(e[0]-t[0])<1e-6&&Math.abs(e[1]-t[1])<1e-6}function bLe(e){let t=function(s){let a=[];for(let o of vy.groupKeyframes(s)){let l=new Set(o.keyframes.flatMap(h=>kW(h.data.value))),u=l.size?[...l].map(h=>o.keyframes.filter(d=>kW(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}([...e.unproxy()]),i=new Map,r=new Set;for(let{left:s,right:a}of t){let o=s.data.easing?.type,l=(o===void 0?void 0:vy.presetHandles(o))?.control2??(o===5?gy(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let u=i.get(a.id);u?_Le(u,l)||r.add(a.id):i.set(a.id,l)}let n=new Map;for(let{id:s,data:a}of e.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:vy.presetHandles(o);l&&n.set(s,l.control1)}for(let{left:s,right:a}of t)r.has(a.id)&&n.delete(s.id);for(let[s,a]of n){let o=e.data(s);!o?.easing||(o.easing.cubicControls={control1:a,control2:gy(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:s,right:a}of t){if(!n.has(s.id))continue;let o=e.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:gy(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function Ite(e,t){e.scene.objects.traverse((i,r)=>{let n=r;if(n.type==="Page"&&n.timelines)for(let s of Object.values(n.timelines))for(let a of Object.values(s.objectTimelines??{}))t(a.keyframes)})}function VW(e){e.pivot=[0,0,0],e.pivotRotation=[0,0,0]}function xLe(e){}function wLe(e){let t=e.schema??0;if(t!==132){if(t>132)return void console.error(`This scene was created with a newer version of Spline (file format ${t}, this runtime reads 132). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",t,"to ",132),function(i,r){if(r<1&&(Zp(i,wte),Kp(i,wte),i.schema=1),r<2&&(function(n){Object.assign(n.scene.publish,{orbitControls:{...EL.defaultData,...$s(n.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(n){function s(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,u]of Object.entries(o))if((K4.includes(l)||typeof u=="boolean")&&delete o[l],l==="texture")for(let[h,d]of Object.entries(u))(WX.includes(h)||typeof d=="boolean")&&delete u[h]}}}n.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let u=l;u.material?s(u.material):u.materials&&u.materials.forEach(h=>{s(h)})})})}(i),i.schema=3),r<4&&(function(n){n.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(n){n.scene.objects.traverse((s,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),r<7&&(function(n){n.scene.objects.traverse((s,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&(Tte(i),i.schema=9),r<10&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((s,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(Tte(i),i.schema=12),r<13&&(function(n){n.shared.audios=Wo({},si.prototype)}(i),i.schema=13),r<14&&(function(n){let s=n.shared.materials;Object.entries(s).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(s,{[a]:l})}})}(i),i.schema=14),r<15&&(function(n){Object.entries($s(n.shared.images)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.images[s]}),Object.entries($s(n.shared.audios)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.audios[s]})}(i),i.schema=15),r<16&&(function(n){n.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Zp(i,Mte),Kp(i,Mte),i.schema=17),r<18&&(Zp(i,Ste),Kp(i,Ste),i.schema=18),r<19&&(function(n){Object.assign(n.scene.publish.settings,{video:{...Sf.defaultData.settings.video,...$s(n.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(n){n.shared.fonts=Wo({},si.prototype)}(i),function(n){let s=[];n.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let u=ns.defaultTwoLayerData("phong"),h=typeof l.color=="string"?n.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(f){return f.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(m=>m.charAt(0).toUpperCase()+m.slice(1)).join(" ")}(l.font);n.shared.fonts[d]===void 0&&(n.shared.fonts[d]={name:d});let c={name:l.name,...ra.defaultData,..._c.defaultData,flatShading:!1,wireframe:!1,geometry:{...df.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:$s(l.states),events:$s(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=$s(n.scene.objects).parent(a);n.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),s.push(a)}}),s.forEach(a=>{n.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(n){let s={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(s[Number(l.type)])if(Object.assign(l,{type:s[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new It,move:new It,jump:new It}});else{let u=new It;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:ht.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,Nv(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let f={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},m={state:h.state,...f,...p},g={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new It({fi:0,id:ht.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:ht.generateUUID(),data:m})};u.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(n){n.scene.objects.traverse((s,a)=>{function o(l,u){let h=new It,d=[];if(a.events.forEach((c,p,f)=>{if(c.type==="Audio"&&c.trigger===u){let m;d.push(p),c.interaction==="play"?m={...Nv(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")&&(m={...Nv(c,"interaction","delay","object","playAudio"),type:"Audio"}),m&&h.push({fi:f,id:p,data:m})}}),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:ht.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&&(Cte(i),i.schema=22),r<23&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(n){n.scene.objects.traverse((s,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(function(n){n.shared.videos=Wo({},si.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(n){n.scene.objects.traverse((s,a)=>{let o=n.scene.objects.unproxy().parent(s);if(o){let l=$s(n.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=$s(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(n){n.scene.objects.traverse((s,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),r<28&&(Cte(i),i.schema=28),r<29&&(function(n){function s(o){Object.setPrototypeOf(o,Ts.prototype),o.texture&&Object.setPrototypeOf(o.texture,Ts.prototype)}function a(o){Object.setPrototypeOf(o,Ts.prototype);for(let l in o)s(o[l])}n.scene.objects.traverse((o,l)=>{l.states.forEach(u=>{let h=u;if(h.material){let d=$s(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=$s(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=ns.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((s,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),r<33&&(function(n){n.scene.objects.traverse((s,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),r<34&&(function(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(n){let{video:s}=n.scene.publish.settings;s.format==="gif"&&s.fps>48&&(s.fps=15)}(i),i.schema=35),r<36&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(n){let s=n.scene.environment.usePhysics;n.scene.objects.traverse((a,o)=>{s&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Zp(i,Ete),Kp(i,Ete),i.schema=38),r<39&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=CL.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(n){n.scene.styles||(n.scene.styles=Yv.defaultData())}(i),i.schema=40),r<41&&(function(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Zp(n,Pte),Kp(n,Pte)}(i),i.schema=41),r<42&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new It})})})}(i),i.schema=42),r<43&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Zp(i,Rte),Kp(i,Rte),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=o1);let n=$s(i.scene.objects),s=i.scene.objects;i.scene.publish.playPage=xx,s.insertBefore(null,null,[{id:xx,data:{...my.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Nv(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Nv(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Tx.defaultData,...Nv(i.scene.environment,"usePhysics","gravity")},camera:$s(i.scene.ownerCamera)??my.defaultData.camera,name:"Scene"},children:[]}]);for(let l of n)l.id!==Kv.TRASH_CAN_ID&&s.move(xx,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,Sx.defaultData)),u.physics!==void 0&&u.physics!==null&&(u.physics.enabled=u.collision??"visibility",delete u.collision)}),i.schema=99}}(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Sf.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Zp(e,Dte),Kp(e,Dte),e.schema=101),t<102&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.geometry;s&&s.type==="PathGeometry"&&(s.extrusion.capType="flat",s.extrusion.bevel=50,s.extrusion.bevelSides=6,s.extrusion.shape.type==="Custom"&&(s.extrusion.shape.shapeQuality="low"))})}(e),e.schema=102),t<104&&(e.shared.catelogs=new si,e.shared.lib=cf.defaultData(),e.schema=104),t<105&&(function(i){i.shared.variables=Wo({},si.prototype)}(e),e.scene.objects.traverse((i,r)=>{j_e(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))W_e(i);t<106&&(function(i){let r=$s(i.shared.variables);i.shared.variables=Wo(Object.entries(r??{}).map(([n,s],a)=>({fi:a,id:n,data:s})),It.prototype)}(e),e.schema=106),t<107&&(e.shared.lib.variables=cf.defaultData().variables,e.schema=107),t<109&&(function(i){i.shared.particles=Wo({},si.prototype),i.shared.lib&&(i.shared.lib.particles=cf.defaultData().particles)}(e),e.schema=109),t<110&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Particle"&&typeof n.renderMaterial.size=="number"&&Object.assign(n.renderMaterial,{size:[n.renderMaterial.size,n.renderMaterial.size]})})}(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{(function(n){Array.isArray($s(n.events))&&n.events?.forEach(s=>{"disabled"in s||(s.disabled=!1),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress")&&(s.mode=s.mode||"Object")})})(r)}),e.schema=111),t<112&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Page"&&(n.postprocessing.depthOfField.focusDistance=100,n.postprocessing.depthOfField.focalLength=20,n.postprocessing.depthOfField.bokehScale=5)})}(e),e.schema=112),t<113&&(function(i){i.scene.objects.traverse((r,n)=>{Array.isArray($s(n.events))!==!1&&n.events?.forEach(s=>{let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(o=>{s.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,s.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),s.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,s.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):s.type==="Start"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,s.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),s.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(function(i){i.shared.userAPIs=Wo({},si.prototype),i.shared.userWebhooks=Wo({},si.prototype),i.shared.lib&&(i.shared.lib.userAPIs=cf.defaultData().userAPIs,i.shared.lib.userWebhooks=cf.defaultData().userWebhooks)}(e),e.schema=115),t<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Sf.defaultData.settings.videoStatic)}(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117),t<118&&(e.shared.timelineAnimations=Wo({},si.prototype),e.scene.objects.traverse((i,r)=>{q_e(r)}),e.schema=118),t<119&&(e.scene.publish.settings.videoStatic.format=Mx.defaultData.scene.publish.settings.videoStatic.format,e.scene.publish.settings.videoStatic.imageFormat=Mx.defaultData.scene.publish.settings.videoStatic.imageFormat,e.schema=119),t<120&&(e.scene.publish.settings.image.colorSpace="display-p3",e.scene.publish.settings.videoStatic.colorSpace="display-p3",e.schema=120),t<121&&(e.scene.objects.traverse((i,r)=>{VW(r),r.type==="Page"&&r.camera!==void 0&&VW(r.camera)}),e.schema=121),t<122&&(delete e.scene.publish.settings.video,e.scene.publish.orbitControls.rotationSpeed=Mx.defaultData.scene.publish.orbitControls.rotationSpeed,e.schema=122),t<123&&(e.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=xg.defaultData)}),e.schema=123),t<124&&(t>=123&&e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(typeof n.exposure=="number"&&(n.exposure=Math.round(n.exposure/5e-4*1e4)/1e4),n.lighting===void 0&&(n.lighting=xg.defaultData.lighting))}),e.schema=124),t<125&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingIntensity===void 0&&(n.lightingIntensity=xg.defaultData.lightingIntensity)}),e.schema=125),t<126&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(n.mode===void 0&&(n.mode="physical"),n.hdri===void 0?n.hdri={...xg.defaultData.hdri}:(n.hdri.blur===void 0&&(n.hdri.blur=xg.defaultData.hdri.blur),Array.isArray(n.hdri.rotation)&&(n.hdri.rotation=n.hdri.rotation[1]??0)))}),e.schema=126),t<127&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n?.hdri!==void 0&&n.hdri.showBackground===void 0&&(n.hdri.showBackground=!0)}),e.schema=127),t<128&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingQuality===void 0&&(n.lightingQuality="full")}),e.schema=128),t<129&&(e.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=my.defaultData.camera);let n=r.camera;n.far=1e5,n.perspective?n.perspective.near=70:n.perspective={near:70,fov:45,zoom:1}}}),e.schema=129),t<130&&(H_e(e,PL),e.schema=130),t<131&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.states;if(!s)return;let a=n.timelineAnimations,o=[];s.forEach((l,u)=>{(l.isAnimation||a?.[u])&&o.push(u)}),o.forEach(l=>s.delete(l))})}(e),function(i){let r=i.shared,n=r.timelineAnimations;if(!n)return;let s=i.scene.objects,a=s.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(n)){let u=Wo({},si.prototype),h=0,d=Boolean(l.loop);for(let[f,m]of Object.entries(l.mapping??{})){let g=s.data(f)?.timelineAnimations?.[m];!g||(h=Math.max(h,g.to??0),d=d||Boolean(g.loop),u[f]={id:f,keyframes:gLe(g.properties?.unproxy())})}let c=l.page??a,p=c?s.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=Wo({},si.prototype)))[o]={id:o,name:l.name,duration:h||5,...d?{loop:d}:{},objectTimelines:u})}delete r.timelineAnimations,s.traverse((o,l)=>{delete l.timelineAnimations})}(e),Ite(e,vLe),Ite(e,bLe),e.schema=131),t<132&&(e.scene.objects.traverse((i,r)=>G_e(r)),e.schema=132)}}cw(V_e,{updateAllMaterials:()=>H_e,updateDocumentSchema:()=>wLe,updateLibSchema:()=>xLe,updateMaterialSchema:()=>fLe,updateObjectStateRec:()=>Gv,updateObjectsSchema:()=>W_e,updateTextValues:()=>pLe});var $_e,ng,X_e,Y_e,Ote,h3,jU,Lte,u3,Zv,BS,j1,d3,WU,CI,HU,qU,Bte,PI,$U,yy,GW,J4=U(()=>{oe(),U_e(),Ir(),k_e(),cLe(),Q4(),VA(),la(),QX(),Z4(),XX(),$_e=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),ng=180/Math.PI,X_e=Math.PI/180,Y_e=["position","rotation","scale","shape size"]}),SLe=U(()=>{var e,t,i;Nh(),Ir(),la(),(Ote||(Ote={})).is=function(r){return!0},(e=h3||(h3={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},e.merge=function(r,n){return{position:n?.position??r.position,rotation:n?.rotation??r.rotation,scale:n?.scale??r.scale,shear:n?.shear??r.shear}},e.diff=function(r,n){return t_e({position:Bc.isEqual(r.position,n.position)?void 0:n.position,rotation:r.rotation===n.rotation?void 0:n.rotation,scale:Bc.isEqual(r.scale,n.scale)?void 0:n.scale,shear:r.shear&&n.shear&&Bc.isEqual(r.shear,n.shear)?void 0:n.shear})},(jU||(jU={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(Lte||(Lte={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(u3||(u3={})).defaultData={opacity:1,fill:{color:Vr.fromHexAndA(eo,1),enabled:!0},stroke:{color:Vr.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:Vr.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Vr.from0to1([0,0,0,1]),enabled:!1,spread:0}},(t=Zv||(Zv={})).newEmpty=function(r,n){return{name:n}},t.patch=function(r,n){if(n===void 0)return r;let s={...r};return Object.assign(s,h3.merge(s,n)),s=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}(s,n),s=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(s,n),s},t.toOps=function(r,n){let s,a=[];for(let[o,l]of Object.entries(n))o!=="name"&&(s===void 0&&(s={path:[],props:{},type:0},a.push(s)),s.props[o]=l);return a},(BS||(BS={})).defaultData={...h3.defaultData,...jU.defaultData,states:new It,events:new It,visible:!0,raycastLock:!1},(j1||(j1={})).defaultData={...BS.defaultData,...u3.defaultData},(d3||(d3={})).defaultData={cornerRadius:[0,0,0,0]},(WU||(WU={})).defaultData={...j1.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(CI||(CI={})).defaultData={...j1.defaultData,...d3.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(HU||(HU={})).defaultData={...j1.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"},(qU||(qU={})).defaultData={...j1.defaultData,type:"path2d",path:"",name:"Path"},(Bte||(Bte={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(PI||(PI={})).defaultData={...BS.defaultData,name:"Group",type:"group2d"},($U||($U={})).defaultData=()=>({...BS.defaultData,...d3.defaultData,...u3.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Vr.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Vr.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(n){switch(n){case"rectangle2d":case"vector2d":return{...CI.defaultData};case"ellipse2d":return{...WU.defaultData};case"text2d":return{...HU.defaultData};case"path2d":return{...qU.defaultData};case"frame2d":return{...$U.defaultData()};case"group2d":return{...PI.defaultData}}},r.getPivot=function(n){return"width"in n&&"height"in n?[typeof n.width=="number"?.5*n.width:0,typeof n.height=="number"?.5*n.height:0]:[0,0]},r.isResizeable=function(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"},r.isAutoLayoutable=function(n){return n.type==="frame2d"&&n.autoLayout!==void 0},r.hasCorners=function(n){return n.type==="rectangle2d"||n.type==="frame2d"}})(yy||(yy={})),(i=GW||(GW={})).defaultData={name:"UI",type:"scene2d",objects:new Ca},i.emptyData=function(){return{type:"scene2d",objects:new Ca}}}),TLe=U(()=>{nLe(),sLe(),T_e(),M_e(),U_e(),x_e(),dLe(),R_e(),I_e(),XX(),J4(),F_e(),$X(),qX(),E_e(),VA(),P_e(),L_e(),Nh(),Q4(),Z4(),KX(),N_e(),QX(),ZX(),oLe(),D_e(),JX(),YX(),A_e(),C_e(),SLe()});function Qv(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),n=new Set(Object.keys(e[0].morphAttributes)),s={},a={},o=e[0].morphTargetsRelative,l=new At,u=0;for(let h=0;h<e.length;++h){let d=e[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;s[p]===void 0&&(s[p]=[]),s[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(!n.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(t){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<e.length;++c){let p=e[c].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+h);h+=e[c].attributes.position.count}l.setIndex(d)}for(let h in s){let d=Fte(s[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 m=0;m<a[h].length;++m)p.push(a[h][m][c]);let f=Fte(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}}return l}function Fte(e){let t,i,r,n=-1,s=0;for(let u=0;u<e.length;++u){let h=e[u];if(t===void 0&&(t=h.array.constructor),t!==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(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*i}let a=new t(s),o=new Rt(a,i,r),l=0;for(let u=0;u<e.length;++u){let h=e[u];if(h.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=h.count;c<p;c++)for(let f=0;f<i;f++){let m=h.getComponent(c,f);o.setComponent(c+d,f,m)}}else a.set(h.array,l);l+=h.count*i}return n!==void 0&&(o.gpuType=n),o}var GA=U(()=>{oe()});function K_e(e){let t=e.points.length/7,i=new It;for(let r=0;r<t;r++){let n=7*r,s=e.points[n+0],a=e.points[n+1],o=e.points[n+2],l=e.points[n+3],u=e.points[n+4],h=e.points[n+5],d=e.points[n+6];i.push({fi:r,id:ht.generateUUID(),data:{roundness:d,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[u,h]}}})}return{points:i,isClosed:e.isClosed,roundness:e.roundness,shapeHoles:e.shapeHoles?.map(r=>K_e(r))??[]}}function Z_e(e){let{userData:t,uuid:i,...r}=e;if(t===void 0||t.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:u}=a,h=u?.groups,d=u?.attributes??{},c=u?.morphAttributes??{},p=u?.interleavedBuffers,f=u?.arrayBuffers,m=u?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(v){let y=1/0,_=1/0,b=1/0,x=-1/0,w=-1/0,S=-1/0;for(let T=0;T<v.length;T+=3){let M=v[T],E=v[T+1],A=v[T+2];y=Math.min(y,M),_=Math.min(_,E),b=Math.min(b,A),x=Math.max(x,M),w=Math.max(w,E),S=Math.max(S,A)}return{width:x-y,height:w-_,depth:S-b}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:f},...o===void 0?{}:o,type:"NonParametricGeometry"};return m!==void 0&&Object.assign(g.data,{index:m}),h!==void 0&&Object.assign(g.data,{groups:h.map(v=>({...v,materialIndex:v.materialIndex??0}))}),g}(e);if(t.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let u=new At;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 Et(h,3)),u.setIndex(new kf(c,1));let p=function(v,y=1e-4){y=Math.max(y,Number.EPSILON);let _={},b=v.getIndex(),x=v.getAttribute("position"),w=b?b.count:x.count,S=0,T=Object.keys(v.attributes),M={},E={},A=[],P=["getX","getY","getZ","getW"],N=["setX","setY","setZ","setW"];for(let G=0,Y=T.length;G<Y;G++){let $=T[G],Q=v.attributes[$];M[$]=new Q.constructor(new Q.array.constructor(Q.count*Q.itemSize),Q.itemSize,Q.normalized);let ue=v.morphAttributes[$];ue&&(E[$]||(E[$]=[]),ue.forEach((pe,xe)=>{let we=new pe.array.constructor(pe.count*pe.itemSize);E[$][xe]=new pe.constructor(we,pe.itemSize,pe.normalized)}))}let D=.5*y,O=Math.log10(1/y),z=Math.pow(10,O),L=D*z;for(let G=0;G<w;G++){let Y=b?b.getX(G):G,$="";for(let Q=0,ue=T.length;Q<ue;Q++){let pe=T[Q],xe=v.getAttribute(pe),we=xe.itemSize;for(let re=0;re<we;re++)$+=~~(xe[P[re]](Y)*z+L)+","}if($ in _)A.push(_[$]);else{for(let Q=0,ue=T.length;Q<ue;Q++){let pe=T[Q],xe=v.getAttribute(pe),we=v.morphAttributes[pe],re=xe.itemSize,Se=M[pe],W=E[pe];for(let k=0;k<re;k++){let K=P[k],ie=N[k];if(Se[ie](S,xe[K](Y)),we)for(let j=0,ae=we.length;j<ae;j++)W[j][ie](S,we[j][K](Y))}}_[$]=S,A.push(S),S++}}let V=v.clone();for(let G in v.attributes){let Y=M[G];if(V.setAttribute(G,new Y.constructor(Y.array.slice(0,S*Y.itemSize),Y.itemSize,Y.normalized)),G in E)for(let $=0;$<E[G].length;$++){let Q=E[G][$];V.morphAttributes[G][$]=new Q.constructor(Q.array.slice(0,S*Q.itemSize),Q.itemSize,Q.normalized)}}return V.setIndex(A),V}(u),f=[],m=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let v=0,y=d.length;v<y;)d[v]===d[v+1]?(m[d[v]]++,f.push(...new Set(g.slice(3*v,3*v+6))),v+=2):(f.push(...g.slice(3*v,3*v+3)),v++);o.indexWASM={array:f},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:m}}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,...MLe(o.positionWASM.array)};l.subdivisions=t.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 n=t.type,s=t.parameters;return n==="VectorGeometry"?(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,width:100,height:100,shape:K_e(t.shape),type:n}):n==="LatheGeometry"?{...t.parameters,type:n,points:(t?.parameters.points??[]).map(a=>[a.x,a.y])}:(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,type:n})}function MLe(e){return jW.setFromArray(e),jW.getSize(PM),{width:PM.x,height:PM.y,depth:PM.z}}var jW,PM,XU,ELe=U(()=>{Ir(),oe(),GA(),new Ue,new kt,new Kr,new R,new R,jW=new fn,PM=new R}),ALe=U(()=>{var e;(e=XU||{}).view="view",e.edit="edit",((XU=e)||(XU={})).canWrite=function(t){return t!=="view"},class extends Error{constructor(t,i){super(`This is a ${t.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=t,this.expected=i,this.name="DocumentKindMismatchError"}}}),Q_e,Wf,TE,J_e,eY,gw,FS,c3,YU,vw,Ute,KU,zte,ZU,tw,dm,cm,lp,QU,kte,Vte,JU,WW,Tf,ebe=U(()=>{ALe()}),CLe=U(()=>{}),PLe=U(()=>{Ir(),J4(),ebe()}),RLe=U(()=>{VA(),[...K4],new Set(WX)}),jt=U(()=>{TLe(),CLe(),uLe(),J4(),PLe(),ebe(),k_e(),RLe(),JX(),Ir()}),Cd=U(()=>{Q_e=[3,4,8,9],Wf=5,TE=3,J_e=32,eY=.98}),jA=U(()=>{oe(),gw=e=>{var t;return(t=class extends e{}).geometryHelper=new Dh(30,30,30),t}}),WA=U(()=>{oe(),FS=new yf,c3=new qa,YU=new Ue,vw=(e,t,i,r,n=!1,s=e)=>{let a=t,o=s.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),c3.copy(a.boundingSphere),c3.applyMatrix4(o),i.ray.intersectsSphere(c3)===!1||(YU.copy(o).invert(),FS.copy(i.ray).applyMatrix4(YU),a.boundingBox!==null&&FS.intersectsBox(a.boundingBox)===!1))return;let l,u,h,d,c,p,f=a.index,m=a.attributes.position,g=a.drawRange;if(n===!1){for(c=Math.max(0,g.start),p=Math.min(f.count,g.start+g.count);c<p;c+=3)if(u=f.getX(c),h=f.getX(c+1),d=f.getX(c+2),l=v(e,i,FS,m,u,h,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let y=a.attributes.position,_=new R,b=new R,x=new R,w=new R,S=2,T=1/((s.scale.x+s.scale.y+s.scale.z)/3),M=T*T;for(let E=Math.max(0,g.start),A=Math.min(y.count,g.start+g.count)-1;E<A;E+=S){if(_.fromBufferAttribute(y,E),b.fromBufferAttribute(y,E+1),FS.distanceSqToSegment(_,b,w,x)>M)continue;w.applyMatrix4(s.matrixWorld);let P=i.ray.origin.distanceTo(w);P<i.near||P>i.far||r.push({distance:P,point:x.clone().applyMatrix4(s.matrixWorld),object:e})}}function v(y,_,b,x,w,S,T){let M=new R,E=new R,A=new R,P=new R,N=new R;if(M.fromBufferAttribute(x,w),E.fromBufferAttribute(x,S),A.fromBufferAttribute(x,T),b.intersectTriangle(M,E,A,!1,P)===null)return null;N.copy(P),N.applyMatrix4(y.matrixWorld);let D=_.ray.origin.distanceTo(N);return D<_.near||D>_.far?null:{faceIndex:1,distance:D,point:N.clone(),object:y}}}}),eB=U(()=>{oe(),jA(),WA(),Ute=new R(1,1,1),KU=new R,zte=new R,ZU=new kt,tw=class extends gw(w1e){constructor(e,t=15){super(t),this.object=e,this.dummy=new fw,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){vw(this.object,tw.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(KU,ZU,zte),this.matrix.compose(KU,ZU,Ute),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}}}),DLe=U(()=>{oe(),dm=new R,cm=new R,lp=new Ue,QU=[new R(-1,1,1),new R(-1,-1,1),new R(1,-1,1),new R(1,1,1),new R(-1,1,-1),new R(-1,-1,-1),new R(1,-1,-1),new R(1,1,-1)],kte=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Vte=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],JU=(e,t,i)=>{e.updateEntityBoxSize(dm,cm),lp.copy(t).multiply(e.matrixWorld),cm.x===0&&cm.y===0&&cm.z===0?i.push(new R(dm.x,dm.y,dm.z).applyMatrix4(lp)):QU.forEach(r=>{i.push(r.clone().multiply(cm).add(dm).applyMatrix4(lp))})},WW=class extends fn{constructor(){super(...arguments),this.matrix=new Ue,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new Ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];if(i===!0){let n=[];e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s))return lp.copy(t).multiply(s.matrixWorld),void n.push(new R().applyMatrix4(lp));JU(s,t,r)}}),r.length===0&&r.push(...n)}else JU(e,t,r);return this.setFromPoints(r)}getCenter(e){return(e=super.getCenter(e)).applyMatrix4(this.matrix),e}getPositionToCenter(e){return(e=super.getCenter(e)).applyMatrix4(lp.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(cm).multiplyScalar(.5),this.getCenter(dm),lp.copy(this.matrix).setPosition(dm),this.vertices=QU.map(e=>e.clone().multiply(cm).applyMatrix4(lp))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=kte.map(([e,t])=>new Eh(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new R))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Vte.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}}}),RL=U(()=>{Tf={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function ME(e){return e?.isParticleSystem===!0}function t1(e){return e?.isHairSystem===!0}function Hf(e){return e?.isShapeBlendEntity===!0}function tB(e){return e?.isPathObject===!0}function Ql(e){return e?.isObject2D===!0}function Xo(e){return e?.isUIObject===!0}function ex(e){return e?.isCloner===!0}function Jv(e){return e?.isClone===!0}function RI(e){return e?.isComponentObject===!0}var ss=U(()=>{});function Nn(e){tY.add(e)}function Ma(e,t){let i=`${e}:${t}`;$W.has(i)||$W.add(i)}function DL(e,t){iY.set(e,t)}function e5(e){return iY.get(e)}function yw(e,t){rY.set(e,t)}function t5(e){return rY.get(e)}function HW(e,t){nY.set(e,t)}function tbe(e){return nY.get(e)}function qW(){return iB}var tY,$W,iY,rY,nY,iB,NL,_r=U(()=>{tY=new Set,$W=new Set,iY=new Map,rY=new Map,nY=new Map,iB=null,NL=null});function ibe(e){let t=e.elements;ud.set(t[0],t[1],t[2]),dd.set(t[4],t[5],t[6]),Ec.set(t[8],t[9],t[10])}function rbe(){let e=Math.max(ud.lengthSq(),dd.lengthSq(),Ec.lengthSq());ud.lengthSq()>RM*e?Th.copy(ud).normalize():Th.set(1,0,0),Mh.crossVectors(Ec,Th),Mh.lengthSq()<=RM*e&&(Mh.copy(dd).addScaledVector(Th,-dd.dot(Th)),Mh.lengthSq()<=RM*e&&function(t,i){t.set(1,0,0).cross(i),t.lengthSq()<=RM&&t.set(0,1,0).cross(i),t.normalize()}(Mh,Th)),Mh.normalize(),ey.crossVectors(Th,Mh)}var ud,dd,Ec,Th,Mh,ey,nbe,RM,DM,p3,ty,rB,sbe=U(()=>{oe(),ud=new R,dd=new R,Ec=new R,Th=new R,Mh=new R,ey=new R,nbe=new Ue,RM=1e-12,DM=.01}),HA=U(()=>{oe(),sbe(),p3=new Ue,(ty||(ty={})).is=function(e){return e&&e.__isSPEObject},rB=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new Ue,this.copyPreviousMatrix=!0,this.hiddenMatrix=new Ue,this.pivotMatrix=new Ue,this.matrixWorldRigid=new Ue,this.shearScale=new Ue,this.shearScaleInv=new Ue}get __isSPEObject(){return!0}getPhysicsLocalMatrix(t){return!!this.rigidBody?.isDynamic()&&(t.copy(this.matrixWorld),this.hasNonUniformScale&&t.multiply(this.shearScaleInv),this.parent&&t.premultiply(p3.copy(this.parent.matrixWorld).invert()),t.premultiply(p3.copy(this.hiddenMatrix).invert()),t.multiply(p3.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(t){t instanceof un&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(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,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&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 n of this.children)n.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)ty.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)ty.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(t,i,r){return ibe(t),rbe(),i.makeBasis(Th,Mh,ey),r.set(Th.dot(ud),Th.dot(dd),Th.dot(Ec),0,Mh.dot(ud),Mh.dot(dd),Mh.dot(Ec),0,ey.dot(ud),ey.dot(dd),ey.dot(Ec),0,0,0,0,1),function(){let n=ud.length(),s=dd.length(),a=Ec.length(),o=Math.max(n,s,a);if(o-n>DM||o-s>DM||o-a>DM)return!0;let l=DM*o*o;return Math.abs(ud.dot(dd))>l||Math.abs(ud.dot(Ec))>l||Math.abs(dd.dot(Ec))>l}()}(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new Ue().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Ue?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,n,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function Gte(e,t,i){return wg.subVectors(t,e),xA.subVectors(t,i),wg.cross(xA).length()<=EE}function abe(e){let t=KW.get(e.points);if(t!==void 0&&t.isClosed===e.isClosed)return t.curve;let i=function(r){let n=r.points,s=[n[0]],a=[new R(...n[0].data.position)];Iv.copy(a[0]);for(let v=0;v<n.length-1;v++)wg.fromArray(n[v].data.position),xA.fromArray(n[v+1].data.position),Db.subVectors(wg,Iv),Nb.subVectors(wg,xA),Db.cross(Nb).length()>EE&&(s.push(n[v]),a.push(new R().copy(wg)),Iv.copy(wg));let o=n[n.length-1];s.push(o),a.push(new R(...o.data.position));let l=r.isClosed,u=s.length-(l?0:1),h=s.length,d=[],c=[];for(let v=0;v<h;v++){let y=s[v].data;d.push(new R(...y.controlPrevious.position)),c.push(new R(...y.controlNext.position))}let p=[];for(let v=0;v<u;v++){let y=v===h-1?0:v+1;p.push(Gte(a[v],c[v],a[y])&&Gte(a[v],d[y],a[y]))}let f=[];for(let v=0;v<h;v++){let y=s[v].data,_=a[v],b={position:_,prevDir:void 0,nextDir:void 0,controlPrevious:d[v],controlNext:c[v],tan:void 0,baseRoundness:y.roundness,removedLength:0};if(f.push(b),y.roundness===0||!l&&(v===0||v===h-1))continue;let x=l&&v==0?h-1:v-1,w=l&&v==h-1?0:v+1,S=new R().subVectors(a[x],_).normalize(),T=new R().subVectors(a[w],_).normalize();b.prevDir=S,b.nextDir=T;let M=p[l&&v===0?h-1:v-1],E=p[v];if(M&&E){Ov.addVectors(S,T).normalize();let A=Iv.crossVectors(Ov,S).length()/S.dot(Ov);b.tan=A,b.removedLength=y.roundness/A}}for(let v=0;v<u;v++){let y=l&&v===h-1?0:v+1,_=f[v],b=f[y];if(_.removedLength!==0||b.removedLength!==0){let x=_.position.distanceTo(b.position);_.removedLength=Math.min(_.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let m=new Array(2*h).fill(null);for(let v=0;v<u;v++){let y=l&&v===h-1?0:v+1,_=f[v],b=f[y],x=null;if(p[v]){let w=_.position.clone(),S=b.position.clone();(_.removedLength!==0||b.removedLength!==0)&&(_.nextDir&&w.add(Iv.copy(_.nextDir).setLength(_.removedLength)),b.prevDir&&S.add(Iv.copy(b.prevDir).setLength(b.removedLength))),w.distanceTo(S)>EE&&(x=new gE(w,w.clone().lerp(S,.3),S.clone().lerp(w,.3),S))}else _.position.distanceTo(b.position)>EE&&(x=new gE(_.position,_.controlNext,b.controlPrevious,b.position));m[2*v+1]=x}for(let v=0;v<h;v++){let y=f[v];if(y.removedLength===0)continue;let _=y.position,b=y.prevDir.clone().multiplyScalar(y.removedLength).add(_),x=y.nextDir.clone().multiplyScalar(y.removedLength).add(_),w=y.tan*y.removedLength;Ov.addVectors(y.prevDir,y.nextDir).normalize(),Db.copy(b).lerp(x,.5);let S=b.distanceTo(x)/2;YW.copy(Ov).multiplyScalar(Math.sqrt(Math.pow(w,2)-Math.pow(S,2))).add(Db),DI.copy(Ov).multiplyScalar(-w).add(YW);let T=_.distanceTo(DI)/_.distanceTo(Db);Nb.copy(y.prevDir).multiplyScalar(T*_.distanceTo(b)).add(_),XW.copy(Nb).lerp(DI,2);let M=b.clone().lerp(Nb,4/3),E=x.clone().lerp(XW,4/3);m[2*v]=new gE(b,M,E,x)}let g=new obe;for(let v=0;v<m.length;v++){let y=m[v];y&&g.add(y)}return g}(e);return KW.set(e.points,{isClosed:e.isClosed,curve:i}),i}var obe,EE,wg,xA,Iv,Ov,Db,DI,Nb,XW,YW,KW,Ib,ZW,NI,lbe,hbe,ube,lr,bc,jte,Wte,US,i5,f3,r5,n5,nB,QW,l1,Ac,dbe=U(()=>{oe(),obe=class extends U7{constructor(){super()}getPoints(e=12){let t,i=[],r=this.getCurveLengths(),n=r[r.length-1]/r.length;for(let s=0,a=this.curves;s<a.length;s++){let o=a[s],l=s===0?r[s]:r[s]-r[s-1],u=Math.ceil(e*l/n),h=o.getPoints(u);for(let d=0;d<h.length;d++){let c=h[d];t&&t.equals(c)||(i.push(c),t=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},EE=.001,wg=new R,xA=new R,Iv=new R,Ov=new R,Db=new R,DI=new R,Nb=new R,XW=new R,YW=new R,KW=new WeakMap}),NLe=U(()=>{oe(),Ib=new Ue,ZW=new kt,NI=new kt,lbe=new Kr,hbe=new R,ube=new R(0,1,0)}),xl=U(()=>{oe(),jt(),DLe(),Ir(),RL(),ss(),_r(),HA(),dbe(),NLe(),Gr(),(lr||(lr={})).is=function(e){return e&&e.__isEntity},bc=e=>lr.is(e),jte={type:"completeState",isfromEntity:!0},Wte=["x","y","z"],US=new R,i5=new R(1,1,1),f3=new kt,r5=new Kr,n5=new Ue,nB=e=>class extends rB(e){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 WW,this._recursiveBBox=new WW,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(lr.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(lr.is(this.children[t]))return t+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 t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(!lr.is(i))return;t=i}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(this.data.states.length!==0||r){for(let n of this.data.states)Dg.toOps(this.data,n.data).forEach(s=>{let a=lL.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let n=this.data.states.data(t);n&&(this.dataPatched=Dg.patch(this.data,n),Dg.toOps(this.data,n).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,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(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{bc(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(lr.is(i[r]))return i[r];if(lr.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&lr.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)bc(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{lr.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)bc(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)bc(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)bc(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>bc(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){return this.updateWorldMatrix(!0,!1),oW({position:this.position.toArray(),rotation:[this.rotation.x*ht.RAD2DEG,this.rotation.y*ht.RAD2DEG,this.rotation.z*ht.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},t)}getTransformValues(t,i,r){return i[t].map((n,s)=>r?.shared.getVariable(n,[this.uuid,t,Wte[s]])??n)}updateTransformState(t,i){let r=!1;if(t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(US.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(ht.DEG2RAD),this.rotation.setFromVector3(US),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??wx.identity)),t.pivot!==void 0||t.pivotRotation!==void 0){if(r=!0,t.pivot!==void 0&&t.pivotRotation!==void 0)this.pivotMatrix.compose(US.fromArray(t.pivot).negate(),f3.setFromEuler(r5.fromArray(t.pivotRotation.map(n=>n*ht.DEG2RAD))).invert(),i5);else if(t.pivot!==void 0)this.pivotMatrix.setPosition(-t.pivot[0],-t.pivot[1],-t.pivot[2]);else if(t.pivotRotation!==void 0){let n=US.setFromMatrixPosition(this.pivotMatrix);f3.setFromEuler(r5.fromArray(t.pivotRotation.map(s=>s*ht.DEG2RAD))).invert(),this.pivotMatrix.compose(n,f3,i5)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){t?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 t of this.children)lr.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{lr.is(t)&&t.disposeRecursively()})}toState(t=[]){return oW({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)},t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,n){let s=this.data;this.data=i;let a=t,o=Jr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let u={...t.props};if(delete u.name,Object.values(t.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let d=Ta.zoom(h,t.path.slice(2));if(d)for(let c in t.props)t.props[c]===void 0&&c in d&&(u[c]=d[c])}}a={...t,props:u,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:h,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:h,...d}=l;l=d}let u=Ta.removeOverridden(t.path,t.props,l);a={...t,props:u}}}if(this.updateByPatchedOpBase(a,Dg.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Jr(t.path,["overrides"])){let l=[],u=[...t.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(t.type===0)for(let h of Object.keys(t.props)){l[l.length-1]=h;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[h],d.updateState(Fg.apply(d.component.data,d.overrideData),r))}}else{let h=r.scene.findInstance([this.uuid,...l]);if(h){let d=Ta.zoom(h.component.data,u);if((t={...t,path:u}).type===0){let c=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(c===t.props&&(c={...t.props}),c[p]=d[p]);t={...t,props:c}}h.overrideData=ML.resolve(i.overrides,l),h.updateByOp(t,Xa.applySimple(h.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let u;for(let h of wf.rootOverrideProps)h in t.props&&(u===void 0&&(u={}),u[h]=t.props[h]);u&&(l={...t,props:u})}else for(let u of wf.rootOverrideProps)if(Jr(t.path,[u])){l=t;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let h=Fg.filterOp(u.overrideData,l);h&&u.updateByOp(h,Xa.applySimple(u.data,h),r,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let h=Fg.filterOp(u.overrideData,t);if(h){let d;d=s===u.data&&t===h?i:Xa.applySimple(u.data,h),u.updateByOp(h,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Jy.is(t.props.type)&&Tf.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Tf.changeEntityProptotype(this,i,r);for(let n of this.children)lr.is(n)&&n.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let n=i.morphTargetInfluences.get(t.path[1])?.data.name;n&&this.updateMorphInfluences(n,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",n]))}if(Jr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Jr(t.path,["cloner"])!==null){let n=Xa.drop(t,1);n.path.length===0&&n.type===0&&n.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(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,n=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=abe(o.geometry.path),u=function(p){let f=p%1;return f<0?f+1:f===0&&p>0?1:f}(r+n),h=null;try{h=l.curves.length?l.getPointAt(u):null}catch{}if(h===null)return;a.updateMatrixWorld();let d=this.parent?n5.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):n5.copy(this.hiddenMatrix),c=function(p,f,m,g){ZW.setFromRotationMatrix(Ib.extractRotation(g));let v=p.clone().applyMatrix4(Ib.copy(g).invert().multiply(m));if(f===null)NI.setFromRotationMatrix(Ib.extractRotation(m));else{let y=f.clone().applyMatrix4(Ib.extractRotation(m));NI.setFromRotationMatrix(Ib.lookAt(hbe.set(0,0,0),y,ube))}return{position:v,rotation:new R().setFromEuler(lbe.setFromQuaternion(ZW.invert().multiply(NI))).multiplyScalar(ht.RAD2DEG)}}(h,s==="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(jte)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>ex(t)&&t.parameters.type==="toObject")}setFromClonerState(t,i){if(!this.disposed)if(t===null||t.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Tf.Cloner===null)return void Ma("cloners","a cloner");this.cloner=new Tf.Cloner(this,t),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(t,i)}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),h1=U(()=>{oe(),xl(),(QW||(QW={})).is=e=>"objectHelper"in e,l1=(e,t)=>class extends nB(e){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof dA&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Dh?(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 dA&&(r.visible=!1)}}}}),sB=U(()=>{oe(),eB(),h1(),Ac=class extends l1(fw,tw){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&Object.keys(e).length===1&&t.scene.reloadSplats()}}});function Pu(e,t,i,r,n,s,a){NM.set(n,s,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let u=0,h=o.length;u<h;u++)l.setXYZ(o[u],NM.x,NM.y,NM.z)}}var NM,nh,Hte,cbe,ILe=U(()=>{oe(),jA(),WA(),NM=new R,nh=new Eg,Hte=class extends Mb{constructor(e){let t=new At,i=new ad({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],s={},a=new ot(15711266),o=new ot(15711266),l=new ot(2857471);function u(d,c,p){h(d,p),h(c,p)}function h(d,c){r.push(0,0,0),n.push(c.r,c.g,c.b),s[d]===void 0&&(s[d]=[]),s[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),t.setAttribute("position",new Et(r,3)),t.setAttribute("color",new Et(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap;nh.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;Pu("n1",t,e,nh,-1,-1,i),Pu("n2",t,e,nh,1,-1,i),Pu("n3",t,e,nh,-1,1,i),Pu("n4",t,e,nh,1,1,i);let r=i;Pu("f1",t,e,nh,-1,-1,r),Pu("f2",t,e,nh,1,-1,r),Pu("f3",t,e,nh,-1,1,r),Pu("f4",t,e,nh,1,1,r);let n=r;Pu("u1",t,e,nh,.35,1.1,n),Pu("u2",t,e,nh,-.35,1.1,n),Pu("u3",t,e,nh,0,1.55,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},cbe=class extends gw(Hte){constructor(e){super(e),this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){vw(this.object,this.geometry,e,t,!0)}}});function qte(e){return 1-Math.pow(1-e,3)}var R0,m3,g3,v3,W1,y3,Hd,Yn,Ih=U(()=>{oe(),ILe(),jt(),h1(),Gr(),R0=new R,m3=new R,g3=new kt,v3=new R,W1=new R,y3=new R,Hd=class extends l1(Eg,cbe){constructor(e="",t={...wE.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=xf.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let n=this._projectionTransition;if(n===void 0)return;if(this.disposed)return void this._endProjectionTransition();n.raf=requestAnimationFrame(this._tickProjectionTransition);let s=Hd.projectionTransitionRequestRender??n.requestRender;this.updateProjectionMatrix(),s?.()},this.super_Entity(e,t),this.previousProjectionMatrix=new Ue,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Hg(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new bh(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(e){let t=Hd.projectionTransitionsEnabled;Hd.projectionTransitionsEnabled=!1;try{return e()}finally{Hd.projectionTransitionsEnabled=t}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){typeof e=="number"&&(e=new R(e,t,i)),super.lookAt(e),this.getWorldPosition(R0),this.targetOffset=R0.distanceTo(e)}getTarget(e=new R){return this.getWorldDirection(m3),this.getWorldPosition(R0),m3.multiplyScalar(this.targetOffset),e.copy(R0).add(m3),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(R0),R0.distanceTo(e)}updateUp(){this.getWorldQuaternion(g3),v3.set(0,0,1).applyQuaternion(g3),W1.copy(un.DEFAULT_UP),this.isUpVectorFlipped&&W1.negate(),W1.applyQuaternion(g3),y3.copy(un.DEFAULT_UP).projectOnPlane(v3),this.angleOffsetFromUp=y3.angleTo(W1),this.angleOffsetFromUp*=y3.cross(W1).dot(v3)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new R),i=e.getWorldDirection(new R).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new R).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new R;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let r=e>t?this.aspect:1,n=e>t?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/n*395,this.bottom=1/n*-395}else this.left=.5*-e,this.right=.5*e,this.top=.5*t,this.bottom=.5*-t;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.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 e=this._projectionTransition;if(e===void 0)return 1;let t=(performance.now()-e.start)/e.duration;return t>=1?1:t<=0?0:qte(t)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Hd.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Hd.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let t=this._projectionTransition;t===void 0&&(t={from:new Ue,blend:new Ue,blendInverse:new Ue,start:0,duration:Hd.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=t),t.from.copy(this.projectionMatrix),t.start=performance.now(),t.duration=Hd.projectionTransitionDuration,t.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(t.requestRender=e),t.raf!==0&&cancelAnimationFrame(t.raf),t.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let t=(performance.now()-e.start)/e.duration;if(t>=1)return void this._endProjectionTransition();let i=qte(t),r=e.from.elements,n=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,a=e.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,n[15]-n[11]*a));for(let u=0;u<16;u++)s[u]=r[u]+(n[u]-r[u])*l;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let t=this._activeSubCamera;this.projectionMatrix=t.projectionMatrix,this.projectionMatrixInverse=t.projectionMatrixInverse}_syncProjectionTransition(e){let t=e._projectionTransition;if(t===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new Ue,blend:new Ue,blendInverse:new Ue,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(t.from),i.start=t.start,i.duration=t.duration,i.referenceDepth=t.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,i,r,n,s):this.orthoCamera.setViewOffset(e,t,i,r,n,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=xf.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){return oW({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},e)}updateCameraSubtype(e,t){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(i,t.zoom),t.near!==void 0&&this.setNear(i,t.near),t.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(t?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(i=>typeof i=="number"?i:0)),e.targetOffset!==void 0&&(this.targetOffset=xf.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},(Yn=Hd).projectionTransitionsEnabled=!1,Yn.projectionTransitionDuration=350,Yn.projectionTransitionMinAgeMs=1e3});function pbe(e){return e.type==="TorusGeometry"&&e.arc===360}var fbe,_3,JW,wA=U(()=>{oe(),fbe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??r),s=Math.abs(i.depth??r),a=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:n,depth:s,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:n,revolutions:s,segments:a,pathRadius:o,pathType:l,pathSegments:u,cornerRadius:h,cornerSegments:d}=e.parameters,c=new JW(!1,t,i,r,n,s,a,o,l,u,h,d);return Object.assign(c,{userData:{...e,type:"HelixGeometry"}})}},_3=new kf([0,0,0],1),JW=class extends At{constructor(e=!0,t=1,i=1,r=1,n=1,s=1,a=1,o=1,l=1,u=1,h=1,d=1){if(super(),s===0)return;let c=e&&s===1;c&&(d=0),h>100&&(h=100),h===0&&(d=0);let p,f,m,g,v,y,_,b,x=()=>new R,w=new R,S=x(),T=x(),M=x(),E=x(),A=x(),P=x(),N=x(),D=x(),O=x(),z=x(),L=x(),V=i-2*o+.001,G=V/s,Y=Math.ceil(a*s),$=Y+1,Q=V/Y,ue=-V/2,pe=u+1,xe=2*Math.PI/u,we=Math.PI/2/d,re=Math.min((1-h/100)*o,o-.01),Se=o-re,W=0,k=2*d+2,K=pe*k/2,ie=K+pe*$,j=Math.max(0,pe*($+k)),[ae,se,H]=[3,3,2].map(pt=>Array(j*pt).fill(0)),me=[],be=n-o;function ke(pt,tt){let Yt=Math.PI/2;y=tt*Q,b=2*Math.PI*(y%G)/G+Yt,y+=ue,_=Math.sin(b)*be,v=Math.cos(b)*be,e?pt.set(v,_,y):pt.set(v,y,_)}ke(w,-1e-10),ke(S,0),E.copy(w),ke(w,1);let Te=w.distanceTo(S),Ze=c?0:Se+re,ze=Te*Y+2*Ze,qe=re,Ne=ze-Ze;for(let pt=0;pt<=Y;pt++){ke(T,pt),L.subVectors(T,E).normalize(),E.copy(T),O.copy(T).setComponent(+e+1,0).normalize(),z.crossVectors(L,O).normalize();let tt=pt===0,Yt=pt===Y,ni=tt?3*Math.PI/2:we,ar=tt?qe:Ne,St=tt?pe:ie,Nt=tt?0:j-pe,Qt=L.clone().multiplyScalar(tt?-Se:Se).add(T),Ei=L.clone().multiplyScalar(tt?-1:1).normalize();for(let xi=0;xi<pe;xi++){let mi=xi*xe;if(A.addVectors(w.copy(O).multiplyScalar(o*Math.cos(mi)),S.copy(z).multiplyScalar(o*Math.sin(mi))),P.copy(A).normalize(),tt||Yt){c||(W=Nt+xi,[0,1,2].forEach(Ai=>{ae[3*W+Ai]=Qt.getComponent(Ai),se[3*W+Ai]=Ei.getComponent(Ai)}),H[2*W]=+Yt,H[2*W+1]=xi/u),S.copy(P).multiplyScalar(re),M.addVectors(T,S);for(let Ai=0;Ai<d;Ai++){let Or=Ai*we+ni;N.addVectors(w.copy(L).multiplyScalar(Se*Math.sin(Or)),S.copy(P).multiplyScalar(Se*Math.cos(Or))),D.copy(N).normalize(),S.addVectors(M,N),N.normalize(),W=St+Ai*pe+xi,[0,1,2].forEach(ir=>{ae[3*W+ir]=S.getComponent(ir),se[3*W+ir]=D.getComponent(ir)});let Hr=+tt+Math.sin(Or);H[2*W]=(ar+Se*Hr)/ze,H[2*W+1]=xi/u}}S.addVectors(T,A),W=K+pt*pe+xi,[0,1,2].forEach(Ai=>{ae[3*W+Ai]=S.getComponent(Ai),se[3*W+Ai]=P.getComponent(Ai)}),H[2*W]=(Ze+pt*Te)/ze,H[2*W+1]=xi/u}}let ee=$+2*d+2,[Ce,He]=[+c,ee-1];for(let pt=Ce;pt<=He-1;pt++){let tt=c&&pt===He-1;for(let Yt=0;Yt<pe-1;Yt++)p=pt*pe+Yt,f=p+1,m=(tt?Yt:p)+pe,g=(tt?Yt+1:f)+pe,pt===0?me.push(f,g,m):pt===ee-2?me.push(p,f,m):me.push(p,f,m,f,g,m)}this.setIndex(me),this.setAttribute("position",new Et(ae,3)),this.setAttribute("normal",new Et(se,3)),this.setAttribute("uv",new Et(H,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e,t,i,r,n=this.userData.parameters,s=Math.ceil(n.tubularSegments),a=n.radialSegments,o=a+1,l=[];for(let u=1;u<s;u++)for(let h=0;h<a;h++)e=u*o+h,t=e+1,i=e+o,r=t+o,l.push(e,t,i,t,r,i);for(let u=0;u<a;u++)e=s*o+u,t=e+1,i=u+o,r=u+1+o,l.push(e,t,i,t,r,i);return _3.array=new Uint32Array(l),_3.count=l.length,_3}}});function OLe(e){return Xte||(Xte=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build",i=import("./boolean.js"),[r,n]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),SA=r}())}function IL(){if(SA===void 0)throw new Error("boolean-wasm is not loaded");return SA}function sY(e){let t=TA.get(e);if(t===void 0)throw new Error("Unknown csg mesh set handle "+e);return t}function aY(e){return TA.set(++eH,e),eH}function LLe(e,t,i){if(SA===void 0)return-1;let{positions:r,indices:n,normals:s}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,f=[];for(let m=0,g=0;m<p.verticesPerFace.length;m++){let v=p.verticesPerFace[m];for(let y=1;y<v-1;y++)f.push(p.indices[g],p.indices[g+y],p.indices[g+y+1]);g+=v}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(f)}}let l;l=pbe(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}}(e,t);return aY(new SA.CsgMesh(r,n,s))}function $te(e,t){let i=IL(),r=gbe[t];if(r===void 0)throw new Error("Unknown boolean operation "+t);let n=e.map(sY);if(n.length===1)return i.clone_mesh(n[0]);let s,a=[];if(t===2&&n.length>2){let o=n[0];for(let l=1;l<n.length-1;l++)o=i.boolean_mesh(o,n[l],0),a.push(o);s=i.boolean_mesh(n[n.length-1],o,2)}else if(t===2)s=i.boolean_mesh(n[1],n[0],2);else{let o=n[n.length-1];for(let l=0;l<n.length-1&&(o=i.boolean_mesh(o,n[l],r),a.push(o),o.tri_count()!==0);l++);s=o,a.pop()}for(let o of a)o.free();return s}function s5(e,t){sY(e).transform(new Float32Array(t.elements))}function mbe(e){let t=TA.get(e);t!==void 0&&(t.free(),TA.delete(e))}var SA,TA,eH,Xte,gbe,aB=U(()=>{oe(),wA(),TA=new Map,eH=0,gbe={0:0,1:1,2:2}});function D0(e){return e!==null&&"booleanOp"in e}var tH,vbe,BLe=U(()=>{oe(),xl(),aB(),tH=class extends nB(Tr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new Ue}updateVisible(e){super.updateVisible(e),this.visible=!D0(this.parent)&&this.visible,D0(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){D0(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(mbe(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),D0(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof tH&&(e.freeBooleanPointer(),D0(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&D0(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),D0(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),FLe=U(()=>{vbe=null});function oY(e,t=0,i=e.count,r,n){let s=1/0,a=1/0,o=1/0,l=-1/0,u=-1/0,h=-1/0;for(let d=t;d<i;d++){let c=e.getX(d),p=e.getY(d),f=e.getZ(d);c<s&&(s=c),p<a&&(a=p),f<o&&(o=f),c>l&&(l=c),p>u&&(u=p),f>h&&(h=f)}IM.min.set(s,a,o),IM.max.set(l,u,h),IM.getCenter(r),IM.getSize(n).multiplyScalar(.5)}var IM,Yte,Kte,Ms,Ia=U(()=>{oe(),BLe(),FLe(),IM=new fn,Yte=new At,Kte=new Zl,Ms=class extends tH{constructor(e,t){super(Yte,Kte),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}raycast(e,t){if(this.raycastDeformed(e,t))return;let i=vbe;i===null?super.raycast(e,t):i(this,e,t)}raycastDeformed(e,t){return!1}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?oY(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}}});function OL(e){return e?.isClassicNodeMaterial===!0}var zr,MA,ybe,_be,AE,bbe,xbe,wbe,lY=U(()=>{}),bu=U(()=>{oe(),zr=class extends ot{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t)}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}}}),Sbe=U(()=>{bu(),MA=class extends zr{}}),ULe=U(()=>{ybe=class{constructor(e=1e4){this.timeout=e,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(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.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 e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let i=t;t=t.next,t.prev=this.head,this.head.next=t,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(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,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((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),Tbe=U(()=>{ULe(),_be=class extends ybe{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}}}),Mbe=U(()=>{bbe=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},xbe=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}}}),zLe=U(()=>{oe(),wbe=class extends c1e{constructor(e){super(e),this.type=di}parse(e){let t=function(p,f){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(p,f,m){f=f||1024;let g=p.pos,v=-1,y=0,_="",b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(v=b.indexOf(`
|
|
4172
|
+
})();`}),Q1e=U(()=>{OX=class{constructor(e,t,i){this.deps=e,this.onConsole=t,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let e of this.eventUnsubs.values())e();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(e,t){let i=this.deps;switch(e){case"setVariable":{let r=i.setVariable(String(t[0]),t[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=t[0]??{},n=!0;for(let[s,a]of Object.entries(r)){let o=i.setVariable(s,a);o.warning&&this.onConsole("warn",o.warning),n=n&&o.ok}return n}case"getVariable":return i.getVariable(String(t[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(t[0]));case"getGeometry":{let r=i.getGeometry(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(t[0]),t[1]??{});case"createObject":return i.createObject(String(t[0]),t[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(t[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(t[0]),t[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(t[0]),t[1]);case"cloneObject":return i.cloneObject(String(t[0]),t[1]??{});case"removeObject":return i.removeObject(String(t[0]));case"spawnObject":{let r=i.spawnObject(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(t[0]));case"setInstanceTransforms":{let r=t[1]===null||t[1]===void 0?null:t[1],n=i.setInstanceTransforms(String(t[0]),r);return n<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(t[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),n}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(t[0]),String(t[1]),e==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(t[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,n=>{this.onEvent(r,n)})),!0}case"unlistenEvent":{let r=String(t[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${e}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let e=this.deps.getVariables(),t=function(i,r){let n=[];for(let s of Object.keys(r))i[s]!==r[s]&&n.push({name:s,value:r[s]});return n}(this.lastVariables??{},e);this.lastVariables=e;for(let i of t)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function VOe(e,t,i,r){return[e[0]*t+e[4]*i+e[8]*r+e[12],e[1]*t+e[5]*i+e[9]*r+e[13],e[2]*t+e[6]*i+e[10]*r+e[14]]}var GOe=U(()=>{}),J1e,jOe=U(()=>{}),WOe=U(()=>{LX(),Q1e(),J1e=class{constructor(e,t,i){this.iframe=e,this.deps=t,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 n=r.data;var s;typeof(s=n)!="object"||s===null||s[pg]!==!0||typeof s.kind!="string"||this.handleMessage(n)},this.host=new OX(t,i,(r,n)=>{this.sendEvent(r,n)})}attach(){window.addEventListener("message",this.onMessage),this.send({[pg]:!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(e){switch(e.kind){case"ready":this.handshakeSeen=!0,this.send({[pg]:!0,kind:"ready-ack"});break;case"console":this.onConsole(e.level,e.text);break;case"call":{let t;try{t=Promise.resolve(this.host.execute(e.method,e.args))}catch(i){t=Promise.reject(i)}t.then(i=>{this.send({[pg]:!0,kind:"result",id:e.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[pg]:!0,kind:"result",id:e.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(e.event)}}send(e){this.iframe.contentWindow?.postMessage(e,"*")}sendEvent(e,t){this.send({[pg]:!0,kind:"event",eventName:e,payload:t})}dispatchInput(e){let t=this.deps.getCanvas();if(!t)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey};switch(e.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":t.dispatchEvent(new PointerEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons,pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,movementX:e.movementX,movementY:e.movementY}));break;case"click":case"dblclick":t.dispatchEvent(new MouseEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons}));break;case"wheel":{let n=new WheelEvent("wheel",{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode});typeof e.wheelDeltaX=="number"&&Object.defineProperty(n,"wheelDeltaX",{value:e.wheelDeltaX}),typeof e.wheelDeltaY=="number"&&Object.defineProperty(n,"wheelDeltaY",{value:e.wheelDeltaY}),t.dispatchEvent(n);break}case"keydown":case"keyup":t.dispatchEvent(new KeyboardEvent(e.type,{...r,key:e.key,code:e.code,repeat:e.repeat}))}}}}),Gr=U(()=>{IX(),EOe(),AOe(),COe(),ROe(),DOe(),NOe(),IOe(),OOe(),LOe(),BOe(),zOe(),LX(),kOe(),Q1e(),GOe(),jOe(),WOe()}),HOe=U(()=>{});function e_e(e){return Array.isArray(e)?e:[e]}function aL(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var qOe=U(()=>{});function Wo(e,t){return Object.setPrototypeOf(e,t),e}function yU(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Ag(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],n=1/(i+1);for(let s=0;s<i;s++){let a=e+(t-e)*(s+.75+.5*Math.random())*n;r.push(a)}return r}function Qy(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}var $Oe=U(()=>{});function BX(e){if(e.deepFreeze!==void 0)return void e.deepFreeze(e);let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&BX(r)}return Object.freeze(e)}function t_e(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}var _U,oL,lW,si,FX,XOe=U(()=>{}),la=U(()=>{HOe(),qOe(),$Oe(),XOe()}),UX=U(()=>{_U=class{},oL=class extends _U{constructor(e){super(),this.id=e}},lW=class extends _U{constructor(e){super(),this.data=e}}}),YOe=U(()=>{}),H4=U(()=>{si=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,si.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i,r=t[e.id];i=r===void 0?{type:2,id:e.id}:{type:1,id:e.id,data:r};let{id:n,data:s}=e,a={...t,[n]:s};return Object.setPrototypeOf(a,si.prototype),{data:a,actual:e,reverse:i}}if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let n={...t};return Object.setPrototypeOf(n,si.prototype),delete n[i],{data:n,actual:e,reverse:{type:1,id:i,data:r}}}}return null}}}),zX=U(()=>{FX=class extends Error{}});function i_e(e,t){for(let i of e)t(i.id,i.data)!==!0&&i_e(i.children,t)}function r_e(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)r_e(i,t)}var Ca,s3,Jx,It,s1=U(()=>{la(),zX(),la(),Ca=class extends Array{constructor(...e){super(...e),Lc(this,"partialObjectCaches"),Lc(this,"objCaches"),Lc(this,"parentCaches"),Object.setPrototypeOf(this,Ca.prototype)}deepFreeze(){let e=0;for(;e<this.length;)BX(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(!t)return e;e=t}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}partialCache(e){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let t=this.get(e);t!==void 0&&this.partialObjectCaches.set(e,t)}get(e){if(this.partialObjectCaches!==void 0){let t=this.partialObjectCaches.get(e);if(t!==void 0)return t}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&r_e(i,t)}}traverse(e){i_e(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),n=r.findIndex(o=>o.id===e);if(n<0)throw new Error("not expected");let s=r[n];r=[...r],r[n]={...s,data:t};let a=new Map;return a.set(e,r[n]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(e,t,i=void 0){let r=e,n=t;for(;r!==null;){let a=n,o=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let l=n.findIndex(u=>u.id===o);if(l<0)throw new Error;n=[...n],n[l]={...n[l],children:a},i&&i.set(o,n[l])}Object.setPrototypeOf(n,Ca.prototype);let s=n;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[a,o]of i)s.objCaches.set(a,o);s.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else s.fillCaches();return s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:n,children:s};return o=[...o,l],o.sort((u,h)=>u.fi-h.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),n=r.findIndex(a=>a.id===t);e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new FX("cyclic tree");d=this.parent(d)}}let n=this.parent(r);if(n===void 0)return null;let s=n,a=this.childrenArray(n),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],u=this.modifyArrayBy(n,a);n=t,a=u.childrenArray(n);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),e.localIndex=a.indexOf(l),u=u.modifyArrayBy(n,a),{data:u,actual:e,reverse:{type:9,parent:s,fi:h,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>aL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getAllIdSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i);r!==void 0&&t.push(r)}t.sort((i,r)=>aL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t.map(i=>i.id)}getWithSortKey(e){let t=e,i=[],r=this.get(t),n=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...n,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Ag(0,i,i);{let n=r[0].fi;return Ag(n-i,n,i)}}{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(a=>a.fi>n.fi);if(s===void 0){let a=r[r.length-1].fi;return Ag(a,a+i,i)}return Ag(n.fi,s.fi,i)}}}}),kX=U(()=>{var e;la(),s3=null,(e=Jx||(Jx={})).setPreservePrototype=function(t){s3=t},e.tryPreservePrototype=function(t,i){return Object.getPrototypeOf(t)===s3&&Object.setPrototypeOf(i,s3),i},e.runOp=function(t,i){if(i.type!==0)return null;if(Array.isArray(t)||Qy(t)){let r=i.props,n={},s=Qy(t)?t.slice():[...t],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");n[o]=s[l],s[l]=r[o],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:n}}:null}{let r=i.props,n={},s={...t},a=!1;if(r)for(let o of Object.keys(r)){n[o]=s[o];let l=r[o];l===void 0?delete s[o]:s[o]=l,a=!0}return a?{data:e.tryPreservePrototype(t,s),actual:i,reverse:{type:0,props:n}}:null}}}),a1=U(()=>{la(),la(),It=class extends Array{constructor(...e){super(...e),Lc(this,"objCaches"),Object.setPrototypeOf(this,It.prototype)}deepFreeze(){let e=0;for(;e<this.length;)BX(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let n=i[r];return i=[...i],i[r]={...n,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,It.prototype);let t=e;return typeof process<"u"||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,n=this,s={fi:t,id:i,data:r};return n=[...n,s],n.sort((a,o)=>a.fi-o.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let n=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...n}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let n=r.findIndex(o=>o.id===i);if(n===-1)return null;let s=r[n].fi,a={...r[n],fi:t};return r[n]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Ag(0,t,t);{let r=i[0].fi;return Ag(r-t,r,t)}}{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let n=i.find(s=>s.fi>r.fi);if(n===void 0){let s=i[i.length-1].fi;return Ag(s,s+t,t)}return Ag(r.fi,n.fi,t)}}}});function KOe(e,t){let i={cur:[],result:[],len:0};return[e=_x(e,t,i)??e,i.result]}function TI(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function MI(e){e&&(e.len-=1)}function n_e(e,t,i){let r=!1,n=e.map(s=>{let a=s.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=_x(s.data,t,TI(i,a));MI(i),r=r||l!==void 0,l===void 0&&(l=s.data);let u=n_e(s.children,t,i);return u!==void 0?r=!0:u=s.children,{...s,id:a,data:l,children:u}});if(r)return n}function _x(e,t,i){if(e instanceof Ca){let r=n_e(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}if(e instanceof It)return function(r,n,s){let a=!1,o=r.map(l=>{let u=l.id,h=n[u];if(h!==void 0&&typeof h=="string"&&(a=!0,u=h,s!==null))throw new Error("not supported");let d=_x(l.data,n,TI(s,u));return MI(s),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}(e,t,i);if(Array.isArray(e)){let r=!1,n=e.map((s,a)=>{let o=_x(s,t,TI(i,a));return MI(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(e)),n):void 0}if(e&&typeof e=="object"&&!Qy(e)){let r={},n=!1;for(let[s,a]of Object.entries(e))if(s!=="name"&&s!=="variableId"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");n=!0,s=o}let l=_x(a,t,TI(i,s));MI(i),n=n||l!==void 0,l===void 0&&(l=a),r[s]=l}else r[s]=a;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(typeof e=="string"){let r=t[e];return r!==void 0&&function(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}(i),r}}var s_e=U(()=>{s1(),a1(),la()});function bx(e){return e&&typeof e=="object"&&e instanceof Ts}function VX(e,t){if(t===void 0)return;let i=!1,r=e.map(n=>{let s=n.id,a=bE(n.data,t[s]);if(i=i||a!==void 0,a===void 0&&(a=n.data),n.children){let o=VX(n.children,t);return o!==void 0?i=!0:o=n.children,{...n,id:s,data:a,children:o}}return{...n,id:s,data:a}});return i?r:void 0}function bE(e,t){if(!bx(t))return t;if(e instanceof Ca){let i=VX(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}if(e instanceof It)return function(i,r){if(r===void 0)return;let n=!1,s=i.map(a=>{let o=a.id,l=bE(a.data,r[o]);return n=n||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return n?(Object.setPrototypeOf(s,Object.getPrototypeOf(i)),s):void 0}(e,t);if(Array.isArray(e)){let i=!1,r=e.map((n,s)=>{let a=bE(n,t[s]);return i=i||a!==void 0,a===void 0&&(a=n),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(e instanceof Ts)return GX(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[n,s]of Object.entries(e)){let a=bE(s,t[n]);r=r||a!==void 0,a===void 0&&(a=s),i[n]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}function GX(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!bx(t))return t;if(!bx(e))return Fg.apply(e,t);let i=new Set;for(let n of Object.keys(e))i.add(n);for(let n of Object.keys(t))i.add(n);let r=new Ts;for(let n of i){let s=GX(e===void 0?void 0:e[n],t===void 0?void 0:t[n]);r[n]=s}return r}var Ts,Fg,lL,Xa,YJ,q4=U(()=>{var e;s1(),a1(),Y4(),la(),Ts=class{unusedFunOverridesTable(t){}runOp(t){let i=[],r=this,n=0,s={};for(;n<t.path.length;){if(i.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!bx(r))return null;n+=1}r=r?yU(r):new Ts;for(let[a,o]of Object.entries(t.props)){let l=r[a];s[a]=l,o===void 0?delete r[a]:r[a]=o}for(;n>0;){if(Object.keys(r).length===0){let a=i[n-1];a&&(r=yU(a),delete r[t.path[n-1]])}else{let a=i[n-1];if(a){let o=yU(a);o[t.path[n-1]]=r,r=o}else{let o=new Ts;o[t.path[n-1]]=r,r=o}}n-=1}return{data:Object.setPrototypeOf(r,Ts.prototype),actual:t,reverse:{...t,props:s}}}},(e=Fg||(Fg={})).apply=function(t,i){return bE(t,i)??t},e.merge=function(t,i){return GX(t,i)},e.filterOp=function(t,i){let r=0,n=i.path,s=t;for(;r<n.length&&s!==void 0;){if(s=Ta.zoomOnce(s,n[r]),s===void 0)return i;if(!bx(s))return;r+=1}if(s===void 0)return i;if(bx(s)){if(i.type===0){let a={...i.props};for(let o of Object.keys(s))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=VX([i],s);return a?a[0]:i}return i}}}),ZOe=U(()=>{la(),Y4(),H4(),s1(),zX(),kX(),a1(),s_e(),q4(),(lL||(lL={})).replaceProps=function(e,t){let i=Ta.zoom(t,e.path);if(typeof i=="object"){let r={};for(let n of Object.keys(e.props))r[n]=i[n];return{...e,props:r}}return{...e,props:{}}},(e=>{function t(n,s){let a=s.path,o=[];for(;;){let l;if(n instanceof Ts&&s.type===0&&(l=n.runOp({...s,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=n instanceof Ca||n instanceof It||n instanceof si?n.runOp(s):Jx.runOp(n,s)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],f=o[c];if(f instanceof Ca){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof It){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof si){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof Ts){let m={...f,[p]:d};d=Object.setPrototypeOf(m,Ts.prototype)}else{if(typeof f!="object")return null;if(Array.isArray(f)||Qy(f)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let m=d;d=Qy(f)?f.slice():[...f],d[p]=m}else d=Jx.tryPreservePrototype(f,{...f,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let u,h=a[o.length];if(n instanceof Ca){if(typeof h=="number")throw new Error("");u=n.get(h)?.data}else if(n instanceof It){if(typeof h=="number")throw new Error("");u=n.get(h)?.data}else n!==null&&(u=n[h]);if(u===void 0)return null;o.push(n),n=u}}function i(n,s){for(let a=0;a<n.length&&a<s.length;a++)if(n[a]!==s[a])return!0;return!1}function r(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;a++)if(n[a]!==s[a])return!1;return!0}e.drop=function(n,s){return{...n,path:n.path.slice(s)}},e.applySimple=function(n,s){return t(n,s)?.data??n},e.apply=t,e.pathDisjoint=i,e.pathEq=r,e.commutative=function(n,s){return i(n.path,s.path)},e.subsumed=function(n,s){return!(n.type!==0||s.type!==0||!r(n.path,s.path))&&Object.keys(n.props).every(a=>s.props[a]!==void 0)}})(Xa||(Xa={})),(e=>{function t(i,r){let n=i,s=[],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=Ta.zoom(n,[...o.path,o.id]),h=Xa.apply(n,{...o,type:2})):(l=Ta.zoom(n,[...o.path,o.id,"value"]),h=Xa.apply(n,o)),h!==null){n=h.data;let[d,c]=KOe(n,{[o.id]:l});n=d;for(let p=0;p<c.length;p++){let f=c[p],m=f.pop();if(typeof m=="number"){let g=[m];for(let y=p+1;y<c.length;y++){let _=c[y],b=_[_.length-1];if(typeof b!="number"||!Ta.equal(f,_.slice(0,_.length-1)))break;g.push(b),c.splice(y,1)}let v=Ta.zoom(n,f);u=v.map((y,_)=>g.includes(_)?o.id:y),l=v,m=f.pop()}else{if(m==="alphaOverride"||m==="alpha"){l/=100;let g=l,v=Ta.zoom(n,f.slice(0,f.length-2)),y=v.layers.map(_=>_.id===f[f.length-1]?{..._,data:{..._.data,[m]:g}}:_);Object.setPrototypeOf(y,Object.getPrototypeOf(v.layers)),v.layers=y}u=o.id}s.push({type:0,path:f,props:{[m]:l}}),a.push({type:0,path:f,props:{[m]:u}})}a.push(h.reverse),s.push(h.actual)}}else{let l=Xa.apply(n,o);l!==null&&(s.push(l.actual),n=l.data,a.push(l.reverse))}}catch(l){if(l instanceof FX)return null;throw l}return{data:n,actual:s,reverse:a.reverse()}}e.empty=function(){return[]},e.removePrefix=function(i,r){let n=[];for(let s of i){let[a,...o]=s.path;a===r&&n.push({...s,path:o})}return n},e.addPrefix=function(i,r){return i.map(n=>({...n,path:[r,...n.path]}))},e.concat=function(i,r){return[...i,...r]},e.compress=function(i,r){return[...i.filter(n=>!r.some(s=>Xa.subsumed(n,s))),...r]},e.commutative=function(i,r){return i.every(n=>r.every(s=>Xa.commutative(n,s)))},e.applyAll=function(i,r){for(let n of r){let s=t(i,n);s!==null&&(i=s.data)}return i},e.apply=t})(YJ||(YJ={}))});function KJ(e,t){return e instanceof Ts?Object.setPrototypeOf(t,Ts.prototype):Jx.tryPreservePrototype(e,t)}function bU(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Ta.equal(r.path,i))return void Object.assign(r.props,t.props)}e.push({...t,path:i})}function EI(e,t,i){return i instanceof Ca?new $4(e,t,i):i instanceof It?new X4(e,t,i):i instanceof si?new Proxy(new o_e(e,t,i),h_e):i!==null&&typeof i=="object"?Qy(i)?i:new Proxy(new a_e(e,t,i),l_e):i}function EM(e){let t=new uW(e);return[EI(t,"",e),t]}function hL(e,t){let[i,r]=EM(e);return t(i),r.result()}function $s(e){return e instanceof $4||e instanceof X4?e._current:e!==null&&typeof e=="object"?e[hW]:e}var hW,ZJ,OS,V1,a_e,o_e,xU,l_e,h_e,$4,X4,uW,Ta,u_e=U(()=>{H4(),s1(),kX(),a1(),la(),Y4(),q4(),hW=Symbol(),ZJ=Symbol(),OS=Symbol(),V1=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let n=i;for(;!(r instanceof uW);){let s=r._path,a=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,a)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[OS];i&&i(),delete this._children[e]}}}},a_e=class extends V1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=KJ(this._current,{...this._current,[e]:t})}runOp(e){let t=Jx.runOp(this._current,e);t!==null&&(t.data=KJ(this._current,t.data)),this.reportOp(e,t,e.path)}},o_e=class extends V1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,si.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},xU={get(e,t){if(t===OS)return()=>{e._parent=null};if(t===hW)return e._current;if(t===ZJ)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=i[t],a=EI(e,t,s);return a!==s?(r===void 0&&(r={},e._children=r),r[t]=a,a):s},has:(e,t)=>t in e._current,ownKeys:e=>Reflect.ownKeys(e._current),defineProperty(){throw Error("not supported")},getPrototypeOf:e=>Object.getPrototypeOf(e._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},l_e={...xU,set(e,t,i){let r={type:0,props:{[t]:$s(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},h_e={...xU,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty:(e,t)=>(e.runOp({type:2,id:t}),!0)},$4=class extends V1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[OS]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=EI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}add(e,t,i,r,n){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:n})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},X4=class extends V1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[OS]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,n=this._current[i].fi;e(this.data(this._current[i].id),r,n,i)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}at(e){let{id:t,fi:i}=this._current.at(e);return{id:t,fi:i,data:this.data(t)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=EI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}},uW=class extends V1{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){bU(this.ts,t,e),bU(this.actual,i,e),bU(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),Y4=U(()=>{UX(),u_e(),a1(),s1(),la(),(e=>{function t(r,n){return(r instanceof Ca||r instanceof $4)&&typeof n=="string"||(r instanceof It||r instanceof X4)&&typeof n=="string"?r.data(n):typeof n=="number"&&Array.isArray(r)||typeof n=="string"&&typeof r=="object"&&r!==null?r[n]:void 0}function i(r,n,s=0){for(;s<n.length&&r!==void 0;)r=t(r,n[s]),s+=1;return r}e.equal=function(r,n){if(n.length!==r.length)return!1;{let s=0;for(;s<r.length;){if(r[s]!==n[s])return!1;s+=1}}return!0},e.removeOverridden=function(r,n,s){let a=i(s,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...n};return Object.keys(a).forEach(l=>{delete o[l]}),o}return n},e.zoomOnce=t,e.zoom=i,e.findPathes=function(r,n){let s=[];return function a(o,l){if(o instanceof oL&&o.id===n.id)s.push(l);else if(o instanceof It)for(let u=0;u<o.length;u++)a(o[u].data,[...l,o[u].id]);else if(o instanceof Ca)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(Qy(o))return;if(typeof o=="object"&&o!==null)for(let u in o)a(o[u],[...l,u])}}(r,[]),s}})(Ta||(Ta={}))}),QOe=U(()=>{});function Jr(e,t){let i=[];if(!(t.length<=e.length))return null;{let r=0;for(;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}}return i}var JOe=U(()=>{});function a3(e){try{if(!An.trusted&&!bf){let i=Fr.sharedLength||0;i<Fr.length&&(Fr.length=i)}let t;if(An.randomAccessStructure&&Pt[Le]<64&&Pt[Le]>=32&&ree?(t=ree(Pt,Le,mu,An),Pt=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),Le=mu):t=Zs(),Mo&&(Le=Mo.postBundlePosition,Mo=null),bf&&(Fr.restoreStructures=null),Le==mu)Fr&&Fr.restoreStructures&&QJ(),Fr=null,Pt=null,_f&&(_f=null);else{if(Le>mu)throw new Error("Unexpected end of MessagePack data");if(!bf){let i;try{i=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`${n}n`:n).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return t}catch(t){throw Fr&&Fr.restoreStructures&&QJ(),cW(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||Le>mu)&&(t.incomplete=!0),t}}function QJ(){for(let e in Fr.restoreStructures)Fr[e]=Fr.restoreStructures[e];Fr.restoreStructures=null}function Zs(){let e=Pt[Le++];if(e<160){if(e<128){if(e<64)return e;{let t=Fr[63&e]||An.getStructures&&d_e()[63&e];return t?(t.read||(t.read=dW(t,63&e)),t.read()):e}}if(e<144){if(e-=128,An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=p_e();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(gd>=Le)return Cg.slice(Le-Sh,(Le+=t)-Sh);if(gd==0&&mu<140){let i=t<16?jX(t):c_e(t);if(i!=null)return i}return cL(t)}{let t;switch(e){case 192:return null;case 193:return Mo?(t=Zs(),t>0?Mo[1].slice(Mo.position1,Mo.position1+=t):Mo[0].slice(Mo.position0,Mo.position0-=t)):g_e;case 194:return!1;case 195:return!0;case 196:if(t=Pt[Le++],t===void 0)throw new Error("Unexpected end of buffer");return wU(t);case 197:return t=Ar.getUint16(Le),Le+=2,wU(t);case 198:return t=Ar.getUint32(Le),Le+=4,wU(t);case 199:return P0(Pt[Le++]);case 200:return t=Ar.getUint16(Le),Le+=2,P0(t);case 201:return t=Ar.getUint32(Le),Le+=4,P0(t);case 202:if(t=Ar.getFloat32(Le),An.useFloat32>2){let i=yW[(127&Pt[Le])<<1|Pt[Le+1]>>7];return Le+=4,(i*t+(t>0?.5:-.5)|0)/i}return Le+=4,t;case 203:return t=Ar.getFloat64(Le),Le+=8,t;case 204:return Pt[Le++];case 205:return t=Ar.getUint16(Le),Le+=2,t;case 206:return t=Ar.getUint32(Le),Le+=4,t;case 207:return An.int64AsType==="number"?(t=4294967296*Ar.getUint32(Le),t+=Ar.getUint32(Le+4)):An.int64AsType==="string"?t=Ar.getBigUint64(Le).toString():An.int64AsType==="auto"?(t=Ar.getBigUint64(Le),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Ar.getBigUint64(Le),Le+=8,t;case 208:return Ar.getInt8(Le++);case 209:return t=Ar.getInt16(Le),Le+=2,t;case 210:return t=Ar.getInt32(Le),Le+=4,t;case 211:return An.int64AsType==="number"?(t=4294967296*Ar.getInt32(Le),t+=Ar.getUint32(Le+4)):An.int64AsType==="string"?t=Ar.getBigInt64(Le).toString():An.int64AsType==="auto"?(t=Ar.getBigInt64(Le),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Ar.getBigInt64(Le),Le+=8,t;case 212:if(t=Pt[Le++],t==114)return vW(63&Pt[Le++]);{let i=_o[t];if(i)return i.read?(Le++,i.read(Zs())):i.noBuffer?(Le++,i()):i(Pt.subarray(Le,++Le));throw new Error("Unknown extension "+t)}case 213:return t=Pt[Le],t==114?(Le++,vW(63&Pt[Le++],Pt[Le++])):P0(2);case 214:return P0(4);case 215:return P0(8);case 216:return P0(16);case 217:return t=Pt[Le++],gd>=Le?Cg.slice(Le-Sh,(Le+=t)-Sh):y_e(t);case 218:return t=Ar.getUint16(Le),gd>=(Le+=2)?Cg.slice(Le-Sh,(Le+=t)-Sh):__e(t);case 219:return t=Ar.getUint32(Le),gd>=(Le+=4)?Cg.slice(Le-Sh,(Le+=t)-Sh):b_e(t);case 220:return t=Ar.getUint16(Le),Le+=2,JJ(t);case 221:return t=Ar.getUint32(Le),Le+=4,JJ(t);case 222:return t=Ar.getUint16(Le),Le+=2,eee(t);case 223:return t=Ar.getUint32(Le),Le+=4,eee(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}function dW(e,t){function i(){if(i.count++>fW){let n;try{n=e.read=new Function("r","return function(){return "+(An.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":v_e.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(Zs)}catch{return fW=1/0,i()}return e.read0=n,e.highByte===0&&(e.read=mW(t,e.read)),n()}let r={};for(let n=0,s=e.length;n<s;n++){let a=e[n];a==="__proto__"&&(a="__proto_"),r[a]=Zs()}return An.freezeData?Object.freeze(r):r}return i.count=0,e.read0=i,e.highByte===0?mW(t,i):i}function d_e(){let e=m_e(()=>(Pt=null,An.getStructures()));return Fr=An._mergeStructures(e,Fr)}function AM(e){let t;if(e<16&&(t=jX(e)))return t;if(e>64&&pW)return pW.decode(Pt.subarray(Le,Le+=e));let i=Le+e,r=[];for(t="";Le<i;){let n=Pt[Le++];if(128&n)if((224&n)==192){let s=(31&n)<<6|63&Pt[Le++];s<128?r.push(65533):r.push(s)}else if((240&n)==224){let s=(31&n)<<12|(63&Pt[Le++])<<6|63&Pt[Le++];s<2048||s>=55296&&s<=57343?r.push(65533):r.push(s)}else if((248&n)==240){let s=(7&n)<<18|(63&Pt[Le++])<<12|(63&Pt[Le++])<<6|63&Pt[Le++];s<65536||s>1114111?r.push(65533):(s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s))}else r.push(65533);else r.push(n);r.length>=4096&&(t+=wa.apply(String,r),r.length=0)}return r.length>0&&(t+=wa.apply(String,r)),t}function JJ(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}function eee(e){if(An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=p_e();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}function c_e(e){let t=Le,i=new Array(e);for(let r=0;r<e;r++){let n=Pt[Le++];if((128&n)>0)return void(Le=t);i[r]=n}return wa.apply(String,i)}function jX(e){if(e<4){if(e<2){if(e===0)return"";{let t=Pt[Le++];return(128&t)>1?void(Le-=1):wa(t)}}{let t=Pt[Le++],i=Pt[Le++];if((128&t)>0||(128&i)>0)return void(Le-=2);if(e<3)return wa(t,i);let r=Pt[Le++];return(128&r)>0?void(Le-=3):wa(t,i,r)}}{let t=Pt[Le++],i=Pt[Le++],r=Pt[Le++],n=Pt[Le++];if((128&t)>0||(128&i)>0||(128&r)>0||(128&n)>0)return void(Le-=4);if(e<6){if(e===4)return wa(t,i,r,n);{let s=Pt[Le++];return(128&s)>0?void(Le-=5):wa(t,i,r,n,s)}}if(e<8){let s=Pt[Le++],a=Pt[Le++];if((128&s)>0||(128&a)>0)return void(Le-=6);if(e<7)return wa(t,i,r,n,s,a);let o=Pt[Le++];return(128&o)>0?void(Le-=7):wa(t,i,r,n,s,a,o)}{let s=Pt[Le++],a=Pt[Le++],o=Pt[Le++],l=Pt[Le++];if((128&s)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(Le-=8);if(e<10){if(e===8)return wa(t,i,r,n,s,a,o,l);{let u=Pt[Le++];return(128&u)>0?void(Le-=9):wa(t,i,r,n,s,a,o,l,u)}}if(e<12){let u=Pt[Le++],h=Pt[Le++];if((128&u)>0||(128&h)>0)return void(Le-=10);if(e<11)return wa(t,i,r,n,s,a,o,l,u,h);let d=Pt[Le++];return(128&d)>0?void(Le-=11):wa(t,i,r,n,s,a,o,l,u,h,d)}{let u=Pt[Le++],h=Pt[Le++],d=Pt[Le++],c=Pt[Le++];if((128&u)>0||(128&h)>0||(128&d)>0||(128&c)>0)return void(Le-=12);if(e<14){if(e===12)return wa(t,i,r,n,s,a,o,l,u,h,d,c);{let p=Pt[Le++];return(128&p)>0?void(Le-=13):wa(t,i,r,n,s,a,o,l,u,h,d,c,p)}}{let p=Pt[Le++],f=Pt[Le++];if((128&p)>0||(128&f)>0)return void(Le-=14);if(e<15)return wa(t,i,r,n,s,a,o,l,u,h,d,c,p,f);let m=Pt[Le++];return(128&m)>0?void(Le-=15):wa(t,i,r,n,s,a,o,l,u,h,d,c,p,f,m)}}}}}function tee(){let e,t=Pt[Le++];if(t<192)e=t-160;else switch(t){case 217:e=Pt[Le++];break;case 218:e=Ar.getUint16(Le),Le+=2;break;case 219:e=Ar.getUint32(Le),Le+=4;break;default:throw new Error("Expected string")}return AM(e)}function wU(e){return An.copyBuffers?Uint8Array.prototype.slice.call(Pt,Le,Le+=e):Pt.subarray(Le,Le+=e)}function P0(e){let t=Pt[Le++];if(_o[t]){let i;return _o[t](Pt.subarray(Le,i=Le+=e),r=>{Le=r;try{return Zs()}finally{Le=i}})}throw new Error("Unknown extension type "+t)}function p_e(){let e=Pt[Le++];if(!(e>=160&&e<192))return Le--,f_e(Zs());if(e-=160,gd>=Le)return Cg.slice(Le-Sh,(Le+=e)-Sh);if(!(gd==0&&mu<180))return cL(e);let t,i=4095&(e<<5^(e>1?Ar.getUint16(Le):e>0?Pt[Le]:0)),r=gW[i],n=Le,s=Le+e-3,a=0;if(r&&r.bytes==e){for(;n<s;){if(t=Ar.getUint32(n),t!=r[a++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(t=Pt[n++],t!=r[a++]){n=1879048192;break}if(n===s)return Le=n,r.string;s-=3,n=Le}for(r=[],gW[i]=r,r.bytes=e;n<s;)t=Ar.getUint32(n),r.push(t),n+=4;for(s+=3;n<s;)t=Pt[n++],r.push(t);let o=e<16?jX(e):c_e(e);return r.string=o??cL(e)}function f_e(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(An.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error("Invalid property type for record: "+typeof e)}function m_e(e){nee&&nee();let t=mu,i=Le,r=dL,n=Sh,s=gd,a=Cg,o=uL,l=_f,u=Mo,h=new Uint8Array(Pt.slice(0,mu)),d=Fr,c=Fr.slice(0,Fr.length),p=An,f=bf,m=e();return mu=t,Le=i,dL=r,Sh=n,gd=s,Cg=a,uL=o,_f=l,Mo=u,Pt=h,bf=f,(Fr=d).splice(0,Fr.length,...c),An=p,Ar=new DataView(Pt.buffer,Pt.byteOffset,Pt.byteLength),m}function cW(){Pt=null,_f=null,Fr=null}function eLe(e){e.unpack?_o[e.type]=e.unpack:_o[e.type]=e}var pW,Pt,mu,Le,iee,uL,dL,An,Fr,Cg,Sh,gd,Mo,_f,_o,Ar,SU,g_e,bf,fW,ree,nee,CM,v_e,mW,cL,y_e,__e,b_e,wa,gW,vW,TU,see,aee,oee,yW,o3,lee,hee,uee,_W,MU,mA,tLe=U(()=>{try{pW=new TextDecoder}catch{}Le=0,uL=iee=[],dL=0,An={},Sh=0,gd=0,_o=[],SU={useRecords:!1,mapsAsObjects:!0},(g_e=new class{}).name="MessagePack 0xC1",bf=!1,fW=2,CM=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(Pt)return m_e(()=>(cW(),this?this.unpack(e,t):CM.prototype.unpack.call(SU,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(mu=t.end||e.length,Le=t.start||0):(Le=0,mu=t>-1?t:e.length),dL=0,gd=0,Cg=null,uL=iee,Mo=null,Pt=e;try{Ar=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Pt=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof CM){if(An=this,this.structures)return Fr=this.structures,a3(t);(!Fr||Fr.length>0)&&(Fr=[])}else An=SU,(!Fr||Fr.length>0)&&(Fr=[]);return a3(t)}unpackMultiple(e,t){let i,r=0;try{bf=!0;let n=e.length,s=this?this.unpack(e,n):o3.unpack(e,n);if(!t){for(i=[s];Le<n;)r=Le,i.push(a3());return i}if(t(s,r,Le)===!1)return;for(;Le<n;)if(r=Le,t(a3(),r,Le)===!1)return}catch(n){throw n.lastPosition=r,n.values=i,n}finally{bf=!1,cW()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(i=>i.slice(0)));for(let i=0,r=e.length;i<r;i++){let n=e[i];n&&(n.isShared=!0,i>=32&&(n.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],n=t[i];n&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}},v_e=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,mW=(e,t)=>function(){let i=Pt[Le++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),n=Fr[r]||d_e()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=dW(n,e)),n.read()},cL=AM,y_e=AM,__e=AM,b_e=AM,wa=String.fromCharCode,gW=new Array(4096),vW=(e,t)=>{let i=Zs().map(f_e),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let n=Fr[e];return n&&(n.isShared||bf)&&((Fr.restoreStructures||(Fr.restoreStructures=[]))[e]=n),Fr[e]=i,i.read=dW(i,r),(i.read0||i.read)()},_o[0]=()=>{},_o[0].noBuffer=!0,_o[66]=e=>{let t=e.byteLength%8||8,i=BigInt(128&e[0]?e[0]-256:e[0]);for(let r=1;r<t;r++)i<<=BigInt(8),i+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(s,a)=>{let o=a-s;if(o<=40){let d=r.getBigUint64(s);for(let c=s+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=s+(o>>4<<3),u=n(s,l),h=n(l,a);return u<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(r.byteLength-t))|n(t,r.byteLength)}return i},TU={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},_o[101]=()=>{let e=Zs();if(!TU[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return TU[e[0]](e[1],{cause:e[2]})},_o[105]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Ar.getUint32(Le-4);_f||(_f=new Map);let i,r=Pt[Le];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)&&Pt[Le+1]===115?new Set:{};let n={target:i};_f.set(t,n);let s=Zs();if(!n.used)return n.target=s;if(Object.assign(i,s),i instanceof Map)for(let[a,o]of s.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(s))i.add(a);return i},_o[112]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Ar.getUint32(Le-4),i=_f.get(t);return i.used=!0,i.target},_o[115]=()=>new Set(Zs()),see=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),aee=typeof globalThis=="object"?globalThis:window,_o[116]=e=>{let t=e[0],i=Uint8Array.prototype.slice.call(e,1).buffer,r=see[t];if(!r){if(t===16)return i;if(t===17)return new DataView(i);throw new Error("Could not find typed array for code "+t)}return new aee[r](i)},_o[120]=()=>{let e=Zs();return new RegExp(e[0],e[1])},oee=[],_o[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Le;return Le+=t-e.length,Mo=oee,(Mo=[tee(),tee()]).position0=0,Mo.position1=0,Mo.postBundlePosition=Le,Le=i,Zs()},_o[255]=e=>e.length==4?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid"),yW=new Array(147);for(let e=0;e<256;e++)yW[e]=+("1e"+Math.floor(45.15-.30103*e));(o3=new CM({useRecords:!1})).unpack,o3.unpackMultiple,o3.unpack,lee=new Float32Array(1),new Uint8Array(lee.buffer,0,4)}),iLe=U(()=>{tLe(),UX(),q4(),a1(),H4(),s1(),hee=[{Class:si.prototype.constructor,type:1,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,si.prototype),e)},{Class:It.prototype.constructor,type:2,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,It.prototype),e)},{Class:Ca.prototype.constructor,type:3,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,Ca.prototype),e)},{Class:oL.prototype.constructor,type:4,write:e=>e.id,read:e=>new oL(e)},{Class:lW.prototype.constructor,type:5,write:e=>e.data,read:e=>new lW(e)},{Class:Ts.prototype.constructor,type:6,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,Ts.prototype),e)}];for(let e of hee)eLe(e);uee=new CM({structuredClone:!0}),(_W||(_W={})).deserialize=function(e){return uee.unpack(e)}}),rLe=U(()=>{iLe(),MU=e=>()=>{throw new Error(e+" is not available in the runtime build (decode-only CollabSerialize)")},mA={deserialize:_W.deserialize,serialize:MU("CollabSerialize.serialize"),checksum:MU("CollabSerialize.checksum")}}),Ir=U(()=>{Y4(),YOe(),zX(),s1(),H4(),kX(),a1(),ZOe(),QOe(),u_e(),JOe(),UX(),rLe(),s_e(),q4()});function bW(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var dee,xW,xE,l3,EU,cee,pee,fee,wW,SW,mee,gee,vee,yee,_ee,TW,MW,bee,xee,wee,See,x_e=U(()=>{var e,t,i;Ir(),oe(),(e=dee||(dee={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},e.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},xW={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(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"},r.defaultData=function(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,name:"",actions:new It}:{type:n,disabled:!1,name:"",key:void 0,actions:new It}}})(xE||(xE={})),(r=>{r.propertyDefaultData=function(n){return{type:"Property",value:[n??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(l3||(l3={})),(t=EU||(EU={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:l3.propertyDefaultData(r),rOperand:{...l3.valueDefaultData}}},t.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},t.stateDefaultData=function(r,n){return{type:"State",object:r??null,state:n??null}},(cee||(cee={})).isConditionalSubActions=function(r){return r.find(n=>n==="ifActions"||n==="elseActions")!==void 0},(r=>{r.is=function(n){return n.type==="Conditional"},r.defaultData=function(n){return{type:"Conditional",disabled:!1,name:"",inActions:new It,outActions:new It,condition:EU.distanceDefaultData(n)}}})(pee||(pee={})),(fee||(fee={})).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 It,drop:new It}},(wW||(wW={})).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 It},(SW||(SW={})).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(n){return n.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new It}}})(mee||(mee={})),(r=>{r.is=function(n){return n.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 It}}})(gee||(gee={})),(r=>{r.is=function(n){return n.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new It}}})(vee||(vee={})),(r=>{r.is=function(n){return n.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new It}}})(yee||(yee={})),(r=>{r.is=function(n){return n.type==="Trigger"},r.defaultData=function(n,s){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new It,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}})(_ee||(_ee={})),(i=TW||(TW={})).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 It},n={size:"tablet",operator:"<",actions:new It},s={size:[...i.defaultSizes.custom],operator:"<>",actions:new It},a=new It;return a.push({id:ht.generateUUID(),fi:0,data:r},{id:ht.generateUUID(),fi:1,data:n},{id:ht.generateUUID(),fi:2,data:s}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new It}},(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(n){return n.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new It,variableId:"",objectId:null,property:"Position X"}}})(MW||(MW={})),(r=>{r.is=function(n){return n.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new It,errorActions:new It,userAPIId:""}}})(bee||(bee={})),(r=>{r.is=function(n){return n.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new It,userWebhookId:""}}})(xee||(xee={})),(r=>{r.is=function(n){return n.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new It,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(wee||(wee={})),(r=>{r.is=function(n){return n.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new It}}})(See||(See={}))});function Tee(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function Mee(e){return typeof e=="string"&&e.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}var o1,xx,w_e,eo,Eee,Bc,Ug,gA,Aee,wx,sa,Vr,EW,Cee,Pg,ew,Pee,Ree,Dee,Nee,Iee,Oee,Lee,Bee,AU,Fee,Uee,CU,zee,kee,Vee,PU,Gee,RU,jee,Wee,DU,Hee,AW,qee,$ee,Xee,Yee,Kee,Zee,Jy,xf,Rg,CW,PW,pL,fL,mL,gL,vL,RW,DW,yL,NW,Sx,Qee,NU,IU,IW,Jee,_L,ete,tte,vA,ite,rte,nte,ste,ate,ote,lte,hte,ute,K4,WX,hs,ns,Rb,S_e,yA,bL,Vv,OW,HX,xL,wL,LW,df,AI,Xn,OU,xg,Nh=U(()=>{var e,t,i,r,n,s,a,o;o1="personal camera",xx="a218fcc3-276b-49b9-b485-49037fd14f5f",w_e=2500134,eo=5526619,(e=Eee||{}).x="x",e.y="y",e.z="z",Eee=e,(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,f){let m=l.sub(p,c),g=l.sub(f,c),v=l.dot(m,g)/l.dot(m,m),y=l.scalarMultiply(m,v);return l.add(c,y)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,f){return[c[0]+(p[0]-c[0])*f,c[1]+(p[1]-c[1])*f]},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,f){return h(c,d(c,p,f))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Bc||(Bc={})),(t=Ug||(Ug={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]},t.add=function(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]},t.sub=function(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]},t.div=function(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]},t.mul=function(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]},t.dist=function(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])},t.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=gA||(gA={})).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])]}})(Aee||(Aee={})),(r=wx||(wx={})).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},(n=sa||(sa={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},n.white={r:1,g:1,b:1},n.red={r:1,g:0,b:0},n.black={r:0,g:0,b:0},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},n.clone=function(l){return{r:l.r,g:l.g,b:l.b}},n.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},n.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},n.equals=function(l,u){return l.r===u.r&&l.g===u.g&&l.b===u.b},n.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)},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}},n.is=function(l){return!!Tee(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(s=Vr||(Vr={})).white={...sa.white,a:1},s.is=function(l){return!!Tee(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},s.transparent={...sa.white,a:0},s.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},s.fromHexAndA=function(l,u){return{...sa.fromHex(l),a:u}},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},s.equals=function(l,u){return sa.equals(l,u)&&l.a===u.a},s.equalsFixed=function(l,u){return sa.equalsFixed(l,u)&&l.a.toFixed(2)===u.a.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,a:l.a+(u.a-l.a)*h}},s.toStyle=function({r:l,g:u,b:h,a:d}=s.white){return`rgba(${255*l}, ${255*u}, ${255*h}, ${d})`},(EW||(EW={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=Cee||{})[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",Cee=a,(Pg||(Pg={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(ew||(ew={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=Pee||(Pee={})).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]}),nLe=U(()=>{var e,t;Ir(),x_e(),(Ree||(Ree={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(Dee||(Dee={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(Nee||(Nee={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(Iee||(Iee={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(Oee||(Oee={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(Lee||(Lee={})).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"},(Bee||(Bee={})).defaultData={type:"Reset",name:"",delay:0},(AU||(AU={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(e=Fee||(Fee={})).pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0},(t=Uee||(Uee={})).defaultData={type:"Audio",name:"",...AU.defaultData},t.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),t.hasAudioByEvents=i=>t.getAudiosByEvents(i).length>0,t.getAudiosByActions=i=>{let r=[];return i.forEach(n=>{let s=n.data;s.type==="Audio"&&s.interaction==="play"&&s.audio&&r.push(n),s.type==="Conditional"&&(r.push(...t.getAudiosByActions(s.ifActions)),r.push(...t.getAudiosByActions(s.elseActions)))}),r},t.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:n})=>{xE.is(n)||n.type==="Collision"||n.type==="Start"||n.type==="Trigger"||n.type==="VariableChange"||n.type==="WEBHOOK"||n.type==="AIAssistantTrigger"?r.push(...t.getAudiosByActions(n.actions)):n.type==="Conditional"?(r.push(...t.getAudiosByActions(n.inActions)),r.push(...t.getAudiosByActions(n.outActions))):n.type==="GameControl"?Object.values(n.gameActions).forEach(s=>{r.push(...t.getAudiosByActions(s))}):n.type==="DragDrop"?(r.push(...t.getAudiosByActions(n.dragDropActions.drag)),r.push(...t.getAudiosByActions(n.dragDropActions.drop))):n.type==="Resize"?n.breakpoints.forEach(({data:s})=>{r.push(...t.getAudiosByActions(s.actions))}):n.type==="API"&&(r.push(...t.getAudiosByActions(n.successActions)),r.push(...t.getAudiosByActions(n.errorActions)))}),r},(CU||(CU={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(zee||(zee={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...CU.defaultData},i.hasVideoByActions=r=>r.some(({data:n})=>n.type==="Video"&&n.interaction==="play"&&n.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:n}of r.events)if((xE.is(n)||n.type==="Start")&&i.hasVideoByActions(n.actions))return!0}},i.getVideosByActions=r=>{let n=[];return r.forEach(s=>{let a=s.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&n.push(s)}),n},i.getVideosByEvents=r=>{let n=[];return r.forEach(({data:s})=>{(xE.is(s)||s.type==="Start")&&n.push(...i.getVideosByActions(s.actions))}),n}})(kee||(kee={})),(Vee||(Vee={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(PU||(PU={})).defaultData=function(){return{tweens:new It,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(Gee||(Gee={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...PU.defaultData()}},(RU||(RU={})).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}})(jee||(jee={})),(Wee||(Wee={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...RU.defaultData(i)}},(DU||(DU={})).defaultData=function(i,r,n){return{interaction:"play",object:i,clipId:r,crop:n,crop2:n,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(Hee||(Hee={})),(i=>{i.defaultData=function(r,n,s){return{type:"Animation",name:"",...DU.defaultData(r,n,s)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(AW||(AW={})),(qee||(qee={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},($ee||($ee={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new It,elseActions:new It,condition:[]}),(Xee||(Xee={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(Yee||(Yee={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(Kee||(Kee={})).defaultData={name:"",type:"UserAPI"}}),sLe=U(()=>{var e;(e=Zee||(Zee={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),t=>t.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},e.maxSize=2e6}),T_e=U(()=>{var e;(e=Jy||(Jy={})).all=["PerspectiveCamera","OrthographicCamera"],e.is=function(t){return e.all.includes(t)},(t=>{t.DefaultUp=[0,1,0],t.DefaultTargetOffset=1e3,t.MinTargetOffset=.001,t.sanitizeTargetOffset=function(s){return s===void 0||!Number.isFinite(s)||s<t.MinTargetOffset?t.DefaultTargetOffset:s},t.DefaultAzimuth=-24,t.DefaultElevation=15;let i=t.DefaultAzimuth*Math.PI/180,r=t.DefaultElevation*Math.PI/180,n=180/Math.PI;t.DefaultPosition=[t.DefaultTargetOffset*Math.sin(i)*Math.cos(r),t.DefaultTargetOffset*Math.sin(r),t.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],t.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*n,Math.asin(Math.sin(i)*Math.cos(r))*n,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*n],t.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:t.DefaultUp,isUpVectorFlipped:!1,targetOffset:t.DefaultTargetOffset},t.getZoom=function(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}})(xf||(xf={}))}),M_e=U(()=>{var e;(e=Rg||(Rg={})).defaultData=function(t,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof t[0]=="number"?t[0]:1,typeof t[1]=="number"?t[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 t[0]=="number"?t[0]+t[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:t.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"}}},e.merge=function(t,i){let r={...t};if(PW.forEach(n=>{Object.assign(r,{[n]:i[n]??t[n]})}),r.radial={...t.radial},i.radial){let n=t.radial,s=i.radial;pL.forEach(a=>{Object.assign(r.radial,{[a]:s[a]??n[a]})})}if(r.linear={...t.linear},i.linear){let n=t.linear,s=i.linear;fL.forEach(a=>{Object.assign(r.linear,{[a]:s[a]??n[a]})})}if(r.grid={...t.grid},i.grid){let n=t.grid,s=i.grid;mL.forEach(a=>{Object.assign(r.grid,{[a]:s[a]??n[a]})})}if(r.toObject={...t.toObject},i.toObject){let n=t.toObject,s=i.toObject;gL.forEach(a=>{Object.assign(r.toObject,{[a]:s[a]??n[a]})})}if(r.randomnessObject={...t.randomnessObject},i.randomnessObject){let n=t.randomnessObject,s=i.randomnessObject;vL.forEach(a=>{Object.assign(r.randomnessObject,{[a]:s[a]??n[a]})})}return r},e.isPartial=function(t){return!(!t.randomnessObject&&!t.toObject)},(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];t.toOps=function(r,n){let s=[];r.count!==void 0&&s.push({type:0,path:n,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&s.push({type:0,path:[...n,a],props:o})}return s}})(CW||(CW={})),PW=["count"],pL=["radius","start","end","position","scale","rotation"],fL=["position","scale","rotation"],mL=["count","size"],gL=["count","position","scale","rotation"],vL=["strength","scale","rotation","position","movement","seed","freqScale"]}),E_e=U(()=>{var e;Nh(),(e=RW||(RW={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],e.is=function(t){return e.all.includes(t)},(DW||(DW={})).defaultData=function(t){return function(i){if(i==="PointLight")return{type:i,color:Vr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:Vr.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:Vr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(t)}}),A_e=U(()=>{var e;(e=yL||(yL={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.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:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}}),C_e=U(()=>{var e;(e=NW||(NW={})).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},e.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),qX=U(()=>{(Sx||(Sx={})).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]}}),P_e=U(()=>{var e,t;(e=Qee||{})[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",Qee=e,(t=NU||(NU={})).defaultData={castShadow:!0,receiveShadow:!0},t.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,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe&&(r.shadowCatcher??!1)===(n.shadowCatcher??!1)}})(IU||(IU={})),(IW||(IW={})).defaultData={...IU.defaultData,...NU.defaultData},(Jee||(Jee={})).getMaterialData=function(i,r){let n=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&n.push(s)}else if("materials"in i)for(let s of i.materials){let a=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;a&&n.push(a)}return n}}),R_e=U(()=>{var e;(e=_L||(_L={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7}),VA=U(()=>{var e,t,i,r;Ir(),Nh(),R_e(),Nh(),(ete||(ete={})).is=function(n){return n==="texture"||n==="video"||n==="color"||n==="depth"||n==="normal"||n==="gradient"||n==="noise"||n==="fresnel"||n==="cavity"||n==="dust"||n==="rainbow"||n==="toon"||n==="outline"||n==="particle"||n==="transmission"||n==="reflection"||n==="matcap"||n==="displace"||n==="pattern"||n==="vertexColor"||n==="light"},(tte||(tte={})).is=function(n){return n==="luminance"||n==="r"||n==="g"||n==="b"||n==="a"},(vA||(vA={})).is=function(n){return typeof n=="object"&&n!==null&&n.image!=null},(ite||(ite={})).is=function(n){return n==="phong"||n==="toon"||n==="lambert"||n==="physical"},(r=rte||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",rte=r,nte=(n=>(n[n.RepeatWrapping=1e3]="RepeatWrapping",n[n.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",n[n.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",n))(nte||{}),ste=(n=>(n[n.NearestFilter=1003]="NearestFilter",n[n.LinearFilter=1006]="LinearFilter",n[n.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",n))(ste||{}),(i=ate||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",ate=i,(t=ote||{})[t.Simplex=0]="Simplex",t[t.SimplexFractal=1]="SimplexFractal",t[t.Ashima=2]="Ashima",t[t.Fbm=3]="Fbm",t[t.Perlin=4]="Perlin",t[t.Voronoi=5]="Voronoi",ote=t,(e=lte||{})[e.F1=0]="F1",e[e.F2=1]="F2",e[e.F2MinusF1=2]="F2MinusF1",e[e.SmoothBlend=3]="SmoothBlend",e[e.Edge=4]="Edge",e[e.Power=5]="Power",e[e.Lines=6]="Lines",e[e.Cells=7]="Cells",lte=e,hte=(n=>(n[n.Lights=0]="Lights",n[n.Static=1]="Static",n[n.Camera=2]="Camera",n))(hte||{}),ute=(n=>(n[n.Circle=0]="Circle",n[n.Ring=1]="Ring",n[n.Polygon=2]="Polygon",n[n.Cross=3]="Cross",n[n.Diamond=4]="Diamond",n[n.Checkerboard=5]="Checkerboard",n[n.Line=6]="Line",n[n.Wave=7]="Wave",n))(ute||{}),K4=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],WX=["wrapping","image","video","name","minFilter","magFilter"],(n=>{n.patch=function(s,a){let{texture:o,...l}=a;if(Object.assign(s,l),o){let u=s.texture;u&&Object.assign(u,o)}},n.defaultColorLayer=function(s){return{...n.defaultData("color"),color:s}},n.defaultData=function(s,a){return s==="light"&&a?function(o){let l={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...l,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...l,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...l,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...l,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(a):function(o){let l={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...l,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...l,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:_L.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:sa.fromHex(eo)};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:{...sa.fromHex(6710886),a:1},colorB:{...sa.fromHex(6710886),a:1},colorC:{...sa.fromHex(16777215),a:1},colorD:{...sa.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:Vr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:Vr.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:Vr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:Vr.fromHexAndA(0,1),contourColor:Vr.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:{...sa.fromHex(0),a:1},colorB:{...sa.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(s)}})(hs||(hs={})),(n=>{function s(a,o="layer1",l="layer2",u=sa.fromHex(16777215)){let h=new It;return h.push({fi:0,data:hs.defaultData("light",a),id:o}),h.push({fi:1,data:hs.defaultData("color"),id:l}),{layers:h}}n.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")},n.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},n.defaultEmptyData=function(){return{layers:new It}},n.defaultData=function(a="layer1",o="layer2"){return s("physical",a,o)},n.withName=function(a,o){return{...a,name:o}},n.defaultTwoLayerData=s,n.defaultColorMaterial=function(a,o,l="layer1",u="layer2"){let h=new It;return h.push({fi:0,data:hs.defaultData("light",o),id:l}),h.push({fi:1,data:hs.defaultColorLayer(a),id:u}),{layers:h}},n.defaultUIObjectMaterial=function(a){let o=hs.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new It;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}},n.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=hs.defaultData("texture");Object.assign(h.texture,{image:a});let d=new It;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:hs.defaultData("light",o),id:u}),{layers:d}},n.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=hs.defaultData("video");Object.assign(h.texture,{video:a});let d=new It;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:hs.defaultData("light",o),id:u}),{layers:d}}})(ns||(ns={}))}),aLe=U(()=>{Rb="Roboto_regular",S_e="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),oLe=U(()=>{aLe()}),D_e=U(()=>{Ir(),(yA||(yA={})).defaultData=function(){return{points:new It,roundness:0,shapeHoles:[],isClosed:!1}}}),N_e=U(()=>{Ir(),(bL||(bL={})).defaultData=function(){return{points:new It,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},Vv={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(OW||(OW={})).merge=function(e,t){let i={...e};return xL.forEach(r=>{Object.assign(i,{[r]:t[r]??e[r]})}),i},HX={shape:Vv,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},xL=["depth","offset","angle","twist","startScale","endScale"]}),$X=U(()=>{var e,t;D_e(),N_e(),(e=wL||(wL={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},e.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"},e.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"},(LW||(LW={})).merge=function(i,r){let n={...i};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...i.extrusion},Object.assign(n.extrusion,OW.merge(n.extrusion,r.extrusion))),n},(t=df||(df={})).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:bL.defaultData(),extrusion:HX};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:yA.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{...t.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")},AI=["width","height","depth"]}),I_e=U(()=>{Nh(),(e=>{function t(i){return i.mode??"linear"}e.defaultData={enabled:!1,useBackgroundColor:!1,color:sa.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},e.getMode=t,e.getModeIndex=function(i){let r=t(i);return r==="height"?1:r==="both"?2:0},e.getDensity=function(i){return i.density??e.defaultData.density},e.getHeightFalloff=function(i){return i.heightFalloff??e.defaultData.heightFalloff},e.getHeightBase=function(i){return i.heightBase??e.defaultData.heightBase}})(Xn||(Xn={}))}),XX=U(()=>{(OU||(OU={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(xg||(xg={})).defaultData={enabled:!1,mode:"hdri",hdri:OU.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function lLe(e){let t=typeof e=="string"?Number.parseInt(e,10):e;return typeof t=="number"&&Number.isFinite(t)?Math.min(5,Math.max(0,Math.round(t))):3}var _A,fy,LU,BU,FU,Tx,UU,BW,FW,dte,G1,O_e,ra,SL,cte,pte,fte,mte,_c,wE,TL,ML,wf,my,gte,Dg,EL,Sf,zU,kU,Yv,e1,Kv,SE,UW,vte,Eo,VU,yte,_te,cf,fu,Mx,zW,L_e=U(()=>{(()=>{let e={opacity:1,blendFunction:13,enabled:!1};(_A||(_A={})).defaultData={enabled:!1,pixelation:{...e,blendFunction:16,granularity:15},bloom:{...e,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...e,offset:[2,2]},vignette:{...e,darkness:1,offset:0},hueSaturation:{...e,hue:3,saturation:0},brightnessContrast:{...e,brightness:.25,contrast:0},depthOfField:{...e,focusDistance:100,focalLength:20,bokehScale:5},noise:{...e,blendFunction:16}}})()}),YX=U(()=>{var e;I_e(),XX(),L_e(),Nh(),(e=fy||(fy={})).defaultData={type:"normal",softShadowQuality:"low"},e.isSoft=function(t){return t!=null&&(t.type===void 0||t.type==="soft")},(LU||(LU={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(BU||(BU={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(t=>{t.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},t.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(FU||(FU={})),(Tx||(Tx={})).defaultData={usePhysics:!1,gravity:-10},(UU||(UU={})).defaultData={playCamera:o1,gameControlObject:null},(BW||(BW={})).defaultData={backgroundColor:Vr.fromHexAndA(w_e,1),postprocessing:_A.defaultData,fog:Xn.defaultData,sky:xg.defaultData,globalPhysics:Tx.defaultData,ambient:LU.defaultData,ao:BU.defaultData,shadow:fy.defaultData,publish:UU.defaultData,grading:FU.defaultData}}),hLe=U(()=>{(FW||(FW={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),Z4=U(()=>{var e,t,i;Ir(),T_e(),E_e(),A_e(),C_e(),qX(),P_e(),Nh(),VA(),$X(),M_e(),la(),YX(),hLe(),(e=dte||(dte={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},e.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(t=G1||(G1={})).identity={...EW.identity,hiddenMatrix:wx.identity},t.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,hiddenMatrix:r.hiddenMatrix}},t.merge=function(r,n){return{position:n?.position||r.position,rotation:n?.rotation||r.rotation,pivot:n?.pivot||r.pivot,pivotRotation:n?.pivotRotation||r.pivotRotation,scale:n?.scale||r.scale,hiddenMatrix:n?.hiddenMatrix||r.hiddenMatrix}},t.diff=function(r,n){return t_e({position:Ug.isEqual(r.position,n.position)?void 0:n.position,rotation:Ug.isEqual(r.rotation,n.rotation)?void 0:n.rotation,scale:Ug.isEqual(r.scale,n.scale)?null:n.scale,hiddenMatrix:wx.isEqual(r.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})},O_e=["slide","offset"],(ra||(ra={})).defaultData={states:new It,events:new It,visible:!0,raycastLock:!1,physics:Sx.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...G1.identity,cloner:null},(SL||(SL={})).defaultData={type:"Empty",...ra.defaultData},(cte||(cte={})).defaultData={type:"ParticleCollider",...FW.defaultData,...ra.defaultData},(pte||(pte={})).defaultData={type:"Component",...ra.defaultData},(fte||(fte={})).defaultData={type:"Particle",...ra.defaultData,...yL.defaultData},(mte||(mte={})).defaultData={type:"Hair",...ra.defaultData,...NW.defaultData},(_c||(_c={})).defaultData={type:"Mesh",...ra.defaultData,...IW.defaultData},(wE||(wE={})).defaultData={...ra.defaultData,...G1.identity,position:xf.DefaultPosition,rotation:xf.DefaultRotation,...xf.defaultData},(r=>{r.defaultData=function(n){return{...ra.defaultData,...DW.defaultData(n)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(TL||(TL={})),(r=>{function n(s,a,o=0){for(;o<a.length;){let l=s?s[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;s=l.descendants,o+=1}}r.resolveWithDes=n,r.resolve=function(s,a,o=0){let l=n(s,a,o);if(l){let u=Object.keys(l);if(u.length===1&&u[0]==="descendants")return}return l}})(ML||(ML={})),(r=>{function n(s,a){return{...ra.defaultData,...a,component:s,overrides:new Ts,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=n,r.fromComponentData=function(s){let a=G1.fromObject(s.data);return n(s.id,a)}})(wf||(wf={})),(r=>{r.defaultData={type:"Page",...ra.defaultData,physics:{...Sx.defaultData,fusedBody:!1},...BW.defaultData,camera:wE.defaultData,timelines:new si},r.isUIPage=function(n){return n.uiScene!==void 0}})(my||(my={})),(i=gte||(gte={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:wx.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Sx.defaultData,states:new It,events:new It,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...xf.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",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("RectangleGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("BooleanGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("ShapeBlendGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("TextGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...ra.defaultData,..._c.defaultData,geometry:df.defaultData("InputGeometry"),material:ns.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(n,s){let a={name:s};return n.type==="Mesh"?(a.geometry={},"material"in n&&(a.material={layers:new Ts}),"materials"in n&&(a.materials=n.materials.map(o=>({layers:new Ts})))):Jy.is(n.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(n,s){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:f,...m}=p;if(f!==void 0&&Object.keys(f).length>0){let g={path:[...h,"layers",c,"texture"],props:f,type:0};o.push(g)}if(Object.keys(m).length>0){let g={path:[...h,"layers",c],props:m,type:0};o.push(g)}}}for(let[h,d]of Object.entries(s)){let c=d;if(h!=="name")if(h==="cloner")o.push(...CW.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,f]of Object.entries(c))u(["materials",p],f);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(n,s){if(s===void 0)return n;let a={...n};if(Object.assign(a,G1.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Jy.is(n.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=s;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(n.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:LW.merge(a.geometry,s.geometry)}),(s.material||s.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=hL(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=hL(u.materials,h=>{for(let d=0;d<u.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,f]of Object.entries(c.layers)){let m=h[d]?.layers?.data(p);m&&hs.patch(m,f)}}}).data),u}(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Rg.merge(a.cloner,s.cloner)});else if(n.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Rg.merge(a.cloner,s.cloner)});else if(RW.is(n.type)){let o=s;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=sa.clone(o.color))}return a}})(Dg||(Dg={}))}),KX=U(()=>{(EL||(EL={})).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}}),Q4=U(()=>{KX(),Nh(),(Sf||(Sf={})).defaultData={orbitControls:EL.defaultData,playPage:xx,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let i=0,r=0;return t<5?r=-30:t<10&&(r=30),t===0||t===10||t===5?i=30:(t===4||t===11||t===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}}),B_e=U(()=>{var e;(zU||(zU={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(kU||(kU={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(e=Yv||(Yv={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...zU.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:kU.defaultData}),e.generateSeed=()=>Math.round(1e5*Math.random())}),ZX=U(()=>{Z4(),Ir(),Q4(),Nh(),la(),B_e(),(e=>{function t(i,r){let n=i.scene.objects.get(r);if(n&&n.data.type==="Component")return n;{let s=i.shared.lib.components[r];if(s)return{...s.asset,id:r}}}e.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},e.findTimeline=function(i,r){let n=i.find(s=>s.data.type==="Page"&&s.data.timelines?.[r]!==void 0);return n&&n.data.timelines?.[r]},e.getComponentData=t,e.traverseModuleInstances=function(i,r,n){i.scene.objects.traverseFrom(r,(s,a)=>{if(a.type==="Instance"){let o=t(i,a.component)?.data;o&&n(s,a,o.events)}else n(s,a,a.events)})}})(e1||(e1={})),(e=>{function t(r=!0,n=[]){let s=[];r&&s.push({...e.defaultLight}),s.push(...n);let a=new Ca;return a.push({fi:1,id:xx,data:{...my.defaultData,name:"Scene 1"},children:s}),a}function i(r){return{...e.defaultData,objects:Wo(r,Ca.prototype)}}e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:TL.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Sf.defaultData,styles:Yv.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new Ca,publish:Sf.defaultData,styles:Yv.defaultData()}},e.emptyDataWithPage=function(r=!0){return{objects:t(r),publish:Sf.defaultData,styles:Yv.defaultData()}},e.emptyData=function(){return{objects:new Ca,publish:{...Sf.defaultData},styles:Yv.defaultData()}},e.withObjs=i,e.withObj=function(r,n){return i([{id:r,data:n,children:[],fi:0}])}})(Kv||(Kv={}))}),F_e=U(()=>{(SE||(SE={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),QX=U(()=>{var e,t;Ir(),la(),(e=UW||(UW={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new It}),e.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(vte||(vte={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new It,queries:new It,autoStart:!0}),(i=>{function r(s){return s.textValue!==void 0}function n(s){return typeof s=="boolean"}i.isTextValue=r,i.isNumber=function(s){return typeof s=="number"},i.isBoolean=n,i.typeOfVariable=function(s){return r(s)?"string":n(s)?"boolean":"number"},i.getDisplayedValue=function(s){return i.isTextValue(s)?Array.isArray(s.textValue)?s.textValue.map(a=>a.toString().padStart(s.padding??2,"0")).join(s.deliminator??":")+(s.suffix!==void 0?" "+s.suffix:""):s.textValue.toString():i.isBoolean(s)?s?"True":"False":i.isNumber(s)?parseFloat(s.toFixed(3)).toString():s.toString()}})(Eo||(Eo={})),(VU||(VU={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(yte||(yte={})).all=[...VU.all,"components"],(_te||(_te={})).defaultData=function(){return{images:new si,videos:new si,colors:new si,audios:new si,particles:new si,fonts:new si,materials:new si,components:new si,variables:new si,userAPIs:new si,userWebhooks:new si}},(cf||(cf={})).defaultData=function(){return{images:new si,videos:new si,colors:new si,audios:new si,particles:new si,fonts:new si,materials:new si,components:new si,variables:new si,userAPIs:new si,userWebhooks:new si}},(t=fu||(fu={})).defaultColors=function(){return Wo({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},si.prototype)},t.defaultImages=function(){return Wo({},si.prototype)},t.emptyData=function(){return{catelogs:new si,materials:new si,images:new si,videos:new si,colors:new si,audios:new si,particles:new si,fonts:new si,variables:new It,userAPIs:new si,userWebhooks:new si,lib:cf.defaultData()}},t.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)}},t.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let n=Math.floor(i/3600),s=Math.floor((i-3600*n)/60);return{textValue:[n,s,Math.round(i-3600*n-60*s)]}}if(r.format==="mm:ss"){let n=Math.floor(i/60);return{textValue:[n,Math.round(i-60*n)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),uLe=U(()=>{}),U_e=U(()=>{var e;Ir(),ZX(),F_e(),QX(),(e=Mx||(Mx={})).defaultData={schema:132,scene:Kv.defaultData,frames:new si().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",SE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors()}},e.createDefaultData=function(){return mA.deserialize(mA.serialize(e.defaultData))},e.emptyDataForImports=function(){return{schema:132,scene:Kv.emptyDataWithPage(),frames:new si().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",SE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors(),images:fu.defaultImages()}}},e.emptyData=function(){return{schema:132,scene:Kv.emptyDataWithPage(),frames:new si().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",SE.defaultData),shared:fu.emptyData()}},e.clipboard2dData=function(){return{schema:132,scene:Kv.emptyData(),frames:new si,shared:fu.emptyData()}},e.withoutLib=function(t){return{...t,shared:{...t.shared,lib:cf.defaultData()}}},e.getComponentData=function(t,i){return e1.getComponentData(t,i)},e.hasSensitiveData=function(t){let i=Object.values(t.shared.userAPIs);for(let r of i){let n=r.headers;for(let s of n)if(s.data.key.toLowerCase()==="authorization"&&s.data.value!=="")return!0}return!1}}),dLe=U(()=>{(zW||(zW={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function gy(e,t=[0,0]){return[e&&!isNaN(e[0])?e[0]:t[0],e&&!isNaN(e[1])?e[1]:t[1]]}function LS(e,t,i){switch(e){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:n}=t??{...ew.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${n[0]}, ${n[1]} )`}case 6:{let{mass:r,stiffness:n,damping:s,velocity:a}=i??{...Pg.defaultData},o=new z_e(r,n,s,a),l=o.solve(1);return()=>u=>o.solve(u)/l}case 8:return()=>r=>Math.floor(r)}}var bte,xte,vy,bA,z_e,AL,CL,k_e=U(()=>{Ir(),Nh(),(bte||(bte={})).defaultData=function(e,t){return{id:e,name:t,duration:5,objectTimelines:new si}},(xte||(xte={})).is=function(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"},(e=>{function t(h,d){let c=[0,0],p=[1,1];if(h?.cubicControls)c=gy(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=gy(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(!e.BEZIER_PRESETS.includes(h))return;let d={type:h};return{control1:t(d).control1,control2:t(void 0,d).control2}}function r(h,d){return Math.abs(h[0]-d[0])<.001&&Math.abs(h[1]-d[1])<.001}function n(h){let d=e.ROOT_PROPERTY_ORDER.indexOf(h[0]);return d===-1?e.ROOT_PROPERTY_ORDER.length:d}function s(h){return h.layerId??h.path.join(".")}function a(h){let d=h[h.length-1];return bA.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]}}}}}e.getControlsWithDefault=t,e.BEZIER_PRESETS=[0,1,2,3,4,7],e.presetHandles=i,e.presetForHandles=function(h){return e.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,h.control1)&&r(c.control2,h.control2)})},e.defaultData=function(h){return{id:h,keyframes:new It}},e.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],e.rowOrder=n,e.propertyKey=s,e.groupKeyframes=function(h,d){let c=new Map;for(let p of h){let f=p.data;if(d?.(f))continue;let m=s(f),g=c.get(m);g||(g={id:m,path:f.path,keyframes:[],layerId:f.layerId,index:f.index},c.set(m,g)),f.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,f)=>{let m=n(p.path)-n(f.path);return m!==0?m:(p.index??0)-(f.index??0)})},e.rowAxis=a,e.drawnRowKey=o,e.drawnRows=function(h){let d=new Map;for(let c of h){let p=a(c.path),f=p?c.path.slice(0,-1):c.path,m=o(c),g=d.get(m);g||(g={id:m,path:f,layerId:c.layerId,index:c.index,tracks:[]},d.set(m,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},e.sortedKeyframes=function(h){return[...h].sort((d,c)=>d.data.time-c.data.time)},e.materialLayerPath=l,e.createMaterialGroup=function(h,d){return h.map(({data:c,id:p},f)=>u(d(),l(c),{layerId:p,index:f}))},e.placeholderKeyframe=u,e.createName=function(h){return Object.entries(h).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:LS(3),duration:1e3},opacity:{value:[0,1],easing:LS(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:LS(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:LS(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:LS(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(vy||(vy={})),bA=["x","y","z"],z_e=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),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(e){return 1-(this.m_zeta<1?Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0))}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,this.solve(t)===1){if(i++,i>=16)break}else i=0;return t*e*1e3}}}),JX=U(()=>{var e;Nh(),Ir(),(AL||(AL={})).list=["idle","move","jump","run"],(e=CL||(CL={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.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:e.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 It,move:new It,jump:new It,run:new It},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Vr.fromHexAndA(3728051,1)}}});function Nv(e,...t){let i={};for(let r of t.flat())e!=null&&r in e&&(i[r]=e[r]);return i}function wte(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,n=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)n.push(n[1]),s.push(1);let a={...Nv($s(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...$s(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Kp(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Zp(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=ns.defaultTwoLayerData("phong"),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ns.defaultTwoLayerData("phong")),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ns.defaultTwoLayerData("phong")),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&Object.getPrototypeOf(n.material)!==Ts.prototype&&t(n.material)})})}function Ste(e){e.layers===void 0&&Object.assign(e,ns.defaultTwoLayerData("lambert"))}function GU(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...$s(t),colors:i,steps:r};Object.assign(t,n)}})}function Tte(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&GU(r)}):"material"in i&&typeof i.material!="string"&&GU(i.material)}),Object.values(e.shared.materials).forEach(t=>GU(t))}function Mte(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Ete(e){e.layers&&e.layers.forEach(t=>{(function(i){return i.type!=="displace"})(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function Ate(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=hs.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Cte(e){Kp(e,Ate),Zp(e,Ate)}function Pte(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Rte(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}var cLe=U(()=>{VA(),Nh(),KX(),Z4(),Ir(),Q4(),la(),oe(),$X(),JX(),B_e(),ZX(),qX(),YX()}),V_e={};function Dte(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function G_e(e){let t=e.geometry;t!==void 0&&$_e.has(t.type)&&t.extrusionVersion===void 0&&(t.extrusionVersion=1)}function Nte(e,t){let[i,r,n]=e,s=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),u=Math.cos(n),h=Math.sin(n),d=[o*u,s*h+a*u*l,a*h-s*u*l],c=Math.hypot(t[0],t[1],t[2])||1;return Math.abs((d[0]*t[0]+d[1]*t[1]+d[2]*t[2])/c)}function j_e(e){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*ng)})(e),e.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(n,s){let a=Array.isArray(s)&&s.length>=3&&s.every(u=>typeof u=="number"&&Number.isFinite(u))?s:[0,1,0],o=Nte(n,a),l=Nte(n.map(u=>u*X_e),a);return Math.abs(o-l)<1e-6?n.some(u=>Math.abs(u)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(n=>n*ng)}(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*ng))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ng),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ng),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ng,t.extrusion.twist*=ng),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray($s(e.events))&&e.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 pLe(e){e.scene.objects.traverse((t,i)=>{})}function fLe(e){let t=e.schema??104;t!==132&&t<130&&(PL(e.asset),e.schema=130)}function Gv(e,t){t(e.data);for(let i of e.children)Gv(i,t)}function W_e(e){let t=e.schema??104;t!==132&&(t<105&&(Gv(e.asset,j_e),e.schema=105),t<118&&(Gv(e.asset,q_e),e.schema=118),t<121&&(Gv(e.asset,VW),e.schema=121),t<130&&(Gv(e.asset,mLe),e.schema=130),t<132&&(Gv(e.asset,G_e),e.schema=132))}function H_e(e,t){Zp(e,t),Kp(e,t),Object.values(e.shared.lib.materials).forEach(i=>t(i.asset))}function PL(e){e.layers===void 0&&Object.assign(e,ns.defaultTwoLayerData("phong"))}function mLe(e){"materials"in e?e.materials.forEach(t=>{t!==void 0&&typeof t!="string"&&PL(t)}):"material"in e&&e.material!==void 0&&typeof e.material!="string"&&PL(e.material)}function q_e(e){e.timelineAnimations=Wo({},si.prototype)}function gLe(e){let t=[];return e?(e.forEach((i,r)=>{let{path:n,keyframes:s}=i.data,a=n[0]==="material"?i.id:void 0;s?.length?s.forEach(({id:o,data:l})=>{t.push({id:o,data:{...l,path:n,layerId:a,index:r}})}):t.push(vy.placeholderKeyframe(i.id,n,{layerId:a,index:r}))}),t.sort((i,r)=>i.data.time-r.data.time),new It(...t.map((i,r)=>({...i,fi:r})))):new It}function vLe(e){for(let{id:t,data:i}of[...e.unproxy()]){let r=i.path?.[0];if(!r||!Y_e.includes(r))continue;let n=kW(i.value);if(!n.length)continue;let s=e.data(t);if(!s)continue;let a=i.value,[o,...l]=n;for(let u of l){let h=ht.generateUUID();e.insertBefore(null,[{id:h,data:{...i,id:h,path:[r,u],value:a[u],easing:yLe(i.easing)}}])}s.path=[r,o],s.value=a[o]}}function kW(e){return e===null||typeof e!="object"?[]:bA.filter(t=>t in e)}function yLe(e){let t=e?.cubicControls;return{...e,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...e?.springParameters?{springParameters:{...e.springParameters}}:{}}}function _Le(e,t){return Math.abs(e[0]-t[0])<1e-6&&Math.abs(e[1]-t[1])<1e-6}function bLe(e){let t=function(s){let a=[];for(let o of vy.groupKeyframes(s)){let l=new Set(o.keyframes.flatMap(h=>kW(h.data.value))),u=l.size?[...l].map(h=>o.keyframes.filter(d=>kW(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}([...e.unproxy()]),i=new Map,r=new Set;for(let{left:s,right:a}of t){let o=s.data.easing?.type,l=(o===void 0?void 0:vy.presetHandles(o))?.control2??(o===5?gy(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let u=i.get(a.id);u?_Le(u,l)||r.add(a.id):i.set(a.id,l)}let n=new Map;for(let{id:s,data:a}of e.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:vy.presetHandles(o);l&&n.set(s,l.control1)}for(let{left:s,right:a}of t)r.has(a.id)&&n.delete(s.id);for(let[s,a]of n){let o=e.data(s);!o?.easing||(o.easing.cubicControls={control1:a,control2:gy(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:s,right:a}of t){if(!n.has(s.id))continue;let o=e.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:gy(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function Ite(e,t){e.scene.objects.traverse((i,r)=>{let n=r;if(n.type==="Page"&&n.timelines)for(let s of Object.values(n.timelines))for(let a of Object.values(s.objectTimelines??{}))t(a.keyframes)})}function VW(e){e.pivot=[0,0,0],e.pivotRotation=[0,0,0]}function xLe(e){}function wLe(e){let t=e.schema??0;if(t!==132){if(t>132)return void console.error(`This scene was created with a newer version of Spline (file format ${t}, this runtime reads 132). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",t,"to ",132),function(i,r){if(r<1&&(Zp(i,wte),Kp(i,wte),i.schema=1),r<2&&(function(n){Object.assign(n.scene.publish,{orbitControls:{...EL.defaultData,...$s(n.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(n){function s(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,u]of Object.entries(o))if((K4.includes(l)||typeof u=="boolean")&&delete o[l],l==="texture")for(let[h,d]of Object.entries(u))(WX.includes(h)||typeof d=="boolean")&&delete u[h]}}}n.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let u=l;u.material?s(u.material):u.materials&&u.materials.forEach(h=>{s(h)})})})}(i),i.schema=3),r<4&&(function(n){n.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(n){n.scene.objects.traverse((s,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),r<7&&(function(n){n.scene.objects.traverse((s,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&(Tte(i),i.schema=9),r<10&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((s,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(Tte(i),i.schema=12),r<13&&(function(n){n.shared.audios=Wo({},si.prototype)}(i),i.schema=13),r<14&&(function(n){let s=n.shared.materials;Object.entries(s).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(s,{[a]:l})}})}(i),i.schema=14),r<15&&(function(n){Object.entries($s(n.shared.images)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.images[s]}),Object.entries($s(n.shared.audios)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.audios[s]})}(i),i.schema=15),r<16&&(function(n){n.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Zp(i,Mte),Kp(i,Mte),i.schema=17),r<18&&(Zp(i,Ste),Kp(i,Ste),i.schema=18),r<19&&(function(n){Object.assign(n.scene.publish.settings,{video:{...Sf.defaultData.settings.video,...$s(n.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(n){n.shared.fonts=Wo({},si.prototype)}(i),function(n){let s=[];n.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let u=ns.defaultTwoLayerData("phong"),h=typeof l.color=="string"?n.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(f){return f.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(m=>m.charAt(0).toUpperCase()+m.slice(1)).join(" ")}(l.font);n.shared.fonts[d]===void 0&&(n.shared.fonts[d]={name:d});let c={name:l.name,...ra.defaultData,..._c.defaultData,flatShading:!1,wireframe:!1,geometry:{...df.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:$s(l.states),events:$s(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=$s(n.scene.objects).parent(a);n.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),s.push(a)}}),s.forEach(a=>{n.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(n){let s={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(s[Number(l.type)])if(Object.assign(l,{type:s[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new It,move:new It,jump:new It}});else{let u=new It;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:ht.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,Nv(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let f={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},m={state:h.state,...f,...p},g={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new It({fi:0,id:ht.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:ht.generateUUID(),data:m})};u.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(n){n.scene.objects.traverse((s,a)=>{function o(l,u){let h=new It,d=[];if(a.events.forEach((c,p,f)=>{if(c.type==="Audio"&&c.trigger===u){let m;d.push(p),c.interaction==="play"?m={...Nv(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")&&(m={...Nv(c,"interaction","delay","object","playAudio"),type:"Audio"}),m&&h.push({fi:f,id:p,data:m})}}),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:ht.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&&(Cte(i),i.schema=22),r<23&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(n){n.scene.objects.traverse((s,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(function(n){n.shared.videos=Wo({},si.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(n){n.scene.objects.traverse((s,a)=>{let o=n.scene.objects.unproxy().parent(s);if(o){let l=$s(n.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=$s(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(n){n.scene.objects.traverse((s,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),r<28&&(Cte(i),i.schema=28),r<29&&(function(n){function s(o){Object.setPrototypeOf(o,Ts.prototype),o.texture&&Object.setPrototypeOf(o.texture,Ts.prototype)}function a(o){Object.setPrototypeOf(o,Ts.prototype);for(let l in o)s(o[l])}n.scene.objects.traverse((o,l)=>{l.states.forEach(u=>{let h=u;if(h.material){let d=$s(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=$s(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=ns.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((s,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),r<33&&(function(n){n.scene.objects.traverse((s,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),r<34&&(function(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(n){let{video:s}=n.scene.publish.settings;s.format==="gif"&&s.fps>48&&(s.fps=15)}(i),i.schema=35),r<36&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(n){let s=n.scene.environment.usePhysics;n.scene.objects.traverse((a,o)=>{s&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Zp(i,Ete),Kp(i,Ete),i.schema=38),r<39&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=CL.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(n){n.scene.styles||(n.scene.styles=Yv.defaultData())}(i),i.schema=40),r<41&&(function(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Zp(n,Pte),Kp(n,Pte)}(i),i.schema=41),r<42&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new It})})})}(i),i.schema=42),r<43&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Zp(i,Rte),Kp(i,Rte),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=o1);let n=$s(i.scene.objects),s=i.scene.objects;i.scene.publish.playPage=xx,s.insertBefore(null,null,[{id:xx,data:{...my.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Nv(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Nv(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Tx.defaultData,...Nv(i.scene.environment,"usePhysics","gravity")},camera:$s(i.scene.ownerCamera)??my.defaultData.camera,name:"Scene"},children:[]}]);for(let l of n)l.id!==Kv.TRASH_CAN_ID&&s.move(xx,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,Sx.defaultData)),u.physics!==void 0&&u.physics!==null&&(u.physics.enabled=u.collision??"visibility",delete u.collision)}),i.schema=99}}(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Sf.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Zp(e,Dte),Kp(e,Dte),e.schema=101),t<102&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.geometry;s&&s.type==="PathGeometry"&&(s.extrusion.capType="flat",s.extrusion.bevel=50,s.extrusion.bevelSides=6,s.extrusion.shape.type==="Custom"&&(s.extrusion.shape.shapeQuality="low"))})}(e),e.schema=102),t<104&&(e.shared.catelogs=new si,e.shared.lib=cf.defaultData(),e.schema=104),t<105&&(function(i){i.shared.variables=Wo({},si.prototype)}(e),e.scene.objects.traverse((i,r)=>{j_e(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))W_e(i);t<106&&(function(i){let r=$s(i.shared.variables);i.shared.variables=Wo(Object.entries(r??{}).map(([n,s],a)=>({fi:a,id:n,data:s})),It.prototype)}(e),e.schema=106),t<107&&(e.shared.lib.variables=cf.defaultData().variables,e.schema=107),t<109&&(function(i){i.shared.particles=Wo({},si.prototype),i.shared.lib&&(i.shared.lib.particles=cf.defaultData().particles)}(e),e.schema=109),t<110&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Particle"&&typeof n.renderMaterial.size=="number"&&Object.assign(n.renderMaterial,{size:[n.renderMaterial.size,n.renderMaterial.size]})})}(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{(function(n){Array.isArray($s(n.events))&&n.events?.forEach(s=>{"disabled"in s||(s.disabled=!1),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress")&&(s.mode=s.mode||"Object")})})(r)}),e.schema=111),t<112&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Page"&&(n.postprocessing.depthOfField.focusDistance=100,n.postprocessing.depthOfField.focalLength=20,n.postprocessing.depthOfField.bokehScale=5)})}(e),e.schema=112),t<113&&(function(i){i.scene.objects.traverse((r,n)=>{Array.isArray($s(n.events))!==!1&&n.events?.forEach(s=>{let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(o=>{s.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,s.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),s.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,s.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):s.type==="Start"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,s.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),s.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(function(i){i.shared.userAPIs=Wo({},si.prototype),i.shared.userWebhooks=Wo({},si.prototype),i.shared.lib&&(i.shared.lib.userAPIs=cf.defaultData().userAPIs,i.shared.lib.userWebhooks=cf.defaultData().userWebhooks)}(e),e.schema=115),t<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Sf.defaultData.settings.videoStatic)}(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117),t<118&&(e.shared.timelineAnimations=Wo({},si.prototype),e.scene.objects.traverse((i,r)=>{q_e(r)}),e.schema=118),t<119&&(e.scene.publish.settings.videoStatic.format=Mx.defaultData.scene.publish.settings.videoStatic.format,e.scene.publish.settings.videoStatic.imageFormat=Mx.defaultData.scene.publish.settings.videoStatic.imageFormat,e.schema=119),t<120&&(e.scene.publish.settings.image.colorSpace="display-p3",e.scene.publish.settings.videoStatic.colorSpace="display-p3",e.schema=120),t<121&&(e.scene.objects.traverse((i,r)=>{VW(r),r.type==="Page"&&r.camera!==void 0&&VW(r.camera)}),e.schema=121),t<122&&(delete e.scene.publish.settings.video,e.scene.publish.orbitControls.rotationSpeed=Mx.defaultData.scene.publish.orbitControls.rotationSpeed,e.schema=122),t<123&&(e.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=xg.defaultData)}),e.schema=123),t<124&&(t>=123&&e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(typeof n.exposure=="number"&&(n.exposure=Math.round(n.exposure/5e-4*1e4)/1e4),n.lighting===void 0&&(n.lighting=xg.defaultData.lighting))}),e.schema=124),t<125&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingIntensity===void 0&&(n.lightingIntensity=xg.defaultData.lightingIntensity)}),e.schema=125),t<126&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(n.mode===void 0&&(n.mode="physical"),n.hdri===void 0?n.hdri={...xg.defaultData.hdri}:(n.hdri.blur===void 0&&(n.hdri.blur=xg.defaultData.hdri.blur),Array.isArray(n.hdri.rotation)&&(n.hdri.rotation=n.hdri.rotation[1]??0)))}),e.schema=126),t<127&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n?.hdri!==void 0&&n.hdri.showBackground===void 0&&(n.hdri.showBackground=!0)}),e.schema=127),t<128&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingQuality===void 0&&(n.lightingQuality="full")}),e.schema=128),t<129&&(e.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=my.defaultData.camera);let n=r.camera;n.far=1e5,n.perspective?n.perspective.near=70:n.perspective={near:70,fov:45,zoom:1}}}),e.schema=129),t<130&&(H_e(e,PL),e.schema=130),t<131&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.states;if(!s)return;let a=n.timelineAnimations,o=[];s.forEach((l,u)=>{(l.isAnimation||a?.[u])&&o.push(u)}),o.forEach(l=>s.delete(l))})}(e),function(i){let r=i.shared,n=r.timelineAnimations;if(!n)return;let s=i.scene.objects,a=s.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(n)){let u=Wo({},si.prototype),h=0,d=Boolean(l.loop);for(let[f,m]of Object.entries(l.mapping??{})){let g=s.data(f)?.timelineAnimations?.[m];!g||(h=Math.max(h,g.to??0),d=d||Boolean(g.loop),u[f]={id:f,keyframes:gLe(g.properties?.unproxy())})}let c=l.page??a,p=c?s.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=Wo({},si.prototype)))[o]={id:o,name:l.name,duration:h||5,...d?{loop:d}:{},objectTimelines:u})}delete r.timelineAnimations,s.traverse((o,l)=>{delete l.timelineAnimations})}(e),Ite(e,vLe),Ite(e,bLe),e.schema=131),t<132&&(e.scene.objects.traverse((i,r)=>G_e(r)),e.schema=132)}}cw(V_e,{updateAllMaterials:()=>H_e,updateDocumentSchema:()=>wLe,updateLibSchema:()=>xLe,updateMaterialSchema:()=>fLe,updateObjectStateRec:()=>Gv,updateObjectsSchema:()=>W_e,updateTextValues:()=>pLe});var $_e,ng,X_e,Y_e,Ote,h3,jU,Lte,u3,Zv,BS,j1,d3,WU,CI,HU,qU,Bte,PI,$U,yy,GW,J4=U(()=>{oe(),U_e(),Ir(),k_e(),cLe(),Q4(),VA(),la(),QX(),Z4(),XX(),$_e=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),ng=180/Math.PI,X_e=Math.PI/180,Y_e=["position","rotation","scale","shape size"]}),SLe=U(()=>{var e,t,i;Nh(),Ir(),la(),(Ote||(Ote={})).is=function(r){return!0},(e=h3||(h3={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},e.merge=function(r,n){return{position:n?.position??r.position,rotation:n?.rotation??r.rotation,scale:n?.scale??r.scale,shear:n?.shear??r.shear}},e.diff=function(r,n){return t_e({position:Bc.isEqual(r.position,n.position)?void 0:n.position,rotation:r.rotation===n.rotation?void 0:n.rotation,scale:Bc.isEqual(r.scale,n.scale)?void 0:n.scale,shear:r.shear&&n.shear&&Bc.isEqual(r.shear,n.shear)?void 0:n.shear})},(jU||(jU={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(Lte||(Lte={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(u3||(u3={})).defaultData={opacity:1,fill:{color:Vr.fromHexAndA(eo,1),enabled:!0},stroke:{color:Vr.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:Vr.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Vr.from0to1([0,0,0,1]),enabled:!1,spread:0}},(t=Zv||(Zv={})).newEmpty=function(r,n){return{name:n}},t.patch=function(r,n){if(n===void 0)return r;let s={...r};return Object.assign(s,h3.merge(s,n)),s=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}(s,n),s=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(s,n),s},t.toOps=function(r,n){let s,a=[];for(let[o,l]of Object.entries(n))o!=="name"&&(s===void 0&&(s={path:[],props:{},type:0},a.push(s)),s.props[o]=l);return a},(BS||(BS={})).defaultData={...h3.defaultData,...jU.defaultData,states:new It,events:new It,visible:!0,raycastLock:!1},(j1||(j1={})).defaultData={...BS.defaultData,...u3.defaultData},(d3||(d3={})).defaultData={cornerRadius:[0,0,0,0]},(WU||(WU={})).defaultData={...j1.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(CI||(CI={})).defaultData={...j1.defaultData,...d3.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(HU||(HU={})).defaultData={...j1.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"},(qU||(qU={})).defaultData={...j1.defaultData,type:"path2d",path:"",name:"Path"},(Bte||(Bte={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(PI||(PI={})).defaultData={...BS.defaultData,name:"Group",type:"group2d"},($U||($U={})).defaultData=()=>({...BS.defaultData,...d3.defaultData,...u3.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Vr.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Vr.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(n){switch(n){case"rectangle2d":case"vector2d":return{...CI.defaultData};case"ellipse2d":return{...WU.defaultData};case"text2d":return{...HU.defaultData};case"path2d":return{...qU.defaultData};case"frame2d":return{...$U.defaultData()};case"group2d":return{...PI.defaultData}}},r.getPivot=function(n){return"width"in n&&"height"in n?[typeof n.width=="number"?.5*n.width:0,typeof n.height=="number"?.5*n.height:0]:[0,0]},r.isResizeable=function(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"},r.isAutoLayoutable=function(n){return n.type==="frame2d"&&n.autoLayout!==void 0},r.hasCorners=function(n){return n.type==="rectangle2d"||n.type==="frame2d"}})(yy||(yy={})),(i=GW||(GW={})).defaultData={name:"UI",type:"scene2d",objects:new Ca},i.emptyData=function(){return{type:"scene2d",objects:new Ca}}}),TLe=U(()=>{nLe(),sLe(),T_e(),M_e(),U_e(),x_e(),dLe(),R_e(),I_e(),XX(),J4(),F_e(),$X(),qX(),E_e(),VA(),P_e(),L_e(),Nh(),Q4(),Z4(),KX(),N_e(),QX(),ZX(),oLe(),D_e(),JX(),YX(),A_e(),C_e(),SLe()});function Qv(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),n=new Set(Object.keys(e[0].morphAttributes)),s={},a={},o=e[0].morphTargetsRelative,l=new At,u=0;for(let h=0;h<e.length;++h){let d=e[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;s[p]===void 0&&(s[p]=[]),s[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(!n.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(t){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<e.length;++c){let p=e[c].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+h);h+=e[c].attributes.position.count}l.setIndex(d)}for(let h in s){let d=Fte(s[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 m=0;m<a[h].length;++m)p.push(a[h][m][c]);let f=Fte(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}}return l}function Fte(e){let t,i,r,n=-1,s=0;for(let u=0;u<e.length;++u){let h=e[u];if(t===void 0&&(t=h.array.constructor),t!==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(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*i}let a=new t(s),o=new Rt(a,i,r),l=0;for(let u=0;u<e.length;++u){let h=e[u];if(h.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=h.count;c<p;c++)for(let f=0;f<i;f++){let m=h.getComponent(c,f);o.setComponent(c+d,f,m)}}else a.set(h.array,l);l+=h.count*i}return n!==void 0&&(o.gpuType=n),o}var GA=U(()=>{oe()});function K_e(e){let t=e.points.length/7,i=new It;for(let r=0;r<t;r++){let n=7*r,s=e.points[n+0],a=e.points[n+1],o=e.points[n+2],l=e.points[n+3],u=e.points[n+4],h=e.points[n+5],d=e.points[n+6];i.push({fi:r,id:ht.generateUUID(),data:{roundness:d,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[u,h]}}})}return{points:i,isClosed:e.isClosed,roundness:e.roundness,shapeHoles:e.shapeHoles?.map(r=>K_e(r))??[]}}function Z_e(e){let{userData:t,uuid:i,...r}=e;if(t===void 0||t.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:u}=a,h=u?.groups,d=u?.attributes??{},c=u?.morphAttributes??{},p=u?.interleavedBuffers,f=u?.arrayBuffers,m=u?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(v){let y=1/0,_=1/0,b=1/0,x=-1/0,w=-1/0,S=-1/0;for(let T=0;T<v.length;T+=3){let M=v[T],E=v[T+1],A=v[T+2];y=Math.min(y,M),_=Math.min(_,E),b=Math.min(b,A),x=Math.max(x,M),w=Math.max(w,E),S=Math.max(S,A)}return{width:x-y,height:w-_,depth:S-b}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:f},...o===void 0?{}:o,type:"NonParametricGeometry"};return m!==void 0&&Object.assign(g.data,{index:m}),h!==void 0&&Object.assign(g.data,{groups:h.map(v=>({...v,materialIndex:v.materialIndex??0}))}),g}(e);if(t.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let u=new At;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 Et(h,3)),u.setIndex(new kf(c,1));let p=function(v,y=1e-4){y=Math.max(y,Number.EPSILON);let _={},b=v.getIndex(),x=v.getAttribute("position"),w=b?b.count:x.count,S=0,T=Object.keys(v.attributes),M={},E={},A=[],P=["getX","getY","getZ","getW"],N=["setX","setY","setZ","setW"];for(let G=0,Y=T.length;G<Y;G++){let $=T[G],Q=v.attributes[$];M[$]=new Q.constructor(new Q.array.constructor(Q.count*Q.itemSize),Q.itemSize,Q.normalized);let ue=v.morphAttributes[$];ue&&(E[$]||(E[$]=[]),ue.forEach((pe,xe)=>{let we=new pe.array.constructor(pe.count*pe.itemSize);E[$][xe]=new pe.constructor(we,pe.itemSize,pe.normalized)}))}let D=.5*y,O=Math.log10(1/y),z=Math.pow(10,O),L=D*z;for(let G=0;G<w;G++){let Y=b?b.getX(G):G,$="";for(let Q=0,ue=T.length;Q<ue;Q++){let pe=T[Q],xe=v.getAttribute(pe),we=xe.itemSize;for(let re=0;re<we;re++)$+=~~(xe[P[re]](Y)*z+L)+","}if($ in _)A.push(_[$]);else{for(let Q=0,ue=T.length;Q<ue;Q++){let pe=T[Q],xe=v.getAttribute(pe),we=v.morphAttributes[pe],re=xe.itemSize,Se=M[pe],W=E[pe];for(let k=0;k<re;k++){let K=P[k],ie=N[k];if(Se[ie](S,xe[K](Y)),we)for(let j=0,ae=we.length;j<ae;j++)W[j][ie](S,we[j][K](Y))}}_[$]=S,A.push(S),S++}}let V=v.clone();for(let G in v.attributes){let Y=M[G];if(V.setAttribute(G,new Y.constructor(Y.array.slice(0,S*Y.itemSize),Y.itemSize,Y.normalized)),G in E)for(let $=0;$<E[G].length;$++){let Q=E[G][$];V.morphAttributes[G][$]=new Q.constructor(Q.array.slice(0,S*Q.itemSize),Q.itemSize,Q.normalized)}}return V.setIndex(A),V}(u),f=[],m=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let v=0,y=d.length;v<y;)d[v]===d[v+1]?(m[d[v]]++,f.push(...new Set(g.slice(3*v,3*v+6))),v+=2):(f.push(...g.slice(3*v,3*v+3)),v++);o.indexWASM={array:f},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:m}}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,...MLe(o.positionWASM.array)};l.subdivisions=t.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 n=t.type,s=t.parameters;return n==="VectorGeometry"?(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,width:100,height:100,shape:K_e(t.shape),type:n}):n==="LatheGeometry"?{...t.parameters,type:n,points:(t?.parameters.points??[]).map(a=>[a.x,a.y])}:(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,type:n})}function MLe(e){return jW.setFromArray(e),jW.getSize(PM),{width:PM.x,height:PM.y,depth:PM.z}}var jW,PM,XU,ELe=U(()=>{Ir(),oe(),GA(),new Ue,new kt,new Kr,new R,new R,jW=new fn,PM=new R}),ALe=U(()=>{var e;(e=XU||{}).view="view",e.edit="edit",((XU=e)||(XU={})).canWrite=function(t){return t!=="view"},class extends Error{constructor(t,i){super(`This is a ${t.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=t,this.expected=i,this.name="DocumentKindMismatchError"}}}),Q_e,Wf,TE,J_e,eY,gw,FS,c3,YU,vw,Ute,KU,zte,ZU,tw,dm,cm,lp,QU,kte,Vte,JU,WW,Tf,ebe=U(()=>{ALe()}),CLe=U(()=>{}),PLe=U(()=>{Ir(),J4(),ebe()}),RLe=U(()=>{VA(),[...K4],new Set(WX)}),jt=U(()=>{TLe(),CLe(),uLe(),J4(),PLe(),ebe(),k_e(),RLe(),JX(),Ir()}),Cd=U(()=>{Q_e=[3,4,8,9],Wf=5,TE=3,J_e=32,eY=.98}),jA=U(()=>{oe(),gw=e=>{var t;return(t=class extends e{}).geometryHelper=new Dh(30,30,30),t}}),WA=U(()=>{oe(),FS=new yf,c3=new qa,YU=new Ue,vw=(e,t,i,r,n=!1,s=e)=>{let a=t,o=s.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),c3.copy(a.boundingSphere),c3.applyMatrix4(o),i.ray.intersectsSphere(c3)===!1||(YU.copy(o).invert(),FS.copy(i.ray).applyMatrix4(YU),a.boundingBox!==null&&FS.intersectsBox(a.boundingBox)===!1))return;let l,u,h,d,c,p,f=a.index,m=a.attributes.position,g=a.drawRange;if(n===!1){for(c=Math.max(0,g.start),p=Math.min(f.count,g.start+g.count);c<p;c+=3)if(u=f.getX(c),h=f.getX(c+1),d=f.getX(c+2),l=v(e,i,FS,m,u,h,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let y=a.attributes.position,_=new R,b=new R,x=new R,w=new R,S=2,T=1/((s.scale.x+s.scale.y+s.scale.z)/3),M=T*T;for(let E=Math.max(0,g.start),A=Math.min(y.count,g.start+g.count)-1;E<A;E+=S){if(_.fromBufferAttribute(y,E),b.fromBufferAttribute(y,E+1),FS.distanceSqToSegment(_,b,w,x)>M)continue;w.applyMatrix4(s.matrixWorld);let P=i.ray.origin.distanceTo(w);P<i.near||P>i.far||r.push({distance:P,point:x.clone().applyMatrix4(s.matrixWorld),object:e})}}function v(y,_,b,x,w,S,T){let M=new R,E=new R,A=new R,P=new R,N=new R;if(M.fromBufferAttribute(x,w),E.fromBufferAttribute(x,S),A.fromBufferAttribute(x,T),b.intersectTriangle(M,E,A,!1,P)===null)return null;N.copy(P),N.applyMatrix4(y.matrixWorld);let D=_.ray.origin.distanceTo(N);return D<_.near||D>_.far?null:{faceIndex:1,distance:D,point:N.clone(),object:y}}}}),eB=U(()=>{oe(),jA(),WA(),Ute=new R(1,1,1),KU=new R,zte=new R,ZU=new kt,tw=class extends gw(w1e){constructor(e,t=15){super(t),this.object=e,this.dummy=new fw,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){vw(this.object,tw.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(KU,ZU,zte),this.matrix.compose(KU,ZU,Ute),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}}}),DLe=U(()=>{oe(),dm=new R,cm=new R,lp=new Ue,QU=[new R(-1,1,1),new R(-1,-1,1),new R(1,-1,1),new R(1,1,1),new R(-1,1,-1),new R(-1,-1,-1),new R(1,-1,-1),new R(1,1,-1)],kte=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Vte=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],JU=(e,t,i)=>{e.updateEntityBoxSize(dm,cm),lp.copy(t).multiply(e.matrixWorld),cm.x===0&&cm.y===0&&cm.z===0?i.push(new R(dm.x,dm.y,dm.z).applyMatrix4(lp)):QU.forEach(r=>{i.push(r.clone().multiply(cm).add(dm).applyMatrix4(lp))})},WW=class extends fn{constructor(){super(...arguments),this.matrix=new Ue,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new Ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];if(i===!0){let n=[];e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s))return lp.copy(t).multiply(s.matrixWorld),void n.push(new R().applyMatrix4(lp));JU(s,t,r)}}),r.length===0&&r.push(...n)}else JU(e,t,r);return this.setFromPoints(r)}getCenter(e){return(e=super.getCenter(e)).applyMatrix4(this.matrix),e}getPositionToCenter(e){return(e=super.getCenter(e)).applyMatrix4(lp.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(cm).multiplyScalar(.5),this.getCenter(dm),lp.copy(this.matrix).setPosition(dm),this.vertices=QU.map(e=>e.clone().multiply(cm).applyMatrix4(lp))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=kte.map(([e,t])=>new Eh(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new R))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Vte.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}}}),RL=U(()=>{Tf={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function ME(e){return e?.isParticleSystem===!0}function t1(e){return e?.isHairSystem===!0}function Hf(e){return e?.isShapeBlendEntity===!0}function tB(e){return e?.isPathObject===!0}function Ql(e){return e?.isObject2D===!0}function Xo(e){return e?.isUIObject===!0}function ex(e){return e?.isCloner===!0}function Jv(e){return e?.isClone===!0}function RI(e){return e?.isComponentObject===!0}var ss=U(()=>{});function Nn(e){tY.add(e)}function Ma(e,t){let i=`${e}:${t}`;$W.has(i)||$W.add(i)}function DL(e,t){iY.set(e,t)}function e5(e){return iY.get(e)}function yw(e,t){rY.set(e,t)}function t5(e){return rY.get(e)}function HW(e,t){nY.set(e,t)}function tbe(e){return nY.get(e)}function qW(){return iB}var tY,$W,iY,rY,nY,iB,NL,_r=U(()=>{tY=new Set,$W=new Set,iY=new Map,rY=new Map,nY=new Map,iB=null,NL=null});function ibe(e){let t=e.elements;ud.set(t[0],t[1],t[2]),dd.set(t[4],t[5],t[6]),Ec.set(t[8],t[9],t[10])}function rbe(){let e=Math.max(ud.lengthSq(),dd.lengthSq(),Ec.lengthSq());ud.lengthSq()>RM*e?Th.copy(ud).normalize():Th.set(1,0,0),Mh.crossVectors(Ec,Th),Mh.lengthSq()<=RM*e&&(Mh.copy(dd).addScaledVector(Th,-dd.dot(Th)),Mh.lengthSq()<=RM*e&&function(t,i){t.set(1,0,0).cross(i),t.lengthSq()<=RM&&t.set(0,1,0).cross(i),t.normalize()}(Mh,Th)),Mh.normalize(),ey.crossVectors(Th,Mh)}var ud,dd,Ec,Th,Mh,ey,nbe,RM,DM,p3,ty,rB,sbe=U(()=>{oe(),ud=new R,dd=new R,Ec=new R,Th=new R,Mh=new R,ey=new R,nbe=new Ue,RM=1e-12,DM=.01}),HA=U(()=>{oe(),sbe(),p3=new Ue,(ty||(ty={})).is=function(e){return e&&e.__isSPEObject},rB=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new Ue,this.copyPreviousMatrix=!0,this.hiddenMatrix=new Ue,this.pivotMatrix=new Ue,this.matrixWorldRigid=new Ue,this.shearScale=new Ue,this.shearScaleInv=new Ue}get __isSPEObject(){return!0}getPhysicsLocalMatrix(t){return!!this.rigidBody?.isDynamic()&&(t.copy(this.matrixWorld),this.hasNonUniformScale&&t.multiply(this.shearScaleInv),this.parent&&t.premultiply(p3.copy(this.parent.matrixWorld).invert()),t.premultiply(p3.copy(this.hiddenMatrix).invert()),t.multiply(p3.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(t){t instanceof un&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(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,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&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 n of this.children)n.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)ty.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)ty.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(t,i,r){return ibe(t),rbe(),i.makeBasis(Th,Mh,ey),r.set(Th.dot(ud),Th.dot(dd),Th.dot(Ec),0,Mh.dot(ud),Mh.dot(dd),Mh.dot(Ec),0,ey.dot(ud),ey.dot(dd),ey.dot(Ec),0,0,0,0,1),function(){let n=ud.length(),s=dd.length(),a=Ec.length(),o=Math.max(n,s,a);if(o-n>DM||o-s>DM||o-a>DM)return!0;let l=DM*o*o;return Math.abs(ud.dot(dd))>l||Math.abs(ud.dot(Ec))>l||Math.abs(dd.dot(Ec))>l}()}(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new Ue().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Ue?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,n,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function Gte(e,t,i){return wg.subVectors(t,e),xA.subVectors(t,i),wg.cross(xA).length()<=EE}function abe(e){let t=KW.get(e.points);if(t!==void 0&&t.isClosed===e.isClosed)return t.curve;let i=function(r){let n=r.points,s=[n[0]],a=[new R(...n[0].data.position)];Iv.copy(a[0]);for(let v=0;v<n.length-1;v++)wg.fromArray(n[v].data.position),xA.fromArray(n[v+1].data.position),Db.subVectors(wg,Iv),Nb.subVectors(wg,xA),Db.cross(Nb).length()>EE&&(s.push(n[v]),a.push(new R().copy(wg)),Iv.copy(wg));let o=n[n.length-1];s.push(o),a.push(new R(...o.data.position));let l=r.isClosed,u=s.length-(l?0:1),h=s.length,d=[],c=[];for(let v=0;v<h;v++){let y=s[v].data;d.push(new R(...y.controlPrevious.position)),c.push(new R(...y.controlNext.position))}let p=[];for(let v=0;v<u;v++){let y=v===h-1?0:v+1;p.push(Gte(a[v],c[v],a[y])&&Gte(a[v],d[y],a[y]))}let f=[];for(let v=0;v<h;v++){let y=s[v].data,_=a[v],b={position:_,prevDir:void 0,nextDir:void 0,controlPrevious:d[v],controlNext:c[v],tan:void 0,baseRoundness:y.roundness,removedLength:0};if(f.push(b),y.roundness===0||!l&&(v===0||v===h-1))continue;let x=l&&v==0?h-1:v-1,w=l&&v==h-1?0:v+1,S=new R().subVectors(a[x],_).normalize(),T=new R().subVectors(a[w],_).normalize();b.prevDir=S,b.nextDir=T;let M=p[l&&v===0?h-1:v-1],E=p[v];if(M&&E){Ov.addVectors(S,T).normalize();let A=Iv.crossVectors(Ov,S).length()/S.dot(Ov);b.tan=A,b.removedLength=y.roundness/A}}for(let v=0;v<u;v++){let y=l&&v===h-1?0:v+1,_=f[v],b=f[y];if(_.removedLength!==0||b.removedLength!==0){let x=_.position.distanceTo(b.position);_.removedLength=Math.min(_.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let m=new Array(2*h).fill(null);for(let v=0;v<u;v++){let y=l&&v===h-1?0:v+1,_=f[v],b=f[y],x=null;if(p[v]){let w=_.position.clone(),S=b.position.clone();(_.removedLength!==0||b.removedLength!==0)&&(_.nextDir&&w.add(Iv.copy(_.nextDir).setLength(_.removedLength)),b.prevDir&&S.add(Iv.copy(b.prevDir).setLength(b.removedLength))),w.distanceTo(S)>EE&&(x=new gE(w,w.clone().lerp(S,.3),S.clone().lerp(w,.3),S))}else _.position.distanceTo(b.position)>EE&&(x=new gE(_.position,_.controlNext,b.controlPrevious,b.position));m[2*v+1]=x}for(let v=0;v<h;v++){let y=f[v];if(y.removedLength===0)continue;let _=y.position,b=y.prevDir.clone().multiplyScalar(y.removedLength).add(_),x=y.nextDir.clone().multiplyScalar(y.removedLength).add(_),w=y.tan*y.removedLength;Ov.addVectors(y.prevDir,y.nextDir).normalize(),Db.copy(b).lerp(x,.5);let S=b.distanceTo(x)/2;YW.copy(Ov).multiplyScalar(Math.sqrt(Math.pow(w,2)-Math.pow(S,2))).add(Db),DI.copy(Ov).multiplyScalar(-w).add(YW);let T=_.distanceTo(DI)/_.distanceTo(Db);Nb.copy(y.prevDir).multiplyScalar(T*_.distanceTo(b)).add(_),XW.copy(Nb).lerp(DI,2);let M=b.clone().lerp(Nb,4/3),E=x.clone().lerp(XW,4/3);m[2*v]=new gE(b,M,E,x)}let g=new obe;for(let v=0;v<m.length;v++){let y=m[v];y&&g.add(y)}return g}(e);return KW.set(e.points,{isClosed:e.isClosed,curve:i}),i}var obe,EE,wg,xA,Iv,Ov,Db,DI,Nb,XW,YW,KW,Ib,ZW,NI,lbe,hbe,ube,lr,bc,jte,Wte,US,i5,f3,r5,n5,nB,QW,l1,Ac,dbe=U(()=>{oe(),obe=class extends U7{constructor(){super()}getPoints(e=12){let t,i=[],r=this.getCurveLengths(),n=r[r.length-1]/r.length;for(let s=0,a=this.curves;s<a.length;s++){let o=a[s],l=s===0?r[s]:r[s]-r[s-1],u=Math.ceil(e*l/n),h=o.getPoints(u);for(let d=0;d<h.length;d++){let c=h[d];t&&t.equals(c)||(i.push(c),t=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},EE=.001,wg=new R,xA=new R,Iv=new R,Ov=new R,Db=new R,DI=new R,Nb=new R,XW=new R,YW=new R,KW=new WeakMap}),NLe=U(()=>{oe(),Ib=new Ue,ZW=new kt,NI=new kt,lbe=new Kr,hbe=new R,ube=new R(0,1,0)}),xl=U(()=>{oe(),jt(),DLe(),Ir(),RL(),ss(),_r(),HA(),dbe(),NLe(),Gr(),(lr||(lr={})).is=function(e){return e&&e.__isEntity},bc=e=>lr.is(e),jte={type:"completeState",isfromEntity:!0},Wte=["x","y","z"],US=new R,i5=new R(1,1,1),f3=new kt,r5=new Kr,n5=new Ue,nB=e=>class extends rB(e){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 WW,this._recursiveBBox=new WW,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(lr.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(lr.is(this.children[t]))return t+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 t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(!lr.is(i))return;t=i}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(this.data.states.length!==0||r){for(let n of this.data.states)Dg.toOps(this.data,n.data).forEach(s=>{let a=lL.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let n=this.data.states.data(t);n&&(this.dataPatched=Dg.patch(this.data,n),Dg.toOps(this.data,n).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,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(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{bc(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(lr.is(i[r]))return i[r];if(lr.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&lr.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)bc(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{lr.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)bc(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)bc(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)bc(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>bc(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){return this.updateWorldMatrix(!0,!1),oW({position:this.position.toArray(),rotation:[this.rotation.x*ht.RAD2DEG,this.rotation.y*ht.RAD2DEG,this.rotation.z*ht.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},t)}getTransformValues(t,i,r){return i[t].map((n,s)=>r?.shared.getVariable(n,[this.uuid,t,Wte[s]])??n)}updateTransformState(t,i){let r=!1;if(t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(US.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(ht.DEG2RAD),this.rotation.setFromVector3(US),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??wx.identity)),t.pivot!==void 0||t.pivotRotation!==void 0){if(r=!0,t.pivot!==void 0&&t.pivotRotation!==void 0)this.pivotMatrix.compose(US.fromArray(t.pivot).negate(),f3.setFromEuler(r5.fromArray(t.pivotRotation.map(n=>n*ht.DEG2RAD))).invert(),i5);else if(t.pivot!==void 0)this.pivotMatrix.setPosition(-t.pivot[0],-t.pivot[1],-t.pivot[2]);else if(t.pivotRotation!==void 0){let n=US.setFromMatrixPosition(this.pivotMatrix);f3.setFromEuler(r5.fromArray(t.pivotRotation.map(s=>s*ht.DEG2RAD))).invert(),this.pivotMatrix.compose(n,f3,i5)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){t?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 t of this.children)lr.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{lr.is(t)&&t.disposeRecursively()})}toState(t=[]){return oW({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)},t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,n){let s=this.data;this.data=i;let a=t,o=Jr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let u={...t.props};if(delete u.name,Object.values(t.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let d=Ta.zoom(h,t.path.slice(2));if(d)for(let c in t.props)t.props[c]===void 0&&c in d&&(u[c]=d[c])}}a={...t,props:u,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:h,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:h,...d}=l;l=d}let u=Ta.removeOverridden(t.path,t.props,l);a={...t,props:u}}}if(this.updateByPatchedOpBase(a,Dg.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Jr(t.path,["overrides"])){let l=[],u=[...t.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(t.type===0)for(let h of Object.keys(t.props)){l[l.length-1]=h;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[h],d.updateState(Fg.apply(d.component.data,d.overrideData),r))}}else{let h=r.scene.findInstance([this.uuid,...l]);if(h){let d=Ta.zoom(h.component.data,u);if((t={...t,path:u}).type===0){let c=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(c===t.props&&(c={...t.props}),c[p]=d[p]);t={...t,props:c}}h.overrideData=ML.resolve(i.overrides,l),h.updateByOp(t,Xa.applySimple(h.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let u;for(let h of wf.rootOverrideProps)h in t.props&&(u===void 0&&(u={}),u[h]=t.props[h]);u&&(l={...t,props:u})}else for(let u of wf.rootOverrideProps)if(Jr(t.path,[u])){l=t;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let h=Fg.filterOp(u.overrideData,l);h&&u.updateByOp(h,Xa.applySimple(u.data,h),r,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let h=Fg.filterOp(u.overrideData,t);if(h){let d;d=s===u.data&&t===h?i:Xa.applySimple(u.data,h),u.updateByOp(h,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Jy.is(t.props.type)&&Tf.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Tf.changeEntityProptotype(this,i,r);for(let n of this.children)lr.is(n)&&n.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let n=i.morphTargetInfluences.get(t.path[1])?.data.name;n&&this.updateMorphInfluences(n,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",n]))}if(Jr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Jr(t.path,["cloner"])!==null){let n=Xa.drop(t,1);n.path.length===0&&n.type===0&&n.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(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,n=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=abe(o.geometry.path),u=function(p){let f=p%1;return f<0?f+1:f===0&&p>0?1:f}(r+n),h=null;try{h=l.curves.length?l.getPointAt(u):null}catch{}if(h===null)return;a.updateMatrixWorld();let d=this.parent?n5.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):n5.copy(this.hiddenMatrix),c=function(p,f,m,g){ZW.setFromRotationMatrix(Ib.extractRotation(g));let v=p.clone().applyMatrix4(Ib.copy(g).invert().multiply(m));if(f===null)NI.setFromRotationMatrix(Ib.extractRotation(m));else{let y=f.clone().applyMatrix4(Ib.extractRotation(m));NI.setFromRotationMatrix(Ib.lookAt(hbe.set(0,0,0),y,ube))}return{position:v,rotation:new R().setFromEuler(lbe.setFromQuaternion(ZW.invert().multiply(NI))).multiplyScalar(ht.RAD2DEG)}}(h,s==="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(jte)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>ex(t)&&t.parameters.type==="toObject")}setFromClonerState(t,i){if(!this.disposed)if(t===null||t.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Tf.Cloner===null)return void Ma("cloners","a cloner");this.cloner=new Tf.Cloner(this,t),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(t,i)}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),h1=U(()=>{oe(),xl(),(QW||(QW={})).is=e=>"objectHelper"in e,l1=(e,t)=>class extends nB(e){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof dA&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Dh?(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 dA&&(r.visible=!1)}}}}),sB=U(()=>{oe(),eB(),h1(),Ac=class extends l1(fw,tw){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&Object.keys(e).length===1&&t.scene.reloadSplats()}}});function Pu(e,t,i,r,n,s,a){NM.set(n,s,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let u=0,h=o.length;u<h;u++)l.setXYZ(o[u],NM.x,NM.y,NM.z)}}var NM,nh,Hte,cbe,ILe=U(()=>{oe(),jA(),WA(),NM=new R,nh=new Eg,Hte=class extends Mb{constructor(e){let t=new At,i=new ad({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],s={},a=new ot(15711266),o=new ot(15711266),l=new ot(2857471);function u(d,c,p){h(d,p),h(c,p)}function h(d,c){r.push(0,0,0),n.push(c.r,c.g,c.b),s[d]===void 0&&(s[d]=[]),s[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),t.setAttribute("position",new Et(r,3)),t.setAttribute("color",new Et(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap;nh.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;Pu("n1",t,e,nh,-1,-1,i),Pu("n2",t,e,nh,1,-1,i),Pu("n3",t,e,nh,-1,1,i),Pu("n4",t,e,nh,1,1,i);let r=i;Pu("f1",t,e,nh,-1,-1,r),Pu("f2",t,e,nh,1,-1,r),Pu("f3",t,e,nh,-1,1,r),Pu("f4",t,e,nh,1,1,r);let n=r;Pu("u1",t,e,nh,.35,1.1,n),Pu("u2",t,e,nh,-.35,1.1,n),Pu("u3",t,e,nh,0,1.55,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},cbe=class extends gw(Hte){constructor(e){super(e),this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){vw(this.object,this.geometry,e,t,!0)}}});function qte(e){return 1-Math.pow(1-e,3)}var R0,m3,g3,v3,W1,y3,Hd,Yn,Ih=U(()=>{oe(),ILe(),jt(),h1(),Gr(),R0=new R,m3=new R,g3=new kt,v3=new R,W1=new R,y3=new R,Hd=class extends l1(Eg,cbe){constructor(e="",t={...wE.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=xf.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let n=this._projectionTransition;if(n===void 0)return;if(this.disposed)return void this._endProjectionTransition();n.raf=requestAnimationFrame(this._tickProjectionTransition);let s=Hd.projectionTransitionRequestRender??n.requestRender;this.updateProjectionMatrix(),s?.()},this.super_Entity(e,t),this.previousProjectionMatrix=new Ue,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Hg(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new bh(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(e){let t=Hd.projectionTransitionsEnabled;Hd.projectionTransitionsEnabled=!1;try{return e()}finally{Hd.projectionTransitionsEnabled=t}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){typeof e=="number"&&(e=new R(e,t,i)),super.lookAt(e),this.getWorldPosition(R0),this.targetOffset=R0.distanceTo(e)}getTarget(e=new R){return this.getWorldDirection(m3),this.getWorldPosition(R0),m3.multiplyScalar(this.targetOffset),e.copy(R0).add(m3),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(R0),R0.distanceTo(e)}updateUp(){this.getWorldQuaternion(g3),v3.set(0,0,1).applyQuaternion(g3),W1.copy(un.DEFAULT_UP),this.isUpVectorFlipped&&W1.negate(),W1.applyQuaternion(g3),y3.copy(un.DEFAULT_UP).projectOnPlane(v3),this.angleOffsetFromUp=y3.angleTo(W1),this.angleOffsetFromUp*=y3.cross(W1).dot(v3)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new R),i=e.getWorldDirection(new R).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new R).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new R;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let r=e>t?this.aspect:1,n=e>t?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/n*395,this.bottom=1/n*-395}else this.left=.5*-e,this.right=.5*e,this.top=.5*t,this.bottom=.5*-t;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.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 e=this._projectionTransition;if(e===void 0)return 1;let t=(performance.now()-e.start)/e.duration;return t>=1?1:t<=0?0:qte(t)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Hd.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Hd.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let t=this._projectionTransition;t===void 0&&(t={from:new Ue,blend:new Ue,blendInverse:new Ue,start:0,duration:Hd.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=t),t.from.copy(this.projectionMatrix),t.start=performance.now(),t.duration=Hd.projectionTransitionDuration,t.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(t.requestRender=e),t.raf!==0&&cancelAnimationFrame(t.raf),t.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let t=(performance.now()-e.start)/e.duration;if(t>=1)return void this._endProjectionTransition();let i=qte(t),r=e.from.elements,n=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,a=e.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,n[15]-n[11]*a));for(let u=0;u<16;u++)s[u]=r[u]+(n[u]-r[u])*l;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let t=this._activeSubCamera;this.projectionMatrix=t.projectionMatrix,this.projectionMatrixInverse=t.projectionMatrixInverse}_syncProjectionTransition(e){let t=e._projectionTransition;if(t===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new Ue,blend:new Ue,blendInverse:new Ue,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(t.from),i.start=t.start,i.duration=t.duration,i.referenceDepth=t.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,i,r,n,s):this.orthoCamera.setViewOffset(e,t,i,r,n,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=xf.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){return oW({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},e)}updateCameraSubtype(e,t){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(i,t.zoom),t.near!==void 0&&this.setNear(i,t.near),t.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(t?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(i=>typeof i=="number"?i:0)),e.targetOffset!==void 0&&(this.targetOffset=xf.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},(Yn=Hd).projectionTransitionsEnabled=!1,Yn.projectionTransitionDuration=350,Yn.projectionTransitionMinAgeMs=1e3});function pbe(e){return e.type==="TorusGeometry"&&e.arc===360}var fbe,_3,JW,wA=U(()=>{oe(),fbe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??r),s=Math.abs(i.depth??r),a=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:n,depth:s,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:n,revolutions:s,segments:a,pathRadius:o,pathType:l,pathSegments:u,cornerRadius:h,cornerSegments:d}=e.parameters,c=new JW(!1,t,i,r,n,s,a,o,l,u,h,d);return Object.assign(c,{userData:{...e,type:"HelixGeometry"}})}},_3=new kf([0,0,0],1),JW=class extends At{constructor(e=!0,t=1,i=1,r=1,n=1,s=1,a=1,o=1,l=1,u=1,h=1,d=1){if(super(),s===0)return;let c=e&&s===1;c&&(d=0),h>100&&(h=100),h===0&&(d=0);let p,f,m,g,v,y,_,b,x=()=>new R,w=new R,S=x(),T=x(),M=x(),E=x(),A=x(),P=x(),N=x(),D=x(),O=x(),z=x(),L=x(),V=i-2*o+.001,G=V/s,Y=Math.ceil(a*s),$=Y+1,Q=V/Y,ue=-V/2,pe=u+1,xe=2*Math.PI/u,we=Math.PI/2/d,re=Math.min((1-h/100)*o,o-.01),Se=o-re,W=0,k=2*d+2,K=pe*k/2,ie=K+pe*$,j=Math.max(0,pe*($+k)),[ae,se,H]=[3,3,2].map(pt=>Array(j*pt).fill(0)),me=[],be=n-o;function ke(pt,tt){let Yt=Math.PI/2;y=tt*Q,b=2*Math.PI*(y%G)/G+Yt,y+=ue,_=Math.sin(b)*be,v=Math.cos(b)*be,e?pt.set(v,_,y):pt.set(v,y,_)}ke(w,-1e-10),ke(S,0),E.copy(w),ke(w,1);let Te=w.distanceTo(S),Ze=c?0:Se+re,ze=Te*Y+2*Ze,qe=re,Ne=ze-Ze;for(let pt=0;pt<=Y;pt++){ke(T,pt),L.subVectors(T,E).normalize(),E.copy(T),O.copy(T).setComponent(+e+1,0).normalize(),z.crossVectors(L,O).normalize();let tt=pt===0,Yt=pt===Y,ni=tt?3*Math.PI/2:we,ar=tt?qe:Ne,St=tt?pe:ie,Nt=tt?0:j-pe,Qt=L.clone().multiplyScalar(tt?-Se:Se).add(T),Ei=L.clone().multiplyScalar(tt?-1:1).normalize();for(let xi=0;xi<pe;xi++){let mi=xi*xe;if(A.addVectors(w.copy(O).multiplyScalar(o*Math.cos(mi)),S.copy(z).multiplyScalar(o*Math.sin(mi))),P.copy(A).normalize(),tt||Yt){c||(W=Nt+xi,[0,1,2].forEach(Ai=>{ae[3*W+Ai]=Qt.getComponent(Ai),se[3*W+Ai]=Ei.getComponent(Ai)}),H[2*W]=+Yt,H[2*W+1]=xi/u),S.copy(P).multiplyScalar(re),M.addVectors(T,S);for(let Ai=0;Ai<d;Ai++){let Or=Ai*we+ni;N.addVectors(w.copy(L).multiplyScalar(Se*Math.sin(Or)),S.copy(P).multiplyScalar(Se*Math.cos(Or))),D.copy(N).normalize(),S.addVectors(M,N),N.normalize(),W=St+Ai*pe+xi,[0,1,2].forEach(ir=>{ae[3*W+ir]=S.getComponent(ir),se[3*W+ir]=D.getComponent(ir)});let Hr=+tt+Math.sin(Or);H[2*W]=(ar+Se*Hr)/ze,H[2*W+1]=xi/u}}S.addVectors(T,A),W=K+pt*pe+xi,[0,1,2].forEach(Ai=>{ae[3*W+Ai]=S.getComponent(Ai),se[3*W+Ai]=P.getComponent(Ai)}),H[2*W]=(Ze+pt*Te)/ze,H[2*W+1]=xi/u}}let ee=$+2*d+2,[Ce,He]=[+c,ee-1];for(let pt=Ce;pt<=He-1;pt++){let tt=c&&pt===He-1;for(let Yt=0;Yt<pe-1;Yt++)p=pt*pe+Yt,f=p+1,m=(tt?Yt:p)+pe,g=(tt?Yt+1:f)+pe,pt===0?me.push(f,g,m):pt===ee-2?me.push(p,f,m):me.push(p,f,m,f,g,m)}this.setIndex(me),this.setAttribute("position",new Et(ae,3)),this.setAttribute("normal",new Et(se,3)),this.setAttribute("uv",new Et(H,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e,t,i,r,n=this.userData.parameters,s=Math.ceil(n.tubularSegments),a=n.radialSegments,o=a+1,l=[];for(let u=1;u<s;u++)for(let h=0;h<a;h++)e=u*o+h,t=e+1,i=e+o,r=t+o,l.push(e,t,i,t,r,i);for(let u=0;u<a;u++)e=s*o+u,t=e+1,i=u+o,r=u+1+o,l.push(e,t,i,t,r,i);return _3.array=new Uint32Array(l),_3.count=l.length,_3}}});function OLe(e){return Xte||(Xte=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build",i=import("./boolean.js"),[r,n]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),SA=r}())}function IL(){if(SA===void 0)throw new Error("boolean-wasm is not loaded");return SA}function sY(e){let t=TA.get(e);if(t===void 0)throw new Error("Unknown csg mesh set handle "+e);return t}function aY(e){return TA.set(++eH,e),eH}function LLe(e,t,i){if(SA===void 0)return-1;let{positions:r,indices:n,normals:s}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,f=[];for(let m=0,g=0;m<p.verticesPerFace.length;m++){let v=p.verticesPerFace[m];for(let y=1;y<v-1;y++)f.push(p.indices[g],p.indices[g+y],p.indices[g+y+1]);g+=v}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(f)}}let l;l=pbe(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}}(e,t);return aY(new SA.CsgMesh(r,n,s))}function $te(e,t){let i=IL(),r=gbe[t];if(r===void 0)throw new Error("Unknown boolean operation "+t);let n=e.map(sY);if(n.length===1)return i.clone_mesh(n[0]);let s,a=[];if(t===2&&n.length>2){let o=n[0];for(let l=1;l<n.length-1;l++)o=i.boolean_mesh(o,n[l],0),a.push(o);s=i.boolean_mesh(n[n.length-1],o,2)}else if(t===2)s=i.boolean_mesh(n[1],n[0],2);else{let o=n[n.length-1];for(let l=0;l<n.length-1&&(o=i.boolean_mesh(o,n[l],r),a.push(o),o.tri_count()!==0);l++);s=o,a.pop()}for(let o of a)o.free();return s}function s5(e,t){sY(e).transform(new Float32Array(t.elements))}function mbe(e){let t=TA.get(e);t!==void 0&&(t.free(),TA.delete(e))}var SA,TA,eH,Xte,gbe,aB=U(()=>{oe(),wA(),TA=new Map,eH=0,gbe={0:0,1:1,2:2}});function D0(e){return e!==null&&"booleanOp"in e}var tH,vbe,BLe=U(()=>{oe(),xl(),aB(),tH=class extends nB(Tr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new Ue}updateVisible(e){super.updateVisible(e),this.visible=!D0(this.parent)&&this.visible,D0(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){D0(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(mbe(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),D0(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof tH&&(e.freeBooleanPointer(),D0(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&D0(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),D0(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),FLe=U(()=>{vbe=null});function oY(e,t=0,i=e.count,r,n){let s=1/0,a=1/0,o=1/0,l=-1/0,u=-1/0,h=-1/0;for(let d=t;d<i;d++){let c=e.getX(d),p=e.getY(d),f=e.getZ(d);c<s&&(s=c),p<a&&(a=p),f<o&&(o=f),c>l&&(l=c),p>u&&(u=p),f>h&&(h=f)}IM.min.set(s,a,o),IM.max.set(l,u,h),IM.getCenter(r),IM.getSize(n).multiplyScalar(.5)}var IM,Yte,Kte,Ms,Ia=U(()=>{oe(),BLe(),FLe(),IM=new fn,Yte=new At,Kte=new Zl,Ms=class extends tH{constructor(e,t){super(Yte,Kte),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}raycast(e,t){if(this.raycastDeformed(e,t))return;let i=vbe;i===null?super.raycast(e,t):i(this,e,t)}raycastDeformed(e,t){return!1}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?oY(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}}});function OL(e){return e?.isClassicNodeMaterial===!0}var zr,MA,ybe,_be,AE,bbe,xbe,wbe,lY=U(()=>{}),bu=U(()=>{oe(),zr=class extends ot{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t)}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}}}),Sbe=U(()=>{bu(),MA=class extends zr{}}),ULe=U(()=>{ybe=class{constructor(e=1e4){this.timeout=e,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(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.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 e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let i=t;t=t.next,t.prev=this.head,this.head.next=t,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(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,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((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),Tbe=U(()=>{ULe(),_be=class extends ybe{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}}}),Mbe=U(()=>{bbe=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},xbe=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}}}),zLe=U(()=>{oe(),wbe=class extends c1e{constructor(e){super(e),this.type=di}parse(e){let t=function(p,f){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(p,f,m){f=f||1024;let g=p.pos,v=-1,y=0,_="",b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(v=b.indexOf(`
|
|
4173
4173
|
`))&&y<f&&g<p.byteLength;)_+=b,y+=b.length,g+=128,b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));return-1<v&&(m!==!1&&(p.pos+=y+v+1),_+b.slice(0,v))},r=function(p,f,m,g){let v=p[f+3],y=Math.pow(2,v-128)/255;m[g+0]=p[f+0]*y,m[g+1]=p[f+1]*y,m[g+2]=p[f+2]*y,m[g+3]=1},n=function(p,f,m,g){let v=p[f+3],y=Math.pow(2,v-128)/255;m[g+0]=wd.toHalfFloat(Math.min(p[f+0]*y,65504)),m[g+1]=wd.toHalfFloat(Math.min(p[f+1]*y,65504)),m[g+2]=wd.toHalfFloat(Math.min(p[f+2]*y,65504)),m[g+3]=wd.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let a,o,l,u=function(p){let f,m,g=/^#\?(\S+)/,v=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,b=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,x={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};for((p.pos>=p.byteLength||!(f=i(p)))&&t(1,"no header found"),(m=f.match(g))||t(3,"bad initial token"),x.valid|=1,x.programtype=m[1],x.string+=f+`
|
|
4174
4174
|
`;f=i(p),f!==!1;)if(x.string+=f+`
|
|
4175
4175
|
`,f.charAt(0)!=="#"){if((m=f.match(v))&&(x.gamma=parseFloat(m[1])),(m=f.match(y))&&(x.exposure=parseFloat(m[1])),(m=f.match(_))&&(x.valid|=2,x.format=m[1]),(m=f.match(b))&&(x.valid|=4,x.height=parseInt(m[1],10),x.width=parseInt(m[2],10)),2&x.valid&&4&x.valid)break}else x.comments+=f+`
|
|
4176
|
-
`;return 2&x.valid||t(3,"missing format specifier"),4&x.valid||t(3,"missing image size specifier"),x}(s),h=u.width,d=u.height,c=function(p,f,m){let g=f;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&t(3,"wrong scanline width");let v=new Uint8Array(4*f*m);v.length||t(4,"unable to allocate buffer space");let y=0,_=0,b=4*g,x=new Uint8Array(4),w=new Uint8Array(b),S=m;for(;S>0&&_<p.byteLength;){_+4>p.byteLength&&t(1),x[0]=p[_++],x[1]=p[_++],x[2]=p[_++],x[3]=p[_++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&t(3,"bad rgbe scanline format");let T,M=0;for(;M<b&&_<p.byteLength;){T=p[_++];let A=T>128;if(A&&(T-=128),(T===0||M+T>b)&&t(3,"bad scanline data"),A){let P=p[_++];for(let N=0;N<T;N++)w[M++]=P}else w.set(p.subarray(_,_+T),M),M+=T,_+=T}let E=g;for(let A=0;A<E;A++){let P=0;v[y]=w[A+P],P+=g,v[y+1]=w[A+P],P+=g,v[y+2]=w[A+P],P+=g,v[y+3]=w[A+P],y+=4}S--}return v}(s.subarray(s.pos),h,d);switch(this.type){case Wt:l=c.length/4;let p=new Float32Array(4*l);for(let m=0;m<l;m++)r(c,4*m,p,4*m);a=p,o=Wt;break;case di:l=c.length/4;let f=new Uint16Array(4*l);for(let m=0;m<l;m++)n(c,4*m,f,4*m);a=f,o=di;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:Md,minFilter:rt,magFilter:rt,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}});function Zte(e){return e.length>2&&e[0]===35&&e[1]===63}function a5(e){return typeof e=="object"&&e!==null&&e.isSplineHdr===!0}function Ebe(e){let t=new Nr(e.data,e.width,e.height,mn,di);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var Qte,hY,Rc,Abe=U(()=>{oe(),zLe()}),Cbe=U(()=>{oe(),Tbe(),Mbe(),Abe(),Qte=0,hY=class extends bbe{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.instanceId=++Qte,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let s of Object.values(n))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,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 e!="string"){let r,n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"})),await new Promise(s=>{n.onloadend=a=>{r=a.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else if(e instanceof Uint8Array?Zte(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let r=e instanceof Uint8Array?e:null;if(r===null)try{r=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{r=null}let n=r!==null&&Zte(r)?function(s){try{let a=new wbe().parse(s.buffer.slice(s.byteOffset,s.byteOffset+s.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=m=>wd.toHalfFloat(Math.pow(Math.max(wd.fromHalfFloat(m),0),1/2.2)),p=new Map,f=m=>{let g=p.get(m);return g===void 0&&(g=c(m),p.set(m,g)),g};for(let m=0;m<l;m++){let g=m*d,v=(l-1-m)*d;for(let y=0;y<d;y+=4)h[v+y]=f(u[g+y]),h[v+y+1]=f(u[g+y+1]),h[v+y+2]=f(u[g+y+2]),h[v+y+3]=u[g+y+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(r):null;n!==null&&(this.isHdr=!0,this.img=n,t())}else this.img=new Image,this.img.src=typeof(i=e)=="string"?i:(AE||(AE=new _be),AE.load(i)),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}});var i}getTexture(e,t=1008,i=1006){let r=this._cache[e]?.[t]?.[i];if(r)return r;{let n;return this.isBuffer?n=this.img.texture:this.isVideo?n=new yX(this.img,void 0,e,e):this.isHdr?(n=Ebe(this.img),n.wrapS=e,n.wrapT=e,n.magFilter=i,n.minFilter=t):n=new Ri(this.img,void 0,e,e,i,t),this.isBuffer||(n.anisotropy=8,n.generateMipmaps=t===1008),this.loaded&&(n.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=n,n}}setNeedsUpdate(e){if(!this.isBuffer)for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[n,s]of Object.entries(r))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][n]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),oB=U(()=>{Cbe(),Rc=class extends hY{}});function kLe(e){if(typeof e=="string")return e;let t=iH.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},iH.set(e,t)),t.url}var iH,VLe=U(()=>{iH=new Map});function GLe(){if(!rH)return Jte||(Jte=async function(){await Promise.resolve().then(()=>(yZ(),M3e)),Pbe(window!==void 0?window:global),rH=!0}())}var Pbe,Rbe,rH,Jte,Dbe=U(()=>{Rbe=new Promise(e=>{Pbe=e}),rH=!1});function eie(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function jLe(e){let t=!1,i=[];return e.scene.objects.traverse((r,n)=>{if(n.type==="Page"&&n.uiScene!==void 0&&n.uiScene.objects.traverse((s,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;eie(a.events,i),t=t||i.some(o=>o.data.type==="Audio")}),n.events===void 0||Array.isArray(n.events)===!1)return!0;eie(n.events,i),t=t||i.some(s=>s.data.type==="Audio")}),t}var tie,tx,uY=U(()=>{VLe(),Dbe(),Rbe.then(e=>tie=e),tx=class{constructor({src:e,volume:t,delay:i,loop:r}){let n;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)},n=typeof e=="string"?{src:e}:{src:kLe(e),format:"wav"},this.sound=new tie.Howl(n),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,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(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function iie(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var dY,cY=U(()=>{dY=null});function rie(e){return new Z(e.y,-e.x)}var pY,nH,Nbe,Ibe,b3,nie,LL,Obe,o5,BL=U(()=>{oe(),pY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,n=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);n.thetaLength=ht.clamp(n.thetaLength,0,360),n.hollow=ht.clamp(n.hollow??0,0,1);let s=n.width/2,a=n.radiusTop??s,o=n.radiusBottom??s;if(a===o?(a=s,o=s):a>o?(a=s,o=o*s/a):(a=a*s/o,o=s),n.shapeBlendNode){a=i??s,o=r??s;let l=2*Math.max(a,o);n.width=l,n.depth=l}return{parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(n.height??n.width),depth:Math.abs(n.depth??n.width),radiusTop:a,radiusBottom:o})}}static build(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:f}=e.parameters;u===0?(t=new At,t.setAttribute("position",new Et([],3))):t=c||f?new nH(h,d,n,s,a,o,l,u*Math.PI/180,c,c,p,f):new mE(h,d,n,s,a,o,l,u*Math.PI/180);let m=r/i;return m!==1&&t.scale(1,1,m),Object.assign(t,{userData:{...e,type:"CylinderGeometry"}})}},nH=class extends At{constructor(e,t,i,r,n,s,a,o,l,u,h,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,n=Math.floor(n)||1,s=s!==void 0&&s,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,s&&(l=0,u=0);let p=i/2;c&&e==0&&(e=l),c&&t==0&&(t=u);let f=new Z(e,p),m=new Z(t,-p),g=null,v=null,y=null,_=null,b=f.clone().sub(m),x=0,w=0,S=0;d>0&&(x=Math.min(e,t)*(1-d),w=e-x,S=t-x);let T=f.clone();T.x-=x;let M=Math.PI-b.angle(),E=b.angle(),A=Math.tan(E/2),P=Math.tan(M/2),N=A+P,D=d?N:P,O=d?N:A;if(l=Math.min(l,(e-w)/D,b.length()/N),u=Math.min(u,(t-S)/O,b.length()/N),l>0){let me=l/A;g=f.clone().sub(new Z(me,l)),d&&(y=g.clone(),y.x-=x-N*l),f.sub(b.clone().setLength(me))}if(u>0){let me=u/P;v=m.clone().sub(new Z(me,-u)),m.add(b.clone().setLength(me)),d&&(_=v.clone(),_.x-=x-N*u,T.sub(b.clone().setLength(me)))}b=f.clone().sub(m);let z=b.length()<.5,L=[],V=[],G=[],Y=[],$=[],Q=[],ue=(me,be,ke,Te,Ze)=>{for(let ze=0;ze<h+1;ze++){let qe=ze/h,Ne=Te<0?qe:1-qe;Ze&&(Ne-=1),Ne*=me;let ee=Math.sin(Ne),Ce=Math.cos(Ne)*Te,He=Ce*be+ke.y;L.push(ee*be+ke.x),V.push(He),G.push(ee),Y.push(Ce),$.push(.5+He/i),Q.push(!1)}},pe=(me,be,ke)=>{let Te=[me,be];ke<0&&Te.reverse();for(let Ze of Te)L.push(Ze),V.push(p*ke),G.push(0),Y.push(ke),$.push(.5),Q.push(!0)};if(_&&v?(ue(M,u,_,-1,!0),ue(E,u,v,-1,!1)):v?(pe(v.x,0,-1),ue(E,u,v,-1,!1)):s||pe(t,S,-1),!z){let me=rie(b).normalize();for(let be=0;be<=n;be++){let ke=be/n,Te=b.y*ke+m.y;L.push(b.x*ke+m.x),V.push(Te),G.push(me.x),Y.push(me.y),$.push(.5+Te/i),Q.push(!1)}}if(y&&g?(ue(M,l,g,1,!1),ue(E,l,y,1,!0)):g?(ue(M,l,g,1,!1),pe(g.x,0,1)):s||pe(e,w,1),d&&!z){let me=rie(b).multiplyScalar(-1).normalize();for(let be=0;be<=n;be++){let ke=be/n,Te=b.y*-ke+T.y;L.push(b.x*-ke+T.x),V.push(Te),G.push(me.x),Y.push(me.y),$.push(.5+Te/i),Q.push(!1)}}let xe=L.length,we=xe+(d&&!s?1:0),re=(me,be)=>me*xe+(be===xe?0:be),Se=o<2*Math.PI,W=(r+1)*xe+(Se?2*(1+we):0),k=new Float32Array(3*W),K=new Float32Array(3*W),ie=new Float32Array(2*W),j=W-1>65535?new Uint32Array(r*Math.max(0,we-1)*6+(Se?2*(we+1)*3:0)):new Uint16Array(r*Math.max(0,we-1)*6+(Se?2*(we+1)*3:0)),ae=0,se=0;for(let me=0;me<=r;me++){let be=me/r,ke=be*o+a,Te=Math.sin(ke),Ze=Math.cos(ke);for(let ze=0;ze<xe;ze++){let qe=3*se,Ne=2*se,ee=L[ze],Ce=G[ze];k[qe]=ee*Te,k[qe+1]=V[ze],k[qe+2]=ee*Ze,K[qe]=Ce*Te,K[qe+1]=Y[ze],K[qe+2]=Ce*Ze,Q[ze]?(ie[Ne]=.5,ie[Ne+1]=.5):(ie[Ne]=be,ie[Ne+1]=$[ze]),se++}}for(let me=0;me<r;me++)for(let be=0;be<we-1;be++){if(s&&d&&be==n)continue;let ke=re(me,be),Te=re(me+1,be),Ze=re(me+1,be+1),ze=re(me,be+1),qe=k[3*Ze+0],Ne=k[3*Ze+2];j[ae++]=ke,j[ae++]=Te,j[ae++]=ze,(qe!=0||Ne!=0)&&(j[ae++]=Te,j[ae++]=Ze,j[ae++]=ze)}function H(me,be,ke){let Te=Math.sin(ke),Ze=Math.cos(ke),ze=-Ze,qe=Te,Ne=me<0?(tt,Yt,ni)=>{j[ae++]=tt,j[ae++]=Yt,j[ae++]=ni}:(tt,Yt,ni)=>{j[ae++]=tt,j[ae++]=ni,j[ae++]=Yt},ee=(e+t+w+S)/4,Ce=3*se,He=2*se;k[Ce]=ee*Te,k[Ce+1]=0,k[Ce+2]=ee*Ze,K[Ce]=ze,K[Ce+1]=0,K[Ce+2]=qe,ie[He]=.5,ie[He+1]=.5;let pt=se++;for(let tt=0;tt<we;tt++){let Yt=3*(be+(tt===xe?0:tt));Ce=3*se,He=2*se,k[Ce]=k[Yt],k[Ce+1]=k[Yt+1],k[Ce+2]=k[Yt+2],K[Ce]=ze,K[Ce+1]=0,K[Ce+2]=qe;let ni=Yt/3*2|0;ie[He]=ie[ni],ie[He+1]=ie[ni+1],se++}for(let tt=pt+1;tt<se-1;tt++)Ne(pt,tt,tt+1);Ne(pt,se-1,pt+1)}Se&&(H(-1,0,a),H(1,r*xe,a+o)),this.setIndex(new Rt(j.slice(0,ae),1)),this.setAttribute("position",new Rt(k,3)),this.setAttribute("normal",new Rt(K,3)),this.setAttribute("uv",new Rt(ie,2))}}}),sie=U(()=>{oe(),BL(),Nbe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=ht.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(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters;u===0?(t=new At,t.setAttribute("position",new Et([],3))):t=h>0||d>0||u<360?new nH(0,i/2,n,s,a,o,l,u*Math.PI/180,h,d,c,0,!0):new iL(i/2,n,s,a,o);let p=r/i;return p!==1&&t.scale(1,1,p),Object.assign(t,{userData:{...e,type:"ConeGeometry"}})}}}),aie=U(()=>{oe(),Ibe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.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(e){let t,{width:i,height:r,depth:n,widthSegments:s,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:u}=e.parameters;return t=l===0?new Dh(i,r,n,s,a,o):new nie(i,r,n,s,a,o,l,u),Object.assign(t,{userData:{...e,type:"CubeGeometry"}})}},b3=Math.PI/2,nie=class extends At{constructor(e=1,t=1,i=1,r=1,n=1,s=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=(a=Math.min(a,e/2,t/2,i/2))>0,u=o+1,h=2*((s+1)*(n+1)+(r+1)*(s+1)+(r+1)*(n+1))+(l?4*u*(s+1+(r+1)+(n+1))+u*(u+1)/2*8:0),d=2*(s*n+r*s+r*n)+(l?4*o*(s+r+n):0),c=l?8*o*o:0,p=new Float32Array(3*h),f=new Float32Array(3*h),m=new Float32Array(2*h),g=h-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),v=0,y=0,_=new Float64Array(u),b=new Float64Array(u),x=new Float64Array(u),w=new Float64Array(u);for(let N=0;N<u;N++){let D=N/o*b3;_[N]=Math.sin(D)*a,b[N]=(1-Math.cos(D))*a,x[N]=Math.sin(D),w[N]=Math.cos(D)}let S=u*(u+1)/2,T=new Float64Array(3*S),M=new Float64Array(3*S);{let N=new R(e/2,t/2,i/2);N.subScalar(a);let D=0;for(let O=0;O<=o;O++){let z=b3*(1-O/o),L=Math.cos(z),V=Math.sin(z),G=0;for(let Y=0;Y<=O;Y++){let $=L*Math.cos(G),Q=V,ue=L*Math.sin(G);T[3*D]=$,T[3*D+1]=Q,T[3*D+2]=ue,M[3*D]=N.x+$*a,M[3*D+1]=N.y+Q*a,M[3*D+2]=N.z+ue*a,D++,G+=b3/O}}}function E(N,D,O,z,L,V,G,Y,$,Q){let ue=(V-2*a)/$,pe=(G-2*a)/Q,xe=V/2-a,we=G/2-a,re=Y/2,Se=$+1,W=Q+1,k=0,K=new R;for(let ie=0;ie<W;ie++){let j=ie*pe-we;for(let ae=0;ae<Se;ae++){let se=ae*ue-xe,H=3*(v+k),me=2*(v+k);K[N]=se*z,K[D]=j*L,K[O]=re,p[H]=K.x,p[H+1]=K.y,p[H+2]=K.z,K[N]=0,K[D]=0,K[O]=Y>0?1:-1,f[H]=K.x,f[H+1]=K.y,f[H+2]=K.z,m[me]=ae/$,m[me+1]=1-ie/Q,k+=1}}for(let ie=0;ie<Q;ie++)for(let j=0;j<$;j++){let ae=v+j+Se*ie,se=v+j+Se*(ie+1),H=v+(j+1)+Se*(ie+1),me=v+(j+1)+Se*ie;g[y++]=ae,g[y++]=se,g[y++]=me,g[y++]=se,g[y++]=H,g[y++]=me}v+=k}function A(N,D,O,z,L,V,G,Y,$,Q){let ue=(G-2*a)/Q,pe=G/2-a,xe=Y/2-a,we=$/2,re=Q+1,Se=0,W=new R,k=new R;for(let K=0;K<o+1;K++){W[D]=(xe+_[K])*L,W[O]=(we-b[K])*V,k[N]=0,k[D]=x[K]*Math.sign(W[D]),k[O]=w[K]*Math.sign(W[O]);for(let ie=0;ie<re;ie++){let j=ie*ue-pe;W[N]=j*z;let ae=3*(v+Se),se=2*(v+Se);p[ae]=W.x,p[ae+1]=W.y,p[ae+2]=W.z,f[ae]=k.x,f[ae+1]=k.y,f[ae+2]=k.z,m[se]=ie/Q,m[se+1]=0,Se+=1}}for(let K=0;K<o;K++)for(let ie=0;ie<Q;ie++){let j=v+ie+re*K,ae=v+ie+re*(K+1),se=v+(ie+1)+re*(K+1),H=v+(ie+1)+re*K;g[y++]=j,g[y++]=ae,g[y++]=H,g[y++]=ae,g[y++]=se,g[y++]=H}v+=Se}function P(N,D,O){let z=N*D*O>0?(V,G,Y)=>{g[y++]=V,g[y++]=G,g[y++]=Y}:(V,G,Y)=>{g[y++]=V,g[y++]=Y,g[y++]=G},L=v;for(let V=0;V<S;V++){let G=3*V,Y=3*v,$=2*v;p[Y]=N*M[G],p[Y+1]=D*M[G+1],p[Y+2]=O*M[G+2],f[Y]=N*T[G],f[Y+1]=D*T[G+1],f[Y+2]=O*T[G+2],m[$]=0,m[$+1]=0,v++}for(let V=0;V<o;V++){let G=L+V*(V+1)/2,Y=L+(V+1)*(V+2)/2;z(G,Y+1,Y);for(let $=1;$<=V;$++)z(G+$-1,G+$,Y+$),z(G+$,Y+$+1,Y+$)}}E("z","y","x",-1,-1,i,t,e,s,n),E("z","y","x",1,-1,i,t,-e,s,n),E("x","z","y",1,1,e,i,t,r,s),E("x","z","y",1,-1,e,i,-t,r,s),E("x","y","z",1,-1,e,t,i,r,n),E("x","y","z",-1,-1,e,t,-i,r,n),a>0&&(A("z","y","x",-1,-1,1,i,t,e,s),A("z","y","x",1,-1,-1,i,t,e,s),A("z","y","x",-1,1,-1,i,t,e,s),A("z","y","x",1,1,1,i,t,e,s),A("x","y","z",-1,-1,-1,e,t,i,r),A("x","y","z",1,-1,1,e,t,i,r),A("x","y","z",-1,1,1,e,t,i,r),A("x","y","z",1,1,-1,e,t,i,r),A("y","x","z",-1,-1,1,t,e,i,n),A("y","x","z",1,-1,-1,t,e,i,n),A("y","x","z",1,1,1,t,e,i,n),A("y","x","z",-1,1,-1,t,e,i,n),P(1,1,1),P(-1,1,1),P(1,-1,1),P(-1,-1,1),P(1,1,-1),P(-1,1,-1),P(1,-1,-1),P(-1,-1,-1)),this.setIndex(new Rt(g,1)),this.setAttribute("position",new Rt(p,3)),this.setAttribute("normal",new Rt(f,3)),this.setAttribute("uv",new Rt(m,2))}}}),Lbe=U(()=>{oe(),LL=class extends At{constructor(e=[],t=[],i="",r=1,n=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,u=0;return function(){(n=Math.min(.99999,n))==0&&(s=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new R,c=d.clone(),p=new Bs,f=n*r,m=r-f,g=s+1,v=new R,y=(re,Se)=>v.subVectors(re,Se).normalize(),_=(re,Se)=>Array(re).fill(void 0).map(Se),b=_(e.length/3,(re,Se)=>new R().fromArray(e,3*Se).setLength(r)),x=[],w=1e6;for(let re=0;re<b.length;re++){let Se,W,k,K=b[re],ie=[],j=1e10,ae=-1;for(;(ae=t.indexOf(re,ae+1))!=-1;){let be=ae-ae%3;Se=t[be+(ae+1)%3],W=t[be+(ae+2)%3],k=K.distanceToSquared(b[Se]),j=Math.min(j,k),ie.push([Se,W,k])}j+=1e-6;let se=[],H=0,me=ie.length;for(let be=0;be<me;be++){[Se,W,k]=ie[H];let ke=x[Se]?.includes(re)==1;k<=j&&se.push(Se+ +ke*w),H=ie.findIndex(Te=>Te[0]==W)}x.push(se)}let S=[];{let re,Se,W=0,k=0,K=h==3;for(let ie=0;ie<=s;ie++){re=ie*(ie+1)/2,Se=(ie+1)*(ie+2)/2;for(let j=0;j<s-ie;j++)[W,k]=[re+j+ie+2,Se+j+ie+3],S.push(re,Se,...K?[k,re]:[W,Se],k,W),[re,Se]=[W,k];S.push(re,Se,re+s+2)}}let T=0;for(let re=0;re<x.length;re++)for(let Se=0;Se<h;Se++)x[re][Se]<w&&T++;let M=b.length*h*S.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(M),o=new Float64Array(M),l=new Float64Array(M/3*2);let E=(re,Se,W)=>{let k=u/3*2;l[k]=Math.atan2(W,-re)/2/Math.PI+.5,l[k+1]=1-(Math.atan2(-Se,Math.sqrt(re*re+W*W))/Math.PI+.5)},A=re=>{a[u]=re.x,a[u+1]=re.y,a[u+2]=re.z,o[u]=v.x,o[u+1]=v.y,o[u+2]=v.z,E(re.x,re.y,re.z),u+=3},P=re=>{a[u]=re[0].x,a[u+1]=re[0].y,a[u+2]=re[0].z,o[u]=re[1].x,o[u+1]=re[1].y,o[u+2]=re[1].z,E(re[0].x,re[0].y,re[0].z),u+=3},N=(s+2)*(s+3)/2,D=new Float64Array(3*N),O=new Float64Array(3*N),z=new Float64Array(2*N),L=_(2*h*g,()=>new R),V=_(s*Math.max(0,s-1)/2,()=>new R),G=d.clone(),Y=d.clone(),$=d.clone(),Q=d.clone(),ue=d.clone(),pe=[],xe=_(b.length,()=>_(h,()=>d.clone()));for(let re=0;re<b.length;re++){d.copy(b[re]).normalize(),G.copy(d).multiplyScalar(m);let Se=x[re];for(let se=0;se<Se.length;se++){let H=Se[se],me=Se[(se+1)%h];p.setFromPointsAndIndices(b,re,H%w,me%w),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(G,xe[re][se])}let W=0,k=[],K=[],ie=new R;s==0&&[...xe[re]].reduce((se,H)=>se.add(H),ie).multiplyScalar(1/h);for(let se=0;se<h;se++){let H=[],me=(se-1+h)%h,be=xe[re][me],ke=xe[re][se];d.copy(be).sub(G),c.copy(ke).sub(G);let Te=G.angleTo(d),Ze=d.angleTo(c),ze=Math.cos(Te)*f;s==0?Y.copy(ie):Y.copy(G).setLength(m+ze),k.push(ze);let qe=[Y,be,ke];for(let Ne=0;Ne<2;Ne++){let ee=qe[Ne],Ce=qe[Ne+1];Q.subVectors(ee,G),ue.subVectors(Ce,G),$.crossVectors(Q,ue).normalize();for(let He=0;He<g;He++){let pt=[Te,Ze][Ne]*He/g;d.copy(Q).applyAxisAngle($,pt).add(G),L[W++].copy(d),Ne&&(y(d,G),H.push([He==0?ee:d.clone(),v.clone()]))}Ne&&(y(Ce,G),H.push([Ce,v.clone()]))}K.push(H)}pe.push(K);let j=2*g,ae=2;for(let se=0;se<h;se++){let H=j*se,me=j*((se+1)%h),be=0,ke=[L[H]];for(let Te=1;Te<g;Te++){let Ze=L[H+Te],ze=L[me+Te];ke.push(Ze);for(let qe=1,Ne=Te-ae+1;qe<=Ne;qe++)d.lerpVectors(Ze,ze,qe/(Ne+1)),d.sub(G).setLength(k[se]).add(G),ke.push(V[be++].copy(d));ke.push(ze)}for(let Te=0;Te<g;Te++)ke.push(L[Te+g+H]);ke.push(L[me+g]);for(let Te=0,Ze=ke.length;Te<Ze;Te++){let ze=ke[Te],qe=3*Te,Ne=2*Te;D[qe]=ze.x,D[qe+1]=ze.y,D[qe+2]=ze.z,y(ze,G),O[qe]=v.x,O[qe+1]=v.y,O[qe+2]=v.z,z[Ne]=Math.atan2(ze.z,-ze.x)/2/Math.PI+.5,z[Ne+1]=1-(Math.atan2(-ze.y,Math.sqrt(ze.x*ze.x+ze.z*ze.z))/Math.PI+.5)}for(let Te=0,Ze=S.length;Te<Ze;Te++){let ze=3*S[Te],qe=2*S[Te],Ne=u/3*2;a[u]=D[ze],a[u+1]=D[ze+1],a[u+2]=D[ze+2],o[u]=O[ze],o[u+1]=O[ze+1],o[u+2]=O[ze+2],l[Ne]=z[qe],l[Ne+1]=z[qe+1],u+=3}}}let we=[];for(let re=0;re<x.length;re++)for(let Se=0;Se<h;Se++){let W=x[re][Se];if(W<w){let k=x[W].findIndex(j=>j%w==re),K=pe[re][Se],ie=pe[W][k];for(let j=0;j<g;j++){let ae=K[j],se=ie[g-j],H=K[j+1],me=ie[g-(j+1)];P(ae),P(se),P(H),P(H),P(se),P(me)}we.push(K[0][0],ie[g][0],K[g][0],ie[0][0])}}for(;we.length;){let re,Se,W,[k,K]=we.splice(0,2);re=K;let ie=[k];for(;k!=re;)ie.push(re),Se=we.indexOf(re),W=Se%2,re=we.splice(Se-W,2)[1-W];v.subVectors(ie[0],ie[1]).cross(d.subVectors(ie[0],ie[2])).normalize();let j=v.dot(ie[0])<0;j&&v.negate();for(let ae=1;ae<=ie.length-2;ae++)A(ie[ae+ +j]),A(ie[ae+1-+j]),A(ie[0])}}(),function(){let h=new R,d=new R,c=new R,p=new R,f=new Z,m=new Z,g=new Z,v=(b,x,w,S)=>{S<0&&b.x===1&&(l[x]=b.x-1),w.x===0&&w.z===0&&(l[x]=S/2/Math.PI+.5)};for(let b=0,x=0;b<u;b+=9,x+=6){h.set(a[b+0],a[b+1],a[b+2]),d.set(a[b+3],a[b+4],a[b+5]),c.set(a[b+6],a[b+7],a[b+8]),f.set(l[x+0],l[x+1]),m.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 w=_(p);v(f,x+0,h,w),v(m,x+2,d,w),v(g,x+4,c,w)}let y=u/3*2;for(let b=0;b<y;b+=6){let x=l[b+0],w=l[b+2],S=l[b+4],T=Math.max(x,w,S),M=Math.min(x,w,S);T>.9&&M<.1&&(x<.2&&(l[b+0]+=1),w<.2&&(l[b+2]+=1),S<.2&&(l[b+4]+=1))}function _(b){return Math.atan2(b.z,-b.x)}}(),this.setAttribute("position",new Rt(new Float32Array(a.subarray(0,u)),3)),this.setAttribute("normal",new Rt(new Float32Array(o.subarray(0,u)),3)),void this.setAttribute("uv",new Rt(new Float32Array(l.subarray(0,u/3*2)),2))}static fromJSON(e){return new LL(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}}}),oie=U(()=>{Lbe(),oe(),Obe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new o5(.5*t,s,a):new B7(.5*t,n),l=i/t,u=r/t;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},o5=class extends LL{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n=1/r,s="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],s,e,t,i),this.type=s}static fromJSON(e){return new o5(e.radius,e.corner,e.cornerSides)}}});function lie(e,t=new Z){let i=e.length();return t.set(-e.y/i,e.x/i)}function WLe(e){let t=new Z;t.addVectors(e.v0,ry.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(e.v2,EA.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new pu(e.v0,t,i,e.v2)}function OM(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function HLe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function qLe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function Bbe(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function $Le(e,t,i){return uie(e,t)&&uie(t,i)&&sH(e.position,t.position,i.position)}function sH(e,t,i){return ry.copy(t).sub(e).cross(EA.copy(i).sub(e))===0}function XLe(e,t,i,r,n){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,u=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,a+u),n.set(o-l,a-u),[r,n]}function YLe(e,t,i){return e.distanceTo(i)<t.distanceTo(i)?t:e}function KLe(e,t,i,r,n,s){let a,o=t.x-e.x,l=t.y-e.y,u=i.x-e.x,h=i.y-e.y,d=Math.sqrt((o+u)*(o+u)+(l+h)*(l+h));return Bbe(t,e,i)>Math.PI&&(d*=-1),a=OM(h,l)?(l+h)*(r/d-.5)*8/3/(o-u):(o+u)*(r/d-.5)*8/3/(h-l),n.set(t.x-a*l,t.y+a*o),s.set(i.x+a*h,i.y-a*u),[n,s]}function hie(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function uie(e,t){return sH(e.position,e.controls[1].position,t.position)&&sH(e.position,t.controls[0].position,t.position)}function die(e,t=12,i=!1){let r=[];for(let n=0,s=e.length;n<s;n++){let a=e[n],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*iy(a.roundedCurveCorner,t);n>0&&(r[n-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=iy(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=.5*iy(e[0].roundedCurveCorner,t)),r}function iy(e,t=12){return e&&e instanceof xM?2*t:e&&(e instanceof wh||e instanceof F7)?1:e&&e instanceof _I?t*e.points.length:t}var Ob,x3,w3,_y,II,ry,EA,Fbe,Ube,zbe,kbe,aH,oH,S3,cie,pie,fie,mie,gie,ds,Vbe=U(()=>{oe(),Ob=1e-12,x3=class{constructor(e){this.position=new Z,this.startPosition=new Z,this.uuid=ht.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new x3(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},w3=class extends x3{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new w3(this.parent).copy(this)}},_y=class extends x3{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new w3(this),new w3(this))}static create(e,t){let i=new _y(e,new Z(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let n=this.controls[i];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new _y(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Z,t=new Z){let[i,r]=this.computeTangents();return i&&r&&(lie(i,e),lie(r,t)),[e,t]}computeTangent(e=new Z){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new Z){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}},II=e=>e,ry=new Z,EA=new Z,Fbe=new Z,Ube=new Z,zbe=new Z,kbe=new Z,aH=new R,oH=new R}),e0=U(()=>{oe(),Vbe(),S3=new Z,cie=new Z,pie=new Z,fie=new Z,mie=new Z,gie=new Z,ds=class extends oA{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new $a(new R(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=ht.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new ds;return r.isClosed=e.isClosed,r.points=e.points.map(n=>_y.create(n.id,n.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(n=>ds.createFromState(n)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let n=0,s=this.shapeHoles.length;n<s;n++){let a=this.shapeHoles[n],o=a.points.length,l=a.getPointIndexById(e);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=e-t;if(s<=n.points.length-1)return n.points[s];t+=n.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=S3.set(e,t);for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,n=this.shapeHoles.length;r<n;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=ht.generateUUID()){let r;r=e instanceof Z?e:new Z(e,t);let n=new _y(i,r);return n.roundness=this.roundness,n}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(n,s,a=12,o=!0){let l,u=oH.set(0,0,0),h=0,d=[];for(let c=0;c<s.length;c++){let p=II(s[c]),f=ry,m=iy(p,a);d.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof uf||p instanceof wh){if(p.getPoint(g/m,f),u.set(f.x,f.y,0),l!==void 0&&qLe(l,u))continue;l===void 0&&(l=aH),l.copy(u),n.setXYZ(h,u.x,u.y,u.z),h++}}o&&h>1&&(n.getX(h-1)!==n.getX(0)||n.getY(h-1)!==n.getY(0)||n.getZ(h-1)!==n.getZ(0))&&(n.setXYZ(h,n.getX(0),n.getY(0),n.getZ(0)),h++)}(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=die(this.points,e,!1),this.roundedCurveDivisions=die(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return 2*function(r,n,s,a=12,o=!0){let l=oH.set(0,0,0),u=0,h=[];for(let d=0;d<n.length;d++){if(s[d]===!1)continue;let c,p=II(n[d]),f=ry,m=iy(p,a);h.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof uf||p instanceof wh){if(p.getPoint(g/m,f),l.set(f.x,f.y,0),c?.equals(l))continue;c===void 0?c=aH:(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}(e,this.curves,t,i,this.autoClose).reduce((r,n)=>r+n,0)}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),function(i,r,n=12,s=!0){let a,o=0;for(let l=0;l<r.length;l++){let u=II(r[l]),h=iy(u,n),d=ry;for(let c=0;c<=h;c++)if(u instanceof pu||u instanceof uf||u instanceof wh){if(u.getPoint(c/h,d),a!==void 0&&HLe(a,d,Ob))continue;a===void 0&&(a=EA),a.copy(d),i.push(d.x,d.y),o++}}return OM(i[0],i[i.length-2],Ob)&&OM(i[1],i[i.length-1],Ob)&&(i.pop(),i.pop()),s&&o>1&&!(OM(i[o-1],i[1],Ob)&&OM(i[o-2],i[0],Ob))&&(i.push(i[0],i[1]),o++),i}(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=.5*iy(this.points[0].roundedCurveCorner,this.subdivision));let s=e-n;s<0&&(s+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(s<i+l)return[a,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(hie(r,n)){let l=r.position.distanceTo(n.position);return r.position.distanceTo(S3.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){hie(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let n=this.points[t-1];this._applyCurveForPoint(r,n)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let n=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=n.roundness,l=s&&a&&$Le(s,n,a);if(!n.controlsMoved()&&o>0&&!l){let u=n.curveBefore,h=n.curveAfter;if(u===void 0||h===void 0)continue;let d,c=n.roundedCurveBefore,p=n.roundedCurveAfter,f=u instanceof wh?u.v1.distanceTo(u.v2):u.getLength(),m=h instanceof wh?h.v1.distanceTo(h.v2):h.getLength(),g=Math.min(o,.499*f),v=Math.min(o,.499*m),y=Math.min(g,v),_=1-y/f,b=y/m,x=u.getPointAt(_,S3),w=h.getPointAt(b,cie);if(this._subSplitCurve(u,c,_,x,void 0),this._subSplitCurve(h,p,b,void 0,w),this.useCubicForRoundedCorners){let S=Bbe(x,n.position,w)/2,T=Math.tan(S)*x.distanceTo(n.position),[M,E]=XLe(x,w,T,pie,fie),A=YLe(M,E,n.position),[P,N]=KLe(A,x,w,T,mie,gie);d=new pu(x.clone(),P.clone(),N.clone(),w.clone())}else d=new uf(x.clone(),n.position.clone(),w.clone());n.roundedCurveCorner=d,this.roundedCurves.splice(i+t,0,d),t++}}}}_subSplitCurve(e,t,i,r,n){if(!(e instanceof wh)){let s=e,a=t,o=s.getUtoTmapping(i,0),l=function(u,h,d,c,p=.5){let f=ry.subVectors(h,u).multiplyScalar(p).add(u),m=EA.subVectors(d,h).multiplyScalar(p).add(h),g=Fbe.subVectors(c,d).multiplyScalar(p).add(d),v=f,y=Ube.subVectors(m,f).multiplyScalar(p).add(f),_=zbe.subVectors(g,m).multiplyScalar(p).add(m),b=g,x=kbe.subVectors(_,y).multiplyScalar(p).add(y);return[u.x,u.y,v.x,v.y,y.x,y.y,x.x,x.y,_.x,_.y,b.x,b.y,c.x,c.y]}(s.v0,s.v1,s.v2,s.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])),n!==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&&t.v2.copy(r),n!==void 0&&t.v1.copy(n),t}clone(){let e=new ds(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=7*i,n=e.points[r+0],s=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],u=e.points[r+5],h=e.points[r+6],d=new _y(ht.generateUUID(),new Z(n,s));d.controls[0].position.set(a,o),d.controls[1].position.set(l,u),d.roundness=h,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new ds;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(r,n)=>{n instanceof pu&&n.v3.equals(r.position)&&r.controls[0].position.copy(n.v2)};return this.points=(r=>{let n,s,a=[];for(n=0,s=r.length;n<s;n++)r[n]instanceof uf&&(r[n]=WLe(r[n]));for(n=0,s=r.length;n<s;n++){let u,h=r[n],d=n>0?r[n-1]:null;h instanceof pu?(u=this.createPoint(h.v0),u.controls[1].position.copy(h.v1)):h instanceof wh&&(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 pu?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof wh&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(e.curves),e instanceof oA&&(this.shapeHoles=e.holes.map(r=>{let n=new ds;return n.fromShape(r),n})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}}});function l5({x:e,y:t},i,r,n,s){return{x:e*i+n,y:t*r+s}}function ZLe(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),n=Math.sin(e),s=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-n*i,y:n+r*i},{x:s+a*i,y:a-s*i},{x:s,y:a}]}function vie(e,t,i,r){let n=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return n*Math.acos(s)}var OI,QLe=U(()=>{OI=2*Math.PI});function Ti(e,t){if(!e)throw t||"Assertion Failed!"}function CE(e){var t=e.windingRule,i=t===void 0?es.ODD:t,r=e.elementType,n=r===void 0?So.POLYGONS:r,s=e.polySize,a=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,u=e.normal,h=u===void 0?[0,0,1]:u,d=e.contours,c=d===void 0?[]:d,p=e.strict,f=p===void 0||p,m=e.debug,g=m!==void 0&&m;if(!c&&f)throw new Error("Contours can't be empty");if(c){var v=new Gbe;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<c.length;y++)v.addContour(l||2,c[y]);return v.tesselate(i,n,a,l,h,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var es,So,fi,H1,zS,N0,h5,u5,d5,yie,T3,c5,_ie,bie,Gbe,qA=U(()=>{var e;(e=es||(es={}))[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(t){t[t.POLYGONS=0]="POLYGONS",t[t.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",t[t.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(So||(So={})),fi=function(){function t(){}return t.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},t.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},t.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},t.edgeGoesLeft=function(i){return t.vertLeq(i.Dst,i.Org)},t.edgeGoesRight=function(i){return t.vertLeq(i.Org,i.Dst)},t.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},t.edgeEval=function(i,r,n){Ti(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?s<a?r.t-i.t+(i.t-n.t)*(s/(s+a)):r.t-n.t+(n.t-i.t)*(a/(s+a)):0},t.edgeSign=function(i,r,n){Ti(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?(r.t-n.t)*s+(r.t-i.t)*a:0},t.transEval=function(i,r,n){Ti(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?s<a?r.s-i.s+(i.s-n.s)*(s/(s+a)):r.s-n.s+(n.s-i.s)*(a/(s+a)):0},t.transSign=function(i,r,n){Ti(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?(r.s-n.s)*s+(r.s-i.s)*a:0},t.vertCCW=function(i,r,n){return i.s*(r.t-n.t)+r.s*(n.t-i.t)+n.s*(i.t-r.t)>=0},t.interpolate=function(i,r,n,s){return(i=i<0?0:i)<=(n=n<0?0:n)?n===0?(r+s)/2:r+i/(i+n)*(s-r):s+n/(i+n)*(r-s)},t.intersect=function(i,r,n,s,a){var o,l,u;t.vertLeq(i,r)||(u=i,i=r,r=u),t.vertLeq(n,s)||(u=n,n=s,s=u),t.vertLeq(i,n)||(u=i,i=n,n=u,u=r,r=s,s=u),t.vertLeq(n,r)?t.vertLeq(r,s)?((o=t.edgeEval(i,n,r))+(l=t.edgeEval(n,r,s))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,r.s)):((o=t.edgeSign(i,n,r))+(l=-t.edgeSign(i,s,r))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,s.s)):a.s=(n.s+r.s)/2,t.transLeq(i,r)||(u=i,i=r,r=u),t.transLeq(n,s)||(u=n,n=s,s=u),t.transLeq(i,n)||(u=i,i=n,n=u,u=r,r=s,s=u),t.transLeq(n,r)?t.transLeq(r,s)?((o=t.transEval(i,n,r))+(l=t.transEval(n,r,s))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,r.t)):((o=t.transSign(i,n,r))+(l=-t.transSign(i,s,r))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,s.t)):a.t=(n.t+r.t)/2},t}(),H1=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},zS=function(){function t(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(t.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),t}(),N0=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},h5=function(){function t(){var i=new N0,r=new H1,n=new zS(0),s=new zS(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,n.next=n,n.Sym=s,s.next=s,s.Sym=n,this.vHead=i,this.fHead=r,this.eHead=n,this.eHeadSym=s}return t.prototype.makeEdge_=function(i){var r=new zS(0),n=new zS(1);i.Sym.side<i.side&&(i=i.Sym);var s=i.Sym.next;return n.next=s,s.Sym.next=r,r.next=i,i.Sym.next=n,r.Sym=n,r.Onext=r,r.Lnext=n,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,n.Sym=r,n.Onext=n,n.Lnext=r,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,r},t.prototype.splice_=function(i,r){var n=i.Onext,s=r.Onext;n.Sym.Lnext=r,s.Sym.Lnext=i,i.Onext=s,r.Onext=n},t.prototype.makeVertex_=function(i,r,n){var s=i;Ti(s,"Vertex can't be null!");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r;var o=r;do o.Org=s,o=o.Onext;while(o!==r)},t.prototype.makeFace_=function(i,r,n){var s=i;Ti(s,"Face can't be null");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r,s.trail=null,s.marked=!1,s.inside=n.inside;var o=r;do o.Lface=s,o=o.Lnext;while(o!==r)},t.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,n=i.Sym.next;r.Sym.next=n,n.Sym.next=r},t.prototype.killVertex_=function(i,r){var n=i.anEdge,s=n;do s.Org=r,s=s.Onext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.killFace_=function(i,r){var n=i.anEdge,s=n;do s.Lface=r,s=s.Lnext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.makeEdge=function(){var i=new N0,r=new N0,n=new H1,s=this.makeEdge_(this.eHead);return this.makeVertex_(i,s,this.vHead),this.makeVertex_(r,s.Sym,this.vHead),this.makeFace_(n,s,this.fHead),s},t.prototype.splice=function(i,r){var n=!1,s=!1;if(i!==r){if(r.Org!==i.Org&&(s=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!s){var a=new N0;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!n){var o=new H1;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},t.prototype.delete=function(i){var r=i.Sym,n=!1;if(i.Lface!==i.Rface&&(n=!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),!n){var s=new H1;this.makeFace_(s,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)},t.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),n=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var s=new N0;return this.makeVertex_(s,n,r.Org),r.Lface=n.Lface=i.Lface,r},t.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},t.prototype.connect=function(i,r){var n=!1,s=this.makeEdge_(i),a=s.Sym;if(r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(s,i.Lnext),this.splice_(a,r),s.Org=i.Dst,a.Org=r.Org,s.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!n){var o=new H1;this.makeFace_(o,s,i.Lface)}return s},t.prototype.zapFace=function(i){var r,n,s,a,o,l=i.anEdge;n=l.Lnext;do n=(r=n).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)),(s=r.Sym).Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},t.prototype.countFaceVerts_=function(i){var r=i.anEdge,n=0;do n++,r=r.Lnext;while(r!==i.anEdge);return n},t.prototype.mergeConvexFaces=function(i){var r,n,s,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(n=r.anEdge).Org;s=n.Lnext,(a=n.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&fi.vertCCW(n.Lprev.Org,n.Org,a.Lnext.Lnext.Org)&&fi.vertCCW(a.Lprev.Org,a.Org,n.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),n=null,a=null),!n||n.Lnext.Org!==o;)n=s;return!0},t.prototype.check=function(){var i,r,n,s,a,o,l=this.fHead,u=this.vHead,h=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Ti(i.prev===r),a=i.anEdge;do Ti(a.Sym!==a),Ti(a.Sym.Sym===a),Ti(a.Lnext.Onext.Sym===a),Ti(a.Onext.Sym.Lnext===a),Ti(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Ti(i.prev===r&&i.anEdge===null),s=u,s=u;(n=s.next)!==u;s=n){Ti(n.prev===s),a=n.anEdge;do Ti(a.Sym!==a),Ti(a.Sym.Sym===a),Ti(a.Lnext.Onext.Sym===a),Ti(a.Onext.Sym.Lnext===a),Ti(a.Org===n),a=a.Onext;while(a!==n.anEdge)}for(Ti(n.prev===s&&n.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)Ti(a.Sym.next===o.Sym),Ti(a.Sym!==a),Ti(a.Sym.Sym===a),Ti(a.Org!==null),Ti(a.Dst!==null),Ti(a.Lnext.Onext.Sym===a),Ti(a.Onext.Sym.Lnext===a);Ti(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)},t}(),u5=function(){this.handle=null},d5=function(){this.key=null,this.node=0},yie=function(){function t(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 n=0;n<i+1;n++)this.nodes[n]=new u5,this.handles[n]=new d5;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return t.prototype.floatDown_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((s=i<<1)<this.size&&this.leq(o[a[s+1].handle].key,o[a[s].handle].key)&&++s,Ti(s<=this.max),n=a[s].handle,s>this.size||this.leq(o[r].key,o[n].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.floatUp_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(n=a[s=i>>1].handle,s===0||this.leq(o[n].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},t.prototype.min=function(){return this.handles[this.nodes[1].handle].key},t.prototype.insert=function(i){var r,n;if(2*(r=++this.size)>this.max){var s,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new u5;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new d5}return this.freeList===0?n=r:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[r].handle=n,this.handles[n].node=r,this.handles[n].key=i,this.initialized&&this.floatUp_(r),n},t.prototype.extractMin=function(){var i=this.nodes,r=this.handles,n=i[1].handle,s=r[n].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[n].key=null,r[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),s},t.prototype.delete=function(i){var r,n=this.nodes,s=this.handles;Ti(i>=1&&i<=this.max&&s[i].key!==null),n[r=s[i].node].handle=n[this.size].handle,s[n[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(s[n[r>>1].handle].key,s[n[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),s[i].key=null,s[i].node=this.freeList,this.freeList=i},t}(),T3=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},c5=function(){this.key=null,this.next=null,this.prev=null},_ie=function(){function t(i,r){this.frame=i,this.leq=r,this.head=new c5,this.head.next=this.head,this.head.prev=this.head}return t.prototype.min=function(){return this.head.next},t.prototype.max=function(){return this.head.prev},t.prototype.insert=function(i){return this.insertBefore(this.head,i)},t.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},t.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var n=new c5;return n.key=r,n.next=i.next,i.next.prev=n,n.prev=i,i.next=n,n},t.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},t}(),bie=function(){function t(){}return t.regionBelow=function(i){return i.nodeUp.prev.key},t.regionAbove=function(i){return i.nodeUp.next.key},t.debugEvent=function(i){},t.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.edgeLeq=function(i,r,n){var s=i.event,a=r.eUp,o=n.eUp;return a.Dst===s?o.Dst===s?fi.vertLeq(a.Org,o.Org)?fi.edgeSign(o.Dst,a.Org,o.Org)<=0:fi.edgeSign(a.Dst,o.Org,a.Org)>=0:fi.edgeSign(o.Dst,s,o.Org)<=0:o.Dst===s?fi.edgeSign(a.Dst,s,a.Org)>=0:fi.edgeEval(a.Dst,s,a.Org)>=fi.edgeEval(o.Dst,s,o.Org)},t.deleteRegion=function(i,r){r.fixUpperEdge&&Ti(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},t.fixUpperEdge=function(i,r,n){Ti(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=n,n.activeRegion=r},t.topLeftRegion=function(i,r){var n,s=r.eUp.Org;do r=t.regionAbove(r);while(r.eUp.Org===s);if(r.fixUpperEdge){if((n=i.mesh.connect(t.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;t.fixUpperEdge(i,r,n),r=t.regionAbove(r)}return r},t.topRightRegion=function(i){var r=i.eUp.Dst;do i=t.regionAbove(i);while(i.eUp.Dst===r);return i},t.addRegionBelow=function(i,r,n){var s=new T3;return s.eUp=n,s.nodeUp=i.dict.insertBefore(r.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,n.activeRegion=s,s},t.isWindingInside=function(i,r){switch(i.windingRule){case es.ODD:return!!(1&r);case es.NONZERO:return r!==0;case es.POSITIVE:return r>0;case es.NEGATIVE:return r<0;case es.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},t.computeWinding=function(i,r){r.windingNumber=t.regionAbove(r).windingNumber+r.eUp.winding,r.inside=t.isWindingInside(i,r.windingNumber)},t.finishRegion=function(i,r){var n=r.eUp,s=n.Lface;s.inside=r.inside,s.anEdge=n,t.deleteRegion(i,r)},t.finishLeftRegions=function(i,r,n){for(var s,a=null,o=r,l=r.eUp;o!==n;){if(o.fixUpperEdge=!1,(s=(a=t.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){t.finishRegion(i,o);break}s=i.mesh.connect(l.Lprev,s.Sym),t.fixUpperEdge(i,a,s)}l.Onext!==s&&(i.mesh.splice(s.Oprev,s),i.mesh.splice(l,s)),t.finishRegion(i,o),l=a.eUp,o=a}return l},t.addRightEdges=function(i,r,n,s,a,o){var l,u,h,d,c=!0;h=n;do Ti(fi.vertLeq(h.Org,h.Dst)),t.addRegionBelow(i,r,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=t.regionBelow(r).eUp.Rprev),u=r,d=a;(h=(l=t.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=t.isWindingInside(i,l.windingNumber),u.dirty=!0,!c&&t.checkForRightSplice(i,u)&&(t.addWinding(h,d),t.deleteRegion(i,u),i.mesh.delete(d)),c=!1,u=l,d=h;u.dirty=!0,Ti(u.windingNumber-h.winding===l.windingNumber),o&&t.walkDirtyRegions(i,u)},t.spliceMergeVertices=function(i,r,n){i.mesh.splice(r,n)},t.vertexWeights=function(i,r,n){var s=fi.vertL1dist(r,i),a=fi.vertL1dist(n,i),o=.5*a/(s+a),l=.5*s/(s+a);i.coords[0]+=o*r.coords[0]+l*n.coords[0],i.coords[1]+=o*r.coords[1]+l*n.coords[1],i.coords[2]+=o*r.coords[2]+l*n.coords[2]},t.getIntersectData=function(i,r,n,s,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,t.vertexWeights(r,n,s),t.vertexWeights(r,a,o)},t.checkForRightSplice=function(i,r){var n=t.regionBelow(r),s=r.eUp,a=n.eUp;if(fi.vertLeq(s.Org,a.Org)){if(fi.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;fi.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(i.pq.delete(s.Org.pqHandle),t.spliceMergeVertices(i,a.Oprev,s)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(s,a.Oprev),r.dirty=n.dirty=!0)}else{if(fi.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(s.Sym),i.mesh.splice(a.Oprev,s)}return!0},t.checkForLeftSplice=function(i,r){var n,s=t.regionBelow(r),a=r.eUp,o=s.eUp;if(Ti(!fi.vertEq(a.Dst,o.Dst)),fi.vertLeq(a.Dst,o.Dst)){if(fi.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,n=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,n),n.Lface.inside=r.inside}else{if(fi.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=s.dirty=!0,n=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),n.Rface.inside=r.inside}return!0},t.checkForIntersect=function(i,r){var n,s,a=t.regionBelow(r),o=r.eUp,l=a.eUp,u=o.Org,h=l.Org,d=o.Dst,c=l.Dst,p=new N0;if(Ti(!fi.vertEq(c,d)),Ti(fi.edgeSign(d,i.event,u)<=0),Ti(fi.edgeSign(c,i.event,h)>=0),Ti(u!==i.event&&h!==i.event),Ti(!r.fixUpperEdge&&!a.fixUpperEdge),u===h||Math.min(u.t,d.t)>Math.max(h.t,c.t))return!1;if(fi.vertLeq(u,h)){if(fi.edgeSign(c,u,h)>0)return!1}else if(fi.edgeSign(d,h,u)<0)return!1;return t.debugEvent(i),fi.intersect(d,u,c,h,p),Ti(Math.min(u.t,d.t)<=p.t),Ti(p.t<=Math.max(h.t,c.t)),Ti(Math.min(c.s,d.s)<=p.s),Ti(p.s<=Math.max(h.s,u.s)),fi.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),n=fi.vertLeq(u,h)?u:h,fi.vertLeq(n,p)&&(p.s=n.s,p.t=n.t),fi.vertEq(p,u)||fi.vertEq(p,h)?(t.checkForRightSplice(i,r),!1):!fi.vertEq(d,i.event)&&fi.edgeSign(d,i.event,p)>=0||!fi.vertEq(c,i.event)&&fi.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=t.topLeftRegion(i,r),o=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),a),t.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=t.topRightRegion(r),s=t.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=t.finishLeftRegions(i,a,null),t.addRightEdges(i,r,l.Onext,o.Rprev,s,!0),!0):(fi.edgeSign(d,i.event,p)>=0&&(t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),fi.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),t.getIntersectData(i,o.Org,u,d,h,c),t.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},t.walkDirtyRegions=function(i,r){for(var n,s,a=t.regionBelow(r);;){for(;a.dirty;)r=a,a=t.regionBelow(a);if(!r.dirty&&(a=r,(r=t.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,n=r.eUp,s=a.eUp,n.Dst!==s.Dst&&t.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(t.deleteRegion(i,a),i.mesh.delete(s),s=(a=t.regionBelow(r)).eUp):r.fixUpperEdge&&(t.deleteRegion(i,r),i.mesh.delete(n),n=(r=t.regionAbove(a)).eUp)),n.Org!==s.Org){if(n.Dst===s.Dst||r.fixUpperEdge||a.fixUpperEdge||n.Dst!==i.event&&s.Dst!==i.event)t.checkForRightSplice(i,r);else if(t.checkForIntersect(i,r))return}n.Org===s.Org&&n.Dst===s.Dst&&(t.addWinding(s,n),t.deleteRegion(i,r),i.mesh.delete(n),r=t.regionAbove(a))}},t.connectRightVertex=function(i,r,n){var s,a=n.Onext,o=t.regionBelow(r),l=r.eUp,u=o.eUp,h=!1;l.Dst!==u.Dst&&t.checkForIntersect(i,r),fi.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=t.topLeftRegion(i,r),a=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),o),h=!0),fi.vertEq(u.Org,i.event)&&(i.mesh.splice(n,u.Oprev),n=t.finishLeftRegions(i,o,null),h=!0),h?t.addRightEdges(i,r,n.Onext,a,a,!0):(s=fi.vertLeq(u.Org,l.Org)?u.Oprev:l,s=i.mesh.connect(n.Lprev,s),t.addRightEdges(i,r,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,t.walkDirtyRegions(i,r))},t.connectLeftDegenerate=function(i,r,n){var s,a,o,l,u;return s=r.eUp,fi.vertEq(s.Org,n)?(Ti(!1),void t.spliceMergeVertices(i,s,n.anEdge)):fi.vertEq(s.Dst,n)?(Ti(!1),r=t.topRightRegion(r),a=l=(o=(u=t.regionBelow(r)).eUp.Sym).Onext,u.fixUpperEdge&&(Ti(a!==o),t.deleteRegion(i,u),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(n.anEdge,o),fi.edgeGoesLeft(a)||(a=null),void t.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(s.Sym),r.fixUpperEdge&&(i.mesh.delete(s.Onext),r.fixUpperEdge=!1),i.mesh.splice(n.anEdge,s),void t.sweepEvent(i,n))},t.connectLeftVertex=function(i,r){var n,s,a,o,l,u,h=new T3;if(h.eUp=r.anEdge.Sym,n=i.dict.search(h).key,s=t.regionBelow(n)){if(o=n.eUp,l=s.eUp,fi.edgeSign(o.Dst,r,o.Org)===0)return void t.connectLeftDegenerate(i,n,r);a=fi.vertLeq(l.Dst,o.Dst)?n:s,n.inside||a.fixUpperEdge?(u=a===n?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?t.fixUpperEdge(i,a,u):t.computeWinding(i,t.addRegionBelow(i,n,u)),t.sweepEvent(i,r)):t.addRightEdges(i,n,r.anEdge,r.anEdge,null,!0)}},t.sweepEvent=function(i,r){i.event=r,t.debugEvent(i);for(var n=r.anEdge;n.activeRegion===null;)if((n=n.Onext)===r.anEdge)return void t.connectLeftVertex(i,r);var s=t.topLeftRegion(i,n.activeRegion);Ti(s!==null);var a=t.regionBelow(s),o=a.eUp,l=t.finishLeftRegions(i,a,null);l.Onext===o?t.connectRightVertex(i,s,l):t.addRightEdges(i,s,l.Onext,o,o,!0)},t.addSentinel=function(i,r,n,s){var a=new T3,o=i.mesh.makeEdge();o.Org.s=n,o.Org.t=s,o.Dst.s=r,o.Dst.t=s,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},t.initEdgeDict=function(i){i.dict=new _ie(i,t.edgeLeq);var r=i.bmax[0]-i.bmin[0],n=i.bmax[1]-i.bmin[1],s=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-n,l=i.bmax[1]+n;t.addSentinel(i,s,a,o),t.addSentinel(i,s,a,l)},t.doneEdgeDict=function(i){for(var r,n=0;(r=i.dict.min().key)!==null;)r.sentinel||(Ti(r.fixUpperEdge),Ti(++n===1)),Ti(r.windingNumber===0),t.deleteRegion(i,r)},t.removeDegenerateEdges=function(i){var r,n,s,a=i.mesh.eHead;for(r=a.next;r!==a;r=n)n=r.next,s=r.Lnext,fi.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(t.spliceMergeVertices(i,s,r),i.mesh.delete(r),s=(r=s).Lnext),s.Lnext===r&&(s!==r&&((s===n||s===n.Sym)&&(n=n.next),i.mesh.delete(s)),(r===n||r===n.Sym)&&(n=n.next),i.mesh.delete(r))},t.initPriorityQ=function(i){var r,n,s,a=0;for(n=(s=i.mesh.vHead).next;n!==s;n=n.next)a++;for(a+=8,r=i.pq=new yie(a,fi.vertLeq),n=(s=i.mesh.vHead).next;n!==s;n=n.next)n.pqHandle=r.insert(n);return n===s&&(r.init(),!0)},t.donePriorityQ=function(i){i.pq=null},t.removeDegenerateFaces=function(i,r){var n,s,a;for(n=r.fHead.next;n!==r.fHead;n=s)s=n.next,Ti((a=n.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(t.addWinding(a.Onext,a),i.mesh.delete(a));return!0},t.computeInterior=function(i,r){var n,s;if(r===void 0&&(r=!0),t.removeDegenerateEdges(i),!t.initPriorityQ(i))return!1;for(t.initEdgeDict(i);(n=i.pq.extractMin())!==null;){for(;(s=i.pq.min())!==null&&fi.vertEq(s,n);)s=i.pq.extractMin(),t.spliceMergeVertices(i,n.anEdge,s.anEdge);t.sweepEvent(i,n)}return i.event=i.dict.min().key.eUp.Org,t.debugEvent(i),t.doneEdgeDict(i),t.donePriorityQ(i),!!t.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},t}(),Gbe=function(){function t(){this.mesh=new h5,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=es.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 t.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},t.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},t.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},t.prototype.computeNormal_=function(i){var r,n,s,a,o,l,u=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],g=this.mesh.vHead;r=g.next;for(var v=0;v<3;++v)a=r.coords[v],h[v]=a,m[v]=r,u[v]=a,f[v]=r;for(r=g.next;r!==g;r=r.next)for(var y=0;y<3;++y)(a=r.coords[y])<h[y]&&(h[y]=a,m[y]=r),a>u[y]&&(u[y]=a,f[y]=r);var _=0;if(u[1]-h[1]>u[0]-h[0]&&(_=1),u[2]-h[2]>u[_]-h[_]&&(_=2),h[_]>=u[_])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,n=m[_],s=f[_],d[0]=n.coords[0]-s.coords[0],d[1]=n.coords[1]-s.coords[1],d[2]=n.coords[2]-s.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.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)},t.prototype.checkOrientation_=function(){for(var i,r,n=this.mesh.fHead,s=this.mesh.vHead,a=0,o=n.next;o!==n;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=s.next;i!==s;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},t.prototype.projectPolygon_=function(){var i,r,n=this.mesh.vHead,s=[0,0,0],a=!1;s[0]=this.normal[0],s[1]=this.normal[1],s[2]=this.normal[2],!s[0]&&!s[1]&&!s[2]&&(this.computeNormal_(s),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(s);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]=s[o]>0?1:-1;for(var l=n.next;l!==n;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=n.next;h!==n;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))},t.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.prototype.tessellateMonoRegion_=function(i,r){var n,s;if((n=r.anEdge).Lnext===n||n.Lnext.Lnext===n)throw"Mono region invalid";for(;fi.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;fi.vertLeq(n.Org,n.Dst);n=n.Lnext);for(s=n.Lprev;n.Lnext!==s;)if(fi.vertLeq(n.Dst,s.Org)){for(;s.Lnext!==n&&(fi.edgeGoesLeft(s.Lnext)||fi.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)s=i.connect(s.Lnext,s).Sym;s=s.Lprev}else{for(;s.Lnext!==n&&(fi.edgeGoesRight(n.Lprev)||fi.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)n=i.connect(n,n.Lprev).Sym;n=n.Lnext}if(s.Lnext===n)throw"Mono region invalid";for(;s.Lnext.Lnext!==n;)s=i.connect(s.Lnext,s).Sym;return!0},t.prototype.tessellateInterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)if(r=n.next,n.inside&&!this.tessellateMonoRegion_(i,n))return!1;return!0},t.prototype.discardExterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)r=n.next,n.inside||i.zapFace(n)},t.prototype.setWindingNumber_=function(i,r,n){for(var s,a=i.eHead.next;a!==i.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:n?i.delete(a):a.winding=0},t.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},t.prototype.outputPolymesh_=function(i,r,n,s){var a,o,l=0,u=0;n>3&&i.mergeConvexFaces(n);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>n)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===So.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*n,this.vertexCount=u,this.vertices=[],this.vertices.length=u*s,this.vertexIndices=[],this.vertexIndices.length=u,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>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 f=o;f<n;++f)this.elements[p++]=-1;if(r===So.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<n;++m)this.elements[p++]=-1}}},t.prototype.outputContours_=function(i,r){var n,s,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){s=n=l.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==s);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,s=n=l.anEdge;do this.vertices[u++]=n.Org.coords[0],this.vertices[u++]=n.Org.coords[1],r>2&&(this.vertices[u++]=n.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==s);this.elements[d++]=a,this.elements[d++]=o,a+=o}},t.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new h5),i<2&&(i=2),i>3&&(i=3);for(var n=null,s=0;s<r.length;s+=i)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=r[s+0],n.Org.coords[1]=r[s+1],n.Org.coords[2]=i>2?r[s+2]:0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},t.prototype.tesselate=function(i,r,n,s,a,o){if(i===void 0&&(i=es.ODD),r===void 0&&(r=So.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),bie.computeInterior(this,o);var l=this.mesh;return r===So.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===So.BOUNDARY_CONTOURS?this.outputContours_(l,s):this.outputPolymesh_(l,r,n,s),!0},t}(),es.ODD,es.NONZERO,es.POSITIVE,es.NEGATIVE,es.ABS_GEQ_TWO,So.POLYGONS,So.CONNECTED_POLYGONS,So.BOUNDARY_CONTOURS});function jbe(e,t){let i=e.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let u=(l+1)%i;r+=e[2*l]*e[2*u+1]-e[2*u]*e[2*l+1]}let n=r>0!==t?1:-1,s=[];for(let l=0;l<i;l++){let u=(l+1)%i,h=e[2*u]-e[2*l],d=e[2*u+1]-e[2*l+1],c=Math.hypot(h,d);s.push(c>0?[n*d/c,-n*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 s.map((l,u)=>[o(l,s[(u+i-1)%i]),o(l,s[(u+1)%i])])}function Wbe(e,t,i){let r=e.length/2,n=new Float32Array(r+1);if(!(t>0)||!(i>0)||r<2)return{u:n,vScale:0};let s=0;for(let a=0;a<r;a++){let o=(a+1)%r;s+=Math.hypot((e[2*o]-e[2*a])/t,(e[2*o+1]-e[2*a+1])/i),n[a+1]=s}return{u:n,vScale:Math.sqrt(t*i)}}function Hbe(e,t,i){for(let r=0;r<i.length;r+=3){let n=3*i[r],s=3*i[r+1],a=3*i[r+2],o=e[s]-e[n],l=e[s+1]-e[n+1],u=e[s+2]-e[n+2],h=e[a]-e[n],d=e[a+1]-e[n+1],c=e[a+2]-e[n+2],p=u*h-o*c,f=o*d-l*h;if((l*c-u*d)*(t[n]+t[s]+t[a])+p*(t[n+1]+t[s+1]+t[a+1])+f*(t[n+2]+t[s+2]+t[a+2])<0){let m=i[r+1];i[r+1]=i[r+2],i[r+2]=m}}}var fY,qbe,mY,$be=U(()=>{}),gY=U(()=>{fY={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},qbe={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},mY={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 Xbe(e,t){return e.normals[3*t+2]<.9999}function Ybe(e){let t=lH.get(e);if(t!==void 0)return t;if(!(e.rise>0))return e;let i=new Float32Array(e.normals),r=e.positions.length/3;for(let s=0;s<r;s++){if(!Xbe(e,s))continue;let a=i[3*s],o=i[3*s+1],l=Math.hypot(a,o);if(l===0)continue;let u=e.rise-e.positions[3*s+2],h=Math.min(1,Math.max(0,1-u/e.rise)),d=Math.sqrt(1-h*h);i[3*s]=a/l*d,i[3*s+1]=o/l*d,i[3*s+2]=h}let n={...e,normals:i};return lH.set(e,n),n}function Kbe(e,t,i,r){let n=(t-e.minX)/e.spanX,s=(i-e.minY)/e.spanY;return r?[s,n]:[n,s]}var lH,FL,hH,vY=U(()=>{lH=new WeakMap}),JLe=U(()=>{oe(),qA(),Gr(),$be(),gY(),vY(),FL=class extends At{constructor(e,t,i=12,r=es.ODD,n,s=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=e,this._depth=t,this._curveSegments=i,this._windingRule=r,this._uvPitch=s?void 0:n,this._legacy=s;let a,o=[e.extractShapePointsToFlatArray([],i),...e.shapeHoles.map(L=>L.extractShapePointsToFlatArray([],i))];try{a=CE({contours:o,windingRule:r,elementType:So.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=mY}let l=a?.vertexCount??0,u=a?.elementCount??0,h=1/0,d=1/0,c=-1/0,p=-1/0;for(let L of o)for(let V=0;V<L.length;V+=2)L[V]<h&&(h=L[V]),L[V]>c&&(c=L[V]),L[V+1]<d&&(d=L[V+1]),L[V+1]>p&&(p=L[V+1]);let f=this._uvPitch,m=f??(c-h||1),g=f??(p-d||1),v=f===void 0?h:0,y=f===void 0?d:0,_=o.map((L,V)=>jbe(L,V>0)),b=0;for(let L of _)b+=L.length;let x=2*l+4*b,w=3*u*2+6*b,S=new Float32Array(3*x),T=new Float32Array(3*x),M=new Float32Array(2*x),E=new Uint32Array(w),A=new Uint8Array(x),P=0,N=0,D=0,O=!1,z=(L,V,G,Y,$,Q,ue=(L-v)/m,pe=(V-y)/g)=>{let xe=3*N;S[xe]=L,S[xe+1]=V,S[xe+2]=G,T[xe]=Y,T[xe+1]=$,T[xe+2]=Q,A[N]=G===t?O?2:1:0,M[2*N]=ue,M[2*N+1]=pe,N++};if(a!==void 0)for(let[L,V]of[[t,1],[0,-1]]){let G=N;for(let Y=0;Y<l;Y++)z(a.vertices[2*Y],a.vertices[2*Y+1],L,0,0,V);for(let Y=0;Y<u;Y++){let[$,Q,ue]=[a.elements[3*Y],a.elements[3*Y+1],a.elements[3*Y+2]];E[D++]=G+$,E[D++]=G+(V>0?Q:ue),E[D++]=G+(V>0?ue:Q)}}O=!0;for(let L=0;L<o.length;L++){let V=o[L],G=_[L],Y=V.length/2,{u:$,vScale:Q}=s?{u:new Float32Array(Y+1),vScale:0}:Wbe(V,m,g);P=Q;let ue=Q===0?0:t/Q,pe={minX:v,minY:y,spanX:m,spanY:g},xe=(we,[re,Se],W,k)=>{let K=V[2*we],ie=V[2*we+1],[j,ae]=s?Kbe(pe,K,ie,W):[k,W?0:ue];z(K,ie,W?0:t,re,Se,0,j,ae)};for(let we=0;we<G.length;we++){let re=(we+1)%Y,[Se,W]=G[we],[k,K]=[$[we],$[we+1]],ie=N;xe(we,Se,!1,k),xe(we,Se,!0,k),xe(re,W,!1,K),xe(re,W,!0,K),E[D++]=ie,E[D++]=ie+1,E[D++]=ie+2,E[D++]=ie+3,E[D++]=ie+2,E[D++]=ie+1}}Hbe(S,T,E),this.setAttribute("position",new Rt(S,3)),this.setAttribute("normal",new Rt(T,3)),this.setAttribute("uv",new Rt(M,2)),this.setIndex(new Rt(E,1)),this._nearSide=A,this._vScale=P}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale)}canShiftDepthTo(e){return this._nearSide.length>0&&this._depth>0&&e>0}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=t,u===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=new FL(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return e.userData=W4(this.userData),e}}}),Zbe=U(()=>{oe(),qA(),Gr(),gY(),hH=class extends At{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=es.ODD,this.elementType=So.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:es.ODD,elementType:So.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,n,s,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 f=2*c,m=a[f+0],g=a[f+1];if(n!==void 0&&m!==n&&(l=!1),s!==void 0&&g!==s&&(u=!1),n=m,s=g,!l&&!u)break}if(!l&&!u)try{r=CE({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=fY}let h=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new Rt(new Float32Array(3*h),3),this._normalAttribute=new Rt(new Float32Array(3*h),3),this._uvAttribute=new Rt(new Float32Array(2*h),2),this._indexAttribute=new Rt(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,_=h;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1];x<c&&(c=x),x>p&&(p=x),w<f&&(f=w),w>m&&(m=w)}let g=p-c,v=m-f;for(let y=0,_=h;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1],S=(x-c)/g,T=(w-f)/v;this._positionAttribute.setXYZ(y,x,w,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,T)}for(let y=0,_=d;y<_;y++){let b=3*y,x=r.elements[b+0],w=r.elements[b+1],S=r.elements[b+2];this._indexAttribute.setX(b+0,x),this._indexAttribute.setX(b+1,w),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let e=new hH(this._shape,this._curveSegments);return e.userData=W4(this.userData),e}}});function e4e(e){return xie||(xie=async function(){let t=e??"https://unpkg.com/@splinetool/runtime@2.0.80/build",i=Promise.resolve().then(()=>(TZ(),SZ)),[r,n]=await Promise.all([i,fetch(`${t}/bevel.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),$A=r}())}function t4e(e){let t=!1;return e.scene.objects.traverse((i,r)=>{let n=r.geometry;if(n!==void 0&&(txe.has(n.type)&&n.depth!==void 0&&n.depth>0&&(n.extrudeBevelSize??0)>0&&(t=!0),n.type==="PathGeometry")){let s=n.extrusion;s!==void 0&&s.capType==="round"&&(s.bevel??0)>0&&(t=!0)}}),t}function Qbe(e,t){let i=[e.extractShapePointsToFlatArray([],t)];for(let o of e.shapeHoles)i.push(o.extractShapePointsToFlatArray([],t));let r=0;for(let o of i)r+=o.length>>1;let n=new Float64Array(2*r),s=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)n.set(i[o],2*a),a+=i[o].length>>1,s[o]=a;return{points:n,ends:s}}function UL(e,t,i,r,n,s){let a=e.positions.length/3,o=n.elements,l=ixe.getNormalMatrix(n).elements;for(let h=0;h<a;h++){let d=3*h,c=3*(i+h),p=e.positions[d],f=e.positions[d+1],m=e.positions[d+2];t.positions[c]=o[0]*p+o[4]*f+o[8]*m+o[12],t.positions[c+1]=o[1]*p+o[5]*f+o[9]*m+o[13],t.positions[c+2]=o[2]*p+o[6]*f+o[10]*m+o[14];let g=e.normals[d],v=e.normals[d+1],y=e.normals[d+2];t.normals[c]=l[0]*g+l[3]*v+l[6]*y,t.normals[c+1]=l[1]*g+l[4]*v+l[7]*y,t.normals[c+2]=l[2]*g+l[5]*v+l[8]*y;let _=2*(i+h);if(s===void 0)t.uvs[_]=e.uvs[2*h],t.uvs[_+1]=e.uvs[2*h+1];else{let[b,x]=s(p,f,e.uvs[2*h],e.uvs[2*h+1],h);t.uvs[_]=b,t.uvs[_+1]=x}}let u=n.determinant()<0;for(let h=0;h<e.indices.length;h+=3)t.indices[r+h]=e.indices[h]+i,t.indices[r+h+1]=e.indices[h+(u?2:1)]+i,t.indices[r+h+2]=e.indices[h+(u?1:2)]+i}function Jbe(e){let{owner:t,shape:i,curveSegments:r,assembledAt:n,bevel:s,bevelSegments:a}=e,o=function(c,p){let f=[p],m=g=>{f.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let v of g.points){f.push(v.roundness??0,v.position.x,v.position.y);for(let y of v.controls)f.push(y.position.x,y.position.y)}f.push(g.shapeHoles.length);for(let v of g.shapeHoles)m(v)};return m(c),function(g){let v=2166136261;for(let y=0;y<g.length;y++)v^=g[y],v=Math.imul(v,16777619)>>>0;return v}(new Uint8Array(new Float64Array(f).buffer))}(i,r),l=t??`outline:${o}`,u=`${s}/${a}`,h=zL.get(l);if(h!==void 0&&h.outlineVersion===o&&h.capKey===u&&(e.stillServes?.(h)??1))return uH.placements++,h.cap;let d=function(c,p,f,m,g){let{points:v,ends:y}=Qbe(c,p);return $A.assemble_cap(v,y,f,m,0,Math.max(1,Math.floor(g)),exe,40)}(i,r,n,s,a);uH.assemblies++;try{let c=function(p,f){return function(m,g,v,y,_){let b=1/0;for(let x=2;x<m.length;x+=3)m[x]<b&&(b=m[x]);if(b===1/0&&(b=0),b!==0)for(let x=2;x<m.length;x+=3)m[x]-=b;return{positions:m,normals:g,uvs:v,indices:y,rise:_-b}}(p.positions(),p.normals(),p.uvs(),p.indices(),f)}(d,n);return zL.set(l,{outlineVersion:o,capKey:u,assembledAt:n,cap:c}),c}finally{d.free()}}function ix(e,t){return .5*t>1.001*e}var $A,exe,xie,txe,ixe,wie,Sie,Tie,zL,uH,dH,t0,_w=U(()=>{oe(),Gr(),$be(),vY(),exe=.4,txe=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),ixe=new oi,wie=new Ue,Sie=new Ue,Tie=new Ue().makeScale(1,1,-1),zL=new Map,uH={assemblies:0,placements:0},dH=class extends At{constructor(e,t,i=0,r=12,n=3,s,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,$A===void 0)throw new Error("bevel-wasm is not loaded");this._shape=e,this._uvPitch=a,this._legacy=o,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegments=n,this._ownerId=s,this.rebuild()}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length>0&&ix(this._effectiveBevel,e)&&ix(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=t,u===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}setDepth(e){e!==this._depth&&(this._depth=e,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let e=Jbe({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>ix(a.cap.rise,this._depth)&&ix(a.cap.rise,a.assembledAt)}),t=function(a,o,l,u,h,d=!1){let c=u.positions.length/3,p=l-u.rise,f=u.rise,{points:m,ends:g}=Qbe(a,o),v=1/0,y=1/0,_=-1/0,b=-1/0;for(let pe=0;pe<m.length;pe+=2)m[pe]<v&&(v=m[pe]),m[pe]>_&&(_=m[pe]),m[pe+1]<y&&(y=m[pe+1]),m[pe+1]>b&&(b=m[pe+1]);d&&(h=void 0);let x=h??_-v,w=h??b-y,S={minX:v,minY:y,spanX:_-v||1,spanY:b-y||1},T=[],M=0;for(let pe of g)T.push({at:M,count:pe-M}),M=pe;let E=0;for(let pe of T)E+=pe.count;let A=2*c+4*E,P=new Float32Array(3*A),N=new Float32Array(3*A),D=new Float32Array(2*A),O=new Uint32Array(2*u.indices.length+6*E),z=new Uint8Array(A),L=0,V=h===void 0?void 0:(pe,xe)=>[pe/h,xe/h],G=d?(pe,xe,we,re,Se)=>Xbe(u,Se)?[re,we]:[we,re]:V,Y=d?Ybe(u):u,$={positions:P,normals:N,uvs:D,indices:O};UL(Y,$,0,0,wie.makeTranslation(0,0,p),V),UL(Y,$,c,u.indices.length,Sie.makeTranslation(0,0,f).multiply(Tie),G),z.fill(1,0,c);let Q=2*c,ue=2*u.indices.length;for(let pe=0;pe<T.length;pe++){let{at:xe,count:we}=T[pe],re=m.subarray(2*xe,2*(xe+we)),Se=jbe(re,pe>0),W=d?{u:new Float32Array(we+1),vScale:0}:Wbe(re,x,w),k=W.u;L=W.vScale;for(let K=0;K<we;K++){let ie=(K+1)%we,[j,ae]=Se[K],se=Q;for(let[H,me,be,ke,Te,Ze]of[[re[2*K],re[2*K+1],j,p,k[K],2],[re[2*ie],re[2*ie+1],ae,p,k[K+1],2],[re[2*ie],re[2*ie+1],ae,f,k[K+1],0],[re[2*K],re[2*K+1],j,f,k[K],0]]){let ze=3*Q;if(P[ze]=H,P[ze+1]=me,P[ze+2]=ke,N[ze]=be[0],N[ze+1]=be[1],N[ze+2]=0,d){let[qe,Ne]=Kbe(S,H,me,Ze===0);D[2*Q]=qe,D[2*Q+1]=Ne}else D[2*Q]=Te,D[2*Q+1]=L===0?0:(ke-f)/L;z[Q]=Ze,Q++}O[ue++]=se,O[ue++]=se+1,O[ue++]=se+2,O[ue++]=se,O[ue++]=se+2,O[ue++]=se+3}}return Hbe(P,N,O),{positions:P,normals:N,uvs:D,indices:O,nearSide:z,vScale:L}}(this._shape,this._curveSegments,this._depth,e,this._uvPitch,this._legacy);this._nearSide=t.nearSide,this._vScale=t.vScale,this._effectiveBevel=e.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),n=this.getAttribute("uv"),s=this.getIndex();if(i!==void 0&&r!==void 0&&n!==void 0&&s!==null&&i.array.length===t.positions.length&&r.array.length===t.normals.length&&n.array.length===t.uvs.length&&s.array.length===t.indices.length)return i.array.set(t.positions),r.array.set(t.normals),n.array.set(t.uvs),s.array.set(t.indices),i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0,void(s.needsUpdate=!0);this.setAttribute("position",new Rt(t.positions,3)),this.setAttribute("normal",new Rt(t.normals,3)),this.setAttribute("uv",new Rt(t.uvs,2)),this.setIndex(new Rt(t.indices,1))}clone(){let e=new dH(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return e.userData=W4(this.userData),e}}}),qg=U(()=>{e0(),JLe(),Zbe(),_w(),qA(),t0=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:es.ODD},e.parameters),n=Math.abs(r.width),s=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=e.shape??t?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ds?(i=o,(i.width!==n||i.height!==s)&&i.applySize(n,s)):i=new ds(n,s).fromJSON(o),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&i.update());let u=i??new ds(n,s);return{parameters:Object.assign(r,{width:n,height:s,depth:a,roundness:l}),shape:u,ownerId:e.ownerId??t?.ownerId}}static build(e){let t,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:n,subdivisions:s,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:u}=e.parameters,h=u===1;return e.shape.roundness=a,i<=0?t=new hH(e.shape,s,{windingRule:o}):r<=0?t=new FL(e.shape,i,s,o,l,h):$A!==void 0?t=new dH(e.shape,i,r,s,n,e.ownerId,l,h):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),t=new FL(e.shape,i,s,o,l,h)),Object.assign(t,{userData:{...e,type:"VectorGeometry"}})}}});function i4e(e,t,i,r,n,s){if(r>=yY)return n>30||n%4==0?(function(h,d,c,p=0,f=0,m=0){let g=.5522847498,v=d*g,y=c*g;h.addPoint(M3(f-d,m,f-d,m-y,f-d,m+y)),h.addPoint(M3(f,m+c,f-v,m+c,f+v,m+c)),h.addPoint(M3(f+d,m,f+d,m+y,f+d,m-y)),h.addPoint(M3(f,m-c,f+v,m-c,f-v,m-c)),p>0&&nxe(h,d,c,p)}(e,t,i,s),Math.round(n/4)):Mie(e,r,n,t,i,s);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*t,y:Math.sin(o)*i},u=function({px:h,py:d,cx:c,cy:p,rx:f,ry:m,largeArcFlag:g,sweepFlag:v}){let y=[];if(f===0||m===0)return[];let _=(h-c)/2,b=(d-p)/2;if(_===0&&b===0)return[];f=Math.abs(f),m=Math.abs(m);let x=Math.pow(_,2)/Math.pow(f,2)+Math.pow(b,2)/Math.pow(m,2);x>1&&(f*=Math.sqrt(x),m*=Math.sqrt(x));let w=function(N,D,O,z,L,V,G,Y,$,Q){let ue=Math.pow(L,2),pe=Math.pow(V,2),xe=Math.pow(G,2),we=Math.pow(Y,2),re=ue*pe-ue*we-pe*xe;re<0&&(re=0),re/=ue*we+pe*xe,re=Math.sqrt(re)*($===Q?-1:1);let Se=re*L/V*Y,W=re*-V/L*G,k=Se+(N+O)/2,K=W+(D+z)/2,ie=(G-Se)/L,j=(Y-W)/V,ae=(-G-Se)/L,se=(-Y-W)/V,H=vie(1,0,ie,j),me=vie(ie,j,ae,se);return!Q&&me>0&&(me-=OI),Q&&me<0&&(me+=OI),{centerx:k,centery:K,ang1:H,ang2:me}}(h,d,c,p,f,m,_,b,g,v),{ang1:S,ang2:T}=w,{centerx:M,centery:E}=w,A=Math.abs(T)/(OI/4);Math.abs(1-A)<1e-7&&(A=1);let P=Math.max(Math.ceil(A),1);T/=P;for(let N=0;N<P;N++)y.push(ZLe(S,T)),S+=T;return y.map(N=>{let{x:D,y:O}=l5(N[0],f,m,M,E),{x:z,y:L}=l5(N[1],f,m,M,E),{x:V,y:G}=l5(N[2],f,m,M,E);return{x1:D,y1:O,x2:z,y2:L,x:V,y:G}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%u.length===0?function(h,d,c,p,f,m,g,v){let y=Math.round(f/p.length);h.addPoint(Ex(d,c));for(let _=0,b=p.length;_<b;_++){let x=p[_],w=h.points[_],S=Ex(x.x,x.y);w.controls[1].position.set(x.x1,x.y1),S.controls[0].position.set(x.x2,x.y2),h.addPoint(S)}return v>0?rxe(h,m,g,v):h.addPoint(Ex(0,0)),y}(e,a.x,a.y,u,n,t,i,s):Mie(e,r,n,t,i,s)}function Mie(e,t,i,r,n,s){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,u=Math.sin(l)*r,h=Math.cos(l)*n;e.addPoint(Ex(u,h))}return t<yY?s>0?rxe(e,r,n,s):e.addPoint(Ex(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&nxe(e,r,n,s)),1}function Ex(e,t){return new _y(ht.generateUUID(),new Z(e,t))}function M3(e,t,i,r,n,s){let a=Ex(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(n,s),a}function rxe(e,t,i,r){sxe(e,t,i,r).forEach(n=>e.addPoint(n))}function nxe(e,t,i,r){let n=sxe(e,t,i,r),s=new ds;n.forEach(a=>s.addPoint(a)),s.isClosed=!0,e.shapeHoles.push(s)}function sxe(e,t,i,r){let n=r*t/100,s=n*(Math.abs(i)/Math.abs(t)),a=new Z(n/t,s/i),o=e.points.map(l=>{let u=l.clone();return u.uuid=ht.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 yY,lB,axe,p5,oxe,kL=U(()=>{e0(),Vbe(),QLe(),qg(),oe(),yY=2*Math.PI,lB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=ht.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof ds?e.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(e){let t,{width:i,height:r,spikes:n,angle:s,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=e.parameters,d=e.shape,c=i4e(d,.5*i,.5*r,s*Math.PI/180,n,a);return d.isClosed=!0,d.update(),s===0?(t=new At,t.setAttribute("position",new Et([],3))):t=t0.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}}),Object.assign(t,{userData:{...e,type:"EllipseGeometry"}})}}}),Eie=U(()=>{oe(),Lbe(),axe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new p5(.5*t,s,a):new k7(.5*t,n),l=i/t,u=r/t;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},p5=class extends LL{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n="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],n,e,t,i),this.type=n}static fromJSON(e){return new p5(e.radius,e.corner,e.cornerSides)}}}),Aie=U(()=>{oe(),oxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.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}]},e.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(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,n=new oA;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new V7(n.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}}});function q1(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function r4e(e){let{positions:t,faces:i,materialIndices:r,uvs:n}=e,s=t.length/3,a=i.length/3,o=n!==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),f=0,m=8;for(;m<2*l;)m*=2;let g=m-1,v=new Int32Array(m).fill(-1),y=(D,O)=>{let z=(Math.imul(D,2654435761)^O)&g;for(;;){let L=v[z];if(L===-1)return v[z]=f,u[f]=D,h[f]=O,f++;if(u[L]===D&&h[L]===O)return L;z=z+1&g}},_=(D,O)=>{let z=D<O?D:O,L=D<O?O:D,V=(Math.imul(z,2654435761)^L)&g;for(;;){let G=v[V];if(u[G]===z&&h[G]===L)return G;V=V+1&g}},b=new Uint32Array(s),x=new Float64Array(3*s),w=(D,O,z)=>{let L=D<O?y(D,O):y(O,D),V=++d[L];V===1?c[L]=z:V===2&&(p[L]=z),b[D]++,b[O]++,x[3*D]+=t[3*O],x[3*D+1]+=t[3*O+1],x[3*D+2]+=t[3*O+2],x[3*O]+=t[3*D],x[3*O+1]+=t[3*D+1],x[3*O+2]+=t[3*D+2]};for(let D=0;D<a;D++){let O=i[3*D],z=i[3*D+1],L=i[3*D+2];w(O,z,L),w(z,L,O),w(L,O,z)}let S=new Float64Array(3*f);for(let D=0;D<f;D++){let O=3*u[D],z=3*h[D];if(d[D]===2){let L=3*c[D],V=3*p[D];S[3*D]=.375*(t[O]+t[z])+.125*(t[L]+t[V]),S[3*D+1]=.375*(t[O+1]+t[z+1])+.125*(t[L+1]+t[V+1]),S[3*D+2]=.375*(t[O+2]+t[z+2])+.125*(t[L+2]+t[V+2])}else S[3*D]=.5*(t[O]+t[z]),S[3*D+1]=.5*(t[O+1]+t[z+1]),S[3*D+2]=.5*(t[O+2]+t[z+2])}let T,M=new Float64Array(3*s);for(let D=0;D<s;D++){let O=b[D];O===3?T=3/16:O>3&&(T=3/(8*O));let z=1-O*Number(T),L=Number(T);O===2&&(z=3/4,L=1/8),M[3*D]=t[3*D]*z+x[3*D]*L,M[3*D+1]=t[3*D+1]*z+x[3*D+1]*L,M[3*D+2]=t[3*D+2]*z+x[3*D+2]*L}let E=new Float64Array(3*(s+f));E.set(M),E.set(S,3*s);let A=new Uint32Array(12*a),P=new Array(4*a),N=o?new Float64Array(24*a):null;for(let D=0;D<a;D++){let O=i[3*D],z=i[3*D+1],L=i[3*D+2],V=_(O,z)+s,G=_(z,L)+s,Y=_(L,O)+s,$=12*D;A[$++]=V,A[$++]=G,A[$++]=Y,A[$++]=O,A[$++]=V,A[$++]=Y,A[$++]=z,A[$++]=G,A[$++]=V,A[$++]=L,A[$++]=Y,A[$++]=G;let Q=r[D];if(P[4*D]=Q,P[4*D+1]=Q,P[4*D+2]=Q,P[4*D+3]=Q,N!==null){let ue=6*D,pe=n[ue],xe=n[ue+1],we=n[ue+2],re=n[ue+3],Se=n[ue+4],W=n[ue+5],k=q1(pe,we),K=q1(xe,re),ie=q1(we,Se),j=q1(re,W),ae=q1(pe,Se),se=q1(xe,W),H=24*D;N[H++]=k,N[H++]=K,N[H++]=ie,N[H++]=j,N[H++]=ae,N[H++]=se,N[H++]=pe,N[H++]=xe,N[H++]=k,N[H++]=K,N[H++]=ae,N[H++]=se,N[H++]=we,N[H++]=re,N[H++]=ie,N[H++]=j,N[H++]=k,N[H++]=K,N[H++]=Se,N[H++]=W,N[H++]=ae,N[H++]=se,N[H++]=ie,N[H++]=j}}return{positions:E,faces:A,materialIndices:P,uvs:N}}var E3,lxe,ea,hxe,_Y,n4e=U(()=>{oe(),E3=1e4,lxe=class{constructor(e=1){this.subdivisions=e}modify(e){let t=function(r){let n=r.getAttribute("position");if(n===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let s=r.getAttribute("uv"),a=r.getIndex(),o=n.count,l=new Map,u=new Uint32Array(o),h=[],d=0;for(let y=0;y<o;y++){let _=n.getX(y),b=n.getY(y),x=n.getZ(y),w=Math.round(_*E3),S=Math.round(b*E3),T=Math.round(x*E3),M=l.get(w);M===void 0&&(M=new Map,l.set(w,M));let E=M.get(S);E===void 0&&(E=new Map,M.set(S,E));let A=E.get(T);A===void 0&&(A=d++,E.set(T,A),h.push(_,b,x)),u[y]=A}let c=[],p=[],f=s===void 0?null:[],m=a!==null?a.count:o,g=(y,_)=>{let b=a!==null?a.getX(y):y,x=a!==null?a.getX(y+1):y+1,w=a!==null?a.getX(y+2):y+2;if(!(b<o&&x<o&&w<o))return;let S=u[b],T=u[x],M=u[w];S===T||T===M||M===S||(c.push(S,T,M),p.push(_),f!==null&&f.push(s.getX(b),s.getY(b),s.getX(x),s.getY(x),s.getX(w),s.getY(w)))},v=r.groups;if(v.length>0)for(let y=0;y<v.length;y++){let _=v[y],b=_.materialIndex===void 0?0:_.materialIndex,x=Math.max(_.start,0),w=Math.min(_.start+_.count,m);for(let S=x;S<w&&S+2<m;S+=3)g(S,b)}else for(let y=0;y+2<m;y+=3)g(y,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(c),materialIndices:p,uvs:f===null?null:Float64Array.from(f)}}(e),i=this.subdivisions;for(;i-- >0;)t=r4e(t);return function(r,n){let{positions:s,faces:a,materialIndices:o,uvs:l}=r,u=s.length/3,h=a.length/3,d=new Float64Array(3*u);for(let v=0;v<h;v++){let y=3*a[3*v],_=3*a[3*v+1],b=3*a[3*v+2],x=s[b]-s[_],w=s[b+1]-s[_+1],S=s[b+2]-s[_+2],T=s[y]-s[_],M=s[y+1]-s[_+1],E=s[y+2]-s[_+2],A=w*E-S*M,P=S*T-x*E,N=x*M-w*T;d[y]+=A,d[y+1]+=P,d[y+2]+=N,d[_]+=A,d[_+1]+=P,d[_+2]+=N,d[b]+=A,d[b+1]+=P,d[b+2]+=N}for(let v=0;v<u;v++){let y=d[3*v],_=d[3*v+1],b=d[3*v+2],x=Math.sqrt(y*y+_*_+b*b)||1;d[3*v]=y/x,d[3*v+1]=_/x,d[3*v+2]=b/x}let c=3*h,p=new Float32Array(3*c),f=new Float32Array(3*c),m=l!==null&&l.length>0?new Float32Array(2*c):null;for(let v=0;v<c;v++){let y=3*a[v];p[3*v]=s[y],p[3*v+1]=s[y+1],p[3*v+2]=s[y+2],f[3*v]=d[y],f[3*v+1]=d[y+1],f[3*v+2]=d[y+2]}m!==null&&m.set(l.subarray(0,2*c));let g=new At;g.setAttribute("position",new Rt(p,3)),c>0&&(g.setAttribute("normal",new Rt(f,3)),g.setAttribute("color",new Rt(new Float32Array(3*c).fill(1),3))),m!==null&&g.setAttribute("uv",new Rt(m,2));for(let v=0;v<h;){let y=o[v],_=v;do v++;while(v<h&&o[v]===y);g.addGroup(3*_,3*(v-_),y)}return n.boundingBox!==null&&(g.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(g.boundingSphere=n.boundingSphere.clone()),g}(t,e)}}}),Cie=U(()=>{oe(),n4e(),ea=new R,hxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=e.geometry??t?.geometry??new At().copy(new Dh(100,100,100));t===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(ea),i={width:ea.x,height:ea.y,depth:ea.z,subdivisions:0}):i=t.parameters;let n={...i,...e.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:r}}static build(e){let{width:t,height:i,depth:r,subdivisions:n}=e.parameters,s=e.geometry??new At().copy(new Dh(100,100,100)),a=s.userData.parameters;a===void 0?(s.boundingBox=function(l){let u=new fn,h=l.attributes.position;return h?(u.setFromBufferAttribute(h),u):(u.makeEmpty(),u)}(s),s.boundingBox.getSize(ea)):ea.set(a.width,a.height,a.depth),(t!==ea.x||i!==ea.y||r!==ea.z)&&s.scale(ea.x===0?1:t/ea.x,ea.y===0?1:i/ea.y,ea.z===0?1:r/ea.z);let o=s.originalGeometry;try{n>0?(o===void 0||a?.subdivisions!==n)&&(o===void 0&&(o=s),s=new lxe(n).modify(o)):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new TX(i).load(e,r=>{let n=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ea);let s=100/ea.x;Object.assign(n.parameters,{width:100,height:ea.y*s,depth:ea.z*s}),t(this.build(n))})}}}),cH=U(()=>{e0(),qg(),_Y=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let{width:t,height:i,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=e.parameters,u=e.shape,h=.5*t,d=.5*i,c=2*Math.PI/r;for(let f=0;f<r;f++){let m=c*f,g=0+Math.sin(m)*h,v=0+Math.cos(m)*d;u.addPoint(u.createPoint(g,v))}u.isClosed=!0;for(let f=0,m=u.points.length;f<m;f++)u.points[f].roundness=n;u.roundness=n,u.update();let p=t0.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...e,type:"PolygonGeometry"}})}}});function kS(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function f5(e,t,i,r,n,s){let a=dxe.copy(t).sub(e),o=cxe.copy(i).sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===n){let u=a.add(o).normalize();s.copy(e).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(o);s.copy(e),s.addScaledVector(a,n/Math.sin(u)),s.addScaledVector(o,r/Math.sin(u))}}function s4e(e,t,i){let r=e.clone().sub(t),n=i.clone().sub(t);return r.projectOnVector(n),r.add(t)}var uxe,dxe,cxe,Pie,hB,pxe,fxe,mxe,Rie,bY,gxe,vxe,yxe,_xe,Die=U(()=>{oe(),uxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.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(e){let{width:t,height:i,depth:r,radialSegments:n,heightSegments:s,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,u=new Pie(.5*t,i,n,s,a,o,l),h=r/t;return h!==1&&u.scale(1,1,h),Object.assign(u,{userData:{...e,type:"PyramidGeometry"}})}},dxe=new R,cxe=new R,Pie=class extends At{constructor(e=.5,t=1,i=4,r=1,n=!1,s=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=t/2,f=Math.PI/i,m=e*Math.cos(Math.PI/i),g=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,_=new R(0,-p,0),b=new R(0,p,0),x=new Z(e,-p),w=new Z(m,-p),S=new Z(0,b.y).sub(w),T=new Z(0,b.y).sub(x),M=new Z(S.y,-S.x).normalize(),E=new Z(T.y,-T.x).normalize(),A=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;s=Math.min(s,A);{let V=new R(M.x,M.y,0),G=new R(Math.cos(g)*V.x,V.y,Math.sin(g)*V.x);o=V.angleTo(G)}let P=s/Math.tan((Math.PI-S.angle())/2),N=s/Math.tan((Math.PI-o)/2),D=new R;if(!n){u.push(_.x,_.y,_.z),h.push(0,-1,0),d.push(0,0);let V=c++,G=[],Y=x.clone(),$=P/Math.cos(Math.PI/i);Y.x-=$;for(let Q=0;Q<i;Q++){let ue=Q/i*Math.PI*2+f;kS(Y,new Z(Math.sin(ue),Math.cos(ue)),D),u.push(D.x,D.y,D.z),h.push(0,-1,0),d.push(0,0),G.push(c++)}for(let Q=0;Q<G.length;Q++)l.push(G[Q],V,G[(Q+1)%G.length])}let O=[];{let V=new R,G=new R,Y=new R,$=new R,Q=new R,ue=new R;for(let pe=0;pe<i;pe++){let xe=pe/i*Math.PI*2+f,we=(pe+.5)/i*Math.PI*2+f,re=(pe+1)/i*Math.PI*2+f,Se=new Z(Math.sin(xe),Math.cos(xe)),W=new Z(Math.sin(we),Math.cos(we)),k=new Z(Math.sin(re),Math.cos(re));kS(x,Se,G),kS(x,k,Y),kS(M,W,V),f5(b,G,Y,N,N,$),u.push($.x,$.y,$.z),f5(G,b,Y,N,P,Q),u.push(Q.x,Q.y,Q.z),f5(Y,G,b,P,N,ue),u.push(ue.x,ue.y,ue.z),h.push(V.x,V.y,V.z),h.push(V.x,V.y,V.z),h.push(V.x,V.y,V.z),d.push(0,0),d.push(0,0),d.push(0,0);let K=c++,ie=c++,j=c++;if(l.push(K,ie,j),s>0){{let H=G.clone().add(Y).multiplyScalar(.5),me=b.clone().sub(H).normalize(),be=_.clone().sub(H).normalize().add(me).normalize().multiplyScalar(-1);z(H,ue.clone().sub(Q),be,S.angle())}let ae,se;{let H=new R;kS(E,k,H);let me=ue.clone().add($).multiplyScalar(.5);me=s4e(me,Y,b);let be=ue.clone().sub($);[ae,se]=z(me,be,H,o,$.y)}{let H=ae,me=H.clone().setY(0).normalize(),be=new R(0,-1,0),ke=me.clone().cross(be);L(H,me,be,ke)}O.concat(se);{let H=S.angle(),me=Math.PI-H,be=b.clone();be.y-=s/Math.sin(H-Math.PI/2);let ke=new R,Te=[];for(let ze=0;ze<a;ze++){let qe=[],Ne=Math.PI/2-me*ze/a,ee=Math.cos(Ne),Ce=Math.sin(Ne),He=we;for(let pt=0;pt<=ze;pt++){let tt=Math.cos(He),Yt=Math.sin(He);V.x=ee*Yt,V.y=Ce,V.z=ee*tt,ke.copy(be).addScaledVector(V,s),u.push(ke.x,ke.y,ke.z),h.push(V.x,V.y,V.z),d.push(0,0),qe.push(c++),He+=2*Math.PI/ze/i}Te.push(qe)}se.reverse(),Te.push(se);let Ze=Te.length-1;for(let ze=0;ze<Ze;ze++){let qe=Te[ze],Ne=Te[ze+1],ee=qe.length-1;l.push(Ne[1],qe[0],Ne[0]);for(let Ce=1;Ce<=ee;Ce++)l.push(qe[Ce],qe[Ce-1],Ne[Ce]),l.push(Ne[Ce+1],qe[Ce],Ne[Ce])}}}}}function z(V,G,Y,$,Q){let ue=-$/2,pe=(Math.PI-$)/2,xe=G.clone().normalize().cross(Y);V.addScaledVector(Y,-s/Math.sin(pe));let we=new R,re=new R,Se=c,W=[];for(let k=0;k<=a;k++){let K=ue+k/a*$;re.set(0,0,0),re.addScaledVector(xe,Math.sin(K)),re.addScaledVector(Y,Math.cos(K));for(let ie=0;ie<=1;ie++){let j=ie/1-.5;if(we.copy(V),we.addScaledVector(G,j),we.addScaledVector(re,s),Q!=null){let ae=Math.max(0,we.y-Q);we.addScaledVector(G,-ae/G.y)}u.push(we.x,we.y,we.z),h.push(re.x,re.y,re.z),d.push(0,0),ie===0&&W.push(c),c++}}for(let k=0;k<a;k++)for(let K=0;K<1;K++){let ie=Se+K+2*k,j=ie+2,ae=j+1,se=ie+1;l.push(ie,j,se),l.push(j,ae,se)}return[V.clone().addScaledVector(G,.5),W]}function L(V,G,Y,$){let Q=Math.PI/2,ue=T.angle()-Q,pe=[],xe=new R,we=new R;for(let Se=0;Se<=a;Se++){let W=[],k=Se/a;for(let K=0;K<=Se;K++){let ie=((Se?K/Se:0)-.5)*y,j=Math.cos(ie),ae=Math.sin(ie),se=(Q+Math.atan(Math.tan(ue)*j))*k,H=Math.cos(se),me=Math.sin(se);xe.set(0,0,0),xe.addScaledVector(G,me*j),xe.addScaledVector(Y,H),xe.addScaledVector($,me*ae),we.copy(V).addScaledVector(xe,s),u.push(we.x,we.y,we.z),h.push(xe.x,xe.y,xe.z),d.push(0,0),W.push(c++)}pe.push(W)}let re=pe.length-1;for(let Se=0;Se<re;Se++){let W=pe[Se],k=pe[Se+1],K=W.length-1;l.push(W[0],k[1],k[0]);for(let ie=1;ie<=K;ie++)l.push(W[ie-1],W[ie],k[ie]),l.push(W[ie],k[ie+1],k[ie])}}this.setIndex(l),this.setAttribute("position",new Et(u,3)),this.setAttribute("normal",new Et(h,3)),this.setAttribute("uv",new Et(d,2))}}}),VL=U(()=>{e0(),qg(),hB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let t=e.shape,{width:i,height:r,cornerRadius:n,cornerType:s,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}=e.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,w,S){return w>i&&S>r?Math.min(x*i/w,x*r/S):w>i?x*i/w:S>r?x*r/S:x}let f=[];f[0]=n[0]===0?0:p(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:p(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:p(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:p(n[3],n[3]+n[0],n[3]+n[2]);let m=d.x,g=c.x,v=c.y,y=d.y;t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let _=!0;for(let x=0,w=t.points.length;x<w;x++)t.points[x].roundness=f[x],x>0&&f[x]!==f[x-1]&&(_=!1);_&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=t0.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}}}),Nie=U(()=>{oe(),pxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=ht.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(e){let t,{width:i=100,height:r=i,depth:n=i,widthSegments:s=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:u,thetaLength:h}=e.parameters;return h===0?(t=new At,t.setAttribute("position",new Et([],3))):t=new Vf(.5*i,s,a,o,l,u,h*ht.DEG2RAD),t.scale(1,r/i,n/i),Object.assign(t,{userData:{...e,type:"SphereGeometry"}})}}}),Iie=U(()=>{oe(),fxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:n=8}=e.parameters,s=new qc(t,i,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}}}),Oie=U(()=>{oe(),mxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.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(e){let{width:t,height:i,depth:r,angle:n,cornerRadius:s,cornerSegments:a}=e.parameters,o=new Rie(t,i,r,n,s,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},Rie=class extends At{constructor(e=1,t=1,i=1,r=90,n=10,s=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],u=.001;n==0&&(s=1),s=Math.max(1,Math.floor(s)),n=Math.min(n,100),r=Math.min(180-u,r),r*=Math.PI/180;let h=[],d=Math.PI/2,c=(we=0,re=0,Se=0)=>new R(we,re,Se),p=c(),f=c(),[m,g,v]=[t/2,e/2,i/2],y=-g,_=+g,[b,x,w]=[c(y,-m,+v),c(y,-m,-v),c(y,+m,-v)],S=(we,re=!1)=>Math.sin(we-Math.PI/(+re+1)),T=(we,re=!1)=>Math.cos(we-Math.PI/(+re+1));w.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,E=b.z-u;r<=d?(w.z=Math.min(M,E),w.z==E&&(w.y-=(M-E)/Math.tan(d-r))):x.z=Math.min(x.z-M-v,b.z-u),p.subVectors(b,x),f.subVectors(w,x);let A=Math.min(p.length(),f.length())*n/100,P=A*Math.tan(r/2),N=A/Math.cos(r/2),D=p.clone().normalize().add(f.normalize()).setLength(N).add(x);p.set(0,S(r,!0),T(r,!0)),h.push([w,p.clone()]);let O=(Math.PI-r)/s;for(let we=0;we<=s;we++){let re=d+r+we*O;p.set(0,Math.sin(re)*P,Math.cos(re)*P),p.add(D),f.set(0,S(re),T(re)),h.push([p.clone(),f.clone()])}h.push([b,c(0,1,0)]);let z=Math.sin(O/2)*P*2,L=h.length-1,V=h[0][0].distanceTo(h[1][0]),G=V+z*s+h[L-1][0].distanceTo(h[L][0]);h[0].push(1);for(let we=0;we<=s;we++)h[we+1].push(1-(V+we*z)/G);h[L].push(0);let Y,$,Q,[ue,pe,xe]=h[0];for(let we=1;we<h.length;we++)[Y,$,Q]=h[we],a.push(y,ue.y,ue.z,y,Y.y,Y.z,_,ue.y,ue.z,_,ue.y,ue.z,y,Y.y,Y.z,_,Y.y,Y.z),o.push(0,pe.y,pe.z,0,$.y,$.z,0,pe.y,pe.z,0,pe.y,pe.z,0,$.y,$.z,0,$.y,$.z),l.push(0,xe,0,Q,1,xe,1,xe,0,Q,1,Q),[ue,pe,xe]=[Y,$,Q];this.setAttribute("position",new Et(a,3)),this.setAttribute("normal",new Et(o,3)),this.setAttribute("uv",new Et(l,2))}}}),pH=U(()=>{e0(),qg(),bY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let{width:t,height:i,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=e.parameters,d=e.shape,c=.5*t,p=.5*i,f=a*Math.PI/360/n,m=Math.PI/2*3*-1,g=c*r/100,v=p*r/100;if(n===3&&r===50){f=2*Math.PI/n;for(let _=0;_<n;_++){let b=f*_,x=0+Math.sin(b)*c,w=0+Math.cos(b)*p;d.addPoint(d.createPoint(x,w))}}else for(let _=0;_<n;_++){let b=0+Math.cos(m)*c,x=0+Math.sin(m)*p;d.addPoint(d.createPoint(b,x)),m+=f,b=0+Math.cos(m)*g,x=0+Math.sin(m)*v,d.addPoint(d.createPoint(b,x)),m+=f}d.isClosed=!0;for(let _=0,b=d.points.length;_<b;_++)d.points[_].roundness=s;d.roundness=s,d.update();let y=t0.create({shape:d,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}});return Object.assign(y,{userData:{...e,type:"StarGeometry"}})}}}),Lie=U(()=>{oe(),gxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.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(e){let{width:t,height:i}=e.parameters,r=new qc(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}}}),Bie=U(()=>{oe(),wA(),vxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??i.width);i.shapeBlendNode&&(n=r);let s=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:n,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:n,tubularSegments:s,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,u=function(h,d,c,p,f,m,g,v,y,_,b){[d,c]=[c,d],g=d/2;let x=ht.clamp(f/360,0,1);if(x===0){let w=new At;return w.setAttribute("position",new Et([],3)),w}return x===1&&(_=0),new JW(!0,h,d,c,p,x,m,g,0,y,_,b)}(t,i,r,.5*t,a,s,0,0,n,o,l);return u.scale(1,i/t,1),Object.assign(u,{userData:{...e,type:"TorusGeometry"}})}}}),Fie=U(()=>{oe(),yxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.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(e){let{width:t,tube:i,tubularSegments:r,radialSegments:n,p:s,q:a}=e.parameters,o=.5*t;o!==i&&(o-=i);let l=new G7(o,i,r,n,s,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}}}),Uie=U(()=>{e0(),qg(),_xe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let{width:t=100,height:i,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=e.parameters,u=e.shape,h=.5*t,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,f=u.points.length;p<f;p++)u.points[p].roundness=r;u.roundness=r,u.update();let c=t0.create({shape:u,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}}}),a4e=U(()=>{}),o4e=U(()=>{oe(),new qa,new Ue,new yf,new R,new R,new R,new R});function zie(){let e=new At;return e.setAttribute("position",new Rt(new Float32Array([]),3)),e.setIndex(new Rt(new Uint16Array([]),1)),e}var kie,fH,bxe=U(()=>{la(),jt(),qA(),oe(),GA(),e0(),qg(),_w(),kie=zie().attributes,fH=class extends At{constructor(e,t){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,kie),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:u,fontSize:h,extrusionVersion:d}=e,c=Eo.getDisplayedValue(l),p=function(w,S,T,M){let E=typeof w.width=="string"?Number(M.getVariable(w.width)):w.width,A=[""],P="";for(let N of T)P+=N,N===" "||N===`
|
|
4176
|
+
`;return 2&x.valid||t(3,"missing format specifier"),4&x.valid||t(3,"missing image size specifier"),x}(s),h=u.width,d=u.height,c=function(p,f,m){let g=f;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&t(3,"wrong scanline width");let v=new Uint8Array(4*f*m);v.length||t(4,"unable to allocate buffer space");let y=0,_=0,b=4*g,x=new Uint8Array(4),w=new Uint8Array(b),S=m;for(;S>0&&_<p.byteLength;){_+4>p.byteLength&&t(1),x[0]=p[_++],x[1]=p[_++],x[2]=p[_++],x[3]=p[_++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&t(3,"bad rgbe scanline format");let T,M=0;for(;M<b&&_<p.byteLength;){T=p[_++];let A=T>128;if(A&&(T-=128),(T===0||M+T>b)&&t(3,"bad scanline data"),A){let P=p[_++];for(let N=0;N<T;N++)w[M++]=P}else w.set(p.subarray(_,_+T),M),M+=T,_+=T}let E=g;for(let A=0;A<E;A++){let P=0;v[y]=w[A+P],P+=g,v[y+1]=w[A+P],P+=g,v[y+2]=w[A+P],P+=g,v[y+3]=w[A+P],y+=4}S--}return v}(s.subarray(s.pos),h,d);switch(this.type){case Wt:l=c.length/4;let p=new Float32Array(4*l);for(let m=0;m<l;m++)r(c,4*m,p,4*m);a=p,o=Wt;break;case di:l=c.length/4;let f=new Uint16Array(4*l);for(let m=0;m<l;m++)n(c,4*m,f,4*m);a=f,o=di;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:Md,minFilter:rt,magFilter:rt,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}});function Zte(e){return e.length>2&&e[0]===35&&e[1]===63}function a5(e){return typeof e=="object"&&e!==null&&e.isSplineHdr===!0}function Ebe(e){let t=new Nr(e.data,e.width,e.height,mn,di);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var Qte,hY,Rc,Abe=U(()=>{oe(),zLe()}),Cbe=U(()=>{oe(),Tbe(),Mbe(),Abe(),Qte=0,hY=class extends bbe{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.instanceId=++Qte,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let s of Object.values(n))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,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 e!="string"){let r,n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"})),await new Promise(s=>{n.onloadend=a=>{r=a.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else if(e instanceof Uint8Array?Zte(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let r=e instanceof Uint8Array?e:null;if(r===null)try{r=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{r=null}let n=r!==null&&Zte(r)?function(s){try{let a=new wbe().parse(s.buffer.slice(s.byteOffset,s.byteOffset+s.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=m=>wd.toHalfFloat(Math.pow(Math.max(wd.fromHalfFloat(m),0),1/2.2)),p=new Map,f=m=>{let g=p.get(m);return g===void 0&&(g=c(m),p.set(m,g)),g};for(let m=0;m<l;m++){let g=m*d,v=(l-1-m)*d;for(let y=0;y<d;y+=4)h[v+y]=f(u[g+y]),h[v+y+1]=f(u[g+y+1]),h[v+y+2]=f(u[g+y+2]),h[v+y+3]=u[g+y+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(r):null;n!==null&&(this.isHdr=!0,this.img=n,t())}else this.img=new Image,this.img.src=typeof(i=e)=="string"?i:(AE||(AE=new _be),AE.load(i)),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}});var i}getTexture(e,t=1008,i=1006){let r=this._cache[e]?.[t]?.[i];if(r)return r;{let n;return this.isBuffer?n=this.img.texture:this.isVideo?n=new yX(this.img,void 0,e,e):this.isHdr?(n=Ebe(this.img),n.wrapS=e,n.wrapT=e,n.magFilter=i,n.minFilter=t):n=new Ri(this.img,void 0,e,e,i,t),this.isBuffer||(n.anisotropy=8,n.generateMipmaps=t===1008),this.loaded&&(n.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=n,n}}setNeedsUpdate(e){if(!this.isBuffer)for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[n,s]of Object.entries(r))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][n]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),oB=U(()=>{Cbe(),Rc=class extends hY{}});function kLe(e){if(typeof e=="string")return e;let t=iH.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},iH.set(e,t)),t.url}var iH,VLe=U(()=>{iH=new Map});function GLe(){if(!rH)return Jte||(Jte=async function(){await Promise.resolve().then(()=>(yZ(),M3e)),Pbe(window!==void 0?window:global),rH=!0}())}var Pbe,Rbe,rH,Jte,Dbe=U(()=>{Rbe=new Promise(e=>{Pbe=e}),rH=!1});function eie(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function jLe(e){let t=!1,i=[];return e.scene.objects.traverse((r,n)=>{if(n.type==="Page"&&n.uiScene!==void 0&&n.uiScene.objects.traverse((s,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;eie(a.events,i),t=t||i.some(o=>o.data.type==="Audio")}),n.events===void 0||Array.isArray(n.events)===!1)return!0;eie(n.events,i),t=t||i.some(s=>s.data.type==="Audio")}),t}var tie,tx,uY=U(()=>{VLe(),Dbe(),Rbe.then(e=>tie=e),tx=class{constructor({src:e,volume:t,delay:i,loop:r}){let n;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)},n=typeof e=="string"?{src:e}:{src:kLe(e),format:"wav"},this.sound=new tie.Howl(n),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,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(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function iie(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var dY,cY=U(()=>{dY=null});function rie(e){return new Z(e.y,-e.x)}var pY,nH,Nbe,Ibe,b3,nie,LL,Obe,o5,BL=U(()=>{oe(),pY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,n=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);n.thetaLength=ht.clamp(n.thetaLength,0,360),n.hollow=ht.clamp(n.hollow??0,0,1);let s=n.width/2,a=n.radiusTop??s,o=n.radiusBottom??s;if(a===o?(a=s,o=s):a>o?(a=s,o=o*s/a):(a=a*s/o,o=s),n.shapeBlendNode){a=i??s,o=r??s;let l=2*Math.max(a,o);n.width=l,n.depth=l}return{parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(n.height??n.width),depth:Math.abs(n.depth??n.width),radiusTop:a,radiusBottom:o})}}static build(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:f}=e.parameters;u===0?(t=new At,t.setAttribute("position",new Et([],3))):t=c||f?new nH(h,d,n,s,a,o,l,u*Math.PI/180,c,c,p,f):new mE(h,d,n,s,a,o,l,u*Math.PI/180);let m=r/i;return m!==1&&t.scale(1,1,m),Object.assign(t,{userData:{...e,type:"CylinderGeometry"}})}},nH=class extends At{constructor(e,t,i,r,n,s,a,o,l,u,h,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,n=Math.floor(n)||1,s=s!==void 0&&s,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,s&&(l=0,u=0);let p=i/2;c&&e==0&&(e=l),c&&t==0&&(t=u);let f=new Z(e,p),m=new Z(t,-p),g=null,v=null,y=null,_=null,b=f.clone().sub(m),x=0,w=0,S=0;d>0&&(x=Math.min(e,t)*(1-d),w=e-x,S=t-x);let T=f.clone();T.x-=x;let M=Math.PI-b.angle(),E=b.angle(),A=Math.tan(E/2),P=Math.tan(M/2),N=A+P,D=d?N:P,O=d?N:A;if(l=Math.min(l,(e-w)/D,b.length()/N),u=Math.min(u,(t-S)/O,b.length()/N),l>0){let me=l/A;g=f.clone().sub(new Z(me,l)),d&&(y=g.clone(),y.x-=x-N*l),f.sub(b.clone().setLength(me))}if(u>0){let me=u/P;v=m.clone().sub(new Z(me,-u)),m.add(b.clone().setLength(me)),d&&(_=v.clone(),_.x-=x-N*u,T.sub(b.clone().setLength(me)))}b=f.clone().sub(m);let z=b.length()<.5,L=[],V=[],G=[],Y=[],$=[],Q=[],ue=(me,be,ke,Te,Ze)=>{for(let ze=0;ze<h+1;ze++){let qe=ze/h,Ne=Te<0?qe:1-qe;Ze&&(Ne-=1),Ne*=me;let ee=Math.sin(Ne),Ce=Math.cos(Ne)*Te,He=Ce*be+ke.y;L.push(ee*be+ke.x),V.push(He),G.push(ee),Y.push(Ce),$.push(.5+He/i),Q.push(!1)}},pe=(me,be,ke)=>{let Te=[me,be];ke<0&&Te.reverse();for(let Ze of Te)L.push(Ze),V.push(p*ke),G.push(0),Y.push(ke),$.push(.5),Q.push(!0)};if(_&&v?(ue(M,u,_,-1,!0),ue(E,u,v,-1,!1)):v?(pe(v.x,0,-1),ue(E,u,v,-1,!1)):s||pe(t,S,-1),!z){let me=rie(b).normalize();for(let be=0;be<=n;be++){let ke=be/n,Te=b.y*ke+m.y;L.push(b.x*ke+m.x),V.push(Te),G.push(me.x),Y.push(me.y),$.push(.5+Te/i),Q.push(!1)}}if(y&&g?(ue(M,l,g,1,!1),ue(E,l,y,1,!0)):g?(ue(M,l,g,1,!1),pe(g.x,0,1)):s||pe(e,w,1),d&&!z){let me=rie(b).multiplyScalar(-1).normalize();for(let be=0;be<=n;be++){let ke=be/n,Te=b.y*-ke+T.y;L.push(b.x*-ke+T.x),V.push(Te),G.push(me.x),Y.push(me.y),$.push(.5+Te/i),Q.push(!1)}}let xe=L.length,we=xe+(d&&!s?1:0),re=(me,be)=>me*xe+(be===xe?0:be),Se=o<2*Math.PI,W=(r+1)*xe+(Se?2*(1+we):0),k=new Float32Array(3*W),K=new Float32Array(3*W),ie=new Float32Array(2*W),j=W-1>65535?new Uint32Array(r*Math.max(0,we-1)*6+(Se?2*(we+1)*3:0)):new Uint16Array(r*Math.max(0,we-1)*6+(Se?2*(we+1)*3:0)),ae=0,se=0;for(let me=0;me<=r;me++){let be=me/r,ke=be*o+a,Te=Math.sin(ke),Ze=Math.cos(ke);for(let ze=0;ze<xe;ze++){let qe=3*se,Ne=2*se,ee=L[ze],Ce=G[ze];k[qe]=ee*Te,k[qe+1]=V[ze],k[qe+2]=ee*Ze,K[qe]=Ce*Te,K[qe+1]=Y[ze],K[qe+2]=Ce*Ze,Q[ze]?(ie[Ne]=.5,ie[Ne+1]=.5):(ie[Ne]=be,ie[Ne+1]=$[ze]),se++}}for(let me=0;me<r;me++)for(let be=0;be<we-1;be++){if(s&&d&&be==n)continue;let ke=re(me,be),Te=re(me+1,be),Ze=re(me+1,be+1),ze=re(me,be+1),qe=k[3*Ze+0],Ne=k[3*Ze+2];j[ae++]=ke,j[ae++]=Te,j[ae++]=ze,(qe!=0||Ne!=0)&&(j[ae++]=Te,j[ae++]=Ze,j[ae++]=ze)}function H(me,be,ke){let Te=Math.sin(ke),Ze=Math.cos(ke),ze=-Ze,qe=Te,Ne=me<0?(tt,Yt,ni)=>{j[ae++]=tt,j[ae++]=Yt,j[ae++]=ni}:(tt,Yt,ni)=>{j[ae++]=tt,j[ae++]=ni,j[ae++]=Yt},ee=(e+t+w+S)/4,Ce=3*se,He=2*se;k[Ce]=ee*Te,k[Ce+1]=0,k[Ce+2]=ee*Ze,K[Ce]=ze,K[Ce+1]=0,K[Ce+2]=qe,ie[He]=.5,ie[He+1]=.5;let pt=se++;for(let tt=0;tt<we;tt++){let Yt=3*(be+(tt===xe?0:tt));Ce=3*se,He=2*se,k[Ce]=k[Yt],k[Ce+1]=k[Yt+1],k[Ce+2]=k[Yt+2],K[Ce]=ze,K[Ce+1]=0,K[Ce+2]=qe;let ni=Yt/3*2|0;ie[He]=ie[ni],ie[He+1]=ie[ni+1],se++}for(let tt=pt+1;tt<se-1;tt++)Ne(pt,tt,tt+1);Ne(pt,se-1,pt+1)}Se&&(H(-1,0,a),H(1,r*xe,a+o)),this.setIndex(new Rt(j.slice(0,ae),1)),this.setAttribute("position",new Rt(k,3)),this.setAttribute("normal",new Rt(K,3)),this.setAttribute("uv",new Rt(ie,2))}}}),sie=U(()=>{oe(),BL(),Nbe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=ht.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(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters;u===0?(t=new At,t.setAttribute("position",new Et([],3))):t=h>0||d>0||u<360?new nH(0,i/2,n,s,a,o,l,u*Math.PI/180,h,d,c,0,!0):new iL(i/2,n,s,a,o);let p=r/i;return p!==1&&t.scale(1,1,p),Object.assign(t,{userData:{...e,type:"ConeGeometry"}})}}}),aie=U(()=>{oe(),Ibe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.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(e){let t,{width:i,height:r,depth:n,widthSegments:s,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:u}=e.parameters;return t=l===0?new Dh(i,r,n,s,a,o):new nie(i,r,n,s,a,o,l,u),Object.assign(t,{userData:{...e,type:"CubeGeometry"}})}},b3=Math.PI/2,nie=class extends At{constructor(e=1,t=1,i=1,r=1,n=1,s=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=(a=Math.min(a,e/2,t/2,i/2))>0,u=o+1,h=2*((s+1)*(n+1)+(r+1)*(s+1)+(r+1)*(n+1))+(l?4*u*(s+1+(r+1)+(n+1))+u*(u+1)/2*8:0),d=2*(s*n+r*s+r*n)+(l?4*o*(s+r+n):0),c=l?8*o*o:0,p=new Float32Array(3*h),f=new Float32Array(3*h),m=new Float32Array(2*h),g=h-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),v=0,y=0,_=new Float64Array(u),b=new Float64Array(u),x=new Float64Array(u),w=new Float64Array(u);for(let N=0;N<u;N++){let D=N/o*b3;_[N]=Math.sin(D)*a,b[N]=(1-Math.cos(D))*a,x[N]=Math.sin(D),w[N]=Math.cos(D)}let S=u*(u+1)/2,T=new Float64Array(3*S),M=new Float64Array(3*S);{let N=new R(e/2,t/2,i/2);N.subScalar(a);let D=0;for(let O=0;O<=o;O++){let z=b3*(1-O/o),L=Math.cos(z),V=Math.sin(z),G=0;for(let Y=0;Y<=O;Y++){let $=L*Math.cos(G),Q=V,ue=L*Math.sin(G);T[3*D]=$,T[3*D+1]=Q,T[3*D+2]=ue,M[3*D]=N.x+$*a,M[3*D+1]=N.y+Q*a,M[3*D+2]=N.z+ue*a,D++,G+=b3/O}}}function E(N,D,O,z,L,V,G,Y,$,Q){let ue=(V-2*a)/$,pe=(G-2*a)/Q,xe=V/2-a,we=G/2-a,re=Y/2,Se=$+1,W=Q+1,k=0,K=new R;for(let ie=0;ie<W;ie++){let j=ie*pe-we;for(let ae=0;ae<Se;ae++){let se=ae*ue-xe,H=3*(v+k),me=2*(v+k);K[N]=se*z,K[D]=j*L,K[O]=re,p[H]=K.x,p[H+1]=K.y,p[H+2]=K.z,K[N]=0,K[D]=0,K[O]=Y>0?1:-1,f[H]=K.x,f[H+1]=K.y,f[H+2]=K.z,m[me]=ae/$,m[me+1]=1-ie/Q,k+=1}}for(let ie=0;ie<Q;ie++)for(let j=0;j<$;j++){let ae=v+j+Se*ie,se=v+j+Se*(ie+1),H=v+(j+1)+Se*(ie+1),me=v+(j+1)+Se*ie;g[y++]=ae,g[y++]=se,g[y++]=me,g[y++]=se,g[y++]=H,g[y++]=me}v+=k}function A(N,D,O,z,L,V,G,Y,$,Q){let ue=(G-2*a)/Q,pe=G/2-a,xe=Y/2-a,we=$/2,re=Q+1,Se=0,W=new R,k=new R;for(let K=0;K<o+1;K++){W[D]=(xe+_[K])*L,W[O]=(we-b[K])*V,k[N]=0,k[D]=x[K]*Math.sign(W[D]),k[O]=w[K]*Math.sign(W[O]);for(let ie=0;ie<re;ie++){let j=ie*ue-pe;W[N]=j*z;let ae=3*(v+Se),se=2*(v+Se);p[ae]=W.x,p[ae+1]=W.y,p[ae+2]=W.z,f[ae]=k.x,f[ae+1]=k.y,f[ae+2]=k.z,m[se]=ie/Q,m[se+1]=0,Se+=1}}for(let K=0;K<o;K++)for(let ie=0;ie<Q;ie++){let j=v+ie+re*K,ae=v+ie+re*(K+1),se=v+(ie+1)+re*(K+1),H=v+(ie+1)+re*K;g[y++]=j,g[y++]=ae,g[y++]=H,g[y++]=ae,g[y++]=se,g[y++]=H}v+=Se}function P(N,D,O){let z=N*D*O>0?(V,G,Y)=>{g[y++]=V,g[y++]=G,g[y++]=Y}:(V,G,Y)=>{g[y++]=V,g[y++]=Y,g[y++]=G},L=v;for(let V=0;V<S;V++){let G=3*V,Y=3*v,$=2*v;p[Y]=N*M[G],p[Y+1]=D*M[G+1],p[Y+2]=O*M[G+2],f[Y]=N*T[G],f[Y+1]=D*T[G+1],f[Y+2]=O*T[G+2],m[$]=0,m[$+1]=0,v++}for(let V=0;V<o;V++){let G=L+V*(V+1)/2,Y=L+(V+1)*(V+2)/2;z(G,Y+1,Y);for(let $=1;$<=V;$++)z(G+$-1,G+$,Y+$),z(G+$,Y+$+1,Y+$)}}E("z","y","x",-1,-1,i,t,e,s,n),E("z","y","x",1,-1,i,t,-e,s,n),E("x","z","y",1,1,e,i,t,r,s),E("x","z","y",1,-1,e,i,-t,r,s),E("x","y","z",1,-1,e,t,i,r,n),E("x","y","z",-1,-1,e,t,-i,r,n),a>0&&(A("z","y","x",-1,-1,1,i,t,e,s),A("z","y","x",1,-1,-1,i,t,e,s),A("z","y","x",-1,1,-1,i,t,e,s),A("z","y","x",1,1,1,i,t,e,s),A("x","y","z",-1,-1,-1,e,t,i,r),A("x","y","z",1,-1,1,e,t,i,r),A("x","y","z",-1,1,1,e,t,i,r),A("x","y","z",1,1,-1,e,t,i,r),A("y","x","z",-1,-1,1,t,e,i,n),A("y","x","z",1,-1,-1,t,e,i,n),A("y","x","z",1,1,1,t,e,i,n),A("y","x","z",-1,1,-1,t,e,i,n),P(1,1,1),P(-1,1,1),P(1,-1,1),P(-1,-1,1),P(1,1,-1),P(-1,1,-1),P(1,-1,-1),P(-1,-1,-1)),this.setIndex(new Rt(g,1)),this.setAttribute("position",new Rt(p,3)),this.setAttribute("normal",new Rt(f,3)),this.setAttribute("uv",new Rt(m,2))}}}),Lbe=U(()=>{oe(),LL=class extends At{constructor(e=[],t=[],i="",r=1,n=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,u=0;return function(){(n=Math.min(.99999,n))==0&&(s=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new R,c=d.clone(),p=new Bs,f=n*r,m=r-f,g=s+1,v=new R,y=(re,Se)=>v.subVectors(re,Se).normalize(),_=(re,Se)=>Array(re).fill(void 0).map(Se),b=_(e.length/3,(re,Se)=>new R().fromArray(e,3*Se).setLength(r)),x=[],w=1e6;for(let re=0;re<b.length;re++){let Se,W,k,K=b[re],ie=[],j=1e10,ae=-1;for(;(ae=t.indexOf(re,ae+1))!=-1;){let be=ae-ae%3;Se=t[be+(ae+1)%3],W=t[be+(ae+2)%3],k=K.distanceToSquared(b[Se]),j=Math.min(j,k),ie.push([Se,W,k])}j+=1e-6;let se=[],H=0,me=ie.length;for(let be=0;be<me;be++){[Se,W,k]=ie[H];let ke=x[Se]?.includes(re)==1;k<=j&&se.push(Se+ +ke*w),H=ie.findIndex(Te=>Te[0]==W)}x.push(se)}let S=[];{let re,Se,W=0,k=0,K=h==3;for(let ie=0;ie<=s;ie++){re=ie*(ie+1)/2,Se=(ie+1)*(ie+2)/2;for(let j=0;j<s-ie;j++)[W,k]=[re+j+ie+2,Se+j+ie+3],S.push(re,Se,...K?[k,re]:[W,Se],k,W),[re,Se]=[W,k];S.push(re,Se,re+s+2)}}let T=0;for(let re=0;re<x.length;re++)for(let Se=0;Se<h;Se++)x[re][Se]<w&&T++;let M=b.length*h*S.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(M),o=new Float64Array(M),l=new Float64Array(M/3*2);let E=(re,Se,W)=>{let k=u/3*2;l[k]=Math.atan2(W,-re)/2/Math.PI+.5,l[k+1]=1-(Math.atan2(-Se,Math.sqrt(re*re+W*W))/Math.PI+.5)},A=re=>{a[u]=re.x,a[u+1]=re.y,a[u+2]=re.z,o[u]=v.x,o[u+1]=v.y,o[u+2]=v.z,E(re.x,re.y,re.z),u+=3},P=re=>{a[u]=re[0].x,a[u+1]=re[0].y,a[u+2]=re[0].z,o[u]=re[1].x,o[u+1]=re[1].y,o[u+2]=re[1].z,E(re[0].x,re[0].y,re[0].z),u+=3},N=(s+2)*(s+3)/2,D=new Float64Array(3*N),O=new Float64Array(3*N),z=new Float64Array(2*N),L=_(2*h*g,()=>new R),V=_(s*Math.max(0,s-1)/2,()=>new R),G=d.clone(),Y=d.clone(),$=d.clone(),Q=d.clone(),ue=d.clone(),pe=[],xe=_(b.length,()=>_(h,()=>d.clone()));for(let re=0;re<b.length;re++){d.copy(b[re]).normalize(),G.copy(d).multiplyScalar(m);let Se=x[re];for(let se=0;se<Se.length;se++){let H=Se[se],me=Se[(se+1)%h];p.setFromPointsAndIndices(b,re,H%w,me%w),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(G,xe[re][se])}let W=0,k=[],K=[],ie=new R;s==0&&[...xe[re]].reduce((se,H)=>se.add(H),ie).multiplyScalar(1/h);for(let se=0;se<h;se++){let H=[],me=(se-1+h)%h,be=xe[re][me],ke=xe[re][se];d.copy(be).sub(G),c.copy(ke).sub(G);let Te=G.angleTo(d),Ze=d.angleTo(c),ze=Math.cos(Te)*f;s==0?Y.copy(ie):Y.copy(G).setLength(m+ze),k.push(ze);let qe=[Y,be,ke];for(let Ne=0;Ne<2;Ne++){let ee=qe[Ne],Ce=qe[Ne+1];Q.subVectors(ee,G),ue.subVectors(Ce,G),$.crossVectors(Q,ue).normalize();for(let He=0;He<g;He++){let pt=[Te,Ze][Ne]*He/g;d.copy(Q).applyAxisAngle($,pt).add(G),L[W++].copy(d),Ne&&(y(d,G),H.push([He==0?ee:d.clone(),v.clone()]))}Ne&&(y(Ce,G),H.push([Ce,v.clone()]))}K.push(H)}pe.push(K);let j=2*g,ae=2;for(let se=0;se<h;se++){let H=j*se,me=j*((se+1)%h),be=0,ke=[L[H]];for(let Te=1;Te<g;Te++){let Ze=L[H+Te],ze=L[me+Te];ke.push(Ze);for(let qe=1,Ne=Te-ae+1;qe<=Ne;qe++)d.lerpVectors(Ze,ze,qe/(Ne+1)),d.sub(G).setLength(k[se]).add(G),ke.push(V[be++].copy(d));ke.push(ze)}for(let Te=0;Te<g;Te++)ke.push(L[Te+g+H]);ke.push(L[me+g]);for(let Te=0,Ze=ke.length;Te<Ze;Te++){let ze=ke[Te],qe=3*Te,Ne=2*Te;D[qe]=ze.x,D[qe+1]=ze.y,D[qe+2]=ze.z,y(ze,G),O[qe]=v.x,O[qe+1]=v.y,O[qe+2]=v.z,z[Ne]=Math.atan2(ze.z,-ze.x)/2/Math.PI+.5,z[Ne+1]=1-(Math.atan2(-ze.y,Math.sqrt(ze.x*ze.x+ze.z*ze.z))/Math.PI+.5)}for(let Te=0,Ze=S.length;Te<Ze;Te++){let ze=3*S[Te],qe=2*S[Te],Ne=u/3*2;a[u]=D[ze],a[u+1]=D[ze+1],a[u+2]=D[ze+2],o[u]=O[ze],o[u+1]=O[ze+1],o[u+2]=O[ze+2],l[Ne]=z[qe],l[Ne+1]=z[qe+1],u+=3}}}let we=[];for(let re=0;re<x.length;re++)for(let Se=0;Se<h;Se++){let W=x[re][Se];if(W<w){let k=x[W].findIndex(j=>j%w==re),K=pe[re][Se],ie=pe[W][k];for(let j=0;j<g;j++){let ae=K[j],se=ie[g-j],H=K[j+1],me=ie[g-(j+1)];P(ae),P(se),P(H),P(H),P(se),P(me)}we.push(K[0][0],ie[g][0],K[g][0],ie[0][0])}}for(;we.length;){let re,Se,W,[k,K]=we.splice(0,2);re=K;let ie=[k];for(;k!=re;)ie.push(re),Se=we.indexOf(re),W=Se%2,re=we.splice(Se-W,2)[1-W];v.subVectors(ie[0],ie[1]).cross(d.subVectors(ie[0],ie[2])).normalize();let j=v.dot(ie[0])<0;j&&v.negate();for(let ae=1;ae<=ie.length-2;ae++)A(ie[ae+ +j]),A(ie[ae+1-+j]),A(ie[0])}}(),function(){let h=new R,d=new R,c=new R,p=new R,f=new Z,m=new Z,g=new Z,v=(b,x,w,S)=>{S<0&&b.x===1&&(l[x]=b.x-1),w.x===0&&w.z===0&&(l[x]=S/2/Math.PI+.5)};for(let b=0,x=0;b<u;b+=9,x+=6){h.set(a[b+0],a[b+1],a[b+2]),d.set(a[b+3],a[b+4],a[b+5]),c.set(a[b+6],a[b+7],a[b+8]),f.set(l[x+0],l[x+1]),m.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 w=_(p);v(f,x+0,h,w),v(m,x+2,d,w),v(g,x+4,c,w)}let y=u/3*2;for(let b=0;b<y;b+=6){let x=l[b+0],w=l[b+2],S=l[b+4],T=Math.max(x,w,S),M=Math.min(x,w,S);T>.9&&M<.1&&(x<.2&&(l[b+0]+=1),w<.2&&(l[b+2]+=1),S<.2&&(l[b+4]+=1))}function _(b){return Math.atan2(b.z,-b.x)}}(),this.setAttribute("position",new Rt(new Float32Array(a.subarray(0,u)),3)),this.setAttribute("normal",new Rt(new Float32Array(o.subarray(0,u)),3)),void this.setAttribute("uv",new Rt(new Float32Array(l.subarray(0,u/3*2)),2))}static fromJSON(e){return new LL(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}}}),oie=U(()=>{Lbe(),oe(),Obe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new o5(.5*t,s,a):new B7(.5*t,n),l=i/t,u=r/t;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},o5=class extends LL{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n=1/r,s="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],s,e,t,i),this.type=s}static fromJSON(e){return new o5(e.radius,e.corner,e.cornerSides)}}});function lie(e,t=new Z){let i=e.length();return t.set(-e.y/i,e.x/i)}function WLe(e){let t=new Z;t.addVectors(e.v0,ry.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(e.v2,EA.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new pu(e.v0,t,i,e.v2)}function OM(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function HLe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function qLe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function Bbe(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function $Le(e,t,i){return uie(e,t)&&uie(t,i)&&sH(e.position,t.position,i.position)}function sH(e,t,i){return ry.copy(t).sub(e).cross(EA.copy(i).sub(e))===0}function XLe(e,t,i,r,n){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,u=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,a+u),n.set(o-l,a-u),[r,n]}function YLe(e,t,i){return e.distanceTo(i)<t.distanceTo(i)?t:e}function KLe(e,t,i,r,n,s){let a,o=t.x-e.x,l=t.y-e.y,u=i.x-e.x,h=i.y-e.y,d=Math.sqrt((o+u)*(o+u)+(l+h)*(l+h));return Bbe(t,e,i)>Math.PI&&(d*=-1),a=OM(h,l)?(l+h)*(r/d-.5)*8/3/(o-u):(o+u)*(r/d-.5)*8/3/(h-l),n.set(t.x-a*l,t.y+a*o),s.set(i.x+a*h,i.y-a*u),[n,s]}function hie(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function uie(e,t){return sH(e.position,e.controls[1].position,t.position)&&sH(e.position,t.controls[0].position,t.position)}function die(e,t=12,i=!1){let r=[];for(let n=0,s=e.length;n<s;n++){let a=e[n],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*iy(a.roundedCurveCorner,t);n>0&&(r[n-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=iy(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=.5*iy(e[0].roundedCurveCorner,t)),r}function iy(e,t=12){return e&&e instanceof xM?2*t:e&&(e instanceof wh||e instanceof F7)?1:e&&e instanceof _I?t*e.points.length:t}var Ob,x3,w3,_y,II,ry,EA,Fbe,Ube,zbe,kbe,aH,oH,S3,cie,pie,fie,mie,gie,ds,Vbe=U(()=>{oe(),Ob=1e-12,x3=class{constructor(e){this.position=new Z,this.startPosition=new Z,this.uuid=ht.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new x3(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},w3=class extends x3{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new w3(this.parent).copy(this)}},_y=class extends x3{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new w3(this),new w3(this))}static create(e,t){let i=new _y(e,new Z(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let n=this.controls[i];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new _y(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Z,t=new Z){let[i,r]=this.computeTangents();return i&&r&&(lie(i,e),lie(r,t)),[e,t]}computeTangent(e=new Z){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new Z){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}},II=e=>e,ry=new Z,EA=new Z,Fbe=new Z,Ube=new Z,zbe=new Z,kbe=new Z,aH=new R,oH=new R}),e0=U(()=>{oe(),Vbe(),S3=new Z,cie=new Z,pie=new Z,fie=new Z,mie=new Z,gie=new Z,ds=class extends oA{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new $a(new R(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=ht.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new ds;return r.isClosed=e.isClosed,r.points=e.points.map(n=>_y.create(n.id,n.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(n=>ds.createFromState(n)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let n=0,s=this.shapeHoles.length;n<s;n++){let a=this.shapeHoles[n],o=a.points.length,l=a.getPointIndexById(e);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=e-t;if(s<=n.points.length-1)return n.points[s];t+=n.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=S3.set(e,t);for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,n=this.shapeHoles.length;r<n;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=ht.generateUUID()){let r;r=e instanceof Z?e:new Z(e,t);let n=new _y(i,r);return n.roundness=this.roundness,n}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(n,s,a=12,o=!0){let l,u=oH.set(0,0,0),h=0,d=[];for(let c=0;c<s.length;c++){let p=II(s[c]),f=ry,m=iy(p,a);d.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof uf||p instanceof wh){if(p.getPoint(g/m,f),u.set(f.x,f.y,0),l!==void 0&&qLe(l,u))continue;l===void 0&&(l=aH),l.copy(u),n.setXYZ(h,u.x,u.y,u.z),h++}}o&&h>1&&(n.getX(h-1)!==n.getX(0)||n.getY(h-1)!==n.getY(0)||n.getZ(h-1)!==n.getZ(0))&&(n.setXYZ(h,n.getX(0),n.getY(0),n.getZ(0)),h++)}(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=die(this.points,e,!1),this.roundedCurveDivisions=die(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return 2*function(r,n,s,a=12,o=!0){let l=oH.set(0,0,0),u=0,h=[];for(let d=0;d<n.length;d++){if(s[d]===!1)continue;let c,p=II(n[d]),f=ry,m=iy(p,a);h.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof uf||p instanceof wh){if(p.getPoint(g/m,f),l.set(f.x,f.y,0),c?.equals(l))continue;c===void 0?c=aH:(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}(e,this.curves,t,i,this.autoClose).reduce((r,n)=>r+n,0)}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),function(i,r,n=12,s=!0){let a,o=0;for(let l=0;l<r.length;l++){let u=II(r[l]),h=iy(u,n),d=ry;for(let c=0;c<=h;c++)if(u instanceof pu||u instanceof uf||u instanceof wh){if(u.getPoint(c/h,d),a!==void 0&&HLe(a,d,Ob))continue;a===void 0&&(a=EA),a.copy(d),i.push(d.x,d.y),o++}}return OM(i[0],i[i.length-2],Ob)&&OM(i[1],i[i.length-1],Ob)&&(i.pop(),i.pop()),s&&o>1&&!(OM(i[o-1],i[1],Ob)&&OM(i[o-2],i[0],Ob))&&(i.push(i[0],i[1]),o++),i}(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=.5*iy(this.points[0].roundedCurveCorner,this.subdivision));let s=e-n;s<0&&(s+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(s<i+l)return[a,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(hie(r,n)){let l=r.position.distanceTo(n.position);return r.position.distanceTo(S3.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){hie(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let n=this.points[t-1];this._applyCurveForPoint(r,n)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let n=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=n.roundness,l=s&&a&&$Le(s,n,a);if(!n.controlsMoved()&&o>0&&!l){let u=n.curveBefore,h=n.curveAfter;if(u===void 0||h===void 0)continue;let d,c=n.roundedCurveBefore,p=n.roundedCurveAfter,f=u instanceof wh?u.v1.distanceTo(u.v2):u.getLength(),m=h instanceof wh?h.v1.distanceTo(h.v2):h.getLength(),g=Math.min(o,.499*f),v=Math.min(o,.499*m),y=Math.min(g,v),_=1-y/f,b=y/m,x=u.getPointAt(_,S3),w=h.getPointAt(b,cie);if(this._subSplitCurve(u,c,_,x,void 0),this._subSplitCurve(h,p,b,void 0,w),this.useCubicForRoundedCorners){let S=Bbe(x,n.position,w)/2,T=Math.tan(S)*x.distanceTo(n.position),[M,E]=XLe(x,w,T,pie,fie),A=YLe(M,E,n.position),[P,N]=KLe(A,x,w,T,mie,gie);d=new pu(x.clone(),P.clone(),N.clone(),w.clone())}else d=new uf(x.clone(),n.position.clone(),w.clone());n.roundedCurveCorner=d,this.roundedCurves.splice(i+t,0,d),t++}}}}_subSplitCurve(e,t,i,r,n){if(!(e instanceof wh)){let s=e,a=t,o=s.getUtoTmapping(i,0),l=function(u,h,d,c,p=.5){let f=ry.subVectors(h,u).multiplyScalar(p).add(u),m=EA.subVectors(d,h).multiplyScalar(p).add(h),g=Fbe.subVectors(c,d).multiplyScalar(p).add(d),v=f,y=Ube.subVectors(m,f).multiplyScalar(p).add(f),_=zbe.subVectors(g,m).multiplyScalar(p).add(m),b=g,x=kbe.subVectors(_,y).multiplyScalar(p).add(y);return[u.x,u.y,v.x,v.y,y.x,y.y,x.x,x.y,_.x,_.y,b.x,b.y,c.x,c.y]}(s.v0,s.v1,s.v2,s.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])),n!==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&&t.v2.copy(r),n!==void 0&&t.v1.copy(n),t}clone(){let e=new ds(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=7*i,n=e.points[r+0],s=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],u=e.points[r+5],h=e.points[r+6],d=new _y(ht.generateUUID(),new Z(n,s));d.controls[0].position.set(a,o),d.controls[1].position.set(l,u),d.roundness=h,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new ds;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(r,n)=>{n instanceof pu&&n.v3.equals(r.position)&&r.controls[0].position.copy(n.v2)};return this.points=(r=>{let n,s,a=[];for(n=0,s=r.length;n<s;n++)r[n]instanceof uf&&(r[n]=WLe(r[n]));for(n=0,s=r.length;n<s;n++){let u,h=r[n],d=n>0?r[n-1]:null;h instanceof pu?(u=this.createPoint(h.v0),u.controls[1].position.copy(h.v1)):h instanceof wh&&(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 pu?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof wh&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(e.curves),e instanceof oA&&(this.shapeHoles=e.holes.map(r=>{let n=new ds;return n.fromShape(r),n})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}}});function l5({x:e,y:t},i,r,n,s){return{x:e*i+n,y:t*r+s}}function ZLe(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),n=Math.sin(e),s=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-n*i,y:n+r*i},{x:s+a*i,y:a-s*i},{x:s,y:a}]}function vie(e,t,i,r){let n=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return n*Math.acos(s)}var OI,QLe=U(()=>{OI=2*Math.PI});function Ti(e,t){if(!e)throw t||"Assertion Failed!"}function CE(e){var t=e.windingRule,i=t===void 0?es.ODD:t,r=e.elementType,n=r===void 0?So.POLYGONS:r,s=e.polySize,a=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,u=e.normal,h=u===void 0?[0,0,1]:u,d=e.contours,c=d===void 0?[]:d,p=e.strict,f=p===void 0||p,m=e.debug,g=m!==void 0&&m;if(!c&&f)throw new Error("Contours can't be empty");if(c){var v=new Gbe;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<c.length;y++)v.addContour(l||2,c[y]);return v.tesselate(i,n,a,l,h,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var es,So,fi,H1,zS,N0,h5,u5,d5,yie,T3,c5,_ie,bie,Gbe,qA=U(()=>{var e;(e=es||(es={}))[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(t){t[t.POLYGONS=0]="POLYGONS",t[t.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",t[t.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(So||(So={})),fi=function(){function t(){}return t.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},t.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},t.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},t.edgeGoesLeft=function(i){return t.vertLeq(i.Dst,i.Org)},t.edgeGoesRight=function(i){return t.vertLeq(i.Org,i.Dst)},t.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},t.edgeEval=function(i,r,n){Ti(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?s<a?r.t-i.t+(i.t-n.t)*(s/(s+a)):r.t-n.t+(n.t-i.t)*(a/(s+a)):0},t.edgeSign=function(i,r,n){Ti(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?(r.t-n.t)*s+(r.t-i.t)*a:0},t.transEval=function(i,r,n){Ti(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?s<a?r.s-i.s+(i.s-n.s)*(s/(s+a)):r.s-n.s+(n.s-i.s)*(a/(s+a)):0},t.transSign=function(i,r,n){Ti(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?(r.s-n.s)*s+(r.s-i.s)*a:0},t.vertCCW=function(i,r,n){return i.s*(r.t-n.t)+r.s*(n.t-i.t)+n.s*(i.t-r.t)>=0},t.interpolate=function(i,r,n,s){return(i=i<0?0:i)<=(n=n<0?0:n)?n===0?(r+s)/2:r+i/(i+n)*(s-r):s+n/(i+n)*(r-s)},t.intersect=function(i,r,n,s,a){var o,l,u;t.vertLeq(i,r)||(u=i,i=r,r=u),t.vertLeq(n,s)||(u=n,n=s,s=u),t.vertLeq(i,n)||(u=i,i=n,n=u,u=r,r=s,s=u),t.vertLeq(n,r)?t.vertLeq(r,s)?((o=t.edgeEval(i,n,r))+(l=t.edgeEval(n,r,s))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,r.s)):((o=t.edgeSign(i,n,r))+(l=-t.edgeSign(i,s,r))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,s.s)):a.s=(n.s+r.s)/2,t.transLeq(i,r)||(u=i,i=r,r=u),t.transLeq(n,s)||(u=n,n=s,s=u),t.transLeq(i,n)||(u=i,i=n,n=u,u=r,r=s,s=u),t.transLeq(n,r)?t.transLeq(r,s)?((o=t.transEval(i,n,r))+(l=t.transEval(n,r,s))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,r.t)):((o=t.transSign(i,n,r))+(l=-t.transSign(i,s,r))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,s.t)):a.t=(n.t+r.t)/2},t}(),H1=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},zS=function(){function t(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(t.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),t}(),N0=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},h5=function(){function t(){var i=new N0,r=new H1,n=new zS(0),s=new zS(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,n.next=n,n.Sym=s,s.next=s,s.Sym=n,this.vHead=i,this.fHead=r,this.eHead=n,this.eHeadSym=s}return t.prototype.makeEdge_=function(i){var r=new zS(0),n=new zS(1);i.Sym.side<i.side&&(i=i.Sym);var s=i.Sym.next;return n.next=s,s.Sym.next=r,r.next=i,i.Sym.next=n,r.Sym=n,r.Onext=r,r.Lnext=n,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,n.Sym=r,n.Onext=n,n.Lnext=r,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,r},t.prototype.splice_=function(i,r){var n=i.Onext,s=r.Onext;n.Sym.Lnext=r,s.Sym.Lnext=i,i.Onext=s,r.Onext=n},t.prototype.makeVertex_=function(i,r,n){var s=i;Ti(s,"Vertex can't be null!");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r;var o=r;do o.Org=s,o=o.Onext;while(o!==r)},t.prototype.makeFace_=function(i,r,n){var s=i;Ti(s,"Face can't be null");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r,s.trail=null,s.marked=!1,s.inside=n.inside;var o=r;do o.Lface=s,o=o.Lnext;while(o!==r)},t.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,n=i.Sym.next;r.Sym.next=n,n.Sym.next=r},t.prototype.killVertex_=function(i,r){var n=i.anEdge,s=n;do s.Org=r,s=s.Onext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.killFace_=function(i,r){var n=i.anEdge,s=n;do s.Lface=r,s=s.Lnext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.makeEdge=function(){var i=new N0,r=new N0,n=new H1,s=this.makeEdge_(this.eHead);return this.makeVertex_(i,s,this.vHead),this.makeVertex_(r,s.Sym,this.vHead),this.makeFace_(n,s,this.fHead),s},t.prototype.splice=function(i,r){var n=!1,s=!1;if(i!==r){if(r.Org!==i.Org&&(s=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!s){var a=new N0;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!n){var o=new H1;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},t.prototype.delete=function(i){var r=i.Sym,n=!1;if(i.Lface!==i.Rface&&(n=!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),!n){var s=new H1;this.makeFace_(s,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)},t.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),n=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var s=new N0;return this.makeVertex_(s,n,r.Org),r.Lface=n.Lface=i.Lface,r},t.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},t.prototype.connect=function(i,r){var n=!1,s=this.makeEdge_(i),a=s.Sym;if(r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(s,i.Lnext),this.splice_(a,r),s.Org=i.Dst,a.Org=r.Org,s.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!n){var o=new H1;this.makeFace_(o,s,i.Lface)}return s},t.prototype.zapFace=function(i){var r,n,s,a,o,l=i.anEdge;n=l.Lnext;do n=(r=n).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)),(s=r.Sym).Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},t.prototype.countFaceVerts_=function(i){var r=i.anEdge,n=0;do n++,r=r.Lnext;while(r!==i.anEdge);return n},t.prototype.mergeConvexFaces=function(i){var r,n,s,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(n=r.anEdge).Org;s=n.Lnext,(a=n.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&fi.vertCCW(n.Lprev.Org,n.Org,a.Lnext.Lnext.Org)&&fi.vertCCW(a.Lprev.Org,a.Org,n.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),n=null,a=null),!n||n.Lnext.Org!==o;)n=s;return!0},t.prototype.check=function(){var i,r,n,s,a,o,l=this.fHead,u=this.vHead,h=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Ti(i.prev===r),a=i.anEdge;do Ti(a.Sym!==a),Ti(a.Sym.Sym===a),Ti(a.Lnext.Onext.Sym===a),Ti(a.Onext.Sym.Lnext===a),Ti(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Ti(i.prev===r&&i.anEdge===null),s=u,s=u;(n=s.next)!==u;s=n){Ti(n.prev===s),a=n.anEdge;do Ti(a.Sym!==a),Ti(a.Sym.Sym===a),Ti(a.Lnext.Onext.Sym===a),Ti(a.Onext.Sym.Lnext===a),Ti(a.Org===n),a=a.Onext;while(a!==n.anEdge)}for(Ti(n.prev===s&&n.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)Ti(a.Sym.next===o.Sym),Ti(a.Sym!==a),Ti(a.Sym.Sym===a),Ti(a.Org!==null),Ti(a.Dst!==null),Ti(a.Lnext.Onext.Sym===a),Ti(a.Onext.Sym.Lnext===a);Ti(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)},t}(),u5=function(){this.handle=null},d5=function(){this.key=null,this.node=0},yie=function(){function t(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 n=0;n<i+1;n++)this.nodes[n]=new u5,this.handles[n]=new d5;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return t.prototype.floatDown_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((s=i<<1)<this.size&&this.leq(o[a[s+1].handle].key,o[a[s].handle].key)&&++s,Ti(s<=this.max),n=a[s].handle,s>this.size||this.leq(o[r].key,o[n].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.floatUp_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(n=a[s=i>>1].handle,s===0||this.leq(o[n].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},t.prototype.min=function(){return this.handles[this.nodes[1].handle].key},t.prototype.insert=function(i){var r,n;if(2*(r=++this.size)>this.max){var s,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new u5;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new d5}return this.freeList===0?n=r:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[r].handle=n,this.handles[n].node=r,this.handles[n].key=i,this.initialized&&this.floatUp_(r),n},t.prototype.extractMin=function(){var i=this.nodes,r=this.handles,n=i[1].handle,s=r[n].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[n].key=null,r[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),s},t.prototype.delete=function(i){var r,n=this.nodes,s=this.handles;Ti(i>=1&&i<=this.max&&s[i].key!==null),n[r=s[i].node].handle=n[this.size].handle,s[n[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(s[n[r>>1].handle].key,s[n[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),s[i].key=null,s[i].node=this.freeList,this.freeList=i},t}(),T3=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},c5=function(){this.key=null,this.next=null,this.prev=null},_ie=function(){function t(i,r){this.frame=i,this.leq=r,this.head=new c5,this.head.next=this.head,this.head.prev=this.head}return t.prototype.min=function(){return this.head.next},t.prototype.max=function(){return this.head.prev},t.prototype.insert=function(i){return this.insertBefore(this.head,i)},t.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},t.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var n=new c5;return n.key=r,n.next=i.next,i.next.prev=n,n.prev=i,i.next=n,n},t.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},t}(),bie=function(){function t(){}return t.regionBelow=function(i){return i.nodeUp.prev.key},t.regionAbove=function(i){return i.nodeUp.next.key},t.debugEvent=function(i){},t.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.edgeLeq=function(i,r,n){var s=i.event,a=r.eUp,o=n.eUp;return a.Dst===s?o.Dst===s?fi.vertLeq(a.Org,o.Org)?fi.edgeSign(o.Dst,a.Org,o.Org)<=0:fi.edgeSign(a.Dst,o.Org,a.Org)>=0:fi.edgeSign(o.Dst,s,o.Org)<=0:o.Dst===s?fi.edgeSign(a.Dst,s,a.Org)>=0:fi.edgeEval(a.Dst,s,a.Org)>=fi.edgeEval(o.Dst,s,o.Org)},t.deleteRegion=function(i,r){r.fixUpperEdge&&Ti(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},t.fixUpperEdge=function(i,r,n){Ti(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=n,n.activeRegion=r},t.topLeftRegion=function(i,r){var n,s=r.eUp.Org;do r=t.regionAbove(r);while(r.eUp.Org===s);if(r.fixUpperEdge){if((n=i.mesh.connect(t.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;t.fixUpperEdge(i,r,n),r=t.regionAbove(r)}return r},t.topRightRegion=function(i){var r=i.eUp.Dst;do i=t.regionAbove(i);while(i.eUp.Dst===r);return i},t.addRegionBelow=function(i,r,n){var s=new T3;return s.eUp=n,s.nodeUp=i.dict.insertBefore(r.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,n.activeRegion=s,s},t.isWindingInside=function(i,r){switch(i.windingRule){case es.ODD:return!!(1&r);case es.NONZERO:return r!==0;case es.POSITIVE:return r>0;case es.NEGATIVE:return r<0;case es.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},t.computeWinding=function(i,r){r.windingNumber=t.regionAbove(r).windingNumber+r.eUp.winding,r.inside=t.isWindingInside(i,r.windingNumber)},t.finishRegion=function(i,r){var n=r.eUp,s=n.Lface;s.inside=r.inside,s.anEdge=n,t.deleteRegion(i,r)},t.finishLeftRegions=function(i,r,n){for(var s,a=null,o=r,l=r.eUp;o!==n;){if(o.fixUpperEdge=!1,(s=(a=t.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){t.finishRegion(i,o);break}s=i.mesh.connect(l.Lprev,s.Sym),t.fixUpperEdge(i,a,s)}l.Onext!==s&&(i.mesh.splice(s.Oprev,s),i.mesh.splice(l,s)),t.finishRegion(i,o),l=a.eUp,o=a}return l},t.addRightEdges=function(i,r,n,s,a,o){var l,u,h,d,c=!0;h=n;do Ti(fi.vertLeq(h.Org,h.Dst)),t.addRegionBelow(i,r,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=t.regionBelow(r).eUp.Rprev),u=r,d=a;(h=(l=t.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=t.isWindingInside(i,l.windingNumber),u.dirty=!0,!c&&t.checkForRightSplice(i,u)&&(t.addWinding(h,d),t.deleteRegion(i,u),i.mesh.delete(d)),c=!1,u=l,d=h;u.dirty=!0,Ti(u.windingNumber-h.winding===l.windingNumber),o&&t.walkDirtyRegions(i,u)},t.spliceMergeVertices=function(i,r,n){i.mesh.splice(r,n)},t.vertexWeights=function(i,r,n){var s=fi.vertL1dist(r,i),a=fi.vertL1dist(n,i),o=.5*a/(s+a),l=.5*s/(s+a);i.coords[0]+=o*r.coords[0]+l*n.coords[0],i.coords[1]+=o*r.coords[1]+l*n.coords[1],i.coords[2]+=o*r.coords[2]+l*n.coords[2]},t.getIntersectData=function(i,r,n,s,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,t.vertexWeights(r,n,s),t.vertexWeights(r,a,o)},t.checkForRightSplice=function(i,r){var n=t.regionBelow(r),s=r.eUp,a=n.eUp;if(fi.vertLeq(s.Org,a.Org)){if(fi.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;fi.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(i.pq.delete(s.Org.pqHandle),t.spliceMergeVertices(i,a.Oprev,s)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(s,a.Oprev),r.dirty=n.dirty=!0)}else{if(fi.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(s.Sym),i.mesh.splice(a.Oprev,s)}return!0},t.checkForLeftSplice=function(i,r){var n,s=t.regionBelow(r),a=r.eUp,o=s.eUp;if(Ti(!fi.vertEq(a.Dst,o.Dst)),fi.vertLeq(a.Dst,o.Dst)){if(fi.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,n=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,n),n.Lface.inside=r.inside}else{if(fi.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=s.dirty=!0,n=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),n.Rface.inside=r.inside}return!0},t.checkForIntersect=function(i,r){var n,s,a=t.regionBelow(r),o=r.eUp,l=a.eUp,u=o.Org,h=l.Org,d=o.Dst,c=l.Dst,p=new N0;if(Ti(!fi.vertEq(c,d)),Ti(fi.edgeSign(d,i.event,u)<=0),Ti(fi.edgeSign(c,i.event,h)>=0),Ti(u!==i.event&&h!==i.event),Ti(!r.fixUpperEdge&&!a.fixUpperEdge),u===h||Math.min(u.t,d.t)>Math.max(h.t,c.t))return!1;if(fi.vertLeq(u,h)){if(fi.edgeSign(c,u,h)>0)return!1}else if(fi.edgeSign(d,h,u)<0)return!1;return t.debugEvent(i),fi.intersect(d,u,c,h,p),Ti(Math.min(u.t,d.t)<=p.t),Ti(p.t<=Math.max(h.t,c.t)),Ti(Math.min(c.s,d.s)<=p.s),Ti(p.s<=Math.max(h.s,u.s)),fi.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),n=fi.vertLeq(u,h)?u:h,fi.vertLeq(n,p)&&(p.s=n.s,p.t=n.t),fi.vertEq(p,u)||fi.vertEq(p,h)?(t.checkForRightSplice(i,r),!1):!fi.vertEq(d,i.event)&&fi.edgeSign(d,i.event,p)>=0||!fi.vertEq(c,i.event)&&fi.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=t.topLeftRegion(i,r),o=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),a),t.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=t.topRightRegion(r),s=t.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=t.finishLeftRegions(i,a,null),t.addRightEdges(i,r,l.Onext,o.Rprev,s,!0),!0):(fi.edgeSign(d,i.event,p)>=0&&(t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),fi.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),t.getIntersectData(i,o.Org,u,d,h,c),t.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},t.walkDirtyRegions=function(i,r){for(var n,s,a=t.regionBelow(r);;){for(;a.dirty;)r=a,a=t.regionBelow(a);if(!r.dirty&&(a=r,(r=t.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,n=r.eUp,s=a.eUp,n.Dst!==s.Dst&&t.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(t.deleteRegion(i,a),i.mesh.delete(s),s=(a=t.regionBelow(r)).eUp):r.fixUpperEdge&&(t.deleteRegion(i,r),i.mesh.delete(n),n=(r=t.regionAbove(a)).eUp)),n.Org!==s.Org){if(n.Dst===s.Dst||r.fixUpperEdge||a.fixUpperEdge||n.Dst!==i.event&&s.Dst!==i.event)t.checkForRightSplice(i,r);else if(t.checkForIntersect(i,r))return}n.Org===s.Org&&n.Dst===s.Dst&&(t.addWinding(s,n),t.deleteRegion(i,r),i.mesh.delete(n),r=t.regionAbove(a))}},t.connectRightVertex=function(i,r,n){var s,a=n.Onext,o=t.regionBelow(r),l=r.eUp,u=o.eUp,h=!1;l.Dst!==u.Dst&&t.checkForIntersect(i,r),fi.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=t.topLeftRegion(i,r),a=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),o),h=!0),fi.vertEq(u.Org,i.event)&&(i.mesh.splice(n,u.Oprev),n=t.finishLeftRegions(i,o,null),h=!0),h?t.addRightEdges(i,r,n.Onext,a,a,!0):(s=fi.vertLeq(u.Org,l.Org)?u.Oprev:l,s=i.mesh.connect(n.Lprev,s),t.addRightEdges(i,r,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,t.walkDirtyRegions(i,r))},t.connectLeftDegenerate=function(i,r,n){var s,a,o,l,u;return s=r.eUp,fi.vertEq(s.Org,n)?(Ti(!1),void t.spliceMergeVertices(i,s,n.anEdge)):fi.vertEq(s.Dst,n)?(Ti(!1),r=t.topRightRegion(r),a=l=(o=(u=t.regionBelow(r)).eUp.Sym).Onext,u.fixUpperEdge&&(Ti(a!==o),t.deleteRegion(i,u),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(n.anEdge,o),fi.edgeGoesLeft(a)||(a=null),void t.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(s.Sym),r.fixUpperEdge&&(i.mesh.delete(s.Onext),r.fixUpperEdge=!1),i.mesh.splice(n.anEdge,s),void t.sweepEvent(i,n))},t.connectLeftVertex=function(i,r){var n,s,a,o,l,u,h=new T3;if(h.eUp=r.anEdge.Sym,n=i.dict.search(h).key,s=t.regionBelow(n)){if(o=n.eUp,l=s.eUp,fi.edgeSign(o.Dst,r,o.Org)===0)return void t.connectLeftDegenerate(i,n,r);a=fi.vertLeq(l.Dst,o.Dst)?n:s,n.inside||a.fixUpperEdge?(u=a===n?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?t.fixUpperEdge(i,a,u):t.computeWinding(i,t.addRegionBelow(i,n,u)),t.sweepEvent(i,r)):t.addRightEdges(i,n,r.anEdge,r.anEdge,null,!0)}},t.sweepEvent=function(i,r){i.event=r,t.debugEvent(i);for(var n=r.anEdge;n.activeRegion===null;)if((n=n.Onext)===r.anEdge)return void t.connectLeftVertex(i,r);var s=t.topLeftRegion(i,n.activeRegion);Ti(s!==null);var a=t.regionBelow(s),o=a.eUp,l=t.finishLeftRegions(i,a,null);l.Onext===o?t.connectRightVertex(i,s,l):t.addRightEdges(i,s,l.Onext,o,o,!0)},t.addSentinel=function(i,r,n,s){var a=new T3,o=i.mesh.makeEdge();o.Org.s=n,o.Org.t=s,o.Dst.s=r,o.Dst.t=s,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},t.initEdgeDict=function(i){i.dict=new _ie(i,t.edgeLeq);var r=i.bmax[0]-i.bmin[0],n=i.bmax[1]-i.bmin[1],s=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-n,l=i.bmax[1]+n;t.addSentinel(i,s,a,o),t.addSentinel(i,s,a,l)},t.doneEdgeDict=function(i){for(var r,n=0;(r=i.dict.min().key)!==null;)r.sentinel||(Ti(r.fixUpperEdge),Ti(++n===1)),Ti(r.windingNumber===0),t.deleteRegion(i,r)},t.removeDegenerateEdges=function(i){var r,n,s,a=i.mesh.eHead;for(r=a.next;r!==a;r=n)n=r.next,s=r.Lnext,fi.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(t.spliceMergeVertices(i,s,r),i.mesh.delete(r),s=(r=s).Lnext),s.Lnext===r&&(s!==r&&((s===n||s===n.Sym)&&(n=n.next),i.mesh.delete(s)),(r===n||r===n.Sym)&&(n=n.next),i.mesh.delete(r))},t.initPriorityQ=function(i){var r,n,s,a=0;for(n=(s=i.mesh.vHead).next;n!==s;n=n.next)a++;for(a+=8,r=i.pq=new yie(a,fi.vertLeq),n=(s=i.mesh.vHead).next;n!==s;n=n.next)n.pqHandle=r.insert(n);return n===s&&(r.init(),!0)},t.donePriorityQ=function(i){i.pq=null},t.removeDegenerateFaces=function(i,r){var n,s,a;for(n=r.fHead.next;n!==r.fHead;n=s)s=n.next,Ti((a=n.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(t.addWinding(a.Onext,a),i.mesh.delete(a));return!0},t.computeInterior=function(i,r){var n,s;if(r===void 0&&(r=!0),t.removeDegenerateEdges(i),!t.initPriorityQ(i))return!1;for(t.initEdgeDict(i);(n=i.pq.extractMin())!==null;){for(;(s=i.pq.min())!==null&&fi.vertEq(s,n);)s=i.pq.extractMin(),t.spliceMergeVertices(i,n.anEdge,s.anEdge);t.sweepEvent(i,n)}return i.event=i.dict.min().key.eUp.Org,t.debugEvent(i),t.doneEdgeDict(i),t.donePriorityQ(i),!!t.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},t}(),Gbe=function(){function t(){this.mesh=new h5,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=es.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 t.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},t.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},t.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},t.prototype.computeNormal_=function(i){var r,n,s,a,o,l,u=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],g=this.mesh.vHead;r=g.next;for(var v=0;v<3;++v)a=r.coords[v],h[v]=a,m[v]=r,u[v]=a,f[v]=r;for(r=g.next;r!==g;r=r.next)for(var y=0;y<3;++y)(a=r.coords[y])<h[y]&&(h[y]=a,m[y]=r),a>u[y]&&(u[y]=a,f[y]=r);var _=0;if(u[1]-h[1]>u[0]-h[0]&&(_=1),u[2]-h[2]>u[_]-h[_]&&(_=2),h[_]>=u[_])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,n=m[_],s=f[_],d[0]=n.coords[0]-s.coords[0],d[1]=n.coords[1]-s.coords[1],d[2]=n.coords[2]-s.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.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)},t.prototype.checkOrientation_=function(){for(var i,r,n=this.mesh.fHead,s=this.mesh.vHead,a=0,o=n.next;o!==n;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=s.next;i!==s;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},t.prototype.projectPolygon_=function(){var i,r,n=this.mesh.vHead,s=[0,0,0],a=!1;s[0]=this.normal[0],s[1]=this.normal[1],s[2]=this.normal[2],!s[0]&&!s[1]&&!s[2]&&(this.computeNormal_(s),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(s);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]=s[o]>0?1:-1;for(var l=n.next;l!==n;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=n.next;h!==n;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))},t.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.prototype.tessellateMonoRegion_=function(i,r){var n,s;if((n=r.anEdge).Lnext===n||n.Lnext.Lnext===n)throw"Mono region invalid";for(;fi.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;fi.vertLeq(n.Org,n.Dst);n=n.Lnext);for(s=n.Lprev;n.Lnext!==s;)if(fi.vertLeq(n.Dst,s.Org)){for(;s.Lnext!==n&&(fi.edgeGoesLeft(s.Lnext)||fi.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)s=i.connect(s.Lnext,s).Sym;s=s.Lprev}else{for(;s.Lnext!==n&&(fi.edgeGoesRight(n.Lprev)||fi.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)n=i.connect(n,n.Lprev).Sym;n=n.Lnext}if(s.Lnext===n)throw"Mono region invalid";for(;s.Lnext.Lnext!==n;)s=i.connect(s.Lnext,s).Sym;return!0},t.prototype.tessellateInterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)if(r=n.next,n.inside&&!this.tessellateMonoRegion_(i,n))return!1;return!0},t.prototype.discardExterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)r=n.next,n.inside||i.zapFace(n)},t.prototype.setWindingNumber_=function(i,r,n){for(var s,a=i.eHead.next;a!==i.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:n?i.delete(a):a.winding=0},t.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},t.prototype.outputPolymesh_=function(i,r,n,s){var a,o,l=0,u=0;n>3&&i.mergeConvexFaces(n);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>n)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===So.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*n,this.vertexCount=u,this.vertices=[],this.vertices.length=u*s,this.vertexIndices=[],this.vertexIndices.length=u,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>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 f=o;f<n;++f)this.elements[p++]=-1;if(r===So.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<n;++m)this.elements[p++]=-1}}},t.prototype.outputContours_=function(i,r){var n,s,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){s=n=l.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==s);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,s=n=l.anEdge;do this.vertices[u++]=n.Org.coords[0],this.vertices[u++]=n.Org.coords[1],r>2&&(this.vertices[u++]=n.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==s);this.elements[d++]=a,this.elements[d++]=o,a+=o}},t.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new h5),i<2&&(i=2),i>3&&(i=3);for(var n=null,s=0;s<r.length;s+=i)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=r[s+0],n.Org.coords[1]=r[s+1],n.Org.coords[2]=i>2?r[s+2]:0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},t.prototype.tesselate=function(i,r,n,s,a,o){if(i===void 0&&(i=es.ODD),r===void 0&&(r=So.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),bie.computeInterior(this,o);var l=this.mesh;return r===So.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===So.BOUNDARY_CONTOURS?this.outputContours_(l,s):this.outputPolymesh_(l,r,n,s),!0},t}(),es.ODD,es.NONZERO,es.POSITIVE,es.NEGATIVE,es.ABS_GEQ_TWO,So.POLYGONS,So.CONNECTED_POLYGONS,So.BOUNDARY_CONTOURS});function jbe(e,t){let i=e.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let u=(l+1)%i;r+=e[2*l]*e[2*u+1]-e[2*u]*e[2*l+1]}let n=r>0!==t?1:-1,s=[];for(let l=0;l<i;l++){let u=(l+1)%i,h=e[2*u]-e[2*l],d=e[2*u+1]-e[2*l+1],c=Math.hypot(h,d);s.push(c>0?[n*d/c,-n*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 s.map((l,u)=>[o(l,s[(u+i-1)%i]),o(l,s[(u+1)%i])])}function Wbe(e,t,i){let r=e.length/2,n=new Float32Array(r+1);if(!(t>0)||!(i>0)||r<2)return{u:n,vScale:0};let s=0;for(let a=0;a<r;a++){let o=(a+1)%r;s+=Math.hypot((e[2*o]-e[2*a])/t,(e[2*o+1]-e[2*a+1])/i),n[a+1]=s}return{u:n,vScale:Math.sqrt(t*i)}}function Hbe(e,t,i){for(let r=0;r<i.length;r+=3){let n=3*i[r],s=3*i[r+1],a=3*i[r+2],o=e[s]-e[n],l=e[s+1]-e[n+1],u=e[s+2]-e[n+2],h=e[a]-e[n],d=e[a+1]-e[n+1],c=e[a+2]-e[n+2],p=u*h-o*c,f=o*d-l*h;if((l*c-u*d)*(t[n]+t[s]+t[a])+p*(t[n+1]+t[s+1]+t[a+1])+f*(t[n+2]+t[s+2]+t[a+2])<0){let m=i[r+1];i[r+1]=i[r+2],i[r+2]=m}}}var fY,qbe,mY,$be=U(()=>{}),gY=U(()=>{fY={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},qbe={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},mY={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 Xbe(e,t){return e.normals[3*t+2]<.9999}function Ybe(e){let t=lH.get(e);if(t!==void 0)return t;if(!(e.rise>0))return e;let i=new Float32Array(e.normals),r=e.positions.length/3;for(let s=0;s<r;s++){if(!Xbe(e,s))continue;let a=i[3*s],o=i[3*s+1],l=Math.hypot(a,o);if(l===0)continue;let u=e.rise-e.positions[3*s+2],h=Math.min(1,Math.max(0,1-u/e.rise)),d=Math.sqrt(1-h*h);i[3*s]=a/l*d,i[3*s+1]=o/l*d,i[3*s+2]=h}let n={...e,normals:i};return lH.set(e,n),n}function Kbe(e,t,i,r){let n=(t-e.minX)/e.spanX,s=(i-e.minY)/e.spanY;return r?[s,n]:[n,s]}var lH,FL,hH,vY=U(()=>{lH=new WeakMap}),JLe=U(()=>{oe(),qA(),Gr(),$be(),gY(),vY(),FL=class extends At{constructor(e,t,i=12,r=es.ODD,n,s=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=e,this._depth=t,this._curveSegments=i,this._windingRule=r,this._uvPitch=s?void 0:n,this._legacy=s;let a,o=[e.extractShapePointsToFlatArray([],i),...e.shapeHoles.map(L=>L.extractShapePointsToFlatArray([],i))];try{a=CE({contours:o,windingRule:r,elementType:So.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=mY}let l=a?.vertexCount??0,u=a?.elementCount??0,h=1/0,d=1/0,c=-1/0,p=-1/0;for(let L of o)for(let V=0;V<L.length;V+=2)L[V]<h&&(h=L[V]),L[V]>c&&(c=L[V]),L[V+1]<d&&(d=L[V+1]),L[V+1]>p&&(p=L[V+1]);let f=this._uvPitch,m=f??(c-h||1),g=f??(p-d||1),v=f===void 0?h:0,y=f===void 0?d:0,_=o.map((L,V)=>jbe(L,V>0)),b=0;for(let L of _)b+=L.length;let x=2*l+4*b,w=3*u*2+6*b,S=new Float32Array(3*x),T=new Float32Array(3*x),M=new Float32Array(2*x),E=new Uint32Array(w),A=new Uint8Array(x),P=0,N=0,D=0,O=!1,z=(L,V,G,Y,$,Q,ue=(L-v)/m,pe=(V-y)/g)=>{let xe=3*N;S[xe]=L,S[xe+1]=V,S[xe+2]=G,T[xe]=Y,T[xe+1]=$,T[xe+2]=Q,A[N]=G===t?O?2:1:0,M[2*N]=ue,M[2*N+1]=pe,N++};if(a!==void 0)for(let[L,V]of[[t,1],[0,-1]]){let G=N;for(let Y=0;Y<l;Y++)z(a.vertices[2*Y],a.vertices[2*Y+1],L,0,0,V);for(let Y=0;Y<u;Y++){let[$,Q,ue]=[a.elements[3*Y],a.elements[3*Y+1],a.elements[3*Y+2]];E[D++]=G+$,E[D++]=G+(V>0?Q:ue),E[D++]=G+(V>0?ue:Q)}}O=!0;for(let L=0;L<o.length;L++){let V=o[L],G=_[L],Y=V.length/2,{u:$,vScale:Q}=s?{u:new Float32Array(Y+1),vScale:0}:Wbe(V,m,g);P=Q;let ue=Q===0?0:t/Q,pe={minX:v,minY:y,spanX:m,spanY:g},xe=(we,[re,Se],W,k)=>{let K=V[2*we],ie=V[2*we+1],[j,ae]=s?Kbe(pe,K,ie,W):[k,W?0:ue];z(K,ie,W?0:t,re,Se,0,j,ae)};for(let we=0;we<G.length;we++){let re=(we+1)%Y,[Se,W]=G[we],[k,K]=[$[we],$[we+1]],ie=N;xe(we,Se,!1,k),xe(we,Se,!0,k),xe(re,W,!1,K),xe(re,W,!0,K),E[D++]=ie,E[D++]=ie+1,E[D++]=ie+2,E[D++]=ie+3,E[D++]=ie+2,E[D++]=ie+1}}Hbe(S,T,E),this.setAttribute("position",new Rt(S,3)),this.setAttribute("normal",new Rt(T,3)),this.setAttribute("uv",new Rt(M,2)),this.setIndex(new Rt(E,1)),this._nearSide=A,this._vScale=P}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale)}canShiftDepthTo(e){return this._nearSide.length>0&&this._depth>0&&e>0}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=t,u===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=new FL(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return e.userData=W4(this.userData),e}}}),Zbe=U(()=>{oe(),qA(),Gr(),gY(),hH=class extends At{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=es.ODD,this.elementType=So.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:es.ODD,elementType:So.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,n,s,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 f=2*c,m=a[f+0],g=a[f+1];if(n!==void 0&&m!==n&&(l=!1),s!==void 0&&g!==s&&(u=!1),n=m,s=g,!l&&!u)break}if(!l&&!u)try{r=CE({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=fY}let h=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new Rt(new Float32Array(3*h),3),this._normalAttribute=new Rt(new Float32Array(3*h),3),this._uvAttribute=new Rt(new Float32Array(2*h),2),this._indexAttribute=new Rt(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,_=h;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1];x<c&&(c=x),x>p&&(p=x),w<f&&(f=w),w>m&&(m=w)}let g=p-c,v=m-f;for(let y=0,_=h;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1],S=(x-c)/g,T=(w-f)/v;this._positionAttribute.setXYZ(y,x,w,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,T)}for(let y=0,_=d;y<_;y++){let b=3*y,x=r.elements[b+0],w=r.elements[b+1],S=r.elements[b+2];this._indexAttribute.setX(b+0,x),this._indexAttribute.setX(b+1,w),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let e=new hH(this._shape,this._curveSegments);return e.userData=W4(this.userData),e}}});function e4e(e){return xie||(xie=async function(){let t=e??"https://unpkg.com/@splinetool/runtime@2.0.82/build",i=Promise.resolve().then(()=>(TZ(),SZ)),[r,n]=await Promise.all([i,fetch(`${t}/bevel.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),$A=r}())}function t4e(e){let t=!1;return e.scene.objects.traverse((i,r)=>{let n=r.geometry;if(n!==void 0&&(txe.has(n.type)&&n.depth!==void 0&&n.depth>0&&(n.extrudeBevelSize??0)>0&&(t=!0),n.type==="PathGeometry")){let s=n.extrusion;s!==void 0&&s.capType==="round"&&(s.bevel??0)>0&&(t=!0)}}),t}function Qbe(e,t){let i=[e.extractShapePointsToFlatArray([],t)];for(let o of e.shapeHoles)i.push(o.extractShapePointsToFlatArray([],t));let r=0;for(let o of i)r+=o.length>>1;let n=new Float64Array(2*r),s=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)n.set(i[o],2*a),a+=i[o].length>>1,s[o]=a;return{points:n,ends:s}}function UL(e,t,i,r,n,s){let a=e.positions.length/3,o=n.elements,l=ixe.getNormalMatrix(n).elements;for(let h=0;h<a;h++){let d=3*h,c=3*(i+h),p=e.positions[d],f=e.positions[d+1],m=e.positions[d+2];t.positions[c]=o[0]*p+o[4]*f+o[8]*m+o[12],t.positions[c+1]=o[1]*p+o[5]*f+o[9]*m+o[13],t.positions[c+2]=o[2]*p+o[6]*f+o[10]*m+o[14];let g=e.normals[d],v=e.normals[d+1],y=e.normals[d+2];t.normals[c]=l[0]*g+l[3]*v+l[6]*y,t.normals[c+1]=l[1]*g+l[4]*v+l[7]*y,t.normals[c+2]=l[2]*g+l[5]*v+l[8]*y;let _=2*(i+h);if(s===void 0)t.uvs[_]=e.uvs[2*h],t.uvs[_+1]=e.uvs[2*h+1];else{let[b,x]=s(p,f,e.uvs[2*h],e.uvs[2*h+1],h);t.uvs[_]=b,t.uvs[_+1]=x}}let u=n.determinant()<0;for(let h=0;h<e.indices.length;h+=3)t.indices[r+h]=e.indices[h]+i,t.indices[r+h+1]=e.indices[h+(u?2:1)]+i,t.indices[r+h+2]=e.indices[h+(u?1:2)]+i}function Jbe(e){let{owner:t,shape:i,curveSegments:r,assembledAt:n,bevel:s,bevelSegments:a}=e,o=function(c,p){let f=[p],m=g=>{f.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let v of g.points){f.push(v.roundness??0,v.position.x,v.position.y);for(let y of v.controls)f.push(y.position.x,y.position.y)}f.push(g.shapeHoles.length);for(let v of g.shapeHoles)m(v)};return m(c),function(g){let v=2166136261;for(let y=0;y<g.length;y++)v^=g[y],v=Math.imul(v,16777619)>>>0;return v}(new Uint8Array(new Float64Array(f).buffer))}(i,r),l=t??`outline:${o}`,u=`${s}/${a}`,h=zL.get(l);if(h!==void 0&&h.outlineVersion===o&&h.capKey===u&&(e.stillServes?.(h)??1))return uH.placements++,h.cap;let d=function(c,p,f,m,g){let{points:v,ends:y}=Qbe(c,p);return $A.assemble_cap(v,y,f,m,0,Math.max(1,Math.floor(g)),exe,40)}(i,r,n,s,a);uH.assemblies++;try{let c=function(p,f){return function(m,g,v,y,_){let b=1/0;for(let x=2;x<m.length;x+=3)m[x]<b&&(b=m[x]);if(b===1/0&&(b=0),b!==0)for(let x=2;x<m.length;x+=3)m[x]-=b;return{positions:m,normals:g,uvs:v,indices:y,rise:_-b}}(p.positions(),p.normals(),p.uvs(),p.indices(),f)}(d,n);return zL.set(l,{outlineVersion:o,capKey:u,assembledAt:n,cap:c}),c}finally{d.free()}}function ix(e,t){return .5*t>1.001*e}var $A,exe,xie,txe,ixe,wie,Sie,Tie,zL,uH,dH,t0,_w=U(()=>{oe(),Gr(),$be(),vY(),exe=.4,txe=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),ixe=new oi,wie=new Ue,Sie=new Ue,Tie=new Ue().makeScale(1,1,-1),zL=new Map,uH={assemblies:0,placements:0},dH=class extends At{constructor(e,t,i=0,r=12,n=3,s,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,$A===void 0)throw new Error("bevel-wasm is not loaded");this._shape=e,this._uvPitch=a,this._legacy=o,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegments=n,this._ownerId=s,this.rebuild()}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length>0&&ix(this._effectiveBevel,e)&&ix(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=t,u===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}setDepth(e){e!==this._depth&&(this._depth=e,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let e=Jbe({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>ix(a.cap.rise,this._depth)&&ix(a.cap.rise,a.assembledAt)}),t=function(a,o,l,u,h,d=!1){let c=u.positions.length/3,p=l-u.rise,f=u.rise,{points:m,ends:g}=Qbe(a,o),v=1/0,y=1/0,_=-1/0,b=-1/0;for(let pe=0;pe<m.length;pe+=2)m[pe]<v&&(v=m[pe]),m[pe]>_&&(_=m[pe]),m[pe+1]<y&&(y=m[pe+1]),m[pe+1]>b&&(b=m[pe+1]);d&&(h=void 0);let x=h??_-v,w=h??b-y,S={minX:v,minY:y,spanX:_-v||1,spanY:b-y||1},T=[],M=0;for(let pe of g)T.push({at:M,count:pe-M}),M=pe;let E=0;for(let pe of T)E+=pe.count;let A=2*c+4*E,P=new Float32Array(3*A),N=new Float32Array(3*A),D=new Float32Array(2*A),O=new Uint32Array(2*u.indices.length+6*E),z=new Uint8Array(A),L=0,V=h===void 0?void 0:(pe,xe)=>[pe/h,xe/h],G=d?(pe,xe,we,re,Se)=>Xbe(u,Se)?[re,we]:[we,re]:V,Y=d?Ybe(u):u,$={positions:P,normals:N,uvs:D,indices:O};UL(Y,$,0,0,wie.makeTranslation(0,0,p),V),UL(Y,$,c,u.indices.length,Sie.makeTranslation(0,0,f).multiply(Tie),G),z.fill(1,0,c);let Q=2*c,ue=2*u.indices.length;for(let pe=0;pe<T.length;pe++){let{at:xe,count:we}=T[pe],re=m.subarray(2*xe,2*(xe+we)),Se=jbe(re,pe>0),W=d?{u:new Float32Array(we+1),vScale:0}:Wbe(re,x,w),k=W.u;L=W.vScale;for(let K=0;K<we;K++){let ie=(K+1)%we,[j,ae]=Se[K],se=Q;for(let[H,me,be,ke,Te,Ze]of[[re[2*K],re[2*K+1],j,p,k[K],2],[re[2*ie],re[2*ie+1],ae,p,k[K+1],2],[re[2*ie],re[2*ie+1],ae,f,k[K+1],0],[re[2*K],re[2*K+1],j,f,k[K],0]]){let ze=3*Q;if(P[ze]=H,P[ze+1]=me,P[ze+2]=ke,N[ze]=be[0],N[ze+1]=be[1],N[ze+2]=0,d){let[qe,Ne]=Kbe(S,H,me,Ze===0);D[2*Q]=qe,D[2*Q+1]=Ne}else D[2*Q]=Te,D[2*Q+1]=L===0?0:(ke-f)/L;z[Q]=Ze,Q++}O[ue++]=se,O[ue++]=se+1,O[ue++]=se+2,O[ue++]=se,O[ue++]=se+2,O[ue++]=se+3}}return Hbe(P,N,O),{positions:P,normals:N,uvs:D,indices:O,nearSide:z,vScale:L}}(this._shape,this._curveSegments,this._depth,e,this._uvPitch,this._legacy);this._nearSide=t.nearSide,this._vScale=t.vScale,this._effectiveBevel=e.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),n=this.getAttribute("uv"),s=this.getIndex();if(i!==void 0&&r!==void 0&&n!==void 0&&s!==null&&i.array.length===t.positions.length&&r.array.length===t.normals.length&&n.array.length===t.uvs.length&&s.array.length===t.indices.length)return i.array.set(t.positions),r.array.set(t.normals),n.array.set(t.uvs),s.array.set(t.indices),i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0,void(s.needsUpdate=!0);this.setAttribute("position",new Rt(t.positions,3)),this.setAttribute("normal",new Rt(t.normals,3)),this.setAttribute("uv",new Rt(t.uvs,2)),this.setIndex(new Rt(t.indices,1))}clone(){let e=new dH(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return e.userData=W4(this.userData),e}}}),qg=U(()=>{e0(),JLe(),Zbe(),_w(),qA(),t0=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:es.ODD},e.parameters),n=Math.abs(r.width),s=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=e.shape??t?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ds?(i=o,(i.width!==n||i.height!==s)&&i.applySize(n,s)):i=new ds(n,s).fromJSON(o),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&i.update());let u=i??new ds(n,s);return{parameters:Object.assign(r,{width:n,height:s,depth:a,roundness:l}),shape:u,ownerId:e.ownerId??t?.ownerId}}static build(e){let t,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:n,subdivisions:s,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:u}=e.parameters,h=u===1;return e.shape.roundness=a,i<=0?t=new hH(e.shape,s,{windingRule:o}):r<=0?t=new FL(e.shape,i,s,o,l,h):$A!==void 0?t=new dH(e.shape,i,r,s,n,e.ownerId,l,h):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),t=new FL(e.shape,i,s,o,l,h)),Object.assign(t,{userData:{...e,type:"VectorGeometry"}})}}});function i4e(e,t,i,r,n,s){if(r>=yY)return n>30||n%4==0?(function(h,d,c,p=0,f=0,m=0){let g=.5522847498,v=d*g,y=c*g;h.addPoint(M3(f-d,m,f-d,m-y,f-d,m+y)),h.addPoint(M3(f,m+c,f-v,m+c,f+v,m+c)),h.addPoint(M3(f+d,m,f+d,m+y,f+d,m-y)),h.addPoint(M3(f,m-c,f+v,m-c,f-v,m-c)),p>0&&nxe(h,d,c,p)}(e,t,i,s),Math.round(n/4)):Mie(e,r,n,t,i,s);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*t,y:Math.sin(o)*i},u=function({px:h,py:d,cx:c,cy:p,rx:f,ry:m,largeArcFlag:g,sweepFlag:v}){let y=[];if(f===0||m===0)return[];let _=(h-c)/2,b=(d-p)/2;if(_===0&&b===0)return[];f=Math.abs(f),m=Math.abs(m);let x=Math.pow(_,2)/Math.pow(f,2)+Math.pow(b,2)/Math.pow(m,2);x>1&&(f*=Math.sqrt(x),m*=Math.sqrt(x));let w=function(N,D,O,z,L,V,G,Y,$,Q){let ue=Math.pow(L,2),pe=Math.pow(V,2),xe=Math.pow(G,2),we=Math.pow(Y,2),re=ue*pe-ue*we-pe*xe;re<0&&(re=0),re/=ue*we+pe*xe,re=Math.sqrt(re)*($===Q?-1:1);let Se=re*L/V*Y,W=re*-V/L*G,k=Se+(N+O)/2,K=W+(D+z)/2,ie=(G-Se)/L,j=(Y-W)/V,ae=(-G-Se)/L,se=(-Y-W)/V,H=vie(1,0,ie,j),me=vie(ie,j,ae,se);return!Q&&me>0&&(me-=OI),Q&&me<0&&(me+=OI),{centerx:k,centery:K,ang1:H,ang2:me}}(h,d,c,p,f,m,_,b,g,v),{ang1:S,ang2:T}=w,{centerx:M,centery:E}=w,A=Math.abs(T)/(OI/4);Math.abs(1-A)<1e-7&&(A=1);let P=Math.max(Math.ceil(A),1);T/=P;for(let N=0;N<P;N++)y.push(ZLe(S,T)),S+=T;return y.map(N=>{let{x:D,y:O}=l5(N[0],f,m,M,E),{x:z,y:L}=l5(N[1],f,m,M,E),{x:V,y:G}=l5(N[2],f,m,M,E);return{x1:D,y1:O,x2:z,y2:L,x:V,y:G}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%u.length===0?function(h,d,c,p,f,m,g,v){let y=Math.round(f/p.length);h.addPoint(Ex(d,c));for(let _=0,b=p.length;_<b;_++){let x=p[_],w=h.points[_],S=Ex(x.x,x.y);w.controls[1].position.set(x.x1,x.y1),S.controls[0].position.set(x.x2,x.y2),h.addPoint(S)}return v>0?rxe(h,m,g,v):h.addPoint(Ex(0,0)),y}(e,a.x,a.y,u,n,t,i,s):Mie(e,r,n,t,i,s)}function Mie(e,t,i,r,n,s){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,u=Math.sin(l)*r,h=Math.cos(l)*n;e.addPoint(Ex(u,h))}return t<yY?s>0?rxe(e,r,n,s):e.addPoint(Ex(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&nxe(e,r,n,s)),1}function Ex(e,t){return new _y(ht.generateUUID(),new Z(e,t))}function M3(e,t,i,r,n,s){let a=Ex(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(n,s),a}function rxe(e,t,i,r){sxe(e,t,i,r).forEach(n=>e.addPoint(n))}function nxe(e,t,i,r){let n=sxe(e,t,i,r),s=new ds;n.forEach(a=>s.addPoint(a)),s.isClosed=!0,e.shapeHoles.push(s)}function sxe(e,t,i,r){let n=r*t/100,s=n*(Math.abs(i)/Math.abs(t)),a=new Z(n/t,s/i),o=e.points.map(l=>{let u=l.clone();return u.uuid=ht.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 yY,lB,axe,p5,oxe,kL=U(()=>{e0(),Vbe(),QLe(),qg(),oe(),yY=2*Math.PI,lB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=ht.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof ds?e.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(e){let t,{width:i,height:r,spikes:n,angle:s,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=e.parameters,d=e.shape,c=i4e(d,.5*i,.5*r,s*Math.PI/180,n,a);return d.isClosed=!0,d.update(),s===0?(t=new At,t.setAttribute("position",new Et([],3))):t=t0.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}}),Object.assign(t,{userData:{...e,type:"EllipseGeometry"}})}}}),Eie=U(()=>{oe(),Lbe(),axe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new p5(.5*t,s,a):new k7(.5*t,n),l=i/t,u=r/t;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},p5=class extends LL{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n="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],n,e,t,i),this.type=n}static fromJSON(e){return new p5(e.radius,e.corner,e.cornerSides)}}}),Aie=U(()=>{oe(),oxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.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}]},e.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(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,n=new oA;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new V7(n.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}}});function q1(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function r4e(e){let{positions:t,faces:i,materialIndices:r,uvs:n}=e,s=t.length/3,a=i.length/3,o=n!==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),f=0,m=8;for(;m<2*l;)m*=2;let g=m-1,v=new Int32Array(m).fill(-1),y=(D,O)=>{let z=(Math.imul(D,2654435761)^O)&g;for(;;){let L=v[z];if(L===-1)return v[z]=f,u[f]=D,h[f]=O,f++;if(u[L]===D&&h[L]===O)return L;z=z+1&g}},_=(D,O)=>{let z=D<O?D:O,L=D<O?O:D,V=(Math.imul(z,2654435761)^L)&g;for(;;){let G=v[V];if(u[G]===z&&h[G]===L)return G;V=V+1&g}},b=new Uint32Array(s),x=new Float64Array(3*s),w=(D,O,z)=>{let L=D<O?y(D,O):y(O,D),V=++d[L];V===1?c[L]=z:V===2&&(p[L]=z),b[D]++,b[O]++,x[3*D]+=t[3*O],x[3*D+1]+=t[3*O+1],x[3*D+2]+=t[3*O+2],x[3*O]+=t[3*D],x[3*O+1]+=t[3*D+1],x[3*O+2]+=t[3*D+2]};for(let D=0;D<a;D++){let O=i[3*D],z=i[3*D+1],L=i[3*D+2];w(O,z,L),w(z,L,O),w(L,O,z)}let S=new Float64Array(3*f);for(let D=0;D<f;D++){let O=3*u[D],z=3*h[D];if(d[D]===2){let L=3*c[D],V=3*p[D];S[3*D]=.375*(t[O]+t[z])+.125*(t[L]+t[V]),S[3*D+1]=.375*(t[O+1]+t[z+1])+.125*(t[L+1]+t[V+1]),S[3*D+2]=.375*(t[O+2]+t[z+2])+.125*(t[L+2]+t[V+2])}else S[3*D]=.5*(t[O]+t[z]),S[3*D+1]=.5*(t[O+1]+t[z+1]),S[3*D+2]=.5*(t[O+2]+t[z+2])}let T,M=new Float64Array(3*s);for(let D=0;D<s;D++){let O=b[D];O===3?T=3/16:O>3&&(T=3/(8*O));let z=1-O*Number(T),L=Number(T);O===2&&(z=3/4,L=1/8),M[3*D]=t[3*D]*z+x[3*D]*L,M[3*D+1]=t[3*D+1]*z+x[3*D+1]*L,M[3*D+2]=t[3*D+2]*z+x[3*D+2]*L}let E=new Float64Array(3*(s+f));E.set(M),E.set(S,3*s);let A=new Uint32Array(12*a),P=new Array(4*a),N=o?new Float64Array(24*a):null;for(let D=0;D<a;D++){let O=i[3*D],z=i[3*D+1],L=i[3*D+2],V=_(O,z)+s,G=_(z,L)+s,Y=_(L,O)+s,$=12*D;A[$++]=V,A[$++]=G,A[$++]=Y,A[$++]=O,A[$++]=V,A[$++]=Y,A[$++]=z,A[$++]=G,A[$++]=V,A[$++]=L,A[$++]=Y,A[$++]=G;let Q=r[D];if(P[4*D]=Q,P[4*D+1]=Q,P[4*D+2]=Q,P[4*D+3]=Q,N!==null){let ue=6*D,pe=n[ue],xe=n[ue+1],we=n[ue+2],re=n[ue+3],Se=n[ue+4],W=n[ue+5],k=q1(pe,we),K=q1(xe,re),ie=q1(we,Se),j=q1(re,W),ae=q1(pe,Se),se=q1(xe,W),H=24*D;N[H++]=k,N[H++]=K,N[H++]=ie,N[H++]=j,N[H++]=ae,N[H++]=se,N[H++]=pe,N[H++]=xe,N[H++]=k,N[H++]=K,N[H++]=ae,N[H++]=se,N[H++]=we,N[H++]=re,N[H++]=ie,N[H++]=j,N[H++]=k,N[H++]=K,N[H++]=Se,N[H++]=W,N[H++]=ae,N[H++]=se,N[H++]=ie,N[H++]=j}}return{positions:E,faces:A,materialIndices:P,uvs:N}}var E3,lxe,ea,hxe,_Y,n4e=U(()=>{oe(),E3=1e4,lxe=class{constructor(e=1){this.subdivisions=e}modify(e){let t=function(r){let n=r.getAttribute("position");if(n===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let s=r.getAttribute("uv"),a=r.getIndex(),o=n.count,l=new Map,u=new Uint32Array(o),h=[],d=0;for(let y=0;y<o;y++){let _=n.getX(y),b=n.getY(y),x=n.getZ(y),w=Math.round(_*E3),S=Math.round(b*E3),T=Math.round(x*E3),M=l.get(w);M===void 0&&(M=new Map,l.set(w,M));let E=M.get(S);E===void 0&&(E=new Map,M.set(S,E));let A=E.get(T);A===void 0&&(A=d++,E.set(T,A),h.push(_,b,x)),u[y]=A}let c=[],p=[],f=s===void 0?null:[],m=a!==null?a.count:o,g=(y,_)=>{let b=a!==null?a.getX(y):y,x=a!==null?a.getX(y+1):y+1,w=a!==null?a.getX(y+2):y+2;if(!(b<o&&x<o&&w<o))return;let S=u[b],T=u[x],M=u[w];S===T||T===M||M===S||(c.push(S,T,M),p.push(_),f!==null&&f.push(s.getX(b),s.getY(b),s.getX(x),s.getY(x),s.getX(w),s.getY(w)))},v=r.groups;if(v.length>0)for(let y=0;y<v.length;y++){let _=v[y],b=_.materialIndex===void 0?0:_.materialIndex,x=Math.max(_.start,0),w=Math.min(_.start+_.count,m);for(let S=x;S<w&&S+2<m;S+=3)g(S,b)}else for(let y=0;y+2<m;y+=3)g(y,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(c),materialIndices:p,uvs:f===null?null:Float64Array.from(f)}}(e),i=this.subdivisions;for(;i-- >0;)t=r4e(t);return function(r,n){let{positions:s,faces:a,materialIndices:o,uvs:l}=r,u=s.length/3,h=a.length/3,d=new Float64Array(3*u);for(let v=0;v<h;v++){let y=3*a[3*v],_=3*a[3*v+1],b=3*a[3*v+2],x=s[b]-s[_],w=s[b+1]-s[_+1],S=s[b+2]-s[_+2],T=s[y]-s[_],M=s[y+1]-s[_+1],E=s[y+2]-s[_+2],A=w*E-S*M,P=S*T-x*E,N=x*M-w*T;d[y]+=A,d[y+1]+=P,d[y+2]+=N,d[_]+=A,d[_+1]+=P,d[_+2]+=N,d[b]+=A,d[b+1]+=P,d[b+2]+=N}for(let v=0;v<u;v++){let y=d[3*v],_=d[3*v+1],b=d[3*v+2],x=Math.sqrt(y*y+_*_+b*b)||1;d[3*v]=y/x,d[3*v+1]=_/x,d[3*v+2]=b/x}let c=3*h,p=new Float32Array(3*c),f=new Float32Array(3*c),m=l!==null&&l.length>0?new Float32Array(2*c):null;for(let v=0;v<c;v++){let y=3*a[v];p[3*v]=s[y],p[3*v+1]=s[y+1],p[3*v+2]=s[y+2],f[3*v]=d[y],f[3*v+1]=d[y+1],f[3*v+2]=d[y+2]}m!==null&&m.set(l.subarray(0,2*c));let g=new At;g.setAttribute("position",new Rt(p,3)),c>0&&(g.setAttribute("normal",new Rt(f,3)),g.setAttribute("color",new Rt(new Float32Array(3*c).fill(1),3))),m!==null&&g.setAttribute("uv",new Rt(m,2));for(let v=0;v<h;){let y=o[v],_=v;do v++;while(v<h&&o[v]===y);g.addGroup(3*_,3*(v-_),y)}return n.boundingBox!==null&&(g.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(g.boundingSphere=n.boundingSphere.clone()),g}(t,e)}}}),Cie=U(()=>{oe(),n4e(),ea=new R,hxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=e.geometry??t?.geometry??new At().copy(new Dh(100,100,100));t===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(ea),i={width:ea.x,height:ea.y,depth:ea.z,subdivisions:0}):i=t.parameters;let n={...i,...e.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:r}}static build(e){let{width:t,height:i,depth:r,subdivisions:n}=e.parameters,s=e.geometry??new At().copy(new Dh(100,100,100)),a=s.userData.parameters;a===void 0?(s.boundingBox=function(l){let u=new fn,h=l.attributes.position;return h?(u.setFromBufferAttribute(h),u):(u.makeEmpty(),u)}(s),s.boundingBox.getSize(ea)):ea.set(a.width,a.height,a.depth),(t!==ea.x||i!==ea.y||r!==ea.z)&&s.scale(ea.x===0?1:t/ea.x,ea.y===0?1:i/ea.y,ea.z===0?1:r/ea.z);let o=s.originalGeometry;try{n>0?(o===void 0||a?.subdivisions!==n)&&(o===void 0&&(o=s),s=new lxe(n).modify(o)):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new TX(i).load(e,r=>{let n=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ea);let s=100/ea.x;Object.assign(n.parameters,{width:100,height:ea.y*s,depth:ea.z*s}),t(this.build(n))})}}}),cH=U(()=>{e0(),qg(),_Y=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let{width:t,height:i,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=e.parameters,u=e.shape,h=.5*t,d=.5*i,c=2*Math.PI/r;for(let f=0;f<r;f++){let m=c*f,g=0+Math.sin(m)*h,v=0+Math.cos(m)*d;u.addPoint(u.createPoint(g,v))}u.isClosed=!0;for(let f=0,m=u.points.length;f<m;f++)u.points[f].roundness=n;u.roundness=n,u.update();let p=t0.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...e,type:"PolygonGeometry"}})}}});function kS(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function f5(e,t,i,r,n,s){let a=dxe.copy(t).sub(e),o=cxe.copy(i).sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===n){let u=a.add(o).normalize();s.copy(e).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(o);s.copy(e),s.addScaledVector(a,n/Math.sin(u)),s.addScaledVector(o,r/Math.sin(u))}}function s4e(e,t,i){let r=e.clone().sub(t),n=i.clone().sub(t);return r.projectOnVector(n),r.add(t)}var uxe,dxe,cxe,Pie,hB,pxe,fxe,mxe,Rie,bY,gxe,vxe,yxe,_xe,Die=U(()=>{oe(),uxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.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(e){let{width:t,height:i,depth:r,radialSegments:n,heightSegments:s,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,u=new Pie(.5*t,i,n,s,a,o,l),h=r/t;return h!==1&&u.scale(1,1,h),Object.assign(u,{userData:{...e,type:"PyramidGeometry"}})}},dxe=new R,cxe=new R,Pie=class extends At{constructor(e=.5,t=1,i=4,r=1,n=!1,s=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=t/2,f=Math.PI/i,m=e*Math.cos(Math.PI/i),g=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,_=new R(0,-p,0),b=new R(0,p,0),x=new Z(e,-p),w=new Z(m,-p),S=new Z(0,b.y).sub(w),T=new Z(0,b.y).sub(x),M=new Z(S.y,-S.x).normalize(),E=new Z(T.y,-T.x).normalize(),A=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;s=Math.min(s,A);{let V=new R(M.x,M.y,0),G=new R(Math.cos(g)*V.x,V.y,Math.sin(g)*V.x);o=V.angleTo(G)}let P=s/Math.tan((Math.PI-S.angle())/2),N=s/Math.tan((Math.PI-o)/2),D=new R;if(!n){u.push(_.x,_.y,_.z),h.push(0,-1,0),d.push(0,0);let V=c++,G=[],Y=x.clone(),$=P/Math.cos(Math.PI/i);Y.x-=$;for(let Q=0;Q<i;Q++){let ue=Q/i*Math.PI*2+f;kS(Y,new Z(Math.sin(ue),Math.cos(ue)),D),u.push(D.x,D.y,D.z),h.push(0,-1,0),d.push(0,0),G.push(c++)}for(let Q=0;Q<G.length;Q++)l.push(G[Q],V,G[(Q+1)%G.length])}let O=[];{let V=new R,G=new R,Y=new R,$=new R,Q=new R,ue=new R;for(let pe=0;pe<i;pe++){let xe=pe/i*Math.PI*2+f,we=(pe+.5)/i*Math.PI*2+f,re=(pe+1)/i*Math.PI*2+f,Se=new Z(Math.sin(xe),Math.cos(xe)),W=new Z(Math.sin(we),Math.cos(we)),k=new Z(Math.sin(re),Math.cos(re));kS(x,Se,G),kS(x,k,Y),kS(M,W,V),f5(b,G,Y,N,N,$),u.push($.x,$.y,$.z),f5(G,b,Y,N,P,Q),u.push(Q.x,Q.y,Q.z),f5(Y,G,b,P,N,ue),u.push(ue.x,ue.y,ue.z),h.push(V.x,V.y,V.z),h.push(V.x,V.y,V.z),h.push(V.x,V.y,V.z),d.push(0,0),d.push(0,0),d.push(0,0);let K=c++,ie=c++,j=c++;if(l.push(K,ie,j),s>0){{let H=G.clone().add(Y).multiplyScalar(.5),me=b.clone().sub(H).normalize(),be=_.clone().sub(H).normalize().add(me).normalize().multiplyScalar(-1);z(H,ue.clone().sub(Q),be,S.angle())}let ae,se;{let H=new R;kS(E,k,H);let me=ue.clone().add($).multiplyScalar(.5);me=s4e(me,Y,b);let be=ue.clone().sub($);[ae,se]=z(me,be,H,o,$.y)}{let H=ae,me=H.clone().setY(0).normalize(),be=new R(0,-1,0),ke=me.clone().cross(be);L(H,me,be,ke)}O.concat(se);{let H=S.angle(),me=Math.PI-H,be=b.clone();be.y-=s/Math.sin(H-Math.PI/2);let ke=new R,Te=[];for(let ze=0;ze<a;ze++){let qe=[],Ne=Math.PI/2-me*ze/a,ee=Math.cos(Ne),Ce=Math.sin(Ne),He=we;for(let pt=0;pt<=ze;pt++){let tt=Math.cos(He),Yt=Math.sin(He);V.x=ee*Yt,V.y=Ce,V.z=ee*tt,ke.copy(be).addScaledVector(V,s),u.push(ke.x,ke.y,ke.z),h.push(V.x,V.y,V.z),d.push(0,0),qe.push(c++),He+=2*Math.PI/ze/i}Te.push(qe)}se.reverse(),Te.push(se);let Ze=Te.length-1;for(let ze=0;ze<Ze;ze++){let qe=Te[ze],Ne=Te[ze+1],ee=qe.length-1;l.push(Ne[1],qe[0],Ne[0]);for(let Ce=1;Ce<=ee;Ce++)l.push(qe[Ce],qe[Ce-1],Ne[Ce]),l.push(Ne[Ce+1],qe[Ce],Ne[Ce])}}}}}function z(V,G,Y,$,Q){let ue=-$/2,pe=(Math.PI-$)/2,xe=G.clone().normalize().cross(Y);V.addScaledVector(Y,-s/Math.sin(pe));let we=new R,re=new R,Se=c,W=[];for(let k=0;k<=a;k++){let K=ue+k/a*$;re.set(0,0,0),re.addScaledVector(xe,Math.sin(K)),re.addScaledVector(Y,Math.cos(K));for(let ie=0;ie<=1;ie++){let j=ie/1-.5;if(we.copy(V),we.addScaledVector(G,j),we.addScaledVector(re,s),Q!=null){let ae=Math.max(0,we.y-Q);we.addScaledVector(G,-ae/G.y)}u.push(we.x,we.y,we.z),h.push(re.x,re.y,re.z),d.push(0,0),ie===0&&W.push(c),c++}}for(let k=0;k<a;k++)for(let K=0;K<1;K++){let ie=Se+K+2*k,j=ie+2,ae=j+1,se=ie+1;l.push(ie,j,se),l.push(j,ae,se)}return[V.clone().addScaledVector(G,.5),W]}function L(V,G,Y,$){let Q=Math.PI/2,ue=T.angle()-Q,pe=[],xe=new R,we=new R;for(let Se=0;Se<=a;Se++){let W=[],k=Se/a;for(let K=0;K<=Se;K++){let ie=((Se?K/Se:0)-.5)*y,j=Math.cos(ie),ae=Math.sin(ie),se=(Q+Math.atan(Math.tan(ue)*j))*k,H=Math.cos(se),me=Math.sin(se);xe.set(0,0,0),xe.addScaledVector(G,me*j),xe.addScaledVector(Y,H),xe.addScaledVector($,me*ae),we.copy(V).addScaledVector(xe,s),u.push(we.x,we.y,we.z),h.push(xe.x,xe.y,xe.z),d.push(0,0),W.push(c++)}pe.push(W)}let re=pe.length-1;for(let Se=0;Se<re;Se++){let W=pe[Se],k=pe[Se+1],K=W.length-1;l.push(W[0],k[1],k[0]);for(let ie=1;ie<=K;ie++)l.push(W[ie-1],W[ie],k[ie]),l.push(W[ie],k[ie+1],k[ie])}}this.setIndex(l),this.setAttribute("position",new Et(u,3)),this.setAttribute("normal",new Et(h,3)),this.setAttribute("uv",new Et(d,2))}}}),VL=U(()=>{e0(),qg(),hB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let t=e.shape,{width:i,height:r,cornerRadius:n,cornerType:s,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}=e.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,w,S){return w>i&&S>r?Math.min(x*i/w,x*r/S):w>i?x*i/w:S>r?x*r/S:x}let f=[];f[0]=n[0]===0?0:p(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:p(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:p(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:p(n[3],n[3]+n[0],n[3]+n[2]);let m=d.x,g=c.x,v=c.y,y=d.y;t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let _=!0;for(let x=0,w=t.points.length;x<w;x++)t.points[x].roundness=f[x],x>0&&f[x]!==f[x-1]&&(_=!1);_&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=t0.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:u}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}}}),Nie=U(()=>{oe(),pxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=ht.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(e){let t,{width:i=100,height:r=i,depth:n=i,widthSegments:s=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:u,thetaLength:h}=e.parameters;return h===0?(t=new At,t.setAttribute("position",new Et([],3))):t=new Vf(.5*i,s,a,o,l,u,h*ht.DEG2RAD),t.scale(1,r/i,n/i),Object.assign(t,{userData:{...e,type:"SphereGeometry"}})}}}),Iie=U(()=>{oe(),fxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:n=8}=e.parameters,s=new qc(t,i,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}}}),Oie=U(()=>{oe(),mxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.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(e){let{width:t,height:i,depth:r,angle:n,cornerRadius:s,cornerSegments:a}=e.parameters,o=new Rie(t,i,r,n,s,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},Rie=class extends At{constructor(e=1,t=1,i=1,r=90,n=10,s=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],u=.001;n==0&&(s=1),s=Math.max(1,Math.floor(s)),n=Math.min(n,100),r=Math.min(180-u,r),r*=Math.PI/180;let h=[],d=Math.PI/2,c=(we=0,re=0,Se=0)=>new R(we,re,Se),p=c(),f=c(),[m,g,v]=[t/2,e/2,i/2],y=-g,_=+g,[b,x,w]=[c(y,-m,+v),c(y,-m,-v),c(y,+m,-v)],S=(we,re=!1)=>Math.sin(we-Math.PI/(+re+1)),T=(we,re=!1)=>Math.cos(we-Math.PI/(+re+1));w.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,E=b.z-u;r<=d?(w.z=Math.min(M,E),w.z==E&&(w.y-=(M-E)/Math.tan(d-r))):x.z=Math.min(x.z-M-v,b.z-u),p.subVectors(b,x),f.subVectors(w,x);let A=Math.min(p.length(),f.length())*n/100,P=A*Math.tan(r/2),N=A/Math.cos(r/2),D=p.clone().normalize().add(f.normalize()).setLength(N).add(x);p.set(0,S(r,!0),T(r,!0)),h.push([w,p.clone()]);let O=(Math.PI-r)/s;for(let we=0;we<=s;we++){let re=d+r+we*O;p.set(0,Math.sin(re)*P,Math.cos(re)*P),p.add(D),f.set(0,S(re),T(re)),h.push([p.clone(),f.clone()])}h.push([b,c(0,1,0)]);let z=Math.sin(O/2)*P*2,L=h.length-1,V=h[0][0].distanceTo(h[1][0]),G=V+z*s+h[L-1][0].distanceTo(h[L][0]);h[0].push(1);for(let we=0;we<=s;we++)h[we+1].push(1-(V+we*z)/G);h[L].push(0);let Y,$,Q,[ue,pe,xe]=h[0];for(let we=1;we<h.length;we++)[Y,$,Q]=h[we],a.push(y,ue.y,ue.z,y,Y.y,Y.z,_,ue.y,ue.z,_,ue.y,ue.z,y,Y.y,Y.z,_,Y.y,Y.z),o.push(0,pe.y,pe.z,0,$.y,$.z,0,pe.y,pe.z,0,pe.y,pe.z,0,$.y,$.z,0,$.y,$.z),l.push(0,xe,0,Q,1,xe,1,xe,0,Q,1,Q),[ue,pe,xe]=[Y,$,Q];this.setAttribute("position",new Et(a,3)),this.setAttribute("normal",new Et(o,3)),this.setAttribute("uv",new Et(l,2))}}}),pH=U(()=>{e0(),qg(),bY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let{width:t,height:i,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}=e.parameters,d=e.shape,c=.5*t,p=.5*i,f=a*Math.PI/360/n,m=Math.PI/2*3*-1,g=c*r/100,v=p*r/100;if(n===3&&r===50){f=2*Math.PI/n;for(let _=0;_<n;_++){let b=f*_,x=0+Math.sin(b)*c,w=0+Math.cos(b)*p;d.addPoint(d.createPoint(x,w))}}else for(let _=0;_<n;_++){let b=0+Math.cos(m)*c,x=0+Math.sin(m)*p;d.addPoint(d.createPoint(b,x)),m+=f,b=0+Math.cos(m)*g,x=0+Math.sin(m)*v,d.addPoint(d.createPoint(b,x)),m+=f}d.isClosed=!0;for(let _=0,b=d.points.length;_<b;_++)d.points[_].roundness=s;d.roundness=s,d.update();let y=t0.create({shape:d,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u,extrusionVersion:h}});return Object.assign(y,{userData:{...e,type:"StarGeometry"}})}}}),Lie=U(()=>{oe(),gxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.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(e){let{width:t,height:i}=e.parameters,r=new qc(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}}}),Bie=U(()=>{oe(),wA(),vxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??i.width);i.shapeBlendNode&&(n=r);let s=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:n,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:n,tubularSegments:s,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,u=function(h,d,c,p,f,m,g,v,y,_,b){[d,c]=[c,d],g=d/2;let x=ht.clamp(f/360,0,1);if(x===0){let w=new At;return w.setAttribute("position",new Et([],3)),w}return x===1&&(_=0),new JW(!0,h,d,c,p,x,m,g,0,y,_,b)}(t,i,r,.5*t,a,s,0,0,n,o,l);return u.scale(1,i/t,1),Object.assign(u,{userData:{...e,type:"TorusGeometry"}})}}}),Fie=U(()=>{oe(),yxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.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(e){let{width:t,tube:i,tubularSegments:r,radialSegments:n,p:s,q:a}=e.parameters,o=.5*t;o!==i&&(o-=i);let l=new G7(o,i,r,n,s,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}}}),Uie=U(()=>{e0(),qg(),_xe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof ds?e.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(e){let{width:t=100,height:i,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=e.parameters,u=e.shape,h=.5*t,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,f=u.points.length;p<f;p++)u.points[p].roundness=r;u.roundness=r,u.update();let c=t0.create({shape:u,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}}}),a4e=U(()=>{}),o4e=U(()=>{oe(),new qa,new Ue,new yf,new R,new R,new R,new R});function zie(){let e=new At;return e.setAttribute("position",new Rt(new Float32Array([]),3)),e.setIndex(new Rt(new Uint16Array([]),1)),e}var kie,fH,bxe=U(()=>{la(),jt(),qA(),oe(),GA(),e0(),qg(),_w(),kie=zie().attributes,fH=class extends At{constructor(e,t){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,kie),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:u,fontSize:h,extrusionVersion:d}=e,c=Eo.getDisplayedValue(l),p=function(w,S,T,M){let E=typeof w.width=="string"?Number(M.getVariable(w.width)):w.width,A=[""],P="";for(let N of T)P+=N,N===" "||N===`
|
|
4177
4177
|
`?(A[A.length-1]+=P,P="",N===`
|
|
4178
|
-
`&&A.push("")):S.getTextWidth(A[A.length-1]+P,w)>E&&(A[A.length-1].length&&A.push(""),S.getTextWidth(A[A.length-1]+P,w)>E&&(P.length===1?(A[A.length-1]+=P,P=""):(A[A.length-1]+=P.slice(0,-1),P=P[P.length-1],A.push(""))));return A[A.length-1]+=P,A}(e,i,u===2?c.toUpperCase():u===3?c.toLowerCase():c,t),{shapes:f,charWidths:m,charCoords:g}=i.generateShapes(p,e,t),v=.5*(typeof r=="number"?r:Number(t.getVariable(r))),y=.5*(typeof n=="number"?n:Number(t.getVariable(n))),_=f.map(w=>new ds().fromShape(w,!0));this.vectorShapes=_;let b=_.map(w=>t0.create({shape:w,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:h,extrusionVersion:d,windingRule:s<=0?es.NONZERO:es.ODD,subdivisions:this.isLowResolution&&s>0?1:12}})),x=b.length?Qv(b):zie();x.translate(-v,y,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([w,S])=>{this.setAttribute(w,S)}),this.setIndex(x.index),this.adoptNearSide(b,s),this.computeBoundingSphere()}adoptNearSide(e,t){this._depth=t;let i=0,r=0,n=0;for(let o of e){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),n=l._vScale??n}this._effectiveBevel=r,this._vScale=n;let s=new Uint8Array(i),a=0;for(let o of e){let l=o._nearSide;s.set(l,a),a+=l.length}this._nearSide=s}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length===this.getAttribute("position")?.count&&ix(this._effectiveBevel,e)&&ix(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position"),r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=t,u===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=Wo(new At,fH.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}}});function l4e(e){if(!mH)return Vie||(Vie=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build",i=import("./process.js"),[r,n]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});xxe(a),mH=!0}())}var xxe,xY,mH,Vie,uB=U(()=>{xY=new Promise(e=>{xxe=e}),mH=!1});function m5(e,t){if(Object.keys(e.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let i=Object.keys(e.attributes),r=Object.keys(t.attributes);if(i.length!==r.length)return!1;for(let l of r){let u=e.attributes[l],h=t.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 n=e.index,s=t.index;if(n===null!=(s===null))return!1;let a=!1;if(n!==null&&s!==null){if(n.array.length!==s.array.length)return!1;let l=n.array.constructor,u=s.array.constructor;if(l!==u){if(l!==Uint32Array||u!==Uint16Array)return!1;a=!0}}if(e.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let u=e.groups[l],h=t.groups[l];if(u.start!==h.start||u.count!==h.count||u.materialIndex!==h.materialIndex)return!1}for(let l of r){let u=e.attributes[l],h=t.attributes[l];u.array.set(h.array),u.needsUpdate=!0}let o=e.takeDepthStateFrom;if(typeof o=="function"&&o.call(e,t),n!==null&&s!==null){if(a){let l=n.array,u=s.array;for(let h=0,d=u.length;h<d;h++){let c=u[h];l[h]=c===65535?4294967295:c}}else n.array.set(s.array);n.needsUpdate=!0}return e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e.boundingBox=null,e.boundingSphere=null,!0}function gH(e,t,i,r){let n,s,a,o=e.position.array,l=e.normal.array,u=wxe.makeScale(t,i,r).invert().elements;for(let h=0,d=o.length;h<d;h+=3)o[h]*=t,o[h+1]*=i,o[h+2]*=r,n=l[h],s=l[h+1],a=l[h+2],l[h]=u[0]*n+u[4]*s+u[8]*a,l[h+1]=u[1]*n+u[5]*s+u[9]*a,l[h+2]=u[2]*n+u[6]*s+u[10]*a;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var wxe,Sxe=U(()=>{oe(),wxe=new Ue});function vH(e){let t=Number(e);return Number.isInteger(t)&&t>=0&&String(t)===e?t:-1}function A3(e){if(e!=null){if(Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView))return e;if(typeof e=="object")return function(t){let i=Object.keys(t),r=0;for(let s of i){let a=vH(s);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let n=new Array(r);for(let s=0;s<r;s++){let a=t[s];if(typeof a!="number")return;n[s]=a}return n}(e)}}function g5(e){if(e==null)return"missing";if(Array.isArray(e))return`Array(${e.length})`;if(ArrayBuffer.isView(e)){let l=e;return`${e.constructor.name}(${l.length})`}if(typeof e!="object")return typeof e;let t=Object.keys(e),i=t.filter(l=>vH(l)===-1),r=0;for(let l of t){let u=vH(l);u>=r&&(r=u+1)}let n=e,s=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):s===-1&&(s=l);let o=[`${t.length} keys`,"max index "+(r-1)];return s!==-1&&o.push(`first missing index ${s}`),a!==-1&&o.push(`non-number at ${a} (${typeof n[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function Txe(e){let t=Object.keys(e);return t.length===1&&t[0]==="subdivisions"}function wY(e,t){let i=t?t.count:e.count,r=0,n=1e4,s=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let d=t?t.getX(h):h,c=e.getX(d),p=e.getY(d),f=e.getZ(d),m=Math.round(c*n),g=Math.round(p*n),v=Math.round(f*n),y=s.get(m);y===void 0&&(y=new Map,s.set(m,y));let _=y.get(g);_===void 0&&(_=new Map,y.set(g,_));let b=_.get(v);b===void 0&&(b=r++,_.set(v,b),o.push(c,p,f)),a[h]=b}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(t?t.getX(h):h,t?t.getX(h+1):h+1,t?t.getX(h+2):h+2));return{positions:o,triIndices:l,triOriginals:u}}var VS,I0,ri,v5,y5,_5,us,GS,C3,P3,R3,yH,LI,bw=U(()=>{oe(),uB(),jt(),dB(),Sxe(),wA(),VS=new fn,I0=new R,xY.then(e=>{ri=e}),v5=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),y5=new Uint32Array([0,1,2,3]),_5=new Uint8Array([4]),us=class extends At{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=Ug.div(t.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&gH(this.subdividedGeometry.attributes,...r),this.originalGeometry&&gH(this.originalGeometry.attributes,...r),this.data=e;let n=this.userData.parameters;this.userData.parameters={width:n.width*r[0],height:n.height*r[1],depth:n.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(I0.fromArray(r));let s=I0.set(n.width,n.height,n.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let t=e.phongAngle??35;this.flatShading&&(t=-1);let i=null;if(e.subdivisions>0){let n=0;try{n=us.allocate(e),i=us.buildRefined(n,e.subdivisions,t)}catch(s){console.error(s,e)}finally{n&&us.freeSubdivPointer(n)}}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 e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Dh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??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 e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new qa,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;VS.setFromBufferAttribute(t),VS.getCenter(i),e.boundingSphere.radius=i.distanceTo(VS.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),VS.getSize(I0);let r={width:I0.x,height:I0.y,depth:I0.z};return this.userData.parameters=r,r}static build(e,t,i,r){let n,s,a=e?.phongAngle??35;i===!1&&(a=-1),t&&(ri.free_bvh(t),ri.free_subdivision_surface(t));try{n=us.allocate(e,r)}catch(l){console.error(l,e),n=us.allocate({positionWASM:v5,indexWASM:y5,verticesPerFaceWASM:_5},r)}ri.set_destination_refinement_level(n,0);let o=us.buildLevel(n,!0,a);return s=e.subdivisions>0?us.buildRefined(n,e.subdivisions,a):null,{subdivPointer:n,originalGeometry:o,subdividedGeometry:s}}static buildRefined(e,t,i){try{return ri.set_destination_refinement_level(e,t),us.buildLevel(e,!1,i)??null}catch{try{return ri.set_destination_refinement_level(e,t-1),us.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r,n=e.shape!==void 0||e.path!==void 0?t.geometry:Ng(e,i,!1,t);r=pbe(e)?n.getClosedTorusIndicesForBooleanOrSubdiv():n.getIndex();let s,{positions:a,triIndices:o,triOriginals:l}=wY(n.getAttribute("position"),r);if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2;s=[c,c+3*e.radialSegments]}let{indices:u,verticesPerFace:h,uvs:d}=function(c,p,f,m,g){let v=[],y=[],_=g?f.getAttribute("uv"):void 0,b=_&&_.itemSize===2?[]:void 0,x=T=>{if(b){let M=g[T];b.push(_.getX(M),_.getY(M))}};if(f.userData.shape!==void 0&&f.userData.parameters.depth===0&&f.userData.shape.shapeHoles.length===0){let T=f.userData.shape.extractShapePointsToFlatArray([]),M=f.userData.parameters.spikes;if(f.userData.type==="EllipseGeometry"&&M<=24&&M%4==0&&f.userData.parameters.angle>=360){let P=T.length/2/M;T=T.filter((N,D)=>Math.floor(D/2)%P===0)}let E=0;for(let P=0;P<T.length;P+=2)E+=(T[P]-T[(P===0?T.length:P)-2])*(T[P+1]+T[(P===0?T.length:P)-1]);c.length=0;let A=0;if(E<0)for(let P=0;P<T.length;P+=2)c.push(T[P],T[P+1],0),v.push(A++);else for(let P=T.length-2;P>=0;P-=2)c.push(T[P],T[P+1],0),v.push(A++);return y.push(A),{indices:v,verticesPerFace:y}}let w=new Float32Array([f.userData.parameters.depth])[0],S=0;for(;S<p.length;){if(f.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[S]+2]===w||c[3*p[S]+2]===0)&&T++,(c[3*p[S+1]+2]===w||c[3*p[S+1]+2]===0)&&T++,(c[3*p[S+2]+2]===w||c[3*p[S+2]+2]===0)&&T++,T===3)break}if(p[S+1]===p[S+3]&&p[S+2]===p[S+5]||p[S+0]===p[S+3]&&p[S+2]===p[S+4]){GS.set(c[3*p[S]],c[3*p[S]+1],c[3*p[S]+2]),C3.set(c[3*p[S+1]],c[3*p[S+1]+1],c[3*p[S+1]+2]),P3.set(c[3*p[S+4]],c[3*p[S+4]+1],c[3*p[S+4]+2]),R3.set(c[3*p[S+5]],c[3*p[S+5]+1],c[3*p[S+5]+2]),C3.sub(GS).normalize(),P3.sub(GS).normalize(),R3.sub(GS).normalize();let T=C3.cross(P3).dot(R3),M=S;Math.abs(T)>.005||m&&m.some((E,A)=>A%2!=1&&M>=m[A]&&M<m[A+1])?(v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3):(v.push(p[S],p[S+1],p[S+4],p[S+5]),x(S),x(S+1),x(S+4),x(S+5),y.push(4),S+=6)}else v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3}if(f.useNgonForTopBottomFaceDuringBake){let T=[],M=[],E=0;for(let A=0,P=0;A<c.length;A+=3,P++)c[A+2]===0&&(T.push(P),E++),c[A+2]===w&&M.push(P);if(f.userData.parameters.extrudeBevelSize===0){let A=M[0];M[0]=M[1],M[1]=A}T.reverse(),v.push(...T,...M),y.push(E,E),b=void 0}return{indices:v,verticesPerFace:y,uvs:b}}(a,o,n,s,l);return{positions:a,indices:u,verticesPerFace:h,uvs:d}}static allocate(e,t){let i,r,n,s=[],a=[],o=A3(e.positionWASM),l=A3(e.indexWASM),u=A3(e.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${g5(e.positionWASM)}, indexWASM ${g5(e.indexWASM)}, verticesPerFaceWASM ${g5(e.verticesPerFaceWASM)}`);i=o,r=l,n=u;let S=A3(e.uvWASM);ri.alloc_subdivision_surface_uvs&&S&&S.length===2*r.length&&(a=S)}else i=v5,r=y5,n=_5;let h=i.length,d=r.length,c=n.length,p=i.length+s.length+a.length,f=r.length+n.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,v=ri._malloc(m);if(!v)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${m}) failed`);let y,_=new Float32Array(ri.HEAPF32.buffer,v,p),b=new Uint32Array(ri.HEAPU32.buffer,v+g,f);_.set(i,0),_.set(s,i.length),_.set(a,i.length+s.length),b.set(r,0),b.set(n,r.length),e?.scaleBaked?.some(S=>S!==1)&&(y=new Ue().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),t&&(y?y.premultiply(t):y=t);let x=v+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,w=a.length?y?ri.alloc_subdivision_surface_uvs2(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,y.elements):ri.alloc_subdivision_surface_uvs(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):y?ri.alloc_subdivision_surface2(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,y.elements):ri.alloc_subdivision_surface(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return ri._free(v),w}static buildLevel(e,t,i,r,n,s=!1){let a=n?ri.get_mesh_data2(e,t?ri.Level.CONTROL:ri.Level.REFINED,i,n.elements):ri.get_mesh_data(e,t?ri.Level.CONTROL:ri.Level.REFINED,i),o=ri.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),u=0,h=ri.HEAPU32[o[u]>>2],d=ri.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let c=ri.HEAPU32[o[u]>>2],p=ri.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let f=ri.HEAPU32[o[u]>>2],m=ri.HEAPU32.subarray(f>>2,(f>>2)+l[u]);u++;let g,v=ri.HEAPU32[o[u]>>2],y=ri.HEAPU32.subarray(v>>2,(v>>2)+l[u]);if(u++,ri.alloc_subdivision_surface_uvs){let b=o[9];if(b>0){let x=ri.HEAPU32[o[8]>>2];g=ri.HEAPF32.subarray(x>>2,(x>>2)+b)}}if(r===void 0){let b=new At;if(b.setIndex(new kf(y,1)),b.setAttribute("position",new Et(d,3)),b.setAttribute("normal",new Et(p,3)),g&&b.setAttribute("uv",new Et(g,2)),t){b.setAttribute("faceMap",new kf(m,1));let x=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Rt(x,4))}return ri.free_mesh_data(a),b.userData.type="SubdivGeometry",b}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,s){let b=r.getIndex();b!==null&&b.array.length===y.length&&(b.copyArray(y),b.needsUpdate=!0)}let _=r.getAttribute("uv");g&&_&&_.array.length===g.length&&(_.copyArray(g),_.needsUpdate=!0),ri.free_mesh_data(a)}static freeSubdivPointer(e){ri.free_bvh(e),ri.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ri.get_wireframe_data_for_base_level(e),n=ri.HEAPU32.subarray(r>>2,4+(r>>2)),s=n.subarray(2,4),a=0,o=ri.HEAPU32[n[a]>>2],l=ri.HEAPF32.subarray(o>>2,(o>>2)+s[a]);a++;let u=ri.HEAPU32[n[a]>>2],h=ri.HEAPU32.subarray(u>>2,(u>>2)+s[a]);if(t===void 0){let d=new At;d.setAttribute("position",new Et(l,3));let c=new Float32Array(l.length);for(let p=0,f=l.length;p<f;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new Rt(c,3)),d.setIndex(new kf(h,1)),ri.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(l),t.attributes.position.needsUpdate=!0,ri.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ri.set_destination_refinement_level(e,t);let n=i?ri.get_topological_data2(e,r?ri.Level.CONTROL:ri.Level.REFINED,i.elements):ri.get_topological_data(e,r?ri.Level.CONTROL:ri.Level.REFINED),s=ri.HEAPU32.subarray(n>>2,8+(n>>2)),a=s.subarray(3,6),o=0,l=ri.HEAPU32[s[o]>>2],u=new Float32Array(ri.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=ri.HEAPU32[s[o]>>2],d=new Uint32Array(ri.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let c,p=ri.HEAPU32[s[o]>>2],f=new Uint8Array(ri.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(ri.alloc_subdivision_surface_uvs){let m=s[7];if(m>0){let g=ri.HEAPU32[s[6]>>2];c=new Float32Array(ri.HEAPF32.subarray(g>>2,(g>>2)+m))}}return ri.free_topological_data(n),{positions:u,indices:d,verticesPerFace:f,uvs:c}}},GS=new R,C3=new R,P3=new R,R3=new R}),Mxe=U(()=>{sie(),aie(),BL(),oie(),kL(),wA(),Eie(),Aie(),Cie(),cH(),Die(),VL(),Nie(),Iie(),Oie(),pH(),Lie(),Bie(),Fie(),Uie(),qg(),_r(),sie(),aie(),BL(),oie(),kL(),a4e(),wA(),Eie(),Aie(),Cie(),cH(),Die(),VL(),Nie(),Iie(),Oie(),pH(),Lie(),Bie(),Fie(),Uie(),qg(),o4e(),Zbe(),bxe(),bw(),uB(),aB(),_w(),yH={ConeGeometry:Nbe,CubeGeometry:Ibe,CylinderGeometry:pY,DodecahedronGeometry:Obe,EllipseGeometry:lB,HelixGeometry:fbe,IcosahedronGeometry:axe,LatheGeometry:oxe,NonParametricGeometry:hxe,PolygonGeometry:_Y,PyramidGeometry:uxe,RectangleGeometry:hB,SphereGeometry:pxe,PlaneGeometry:fxe,BackdropGeometry:mxe,StarGeometry:bY,TextFrameGeometry:gxe,TorusGeometry:vxe,TorusKnotGeometry:yxe,TriangleGeometry:_xe,VectorGeometry:t0},LI=e=>{let t=yH[e.type]??tbe(e.type);if(t===void 0)throw new Error(`No geometry factory registered for "${e.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(e)}});function Ng(e,t,i,r){let n,s,a;e.type==="PathGeometry"?(s={...e,extrusion:{...e.extrusion}},a=[[],["extrusion"]]):(s={...e},a=[[]]);for(let u of a){let h=s;for(let d of u)h=h[d];for(n in h){let d=h[n];Mee(d)&&!Exe.includes(n)&&(h[n]=t.getVariable(d,[r.uuid,"geometry",...u,n]),Mee(h[n])&&(h[n]=1))}}let o,l={parameters:s,type:s.type};if(s.type==="PathGeometry"){l.path=s.path;let u=r.profileShape;u!==void 0&&(l.shapeData=u),l.ownerId=r.uuid}else if(s.type==="VectorGeometry"){let u=ds.createFromState(s.shape,s.width,s.height);l.shape=u,l.ownerId=r.uuid}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),l.geometry=new TX().parse(s),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(s.type==="SubdivGeometry"){let u=new us(s,i);return u.data=e,u}if(s.type==="TextGeometry"||s.type==="InputGeometry"){let u=tbe(s.type);if(u)return u.create(s,t);Ma("text",`a ${s.type}`);let h=ds.createFromState(yA.defaultData(),100,100);return LI({...s,shape:h,type:"VectorGeometry"})}if(s.type==="UIGeometry")return hB.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}try{o=LI(l)}catch(u){console.error(u),console.error(`Error generating geometry with inputs: ${l}`);let h=ds.createFromState(yA.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=LI(l)}return o}var Exe,Gie,_H,dB=U(()=>{jt(),oe(),Mxe(),_r(),VL(),e0(),bw(),Exe=["font"]}),h4e=U(()=>{dB(),Gie=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(e){return this.objects.get(e)}get size(){return this.objects.size}get(e,t,i){let r=this.objects.get(e);return r===void 0?(r=this.createObject(e,t,i),this.objects.set(e,r)):r.isShared=!0,r}forceDelete(e){let t=this.objects.get(e);t&&(this.disposeObject(t),this.objects.delete(e))}adopt(e,t){this.objects.set(e,t)}mutateIfUnique(e,t){let i=this.objects.get(e);if(i&&i.isShared!==!0)return this.objects.delete(e),this.objects.set(t,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(e,t){t===this.objects.get(e)&&this.unreachable.delete(e)}endGc(){this.unreachable.forEach(e=>{this.disposeObject(this.objects.get(e)),this.objects.delete(e)}),this.unreachable.clear()}dispose(){this.objects.forEach(e=>{this.disposeObject(e)}),this.objects.clear()}},_H=class extends Gie{constructor(e){super(),this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,i){let r=Ng(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}}});function GL(){return XA}function Axe(){if(XA==="webgpu"){if(xH!==void 0)return xH;SH||(SH=!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(wH===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 wH}function Cxe(e,t){return Axe().createRootMaterial(e,t)}function jie(e,t,i){return Axe().createSharedMaterial(e,t,i)}function Wie(e){return e.getLayersOfType===void 0&&Object.assign(e,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),e}function bH(){return Rxe}var XA,xH,wH,SH,TH,Pxe,Rxe,MH,Dxe,Yf=U(()=>{XA="webgl",SH=!1}),u4e=U(()=>{Dxe={markNeedsUpdateRendererDirty:()=>{}}});function Sd(e,t){let i=0;if(!e.layers||e.layers.length===0)return!1;let r=e.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,s=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?s/100:n.alphaOverride)<1)return!0}for(let n of e.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="cavity"&&n.data.type!=="dust"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let s=n.data.visible?n.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let a of n.data.colors)if(a[3]<1){s=a[3];break}}else if(s===1&&n.data.type==="noise"){let a=t.color(n.data.colorA).a,o=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,u=t.color(n.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,u)));h<1&&(s=h)}i+=(1-i)*s}}return i<1}var cB=U(()=>{});function Gf(e){return typeof e=="string"||typeof e=="number"&&e!==0}var Oh,Lt,xw,SY,Hie,qie,Ph,Ed=U(()=>{Oh=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?100*e:e,i)??100)/100))??1,Lt=(e,t,i)=>typeof e=="number"?e:t.getVariable(e,i),xw={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"]},SY={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),ww=U(()=>{oe(),HA(),Hie=class extends rB(un){},qie=e=>e.type==="Mesh",Ph=class extends Hie{constructor(e){super(),this.object=e,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Ph(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return(e===void 0||this.parent!==e||!e.instancingActive&&!e.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return qie(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}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(e){}}});function $ie(){return TY}var TY,MY,EY=U(()=>{TY=null,MY=null});function EH(e){return"variable_"+e}var b5,x5,w5,Xie,S5,Yie,T5,Kie,jL,AY=U(()=>{jt(),Sbe(),Cbe(),oB(),bu(),uY(),cY(),h4e(),Yf(),Mbe(),u4e(),cB(),Ed(),xl(),ww(),Ir(),oe(),EY(),_r(),b5=new Ue,x5=new R,w5=new kt,Xie=new R,S5=new Kr,Yie=class extends xbe{constructor(e){super(),this.shared=e}create(e){return new hY(e,this.shared)}},T5=new Set,(jL=Kie=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new _H(!0),this.geometryCache2=new _H(!1),this.imageHolderCache=new Yie(this),this.thisContext={scene:Dxe,shared:this},this.deletedImage=new Rc(zW.emptyImage,this),this.deletedVideo=new Rc(_L.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,t.images)for(let[n,s]of Object.entries(t.images))this.addImage(n,s);if(t.videos)for(let[n,s]of Object.entries(t.videos))this.addVideo(n,s);if(t.audios)for(let[n,s]of Object.entries(t.audios))this.addAudio(n,s);if(t.particles)for(let[n,s]of Object.entries(t.particles))this.addParticle(n,s);this.reset(e)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=jie(ns.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:r,data:n}of e.variables)this.addVariableHolder(r,n),t&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(e.userAPIs??{}))this.addUserAPI(r,n);for(let[r,n]of Object.entries(e.userWebhooks??{}))this.addUserWebhook(r,n);if(!i){for(let[r,n]of Object.entries(e.images))this.addImage(r,n);for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n)}for(let[r,n]of Object.entries(e.colors))this.addColor(r,n);for(let[r,n]of Object.entries(e.lib.materials))this.addMaterial(r,n.asset);for(let[r,n]of Object.entries(e.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(e.particles))this.addParticle(r,n);for(let[r,n]of Object.entries(e.fonts))this.addFont(r,n)}addMaterial(e,t){if(t.layers===void 0&&(t={...t,layers:ns.defaultTwoLayerData("phong").layers}),this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=jie(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):e==null?(console.error("material is undefined or null"),this.deletedMaterial):(e.layers===void 0&&(e={...e,layers:ns.defaultTwoLayerData("phong").layers}),Cxe(e,this.thisContext))}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new Rc(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new Rc(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}getEntityTexture(e,t={}){let i=e.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let n=r.root??r;for(let s of n?.data?.layers??[]){let a=s?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||t.layer!==void 0&&s.id!==t.layer&&a.type!==t.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:s.id,layerType:a.type}}}return null}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new Rc(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return typeof e=="string"?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):(this.colors[e]=new MA(t.r,t.g,t.b,"a"in t?t.a:1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if(typeof e!="string")return new zr(e.r,e.g,e.b,"a"in e?e.a:1);{let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new zr(0,0,0,0))}return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof tx)return t;{let i=new tx({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof tx&&t.dispose(),delete this.audios[e])}addFont(e,t){let i=dY;i!==null?(this.fonts[e]=new i(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())):Ma("text","a font asset")}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof tx&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(this.variables[e]===void 0){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(EH(e));i=r!==null?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)this.variables[e].dynamicVariablePlayState!==void 0&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(this.variables[e]===void 0)return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(EH(e),JSON.stringify(t));let i=t;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,n=!1;for(let s=this.variables[e].locations.length-1;s>=0;s--){let a=this.variables[e].locations[s];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[e].locations.splice(s,1);continue}if(n=!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*ht.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),lr.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 n&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||typeof n.type!="string"||n.type==="VectorGeometry"||n.type==="PathGeometry")return!1;let s=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let u of Object.keys(n))a.set(s(u),u);let o={};for(let[u,h]of Object.entries(t??{})){let d=a.get(s(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=n[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={...n,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(n)&&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(e){let t=e;if(t.component&&(t=t.component),typeof t.chooseGeoemtryCache!="function")return!1;let i=t.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(t.dataPatched=t.data,t.chooseGeoemtryCache(this).forceDelete(i),t.createGeometryDelayed(this.entityOpContext),t.onVariableUpdate(!0),t.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||n.type!=="NonParametricGeometry")return!1;let s=t?.vertices;if(s===void 0||typeof s.length!="number"||s.length<9||s.length%3!=0||s.length/3>Kie.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,u=s instanceof Float32Array?s:Float32Array.from(s),h=u.length/3;if(t.normals!==void 0){if(t.normals.length!==u.length)return!1;a=t.normals instanceof Float32Array?t.normals:Float32Array.from(t.normals)}if(t.uvs!==void 0){if(t.uvs.length!==2*h)return!1;o=t.uvs instanceof Float32Array?t.uvs:Float32Array.from(t.uvs)}if(t.indices!==void 0){let x=h>65535?Uint32Array.from(t.indices):Uint16Array.from(t.indices);if(x.length===0||x.length%3!=0)return!1;for(let w=0;w<x.length;w++)if(x[w]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=n.data,w=x?.index;if(w?.array?.length){let S=(x?.attributes?.position?.array?.length??0)/3;if(h!==S)return function(T,M){let E=`${T}/${M}`;T5.has(E)||(T5.add(E),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${M}. 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,S),!1;l=w}}let d=1/0,c=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;for(let x=0;x<u.length;x+=3){let w=u[x],S=u[x+1],T=u[x+2];w<d&&(d=w),w>f&&(f=w),S<c&&(c=S),S>m&&(m=S),T<p&&(p=T),T>g&&(g=T)}let v=(x,w)=>({array:x,itemSize:w,type:"Float32Array",normalized:!1}),y={position:v(u,3)};a&&(y.normal=v(a,3)),o&&(y.uv=v(o,2));let _={...n,width:f-d,height:m-c,depth:g-p,data:{attributes:y,...l?{index:l}:{}}},b=this.transientGeometryKeys.has(n);return i.dataPatched={...r,geometry:_},this.transientGeometryKeys.add(_),i.applyTransientGeometryData(this.entityOpContext,b),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(e,t){let i=e;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let n=r.children,s=Math.PI/180,a=!1;if(t===null)for(let o of n)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(t))return n.length;{let o=Math.min(t.length,n.length);for(let l=0;l<o;l++){let u=t[l],h=n[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*s),typeof u.rotation.y=="number"&&(d.rotation[1]=u.rotation.y*s),typeof u.rotation.z=="number"&&(d.rotation[2]=u.rotation.z*s)),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(),n.length}spawnRuntimeClone(e,t={}){if(typeof e.entityChildren!="function")return;let i=e.parent;if(i===null)return;let r=new Ph(e);r.playModeVisible=t.visible!==!1,r.expand(),typeof t.name=="string"&&(r.name=t.name);let n=Math.PI/180;return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),r.hiddenMatrix.copy(e.hiddenMatrix),t.position&&(typeof t.position.x=="number"&&(r.position.x=t.position.x),typeof t.position.y=="number"&&(r.position.y=t.position.y),typeof t.position.z=="number"&&(r.position.z=t.position.z)),t.rotation&&(typeof t.rotation.x=="number"&&(r.rotation.x=t.rotation.x*n),typeof t.rotation.y=="number"&&(r.rotation.y=t.rotation.y*n),typeof t.rotation.z=="number"&&(r.rotation.z=t.rotation.z*n)),t.scale&&(typeof t.scale.x=="number"&&(r.scale.x=t.scale.x),typeof t.scale.y=="number"&&(r.scale.y=t.scale.y),typeof t.scale.z=="number"&&(r.scale.z=t.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(e){e.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(e,t){let i=e.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 n={scene:this.entityOpContext.scene,shared:this},s=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=u=>{if(typeof u=="string"){let h=new zr(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 MA?u.setValue(h,new zr(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(t.color!==void 0){let c=a(t.color),p=h.find(m=>m.data.type==="color"),f=p&&d(p.id);if(c&&f&&o(f,"color",c)&&(l=!0,c.a!==void 0)){let m=c.a<1||Sd(u.data,this);u.setTransparent?u.setTransparent(m,n.scene):u.transparent=m}}typeof t.alpha=="number"&&isFinite(t.alpha)&&(u.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(t.alpha,100)),n),l=!0);for(let c of t.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?h.find(v=>v.id===c.id):typeof c.index=="number"?h[c.index]:typeof c.type=="string"?h.find(v=>v.data.type===c.type):void 0,f=p&&d(p.id);if(!p||!f)continue;let m=xw[p.data.type]??[],g=Object.keys(p.data);for(let[v,y]of Object.entries(c)){if(v==="id"||v==="index"||v==="type")continue;let _=g.find(x=>x===v)??g.find(x=>s(x)===s(v))??v;if(m.includes(_))continue;let b=a(y);if(b&&o(f,_,b))l=!0;else if(typeof y=="number"&&isFinite(y))u.onVariableUpdate?.(["layer",p.id,_],y,n),l=!0;else if(Array.isArray(y)&&y.length<=3&&y.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];y.forEach((w,S)=>{u.onVariableUpdate?.(["layer",p.id,_,x[S]],w,n)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(e){this.variables[e]&&delete this.variables[e]}getVariable(e,t){if(Array.isArray(e)){if(e[0]==="mouse")return this.mouseProperty?.[e[1]]??0;if(e[0]==="raycast")return this.raycastProperty?.[e[1]]??0;let i=this.entityOpContext.scene.find(e[0]);if(e[1]==="width"||e[1]==="height"||e[1]==="depth")return i.geometry.userData.parameters[e[1]];if((e[1]==="position"||e[1]==="rotation")&&e.length>2&&i?.getPhysicsLocalMatrix?.(b5))return b5.decompose(x5,w5,Xie),e[1]==="position"?x5[e[2]]:(S5.setFromQuaternion(w5,i.rotation.order),S5[e[2]]*ht.RAD2DEG);for(let r=1;r<e.length;r++)i=i[e[r]];return e[1]==="rotation"&&(i*=ht.RAD2DEG),i}for(let i in this.variables){if(t===void 0)break;let r=this.variables[i],n=r.locations?.findIndex(s=>Ta.equal(s,t));n!==void 0&&n!==-1&&r.locations.splice(n,1)}if(typeof e=="string"){let i=e,r=e;do{if(r=i,this.variables[i]===void 0)break;let n=this.variables[i].value;t&&this.variables[r]!==void 0&&this.variables[r].locations.push(t),i=n}while(typeof i=="string");return i}return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){return this.variables[e]?.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){return this.variables[e]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){e.path[0]==="images"?e.path.length===1&&e.type===1?this.addImage(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteImage(e.id):e.path[0]==="videos"?e.path.length===1&&e.type===1?this.addVideo(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVideo(e.id):e.path[0]==="audios"?e.path.length===1&&e.type===1?this.addAudio(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteAudio(e.id):e.path[0]==="particles"?e.path.length===1&&e.type===1?this.addParticle(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteParticle(e.id):e.path[0]==="colors"?e.path.length===1&&e.type===1?this.addColor(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteColor(e.id):e.path[0]==="materials"?e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteMaterial(e.id):e.path[0]==="fonts"?e.path.length===1&&e.type===1?this.addFont(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteFont(e.id):e.path[0]==="variables"?e.path.length===1&&e.type===1?this.addVariableHolder(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVariable(e.id):e.path[0]==="components"&&t.updateByLibOp(e,this)}updateByOp(e,t,i){if(this.data=t,e.path[0]==="images")e.path.length===2&&e.type===0?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addImage(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteImage(e.id);else if(e.path[0]==="videos")e.path.length===2&&e.type===0?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addVideo(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteVideo(e.id);else if(e.path[0]==="audios")e.path.length===2&&e.type===0?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):e.path.length===1&&e.type===1?this.addAudio(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteAudio(e.id);else if(e.path[0]==="particles")e.path.length===2&&e.type===0?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):e.path.length===1&&e.type===1?this.addParticle(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteParticle(e.id);else if(e.path[0]==="colors")e.path.length===2&&e.type===0?this.updateColor(e.path[1],e.props):e.path.length===1&&e.type===1?this.addColor(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteColor(e.id);else if(e.path[0]==="materials")e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data):e.path.length===1&&e.type===2?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(Xa.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if(e.path[0]==="fonts")e.path.length===2&&e.type===0?this.updateFont(e.path[1],e,i):e.path.length===1&&e.type===1?this.addFont(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteFont(e.id);else if(e.path[0]==="variables")e.path.length===2&&e.type===0?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):e.path.length===1&&e.type===4?this.addVariableHolder(e.id,e.data):e.path.length===1&&e.type===5&&this.deleteVariable(e.id);else if(e.path[0]==="userAPIs"){if(e.path.length===1&&e.type===1)this.addUserAPI(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserAPI(e.id);else if(typeof e.path[1]=="string"){let r=t.userAPIs[e.path[1]];if(r){let n=e.type===0&&e.props.debounce===void 0,s=this.getUserAPI(e.path[1]);s!==void 0&&s===this.openAIRealtime?s.update(r):s?.update(r,this,n)}}}else if(e.path[0]==="userWebhooks"){if(e.path.length===1&&e.type===1)this.addUserWebhook(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserWebhook(e.id);else if(typeof e.path[1]=="string"){let r=t.userWebhooks[e.path[1]];r&&this.getUserWebhook(e.path[1])?.update(r)}}else e.path[0]==="lib"&&this.updateLibByOp(Xa.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),n={...this.data.fonts[e],url:t.props.url};r.update(n),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){if(this.userAPIs[e])return this.userAPIs[e].update(t,this),!0;if(this.openAIRealtime?.id===e)return this.openAIRealtime.update(t),!0;if(t.integration?.type==="VoiceAssistant"){let i=MY;return i===null?(Ma("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(t,e,this),!1)}{let i=$ie();return i===null?(Ma("api-services","a user API integration"),!1):(this.userAPIs[e]=i.createUserAPI(e,t,this),!1)}}getUserAPI(e){return this.openAIRealtime?.id===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){if(this.userWebhooks[e])return this.userWebhooks[e].update(t),!0;{let i=$ie();return i===null?(Ma("api-services","a user webhook"),!1):(this.userWebhooks[e]=i.createUserWebhook(e,t),!1)}}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new jL(fu.emptyData())});function Nxe(e){return OL(e)||e?.isTSLNodeMaterial===!0}var bl,M5,E5,A5,Zie,C5,hp,Qie,Jie,jS,Un,Ixe=U(()=>{lY()}),u1=U(()=>{jt(),Ia(),Yf(),Ixe(),Ir(),la(),bl=class extends Ms{setMaterialOverride(e,t){this.materialOverride=Wie(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),t.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),Jr(e.path,["geometry"])&&this.syncShadowCatcher(i),function(r,n){let s=[];if(n.length!==r.length)return null;{let a=0;for(;a<r.length;){if(n[a]==="*")s.push(r[a]);else if(r[a]!==n[a])return null;a+=1}}return s}(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[r,n]of Object.entries(e.props)){let s=this.material[Number(r)],a=i.shared.material(n);a!==s&&bl.disposeOneMaterial(s),this.material[Number(r)]=a}else if(Jr(e.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in t&&typeof t.material!="string"&&r.updateByOp(Xa.drop(e,1),t.material,i)}else if(Jr(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&r<this.material.length){let n=t.materials[r];typeof n!="string"&&this.material[r].updateByOp(Xa.drop(e,2),n,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(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.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 n=this.materialOverride!==void 0;!n&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe,i),t.scene.markNeedsUpdateRendererDirty()),!n&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(a=>t.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe)],t.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!n&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(s.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!n&&(e.flatShading!==void 0||e.wireframe!==void 0||e.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(t)}shadowCatcherActive(){let e=this.dataPatched,t=e.geometry?.type;return e.shadowCatcher===!0&&(t==="RectangleGeometry"||t==="PlaneGeometry")}syncShadowCatcher(e){let t=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=XA==="webgpu"&&TH!==void 0?TH:Pxe;return r===void 0?null:Wie(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=t.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.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,e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.material=e.shared.material(t.material).getFlavor(t.flatShading,t.side,t.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow)}static disposeOneMaterial(e){var t;Nxe(e)&&!function(i){return i?.isClassicSharedMaterial===!0}(t=e)&&t?.isTSLSharedMaterial!==!0&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&e_e(this.material).forEach(e=>{bl.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),wl=U(()=>{jt(),Ir(),AY(),u1(),oe(),dB(),_w(),bw(),Sxe(),M5=new R,E5=new ct,A5=new ct,Zie=new R,C5=new Ue,hp=new Tr,Qie=hp.geometry,Jie=hp.material,jS=new R,Un=class extends bl{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new Ue().fromArray(t.bindMatrix),this.bindMatrixInverse=new Ue)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof At&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof At?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof jL){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=t.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return wL.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return wL.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Jr(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Xa.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var e;super.dispose(),e=this.uuid,zL.delete(e),this._posed=void 0}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(e!==void 0&&e.sxPrev!==void 0)return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,n,s,a=e;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=Ng(d,t,this.data.flatShading,this)}a.scaleBaked?[r,n,s]=a.scaleBaked:{width:r,height:n,depth:s}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,u=typeof n=="number"?n:1,h=typeof s=="number"?s:1;o.sxPrev!==void 0&&gH(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(e)){let r=Ng({...this.data.geometry,...e},t,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&m5(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(e){let t=this.localGeometry;if(t?.shiftDepthTo===void 0)return!1;let i=e;if(typeof i.depth!="number")return!1;let r=t.userData?.parameters;if(r===void 0)return!1;for(let n of Object.keys(i))if(n!=="depth"&&i[n]!==r[n])return!1;return!!t.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(e){for(let t of this.attachedSurfaceCloners)t.update(e)}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){let r=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&Txe(e.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(t),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof At&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=i.shared,s=this.chooseGeoemtryCache(n),a=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=Ng(o,n,this.data.flatShading,this);m5(a,l)?(l.dispose(),a.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}applyTransientGeometryData(e,t){let i=e.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof At&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let a=Ng(r,i,this.data.flatShading,this);return m5(s,a)?(a.dispose(),s.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(e),void this.refreshAttachedPaths(e)}}t&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:n}}of i)this.updateMorphInfluences(r,t.shared.getVariable(n,[this.uuid,"morphTargetInfluences",r]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=t)}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(e,t){let i=this.posedGeometry()?.boundingBox;if(i)return i.getCenter(e),void i.getSize(t).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,.5*r.depth):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?e.fromArray(r.centerOffset):e.setScalar(0),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new ct,i=this.geometry.attributes.skinWeight;for(let r=0,n=i.count;r<n;r++){t.fromBufferAttribute(i,r);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),i.setXYZW(r,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;E5.fromBufferAttribute(r.attributes.skinIndex,e),A5.fromBufferAttribute(r.attributes.skinWeight,e),M5.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){let s=A5.getComponent(n);if(s!==0){let a=E5.getComponent(n);C5.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(Zie.copy(M5).applyMatrix4(C5),s)}}return t.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(e,t){let i=this.posedGeometry();if(i===void 0)return!1;hp.geometry=i,hp.material=this.material,hp.matrixWorld.copy(this.matrixWorld);let r=t.length;hp.raycast(e,t);for(let n=r;n<t.length;n++)t[n].object=this;return hp.geometry=Qie,hp.material=Jie,!0}posedGeometry(){let e=this.skeleton;if(!this.isSkinnedMesh||e===void 0)return;let t=this.geometry,{position:i,skinIndex:r,skinWeight:n}=t.attributes;if(!i||!r||!n)return;let s=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<e.bones.length;d++){let c=e.bones[d];if(!c||!e.boneInverses[d])return;s.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===t&&a.version===i.version&&a.pose.length===s.length&&a.pose.every((d,c)=>d===s[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,u=l?.count===o?l:new Rt(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,jS)),u.setXYZ(d,jS.x,jS.y,jS.z);let h=new At;h.setAttribute("position",u);for(let d of["normal","uv","uv1"]){let c=t.attributes[d];c&&h.setAttribute(d,c)}return h.setIndex(t.index),h.groups=t.groups,h.drawRange=t.drawRange,h.computeBoundingSphere(),h.computeBoundingBox(),this._posed={source:t,version:i.version,pose:s,geometry:h},h}}});function Ax(e){if(Array.isArray(e.material)){for(let t of e.material)if(t.getLayersOfType("outline").length===0)return}else if(!OL(e.material)||e.material.getLayersOfType("outline").length===0)return;e instanceof Un&&e.is2DAndNoDepth?function(t){if(t.geometry.attributes.extrudeNormals||!t.geometry.attributes.position)return;let i=t.geometry.attributes.position.array,r=new Float32Array(i.length),n=new R;for(let s=0;s<i.length;s+=3)n.set(i[s],i[s+1],i[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;t.geometry.setAttribute("extrudeNormal",new Et(r,3))}(e):function(t){if(t.geometry.attributes.extrudeNormal||!t.geometry.attributes.position||!t.geometry.attributes.normal)return;let i=new Map,r=t.geometry.attributes,n=r.position.array,s=r.normal.array,a=new Float32Array(n.length);for(let o=0;o<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,u=new R(s[o],s[o+1],s[o+2]);i.has(l)?i.get(l)?.normals.push(u):i.set(l,{normals:[u],result:new R})}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<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,u=i.get(l)?.result;u&&(a[o]=u.x,a[o+1]=u.y,a[o+2]=u.z)}t.geometry.setAttribute("extrudeNormal",new Et(a,3))}(e)}function P5(e){return Math.min(2047,Math.max(1,Math.round(2048*e)))/2048}function Cx(e){if(!e.geometry.attributes.position)return;let t=e.geometry.attributes,i=t.position.array,r=t.randomColor;if(r!==void 0&&3*r.count===i.length)return;let n=new Float32Array(i.length),s=parseInt(e.uuid.replace(/\D/g,"")),a=[P5(ht.seededRandom(s)),P5(ht.seededRandom(s+1e4)),P5(ht.seededRandom(s+2e4))];for(let o=0;o<i.length;o++)n[o]=a[o%3];e.geometry.setAttribute("randomColor",new Rt(n,3))}var pB=U(()=>{oe(),lY(),wl()});function ere(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}function d4e(e,t){let i=e.cloner;return i!==void 0&&i.parent===t?i:void 0}function tre(e,t,i,r){let n=16*(t.children.length+1);LM.length<n&&(LM=new Float32Array(n));let s=0,a=l=>{l.toArray(LM,16*s),s++},o=t.parameters.hideBase!==!0;o&&a(r),AH.multiplyMatrices(e.hiddenMatrix,e.matrix);for(let l of t.children)!Jv(l)||l.playModeVisible===!1||(CH.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),BI.multiplyMatrices(AH,CH),(!o||!BI.equals(r))&&a(BI));try{return s===0?0:function(l,u){return aY(IL().instanced_union(sY(l),u))}(i,LM.subarray(0,16*s))}finally{mbe(i)}}var up,ire,AH,CH,BI,LM,zg,WL,fB,vd,Fc,HL,YA=U(()=>{Ia(),oe(),aB(),pB(),u1(),ss(),up=new Ue,ire=new Ue,AH=new Ue,CH=new Ue,BI=new Ue,LM=new Float32Array(0),zg=class extends bl{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new At,this.onAfterRender=(r,n,s,a,o,l)=>{super.onAfterRender(r,n,s,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let r=0;r<this.children.length;r++){let n=this.children[r];n instanceof zg&&n.dataPatched.visible===!0&&n.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let n=this.children[r];if(n instanceof Ms&&n.dataPatched.visible===!0&&n.geometry.attributes.position?.count>0&&n.geometry.drawRange.count>0&&n.booleanMeshSetAddress!==0){up.multiplyMatrices(n.hiddenMatrix,n.matrix).multiply(n.pivotMatrix);try{let s=d4e(n,this);if(n.booleanMeshSetAddress===-1){if((n.geometry.index??n.geometry.getAttribute("position")).count/3<15e5){let a=LLe(n.geometry,e===!0);n.booleanMeshSetAddress=s===void 0||a===-1?a:tre(n,s,a,up)}if(n.booleanMeshSetAddress===-1)return;s===void 0&&s5(n.booleanMeshSetAddress,up),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1}else n instanceof zg&&n.needsTransformForDownstream===!0?(s===void 0?s5(n.booleanMeshSetAddress,up):n.booleanMeshSetAddress=tre(n,s,n.booleanMeshSetAddress,up),n.needsTransformForDownstream=!1):n.booleanWasTransformed===!0&&(s5(n.booleanMeshSetAddress,ire.multiplyMatrices(up,n.booleanMatrixInvOld)),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1)}catch(s){console.error(s),n.booleanMeshSetAddress=0,n.geometry.userData.booleanOperationDidFail=!0;continue}if(n.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(n.booleanMeshSetAddress),n.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 At,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new Et([],3))}return void this.geometry.setDrawRange(0,0)}if(e===!0)return function(r,n){let s=IL(),a=$te(r,n),o=s.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 At,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,n,s,a){let o=IL(),l=$te(r,n),u=o.mesh_render_data(l,Math.max(a,0));if(s.setAttribute("position",new Et(u.positions(),3)),s.setAttribute("normal",new Et(u.normals(),3)),u.free(),s.boundingSphere===null&&(s.boundingSphere=new qa),l.tri_count()===0)s.boundingSphere.center.set(0,0,0),s.boundingSphere.radius=0,s.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();s.boundingSphere.center.set(h[0],h[1],h[2]),s.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,s.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return aY(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,Ax(this),Cx(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),KA=U(()=>{oe(),xl(),h1(),(WL||(WL={})).is=function(e){return lr.is(e)&&e instanceof Hp},fB=(e,t)=>class extends l1(e,t){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 n=this.shadow;n.camera.far=i.depth,n.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),i0=U(()=>{YA(),Ia(),h1(),vd=e=>e instanceof Ms,Fc=e=>e!==null&&e instanceof zg,HL=e=>QW.is(e)});function vo(e,t){return t.color(e)}function rre(e=new Date,t){let i=t.format,r=e.getSeconds(),n=e;t&&t.timeZone!==null&&(n=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),f=m=>Number(p.find(g=>g.type===m)?.value);return new Date(f("year"),f("month")-1,f("day"),f("hour"),f("minute"),f("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,t.timeZone));let s,a=n.getHours(),o=n.getMinutes();t.format12h24h==="12ampm"&&(s=a>=12?"PM":"AM");let l,u,h=a;switch(t.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],s=void 0;break;case"mm":l=[o],s=void 0;break;case"ss":l=[r],s=void 0;break;case"year":u=n.getFullYear();break;case"month":u=n.getMonth()+1;break;case"dayOfYear":u=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=n.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:s}:u}var PH,Sw,CY=U(()=>{}),c4e=U(()=>{oe(),jA(),WA(),PH=class extends gw(x1e){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){vw(this.object,PH.geometryHelper,e,t)}}}),mB=U(()=>{oe(),c4e(),KA(),Sw=class extends fB(hA,PH){constructor(e,t,i){super(),this.super_Entity(e,t),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 n=new uA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof uA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&function(r,n){r.shadow.camera.right=n/2,r.shadow.camera.left=-n/2,r.shadow.camera.top=n/2,r.shadow.camera.bottom=-n/2,r.shadow.needsUpdate=!0}(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}}});function PY(e){return e instanceof bl&&e.needsAO&&!Hf(e)&&e.isDecalObject!==!0}function RY(e){let t=e.cloner;if(t&&Array.isArray(t.children))for(let i of t.children)i?.layers&&(i.layers.mask=e.layers.mask)}function DY(e){return e.getLayersOfType("reflection").filter(t=>t.data.visible).length}function p4e(e){let t=1/0,i=-1/0;for(let r of e.getLayersOfType("reflection")){let n=r.data;if(!n.visible||n.mirror===1)continue;let s=typeof n.blur=="number"?n.blur:null;t=Math.min(t,s??0),i=Math.max(i,s??10)}return t===1/0?null:{min:t,max:i}}function f4e(e){for(let t of e.getLayersOfType("reflection")){let i=t.data;if(!i.visible)continue;let{blur:r,thickness:n,steps:s,stepSize:a}=i;return typeof r!="number"||typeof n!="number"||typeof s!="number"||typeof a!="number"?"variable":{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function nre(e,t){let i={outline:!1,cavity:!1},r=e.layers.mask&gB,n=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline"),a=DY(t),o=t.getLayersOfType("cavity");return(s.length>0||o.length>0)&&(e.layers.set(8),n.length>0&&e.layers.enable(3),a>0&&e.layers.enable(4),i.outline=s.length>0,i.cavity=o.length>0,Cx(e),Ax(e)),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),r&&e.layers.set(9),!r&&PY(e)&&e.layers.enable(5),RY(e),i}function sre(e,t){if(!t.layers)return!1;let i=e.layers.mask&gB,r=!1,n=t.getLayersOfType("transmission").filter(l=>l.data.visible),s=t.getLayersOfType("outline").filter(l=>l.data.visible),a=DY(t),o=t.getLayersOfType("cavity").filter(l=>l.data.visible);return n.length>0&&(e.layers.set(3),(s.length>0||o.length>0)&&e.layers.enable(8),a>0&&e.layers.enable(4),r=!0),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),i&&e.layers.set(9),!i&&PY(e)&&e.layers.enable(5),RY(e),r}function are(e,t){var i;if(!t.layers)return!1;let r=e.layers.mask&gB,n=!1,s=DY(t),a=t.getLayersOfType("transmission").filter(u=>u.data.visible),o=t.getLayersOfType("outline").filter(u=>u.data.visible),l=t.getLayersOfType("cavity").filter(u=>u.data.visible);return s>0&&((i=e.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),e.layers.set(4),a.length>0&&e.layers.enable(3),(o.length>0||l.length>0)&&e.layers.enable(8),n=!0),s===0&&a.length===0&&o.length===0&&l.length===0&&e.layers.set(0),r&&e.layers.set(9),!r&&PY(e)&&e.layers.enable(5),RY(e),n}function RH(e,t,i,r=!1){let n=e.cloner;if(n){let s=null;if((e.raycast===Tr.prototype.raycast||e.raycast===Ms.prototype.raycast)&&e.isSkinnedMesh!==!0){let a=e.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),s=a.boundingSphere)}for(let a of n.children){if(s!==null&&(DH.copy(s).applyMatrix4(a.matrixWorld),!t.ray.intersectsSphere(DH)))continue;let o=Lxe.copy(a.matrixWorld).invert(),l=Bxe.copy(t.ray).applyMatrix4(o),u=e.matrixWorld;l.applyMatrix4(u);let h=Oxe;h.set(l.origin,l.direction),h.near=t.near,h.far=t.far,h.layers.mask=t.layers.mask;let d=h.intersectObject(e,!1);d.length>0&&i.push({...d[0],object:r?a:e})}}}var gB,Oxe,Lxe,Bxe,DH,D3,Fxe,R5,D5,N5,Tw,Ks,NY=U(()=>{ss(),pB(),Ia(),u1(),oe(),gB=512,Oxe=new G4,Lxe=new Ue,Bxe=new yf,DH=new qa}),m4e=U(()=>{oe(),jA(),WA(),D3=class extends gw(_1e){constructor(e,t=6710886){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){vw(this.object,D3.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=D3._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(r);else this.cone.material.color.set(r)}}},(Fxe=D3)._vector=new R}),vB=U(()=>{oe(),m4e(),KA(),R5=new R,D5=new R,N5=new kt,Tw=class extends fB(cy,Fxe){constructor(e,t,i){super(),this.super_Entity(e,t),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*ht.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new uA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof uA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),D5.setFromMatrixPosition(this.matrixWorld),N5.setFromRotationMatrix(this.matrixWorld),R5.copy(this.up).applyQuaternion(N5).negate().multiplyScalar(this.distance),this.target.position.copy(D5).add(R5),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),Kf=U(()=>{jt(),Ih(),oe(),xl(),bu(),CY(),Cd(),mB(),Ir(),Yf(),oe(),u1(),i0(),NY(),vB(),_r(),YA(),Ks=class extends nB(Zo){constructor(e,t,i){if(super(),this.data=t,this.bgColor=new zr(1,1,1,1),this.fog=null,this.backupFog=new A7(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Xn.getDensity({}),this.fogHeightFalloff=Xn.getHeightFalloff({}),this.fogHeightBase=Xn.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ot,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Yn(o1,{...wE.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new V4(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene){let r=qW();r===null?Ma("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else t.uiFrame&&this.createUICanvas(t.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(e,t){let i=qW();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})):Ma("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=vo(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity*Math.PI),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof zg&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof bl)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){if(e.softShadowQuality===void 0&&e.type===void 0||!this.isActive)return;let t=this.data.shadow;var i,r;i=fy.isSoft(t),r=t?.softShadowQuality,MH!==void 0&&MH(i,r)&&this.forceMaterialsUpdate()}updateFog(e,t){e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=vo(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far,this.fogMode=Xn.getMode(e),this.fogDensity=Xn.getDensity(e),this.fogHeightFalloff=Xn.getHeightFalloff(e),this.fogHeightBase=Xn.getHeightBase(e)}updateSky(e,t){this.skyState=e??null,this.skyStateVersion++;let i=e?.hdri?.image;this.skyHdriHolder=i!=null?t.image(i):null}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=vo(e.aoColor,t))}updateByOp(e,t,i,r){let n=this.data.uiFrame;super.updateByOp(e,t,i,r);let s=t;Jr(e.path,["fog"])?this.updateFog(s.fog,i.shared):Jr(e.path,["sky"])?this.updateSky(s.sky,i.shared):Jr(e.path,["grading"])?this.gradingState=s.grading??null:Jr(e.path,["ao"])?this.updateAo(s.ao,i.shared):Jr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Jr(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||n!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(vo(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.sky!==void 0&&this.updateSky(e.sky,t.shared),e.grading!==void 0&&(this.gradingState=e.grading),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e instanceof Yn&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){let e=this.scene?.find(this.data.publish.playCamera);return e instanceof Yn?e:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(Wf).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof Sw&&i.visible&&e<TE&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof Tw&&i.visible&&e<Wf-TE&&(this.penumbraSizeArrayCache[TE+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let n of r.children){let s=n.cloner;lr.is(n)&&(n.visible||s?.object.data.visible)&&((vd(n)||HL(n)&&this.scene.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),RH(n,e,t,!0)),i(n))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}}});function ore(){return IY}function I5(){if(qL===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 qL}function O5(e){return e?.isWebGPUSplineRenderer===!0}var IY,qL,OY=U(()=>{IY=null,qL=null});function NH(){return BY}var LY,BY,FY=U(()=>{LY=null,BY=null});function lre(e,t,i){return BM.setRGB(e,t,i,Xi),{r:BM.r,g:BM.g,b:BM.b}}function g4e(e,t,i){let r,n=AA(e.angle,0),[s,a]=IH(e.offset),[o,l]=IH(e.morph),u=e.colors??[],h=e.steps??[],d=Math.min(10,u.length,h.length);if(d===0)return[1,1,1,1];if(e.gradientType===1){let g=3*(t+o)-(t+s)-1,v=3*(i+l)-(i+a)-1;r=Math.hypot(g,v)+n}else if(e.gradientType===2){let g=-1*Math.atan2(t+o-.5+s,i+l-.5+a),v=n/Math.PI/-2+.5*g/Math.PI;r=v-Math.floor(v)}else{let g=.5+o/(t!==0?t:1e-6),v=l/(i!==0?i:1e-6),y=Math.cos(n)*g-Math.sin(n)*v,_=Math.sin(n)*g+Math.cos(n)*v,b=y*y+_*_;r=b>1e-12?(((t-.5+s)/2+y/2)*y+((i-.5+a)/2+_/2)*_)/b:0}let c=u[0][0],p=u[0][1],f=u[0][2],m=u[0][3];for(let g=1;g<d;g++){let v=h[g-1],y=h[g]-v,_=y!==0?Math.min(1,Math.max(0,(r-v)/y)):r>=v?1:0;e.smooth&&(_=_*_*(3-2*_)),c+=(u[g][0]-c)*_,p+=(u[g][1]-p)*_,f+=(u[g][2]-f)*_,m+=(u[g][3]-m)*_}return[c,p,f,m]}function v4e(e,t){let i=e,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let n=t,s=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=AA(o.alpha,1);if(!(l<=0))if(o.type==="color"){let u,h=o.color;typeof h=="string"?u=typeof n?.color=="function"?n.color(h):void 0:h&&typeof h.r=="number"&&(u=h),u&&s.push({kind:"color",layer:o,rgb:{...lre(u.r,u.g,u.b),a:u.a??1},alpha:l})}else o.type==="gradient"&&s.push({kind:"gradient",layer:o,alpha:l})}),s.length===0?null:(a,o)=>{let l=1,u=1,h=1,d=!0;for(let c of s){let p,f,m,g;if(c.kind==="color")({r:p,g:f,b:m}=c.rgb),g=c.rgb.a;else{let[y,_,b,x]=g4e(c.layer,a,o);({r:p,g:f,b:m}=lre(y,_,b)),g=x}let v=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*v,u+=(f-u)*v,h+=(m-h)*v,d=!1}return{r:l,g:u,b:h}}}if(i?.color&&i.color.isColor===!0){let{r:n,g:s,b:a}=i.color;return()=>({r:n,g:s,b:a})}return null}var BM,AA,IH,y4e=U(()=>{oe(),BM=new ot,AA=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t,IH=e=>Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"?[e[0],e[1]]:[0,0]});function _4e(e,t){if(e==="torus"){let l=t()*Math.PI*2,u=t()*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(e==="cylinder"){let l=t()*Math.PI*2,u=Math.cos(l),h=Math.sin(l);return{x:.8*u,y:1.6*(t()-.5),z:.8*h,nx:u,ny:0,nz:h,cr:1,cg:1,cb:1}}let i=t()*Math.PI*2,r=2*t()-1,n=Math.acos(r),s=Math.sin(n)*Math.cos(i),a=Math.cos(n),o=Math.sin(n)*Math.sin(i);return{x:s,y:a,z:o,nx:s,ny:a,nz:o,cr:1,cg:1,cb:1}}function b4e(e){let{geometry:t,matrix:i}=e,r=t.getAttribute("position");if(!r||r.count<3)return null;let n=t.getAttribute("normal"),s=t.getAttribute("uv"),a=t.getAttribute("color"),o=t.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let u=(v,y)=>o?o.getX(3*v+y):3*v+y,h=i?i.elements:null,d=i?new oi().getNormalMatrix(i).elements:null,c=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return h?h[0]*y+h[4]*_+h[8]*b+h[12]:y},p=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return h?h[1]*y+h[5]*_+h[9]*b+h[13]:_},f=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return h?h[2]*y+h[6]*_+h[10]*b+h[14]:b},m=new Float64Array(l),g=0;for(let v=0;v<l;v++){let y=u(v,0),_=u(v,1),b=u(v,2),x=c(y),w=p(y),S=f(y),T=c(_)-x,M=p(_)-w,E=f(_)-S,A=c(b)-x,P=p(b)-w,N=f(b)-S,D=M*N-E*P,O=E*A-T*N,z=T*P-M*A;g+=.5*Math.sqrt(D*D+O*O+z*z),m[v]=g}return g<=0?null:{total:g,sample:(v,y)=>{let _=0,b=l-1;for(;_<b;){let Q=_+b>>1;m[Q]<v?_=Q+1:b=Q}let x=_,w=u(x,0),S=u(x,1),T=u(x,2),M=y(),E=y();M+E>1&&(M=1-M,E=1-E);let A,P,N,D=1-M-E,O=c(w)*D+c(S)*M+c(T)*E,z=p(w)*D+p(S)*M+p(T)*E,L=f(w)*D+f(S)*M+f(T)*E;if(n){if(A=n.getX(w)*D+n.getX(S)*M+n.getX(T)*E,P=n.getY(w)*D+n.getY(S)*M+n.getY(T)*E,N=n.getZ(w)*D+n.getZ(S)*M+n.getZ(T)*E,d){let Q=d[0]*A+d[3]*P+d[6]*N,ue=d[1]*A+d[4]*P+d[7]*N,pe=d[2]*A+d[5]*P+d[8]*N;A=Q,P=ue,N=pe}}else{let Q=c(w),ue=p(w),pe=f(w),xe=c(S)-Q,we=p(S)-ue,re=f(S)-pe,Se=c(T)-Q,W=p(T)-ue,k=f(T)-pe;A=we*k-re*W,P=re*Se-xe*k,N=xe*W-we*Se}let V=Math.sqrt(A*A+P*P+N*N)||1,G=1,Y=1,$=1;if(a)G=a.getX(w)*D+a.getX(S)*M+a.getX(T)*E,Y=a.getY(w)*D+a.getY(S)*M+a.getY(T)*E,$=a.getZ(w)*D+a.getZ(S)*M+a.getZ(T)*E;else if(e.sampleColor){let Q=s?s.getX(w)*D+s.getX(S)*M+s.getX(T)*E:.5,ue=s?s.getY(w)*D+s.getY(S)*M+s.getY(T)*E:.5,pe=e.sampleColor(Q,ue);pe&&(G=pe.r,Y=pe.g,$=pe.b)}return{x:O,y:z,z:L,nx:A/V,ny:P/V,nz:N/V,cr:G,cg:Y,cb:$}}}}function hre(e){let t=Math.min(Math.max(1,Math.floor(e.guideStrands)),Px),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}}(e.seed??1337),r=e.shape==="object"&&e.sampler,n=r?e.samplerRadius??od:od,s=new Float32Array(4*tf),a=new Float32Array(tf),o=new Float32Array(4*Px).fill(1);for(let l=0;l<t;l++){let u=r?e.sampler(i):_4e(e.shape,i),h=r?u.x:u.x*n,d=r?u.y:u.y*n,c=r?u.z:u.z*n,{nx:p,ny:f,nz:m}=u;o[4*l+0]=u.cr,o[4*l+1]=u.cg,o[4*l+2]=u.cb;let g,v,y,_=l*jv,b=(1.8+.8*i())*e.hairLength*n/(jv-1),x=.5+1.5*i(),w=(.02+.06*i())*n;Math.abs(f)<.99?(g=-m,v=0,y=p):(g=1,v=0,y=0);let S=Math.sqrt(g*g+v*v+y*y)||1;for(let T=0;T<jv;T++){let M=T/(jv-1),E=M*M*.4*n,A=w*Math.sin(M*x*Math.PI*2),P=4*(_+T);s[P+0]=h+p*b*T+A*g/S,s[P+1]=d+f*b*T-E+A*v/S,s[P+2]=c+m*b*T+A*y/S,s[P+3]=T===0?0:1,T<jv-1&&(a[_+T]=b)}}return{initialPositions:s,restLengths:a,unitScale:n,rootColors:o}}var jv,Px,tf,od,fg,WS,$1,O0,X1,FI,Uxe=U(()=>{oe(),tf=(Px=16384)*(jv=32),od=100}),zxe=U(()=>{oe(),Ia(),FY(),y4e(),Uxe(),fg=1/60,WS=new Ue,$1=new kt,O0=new R,X1=new R,FI=class extends Ms{constructor(e,t,i){super(e,t),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 kt,this.lastBonePos=new R,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=t,this.geometry.setAttribute("position",new Rt(new Float32Array(0),3)),this.material=new Zl({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new Tr(new Vf(od,48,32),new Zl({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new nL;r.setAttribute("position",new Rt(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new Tr(r,new Zl({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=t.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:t.guideStrands,hairLength:t.hairLength,spreadRadius:t.spreadRadius,headShape:t.headShape,baseObjectId:t.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,4*fg*2),this.trackMotionRest(e/1e3))}trackMotionRest(e){this.boneTransform($1,O0);let t=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot($1))<.9999995||this.lastBonePos.distanceToSquared(O0)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||t||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy($1),this.lastBonePos.copy(O0),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+e}motionFingerprint(){let e=this.data;return e.gravity+2*e.damping+3*e.localStiffness+4*e.globalStiffness+5*e.globalRange+6*e.stiffnessFalloff+7*e.windStrength+8*e.vspCoefficient+9*e.kink+10*e.kinkFrequency+11*e.clumpStrength+12*e.clumpSize+13*e.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(e){this.playModeActive=e,e&&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(e,t){super.updateState(e,t),this.updateHairState(e)}updateHairState(e){if((e.guideStrands!==void 0||e.hairLength!==void 0||e.spreadRadius!==void 0||e.headShape!==void 0||e.baseObjectId!==void 0)&&this.regenerate(),(e.headShape!==void 0||e.baseObjectId!==void 0)&&this.applyScalpState(),e.headColor!==void 0){let t=this.scalpMesh.material;t.isMeshBasicMaterial===!0&&t.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,Xi)}(e.castShadow!==void 0||e.receiveShadow!==void 0)&&this.applyShadowState(),e.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,t=this.data.receiveShadow??!0;this.castShadow=e,this.receiveShadow=t,this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=t,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=t}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 e=this.data,t=this.regenSnapshot;if(t===null||t.guideStrands!==e.guideStrands||t.hairLength!==e.hairLength||t.spreadRadius!==e.spreadRadius||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId){let i=t===null||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:t,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,e==="object"&&t){let n=this.context.scene.find(t);if(n){this.baseFoundAtRegen=!0,n.updateWorldMatrix(!0,!0);let s=this.collectBaseSources(n),a=s?function(o){let l=[];for(let d of o){let c=b4e(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,f=l.length-1;for(;p<f;){let g=p+f>>1;u[g]<c?p=g+1:f=g}let m=p===0?c:c-u[p-1];return l[p].sample(m,d)}}(s.sources):null;if(this.baseSourceGeomsAtRegen=s?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=s?.hashes??[],this.baseColorHashAtRegen=s?.colorHash??0,s&&a){let o=this.baseWorldScale(n),l=Math.max(s.radius*o,.001);this.baseScaleAtRegen=o;let u=o;return hre({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 hre({shape:e==="object"?"sphere":e,guideStrands:i,hairLength:r})}collectBaseSources(e){let t=[],i=[],r=0,n=0;WS.copy(e.matrixWorld).invert();let s=WS.clone(),a=o=>{if(o.isHairSystem===!0||o!==e&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let u=o===e?void 0:new Ue().multiplyMatrices(s,o.matrixWorld),h=Array.isArray(o.material)?o.material[0]:o.material;t.push({geometry:l,matrix:u,sampleColor:v4e(h,this.context.shared)??void 0}),i.push(FI.matrixHash(u)),n+=function(c,p){let f=c,m=0,g=1,v=_=>{m+=_*g,g+=1},y=f?.data?.layers;if(y&&typeof y.forEach=="function"){let _=p;y.forEach(b=>{let x=b.data;if(x.visible!==!1){if(x.type==="color"){let w=x.color,S=typeof w=="string"?typeof _?.color=="function"?_.color(w):void 0:w;S&&typeof S.r=="number"&&(v(S.r),v(S.g),v(S.b)),v(AA(x.alpha,1))}else if(x.type==="gradient"){let w=x;for(let S of w.colors??[])v(S[0]),v(S[1]),v(S[2]),v(S[3]);for(let S of w.steps??[])v(S);v(AA(w.angle,0)),v(w.gradientType),v(w.smooth?1:0)}}})}else f?.color&&f.color.isColor===!0&&(v(f.color.r),v(f.color.g),v(f.color.b));return m}(h,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;u?(O0.copy(d.center).applyMatrix4(u),c=O0.length(),p=FI.matrixMaxScale(u)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let u of o.children)a(u)};return a(e),t.length===0?null:{sources:t,hashes:i,radius:Math.max(r,.001),colorHash:n}}static matrixHash(e){if(!e)return 0;let t=e.elements,i=0;for(let r=0;r<16;r++)i+=t[r]*(r+1);return i}static matrixMaxScale(e){let t=e.elements,i=Math.hypot(t[0],t[1],t[2]),r=Math.hypot(t[4],t[5],t[6]),n=Math.hypot(t[8],t[9],t[10]);return Math.max(i,r,n,1e-6)}baseWorldScale(e){return WS.copy(e.matrixWorld).decompose(O0,$1,X1),Math.max(Math.abs(X1.x),Math.abs(X1.y),Math.abs(X1.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 e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen)return void this.regenerate();e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),i=t?.sources??[],r=t?.hashes??[],n=this.baseSourceGeomsAtRegen,s=this.baseSourceHashesAtRegen,a=i.length!==n.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==n[o]||Math.abs(r[o]-s[o])>1e-4*Math.max(Math.abs(s[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(t?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(e);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let e=this.data.headShape,t=e==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!t,!t&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=e==="torus"?new rL(1.4*od,.7*od,24,48):e==="cylinder"?new mE(.8*od,.8*od,1.6*od,48,1):new Vf(od,48,32))}boneTransform(e,t){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)}WS.copy(i).decompose(t,e,X1)}raycast(e,t){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(e,i);for(let r of i)r.object=this,t.push(r)}get shadowBoundsRadius(){let e=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(e+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(e){return this.boneTransform($1,e),e}updateEntityBoxSize(e,t){let i=this.shadowBoundsRadius;e.set(0,0,0),t.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),NH()?.release(this)}}});function UI(){return{shapeInput:()=>`
|
|
4178
|
+
`&&A.push("")):S.getTextWidth(A[A.length-1]+P,w)>E&&(A[A.length-1].length&&A.push(""),S.getTextWidth(A[A.length-1]+P,w)>E&&(P.length===1?(A[A.length-1]+=P,P=""):(A[A.length-1]+=P.slice(0,-1),P=P[P.length-1],A.push(""))));return A[A.length-1]+=P,A}(e,i,u===2?c.toUpperCase():u===3?c.toLowerCase():c,t),{shapes:f,charWidths:m,charCoords:g}=i.generateShapes(p,e,t),v=.5*(typeof r=="number"?r:Number(t.getVariable(r))),y=.5*(typeof n=="number"?n:Number(t.getVariable(n))),_=f.map(w=>new ds().fromShape(w,!0));this.vectorShapes=_;let b=_.map(w=>t0.create({shape:w,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:h,extrusionVersion:d,windingRule:s<=0?es.NONZERO:es.ODD,subdivisions:this.isLowResolution&&s>0?1:12}})),x=b.length?Qv(b):zie();x.translate(-v,y,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([w,S])=>{this.setAttribute(w,S)}),this.setIndex(x.index),this.adoptNearSide(b,s),this.computeBoundingSphere()}adoptNearSide(e,t){this._depth=t;let i=0,r=0,n=0;for(let o of e){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),n=l._vScale??n}this._effectiveBevel=r,this._vScale=n;let s=new Uint8Array(i),a=0;for(let o of e){let l=o._nearSide;s.set(l,a),a+=l.length}this._nearSide=s}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length===this.getAttribute("position")?.count&&ix(this._effectiveBevel,e)&&ix(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position"),r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=t,u===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=Wo(new At,fH.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}}});function l4e(e){if(!mH)return Vie||(Vie=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build",i=import("./process.js"),[r,n]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});xxe(a),mH=!0}())}var xxe,xY,mH,Vie,uB=U(()=>{xY=new Promise(e=>{xxe=e}),mH=!1});function m5(e,t){if(Object.keys(e.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let i=Object.keys(e.attributes),r=Object.keys(t.attributes);if(i.length!==r.length)return!1;for(let l of r){let u=e.attributes[l],h=t.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 n=e.index,s=t.index;if(n===null!=(s===null))return!1;let a=!1;if(n!==null&&s!==null){if(n.array.length!==s.array.length)return!1;let l=n.array.constructor,u=s.array.constructor;if(l!==u){if(l!==Uint32Array||u!==Uint16Array)return!1;a=!0}}if(e.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let u=e.groups[l],h=t.groups[l];if(u.start!==h.start||u.count!==h.count||u.materialIndex!==h.materialIndex)return!1}for(let l of r){let u=e.attributes[l],h=t.attributes[l];u.array.set(h.array),u.needsUpdate=!0}let o=e.takeDepthStateFrom;if(typeof o=="function"&&o.call(e,t),n!==null&&s!==null){if(a){let l=n.array,u=s.array;for(let h=0,d=u.length;h<d;h++){let c=u[h];l[h]=c===65535?4294967295:c}}else n.array.set(s.array);n.needsUpdate=!0}return e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e.boundingBox=null,e.boundingSphere=null,!0}function gH(e,t,i,r){let n,s,a,o=e.position.array,l=e.normal.array,u=wxe.makeScale(t,i,r).invert().elements;for(let h=0,d=o.length;h<d;h+=3)o[h]*=t,o[h+1]*=i,o[h+2]*=r,n=l[h],s=l[h+1],a=l[h+2],l[h]=u[0]*n+u[4]*s+u[8]*a,l[h+1]=u[1]*n+u[5]*s+u[9]*a,l[h+2]=u[2]*n+u[6]*s+u[10]*a;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var wxe,Sxe=U(()=>{oe(),wxe=new Ue});function vH(e){let t=Number(e);return Number.isInteger(t)&&t>=0&&String(t)===e?t:-1}function A3(e){if(e!=null){if(Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView))return e;if(typeof e=="object")return function(t){let i=Object.keys(t),r=0;for(let s of i){let a=vH(s);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let n=new Array(r);for(let s=0;s<r;s++){let a=t[s];if(typeof a!="number")return;n[s]=a}return n}(e)}}function g5(e){if(e==null)return"missing";if(Array.isArray(e))return`Array(${e.length})`;if(ArrayBuffer.isView(e)){let l=e;return`${e.constructor.name}(${l.length})`}if(typeof e!="object")return typeof e;let t=Object.keys(e),i=t.filter(l=>vH(l)===-1),r=0;for(let l of t){let u=vH(l);u>=r&&(r=u+1)}let n=e,s=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):s===-1&&(s=l);let o=[`${t.length} keys`,"max index "+(r-1)];return s!==-1&&o.push(`first missing index ${s}`),a!==-1&&o.push(`non-number at ${a} (${typeof n[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function Txe(e){let t=Object.keys(e);return t.length===1&&t[0]==="subdivisions"}function wY(e,t){let i=t?t.count:e.count,r=0,n=1e4,s=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let d=t?t.getX(h):h,c=e.getX(d),p=e.getY(d),f=e.getZ(d),m=Math.round(c*n),g=Math.round(p*n),v=Math.round(f*n),y=s.get(m);y===void 0&&(y=new Map,s.set(m,y));let _=y.get(g);_===void 0&&(_=new Map,y.set(g,_));let b=_.get(v);b===void 0&&(b=r++,_.set(v,b),o.push(c,p,f)),a[h]=b}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(t?t.getX(h):h,t?t.getX(h+1):h+1,t?t.getX(h+2):h+2));return{positions:o,triIndices:l,triOriginals:u}}var VS,I0,ri,v5,y5,_5,us,GS,C3,P3,R3,yH,LI,bw=U(()=>{oe(),uB(),jt(),dB(),Sxe(),wA(),VS=new fn,I0=new R,xY.then(e=>{ri=e}),v5=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),y5=new Uint32Array([0,1,2,3]),_5=new Uint8Array([4]),us=class extends At{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=Ug.div(t.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&gH(this.subdividedGeometry.attributes,...r),this.originalGeometry&&gH(this.originalGeometry.attributes,...r),this.data=e;let n=this.userData.parameters;this.userData.parameters={width:n.width*r[0],height:n.height*r[1],depth:n.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(I0.fromArray(r));let s=I0.set(n.width,n.height,n.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let t=e.phongAngle??35;this.flatShading&&(t=-1);let i=null;if(e.subdivisions>0){let n=0;try{n=us.allocate(e),i=us.buildRefined(n,e.subdivisions,t)}catch(s){console.error(s,e)}finally{n&&us.freeSubdivPointer(n)}}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 e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Dh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??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 e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new qa,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;VS.setFromBufferAttribute(t),VS.getCenter(i),e.boundingSphere.radius=i.distanceTo(VS.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),VS.getSize(I0);let r={width:I0.x,height:I0.y,depth:I0.z};return this.userData.parameters=r,r}static build(e,t,i,r){let n,s,a=e?.phongAngle??35;i===!1&&(a=-1),t&&(ri.free_bvh(t),ri.free_subdivision_surface(t));try{n=us.allocate(e,r)}catch(l){console.error(l,e),n=us.allocate({positionWASM:v5,indexWASM:y5,verticesPerFaceWASM:_5},r)}ri.set_destination_refinement_level(n,0);let o=us.buildLevel(n,!0,a);return s=e.subdivisions>0?us.buildRefined(n,e.subdivisions,a):null,{subdivPointer:n,originalGeometry:o,subdividedGeometry:s}}static buildRefined(e,t,i){try{return ri.set_destination_refinement_level(e,t),us.buildLevel(e,!1,i)??null}catch{try{return ri.set_destination_refinement_level(e,t-1),us.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r,n=e.shape!==void 0||e.path!==void 0?t.geometry:Ng(e,i,!1,t);r=pbe(e)?n.getClosedTorusIndicesForBooleanOrSubdiv():n.getIndex();let s,{positions:a,triIndices:o,triOriginals:l}=wY(n.getAttribute("position"),r);if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2;s=[c,c+3*e.radialSegments]}let{indices:u,verticesPerFace:h,uvs:d}=function(c,p,f,m,g){let v=[],y=[],_=g?f.getAttribute("uv"):void 0,b=_&&_.itemSize===2?[]:void 0,x=T=>{if(b){let M=g[T];b.push(_.getX(M),_.getY(M))}};if(f.userData.shape!==void 0&&f.userData.parameters.depth===0&&f.userData.shape.shapeHoles.length===0){let T=f.userData.shape.extractShapePointsToFlatArray([]),M=f.userData.parameters.spikes;if(f.userData.type==="EllipseGeometry"&&M<=24&&M%4==0&&f.userData.parameters.angle>=360){let P=T.length/2/M;T=T.filter((N,D)=>Math.floor(D/2)%P===0)}let E=0;for(let P=0;P<T.length;P+=2)E+=(T[P]-T[(P===0?T.length:P)-2])*(T[P+1]+T[(P===0?T.length:P)-1]);c.length=0;let A=0;if(E<0)for(let P=0;P<T.length;P+=2)c.push(T[P],T[P+1],0),v.push(A++);else for(let P=T.length-2;P>=0;P-=2)c.push(T[P],T[P+1],0),v.push(A++);return y.push(A),{indices:v,verticesPerFace:y}}let w=new Float32Array([f.userData.parameters.depth])[0],S=0;for(;S<p.length;){if(f.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[S]+2]===w||c[3*p[S]+2]===0)&&T++,(c[3*p[S+1]+2]===w||c[3*p[S+1]+2]===0)&&T++,(c[3*p[S+2]+2]===w||c[3*p[S+2]+2]===0)&&T++,T===3)break}if(p[S+1]===p[S+3]&&p[S+2]===p[S+5]||p[S+0]===p[S+3]&&p[S+2]===p[S+4]){GS.set(c[3*p[S]],c[3*p[S]+1],c[3*p[S]+2]),C3.set(c[3*p[S+1]],c[3*p[S+1]+1],c[3*p[S+1]+2]),P3.set(c[3*p[S+4]],c[3*p[S+4]+1],c[3*p[S+4]+2]),R3.set(c[3*p[S+5]],c[3*p[S+5]+1],c[3*p[S+5]+2]),C3.sub(GS).normalize(),P3.sub(GS).normalize(),R3.sub(GS).normalize();let T=C3.cross(P3).dot(R3),M=S;Math.abs(T)>.005||m&&m.some((E,A)=>A%2!=1&&M>=m[A]&&M<m[A+1])?(v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3):(v.push(p[S],p[S+1],p[S+4],p[S+5]),x(S),x(S+1),x(S+4),x(S+5),y.push(4),S+=6)}else v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3}if(f.useNgonForTopBottomFaceDuringBake){let T=[],M=[],E=0;for(let A=0,P=0;A<c.length;A+=3,P++)c[A+2]===0&&(T.push(P),E++),c[A+2]===w&&M.push(P);if(f.userData.parameters.extrudeBevelSize===0){let A=M[0];M[0]=M[1],M[1]=A}T.reverse(),v.push(...T,...M),y.push(E,E),b=void 0}return{indices:v,verticesPerFace:y,uvs:b}}(a,o,n,s,l);return{positions:a,indices:u,verticesPerFace:h,uvs:d}}static allocate(e,t){let i,r,n,s=[],a=[],o=A3(e.positionWASM),l=A3(e.indexWASM),u=A3(e.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${g5(e.positionWASM)}, indexWASM ${g5(e.indexWASM)}, verticesPerFaceWASM ${g5(e.verticesPerFaceWASM)}`);i=o,r=l,n=u;let S=A3(e.uvWASM);ri.alloc_subdivision_surface_uvs&&S&&S.length===2*r.length&&(a=S)}else i=v5,r=y5,n=_5;let h=i.length,d=r.length,c=n.length,p=i.length+s.length+a.length,f=r.length+n.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,v=ri._malloc(m);if(!v)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${m}) failed`);let y,_=new Float32Array(ri.HEAPF32.buffer,v,p),b=new Uint32Array(ri.HEAPU32.buffer,v+g,f);_.set(i,0),_.set(s,i.length),_.set(a,i.length+s.length),b.set(r,0),b.set(n,r.length),e?.scaleBaked?.some(S=>S!==1)&&(y=new Ue().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),t&&(y?y.premultiply(t):y=t);let x=v+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,w=a.length?y?ri.alloc_subdivision_surface_uvs2(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,y.elements):ri.alloc_subdivision_surface_uvs(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):y?ri.alloc_subdivision_surface2(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,y.elements):ri.alloc_subdivision_surface(v,h,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return ri._free(v),w}static buildLevel(e,t,i,r,n,s=!1){let a=n?ri.get_mesh_data2(e,t?ri.Level.CONTROL:ri.Level.REFINED,i,n.elements):ri.get_mesh_data(e,t?ri.Level.CONTROL:ri.Level.REFINED,i),o=ri.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),u=0,h=ri.HEAPU32[o[u]>>2],d=ri.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let c=ri.HEAPU32[o[u]>>2],p=ri.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let f=ri.HEAPU32[o[u]>>2],m=ri.HEAPU32.subarray(f>>2,(f>>2)+l[u]);u++;let g,v=ri.HEAPU32[o[u]>>2],y=ri.HEAPU32.subarray(v>>2,(v>>2)+l[u]);if(u++,ri.alloc_subdivision_surface_uvs){let b=o[9];if(b>0){let x=ri.HEAPU32[o[8]>>2];g=ri.HEAPF32.subarray(x>>2,(x>>2)+b)}}if(r===void 0){let b=new At;if(b.setIndex(new kf(y,1)),b.setAttribute("position",new Et(d,3)),b.setAttribute("normal",new Et(p,3)),g&&b.setAttribute("uv",new Et(g,2)),t){b.setAttribute("faceMap",new kf(m,1));let x=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Rt(x,4))}return ri.free_mesh_data(a),b.userData.type="SubdivGeometry",b}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,s){let b=r.getIndex();b!==null&&b.array.length===y.length&&(b.copyArray(y),b.needsUpdate=!0)}let _=r.getAttribute("uv");g&&_&&_.array.length===g.length&&(_.copyArray(g),_.needsUpdate=!0),ri.free_mesh_data(a)}static freeSubdivPointer(e){ri.free_bvh(e),ri.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ri.get_wireframe_data_for_base_level(e),n=ri.HEAPU32.subarray(r>>2,4+(r>>2)),s=n.subarray(2,4),a=0,o=ri.HEAPU32[n[a]>>2],l=ri.HEAPF32.subarray(o>>2,(o>>2)+s[a]);a++;let u=ri.HEAPU32[n[a]>>2],h=ri.HEAPU32.subarray(u>>2,(u>>2)+s[a]);if(t===void 0){let d=new At;d.setAttribute("position",new Et(l,3));let c=new Float32Array(l.length);for(let p=0,f=l.length;p<f;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new Rt(c,3)),d.setIndex(new kf(h,1)),ri.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(l),t.attributes.position.needsUpdate=!0,ri.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ri.set_destination_refinement_level(e,t);let n=i?ri.get_topological_data2(e,r?ri.Level.CONTROL:ri.Level.REFINED,i.elements):ri.get_topological_data(e,r?ri.Level.CONTROL:ri.Level.REFINED),s=ri.HEAPU32.subarray(n>>2,8+(n>>2)),a=s.subarray(3,6),o=0,l=ri.HEAPU32[s[o]>>2],u=new Float32Array(ri.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=ri.HEAPU32[s[o]>>2],d=new Uint32Array(ri.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let c,p=ri.HEAPU32[s[o]>>2],f=new Uint8Array(ri.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(ri.alloc_subdivision_surface_uvs){let m=s[7];if(m>0){let g=ri.HEAPU32[s[6]>>2];c=new Float32Array(ri.HEAPF32.subarray(g>>2,(g>>2)+m))}}return ri.free_topological_data(n),{positions:u,indices:d,verticesPerFace:f,uvs:c}}},GS=new R,C3=new R,P3=new R,R3=new R}),Mxe=U(()=>{sie(),aie(),BL(),oie(),kL(),wA(),Eie(),Aie(),Cie(),cH(),Die(),VL(),Nie(),Iie(),Oie(),pH(),Lie(),Bie(),Fie(),Uie(),qg(),_r(),sie(),aie(),BL(),oie(),kL(),a4e(),wA(),Eie(),Aie(),Cie(),cH(),Die(),VL(),Nie(),Iie(),Oie(),pH(),Lie(),Bie(),Fie(),Uie(),qg(),o4e(),Zbe(),bxe(),bw(),uB(),aB(),_w(),yH={ConeGeometry:Nbe,CubeGeometry:Ibe,CylinderGeometry:pY,DodecahedronGeometry:Obe,EllipseGeometry:lB,HelixGeometry:fbe,IcosahedronGeometry:axe,LatheGeometry:oxe,NonParametricGeometry:hxe,PolygonGeometry:_Y,PyramidGeometry:uxe,RectangleGeometry:hB,SphereGeometry:pxe,PlaneGeometry:fxe,BackdropGeometry:mxe,StarGeometry:bY,TextFrameGeometry:gxe,TorusGeometry:vxe,TorusKnotGeometry:yxe,TriangleGeometry:_xe,VectorGeometry:t0},LI=e=>{let t=yH[e.type]??tbe(e.type);if(t===void 0)throw new Error(`No geometry factory registered for "${e.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(e)}});function Ng(e,t,i,r){let n,s,a;e.type==="PathGeometry"?(s={...e,extrusion:{...e.extrusion}},a=[[],["extrusion"]]):(s={...e},a=[[]]);for(let u of a){let h=s;for(let d of u)h=h[d];for(n in h){let d=h[n];Mee(d)&&!Exe.includes(n)&&(h[n]=t.getVariable(d,[r.uuid,"geometry",...u,n]),Mee(h[n])&&(h[n]=1))}}let o,l={parameters:s,type:s.type};if(s.type==="PathGeometry"){l.path=s.path;let u=r.profileShape;u!==void 0&&(l.shapeData=u),l.ownerId=r.uuid}else if(s.type==="VectorGeometry"){let u=ds.createFromState(s.shape,s.width,s.height);l.shape=u,l.ownerId=r.uuid}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),l.geometry=new TX().parse(s),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(s.type==="SubdivGeometry"){let u=new us(s,i);return u.data=e,u}if(s.type==="TextGeometry"||s.type==="InputGeometry"){let u=tbe(s.type);if(u)return u.create(s,t);Ma("text",`a ${s.type}`);let h=ds.createFromState(yA.defaultData(),100,100);return LI({...s,shape:h,type:"VectorGeometry"})}if(s.type==="UIGeometry")return hB.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}try{o=LI(l)}catch(u){console.error(u),console.error(`Error generating geometry with inputs: ${l}`);let h=ds.createFromState(yA.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=LI(l)}return o}var Exe,Gie,_H,dB=U(()=>{jt(),oe(),Mxe(),_r(),VL(),e0(),bw(),Exe=["font"]}),h4e=U(()=>{dB(),Gie=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(e){return this.objects.get(e)}get size(){return this.objects.size}get(e,t,i){let r=this.objects.get(e);return r===void 0?(r=this.createObject(e,t,i),this.objects.set(e,r)):r.isShared=!0,r}forceDelete(e){let t=this.objects.get(e);t&&(this.disposeObject(t),this.objects.delete(e))}adopt(e,t){this.objects.set(e,t)}mutateIfUnique(e,t){let i=this.objects.get(e);if(i&&i.isShared!==!0)return this.objects.delete(e),this.objects.set(t,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(e,t){t===this.objects.get(e)&&this.unreachable.delete(e)}endGc(){this.unreachable.forEach(e=>{this.disposeObject(this.objects.get(e)),this.objects.delete(e)}),this.unreachable.clear()}dispose(){this.objects.forEach(e=>{this.disposeObject(e)}),this.objects.clear()}},_H=class extends Gie{constructor(e){super(),this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,i){let r=Ng(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}}});function GL(){return XA}function Axe(){if(XA==="webgpu"){if(xH!==void 0)return xH;SH||(SH=!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(wH===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 wH}function Cxe(e,t){return Axe().createRootMaterial(e,t)}function jie(e,t,i){return Axe().createSharedMaterial(e,t,i)}function Wie(e){return e.getLayersOfType===void 0&&Object.assign(e,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),e}function bH(){return Rxe}var XA,xH,wH,SH,TH,Pxe,Rxe,MH,Dxe,Yf=U(()=>{XA="webgl",SH=!1}),u4e=U(()=>{Dxe={markNeedsUpdateRendererDirty:()=>{}}});function Sd(e,t){let i=0;if(!e.layers||e.layers.length===0)return!1;let r=e.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,s=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?s/100:n.alphaOverride)<1)return!0}for(let n of e.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="cavity"&&n.data.type!=="dust"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let s=n.data.visible?n.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let a of n.data.colors)if(a[3]<1){s=a[3];break}}else if(s===1&&n.data.type==="noise"){let a=t.color(n.data.colorA).a,o=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,u=t.color(n.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,u)));h<1&&(s=h)}i+=(1-i)*s}}return i<1}var cB=U(()=>{});function Gf(e){return typeof e=="string"||typeof e=="number"&&e!==0}var Oh,Lt,xw,SY,Hie,qie,Ph,Ed=U(()=>{Oh=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?100*e:e,i)??100)/100))??1,Lt=(e,t,i)=>typeof e=="number"?e:t.getVariable(e,i),xw={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"]},SY={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),ww=U(()=>{oe(),HA(),Hie=class extends rB(un){},qie=e=>e.type==="Mesh",Ph=class extends Hie{constructor(e){super(),this.object=e,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Ph(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return(e===void 0||this.parent!==e||!e.instancingActive&&!e.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return qie(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}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(e){}}});function $ie(){return TY}var TY,MY,EY=U(()=>{TY=null,MY=null});function EH(e){return"variable_"+e}var b5,x5,w5,Xie,S5,Yie,T5,Kie,jL,AY=U(()=>{jt(),Sbe(),Cbe(),oB(),bu(),uY(),cY(),h4e(),Yf(),Mbe(),u4e(),cB(),Ed(),xl(),ww(),Ir(),oe(),EY(),_r(),b5=new Ue,x5=new R,w5=new kt,Xie=new R,S5=new Kr,Yie=class extends xbe{constructor(e){super(),this.shared=e}create(e){return new hY(e,this.shared)}},T5=new Set,(jL=Kie=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new _H(!0),this.geometryCache2=new _H(!1),this.imageHolderCache=new Yie(this),this.thisContext={scene:Dxe,shared:this},this.deletedImage=new Rc(zW.emptyImage,this),this.deletedVideo=new Rc(_L.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,t.images)for(let[n,s]of Object.entries(t.images))this.addImage(n,s);if(t.videos)for(let[n,s]of Object.entries(t.videos))this.addVideo(n,s);if(t.audios)for(let[n,s]of Object.entries(t.audios))this.addAudio(n,s);if(t.particles)for(let[n,s]of Object.entries(t.particles))this.addParticle(n,s);this.reset(e)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=jie(ns.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:r,data:n}of e.variables)this.addVariableHolder(r,n),t&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(e.userAPIs??{}))this.addUserAPI(r,n);for(let[r,n]of Object.entries(e.userWebhooks??{}))this.addUserWebhook(r,n);if(!i){for(let[r,n]of Object.entries(e.images))this.addImage(r,n);for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n)}for(let[r,n]of Object.entries(e.colors))this.addColor(r,n);for(let[r,n]of Object.entries(e.lib.materials))this.addMaterial(r,n.asset);for(let[r,n]of Object.entries(e.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(e.particles))this.addParticle(r,n);for(let[r,n]of Object.entries(e.fonts))this.addFont(r,n)}addMaterial(e,t){if(t.layers===void 0&&(t={...t,layers:ns.defaultTwoLayerData("phong").layers}),this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=jie(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):e==null?(console.error("material is undefined or null"),this.deletedMaterial):(e.layers===void 0&&(e={...e,layers:ns.defaultTwoLayerData("phong").layers}),Cxe(e,this.thisContext))}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new Rc(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new Rc(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}getEntityTexture(e,t={}){let i=e.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let n=r.root??r;for(let s of n?.data?.layers??[]){let a=s?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||t.layer!==void 0&&s.id!==t.layer&&a.type!==t.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:s.id,layerType:a.type}}}return null}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new Rc(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return typeof e=="string"?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):(this.colors[e]=new MA(t.r,t.g,t.b,"a"in t?t.a:1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if(typeof e!="string")return new zr(e.r,e.g,e.b,"a"in e?e.a:1);{let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new zr(0,0,0,0))}return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof tx)return t;{let i=new tx({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof tx&&t.dispose(),delete this.audios[e])}addFont(e,t){let i=dY;i!==null?(this.fonts[e]=new i(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())):Ma("text","a font asset")}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof tx&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(this.variables[e]===void 0){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(EH(e));i=r!==null?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)this.variables[e].dynamicVariablePlayState!==void 0&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(this.variables[e]===void 0)return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(EH(e),JSON.stringify(t));let i=t;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,n=!1;for(let s=this.variables[e].locations.length-1;s>=0;s--){let a=this.variables[e].locations[s];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[e].locations.splice(s,1);continue}if(n=!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*ht.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),lr.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 n&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||typeof n.type!="string"||n.type==="VectorGeometry"||n.type==="PathGeometry")return!1;let s=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let u of Object.keys(n))a.set(s(u),u);let o={};for(let[u,h]of Object.entries(t??{})){let d=a.get(s(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=n[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={...n,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(n)&&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(e){let t=e;if(t.component&&(t=t.component),typeof t.chooseGeoemtryCache!="function")return!1;let i=t.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(t.dataPatched=t.data,t.chooseGeoemtryCache(this).forceDelete(i),t.createGeometryDelayed(this.entityOpContext),t.onVariableUpdate(!0),t.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||n.type!=="NonParametricGeometry")return!1;let s=t?.vertices;if(s===void 0||typeof s.length!="number"||s.length<9||s.length%3!=0||s.length/3>Kie.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,u=s instanceof Float32Array?s:Float32Array.from(s),h=u.length/3;if(t.normals!==void 0){if(t.normals.length!==u.length)return!1;a=t.normals instanceof Float32Array?t.normals:Float32Array.from(t.normals)}if(t.uvs!==void 0){if(t.uvs.length!==2*h)return!1;o=t.uvs instanceof Float32Array?t.uvs:Float32Array.from(t.uvs)}if(t.indices!==void 0){let x=h>65535?Uint32Array.from(t.indices):Uint16Array.from(t.indices);if(x.length===0||x.length%3!=0)return!1;for(let w=0;w<x.length;w++)if(x[w]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=n.data,w=x?.index;if(w?.array?.length){let S=(x?.attributes?.position?.array?.length??0)/3;if(h!==S)return function(T,M){let E=`${T}/${M}`;T5.has(E)||(T5.add(E),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${M}. 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,S),!1;l=w}}let d=1/0,c=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;for(let x=0;x<u.length;x+=3){let w=u[x],S=u[x+1],T=u[x+2];w<d&&(d=w),w>f&&(f=w),S<c&&(c=S),S>m&&(m=S),T<p&&(p=T),T>g&&(g=T)}let v=(x,w)=>({array:x,itemSize:w,type:"Float32Array",normalized:!1}),y={position:v(u,3)};a&&(y.normal=v(a,3)),o&&(y.uv=v(o,2));let _={...n,width:f-d,height:m-c,depth:g-p,data:{attributes:y,...l?{index:l}:{}}},b=this.transientGeometryKeys.has(n);return i.dataPatched={...r,geometry:_},this.transientGeometryKeys.add(_),i.applyTransientGeometryData(this.entityOpContext,b),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(e,t){let i=e;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let n=r.children,s=Math.PI/180,a=!1;if(t===null)for(let o of n)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(t))return n.length;{let o=Math.min(t.length,n.length);for(let l=0;l<o;l++){let u=t[l],h=n[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*s),typeof u.rotation.y=="number"&&(d.rotation[1]=u.rotation.y*s),typeof u.rotation.z=="number"&&(d.rotation[2]=u.rotation.z*s)),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(),n.length}spawnRuntimeClone(e,t={}){if(typeof e.entityChildren!="function")return;let i=e.parent;if(i===null)return;let r=new Ph(e);r.playModeVisible=t.visible!==!1,r.expand(),typeof t.name=="string"&&(r.name=t.name);let n=Math.PI/180;return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),r.hiddenMatrix.copy(e.hiddenMatrix),t.position&&(typeof t.position.x=="number"&&(r.position.x=t.position.x),typeof t.position.y=="number"&&(r.position.y=t.position.y),typeof t.position.z=="number"&&(r.position.z=t.position.z)),t.rotation&&(typeof t.rotation.x=="number"&&(r.rotation.x=t.rotation.x*n),typeof t.rotation.y=="number"&&(r.rotation.y=t.rotation.y*n),typeof t.rotation.z=="number"&&(r.rotation.z=t.rotation.z*n)),t.scale&&(typeof t.scale.x=="number"&&(r.scale.x=t.scale.x),typeof t.scale.y=="number"&&(r.scale.y=t.scale.y),typeof t.scale.z=="number"&&(r.scale.z=t.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(e){e.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(e,t){let i=e.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 n={scene:this.entityOpContext.scene,shared:this},s=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=u=>{if(typeof u=="string"){let h=new zr(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 MA?u.setValue(h,new zr(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(t.color!==void 0){let c=a(t.color),p=h.find(m=>m.data.type==="color"),f=p&&d(p.id);if(c&&f&&o(f,"color",c)&&(l=!0,c.a!==void 0)){let m=c.a<1||Sd(u.data,this);u.setTransparent?u.setTransparent(m,n.scene):u.transparent=m}}typeof t.alpha=="number"&&isFinite(t.alpha)&&(u.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(t.alpha,100)),n),l=!0);for(let c of t.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?h.find(v=>v.id===c.id):typeof c.index=="number"?h[c.index]:typeof c.type=="string"?h.find(v=>v.data.type===c.type):void 0,f=p&&d(p.id);if(!p||!f)continue;let m=xw[p.data.type]??[],g=Object.keys(p.data);for(let[v,y]of Object.entries(c)){if(v==="id"||v==="index"||v==="type")continue;let _=g.find(x=>x===v)??g.find(x=>s(x)===s(v))??v;if(m.includes(_))continue;let b=a(y);if(b&&o(f,_,b))l=!0;else if(typeof y=="number"&&isFinite(y))u.onVariableUpdate?.(["layer",p.id,_],y,n),l=!0;else if(Array.isArray(y)&&y.length<=3&&y.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];y.forEach((w,S)=>{u.onVariableUpdate?.(["layer",p.id,_,x[S]],w,n)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(e){this.variables[e]&&delete this.variables[e]}getVariable(e,t){if(Array.isArray(e)){if(e[0]==="mouse")return this.mouseProperty?.[e[1]]??0;if(e[0]==="raycast")return this.raycastProperty?.[e[1]]??0;let i=this.entityOpContext.scene.find(e[0]);if(e[1]==="width"||e[1]==="height"||e[1]==="depth")return i.geometry.userData.parameters[e[1]];if((e[1]==="position"||e[1]==="rotation")&&e.length>2&&i?.getPhysicsLocalMatrix?.(b5))return b5.decompose(x5,w5,Xie),e[1]==="position"?x5[e[2]]:(S5.setFromQuaternion(w5,i.rotation.order),S5[e[2]]*ht.RAD2DEG);for(let r=1;r<e.length;r++)i=i[e[r]];return e[1]==="rotation"&&(i*=ht.RAD2DEG),i}for(let i in this.variables){if(t===void 0)break;let r=this.variables[i],n=r.locations?.findIndex(s=>Ta.equal(s,t));n!==void 0&&n!==-1&&r.locations.splice(n,1)}if(typeof e=="string"){let i=e,r=e;do{if(r=i,this.variables[i]===void 0)break;let n=this.variables[i].value;t&&this.variables[r]!==void 0&&this.variables[r].locations.push(t),i=n}while(typeof i=="string");return i}return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){return this.variables[e]?.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){return this.variables[e]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){e.path[0]==="images"?e.path.length===1&&e.type===1?this.addImage(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteImage(e.id):e.path[0]==="videos"?e.path.length===1&&e.type===1?this.addVideo(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVideo(e.id):e.path[0]==="audios"?e.path.length===1&&e.type===1?this.addAudio(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteAudio(e.id):e.path[0]==="particles"?e.path.length===1&&e.type===1?this.addParticle(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteParticle(e.id):e.path[0]==="colors"?e.path.length===1&&e.type===1?this.addColor(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteColor(e.id):e.path[0]==="materials"?e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteMaterial(e.id):e.path[0]==="fonts"?e.path.length===1&&e.type===1?this.addFont(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteFont(e.id):e.path[0]==="variables"?e.path.length===1&&e.type===1?this.addVariableHolder(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVariable(e.id):e.path[0]==="components"&&t.updateByLibOp(e,this)}updateByOp(e,t,i){if(this.data=t,e.path[0]==="images")e.path.length===2&&e.type===0?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addImage(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteImage(e.id);else if(e.path[0]==="videos")e.path.length===2&&e.type===0?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addVideo(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteVideo(e.id);else if(e.path[0]==="audios")e.path.length===2&&e.type===0?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):e.path.length===1&&e.type===1?this.addAudio(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteAudio(e.id);else if(e.path[0]==="particles")e.path.length===2&&e.type===0?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):e.path.length===1&&e.type===1?this.addParticle(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteParticle(e.id);else if(e.path[0]==="colors")e.path.length===2&&e.type===0?this.updateColor(e.path[1],e.props):e.path.length===1&&e.type===1?this.addColor(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteColor(e.id);else if(e.path[0]==="materials")e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data):e.path.length===1&&e.type===2?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(Xa.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if(e.path[0]==="fonts")e.path.length===2&&e.type===0?this.updateFont(e.path[1],e,i):e.path.length===1&&e.type===1?this.addFont(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteFont(e.id);else if(e.path[0]==="variables")e.path.length===2&&e.type===0?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):e.path.length===1&&e.type===4?this.addVariableHolder(e.id,e.data):e.path.length===1&&e.type===5&&this.deleteVariable(e.id);else if(e.path[0]==="userAPIs"){if(e.path.length===1&&e.type===1)this.addUserAPI(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserAPI(e.id);else if(typeof e.path[1]=="string"){let r=t.userAPIs[e.path[1]];if(r){let n=e.type===0&&e.props.debounce===void 0,s=this.getUserAPI(e.path[1]);s!==void 0&&s===this.openAIRealtime?s.update(r):s?.update(r,this,n)}}}else if(e.path[0]==="userWebhooks"){if(e.path.length===1&&e.type===1)this.addUserWebhook(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserWebhook(e.id);else if(typeof e.path[1]=="string"){let r=t.userWebhooks[e.path[1]];r&&this.getUserWebhook(e.path[1])?.update(r)}}else e.path[0]==="lib"&&this.updateLibByOp(Xa.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),n={...this.data.fonts[e],url:t.props.url};r.update(n),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){if(this.userAPIs[e])return this.userAPIs[e].update(t,this),!0;if(this.openAIRealtime?.id===e)return this.openAIRealtime.update(t),!0;if(t.integration?.type==="VoiceAssistant"){let i=MY;return i===null?(Ma("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(t,e,this),!1)}{let i=$ie();return i===null?(Ma("api-services","a user API integration"),!1):(this.userAPIs[e]=i.createUserAPI(e,t,this),!1)}}getUserAPI(e){return this.openAIRealtime?.id===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){if(this.userWebhooks[e])return this.userWebhooks[e].update(t),!0;{let i=$ie();return i===null?(Ma("api-services","a user webhook"),!1):(this.userWebhooks[e]=i.createUserWebhook(e,t),!1)}}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new jL(fu.emptyData())});function Nxe(e){return OL(e)||e?.isTSLNodeMaterial===!0}var bl,M5,E5,A5,Zie,C5,hp,Qie,Jie,jS,Un,Ixe=U(()=>{lY()}),u1=U(()=>{jt(),Ia(),Yf(),Ixe(),Ir(),la(),bl=class extends Ms{setMaterialOverride(e,t){this.materialOverride=Wie(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),t.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),Jr(e.path,["geometry"])&&this.syncShadowCatcher(i),function(r,n){let s=[];if(n.length!==r.length)return null;{let a=0;for(;a<r.length;){if(n[a]==="*")s.push(r[a]);else if(r[a]!==n[a])return null;a+=1}}return s}(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[r,n]of Object.entries(e.props)){let s=this.material[Number(r)],a=i.shared.material(n);a!==s&&bl.disposeOneMaterial(s),this.material[Number(r)]=a}else if(Jr(e.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in t&&typeof t.material!="string"&&r.updateByOp(Xa.drop(e,1),t.material,i)}else if(Jr(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&r<this.material.length){let n=t.materials[r];typeof n!="string"&&this.material[r].updateByOp(Xa.drop(e,2),n,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(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.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 n=this.materialOverride!==void 0;!n&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe,i),t.scene.markNeedsUpdateRendererDirty()),!n&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(a=>t.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe)],t.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!n&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(s.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!n&&(e.flatShading!==void 0||e.wireframe!==void 0||e.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(t)}shadowCatcherActive(){let e=this.dataPatched,t=e.geometry?.type;return e.shadowCatcher===!0&&(t==="RectangleGeometry"||t==="PlaneGeometry")}syncShadowCatcher(e){let t=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=XA==="webgpu"&&TH!==void 0?TH:Pxe;return r===void 0?null:Wie(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=t.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.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,e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.material=e.shared.material(t.material).getFlavor(t.flatShading,t.side,t.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow)}static disposeOneMaterial(e){var t;Nxe(e)&&!function(i){return i?.isClassicSharedMaterial===!0}(t=e)&&t?.isTSLSharedMaterial!==!0&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&e_e(this.material).forEach(e=>{bl.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),wl=U(()=>{jt(),Ir(),AY(),u1(),oe(),dB(),_w(),bw(),Sxe(),M5=new R,E5=new ct,A5=new ct,Zie=new R,C5=new Ue,hp=new Tr,Qie=hp.geometry,Jie=hp.material,jS=new R,Un=class extends bl{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new Ue().fromArray(t.bindMatrix),this.bindMatrixInverse=new Ue)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof At&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof At?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof jL){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=t.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return wL.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return wL.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Jr(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Xa.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var e;super.dispose(),e=this.uuid,zL.delete(e),this._posed=void 0}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(e!==void 0&&e.sxPrev!==void 0)return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,n,s,a=e;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=Ng(d,t,this.data.flatShading,this)}a.scaleBaked?[r,n,s]=a.scaleBaked:{width:r,height:n,depth:s}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,u=typeof n=="number"?n:1,h=typeof s=="number"?s:1;o.sxPrev!==void 0&&gH(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(e)){let r=Ng({...this.data.geometry,...e},t,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&m5(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(e){let t=this.localGeometry;if(t?.shiftDepthTo===void 0)return!1;let i=e;if(typeof i.depth!="number")return!1;let r=t.userData?.parameters;if(r===void 0)return!1;for(let n of Object.keys(i))if(n!=="depth"&&i[n]!==r[n])return!1;return!!t.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(e){for(let t of this.attachedSurfaceCloners)t.update(e)}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){let r=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&Txe(e.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(t),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof At&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=i.shared,s=this.chooseGeoemtryCache(n),a=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=Ng(o,n,this.data.flatShading,this);m5(a,l)?(l.dispose(),a.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}applyTransientGeometryData(e,t){let i=e.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof At&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let a=Ng(r,i,this.data.flatShading,this);return m5(s,a)?(a.dispose(),s.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(e),void this.refreshAttachedPaths(e)}}t&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:n}}of i)this.updateMorphInfluences(r,t.shared.getVariable(n,[this.uuid,"morphTargetInfluences",r]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=t)}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(e,t){let i=this.posedGeometry()?.boundingBox;if(i)return i.getCenter(e),void i.getSize(t).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,.5*r.depth):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?e.fromArray(r.centerOffset):e.setScalar(0),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new ct,i=this.geometry.attributes.skinWeight;for(let r=0,n=i.count;r<n;r++){t.fromBufferAttribute(i,r);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),i.setXYZW(r,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;E5.fromBufferAttribute(r.attributes.skinIndex,e),A5.fromBufferAttribute(r.attributes.skinWeight,e),M5.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){let s=A5.getComponent(n);if(s!==0){let a=E5.getComponent(n);C5.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(Zie.copy(M5).applyMatrix4(C5),s)}}return t.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(e,t){let i=this.posedGeometry();if(i===void 0)return!1;hp.geometry=i,hp.material=this.material,hp.matrixWorld.copy(this.matrixWorld);let r=t.length;hp.raycast(e,t);for(let n=r;n<t.length;n++)t[n].object=this;return hp.geometry=Qie,hp.material=Jie,!0}posedGeometry(){let e=this.skeleton;if(!this.isSkinnedMesh||e===void 0)return;let t=this.geometry,{position:i,skinIndex:r,skinWeight:n}=t.attributes;if(!i||!r||!n)return;let s=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<e.bones.length;d++){let c=e.bones[d];if(!c||!e.boneInverses[d])return;s.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===t&&a.version===i.version&&a.pose.length===s.length&&a.pose.every((d,c)=>d===s[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,u=l?.count===o?l:new Rt(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,jS)),u.setXYZ(d,jS.x,jS.y,jS.z);let h=new At;h.setAttribute("position",u);for(let d of["normal","uv","uv1"]){let c=t.attributes[d];c&&h.setAttribute(d,c)}return h.setIndex(t.index),h.groups=t.groups,h.drawRange=t.drawRange,h.computeBoundingSphere(),h.computeBoundingBox(),this._posed={source:t,version:i.version,pose:s,geometry:h},h}}});function Ax(e){if(Array.isArray(e.material)){for(let t of e.material)if(t.getLayersOfType("outline").length===0)return}else if(!OL(e.material)||e.material.getLayersOfType("outline").length===0)return;e instanceof Un&&e.is2DAndNoDepth?function(t){if(t.geometry.attributes.extrudeNormals||!t.geometry.attributes.position)return;let i=t.geometry.attributes.position.array,r=new Float32Array(i.length),n=new R;for(let s=0;s<i.length;s+=3)n.set(i[s],i[s+1],i[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;t.geometry.setAttribute("extrudeNormal",new Et(r,3))}(e):function(t){if(t.geometry.attributes.extrudeNormal||!t.geometry.attributes.position||!t.geometry.attributes.normal)return;let i=new Map,r=t.geometry.attributes,n=r.position.array,s=r.normal.array,a=new Float32Array(n.length);for(let o=0;o<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,u=new R(s[o],s[o+1],s[o+2]);i.has(l)?i.get(l)?.normals.push(u):i.set(l,{normals:[u],result:new R})}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<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,u=i.get(l)?.result;u&&(a[o]=u.x,a[o+1]=u.y,a[o+2]=u.z)}t.geometry.setAttribute("extrudeNormal",new Et(a,3))}(e)}function P5(e){return Math.min(2047,Math.max(1,Math.round(2048*e)))/2048}function Cx(e){if(!e.geometry.attributes.position)return;let t=e.geometry.attributes,i=t.position.array,r=t.randomColor;if(r!==void 0&&3*r.count===i.length)return;let n=new Float32Array(i.length),s=parseInt(e.uuid.replace(/\D/g,"")),a=[P5(ht.seededRandom(s)),P5(ht.seededRandom(s+1e4)),P5(ht.seededRandom(s+2e4))];for(let o=0;o<i.length;o++)n[o]=a[o%3];e.geometry.setAttribute("randomColor",new Rt(n,3))}var pB=U(()=>{oe(),lY(),wl()});function ere(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}function d4e(e,t){let i=e.cloner;return i!==void 0&&i.parent===t?i:void 0}function tre(e,t,i,r){let n=16*(t.children.length+1);LM.length<n&&(LM=new Float32Array(n));let s=0,a=l=>{l.toArray(LM,16*s),s++},o=t.parameters.hideBase!==!0;o&&a(r),AH.multiplyMatrices(e.hiddenMatrix,e.matrix);for(let l of t.children)!Jv(l)||l.playModeVisible===!1||(CH.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),BI.multiplyMatrices(AH,CH),(!o||!BI.equals(r))&&a(BI));try{return s===0?0:function(l,u){return aY(IL().instanced_union(sY(l),u))}(i,LM.subarray(0,16*s))}finally{mbe(i)}}var up,ire,AH,CH,BI,LM,zg,WL,fB,vd,Fc,HL,YA=U(()=>{Ia(),oe(),aB(),pB(),u1(),ss(),up=new Ue,ire=new Ue,AH=new Ue,CH=new Ue,BI=new Ue,LM=new Float32Array(0),zg=class extends bl{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new At,this.onAfterRender=(r,n,s,a,o,l)=>{super.onAfterRender(r,n,s,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let r=0;r<this.children.length;r++){let n=this.children[r];n instanceof zg&&n.dataPatched.visible===!0&&n.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let n=this.children[r];if(n instanceof Ms&&n.dataPatched.visible===!0&&n.geometry.attributes.position?.count>0&&n.geometry.drawRange.count>0&&n.booleanMeshSetAddress!==0){up.multiplyMatrices(n.hiddenMatrix,n.matrix).multiply(n.pivotMatrix);try{let s=d4e(n,this);if(n.booleanMeshSetAddress===-1){if((n.geometry.index??n.geometry.getAttribute("position")).count/3<15e5){let a=LLe(n.geometry,e===!0);n.booleanMeshSetAddress=s===void 0||a===-1?a:tre(n,s,a,up)}if(n.booleanMeshSetAddress===-1)return;s===void 0&&s5(n.booleanMeshSetAddress,up),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1}else n instanceof zg&&n.needsTransformForDownstream===!0?(s===void 0?s5(n.booleanMeshSetAddress,up):n.booleanMeshSetAddress=tre(n,s,n.booleanMeshSetAddress,up),n.needsTransformForDownstream=!1):n.booleanWasTransformed===!0&&(s5(n.booleanMeshSetAddress,ire.multiplyMatrices(up,n.booleanMatrixInvOld)),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1)}catch(s){console.error(s),n.booleanMeshSetAddress=0,n.geometry.userData.booleanOperationDidFail=!0;continue}if(n.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(n.booleanMeshSetAddress),n.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 At,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new Et([],3))}return void this.geometry.setDrawRange(0,0)}if(e===!0)return function(r,n){let s=IL(),a=$te(r,n),o=s.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 At,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,n,s,a){let o=IL(),l=$te(r,n),u=o.mesh_render_data(l,Math.max(a,0));if(s.setAttribute("position",new Et(u.positions(),3)),s.setAttribute("normal",new Et(u.normals(),3)),u.free(),s.boundingSphere===null&&(s.boundingSphere=new qa),l.tri_count()===0)s.boundingSphere.center.set(0,0,0),s.boundingSphere.radius=0,s.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();s.boundingSphere.center.set(h[0],h[1],h[2]),s.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,s.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return aY(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,Ax(this),Cx(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),KA=U(()=>{oe(),xl(),h1(),(WL||(WL={})).is=function(e){return lr.is(e)&&e instanceof Hp},fB=(e,t)=>class extends l1(e,t){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 n=this.shadow;n.camera.far=i.depth,n.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),i0=U(()=>{YA(),Ia(),h1(),vd=e=>e instanceof Ms,Fc=e=>e!==null&&e instanceof zg,HL=e=>QW.is(e)});function vo(e,t){return t.color(e)}function rre(e=new Date,t){let i=t.format,r=e.getSeconds(),n=e;t&&t.timeZone!==null&&(n=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),f=m=>Number(p.find(g=>g.type===m)?.value);return new Date(f("year"),f("month")-1,f("day"),f("hour"),f("minute"),f("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,t.timeZone));let s,a=n.getHours(),o=n.getMinutes();t.format12h24h==="12ampm"&&(s=a>=12?"PM":"AM");let l,u,h=a;switch(t.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],s=void 0;break;case"mm":l=[o],s=void 0;break;case"ss":l=[r],s=void 0;break;case"year":u=n.getFullYear();break;case"month":u=n.getMonth()+1;break;case"dayOfYear":u=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=n.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:s}:u}var PH,Sw,CY=U(()=>{}),c4e=U(()=>{oe(),jA(),WA(),PH=class extends gw(x1e){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){vw(this.object,PH.geometryHelper,e,t)}}}),mB=U(()=>{oe(),c4e(),KA(),Sw=class extends fB(hA,PH){constructor(e,t,i){super(),this.super_Entity(e,t),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 n=new uA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof uA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&function(r,n){r.shadow.camera.right=n/2,r.shadow.camera.left=-n/2,r.shadow.camera.top=n/2,r.shadow.camera.bottom=-n/2,r.shadow.needsUpdate=!0}(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}}});function PY(e){return e instanceof bl&&e.needsAO&&!Hf(e)&&e.isDecalObject!==!0}function RY(e){let t=e.cloner;if(t&&Array.isArray(t.children))for(let i of t.children)i?.layers&&(i.layers.mask=e.layers.mask)}function DY(e){return e.getLayersOfType("reflection").filter(t=>t.data.visible).length}function p4e(e){let t=1/0,i=-1/0;for(let r of e.getLayersOfType("reflection")){let n=r.data;if(!n.visible||n.mirror===1)continue;let s=typeof n.blur=="number"?n.blur:null;t=Math.min(t,s??0),i=Math.max(i,s??10)}return t===1/0?null:{min:t,max:i}}function f4e(e){for(let t of e.getLayersOfType("reflection")){let i=t.data;if(!i.visible)continue;let{blur:r,thickness:n,steps:s,stepSize:a}=i;return typeof r!="number"||typeof n!="number"||typeof s!="number"||typeof a!="number"?"variable":{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function nre(e,t){let i={outline:!1,cavity:!1},r=e.layers.mask&gB,n=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline"),a=DY(t),o=t.getLayersOfType("cavity");return(s.length>0||o.length>0)&&(e.layers.set(8),n.length>0&&e.layers.enable(3),a>0&&e.layers.enable(4),i.outline=s.length>0,i.cavity=o.length>0,Cx(e),Ax(e)),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),r&&e.layers.set(9),!r&&PY(e)&&e.layers.enable(5),RY(e),i}function sre(e,t){if(!t.layers)return!1;let i=e.layers.mask&gB,r=!1,n=t.getLayersOfType("transmission").filter(l=>l.data.visible),s=t.getLayersOfType("outline").filter(l=>l.data.visible),a=DY(t),o=t.getLayersOfType("cavity").filter(l=>l.data.visible);return n.length>0&&(e.layers.set(3),(s.length>0||o.length>0)&&e.layers.enable(8),a>0&&e.layers.enable(4),r=!0),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),i&&e.layers.set(9),!i&&PY(e)&&e.layers.enable(5),RY(e),r}function are(e,t){var i;if(!t.layers)return!1;let r=e.layers.mask&gB,n=!1,s=DY(t),a=t.getLayersOfType("transmission").filter(u=>u.data.visible),o=t.getLayersOfType("outline").filter(u=>u.data.visible),l=t.getLayersOfType("cavity").filter(u=>u.data.visible);return s>0&&((i=e.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),e.layers.set(4),a.length>0&&e.layers.enable(3),(o.length>0||l.length>0)&&e.layers.enable(8),n=!0),s===0&&a.length===0&&o.length===0&&l.length===0&&e.layers.set(0),r&&e.layers.set(9),!r&&PY(e)&&e.layers.enable(5),RY(e),n}function RH(e,t,i,r=!1){let n=e.cloner;if(n){let s=null;if((e.raycast===Tr.prototype.raycast||e.raycast===Ms.prototype.raycast)&&e.isSkinnedMesh!==!0){let a=e.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),s=a.boundingSphere)}for(let a of n.children){if(s!==null&&(DH.copy(s).applyMatrix4(a.matrixWorld),!t.ray.intersectsSphere(DH)))continue;let o=Lxe.copy(a.matrixWorld).invert(),l=Bxe.copy(t.ray).applyMatrix4(o),u=e.matrixWorld;l.applyMatrix4(u);let h=Oxe;h.set(l.origin,l.direction),h.near=t.near,h.far=t.far,h.layers.mask=t.layers.mask;let d=h.intersectObject(e,!1);d.length>0&&i.push({...d[0],object:r?a:e})}}}var gB,Oxe,Lxe,Bxe,DH,D3,Fxe,R5,D5,N5,Tw,Ks,NY=U(()=>{ss(),pB(),Ia(),u1(),oe(),gB=512,Oxe=new G4,Lxe=new Ue,Bxe=new yf,DH=new qa}),m4e=U(()=>{oe(),jA(),WA(),D3=class extends gw(_1e){constructor(e,t=6710886){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){vw(this.object,D3.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=D3._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(r);else this.cone.material.color.set(r)}}},(Fxe=D3)._vector=new R}),vB=U(()=>{oe(),m4e(),KA(),R5=new R,D5=new R,N5=new kt,Tw=class extends fB(cy,Fxe){constructor(e,t,i){super(),this.super_Entity(e,t),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*ht.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new uA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof uA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),D5.setFromMatrixPosition(this.matrixWorld),N5.setFromRotationMatrix(this.matrixWorld),R5.copy(this.up).applyQuaternion(N5).negate().multiplyScalar(this.distance),this.target.position.copy(D5).add(R5),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),Kf=U(()=>{jt(),Ih(),oe(),xl(),bu(),CY(),Cd(),mB(),Ir(),Yf(),oe(),u1(),i0(),NY(),vB(),_r(),YA(),Ks=class extends nB(Zo){constructor(e,t,i){if(super(),this.data=t,this.bgColor=new zr(1,1,1,1),this.fog=null,this.backupFog=new A7(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Xn.getDensity({}),this.fogHeightFalloff=Xn.getHeightFalloff({}),this.fogHeightBase=Xn.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ot,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Yn(o1,{...wE.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new V4(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene){let r=qW();r===null?Ma("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else t.uiFrame&&this.createUICanvas(t.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(e,t){let i=qW();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})):Ma("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=vo(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity*Math.PI),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof zg&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof bl)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){if(e.softShadowQuality===void 0&&e.type===void 0||!this.isActive)return;let t=this.data.shadow;var i,r;i=fy.isSoft(t),r=t?.softShadowQuality,MH!==void 0&&MH(i,r)&&this.forceMaterialsUpdate()}updateFog(e,t){e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=vo(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far,this.fogMode=Xn.getMode(e),this.fogDensity=Xn.getDensity(e),this.fogHeightFalloff=Xn.getHeightFalloff(e),this.fogHeightBase=Xn.getHeightBase(e)}updateSky(e,t){this.skyState=e??null,this.skyStateVersion++;let i=e?.hdri?.image;this.skyHdriHolder=i!=null?t.image(i):null}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=vo(e.aoColor,t))}updateByOp(e,t,i,r){let n=this.data.uiFrame;super.updateByOp(e,t,i,r);let s=t;Jr(e.path,["fog"])?this.updateFog(s.fog,i.shared):Jr(e.path,["sky"])?this.updateSky(s.sky,i.shared):Jr(e.path,["grading"])?this.gradingState=s.grading??null:Jr(e.path,["ao"])?this.updateAo(s.ao,i.shared):Jr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Jr(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||n!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(vo(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.sky!==void 0&&this.updateSky(e.sky,t.shared),e.grading!==void 0&&(this.gradingState=e.grading),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e instanceof Yn&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){let e=this.scene?.find(this.data.publish.playCamera);return e instanceof Yn?e:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(Wf).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof Sw&&i.visible&&e<TE&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof Tw&&i.visible&&e<Wf-TE&&(this.penumbraSizeArrayCache[TE+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let n of r.children){let s=n.cloner;lr.is(n)&&(n.visible||s?.object.data.visible)&&((vd(n)||HL(n)&&this.scene.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),RH(n,e,t,!0)),i(n))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}}});function ore(){return IY}function I5(){if(qL===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 qL}function O5(e){return e?.isWebGPUSplineRenderer===!0}var IY,qL,OY=U(()=>{IY=null,qL=null});function NH(){return BY}var LY,BY,FY=U(()=>{LY=null,BY=null});function lre(e,t,i){return BM.setRGB(e,t,i,Xi),{r:BM.r,g:BM.g,b:BM.b}}function g4e(e,t,i){let r,n=AA(e.angle,0),[s,a]=IH(e.offset),[o,l]=IH(e.morph),u=e.colors??[],h=e.steps??[],d=Math.min(10,u.length,h.length);if(d===0)return[1,1,1,1];if(e.gradientType===1){let g=3*(t+o)-(t+s)-1,v=3*(i+l)-(i+a)-1;r=Math.hypot(g,v)+n}else if(e.gradientType===2){let g=-1*Math.atan2(t+o-.5+s,i+l-.5+a),v=n/Math.PI/-2+.5*g/Math.PI;r=v-Math.floor(v)}else{let g=.5+o/(t!==0?t:1e-6),v=l/(i!==0?i:1e-6),y=Math.cos(n)*g-Math.sin(n)*v,_=Math.sin(n)*g+Math.cos(n)*v,b=y*y+_*_;r=b>1e-12?(((t-.5+s)/2+y/2)*y+((i-.5+a)/2+_/2)*_)/b:0}let c=u[0][0],p=u[0][1],f=u[0][2],m=u[0][3];for(let g=1;g<d;g++){let v=h[g-1],y=h[g]-v,_=y!==0?Math.min(1,Math.max(0,(r-v)/y)):r>=v?1:0;e.smooth&&(_=_*_*(3-2*_)),c+=(u[g][0]-c)*_,p+=(u[g][1]-p)*_,f+=(u[g][2]-f)*_,m+=(u[g][3]-m)*_}return[c,p,f,m]}function v4e(e,t){let i=e,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let n=t,s=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=AA(o.alpha,1);if(!(l<=0))if(o.type==="color"){let u,h=o.color;typeof h=="string"?u=typeof n?.color=="function"?n.color(h):void 0:h&&typeof h.r=="number"&&(u=h),u&&s.push({kind:"color",layer:o,rgb:{...lre(u.r,u.g,u.b),a:u.a??1},alpha:l})}else o.type==="gradient"&&s.push({kind:"gradient",layer:o,alpha:l})}),s.length===0?null:(a,o)=>{let l=1,u=1,h=1,d=!0;for(let c of s){let p,f,m,g;if(c.kind==="color")({r:p,g:f,b:m}=c.rgb),g=c.rgb.a;else{let[y,_,b,x]=g4e(c.layer,a,o);({r:p,g:f,b:m}=lre(y,_,b)),g=x}let v=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*v,u+=(f-u)*v,h+=(m-h)*v,d=!1}return{r:l,g:u,b:h}}}if(i?.color&&i.color.isColor===!0){let{r:n,g:s,b:a}=i.color;return()=>({r:n,g:s,b:a})}return null}var BM,AA,IH,y4e=U(()=>{oe(),BM=new ot,AA=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t,IH=e=>Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"?[e[0],e[1]]:[0,0]});function _4e(e,t){if(e==="torus"){let l=t()*Math.PI*2,u=t()*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(e==="cylinder"){let l=t()*Math.PI*2,u=Math.cos(l),h=Math.sin(l);return{x:.8*u,y:1.6*(t()-.5),z:.8*h,nx:u,ny:0,nz:h,cr:1,cg:1,cb:1}}let i=t()*Math.PI*2,r=2*t()-1,n=Math.acos(r),s=Math.sin(n)*Math.cos(i),a=Math.cos(n),o=Math.sin(n)*Math.sin(i);return{x:s,y:a,z:o,nx:s,ny:a,nz:o,cr:1,cg:1,cb:1}}function b4e(e){let{geometry:t,matrix:i}=e,r=t.getAttribute("position");if(!r||r.count<3)return null;let n=t.getAttribute("normal"),s=t.getAttribute("uv"),a=t.getAttribute("color"),o=t.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let u=(v,y)=>o?o.getX(3*v+y):3*v+y,h=i?i.elements:null,d=i?new oi().getNormalMatrix(i).elements:null,c=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return h?h[0]*y+h[4]*_+h[8]*b+h[12]:y},p=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return h?h[1]*y+h[5]*_+h[9]*b+h[13]:_},f=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return h?h[2]*y+h[6]*_+h[10]*b+h[14]:b},m=new Float64Array(l),g=0;for(let v=0;v<l;v++){let y=u(v,0),_=u(v,1),b=u(v,2),x=c(y),w=p(y),S=f(y),T=c(_)-x,M=p(_)-w,E=f(_)-S,A=c(b)-x,P=p(b)-w,N=f(b)-S,D=M*N-E*P,O=E*A-T*N,z=T*P-M*A;g+=.5*Math.sqrt(D*D+O*O+z*z),m[v]=g}return g<=0?null:{total:g,sample:(v,y)=>{let _=0,b=l-1;for(;_<b;){let Q=_+b>>1;m[Q]<v?_=Q+1:b=Q}let x=_,w=u(x,0),S=u(x,1),T=u(x,2),M=y(),E=y();M+E>1&&(M=1-M,E=1-E);let A,P,N,D=1-M-E,O=c(w)*D+c(S)*M+c(T)*E,z=p(w)*D+p(S)*M+p(T)*E,L=f(w)*D+f(S)*M+f(T)*E;if(n){if(A=n.getX(w)*D+n.getX(S)*M+n.getX(T)*E,P=n.getY(w)*D+n.getY(S)*M+n.getY(T)*E,N=n.getZ(w)*D+n.getZ(S)*M+n.getZ(T)*E,d){let Q=d[0]*A+d[3]*P+d[6]*N,ue=d[1]*A+d[4]*P+d[7]*N,pe=d[2]*A+d[5]*P+d[8]*N;A=Q,P=ue,N=pe}}else{let Q=c(w),ue=p(w),pe=f(w),xe=c(S)-Q,we=p(S)-ue,re=f(S)-pe,Se=c(T)-Q,W=p(T)-ue,k=f(T)-pe;A=we*k-re*W,P=re*Se-xe*k,N=xe*W-we*Se}let V=Math.sqrt(A*A+P*P+N*N)||1,G=1,Y=1,$=1;if(a)G=a.getX(w)*D+a.getX(S)*M+a.getX(T)*E,Y=a.getY(w)*D+a.getY(S)*M+a.getY(T)*E,$=a.getZ(w)*D+a.getZ(S)*M+a.getZ(T)*E;else if(e.sampleColor){let Q=s?s.getX(w)*D+s.getX(S)*M+s.getX(T)*E:.5,ue=s?s.getY(w)*D+s.getY(S)*M+s.getY(T)*E:.5,pe=e.sampleColor(Q,ue);pe&&(G=pe.r,Y=pe.g,$=pe.b)}return{x:O,y:z,z:L,nx:A/V,ny:P/V,nz:N/V,cr:G,cg:Y,cb:$}}}}function hre(e){let t=Math.min(Math.max(1,Math.floor(e.guideStrands)),Px),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}}(e.seed??1337),r=e.shape==="object"&&e.sampler,n=r?e.samplerRadius??od:od,s=new Float32Array(4*tf),a=new Float32Array(tf),o=new Float32Array(4*Px).fill(1);for(let l=0;l<t;l++){let u=r?e.sampler(i):_4e(e.shape,i),h=r?u.x:u.x*n,d=r?u.y:u.y*n,c=r?u.z:u.z*n,{nx:p,ny:f,nz:m}=u;o[4*l+0]=u.cr,o[4*l+1]=u.cg,o[4*l+2]=u.cb;let g,v,y,_=l*jv,b=(1.8+.8*i())*e.hairLength*n/(jv-1),x=.5+1.5*i(),w=(.02+.06*i())*n;Math.abs(f)<.99?(g=-m,v=0,y=p):(g=1,v=0,y=0);let S=Math.sqrt(g*g+v*v+y*y)||1;for(let T=0;T<jv;T++){let M=T/(jv-1),E=M*M*.4*n,A=w*Math.sin(M*x*Math.PI*2),P=4*(_+T);s[P+0]=h+p*b*T+A*g/S,s[P+1]=d+f*b*T-E+A*v/S,s[P+2]=c+m*b*T+A*y/S,s[P+3]=T===0?0:1,T<jv-1&&(a[_+T]=b)}}return{initialPositions:s,restLengths:a,unitScale:n,rootColors:o}}var jv,Px,tf,od,fg,WS,$1,O0,X1,FI,Uxe=U(()=>{oe(),tf=(Px=16384)*(jv=32),od=100}),zxe=U(()=>{oe(),Ia(),FY(),y4e(),Uxe(),fg=1/60,WS=new Ue,$1=new kt,O0=new R,X1=new R,FI=class extends Ms{constructor(e,t,i){super(e,t),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 kt,this.lastBonePos=new R,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=t,this.geometry.setAttribute("position",new Rt(new Float32Array(0),3)),this.material=new Zl({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new Tr(new Vf(od,48,32),new Zl({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new nL;r.setAttribute("position",new Rt(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new Tr(r,new Zl({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=t.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:t.guideStrands,hairLength:t.hairLength,spreadRadius:t.spreadRadius,headShape:t.headShape,baseObjectId:t.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,4*fg*2),this.trackMotionRest(e/1e3))}trackMotionRest(e){this.boneTransform($1,O0);let t=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot($1))<.9999995||this.lastBonePos.distanceToSquared(O0)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||t||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy($1),this.lastBonePos.copy(O0),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+e}motionFingerprint(){let e=this.data;return e.gravity+2*e.damping+3*e.localStiffness+4*e.globalStiffness+5*e.globalRange+6*e.stiffnessFalloff+7*e.windStrength+8*e.vspCoefficient+9*e.kink+10*e.kinkFrequency+11*e.clumpStrength+12*e.clumpSize+13*e.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(e){this.playModeActive=e,e&&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(e,t){super.updateState(e,t),this.updateHairState(e)}updateHairState(e){if((e.guideStrands!==void 0||e.hairLength!==void 0||e.spreadRadius!==void 0||e.headShape!==void 0||e.baseObjectId!==void 0)&&this.regenerate(),(e.headShape!==void 0||e.baseObjectId!==void 0)&&this.applyScalpState(),e.headColor!==void 0){let t=this.scalpMesh.material;t.isMeshBasicMaterial===!0&&t.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,Xi)}(e.castShadow!==void 0||e.receiveShadow!==void 0)&&this.applyShadowState(),e.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,t=this.data.receiveShadow??!0;this.castShadow=e,this.receiveShadow=t,this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=t,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=t}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 e=this.data,t=this.regenSnapshot;if(t===null||t.guideStrands!==e.guideStrands||t.hairLength!==e.hairLength||t.spreadRadius!==e.spreadRadius||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId){let i=t===null||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:t,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,e==="object"&&t){let n=this.context.scene.find(t);if(n){this.baseFoundAtRegen=!0,n.updateWorldMatrix(!0,!0);let s=this.collectBaseSources(n),a=s?function(o){let l=[];for(let d of o){let c=b4e(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,f=l.length-1;for(;p<f;){let g=p+f>>1;u[g]<c?p=g+1:f=g}let m=p===0?c:c-u[p-1];return l[p].sample(m,d)}}(s.sources):null;if(this.baseSourceGeomsAtRegen=s?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=s?.hashes??[],this.baseColorHashAtRegen=s?.colorHash??0,s&&a){let o=this.baseWorldScale(n),l=Math.max(s.radius*o,.001);this.baseScaleAtRegen=o;let u=o;return hre({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 hre({shape:e==="object"?"sphere":e,guideStrands:i,hairLength:r})}collectBaseSources(e){let t=[],i=[],r=0,n=0;WS.copy(e.matrixWorld).invert();let s=WS.clone(),a=o=>{if(o.isHairSystem===!0||o!==e&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let u=o===e?void 0:new Ue().multiplyMatrices(s,o.matrixWorld),h=Array.isArray(o.material)?o.material[0]:o.material;t.push({geometry:l,matrix:u,sampleColor:v4e(h,this.context.shared)??void 0}),i.push(FI.matrixHash(u)),n+=function(c,p){let f=c,m=0,g=1,v=_=>{m+=_*g,g+=1},y=f?.data?.layers;if(y&&typeof y.forEach=="function"){let _=p;y.forEach(b=>{let x=b.data;if(x.visible!==!1){if(x.type==="color"){let w=x.color,S=typeof w=="string"?typeof _?.color=="function"?_.color(w):void 0:w;S&&typeof S.r=="number"&&(v(S.r),v(S.g),v(S.b)),v(AA(x.alpha,1))}else if(x.type==="gradient"){let w=x;for(let S of w.colors??[])v(S[0]),v(S[1]),v(S[2]),v(S[3]);for(let S of w.steps??[])v(S);v(AA(w.angle,0)),v(w.gradientType),v(w.smooth?1:0)}}})}else f?.color&&f.color.isColor===!0&&(v(f.color.r),v(f.color.g),v(f.color.b));return m}(h,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;u?(O0.copy(d.center).applyMatrix4(u),c=O0.length(),p=FI.matrixMaxScale(u)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let u of o.children)a(u)};return a(e),t.length===0?null:{sources:t,hashes:i,radius:Math.max(r,.001),colorHash:n}}static matrixHash(e){if(!e)return 0;let t=e.elements,i=0;for(let r=0;r<16;r++)i+=t[r]*(r+1);return i}static matrixMaxScale(e){let t=e.elements,i=Math.hypot(t[0],t[1],t[2]),r=Math.hypot(t[4],t[5],t[6]),n=Math.hypot(t[8],t[9],t[10]);return Math.max(i,r,n,1e-6)}baseWorldScale(e){return WS.copy(e.matrixWorld).decompose(O0,$1,X1),Math.max(Math.abs(X1.x),Math.abs(X1.y),Math.abs(X1.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 e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen)return void this.regenerate();e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),i=t?.sources??[],r=t?.hashes??[],n=this.baseSourceGeomsAtRegen,s=this.baseSourceHashesAtRegen,a=i.length!==n.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==n[o]||Math.abs(r[o]-s[o])>1e-4*Math.max(Math.abs(s[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(t?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(e);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let e=this.data.headShape,t=e==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!t,!t&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=e==="torus"?new rL(1.4*od,.7*od,24,48):e==="cylinder"?new mE(.8*od,.8*od,1.6*od,48,1):new Vf(od,48,32))}boneTransform(e,t){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)}WS.copy(i).decompose(t,e,X1)}raycast(e,t){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(e,i);for(let r of i)r.object=this,t.push(r)}get shadowBoundsRadius(){let e=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(e+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(e){return this.boneTransform($1,e),e}updateEntityBoxSize(e,t){let i=this.shadowBoundsRadius;e.set(0,0,0),t.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),NH()?.release(this)}}});function UI(){return{shapeInput:()=>`
|
|
4179
4179
|
const float posRowCoord = ${.5/pf};
|
|
4180
4180
|
const float quatRowCoord = ${1.5/pf};
|
|
4181
4181
|
const float param1RowCoord = ${2.5/pf};
|
|
@@ -5372,7 +5372,7 @@ function sortWorker(self) {
|
|
|
5372
5372
|
gl_FragColor = vec4(color.rgb, A);
|
|
5373
5373
|
gVelocity = vec4(0.0);
|
|
5374
5374
|
}`,transparent:!0,alphaTest:1,blending:na,depthTest:!0,depthWrite:!1,side:Ur})}static buildGeomtery(e){let t=new At;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(12),r=new Rt(i,3);t.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 n=new nL().copy(t),s=new Uint32Array(e),a=new ml(s,1,!1);return a.setUsage(xd),n.setAttribute("splatIndex",a),n.instanceCount=e,n}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 e=0,t=0,i=0;for(let r of this.splatBuffers){let n=r.nsplats;this.colors.subarray(e,e+4*n).set(r.colorsA),e+=4*n,this.centers.subarray(t,t+3*n).set(r.decoded.xyz.denormDequant().data),t+=3*n,this.covariances.subarray(i,i+6*n).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=6*n}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new Z(4096,1024);for(;t.x*t.y*2<6*e;)t.y*=2;let i,r,n=new Z(4096,1024);for(;n.x*n.y*4<4*e;)n.y*=2;if(this.halfPrecisionCovariancesOnGPU){r=new Uint16Array(t.x*t.y*2);for(let u=0;u<this.covariances.length;u++)r[u]=wd.toHalfFloat(this.covariances[u]);i=new Nr(r,t.x,t.y,xs,di)}else r=new Float32Array(t.x*t.y*2),r.set(this.covariances),i=new Nr(r,t.x,t.y,xs,Wt);i.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=i,this.material.uniforms.covariancesTextureSize.value.copy(t);let s=new Uint32Array(n.x*n.y*4);for(let u=0;u<e;u++){let h=4*u,d=3*u,c=4*u;s[c]=_we(this.colors[h],this.colors[h+1],this.colors[h+2],this.colors[h+3]),s[c+1]=GI(this.centers[d]),s[c+2]=GI(this.centers[d+1]),s[c+3]=GI(this.centers[d+2])}let a=new Nr(s,n.x,n.y,Wg,cn);GL()!=="webgpu"&&(a.internalFormat="RGBA32UI"),a.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=a,this.material.uniforms.centersColorsTextureSize.value.copy(n);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 Nr(o,1024,1,mn,Wt);l.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=l,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:r,texture:i,size:t},centerColors:{data:s,texture:a,size:n},meshMatrixWorlds:{data:o,texture:l}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&($S.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy($S),this.material.uniforms.basisViewport.value.set(2/$S.x,2/$S.y),this.material.uniforms.focal.value.set(t,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 q4e(){if(!GH)return wre||(wre=async function(){let e=await Promise.resolve().then(()=>(JZ(),QZ));wwe(e),GH=!0}())}var wwe,Swe,GH,wre,Sre,Twe,KL,J5,Og,Mwe=U(()=>{Swe=new Promise(e=>{wwe=e}),GH=!1}),$4e=U(()=>{W4e(),oe(),xwe(),Mwe(),Swe.then(e=>Sre=e),Twe=class{constructor(e={}){Lc(this,"updateView",function(){let t=new Ue,i=[],r=new R(0,0,-1),n=new R(0,0,-1),s=new R,a=new R;return function(o=!1,l){let u=this.updateMatrixWorldsInWorkerIfNeeded(),h=this.cropsChanged();if(!o){n.set(0,0,-1).applyQuaternion(l.quaternion);let c=!1,p=!1;if(n.dot(r)<=.95&&(c=!0),a.copy(l.position).sub(s).length()>=1&&(p=!0),!(c||p||u||h||this.needsInitialRender))return}this.needsInitialRender=!1,s.copy(l.position),r.copy(n),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:t.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=e.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 Ue().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new Z;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new R().fromArray(e.position)),e.orientation&&(e.orientation=new kt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(s=>{s.data.type==="Splat"&&t.push(s)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(s=>s.matrixWorld),this.meshMatrixWorldsOld=t.map(s=>s.matrixWorld.clone()),this.cropsArray=t.map(s=>s.data.crops.map(a=>a.data)),this._splatBufferCache??(this._splatBufferCache=new WeakMap);let i=t.map(s=>{let a=this._splatBufferCache.get(s.data.buffer);return a===void 0&&(a=new Sre.GSplineBuffer(new Uint8Array(s.data.buffer).buffer),this._splatBufferCache.set(s.data.buffer,a)),a}),r=0,n=[0];for(let s of i)r+=s.getSplatCount(),n.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,16*t);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,!this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))&&(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,n)=>{this.cropsArray[i][n]===void 0?(e=!0,this.cropsArray[i][n]=r.data):Object.entries(r.data).forEach(([s,a])=>{(Array.isArray(a)&&a.some((o,l)=>o!==this.cropsArray[i][n][s][l])||a!==this.cropsArray[i][n]?.[s])&&(e=!0,this.cropsArray[i][n][s]=a)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new R,r=new kt,n=!1,s=1,a,o){this.splatMesh=jM.buildMesh(e,t,n,s,a,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,u,h)=>this.update(l,h)}setupSortWorker(e){this.sortWorker=function(t){let i=new Worker(URL.createObjectURL(new Blob(["(",ywe,")(self)"],{type:"application/javascript"}))),r=atob(vwe),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return i.postMessage({init:{sorterWasmBytes:n.buffer,splatCount:t,Constants:{BytesPerFloat:Ig.BytesPerFloat,BytesPerInt:Ig.BytesPerInt,DepthMapRange:Ig.DepthMapRange,MemoryPageSize:Ig.MemoryPageSize}}}),i}(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}}}),xB=U(()=>{oe(),Ih(),xl(),i0(),jt(),dwe(),Ir(),NY(),lY(),Ia(),YA(),k4e(),sB(),wl(),ss(),Kf(),swe(),ss(),la(),HA(),V4e(),$4e(),(KL=new Zl).wireframe=!0,J5=new R,Og=class extends Zo{constructor(e,t){super(),this.data=e,this.sharedAssets=t,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 gwe,this.invisibleObjects=new Ac("jflkdsafjasdifjaslk",{...SL.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Ks("fdasfa",{...my.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markShadowsDirty(){this.shadowsDirty=!0}markInstanceGroupsDirty(){this.instanceGroupsDirty=!0}get autoInstancing(){return this._autoInstancing}updateInstanceGroups(e,t){let i=this._autoInstancing;(i===null||i.minGroupSize!==t)&&(i?.dispose(),i=new uwe(t),this._autoInstancing=i);let r=this.instanceGroupsDirty;return this.instanceGroupsDirty=!1,i.update(e,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(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof bl)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)sre(i,i.material[r])&&(t=!0);else sre(i,i.material)&&(t=!0)}),t}(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._normalPassNeeds=function(e){let t={outline:!1,cavity:!1},i=r=>{t.outline=t.outline||r.outline,t.cavity=t.cavity||r.cavity};return e.traverseEntity(r=>{if(r instanceof bl)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)i(nre(r,r.material[n]));else i(nre(r,r.material))}),t}(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(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof bl)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)are(i,i.material[r])&&(t=!0);else are(i,i.material)&&(t=!0)}),t}(this),this.needsReflectionDirty=!1),this._needsReflection}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Ks&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let n=r;r=r.parent;let s=r.children.indexOf(n);i.splice(0,0,s)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>aL(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===o1)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Ks&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Ks&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&Xo(i)&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Ks&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);t?Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0&&console.error("not found instance"):console.error("not found")}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(t=>{t.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(t=>{t.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error(`scene tree add: parent ${e.parent} not found for object ${e.id}`);let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(this),r.resetBBoxNeedsUpdate(),vd(r)&&Fc(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error(`scene tree delete: object ${e.id} not found`);i.traverseEntity(n=>{Hf(n)&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==n)),t1(n)&&(this.hairInstances=this.hairInstances.filter(s=>s!==n))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Fc(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),vd(i)&&(i.freeBooleanPointer(),r instanceof zg&&r.invalidateDownstreamBooleanData().recomputeBoolean()),tB(i)&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error(`scene tree move: object ${e.id} not found`);this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let n=e.parent===null?this:this.find(e.parent);if(n===void 0)throw new Error(`scene tree move: new parent ${e.parent} not found for object ${e.id}`);n.add(i),this.markNeedsRecomputeInstancesForAncessors(n),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;n.children.splice(s,0,n.children.pop()),vd(i)&&(i.invalidateUpstreamBooleanData(),Fc(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof zg&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.shadowsDirty=!0,this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Ks&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(this.shadowsDirty=!0,t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let n=this.find(e);if(n)try{(function(s,a,o,l){s.updateByOp(a,o,l,!1)})(n,t,i,{scene:this,shared:r}),n instanceof Un&&n.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,i,r,n,s=[]){e.updateEntityByOp(t,i,r,n),this.traverseEntity(a=>{(Xo(a)||a instanceof Ks)&&(s.includes(a.frameId??"")||a.frameId===t)&&a.updateEntity2DByOp(t,i,r,n)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,n)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:n}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof Yn&&r.updateUp()}),this.doPendingExpandCloner({scene:this,shared:t}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){lr.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{lr.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,n,s,a){if(e){let o=r.find(e);o&&o!==r&&n.forInstancesRec(l=>{l.data=hL(l.data,u=>{let h=u.events.data(a.id),d=l.goUp(s);if(d){let c=[...e_e(d.identity),e].join("-"),p=this.entityIdentityToEntity[c];if(p){let f=p.uuid;Ta.zoom(h,t)[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,n,s){e.forEach(a=>{a.data.type==="Transition"||a.data.type==="Animation"&&a.data.object?this.relativeizeInner(a.data.object,[...t,a.id],"object",i,r,n,s):a.data.type==="Conditional"&&(this.rewriteActions(a.data.ifActions,[...t,a.id,"ifActions"],i,r,n,s),this.rewriteActions(a.data.elseActions,[...t,a.id,"elseActions"],i,r,n,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(RI(e)&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let n=!1;if(t.forInstancesRec(s=>{s.data=hL(s.data,a=>{s.isInstanceRoot||(a.events.delete(r.id),n=!0)}).data}),n===!1)for(let s of AL.list)this.rewriteActions(r.data.gameActions[s],["gameActions",s],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,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,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(n=>{if(RI(n)&&n.isInstanceRoot)return n.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||n.resetBBoxNeedsUpdate(),i&&n.traverseEntity(s=>{i.addClip(s)}),!0});for(let n of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),WY(n)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{RI(i)&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){this._autoInstancing?.dispose(),this._autoInstancing=null,this.instanceGroupsDirty=!0;for(let e of this.children)lr.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=n=>{for(let s of n.children){let a=s.cloner;if(lr.is(s)&&!s.raycastLock&&(s.visible||a?.object.data.visible))if(t===!0&&s.isInstanceRoot){let o=[];if(e.intersectObject(s,!0,o),o.length){let l=o[0];l.object=s,l.point.applyMatrix4(l.object.matrixWorld);let u=s.matrixWorld.clone().invert();l.point.applyMatrix4(u),i.push(l)}}else(vd(s)||HL(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,i),RH(s,e,i)),r(s)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let n of r.children){let s=n.cloner;lr.is(n)&&(n.visible||s?.object.data.visible)&&((vd(n)||HL(n)&&this.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),RH(n,e,t,!0)),i(n))}};return i(this),t}forEachEntity(e){for(let t of this.children)lr.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)lr.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)lr.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof Un&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let r=i.geometry,n=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(n,t);let s=i.invalidateDownstreamBooleanData();Fc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)ty.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)lr.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let n of e)this.createObject(n.id,n.data,n.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,n,s){let a={scene:this,shared:s},o=XY(e,t,a);return Hf(o)&&this.shapeBlendIntances.push(o),t1(o)&&this.hairInstances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(n,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,s)),o.updateState(t,a),o instanceof Un&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{let u=l.dataPatched;if(l instanceof Un&&u.bones&&u.boneInverses){let h=u.bones.map(p=>this.find(p)),d=u.boneInverses.map(p=>new Ue().fromArray(p)),c=new tL(h,d);l.bind(c,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,n=e.length;r<n;++r){let{id:s,recursive:a}=e[r],o=this.find(s),l=a?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new fn;return i.setFromPoints(t),i.getCenter(J5),J5}copyMatrixWorld(e,t){if(e===null)return void t.identity();let i=this.find(e);i?(i.updateWorldMatrix(!0,!1),t.copy(i.matrixWorld)):t.identity()}copyParentMatrixWorld(e,t){if(e===null)return void t.identity();let i=this.find(e)?.parent;i?(i.updateWorldMatrix(!0,!1),t.copy(i.matrixWorld)):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ms)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)OL(t.material[i])&&e(t.material[i]);else OL(t.material)&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Yn&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new Twe({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}}}),Ewe={};function X4e(){let e,t;function i(r,n,s,a,o,l){let u=s.num_points(),h=l.num_components(),d=function(b,x){switch(x){case Float32Array:return b.DT_FLOAT32;case Int8Array:return b.DT_INT8;case Int16Array:return b.DT_INT16;case Int32Array:return b.DT_INT32;case Uint8Array:return b.DT_UINT8;case Uint16Array:return b.DT_UINT16;case Uint32Array:return b.DT_UINT32}}(r,o),c=h*o.BYTES_PER_ELEMENT,p=4*Math.ceil(c/4),f=p/o.BYTES_PER_ELEMENT,m=u*c,g=u*p,v=r._malloc(m);n.GetAttributeDataArrayForAllPoints(s,l,d,m,v);let y,_=new o(r.HEAPF32.buffer,v,m/o.BYTES_PER_ELEMENT);if(c===p)y=_.slice();else{y=new o(g/o.BYTES_PER_ELEMENT);let b=0;for(let x=0,w=_.length;x<w;x++){for(let S=0;S<h;S++)y[b+S]=_[x*h+S];b+=f}}return r._free(v),{name:a,count:u,itemSize:h,array:y,stride:f}}onmessage=function(r){let n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise(function(o){e.onModuleLoaded=function(l){o({draco:l})},DracoDecoderModule(e)});break;case"decode":let s=n.buffer,a=n.taskConfig;t.then(o=>{let l=o.draco,u=new l.Decoder;try{let h=function(c,p,f,m){let g,v,y=m.attributeIDs,_=m.attributeTypes,b=p.GetEncodedGeometryType(f);if(b===c.TRIANGULAR_MESH)g=new c.Mesh,v=p.DecodeArrayToMesh(f,f.byteLength,g);else{if(b!==c.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");g=new c.PointCloud,v=p.DecodeArrayToPointCloud(f,f.byteLength,g)}if(!v.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+v.error_msg());let x={index:null,attributes:[]};for(let w in y){let S,T,M=self[_[w]];if(m.useUniqueIDs)T=y[w],S=p.GetAttributeByUniqueId(g,T);else{if(T=p.GetAttributeId(g,c[y[w]]),T===-1)continue;S=p.GetAttribute(g,T)}let E=i(c,p,g,w,M,S);w==="color"&&(E.vertexColorSpace=m.vertexColorSpace),x.attributes.push(E)}return b===c.TRIANGULAR_MESH&&(x.index=function(w,S,T){let M=3*T.num_faces(),E=4*M,A=w._malloc(E);S.GetTrianglesUInt32Array(T,E,A);let P=new Uint32Array(w.HEAPF32.buffer,A,M).slice();return w._free(A),{array:P,itemSize:1}}(c,p,g)),c.destroy(g),x}(l,u,new Int8Array(s),a),d=h.attributes.map(c=>c.array.buffer);h.index&&d.push(h.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:h},d)}catch(h){console.error(h),self.postMessage({type:"error",id:n.id,error:h.message})}finally{l.destroy(u)}})}}}cw(Ewe,{DRACOLoader:()=>Cwe,DRACO_GLTF_CONFIG:()=>Awe});var k3,Awe,Cwe,Y4e=U(()=>{oe(),k3=new WeakMap,Awe={js:"",wasm:""},Cwe=class extends Dv{constructor(e){super(e),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(e){let{decoderPaths:t}=this;return typeof e=="object"?(t.js=e.js,t.wasm=e.wasm,t.dep_js=null):(t.js=xI.resolveURL("draco_wasm_wrapper.js",e),t.wasm=xI.resolveURL("draco_decoder.wasm",e),t.dep_js=xI.resolveURL("draco_decoder.js",e)),this}setDecoderConfig(e){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let n=new yE(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,s=>{this.parse(s,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,Xi,i).catch(i)}decodeDracoFile(e,t,i,r,n=Md,s=()=>{}){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:n};return this.decodeGeometry(e,a).then(t).catch(s)}decodeGeometry(e,t){let i=JSON.stringify(t);if(k3.has(e)){let o=k3.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,n=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(n,s).then(o=>(r=o,new Promise((l,u)=>{r._callbacks[n]={resolve:l,reject:u},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),k3.set(e,{key:i,promise:a}),a}_createGeometry(e){let t=new At;e.index&&t.setIndex(new Rt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r,{name:n,array:s,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[i];if(a===o)r=new Rt(s,a);else{let u=new Qb(s,o);r=new cg(u,a,0)}n==="color"&&(this._assignVertexColorSpace(r,l),r.normalized=!(s instanceof Float32Array)),t.setAttribute(n,r)}return t}_assignVertexColorSpace(e,t){if(t!==Xi)return;let i=new ot;for(let r=0,n=e.count;r<n;r++)i.fromBufferAttribute(e,r),ai.colorSpaceToWorking(i,Xi),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){let i=new yE(this.manager);return i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,n)=>{i.load(e,r,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[],{decoderPaths:i}=this;if(e){if(i.dep_js===null)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");t.push(this._loadLibrary(i.dep_js,"text"))}else t.push(this._loadLibrary(i.js,"text")),t.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(t).then(r=>{let n=r[0];e||(this.decoderConfig.wasmBinary=r[1]);let s=X4e.toString(),a=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
5375
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){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(n){let s=n.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,n){return r._taskLoad>n._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),K4e=U(()=>{});function Pwe(e){return function(t,{basePath:i,moduleUrl:r,cdnBuild:n}){if(i!==void 0)return{url:`${i}/${t}`};let s=`${n}/${t}`;if(r===void 0||r.startsWith("file:"))return{url:s};let a=r.slice(0,r.lastIndexOf("/")+1)+t;return a===s?{url:a}:{url:a,fallback:s}}(e,{basePath:Rwe,moduleUrl:typeof Tye.url=="string"?Tye.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
5375
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){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(n){let s=n.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,n){return r._taskLoad>n._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),K4e=U(()=>{});function Pwe(e){return function(t,{basePath:i,moduleUrl:r,cdnBuild:n}){if(i!==void 0)return{url:`${i}/${t}`};let s=`${n}/${t}`;if(r===void 0||r.startsWith("file:"))return{url:s};let a=r.slice(0,r.lastIndexOf("/")+1)+t;return a===s?{url:a}:{url:a,fallback:s}}(e,{basePath:Rwe,moduleUrl:typeof Tye.url=="string"?Tye.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.82/build"})}function ZL(e,t){let{url:i,fallback:r}=Pwe(t);r!==void 0&&e.addEventListener("error",()=>{e.src=r},{once:!0}),e.src=i}var Rwe,wB=U(()=>{K4e()});function r0(e,t){SB.set(e,t)}function Z4e(e){return SB.get(e)}function Dwe(e,t){YY.set(e,t)}function Tre(e){return YY.get(e)}function jH(e,t){let i=`${t}:${e}`;WH.has(i)||WH.add(i)}var SB,YY,WH,xu=U(()=>{SB=new Map,YY=new Map,WH=new Set});function Mre(e,t,i){return e*(t-i)-t}function ez(e,t,i){return Math.min(Math.max((e+t)/(t-i),0),1)}function Ere(e,t,i){for(let r of t){let n="$1"+e+r.charAt(0).toUpperCase()+r.slice(1),s=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(let a of i.entries())a[1]!==null&&i.set(a[0],a[1].replace(s,n))}}function Q4e(e,t,i,r,n,s,a){let o=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=o.get("fragment")!==void 0&&/mainImage/.test(o.get("fragment")),u=o.get("fragment")!==void 0&&/mainUv/.test(o.get("fragment")),h=[],d=[],c=!1,p=!1;if(o.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(u&&(a&nd.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(l||u){let f=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,m=jI.Section;if(u){let v=` ${e}MainUv(UV);
|
|
5376
5376
|
`;i.set(m.FRAGMENT_MAIN_UV,i.get(m.FRAGMENT_MAIN_UV)+v),c=!0}if(o.get("vertex")!==null&&/mainSupport/.test(o.get("vertex"))){let v=` ${e}MainSupport(`;v+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get("vertex"))?`vUv);
|
|
5377
5377
|
`:`);
|
|
5378
5378
|
`,i.set(m.VERTEX_MAIN_SUPPORT,i.get(m.VERTEX_MAIN_SUPPORT)+v),h=h.concat([...o.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(y=>y[1])),d=d.concat(h).concat([...o.get("vertex").matchAll(f)].map(y=>y[1]))}d=d.concat([...o.get("fragment").matchAll(f)].map(v=>v[1])),d=d.concat([...t.defines.keys()].map(v=>v.replace(/\([\w\s,]*\)/g,""))),d=d.concat([...t.uniforms.keys()]),t.uniforms.forEach((v,y)=>s.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),t.defines.forEach((v,y)=>n.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),Ere(e,d,n),Ere(e,d,o);let g=t.blendMode;if(r.set(g.blendFunction,g),l){let v=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,y=`${e}MainImage(color0, UV, `;(a&nd.DEPTH)!==0&&v.test(o.get("fragment"))&&(y+="depth, ",p=!0),y+=`color1);
|
|
@@ -6224,7 +6224,7 @@ var<${i}> ${e} : ${s};`}},ho=new rv,DD=new A_,qG=new Map([[Int8Array,["sint8","s
|
|
|
6224
6224
|
`).slice(2,9).join(`
|
|
6225
6225
|
`)}),Ix.length>RTe&&Ix.shift()}var Nq,RTe,Ix,Iq,a4,Oq,Lq,GBe=U(()=>{Nq=(()=>{try{return new URLSearchParams(window.location.search).get("dbgdestroys")==="1"}catch{return!1}})(),RTe=32,Ix=[],Iq=6,a4=()=>-1,Oq=!1,Lq=null}),jBe=U(()=>{});function Bq(e,t){let i=new Ui(e,t,{depthBuffer:!1,type:Wt,format:xs});return i.texture.generateMipmaps=!1,i.texture.minFilter=yt,i.texture.magFilter=yt,i}function Fq(){return xy===null&&((xy=Bq(Af*o4,Af)).texture.name="SplinePCSSPyramidAtlas"),xy.texture}function $fe(e,t,i,r,n,s){let a=new ei,o=vt(t),l=Xe(()=>{let u=Qo,h=s!==0?KM(u.x).sub(s):KM(u.x),d=De(h).mul(i).toVar(),c=De(u.y).mul(i).toVar(),p=B(1e9).toVar(),f=B(-1e9).toVar();return Zr(zq("ly",i),zq("lx",i),m=>{let{lx:g,ly:v}=m,y=Uq(kq(d.add(g),De(0),De(r))),_=Uq(kq(c.add(v),De(0),De(r))),b=o.load(Wa(y,_));p.assign(Fi(p,KM(b.x))),f.assign(mt(f,KM(n?b.y:b.x)))}),Pe(p,f,0,1)})();return a.fragmentNode=l,a.name=e,a.lights=!1,a.blending=Di,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,a}function Xfe(e){let t=e;if(!t.__spePcssPyramid){t.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null};for(let i of Ox)i.deref()===void 0&&Ox.delete(i);Ox.add(new WeakRef(t.__spePcssPyramid))}return t.__spePcssPyramid}function Yfe(e){return e.__spePcssPyramid?.fresh===!0}function WBe(e){return e.__spePcssPyramid?.slot??-1}var Af,o4,Gb,KM,Uq,zq,kq,xy,Ox,hO,uO,Vq,DTe=U(()=>{oe(),vn(),bi(),ua(),Af=8,o4=8,Gb=64,KM=e=>e,Uq=e=>e,zq=(e,t)=>({start:De(0),end:De(t),type:"int",condition:"<",name:e}),kq=Xt,xy=null,Ox=new Set,hO=new Array(o4).fill(null),uO=!1,Vq=new R});function Lx(e){let t=e;return t.__spePcssKnobs||(t.__spePcssKnobs={mapSize:Fe(2048),radius:Fe(1),penumbraSize:Fe(.5),depthEps:Fe(1e-4),penumbraFrameScale:Fe(1),penumbraFrameOffset:Fe(0),pyramidEnabled:Fe(0),pyramidSlot:Fe(0),maskChannel:Fe(new ct(0,0,0,0)),planeNormalMat:Fe(new oi().set(0,0,0,0,0,0,0,0,0))}),t.__spePcssKnobs}function NTe(e,t){Lx(e).maskChannel.value.set(t===0?1:0,t===1?1:0,t===2?1:0,t===3?1:0)}function Kfe(e,t,i){let r=e,n=Lx(e);n.mapSize.value=r.mapSize?.x??2048,n.radius.value=r.radius??1,n.penumbraSize.value=t??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?n.planeNormalMat.value.getNormalMatrix(r.matrix):n.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let s=typeof r.camera?.far=="number"&&typeof r.camera?.near=="number"?r.camera.far-r.camera.near:0;n.depthEps.value=s>.001?FTe/s:1e-4;let a=e.__speRangeEnvelope,o=a?a.far-a.near:0;a&&o>.001&&s>.001&&r.camera?(n.penumbraFrameScale.value=s/o,n.penumbraFrameOffset.value=(r.camera.near-a.near)/o):(n.penumbraFrameScale.value=1,n.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&l4()){let u=n.mapSize.value;fK/1024+(2*n.radius.value+2)/Math.max(1,u)<=1/Af&&(l=1)}return n.pyramidEnabled.value=UTe??l,n.pyramidSlot.value=Math.max(0,i?.slot??0),n.pyramidEnabled.value===1}function ITe(e,t){let i=jb(e.planeNormalMat.mul(t)).toVar(),r=Mi(i.z),n=Mi(jc(r).add(hr(ui(r),B(0))).mul(mt(ui(r),B(1e-4))));return Ln(Me(Mi(i.x).negate().div(n),Mi(i.y).div(n))).toVar()}function Gq(e,t,i,r,n,s,a){let o=LTe(),l=BTe(),u=jq(),h=Lx(t),d=Mi(h.mapSize),c=Ln(Me(d,d)),p=Mi(h.radius),f=Mi(h.penumbraSize),m=vt(e),g=w=>Mi(m.load(Wa(Xt(w,Me(0),Me(1)).mul(c))).x),v=B(1).div(c.x).toVar(),y=B(fK).div(v.mul(1024)).toVar(),_=Mi(h.depthEps),b=ITe(h,a),x=()=>{let w=B(0).toVar(),S=B(0).toVar();for(let E=0;E<l;E++){let A=Ln(Xg(De(E),De(l),n)).mul(v).mul(y),P=g(Ln(i.add(A))).toVar();Ve(P.lessThan(r.add(h4(b,A)).add(_)),()=>{w.addAssign(P),S.addAssign(1)})}let T=B(0).toVar();Ve(S.greaterThan(0),()=>{let E=w.div(S).toVar(),A=Mi(h.penumbraFrameScale),P=Mi(h.penumbraFrameOffset),N=r.sub(E).mul(A).div(E.mul(A).add(P)).toVar();T.assign(Xt(N.mul(N).mul(200).mul(f),B(0),B(1)))});let M=B(0).toVar();for(let E=0;E<o;E++){let A=Ln(Xg(De(E),De(o),n)).mul(v),P=Ln(A.mul(p.mul(2)).add(A.mul(T.mul(y)))),N=Mi(r.add(h4(b,P)));u?M.addAssign(Mi(vt(e,Ln(i.add(P))).compare(N))):M.addAssign(hr(N,g(Ln(i.add(P)))))}s.assign(M.div(o))};if(l4()){let w=vt(Fq()),S=Mi(h.pyramidEnabled),T=Mi(h.pyramidSlot),M=B(Af),E=B(0).toVar();Ve(S.greaterThan(.5),()=>{let A=Ln(Xt(i,Me(0),Me(1))),P=Mi(A.x.mul(M)).toVar(),N=Mi(A.y.mul(M)).toVar(),D=T.mul(M),O=B(1e9).toVar(),z=B(-1e9).toVar();for(let G=-1;G<=1;G++)for(let Y=-1;Y<=1;Y++){let $=Xt(P.add(B(Y)),B(0),M.sub(1)),Q=Xt(N.add(B(G)),B(0),M.sub(1)),ue=Ln(Me($.add(D),Q)),pe=w.load(Wa(ue));O.assign(Fi(O,Mi(pe.x))),z.assign(mt(z,Mi(pe.y)))}let L=Mi(v.mul(p.mul(2).add(y))),V=Mi(Fi(Yi(b).mul(L),B(.05))).toVar();Ve(O.greaterThanEqual(r.add(_).add(V)),()=>{E.assign(1)}).ElseIf(z.lessThan(r.sub(V)),()=>{E.assign(2)})}),Ve(E.equal(1),()=>{s.assign(1)}).ElseIf(E.equal(2),()=>{s.assign(0)}).Else(x)}else x()}function HBe(e,t){let i=t;return i.isPointLight?(Pi.pcssHookServes++,d4):i.isSpotLight||i.isDirectionalLight?(Pi.pcssHookServes++,u4):null}function Zfe(e){mK.value=e?1:0}function Qfe(e,t){return i=>{let r=function(a){let o=a,l={};if(o==null)return l;for(let u of zTe){let h=o[u];h!==void 0&&(l[u]=h)}return l}(i),n=Mi(qq(e,r)),s=Mi(qq(t,r));return Xe(()=>{let a=B(1).toVar();return Ve(Mi(mK).greaterThan(.5),()=>{a.assign(n)}).Else(()=>{a.assign(s)}),a})()}}var Mi,Ln,jb,UD,zD,kD,VD,ZM,jq,l4,JG,Wq,Hq,OTe,fK,sf,LTe,BTe,FTe,UTe,h4,Jfe,eme,tme,mK,qq,zTe,u4,d4,GD,ime,rme,kTe,jD,c4,VTe=U(()=>{bi(),oe(),ua(),DTe(),Mi=e=>e,Ln=e=>e,jb=e=>e,UD=!0,zD=!0,kD=!0,VD=!0;try{let e=new URLSearchParams(window.location.search),t=e.get("dbgpcss");t==="classic"||t==="0"?(UD=!1,zD=!1,kD=!1,VD=!1):(UD=e.get("dbgpcsssplit")!=="0",zD=e.get("dbgpcsshw")!=="0",kD=e.get("dbgpcsshiz")!=="0",VD=e.get("dbgshadowmask")!=="0")}catch{}ZM=!1,jq=()=>zD&&ZM,l4=()=>kD&&ZM,JG=()=>VD&&ZM,Wq=()=>l4(),Hq=()=>JG(),OTe=[[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]],fK=80,sf=16,LTe=()=>jq()?Math.max(4,sf>>1):sf,BTe=()=>UD?Math.max(4,sf>>1):sf,FTe=1.25,UTe=null,h4=(e,t)=>Mi(Xt(et(e,t),B(-.05),B(.05))),Jfe=Xe(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,n=Lx(r),s=Ln(i.xy).toVar(),a=Mi(i.z).toVar(),o=jb(RA).toVar(),l=Ln(it.pcssHalton),u=Mi(jf(Qo.xy.add(l))).mul(6.28318530718).toVar(),h=B(1).toVar();if(JG()){let d=n.maskChannel,c=Mi(it.shadowMaskEnabled),p=it.shadowMaskGBuffer,f=it.shadowMaskTexture,m=B(0).toVar(),g=B(1).toVar();Ve(c.greaterThan(.5).and(Mi(et(d,Pe(1,1,1,1))).greaterThan(.5)),()=>{let v=Ln(gu),y=Ln(it.shadowMaskResolution),_=Ln(it.shadowMaskFullResolution),b=Mi($f.z),x=Ln(v.mul(y).sub(Me(.5,.5))).toVar(),w=Ln(Ct(x)).toVar(),S=Ln(x.sub(w)).toVar(),T=Mi(mt(ui(b).mul(.02),B(.05))),M=B(0).toVar(),E=B(0).toVar();for(let A=0;A<=1;A++)for(let P=0;P<=1;P++){let N=Ln(Xt(w.add(Me(P,A)),Me(0,0),y.sub(Me(1,1)))),D=Ln(N.add(Me(.5,.5)).div(y)),O=Ln(Ct(D.mul(_)).add(Me(.5,.5)).div(_)),z=Mi(p.sample(O).w),L=Mi(et(f.sample(D),d)),V=Mi(P===0?B(1).sub(S.x):Mi(S.x)),G=Mi(A===0?B(1).sub(S.y):Mi(S.y)),Y=Mi(hr(ui(z.sub(b)),T)),$=Mi(V.mul(G).mul(Y)).toVar();M.addAssign($),E.addAssign(L.mul($))}Ve(M.greaterThan(.001),()=>{m.assign(1),g.assign(E.div(M))})}),Ve(m.greaterThan(.5),()=>{h.assign(g)}).Else(()=>{Gq(t,r,s,a,u,h,o)})}else Gq(t,r,s,a,u,h,o);return h}),eme=Xe(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,n=Lx(r),s=Ln(i.xy).toVar(),a=Mi(i.z).toVar(),o=ITe(n,jb(RA).toVar()),l=Mi(n.mapSize),u=Mi(n.radius),h=Mi(u.mul(B(1).div(l))).toVar(),d=Mi(jf(Qo.xy)).mul(6.28318530718).toVar(),c=B(0).toVar();for(let p=0;p<5;p++){let f=Ln(Xg(De(p),De(5),d)).mul(h).toVar();c.addAssign(Mi(vt(t,Ln(s.add(f))).compare(a.add(h4(o,f)))))}return c.mul(.2)}),tme=Xe(e=>{let{depthTexture:t,bd3D:i,dp:r,shadow:n}=e,s=sf,a=Lx(n),o=Mi(a.mapSize),l=Mi(a.radius),u=B(1).div(o).toVar(),h=Ln(it.pcssHalton),d=Mi(jf(Qo.xy.add(h))).mul(6.28318530718).toVar(),c=Mi(l.add(5)).toVar(),p=B(0).toVar();for(let f=0;f<s;f++){let m=Ln(Xg(De(f),De(s),d)).mul(u).toVar(),g=jb(J(m.x,m.y,Mi(m.x).negate()).mul(c)),v=jb(i.add(g));p.addAssign(Mi(ASe(t,v).compare(r)))}return p.div(s)}),mK=Fe(1),qq=(e,t)=>e(t),zTe=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],u4=Qfe(Jfe,eme),d4=Qfe(tme,vSe)}),qBe=U(()=>{oe(),vn(),bi(),ua(),VTe(),GD=new Cn,ime=new ot,rme=new Z,kTe=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=Fe(new Ue),this._projInv=Fe(new Ue),this._lightRows=[];let e=new ei;e.name="SplineShadowMask.gbuffer",e.fragmentNode=Pe(Ao,$f.z),e.lights=!1,e.blending=Di,e.needsUpdate=!0,this._gBufferMaterial=e}_ensureTarget(e,t,i,r){return e&&e.width===t&&e.height===i?{target:e,changed:!1}:(e?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(e){let t=new ei;t.name="SplineShadowMask.resolve";let i=vt(this._gBuffer.depthTexture),r=vt(this._gBuffer.texture),n=this._cameraWorld,s=this._projInv,a=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=e.map(()=>({matrix:Fe(new Ue),bias:Fe(0),normalBias:Fe(0)}));let l=this._lightRows,u=Xe(()=>{let h=tr(),d=Ct(h.mul(Me(a,o))).add(Me(.5,.5)).div(Me(a,o)).toVar(),c=i.sample(d),p=rK(d,c,s).toVar(),f=r.sample(d).toVar(),m=n,g=m.mul(Pe(p,1)).xyz.toVar(),v=Ut(m.mul(Pe(f.xyz,0)).xyz).toVar(),y=it.pcssHalton,_=jf(Qo.xy.add(y)).mul(6.28318530718).toVar(),b=[B(1).toVar(),B(1).toVar(),B(1).toVar(),B(1).toVar()];return e.forEach((x,w)=>{let S=l[w],T=g.add(v.mul(S.normalBias)),M=S.matrix.mul(Pe(T,1)).toVar(),E=M.xyz.div(M.w),A=J(E.x,B(1).sub(E.y),E.z).toVar(),P=A.z.add(S.bias).toVar(),N=A.x.greaterThanEqual(0).and(A.x.lessThanEqual(1)).and(A.y.greaterThanEqual(0)).and(A.y.lessThanEqual(1)).and(P.lessThanEqual(1));Ve(N,()=>{Gq(x.shadow.map.depthTexture,x.shadow,A.xy,P,_,b[w],v)})}),Pe(b[0],b[1],b[2],b[3])})();return t.fragmentNode=u,t.lights=!1,t.blending=Di,t.depthTest=!1,t.depthWrite=!1,t.needsUpdate=!0,t}render(e,t,i,r,n){let s=n??e.getDrawingBufferSize(rme),a=Math.max(1,Math.round(s.x)),o=Math.max(1,Math.round(s.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 M=new Ui(a,o,{type:di,depthTexture:new is(a,o),minFilter:rt,magFilter:rt});return M.texture.name="SplineShadowMask.gbuffer",M});this._gBuffer=d.target,h=h||d.changed;let c=this._ensureTarget(this._maskTarget,l,u,()=>{let M=new Ui(l,u,{depthBuffer:!1,minFilter:rt,magFilter:rt});return M.texture.name="SplineShadowMask.mask",M});this._maskTarget=c.target,h=h||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(M=>M.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((M,E)=>{M.shadow.updateMatrices?.(M.light);let A=this._lightRows[E];M.shadow.matrix&&A.matrix.value.copy(M.shadow.matrix),A.bias.value=M.shadow.bias??0,A.normalBias.value=M.shadow.normalBias??0});let f=t,m=f.isScene===!0,g=[],v=[];f.traverse(M=>{let E=M;if(E.isMesh===!0&&E.visible!==!1){if((Array.isArray(E.material)?E.material:[E.material]).some(A=>A?.transparent===!0))g.push(E),E.visible=!1;else if(!m){let A=E;v.push({obj:A,material:A.material}),A.material=this._gBufferMaterial}}});let y=f.overrideMaterial,_=e.getRenderTarget(),b=e.getMRT(),x=e.getClearColor(ime),w=e.getClearAlpha(),S=i.layers,T=S.mask;S.disable(3),f.overrideMaterial=this._gBufferMaterial,e.setMRT(null),e.setClearColor(0,0),e.setRenderTarget(this._gBuffer),e.render(t,i),f.overrideMaterial=y,S.mask=T;for(let M of g)M.visible=!0;for(let M of v)M.obj.material=M.material;return GD.material=this._resolveMaterial,GD.name="SplineShadowMask.resolve",e.setRenderTarget(this._maskTarget),GD.render(e),e.setRenderTarget(_),e.setMRT(b),e.setClearColor(x,w),it.shadowMaskTexture.value=this._maskTarget.texture,it.shadowMaskGBuffer.value=this._gBuffer.texture,it.shadowMaskResolution.value.set(l,u),it.shadowMaskFullResolution.value.set(a,o),r.forEach((M,E)=>{NTe(M.shadow,E)}),Pi.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=""}}}),GTe=U(()=>{bi(),vn(),jD=new WeakMap,c4=HSe(class extends cSe{update(e){super.update(e);let{frameId:t,object:i}=e,r=jD.get(i);r===void 0?(r={frameId:t,prev:i.matrixWorld.clone(),last:i.matrixWorld.clone()},jD.set(i,r)):r.frameId!==t&&(r.frameId=t,r.prev.copy(r.last)),this.previousModelWorldMatrix.value.copy(r.prev)}updateAfter(e){let{object:t}=e;jD.get(t)?.last.copy(t.matrixWorld)}})});function p4(e,t){let i=0,r=1,n=e;for(;n>0;)r/=t,i+=r*(n%t),n=Math.floor(n/t);return i}function e9(e){return J(e.x.div(4).add(e.y.div(2)).add(e.z.div(4)),e.x.div(2).sub(e.z.div(2)),e.x.div(-4).add(e.y.div(2)).sub(e.z.div(4)))}function nme(e,t=!0){let i=J(e.x.add(e.y).sub(e.z),e.x.add(e.z),e.x.sub(e.y).sub(e.z));return t?Xt(i,J(0),J(1)):mt(i,J(0))}function jTe(){let e=!1;try{let c=new URLSearchParams(window.location.search).get("dbgfp16");e=c==="1"||c==="hist"||c==="st"}catch{}let t=!1,i=()=>e||t,r=(c,p,f)=>{let m=new Ui(c,p,{minFilter:rt,magFilter:rt,depthBuffer:!1});return i()?m.texture.type=di:NB()&&(m.texture.internalFormat="rgba8unorm-srgb"),m.texture.name=f,m},n=r(1,1,"SplineTAA.A"),s=r(1,1,"SplineTAA.B"),a=null,o=!1,l=0,u=0,h=0,d=0;return{rtA:n,rtB:s,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new Ue,jitterOffsetUV:new Z(0,0),beginJitter(c,p,f){if(o)return;let m,g;if(o=!0,(a===null||a.cam!==c)&&(a?.clearViewOffset(),a=new WTe(c)),this.unjitteredProjection.copy(c.projectionMatrix),it.unjitteredProjection.value.copy(c.projectionMatrix),sx==="r2"){let v=++this.jitterIndex;m=(.5+HTe*v)%1,g=(.5+qTe*v)%1}else if(sx==="white")this.jitterIndex++,m=Math.random(),g=Math.random();else if(sx==="h64")m=p4(this.jitterIndex%64+1,2),g=p4(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if(sx==="half"){let[v,y]=QM[this.jitterIndex];m=.5+.5*(v-.5),g=.5+.5*(y-.5),this.jitterIndex=(this.jitterIndex+1)%QM.length}else[m,g]=QM[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%QM.length;l=p,u=f,h=m-.5,d=g-.5,it.cameraJitterPx.value.set(2*h,2*d),a.setViewOffset(p,f,h,d),this.jitterOffsetUV.set(-(m-.5)/p,-(g-.5)/f),Pi.taaJitterIndex=this.jitterIndex,Pi.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(t===c)return;let p=i();t=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 sme,ame,WD,WTe,QM,sx,HTe,qTe,$Te,XTe,pv,ome,t9,lme,YTe,HD,i9,KTe,ZTe=U(()=>{oe(),GTe(),ua(),vn(),bi(),sme=e=>e,ame=e=>e,WD=new Cn,WTe=class{constructor(e){this.cam=e,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(e,t,i,r){this.clearViewOffset();let n=this.cam.projectionMatrix.elements,s=-2*i/e,a=2*r/t;this._savedSkewX=n[8],this._savedSkewY=n[9],this._savedShiftX=n[12],this._savedShiftY=n[13],n[8]+=s*n[11],n[9]+=a*n[11],n[12]+=s*n[15],n[13]+=a*n[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let e=this.cam.projectionMatrix.elements;e[8]=this._savedSkewX,e[9]=this._savedSkewY,e[12]=this._savedShiftX,e[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},QM=Array.from({length:16},(e,t)=>[p4(t+1,2),p4(t+1,3)]),sx="h16";try{let e=new URLSearchParams(window.location.search).get("dbgjitseq");(e==="r2"||e==="h64"||e==="white"||e==="half")&&(sx=e)}catch{}HTe=.7548776662466927,qTe=.5698402909980532,$Te=class extends En{constructor(e,t,i,r,n=!1){super("vec4"),this._resolution=Fe(new Z(1,1)),this._historyValid=Fe(0),this._jitterUV=Fe(new Z(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=e,this.depthNode=t,this.velocityNode=i,this._hdr=n,this._history=r??jTe(),this._ownsHistory=r===void 0,this._outputTexNode=vt(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(e){c4.setProjectionMatrix(this._history.unjitteredProjection);let t=this.beautyNode.passNode.renderTarget,i=t.texture.width,r=t.texture.height,n=this._history;(n.rtA.width!==i||n.rtA.height!==r)&&(n.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=n.valid?1:0,this._jitterUV.value.copy(n.jitterOffsetUV);let s=n.flip?n.rtB:n.rtA,a=this._resolveMaterials?this._resolveMaterials[n.flip?1:0]:null,o=e.getRenderTarget(),l=e.getMRT();e.setMRT(null),n.valid||(e.setRenderTarget(n.rtA),e.clear(!0,!1,!1),e.setRenderTarget(n.rtB),e.clear(!0,!1,!1)),e.setRenderTarget(s),a&&(WD.material=a,WD.name="SplineTAA.resolve",WD.render(e)),e.setRenderTarget(o),e.setMRT(l),this._outputTexNode.value=s.texture,n.valid=!0,n.flip=!n.flip,Pi.taaResolves++,Pi.taaJitterIndex=n.jitterIndex,Pi.taaHistoryValid=!0,Pi.taaResolveSize=`${i}x${r}`}setup(e){let t=e.renderer.reversedDepthBuffer===!0,i=e.renderer.backend?.isWebGLBackend===!0,r=!1,n=!1,s=!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",n=x==="zv",s=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,f=this.velocityNode,m=this.depthNode,g=this._resolution,v=this._historyValid,y=this._jitterUV,_=x=>{let w=p.sample(x);return Pe(e9(w.rgb),w.a)},b=x=>{let w=Xe(()=>{let T=tr().toVar();if(d)return Pe(y.x.mul(400).add(.5),y.y.mul(400).add(.5),B(.5),B(1));let M=T,E=Me(B(1).div(g.x),B(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(([St,Nt])=>T.add(Me(E.x.mul(St),E.y.mul(Nt))).toVar()),P=A,N=B(t?-1e3:1e3).toVar(),D=Me(A[4]).toVar();for(let St=0;St<9;St++){let Nt=sme(m.load(Wa(A[St].mul(ame(g)))).r).toVar(),Qt=t?Nt.greaterThan(N):Nt.lessThan(N);N.assign(Qt.select(Nt,N)),D.assign(Qt.select(A[St],D))}let O=f.load(Wa(D.mul(g))).xy.mul(Me(.5,-.5)).toVar();n&&O.assign(Me(0,0));let z=T.sub(O).toVar(),L=i?Me(z.x,B(1).sub(z.y)).toVar():z,V=_(M).toVar();if(r)return Pe(O.x.mul(20).add(.5),O.y.mul(20).add(.5),v,B(1));if(l){let St=new Nr(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return St.needsUpdate=!0,vt(St).sample(T)}if(o){let St=i?Me(T.x,B(1).sub(T.y)):T;return x.sample(St)}if(a){let St=i?Me(T.x,B(1).sub(T.y)):T,Nt=x.sample(L),Qt=x.sample(St),Ei=V.x,xi=mi=>e9(mi.rgb).x;return Pe(xi(Nt).sub(Ei).abs().mul(8),xi(Qt).sub(Ei).abs().mul(8),B(0),B(1))}let G=L.mul(g).toVar(),Y=Ct(G.sub(.5)).add(.5).toVar(),$=G.sub(Y).toVar(),Q=$.mul($.mul($.mul(-.5).add(1)).add(-.5)).toVar(),ue=$.mul($).mul($.mul(1.5).add(-2.5)).add(1).toVar(),pe=$.mul($.mul($.mul(-1.5).add(2)).add(.5)).toVar(),xe=$.mul($).mul($.mul(.5).add(-.5)).toVar(),we=ue.add(pe).toVar(),re=pe.div(we).toVar(),Se=Y.sub(1).div(g).toVar(),W=Y.add(2).div(g).toVar(),k=Y.add(re).div(g).toVar(),K=Pe(0).toVar();K.addAssign(x.sample(Me(k.x,Se.y)).mul(we.x.mul(Q.y))),K.addAssign(x.sample(Me(Se.x,k.y)).mul(Q.x.mul(we.y))),K.addAssign(x.sample(Me(k.x,k.y)).mul(we.x.mul(we.y))),K.addAssign(x.sample(Me(W.x,k.y)).mul(xe.x.mul(we.y))),K.addAssign(x.sample(Me(k.x,W.y)).mul(we.x.mul(xe.y)));let ie=Pe(e9(K.rgb),K.a).toVar();if(c)return Pe(nme(ie.rgb).mul(J(1,.55,.55)),K.a);let j=_(P[0]).toVar(),ae=_(P[1]).toVar(),se=_(P[2]).toVar(),H=_(P[3]).toVar(),me=_(P[4]).toVar(),be=_(P[5]).toVar(),ke=_(P[6]).toVar(),Te=_(P[7]).toVar(),Ze=_(P[8]).toVar(),ze=Pe(Fi(j,Fi(ae,Fi(se,Fi(H,Fi(me,Fi(be,Fi(ke,Fi(Te,Ze))))))))).toVar(),qe=Pe(mt(j,mt(ae,mt(se,mt(H,mt(me,mt(be,mt(ke,mt(Te,Ze))))))))).toVar(),Ne=Pe(Fi(ae,Fi(H,Fi(me,Fi(be,Te))))).toVar(),ee=Pe(mt(ae,mt(H,mt(me,mt(be,Te))))).toVar();ze.assign(ze.add(Ne).mul(.5)),qe.assign(qe.add(ee).mul(.5));let Ce=qe.r.sub(ze.r).mul(.25).mul(.5).toVar(),He=V.gb.toVar();u||(ze.y.assign(He.x.sub(Ce)),ze.z.assign(He.y.sub(Ce)),qe.y.assign(He.x.add(Ce)),qe.z.assign(He.y.add(Ce)));let pt=Pe(s?ie:Xt(ie,ze,qe)).toVar(),tt=h||s?B(.9):B(.9).mul(v),Yt=Pe(ut(V,pt,tt)).toVar(),ni=it.tapAngle,ar=lK(T.mul(g).add(Me(ni.mul(127.1),ni.mul(311.7)))).sub(.5).mul(1/255);return Pe(nme(Yt.rgb,!this._hdr).add(J(ar)),Yt.a)}),S=new ei;return S.name="SplineTAA.resolve",S.colorNode=w(),S.depthTest=!1,S.depthWrite=!1,S.blending=Di,S.needsUpdate=!0,S};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[b(vt(this._history.rtB.texture)),b(vt(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),c4.setProjectionMatrix(null)}}}),$Be=U(()=>{XTe=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(e,t){this._frames=e>0&&!t?this._frames+1:0}}}),XBe=U(()=>{}),YBe=U(()=>{wB(),vn(),bi(),pv=new Cn,ome=new Z,lme=class extends En{static get type(){return"SMAANode"}constructor(e){super("vec4"),this.textureNode=e,this.updateBeforeType=gSe.FRAME,this._renderTargetEdges=new Ui(1,1,{depthBuffer:!1,type:di}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new Ui(1,1,{depthBuffer:!1,type:di}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new Ui(1,1,{depthBuffer:!1,type:di}),this._renderTargetBlend.texture.name="SMAANode.blend";let t=this,i=new Image;i.crossOrigin="anonymous",ZL(i,"smaa-node-area.png"),i.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Ri,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=rt,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",ZL(r,"smaa-node-search.png"),r.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Ri,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=yt,this._searchTexture.minFilter=yt,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=Fe(new Z),this._areaTextureUniform=vt(this._areaTexture),this._searchTextureUniform=vt(this._searchTexture),this._edgesTextureUniform=vt(this._renderTargetEdges.texture),this._weightsTextureUniform=vt(this._renderTargetWeights.texture),this._materialEdges=new ei,this._materialEdges.name="SMAANode.edges",this._materialWeights=new ei,this._materialWeights.name="SMAANode.weights",this._materialBlend=new ei,this._materialBlend.name="SMAANode.blend",this._textureNode=QSe(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),this._renderTargetEdges.setSize(e,t),this._renderTargetWeights.setSize(e,t),this._renderTargetBlend.setSize(e,t)}updateBefore(e){let{renderer:t}=e;t9=uq.resetRendererState(t,t9);let i=t.getDrawingBufferSize(ome);this.setSize(i.width,i.height),t.setRenderTarget(this._renderTargetEdges),pv.material=this._materialEdges,pv.render(t),t.setRenderTarget(this._renderTargetWeights),pv.material=this._materialWeights,pv.render(t),t.setRenderTarget(this._renderTargetBlend),pv.material=this._materialBlend,pv.render(t),uq.restoreRendererState(t,t9)}setup(e){let t=Me(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||tr(),n=Xe(()=>{let g=Pe(r.xy,r.xy).add(Pe(this._invSize.xy,this._invSize.xy).mul(Pe(-1,0,0,-1))),v=Pe(r.xy,r.xy).add(Pe(this._invSize.xy,this._invSize.xy).mul(Pe(1,0,0,1))),y=Pe(r.xy,r.xy).add(Pe(this._invSize.xy,this._invSize.xy).mul(Pe(-2,0,0,-2)));return Bn("vec4","vOffset0").assign(g),Bn("vec4","vOffset1").assign(v),Bn("vec4","vOffset2").assign(y),aO}),s=Xe(()=>{let g=Bn("vec4","vOffset0"),v=Bn("vec4","vOffset1"),y=Bn("vec4","vOffset2"),_=Me(.1,.1),b=Pe().toVar(),x=this.textureNode.sample(r).rgb.toVar(),w=this.textureNode.sample(g.xy).rgb.toVar(),S=ui(x.sub(w));b.x=mt(S.r,S.g,S.b);let T=this.textureNode.sample(g.zw).rgb.toVar();S=ui(x.sub(T)),b.y=mt(S.r,S.g,S.b);let M=hr(_,b.xy).toVar();et(M,Me(1,1)).equal(0).discard();let E=this.textureNode.sample(v.xy).rgb.toVar();S=ui(x.sub(E)),b.z=mt(S.r,S.g,S.b);let A=this.textureNode.sample(v.zw).rgb.toVar();S=ui(x.sub(A)),b.w=mt(S.r,S.g,S.b);let P=mt(b.x,b.y,b.z,b.w).toVar(),N=this.textureNode.sample(y.xy).rgb.toVar();S=ui(x.sub(N)),b.z=mt(S.r,S.g,S.b);let D=this.textureNode.sample(y.zw).rgb.toVar();return S=ui(x.sub(D)),b.w=mt(S.r,S.g,S.b),P=mt(P,b.z,b.w),M.xy.mulAssign(Me(hr(B(.5).mul(P),b.xy))),Pe(M,0,0)}),a=Xe(([g,v,y,_])=>{let b=Me(v).toVar();return b.r=y.add(b.r.mul(_)),B(255).mul(g.sample(b)).r}),o=Xe(([g,v,y,_,b])=>{let x=B(16).mul(B(4).mul(Me(y,_)).round()).add(v);return x=t.mul(x).add(B(.5).mul(t)),x.y.addAssign(B(i).mul(b)),g.sample(x).rg}),l=Xe(([g,v,y,_])=>{let b=Me(0,1).toVar(),x=Me(y).toVar();return Zr({start:De(0),end:De(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.subAssign(Me(2,0).mul(this._invSize)),Ve(x.x.lessThanEqual(_).or(b.g.lessThanEqual(B(.8281)).or(b.r.notEqual(B(0)))),()=>{Ya()})}),x.x.addAssign(B(.25).mul(this._invSize.x)),x.x.addAssign(this._invSize.x),x.x.addAssign(B(2).mul(this._invSize.x)),x.x.subAssign(this._invSize.x.mul(a(v,b,0,.5))),x.x}),u=Xe(([g,v,y,_])=>{let b=Me(0,1).toVar(),x=Me(y).toVar();return Zr({start:De(0),end:De(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.addAssign(Me(2,0).mul(this._invSize)),Ve(x.x.greaterThanEqual(_).or(b.g.lessThanEqual(B(.8281)).or(b.r.notEqual(B(0)))),()=>{Ya()})}),x.x.subAssign(B(.25).mul(this._invSize.x)),x.x.subAssign(this._invSize.x),x.x.subAssign(B(2).mul(this._invSize.x)),x.x.addAssign(this._invSize.x.mul(a(v,b,.5,.5))),x.x}),h=Xe(([g,v,y,_])=>{let b=Me(1,0).toVar(),x=Me(y).toVar();return Zr({start:De(0),end:De(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.addAssign(Me(0,-2).mul(this._invSize)),Ve(x.y.lessThanEqual(_).or(b.r.lessThanEqual(B(.8281)).or(b.g.notEqual(B(0)))),()=>{Ya()})}),x.y.addAssign(B(.25).mul(this._invSize.y)),x.y.addAssign(this._invSize.y),x.y.addAssign(B(2).mul(this._invSize.y)),x.y.subAssign(this._invSize.y.mul(a(v,b.gr,0,.5))),x.y}),d=Xe(([g,v,y,_])=>{let b=Me(1,0).toVar(),x=Me(y).toVar();return Zr({start:De(0),end:De(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.subAssign(Me(0,-2).mul(this._invSize)),Ve(x.y.greaterThanEqual(_).or(b.r.lessThanEqual(B(.8281)).or(b.g.notEqual(B(0)))),()=>{Ya()})}),x.y.subAssign(B(.25).mul(this._invSize.y)),x.y.subAssign(this._invSize.y),x.y.subAssign(B(2).mul(this._invSize.y)),x.y.addAssign(this._invSize.y.mul(a(v,b.gr,.5,.5))),x.y}),c=Xe(()=>{let g=r.xy.div(this._invSize),v=Pe(r.xy,r.xy).add(Pe(this._invSize.xy,this._invSize.xy).mul(Pe(-.25,-.125,1.25,-.125))).toVar(),y=Pe(r.xy,r.xy).add(Pe(this._invSize.xy,this._invSize.xy).mul(Pe(-.125,-.25,-.125,1.25))).toVar(),_=Pe(v.xz,y.yw).add(Pe(-2,2,-2,2).mul(Pe(this._invSize.xx,this._invSize.yy)).mul(B(8))).toVar();return Bn("vec2","vPixcoord").assign(g),Bn("vec4","vOffset0").assign(v),Bn("vec4","vOffset1").assign(y),Bn("vec4","vOffset2").assign(_),aO}),p=Xe(()=>{let g=Bn("vec2","vPixcoord"),v=Bn("vec4","vOffset0"),y=Bn("vec4","vOffset1"),_=Bn("vec4","vOffset2"),b=Pe(0,0,0,0).toVar(),x=Pe(0,0,0,0).toVar(),w=this._edgesTextureUniform.sample(r).rg.toVar();return Ve(w.g.greaterThan(B(0)),()=>{let S=Me().toVar(),T=Me().toVar();T.x=l(this._edgesTextureUniform,this._searchTextureUniform,v.xy,_.x),T.y=y.y,S.x=T.x;let M=this._edgesTextureUniform.sample(T).r.toVar(),E=Me().toVar();E.x=u(this._edgesTextureUniform,this._searchTextureUniform,v.zw,_.y),E.y=y.y,S.y=E.x,S=S.div(this._invSize.x).sub(g.x);let A=Rh(ui(S)),P=this._edgesTextureUniform.sample(E.add(Me(1,0).mul(this._invSize))).r.toVar();b.r=P,b.rg=o(this._areaTextureUniform,A,M,P,B(x.y))}),Ve(w.r.greaterThan(B(0)),()=>{let S=Me().toVar(),T=Me().toVar();T.y=h(this._edgesTextureUniform,this._searchTextureUniform,y.xy,_.z),T.x=v.x,S.x=T.y;let M=this._edgesTextureUniform.sample(T).g.toVar(),E=Me().toVar();E.y=d(this._edgesTextureUniform,this._searchTextureUniform,y.zw,_.w),E.x=v.x,S.y=E.y,S=S.div(this._invSize.y).sub(g.y);let A=Rh(ui(S)),P=this._edgesTextureUniform.sample(E.add(Me(0,1).mul(this._invSize))).g.toVar();b.ba=o(this._areaTextureUniform,A,M,P,B(x.x))}),b}),f=Xe(()=>{let g=Pe(r.xy,r.xy).add(Pe(this._invSize.xy,this._invSize.xy).mul(Pe(1,0,0,1)));return Bn("vec4","vOffset1").assign(g),aO}),m=Xe(()=>{let g=Bn("vec4","vOffset1"),v=Pe().toVar(),y=Pe().toVar();return y.xz=this._weightsTextureUniform.sample(r).xz,y.y=this._weightsTextureUniform.sample(g.zw).g,y.w=this._weightsTextureUniform.sample(g.xy).a,Ve(et(y,Pe(1)).lessThan(1e-5),()=>{v.assign(this.textureNode.sample(r))}).Else(()=>{let _=Me().toVar();_.x=y.a.greaterThan(y.b).select(y.a,y.b.negate()),_.y=y.g.greaterThan(y.r).select(y.g,y.r.negate()),Ve(ui(_.x).greaterThan(ui(_.y)),()=>{_.y.assign(0)}).Else(()=>{_.x.assign(0)});let b=this.textureNode.sample(r).toVar(),x=Me(r).toVar();x.addAssign(jc(_).mul(this._invSize));let w=this.textureNode.sample(x).toVar(),S=ui(_.x).greaterThan(ui(_.y)).select(ui(_.x),ui(_.y)).toVar(),T=ut(b,w,S);v.assign(T)}),v});return this._materialEdges.vertexNode=n().context(e.getSharedContext()),this._materialEdges.fragmentNode=s().context(e.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(e.getSharedContext()),this._materialWeights.fragmentNode=p().context(e.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=f().context(e.getSharedContext()),this._materialBlend.fragmentNode=m().context(e.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""}},YTe=e=>new lme(ESe(e))}),KBe=U(()=>{oe(),vn(),bi(),YBe(),ua(),HD=new Z,i9=new ot,KTe=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(e,t,i){if(this._rt===null||this._rt.width!==e||this._rt.height!==t){this._rt?.dispose();let r=new Ui(e,t,{depthBuffer:!0,stencilBuffer:!1,samples:0});r.texture.name="SplineHelperOverlay.color",this._rt=r}if(this._texNode===null){this._texNode=vt(this._rt.texture),this._smaaNode=YTe(this._texNode);let r=new ei;r.name="SplineHelperOverlayComposite",r.fragmentNode=this._smaaNode,r.transparent=!0,r.blending=qv,r.blendEquation=qo,r.blendSrc=Wx,r.blendDst=Rf,r.blendSrcAlpha=Wx,r.blendDstAlpha=Rf,r.depthTest=!1,r.depthWrite=!1,this._material=r,this._quad=new Cn(r);let n=new ei;n.name="SplineHelperOverlayDepthSeed",this._depthTexNode=vt(i),n.depthNode=this._depthTexNode.x,n.fragmentNode=Pe(0),n.colorWrite=!1,n.depthTest=!1,n.depthWrite=!0,this._seedMaterial=n,this._seedQuad=new Cn(n)}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(e,t,i,r,n){e.getDrawingBufferSize(HD);let s=this._ensureTarget(HD.x,HD.y,n),a=e.getRenderTarget(),o=e.autoClear;e.getClearColor(i9);let l=e.getClearAlpha();if(e.autoClear=!1,e.setRenderTarget(s),e.setClearColor(0,0),e.clear(!0,!0,!1),this._seedQuad.render(e),t&&e.render(t,r),e.clear(!1,!0,!1),i&&e.render(i,r),e.setRenderTarget(a),e.setClearColor(i9,l),function(){try{return new URLSearchParams(window.location.search).get("dbgoutguard")!=="0"}catch{return!0}}()){let u=e.toneMapping,h=e.outputColorSpace;e.toneMapping=Ls,e.outputColorSpace=ai.workingColorSpace,this._quad.render(e),e.toneMapping=u,e.outputColorSpace=h}else this._quad.render(e);e.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}}),$q,dO,cO,ZBe=U(()=>{vn(),$q=new WeakMap,dO=new Set,cO=0});function hme(e){let t=e.parent?.selectedTexture;return t&&t.isTexture===!0?t:null}function qD(e){let t=e.src.array,i=e.attr.array;for(let r=0,n=Math.min(t.length,i.length);r<n;r++)i[r]=t[r];e.attr.needsUpdate=!0}var Xq,JM,Wb,Yq,QBe=U(()=>{oe(),vn(),bi(),Xq=new WeakMap,JM=new Set,Wb=0,Yq=new WeakMap}),JBe=U(()=>{});function QTe(e,t,i,r){let n=e.num(0),s=e.num(1),a=e.num(.5),o=e.num(2),l=e.num(JTe),u=h=>e.sub(s,h);switch(t){case 0:return i;case 1:return e.min(e.add(i,r),s);case 3:return e.mul(e.add(i,r),a);case 4:{let h=e.max(u(e.div(u(i),e.max(r,l))),n);return e.mix(r,h,e.step(l,r))}case 5:{let h=e.min(e.div(i,e.max(u(r),l)),s);return e.mix(h,r,e.step(s,r))}case 6:return e.min(i,r);case 7:return e.abs(e.sub(i,r));case 8:return e.sub(e.add(i,r),e.mul(o,e.mul(i,r)));case 9:return e.max(i,r);case 10:return e.mul(i,r);case 11:{let h=e.min(e.div(i,e.max(r,l)),s);return e.mix(s,h,e.step(l,r))}case 12:return u(e.abs(e.sub(u(i),r)));case 14:{let h=e.mul(o,e.mul(i,r)),d=u(e.mul(o,e.mul(u(i),u(r))));return e.mix(h,d,e.step(a,i))}case 15:{let h=e.min(e.div(e.mul(i,i),e.max(u(r),l)),s);return e.mix(h,r,e.step(s,r))}case 16:return u(e.mul(u(i),u(r)));case 17:{let h=e.mul(o,r),d=e.add(e.mul(i,h),e.mul(e.mul(i,i),u(h))),c=e.add(e.mul(e.sqrt(e.max(i,n)),e.sub(h,s)),e.mul(e.mul(o,i),u(r)));return e.mix(d,c,e.step(a,r))}case 18:return e.max(e.sub(e.add(i,r),s),n);default:return r}}var JTe,eFe=U(()=>{JTe=1e-6});function fv(e,t,i,r,n){if(i===0)return e;if(i===2)return ut(e,t,Fi(n,r));let s=QTe(e2e,i,e,t);return ut(e,s,r)}function r9(e,t,i,r){if(i===0)return e;if(i===2)return mt(e,Fi(t,r));let n=QTe(t2e,i,e,t);return ut(e,n,r)}function n9(){return fO===null&&(fO=aw({output:YSe,velocity:c4})),fO}var ed,pO,e2e,t2e,fO,tFe=U(()=>{oe(),vn(),bi(),ZTe(),GTe(),vTe(),JBe(),xu(),ua(),eFe(),jt(),ed=e=>e,pO=e=>e,t2e=e2e={num:e=>B(e),add:(e,t)=>e.add(t),sub:(e,t)=>e.sub(t),mul:(e,t)=>e.mul(t),div:(e,t)=>e.div(t),min:(e,t)=>Fi(e,t),max:(e,t)=>mt(e,t),abs:e=>ui(e),sqrt:e=>Rh(e),step:(e,t)=>hr(e,t),mix:(e,t,i)=>ut(e,t,i)},fO=null});function i2e(e){if(!OA.enabled)return e;let t=Kq.get(e);return t||(t={...e,bloom:{...e.bloom,kernelSize:0},depthOfField:{...e.depthOfField,enabled:!1}},Kq.set(e,t)),t}var OA,Kq,mO,s9,Zq,Qq,gK,r2e=U(()=>{OA={enabled:!1},Kq=new WeakMap,mO=new WeakSet}),iFe=U(()=>{oe(),vn(),bi(),$Y(),vB(),mB(),s9=Xe(e=>{let t=e.lightDistance,i=e.cutoffDistance,r=e.decayExponent,n=i.greaterThan(0).and(r.greaterThan(0));return Ki(n,t.div(i).oneMinus().clamp().pow(r),B(1))}),Zq=class extends dq{static get type(){return"SplinePointLightNode"}setupDirect(e){let t=this.getLightVector(e),i=t.normalize(),r=s9({lightDistance:t.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},Qq=class extends qM{static get type(){return"SplineSpotLightNode"}setupDirect(e){let t,i,r=this.light,n=this.getLightVector(e),s=n.normalize(),a=s.dot(LSe(r)),o=this.getSpotAttenuation(e,a),l=s9({lightDistance:n.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),u=this.colorNode.mul(o).mul(l),h=r;if(h.colorNode?(i=this.getLightCoord(e),t=h.colorNode(i)):h.map&&(i=this.getLightCoord(e),t=vt(h.map,i.xy).onRenderUpdate(()=>h.map)),t&&i){let d=i.mul(2).sub(1).abs().lessThan(1).all();u=Ki(d,u.mul(t),u)}return{lightColor:u,lightDirection:s}}}}),n2e=U(()=>{gK=null});function rFe(){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.hidden===!0?Promise.resolve():new Promise(e=>{let t=!1,i=()=>{t||(t=!0,clearTimeout(r),e())},r=setTimeout(i,250);requestAnimationFrame(i)})}var ume,B_,dme,cme,pme,a9,o9,fme,mme,gme,vme,Ip,jm,N2,Wm,$D,l9,I2,mv,ac,F_,yme,gv,oc,O2,U_,XD,vv,lc,h9,u9,d9,YD,c9,p9,KD,ZD,Hm,f9,m9,g9,v9,y9,_9,b9,x9,vK,_me=U(()=>{oe(),vn(),bi(),kBe(),TTe(),xB(),yB(),dK(),FY(),Ih(),VBe(),jt(),IB(),qY(),NY(),CTe(),PTe(),GBe(),jBe(),ua(),VTe(),DTe(),qBe(),ZTe(),$Be(),XBe(),KBe(),ZBe(),QBe(),tFe(),r2e(),iFe(),n2e(),ume=new R,B_=new R,dme=new ot,cme=new ot,pme=new ot,a9=new R,o9=new R,fme=new Z,mme=new R(1,0,0),gme=new R(0,1,0),vme=new R(0,0,1),Ip=new R,jm=new R,N2=new R,Wm=new R,$D=new Ue,l9=new R,I2=new R,mv=new $a,ac=new ct,F_=new ct,yme=new Z,gv=new Z,oc=new R,O2=new R,U_=new R,XD=new R,vv=new R,lc=[],h9=!1,u9=!1,d9=!1,YD="full",c9="g16",p9=!1,KD=!1,ZD=!1,Hm="default",f9=!1,m9=!0,g9=!0,v9=!0,y9=!0,_9=!0,b9=kH;try{let e=new URLSearchParams(window.location.search),t=e.get("instancing");if(t!==null)if(t==="off"||t==="0"||t==="false"||t==="no")_9=!1;else{let n=Number.parseInt(t,10);Number.isFinite(n)&&n>1&&(b9=n)}h9=e.get("dbgao")==="0",u9=e.get("dbgshadow")==="0",d9=e.get("dbgfp16")==="1",p9=e.get("dbgsky")==="0",KD=e.get("dbgssr")==="0",ZD=e.get("dbgibl")==="0";let i=e.get("pbrcolor");i==="0"?Hm="off":(i==="linear"||i==="aces"||i==="agx"||i==="neutral")&&(Hm=i),f9=e.get("dbgplanar")==="0",m9=e.get("dbgplanarpyr")!=="0",g9=e.get("dbgssrpyr")!=="0",v9=e.get("dbgssrhalf")!=="0",y9=e.get("dbgssrresolve")!=="0";let r=e.get("dbgprefilter");r==="0"?YD="off":r==="base"?YD="base":r==="k4"&&(c9="k4")}catch{}(vK=x9=class extends pSe{constructor(e={}){var t;super({canvas:e.canvas,alpha:e.alpha??!0,antialias:e.antialias??!1,forceWebGL:e.forceWebGL??!1,powerPreference:e.powerPreference,trackTimestamp:e.trackTimestamp??globalThis.__SPLINE_TRACK_TIMESTAMP__===!0,stencil:!1,requiredLimits:e.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:d9?di:kr,asyncCompilation:e.asyncCompilation===!0||e.asyncCompilation==="load"}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new Z,this.dummyCamera=new Yn,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=HBe,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new XTe,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=e.asyncCompilation??!1,this._updateCompilationBurst(),Nq&&function(){if(!Oq){if(Oq=!0,a4=()=>it.frameIndex.value,typeof GPUBuffer<"u"){let i=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return qfe("buffer",this.label,this.size),i.call(this)}}if(typeof GPUTexture<"u"){let i=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return qfe("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 pK(this),this.library.addLight(MTe,s4),this.shadowMap.enabled=!0,this.shadowMap.type=Pf,t=this.backend?.isWebGPUBackend===!0,ZM=t,this._deferGpuBufferDestruction(),function(i){let r=i;if(r==null||typeof r._draw!="function"||r.__splineDrawGuardInstalled===!0)return;r.__splineDrawGuardInstalled=!0;let n=r._draw.bind(r);r._draw=function(s,a,o,l,u,h,d,c,p){if(d.vertexCount>0&&s.getIndex()===null&&s.getIndirect()===null&&s.object.isBatchedMesh!==!0){let f=d.firstVertex+d.vertexCount;for(let m=0;m<h.length;m++){let g=h[m];if(g.isInstancedBufferAttribute!==!0&&g.isInstancedInterleavedBuffer!==!0&&g.count!==void 0&&g.count<f)return}}return n(s,a,o,l,u,h,d,c,p)}}(this.backend),this.outputColorSpace=Md,this.toneMapping=Ls,function(i){let r=i.library;r.addLight(Zq,QA),r.addLight(Qq,Tw),r.addLight(cq,Sw),r.lightNodes.delete(lA),r.lightNodes.delete(cy),r.addLight(Zq,lA),r.addLight(Qq,cy)}(this),this.sceneBundlesEnabled=e.sceneBundles===!0||e.sceneBundles==="rerecord",this.sceneBundlesForceRerecord=e.sceneBundles==="rerecord",this.auxiliary=e.auxiliary===!0,this.domElement.removeAttribute?.("data-engine")}advanceFrame(){let e=this._nodes,t=this.info;t.autoReset===!0&&t.reset(),e.nodeFrame.update(),t.frame=e.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>x9._GAUGE_STALL_MS}_trackGaugeStall(){let e=this._asyncCompilationGauges,t=e!==void 0&&(e.queued>0||e.pipelines>0),i=t?`${e.queued}/${e.pipelines}`:"";return t?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 ${x9._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(e){let t=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(e,t),Pi.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${e} 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 e=this._asyncCompilationGauges;return e!==void 0&&(e.queued>0||e.pipelines>0)}get asyncCompilationEnabled(){return this._asyncCompilation===!0}get taaHistory(){return this._taaHistory||(this._taaHistory=jTe()),this._taaHistory}async init(){await super.init();let e=this.backend.gl;if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(t){console.warn(t)}return this.backend.device?.lost?.then(t=>{Pi.deviceLost=`${t?.reason??"unknown"}: ${t?.message??""}`.trim()}),this}setSize(e,t,i=!0){if(this._appliedWidth!==e||this._appliedHeight!==t||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=e,this._appliedHeight=t,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==e||this.viewportHeight!==t;this.viewportWidth=e,this.viewportHeight=t,super.setSize(e,t,i),r&&this.pipeline.resize(e,t,i)}return this}setPixelRatio(e=1){return this.getPixelRatio()!==e&&super.setPixelRatio(e),this}get hdTransmission(){return it.transmissionLod.value===1}set hdTransmission(e){it.transmissionLod.value=e===!0?1:2}renderScenePass(e,t){this.render(e,t)}_renderObjects(e,t,i,r,n=null){let s=this,a=n===null&&i.overrideMaterial===null;for(let o=0,l=e.length;o<l;o++){let{object:u,geometry:h,material:d,group:c,clippingContext:p}=e[o];a&&ETe(d)?this._renderWithDepthPrepass(u,i,t,h,d,c,r,p):s._currentRenderObjectFunction(u,i,t,h,d,c,r,p,n)}}_renderWithDepthPrepass(e,t,i,r,n,s,a,o){let l=this,u=(d,c)=>l._handleObjectFunction(e,d,t,i,a,s,o,c),h=s;e.onBeforeRender(this,t,i,r,n,h),n.side===Ur&&n.forceSinglePass===!1?(u(n.getDepthPrepassTwin(Rr),null),n.side=Rr,u(n,"backSide"),u(n.getDepthPrepassTwin(Aa),null),n.side=Aa,u(n,null),n.side=Ur,Pi.depthPrepassDraws+=2):(u(n.getDepthPrepassTwin(n.side),null),u(n,null),Pi.depthPrepassDraws++),e.onAfterRender(this,t,i,r,n,h)}get skySystem(){return this._skySystem}get skyAnimationActive(){return this._skySystem?.animationActive===!0}*_liveBundledPages(){for(let e of this._bundledPages){let t=e.deref();t===void 0?this._bundledPages.delete(e):yield t}}_armBundleValve(){if(this._bundleValveArmed)return;let e=this.backend.device;typeof e?.addEventListener=="function"&&(this._bundleValveArmed=!0,e.addEventListener("uncapturederror",t=>{if(!this.sceneBundlesEnabled||!(t?.error?.message??"").toLowerCase().includes("destroyed"))return;let i=it.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,Pi.bundleDisabled=!0;for(let n of this._liveBundledPages()){let s=this._bundleStates.get(n);s&&(s.disabled=!0),n.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(e,t){if(this.backend.beginBundle===void 0)return;let i=this._bundleStates.get(e);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(e,i),this._bundledPages.add(new WeakRef(e)),this._armBundleValve()}let r=e;if(i.disabled)return;{let d=t.matrixWorld.elements,c=t.projectionMatrix.elements,p=-2128831035;for(let f=0;f<16;f++)p^=1e4*d[f]|0,p=Math.imul(p,16777619),p^=1e4*c[f]|0,p=Math.imul(p,16777619);i.camHash=p}let n=-2128831035,s=d=>{n^=0|d,n=Math.imul(n,16777619)};s(this._grabTargetEpoch),s(e.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),s(d.id),s(d.version),s(d.transparent===!0?1:0),typeof d.assetsLoaded=="function"&&s(d.assetsLoaded()?1:0)},h=!1;if(e.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),s(c.id),s(c.visible?1:0),s(c.layers.mask),s(c.renderOrder),s(c.matrixWorld.determinantAffine()<0?1:0);let f=c.geometry;o(f),s(f.id),s(f.drawRange.start),s(f.drawRange.count===1/0?-1:f.drawRange.count),s(l(f.index)),s(l(f.attributes.position)),s(f.instanceCount??-1),s(c.count===void 0?-1:c.count);let m=c.material;if(Array.isArray(m))for(let g of m)u(g);else m&&u(m)}else d.isLight===!0?(s(d.id),s(d.visible?1:0),s(d.castShadow?1:0)):(s(d.id),s(d.visible?1:0))}),s(i.epoch),i.checks++,Pi.bundleChecks=i.checks,i.checks%600==0){let d=this._bundleDebug;Pi.bundleIncompleteRecords=d?.incompleteRecords??0,Pi.bundleRecords=d?.records??0,Pi.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)}(e),void(i.signature=n);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=n);if(n!==i.signature){if(i.signature=n,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch||h)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(Pi.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,Pi.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,Pi.bundleDisabled=!0)}}_ensureWarmupTarget(){if(this._warmupTarget===null){let e=new Ui(2,2,{count:2});e.textures[0].name="output",e.textures[0].type=kr,e.textures[1].name="velocity",e.textures[1].type=di;let t=new is(2,2);t.isRenderTargetTexture=!0,e.depthTexture=t,this._warmupTarget=e}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(e,t=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[e,t,i]:super.setRenderTarget(e,t,i)}setMRT(e){return this._warmupInFlight?(this._warmupPendingMRT=[e],this):(super.setMRT(e),this)}async compileSceneAsync(e,t){if(!t)return;{let n=e instanceof Og?e.activePage:e;Zfe(fy.isSoft(n?.data?.shadow)),n&&Ufe(n)}if(this._asyncCompilationMode!==!1)return this._asyncCompilationMode==="load"&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(e,t);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(t),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(n9())),await this.compileAsync(e,t)}catch(n){console.warn("[spline/webgpu] pipeline warm-up failed:",n)}finally{let n=this._warmupPendingTarget,s=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),n!==null?super.setRenderTarget(n[0],n[1],n[2]):super.setRenderTarget(i),s!==null?super.setMRT(s[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(e,t){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(t);let i,r=this.getRenderTarget(),n=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(n9())),i=this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(n)}let s=this._warmupGrabContext(e,t);await i,await s}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(e,t){let i=e instanceof Og?e:e.scene;if(i.needsTransmission?.()!==!0&&i.needsReflection?.()!==!0)return null;if(this._grabWarmupTarget===null){let s=new Ui(2,2);s.texture.type=kr;let a=new is(2,2);a.isRenderTargetTexture=!0,s.depthTexture=a,this._grabWarmupTarget=s}let r=this.getRenderTarget(),n=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(n)}}_setThreeAsyncCompilation(e){this.setAsyncCompilation(e)}_updateCompilationBurst(){let e=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||this._asyncCompilationMode==="load"&&this.asyncCompilationEnabled;this.setCompilationBurst(e),Pi.compilationBurst=e}_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(e){let t=e;(t.coordinateSystem!==this.coordinateSystem||t.perspCamera!==void 0&&t.perspCamera.coordinateSystem!==this.coordinateSystem||t.orthoCamera!==void 0&&t.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(t.coordinateSystem=this.coordinateSystem,t.perspCamera!==void 0&&(t.perspCamera.coordinateSystem=this.coordinateSystem),t.orthoCamera!==void 0&&(t.orthoCamera.coordinateSystem=this.coordinateSystem),e.updateProjectionMatrix?.())}_prepareHelpers(e,t,i){e.traverse(r=>{let n=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=Xq.get(d);return p&&(p.epoch!==Wb||p.srcMaterial!==c||p.geometry!==d.geometry||p.position.src!==d.geometry.getAttribute("position")||p.map!==c.map||p.selectedMap!==hme(d))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(f,m){let g=f.geometry,v=g.getAttribute("position"),y=g.getAttribute("aSelection"),_=g.getAttribute("aVisibility"),b=m.map,x=hme(f),w=new ml(v.array,3);w.setUsage(xd);let S={src:v,attr:w,version:v.version},T=[],M=L=>{let V=new ml(new Float32Array(L.count),1);V.setUsage(xd);let G={src:L,attr:V,version:L.version};return qD(G),T.push(G),G},E=y?M(y):null,A=_?M(_):null,P=new PA;P.name=`SplinePointsTwin(${m.name||m.type})`,P.positionNode=gg(S.attr,"vec3"),P.size=m.size,P.sizeAttenuation=m.sizeAttenuation,P.transparent=m.transparent,P.depthTest=m.depthTest,P.depthWrite=m.depthWrite,P.blending=m.blending,P.fog=!1;let N=E?gg(E.attr,"float"):null,D=A?gg(A.attr,"float"):null;P.colorNode=Xe(()=>{D!==null?eO(D.lessThan(.5)):N!==null&&eO(N.greaterThan(.5));let L=b!==null?vt(b,tr()):Pe(1);return(N!==null&&b!==null&&x!==null?ut(L,vt(x,tr()),N):L).mul(Pe(FSe,1))})();let O=new D7(P);O.name=`SplinePointsTwin(${f.name||f.type})`,O.frustumCulled=!1,O.raycast=()=>{};let z={sprite:O,material:P,srcMaterial:m,geometry:g,map:b,selectedMap:x,position:S,mirrors:T,epoch:Wb};return JM.add(new WeakRef(z)),z}(d,c),Xq.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(f,m){let{sprite:g,position:v,srcMaterial:y}=m;v.version!==v.src.version&&(m.position.attr.needsUpdate=!0,v.version=v.src.version);for(let b of m.mirrors)b.version!==b.src.version&&(qD(b),b.version=b.src.version);let _=Math.max(0,Math.min(m.geometry.drawRange.count,v.src.count));g.count=_,m.material.size=y.size,m.material.opacity=y.opacity,m.material.color.copy(y.color),g.layers.mask=f.layers.mask,g.renderOrder=f.renderOrder}(d,p),p.sprite}(u,h):function(d,c){if(c.isShaderMaterial!==!0)return!1;let p=c.uniforms,f=p?.pointSize?.value,m=p?.color?.value;return typeof f=="number"&&f>1&&Array.isArray(m)&&m.length>=3&&d.geometry.getAttribute("hover")!==void 0&&d.geometry.getAttribute("selected")!==void 0}(u,h)?function(d,c){let p=Yq.get(d);return p&&(p.epoch!==Wb||p.srcMaterial!==c||p.geometry!==d.geometry||!function(f,m){let g=[[f.position,"position"],[f.hover,"hover"],[f.selected,"selected"]];for(let[v,y]of g){let _=m.getAttribute(y);if(_===void 0)return!1;if(v.src!==_){if(_.count!==v.attr.count)return!1;v.src=_,v.version=-1}}return!0}(p,d.geometry))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(f,m){let g=f.geometry,v=m.uniforms,y=(N,D)=>{let O=new ml(new Float32Array(N.count*D),D);O.setUsage(xd);let z={src:N,attr:O,version:N.version};return qD(z),z},_=y(g.getAttribute("position"),3),b=y(g.getAttribute("hover"),1),x=y(g.getAttribute("selected"),1),w=Fe(v.pointSize.value),S=Fe(new ot().fromArray(v.color.value)),T=new PA;T.name=`SplinePointsTwin(${m.name||m.type})`,T.positionNode=gg(_.attr,"vec3");let M=gg(b.attr,"float"),E=gg(x.attr,"float");T.sizeNode=w.add(M.mul(4)),T.sizeAttenuation=!1,T.transparent=m.transparent,T.depthTest=m.depthTest,T.depthWrite=m.depthWrite,T.blending=m.blending,T.fog=!1,T.colorNode=Xe(()=>{let N=Yi(tr().mul(2).sub(1)).toVar();eO(N.greaterThan(1));let D=Ki(E.equal(1),J(.22,.9,.7),S.add(M.mul(.25)));return Pe(Ki(N.greaterThan(.75),J(1),D),1)})();let A=new D7(T);A.name=`SplinePointsTwin(${f.name||f.type})`,A.frustumCulled=!1,A.raycast=()=>{};let P={sprite:A,material:T,srcMaterial:m,geometry:g,pointSize:w,color:S,position:_,hover:b,selected:x,epoch:Wb};return JM.add(new WeakRef(P)),P}(d,c),Yq.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(f,m){for(let y of[m.position,m.hover,m.selected])y.version!==y.src.version&&(qD(y),y.version=y.src.version);let g=m.srcMaterial.uniforms;m.pointSize.value=g.pointSize.value,m.color.value.fromArray(g.color.value);let v=Math.max(0,Math.min(m.geometry.drawRange.count,m.position.src.count));m.sprite.count=v,m.material.opacity=m.srcMaterial.opacity,m.sprite.layers.mask=f.layers.mask,m.sprite.renderOrder=f.renderOrder}(d,p),p.sprite}(u,h):null}(r);if(l!==null)return l.visible=n.visible,void(n.visible&&(t.push(n),n.visible=!1))}let s=!1,a="",o=Array.isArray(n.material)?n.material:n.material?[n.material]:[];for(let l of o){let u=l;if(u.isShaderMaterial===!0&&u.isNodeMaterial!==!0){s=!0,a=`WebGL-only material "${u.type}"`;break}}if(s&&!Array.isArray(n.material)){let l=function(u){return u.isLineMaterial===!0?function(h){let d=$q.get(h);if(!d||d.epoch!==cO){let g=new dSe;g.name=`SplineHelperTwin(${h.name||h.type})`,g.worldUnits=!1,d={twin:g,epoch:cO},$q.set(h,d),dO.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 f=p.dashed===!0;if(c.dashed!==f&&(c.dashed=f,c.needsUpdate=!0),f){let g=c;g.dashScale=p.dashScale??1,g.dashSize=p.dashSize??1,g.gapSize=p.gapSize??1}let m=p.vertexColors===!0||p.vertexColors===2;return c.vertexColors!==m&&(c.vertexColors=m,c.needsUpdate=!0),c}(u):null}(n.material);if(l)return i.push({object:n,original:n.material}),void(n.material=l)}!s&&n.geometry?.isInstancedBufferGeometry===!0&&!Number.isFinite(n.geometry.instanceCount??0)&&(s=!0,a="infinite instanceCount geometry"),s&&n.visible&&(this._warnedHelperIncompat.has(r)||this._warnedHelperIncompat.add(r),t.push(n),n.visible=!1)})}renderHelperOverlay(e,t,i,r){let n=[],s=[];if(e&&this._prepareHelpers(e,n,s),t&&this._prepareHelpers(t,n,s),r)this._helperOverlay??(this._helperOverlay=new KTe),this._helperOverlay.render(this,e,t,i,r),Pi.helperOverlayMode="smaa";else{let a=this.autoClear;this.autoClear=!1,e&&this.render(e,i),t&&(this.clearDepth(),this.render(t,i)),this.autoClear=a,Pi.helperOverlayMode="direct"}for(let a of s)a.object.material=a.original;for(let a of n)a.visible=!0}createEffectChain(){return function(e){let t=e.pipeline,i=t.postprocessingState,r=i.enabled===!0,n=ZSe(t.scene,t.camera),s=e.hdrChainActive;try{let E=new URLSearchParams(window.location.search).get("dbgfp16");(E==="scene"||E==="st")&&(s=!0)}catch{}let a=n.getTextureNode(),o=a,l=null;if(e.temporalAAEnabled){n.setMRT(n9()),l=function(E,A,P,N,D=!1){return new $Te(E,A,P,N,D)}(a,n.getTextureNode("depth"),n.getTextureNode("velocity"),e.taaHistory,s),o=l,n.getTexture("velocity").type=di;try{if(new URLSearchParams(window.location.search).get("dbgvel")==="1"){let E=ed(n.getTextureNode("velocity"));o=Pe(pO(E.x).mul(20).add(.5),pO(E.y).mul(20).add(.5),B(.5),B(1))}}catch{}}s?n.getTexture("output").type=di:NB()&&(n.getTexture("output").internalFormat="rgba8unorm-srgb");let u=(E,A)=>typeof E=="number"&&Number.isFinite(E)?E:A,h={bloomIntensity:Fe(1),caOffset:Fe(new Z(0,0)),caAspect:Fe(1),vignetteOffset:Fe(0),vignetteDarkness:Fe(0),hueVector:Fe(new R(1,0,0)),saturationFactor:Fe(0),brightness:Fe(0),bcContrastScale:Fe(1),dofFocusDistance:Fe(0),dofFocalLength:Fe(0),dofBokehScale:Fe(1),dofCameraNear:Fe(50),dofCameraFar:Fe(1e4),dofOrtho:Fe(0),pixelCells:Fe(new Z(1,1)),bloomOpacity:Fe(1),caOpacity:Fe(1),vignetteOpacity:Fe(1),noiseOpacity:Fe(1),hueSaturationOpacity:Fe(1),brightnessContrastOpacity:Fe(1),dofOpacity:Fe(1)},d=E=>pO(E),c=(E,A)=>{h.bloomIntensity.value=u(E.bloom.intensity,1),h.bloomOpacity.value=u(E.bloom.opacity,1),h.caOffset.value.set(u(E.chromaticAberration.offset?.[0],10),u(E.chromaticAberration.offset?.[1],10)),h.caOpacity.value=u(E.chromaticAberration.opacity,1),h.vignetteOffset.value=u(E.vignette.offset,.5),h.vignetteDarkness.value=u(E.vignette.darkness,.5),h.vignetteOpacity.value=u(E.vignette.opacity,1),h.noiseOpacity.value=u(E.noise.opacity,1),h.hueVector.value.fromArray(function(G){let Y=Math.sin(G),$=Math.cos(G);return[(2*$+1)/3,(-Math.sqrt(3)*Y-$+1)/3,(Math.sqrt(3)*Y-$+1)/3]}(u(E.hueSaturation.hue,0))),h.saturationFactor.value=function(G){return G>0?1-1/(1.001-G):-G}(u(E.hueSaturation.saturation,0)),h.hueSaturationOpacity.value=u(E.hueSaturation.opacity,1),h.brightness.value=u(E.brightnessContrast.brightness,0);let P=Math.min(u(E.brightnessContrast.contrast,0),.9999);h.bcContrastScale.value=P>0?1/(1-P):1+P,h.brightnessContrastOpacity.value=u(E.brightnessContrast.opacity,1);let N=t.camera,D=N?.isPerspectiveCamera===!0,O=function(G,Y,$){return{focusDistance:$?G/2e3:(G+992)/2e3,focusRange:Math.max(Y/2e3,1e-6)}}(u(E.depthOfField.focusDistance,lO.focusDistance),u(E.depthOfField.focalLength,lO.focalLength),D);h.dofFocusDistance.value=O.focusDistance,h.dofFocalLength.value=O.focusRange,h.dofBokehScale.value=u(E.depthOfField.bokehScale,lO.bokehScale),h.dofOpacity.value=u(E.depthOfField.opacity,1),h.dofCameraNear.value=u(N?.near,50),h.dofCameraFar.value=u(N?.far,1e4),h.dofOrtho.value=D?0:1;let z=A.resolution.x?A.resolution:new Z(A.viewportWidth*A.getPixelRatio(),A.viewportHeight*A.getPixelRatio());h.caAspect.value=z.y>0?z.x/z.y:1;let L=Math.floor(u(E.pixelation.granularity,30));L%2>0&&(L+=1);let V=L>0;h.pixelCells.value.set(V?z.x/L:z.x,V?z.y/L:z.y)};c(i,e);let p=ed(o),f=p.rgb,m=p.a,g=r&&i.pixelation.enabled,v=h.pixelCells,y=E=>E.mul(v).floor().add(.5).div(v),_=l?l.outputTextureNode:a;if(g){let E=ed(_.sample(y(tr())));f=ut(f,E.rgb,1),m=ut(m,E.a,1)}if(r&&i.chromaticAberration.enabled){let E=i.chromaticAberration,A=h.caOffset.mul(.001).mul(Me(1,d(h.caAspect))),P=z=>g?y(z):z,N=ed(_.sample(P(tr().add(A)))),D=ed(_.sample(P(tr().sub(A)))),O=mt(mt(N.a,D.a),m);f=fv(f,J(N.r,f.g,D.b),E.blendFunction,d(h.caOpacity),O),m=r9(m,O,E.blendFunction,d(h.caOpacity))}let b=null;if(r&&i.depthOfField.enabled){let E=Tre("depthOfField");if(E){let A=i.depthOfField;b=E(Pe(f,m),_,n.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:s,inputUv:g?y:void 0});let P=ed(b);f=fv(f,P.rgb,A.blendFunction,d(h.dofOpacity),P.a),m=r9(m,P.a,A.blendFunction,d(h.dofOpacity))}else jH("depthOfField","webgpu")}let x=null;if(r&&i.bloom.enabled){let E=Tre("bloom");if(E){let A=i.bloom;x=E(l?l.outputTextureNode:a,{kernelSize:lLe(A.kernelSize),blurScale:u(A.blurScale,1),luminanceThreshold:u(A.luminanceThreshold,.9),luminanceSmoothing:u(A.luminanceSmoothing,.025)});let P=Xt(ed(x).mul(d(h.bloomIntensity)),0,1);f=fv(f,P.rgb,A.blendFunction,d(h.bloomOpacity),P.a),m=r9(m,P.a,A.blendFunction,d(h.bloomOpacity))}else jH("bloom","webgpu")}if(r&&i.hueSaturation.enabled){let E=i.hueSaturation,A=h.hueVector,P=J(et(f,A),et(f,A.zxy),et(f,A.yzx)),N=P.r.add(P.g).add(P.b).div(3);f=fv(f,P.add(J(N).sub(P).mul(d(h.saturationFactor))).min(1),E.blendFunction,d(h.hueSaturationOpacity),m)}if(r&&i.brightnessContrast.enabled){let E=i.brightnessContrast,A=f.add(J(d(h.brightness)));A=A.sub(.5).mul(d(h.bcContrastScale)).add(.5),f=fv(f,A.min(1),E.blendFunction,d(h.brightnessContrastOpacity),m)}if(r&&i.vignette.enabled){let E=i.vignette,A=Yi(tr().sub(.5)).mul(d(h.vignetteDarkness).add(d(h.vignetteOffset))),P=Qr(d(h.vignetteOffset).mul(.799),B(.8),A).oneMinus();f=fv(f,f.mul(P),E.blendFunction,d(h.vignetteOpacity),m)}if(r&&i.noise.enabled){let E=i.noise,A=gr(Pa(yd(et(tr().mul(cTe),Me(12.9898,78.233)),Math.PI)).mul(43758.5453));f=fv(f,J(A),E.blendFunction,d(h.noiseOpacity),m)}r&&(s?f=f.max(0):(f=Xt(f,0,1),m=Xt(m,0,1)));let w=Pe(f,m);if(t.uiOverlayEnabled&&t.uiCanvasTexture){let E=ed(vt(t.uiCanvasTexture,tr().flipY())),A=ut(w.rgb,E.rgb,E.a),P=Xt(w.a.add(E.a),0,1);w=Pe(A,P)}let S=t.sceneTransitionFromTexture;if(S){let E=ed(vt(S,tr())),A=t.sceneTransitionPass.uniforms.mixRatio;w=ut(E,w,A)}let T=t.watermarkTexture;if(T){let E=T.image,A=E?.width||128,P=E?.height||32,N=new Z(e.viewportWidth*e.getPixelRatio(),e.viewportHeight*e.getPixelRatio()),D=12*e.getPixelRatio(),O=.5*A*e.getPixelRatio(),z=.5*P*e.getPixelRatio(),L=Me((N.x-O-D)/N.x,D/N.y),V=Me(O/N.x,z/N.y),G=tr().flipY().sub(L).div(V),Y=G.x.greaterThanEqual(0).and(G.x.lessThanEqual(1)).and(G.y.greaterThanEqual(0)).and(G.y.lessThanEqual(1)),$=Xt(G,0,1),Q=ed(vt(T,$)),ue=Q.a.mul(Y.select(B(1),B(0)));w=Pe(ut(w.rgb,Q.rgb,ue),Xt(w.a.add(ue),0,1))}let M=new fSe(e,w);return{syncValues:c,render(){n.scene=t.scene,n.camera=t.camera,M.render()},renderTAAResolve:l?E=>{n.scene=t.scene,n.camera=t.camera,l.renderResolve(E)}:null,renderBloomPasses:x?E=>{n.scene=t.scene,n.camera=t.camera,x.renderBloom(E)}:null,renderDoFPasses:b?E=>{n.scene=t.scene,n.camera=t.camera,b.renderDoF(E)}:null,resize(){},sceneDepthTexture:()=>n.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),b?.dispose(),n.dispose(),M.dispose()}}}(this)}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,n=t.width,s=this.viewportWidth/this.viewportHeight;n<r?n=r*s:r=n/s,this.dummyCamera.setViewplaneSize(n,r);for(let a=0;a<i;a++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(NH()?.drainRetired()??0)+(OH()?.drainRetired()??0)>0&&this._retireBundleRecords(),Nq&&function(v){if(v==null||v===Lq)return;let y=v;typeof y.addEventListener=="function"&&(Lq=v,y.addEventListener("uncapturederror",_=>{let b=_?.error?.message??"";!b.toLowerCase().includes("destroyed")||Iq<=0||(Iq--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${a4()} (t=${Math.round(performance.now())}ms):
|
|
6226
6226
|
${b.slice(0,400)}
|
|
6227
|
-
\u2014 last ${Ix.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,Ix.map(x=>({...x}))))}))}(this.backend.device);let n=this._skippedAsyncDraws??0;Pi.skippedAsyncDraws=n,this._skippedAsyncDraws=0,this._trackStalledSkips(n),this._trackGaugeStall(),awe(this);let s=e instanceof Og?e.activePage:e,a=s.visible;s.visible=!0;let o=s.scene;if(Ufe(s),this.renderStarted=!0,_9&&e instanceof Og){let v=e.updateInstanceGroups(s,b9);Pi.instancingGroups=v.instancingGroups,Pi.instancedDrawsSaved=v.instancedDrawsSaved,Pi.instancingRegroups=v.instancingRegroups,Pi.instancingParks=v.instancingParks,Pi.instancingIneligible=v.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(s,t)),this.normalizeCameraCoordinateSystem(t),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(s.bgColor,s.bgColor.a),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride);let l=p9?null:s.skyState;if(l?.enabled===!0){if(this.skyEnvironmentNeeded=!this.auxiliary&&(!KD&&(o.needsReflectionDirty||o.needsReflection())||!ZD&&l.lighting===!0),this._skySystem===null){let v=gK;v===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=v(this)}this._skySystem?.update(s,t)}else this._skySystem?.attached&&this._skySystem.detach();if(!this.auxiliary){let v=null,y=0;!ZD&&l?.enabled===!0&&this._skySystem&&(v=this._skySystem.iblTexture??null,y=this._skySystem.iblRotationY??0),function(_){if(cd.quality===_)return!1;cd.quality=_;for(let b of IA)zE(b)}(l?.lightingQuality==="low"?"low":"full"),function(_){if(cd.texture===_)return!1;cd.texture=_,cd.version++;for(let b of IA)zE(b)}(v),cd.rotation.set(0,-y,0),s.environmentIntensity=l?.enabled===!0?l.lightingIntensity??1:1}{let v=Hm==="off"?null:s.gradingState,y=Hm!=="default"&&Hm!=="off",_=y||v?.pipeline==="linear",b=y?Hm==="linear"?"none":Hm:v?.toneMapping??"aces";this.toneMapping=_?b==="aces"?rA:b==="agx"?nA:b==="neutral"?sA:Ls:Ls,this.toneMappingExposure=_?v?.exposure??1:1,this.outputColorSpace=_?Xi:Md,this.hdrChainActive=_,this.temporalAAEnabled&&this.taaHistory.setHdr(_)}it.pixelRatio.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?it.resolution.value.set(this.resolution.x,this.resolution.y):it.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let u=(it.frameIndex.value+1)%16;it.frameIndex.value=u;let h=OTe[u];it.pcssHalton.value.set(h[0],h[1]),it.tapAngle.value=Math.random()*Math.PI*2,it.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(s),this.sceneBundlesEnabled&&this._lightShadowStateDirty&&(this._lightShadowStateDirty=!1,this._updateSceneBundle(s,t)),it.unjitteredProjection.value.copy(t.projectionMatrix);let d=this.temporalAAEnabled?this.taaHistory:null;if(d){let v=this.getDrawingBufferSize(gv);d.beginJitter(t,v.x,v.y)}this._renderShadowMaskPass(s,t),it.orthographicUniform.value=t.projectionMatrix.elements[11]===0?1:0;let c=o.shapeBlendIntances.length>0?zY:null;if(c!==null)for(let v of o.shapeBlendIntances)c(v).update(v,this,t);let p=o.hairInstances.length>0?LY:null;if(p!==null)for(let v of o.hairInstances)p(v).update(v,this);o.needsTransmission()&&this._renderTransmissionPass(s,t),o.needsNormal()&&this._renderNormalPass(s,t,o.normalPassNeeds()),s.overrideMaterial=o.wireframeState?KL:null,t.layers.enable(3),t.layers.enable(8),t.layers.enable(4);let f=s.data.ao,m=f.occlusion&&!h9&&!OA.enabled;if(it.aoEnabled.value=m,it.aoEnabledUniform.value=m?1:0,m){let v=this,y=v._skippedAsyncDraws??0;this._renderAOPass(s,t,f),(v._skippedAsyncDraws??0)>y&&(it.aoEnabledUniform.value=0)}if(!KD&&o.needsReflection()?(this._renderReflectionPass(s,t),f9?it.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(s,t),this._renderReflectionResolvePass(s,t)):it.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(s,t),this.pipeline.isUIOverlayEnabled&&s.uiCanvas?.enabled&&s.uiCanvas.texture&&s.uiCanvas.texture.image.width>0){let v=this.getPixelRatio();(s.uiCanvas.width!==this.viewportWidth||s.uiCanvas.height!==this.viewportHeight||s.uiCanvas.dpr!==v)&&s.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},v),s.uiCanvas.render(this),this.pipeline.uiCanvasTexture=s.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=s,this.pipeline.camera=t;let g=i2e(s.postprocessing);if(this.pipeline.postprocessingState!==g&&this.pipeline.updatePostprocessing(g),this.pipeline.render(),d?.endJitter(),this._skySystem?.endFrame?.(),Pi.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates){let v=(this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled,y=this.info.asyncCompilation?.promotions??0,_=y!==this._shadowSyncPromotions;this._shadowSyncPromotions=y,o.shadowsDirty=this._shadowMapMissingAtSync||this._warmupInFlight||v||_}t instanceof Yn&&t.copyHistory(),s.visible=a}_fitDirectionalShadowRange(e,t,i){if(i===0)return;let r=e.shadow.camera,n=e.shadow;n.__speRangeEnvelope||(n.__speRangeEnvelope={near:r.near,far:r.far});let s=n.__speRangeEnvelope.near,a=e.data?.depth??n.__speRangeEnvelope.far;if(n.__speRangeEnvelope.far=a,U_.setFromMatrixPosition(e.matrixWorld),e.target?(e.target.updateMatrixWorld(),XD.setFromMatrixPosition(e.target.matrixWorld)):XD.set(0,0,0),vv.subVectors(XD,U_),vv.lengthSq()<1e-10)return;vv.normalize();let o=1/0,l=-1/0;for(let c=0;c<i;c++){let p=4*c,f=(t[p]-U_.x)*vv.x+(t[p+1]-U_.y)*vv.y+(t[p+2]-U_.z)*vv.z,m=t[p+3];f-m<o&&(o=f-m),f+m>l&&(l=f+m)}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,s),d=Math.min(d,a),d-h>=1&&(r.near!==h||r.far!==d)&&(r.near=h,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(e){let t=0;return e.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(oc):oc.setFromMatrixPosition(r.matrixWorld);let u=4*t;lc[u]=oc.x,lc[u+1]=oc.y,lc[u+2]=oc.z,lc[u+3]=l,t++}return}if(r.isMesh!==!0||!r.geometry||r.isInstanceGroup===!0)return;let n=r.geometry.boundingSphere;n===null&&(r.geometry.computeBoundingSphere(),n=r.geometry.boundingSphere);let s=r;if(s.isInstancedMesh===!0&&(s.boundingSphere===null&&s.computeBoundingSphere(),n=s.boundingSphere??n),!n||!Number.isFinite(n.radius)||n.radius<=0)return;oc.copy(n.center).applyMatrix4(r.matrixWorld),O2.setFromMatrixScale(r.matrixWorld);let a=n.radius*Math.max(Math.abs(O2.x),Math.abs(O2.y),Math.abs(O2.z)),o=4*t;lc[o]=oc.x,lc[o+1]=oc.y,lc[o+2]=oc.z,lc[o+3]=a,t++}),t}_syncLightState(e){let t=fy.isSoft(e.data.shadow);Zfe(t),Pi.shadowTypeSoft=t,function(d){switch(d){case"low":sf=8;break;case"high":sf=32;break;default:sf=16}}(e.data.shadow?.softShadowQuality),t&&Wq()&&(uO||(this.initTexture?.(Fq()),uO=!0));let i=-1;Pi.pcssLights=0,Pi.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,Pi.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,n=it.toonLightData.array,s=0,a=this.manageShadowUpdates,o=e.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1;let l=-2128831035,u=d=>{l^=0|d,l=Math.imul(l,16777619)};e.traverseVisible(d=>{let c=d;if(function(p){if(!p.isPointLight&&!p.isSpotLight&&!p.isDirectionalLight)return!1;if(OA.enabled){if(p.castShadow===!0)return p.castShadow=!1,mO.add(p),!0}else if(mO.has(p)&&(mO.delete(p),p.castShadow===!1))return p.castShadow=!0,!0;return!1}(c)&&(e.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)),u9&&(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!==d4&&Pi.pcssForeignFilter++:(p.filterNode=d4,Pi.pcssInstalled++)}(c.shadow),Kfe(c.shadow),Pi.pcssLights++),(c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&c.shadow){c.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(e)),this._fitDirectionalShadowRange(c,lc,i)),function(m){m.filterNode!==void 0&&m.filterNode!==null?m.filterNode!==u4&&Pi.pcssForeignFilter++:(Object.defineProperty(m,"penumbraSize",{get:()=>c.data?.penumbraSize??.5,configurable:!0}),m.filterNode=u4,Pi.pcssInstalled++)}(c.shadow);let p,f=!a||o||c.shadow.needsUpdate===!0;if(t&&Wq()&&(f?function(m){let g=m;g.__spePcssPyramid&&(g.__spePcssPyramid.fresh=!1)}(c.shadow):Yfe(c.shadow)||function(m,g){let v=g,y=v.map?.depthTexture??null;if(y==null)return!1;let _=Xfe(g);if(function(T){let M=Xfe(T);if(M.slot>=0)return M.slot;for(let E=0;E<o4;E++){let A=hO[E];if(A===null||A.deref()===void 0)return hO[E]=new WeakRef(T),M.slot=E,E}return-1}(g)<0)return!1;let b=Math.max(1,Math.round(v.mapSize?.x??2048)),x=_.slot*Af,w=`${y.uuid}:${b}`;_.passKey!==w&&(_.toMid?.material?.dispose(),_.toSmall?.material?.dispose(),_.mid===null&&(_.mid=Bq(Gb,Gb),_.mid.texture.name="SplinePCSSPyramidMid"),_.small===null&&(_.small=Bq(Af,Af),_.small.texture.name="SplinePCSSPyramidSmall"),_.toMid=new Cn($fe(`SplinePCSSPyramidToMid${b}`,y,Math.ceil(b/Gb),b-1,!1,0)),_.toSmall=new Cn($fe("SplinePCSSPyramidToSmall",_.mid.texture,Gb/Af,Gb-1,!0,0)),_.passKey=w),Fq();let S=m.getRenderTarget();m.setRenderTarget(_.mid),_.toMid.render(m),m.setRenderTarget(_.small),_.toSmall.render(m),m.setRenderTarget(S),Vq.set(x,0,0),m.copyTextureToTexture(_.small.texture,xy.texture,null,Vq),_.fresh=!0,Pi.pcssPyramidBuilds++}(this,c.shadow),p={slot:WBe(c.shadow),fresh:Yfe(c.shadow)}),t&&Hq()&&(NTe(c.shadow,-1),this._maskLights.push({light:c,shadow:c.shadow}),(f||c.shadow.map==null)&&(this._maskBlocked=!0)),Kfe(c.shadow,c.data?.penumbraSize??.5,p)&&Pi.pcssPyramidActive++,!r){r=!0;let m=c.shadow;Pi.pcssRadius0=m.radius??-1,Pi.pcssPenumbra0=m.penumbraSize??-1}Pi.pcssLights++}if(!(s>=xq)){if(c.isPointLight||c.isSpotLight)B_.setFromMatrixPosition(c.matrixWorld),n[s].set(B_.x,B_.y,B_.z,0),s++;else if(c.isDirectionalLight&&c.target){c.target.updateMatrixWorld();let p=B_;p.setFromMatrixPosition(c.matrixWorld),p.sub(ume.setFromMatrixPosition(c.target.matrixWorld)).normalize(),n[s].set(p.x,p.y,p.z,1),s++}}}),it.toonLightCount.value=s;let h=this._lightShadowSignatures.get(e);this._lightShadowSignatures.set(e,l),this._lightShadowStateDirty=h!==void 0&&h!==l}_shadowMapId(e){if(e==null)return 0;let t=this._shadowMapIds.get(e);return t===void 0&&(t=++this._shadowMapIdSeq,this._shadowMapIds.set(e,t)),t}_renderShadowMaskPass(e,t){let i=0;if(Hq()&&!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 kTe);let{targetsChanged:r}=this._shadowMask.render(this,e,t,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}it.shadowMaskEnabled.value=i>0?1:0,Pi.shadowMaskActive=i}retireRenderTarget(e){e&&this._retiredGrabTargets.push(e),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let e of this._retiredGrabTargets)e.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let e of this._retiredGpuBuffers)try{e.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let e of this._liveBundledPages())this._bundleStates.get(e)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let e=this.backend,t=this._retiredGpuBuffers;e.destroyUniformBuffer=r=>{let n=e.get(r);n?.buffer&&t.push(n.buffer),e.delete(r),this._retireBundleRecords()};let i=e.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=n=>{let s=e.get(r(n));s?.buffer&&t.push(s.buffer),e.delete(n),this._retireBundleRecords()}}}_reallocGrabTarget(e,t,i,r){return e&&e.width===t&&e.height===i?e:(this.retireRenderTarget(e),r())}_withShadowUpdatesSuspended(e,t){let i=[];e.traverse(r=>{let n=r;if(n.isLight&&n.shadow){if(n.shadow.map==null)return;i.push({shadow:n.shadow,auto:n.shadow.autoUpdate,needs:n.shadow.needsUpdate}),n.shadow.autoUpdate=!1,n.shadow.needsUpdate=!1}});try{t()}finally{for(let r of i)r.shadow.autoUpdate=r.auto,r.shadow.needsUpdate=r.needs}}_renderPrepass(e,t){this._withShadowUpdatesSuspended(e,()=>{this.render(e,t)})}_renderAOPass(e,t,i){let r=this.getDrawingBufferSize(gv),n=Math.max(1,Math.round(r.x)),s=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,n,s,()=>new Ui(n,s,{depthBuffer:!1})),it.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new STe);let a=e;this._hbao.render(this,e,t,{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:Xn.getModeIndex({mode:e.fogMode}),fogDensity:e.fogDensity??Xn.getDensity({}),fogHeightFalloff:e.fogHeightFalloff??Xn.getHeightFalloff({}),fogHeightBase:e.fogHeightBase??Xn.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(e,t,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",n=this.getDrawingBufferSize(gv),s=Math.max(1,Math.round(n.x)),a=Math.max(1,Math.round(n.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,s,a,()=>{let p=new Ui(s,a,{count:r==="both"?2:1,type:r==="normals"?di:Wt,depthTexture:new is(s,a)});r==="both"&&(p.textures[0].name="g0",p.textures[1].name="g1",p.textures[1].type=di);for(let f of p.textures)f.minFilter=yt,f.magFilter=yt;return p});let o=this._encodeMaterials[r];if(o===void 0){this._depthContrastUniform??(this._depthContrastUniform=Fe(1));let p=new ei;p.name=`SplineNormalPassEncode_${r}`;let f=$g("randomColor","vec3"),m=()=>{let v=Ut(RA),y=MB.sub(.5).mul(this._depthContrastUniform).add(.5),_=ut(ut(f,v,.2),J(y),.4);return Pe(_,f.x)},g=()=>{let v=Ut(Ao),y=Ki(RSe,v,v.negate());return Pe(y,f.x)};p.fragmentNode=r==="both"?aw({g0:m(),g1:g()}):r==="normals"?g():m(),p.lights=!1,p.blending=Di,p.needsUpdate=!0,this._encodeMaterials[r]=p,o=p}this._depthContrastUniform.value=t instanceof Yn?(t.far-t.near)/1e4:1;let l=e.overrideMaterial,u=this.getRenderTarget(),h=this.getClearColor(dme),d=this.getClearAlpha();t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),e.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(e,t),this.setRenderTarget(u),this.setClearColor(h,d),e.overrideMaterial=l,t.layers.enable(0),t.layers.enable(3);let c=this._normalTarget.textures;it.normalRenderTarget.value=r==="normals"?Hl:c[0],it.normalRenderTargetDepth.value=this._normalTarget.depthTexture,it.normalViewRenderTarget.value=r==="both"?c[1]:r==="normals"?c[0]:Hl}blitTextureToTarget(e,t){let i=this._uiBlitPass;if(!i){let s=vt(Hl),a=new ei;a.name="SplineUICanvasBlit",a.fragmentNode=s.sample(tr()),a.lights=!1,a.blending=Di,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,i={quad:new Cn(a),input:s},this._uiBlitPass=i}let r=this.getRenderTarget(),n=this.getMRT();i.input.value=e,this.setMRT(null),this.setRenderTarget(t),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(n)}_getPrefilterPass(e){this._prefilterPasses||(this._prefilterPasses=[]);let t=this._prefilterPasses[e];if(t)return t;let i=vt(Hl),r=Fe(new Z(1,0)),n=new ei;n.name="SplineTransmissionPrefilter";let s=tr(),a=r,o=u=>i.sample(s.add(a.mul(u))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return n.fragmentNode=Pe(l,1),n.lights=!1,n.blending=Di,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,t={quad:new Cn(n),input:i,step:r},this._prefilterPasses[e]=t,t}_getDownsamplePass(e){this._downsamplePasses||(this._downsamplePasses=[]);let t=this._downsamplePasses[e];return t||(t=this._buildDownsamplePassEntry(c9,"SplineTransmissionDownsample"),this._downsamplePasses[e]=t,t)}_buildDownsamplePassEntry(e,t){let i=vt(Hl),r=Fe(new Z(1,1)),n=new ei;n.name=t;let s=tr(),a=r,o=(u,h)=>i.sample(s.add(Me(u,h).mul(a))).rgb,l=null;if(e==="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],f=o(u[c],u[d]).mul(p);l=l?l.add(f):f}}return n.fragmentNode=Pe(l,1),n.lights=!1,n.blending=Di,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,{quad:new Cn(n),input:i,step:r}}_getPlanarDownsamplePass(e){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let t=this._planarDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[e]=t,t)}_batchedMipCopies(e){let t=this.backend,i=t?.device;if(!i||typeof t?.get!="function"){for(let s of e)this.copyTextureToTexture(s.src,s.dst,null,null,0,s.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),n=0;for(let s of e){let a=t.get(s.src)?.texture,o=t.get(s.dst)?.texture;a&&o?(r.copyTextureToTexture({texture:a,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:o,mipLevel:s.dstLevel,origin:{x:0,y:0,z:0}},{width:s.width,height:s.height,depthOrArrayLayers:1}),n++):this.copyTextureToTexture(s.src,s.dst,null,null,0,s.dstLevel)}n>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(e){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let t=this._reflectionDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[e]=t,t)}_renderTransmissionPass(e,t){let i=this.getDrawingBufferSize(gv),r=this.hdTransmission?1:2,n=Math.max(1,Math.round(i.x/r)),s=Math.max(1,Math.round(i.y/r)),a=this.backend?.isWebGPUBackend===!0?YD:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,n,s,()=>{let h=new Ui(n,s,{depthBuffer:!0}),d=h.texture;return a==="off"?(d.generateMipmaps=!0,d.minFilter=Rn):(d.generateMipmaps=!1,d.minFilter=rt),d.magFilter=rt,h});let o=[];e.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();t.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(e,t),this.setRenderTarget(l),t.layers.enable(3);for(let h of o)h.layers.mask=h.mask;let u=this._transmissionTarget.texture;if(a!=="off"){let h=(m,g)=>{let v=new Ui(m,g,{depthBuffer:!1});return v.texture.generateMipmaps=!1,v.texture.minFilter=rt,v.texture.magFilter=rt,v};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,n,s,()=>h(n,s));let d=Math.floor(Math.log2(Math.max(n,s)))+1,c=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,n,s,()=>{let m=new Ui(n,s,{depthBuffer:!1}),g=m.texture;return g.minFilter=Rn,g.magFilter=rt,a==="base"?g.generateMipmaps=!0:(g.generateMipmaps=!1,g.mipmaps=Array.from({length:d},(v,y)=>({width:Math.max(1,n>>y),height:Math.max(1,s>>y)}))),m}),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/n,0),this.setRenderTarget(this._transmissionBlurTmp),p.quad.render(this);let f=this._getPrefilterPass(1);if(f.input.value=this._transmissionBlurTmp.texture,f.step.value.set(0,1/s),a==="base")this.setRenderTarget(this._transmissionBlurTarget),f.quad.render(this);else{for(let m=0;m<d;m++)this._transmissionChain[m]=this._reallocGrabTarget(this._transmissionChain[m],Math.max(1,n>>m),Math.max(1,s>>m),()=>h(Math.max(1,n>>m),Math.max(1,s>>m)));for(let m=d;m<this._transmissionChain.length;m++)this._transmissionChain[m]?.dispose(),this._transmissionChain[m]=void 0;this._transmissionChain.length=d,this.setRenderTarget(this._transmissionChain[0]),f.quad.render(this);for(let m=1;m<d;m++){let g=this._transmissionChain[m-1],v=this._getDownsamplePass(m-1);v.input.value=g.texture,v.step.value.set(1/g.width,1/g.height),this.setRenderTarget(this._transmissionChain[m]),v.quad.render(this)}for(let m=0;m<d;m++)this.copyTextureToTexture(this._transmissionChain[m].texture,this._transmissionBlurTarget.texture,null,null,0,m)}this.setRenderTarget(l),u=this._transmissionBlurTarget.texture}it.transmissionRenderTarget.value=u,it.transmissionActualSize.value.set(n,s),it.aspectRatio.value=i.x>=i.y?it.aspectRatio.value.set(i.y/i.x,1):it.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(e,t,i){if(this._reflectionDepthPasses)for(let n of this._reflectionDepthPasses)n?.quad.material?.dispose();let r=[];{let n=new ei;n.name="SplineReflectionDepthBlit";let s=vt(this._reflectionTarget.depthTexture);n.fragmentNode=Pe(J(s.sample(tr())),1),n.lights=!1,n.blending=Di,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,r.push({quad:new Cn(n)})}for(let n=1;n<i;n++){let s=Math.max(1,e>>n-1),a=Math.max(1,t>>n-1),o=new ei;o.name=`SplineReflectionDepthMin${n}`;let l=vt(this._reflectionDepthChain[n-1].texture),u=Qo,h=De(u.x).mul(2),d=De(u.y).mul(2),c=(v,y)=>l.load(Wa(h.add(v),d.add(y))).x,p=(v,y)=>Fi(v,y),f=p(p(c(0,0),c(1,0)),p(c(1,1),c(0,1))),m=!!(1&s),g=!!(1&a);m&&(f=p(f,p(c(2,0),c(2,1)))),g&&(f=p(f,p(c(0,2),c(1,2)))),m&&g&&(f=p(f,c(2,2))),o.fragmentNode=Pe(J(f),1),o.lights=!1,o.blending=Di,o.depthTest=!1,o.depthWrite=!1,o.needsUpdate=!0,r.push({quad:new Cn(o)})}this._reflectionDepthPasses=r}_renderReflectionPass(e,t){let i=this.getDrawingBufferSize(gv),r=1/0,n=0,s=0;e.traverse(x=>{let w=x;if(!(w.isMesh&&16&w.layers.mask))return;let S=this._reflectiveMeshCoverage(w,t,i.y),T=Array.isArray(w.material)?w.material:[w.material];for(let M of T){if(!M?.layers)continue;let E=p4e(M);!E||(r=Math.min(r,E.min*S.scale),n=Math.max(n,E.max*S.scale),E.max*S.scale>.45&&(s=Math.max(s,S.diameterPx)))}});let a=1;if(v9&&r!==1/0)for(r>=6?a=4:r>=2&&(a=2);a>1&&s>0&&s/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&&g9;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let x=new Ui(o,l,{depthTexture:new is(o,l)});return h?(x.texture.generateMipmaps=!1,x.texture.minFilter=rt):(x.texture.generateMipmaps=!0,x.texture.minFilter=Rn),x.texture.magFilter=rt,x});let d=(x,w)=>{let S=new Ui(x,w,{depthBuffer:!1,type:Wt,format:aa});return S.texture.generateMipmaps=!1,S.texture.minFilter=yt,S.texture.magFilter=yt,S},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let x=d(o,l);return x.texture.mipmaps=Array.from({length:u},(w,S)=>({width:Math.max(1,o>>S),height:Math.max(1,l>>S)})),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,f=it.reflectionEnvMap,m=p??Nc;!this.auxiliary&&f.value!==m&&(f.value=m,this._grabTargetEpoch++),it.reflectionEnvEnabled.value=p!==null?1:0;let g=this.getClearColor(cme);it.reflectionMissColor.value.set(g.r,g.g,g.b);let v=[];e.traverse(x=>{let w=x;if(!(w.isMesh||w.isLine||w.isPoints||w.isSprite))return;let S=w.layers;S&&16&S.mask&&S.mask!==16&&(v.push({layers:S,mask:S.mask}),S.mask=16)});let y=this.getRenderTarget();t.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(e,t),t.layers.enable(4);for(let x of v)x.layers.mask=x.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,u),this._reflectionPassesKey=`${o}x${l}`);let _=this._reflectionDepthPasses;for(let x=0;x<u;x++)this.setRenderTarget(this._reflectionDepthChain[x]),_[x].quad.render(this);this._batchedMipCopies(Array.from({length:u},(x,w)=>({src:this._reflectionDepthChain[w].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:w,width:Math.max(1,o>>w),height:Math.max(1,l>>w)})));let b=this._reflectionTarget.texture;if(h){let x=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let T=new Ui(o,l,{depthBuffer:!1}),M=T.texture;return M.minFilter=Rn,M.magFilter=rt,M.generateMipmaps=!1,M.mipmaps=Array.from({length:u},(E,A)=>({width:Math.max(1,o>>A),height:Math.max(1,l>>A)})),T}),this._reflectionColorPyramid!==x&&this.initTexture(this._reflectionColorPyramid.texture);let w=n>0?u:1,S=(T,M)=>{let E=new Ui(T,M,{depthBuffer:!1});return E.texture.generateMipmaps=!1,E.texture.minFilter=rt,E.texture.magFilter=rt,E};for(let T=1;T<w;T++)this._reflectionColorChain[T]=this._reallocGrabTarget(this._reflectionColorChain[T],Math.max(1,o>>T),Math.max(1,l>>T),()=>S(Math.max(1,o>>T),Math.max(1,l>>T)));for(let T=w;T<this._reflectionColorChain.length;T++)this._reflectionColorChain[T]?.dispose(),this._reflectionColorChain[T]=void 0;this._reflectionColorChain.length=w;for(let T=1;T<w;T++){let M=T===1?this._reflectionTarget:this._reflectionColorChain[T-1],E=this._getReflectionDownsamplePass(T-1);E.input.value=M.texture,E.step.value.set(1/M.width,1/M.height),this.setRenderTarget(this._reflectionColorChain[T]),E.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:w-1},(T,M)=>({src:this._reflectionColorChain[M+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:M+1,width:Math.max(1,o>>M+1),height:Math.max(1,l>>M+1)}))]),b=this._reflectionColorPyramid.texture}this.setRenderTarget(y),it.reflectionRenderTarget.value=b,it.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,it.reflectionDepthSize.value.set(o,l),it.reflectionDepthLevels.value=u,this._reflectionGrabInfo={div:a,w:o,h:l,minBlur:r,maxBlur:n}}_reflectiveMeshCoverage(e,t,i){let r=e.geometry;if(!r)return{diameterPx:i,scale:1};r.boundingSphere===null&&r.computeBoundingSphere();let n=r.boundingSphere;if(!n)return{diameterPx:i,scale:1};let s=e.matrixWorld.elements,a=Math.sqrt(Math.max(s[0]*s[0]+s[1]*s[1]+s[2]*s[2],s[4]*s[4]+s[5]*s[5]+s[6]*s[6],s[8]*s[8]+s[9]*s[9]+s[10]*s[10])),o=n.radius*a;a9.copy(n.center).applyMatrix4(e.matrixWorld);let l=t.projectionMatrix.elements[5]*i/2,u=1;t.isPerspectiveCamera===!0&&(o9.setFromMatrixPosition(t.matrixWorld),u=Math.max(a9.distanceTo(o9),t.near??.1));let h=2*o*l/u;return{diameterPx:h,scale:Math.min(1,h/(.66*i))}}_renderReflectionResolvePass(e,t){let i=this._reflectionGrabInfo,r=this.backend?.isWebGPUBackend===!0&&y9&&i!==void 0&&i.maxBlur>.45;if(r){let b=!0;e.traverse(x=>{let w=x;if(!(w.isMesh&&16&w.layers.mask))return;let S=Array.isArray(w.material)?w.material:[w.material],T=null;for(let M of S)if(M?.layers&&(T=f4e(M),T!==null))break;T!=="variable"?T!==null?(w.userData.__srMode=T.blur>.45?1+T.tracingMode:0,w.userData.__srBlur=T.blur*this._reflectiveMeshCoverage(w,t,this.getDrawingBufferSize(fme).y).scale,w.userData.__srThickness=T.thickness,w.userData.__srStepSize=T.stepSize,w.userData.__srSteps=T.steps):w.userData.__srMode=0:b=!1}),r=b}let n=r?i.w:4,s=r?i.h:4,a=(b,x)=>()=>{let w=new Ui(b,x,{type:di,depthBuffer:!1});return w.texture.generateMipmaps=!1,w.texture.minFilter=rt,w.texture.magFilter=rt,w};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,n,s,a(n,s)),it.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(it.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let b=new Ui(o,l,{count:2,type:di,depthTexture:new is(o,l)});for(let x of b.textures)x.generateMipmaps=!1,x.minFilter=yt,x.magFilter=yt;return b.textures[0].name="g0",b.textures[1].name="g1",b}),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 b=new ei;b.name="SplineReflectionGBuffer";let x=yg("__splinePlanarMirror","float"),w=it.reflectionPlanarEnabled.greaterThan(.5),S=yg("__srMode","float"),T=Ki(x.greaterThan(.5).and(w),B(0),S);b.fragmentNode=aw({g0:Pe(Ut(Ao),T),g1:Pe(yg("__srBlur","float"),yg("__srThickness","float"),yg("__srStepSize","float"),yg("__srSteps","float"))}),b.lights=!1,b.blending=Di,b.needsUpdate=!0,this._reflectionGBufferMaterial=b}let u=this._skippedAsyncDraws??0,h=e.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(pme),p=this.getClearAlpha(),f=t.layers.mask;e.overrideMaterial=this._reflectionGBufferMaterial,t.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(e,t),e.overrideMaterial=h,t.layers.mask=f,this.setClearColor(c,p);let m=it.reflectionRenderTarget.value,g=it.reflectionEnvMap.value,v=this._reflectionGBufferTarget,y=`${o}x${l}|${v.textures[0].uuid}|${m.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${g.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;y!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(m,g,o,l),this._reflectionResolveMarchKey=y);let _=this._reflectionResolveMarch;_.proj.value.copy(t.projectionMatrix),_.projInv.value.copy(t.projectionMatrix).invert(),_.camWorld.value.copy(t.matrixWorld),_.near.value=t.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),_.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),it.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>u&&(it.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(e,t,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let n=Fe(new Ue),s=Fe(new Ue),a=Fe(new Ue),o=Fe(.1),l=this._reflectionGBufferTarget,u=vt(l.textures[0]),h=vt(l.textures[1]),d=vt(l.depthTexture),c=vt(e),p=vt(this._reflectionDepthPyramid.texture),f=vt(t),m=new ei;m.name="SplineReflectionResolve";let g=Xe(()=>{let b=Qo,x=Wa(De(b.x),De(b.y)),w=tr(),S=u.load(x).toVar(),T=d.sample(w).toVar(),M=Pe(0).toVar(),E=B(0).toVar();return Ve(S.w.greaterThan(.5),()=>{let A=h.load(x).toVar(),P=Uv(s,w.x,w.y,T),N=cK({dials:{blur:A.x,thickness:A.y,stepSize:A.z,steps:De(A.w),tracingMode:S.w.sub(1)},surface:{originView:P,normalV:Ut(S.xyz),screenUv:w,fragWindowZ:T},camera:{projectionMatrix:n,projectionMatrixInverse:s,worldMatrix:a,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:f},usePlanar:_Se(!1),noisePixel:Me(x),singleRay:{footprintOut:E}});M.assign(Pe(N,E.add(1)))}),M});m.fragmentNode=g(),m.lights=!1,m.blending=Di,m.depthTest=!1,m.depthWrite=!1,m.needsUpdate=!0,this._reflectionResolveMarch={quad:new Cn(m),proj:n,projInv:s,camWorld:a,near:o};let v=vt(this._reflectionResolveMarchTarget.texture),y=vt(this._reflectionResolveBlurTmp.texture),_=b=>{let x=new ei;x.name=`SplineReflectionResolveBlur${b.toUpperCase()}`;let w=b==="x"?v:y,S=b==="x"?1/i:1/r,T=Xe(()=>{let M=tr(),E=v.sample(M).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),A=Pe(0).toVar(),P=0;for(let N=-6;N<=6;N++){let D=Math.exp(N/3*-.5*(N/3));P+=D;let O=b==="x"?Me(E.mul(N/6*S),0):Me(0,E.mul(N/6*S)),z=w.sample(M.add(O)).toVar(),L=b==="x"?z.w.min(1):z.w;A.addAssign(Pe(z.rgb,L).mul(D))}return A.div(P)});return x.fragmentNode=T(),x.lights=!1,x.blending=Di,x.depthTest=!1,x.depthWrite=!1,x.needsUpdate=!0,new Cn(x)};this._reflectionResolveBlur={h:_("x"),v:_("y")}}_renderPlanarReflectionPass(e,t){let i=null;if(e.traverse(f=>{let m=f;if(!(m.isMesh&&16&m.layers.mask&&(m.userData.__splinePlanarMirror=0,(Array.isArray(m.material)?m.material:[m.material]).some(A=>A?.layers&&A.getLayersOfType("reflection").some(P=>P.data.visible&&P.data.mirror===1)))))return;let g=m.geometry;if(!g)return;g.boundingBox===null&&g.computeBoundingBox();let v,y,_=g.boundingBox,b=_.max.x-_.min.x,x=_.max.y-_.min.y,w=_.max.z-_.min.z,S=m.matrixWorld.elements,T=Math.hypot(S[0],S[1],S[2]),M=Math.hypot(S[4],S[5],S[6]),E=Math.hypot(S[8],S[9],S[10]);b<=x&&b<=w?(v=mme,y=x*M*(w*E)):x<=b&&x<=w?(v=gme,y=b*T*(w*E)):(v=vme,y=b*T*(x*M)),(!i||y>i.area)&&(i={mesh:m,normalAxis:v,area:y})}),!i)return void(it.reflectionPlanarEnabled.value=0);let r=i.mesh,n=i.mesh.matrixWorld;if(Ip.copy(i.normalAxis).transformDirection(n),jm.setFromMatrixPosition(n),N2.setFromMatrixPosition(t.matrixWorld),Wm.subVectors(jm,N2),Wm.dot(Ip)>0&&Ip.negate(),Wm.dot(Ip)>0)return void(it.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==t.type)&&(this._planarVirtualCamera=t.clone());let s=this._planarVirtualCamera;if(Wm.subVectors(jm,N2),Wm.reflect(Ip).negate(),Wm.add(jm),$D.extractRotation(t.matrixWorld),l9.set(0,0,-1).applyMatrix4($D).add(N2),I2.subVectors(jm,l9),I2.reflect(Ip).negate(),I2.add(jm),s.position.copy(Wm),s.up.set(0,1,0).applyMatrix4($D),s.up.reflect(Ip),s.lookAt(I2),s.updateMatrixWorld(),s.projectionMatrix.copy(t.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),t.isPerspectiveCamera===!0){mv.setFromNormalAndCoplanarPoint(Ip,jm),mv.applyMatrix4(s.matrixWorldInverse),ac.set(mv.normal.x,mv.normal.y,mv.normal.z,mv.constant);let f=s.projectionMatrix.elements;F_.x=(Math.sign(ac.x)+f[8])/f[0],F_.y=(Math.sign(ac.y)+f[9])/f[5],F_.z=-1,F_.w=(1+f[10])/f[14],ac.multiplyScalar(1/ac.dot(F_)),f[2]=ac.x,f[6]=ac.y,f[10]=ac.z,f[14]=ac.w}let a=this.getDrawingBufferSize(yme),o=Math.max(1,Math.round(a.x)),l=Math.max(1,Math.round(a.y)),u=this.backend?.isWebGPUBackend===!0&&m9;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let f=new Ui(o,l);return u?(f.texture.generateMipmaps=!1,f.texture.minFilter=rt):(f.texture.generateMipmaps=!0,f.texture.minFilter=Rn),f.texture.magFilter=rt,f});let h=[];e.traverse(f=>{let m=f;if(!(m.isMesh||m.isLine||m.isPoints||m.isSprite))return;let g=m.layers;g&&16&g.mask&&g.mask!==16&&(h.push({layers:g,mask:g.mask}),g.mask=16)}),s.layers.mask=-17&t.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(e,s),this.setRenderTarget(d);for(let f of h)f.layers.mask=f.mask;let c=this._planarTarget.texture;if(u){let f=Math.floor(Math.log2(Math.max(o,l)))+1,m=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let v=new Ui(o,l,{depthBuffer:!1}),y=v.texture;return y.minFilter=Rn,y.magFilter=rt,y.generateMipmaps=!1,y.mipmaps=Array.from({length:f},(_,b)=>({width:Math.max(1,o>>b),height:Math.max(1,l>>b)})),v}),this._planarPyramid!==m&&this.initTexture(this._planarPyramid.texture);let g=(v,y)=>{let _=new Ui(v,y,{depthBuffer:!1});return _.texture.generateMipmaps=!1,_.texture.minFilter=rt,_.texture.magFilter=rt,_};for(let v=1;v<f;v++)this._planarChain[v]=this._reallocGrabTarget(this._planarChain[v],Math.max(1,o>>v),Math.max(1,l>>v),()=>g(Math.max(1,o>>v),Math.max(1,l>>v)));for(let v=f;v<this._planarChain.length;v++)this._planarChain[v]?.dispose(),this._planarChain[v]=void 0;this._planarChain.length=f;for(let v=1;v<f;v++){let y=v===1?this._planarTarget:this._planarChain[v-1],_=this._getPlanarDownsamplePass(v-1);_.input.value=y.texture,_.step.value.set(1/y.width,1/y.height),this.setRenderTarget(this._planarChain[v]),_.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:f-1},(v,y)=>({src:this._planarChain[y+1].texture,dst:this._planarPyramid.texture,dstLevel:y+1,width:Math.max(1,o>>y+1),height:Math.max(1,l>>y+1)}))]),c=this._planarPyramid.texture}let p=it.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),it.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(e,t,i){let r=this.getDrawingBufferSize(gv),n=Math.max(1,Math.round(r.x)),s=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,n,s,()=>new Ui(n,s,{depthBuffer:!0}));let a=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget);try{this.renderSplineScene(e,t)}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(e,{includeHelpers:t=!1,settleFrames:i=0}={}){if(this.xr?.isPresenting===!0)return null;let r=this._frameSerial,n=this.getRenderTarget(),s=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled,o=this.suppressShadowMask;this.suppressShadowMask=!0,t||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{for(let g=0;g<i;g++)e(),await rFe();e()}finally{this.suppressShadowMask=o,this.pipeline.renderToScreen=s,this.setRenderTarget(n),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,f=256*Math.ceil(p/256),m=Math.max(1,Math.min(h,Math.floor((1<<20)/f)));for(let g=0;g<h;g+=m){let v=Math.min(m,h-g),y=await d.readRenderTargetPixelsAsync(l,0,g,u,v);if(f===p)c.set(y.subarray(0,v*p),g*p);else for(let _=0;_<v;_++){let b=_*f;c.set(y.subarray(b,b+p),(g+_)*p)}}return{pixels:c,width:u,height:h}}_applyCIOffscreenTargetIfRequested(){if(globalThis.__SPLINE_RENDER_OFFSCREEN__!==!0)return;let e=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),t=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==e||this._ciOffscreenTarget.height!==t)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new Ui(e,t,{depthBuffer:!0})):(this._ciOffscreenTarget=new Ui(e,t,{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(),NH()?.drainRetired(),OH()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let e of Ox){let t=e.deref();t!==void 0&&(t.mid?.dispose(),t.mid=null,t.small?.dispose(),t.small=null,t.toMid?.material?.dispose(),t.toSmall?.material?.dispose(),t.toMid=null,t.toSmall=null,t.passKey="",t.fresh=!1,t.slot=-1)}Ox.clear(),hO.fill(null),xy?.dispose(),xy=null,uO=!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 e of this._transmissionChain)e?.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 e of this._reflectionColorChain)e?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let e of this._reflectionDownsamplePasses)e?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let e of this._planarChain)e?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let e of this._planarDownsamplePasses)e?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let e of this._reflectionDepthChain)e?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let e of this._reflectionDepthPasses)e?.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 e of this._prefilterPasses)e?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let e of this._downsamplePasses)e?.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 e of dO)e.deref()?.dispose();dO.clear(),cO++}(),function(){for(let e of JM){let t=e.deref();t!==void 0&&(t.sprite.removeFromParent(),t.material.dispose())}JM.clear(),Wb++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let e of Object.values(this._encodeMaterials))e?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),it.transmissionRenderTarget.value=Hl,it.normalRenderTarget.value=Hl,it.aoRenderTarget.value=Hl,it.reflectionRenderTarget.value=Nc,it.reflectionDepthPyramid.value=Nc,it.reflectionEnvMap.value=Nc,it.reflectionPlanarTarget.value=Nc,it.reflectionPlanarEnabled.value=0,it.reflectionResolveTarget.value=wq,it.reflectionResolveEnabled.value=0}})._GAUGE_STALL_MS=3e3});function il(e,t){switch(e.type){case"cavity":return function(i,r){return{...ll(i,r),ridge:i.ridge,valley:i.valley}}(e,t);case"dust":return function(i,r){return{...ll(i,r),color:vo(i.color,r),coverage:Lt(i.coverage,r)??.2,softness:Lt(i.softness,r)??.2,noiseStrength:Lt(i.noiseStrength,r)??.2,noiseScale:Lt(i.noiseScale,r)??1}}(e,t);case"fresnel":return function(i,r){let{bias:n,scale:s,intensity:a,factor:o,color:l}=i;return{...ll(i,r),color:vo(l,r),bias:n,scale:s,intensity:a,factor:o}}(e,t);case"gradient":return function(i,r){let{gradientType:n,smooth:s,colors:a,steps:o,angle:l,offset:u,morph:h}=i;return{...ll(i,r),gradientType:n,smooth:s,colors:a.map(d=>new ct(d[0],d[1],d[2],d[3])),num:a.length,steps:o,offset:new Z(...u.map(d=>typeof d=="number"?d:0)),morph:new Z(...h.map(d=>typeof d=="number"?d:0)),angle:l}}(e,t);case"depth":return function(i,r){let{gradientType:n,near:s,far:a,isVector:o,isWorldSpace:l,origin:u,direction:h,colors:d,steps:c,smooth:p}=i;return{...ll(i,r),gradientType:n,near:s,far:a,isVector:o,isWorldSpace:l,origin:new R(...u),direction:h?new R(...h):new R(1,0,0),colors:d.map(f=>f!==void 0?new ct(f[0],f[1],f[2],f[3]):new ct(0,0,0,0)),steps:c.slice(0,d.length),smooth:p}}(e,t);case"normal":return function(i,r){let{cnormal:n}=i;return{...ll(i,r),cnormal:new R(n[0],n[1],n[2])}}(e,t);case"noise":return function(i,r){return{...ll(i,r),scale:i.scale,move:i.move,fA:new Z(...i.fA.map(n=>typeof n=="number"?n:0)),fB:new Z(...i.fB.map(n=>typeof n=="number"?n:0)),size:new R(...i.size),distortion:new Z(...i.distortion.map(n=>typeof n=="number"?n:0)),colorA:vo(i.colorA,r),colorB:vo(i.colorB,r),colorC:vo(i.colorC,r),colorD:vo(i.colorD,r),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}(e,t);case"rainbow":return function(i,r){return{...ll(i,r),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new R(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new R(...i.offset)}}(e,t);case"toon":return function(i,r){return{...ll(i,r),positioning:i.positioning,colors:i.colors.map(n=>new ct(n[0],n[1],n[2],n[3])),num:i.colors.length,steps:i.steps,source:new R(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:vo(i.shadowColor,r),offset:new R(...i.offset)}}(e,t);case"outline":return function(i,r){return{...ll(i,r),outlineColor:vo(i.outlineColor,r),contourColor:vo(i.contourColor,r),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new R(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}(e,t);case"transmission":return function(i,r){return{...ll(i,r),thickness:i.thickness,ior:i.ior,roughness:i.roughness,attenuationColor:i.attenuationColor!==void 0?vo(i.attenuationColor,r):{r:1,g:1,b:1,a:1},attenuationDistance:i.attenuationDistance??0}}(e,t);case"reflection":return function(i,r){return{...ll(i,r),blur:Lt(i.blur,r)??0,thickness:Lt(i.thickness,r)??.001,steps:Lt(i.steps,r)??60,stepSize:Lt(i.stepSize,r)??.005,tracingMode:i.tracingMode,mirror:i.mirror??0}}(e,t);case"pattern":return function(i,r){return{...ll(i,r),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Z(...i.offset.map(n=>typeof n=="number"?n:0)),colorA:vo(i.colorA,r),colorB:vo(i.colorB,r),frequency:new Z(...i.frequency.map(n=>typeof n=="number"?n:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Z(...i.vertical.map(n=>typeof n=="number"?n:0)),horizontal:new Z(...i.horizontal.map(n=>typeof n=="number"?n:0)),sides:i.sides}}(e,t);case"vertexColor":return ll(e,t);default:return function(i,r){return{...ll(i,r),color:vo(i.color,r)}}(e,t)}}function nFe(e){return{type:e.type}}function ll(e,t){let{alpha:i,mode:r,isMask:n}=e,s=typeof i=="string"?Number(t.getVariable(i)??100)/100:i;return{...nFe(e),alpha:s,mode:r,isMask:n}}var rl=U(()=>{oe(),CY(),Ed()});function z_(e){let t=e;return t!=null&&t.isInstancedMesh===!0&&t.instanceMatrix!=null&&t.instanceMatrix.isInstancedBufferAttribute===!0}function QD(e){return pd(pd(PB).mul(function(t){let i=t.spInstanceMatrixNode;if(i!==void 0)return pd(i);let r=t.object,n=r.instanceMatrix,s=Math.max(r.count??1,1);if(n.isStorageInstancedBufferAttribute===!0)return pd(f4(lTe(n,"mat4",s),Sa));if(16*s*4<=t.getUniformBufferLimit())return pd(f4(bSe(n.array,"mat4",s),Sa));let a=Jq.get(n);a===void 0&&(a=new MX(n.array,16,1),Jq.set(n,a));let o=n.usage===xd?DSe:gg;return pd(sK(o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)))}(e)))}var pd,f4,Jq,Ko,JA,s2e,a2e=U(()=>{oe(),bi(),pd=e=>e,f4=(e,t)=>e.element(t),Jq=new WeakMap,Ko=Xe(e=>z_(e.object)?RB:ow).once()().toVar("speObjectPosition"),JA=Xe(e=>e.material?.shapeBlendObjectNormal||(z_(e.object)?e.geometry.hasAttribute("normal")?qSe:J(0,1,0):aK)).once()().toVar("speObjectNormal"),pd(Xe(e=>pd(z_(e.object)?QD(e):PB)).once()()),s2e=Xe(e=>{if(!z_(e.object))return VSe;let t=QD(e),i=r=>f4(t,r).xyz;return J(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),Xe(e=>z_(e.object)?Vg(QD(e)).inverse().transpose():kSe).once()(),pd(Xe(e=>pd(z_(e.object)?QD(e).inverse():jSe)).once()())});function yK(e){if(LA.has(e))return;let t={own:e.value,render:e.value};LA.set(e,t),Object.defineProperty(e,"value",{configurable:!0,enumerable:!0,get:()=>t.render,set:i=>{t.render=i,t.own=i}})}function e$(e){let t=LA.get(e);return t!==void 0?t.own:e.value}function _K(e,t){let i=LA.get(e);i!==void 0?i.render=t:e.value=t}var LA,bK,o2e=U(()=>{LA=new WeakMap}),sFe=U(()=>{o2e(),bK=class{constructor(e){this.layerId=e,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(e,t,i){return this.byName.set(e,t),this.uniforms[`f${this.layerId}_${e}`]=t,i!==void 0&&this.liveValues.set(e,i),this}has(e){return this.byName.has(e)}names(){return[...this.byName.keys()]}get(e){let t=this.byName.get(e);if(t===void 0)throw new Error(`TSLLayerParams: unknown param "${e}" (layer f${this.layerId})`);return t}getFloat(e){return this.get(e)}getInt(e){return this.get(e)}getBool(e){return this.get(e)}getVec2(e){return this.get(e)}getVec3(e){return this.get(e)}getVec4(e){return this.get(e)}getColor(e){return this.get(e)}getValue(e){if(this.liveValues.has(e))return this.liveValues.get(e);let t=this.byName.get(e);return t===void 0?void 0:e$(t)}getLiveValue(e){return this.liveValues.get(e)}getNodeValue(e){let t=this.byName.get(e);return t===void 0?void 0:e$(t)}setValue(e,t){let i=this.byName.get(e);i===void 0||t===void 0||(this.liveValues.has(e)&&this.liveValues.set(e,t),i.value=t)}}});function $c(e,t,i){let r=B(e).toVar(),n=B(ut(r.div(Xt(r.add(t.accumAlpha),B(1e-5),B(1))),r,i)).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(r).mul(Pn(i))),n}function Ew(e,t){let i=B(e).toVar(),r=B(i.div(Xt(i.add(t.accumAlpha),B(1e-5),B(1)))).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(i)),r}function gO(e,t,i,r){return h2e({a:e,b:t,alpha:i,mode:r})}function Na(e,t){OB.set(e,t)}function l2e(e){let t=OB.get(e);return t!==void 0?t:(s$.has(e)||(s$.add(e),console.warn(`[spe] Material layer type "${e}" is not available in this runtime build (no WebGPU port, or compiled out) \u2014 rendering flat red.`)),xK)}function aFe(e){return OB.has(e)}var t$,i$,r$,n$,h2e,OB,s$,xK,da=U(()=>{bi(),a2e(),sFe(),o2e(),t$=0,i$=1,r$=2,n$=3,h2e=Xe(e=>{let t=e.a.toVar(),i=e.b.toVar(),r=e.alpha.toVar(),n=e.mode,s=J(1).toVar();return Ve(n.equal(De(t$)),()=>{s.assign(ut(t,i,r))}).ElseIf(n.equal(De(i$)),()=>{s.assign(ut(t,t.mul(i),r))}).ElseIf(n.equal(De(r$)),()=>{s.assign(ut(t,Pn(Pn(t).mul(Pn(i))),r))}).ElseIf(n.equal(De(n$)),()=>{let a=hr(t,J(.5)),o=ut(Pn(Pn(t).mul(Pn(i)).mul(2)),t.mul(i).mul(2),a);s.assign(ut(t,o,r).clamp(0,1))}),s}),OB=new Map,s$=new Set,xK=(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:J(1,0,0),calpha:Ew(r,i)}}});function u2e(e){let t=pl(it.aoRenderTarget.sample(gu).rgb),i=uw(it.aoEnabledUniform);return e!==null&&(i=uw(i.mul(Ki(e,B(1),B(0))))),pl(ut(J(1),t,i))}var a$,o$,pl,uw,bme,xme,d2e,c2e,p2e=U(()=>{var e;vn(),bi(),ua(),da(),{diffuseContribution:a$,specularColorBlended:o$}=I,pl=t=>t,uw=t=>t,bme=Xe(t=>{let i=Ao.dot(pl(t.lightDirection)),r=Me(i.mul(.5).add(.5),0),n=r.fwidth().mul(.5);return ut(J(.7),J(1),Qr(B(.7).sub(n.x),B(.7).add(n.x),r.x))}),xme=Xe(t=>{let i=pl(t.lightDirection).add(lw).normalize(),r=Ao.dot(i).clamp(),n=lw.dot(i).clamp(),s=n.mul(-5.55473).sub(6.98316).mul(n).exp2(),a=nx.mul(s.oneMinus()).add(s),o=B(.25),l=r4.mul(.5).add(1).mul(1/Math.PI).mul(r.pow(r4));return a.mul(o).mul(l)}),e=class extends Nx{direct(t){let{lightDirection:i,lightColor:r,reflectedLight:n}=t,s=pl(bme({lightDirection:i})).mul(r);n.directDiffuse.addAssign(s.mul(pl(Wl.rgb).mul(1/Math.PI))),n.directSpecular.addAssign(s.mul(uw(xme({lightDirection:i}))))}},d2e=class extends e{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(t,...i){super.finish?.call(this,t,...i);let{reflectedLight:r,outgoingLight:n}=t.context,s=u2e(this.aoOcclusionGate),a=pl(r.directDiffuse.add(r.indirectDiffuse));n.subAssign(a.mul(Pn(s)))}},c2e=class extends YI{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(t,i){let r=t;if(r.lightNode?.light?.userData?.splineDiffuseOnly===!0){if(this.envIrradianceActive)return;let n=pl(Ao).dot(r.lightDirection).clamp().mul(r.lightColor),s=I.BRDF_Lambert({diffuseColor:a$});return void r.reflectedLight.directDiffuse.addAssign(n.mul(s))}super.direct(t,i)}}});function k_(e,t){return Uc(t==="x"?e.x:t==="y"?e.y:e.z)}function L2(e,t){return Va(WSe(e,J(t,1)).div(2).add(.5).xy)}function oFe(e,t,i){let r=B(e.div(Xt(e.add(t.accumAlpha),B(1e-5),B(1)))).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(e).mul(Pn(i))),r}function kE(e){let t=e.getValue("projection")??0,i=e.getValue("axis")??0,r=i>=0&&i<=2?i:0,n=e.getValue("projectionAxis")??-1,s=n>=0&&n<=2?n:1,a=f2e(e.get("mat")),o=e.getVec2("size");if(t===1){let u=Ko,h=r===0?u.zy:r===1?u.xz:u.xy,d=Me(h.add(1).div(2)).toVar(),c=Me(L2(a,Va(d.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[Va(c)],weights:null}}if(t===2){let u=J(Ut(Ko)).toVar(),{a:h,b:d,pole:c}=l$[s],p=B(Mf(k_(u,h),k_(u,d)).div(6.283).add(.5)).toVar(),f=B(tK(k_(u,c)).div(3.1415).add(.5)).toVar(),m=Me(p,f).toVar(),g=Me(L2(a,Va(m.mul(2).sub(1)))).toVar();return{uvs:[Va(g)],weights:null}}if(t===3){let u=J(Ut(Ko)).toVar(),{a:h,b:d,pole:c}=l$[s],p=B(Mf(k_(u,h),k_(u,d)).div(6.283).add(.5)).toVar(),f=B(k_(hn(Ko),c).div(o.y.mul(.5))).toVar(),m=B(f.div(2).add(.5)).toVar(),g=Me(p,m).toVar(),v=Me(L2(a,Va(g.mul(2).sub(1)))).toVar();return{uvs:[Va(v)],weights:null}}if(t===4){let u=e.getFloat("blending"),h=J(Ko).toVar(),d=Me(h.xy.add(1).div(2)).toVar(),c=Me(h.zy.add(1).div(2)).toVar(),p=Me(h.xz.add(1).div(2)).toVar();for(let v of[d,c,p])v.assign(L2(a,Va(v.mul(2).sub(1).div(o.mul(.5)))));let f=B(Pn(u).mul(125).add(3)).toVar(),m=J(JA).toVar(),g=J(ui(Ut(m))).toVar();return g.assign(Xl(g,J(f))),g.divAssign(et(g,J(1))),{uvs:[Va(d),Va(c),Va(p)],weights:hn(g)}}let l=Me(L2(a,Va(tr().mul(2).sub(1)))).toVar();return{uvs:[Va(l)],weights:null}}function JD(e,t,i){let r=Me(t).toVar(),n=Me(rw(r)).toVar(),s=Me(nw(r)).toVar(),a=h=>Uc(i.mul(CB(To(e.sample(h)).rgb))),o=B(a(Va(r))).toVar(),l=B(a(Va(r.add(n))).sub(o)).toVar(),u=B(a(Va(r.add(s))).sub(o)).toVar();return Va(Me(l,u))}function eN(e,t,i){let r=J(rw(e)).toVar(),n=J(nw(e)).toVar(),s=J(Ut(t)).toVar(),a=J(Ut(qn(n,s))).toVar(),o=J(Ut(qn(s,r))).toVar(),l=B(et(r,a).mul(AB)).toVar(),u=J(jc(l).mul(i.x.mul(a).add(i.y.mul(o)))).toVar();return hn(Ut(ui(l).mul(s).sub(u)))}function w9(e,t){let i,r=e.get("texture"),n=e.has("loaded")?e.getFloat("loaded"):B(1),s=l=>{let u=To(r.sample(l)),h=t==="luminance"?CB(u.rgb):u[t];return B(h).toVar()},{uvs:a,weights:o}=kE(e);if(o!==null){let l=s(a[0]),u=s(a[1]),h=s(a[2]);i=Uc(l.mul(o.z).add(u.mul(o.x)).add(h.mul(o.y)))}else i=Uc(s(a[0]));return Uc(ut(B(1),i,n))}var Uc,Va,hn,To,f2e,l$,wme,m2e=U(()=>{vn(),bi(),da(),Uc=e=>e,Va=e=>e,hn=e=>e,To=e=>e,f2e=e=>e,l$=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],Na("texture",wme=(e,t,i)=>{let r,n=e.getValue("projection")??0,s=e.getValue("axis")??0,a=s>=0&&s<=2?s:0,o=e.getValue("side")??0,l=e.get("texture"),u=e.getFloat("crop"),{uvs:h,weights:d}=kE(e),c=[...h],p=null;if(n===1){if(r=To(l.sample(h[0])),o!==2){let y=a===0?J(1,0,0):a===1?J(0,1,0):J(0,0,1),_=et(JA,y);p=Uc(hr(B(0),o===1?_.mul(-1):_))}}else if(n===2||n===3)r=function(y,_){if(y.value.minFilter===yt&&y.value.magFilter===yt)return To(y.sample(_));let b=Me(rw(_)).toVar(),x=Me(nw(_)).toVar();return b.x.subAssign(Ct(b.x.add(.5))),x.x.subAssign(Ct(x.x.add(.5))),To(y.sample(_).grad(b,x))}(l,h[0]);else if(n===4){let y=d,_=To(l.sample(h[0])),b=To(l.sample(h[1])),x=To(l.sample(h[2]));r=To(_.mul(y.z).add(b.mul(y.x)).add(x.mul(y.y)))}else r=To(l.sample(h[0]));let f=e.has("loaded")?e.getFloat("loaded"):B(1),m=Pe(ut(Pe(0,0,0,1),To(r),f)).toVar(),g=J(m.rgb).toVar(),v=B(t.alpha.mul(m.a)).toVar();return p!==null&&v.mulAssign(p),function(y,_,b){Ve(y.greaterThan(.5),()=>{for(let x of b)Ve(x.x.lessThan(0).or(x.x.greaterThan(1)).or(x.y.lessThan(0)).or(x.y.greaterThan(1)),()=>{_.assign(0)})})}(u,Uc(v),c),v.mulAssign(t.mask),{color:hn(g),calpha:oFe(Uc(v),i,t.isMask)}}),Na("video",wme)});function tN(e){return _2e({c:e})}function Sg(e){return b2e({p:e})}function lFe(e){return x2e({m:e})}function yv(e){return w2e({x:e})}function S9(e){return S2e({r:e})}function Bx(e){return T2e({v:e})}function iN(e){return M2e({x:e})}function hFe(e){return E2e({x:e})}function vO(e){return A2e({P:e})}function T9(e){return C2e({p3:e})}function VE(e,t,i){return P2e({a:e,b:t,k:i})}function g2e(e,t,i){return R2e({a:e,b:t,k:i})}function v2e(e,t,i,r,n){return D2e({value:e,input_min:t,input_max:i,output_min:r,output_max:n})}function y2e(e,t,i,r,n){return N2e({x:e,style:t,smoothness:i,seed:r,quality:n})}var Sme,M9,B2,_2e,b2e,x2e,w2e,S2e,T2e,Tme,M2e,Mme,E2e,Eme,A2e,Ame,C2e,P2e,R2e,D2e,N2e,BA,eC=U(()=>{bi(),Sme=oK,M9=Zr,B2=.1666667,_2e=Xe(e=>{let t=e.c,i=Pa(et(t,J(17,59.4,15))).mul(4096),r=gr(i.mul(512)),n=i.mul(.125),s=gr(n.mul(512)),a=n.mul(.125),o=gr(a.mul(512));return J(s,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),b2e=Xe(e=>{let t=e.p,i=Ct(t.add(et(t,J(.3333333)))).toVar(),r=t.sub(i).add(et(i,J(B2))).toVar(),n=hr(J(0),r.sub(r.yzx)).toVar(),s=n.mul(Pn(n.zxy)).toVar(),a=Pn(n.zxy.mul(Pn(n))).toVar(),o=r.sub(s).add(B2).toVar(),l=r.sub(a).add(2*B2).toVar(),u=r.sub(1).add(3*B2).toVar(),h=Pe(et(r,r),et(o,o),et(l,l),et(u,u)).toVar();h.assign(Pe(.6).sub(h).max(0));let d=Pe(et(tN(i),r),et(tN(i.add(s)),o),et(tN(i.add(a)),l),et(tN(i.add(1)),u)).toVar();return h.mulAssign(h),h.mulAssign(h),d.mulAssign(h),et(d,Pe(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),x2e=Xe(e=>{let t=e.m,i=Vg(J(-.37,.36,.85),J(-.14,-.93,.34),J(.92,.01,.4)),r=Vg(J(-.55,-.39,.74),J(.33,-.91,-.24),J(.77,.12,.63)),n=Vg(J(-.71,.52,-.47),J(-.08,-.72,-.68),J(-.7,-.45,.56));return Sg(t.mul(i)).mul(.5333333).add(Sg(t.mul(2).mul(r)).mul(.2666667)).add(Sg(t.mul(4).mul(n)).mul(.1333333)).add(Sg(t.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),w2e=Xe(e=>{let t=e.x;return yd(t.mul(34).add(1).mul(t),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),S2e=Xe(e=>$M(1.79284291400159,e.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),T2e=Xe(e=>{let t=e.v,i=Me(1/6,1/3),r=Pe(0,.5,1,2),n=Ct(t.add(et(t,i.yyy))).toVar(),s=t.sub(n).add(et(n,i.xxx)).toVar(),a=hr(s.yzx,s.xyz).toVar(),o=Pn(a).toVar(),l=Fi(a.xyz,o.zxy).toVar(),u=mt(a.xyz,o.zxy).toVar(),h=s.sub(l).add(i.xxx.mul(1)).toVar(),d=s.sub(u).add(i.xxx.mul(2)).toVar(),c=s.sub(1).add(i.xxx.mul(3)).toVar();n.assign(yd(n,289));let p=yv(yv(yv(n.z.add(Pe(0,l.z,u.z,1))).add(n.y).add(Pe(0,l.y,u.y,1))).add(n.x).add(Pe(0,l.x,u.x,1))).toVar(),f=r.wyz.mul(1/7).sub(r.xzx).toVar(),m=p.sub(Ct(p.mul(f.z).mul(f.z)).mul(49)).toVar(),g=Ct(m.mul(f.z)).toVar(),v=Ct(m.sub(g.mul(7))).toVar(),y=g.mul(f.x).add(f.yyyy).toVar(),_=v.mul(f.x).add(f.yyyy).toVar(),b=$M(1,ui(y)).sub(ui(_)).toVar(),x=Pe(y.xy,_.xy).toVar(),w=Pe(y.zw,_.zw).toVar(),S=Ct(x).mul(2).add(1).toVar(),T=Ct(w).mul(2).add(1).toVar(),M=hr(b,Pe(0)).negate().toVar(),E=x.xzyw.add(S.xzyw.mul(M.xxyy)).toVar(),A=w.xzyw.add(T.xzyw.mul(M.zzww)).toVar(),P=J(E.xy,b.x).toVar(),N=J(E.zw,b.y).toVar(),D=J(A.xy,b.z).toVar(),O=J(A.zw,b.w).toVar(),z=S9(Pe(et(P,P),et(N,N),et(D,D),et(O,O))).toVar();P.mulAssign(z.x),N.mulAssign(z.y),D.mulAssign(z.z),O.mulAssign(z.w);let L=mt($M(.6,Pe(et(s,s),et(h,h),et(d,d),et(c,c))),0).toVar();return L.mulAssign(L),et(L.mul(L),Pe(et(P,s),et(N,h),et(D,d),et(O,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Tme=Xe(e=>{let t=e.x;return t.sub(Ct(t.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),M2e=Xe(e=>{let t=e.x;return Tme({x:t.mul(34).add(1).mul(t)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),Mme=Xe(e=>{let t=e.p,i=Ct(t).toVar(),r=t.sub(i).toVar();r.assign(r.mul(r).mul($M(3,r.mul(2))));let n=i.xxyy.add(Pe(0,1,0,1)).toVar(),s=iN(n.xyxy).toVar(),a=iN(s.xyxy.add(n.zzww)).toVar().add(i.zzzz).toVar(),o=iN(a).toVar(),l=iN(a.add(1)).toVar(),u=gr(o.mul(1/41)).toVar(),h=gr(l.mul(1/41)).toVar().mul(r.z).add(u.mul(Pn(r.z))).toVar(),d=h.yw.mul(r.x).add(h.xz.mul(Pn(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(Pn(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),E2e=Xe(e=>{let t=J(e.x).toVar(),i=B(0).toVar(),r=B(.5).toVar(),n=J(100).toVar();return Zr(5,()=>{i.addAssign(r.mul(function(s){return Mme({p:s})}(t))),t.assign(t.mul(2).add(n)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),Eme=Xe(e=>{let t=e.t;return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),A2e=Xe(e=>{let t=e.P,i=Ct(t).toVar(),r=i.add(J(1)).toVar();i.assign(yd(i,289)),r.assign(yd(r,289));let n=gr(t).toVar(),s=n.sub(J(1)).toVar(),a=Pe(i.x,r.x,i.x,r.x).toVar(),o=Pe(i.yy,r.yy).toVar(),l=Pe(i.zzzz).toVar(),u=Pe(r.zzzz).toVar(),h=yv(yv(a).add(o)).toVar(),d=yv(h.add(l)).toVar(),c=yv(h.add(u)).toVar(),p=d.div(7).toVar(),f=gr(Ct(p).div(7)).sub(.5).toVar();p.assign(gr(p));let m=Pe(.5).sub(ui(p)).sub(ui(f)).toVar(),g=hr(m,Pe(0)).toVar();p.subAssign(g.mul(hr(0,p).sub(.5))),f.subAssign(g.mul(hr(0,f).sub(.5)));let v=c.div(7).toVar(),y=gr(Ct(v).div(7)).sub(.5).toVar();v.assign(gr(v));let _=Pe(.5).sub(ui(v)).sub(ui(y)).toVar(),b=hr(_,Pe(0)).toVar();v.subAssign(b.mul(hr(0,v).sub(.5))),y.subAssign(b.mul(hr(0,y).sub(.5)));let x=J(p.x,f.x,m.x).toVar(),w=J(p.y,f.y,m.y).toVar(),S=J(p.z,f.z,m.z).toVar(),T=J(p.w,f.w,m.w).toVar(),M=J(v.x,y.x,_.x).toVar(),E=J(v.y,y.y,_.y).toVar(),A=J(v.z,y.z,_.z).toVar(),P=J(v.w,y.w,_.w).toVar(),N=S9(Pe(et(x,x),et(S,S),et(w,w),et(T,T))).toVar();x.mulAssign(N.x),S.mulAssign(N.y),w.mulAssign(N.z),T.mulAssign(N.w);let D=S9(Pe(et(M,M),et(A,A),et(E,E),et(P,P))).toVar();M.mulAssign(D.x),A.mulAssign(D.y),E.mulAssign(D.z),P.mulAssign(D.w);let O=et(x,n).toVar(),z=et(w,J(s.x,n.yz)).toVar(),L=et(S,J(n.x,s.y,n.z)).toVar(),V=et(T,J(s.xy,n.z)).toVar(),G=et(M,J(n.xy,s.z)).toVar(),Y=et(E,J(s.x,n.y,s.z)).toVar(),$=et(A,J(n.x,s.yz)).toVar(),Q=et(P,s).toVar(),ue=function(we){return Eme({t:we})}(n).toVar(),pe=ut(Pe(O,z,L,V),Pe(G,Y,$,Q),ue.z).toVar(),xe=ut(pe.xy,pe.zw,ue.y).toVar();return ut(xe.x,xe.y,ue.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Ame=Xe(e=>{let t=gr(e.p3.mul(.1031)).toVar();return t.addAssign(et(t,t.yzx.add(33.33))),gr(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),C2e=Xe(e=>{let t=gr(e.p3.mul(J(.1031,.103,.0973))).toVar();return t.addAssign(et(t,t.yxz.add(33.33))),gr(t.xxy.add(t.yxx).mul(t.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),P2e=Xe(e=>{let{a:t,b:i,k:r}=e,n=Qr(0,1,i.sub(t).mul(.5).div(r).add(.5)).toVar(),s=r.mul(n).mul(Pn(n)).toVar();return ut(i,t,n).sub(s)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),R2e=Xe(e=>{let{a:t,b:i,k:r}=e,n=Qr(1,0,t.sub(i).mul(.5).div(r).add(.5)).toVar(),s=r.mul(n).mul(Pn(n)).toVar();return ut(t,i,n).add(s)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),D2e=Xe(e=>{let{value:t,input_min:i,input_max:r,output_min:n,output_max:s}=e,a=r.sub(i).toVar(),o=s.sub(n).toVar(),l=t.sub(i).div(a).toVar();return n.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"}]}),N2e=Xe(e=>{let{x:t,style:i,smoothness:r,seed:n,quality:s}=e,a=Ha(Ct(t)).toVar(),o=gr(t).toVar(),l=B(8).toVar(),u=B(8).toVar(),h=B(8).toVar(),d=B(8).toVar(),c=B(8).toVar(),p=B(8).toVar(),f=Ha(0).toVar(),m=J(0).toVar(),g=De(s).toVar(),v=()=>({start:g.negate(),end:g,condition:"<=",type:"int"});M9(v(),v(),v(),({i:_,j:b,k:x})=>{let w=Ha(_,b,x).toVar(),S=J(w).add(T9(J(a.add(w)).add(n))).sub(o).toVar(),T=Yi(S).toVar();l.assign(VE(T,l,r)),Ve(T.lessThan(u),()=>{d.assign(u),u.assign(T),f.assign(Ha(_,b,x)),m.assign(S)}).ElseIf(T.lessThan(d),()=>{d.assign(T)})}),Ve(i.notEqual(De(0)).and(i.notEqual(De(5))).and(i.notEqual(De(7))),()=>{M9(v(),v(),v(),({i:_,j:b,k:x})=>{let w=f.add(Ha(_,b,x)).toVar(),S=J(w).add(T9(J(a.add(w)).add(n))).sub(o).toVar(),T=et(m.add(S).mul(.5),S.sub(m)).toVar(),M=et(m.add(S).mul(.5),Ut(S.sub(m))).toVar();c.assign(VE(T,c,r)),p.assign(Fi(p,M));let E=Ha(_,b,x).toVar();Ve(eK(Sme(E,f)),()=>{let A=J(E).add(T9(J(a.add(E)).add(n))).sub(o).toVar(),P=Yi(A).toVar();h.assign(VE(P,h,r))})})});let y=B(0).toVar();return Ve(i.equal(De(0)),()=>{y.assign(l)}).ElseIf(i.equal(De(1)),()=>{y.assign(h)}).ElseIf(i.equal(De(2)),()=>{y.assign(h.sub(l))}).ElseIf(i.equal(De(3)),()=>{let _=B(3).toVar(),b=mt(_.sub(ui(u.sub(d))),0).div(_).toVar();y.assign(Fi(u,d).sub(b.mul(b).mul(_).mul(1/4)))}).ElseIf(i.equal(De(4)),()=>{y.assign(EB(c.mul(5)))}).ElseIf(i.equal(De(5)),()=>{y.assign(Xl(l,3))}).ElseIf(i.equal(De(6)),()=>{let _=r.mul(.25).add(.0125).toVar(),b=Xl(r,3).mul(.25).add(.0125).toVar();y.assign(Qr(_.sub(_.mul(b)),_.add(_.mul(b)),p))}).ElseIf(i.equal(De(7)),()=>{y.assign(function(_){return Ame({p3:_})}(J(a.add(f)).add(n)))}),y}).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"}]}),BA=[Sg,lFe,Bx,hFe,vO]});function I2e(e,t,i,r){return gl(e.add(t).mul(i).mul(.001).add(O2e).add(r.mul(.1)))}function uFe(e,t,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 f=>gl(B2e({...c,p:f,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(f){let m=h$.get(f);if(m===void 0){let g=BA[f]??BA[0];m=Xe(v=>{let{n:y,scale:_,intensity:b,offset:x,movement:w}=v,S=gl(v.p);return S.add(y.mul(g(I2e(S,x,_,w))).mul(b))}).setLayout({name:`spe_displaceScalar${f}`,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"}]}),h$.set(f,m)}return m}(d);return f=>gl(p({...c,p:f}))}(e,i),n=J(r(t)).toVar(),s=J(function(u){return L2e({v:u})}(i)).toVar(),a=Ut(qn(i,s)).toVar(),o=J(r(gl(t.add(s)))).toVar(),l=J(r(gl(t.add(a)))).toVar();return{position:n,normal:gl(Ut(qn(o.sub(n),l.sub(n))))}}var gl,O2e,L2e,h$,B2e,E9,Cme,d1,F2,rN,Pme,dFe=U(()=>{bi(),eC(),gl=e=>e,O2e=1e-4,L2e=Xe(e=>{let t=gl(e.v);return Ut(gl(Ki(ui(t.x).greaterThan(ui(t.z)),J(t.y.negate(),t.x,0),J(0,t.z.negate(),t.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),h$=new Map,B2e=Xe(e=>{let{n:t,scale:i,intensity:r,offset:n,movement:s,smoothness:a}=e,o=gl(e.p),l=B(y2e(I2e(o,n,i,s),e.voronoiStyle,a,e.seed,e.quality)).toVar();return l.assign(v2e(l,e.lowCut,e.highCut,B(0),B(1))),l.assign(g2e(l,B(0),a.mul(.25))),l.assign(VE(l,B(1),a.mul(.25))),o.add(t.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"}]})}),cFe=U(()=>{da(),Na("color",(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:e.getColor("color"),calpha:Ew(r,i)}})}),pFe=U(()=>{bi(),da(),E9=e=>e,Cme=e=>e,Na("depth",(e,t,i)=>{let r,n=e.get("colors"),s=e.get("steps"),a=(e.getValue("colors")??n.array).length,o=e.getValue("smooth")===!0,l=(e.getValue("isVector")??1)>.5,u=(e.getValue("gradientType")??0)===0,h=(e.getValue("isWorldSpace")??0)>.5,d=e.getFloat("near"),c=e.getFloat("far");if(l){let g=e.getVec3("origin"),v=h?Jl:Ko;if(u){let y=Ut(e.getVec3("direction"));r=et(y,v.sub(g))}else r=Yi(v.sub(g))}else r=Yi(Jl.sub(qf));let p=r.sub(d).div(c.sub(d)).toVar(),f=Pe(n.element(0)).toVar();for(let g=1;g<a;g++){let v=E9(s.element(g-1)),y=E9(s.element(g)),_=Xt(p.sub(v).div(y.sub(v)),B(0),B(1)),b=o?Qr(B(0),B(1),_):_;f.assign(ut(f,Cme(n.element(g)),b))}let m=t.alpha.mul(f.a).mul(t.mask);return{color:f.rgb,calpha:$c(m,i,t.isMask)}})}),fFe=U(()=>{bi(),da(),ua(),Na("cavity",(e,t,i)=>{let r=Xt(e.getFloat("ridge"),0,2),n=Xt(e.getFloat("valley"),0,2),s=it.normalViewRenderTarget,a=it.resolution,o=$g("randomColor","vec3").x.toVar(),l=gu.toVar(),u=Me(B(1).div(a.x),B(1).div(a.y)).toVar(),h=(E,A)=>s.sample(l.add(Me(E,A)).toVar()).toVar(),d=h(B(0),u.y.negate()),c=h(B(0),u.y),p=h(u.x.negate(),B(0)),f=h(u.x,B(0)),m=E=>E.a.equal(o).and(et(E.xyz,E.xyz).greaterThan(.5)),g=m(d).and(m(c)).and(m(p)).and(m(f)),v=d.y.sub(c.y).add(f.x.sub(p.x)).toVar(),y=B(.5).div(mt(r.mul(r),B(1e-4))).toVar(),_=B(.7).div(mt(n.mul(n),B(1e-4))).toVar(),b=(E,A)=>Ki(E.lessThan(B(.5).div(A)),E.mul(B(1).sub(E.mul(A))),B(.25).div(A)),x=Ki(g,Ki(v.greaterThan(0),b(v,y).mul(2),b(v.negate(),_).mul(-2)),B(0)).toVar(),w=Ki(x.abs().lessThan(.001),B(0),x).toVar(),S=J(Xt(w.mul(.5).add(.5),0,1)),T=Ki(w.notEqual(0),B(1),B(0)),M=Ki(t.isMask,B(1),T);return{color:S,calpha:$c(t.alpha.mul(t.mask).mul(M),i,t.isMask)}})}),Aw=U(()=>{bi(),d1=Xe(e=>{let t=e.material?.vertexObjectNormal??null;return t?n4(t).transformNormalByInverseViewMatrix(_u).normalize():$Se}).once()().toVar("speVertexNormalWorld")}),mFe=U(()=>{bi(),Aw(),da(),eC(),Na("dust",(e,t,i)=>{let r=e.getFloat("coverage"),n=e.getFloat("softness"),s=e.getFloat("noiseStrength"),a=e.getFloat("noiseScale"),o=et(Ut(d1),J(0,1,0)),l=B(0).toVar();Ve(s.notEqual(0),()=>{let c=Sg(Ko.div(a).toVar().add(J(1.7,9.2,1)));l.assign(c.mul(s))});let u=mt(n,1e-4).toVar(),h=ut(u.add(1),u.add(1).negate(),Xt(r,0,1)).toVar(),d=Qr(h.sub(u),h.add(u),o.add(l)).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:$c(d,i,t.isMask)}})}),gFe=U(()=>{bi(),Aw(),da(),F2=(e,t)=>e.element(t),Na("fresnel",(e,t,i)=>{let r=F2(Mw,2).w.equal(-1),n=J(F2(_u,0).z,F2(_u,1).z,F2(_u,2).z).negate(),s=Jl.sub(qf),a=Ki(r,s,n),o=e.getFloat("bias").add(e.getFloat("scale").mul(Xl(ui(e.getFloat("factor").add(et(Ut(a),Ut(d1)))),e.getFloat("intensity")))),l=Xt(o,0,1).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:$c(l,i,t.isMask)}})}),vFe=U(()=>{bi(),da(),rN=e=>e,Pme=e=>e,Na("gradient",(e,t,i)=>{let r=e.get("colors"),n=e.get("steps"),s=(e.getValue("colors")??r.array).length,a=(e.getValue("steps")??n.array).length,o=Math.min(10,s,a),l=e.getInt("gradientType"),u=e.getBool("smooth"),h=e.getVec2("offset"),d=e.getVec2("morph"),c=e.getFloat("angle"),p=tr(),f=Pe(r.element(0)).toVar(),m=Me(d.div(p)).toVar(),g=Me(B(.5).add(m.x),m.y).toVar(),v=Me(Yo(c).mul(g.x).sub(Pa(c).mul(g.y)),Pa(c).mul(g.x).add(Yo(c).mul(g.y))).toVar(),y=Me(p.sub(.5).add(h).div(2).add(v.div(2))),_=B(et(y,v).div(et(v,v))).toVar();Ve(l.equal(De(1)),()=>{_.assign(CSe(p.add(d).mul(3),p.add(h).add(1)).add(c))}).ElseIf(l.equal(De(2)),()=>{let x=Mf(p.x.add(d.x).sub(.5).add(h.x),p.y.add(d.y).sub(.5).add(h.y)).mul(-1);_.assign(gr(c.div(fq).div(-2).add(x.div(fq).mul(.5))))});for(let x=1;x<o;x++){let w=rN(n.element(x-1)),S=rN(n.element(x)),T=Xt(_.sub(w).div(S.sub(w)),B(0),B(1)),M=rN(Ki(u,Qr(B(0),B(1),T),T));f.assign(ut(f,Pme(r.element(x)),M))}let b=t.alpha.mul(f.a).mul(t.mask);return{color:f.rgb,calpha:$c(b,i,t.isMask)}})}),yFe=U(()=>{bi(),da(),Na("matcap",(e,t,i)=>{let r=e.getFloat("rotation"),n=Ut($f.negate()),s=Ut(J(n.z,0,n.x.negate())),a=qn(n,s),o=Me(et(s,Ao),et(a,Ao)),l=Yo(r),u=Pa(r),h=Me(l.mul(o.x).sub(u.mul(o.y)),u.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=e.get("texture").sample(h),c=t.alpha.mul(t.mask);return{color:d.rgb,calpha:$c(c,i,t.isMask)}})}),_Fe=U(()=>{bi(),da(),eC(),Na("noise",(e,t,i)=>{try{if(new URLSearchParams(window.location.search).get("dbgnoise")==="0")return{color:J(0),calpha:B(0)}}catch{}let r=Math.trunc(e.getValue("noiseType")??0),n=B(mt(ui(e.getFloat("scale")),.001)).toVar(),s=J(Ko.div(e.getVec3("size"))).toVar();s.divAssign(n);let a=e.getFloat("move"),o=e.getVec4("colorA"),l=e.getVec4("colorC"),u=Pe(0).toVar();if(r===5){let d=e.getFloat("smoothness"),c=B(y2e(s.add(a),e.getInt("voronoiStyle"),d,e.getFloat("seed"),e.getInt("quality"))).toVar();c.assign(v2e(c,e.getFloat("lowCut"),e.getFloat("highCut"),B(0),B(1))),c.assign(g2e(c,B(0),d.mul(.25))),c.assign(VE(c,B(1),d.mul(.25))),u.assign(ut(o,l,c))}else{let d=BA[r]??BA[0],c=e.getVec4("colorB"),p=e.getVec4("colorD"),f=J(e.getVec2("distortion"),1).toVar(),m=J(e.getVec2("fA"),1).toVar(),g=J(e.getVec2("fB"),1).toVar(),v=J(d(s),d(s.add(J(1))),d(s.add(J(1)))).toVar(),y=J(d(s.add(f.mul(v)).add(m).add(a)),d(s.add(f.mul(v)).add(g).add(a)),d(s.mul(v))).toVar(),_=B(d(s.add(y))).toVar();u.assign(ut(o,c,Xt(_.mul(_).mul(4),B(0),B(1)))),u.assign(ut(u,l,Xt(Yi(v),B(0),B(1)))),u.assign(ut(u,p,Xt(Yi(y.x),B(0),B(1))))}let h=t.alpha.mul(u.a).mul(t.mask);return{color:Xt(u,B(0),B(1)).rgb,calpha:$c(h,i,t.isMask)}})}),bFe=U(()=>{bi(),da(),Na("normal",(e,t,i)=>({color:KSe(Ut(Ao)).mul(hr(J(.5),e.getVec3("cnormal"))),calpha:Ew(t.alpha.mul(t.mask),i)}))});function A9(e){return F2e({p:e})}function nN(e,t){return U2e({uv:e,a:t})}function V_(e,t,i,r,n){return z2e({uv:e,frequency:t,variation:i,zigzag:r,rotation:n})}function sN(e,t){let i={uv:t.uv,frequency:t.frequency,size:t.size,variation:t.variation,smoothness:t.smoothness,zigzag:t.zigzag,rotation:t.rotation};switch(e){case 1:return V2e(i);case 2:return G2e({...i,sides:t.sides});case 3:return j2e(i);case 4:return W2e(i);case 5:return H2e(i);case 6:return q2e(i);case 7:return $2e(i);default:return k2e(i)}}var G_,Rme,F2e,U2e,z2e,k2e,V2e,Dme,G2e,Nme,j2e,Ime,W2e,H2e,q2e,Ome,$2e,U2,C9,Lme,Bme,Fme,Ume,zme,P9,kme,_v,Vme,Gme,R9,jme,xFe=U(()=>{bi(),da(),G_=2*Math.PI,Rme=Math.PI/180,F2e=Xe(e=>{let t=gr(e.p.xyx.mul(.1031)).toVar();return t.addAssign(et(t,t.yzx.add(33.33))),gr(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),U2e=Xe(e=>{let t=e.uv,i=.5,r=B(e.a.mul(Rme)).toVar(),n=Me(Yo(r).mul(t.x.sub(i)).add(Pa(r).mul(t.y.sub(i))).add(i),Yo(r).mul(t.y.sub(i)).sub(Pa(r).mul(t.x.sub(i))).add(i));return gr(n)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),z2e=Xe(e=>{let t=Me(e.uv.mul(e.frequency)).toVar(),i=Me(Ct(t)).toVar(),r=B(yd(i.y,2)).toVar();t.x.addAssign(r.mul(e.zigzag));let n=Me(gr(t)).toVar();n.assign(n.mul(2).sub(1)),i.assign(Ct(t));let s=B(A9(i).mul(5).add(1)).toVar(),a=B(ut(B(1),s,e.variation)).toVar();return n.mulAssign(a),n}).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"}]}),k2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Yi(t).sub(e.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"}]}),V2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar(),i=B(Yi(t)).toVar(),r=B(Qr(e.smoothness.negate(),e.smoothness,i.sub(e.size))).toVar(),n=B(Qr(e.smoothness.negate(),e.smoothness,i.sub(e.size.mul(.5)))).toVar();return r.add(Pn(n))}).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"}]}),Dme=Xe(e=>{let t=B(B(G_).div(B(e.n))).toVar(),i=B(e.r.mul(uTe(t.mul(.5)))).toVar(),r=Me(e.p.yx.negate()).toVar(),n=B(t.mul(Ct(Mf(r.y,r.x).add(t.mul(.5)).div(t)))).toVar(),s=Me(Yo(n),Pa(n)).toVar();return r.assign(Me(s.x.mul(r.x).add(s.y.mul(r.y)),s.y.negate().mul(r.x).add(s.x.mul(r.y)))),Yi(r.sub(Me(e.r,Xt(r.y,i.negate(),i)))).mul(jc(r.x.sub(e.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),G2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Dme({p:t,r:e.size,n:e.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"}]}),Nme=Xe(e=>{let t=e.b,i=Me(ui(e.p)).toVar();i.assign(Ki(i.y.greaterThan(i.x),i.yx,i.xy));let r=Me(i.sub(t)).toVar(),n=B(mt(r.y,r.x)).toVar(),s=Me(Ki(n.greaterThan(0),r,Me(t.y.sub(i.x),n.negate()))).toVar();return jc(n).mul(Yi(mt(s,Me(0)))).add(e.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),j2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Nme({p:t,b:Me(e.size,e.size.mul(.25)),r:e.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"}]}),Ime=Xe(e=>{let t=e.b,i=Me(ui(e.p)).toVar(),r=Me(t.sub(i.mul(2))).toVar(),n=r.x.mul(t.x).sub(r.y.mul(t.y)),s=B(Xt(n.div(et(t,t)),B(-1),B(1))).toVar();return B(Yi(i.sub(t.mul(.5).mul(Me(Pn(s),s.add(1)))))).toVar().mul(jc(i.x.mul(t.y).add(i.y.mul(t.x)).sub(t.x.mul(t.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),W2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Ime({p:t,b:Me(e.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"}]}),H2e=Xe(e=>{let t=Me(e.uv.mul(e.frequency)).toVar(),i=Me(Ct(t)).toVar(),r=B(yd(i.y,2)).toVar();t.x.addAssign(r.add(e.zigzag.mul(r)));let n=B(Ct(t.x)).toVar();return yd(n,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"}]}),q2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,B(0),e.zigzag,e.rotation)).toVar(),i=B(Ct(e.uv.mul(e.frequency)).y).toVar(),r=B(A9(Me(i))).toVar(),n=B(ut(e.size,e.size.mul(r),e.variation)).toVar();return Qr(n.sub(e.smoothness),n.add(e.smoothness),ui(t.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"}]}),Ome=Xe(e=>{let{a:t,b:i,c:r,d:n}=e,s=Me(e.p.sub(Me(n,t)).mul(r)).toVar();s.x.assign(yd(s.x,G_)),Ve(s.x.greaterThan(Math.PI),()=>{s.x.assign(B(G_).sub(s.x))});let a=B(0).toVar(),o=B(G_).toVar();Zr(24,()=>{let h=B(a.add(o).mul(.5)).toVar(),d=B(h.sub(s.x).add(i.mul(r).mul(Pa(h)).mul(s.y.sub(i.mul(r).mul(Yo(h)))))).toVar();Ve(d.lessThan(0),()=>{a.assign(h)}).Else(()=>{o.assign(h)})});let l=B(a.add(o).mul(.5)).toVar(),u=Me(l,i.mul(r).mul(Yo(l))).toVar();return Yi(s.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"}]}),$2e=Xe(e=>{let t=B(e.frequency.x).toVar(),i=Me(e.uv.mul(t)).toVar(),r=Me(Ct(i)).toVar(),n=B(yd(r.y,2)).toVar();i.x.addAssign(n.mul(e.zigzag));let s=Me(i.x,gr(i.y)).toVar(),a=B(e.frequency.y.mul(.1)).toVar(),o=B(Ome({p:s,a:B(.5),b:B(.125),c:a.mul(G_),d:B(0)})).toVar(),l=B(A9(Me(r.y))).toVar(),u=B(ut(e.size,e.size.mul(l),e.variation)).toVar();return Qr(e.smoothness.negate(),e.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"}]}),Na("pattern",(e,t,i)=>{let r,n,s=e.getValue("style")??0,a=e.getValue("projection")??0,o=e.getValue("axis")??0,l=e.getFloat("blending"),u=e.getVec2("offset"),h=e.getVec4("colorA"),d=e.getVec4("colorB"),c=e.getVec2("frequency"),p=e.getFloat("size"),f=e.getFloat("variation"),m=e.getFloat("smoothness"),g=e.getFloat("zigzag"),v=e.getFloat("rotation"),y=e.getVec2("vertical"),_=e.getVec2("horizontal"),b=e.getInt("sides"),x={frequency:c,size:p,variation:f,smoothness:B(Xl(m,5)).toVar(),zigzag:g,rotation:v,sides:b};if(a===4){let T=J(Ko).toVar(),M=B(.0125).toVar(),E=Me(gr(T.xy.mul(M))).toVar(),A=Me(gr(T.zy.mul(M))).toVar(),P=Me(gr(T.xz.mul(M))).toVar();E.assign(nN(E.add(u),v)),A.assign(nN(A.add(u),v)),P.assign(nN(P.add(u),v));let N=B(sN(s,{uv:E,...x})).toVar(),D=B(sN(s,{uv:A,...x})).toVar(),O=B(sN(s,{uv:P,...x})).toVar(),z=B(Pn(l).mul(125).add(3)).toVar(),L=J(JA).toVar(),V=J(ui(Ut(L))).toVar();V.assign(Xl(V,J(z))),V.divAssign(et(V,J(1))),N.mulAssign(V.z),D.mulAssign(V.x),O.mulAssign(V.y),r=B(N.add(D).add(O)).toVar(),n=Me(E.mul(V.z).add(A.mul(V.x)).add(P.mul(V.y))).toVar()}else{let T=Me(0).toVar();if(a===0)T.assign(tr());else if(a===2){let M,E,A=J(Ko).toVar(),P=B(Yi(A)).toVar();o===0?(M=B(Mf(A.y,A.z)).toVar(),E=B(tO(A.x.div(P))).toVar()):o===1?(M=B(Mf(A.x,A.z)).toVar(),E=B(tO(A.y.div(P))).toVar()):(M=B(Mf(A.y,A.x)).toVar(),E=B(tO(A.z.div(P))).toVar()),T.assign(Me(M,E).div(Math.PI))}T.addAssign(u),T.assign(gr(T)),T.assign(nN(T,v)),r=sN(s,{uv:T,...x}),n=T}let w=Pe(ut(h,d,r)).toVar();w.a.assign(Xt(w.a,B(0),B(1))),w.a.mulAssign(hr(y.x,n.y).mul(hr(n.y,y.y))),w.a.mulAssign(hr(_.x,ui(n.x)).mul(hr(ui(n.x),_.y)));let S=t.alpha.mul(Xt(w.a,B(0),B(1))).mul(t.mask);return{color:Xt(w,Pe(0),Pe(1)).rgb,calpha:$c(S,i,t.isMask)}})}),wFe=U(()=>{bi(),Aw(),da(),eC(),U2=(e,t)=>e.element(t),Na("rainbow",(e,t,i)=>{let r=e.getFloat("filmThickness"),n=e.getFloat("movement"),s=e.getVec3("wavelengths"),a=e.getFloat("noiseStrength"),o=e.getFloat("noiseScale"),l=e.getVec3("offset"),u=B(0).toVar();t.noiseCompiledIn!==!1&&Ve(a.notEqual(0),()=>{let _=Ko.div(o).toVar(),b=Sg(_.mul(1.6).add(J(1.8,1.5,1.9).mul(Sg(_))).add(J(1.7,9.2,1)));u.assign(b.mul(a))});let h=s.mul(J(1,.8,.6)).add(1),d=U2(Mw,2).w.equal(-1),c=J(U2(_u,0).z,U2(_u,1).z,U2(_u,2).z).negate(),p=Jl.sub(qf),f=Ki(d,p,c),m=et(Ut(f.add(l.mul(-.001))),Ut(d1)),g=Yo(r.add(u).div(h).mul(m).add(n)).mul(.5).add(.5),v=J(Xt(g,0,2)).toVar(),y=Xt(v.r.add(v.g).add(v.b),0,1);return{color:v,calpha:$c(t.alpha.mul(y).mul(t.mask),i,t.isMask)}})}),SFe=U(()=>{bi(),Aw(),da(),ua(),C9=e=>e,Lme=e=>e,Bme=Zr,Fme=Zr,Ume=Xe(e=>{let t=e.x,i=J(et(t,J(127.1,311.7,74.7)),et(t,J(269.5,183.3,246.1)),et(t,J(113.5,271.9,124.6)));return gr(Pa(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),zme=Xe(e=>{let t=e.x,i=Ct(t).toVar(),r=gr(t).toVar(),n=B(100).toVar(),s=()=>({start:De(-1),end:De(1),condition:"<=",type:"int"});return Fme(s(),s(),s(),({i:a,j:o,k:l})=>{let u=J(a,o,l).toVar(),h=u.sub(r).add(function(c){return Ume({x:c})}(i.add(u))).toVar(),d=et(h,h).toVar();Ve(d.lessThan(n),()=>{n.assign(d)})}),n.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),Na("toon",(e,t,i)=>{let r=e.getInt("positioning"),n=e.get("colors"),s=e.get("steps"),a=e.getVec3("source"),o=e.getBool("isWorldSpace"),l=e.getFloat("noiseStrength"),u=e.getFloat("noiseScale"),h=e.getVec4("shadowColor"),d=e.getVec3("offset"),c=Ut(d1).toVar(),p=B(0).toVar();i.lightsAvailable===!0&&Ve(r.equal(De(0)),()=>{Bme({start:De(0),end:it.toonLightCount,condition:"<",type:"int"},({i:_})=>{let b=it.toonLightData.element(_).toVar(),x=b.xyz,w=b.w,S=Ki(w.greaterThan(.5),Ut(x),Ut(x.sub(Jl))),T=et(S,c).mul(.5).add(.5);p.assign(mt(p,T))}),p.assign(Xt(p,0,1))}),Ve(r.equal(De(1)),()=>{let _=ut(Ko,Jl,Ki(o,B(1),B(0))),b=Ut(a.sub(_));p.assign(et(b,c).mul(.5).add(.5))}).ElseIf(r.equal(De(2)),()=>{let _=qf.sub(d),b=Ut(_.sub(Jl));p.assign(et(b,c).mul(.5).add(.5))}),Ve(l.greaterThan(0),()=>{let _=Ko.div(u),b=B(1).sub(zme({x:_}));p.addAssign(b.mul(l))}),p.assign(Xt(p,0,1));let f=(e.getValue("colors")??n.array).length,m=(e.getValue("steps")??s.array).length,g=Math.min(10,f,m),v=Pe(n.element(0)).toVar();for(let _=1;_<g;_++){let b=C9(s.element(_-1)),x=C9(s.element(_)),w=Xt(p.sub(b).div(x.sub(b)),B(0),B(1));v.assign(ut(v,Lme(n.element(_)),Qr(0,1,w)))}i.lightsAvailable===!0&&Ve(r.equal(De(0)),()=>{let _=B(1),b=ut(v.rgb,h.rgb,h.a);v.rgb.assign(ut(b,v.rgb,_))});let y=t.alpha.mul(v.a).mul(t.mask);return{color:v.rgb,calpha:Ew(y,i)}})}),TFe=U(()=>{bi(),Aw(),da(),a2e(),ua(),P9=e=>e,kme=(e,t)=>e.element(t),_v=e=>e,Vme=e=>e,Gme=e=>e,Na("transmission",(e,t,i)=>{let r=e.getFloat("thickness"),n=e.getFloat("ior"),s=e.getFloat("roughness"),a=it.transmissionRenderTarget,o=it.transmissionSamplerSize,l=G=>kme(_u,G),u=Ut(J(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),h=Ut(Jl.sub(qf)),d=it.orthographicUniform,c=Ki(d.greaterThan(.5),u,h).toVar(),p=Ut(d1).toVar(),f=nTe(c,p,B(1).div(n)).toVar(),m=Ut(f).mul(r).mul(s2e).toVar(),g=G=>{let Y=it.unjitteredProjection.mul(_u).mul(Pe(G,1)),$=Y.xy.div(Y.w);return Me($.x.mul(.5).add(.5),$.y.mul(-.5).add(.5))},v=g(Jl.add(m).toVar()).toVar(),y=(g(Jl).toVar(),s.mul(Xt(n.mul(2).sub(2),B(0),B(1))).toVar()),_=sw(o.x).mul(y).toVar(),b=y,x=Fi(_.div(5.5),B(8.5)).toVar(),w=null,S="fit",T=!0,M=!1,E=12,A="white",P=1;try{let G=new URLSearchParams(window.location.search),Y=G.get("dbglod");Y!==null&&(w=Number(Y));let $=G.get("dbgtap");$==="ring"&&(S="ring"),($==="single"||$==="1")&&(S="single"),($==="r50"||$==="r75"||$==="full")&&(S=$),$==="singlewide"&&(S="singlewide"),($==="fit"||$==="singlefit")&&(S="fit");let Q=G.get("dbgwidth");Q!==null&&Number.isFinite(Number(Q))&&(P=Math.max(0,Number(Q))),$==="6"&&(S="ring",E=6),G.get("dbgwarp")==="0"&&(T=!1),G.get("dbgdither")==="1"&&(M=!0);let ue=G.get("dbgangle");(ue==="classic"||ue==="0")&&(A=ue)}catch{}w!==null&&Number.isFinite(w)&&x.assign(B(w));let N,D=(()=>{if(S==="singlewide")return Fi(x.add(1),B(8.5)).toVar();if(S!=="fit")return x;let G=it.transmissionActualSize.x.div(it.resolution.x),Y=b.mul(x).mul(5*P).mul(G).toVar();return Fi(sw(zb(x.mul(2)).add(Y.mul(Y).mul(3))).mul(.5),B(8.5)).toVar()})(),O=G=>a.sample(T?(Y=>{let $=it.transmissionActualSize.div(zb(Ct(D))),Q=Y.mul($).sub(.5),ue=Ct(Q),pe=Q.sub(ue),xe=pe.mul(pe).mul(Me(3,3).sub(pe.mul(2)));return ue.add(.5).add(xe).div($)})(G):G).level(D).rgb,z=S==="r50"?.5:S==="r75"?.75:1;if(S==="single"||S==="singlewide"||S==="fit")if(S==="fit"){let G=Ct(D).toVar(),Y=D.sub(G).toVar(),$=Rh(zb(Y.mul(2)).sub(1)).mul(1.1547).toVar(),Q=Me(zb(G)).div(it.transmissionActualSize).mul($).toVar(),ue=J(0).toVar(),pe=12;for(let xe=0;xe<pe;xe++){let we=_v(Xg(xe,pe,B(0))),re=_v(v.add(we.mul(Q)));ue.addAssign(Vme(Gme(a.sample(re).level(G)).rgb))}N=ue.div(pe).toVar()}else N=O(v).toVar();else{let G=Me(B(1).div(it.resolution.x),B(1).div(it.resolution.y)).toVar(),Y=jf(A==="classic"?Qo.xy.add(it.cameraJitterPx):Qo.xy).mul(6.28318530718);A==="white"&&(Y=Y.add(it.tapAngle));let $=Y.toVar(),Q=it.tapAngle.mul(13.7).toVar(),ue=it.tapAngle2.mul(5.3).toVar(),pe=Me(zb(Ct(D).add(1))).div(it.transmissionActualSize).toVar(),xe=jf(Qo.xy.add(Me(Q,ue))).toVar(),we=jf(Qo.xy.add(Me(ue.mul(1.71),Q.mul(2.39)))).toVar(),re=J(0).toVar();for(let Se=0;Se<E;Se++){let W=_v(Xg(Se,E,$)).mul(G).mul(b).mul(x.mul(10)).mul(z),k=_v(v.add(W));if(M){let K=P9(gr(xe.add(.7548776662*Se))),ie=P9(gr(we.add(.5698402911*Se))),j=_v(Me(K.sub(.5),ie.sub(.5)).mul(pe));k=_v(k.add(j))}re.addAssign(O(k))}N=re.div(E).toVar()}if(e.has("attenuationDistance")){let G=e.getFloat("attenuationDistance"),Y=J(e.getColor("attenuationColor")).toVar();Ve(G.greaterThan(0),()=>{let $=Xl(mt(Y,J(1e-4)),J(r.div(G)));N.mulAssign($)})}let L=t.alpha.mul(t.mask).toVar(),V=L.div(Xt(L.add(i.accumAlpha),B(1e-5),B(1))).toVar();return i.accumAlpha.addAssign(B(1).sub(i.accumAlpha).mul(t.alpha)),{color:N,calpha:V}})}),MFe=U(()=>{bi(),da(),ua(),CTe(),Na("reflection",(e,t,i)=>{let r=e.getFloat("blur"),n=e.getFloat("thickness"),s=e.getInt("steps"),a=e.getFloat("stepSize"),o=e.getValue("tracingMode")??0,l=it.reflectionRenderTarget,u=it.reflectionDepthPyramid,h=it.reflectionDepthPyramid,d=it.reflectionDepthLevels,c=it.reflectionEnvMap,p=it.reflectionPlanarTarget,f=it.reflectionPlanarEnabled,m=yg("__splinePlanarMirror","float"),g=f.greaterThan(.5).and(m.greaterThan(.5)),v=it.reflectionResolveTarget,y=it.reflectionResolveEnabled,_=it.orthographicUniform.greaterThan(.5),b=Ki(_,J(0,0,-1),Ut($f)).toVar(),x=Ut(Ao).toVar(),w=DA(b,x).toVar(),S=Xt(r.mul(.1),B(0),B(1)).toVar(),T=it.resolution,M=J(0).toVar(),E=y.greaterThan(.5).and(S.greaterThan(.05)).and(g.not()),A=Ut(uK(w,i4)).toVar(),P=Dq(c,A,S).toVar(),N=v.sample(gu).level(B(0)).toVar();Ve(E,()=>{let z=N.a.toVar();M.assign(ut(P,N.rgb.div(z.max(1e-4)),Xt(z.mul(2),B(0),B(1))))}).Else(()=>{M.assign(cK({dials:{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:o},surface:{originView:$f,normalV:x,screenUv:gu,fragWindowZ:MB},camera:{projectionMatrix:Mw,projectionMatrixInverse:wSe,worldMatrix:i4,near:xSe},resources:{colorMap:l,depthPyramid:u,depthPyramidNode:h,envMap:c},usePlanar:g,noisePixel:gu.mul(T).floor()}))}),Ve(g,()=>{let z=Me(B(1).sub(gu.x),gu.y).toVar(),L=B(d.sub(1)),V=Fi(sw(S.mul(T.y).mul(Pq).add(1)),L).toVar(),G=V.sub(1).max(0).floor().toVar(),Y=B(2).pow(V).sub(1).max(0).toVar(),$=Y.mul(.75).div(T.y).toVar();M.assign(Rq(p,z,$,Y.mul(.75),G))});let D=t.alpha.mul(t.mask).toVar(),O=D.div(Xt(D.add(i.accumAlpha),B(1e-5),B(1))).toVar();return i.accumAlpha.addAssign(B(1).sub(i.accumAlpha).mul(D)),{color:M,calpha:O}})}),EFe=U(()=>{bi(),Aw(),da(),ua(),R9=e=>e,jme=e=>e,Na("outline",(e,t,i)=>{let r=e.getColor("outlineColor"),n=e.getColor("contourColor"),s=e.getFloat("outlineWidth"),a=e.getFloat("contourWidth"),o=e.getFloat("outlineThreshold"),l=e.getFloat("contourThreshold"),u=e.getFloat("outlineSmoothing"),h=e.getFloat("contourFrequency"),d=e.getVec3("contourDirection"),c=e.getBool("positionalLines"),p=e.getBool("compensation"),f=it.normalRenderTarget,m=it.normalRenderTargetDepth,g=it.resolution,v=it.pixelRatio,y=$g("randomColor","vec3").x.toVar(),_=MB.toVar(),b=gu.toVar(),x=Me(B(1).div(g.x),B(1).div(g.y)).toVar(),w=it.pcssHalton,S=jf(Qo.xy.add(w)).mul(6.28318530718).toVar(),T=p.select(s.div(2),s),M=x.mul(T).mul(v).toVar(),E=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=ue=>Xg(ue,9,S).mul(x),P=[],N=B(0).toVar();for(let ue=0;ue<9;ue++){let[pe,xe]=E[ue],we=ue===4?b:R9(b.add(Me(M.x.mul(pe),M.y.mul(xe))).add(A(ue))),re=R9(we).toVar(),Se=jme(f.sample(re)).toVar();P.push(Se),Ve(Se.a.notEqual(y).and(Se.a.notEqual(0)),()=>{let W=m.sample(re).r.add(1e-4);Ve(_.greaterThan(W),()=>{N.assign(1)})})}let D=P[2].rgb.add(P[5].rgb.mul(2)).add(P[8].rgb).sub(P[0].rgb.add(P[3].rgb.mul(2)).add(P[6].rgb)),O=P[0].rgb.add(P[1].rgb.mul(2)).add(P[2].rgb).sub(P[6].rgb.add(P[7].rgb.mul(2)).add(P[8].rgb)),z=Rh(et(D,D).add(et(O,O))).mul(N.oneMinus()).toVar(),L=J(r).toVar(),V=Qr(o.sub(u),o.add(u),z).toVar(),G=Ut(d1).toVar(),Y=B(1).sub(l).toVar();Ve(c,()=>{let ue=Ko.mul(d),pe=ue.x.add(ue.y).add(ue.z).toVar(),xe=gr(pe.mul(h).mul(.01)),we=gq(pe.mul(h)),re=Qr(we.mul(a.mul(.01)),we.mul(a.mul(.02)),xe).toVar();Ve(re.lessThan(1).and(V.equal(0)),()=>{L.assign(n),V.assign(1)})}).Else(()=>{let ue=G.mul(d),pe=ue.x.add(ue.y).add(ue.z).toVar(),xe=gq(pe.mul(l)).toVar(),we=Pa(pe.mul(h)).toVar(),re=Qr(B(0),xe.mul(a),B(1).sub(we)).toVar();Ve(xe.greaterThan(Y.mul(.5)).and(re.lessThan(1)).and(V.equal(0)),()=>{L.assign(n),V.assign(B(1).sub(re))})});let $=t.alpha.mul(V).mul(t.mask).toVar(),Q=$.div(Xt($.add(i.accumAlpha),B(1e-5),B(1))).toVar();return i.accumAlpha.addAssign(B(1).sub(i.accumAlpha).mul($)),{color:L,calpha:Q}})}),AFe=U(()=>{bi(),da(),Na("vertexColor",(e,t,i)=>{let r=fTe(),n=t.alpha.mul(t.mask).mul(r.a);return{color:r.rgb,calpha:Ew(n,i)}})}),X2e=U(()=>{cFe(),pFe(),fFe(),mFe(),gFe(),vFe(),yFe(),_Fe(),bFe(),xFe(),wFe(),m2e(),SFe(),TFe(),MFe(),EFe(),AFe(),p2e()});function Wme(e){let t=e.data,i=[e.kind,e.type,`v=${!!t.visible}`,`m=${!!t.isMask}`,`p=${e.params.names().join(",")}`];if(e.type!=="light"){let r=xw[e.type];if(r!==void 0)for(let n of r)i.push(`${n}=${String(t[n])}`)}for(let[r,n]of e.uniformKinds)(n==="vec4array"||n==="floatArray")&&i.push(`${r}#${(e.params.getValue(r)??[]).length}`);if(e.type==="rainbow"&&i.push(`noise=${e.noiseCompiledIn!==!1}`,`forced=${e.noiseForced===!0}`),e.type==="displace"&&i.push(`dt=${String(t.displacementType)}`),e.type==="texture"||e.type==="video"||e.type==="matcap"){if(e.holders.length===0)throw new Error(`structuralKey: ${e.type} layer has no holder`);let r=t.texture??{};i.push(`holder=${e.holders.map(n=>n.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var CFe=U(()=>{Ed()});function ja(e,t=1){let i=new ot(e);return new zr(i.r,i.g,i.b,t)}function u$(e,t){if(e instanceof zr)return e;if(e instanceof ot)return new zr(e.r,e.g,e.b,1);if(typeof e=="number")return ja(e);if(typeof e=="object"&&e!==null&&"r"in e&&"g"in e&&"b"in e){let i=e;return new zr(i.r,i.g,i.b,i.a??1)}return t()}function Hme(){let e=new Array(10).fill(new ct(0,0,0,1)).map(t=>t.clone());return e[1]=new ct(1,1,1,1),e}function qme(){let e=new Array(10).fill(1);return e[0]=0,e}function eE(e,t){let i=e.material;if((i==null||i.isTSLNodeMaterial!==!0)&&(i=e.object?.material,i==null||i.isTSLNodeMaterial!==!0))return t;if(t.kind==="light"){let n=i.lightLayer;if(n==null)return t;let s=n.data?.category,a=t.data?.category;return s===a?n:t}let r=i.layers?.[t.structIndex];return r!==void 0&&r.type===t.type?r:t}function $me(e,t){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new Error(`[spe] ${e}.element() needs a build-time constant index (got ${String(t)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return t}function _i(e,t,i,r){let n,s,a=e.params;switch(i){case"float":n=Fe(Number(r??0));break;case"int":n=Fe(Number(r??0),"int");break;case"axis":n=Fe(["x","y","z"].indexOf(String(r)),"int");break;case"bool":n=Fe(!!r);break;case"vec2":n=Fe(r instanceof Z?r:new Z);break;case"vec3":n=Fe(r instanceof R?r:new R);break;case"vec4":n=Fe(r instanceof ct?r:new ct);break;case"color":{let o=u$(r,()=>ja(16777215));n=Fe(o),s=o;break}case"colorVec4":{let o=u$(r,()=>new zr(1,1,1,1)),l=new ct(o.r,o.g,o.b,o.a),u=Fe(l);u.onObjectUpdate(h=>{let d=eE(h,e).params.getLiveValue(t)??o;l.set(d.r,d.g,d.b,d.a)}),n=u,s=o;break}case"vec4array":{let o=Array.isArray(r)?r:[];n=function(l,u,h){let d=new Map;return{element(c){let p=$me(u,c),f=d.get(p);if(f===void 0){let m=Fe(h[p]??new ct);m.onObjectUpdate(g=>(eE(g,l).params.getValue(u)??h)[p]??Q2e),f=m,d.set(p,f)}return f},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 f=c[p];Array.isArray(f)?h[p].set(f[0]??0,f[1]??0,f[2]??0,f[3]??1):f&&typeof f=="object"&&h[p].set(f.x??0,f.y??0,f.z??0,f.w??1)}}}}(e,t,o.length>0?o:[new ct]),s=o;break}case"floatArray":{let o=Array.isArray(r)?r:[0];n=function(l,u,h){let d=new Map;return{element(c){let p=$me(u,c),f=d.get(p);if(f===void 0){let m=Fe(h[p]??0);m.onObjectUpdate(g=>{let v=eE(g,l).params.getValue(u);return Number((v??h)[p]??0)}),f=m,d.set(p,f)}return f},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])}}}(e,t,o.length>0?o:[0]),s=o;break}}i!=="vec4array"&&i!=="floatArray"&&i!=="colorVec4"&&(yK(n),n.onObjectUpdate(o=>{let l=eE(o,e).params.getValue(t);l!==void 0&&_K(n,l)})),a.set(t,n,s),e.uniformKinds.set(t,i)}function FA(e,t){let i=e.data;i.type!=="displace"?("alpha"in i&&e.params.has("alpha")&&e.params.setValue("alpha",Oh(i.alpha,t)*(i.visible?1:0)),i.type==="outline"&&e.params.has("compensation")&&e.params.setValue("compensation",!!i.compensation&&!!i.visible)):e.params.has("intensity")&&e.params.setValue("intensity",(Lt(i.intensity,t)??1)*(i.visible?1:0))}function Y2e(e,t){_i(e,"alpha","float",t.alpha??1),_i(e,"mode","int",t.mode??0),_i(e,"isMask","float",t.isMask?1:0)}function K2e(e,t,i,r){let n=new tE(e,t,i),s=i;if(_i(n,"alpha","float",Oh(s.alpha,r)),_i(n,"mode","int",s.mode??0),_i(n,"bumpMapIntensity","float",s.bumpMapIntensity??5),_i(n,"alphaOverride","float",Oh(s.alphaOverride,r)),i.visible)if(s.category==="lambert")_i(n,"emissive","color",r.color(s.emissive)??ja(0)),_i(n,"occlusion","bool",s.occlusion??!0);else if(s.category==="toon")_i(n,"shininess","float",s.shininess??30),_i(n,"specular","color",r.color(s.specular)??ja(1118481));else if(s.category==="physical"){_i(n,"roughness","float",s.roughness??.3),_i(n,"metalness","float",s.metalness??0),_i(n,"reflectivity","float",s.reflectivity??.5),_i(n,"occlusion","bool",s.occlusion??!0),_i(n,"normalScale","float",s.normalScale??1),_i(n,"aoMapIntensity","float",s.aoMapIntensity??1),_i(n,"emissive","color",s.emissive!==void 0?r.color(s.emissive)??ja(0):ja(0)),_i(n,"emissiveIntensity","float",s.emissiveIntensity??1);let a=s;a.clearcoat!==void 0&&(_i(n,"clearcoat","float",a.clearcoat),_i(n,"clearcoatRoughness","float",a.clearcoatRoughness??.1)),a.sheen!==void 0&&(_i(n,"sheen","float",a.sheen),_i(n,"sheenColor","color",a.sheenColor!==void 0?r.color(a.sheenColor)??ja(16777215):ja(16777215)),_i(n,"sheenRoughness","float",a.sheenRoughness??.5)),a.ior!==void 0&&(_i(n,"ior","float",a.ior),_i(n,"specularIntensity","float",a.specularIntensity??1),_i(n,"specularColor","color",a.specularColor!==void 0?r.color(a.specularColor)??ja(16777215):ja(16777215))),a.iridescence!==void 0&&(_i(n,"iridescence","float",a.iridescence),_i(n,"iridescenceIOR","float",a.iridescenceIOR??1.3),_i(n,"iridescenceThickness","float",a.iridescenceThickness??400))}else _i(n,"shininess","float",s.shininess??30),_i(n,"specular","color",s.specular!==void 0?r.color(s.specular)??ja(1118481):ja(1118481)),_i(n,"occlusion","bool",s.occlusion??!0);return n.node.alphaOverride=n.params.get("alphaOverride"),FA(n,r),n}function Z2e(e,t,i,r){let n=new UA("fragment",e,t,i),s=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("");n.holders.push(s);let a=i.texture.wrapping??(i.type==="texture"?1e3:1001),o=function(u,h,d,c){let p=vt(u.getTexture(h,d,c));return p.onRenderUpdate(()=>u.getTexture(h,d,c)),p}(s,a,i.texture.minFilter??1008,i.texture.magFilter??1006);n.params.set("texture",o);let l=Lt(i.texture.rotation??0,r)??0;if(i.type==="matcap")_i(n,"rotation","float",l*ht.DEG2RAD);else{let u=Fe(new Z(1,1));u.onRenderUpdate(()=>{let m=s.getTexture(a,i.texture.minFilter??1008,i.texture.magFilter??1006).image;u.value.set(m?.width??1,m?.height??1)}),n.params.set("textureSize",u),n.uniformKinds.set("textureSize","vec2");let h=Fe(s.loaded||s.isBuffer?1:0);h.onRenderUpdate(()=>s.loaded||s.isBuffer?1:0),n.params.set("loaded",h),n.uniformKinds.set("loaded","float"),_i(n,"crop","float",i.crop?1:0),_i(n,"projection","int",i.projection??0),_i(n,"axis","axis",i.axis),_i(n,"projectionAxis","axis",i.projectionAxis),_i(n,"side","int",i.side??0);let d=i.size?new Z(Lt(i.size[0],r)??0,Lt(i.size[1],r)??0):new Z(100,100);_i(n,"size","vec2",d),_i(n,"blending","float",i.blending??0);let c=new oi,p=new J2e([Lt(i.texture.repeat?.[0]??1,r)??1,Lt(i.texture.repeat?.[1]??1,r)??1],[Lt(i.texture.offset?.[0]??0,r)??0,Lt(i.texture.offset?.[1]??0,r)??0],l,c),f=Fe(c);yK(f),f.onObjectUpdate(m=>{let g=eE(m,n).params.getNodeValue("mat");g!==void 0&&_K(f,g)}),n.params.set("mat",f,p)}return Y2e(n,{alpha:Oh(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),FA(n,r),n}function PFe(e,t,i,r){if(i.type==="light")return K2e(e,t,i,r);if(i.type==="texture"||i.type==="video"||i.type==="matcap")return Z2e(e,t,i,r);if(i.type==="displace")return function(o,l,u,h){if(u.displacementType!=="noise")throw new Error;let d=new UA("vertex",o,l,u),c=(p,f)=>Lt(p,h)??f;return _i(d,"offset","vec3",new R(...u.offset.map(p=>c(p,0)))),_i(d,"scale","float",c(u.scale,10)),_i(d,"intensity","float",c(u.intensity,8)),_i(d,"movement","float",c(u.movement,1)),_i(d,"noiseType","int",u.noiseType??0),_i(d,"voronoiStyle","int",u.voronoiStyle??0),_i(d,"smoothness","float",c(u.smoothness,.5)),_i(d,"seed","float",c(u.seed,0)),_i(d,"highCut","float",c(u.highCut,1)),_i(d,"lowCut","float",c(u.lowCut,0)),_i(d,"quality","int",Lt(u.quality,h)??1),FA(d,h),d}(e,t,i,r);let n=new UA("fragment",e,t,i),s=il(i,r),a=d$[i.type]??d$.color;for(let[o,l]of Object.entries(a))_i(n,o,l.kind,s[o]??l.def());if(i.type==="transmission"){let o=typeof window<"u"?window.innerWidth:1,l=typeof window<"u"?window.innerHeight:1;_i(n,"aspectRatio","vec2",o>=l?new Z(l/o,1):new Z(1,o/l))}return Y2e(n,s),FA(n,r),n}var Xme,D9,d$,Q2e,J2e,UA,tE,Yme,_g,wK,RFe=U(()=>{oe(),vn(),Cd(),IB(),bi(),jt(),cB(),rl(),Ed(),bu(),oB(),da(),p2e(),dK(),m2e(),dFe(),X2e(),yB(),CFe(),Xme=e=>e,D9=e=>e,d$={color:{color:{kind:"color",def:()=>ja(eo)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>ja(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:()=>ja(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 R},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new R}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>ja(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:Hme},steps:{kind:"floatArray",def:qme},source:{kind:"vec3",def:()=>new R},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new zr(0,0,0,0)},offset:{kind:"vec3",def:()=>new R}},outline:{outlineColor:{kind:"color",def:()=>ja(16777215)},contourColor:{kind:"color",def:()=>ja(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 R(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 R},direction:{kind:"vec3",def:()=>new R(1,0,0)},colors:{kind:"vec4array",def:()=>[new ct(0,0,0,1),new ct(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new R(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new Z(1.7,9.2)},fB:{kind:"vec2",def:()=>new Z(8.3,2.8)},distortion:{kind:"vec2",def:()=>new Z(1,1)},colorA:{kind:"colorVec4",def:()=>new zr(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new zr(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new zr(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new zr(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 R(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:Hme},steps:{kind:"floatArray",def:qme},offset:{kind:"vec2",def:()=>new Z},morph:{kind:"vec2",def:()=>new Z},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 Z},colorA:{kind:"colorVec4",def:()=>new zr(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new zr(1,1,1,1)},frequency:{kind:"vec2",def:()=>new Z(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 Z(0,1)},horizontal:{kind:"vec2",def:()=>new Z(0,1)},sides:{kind:"int",def:()=>6}}},Q2e=new ct,J2e=class{constructor(e,t,i,r){this.repeat=e,this.offset=t,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 oi().makeRotation(this.rotation*ht.DEG2RAD))}},UA=class{constructor(e,t,i,r){this.kind=e,this.id=t,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new bK(t)}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(e){return this.params.has(e)}setValue(e,t){if(e==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof t=="number"&&t!==0&&this.onNoiseMismatch!==void 0){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(e,t),void(i(t)&&(this.noiseCompiledIn=!0))}this.params.setValue(e,t)}getNode(e){return this.params.has(e)?this.params.get(e):void 0}getValue(e){return this.params.getValue(e)}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(e=>e.loaded)}dispose(){for(let e of this.holders)e instanceof Rc||e.deref();this.holders.length=0}},tE=class extends UA{constructor(e,t,i){super("light",e,t,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},Yme={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"]}]},_g=class extends ei{constructor(e,t,i=!0,r,n=!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=cd.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=n,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(e,t),IA.add(this),this.addEventListener("dispose",()=>function(s){IA.delete(s)}(this))}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let e=this._structuralKey;if(e===null||this._structuralKeyVersion!==this.version){try{e=function(r){let n=r.lightLayer,s=n.data,a=u=>{if(!u)return-1;if(typeof u!="string"){let c=r.syntheticMapLayers?.get(u);return c!==void 0?`img(${Wme(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=${s.visible===!0}`,`lidx=${r.layers.indexOf(n)}`,`bump=${a(s.bumpMap)}`,`rough=${o?a(s.roughnessMap):-1}`,`metal=${o?a(s.metalnessMap):-1}`,`nrm=${o?a(s.normalMap):-1}`,`ao=${o?a(s.aoMap):-1}`,`emis=${o?a(s.emissiveMap):-1}`,`rch=${o?s.roughnessMapChannel??"luminance":""}`,`mch=${o?s.metalnessMapChannel??"b":""}`,`ach=${o?s.aoMapChannel??"r":""}`];for(let u of r.layers)l.push(Wme(u));return l.join("|")}(this),this.shapeBlendOptions!==null&&(e+=`|sb:${this.uuid}:${this._shapeBlendResources!==null?1:0}`)}catch{e=super.customProgramCacheKey()}this._structuralKey=e,this._structuralKeyVersion=this.version}let t=this.envNode instanceof hw?cd.version:0,i=this.physicalLobes();return`${e}|env${t}|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 e=ATe({transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.shapeBlendOptions!==null,data:this.root.data});this.depthPrepass=e,this.depthWrite=!e}getDepthPrepassTwin(e){let t=this.depthPrepassTwins[e];if(t===void 0){let i=this.root;t=new _g(i.data,i.lastContext,i.allowVariableSaves,i,!0),t.flatShading=this.flatShading,t.side=e,t.wireframe=!1,t.depthPrepassCutoff=eY,t.applyDepthPrepassPolicy(),this.depthPrepassTwins[e]=t,i.depthTwins.push(t)}return t}get vertexObjectNormal(){return this.shapeBlendObjectNormal??this.root.displacedObjectNormal}get category(){return this.lightLayer.category}envReflectiveInLow(){let e=!1;for(let t of this.layers){let i=t.data;if(i?.category==="physical"&&(e=!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!e}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(e,t,i=!1){(this.data!==e||i)&&this.reset0(e,t)}reset0(e,t){this.lastContext=t,this.data=e;let i=e.layers??ns.defaultTwoLayerData("phong").layers;for(let s of this.layers)s.dispose();for(let s of this.syntheticMapLayers.values())s.dispose();this.syntheticMapLayers.clear();let r=[];for(let s of i)try{let a=PFe(this.layerIdGen++,s.id,s.data,t.shared);a.type==="rainbow"&&this.armRainbowNoiseSpecialization(a),r.push(a)}catch(a){console.warn(`[spe] material layer '${s.data.type}' (${s.id}) failed to build \u2014 skipping this layer`,a)}this.layers=r,this.layers.reverse();for(let s=0;s<this.layers.length;s++)this.layers[s].structIndex=s;this.name=e.name??"Untitled Material";let n=this.layers.find(s=>s instanceof tE);if(n===void 0&&(n=K2e(0,"",{...hs.defaultData("light","phong"),visible:!1},t.shared)),this.lightLayer=n,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:B(0).toVar("accumAlpha"),lightsAvailable:this.lights&&(this.category==="phong"||this.category==="lambert"||this.category==="physical")},this.colorNode=Xe(()=>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 s=this.lightLayer.params,a=this.lightLayer.lightData;if(s.has("emissive")){let l=this.findTextureMapLayer(a.emissiveMap);this.emissiveNode=Xe(()=>{let u=J(s.getColor("emissive")).mul(s.getFloat("emissiveIntensity"));return l!==null&&(u=u.mul(function(h){let d,c=h.get("texture"),p=h.has("loaded")?h.getFloat("loaded"):B(1),{uvs:f,weights:m}=kE(h);if(m!==null){let g=J(To(c.sample(f[0])).rgb).toVar(),v=J(To(c.sample(f[1])).rgb).toVar(),y=J(To(c.sample(f[2])).rgb).toVar();d=hn(g.mul(m.z).add(v.mul(m.x)).add(y.mul(m.y)))}else d=hn(J(To(c.sample(f[0])).rgb));return hn(ut(J(0),d,p))}(l.params))),u})()}let o=this.findTextureMapLayer(a.aoMap);o!==null&&(this.aoNode=Xe(()=>ut(B(1),w9(o.params,a.aoMapChannel??"r"),s.getFloat("aoMapIntensity")))())}this.transparent=Sd(e,t.shared),this.applyDepthPrepassPolicy(),zE(this),this.needsUpdate=!0;for(let s of this.flavors)s?.syncFromRoot();for(let s of this.depthTwins)s.syncFromRoot();this.saveVariableLocations(t)}setTransparent(e,t){if(!this.isRoot)return void this.root.setTransparent(e,t);let i=this.transparent!==e;if(i){this.transparent=e,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=e,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=e,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||t?.markNeedsUpdateRendererDirty()}syncFromRoot(){let e=this.root;this.data=e.data,this.layers=e.layers,this.lightLayer=e.lightLayer,this.ctx=e.ctx,this.name=e.name,this.lights=e.lights,this.colorNode=e.colorNode,this.positionNode=e.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=e.emissiveNode,this.aoNode=e.aoNode,this.transparent=e.transparent,this.applyDepthPrepassPolicy(),this._applyShapeBlendGraph(),zE(this),this.needsUpdate=!0}getFlavor(e,t,i,r){if(!this.isRoot)return this.root.getFlavor(e,t,i,r);let n=i?6:(e?3:0)+t;if(n+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),n===0)return this;n-=1;let s=this.flavors[n];return s===void 0&&(s=new _g(this.data,this.lastContext,this.allowVariableSaves,this),s.flatShading=e,s.side=t,s.wireframe=i,r&&(s.shapeBlendOptions={...r},s.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},s._invalidateStructuralKey()),s.applyDepthPrepassPolicy(),this.flavors[n]=s),s}getShapeBlendBaseColor(){let e=this.layers.find(r=>r.kind==="fragment"&&r.type==="color"),t=e?.getValue("color"),i=e?.getValue("alpha");return{r:t?.r??1,g:t?.g??1,b:t?.b??1,a:i??1}}setShapeBlendResources(e){this._shapeBlendResources=e,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources||$L===null)return;let e=$L(this._shapeBlendResources);this.positionNode=e.position,this.shapeBlendObjectNormal=e.normal,this.normalNode=this.buildNormalNode(vq(n4(e.normal))),this.castShadowPositionNode=e.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=e.color,this.colorNode=Xe(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(e=>e instanceof tE)}findTextureMapLayer(e){if(!e)return null;if(typeof e!="string")return vA.is(e)?this.syntheticMapLayer(e):null;let t=this.layers.find(i=>i.uuid===e);return t===void 0||t.kind!=="fragment"?null:t.type==="texture"||t.type==="video"?t:null}syntheticMapLayer(e){if(!this.isRoot)return this.root.syntheticMapLayer(e);let t=this.syntheticMapLayers.get(e);if(t!==void 0)return t;try{let i=hs.defaultData("texture"),r={...i,visible:!1,texture:{...i.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}},n=Z2e(this.layerIdGen++,`mapImage${this.layerIdGen}`,r,this.lastContext.shared);return this.syntheticMapLayers.set(e,n),n}catch(i){return console.warn("[spe] light-layer map image failed to build \u2014 skipped",i),null}}buildNormalNode(e){if(this.lights&&this.category==="physical"&&!this.wireframe){let n=this.lightLayer.lightData,s=this.findTextureMapLayer(n.normalMap);if(s!==null){let a=this.lightLayer.params.getFloat("normalScale");return Xe(()=>function(o,l,u){let h=J(u??Ao).toVar(),d=hn($f),c=o.get("texture"),p=o.has("loaded")?o.getFloat("loaded"):B(1),f=v=>{let y=Me(v).toVar(),_=J(To(c.sample(y)).rgb.mul(2).sub(1)).toVar(),b=J(ut(J(0,0,1),hn(_),p)).toVar();b.xy.mulAssign(l);let x=J(rw(d)).toVar(),w=J(nw(d)).toVar(),S=Me(rw(y)).toVar(),T=Me(nw(y)).toVar(),M=J(Ut(hn(h))).toVar(),E=J(qn(hn(w),M)).toVar(),A=J(qn(M,hn(x))).toVar(),P=J(hn(E).mul(S.x).add(hn(A).mul(T.x))).toVar(),N=J(hn(E).mul(S.y).add(hn(A).mul(T.y))).toVar(),D=B(mt(et(hn(P),hn(P)),et(hn(N),hn(N)))).toVar(),O=B(Ki(D.equal(0),B(0),Uc(AB).mul(nK(D)))).toVar();return hn(Ut(hn(P).mul(b.x.mul(O)).add(hn(N).mul(b.y.mul(O))).add(M.mul(b.z))))},{uvs:m,weights:g}=kE(o);if(g!==null){let v=f(m[0]),y=f(m[1]),_=f(m[2]);return hn(Ut(v.mul(g.z).add(y.mul(g.x)).add(_.mul(g.y))))}return f(m[0])}(s.params,a,e))()}}let t=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&this.category!=="lambert";if(t===null||!i||this.wireframe)return e;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return Xe(()=>function(n,s,a){let o=J(a??Ao).toVar(),l=hn($f),u=n.get("texture"),{uvs:h,weights:d}=kE(n);if(d!==null){let c=eN(l,hn(o),JD(u,h[0],s)),p=eN(l,hn(o),JD(u,h[1],s)),f=eN(l,hn(o),JD(u,h[2],s));return hn(Ut(c.mul(d.z).add(p.mul(d.x)).add(f.mul(d.y))))}return eN(l,hn(o),JD(u,h[0],s))}(t.params,r,e))()}buildVertexStack(){let e=this.layers.filter(i=>i.kind==="vertex");if(e.length===0)return this.positionNode=null,void(this.displacedObjectNormal=null);let t=function(i){let r=Bn("vec3","vDisplacedNormal");return{position:Xe(n=>{let s=gl(ow),a=gl(aK);for(let l=0;l<i.length;l++){let u=uFe(i[l],gl(ow),a);s=l===0?u.position:gl(s.add(u.position).mul(.5)),a=u.normal}let o=J(s).toVar();return r.assign(a),n.needsPreviousData?.()===!0&&DB.assign(o),o})(),normal:r}}(e.map(i=>i.params));this.positionNode=t.position,this.displacedObjectNormal=t.normal}displacedNormalView(){let e=this.root.displacedObjectNormal;return e===null?null:vq(n4(e))}maskSourceFor(e){let t=this.layers[e];if(t.kind==="fragment"&&t.isMaskEnabled)return null;let i=this.layers[e+1];return i!==void 0&&i.kind==="fragment"&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(e,t,i){let r=B(1);t!==null&&(r=this.evaluateMask(t));let n={alpha:i?.alpha??e.alphaNode,isMask:e.isMaskNode,mask:r,mode:e.modeNode,noiseCompiledIn:e.noiseCompiledIn},s=l2e(e.type)(e.params,n,this.ctx);return i?.color?{...s,color:i.color}:s}evaluateMask(e){let t=this.runLayerBuilder(e,null);return CB(t.color.mul(t.calpha))}buildColorStack(){let e=this.lightLayerIndex(),t=e===-1?0:e,i=null;for(let r=0;r<t;r++){let n=this.layers[r];if(n.kind!=="fragment")continue;if(i===null){let a=this._shapeBlendColorNode;i=D9(this.runLayerBuilder(n,this.maskSourceFor(r),a?{color:D9(a.rgb),alpha:Xme(a.w)}:void 0).color);continue}if(n.isMaskEnabled)continue;let s=this.runLayerBuilder(n,this.maskSourceFor(r));i=gO(i,s.color,s.calpha,n.modeNode)}return i??MSe(eo)}setup(e){e.context.setupClearcoatNormal=()=>hTe(Ao,"NORMAL","vec3"),super.setup(e)}setupLightingModel(){let e=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(t,i=null,r=null,n=!1){switch(t){case"physical":{let s=new c2e(r?.clearcoat===!0,r?.sheen===!0,r?.iridescence===!0,!1,!1,!1);return s.envIrradianceActive=n,s}case"lambert":return new Nx(!1);case"toon":{let s=new d2e;return s.aoOcclusionGate=i,s}default:return new Nx}}(this.category,e,this.physicalLobes(),this.envNode instanceof hw)}physicalLobes(){let e=this.lightLayer.params;return{clearcoat:e.has("clearcoat"),sheen:e.has("sheen"),iridescence:e.has("iridescence")}}setupVariants(e){if(!this.lights)return;let t=null,i=null;if(this.category==="physical"){let r=this.lightLayer.lightData,n=this.findTextureMapLayer(r.roughnessMap);n!==null&&(t=Xe(()=>w9(n.params,r.roughnessMapChannel??"luminance"))());let s=this.findTextureMapLayer(r.metalnessMap);s!==null&&(i=Xe(()=>w9(s.params,r.metalnessMapChannel??"b"))())}(function(r,n,s=null,a=null){if(r==="phong"||r==="toon")r4.assign(n.getFloat("shininess").max(1e-4)),nx.assign(n.getColor("specular"));else if(r==="physical"){let o=n.getFloat("metalness"),l=n.getFloat("roughness"),u=n.getFloat("reflectivity");if(s!==null&&(l=uw(s.mul(l))),a!==null&&(o=uw(Xt(a.mul(o),B(0),B(1)))),zSe.assign(o),hK.assign(Xt(l,B(.0525),B(1))),n.has("ior")){let h=n.getFloat("ior"),d=n.has("specularColor")?J(n.getColor("specularColor")):J(1),c=n.has("specularIntensity")?n.getFloat("specularIntensity"):B(1);rO.assign(h),nx.assign(Fi(tTe(rO.sub(1).div(rO.add(1))).mul(d),J(1)).mul(c)),o$.assign(ut(pl(nx),pl(Wl.rgb),o)),yq.assign(ut(c,B(1),o))}else{let h=J(u.pow(2).mul(.16));nx.assign(h),o$.assign(ut(h,pl(Wl.rgb),o)),yq.assign(B(1))}if(a$.assign(pl(Wl.rgb).mul(Pn(o))),n.has("clearcoat")&&(SSe.assign(n.getFloat("clearcoat")),iK.assign(Xt(n.getFloat("clearcoatRoughness"),B(.0525),B(1)))),n.has("sheen")){let h=n.has("sheenColor")?J(n.getColor("sheenColor")):J(1);aTe.assign(h.mul(n.getFloat("sheen"))),oTe.assign(Xt(n.getFloat("sheenRoughness"),B(.07),B(1)))}n.has("iridescence")&&(NSe.assign(n.getFloat("iridescence")),ISe.assign(n.getFloat("iridescenceIOR")),OSe.assign(n.getFloat("iridescenceThickness")))}})(this.category,this.lightLayer.params,t,i)}setupLighting(e){let t=this.lights===!0||this.lightsNode!==null,i=this.lights===!0?this.setupMaterialLightings(e):[],r=t?this.lightsNode??e.lightsNode:null,n=this.lights===!0?J(0):Wl.rgb,s=J(0),a=J(0);if(r&&(i.length>0||r.getScope().hasLights)){let o=this.setupLightingModel()||null,l=BSe(r,o,i,this.backdropNode,this.backdropAlphaNode),u=l,h=u._value??(u._value=u.getContext());s=h.reflectedLight.directSpecular,a=h.reflectedLight.indirectSpecular,n=l}return this.emissiveNode!==null&&this.emissiveNode!==void 0&&(mq.assign(J(this.emissiveNode)),n=n.add(mq)),Xe(()=>this.applyPostLighting(n,s,a))()}applyPostLighting(e,t,i){let r,n=this.ctx.accumAlpha,s=this.lights===!0,a=this.lightLayerIndex(),o=a===-1?0:a+1,l=B(1);if(s){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p)),r=function(f){let{outgoing:m,directSpecular:g,indirectSpecular:v,shadingAlpha:y,shadingBlend:_,mask:b,occlusion:x=null,ctx:w}=f,S=J(m).toVar();return Ve(eK(oK(S,pl(Wl.rgb))),()=>{let T=Xt(Yi(g.add(v)),B(0),B(1));w.accumAlpha.addAssign(Pn(w.accumAlpha).mul(y).mul(b).mul(T)),S.assign(gO(pl(Wl.rgb),S,y.mul(b),_)),S.mulAssign(u2e(x))}),S}({outgoing:e,directSpecular:t,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=J(e).toVar();let u=r,h=!1;for(let p=o;p<this.layers.length;p++){let f=this.layers[p];if(f.kind!=="fragment"||f.isMaskEnabled)continue;let m=this.runLayerBuilder(f,this.maskSourceFor(p));u=gO(u,m.color,m.calpha,f.modeNode),h=!0}if(h&&r.assign(u),!s){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"):B(1),c=s?n:n.mul(l);if(Wl.a.assign(c.mul(d)),Wl.a.lessThanEqual(USe("depthPrepassCutoff","float")).discard(),this.dithering){let p=lK(Qo.xy),f=J(.25/255,-.25/255,.25/255),m=ut(f.mul(2),f.mul(-2),p);r.assign(r.add(m))}return r}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}armRainbowNoiseSpecialization(e){let t=this.root.forceRainbowNoise.has(e.uuid),i=e.data;if(e.noiseForced=t,e.noiseCompiledIn=t||Gf(i.noiseStrength),e.noiseCompiledIn===!1){let r=e.uuid;e.onNoiseMismatch=n=>this.root.ensureRainbowNoiseCompiled(r,n)}}ensureRainbowNoiseCompiled(e,t){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(e,t);let i=this.data.layers?.data(e);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(e)&&!Gf(i.noiseStrength)||this.getLayerByUuid(e)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(e),this.reset0(this.data,this.lastContext),t!==void 0&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}updateByOp(e,t,i){if(this.isRoot)if(t!==void 0?this.data=t:t=this.data,this.setTransparent(Sd(t,i.shared),i.scene),e.path[0]==="layers"){let r=e.path[1];if(r===void 0)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(t,i);e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===r);if(!n)return;let s=t.layers.data(r);if(!s)return;this.updateLayerByOp(n,{...e,path:e.path.slice(2)},s,i)?this.reset0(t,i):zE(this)}else this.reset0(t,i);else this.root.updateByOp(e,t,i)}static hasVariableString(e){return typeof e=="string"||Array.isArray(e)&&e.some(t=>typeof t=="string")}updateLayerTextureByOp(e,t,i){if(t.path.length!==1||t.type!==0)return!0;let r=t.props,n=i.texture;if(!n)return!0;let s=e.data.texture;for(let o of Object.keys(r))if(o!=="repeat"&&o!=="offset"&&o!=="rotation"||_g.hasVariableString(n[o])||_g.hasVariableString(s?.[o]))return!0;if(e.type==="matcap")return"repeat"in r||"offset"in r||(e.data=i,e.setValue("rotation",(n.rotation??0)*ht.DEG2RAD),!1);let a=e.getValue("mat");if(!a)return!0;if(e.data=i,"repeat"in r){let o=n.repeat;a.repeat=[o?.[0]??1,o?.[1]??1]}if("offset"in r){let o=n.offset;a.offset=[o?.[0]??0,o?.[1]??0]}return"rotation"in r&&(a.rotation=n.rotation??0),a.updateMatrix(),!1}updateLayerByOp(e,t,i,r){if(t.path[0]==="texture")return this.updateLayerTextureByOp(e,t,i);if(t.path[0]!==void 0||t.type!==0)return!0;let n=t.props;if("type"in n||"category"in n||"visible"in n||"noiseType"in n)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let s of Object.keys(n)){if(s==="isMask")return!0;if(e.type==="rainbow"&&s==="noiseStrength"&&e.noiseCompiledIn!==void 0){let h=i[s];if((e.noiseForced===!0||Gf(h))!==e.noiseCompiledIn)return!0}let a=xw[e.type];if(a!==void 0&&a.includes(s))return!0;let o=SY[e.type];if(o!==void 0&&o.includes(s)){let h=e.getValue(s),d=n[s];if(Array.isArray(h)&&Array.isArray(d)&&h.length!==d.length)return!0}let l=i[s],u=e.data[s];if(s!=="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}e.data=i;for(let s of Object.keys(n))this.applyLayerValue(e,s,i,r.shared);return!1}applyLayerValue(e,t,i,r){let n=i;if((t==="alpha"||t==="visible"||t==="intensity")&&(FA(e,r),t!=="intensity"||e.type==="displace"))return;if(t==="alphaOverride"&&e instanceof tE)return void e.setValue("alphaOverride",Oh(n[t],r));if(!e.hasValue(t))return;let s=e.uniformKinds.get(t),a=n[t];switch(s){case"color":case"colorVec4":{let o=e.getValue(t),l=typeof a=="string"?r.color(a):u$(a,()=>o??new zr(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=e.getValue(t);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y));break}case"vec3":{let o=e.getValue(t);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=e.getValue(t);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=e.getValue(t);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":e.setValue(t,["x","y","z"].indexOf(String(a)));break;case"bool":e.setValue(t,!!a);break;default:(typeof a=="number"||typeof a=="boolean")&&e.setValue(t,a)}}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")return this.setTransparent(Sd(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));if(e[0]!=="layer")return;let r=e[1],n=e[2];if(!r||!n)return;let s=this.layers.find(l=>l.uuid===r);if(!s?.hasValue(n))return;if(n==="alpha")return this.setTransparent(Sd(this.data,i.shared),i.scene),void s.setValue(n,Math.max(0,Math.min(Number(t)/100,1)));let a=s.getValue(n),o=e[3];(o==="x"||o==="y"||o==="z")&&a?.isVector3||(o==="x"||o==="y")&&a?.isVector2?a[o]=Number(t):a instanceof Ri||s.setValue(n,t)}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{let r=i.data;"alpha"in r&&typeof r.alpha=="string"&&e.shared.getVariable(r.alpha,["material",this.uuid,"layer",i.id,"alpha"]);let n=i.data.type==="displace"?r.displacementType==="noise"?"displace_noise":"displace_map":i.data.type,s=Yme[n];if(s)for(let a of s){let o=r;for(let l of a.path??[])l in o&&(o=o[l]);for(let l of a.nums)l in o&&e.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)=>{e.shared.getVariable(u,["material",this.uuid,"layer",i.id,...a.path??[],l,h===0?"x":h===1?"y":"z"])})}})}clampUniformsForPreview(e,t){let i=(r,n,s)=>Math.min(Math.max(r,n),s);for(let r of this.layers)if(r.type==="displace"){let n=r.uniforms[`f${r.id}_intensity`];n.value=i(n.value,e,t)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(e=>e.assetsLoaded))return!1;for(let e of this.root.syntheticMapLayers.values())if(!e.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let e of this.layers)e.dispose();for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let e of this.flavors)e?.dispose();for(let e of this.depthTwins)e.dispose()}},wK=class extends _g{constructor(e,t,i){super(e,t,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}}});function ru(e,t){let i=$i(e.xyz);return $i(t.add(qn(i,qn(i,t).add(t.mul(e.w))).mul(2)))}function j_(e){let t=Bx(e),i=Bx(J(e.y.sub(19.1),e.z.add(33.4),e.x.add(47.2))),r=Bx(J(e.z.add(74.2),e.x.sub(124.5),e.y.add(99.4)));return J(t,i,r)}function Kme(e,t){return eMe({p:e,seed:t})}function Zme(e,t,i){return J(vO($i(e.add(J(i)).mul(t))),vO($i(e.add(J(i.add(20))).mul(t))),vO($i(e.add(J(i.sub(30))).mul(t))))}function N9(e){return{f:(t,i=0)=>_h(e.node(t)??e.getUniform(t,i)),v3:t=>$i(e.node(t)??e.getUniform(t,null)),v4:t=>Vl(e.node(t)??e.getUniform(t,null)),tex:t=>e.node(t)??e.getTexture(t,null)}}function DFe(e,t){switch(e){case"position":return function(i){let r=N9(i.registry);return Xe(()=>{let n=tr(),s=i.depTexture("uCurrentPosition"),a=i.depTexture("uCurrentVelocity"),o=i.depTexture("uCurrentEmissionRate"),l=Vl(s.sample(n)).toVar(),u=$i(l.xyz).toVar(),h=Vl(o.sample(n)).toVar(),d=_h(h.x).toVar(),c=_h(h.y).toVar(),p=_h(h.z).toVar(),f=$i(Vl(r.tex("uOriginalPosition").sample(n)).xyz.mul(r.v3("uEmitterSize"))).toVar(),m=Vl(a.sample(n)).toVar(),g=$i(m.xyz).toVar(),v=_h(m.w).toVar(),y=r.f("uMaxLifeTime",1),_=hr(.5,v),b=B(3).mul(_),x=g.mul(B(1).add(b)),w=g.mul(Fi(r.f("uFPSRatio",1),B(5)));u.addAssign(ut(w,x,_));let S=ru(r.v4("uWorldQuaternion"),f).add(r.v3("uWorldOffset"));u.assign(ut(u,S,d)),p.assign(ut(p,r.f("uTime"),d));let T=mt(y.sub(r.f("uTime").sub(p)),B(0)).div(y);return ut(Pe(0),Pe(u,T),c)})()}(t);case"velocity":return function(i){let r=N9(i.registry),n=i.features;return Xe(()=>{let s=tr(),a=i.depTexture("uCurrentPosition"),o=i.depTexture("uCurrentVelocity"),l=i.depTexture("uCurrentEmissionRate"),u=$i(Vl(a.sample(s)).xyz).toVar(),h=$i(Vl(r.tex("uOriginalPosition").sample(s)).xyz).toVar(),d=$i(Vl(r.tex("uDirections").sample(s)).xyz).toVar(),c=$i(Vl(o.sample(s)).xyz).toVar(),p=Vl(l.sample(s)).toVar(),f=_h(p.x).toVar(),m=_h(p.y).toVar(),g=_h(Vl(o.sample(s)).w).toVar(),v=B(1).sub(r.f("uRandomMassFactor").mul(function(S){return _h(S.dot(Me(12.9898,78.233)).sin().mul(43758.5453).fract())}(function(S){return S.xy}(h)).mul(.5).add(.5))).toVar(),y=r.f("uSpeed",1),_=r.f("uNoiseStrength"),b=r.f("uNoiseScale"),x=r.f("uNoiseSeed");Ve(m.equal(1),()=>{n.USE_CURL_NOISE&&(Ve(b.greaterThan(0),()=>{c.assign(Kme($i(u.mul(b).mul(.002)),x).mul(_.add(1)).mul(.05).mul(y))}),Ve(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Kme(u,x).mul(_).mul(.05).mul(y))})),n.USE_SIMPLEX_NOISE&&(Ve(b.greaterThan(0),()=>{c.assign(J(Bx($i(u.mul(b).mul(.001))).mul(_.add(1)).mul(.1)).mul(y))}),Ve(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(J(Bx($i(u.mul(_).mul(.001))).mul(.05)).mul(y))})),n.USE_FBM_NOISE&&(Ve(b.greaterThan(0),()=>{c.assign(Zme($i(u.mul(b).mul(.001)),_.add(1),x).mul(y))}),Ve(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Zme($i(u.mul(_).mul(.001)),_.add(1),x).mul(.1).mul(y))})),function(S,T,M,E,A){if(!S.features.USE_COLLIDER)return;let P=mt(T.f("uBounce").mul(2),B(.01)).toVar(),N=T.f("particleSize");if(S.features.USE_SPHERE_COLLIDER){let D=T.v3("uColliderSize"),O=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))).toVar(),z=$i(O.div(D)).toVar(),L=Yi(z).toVar();Ve(L.lessThanEqual(B(1).add(N.div(Yi(D)))).and(A.equal(0)),()=>{let V=z.mul(B(1).add(N.div(Yi(D)))),G=Ut($i(V.div(D.mul(D))));G=ru(T.v4("uColliderQuaternion"),G),E.assign(DA(E,G).mul(P)),A.assign(1)}).Else(()=>{A.assign(0)})}if(S.features.USE_BOX_COLLIDER){let D=$i(T.v3("uColliderSize").div(2)),O=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))).toVar(),z=$i(ui(O).sub(D)).toVar(),L=mt(z.x,mt(z.y,z.z)).toVar();Ve(L.lessThanEqual(N.mul(.5)).and(A.equal(0)),()=>{let V=J(0).toVar();Ve(z.x.greaterThan(z.y).and(z.x.greaterThan(z.z)),()=>{V.assign(J(jc(O.x),0,0))}).ElseIf(z.y.greaterThan(z.z),()=>{V.assign(J(0,jc(O.y),0))}).Else(()=>{V.assign(J(0,0,jc(O.z)))});let G=ru(T.v4("uColliderQuaternion"),$i(V));E.assign(DA(E,G).mul(P)),A.assign(1)}).Else(()=>{A.assign(0)})}}(i,r,u,c,g),function(S,T,M,E){if(!S.features.USE_ATTRACTOR)return;let A=T.f("uForceIntensity"),P=T.f("uForceDamping");if(S.features.USE_FORCE_LOCAL_SPACE){let N,D,O=T.f("particleSize");if(S.features.USE_SPHERE_COLLIDER){let z=T.v3("uColliderSize"),L=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos"))));N=Yi($i(L.div(z))).toVar(),D=B(1)}else{let z=$i(T.v3("uColliderSize").div(2)),L=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))),V=$i(ui(L).sub(z));N=mt(V.x,mt(V.y,V.z)).toVar(),D=O}Ve(N.lessThanEqual(D),()=>{let z=S.features.USE_SPHERE_COLLIDER?B(1).sub(N).mul(A):mt(B(1).sub(D.div(N)),B(0)).mul(A),L=$i(M.sub(T.v3("uColliderPos"))),V=Ut(L).mul(z);E.subAssign(V),E.mulAssign(P)})}else{let N=$i(M.sub(T.v3("uColliderPos"))),D=Ut(N).mul(A);E.subAssign(D),E.mulAssign(P)}}(i,r,u,c),function(S,T,M,E,A,P,N){if(!S.features.USE_VORTEX)return;let D=T.f("particleSize"),O=$i(T.v3("uColliderSize").div(2)),z=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))).toVar(),L=$i(ui(z).sub(O)).toVar(),V=mt(L.x,mt(L.y,L.z)).toVar();Ve(V.lessThanEqual(D),()=>{let G=T.f("uForceIntensity"),Y=T.v3("uColliderPos").add(ru(T.v4("uColliderQuaternion"),J(0))),$=$i(Y.sub(M)).toVar(),Q=J(0,1,.01),ue=Ut(qn(Q,ru(T.v4("uColliderQuaternion"),$))).toVar(),pe=Yi($.mul(G).mul(3)).toVar();E.assign(ue.mul(pe).mul(.005));let xe=ru(T.v4("uWorldQuaternion"),A);E.addAssign(xe.mul(N).mul(B(1).sub(T.f("uForceDamping"))).div(P.mul(.5)))})}(i,r,u,c,d,v,y)});let w=n.USE_NORMALS?d:r.v3("uDirectionsAxis");return c.assign(ut(c,ru(r.v4("uWorldQuaternion"),w).mul(y),f)),c.addAssign(r.v3("uGravity").div(v.mul(.5)).mul(B(1).sub(g))),Pe(c,g)})()}(t);case"emissionRate":return function(i){let r=N9(i.registry);return Xe(()=>{let n=tr(),s=i.depTexture("uCurrentEmissionRate"),a=_h(Vl(r.tex("uIndex").sample(n)).x).toVar(),o=Vl(s.sample(n)).toVar(),l=_h(o.y).toVar(),u=_h(o.z).toVar(),h=r.f("uLastIndexEmitted"),d=r.f("uParticlesToEmit"),c=hr(h,a),p=hr(a,h.add(d).sub(1)),f=c.mul(p);return u.assign(ut(u,r.f("uTime"),f)),Pe(f,ut(l,B(1),f),u,1)})()}(t)}}var _h,$i,Vl,eMe,Qme,Jme,I9,tMe,NFe=U(()=>{bi(),eC(),_h=e=>e,$i=e=>e,Vl=e=>e,eMe=Xe(e=>{let t=$i(e.p.add(e.seed)).toVar(),i=J(.1,0,0),r=J(0,.1,0),n=J(0,0,.1),s=j_($i(t.sub(i))).toVar(),a=j_($i(t.add(i))).toVar(),o=j_($i(t.sub(r))).toVar(),l=j_($i(t.add(r))).toVar(),u=j_($i(t.sub(n))).toVar(),h=j_($i(t.add(n))).toVar(),d=l.z.sub(o.z).sub(h.y).add(u.y),c=h.x.sub(u.x).sub(a.z).add(s.z),p=a.y.sub(s.y).sub(l.x).add(o.x);return Ut(J(d,c,p).mul(5))})}),IFe=U(()=>{oe(),vn(),bi(),NFe(),Qme=class{constructor(){this.nodes=new Map,this.textureNodes=new Map}getUniform(e,t){let i=this.nodes.get(e);return i||(i=Fe(t),this.nodes.set(e,i)),i}getTexture(e,t){let i=this.textureNodes.get(e);return i||(i=vt(t??new Ri),this.textureNodes.set(e,i)),i}node(e){return this.nodes.get(e)??this.textureNodes.get(e)}adopt(e){for(let t of Object.keys(e)){let i=e[t].value;if(i instanceof Ri||i&&typeof i=="object"&&i.isTexture){let r=this.getTexture(t,i);r.value=i,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(n){r.value=n}}})}else{let r=this.getUniform(t,i);r.value=i,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(n){r.value=n}}})}}}},Jme=class{constructor(e,t,i,r){this.name=e,this.kind=t,this.initialTexture=i,this.currentIndex=0,this.registry=new Qme,this.depTextureNodes=new Map,this.dependencies=[],this.nodeMaterial=null,this._uniformsStore={};let n=()=>new Ui(r,r,{type:Wt,minFilter:yt,magFilter:yt,wrapS:vr,wrapT:vr,depthBuffer:!1});this.renderTargets=[n(),n()],this.material=Object.defineProperty({},"uniforms",{get:()=>this._uniformsStore,set:s=>{this.registry.adopt(s),this._uniformsStore=s}})}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()}},I9=new Cn,tMe=class{constructor(e,t,i,r){this.sizeX=e,this.sizeY=t,this.renderer=i,this.features=r,this.variables=[],this._copyMaterial=null,this._copyTextureNode=vt(new Ri)}addVariable(e,t,i){let r=new Jme(e,e==="uCurrentPosition"?"position":e==="uCurrentVelocity"?"velocity":"emissionRate",i,this.sizeX);return this.variables.push(r),r}setVariableDependencies(e,t){e.dependencies=t;for(let i of t)e.depTextureNodes.has(i.name)||e.depTextureNodes.set(i.name,vt(i.currentRenderTarget.texture))}init(){if(!this._copyMaterial){let e=new ei;e.name="WebGPUComputation.copy",e.fragmentNode=Pe(this._copyTextureNode),e.depthTest=!1,e.depthWrite=!1,e.blending=Di,this._copyMaterial=e}for(let e of this.variables){this._copyTextureNode.value=e.initialTexture;for(let i of e.renderTargets)this._renderQuad(this._copyMaterial,i);let t=new ei;t.name=`WebGPUComputation.${e.kind}`,t.fragmentNode=DFe(e.kind,{features:this.features,registry:e.registry,depTexture:i=>{let r=e.depTextureNodes.get(i);if(!r)throw new Error(`WebGPUComputationRenderer: variable "${e.name}" reads undeclared dependency "${i}"`);return r},resolution:new Z(this.sizeX,this.sizeY)}),t.depthTest=!1,t.depthWrite=!1,t.blending=Di,t.needsUpdate=!0,e.nodeMaterial=t}}compute(){for(let e of this.variables)if(e.nodeMaterial){for(let t of e.dependencies)e.depTextureNodes.get(t.name).value=t.currentRenderTarget.texture;this._renderQuad(e.nodeMaterial,e.nextRenderTarget)}for(let e of this.variables)e.advance()}getCurrentRenderTarget(e){return e.currentRenderTarget}_renderQuad(e,t){let i=this.renderer,r=i.getRenderTarget(),n=i.getMRT();i.setMRT(null),i.setRenderTarget(t),I9.material=e,I9.render(i),i.setRenderTarget(r),i.setMRT(n)}dispose(){for(let e of this.variables)e.dispose();this._copyMaterial?.dispose()}}});function ege(e,t){switch(e){case"linearFadeOut":return xh(B(1).sub(t));case"linearInOut":return xh(t.lessThan(.5).select(t,B(1).sub(t)));case"exponentialInOut":return xh(t.lessThan(.4).select(t.div(.4),t.greaterThan(.6).select(B(1).sub(t.sub(.6).div(.4)),B(1))));case"constant":return B(1);default:return t}}function tge(e){return xh(e.dot(Me(12.9898,78.233)).sin().mul(43758.5453).fract())}var xh,iMe,OFe=U(()=>{oe(),vn(),bi(),xh=e=>e,iMe=class extends ei{constructor(e,t){super(),this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this._uniformsStore={},this._uPosition=vt(new Ri),this._uTexture=vt(new Ri),this._uColor=Fe(new ct(1,1,1,1)),this._uColor2=Fe(new ct(1,1,1,1)),this._uSize=Fe(1),this._uSizeEnd=Fe(1),this._uWorldOffset=Fe(new R),this._uWorldQuaternion=Fe(new ct(0,0,0,1)),this._uRotation=Fe(0),this._uRotationEnd=Fe(0),this._center=Fe(new Z(.5,.5)),this._uRandScaleFactor=Fe(0),this._uRandRotationFactor=Fe(0),this.context=t,this.name="WebGPUParticleMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.lights=!1;let i=s=>({get value(){return s.value},set value(a){s.value=a}}),r=s=>({get value(){return s.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,s.value)}}),n=s=>({get value(){return s.value},set value(a){a&&a.isTexture&&(s.value=a)}});this._binders={uPosition:n(this._uPosition),uTexture:n(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(e),this._rebuildGraph()}get uniforms(){return this._uniformsStore}set uniforms(e){for(let t of Object.keys(e)){let i=this._binders[t];if(!i)continue;let r=e[t]?.value;Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i}),r!==void 0&&(i.value=r)}this._uniformsStore=e}updateState(e){let t=!1;if(e.coloring!==void 0){let i=e.coloring==="random";t||(t=i!==this.isColoringRandom),this.isColoringRandom=i}if(e.color!==void 0&&(this.uniforms.uColor.value=Array.isArray(e.color)?e.color:this.context.shared.color(e.color)),e.color2!==void 0&&(this.uniforms.uColor2.value=Array.isArray(e.color2)?e.color2:this.context.shared.color(e.color2)),e.size!==void 0){this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1];let i=e.size[0]!==e.size[1];t||(t=i!==this.useSizeEnd),this.useSizeEnd=i}e.ease!==void 0&&e.ease!==this.easeOpacity&&(this.easeOpacity=e.ease,t=!0),e.easeSize!==void 0&&e.easeSize!==this.easeSize&&(this.easeSize=e.easeSize,t=!0),t&&this._rebuildGraph(),this.needsUpdate=!0}_rebuildGraph(){let e=$g("particleRef","vec2"),t=this._uPosition,i=Xe(()=>{let n=t.sample(e).toVar(),s=xh(n.w).toVar(),a=n.xyz.sub(this._uWorldOffset);a=function(M,E){let A=M.xyz;return E.add(A.cross(A.cross(E).add(E.mul(M.w))).mul(2))}(this._uWorldQuaternion,a);let o=$g("position","vec3"),l=B(1).sub(s),u=this.useSizeEnd?o.mul(J(ut(this._uSize,this._uSizeEnd,l))):o.mul(J(xh(this._uSize).mul(ege(this.easeSize,l)))),h=PB,d=h.element(0).xyz.length(),c=h.element(1).xyz.length(),p=tge(e).toVar(),f=B(1).sub(xh(this._uRandScaleFactor).mul(p)),m=Me(d,c).mul(f).toVar(),g=2*Math.PI,v=p.mul(xh(this._uRandRotationFactor)).mul(g),y=B(1).sub(xh(this._uRotation)).mul(g),_=B(1).sub(xh(this._uRotationEnd)).mul(g),b=ut(y.add(v),_.add(v),s).toVar(),x=this._center,w=u.xy.sub(x.sub(Me(.5))).mul(m).toVar(),S=Me(Yo(b).mul(w.x).sub(Pa(b).mul(w.y)),Pa(b).mul(w.x).add(Yo(b).mul(w.y))).toVar(),T=GSe.mul(Pe(a,1)).toVar();return T.xy.addAssign(S),Mw.mul(T)}),r=Xe(()=>{let n=t.sample(e),s=xh(n.w).toVar();s.lessThanEqual(.005).discard();let a=B(1).sub(s),o=this.isColoringRandom?tge(e):a,l=ut(this._uColor,this._uColor2,o).toVar(),u=ege(this.easeOpacity,a).toVar(),h=this._uTexture.sample(tr()).toVar();return Pe(h.rgb.mul(l.rgb),xh(l.a).mul(h.a).mul(u))});this.vertexNode=i(),this.colorNode=r(),this.needsUpdate=!0}nodeMaterialDispose(){this.dispose()}}}),LFe=U(()=>{OY(),IFe(),OFe(),IY={createComputation:(e,t,i,r)=>new tMe(e,t,i,r),createMaterial:(e,t)=>new iMe(e,t)}});function rMe(e,t){return(i,r,n,s)=>{let a=n.mod(t).add(i.add(.5).div(e)).div(t),o=Ct(n.div(t)).add(r.add(.5).div(e)).div(t);return ax(s.sample(Me(a,o)))}}function ige(e){let t=Cr(ln(e.x).mul(65535).add(.5)),i=t.bitAnd(Cr(255)).toFloat().mul(.00392156862),r=t.shiftRight(Cr(8)).bitAnd(Cr(255)).toFloat().mul(.00392156862);return Pe(r,i,e.y,e.z)}function nMe(e){let{levelShiftX:t,scale:i,originOffset:r}=function(m){switch(m){case 5:return{levelShiftX:[4,6,12,24,48,96,192],scale:8*iE,originOffset:16};case 7:return{levelShiftX:[4,6,12,24,48,96,192,384,768,1536],scale:2*iE,originOffset:64};case 8:return{levelShiftX:[4,8,16,32,64,128,256,512,1024,2048,4096],scale:iE,originOffset:128};default:return{levelShiftX:[4,8,16,32,64,128,256,512],scale:4*iE,originOffset:32}}}(e.resolutionLevel),n=e.pyramidLevelSizes.length,s=n%2==0?n-3:n-2,a=n%2==0,o=Math.pow(2,e.resolutionLevel),l=e.pyramidLevelSizes[n-1]/o,u=rMe(o,l),h=e.pyramid1Size.width,d=e.pyramid1Size.height,c=e.pyramid2Size.width,p=e.pyramid2Size.height,f=NA(SK.map(([m,g,v])=>new R(m,g,v)));return m=>{let g=J(0).toVar(),v=J(0,0,1).toVar(),y=Pe(0).toVar(),_=m.toVar(),b=Ct(_.div(3)).toVar(),x=(A,P)=>Me(ln(A.x).add(P).add(.5).div(h),ln(A.y).add(.5).div(d)),w=(A,P)=>Me(ln(A.x).add(P).add(.5).div(c),ln(A.y).add(.5).div(p)),S=h-2,T=c-1,M=Me(0,0).toVar(),E=ax(e.pyramid2.sample(w(yO(M),T))).toVar();return Ve(b.lessThan(ln(E.x)),()=>{let A=B(0).toVar(),P=re=>{let Se=ax(E.add(Pe(A))).toVar(),W=Pe(ef(Se.yzw),A),k=ax(Pe(Pe(b).greaterThanEqual(W)).mul(Pe(Pe(b).lessThan(Se)))).toVar();M.mulAssign(2),M.addAssign(Me(0,1).mul(ln(k.x)).add(Me(1,1).mul(ln(k.y))).add(Me(1,0).mul(ln(k.z)))),A.assign(k.dot(W)),re?.()};for(let re=0;re<s;){let Se=t[re];P(()=>{T-=Se,E.assign(e.pyramid1.sample(x(yO(M),S)))}),re++;let W=t[re];P(()=>{S-=W,E.assign(e.pyramid2.sample(w(yO(M),T)))}),re++}a&&P(null);let N=ln(M.x).mod(o).toVar(),D=ln(M.y).mod(o).toVar(),O=Ct(ln(M.x).div(o)).add(Ct(ln(M.y).div(o)).mul(l)).toVar(),z=_.sub(A.mul(3)).mul(.0625).add(.03125),L=u(N,D,O,e.voxel).toVar(),V=ln(L.w).add(.5).mul(.00390625),G=ln(ax(e.triTable.sample(Me(z,V))).x).mul(2).toInt().toVar(),Y=J(N,D,O).add(ef(f.element(G))).toVar(),$=J(N,D,O).add(ef(f.element(G.add(1)))).toVar(),Q=u(ln(Y.x),ln(Y.y),ln(Y.z),e.potential).toVar(),ue=u(ln($.x),ln($.y),ln($.z),e.potential).toVar(),pe=ln(Q.x).div(ln(Q.x).sub(ln(ue.x)));y.assign(ut(ige(ef(Q.yzw)),ige(ef(ue.yzw)),pe)),g.assign(Y.add($.sub(Y).mul(pe)).sub(J(r)).mul(i));let xe=u(ln(Y.x),ln(Y.y),ln(Y.z),e.voxel),we=u(ln($.x),ln($.y),ln($.z),e.voxel);v.assign(Ut(ut(ef(xe.xyz),ef(we.xyz),pe)))}),{position:g,normal:v,color:y}}}function rge(e,t){e.needsPreviousData?.()===!0&&DB.assign(t)}function BFe(e){if(e.cached)return function(n){let s=()=>n.drawIndex?n.drawIndex.element(UE):UE;return{position:Xe(a=>{let o=ef(n.positions.element(s()).xyz).toVar();return rge(a,o),o})(),normal:_q(n.normals.element(s()).xyz),color:_q(n.colors.element(s()))}}(e.cached);let t=nMe(e),i=Bn("vec3","vShapeBlendNormal"),r=Bn("vec4","vShapeBlendColor");return{position:Xe(n=>{let{position:s,normal:a,color:o}=t(UE.toFloat());return i.assign(a),r.assign(o),rge(n,s),s})(),normal:i,color:r}}var ln,yO,ef,ax,iE,SK,TK=U(()=>{oe(),bi(),ln=e=>e,yO=e=>e,ef=e=>e,ax=e=>e,iE=2,SK=[[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 sMe(e,t){let i=Mt(e.xyz);return Mt(t.add(i.cross(i.cross(t).add(t.mul(Ae(e.w)))).mul(2)))}function aMe(e,t,i,r){let n=Xt(e,-1,1),s=e.sub(n).mul(2).add(1),a=Xt(B(.5).add(n.mul(.5).mul(t.sub(n.mul(s).mul(i))).div(r)),0,1);return Ae(ut(t,n.mul(s).mul(i),a).sub(n.mul(r).mul(a).mul(B(1).sub(a))))}function oMe(e,t,i,r,n){let s=B(0).toVar(),a=Ae(i.y),o=Ae(i.z),l=Ae(i.w),u=Ve(e.lessThan(.5),()=>{s.assign(Yi(t).sub(a))}).ElseIf(e.lessThan(1.5),()=>{let d=J(a,o,l),c=Yi(t.div(d)),p=Yi(t.div(d.mul(d)));s.assign(c.mul(c.sub(1)).div(p))}).ElseIf(e.lessThan(2.5),()=>{let d=J(a,o,l),c=ui(t).sub(d).toVar();s.assign(Yi(mt(c,J(0))).add(Fi(mt(Ae(c.x),mt(Ae(c.y),Ae(c.z))),0)))}).ElseIf(e.lessThan(3.5),()=>{let d=ui(Me(Yi(_O(t.xz)),Ae(t.y))).sub(Me(o,a)).toVar();s.assign(Fi(mt(Ae(d.x),Ae(d.y)),0).add(Yi(mt(d,Me(0)))))}).ElseIf(e.lessThan(4.5),()=>{let d=a,c=o,p=l,f=Me(Yi(_O(t.xz)),Ae(t.y)).toVar(),m=Me(p,d),g=Me(p.sub(c),d.mul(2)),v=Me(Ae(f.x).sub(Fi(Ae(f.x),Ae(f.y).lessThan(0).select(c,p))),ui(Ae(f.y)).sub(d)).toVar(),y=f.sub(m).add(g.mul(Xt(et(m.sub(f),g).div(et(g,g)),0,1))).toVar(),_=Ae(y.x).lessThan(0).and(Ae(v.y).lessThan(0)).select(B(-1),B(1));s.assign(_.mul(Rh(Fi(et(v,v),et(y,y)))))}).ElseIf(e.lessThan(5.5),()=>{let d=Me(Yi(_O(t.xy)).sub(a),Ae(t.z));s.assign(Yi(d).sub(o))}),h=()=>{let d=ui(Ae(t.x)).toVar(),c=Me(a,o),p=l,f=Ae(r.w),m=Ae(c.y).mul(d).greaterThan(Ae(c.x).mul(Ae(t.y))).select(et(Me(d,Ae(t.y)),c),Yi(Me(d,Ae(t.y)))),g=J(d,Ae(t.y),Ae(t.z));s.assign(Rh(et(g,g).add(p.mul(p)).sub(p.mul(m).mul(2))).sub(f))};return n?u.ElseIf(e.lessThan(6.5),h).Else(()=>{s.assign(n(t,i,r))}):u.Else(h),s}function c$(e,t=!0){let i=e.spatialDivisions,r=e.spatialn;return(n,s)=>{let a=t?Pe(0).toVar():Pe(0),o=B(1e3).toVar(),l=t?B(0).toVar():B(0),u=t?B(0).toVar():B(0),h=Ae(s.y).add(Ae(s.z).mul(i)).add(.5).div(i*i),d=(f,m)=>{let g=m.toVar();Zr(Hb,({i:v})=>{Ve(g.lessThan(1),()=>{Ya()}),g.mulAssign(.5),Ve(gr(g).greaterThanEqual(.5),()=>{let y=B(v).add(f).add(.5).mul(1/m4),_=e.shapeRow(y,0).toVar(),b=e.shapeRow(y,1).toVar(),x=e.shapeRow(y,2).toVar(),w=e.shapeRow(y,3).toVar(),S=sMe(wo(b),Mt(n.sub(Mt(_.xyz)))).div(Ae(w.z)).toVar(),T=oMe(Ae(x.x),Mt(S),wo(x),wo(w),e.meshSdf).sub(Ae(w.y)).mul(Ae(w.z)).toVar(),M=Ae(w.x).toVar(),E=Ae(_.w);if(o.assign(aMe(E,o,T,M)),t){let A=hr(-1.5,E).mul(hr(E,-.5)),P=Qr(u,0,T.negate()),N=ut(B(1),P,A);a.mulAssign(N),l.mulAssign(N),u.assign(mt(u,M)),M.addAssign(e.colorKBump);let D=e.shapeRow(y,4).toVar(),O=Qr(M,0,T).mul(Ae(D.a).greaterThanEqual(0).toFloat()).toVar();l.addAssign(O),a.addAssign(D.mul(O))}})})},c=f=>{let m=f.mul(4*Hb).toVar(),g=wo(e.spatialTex.sample(Me(Ae(s.x).mul(r).add(f).add(.5).div(r*i),h))).toVar();d(Ae(m),Ae(g.x)),d(Ae(m.add(Hb)),Ae(g.y)),d(Ae(m.add(2*Hb)),Ae(g.z)),d(Ae(m.add(3*Hb)),Ae(g.w))};r===1?c(B(0)):Zr(r,({i:f})=>{c(B(f).toVar())}),t&&a.divAssign(l);let p=ut(o,B(0),hr(1e20,o)).toVar();return{sdf:Ae(p),color:wo(a),colorDivisor:Ae(l)}}}function nge(e){let t=e.resolution,i=t-1,r=e.colorResolution,n=e.capacity,s=t/4,a=s-1,o=Fe(e.bboxHalf),l=Fe(e.bboxOffset),u=Fe(1e30),h=Fe(new R(0,0,0)),d=Fe(new R(s,s,s)),c=e.env.spatialDivisions,p=B(e.buildSeq).mul(0),f=e.sparseStorage??null,m=f?f.poolBricks:0,g=f?Math.ceil(m/4096):0,v=f?.meshlet??null,y=v?v.drawIndex:null,_=v?Math.floor(n/24):0,b=v?v.vertexBlocks:0,x=(q,fe,Be,F)=>{let ne=new by(q,fe,Be);return ne.format=aa,ne.type=Wt,ne.minFilter=yt,ne.magFilter=yt,ne.name=F,ne},w=f?x(256,256,4*Math.max(g,1),"SplineShapeBlend.ultraSdfPool"):e.reuseTextures?.sdfTexture??x(t,t,t,"SplineShapeBlend.ultraSdf");w.format=aa,w.type=Wt,w.minFilter=yt,w.magFilter=yt;let S=e.reuseTextures?.colorTexture??new by(r,r,r);S.name="SplineShapeBlend.ultraColor";let T=e.reuseTextures?.coarseTexture??new by(s,s,s);T.format=aa,T.type=Wt,T.minFilter=yt,T.magFilter=yt,T.name="SplineShapeBlend.ultraCoarse";let M=$n(8,"uint").toAtomic(),E=(q=0)=>M.element(q),A=f?$n(v?12:4,"int").toAtomic():null,P=q=>A.element(q),N=f?$n(Math.max(m,1),"float"):null,D=s*s*s,O=f?$n(D*(v?4:1),"float"):null,z=q=>De(Ae(q.x).add(Ae(q.y).mul(s)).add(Ae(q.z).mul(s*s))),L=q=>O.element(z(q)),V=q=>O.element(z(q).add(De(D))),G=q=>O.element(z(q).add(De(2*D))),Y=q=>O.element(z(q).add(De(3*D))),$=q=>O.element(q.add(De(3*D))),Q=f?$n(Math.max(m,1),"float"):null,ue=v?$n(3*Math.max(_,1),"float"):null,pe=q=>ue.element(q),xe=q=>pe(De(q)),we=q=>pe(De(q.add(_))),re=q=>pe(q.add(De(2*_))),Se=v?$n(Math.max(b,1),"float"):null,W=q=>Se.element(q),k=v?$n(24*Math.max(_,1),"uint"):null,K=q=>k.element(q),ie=v?Fe(0):null,j=v?Fe(new Ue):null,ae=v?Fe(2):null,se=NA(Array.from(e.numTrisTable)),H=NA(SK.map(([q,fe,Be])=>new R(q,fe,Be))),me=c$(e.env,!1),be=c$(e.env),ke=(q,fe)=>Mt(q.div(fe).mul(2).sub(1)),Te=(q,fe)=>Mt(q.div(fe).mul(c-1).floor()),Ze=Xe(()=>{for(let q=0;q<8;q++)kl(E(q),Cr(0))})(),ze=Xe(()=>{Ve(De(Sa).greaterThanEqual(De(n)),()=>{bn()}),e.buffers.positions.element(De(Sa)).assign(Pe(0))})(),qe=v?Xe(()=>{Ve(De(Sa).greaterThanEqual(De(n)),()=>{bn()}),y.element(De(Sa)).assign(Cr(p))})():null,Ne=Ef(T),ee=q=>Ae(wo(Ne.load(Ha(Xt(q,J(0),J(a))))).x),Ce=q=>Ae(L(Mt(Xt(q,J(0),J(a))))),He=(q,fe)=>{let Be=mt(q,0),F=Ct(Be.div(4096)),ne=Be.sub(F.mul(4096)),Ee=Ct(ne.div(64)),Ie=ne.sub(Ee.mul(64));return Mt(J(Ie,Ee,F).mul(4).add(fe))},pt=Xe(()=>{let q=J(cl).add(h).toVar();Ve(Ae(q.x).greaterThan(a).or(Ae(q.y).greaterThan(a)).or(Ae(q.z).greaterThan(a)),()=>{bn()});let fe=Mt(q.mul(4).add(J(1.5))),Be=(F=>{let ne=B(1e3).toVar();return Zr(m4,({i:Ee})=>{Ve(B(Ee).greaterThanEqual(Ae(e.npart)),()=>{Ya()});let Ie=B(Ee).add(.5).mul(1/m4),_e=e.env.shapeRow(Ie,0).toVar(),ye=e.env.shapeRow(Ie,1).toVar(),Ge=e.env.shapeRow(Ie,2).toVar(),at=e.env.shapeRow(Ie,3).toVar(),bt=sMe(wo(ye),Mt(F.sub(Mt(_e.xyz)))).div(Ae(at.z)).toVar(),Bt=oMe(Ae(Ge.x),Mt(bt),wo(Ge),wo(at),e.env.meshSdf).sub(Ae(at.y)).mul(Ae(at.z)).toVar();ne.assign(aMe(Ae(_e.w),ne,Bt,Ae(at.x)))}),Ae(ne)})(ke(fe,i));vg(T,Ha(q),Pe(Ae(Be.add(p)),0,0,0)).toStack()})(),tt=q=>{Ve(Ae(q.x).greaterThan(a).or(Ae(q.y).greaterThan(a)).or(Ae(q.z).greaterThan(a)),()=>{bn()})},Yt=f?Xe(()=>{let q=J(cl).toVar();tt(Mt(q)),L(Mt(q)).assign(Ae(B(-1).add(p))),v&&(V(Mt(q)).assign(Ae(B(-1).add(p))),G(Mt(q)).assign(Ae(B(-1).add(p))))})():null,ni=f?Xe(()=>{let q=J(cl).add(h).toVar();tt(Mt(q));let fe=ee(Mt(q)).toVar(),Be=Ce(Mt(q)).toVar();Ve(ui(fe).greaterThan(u).and(Be.greaterThan(-.5)),()=>{let F=yh(P(1),De(1)).toVar();N.element(F).assign(Be),L(Mt(q)).assign(Ae(B(-1).add(p)))})})():null,ar=f?Xe(()=>{let q=J(cl).add(h).toVar();tt(Mt(q));let fe=ee(Mt(q)).toVar(),Be=Ce(Mt(q)).toVar();Ve(ui(fe).lessThanEqual(u).and(Be.lessThan(-.5)),()=>{let F=B(-1).toVar(),ne=iO(P(1),De(1)).toVar();Ve(ne.greaterThanEqual(1),()=>{F.assign(Ae(N.element(ne.sub(1))))}).Else(()=>{yh(P(1),De(1));let Ee=yh(P(0),De(1)).toVar();Ve(Ee.lessThan(De(m)),()=>{F.assign(Ee.toFloat())}).Else(()=>{kl(P(2),De(1))})}),Ve(F.greaterThan(-.5),()=>{Q.element(De(F)).assign((Ee=>Ae(Ae(Ee.x).add(Ae(Ee.y).mul(256)).add(Ae(Ee.z).mul(65536))))(Mt(q))),L(Mt(q)).assign(Ae(F.add(p)))})})})():null,St=f?Xe(()=>{let q=Fv(P(0)).toVar(),fe=Fv(P(2)).toVar();if(kl(E(1),Cr(q)),kl(E(2),Cr(fe)),kl(P(2),De(0)),v){let Be=Fv(P(3)).toVar(),F=Fv(P(5)).toVar();kl(E(4),Cr(Be)),kl(E(5),Cr(F)),kl(P(5),De(0));let ne=Fv(P(6)).toVar(),Ee=Fv(P(8)).toVar();kl(E(6),Cr(ne)),kl(E(7),Cr(Ee)),kl(P(8),De(0))}})():null,Nt=v?Xe(()=>{let q=J(cl).toVar();Ve(Ae(q.x).greaterThanEqual(Ae(d.x)).or(Ae(q.y).greaterThanEqual(Ae(d.y))).or(Ae(q.z).greaterThanEqual(Ae(d.z))),()=>{bn()});let fe=Mt(q.add(h)).toVar();tt(Mt(fe));let Be=Ae(G(Mt(fe))).toVar();Ve(Be.greaterThan(-.5),()=>{let ne=yh(P(7),De(1)).toVar();W(ne).assign(Be),G(Mt(fe)).assign(Ae(B(-1).add(p)))});let F=Ae(V(Mt(fe))).toVar();Ve(F.lessThan(-.5),()=>{bn()}),V(Mt(fe)).assign(Ae(B(-1).add(p))),Zr(48,()=>{Ve(F.lessThan(-.5),()=>{Ya()});let ne=yh(P(4),De(1)).toVar();re(ne).assign(F),F.assign(Ae(xe(F)))})})():null,Qt=v?Xe(()=>{let q=J(cl).add(h).toVar();tt(Mt(q));let fe=B(0).toVar();Ve(Ce(Mt(q)).greaterThan(-.5),()=>{let Be=Mt(q.mul(4)).toVar(),F=Ml.map(([_e,ye,Ge])=>qr(Mt(J(Ae(Be.x).add(4*_e),Ae(Be.y).add(4*ye),Ae(Be.z).add(4*Ge)))).toVar()),ne=F[0];for(let _e=1;_e<8;_e++)ne=ne.add(F[_e]);let Ee=Ut(ne).toVar(),Ie=et(F[0],Ee);for(let _e=1;_e<8;_e++)Ie=Fi(Ie,et(F[_e],Ee));Ve(Ae(Ie).greaterThan(Ae(ae)),()=>{fe.assign(B(1))})}),Y(Mt(q)).assign(Ae(fe.add(p)))})():null,Ei=Math.min(4096,Math.max(m,1)),xi=()=>{let q=J(cl).toVar(),fe=Ct(Ae(q.x).mul(.25)).toVar(),Be=Ct(Ae(q.y).mul(.25)).toVar(),F=Be.mul(Ei).add(fe).toVar(),ne=J(Ae(q.x).sub(fe.mul(4)),Ae(q.y).sub(Be.mul(4)),Ae(q.z)).toVar();return{slot:Ae(F),local:Mt(ne)}},mi=q=>(fe=>{let Be=Ct(fe.div(65536)),F=fe.sub(Be.mul(65536)),ne=Ct(F.div(256)),Ee=F.sub(ne.mul(256));return Mt(J(Ee,ne,Be))})(Ae(Q.element(De(q)))),Ai=f?Xe(()=>{let q=J(cl).add(h.mul(4)).toVar(),fe=Mt(q.mul(.25).floor()).toVar(),Be=Ce(fe).toVar();Ve(Be.lessThan(-.5),()=>{bn()});let{sdf:F}=me(ke(Mt(q),i),Te(Mt(q),i));vg(w,Ha(He(Be,Mt(q.sub(fe.mul(4))))),Pe(Ae(F.add(p)),0,0,0)).toStack()})():null,Or=f?Xe(()=>{let{slot:q,local:fe}=xi();Ve(q.greaterThanEqual(m),()=>{bn()});let Be=mi(q).toVar();Ve(Ce(Mt(Be)).notEqual(q),()=>{bn()});let F=Mt(Be.mul(4).add(fe)).toVar(),{sdf:ne}=me(ke(Mt(F),i),Te(Mt(F),i));vg(w,Ha(He(q,Mt(fe))),Pe(Ae(ne.add(p)),0,0,0)).toStack()})():Xe(()=>{let q=J(cl).add(h.mul(4)).toVar(),fe=ee(Mt(q.mul(.25).floor())).toVar();Ve(ui(fe).greaterThan(u),()=>{vg(w,Ha(q),Pe(Ae(fe.add(p)),0,0,0)).toStack(),bn()});let{sdf:Be}=me(ke(Mt(q),i),Te(Mt(q),i));vg(w,Ha(q),Pe(Ae(Be.add(p)),0,0,0)).toStack()})(),Hr=Xe(()=>{let q=J(cl).add(h.mul(2)).toVar();Ve(Ae(q.x).greaterThan(r-1).or(Ae(q.y).greaterThan(r-1)).or(Ae(q.z).greaterThan(r-1)),()=>{bn()}),Ve(ui(ee(Mt(q.mul(.5).floor()))).greaterThan(u),()=>{bn()});let{color:fe,colorDivisor:Be}=be(ke(Mt(q),r-1),Te(Mt(q),r-1)),F=wo(Be.greaterThan(0).select(fe,Pe(0)));vg(S,Ha(q),Xt(wo(F.add(p)),Pe(0),Pe(1))).toStack()})(),ir=Ef(w),Zi=f?(q,fe,Be)=>{let F=Xt(J(q,fe,Be),J(0),J(i)),ne=F.mul(.25).floor(),Ee=Ce(Mt(ne)),Ie=Ae(wo(ir.load(Ha(He(Ee,Mt(F.sub(ne.mul(4))))))).x);return Ae(Ee.lessThan(-.5).select(ee(Mt(ne)),Ie))}:(q,fe,Be)=>Ae(wo(ir.load(Ha(Xt(J(q,fe,Be),J(0),J(i))))).x),qr=q=>{let fe=Ae(q.x),Be=Ae(q.y),F=Ae(q.z),ne=Zi(fe.add(1),Be,F).sub(Zi(fe.sub(1),Be,F)),Ee=Zi(fe,Be.add(1),F).sub(Zi(fe,Be.sub(1),F)),Ie=Zi(fe,Be,F.add(1)).sub(Zi(fe,Be,F.sub(1))),_e=ne.equal(0).and(Ee.equal(0)).and(Ie.equal(0));return Mt(_e.select(J(.199,.299,.399),Ut(J(ne,Ee,Ie))))},Oe=(q,fe,Be)=>{let F=((Ie,_e,ye)=>{let Ge=(at,bt,Bt,Jt)=>Zi(Ie.add(at),_e.add(bt),ye.add(Bt)).lessThan(0).toFloat().mul(Jt);return Ge(0,0,0,1).add(Ge(1,0,0,2)).add(Ge(0,1,0,8)).add(Ge(1,1,0,4)).add(Ge(0,0,1,16)).add(Ge(1,0,1,32)).add(Ge(0,1,1,128)).add(Ge(1,1,1,64))})(q,fe,Be).toVar(),ne=Ae(se.element(De(F))).toVar();Ve(ne.lessThan(.5),()=>{bn()});let Ee=yh(E(),Cr(ne)).toVar();Ve(B(Ee).add(ne).mul(3).lessThanEqual(n),()=>{let Ie=Ae(F).add(.5).mul(.00390625);Zr(5,({i:_e})=>{Ve(B(_e).greaterThanEqual(ne),()=>{Ya()});let ye=B(_e).toVar();Zr(3,({i:Ge})=>{let at=B(Ge).toVar();((bt,Bt,Jt,li,Ht,ki)=>{let ur=Ht.mul(.0625).add(.03125),Ci=Ae(wo(e.triTable.sample(Me(ur,li))).x).mul(2).toInt().toVar(),Si=J(bt,Bt,Jt).add(Mt(H.element(Ci))).toVar(),Vt=J(bt,Bt,Jt).add(Mt(H.element(Ci.add(1)))).toVar(),rr=Zi(Ae(Si.x),Ae(Si.y),Ae(Si.z)).toVar(),br=Zi(Ae(Vt.x),Ae(Vt.y),Ae(Vt.z)).toVar(),Dt=rr.div(rr.sub(br)).toVar(),qt=Si.add(Vt.sub(Si).mul(Dt)).toVar(),en=Mt(qt.div(i).mul(2).sub(1)).toVar(),zs=en.mul(o).add(J(l)),tn=Ut(ut(qr(Mt(Si)),qr(Mt(Vt)),Dt)),Kn=en.add(1).mul(.5),xr=wo(Ef(S,Kn,De(0))),In=ki.toVar();e.buffers.positions.element(In).assign(Pe(zs,1)),e.buffers.normals.element(In).assign(Pe(tn,0)),e.buffers.colors.element(In).assign(xr)})(q,fe,Be,Ie,ye.mul(3).add(at),De(Ee).add(De(ye)).mul(3).add(De(at)))})})})},eh=f?Xe(()=>{let{slot:q,local:fe}=xi();Ve(q.greaterThanEqual(m),()=>{bn()});let Be=mi(q).toVar();Ve(Ce(Mt(Be)).notEqual(q),()=>{bn()});let F=Ae(Be.x).mul(4).add(Ae(fe.x)).toVar(),ne=Ae(Be.y).mul(4).add(Ae(fe.y)).toVar(),Ee=Ae(Be.z).mul(4).add(Ae(fe.z)).toVar();Ve(F.greaterThanEqual(i).or(ne.greaterThanEqual(i)).or(Ee.greaterThanEqual(i)),()=>{bn()}),Oe(F,ne,Ee)})():Xe(()=>{let q=Ae(J(cl).x).toVar(),fe=Ae(J(cl).y).toVar(),Be=Ae(J(cl).z).toVar();Ve(q.greaterThanEqual(i).or(fe.greaterThanEqual(i)).or(Be.greaterThanEqual(i)),()=>{bn()}),Ve(ui(ee(Mt(J(q,fe,Be).mul(.25).floor()))).greaterThan(u),()=>{bn()}),Oe(q,fe,Be)})(),Rd=()=>{let q=J(oO).toVar(),fe=Ae(q.y).mul(Ei).add(Ae(q.x)).toVar(),Be=J(0).toVar(),F=B(0).toVar();return Ve(fe.lessThan(m),()=>{Be.assign(mi(fe)),Ve(Ce(Mt(Be)).equal(fe),()=>{F.assign(B(1))})}),{brick:Mt(Be),valid:Ae(F)}},wi=()=>{let q=J(oO).add(h).toVar(),fe=B(0).toVar();return Ve(Ae(q.x).lessThanEqual(a).and(Ae(q.y).lessThanEqual(a)).and(Ae(q.z).lessThanEqual(a)),()=>{Ve(Ce(Mt(q)).greaterThan(-.5),()=>{fe.assign(B(1))})}),{brick:Mt(q),valid:Ae(fe)}},Ml=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],Kc=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Dd=q=>Xe(()=>{let fe=hg("float",64),Be=hg("float",1),F=J(nO).toVar(),ne=De(Ae(F.x).add(Ae(F.y).mul(4)).add(Ae(F.z).mul(16))).toVar(),{brick:Ee,valid:Ie}=q(),_e=Ae(Y(Mt(Ee))).toVar(),ye=B(1).add(_e).toVar(),Ge=_e.greaterThan(.5),at=Ge.and(Ae(F.x).lessThan(2).and(Ae(F.y).lessThan(2)).and(Ae(F.z).lessThan(2))).or(Ge.not()),bt=Ae(Ee.x).mul(4).add(Ae(F.x).mul(ye)).toVar(),Bt=Ae(Ee.y).mul(4).add(Ae(F.y).mul(ye)).toVar(),Jt=Ae(Ee.z).mul(4).add(Ae(F.z).mul(ye)).toVar(),li=Ml.map(([Vt,rr,br])=>Zi(bt.add(ye.mul(Vt)),Bt.add(ye.mul(rr)),Jt.add(ye.mul(br))).toVar()),Ht=li[0].lessThan(0).toFloat();for(let Vt=1;Vt<8;Vt++)Ht=Ht.add(li[Vt].lessThan(0).toFloat());let ki=Ht.toVar(),ur=B(0).toVar();Ve(Ie.greaterThan(.5).and(at).and(bt.add(ye).lessThanEqual(i)).and(Bt.add(ye).lessThanEqual(i)).and(Jt.add(ye).lessThanEqual(i)).and(ki.greaterThan(.5)).and(ki.lessThan(7.5)),()=>{ur.assign(B(1))}),fe.element(ne).assign(ur.add(p)),Vb(),Ve(ne.equal(De(0)).and(Ie.greaterThan(.5)),()=>{let Vt=B(0).toVar();Zr(64,({i:br})=>{Vt.addAssign(Ae(fe.element(br)))});let rr=B(-1).toVar();Ve(Vt.greaterThan(.5),()=>{let br=iO(P(7),De(1)).toVar();Ve(br.greaterThanEqual(1),()=>{rr.assign(Ae(W(br.sub(1))))}).Else(()=>{yh(P(7),De(1));let Dt=yh(P(6),De(1)).toVar();Ve(Dt.lessThan(De(b)),()=>{rr.assign(Dt.toFloat())}).Else(()=>{kl(P(8),De(1))})}),Ve(rr.greaterThan(-.5),()=>{G(Mt(Ee)).assign(Ae(rr.add(p)))})}),Be.element(De(0)).assign(rr)}),Vb();let Ci=Ae(Be.element(De(0))).toVar(),Si=ur.greaterThan(.5).or(Ge.and(at).and(Ie.greaterThan(.5)).and(bt.add(ye).lessThanEqual(i)).and(Bt.add(ye).lessThanEqual(i)).and(Jt.add(ye).lessThanEqual(i)));Ve(Si.and(Ci.greaterThan(-.5)),()=>{let Vt=J(0).toVar(),rr=B(0).toVar();for(let[pa,Uh]of Kc)Ve(li[pa].lessThan(0).toFloat().notEqual(li[Uh].lessThan(0).toFloat()),()=>{let o0=li[pa].div(li[pa].sub(li[Uh])),[Jf,_1,Ni]=Ml[pa],[Su,Fw,Ld]=Ml[Uh];Vt.addAssign(J(Jf,_1,Ni).add(J(Su-Jf,Fw-_1,Ld-Ni).mul(o0)).mul(ye)),rr.addAssign(1)});let br=Mt(Vt.div(mt(rr,1))).toVar();Ve(rr.lessThan(.5),()=>{br.assign(J(ye.mul(.5)))});let Dt=J(bt,Bt,Jt).add(br).toVar(),qt=Mt(Dt.div(i).mul(2).sub(1)).toVar(),en=qt.mul(o).add(J(l)),zs=J(0).toVar(),tn=Mt(br.div(ye)).toVar();for(let pa=0;pa<8;pa++){let[Uh,o0,Jf]=Ml[pa],_1=Uh?Ae(tn.x):B(1).sub(Ae(tn.x)),Ni=o0?Ae(tn.y):B(1).sub(Ae(tn.y)),Su=Jf?Ae(tn.z):B(1).sub(Ae(tn.z));zs.addAssign(qr(Mt(J(bt.add(ye.mul(Uh)),Bt.add(ye.mul(o0)),Jt.add(ye.mul(Jf))))).mul(_1.mul(Ni).mul(Su)))}let Kn=Ut(zs),xr=qt.add(1).mul(.5),In=wo(Ef(S,xr,De(0))),xn=De(Ge.select(Ae(F.x).add(Ae(F.y).mul(2)).add(Ae(F.z).mul(4)),B(ne))).toVar(),Qs=De(Ci.mul(64)).add(xn).toVar();e.buffers.positions.element(Qs).assign(Pe(en,1)),e.buffers.normals.element(Qs).assign(Pe(Kn,0)),e.buffers.colors.element(Qs).assign(In)})})(),Nd=v?Dd(Rd):null,El=v?Dd(wi):null,ji=q=>Xe(()=>{let fe=hg("float",64),Be=hg("float",64),F=hg("float",48),ne=J(nO).toVar(),Ee=De(Ae(ne.x).add(Ae(ne.y).mul(4)).add(Ae(ne.z).mul(16))).toVar(),{brick:Ie,valid:_e}=q(),ye=Ae(Ie.x).mul(4).add(Ae(ne.x)).toVar(),Ge=Ae(Ie.y).mul(4).add(Ae(ne.y)).toVar(),at=Ae(Ie.z).mul(4).add(Ae(ne.z)).toVar(),bt=Zi(ye,Ge,at).lessThan(0).toFloat().toVar(),Bt=(Dt,qt,en)=>Ae($(De(Ct(Dt.mul(.25))).add(De(Ct(qt.mul(.25))).mul(s)).add(De(Ct(en.mul(.25))).mul(s*s)))),Jt=Dt=>Dt.mul(.5).fract().lessThan(.25),li=(Dt,qt)=>Dt.greaterThanEqual(qt).and(Dt.add(qt).lessThanEqual(i)),Ht=B(0).toVar(),ki=B(0).toVar(),ur=B(0).toVar(),Ci=B(1).toVar(),Si=B(1).toVar(),Vt=B(1).toVar(),rr=(Dt,qt,en,zs,tn,Kn,xr,In,xn)=>{let Qs=Bt(...xn[0]).add(Bt(...xn[1])).add(Bt(...xn[2])).add(Bt(...xn[3])).greaterThan(3.5).toVar(),pa=Zi(ye.add(en),Ge.add(zs),at.add(tn)).lessThan(0).toFloat(),Uh=Zi(ye.add(2*en),Ge.add(2*zs),at.add(2*tn)).lessThan(0).toFloat();Ve(_e.greaterThan(.5).and(Qs.not()).and(In.add(1).lessThanEqual(i)).and(li(Kn,B(1))).and(li(xr,B(1))).and(bt.notEqual(pa)),()=>{Dt.assign(B(1)),qt.assign(B(1))}),Ve(_e.greaterThan(.5).and(Qs).and(Jt(ye)).and(Jt(Ge)).and(Jt(at)).and(In.add(2).lessThanEqual(i)).and(li(Kn,B(2))).and(li(xr,B(2))).and(bt.notEqual(Uh)),()=>{Dt.assign(B(1)),qt.assign(B(2))})};rr(Ht,Ci,1,0,0,Ge,at,ye,[[ye,Ge.sub(1),at.sub(1)],[ye,Ge,at.sub(1)],[ye,Ge,at],[ye,Ge.sub(1),at]]),rr(ki,Si,0,1,0,at,ye,Ge,[[ye.sub(1),Ge,at.sub(1)],[ye.sub(1),Ge,at],[ye,Ge,at],[ye,Ge,at.sub(1)]]),rr(ur,Vt,0,0,1,ye,Ge,at,[[ye.sub(1),Ge.sub(1),at],[ye,Ge.sub(1),at],[ye,Ge,at],[ye.sub(1),Ge,at]]);let br=Ht.add(ki).add(ur).mul(2).toVar();fe.element(Ee).assign(br.add(p)),Vb(),Ve(Ee.equal(De(0)).and(_e.greaterThan(.5)),()=>{let Dt=B(0).toVar();Zr(64,({i:tn})=>{Be.element(tn).assign(Dt),Dt.addAssign(Ae(fe.element(tn)))}),yh(E(0),Cr(Dt));let qt=Ct(Dt.add(7).mul(1/8)).toVar(),en=B(-1).toVar(),zs=B(-1).toVar();Zr(48,({i:tn})=>{Ve(B(tn).greaterThanEqual(qt),()=>{Ya()});let Kn=B(tn).toVar(),xr=B(-1).toVar(),In=iO(P(4),De(1)).toVar();Ve(In.greaterThanEqual(1),()=>{xr.assign(Ae(re(In.sub(1))))}).Else(()=>{yh(P(4),De(1));let xn=yh(P(3),De(1)).toVar();Ve(xn.lessThan(De(_)),()=>{xr.assign(xn.toFloat())}).Else(()=>{kl(P(5),De(1))})}),F.element(De(Kn)).assign(xr),Ve(xr.greaterThan(-.5),()=>{we(xr).assign(Fi(Dt.sub(Kn.mul(8)),8)),xe(xr).assign(B(-1)),Ve(zs.greaterThan(-.5),()=>{xe(zs).assign(xr)}).Else(()=>{en.assign(xr)}),zs.assign(xr)})}),V(Mt(Ie)).assign(en)}),Vb(),Ve(br.greaterThan(.5),()=>{let Dt=(tn,Kn,xr)=>{let In=Ct(tn.mul(.25)),xn=Ct(Kn.mul(.25)),Qs=Ct(xr.mul(.25)),pa=De(In).add(De(xn).mul(s)).add(De(Qs).mul(s*s)),Uh=De(tn.sub(In.mul(4))).add(De(Kn.sub(xn.mul(4))).mul(4)).add(De(xr.sub(Qs.mul(4))).mul(16));return Cr(pa.mul(64).add(Uh))},qt=Ae(Be.element(Ee)).toVar(),en=(tn,Kn,xr)=>{let In=Ae(F.element(De(Ct(qt.mul(.125))))).toVar();Ve(In.greaterThan(-.5),()=>{let xn=qt.sub(Ct(qt.mul(.125)).mul(8)),Qs=De(In.mul(24).add(xn.mul(3))).toVar();K(Qs).assign(tn),K(Qs.add(De(1))).assign(Kn),K(Qs.add(De(2))).assign(xr)}),qt.addAssign(1)},zs=(tn,Kn)=>{Ve(tn.greaterThan(.5),()=>{let xr=Dt(...Kn[0]).toVar(),In=Dt(...Kn[1]).toVar(),xn=Dt(...Kn[2]).toVar(),Qs=Dt(...Kn[3]).toVar();Ve(bt.greaterThan(.5),()=>{en(xr,In,xn),en(xr,xn,Qs)}).Else(()=>{en(xr,Qs,xn),en(xr,xn,In)})})};zs(Ht,[[ye,Ge.sub(Ci),at.sub(Ci)],[ye,Ge,at.sub(Ci)],[ye,Ge,at],[ye,Ge.sub(Ci),at]]),zs(ki,[[ye.sub(Si),Ge,at.sub(Si)],[ye.sub(Si),Ge,at],[ye,Ge,at],[ye,Ge,at.sub(Si)]]),zs(ur,[[ye.sub(Vt),Ge.sub(Vt),at],[ye,Ge.sub(Vt),at],[ye,Ge,at],[ye.sub(Vt),Ge,at]])})})(),Id=v?ji(Rd):null,Od=v?ji(wi):null,Al=v?Xe(()=>{let q=hg("float",48),fe=hg("float",2),Be=J(nO).toVar(),F=De(Ae(Be.x).add(Ae(Be.y).mul(4)).add(Ae(Be.z).mul(16))).toVar(),ne=J(oO).toVar(),Ee=Ae(ne.y).mul(Ei).add(Ae(ne.x)).toVar();Ve(F.equal(De(0)),()=>{let Ge=B(0).toVar();Ve(Ee.lessThan(m),()=>{let bt=mi(Ee).toVar();Ve(Ce(Mt(bt)).equal(Ee),()=>{let Bt=B(0).toVar();Ve(Ae(ie).greaterThan(.5),()=>{let Jt=J(0).toVar(),li=J(0).toVar();for(let Ht=0;Ht<8;Ht++){let ki=Mt(bt.mul(4).add(J(4*(1&Ht),4*(Ht>>1&1),4*(Ht>>2&1)))),ur=Mt(ki.div(i).mul(2).sub(1)).mul(o).add(J(l)),Ci=j.mul(Pe(ur,1)).toVar(),Si=Ae(Ci.w);Jt.addAssign(J(Ae(Ci.x).lessThan(Si.negate()).toFloat(),Ae(Ci.y).lessThan(Si.negate()).toFloat(),Ae(Ci.z).lessThan(0).toFloat())),li.addAssign(J(Ae(Ci.x).greaterThan(Si).toFloat(),Ae(Ci.y).greaterThan(Si).toFloat(),Ae(Ci.z).greaterThan(Si).toFloat()))}Ve(mt(mt(Ae(Jt.x),mt(Ae(Jt.y),Ae(Jt.z))),mt(Ae(li.x),mt(Ae(li.y),Ae(li.z)))).greaterThan(7.5),()=>{Bt.assign(B(1))})}),Ve(Bt.lessThan(.5),()=>{let Jt=Ae(V(Mt(bt))).toVar();Zr(48,({i:li})=>{Ve(Jt.lessThan(-.5),()=>{Ya()}),q.element(li).assign(Jt),Ge.addAssign(Ae(we(Jt))),Jt.assign(Ae(xe(Jt)))})})})});let at=B(0).toVar();Ve(Ge.greaterThan(.5),()=>{let bt=yh(E(3),Cr(Ge.mul(3))).toVar();at.assign(B(bt))}),fe.element(De(0)).assign(at.add(p)),fe.element(De(1)).assign(Ge)}),Vb();let Ie=Ae(fe.element(De(1))).toVar(),_e=Ae(fe.element(De(0))).toVar(),ye=B(F).toVar();Zr(6,()=>{Ve(ye.greaterThanEqual(Ie),()=>{Ya()});let Ge=Ae(q.element(De(Ct(ye.mul(1/8))))).toVar(),at=ye.sub(Ct(ye.mul(1/8)).mul(8)),bt=De(Ge.mul(24).add(at.mul(3))).toVar(),Bt=De(_e.add(ye.mul(3))).toVar(),Jt=ur=>{let Ci=K(ur===0?bt:bt.add(De(ur))).toVar(),Si=De(Ci.shiftRight(Cr(6))).toVar(),Vt=De(Ci.bitAnd(Cr(63))).toVar(),rr=Ae((tn=>O.element(tn.add(De(2*D))))(Si)).toVar(),br=Ae($(Si)),Dt=Vt.bitAnd(De(3)),qt=Vt.shiftRight(De(2)).bitAnd(De(3)),en=Vt.shiftRight(De(4)).bitAnd(De(3)),zs=Dt.shiftRight(De(1)).add(qt.shiftRight(De(1)).mul(De(2))).add(en.shiftRight(De(1)).mul(De(4)));return{blockF:rr,li:De(br.greaterThan(.5).select(zs,Vt)).toVar()}},li=Jt(0),Ht=Jt(1),ki=Jt(2);Ve(li.blockF.greaterThan(-.5).and(Ht.blockF.greaterThan(-.5)).and(ki.blockF.greaterThan(-.5)),()=>{let ur=Ci=>Cr(De(Ci.blockF.mul(64)).add(Ci.li));y.element(Bt).assign(ur(li)),y.element(Bt.add(De(1))).assign(ur(Ht)),y.element(Bt.add(De(2))).assign(ur(ki))}).Else(()=>{y.element(Bt).assign(Cr(0)),y.element(Bt.add(De(1))).assign(Cr(0)),y.element(Bt.add(De(2))).assign(Cr(0))}),ye.addAssign(64)})})():null,As=Math.ceil(t/rE[0]),wu=Math.ceil(r/rE[0]),yn=Math.ceil(s/rE[0]),he=(q,fe)=>q.compute(fe,Array.isArray(fe)?rE:void 0),je=[Ei,Math.max(1,Math.ceil(m/Ei)),1];return{resolution:t,sparse:f!==null,poolBricks:m,meshlet:v!==null,vertexBlocks:b,needsInit:f!==null,sdfTexture:w,colorTexture:S,coarseTexture:T,counterAttribute:M.value,storageAttributes:[M,A,N,O,Q,ue,Se,k].filter(q=>q!==null).map(q=>q.value),uniforms:{bboxHalf:o,bboxOffset:l,activeThreshold:u,windowOrigin:h,...v?{windowSize:d,cullEnabled:ie,cullMVP:j,adaptCos:ae}:{}},kernels:{zero:he(Ze,1),clear:ze.compute([Math.ceil(n/256),1,1],[256,1,1]),coarse:he(pt,[yn,yn,yn]),...Yt?{init:he(Yt,[yn,yn,yn])}:{},...ni?{release:he(ni,[yn,yn,yn])}:{},...ar?{alloc:he(ar,[yn,yn,yn])}:{},...St?{stats:he(St,1)}:{},sdf:he(Or,f?je:[As,As,As]),...Ai?{sdfWindow:he(Ai,[As,As,As])}:{},color:he(Hr,[wu,wu,wu]),extract:v?he(Id,je):he(eh,f?je:[As,As,As]),...v?{clearDraw:qe.compute([Math.ceil(n/256),1,1],[256,1,1]),meshRelease:he(Nt,[yn,yn,yn]),verts:he(Nd,je),vertsWindow:he(El,[s,s,s]),extractWindow:he(Od,[s,s,s]),classify:he(Qt,[yn,yn,yn]),gather:he(Al,je)}:{}}}}var Ae,_O,Mt,wo,Hb,m4,rE,hg,FFe=U(()=>{oe(),vn(),bi(),jY(),TK(),Ae=e=>e,_O=e=>e,Mt=e=>e,wo=e=>e,Hb=24,m4=GY,rE=[4,4,4],hg=(e,t)=>mTe(e,t)});function UFe(e){let t=e.getAttribute("position");if(!t||t.count<3)return null;let i=e.getIndex(),r=Math.floor((i?i.count:t.count)/3);if(r===0)return null;let n=Math.max(1,Math.ceil(r/g4));n>1&&console.warn(`Spline shape blend: mesh child has ${r} triangles \u2014 baking every ${n}th (SDF detail reduced).`);let s=Math.floor(r/n),a=new Float32Array(12*s),o=new R(0,0,0),l=new R,u=0;for(let d=0;d<s;d++){let c=d*n*3;for(let p=0;p<3;p++){let f=i?i.getX(c+p):c+p;l.fromBufferAttribute(t,f),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+bO),o.y=Math.max(o.y,.05*h)*(1+bO),o.z=Math.max(o.z,.05*h)*(1+bO),{data:a,triCount:s,boxHalf:o}}function zFe(e){let t=Ef(e),i=LB;return(r,n,s)=>{let a=mt(J(Xs(n.z),Xs(n.w),Xs(s.w)),J(1e-5)).toVar(),o=Xs(n.y),l=J(o.mod(Cf).mul(i),Ct(o.div(Cf)).mul(i),0).toVar(),u=Xt(GE(r.div(a).mul(.5).add(.5)),J(0),J(1)).mul(i-1).toVar(),h=Fi(Ct(u),J(i-2)).toVar(),d=u.sub(h).toVar(),c=l.add(h).toVar(),p=(M,E,A)=>Xs(lMe(t.load(Ha(c.add(J(M,E,A))))).x),f=Xs(d.x),m=Xs(d.y),g=Xs(d.z),v=ut(p(0,0,0),p(1,0,0),f),y=ut(p(0,1,0),p(1,1,0),f),_=ut(p(0,0,1),p(1,0,1),f),b=ut(p(0,1,1),p(1,1,1),f),x=ut(ut(v,y,m),ut(_,b,m),g),w=mt(Xs(a.x),mt(Xs(a.y),Xs(a.z))),S=ui(r).sub(a),T=Yi(mt(S,J(0)));return Xs(x.mul(w).add(T))}}function kFe(e){let t=LB;return new R(e%Cf*t,Math.floor(e/Cf)*t,0)}var Xs,GE,lMe,LB,Cf,bO,g4,VFe=U(()=>{oe(),oe(),vn(),bi(),Xs=e=>e,GE=e=>e,lMe=e=>e,LB=48,Cf=4,bO=.08,g4=24576});function GFe(){if(xO!==null)return xO;let e=Xe(()=>{let i=Me(Ii(p$),Ii(f$)),r=Me(1).div(i),n=tr().mul(Ii(m$)).sub(Me(.5)).mul(2).add(Me(.5)).toVar();n.x.addAssign(Ii(nE));let s=n.div(i).toVar(),a=Ii(ox.sample(s).x).toVar();s.x.addAssign(Ii(r.x));let o=Ii(ox.sample(s).x).toVar();s.y.addAssign(Ii(r.y));let l=Ii(ox.sample(s).x).toVar();s.x.subAssign(Ii(r.x));let u=Ii(ox.sample(s).x).toVar(),h=a,d=h.add(o),c=d.add(l),p=c.add(u);return Pe(p,c,d,h)})(),t=new ei;return t.name="SplineShapeBlend.pyramid",t.fragmentNode=e,t.depthTest=!1,t.depthWrite=!1,t.blending=Di,t.needsUpdate=!0,xO=t,t}function z2(e,t,i=1){return new Ui(e,t,{count:i,format:mn,type:Wt,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:yt,magFilter:yt,wrapS:vr,wrapT:vr})}function jFe(){let e=Fx.length;if(e>0){for(let t of Fx)t.dispose();Fx.length=0}return e}var Ii,sge,Op,ox,p$,f$,nE,W_,m$,xO,O9,L9,qm,aN,B9,F9,U9,z9,k9,V9,G9,oN,sn,k2,age,g$,qb,sE,Fx,WFe=U(()=>{oe(),vn(),bi(),jY(),Vxe(),TK(),FFe(),VFe(),ua(),Ii=e=>e,sge=e=>e,Op=new Cn,ox=vt(new Ri),p$=Fe(1),f$=Fe(1),nE=Fe(0),W_=Fe(0),m$=Fe(1),xO=null,O9=!1,L9=!1,qm="",aN=!1,B9=!1,F9=!1,U9=!1,z9=!1,k9=!1,V9=!1,G9=!1,oN=!1;try{let e=new URLSearchParams(window.location.search);O9=e.get("dbgsbmarch")==="vertex",L9=e.get("dbgsbultra")==="0",qm=e.get("dbgsbchain")??"",aN=e.get("dbgsbnoclear")==="1",B9=e.get("dbgsbsparse")==="0",F9=e.get("dbgsbincr")==="0",U9=e.get("dbgsblod")==="1",z9=e.get("dbgsbpool")==="1",k9=e.get("dbgsbpool")==="0",V9=e.get("dbgsbmesh")==="0",G9=e.get("dbgsbadapt")==="0",oN=e.get("dbgsbcull")==="1"}catch{}sn={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},k2=24576,age=Math.cos(8*Math.PI/180),g$=class{constructor(e=0,t=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 Ue,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=vt(new Ri),this.spatialTexNode=vt(new Ri),this.potentialTexNode=vt(new Ri),this.voxelTexNode=vt(new Ri),this.pyramid1TexNode=vt(new Ri),this.pyramid2TexNode=vt(new Ri),this.npartUniform=Fe(0),this.spatialnUniform=Fe(1),this.spanUniform=Fe(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=e,this.poolHint=t,this.vertHint=i;let r=UI(),n=new Nr(r.triTable,16,256,aa,Wt);n.needsUpdate=!0;let s=new Nr(r.numTrisTable,256,1,aa,Wt);s.needsUpdate=!0,this.triTableTexNode=vt(n),this.numTrisTableTexNode=vt(s)}shapeRow(e,t){return this.shapesTex.sample(Me(e,(t+.5)/5))}_quadMaterial(e,t){let i=new ei;return i.name=e,i.fragmentNode=t,i.depthTest=!1,i.depthWrite=!1,i.blending=Di,i.needsUpdate=!0,i}_buildSpatialMaterial(e){let t=e.spatialDivisions,i=GY,r=this.npartUniform,n=this.spatialnUniform,s=this.spanUniform,a=e.spatialn,o=Xe(()=>{let l=Me(t*a,t**2),u=Ct(tr().mul(l)).toVar(),h=Ii(u.y).toVar(),d=h.sub(Ct(h.div(t)).mul(t)).toVar();h.assign(Ct(h.div(t)));let c=h,p=Ii(u.x).toVar(),f=p.sub(Ct(p.div(n)).mul(Ii(n))).toVar().mul(96).toVar();p.assign(Ct(p.div(n)));let m=J(p,d,c),g=m.div(t).mul(2).sub(1).sub(Ii(s)).toVar(),v=m.add(1).div(t).mul(2).sub(1).add(Ii(s)).toVar(),y=_=>{let b=B(0).toVar();for(let x=23;x>=0;x--){let w=_.add(x),S=w.add(.5).div(i),T=this.shapeRow(S,0),M=sge(T.xyz),E=Ii(T.w);b.mulAssign(2);let A=Ii(g.x).lessThan(Ii(M.x)).and(Ii(M.x).lessThan(Ii(v.x))).and(Ii(g.y).lessThan(Ii(M.y))).and(Ii(M.y).lessThan(Ii(v.y))).and(Ii(g.z).lessThan(Ii(M.z))).and(Ii(M.z).lessThan(Ii(v.z))).and(w.lessThan(Ii(r))).or(E.equal(-2));b.addAssign(A.select(B(1),B(0)))}return b};return Pe(y(f),y(f.add(24)),y(f.add(48)),y(f.add(72)))})();return this._quadMaterial("SplineShapeBlend.spatial",o)}_fieldEnv(e,t){return{shapeRow:(i,r)=>this.shapeRow(i,r),spatialTex:this.spatialTexNode,spatialDivisions:e.spatialDivisions,spatialn:e.spatialn,colorKBump:t,meshSdf:this._meshBaker?zFe(this._meshBaker.atlas):void 0}}_buildPotentialMaterial(e){let t=e.spatialDivisions,i=e.resolution,r=i-1,n=1/i,s=e.zLayersPerRow,a=e.basePyramidSize,o=c$(this._fieldEnv(e,2*n)),l=Xe(()=>{let u=Ct(tr().mul(Me(a,a))).toVar(),h=Ii(u.x).mod(i),d=Ii(u.y).mod(i),c=Ct(Ii(u.x).mul(n)).add(Ct(Ii(u.y).mul(n)).mul(s)),p=J(h,d,c),f=p.div(r).mul(2).sub(1).toVar(),m=Ct(p.div(r).mul(t-1)).toVar(),{sdf:g,color:v}=o(f,m),y=Cr(Ii(v.x).mul(255)),_=Cr(Ii(v.y).mul(255)),b=y.shiftLeft(Cr(8)).bitOr(_);return Pe(g,b.toFloat().mul(1525902e-11),Ii(v.z),Ii(v.w))})();return this._quadMaterial("SplineShapeBlend.potential",l)}_buildVoxelMaterial(e){let t=e.resolution,i=t-1,r=1/t,n=e.zLayersPerRow,s=e.basePyramidSize,a=rMe(t,n),o=this.potentialTexNode,l=()=>{let c=Ct(tr().mul(Me(s,s))).toVar();return{xi:Ii(c.x).mod(t).toVar(),yi:Ii(c.y).mod(t).toVar(),zi:Ct(Ii(c.x).mul(r)).add(Ct(Ii(c.y).mul(r)).mul(n)).toVar()}},u=(c,p,f)=>{let m=(g,v,y,_)=>Ii(a(c.add(g),p.add(v),f.add(y),o).x).lessThan(0).toFloat().mul(_);return m(0,0,0,1).add(m(1,0,0,2)).add(m(0,1,0,8)).add(m(1,1,0,4)).add(m(0,0,1,16)).add(m(1,0,1,32)).add(m(0,1,1,128)).add(m(1,1,1,64))},h=Xe(()=>{let{xi:c,yi:p,zi:f}=l(),m=((y,_,b)=>{let x=Ii(a(y.add(1),_,b,o).x).sub(Ii(a(y.sub(1),_,b,o).x)),w=Ii(a(y,_.add(1),b,o).x).sub(Ii(a(y,_.sub(1),b,o).x)),S=Ii(a(y,_,b.add(1),o).x).sub(Ii(a(y,_,b.sub(1),o).x));return x.equal(0).and(w.equal(0)).and(S.equal(0)).select(J(.199,.299,.399),Ut(J(x,w,S)))})(c,p,f).toVar(),g=Pe(m,0).toVar(),v=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(f.greaterThanEqual(i));return Ve(v.not(),()=>{g.assign(Pe(m,u(c,p,f)))}),g})(),d=Xe(()=>{let{xi:c,yi:p,zi:f}=l(),m=Pe(0).toVar(),g=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(f.greaterThanEqual(i));return Ve(g.not(),()=>{let v=u(c,p,f);m.assign(this.numTrisTableTexNode.sample(Me(v.add(.5).div(256),.5)))}),m})();return this._quadMaterial("SplineShapeBlend.voxel",aw({output:h,numTris:d}))}_spatialTargetFor(e){let t=e.resolutionLevel,i=this.spatialTargets[t];return i||(i=z2(e.spatialDivisions*e.spatialn,e.spatialDivisions**2),this.spatialTargets[t]=i),i}_targetsFor(e){let t=e.resolutionLevel,i=this._spatialTargetFor(e),r=this.potentialTargets[t];r||(r=z2(e.basePyramidSize,e.basePyramidSize),this.potentialTargets[t]=r);let n=this.voxelTargets[t];n||(n=z2(e.basePyramidSize,e.basePyramidSize,2),n.textures[0].name="output",n.textures[1].name="numTris",n.textures[1].format=aa,this.voxelTargets[t]=n);let s=this.pyramidTargets[t];return s||(s=[z2(e.pyramidTexture1Width,e.pyramidTexture1Height),z2(e.pyramidTexture2Width,e.pyramidTexture2Height)],this.pyramidTargets[t]=s),{spatial:i,potential:r,voxel:n,pyramid:s}}_marchResources(e){let t=this._targetsFor(e),i=e.pyramidLevelSizes.length%2==0?0:1,r=1-i;return{resolutionLevel:e.resolutionLevel,pyramidLevelSizes:e.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:t.pyramid[r].width,height:t.pyramid[r].height},pyramid2Size:{width:t.pyramid[i].width,height:t.pyramid[i].height}}}_maxMarchSlots(e){let t=e.backend?.device?.limits,i=Math.min(t?.maxStorageBufferBindingSize??134217728,t?.maxBufferSize??268435456);return 192*Math.floor(i/16/192)}_ensureMarchCapacity(e,t){if(this._marchBuffers!==null&&e<=this._marchCapacity)return!1;let i=Math.min(Math.max(t,k2),192*Math.ceil(1.5*e/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 n=r.value;n&&this._retiredStorage.push(n)}return this._marchBuffers={positions:$n(i,"vec4"),normals:$n(i,"vec4"),colors:$n(i,"vec4")},this._marchCapacity=i,this._computeNode=null,!0}update(e,t,i){if(sn.updates++,this._lastRenderer=t,i!==void 0&&(this._cullCamera=i),e._meshSdfBaked.size>0)for(let[T,M]of e._meshSdfBaked)M.owner!==this&&e._meshSdfBaked.delete(T);let r=(s=e,ewe.call(s)),n=t.backend?.isWebGPUBackend===!0;var s;if(n&&e._meshSdfWanted.size>0&&this._meshBaker===null&&(this._meshBaker=function(T,M){let E=LB,A=new by(Cf*E,Math.ceil(T/Cf)*E,E);A.format=aa,A.type=Wt,A.minFilter=yt,A.magFilter=yt,A.name="SplineShapeBlend.meshSdfAtlas";let P=B(M).mul(0),N=Fe(new R(0,0,0)),D=Fe(0),O=Fe(new R(1,1,1)),z=$n(3*g4,"vec4"),L=$=>z.element($),V=Xe(()=>{let $=J(cl).toVar();Ve(Xs($.x).greaterThanEqual(E).or(Xs($.y).greaterThanEqual(E)).or(Xs($.z).greaterThanEqual(E)),()=>{bn()});let Q=$.div(E-1).mul(2).sub(1).mul(O).toVar(),ue=B(1e30).toVar(),pe=B(1e15).toVar();Zr(g4,({i:we})=>{Ve(B(we).greaterThanEqual(Xs(D)),()=>{Ya()});let re=De(B(we).toVar()).mul(3).toVar(),Se=GE(L(re).xyz).toVar(),W=GE(L(re.add(De(1))).xyz).toVar(),k=GE(L(re.add(De(2))).xyz).toVar(),K=W.sub(Se).toVar(),ie=k.sub(Se).toVar(),j=Q.sub(Se).toVar(),ae=et(K,j).toVar(),se=et(ie,j).toVar(),H=Q.sub(W).toVar(),me=et(K,H).toVar(),be=et(ie,H).toVar(),ke=Q.sub(k).toVar(),Te=et(K,ke).toVar(),Ze=et(ie,ke).toVar(),ze=J(0).toVar(),qe=me.mul(Ze).sub(Te.mul(be)).toVar(),Ne=Te.mul(se).sub(ae.mul(Ze)).toVar(),ee=ae.mul(be).sub(me.mul(se)).toVar();Ve(ae.lessThanEqual(0).and(se.lessThanEqual(0)),()=>{ze.assign(Se)}).ElseIf(me.greaterThanEqual(0).and(be.lessThanEqual(me)),()=>{ze.assign(W)}).ElseIf(Ze.greaterThanEqual(0).and(Te.lessThanEqual(Ze)),()=>{ze.assign(k)}).ElseIf(ee.lessThanEqual(0).and(ae.greaterThanEqual(0)).and(me.lessThanEqual(0)),()=>{let pt=ae.div(ae.sub(me));ze.assign(Se.add(K.mul(pt)))}).ElseIf(Ne.lessThanEqual(0).and(se.greaterThanEqual(0)).and(Ze.lessThanEqual(0)),()=>{let pt=se.div(se.sub(Ze));ze.assign(Se.add(ie.mul(pt)))}).ElseIf(qe.lessThanEqual(0).and(be.sub(me).greaterThanEqual(0)).and(Te.sub(Ze).greaterThanEqual(0)),()=>{let pt=be.sub(me).div(be.sub(me).add(Te.sub(Ze)));ze.assign(W.add(k.sub(W).mul(pt)))}).Else(()=>{let pt=B(1).div(qe.add(Ne).add(ee)),tt=Ne.mul(pt),Yt=ee.mul(pt);ze.assign(Se.add(K.mul(tt)).add(ie.mul(Yt)))});let Ce=Q.sub(ze).toVar(),He=et(Ce,Ce).toVar();Ve(He.lessThan(ue),()=>{ue.assign(He);let pt=qn(K,ie),tt=et(Ce,pt).greaterThanEqual(0).select(B(1),B(-1));pe.assign(Rh(He).mul(tt))})});let xe=mt(Xs(O.x),mt(Xs(O.y),Xs(O.z)));vg(A,Ha($.add(N)),Pe(Xs(pe.div(xe).add(P)),0,0,0)).toStack()})(),G=Math.ceil(E/4),Y=V.compute([G,G,G],[4,4,4]);return{atlas:A,slots:T,kernel:Y,uniforms:{slotOrigin:N,triCount:D,boxHalf:O},setTriangles($,Q){let ue=z.value;ue.array.set($.subarray(0,12*Q)),ue.needsUpdate=!0}}}(Cf*Cf,++this._ultraBuildSeq)),e.npart===0)return this._meshBaker!==null&&e._meshSdfWanted.size>0&&this._bakeNextMeshChild(e,t),void(e.geometry.drawRange.count=0);this.npartUniform.value=e.npart,this.spatialnUniform.value=e.spatialn,this.spanUniform.value=e.spatialPassUniforms.span.value,e.shapesDataTexture.value&&(this.shapesTex.value=e.shapesDataTexture.value);let a=!O9&&n,o=a&&!L9&&e.ultraFieldResolution>0,l=o&&!k9&&(z9||e.ultraFieldResolution>=512)?Math.min(Math.pow(e.ultraFieldResolution/4,3),Math.max(function(T){let M=T/4;return Math.min(M*M*M,Math.max(8192,16*M*M))}(e.ultraFieldResolution),this._ultraWantedPoolBricks,this.poolHint)):0,u=l>0&&!V9,h=this._maxMarchSlots(t),d=u?Math.min(Math.floor(h/64),Math.max(function(T){let M=T/4;return Math.min(262144,Math.max(2048,2*M*M))}(e.ultraFieldResolution),this._ultraWantedVertexBlocks,this.vertHint)):0,c=this._meshBaker!==null,p=e.needsRebuild||this.level!==e.resolutionLevel||this.spatialnAtBuild!==e.spatialn||this._cachedAtBuild!==a||this._ultraResAtBuild!==(o?e.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 f=a&&this._ensureMarchCapacity(Math.min(Math.max(h,k2),Math.max(e.geometry.drawRange.count,this.capacityHint,o?Math.max(function(T){return Math.max(k2,192*Math.ceil(16*T*T/192))}(e.ultraFieldResolution),this._ultraWantedCapacity):k2)),h);if(f&&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=this._spatialTargetFor(e),g=o?null:this._targetsFor(e),v=p||f,y=o&&this._ultra!==null&&this._ultraResAtBuild===e.ultraFieldResolution&&!f&&this.level===e.resolutionLevel&&this.spatialnAtBuild===e.spatialn&&this._cachedAtBuild===a;if(v&&y)e.needsRebuild=!1,this._ultra.uniforms.bboxHalf.value=e.bboxSize/2,this._ultra.uniforms.bboxOffset.value=e.bboxOffset,this._ultraDrag&&(this._ultraDrag.uniforms.bboxHalf.value=e.bboxSize/2,this._ultraDrag.uniforms.bboxOffset.value=e.bboxOffset);else if(v){e.needsRebuild=!1;let T=this.spatialnAtBuild!==e.spatialn;this.level=e.resolutionLevel,this.spatialnAtBuild=e.spatialn,this._meshAtBuild=c,(T||this.spatialMaterial===null)&&(this.spatialMaterial?.dispose(),this.spatialMaterial=this._buildSpatialMaterial(e)),this.spatialTexNode.value=m.texture;let M=this._ultra,E=this._ultraDrag;if(this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,o){let N=e.ultraFieldResolution,D=M!==null&&this._ultraResAtBuild===N;if(D&&!f)this._ultra=M,M.uniforms.bboxHalf.value=e.bboxSize/2,M.uniforms.bboxOffset.value=e.bboxOffset,this._ultraDrag=E,E&&(E.uniforms.bboxHalf.value=e.bboxSize/2,E.uniforms.bboxOffset.value=e.bboxOffset);else{let O=D&&l===0&&!M.sparse;M&&!O&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),u&&this._drawIndex===null&&(this._drawIndex=$n(this._marchCapacity,"uint")),u&&this._vertexBuffers===null&&(this._vertexBuffers={positions:$n(64*d,"vec4"),normals:$n(64*d,"vec4"),colors:$n(64*d,"vec4")}),this._ultra=nge({resolution:N,colorResolution:N/2,bboxHalf:e.bboxSize/2,bboxOffset:e.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(e,2/(N/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:UI().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:O?{sdfTexture:M.sdfTexture,colorTexture:M.colorTexture,coarseTexture:M.coarseTexture}:void 0}),this._poolAtBuild=l,this._vertBlocksAtBuild=d;let z=U9&&N>=128&&!u?N/2:0;E&&(!D||z===0)&&this._ultraRetired.push(E.sdfTexture,E.colorTexture,E.coarseTexture),z>0&&(this._ultraDrag=nge({resolution:z,colorResolution:z/2,bboxHalf:e.bboxSize/2,bboxOffset:e.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(e,2/(z/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:UI().numTrisTable,buffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,reuseTextures:D&&E?{sdfTexture:E.sdfTexture,colorTexture:E.colorTexture,coarseTexture:E.coarseTexture}:void 0}))}this._ultraResAtBuild=N}else{M&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),E&&this._ultraRetired.push(E.sdfTexture,E.colorTexture,E.coarseTexture),(this._legacyMaterialsLevel!==e.resolutionLevel||T||this.potentialMaterial===null||this.voxelMaterial===null)&&(this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose(),this.potentialMaterial=this._buildPotentialMaterial(e),this.voxelMaterial=this._buildVoxelMaterial(e),this._legacyMaterialsLevel=e.resolutionLevel),this.potentialTexNode.value=g.potential.texture,this.voxelTexNode.value=g.voxel.textures[0];let N=e.pyramidLevelSizes.length%2==0?0:1,D=1-N;this.pyramid1TexNode.value=g.pyramid[D].texture,this.pyramid2TexNode.value=g.pyramid[N].texture,this._ultraResAtBuild=0}let A=e.material;A.defines===void 0&&(A.defines={}),qm.includes("nomat")||(A.defines.SHAPEBLEND=e.resolutionLevel),qm.includes("nomat")||A.setShapeBlendResources?.(o?{resolutionLevel:e.resolutionLevel,pyramidLevelSizes:e.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(e),cached:a?this._marchBuffers:void 0}),this._cachedAtBuild=a;let P=`${e.resolutionLevel}:${this._marchCapacity}`;this._computeNodeKey!==P&&(this._computeNode=null,this._computeNodeKey=P)}if(v)return this._builtOnce=!0,void(this._computeDirty=!0);this._meshBaker!==null&&e._meshSdfWanted.size>0&&this._bakeNextMeshChild(e,t);let _=this._passesRenderer!==t,b=r&&!F9&&!this._computeDirty&&!_&&!e._fieldDirtyFull;if(!(r||this._computeDirty||_)){if(o&&this._refinePending&&this._ultra!==null&&performance.now()-this._lastFieldChangeMs>250)return this._refinePending=!1,this._passesRenderer=t,sn.refines++,void this._runUltra(e,t,!1,this._ultra);if(o&&oN&&this._ultra!==null&&this._ultra.meshlet&&this._lastDispatched===this._ultra&&!this._ultraReadbackPending&&this._updateCullUniforms(e,this._ultra)&&(!this._hasGatherMVP||!this._lastGatherMVP.equals(this._ultra.uniforms.cullMVP.value))){this._lastGatherMVP.copy(this._ultra.uniforms.cullMVP.value),this._hasGatherMVP=!0,sn.regathers++;let T=t;return T.compute(this._ultra.kernels.zero),aN||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(e,t)}if(!e.drawRangeNeedsForceUpdate)return void sn.skips++;if(o)return void(this._ultraReadbackPending||this._runUltraReadback(e,t))}if(this._passesRenderer=t,qm.includes("none")&&sn.readbacksResolved>0)return void(this._computeDirty=!1);let x=t.getRenderTarget(),w=t.getMRT(),S=t.autoClear;if(t.setMRT(null),t.autoClear=!1,sn.lastPass="spatial",t.setRenderTarget(m),Op.material=this.spatialMaterial,Op.render(t),o){t.autoClear=S,t.setRenderTarget(x),t.setMRT(w);let T=this._ultraDrag!==null&&r&&!this._computeDirty;return this._refinePending=T,this._lastFieldChangeMs=performance.now(),this._runUltra(e,t,b,T?this._ultraDrag:this._ultra),void(this._computeDirty=!1)}return qm==="spatial"&&sn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(sn.lastPass="potential",t.setRenderTarget(g.potential),Op.material=this.potentialMaterial,Op.render(t),qm==="potential"&&sn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(sn.lastPass="voxel",t.setRenderTarget(g.voxel),Op.material=this.voxelMaterial,Op.render(t),qm==="voxel"&&sn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(sn.lastPass="pyramid",this._renderPyramid(e,t,g.voxel,g.pyramid),t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),sn.lastPass="march",a&&(this._computeNode===null&&(this._computeNode=function(T,M,E){let A=nMe(T);return Xe(()=>{let{position:P,normal:N,color:D}=A(Sa.toFloat());M.positions.element(Sa).assign(Pe(P,1)),M.normals.element(Sa).assign(Pe(N,0)),M.colors.element(Sa).assign(D)})().compute(E)}(this._marchResources(e),this._marchBuffers,this._marchCapacity)),t.compute(this._computeNode),sn.computes++),void(this._computeDirty=!1))))}_bakeNextMeshChild(e,t){let i=this._meshBaker;for(let[r,n]of e._meshSdfWanted){let s=Qxe(n);if(this._meshBakeFailed.get(r)===s)continue;let a=this._meshSlots.get(r);if(a===void 0){if(this._meshSlots.size>=i.slots)for(let u of this._meshSlots.keys())!e._meshSdfBaked.has(u)&&!e._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=UFe(n);if(o!==null)return i.setTriangles(o.data,o.triCount),i.uniforms.slotOrigin.value.copy(kFe(a)),i.uniforms.triCount.value=o.triCount,i.uniforms.boxHalf.value.copy(o.boxHalf),t.compute(i.kernel),e._meshSdfBaked.set(r,{slot:a,boxHalf:o.boxHalf.clone(),posVersion:s,owner:this}),void e._meshSdfWanted.delete(r);this._meshBakeFailed.set(r,s)}}_updateCullUniforms(e,t){if(!t.meshlet)return!1;let i=this._cullCamera;return oN&&i&&i.projectionMatrix!==void 0&&i.matrixWorldInverse!==void 0?(t.uniforms.cullMVP.value.multiplyMatrices(it.unjitteredProjection.value,i.matrixWorldInverse).multiply(e.matrixWorld),t.uniforms.cullEnabled.value=1,!0):(t.uniforms.cullEnabled.value=0,!1)}_runUltra(e,t,i,r){let n=t;sn.lastPass="ultra-kernels",sn.lastDispatchRes=r.resolution,sn.marchPositions=(r.meshlet?this._vertexBuffers:this._marchBuffers).positions.value,this._lastDispatched=r;let s=r.resolution,a=s/4,o=2/(s-1);r.uniforms.activeThreshold.value=B9?1e30:(3*Math.sqrt(3)+4)*o+.25*e._maxBlendK;let l=r.meshlet&&!G9;r.meshlet&&(r.uniforms.adaptCos.value=l?age:2);let u=0,h=0,d=0,c=a,p=a,f=a;if(i){let v=r.uniforms.activeThreshold.value+2/(e.spatialDivisions-1)+4/(s-1),y=x=>Math.floor(.5*(x+1)*(s-1)/4),_=x=>Math.min(a-1,Math.max(0,y(x))),b=x=>Math.min(a,Math.max(1,y(x)+1));if(u=_(e._fieldDirtyMin.x-v),h=_(e._fieldDirtyMin.y-v),d=_(e._fieldDirtyMin.z-v),c=b(e._fieldDirtyMax.x+v)-u,p=b(e._fieldDirtyMax.y+v)-h,f=b(e._fieldDirtyMax.z+v)-d,sn.fieldsWindowed++,l){let x=Math.min(a,u+c+1),w=Math.min(a,h+p+1),S=Math.min(a,d+f+1);u=Math.max(0,u-1),h=Math.max(0,h-1),d=Math.max(0,d-1),c=x-u,p=w-h,f=S-d}}else sn.fieldsFull++;sn.lastWindowBricks=c*p*f,r.uniforms.windowOrigin.value.set(u,h,d),r.uniforms.windowSize?.value.set(c,p,f);let m=u===0&&h===0&&d===0&&c===a&&p===a&&f===a,g=[Math.ceil(c/4),Math.ceil(p/4),Math.ceil(f/4)];r.meshlet&&this._updateCullUniforms(e,r)&&(this._lastGatherMVP.copy(r.uniforms.cullMVP.value),this._hasGatherMVP=!0),n.compute(r.kernels.zero),aN||n.compute(r.meshlet?r.kernels.clearDraw:r.kernels.clear),r.needsInit&&r.kernels.init&&(n.compute(r.kernels.init),r.needsInit=!1),n.compute(r.kernels.coarse,g),r.kernels.release&&n.compute(r.kernels.release,g),r.kernels.alloc&&n.compute(r.kernels.alloc,g),r.kernels.meshRelease&&n.compute(r.kernels.meshRelease,g),r.sparse?m?n.compute(r.kernels.sdf):n.compute(r.kernels.sdfWindow,[c,p,f]):n.compute(r.kernels.sdf,[c,p,f]),r.kernels.classify&&n.compute(r.kernels.classify,g),n.compute(r.kernels.color,[Math.ceil(c/2),Math.ceil(p/2),Math.ceil(f/2)]),r.meshlet?(m?(n.compute(r.kernels.verts),n.compute(r.kernels.extract)):(n.compute(r.kernels.vertsWindow,[c,p,f]),n.compute(r.kernels.extractWindow,[c,p,f])),n.compute(r.kernels.gather)):n.compute(r.kernels.extract),r.kernels.stats&&n.compute(r.kernels.stats),sn.computes++,this._ultraReadbackPending?this._ultraReadbackQueued=!0:this._runUltraReadback(e,t)}_disposeRetired(){for(let e of this._ultraRetired)e.dispose();if(this._ultraRetired.length=0,this._retiredStorage.length>0){let e=this._lastRenderer?.backend?.attributeUtils;if(e)for(let t of this._retiredStorage)e.destroyAttribute(t);this._retiredStorage.length=0}for(let e of this._onSettled)e();this._onSettled.length=0}runWhenSettled(e){this._onSettled.push(e)}transferSettleQueue(e){e._onSettled.push(...this._onSettled),this._onSettled.length=0}_runUltraReadback(e,t){let i=this._lastDispatched??this._ultra,r=t;this._ultraReadbackPending=!0,sn.readbackPending=!0,r.getArrayBufferAsync(i.counterAttribute).then(n=>{if(this._ultraReadbackPending=!1,sn.readbackPending=!1,this.retired)return;this._disposeRetired();let s=new Uint32Array(n),a=i.meshlet?Math.floor(s[3]/3):s[0];if(sn.readbacksResolved++,sn.lastTotal=a,i.sparse&&s.length>2&&s[2]>0&&(this._ultraWantedPoolBricks=Math.ceil(1.5*Math.max(s[1],i.poolBricks)),this._computeDirty=!0),i.meshlet&&s.length>5&&s[5]>0){let l=Math.min(24*s[4],this._maxMarchSlots(t));l>this._marchCapacity&&(this._ultraWantedCapacity=Math.max(this._ultraWantedCapacity,l),this._computeDirty=!0)}if(i.meshlet&&s.length>7&&s[7]>0){let l=Math.min(Math.ceil(1.5*s[6]),Math.floor(this._maxMarchSlots(t)/64));l>i.vertexBlocks&&(this._ultraWantedVertexBlocks=Math.max(this._ultraWantedVertexBlocks,l),this._computeDirty=!0)}let o=Math.floor(this._marchCapacity/3);if(e.geometry.drawRange.count=3*Math.min(Math.ceil(1.25*a),o),e.markSceneShadowsDirty(),e.drawRangeNeedsForceUpdate=!1,this._ultraReadbackQueued&&(this._ultraReadbackQueued=!1,this._runUltraReadback(e,t)),a>o){let l=Math.min(3*a,this._maxMarchSlots(t));l>this._marchCapacity&&(this._ultraWantedCapacity=l,this._computeDirty=!0)}}).catch(()=>{sn.readbackErrors++,this._ultraReadbackPending=!1,sn.readbackPending=!1})}_renderPyramid(e,t,i,r){let n=e.pyramidLevelSizes,s=n.length-1-1;nE.value=0,W_.value=0;for(let o=s;o>=0;o--){let l=o%2==s%2?r[0]:r[1],u=o===s?i:o%2==s%2?r[1]:r[0];ox.value=u.textures.length>1?u.textures[1]:u.texture,p$.value=u.width,f$.value=u.height;let h=n[o];o===2&&e.resolutionLevel%2!=0&&(h=3),m$.value=h,l.viewport.set(W_.value,0,h,h),t.setRenderTarget(l),Op.material=GFe(),Op.render(t),l.viewport.set(0,0,l.width,l.height);let d=nE.value;nE.value=W_.value,W_.value=d,o<s&&(W_.value+=n[o+1])}sn.lastPass="pyramid-readback";let a=n.length%2==0?0:1;t.readRenderTargetPixelsAsync(r[a],r[a].width-1,0,1,1).then(o=>{let l=o[0];sn.readbacksResolved++,sn.lastTotal=l,!this.retired&&(this._disposeRetired(),(3*l>e.geometry.drawRange.count||e.drawRangeNeedsForceUpdate)&&(e.geometry.drawRange.count=3*Math.floor(1.2*l)),e.drawRangeNeedsForceUpdate=!1,this._marchBuffers!==null&&e.geometry.drawRange.count>this._marchCapacity&&(this._computeDirty=!0))}).catch(()=>{})}dispose(){for(let n of[...this.spatialTargets,...this.potentialTargets,...this.voxelTargets,...this.pyramidTargets.flat()])n?.dispose();this.spatialMaterial?.dispose(),this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose();let e=this._lastRenderer?.backend?.attributeUtils,t=n=>{if(e&&n!==null)for(let s of[n.positions,n.normals,n.colors]){let a=s.value;a&&e.destroyAttribute(a)}},i=n=>{if(n!==null){for(let s of Object.values(n.kernels))s?.dispose?.();if(e)for(let s of n.storageAttributes)e.destroyAttribute(s)}};t(this._marchBuffers),t(this._vertexBuffers);let r=this._drawIndex?.value;e&&r&&e.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}},qb=new WeakMap,sE=new WeakMap,Fx=[]}),HFe=U(()=>{yB(),TK(),WFe(),$L=BFe,zY=e=>function(t){let i=qb.get(t);if(i?.wantsReplacement){let r=sE.get(t);sE.set(t,i),i.retired=!0;let n=new g$(i.capacityHint,i.poolHint,i.vertHint);i.transferSettleQueue(n),r&&n.runWhenSettled(()=>r.dispose()),i=n,qb.set(t,i)}return i||(i=new g$,qb.set(t,i)),i}(e),function(e){kY=e}({release:e=>function(t){let i=qb.get(t),r=sE.get(t);qb.delete(t),sE.delete(t),r&&Fx.push(r),i&&(i.retired=!0,Fx.push(i))}(e),drainRetired:jFe})});function qFe(){let e=jE.length;if(e>0){for(let t of jE)t.dispose();jE.length=0}return e}var hl,uo,nu,Oi,Xu,oge,j9,lge,hge,lN,uge,hN,dge,cge,W9,Lp,H_,V2,hMe,aE,jE,v4,q_,uMe,dMe,cMe,pMe,fMe,mMe,$Fe=U(()=>{oe(),vn(),bi(),zxe(),Uxe(),hl=[64,1,1],nu=(uo=jv)-1,Oi=(e,t)=>t!==void 0?Fe(e,t):Fe(e),Xu=(e,t)=>{let i=e.xyz,r=qn(i,t),n=qn(i,r);return t.add(r.mul(e.w).mul(2)).add(n.mul(2))},oge=e=>{let t=et(e,e);return t.lessThan(1e-10).select(Pe(0,0,0,1),e.mul(nK(mt(t,1e-20))))},j9=Xe(([e,t])=>{let i=e,r=t,n=et(i,r).add(1).toVar(),s=J(0).toVar();return Ve(n.lessThan(1e-7),()=>{n.assign(0),Ve(ui(i.x).greaterThan(ui(i.z)),()=>{s.assign(J(i.y.negate(),i.x,0))}).Else(()=>{s.assign(J(0,i.z.negate(),i.y))})}).Else(()=>{s.assign(qn(i,r))}),oge(Pe(s,n))}),lge=e=>e.sub(Ct(e.mul(1/289)).mul(289)),hge=e=>e.sub(Ct(e.mul(1/289)).mul(289)),lN=e=>hge(e.mul(34).add(10).mul(e)),uge=e=>Pe(1.79284291400159).sub(e.mul(.85373472095314)),hN=Xe(([e])=>{let t=e,i=1/6,r=1/3,n=Ct(t.add(et(t,J(r)))).toVar(),s=t.sub(n).add(et(n,J(i))).toVar(),a=hr(s.yzx,s.xyz).toVar(),o=J(1).sub(a).toVar(),l=Fi(a,o.zxy).toVar(),u=mt(a,o.zxy).toVar(),h=s.sub(l).add(i).toVar(),d=s.sub(u).add(r).toVar(),c=s.sub(.5).toVar();n.assign(lge(n));let p=lN(lN(lN(Pe(0,l.z,u.z,1).add(n.z)).add(n.y).add(Pe(0,l.y,u.y,1))).add(n.x).add(Pe(0,l.x,u.x,1))).toVar(),f=.142857142857,m=2*f,g=.5*f-1,v=f,y=p.sub(Ct(p.mul(v*v)).mul(49)).toVar(),_=Ct(y.mul(v)).toVar(),b=Ct(y.sub(_.mul(7))).toVar(),x=_.mul(m).add(g).toVar(),w=b.mul(m).add(g).toVar(),S=Pe(1).sub(ui(x)).sub(ui(w)).toVar(),T=Pe(x.xy,w.xy).toVar(),M=Pe(x.zw,w.zw).toVar(),E=Ct(T).mul(2).add(1).toVar(),A=Ct(M).mul(2).add(1).toVar(),P=hr(S,Pe(0)).negate().toVar(),N=T.xzyw.add(E.xzyw.mul(P.xxyy)).toVar(),D=M.xzyw.add(A.xzyw.mul(P.zzww)).toVar(),O=J(N.xy,S.x).toVar(),z=J(N.zw,S.y).toVar(),L=J(D.xy,S.z).toVar(),V=J(D.zw,S.w).toVar(),G=uge(Pe(et(O,O),et(z,z),et(L,L),et(V,V))).toVar();O.assign(O.mul(G.x)),z.assign(z.mul(G.y)),L.assign(L.mul(G.z)),V.assign(V.mul(G.w));let Y=mt(Pe(.5).sub(Pe(et(s,s),et(h,h),et(d,d),et(c,c))),Pe(0)).toVar();return Y.assign(Y.mul(Y)),et(Y.mul(Y),Pe(et(O,s),et(z,h),et(L,d),et(V,c))).mul(105)}),dge=class extends Hv{constructor(e,t,i,r,n){super(),this.tangentWorld=e,this.specularPower=t,this.specularIntensity=i,this.diffuseIntensity=r,this.ambientFloor=n}direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,n=Ut(_u.mul(Pe(this.tangentWorld,0)).xyz),s=t,a=lw,o=Ut(s.add(a)),l=mt(Yi(qn(n,s)),0),u=mt(Yi(qn(n,o)),0);r.directDiffuse.addAssign(i.mul(l).mul(this.diffuseIntensity).mul(Wl.rgb)),r.directSpecular.addAssign(i.mul(Xl(u,this.specularPower)).mul(this.specularIntensity).mul(J(1,.95,.9)))}indirect(e){let{irradiance:t,ambientOcclusion:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(1/Math.PI).add(this.ambientFloor).mul(Wl.rgb)),r.indirectDiffuse.mulAssign(i)}},cge=class extends Hv{direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,n=t,s=Ao,a=lw,o=Ut(n.add(a)),l=et(s,n).clamp(),u=et(s,o).clamp();r.directDiffuse.addAssign(i.mul(l).mul(.85).mul(Wl.rgb)),r.directSpecular.addAssign(i.mul(Xl(u,60)).mul(.3).mul(J(.3,.28,.25)))}indirect(e){let{irradiance:t,ambientOcclusion:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(1/Math.PI).add(.15).mul(Wl.rgb)),r.indirectDiffuse.mulAssign(i)}},W9=class extends ei{constructor(e){super(),this.model=e,this.lights=!0}setupLightingModel(){return this.model}},Lp=new kt,H_=new kt,V2=new R,hMe=class{constructor(){this.uNumStrands=Oi(0,"int"),this.uNumVerts=Oi(0,"int"),this.uDamping=Oi(.03),this.uLocalStiffness=Oi(.67),this.uGlobalStiffness=Oi(.5),this.uGlobalRange=Oi(.15),this.uStiffnessFalloff=Oi(.1),this.uGravity=Oi(0),this.uVspCoeff=Oi(.01),this.uVspThreshold=Oi(50),this.uKink=Oi(0),this.uKinkFreq=Oi(0),this.uUnitScale=Oi(100),this.uClumpStrength=Oi(0),this.uClumpSize=Oi(32,"int"),this.uClumpTipScale=Oi(1.5),this.uReset=Oi(1),this.uHasWind=Oi(0),this.uWind0=Oi(new R),this.uWind1=Oi(new R),this.uWind2=Oi(new R),this.uWind3=Oi(new R),this.uBoneQuat=Oi(new ct(0,0,0,1)),this.uBoneTrans=Oi(new R),this.uDeltaQuat=Oi(new ct(0,0,0,1)),this.uPrevBoneTrans=Oi(new R),this.uHairRoot=Oi(new ot),this.uHairMid=Oi(new ot),this.uHairTip=Oi(new ot),this.uHeadColor=Oi(new ot),this.uNoiseA=Oi(new ot),this.uNoiseB=Oi(new ot),this.uNoiseC=Oi(new ot),this.uNoiseD=Oi(new ot),this.uNoiseScale=Oi(.018),this.uNoiseMixHair=Oi(0),this.uNoiseMixHead=Oi(0),this.uWidth=Oi(.525),this.uSpecPow=Oi(40),this.uSpecInt=Oi(.4),this.uDiffInt=Oi(.6),this.uAmbInt=Oi(.25),this.uOpacity=Oi(1),this.uTipFade=Oi(.4),this.uColorSource=Oi(0),this.uShadeRoot=Oi(.6),this.uShadeTip=Oi(1.15),this.uShadowTexelWorld=Oi(0),this._armed=!1,this._uploadedGeneration=-1,this._prevBoneQuat=new kt,this._prevBonePos=new R,this._hasPrevBone=!1,this._renderer=null,this.initialPos=$n(tf,"vec4"),this.rootColors=$n(Px,"vec4"),this.positions=$n(tf,"vec4"),this.positionsPrev=$n(tf,"vec4"),this.positionsPrevPrev=$n(tf,"vec4"),this.tangents=$n(tf,"vec4"),this.restLengths=$n(tf,"float"),this.vspQuats=$n(Px,"vec4"),this.vspTrans=$n(Px,"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 Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumVerts),()=>{bn()});let t=e.div(uo).toVar(),i=e.sub(t.mul(uo)).toVar(),r=this.boneQuatNode(),n=this.boneTransNode(),s=this.initialPos.element(e).toVar(),a=Pe(Xu(r,s.xyz).add(n),s.w).toVar(),o=this.positions.element(e).toVar(),l=this.positionsPrev.element(e).toVar(),u=l.toVar();Ve(this.uReset.greaterThan(.5),()=>{o.assign(a),u.assign(a)});let h=a.toVar();Ve(o.w.greaterThan(0),()=>{let d=B(fg),c=EB(this.uDamping.negate().mul(d).mul(60)),p=o.xyz.add(o.xyz.sub(u.xyz).mul(c)).add(J(0,-1,0).mul(this.uGravity).mul(d).mul(d));h.assign(Pe(p,o.w))}),Ve(this.uGlobalStiffness.greaterThan(0).and(this.uGlobalRange.greaterThan(0)).and(h.w.greaterThan(0)).and(i.toFloat().lessThan(this.uGlobalRange.mul(uo))),()=>{let d=e.sub(i),c=this.initialPos.element(d),p=Ut(Xu(r,c.xyz)).y.mul(.5).add(.5),f=this.uGlobalStiffness.mul(Xl(mt(p,0),this.uStiffnessFalloff)),m=a.xyz.sub(h.xyz).mul(f);h.assign(Pe(h.xyz.add(m),h.w))}),Ve(this.uKink.greaterThan(0).and(h.w.greaterThan(0)),()=>{let d=i.toFloat().div(uo),c=t.sub(t.div(256).mul(256)).toFloat().mul(.0245),p=d.mul(this.uKinkFreq).mul(6.2831853).add(c),f=this.uKink.mul(d).mul(.15).mul(this.uUnitScale),m=Ut(a.xyz.sub(n)).toVar(),g=J(0).toVar();Ve(ui(m.y).lessThan(.99),()=>{g.assign(Ut(qn(m,J(0,1,0))))}).Else(()=>{g.assign(Ut(qn(m,J(1,0,0))))});let v=Ut(qn(m,g)),y=g.mul(Pa(p)).mul(f).add(v.mul(Yo(p.mul(1.3).add(c))).mul(f).mul(.7));h.assign(Pe(h.xyz.add(y),h.w))}),this.positionsPrevPrev.element(e).assign(l),this.positionsPrev.element(e).assign(o),this.positions.element(e).assign(h)})().compute(hl[0],hl)}_buildStrandLevel(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=e.mul(uo).toVar(),i=this.positionsPrevPrev.element(t.add(1)),r=this.positionsPrev.element(t),n=this.positionsPrev.element(t.add(1)),s=this.positions.element(t),a=this.positions.element(t.add(1)),o=n.xyz.sub(r.xyz),l=a.xyz.sub(s.xyz),u=o.div(mt(Yi(o),1e-7)),h=l.div(mt(Yi(l),1e-7)),d=j9(u,h).toVar(),c=s.xyz.sub(Xu(d,r.xyz)),p=this.uVspCoeff.toVar(),f=Yi(a.xyz.sub(n.xyz.mul(2)).add(i.xyz));Ve(f.greaterThan(this.uVspThreshold),()=>{p.assign(1)}),this.vspQuats.element(e).assign(d),this.vspTrans.element(e).assign(Pe(c,p))})().compute(hl[0],hl)}_buildVsp(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumVerts),()=>{bn()});let t=e.div(uo).toVar(),i=e.sub(t.mul(uo)).toVar();Ve(i.lessThan(2),()=>{bn()});let r=this.vspQuats.element(t),n=this.vspTrans.element(t),s=n.w,a=this.positions.element(e).toVar(),o=this.positionsPrev.element(e).toVar(),l=u=>Pe(u.xyz.mul(B(1).sub(s)).add(Xu(r,u.xyz).add(n.xyz).mul(s)),u.w);this.positions.element(e).assign(l(a)),this.positionsPrev.element(e).assign(l(o))})().compute(hl[0],hl)}_buildLocalShape(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=e.mul(uo).toVar(),i=Fi(this.uLocalStiffness,.95).mul(.5),r=this.boneQuatNode();Zr(nu-1,({i:n})=>{let s=t.add(n).add(1).toVar(),a=this.positions.element(s).toVar(),o=this.positions.element(s.add(1)).toVar(),l=this.positions.element(s.sub(1)),u=Xu(r,this.initialPos.element(s).xyz),h=Xu(r,this.initialPos.element(s.add(1)).xyz),d=Xu(r,this.initialPos.element(s.sub(1)).xyz),c=a.xyz.sub(l.xyz),p=h.sub(u),f=u.sub(d),m=j9(f.div(mt(Yi(f),1e-7)),c.div(mt(Yi(c),1e-7))),g=Xu(m,p).add(a.xyz).sub(o.xyz).mul(i);Ve(a.w.greaterThan(0),()=>{a.assign(Pe(a.xyz.sub(g),a.w))}),Ve(o.w.greaterThan(0),()=>{o.assign(Pe(o.xyz.add(g),o.w))}),this.positions.element(s).assign(a),this.positions.element(s.add(1)).assign(o)})})().compute(hl[0],hl)}_buildLengthWind(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=e.mul(uo).toVar();Ve(this.uHasWind.greaterThan(.5),()=>{let i=e.sub(e.div(20).mul(20)).toFloat().div(20),r=this.uWind0.mul(i).add(this.uWind1.mul(B(1).sub(i))).add(this.uWind2.mul(i)).add(this.uWind3.mul(B(1).sub(i))).toVar();Zr(nu-2,({i:n})=>{let s=t.add(n).add(2).toVar(),a=this.positions.element(s).toVar(),o=this.positions.element(s.add(1)),l=a.xyz.sub(o.xyz),u=qn(qn(l,r),l).negate();a.assign(Pe(a.xyz.add(u.mul(fg).mul(.1)),a.w)),this.positions.element(s).assign(a)})}),Zr(5,()=>{Zr(nu,({i})=>{let r=t.add(i).toVar(),n=this.positions.element(r).toVar(),s=this.positions.element(r.add(1)).toVar(),a=this.restLengths.element(r),o=s.xyz.sub(n.xyz),l=mt(Yi(o),1e-7),u=B(1).sub(a.div(l)),h=o.mul(u),d=n.w.greaterThan(0),c=s.w.greaterThan(0),p=d.select(c.select(B(.5),B(1)),B(0)),f=c.select(d.select(B(.5),B(1)),B(0));n.assign(Pe(n.xyz.add(h.mul(p)),n.w)),s.assign(Pe(s.xyz.sub(h.mul(f)),s.w)),this.positions.element(r).assign(n),this.positions.element(r.add(1)).assign(s)})}),Zr(nu,({i})=>{let r=t.add(i).add(1).toVar(),n=this.positions.element(r.sub(1)),s=this.positions.element(r).toVar(),a=s.xyz.sub(n.xyz),o=mt(Yi(a),1e-7),l=this.restLengths.element(r.sub(1));Ve(o.greaterThan(l),()=>{s.assign(Pe(n.xyz.add(a.div(o).mul(l)),s.w)),this.positions.element(r).assign(s)})}),Zr(uo,({i})=>{let r=t.add(i).toVar(),n=i.equal(uo-1).select(r.sub(1),r).toVar(),s=Ut(this.positions.element(n.add(1)).xyz.sub(this.positions.element(n).xyz));this.tangents.element(r).assign(Pe(s,0))})})().compute(hl[0],hl)}_buildClump(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=this.uClumpSize.toVar(),i=e.div(t).mul(t).toVar();Ve(e.equal(i),()=>{bn()}),Ve(i.greaterThanEqual(this.uNumStrands),()=>{bn()});let r=e.mul(uo).toVar(),n=i.mul(uo).toVar();Zr(nu,({i:s})=>{let a=s.add(1).toVar(),o=a.toFloat().div(nu),l=this.uClumpStrength.mul(Xl(o,B(1).div(mt(this.uClumpTipScale,.5)))),u=r.add(a).toVar(),h=this.positions.element(u).toVar(),d=this.positions.element(n.add(a));h.assign(Pe(ut(h.xyz,d.xyz,l),h.w)),this.positions.element(u).assign(h)})})().compute(hl[0],hl)}_buildRigidFollow(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumVerts),()=>{bn()});let t=this.uDeltaQuat,i=this.uPrevBoneTrans,r=this.boneTransNode(),n=a=>{let o=a.element(e).toVar();o.assign(Pe(Xu(t,o.xyz.sub(i)).add(r),o.w)),a.element(e).assign(o)};n(this.positions),n(this.positionsPrev),n(this.positionsPrevPrev);let s=this.tangents.element(e).toVar();s.assign(Pe(Xu(t,s.xyz),0)),this.tangents.element(e).assign(s)})().compute(hl[0],hl)}pastelNoise(e){let t=e.sub(this.boneTransNode()).mul(this.uNoiseScale),i=hN(t).mul(.5).add(.5),r=hN(t.add(J(31.7,17.3,53.1))).mul(.5).add(.5),n=hN(t.mul(.7).add(J(71.9,11.2,43.8))).mul(.5).add(.5),s=ut(this.uNoiseA,this.uNoiseB,i);return s=ut(s,this.uNoiseC,r.mul(.6)),s=ut(s,this.uNoiseD,n.mul(.25)),s}_buildRibbonMaterial(){let e=Bn("vec3","vHairTangent"),t=Bn("vec3","vHairNormal"),i=Bn("vec2","vHairUv"),r=Bn("float","vHairRand"),n=Bn("vec3","vHairInherit"),s=new W9(new dge(e,this.uSpecPow,this.uSpecInt,this.uDiffInt,this.uAmbInt));s.name="SplineHairRibbons",s.userData.hairShadowVariant="texel-floor-v6",s.transparent=!1,s.depthTest=!0,s.depthWrite=!0,s.side=Ur;let a=l=>Xe(()=>{let u=De(Sa).toVar(),h=u.div(nu).toVar(),d=u.sub(h.mul(nu)).toVar(),c=h.mul(uo).add(d).toVar(),p=De(UE).toVar(),f=p.bitAnd(1).toFloat().toVar(),m=p.shiftRight(1).bitAnd(1).toFloat().toVar(),g=this.positions.element(c).xyz.toVar(),v=this.positions.element(c.add(1)).xyz.toVar(),y=this.tangents.element(c).xyz,_=this.tangents.element(c.add(1)).xyz,b=ut(g,v,m).toVar(),x=ut(y,_,m).toVar(),w=Ut(qf.sub(b)),S=qn(x,w).toVar(),T=Yi(S).toVar();S.assign(T.greaterThan(1e-7).select(S.div(T),J(1,0,0)));let M=d.toFloat().div(nu),E=d.add(1).toFloat().div(nu),A=ut(M,E,m).toVar(),P=this.uWidth.mul(B(1).sub(A.mul(this.uTipFade))).toVar(),N=l?(()=>{let G=this.uShadowTexelWorld,Y=G.greaterThan(0).select(G.mul(1.5).clamp(B(2),B(8)),B(0));return mt(Y.sub(P),0).toVar()})():null;N&&P.addAssign(N);let D=f.mul(2).sub(1),O=b.add(S.mul(P).mul(D)).toVar();N&&O.assign(O.sub(w.mul(N)));let z=this.positionsPrev.element(c).xyz,L=this.positionsPrev.element(c.add(1)).xyz;DB.assign(ut(z,L,m).add(S.mul(P).mul(D)));let V=gr(Pa(h.toFloat().mul(12.9898)).mul(43758.5453));return r.assign(V),n.assign(this.rootColors.element(h).xyz),e.assign(x),t.assign(Ut(w.sub(x.mul(et(x,w))))),i.assign(Me(f,A)),O}),o=Xe(()=>{let l=i.y,u=ut(this.uHairRoot,this.uHairMid,Fi(l.mul(2),1)),h=l.lessThan(.5).select(u,ut(this.uHairMid,this.uHairTip,l.sub(.5).mul(2))).toVar(),d=n.mul(ut(this.uShadeRoot,this.uShadeTip,l));h.assign(this.uColorSource.greaterThan(.5).select(d,h)),h.assign(ut(h,this.pastelNoise(Jl),this.uNoiseMixHair));let c=B(1).sub(ui(i.x.sub(.5)).mul(2));return B(1).sub(l.mul(this.uTipFade)).mul(Xl(mt(c,0),.5)).toVar().lessThan(.25).discard(),r.greaterThanEqual(this.uOpacity).discard(),Pe(h,1)});return s.positionNode=a(!1)(),s.castShadowPositionNode=a(!0)(),s.normalNode=t,s.colorNode=o(),s.needsUpdate=!0,s}_buildScalpMaterial(){let e=new W9(new cge);e.name="SplineHairScalp";let t=Xe(()=>{let i=ut(this.uHeadColor,this.pastelNoise(Jl),this.uNoiseMixHead);return Pe(i,1)});return e.colorNode=t(),e.needsUpdate=!0,e}update(e,t){let i=t;if(i.backend?.isWebGPUBackend!==!0||(this._renderer=i,e.visible===!1))return;if(!this._armed){this._armed=!0;let o=e.ribbonMesh.material;e.ribbonMesh.material=this.ribbonMaterial,o.dispose?.();let l=e.scalpMesh.material;e.scalpMesh.material=this.scalpMaterial,l.dispose?.(),e.ribbonMesh.visible=!0}e.checkDataDrift();let r=e.activeGuideStrands,n=r*uo;e.generation!==this._uploadedGeneration&&(this._uploadedGeneration=e.generation,this.initialPos.value.array.set(e.roots.initialPositions),this.initialPos.value.needsUpdate=!0,this.restLengths.value.array.set(e.roots.restLengths),this.restLengths.value.needsUpdate=!0,this.rootColors.value.array.set(e.roots.rootColors),this.rootColors.value.needsUpdate=!0,e.ribbonMesh.geometry.instanceCount=r*nu,e.resetRequested=!0),this._syncUniforms(e),e.boneTransform(Lp,V2),this.uBoneQuat.value.set(Lp.x,Lp.y,Lp.z,Lp.w),this.uBoneTrans.value.copy(V2);let s=this._hasPrevBone&&(Math.abs(this._prevBoneQuat.dot(Lp))<.9999995||this._prevBonePos.distanceToSquared(V2)>1e-8),a=Math.floor(e.pendingSimSeconds/fg);a>4&&(a=4),e.pendingSimSeconds=Math.max(0,Math.min(e.pendingSimSeconds-a*fg,fg)),e.resetRequested&&a<1&&(a=1),a<1&&s&&(H_.copy(this._prevBoneQuat).invert().premultiply(Lp),this.uDeltaQuat.value.set(H_.x,H_.y,H_.z,H_.w),this.uPrevBoneTrans.value.copy(this._prevBonePos),this._dispatch(i,this.kRigidFollow,n));for(let o=0;o<a;o++){this.uReset.value=e.resetRequested&&o===0?1:0,e.simTime+=fg,this._updateWind(e),this._dispatch(i,this.kIntegrate,n),this._dispatch(i,this.kStrandLevel,r),this._dispatch(i,this.kVsp,n);for(let l=0;l<2;l++)this._dispatch(i,this.kLocalShape,r);this._dispatch(i,this.kLengthWind,r),e.data.clumpStrength>.001&&this._dispatch(i,this.kClump,r)}a>0&&(e.resetRequested=!1),this._prevBoneQuat.copy(Lp),this._prevBonePos.copy(V2),this._hasPrevBone=!0}_dispatch(e,t,i){t.count=i,e.compute(t)}_updateWind(e){let t=e.data,i=Math.max(e.roots.unitScale,.001),r=t.windStrength/i;this.uHasWind.value=t.windStrength>.001?1:0;let n=.7*e.simTime,s=Math.sin(n)*r,a=Math.cos(n)*r*.5;this.uWind0.value.set(s,0,a),this.uWind1.value.set(.7*s,.5*r,1.2*a),this.uWind2.value.set(.3*-s,0,.5*a),this.uWind3.value.set(.5*s,-.3*r,.8*-a)}_shadowTexelWorld(e){let t=e;for(;t.parent;)t=t.parent;let i=t;if(!i?.traverse)return 0;let r=0;return i.traverse(n=>{let s=n;if(s.isDirectionalLight!==!0||s.castShadow!==!0||s.visible===!1)return;let a=s.shadow?.camera,o=s.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(e){let t=e.data,i=e.roots.unitScale;this.uNumStrands.value=e.activeGuideStrands,this.uNumVerts.value=e.activeGuideStrands*uo,this.uDamping.value=t.damping,this.uLocalStiffness.value=t.localStiffness,this.uGlobalStiffness.value=t.globalStiffness,this.uGlobalRange.value=t.globalRange,this.uStiffnessFalloff.value=t.stiffnessFalloff,this.uGravity.value=t.gravity*i,this.uVspCoeff.value=t.vspCoefficient,this.uVspThreshold.value=.5*i,this.uKink.value=t.kink,this.uKinkFreq.value=t.kinkFrequency,this.uUnitScale.value=i,this.uClumpStrength.value=t.clumpStrength,this.uClumpSize.value=Math.max(1,Math.round(t.clumpSize)),this.uClumpTipScale.value=t.clumpTipScale;let r=(s,a)=>{s.value.setRGB(a.r,a.g,a.b,Xi)};r(this.uHairRoot,t.hairRootColor),r(this.uHairMid,t.hairMidColor),r(this.uHairTip,t.hairTipColor),r(this.uHeadColor,t.headColor),r(this.uNoiseA,t.noiseColorA),r(this.uNoiseB,t.noiseColorB),r(this.uNoiseC,t.noiseColorC),r(this.uNoiseD,t.noiseColorD);let n=t.noiseEnabled?1:0;this.uNoiseScale.value=t.noiseScale/Math.max(i,.001),this.uNoiseMixHair.value=t.noiseMixHair*n,this.uNoiseMixHead.value=t.noiseMixHead*n,this.uWidth.value=.003*t.hairWidth*od*e.widthWorldScale,this.uShadowTexelWorld.value=this._shadowTexelWorld(e),this.uColorSource.value=t.hairColorSource==="object"&&t.headShape==="object"&&t.baseObjectId?1:0,this.uShadeRoot.value=t.hairShadeRoot??.6,this.uShadeTip.value=t.hairShadeTip??1.15,this.uSpecPow.value=t.specularPower,this.uSpecInt.value=t.specularIntensity,this.uDiffInt.value=t.diffuseIntensity,this.uAmbInt.value=t.ambientIntensity,this.uOpacity.value=t.opacity,this.uTipFade.value=t.tipFade}dispose(){for(let t of[this.kIntegrate,this.kStrandLevel,this.kVsp,this.kLocalShape,this.kLengthWind,this.kClump,this.kRigidFollow])t.dispose();this.ribbonMaterial.dispose(),this.scalpMaterial.dispose();let e=this._renderer?.backend?.attributeUtils;if(e)for(let t of[this.initialPos,this.rootColors,this.positions,this.positionsPrev,this.positionsPrevPrev,this.tangents,this.restLengths,this.vspQuats,this.vspTrans])e.destroyAttribute(t.value);this._renderer=null}},aE=new WeakMap,jE=[]}),XFe=U(()=>{FY(),$Fe(),LY=e=>function(t){let i=aE.get(t);return i===void 0&&(i=new hMe,aE.set(t,i)),i}(e),function(e){BY=e}({release:e=>function(t){let i=aE.get(t);i!==void 0&&(aE.delete(t),jE.push(i))}(e),drainRetired:qFe})}),gMe=U(()=>{v4=`
|
|
6227
|
+
\u2014 last ${Ix.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,Ix.map(x=>({...x}))))}))}(this.backend.device);let n=this._skippedAsyncDraws??0;Pi.skippedAsyncDraws=n,this._skippedAsyncDraws=0,this._trackStalledSkips(n),this._trackGaugeStall(),awe(this);let s=e instanceof Og?e.activePage:e,a=s.visible;s.visible=!0;let o=s.scene;if(Ufe(s),this.renderStarted=!0,_9&&e instanceof Og){let v=e.updateInstanceGroups(s,b9);Pi.instancingGroups=v.instancingGroups,Pi.instancedDrawsSaved=v.instancedDrawsSaved,Pi.instancingRegroups=v.instancingRegroups,Pi.instancingParks=v.instancingParks,Pi.instancingIneligible=v.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(s,t)),this.normalizeCameraCoordinateSystem(t),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(s.bgColor,s.bgColor.a),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride);let l=p9?null:s.skyState;if(l?.enabled===!0){if(this.skyEnvironmentNeeded=!this.auxiliary&&(!KD&&(o.needsReflectionDirty||o.needsReflection())||!ZD&&l.lighting===!0),this._skySystem===null){let v=gK;v===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=v(this)}this._skySystem?.update(s,t)}else this._skySystem?.attached&&this._skySystem.detach();if(!this.auxiliary){let v=null,y=0;!ZD&&l?.enabled===!0&&this._skySystem&&(v=this._skySystem.iblTexture??null,y=this._skySystem.iblRotationY??0),function(_){if(cd.quality===_)return!1;cd.quality=_;for(let b of IA)zE(b)}(l?.lightingQuality==="low"?"low":"full"),function(_){if(cd.texture===_)return!1;cd.texture=_,cd.version++;for(let b of IA)zE(b)}(v),cd.rotation.set(0,-y,0),s.environmentIntensity=l?.enabled===!0?l.lightingIntensity??1:1}{let v=Hm==="off"?null:s.gradingState,y=Hm!=="default"&&Hm!=="off",_=y||v?.pipeline==="linear",b=y?Hm==="linear"?"none":Hm:v?.toneMapping??"aces";this.toneMapping=_?b==="aces"?rA:b==="agx"?nA:b==="neutral"?sA:Ls:Ls,this.toneMappingExposure=_?v?.exposure??1:1,this.outputColorSpace=_?Xi:Md,this.hdrChainActive=_,this.temporalAAEnabled&&this.taaHistory.setHdr(_)}it.pixelRatio.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?it.resolution.value.set(this.resolution.x,this.resolution.y):it.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let u=(it.frameIndex.value+1)%16;it.frameIndex.value=u;let h=OTe[u];it.pcssHalton.value.set(h[0],h[1]),it.tapAngle.value=Math.random()*Math.PI*2,it.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(s),this.sceneBundlesEnabled&&this._lightShadowStateDirty&&(this._lightShadowStateDirty=!1,this._updateSceneBundle(s,t)),it.unjitteredProjection.value.copy(t.projectionMatrix);let d=this.temporalAAEnabled?this.taaHistory:null;if(d){let v=this.getDrawingBufferSize(gv);d.beginJitter(t,v.x,v.y)}this._renderShadowMaskPass(s,t),it.orthographicUniform.value=t.projectionMatrix.elements[11]===0?1:0;let c=o.shapeBlendIntances.length>0?zY:null;if(c!==null)for(let v of o.shapeBlendIntances)c(v).update(v,this,t);let p=o.hairInstances.length>0?LY:null;if(p!==null)for(let v of o.hairInstances)p(v).update(v,this);o.needsTransmission()&&this._renderTransmissionPass(s,t),o.needsNormal()&&this._renderNormalPass(s,t,o.normalPassNeeds()),s.overrideMaterial=o.wireframeState?KL:null,t.layers.enable(3),t.layers.enable(8),t.layers.enable(4);let f=s.data.ao,m=f.occlusion&&!h9&&!OA.enabled;if(it.aoEnabled.value=m,it.aoEnabledUniform.value=m?1:0,m){let v=this,y=v._skippedAsyncDraws??0;this._renderAOPass(s,t,f),(v._skippedAsyncDraws??0)>y&&(it.aoEnabledUniform.value=0)}if(!KD&&o.needsReflection()?(this._renderReflectionPass(s,t),f9?it.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(s,t),this._renderReflectionResolvePass(s,t)):it.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(s,t),this.pipeline.isUIOverlayEnabled&&s.uiCanvas?.enabled&&s.uiCanvas.texture&&s.uiCanvas.texture.image.width>0){let v=this.getPixelRatio();(s.uiCanvas.width!==this.viewportWidth||s.uiCanvas.height!==this.viewportHeight||s.uiCanvas.dpr!==v)&&s.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},v),s.uiCanvas.render(this),this.pipeline.uiCanvasTexture=s.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=s,this.pipeline.camera=t;let g=i2e(s.postprocessing);if(this.pipeline.postprocessingState!==g&&this.pipeline.updatePostprocessing(g),this.pipeline.render(),d?.endJitter(),this._skySystem?.endFrame?.(),Pi.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates){let v=(this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled,y=this.info.asyncCompilation?.promotions??0,_=y!==this._shadowSyncPromotions;this._shadowSyncPromotions=y,o.shadowsDirty=this._shadowMapMissingAtSync||this._warmupInFlight||v||_}t instanceof Yn&&t.copyHistory(),s.visible=a}_fitDirectionalShadowRange(e,t,i){if(i===0)return;let r=e.shadow.camera,n=e.shadow;n.__speRangeEnvelope||(n.__speRangeEnvelope={near:r.near,far:r.far});let s=n.__speRangeEnvelope.near,a=e.data?.depth??n.__speRangeEnvelope.far;if(n.__speRangeEnvelope.far=a,U_.setFromMatrixPosition(e.matrixWorld),e.target?(e.target.updateMatrixWorld(),XD.setFromMatrixPosition(e.target.matrixWorld)):XD.set(0,0,0),vv.subVectors(XD,U_),vv.lengthSq()<1e-10)return;vv.normalize();let o=1/0,l=-1/0;for(let c=0;c<i;c++){let p=4*c,f=(t[p]-U_.x)*vv.x+(t[p+1]-U_.y)*vv.y+(t[p+2]-U_.z)*vv.z,m=t[p+3];f-m<o&&(o=f-m),f+m>l&&(l=f+m)}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,s),d=Math.min(d,a),d-h>=1&&(r.near!==h||r.far!==d)&&(r.near=h,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(e){let t=0;return e.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(oc):oc.setFromMatrixPosition(r.matrixWorld);let u=4*t;lc[u]=oc.x,lc[u+1]=oc.y,lc[u+2]=oc.z,lc[u+3]=l,t++}return}if(r.isMesh!==!0||!r.geometry||r.isInstanceGroup===!0)return;let n=r.geometry.boundingSphere;n===null&&(r.geometry.computeBoundingSphere(),n=r.geometry.boundingSphere);let s=r;if(s.isInstancedMesh===!0&&(s.boundingSphere===null&&s.computeBoundingSphere(),n=s.boundingSphere??n),!n||!Number.isFinite(n.radius)||n.radius<=0)return;oc.copy(n.center).applyMatrix4(r.matrixWorld),O2.setFromMatrixScale(r.matrixWorld);let a=n.radius*Math.max(Math.abs(O2.x),Math.abs(O2.y),Math.abs(O2.z)),o=4*t;lc[o]=oc.x,lc[o+1]=oc.y,lc[o+2]=oc.z,lc[o+3]=a,t++}),t}_syncLightState(e){let t=fy.isSoft(e.data.shadow);Zfe(t),Pi.shadowTypeSoft=t,function(d){switch(d){case"low":sf=8;break;case"high":sf=32;break;default:sf=16}}(e.data.shadow?.softShadowQuality),t&&Wq()&&(uO||(this.initTexture?.(Fq()),uO=!0));let i=-1;Pi.pcssLights=0,Pi.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,Pi.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,n=it.toonLightData.array,s=0,a=this.manageShadowUpdates,o=e.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1;let l=-2128831035,u=d=>{l^=0|d,l=Math.imul(l,16777619)};e.traverseVisible(d=>{let c=d;if(function(p){if(!p.isPointLight&&!p.isSpotLight&&!p.isDirectionalLight)return!1;if(OA.enabled){if(p.castShadow===!0)return p.castShadow=!1,mO.add(p),!0}else if(mO.has(p)&&(mO.delete(p),p.castShadow===!1))return p.castShadow=!0,!0;return!1}(c)&&(e.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)),u9&&(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!==d4&&Pi.pcssForeignFilter++:(p.filterNode=d4,Pi.pcssInstalled++)}(c.shadow),Kfe(c.shadow),Pi.pcssLights++),(c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&c.shadow){c.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(e)),this._fitDirectionalShadowRange(c,lc,i)),function(m){m.filterNode!==void 0&&m.filterNode!==null?m.filterNode!==u4&&Pi.pcssForeignFilter++:(Object.defineProperty(m,"penumbraSize",{get:()=>c.data?.penumbraSize??.5,configurable:!0}),m.filterNode=u4,Pi.pcssInstalled++)}(c.shadow);let p,f=!a||o||c.shadow.needsUpdate===!0;if(t&&Wq()&&(f?function(m){let g=m;g.__spePcssPyramid&&(g.__spePcssPyramid.fresh=!1)}(c.shadow):Yfe(c.shadow)||function(m,g){let v=g,y=v.map?.depthTexture??null;if(y==null)return!1;let _=Xfe(g);if(function(T){let M=Xfe(T);if(M.slot>=0)return M.slot;for(let E=0;E<o4;E++){let A=hO[E];if(A===null||A.deref()===void 0)return hO[E]=new WeakRef(T),M.slot=E,E}return-1}(g)<0)return!1;let b=Math.max(1,Math.round(v.mapSize?.x??2048)),x=_.slot*Af,w=`${y.uuid}:${b}`;_.passKey!==w&&(_.toMid?.material?.dispose(),_.toSmall?.material?.dispose(),_.mid===null&&(_.mid=Bq(Gb,Gb),_.mid.texture.name="SplinePCSSPyramidMid"),_.small===null&&(_.small=Bq(Af,Af),_.small.texture.name="SplinePCSSPyramidSmall"),_.toMid=new Cn($fe(`SplinePCSSPyramidToMid${b}`,y,Math.ceil(b/Gb),b-1,!1,0)),_.toSmall=new Cn($fe("SplinePCSSPyramidToSmall",_.mid.texture,Gb/Af,Gb-1,!0,0)),_.passKey=w),Fq();let S=m.getRenderTarget();m.setRenderTarget(_.mid),_.toMid.render(m),m.setRenderTarget(_.small),_.toSmall.render(m),m.setRenderTarget(S),Vq.set(x,0,0),m.copyTextureToTexture(_.small.texture,xy.texture,null,Vq),_.fresh=!0,Pi.pcssPyramidBuilds++}(this,c.shadow),p={slot:WBe(c.shadow),fresh:Yfe(c.shadow)}),t&&Hq()&&(NTe(c.shadow,-1),this._maskLights.push({light:c,shadow:c.shadow}),(f||c.shadow.map==null)&&(this._maskBlocked=!0)),Kfe(c.shadow,c.data?.penumbraSize??.5,p)&&Pi.pcssPyramidActive++,!r){r=!0;let m=c.shadow;Pi.pcssRadius0=m.radius??-1,Pi.pcssPenumbra0=m.penumbraSize??-1}Pi.pcssLights++}if(!(s>=xq)){if(c.isPointLight||c.isSpotLight)B_.setFromMatrixPosition(c.matrixWorld),n[s].set(B_.x,B_.y,B_.z,0),s++;else if(c.isDirectionalLight&&c.target){c.target.updateMatrixWorld();let p=B_;p.setFromMatrixPosition(c.matrixWorld),p.sub(ume.setFromMatrixPosition(c.target.matrixWorld)).normalize(),n[s].set(p.x,p.y,p.z,1),s++}}}),it.toonLightCount.value=s;let h=this._lightShadowSignatures.get(e);this._lightShadowSignatures.set(e,l),this._lightShadowStateDirty=h!==void 0&&h!==l}_shadowMapId(e){if(e==null)return 0;let t=this._shadowMapIds.get(e);return t===void 0&&(t=++this._shadowMapIdSeq,this._shadowMapIds.set(e,t)),t}_renderShadowMaskPass(e,t){let i=0;if(Hq()&&!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 kTe);let{targetsChanged:r}=this._shadowMask.render(this,e,t,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}it.shadowMaskEnabled.value=i>0?1:0,Pi.shadowMaskActive=i}retireRenderTarget(e){e&&this._retiredGrabTargets.push(e),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let e of this._retiredGrabTargets)e.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let e of this._retiredGpuBuffers)try{e.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let e of this._liveBundledPages())this._bundleStates.get(e)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let e=this.backend,t=this._retiredGpuBuffers;e.destroyUniformBuffer=r=>{let n=e.get(r);n?.buffer&&t.push(n.buffer),e.delete(r),this._retireBundleRecords()};let i=e.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=n=>{let s=e.get(r(n));s?.buffer&&t.push(s.buffer),e.delete(n),this._retireBundleRecords()}}}_reallocGrabTarget(e,t,i,r){return e&&e.width===t&&e.height===i?e:(this.retireRenderTarget(e),r())}_withShadowUpdatesSuspended(e,t){let i=[];e.traverse(r=>{let n=r;if(n.isLight&&n.shadow){if(n.shadow.map==null)return;i.push({shadow:n.shadow,auto:n.shadow.autoUpdate,needs:n.shadow.needsUpdate}),n.shadow.autoUpdate=!1,n.shadow.needsUpdate=!1}});try{t()}finally{for(let r of i)r.shadow.autoUpdate=r.auto,r.shadow.needsUpdate=r.needs}}_renderPrepass(e,t){this._withShadowUpdatesSuspended(e,()=>{this.render(e,t)})}_renderAOPass(e,t,i){let r=this.getDrawingBufferSize(gv),n=Math.max(1,Math.round(r.x)),s=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,n,s,()=>new Ui(n,s,{depthBuffer:!1})),it.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new STe);let a=e;this._hbao.render(this,e,t,{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:Xn.getModeIndex({mode:e.fogMode}),fogDensity:e.fogDensity??Xn.getDensity({}),fogHeightFalloff:e.fogHeightFalloff??Xn.getHeightFalloff({}),fogHeightBase:e.fogHeightBase??Xn.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(e,t,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",n=this.getDrawingBufferSize(gv),s=Math.max(1,Math.round(n.x)),a=Math.max(1,Math.round(n.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,s,a,()=>{let p=new Ui(s,a,{count:r==="both"?2:1,type:r==="normals"?di:Wt,depthTexture:new is(s,a)});r==="both"&&(p.textures[0].name="g0",p.textures[1].name="g1",p.textures[1].type=di);for(let f of p.textures)f.minFilter=yt,f.magFilter=yt;return p});let o=this._encodeMaterials[r];if(o===void 0){this._depthContrastUniform??(this._depthContrastUniform=Fe(1));let p=new ei;p.name=`SplineNormalPassEncode_${r}`;let f=$g("randomColor","vec3"),m=()=>{let v=Ut(RA),y=MB.sub(.5).mul(this._depthContrastUniform).add(.5),_=ut(ut(f,v,.2),J(y),.4);return Pe(_,f.x)},g=()=>{let v=Ut(Ao),y=Ki(RSe,v,v.negate());return Pe(y,f.x)};p.fragmentNode=r==="both"?aw({g0:m(),g1:g()}):r==="normals"?g():m(),p.lights=!1,p.blending=Di,p.needsUpdate=!0,this._encodeMaterials[r]=p,o=p}this._depthContrastUniform.value=t instanceof Yn?(t.far-t.near)/1e4:1;let l=e.overrideMaterial,u=this.getRenderTarget(),h=this.getClearColor(dme),d=this.getClearAlpha();t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),e.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(e,t),this.setRenderTarget(u),this.setClearColor(h,d),e.overrideMaterial=l,t.layers.enable(0),t.layers.enable(3);let c=this._normalTarget.textures;it.normalRenderTarget.value=r==="normals"?Hl:c[0],it.normalRenderTargetDepth.value=this._normalTarget.depthTexture,it.normalViewRenderTarget.value=r==="both"?c[1]:r==="normals"?c[0]:Hl}blitTextureToTarget(e,t){let i=this._uiBlitPass;if(!i){let s=vt(Hl),a=new ei;a.name="SplineUICanvasBlit",a.fragmentNode=s.sample(tr()),a.lights=!1,a.blending=Di,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,i={quad:new Cn(a),input:s},this._uiBlitPass=i}let r=this.getRenderTarget(),n=this.getMRT();i.input.value=e,this.setMRT(null),this.setRenderTarget(t),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(n)}_getPrefilterPass(e){this._prefilterPasses||(this._prefilterPasses=[]);let t=this._prefilterPasses[e];if(t)return t;let i=vt(Hl),r=Fe(new Z(1,0)),n=new ei;n.name="SplineTransmissionPrefilter";let s=tr(),a=r,o=u=>i.sample(s.add(a.mul(u))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return n.fragmentNode=Pe(l,1),n.lights=!1,n.blending=Di,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,t={quad:new Cn(n),input:i,step:r},this._prefilterPasses[e]=t,t}_getDownsamplePass(e){this._downsamplePasses||(this._downsamplePasses=[]);let t=this._downsamplePasses[e];return t||(t=this._buildDownsamplePassEntry(c9,"SplineTransmissionDownsample"),this._downsamplePasses[e]=t,t)}_buildDownsamplePassEntry(e,t){let i=vt(Hl),r=Fe(new Z(1,1)),n=new ei;n.name=t;let s=tr(),a=r,o=(u,h)=>i.sample(s.add(Me(u,h).mul(a))).rgb,l=null;if(e==="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],f=o(u[c],u[d]).mul(p);l=l?l.add(f):f}}return n.fragmentNode=Pe(l,1),n.lights=!1,n.blending=Di,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,{quad:new Cn(n),input:i,step:r}}_getPlanarDownsamplePass(e){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let t=this._planarDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[e]=t,t)}_batchedMipCopies(e){let t=this.backend,i=t?.device;if(!i||typeof t?.get!="function"){for(let s of e)this.copyTextureToTexture(s.src,s.dst,null,null,0,s.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),n=0;for(let s of e){let a=t.get(s.src)?.texture,o=t.get(s.dst)?.texture;a&&o?(r.copyTextureToTexture({texture:a,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:o,mipLevel:s.dstLevel,origin:{x:0,y:0,z:0}},{width:s.width,height:s.height,depthOrArrayLayers:1}),n++):this.copyTextureToTexture(s.src,s.dst,null,null,0,s.dstLevel)}n>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(e){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let t=this._reflectionDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[e]=t,t)}_renderTransmissionPass(e,t){let i=this.getDrawingBufferSize(gv),r=this.hdTransmission?1:2,n=Math.max(1,Math.round(i.x/r)),s=Math.max(1,Math.round(i.y/r)),a=this.backend?.isWebGPUBackend===!0?YD:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,n,s,()=>{let h=new Ui(n,s,{depthBuffer:!0}),d=h.texture;return a==="off"?(d.generateMipmaps=!0,d.minFilter=Rn):(d.generateMipmaps=!1,d.minFilter=rt),d.magFilter=rt,h});let o=[];e.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();t.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(e,t),this.setRenderTarget(l),t.layers.enable(3);for(let h of o)h.layers.mask=h.mask;let u=this._transmissionTarget.texture;if(a!=="off"){let h=(m,g)=>{let v=new Ui(m,g,{depthBuffer:!1});return v.texture.generateMipmaps=!1,v.texture.minFilter=rt,v.texture.magFilter=rt,v};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,n,s,()=>h(n,s));let d=Math.floor(Math.log2(Math.max(n,s)))+1,c=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,n,s,()=>{let m=new Ui(n,s,{depthBuffer:!1}),g=m.texture;return g.minFilter=Rn,g.magFilter=rt,a==="base"?g.generateMipmaps=!0:(g.generateMipmaps=!1,g.mipmaps=Array.from({length:d},(v,y)=>({width:Math.max(1,n>>y),height:Math.max(1,s>>y)}))),m}),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/n,0),this.setRenderTarget(this._transmissionBlurTmp),p.quad.render(this);let f=this._getPrefilterPass(1);if(f.input.value=this._transmissionBlurTmp.texture,f.step.value.set(0,1/s),a==="base")this.setRenderTarget(this._transmissionBlurTarget),f.quad.render(this);else{for(let m=0;m<d;m++)this._transmissionChain[m]=this._reallocGrabTarget(this._transmissionChain[m],Math.max(1,n>>m),Math.max(1,s>>m),()=>h(Math.max(1,n>>m),Math.max(1,s>>m)));for(let m=d;m<this._transmissionChain.length;m++)this._transmissionChain[m]?.dispose(),this._transmissionChain[m]=void 0;this._transmissionChain.length=d,this.setRenderTarget(this._transmissionChain[0]),f.quad.render(this);for(let m=1;m<d;m++){let g=this._transmissionChain[m-1],v=this._getDownsamplePass(m-1);v.input.value=g.texture,v.step.value.set(1/g.width,1/g.height),this.setRenderTarget(this._transmissionChain[m]),v.quad.render(this)}for(let m=0;m<d;m++)this.copyTextureToTexture(this._transmissionChain[m].texture,this._transmissionBlurTarget.texture,null,null,0,m)}this.setRenderTarget(l),u=this._transmissionBlurTarget.texture}it.transmissionRenderTarget.value=u,it.transmissionActualSize.value.set(n,s),it.aspectRatio.value=i.x>=i.y?it.aspectRatio.value.set(i.y/i.x,1):it.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(e,t,i){if(this._reflectionDepthPasses)for(let n of this._reflectionDepthPasses)n?.quad.material?.dispose();let r=[];{let n=new ei;n.name="SplineReflectionDepthBlit";let s=vt(this._reflectionTarget.depthTexture);n.fragmentNode=Pe(J(s.sample(tr())),1),n.lights=!1,n.blending=Di,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,r.push({quad:new Cn(n)})}for(let n=1;n<i;n++){let s=Math.max(1,e>>n-1),a=Math.max(1,t>>n-1),o=new ei;o.name=`SplineReflectionDepthMin${n}`;let l=vt(this._reflectionDepthChain[n-1].texture),u=Qo,h=De(u.x).mul(2),d=De(u.y).mul(2),c=(v,y)=>l.load(Wa(h.add(v),d.add(y))).x,p=(v,y)=>Fi(v,y),f=p(p(c(0,0),c(1,0)),p(c(1,1),c(0,1))),m=!!(1&s),g=!!(1&a);m&&(f=p(f,p(c(2,0),c(2,1)))),g&&(f=p(f,p(c(0,2),c(1,2)))),m&&g&&(f=p(f,c(2,2))),o.fragmentNode=Pe(J(f),1),o.lights=!1,o.blending=Di,o.depthTest=!1,o.depthWrite=!1,o.needsUpdate=!0,r.push({quad:new Cn(o)})}this._reflectionDepthPasses=r}_renderReflectionPass(e,t){let i=this.getDrawingBufferSize(gv),r=1/0,n=0,s=0;e.traverse(x=>{let w=x;if(!(w.isMesh&&16&w.layers.mask))return;let S=this._reflectiveMeshCoverage(w,t,i.y),T=Array.isArray(w.material)?w.material:[w.material];for(let M of T){if(!M?.layers)continue;let E=p4e(M);!E||(r=Math.min(r,E.min*S.scale),n=Math.max(n,E.max*S.scale),E.max*S.scale>.45&&(s=Math.max(s,S.diameterPx)))}});let a=1;if(v9&&r!==1/0)for(r>=6?a=4:r>=2&&(a=2);a>1&&s>0&&s/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&&g9;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let x=new Ui(o,l,{depthTexture:new is(o,l)});return h?(x.texture.generateMipmaps=!1,x.texture.minFilter=rt):(x.texture.generateMipmaps=!0,x.texture.minFilter=Rn),x.texture.magFilter=rt,x});let d=(x,w)=>{let S=new Ui(x,w,{depthBuffer:!1,type:Wt,format:aa});return S.texture.generateMipmaps=!1,S.texture.minFilter=yt,S.texture.magFilter=yt,S},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let x=d(o,l);return x.texture.mipmaps=Array.from({length:u},(w,S)=>({width:Math.max(1,o>>S),height:Math.max(1,l>>S)})),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,f=it.reflectionEnvMap,m=p??Nc;!this.auxiliary&&f.value!==m&&(f.value=m,this._grabTargetEpoch++),it.reflectionEnvEnabled.value=p!==null?1:0;let g=this.getClearColor(cme);it.reflectionMissColor.value.set(g.r,g.g,g.b);let v=[];e.traverse(x=>{let w=x;if(!(w.isMesh||w.isLine||w.isPoints||w.isSprite))return;let S=w.layers;S&&16&S.mask&&S.mask!==16&&(v.push({layers:S,mask:S.mask}),S.mask=16)});let y=this.getRenderTarget();t.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(e,t),t.layers.enable(4);for(let x of v)x.layers.mask=x.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,u),this._reflectionPassesKey=`${o}x${l}`);let _=this._reflectionDepthPasses;for(let x=0;x<u;x++)this.setRenderTarget(this._reflectionDepthChain[x]),_[x].quad.render(this);this._batchedMipCopies(Array.from({length:u},(x,w)=>({src:this._reflectionDepthChain[w].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:w,width:Math.max(1,o>>w),height:Math.max(1,l>>w)})));let b=this._reflectionTarget.texture;if(h){let x=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let T=new Ui(o,l,{depthBuffer:!1}),M=T.texture;return M.minFilter=Rn,M.magFilter=rt,M.generateMipmaps=!1,M.mipmaps=Array.from({length:u},(E,A)=>({width:Math.max(1,o>>A),height:Math.max(1,l>>A)})),T}),this._reflectionColorPyramid!==x&&this.initTexture(this._reflectionColorPyramid.texture);let w=n>0?u:1,S=(T,M)=>{let E=new Ui(T,M,{depthBuffer:!1});return E.texture.generateMipmaps=!1,E.texture.minFilter=rt,E.texture.magFilter=rt,E};for(let T=1;T<w;T++)this._reflectionColorChain[T]=this._reallocGrabTarget(this._reflectionColorChain[T],Math.max(1,o>>T),Math.max(1,l>>T),()=>S(Math.max(1,o>>T),Math.max(1,l>>T)));for(let T=w;T<this._reflectionColorChain.length;T++)this._reflectionColorChain[T]?.dispose(),this._reflectionColorChain[T]=void 0;this._reflectionColorChain.length=w;for(let T=1;T<w;T++){let M=T===1?this._reflectionTarget:this._reflectionColorChain[T-1],E=this._getReflectionDownsamplePass(T-1);E.input.value=M.texture,E.step.value.set(1/M.width,1/M.height),this.setRenderTarget(this._reflectionColorChain[T]),E.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:w-1},(T,M)=>({src:this._reflectionColorChain[M+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:M+1,width:Math.max(1,o>>M+1),height:Math.max(1,l>>M+1)}))]),b=this._reflectionColorPyramid.texture}this.setRenderTarget(y),it.reflectionRenderTarget.value=b,it.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,it.reflectionDepthSize.value.set(o,l),it.reflectionDepthLevels.value=u,this._reflectionGrabInfo={div:a,w:o,h:l,minBlur:r,maxBlur:n}}_reflectiveMeshCoverage(e,t,i){let r=e.geometry;if(!r)return{diameterPx:i,scale:1};r.boundingSphere===null&&r.computeBoundingSphere();let n=r.boundingSphere;if(!n)return{diameterPx:i,scale:1};let s=e.matrixWorld.elements,a=Math.sqrt(Math.max(s[0]*s[0]+s[1]*s[1]+s[2]*s[2],s[4]*s[4]+s[5]*s[5]+s[6]*s[6],s[8]*s[8]+s[9]*s[9]+s[10]*s[10])),o=n.radius*a;a9.copy(n.center).applyMatrix4(e.matrixWorld);let l=t.projectionMatrix.elements[5]*i/2,u=1;t.isPerspectiveCamera===!0&&(o9.setFromMatrixPosition(t.matrixWorld),u=Math.max(a9.distanceTo(o9),t.near??.1));let h=2*o*l/u;return{diameterPx:h,scale:Math.min(1,h/(.66*i))}}_renderReflectionResolvePass(e,t){let i=this._reflectionGrabInfo,r=this.backend?.isWebGPUBackend===!0&&y9&&i!==void 0&&i.maxBlur>.45;if(r){let b=!0;e.traverse(x=>{let w=x;if(!(w.isMesh&&16&w.layers.mask))return;let S=Array.isArray(w.material)?w.material:[w.material],T=null;for(let M of S)if(M?.layers&&(T=f4e(M),T!==null))break;T!=="variable"?T!==null?(w.userData.__srMode=T.blur>.45?1+T.tracingMode:0,w.userData.__srBlur=T.blur*this._reflectiveMeshCoverage(w,t,this.getDrawingBufferSize(fme).y).scale,w.userData.__srThickness=T.thickness,w.userData.__srStepSize=T.stepSize,w.userData.__srSteps=T.steps):w.userData.__srMode=0:b=!1}),r=b}let n=r?i.w:4,s=r?i.h:4,a=(b,x)=>()=>{let w=new Ui(b,x,{type:di,depthBuffer:!1});return w.texture.generateMipmaps=!1,w.texture.minFilter=rt,w.texture.magFilter=rt,w};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,n,s,a(n,s)),it.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(it.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let b=new Ui(o,l,{count:2,type:di,depthTexture:new is(o,l)});for(let x of b.textures)x.generateMipmaps=!1,x.minFilter=yt,x.magFilter=yt;return b.textures[0].name="g0",b.textures[1].name="g1",b}),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 b=new ei;b.name="SplineReflectionGBuffer";let x=yg("__splinePlanarMirror","float"),w=it.reflectionPlanarEnabled.greaterThan(.5),S=yg("__srMode","float"),T=Ki(x.greaterThan(.5).and(w),B(0),S);b.fragmentNode=aw({g0:Pe(Ut(Ao),T),g1:Pe(yg("__srBlur","float"),yg("__srThickness","float"),yg("__srStepSize","float"),yg("__srSteps","float"))}),b.lights=!1,b.blending=Di,b.needsUpdate=!0,this._reflectionGBufferMaterial=b}let u=this._skippedAsyncDraws??0,h=e.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(pme),p=this.getClearAlpha(),f=t.layers.mask;e.overrideMaterial=this._reflectionGBufferMaterial,t.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(e,t),e.overrideMaterial=h,t.layers.mask=f,this.setClearColor(c,p);let m=it.reflectionRenderTarget.value,g=it.reflectionEnvMap.value,v=this._reflectionGBufferTarget,y=`${o}x${l}|${v.textures[0].uuid}|${m.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${g.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;y!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(m,g,o,l),this._reflectionResolveMarchKey=y);let _=this._reflectionResolveMarch;_.proj.value.copy(t.projectionMatrix),_.projInv.value.copy(t.projectionMatrix).invert(),_.camWorld.value.copy(t.matrixWorld),_.near.value=t.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),_.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),it.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>u&&(it.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(e,t,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let n=Fe(new Ue),s=Fe(new Ue),a=Fe(new Ue),o=Fe(.1),l=this._reflectionGBufferTarget,u=vt(l.textures[0]),h=vt(l.textures[1]),d=vt(l.depthTexture),c=vt(e),p=vt(this._reflectionDepthPyramid.texture),f=vt(t),m=new ei;m.name="SplineReflectionResolve";let g=Xe(()=>{let b=Qo,x=Wa(De(b.x),De(b.y)),w=tr(),S=u.load(x).toVar(),T=d.sample(w).toVar(),M=Pe(0).toVar(),E=B(0).toVar();return Ve(S.w.greaterThan(.5),()=>{let A=h.load(x).toVar(),P=Uv(s,w.x,w.y,T),N=cK({dials:{blur:A.x,thickness:A.y,stepSize:A.z,steps:De(A.w),tracingMode:S.w.sub(1)},surface:{originView:P,normalV:Ut(S.xyz),screenUv:w,fragWindowZ:T},camera:{projectionMatrix:n,projectionMatrixInverse:s,worldMatrix:a,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:f},usePlanar:_Se(!1),noisePixel:Me(x),singleRay:{footprintOut:E}});M.assign(Pe(N,E.add(1)))}),M});m.fragmentNode=g(),m.lights=!1,m.blending=Di,m.depthTest=!1,m.depthWrite=!1,m.needsUpdate=!0,this._reflectionResolveMarch={quad:new Cn(m),proj:n,projInv:s,camWorld:a,near:o};let v=vt(this._reflectionResolveMarchTarget.texture),y=vt(this._reflectionResolveBlurTmp.texture),_=b=>{let x=new ei;x.name=`SplineReflectionResolveBlur${b.toUpperCase()}`;let w=b==="x"?v:y,S=b==="x"?1/i:1/r,T=Xe(()=>{let M=tr(),E=v.sample(M).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),A=Pe(0).toVar(),P=0;for(let N=-6;N<=6;N++){let D=Math.exp(N/3*-.5*(N/3));P+=D;let O=b==="x"?Me(E.mul(N/6*S),0):Me(0,E.mul(N/6*S)),z=w.sample(M.add(O)).toVar(),L=b==="x"?z.w.min(1):z.w;A.addAssign(Pe(z.rgb,L).mul(D))}return A.div(P)});return x.fragmentNode=T(),x.lights=!1,x.blending=Di,x.depthTest=!1,x.depthWrite=!1,x.needsUpdate=!0,new Cn(x)};this._reflectionResolveBlur={h:_("x"),v:_("y")}}_renderPlanarReflectionPass(e,t){let i=null;if(e.traverse(f=>{let m=f;if(!(m.isMesh&&16&m.layers.mask&&(m.userData.__splinePlanarMirror=0,(Array.isArray(m.material)?m.material:[m.material]).some(A=>A?.layers&&A.getLayersOfType("reflection").some(P=>P.data.visible&&P.data.mirror===1)))))return;let g=m.geometry;if(!g)return;g.boundingBox===null&&g.computeBoundingBox();let v,y,_=g.boundingBox,b=_.max.x-_.min.x,x=_.max.y-_.min.y,w=_.max.z-_.min.z,S=m.matrixWorld.elements,T=Math.hypot(S[0],S[1],S[2]),M=Math.hypot(S[4],S[5],S[6]),E=Math.hypot(S[8],S[9],S[10]);b<=x&&b<=w?(v=mme,y=x*M*(w*E)):x<=b&&x<=w?(v=gme,y=b*T*(w*E)):(v=vme,y=b*T*(x*M)),(!i||y>i.area)&&(i={mesh:m,normalAxis:v,area:y})}),!i)return void(it.reflectionPlanarEnabled.value=0);let r=i.mesh,n=i.mesh.matrixWorld;if(Ip.copy(i.normalAxis).transformDirection(n),jm.setFromMatrixPosition(n),N2.setFromMatrixPosition(t.matrixWorld),Wm.subVectors(jm,N2),Wm.dot(Ip)>0&&Ip.negate(),Wm.dot(Ip)>0)return void(it.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==t.type)&&(this._planarVirtualCamera=t.clone());let s=this._planarVirtualCamera;if(Wm.subVectors(jm,N2),Wm.reflect(Ip).negate(),Wm.add(jm),$D.extractRotation(t.matrixWorld),l9.set(0,0,-1).applyMatrix4($D).add(N2),I2.subVectors(jm,l9),I2.reflect(Ip).negate(),I2.add(jm),s.position.copy(Wm),s.up.set(0,1,0).applyMatrix4($D),s.up.reflect(Ip),s.lookAt(I2),s.updateMatrixWorld(),s.projectionMatrix.copy(t.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),t.isPerspectiveCamera===!0){mv.setFromNormalAndCoplanarPoint(Ip,jm),mv.applyMatrix4(s.matrixWorldInverse),ac.set(mv.normal.x,mv.normal.y,mv.normal.z,mv.constant);let f=s.projectionMatrix.elements;F_.x=(Math.sign(ac.x)+f[8])/f[0],F_.y=(Math.sign(ac.y)+f[9])/f[5],F_.z=-1,F_.w=(1+f[10])/f[14],ac.multiplyScalar(1/ac.dot(F_)),f[2]=ac.x,f[6]=ac.y,f[10]=ac.z,f[14]=ac.w}let a=this.getDrawingBufferSize(yme),o=Math.max(1,Math.round(a.x)),l=Math.max(1,Math.round(a.y)),u=this.backend?.isWebGPUBackend===!0&&m9;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let f=new Ui(o,l);return u?(f.texture.generateMipmaps=!1,f.texture.minFilter=rt):(f.texture.generateMipmaps=!0,f.texture.minFilter=Rn),f.texture.magFilter=rt,f});let h=[];e.traverse(f=>{let m=f;if(!(m.isMesh||m.isLine||m.isPoints||m.isSprite))return;let g=m.layers;g&&16&g.mask&&g.mask!==16&&(h.push({layers:g,mask:g.mask}),g.mask=16)}),s.layers.mask=-17&t.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(e,s),this.setRenderTarget(d);for(let f of h)f.layers.mask=f.mask;let c=this._planarTarget.texture;if(u){let f=Math.floor(Math.log2(Math.max(o,l)))+1,m=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let v=new Ui(o,l,{depthBuffer:!1}),y=v.texture;return y.minFilter=Rn,y.magFilter=rt,y.generateMipmaps=!1,y.mipmaps=Array.from({length:f},(_,b)=>({width:Math.max(1,o>>b),height:Math.max(1,l>>b)})),v}),this._planarPyramid!==m&&this.initTexture(this._planarPyramid.texture);let g=(v,y)=>{let _=new Ui(v,y,{depthBuffer:!1});return _.texture.generateMipmaps=!1,_.texture.minFilter=rt,_.texture.magFilter=rt,_};for(let v=1;v<f;v++)this._planarChain[v]=this._reallocGrabTarget(this._planarChain[v],Math.max(1,o>>v),Math.max(1,l>>v),()=>g(Math.max(1,o>>v),Math.max(1,l>>v)));for(let v=f;v<this._planarChain.length;v++)this._planarChain[v]?.dispose(),this._planarChain[v]=void 0;this._planarChain.length=f;for(let v=1;v<f;v++){let y=v===1?this._planarTarget:this._planarChain[v-1],_=this._getPlanarDownsamplePass(v-1);_.input.value=y.texture,_.step.value.set(1/y.width,1/y.height),this.setRenderTarget(this._planarChain[v]),_.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:f-1},(v,y)=>({src:this._planarChain[y+1].texture,dst:this._planarPyramid.texture,dstLevel:y+1,width:Math.max(1,o>>y+1),height:Math.max(1,l>>y+1)}))]),c=this._planarPyramid.texture}let p=it.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),it.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(e,t,i){let r=this.getDrawingBufferSize(gv),n=Math.max(1,Math.round(r.x)),s=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,n,s,()=>new Ui(n,s,{depthBuffer:!0}));let a=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget);try{this.renderSplineScene(e,t)}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(e,{includeHelpers:t=!1,settleFrames:i=0}={}){if(this.xr?.isPresenting===!0)return null;let r=this._frameSerial,n=this.getRenderTarget(),s=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled,o=this.suppressShadowMask;this.suppressShadowMask=!0,t||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{for(let g=0;g<i;g++)e(),await rFe();e()}finally{this.suppressShadowMask=o,this.pipeline.renderToScreen=s,this.setRenderTarget(n),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,f=256*Math.ceil(p/256),m=Math.max(1,Math.min(h,Math.floor((1<<20)/f)));for(let g=0;g<h;g+=m){let v=Math.min(m,h-g),y=await d.readRenderTargetPixelsAsync(l,0,g,u,v);if(f===p)c.set(y.subarray(0,v*p),g*p);else for(let _=0;_<v;_++){let b=_*f;c.set(y.subarray(b,b+p),(g+_)*p)}}return{pixels:c,width:u,height:h}}_applyCIOffscreenTargetIfRequested(){if(globalThis.__SPLINE_RENDER_OFFSCREEN__!==!0)return;let e=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),t=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==e||this._ciOffscreenTarget.height!==t)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new Ui(e,t,{depthBuffer:!0})):(this._ciOffscreenTarget=new Ui(e,t,{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(),NH()?.drainRetired(),OH()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let e of Ox){let t=e.deref();t!==void 0&&(t.mid?.dispose(),t.mid=null,t.small?.dispose(),t.small=null,t.toMid?.material?.dispose(),t.toSmall?.material?.dispose(),t.toMid=null,t.toSmall=null,t.passKey="",t.fresh=!1,t.slot=-1)}Ox.clear(),hO.fill(null),xy?.dispose(),xy=null,uO=!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 e of this._transmissionChain)e?.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 e of this._reflectionColorChain)e?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let e of this._reflectionDownsamplePasses)e?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let e of this._planarChain)e?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let e of this._planarDownsamplePasses)e?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let e of this._reflectionDepthChain)e?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let e of this._reflectionDepthPasses)e?.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 e of this._prefilterPasses)e?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let e of this._downsamplePasses)e?.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 e of dO)e.deref()?.dispose();dO.clear(),cO++}(),function(){for(let e of JM){let t=e.deref();t!==void 0&&(t.sprite.removeFromParent(),t.material.dispose())}JM.clear(),Wb++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let e of Object.values(this._encodeMaterials))e?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),it.transmissionRenderTarget.value=Hl,it.normalRenderTarget.value=Hl,it.aoRenderTarget.value=Hl,it.reflectionRenderTarget.value=Nc,it.reflectionDepthPyramid.value=Nc,it.reflectionEnvMap.value=Nc,it.reflectionPlanarTarget.value=Nc,it.reflectionPlanarEnabled.value=0,it.reflectionResolveTarget.value=wq,it.reflectionResolveEnabled.value=0}})._GAUGE_STALL_MS=3e3});function il(e,t){switch(e.type){case"cavity":return function(i,r){return{...ll(i,r),ridge:i.ridge,valley:i.valley}}(e,t);case"dust":return function(i,r){return{...ll(i,r),color:vo(i.color,r),coverage:Lt(i.coverage,r)??.2,softness:Lt(i.softness,r)??.2,noiseStrength:Lt(i.noiseStrength,r)??.2,noiseScale:Lt(i.noiseScale,r)??1}}(e,t);case"fresnel":return function(i,r){let{bias:n,scale:s,intensity:a,factor:o,color:l}=i;return{...ll(i,r),color:vo(l,r),bias:n,scale:s,intensity:a,factor:o}}(e,t);case"gradient":return function(i,r){let{gradientType:n,smooth:s,colors:a,steps:o,angle:l,offset:u,morph:h}=i;return{...ll(i,r),gradientType:n,smooth:s,colors:a.map(d=>new ct(d[0],d[1],d[2],d[3])),num:a.length,steps:o,offset:new Z(...u.map(d=>typeof d=="number"?d:0)),morph:new Z(...h.map(d=>typeof d=="number"?d:0)),angle:l}}(e,t);case"depth":return function(i,r){let{gradientType:n,near:s,far:a,isVector:o,isWorldSpace:l,origin:u,direction:h,colors:d,steps:c,smooth:p}=i;return{...ll(i,r),gradientType:n,near:s,far:a,isVector:o,isWorldSpace:l,origin:new R(...u),direction:h?new R(...h):new R(1,0,0),colors:d.map(f=>f!==void 0?new ct(f[0],f[1],f[2],f[3]):new ct(0,0,0,0)),steps:c.slice(0,d.length),smooth:p}}(e,t);case"normal":return function(i,r){let{cnormal:n}=i;return{...ll(i,r),cnormal:new R(n[0],n[1],n[2])}}(e,t);case"noise":return function(i,r){return{...ll(i,r),scale:i.scale,move:i.move,fA:new Z(...i.fA.map(n=>typeof n=="number"?n:0)),fB:new Z(...i.fB.map(n=>typeof n=="number"?n:0)),size:new R(...i.size),distortion:new Z(...i.distortion.map(n=>typeof n=="number"?n:0)),colorA:vo(i.colorA,r),colorB:vo(i.colorB,r),colorC:vo(i.colorC,r),colorD:vo(i.colorD,r),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}(e,t);case"rainbow":return function(i,r){return{...ll(i,r),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new R(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new R(...i.offset)}}(e,t);case"toon":return function(i,r){return{...ll(i,r),positioning:i.positioning,colors:i.colors.map(n=>new ct(n[0],n[1],n[2],n[3])),num:i.colors.length,steps:i.steps,source:new R(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:vo(i.shadowColor,r),offset:new R(...i.offset)}}(e,t);case"outline":return function(i,r){return{...ll(i,r),outlineColor:vo(i.outlineColor,r),contourColor:vo(i.contourColor,r),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new R(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}(e,t);case"transmission":return function(i,r){return{...ll(i,r),thickness:i.thickness,ior:i.ior,roughness:i.roughness,attenuationColor:i.attenuationColor!==void 0?vo(i.attenuationColor,r):{r:1,g:1,b:1,a:1},attenuationDistance:i.attenuationDistance??0}}(e,t);case"reflection":return function(i,r){return{...ll(i,r),blur:Lt(i.blur,r)??0,thickness:Lt(i.thickness,r)??.001,steps:Lt(i.steps,r)??60,stepSize:Lt(i.stepSize,r)??.005,tracingMode:i.tracingMode,mirror:i.mirror??0}}(e,t);case"pattern":return function(i,r){return{...ll(i,r),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Z(...i.offset.map(n=>typeof n=="number"?n:0)),colorA:vo(i.colorA,r),colorB:vo(i.colorB,r),frequency:new Z(...i.frequency.map(n=>typeof n=="number"?n:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Z(...i.vertical.map(n=>typeof n=="number"?n:0)),horizontal:new Z(...i.horizontal.map(n=>typeof n=="number"?n:0)),sides:i.sides}}(e,t);case"vertexColor":return ll(e,t);default:return function(i,r){return{...ll(i,r),color:vo(i.color,r)}}(e,t)}}function nFe(e){return{type:e.type}}function ll(e,t){let{alpha:i,mode:r,isMask:n}=e,s=typeof i=="string"?Number(t.getVariable(i)??100)/100:i;return{...nFe(e),alpha:s,mode:r,isMask:n}}var rl=U(()=>{oe(),CY(),Ed()});function z_(e){let t=e;return t!=null&&t.isInstancedMesh===!0&&t.instanceMatrix!=null&&t.instanceMatrix.isInstancedBufferAttribute===!0}function QD(e){return pd(pd(PB).mul(function(t){let i=t.spInstanceMatrixNode;if(i!==void 0)return pd(i);let r=t.object,n=r.instanceMatrix,s=Math.max(r.count??1,1);if(n.isStorageInstancedBufferAttribute===!0)return pd(f4(lTe(n,"mat4",s),Sa));if(16*s*4<=t.getUniformBufferLimit())return pd(f4(bSe(n.array,"mat4",s),Sa));let a=Jq.get(n);a===void 0&&(a=new MX(n.array,16,1),Jq.set(n,a));let o=n.usage===xd?DSe:gg;return pd(sK(o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)))}(e)))}var pd,f4,Jq,Ko,JA,s2e,a2e=U(()=>{oe(),bi(),pd=e=>e,f4=(e,t)=>e.element(t),Jq=new WeakMap,Ko=Xe(e=>z_(e.object)?RB:ow).once()().toVar("speObjectPosition"),JA=Xe(e=>e.material?.shapeBlendObjectNormal||(z_(e.object)?e.geometry.hasAttribute("normal")?qSe:J(0,1,0):aK)).once()().toVar("speObjectNormal"),pd(Xe(e=>pd(z_(e.object)?QD(e):PB)).once()()),s2e=Xe(e=>{if(!z_(e.object))return VSe;let t=QD(e),i=r=>f4(t,r).xyz;return J(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),Xe(e=>z_(e.object)?Vg(QD(e)).inverse().transpose():kSe).once()(),pd(Xe(e=>pd(z_(e.object)?QD(e).inverse():jSe)).once()())});function yK(e){if(LA.has(e))return;let t={own:e.value,render:e.value};LA.set(e,t),Object.defineProperty(e,"value",{configurable:!0,enumerable:!0,get:()=>t.render,set:i=>{t.render=i,t.own=i}})}function e$(e){let t=LA.get(e);return t!==void 0?t.own:e.value}function _K(e,t){let i=LA.get(e);i!==void 0?i.render=t:e.value=t}var LA,bK,o2e=U(()=>{LA=new WeakMap}),sFe=U(()=>{o2e(),bK=class{constructor(e){this.layerId=e,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(e,t,i){return this.byName.set(e,t),this.uniforms[`f${this.layerId}_${e}`]=t,i!==void 0&&this.liveValues.set(e,i),this}has(e){return this.byName.has(e)}names(){return[...this.byName.keys()]}get(e){let t=this.byName.get(e);if(t===void 0)throw new Error(`TSLLayerParams: unknown param "${e}" (layer f${this.layerId})`);return t}getFloat(e){return this.get(e)}getInt(e){return this.get(e)}getBool(e){return this.get(e)}getVec2(e){return this.get(e)}getVec3(e){return this.get(e)}getVec4(e){return this.get(e)}getColor(e){return this.get(e)}getValue(e){if(this.liveValues.has(e))return this.liveValues.get(e);let t=this.byName.get(e);return t===void 0?void 0:e$(t)}getLiveValue(e){return this.liveValues.get(e)}getNodeValue(e){let t=this.byName.get(e);return t===void 0?void 0:e$(t)}setValue(e,t){let i=this.byName.get(e);i===void 0||t===void 0||(this.liveValues.has(e)&&this.liveValues.set(e,t),i.value=t)}}});function $c(e,t,i){let r=B(e).toVar(),n=B(ut(r.div(Xt(r.add(t.accumAlpha),B(1e-5),B(1))),r,i)).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(r).mul(Pn(i))),n}function Ew(e,t){let i=B(e).toVar(),r=B(i.div(Xt(i.add(t.accumAlpha),B(1e-5),B(1)))).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(i)),r}function gO(e,t,i,r){return h2e({a:e,b:t,alpha:i,mode:r})}function Na(e,t){OB.set(e,t)}function l2e(e){let t=OB.get(e);return t!==void 0?t:(s$.has(e)||(s$.add(e),console.warn(`[spe] Material layer type "${e}" is not available in this runtime build (no WebGPU port, or compiled out) \u2014 rendering flat red.`)),xK)}function aFe(e){return OB.has(e)}var t$,i$,r$,n$,h2e,OB,s$,xK,da=U(()=>{bi(),a2e(),sFe(),o2e(),t$=0,i$=1,r$=2,n$=3,h2e=Xe(e=>{let t=e.a.toVar(),i=e.b.toVar(),r=e.alpha.toVar(),n=e.mode,s=J(1).toVar();return Ve(n.equal(De(t$)),()=>{s.assign(ut(t,i,r))}).ElseIf(n.equal(De(i$)),()=>{s.assign(ut(t,t.mul(i),r))}).ElseIf(n.equal(De(r$)),()=>{s.assign(ut(t,Pn(Pn(t).mul(Pn(i))),r))}).ElseIf(n.equal(De(n$)),()=>{let a=hr(t,J(.5)),o=ut(Pn(Pn(t).mul(Pn(i)).mul(2)),t.mul(i).mul(2),a);s.assign(ut(t,o,r).clamp(0,1))}),s}),OB=new Map,s$=new Set,xK=(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:J(1,0,0),calpha:Ew(r,i)}}});function u2e(e){let t=pl(it.aoRenderTarget.sample(gu).rgb),i=uw(it.aoEnabledUniform);return e!==null&&(i=uw(i.mul(Ki(e,B(1),B(0))))),pl(ut(J(1),t,i))}var a$,o$,pl,uw,bme,xme,d2e,c2e,p2e=U(()=>{var e;vn(),bi(),ua(),da(),{diffuseContribution:a$,specularColorBlended:o$}=I,pl=t=>t,uw=t=>t,bme=Xe(t=>{let i=Ao.dot(pl(t.lightDirection)),r=Me(i.mul(.5).add(.5),0),n=r.fwidth().mul(.5);return ut(J(.7),J(1),Qr(B(.7).sub(n.x),B(.7).add(n.x),r.x))}),xme=Xe(t=>{let i=pl(t.lightDirection).add(lw).normalize(),r=Ao.dot(i).clamp(),n=lw.dot(i).clamp(),s=n.mul(-5.55473).sub(6.98316).mul(n).exp2(),a=nx.mul(s.oneMinus()).add(s),o=B(.25),l=r4.mul(.5).add(1).mul(1/Math.PI).mul(r.pow(r4));return a.mul(o).mul(l)}),e=class extends Nx{direct(t){let{lightDirection:i,lightColor:r,reflectedLight:n}=t,s=pl(bme({lightDirection:i})).mul(r);n.directDiffuse.addAssign(s.mul(pl(Wl.rgb).mul(1/Math.PI))),n.directSpecular.addAssign(s.mul(uw(xme({lightDirection:i}))))}},d2e=class extends e{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(t,...i){super.finish?.call(this,t,...i);let{reflectedLight:r,outgoingLight:n}=t.context,s=u2e(this.aoOcclusionGate),a=pl(r.directDiffuse.add(r.indirectDiffuse));n.subAssign(a.mul(Pn(s)))}},c2e=class extends YI{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(t,i){let r=t;if(r.lightNode?.light?.userData?.splineDiffuseOnly===!0){if(this.envIrradianceActive)return;let n=pl(Ao).dot(r.lightDirection).clamp().mul(r.lightColor),s=I.BRDF_Lambert({diffuseColor:a$});return void r.reflectedLight.directDiffuse.addAssign(n.mul(s))}super.direct(t,i)}}});function k_(e,t){return Uc(t==="x"?e.x:t==="y"?e.y:e.z)}function L2(e,t){return Va(WSe(e,J(t,1)).div(2).add(.5).xy)}function oFe(e,t,i){let r=B(e.div(Xt(e.add(t.accumAlpha),B(1e-5),B(1)))).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(e).mul(Pn(i))),r}function kE(e){let t=e.getValue("projection")??0,i=e.getValue("axis")??0,r=i>=0&&i<=2?i:0,n=e.getValue("projectionAxis")??-1,s=n>=0&&n<=2?n:1,a=f2e(e.get("mat")),o=e.getVec2("size");if(t===1){let u=Ko,h=r===0?u.zy:r===1?u.xz:u.xy,d=Me(h.add(1).div(2)).toVar(),c=Me(L2(a,Va(d.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[Va(c)],weights:null}}if(t===2){let u=J(Ut(Ko)).toVar(),{a:h,b:d,pole:c}=l$[s],p=B(Mf(k_(u,h),k_(u,d)).div(6.283).add(.5)).toVar(),f=B(tK(k_(u,c)).div(3.1415).add(.5)).toVar(),m=Me(p,f).toVar(),g=Me(L2(a,Va(m.mul(2).sub(1)))).toVar();return{uvs:[Va(g)],weights:null}}if(t===3){let u=J(Ut(Ko)).toVar(),{a:h,b:d,pole:c}=l$[s],p=B(Mf(k_(u,h),k_(u,d)).div(6.283).add(.5)).toVar(),f=B(k_(hn(Ko),c).div(o.y.mul(.5))).toVar(),m=B(f.div(2).add(.5)).toVar(),g=Me(p,m).toVar(),v=Me(L2(a,Va(g.mul(2).sub(1)))).toVar();return{uvs:[Va(v)],weights:null}}if(t===4){let u=e.getFloat("blending"),h=J(Ko).toVar(),d=Me(h.xy.add(1).div(2)).toVar(),c=Me(h.zy.add(1).div(2)).toVar(),p=Me(h.xz.add(1).div(2)).toVar();for(let v of[d,c,p])v.assign(L2(a,Va(v.mul(2).sub(1).div(o.mul(.5)))));let f=B(Pn(u).mul(125).add(3)).toVar(),m=J(JA).toVar(),g=J(ui(Ut(m))).toVar();return g.assign(Xl(g,J(f))),g.divAssign(et(g,J(1))),{uvs:[Va(d),Va(c),Va(p)],weights:hn(g)}}let l=Me(L2(a,Va(tr().mul(2).sub(1)))).toVar();return{uvs:[Va(l)],weights:null}}function JD(e,t,i){let r=Me(t).toVar(),n=Me(rw(r)).toVar(),s=Me(nw(r)).toVar(),a=h=>Uc(i.mul(CB(To(e.sample(h)).rgb))),o=B(a(Va(r))).toVar(),l=B(a(Va(r.add(n))).sub(o)).toVar(),u=B(a(Va(r.add(s))).sub(o)).toVar();return Va(Me(l,u))}function eN(e,t,i){let r=J(rw(e)).toVar(),n=J(nw(e)).toVar(),s=J(Ut(t)).toVar(),a=J(Ut(qn(n,s))).toVar(),o=J(Ut(qn(s,r))).toVar(),l=B(et(r,a).mul(AB)).toVar(),u=J(jc(l).mul(i.x.mul(a).add(i.y.mul(o)))).toVar();return hn(Ut(ui(l).mul(s).sub(u)))}function w9(e,t){let i,r=e.get("texture"),n=e.has("loaded")?e.getFloat("loaded"):B(1),s=l=>{let u=To(r.sample(l)),h=t==="luminance"?CB(u.rgb):u[t];return B(h).toVar()},{uvs:a,weights:o}=kE(e);if(o!==null){let l=s(a[0]),u=s(a[1]),h=s(a[2]);i=Uc(l.mul(o.z).add(u.mul(o.x)).add(h.mul(o.y)))}else i=Uc(s(a[0]));return Uc(ut(B(1),i,n))}var Uc,Va,hn,To,f2e,l$,wme,m2e=U(()=>{vn(),bi(),da(),Uc=e=>e,Va=e=>e,hn=e=>e,To=e=>e,f2e=e=>e,l$=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],Na("texture",wme=(e,t,i)=>{let r,n=e.getValue("projection")??0,s=e.getValue("axis")??0,a=s>=0&&s<=2?s:0,o=e.getValue("side")??0,l=e.get("texture"),u=e.getFloat("crop"),{uvs:h,weights:d}=kE(e),c=[...h],p=null;if(n===1){if(r=To(l.sample(h[0])),o!==2){let y=a===0?J(1,0,0):a===1?J(0,1,0):J(0,0,1),_=et(JA,y);p=Uc(hr(B(0),o===1?_.mul(-1):_))}}else if(n===2||n===3)r=function(y,_){if(y.value.minFilter===yt&&y.value.magFilter===yt)return To(y.sample(_));let b=Me(rw(_)).toVar(),x=Me(nw(_)).toVar();return b.x.subAssign(Ct(b.x.add(.5))),x.x.subAssign(Ct(x.x.add(.5))),To(y.sample(_).grad(b,x))}(l,h[0]);else if(n===4){let y=d,_=To(l.sample(h[0])),b=To(l.sample(h[1])),x=To(l.sample(h[2]));r=To(_.mul(y.z).add(b.mul(y.x)).add(x.mul(y.y)))}else r=To(l.sample(h[0]));let f=e.has("loaded")?e.getFloat("loaded"):B(1),m=Pe(ut(Pe(0,0,0,1),To(r),f)).toVar(),g=J(m.rgb).toVar(),v=B(t.alpha.mul(m.a)).toVar();return p!==null&&v.mulAssign(p),function(y,_,b){Ve(y.greaterThan(.5),()=>{for(let x of b)Ve(x.x.lessThan(0).or(x.x.greaterThan(1)).or(x.y.lessThan(0)).or(x.y.greaterThan(1)),()=>{_.assign(0)})})}(u,Uc(v),c),v.mulAssign(t.mask),{color:hn(g),calpha:oFe(Uc(v),i,t.isMask)}}),Na("video",wme)});function tN(e){return _2e({c:e})}function Sg(e){return b2e({p:e})}function lFe(e){return x2e({m:e})}function yv(e){return w2e({x:e})}function S9(e){return S2e({r:e})}function Bx(e){return T2e({v:e})}function iN(e){return M2e({x:e})}function hFe(e){return E2e({x:e})}function vO(e){return A2e({P:e})}function T9(e){return C2e({p3:e})}function VE(e,t,i){return P2e({a:e,b:t,k:i})}function g2e(e,t,i){return R2e({a:e,b:t,k:i})}function v2e(e,t,i,r,n){return D2e({value:e,input_min:t,input_max:i,output_min:r,output_max:n})}function y2e(e,t,i,r,n){return N2e({x:e,style:t,smoothness:i,seed:r,quality:n})}var Sme,M9,B2,_2e,b2e,x2e,w2e,S2e,T2e,Tme,M2e,Mme,E2e,Eme,A2e,Ame,C2e,P2e,R2e,D2e,N2e,BA,eC=U(()=>{bi(),Sme=oK,M9=Zr,B2=.1666667,_2e=Xe(e=>{let t=e.c,i=Pa(et(t,J(17,59.4,15))).mul(4096),r=gr(i.mul(512)),n=i.mul(.125),s=gr(n.mul(512)),a=n.mul(.125),o=gr(a.mul(512));return J(s,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),b2e=Xe(e=>{let t=e.p,i=Ct(t.add(et(t,J(.3333333)))).toVar(),r=t.sub(i).add(et(i,J(B2))).toVar(),n=hr(J(0),r.sub(r.yzx)).toVar(),s=n.mul(Pn(n.zxy)).toVar(),a=Pn(n.zxy.mul(Pn(n))).toVar(),o=r.sub(s).add(B2).toVar(),l=r.sub(a).add(2*B2).toVar(),u=r.sub(1).add(3*B2).toVar(),h=Pe(et(r,r),et(o,o),et(l,l),et(u,u)).toVar();h.assign(Pe(.6).sub(h).max(0));let d=Pe(et(tN(i),r),et(tN(i.add(s)),o),et(tN(i.add(a)),l),et(tN(i.add(1)),u)).toVar();return h.mulAssign(h),h.mulAssign(h),d.mulAssign(h),et(d,Pe(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),x2e=Xe(e=>{let t=e.m,i=Vg(J(-.37,.36,.85),J(-.14,-.93,.34),J(.92,.01,.4)),r=Vg(J(-.55,-.39,.74),J(.33,-.91,-.24),J(.77,.12,.63)),n=Vg(J(-.71,.52,-.47),J(-.08,-.72,-.68),J(-.7,-.45,.56));return Sg(t.mul(i)).mul(.5333333).add(Sg(t.mul(2).mul(r)).mul(.2666667)).add(Sg(t.mul(4).mul(n)).mul(.1333333)).add(Sg(t.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),w2e=Xe(e=>{let t=e.x;return yd(t.mul(34).add(1).mul(t),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),S2e=Xe(e=>$M(1.79284291400159,e.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),T2e=Xe(e=>{let t=e.v,i=Me(1/6,1/3),r=Pe(0,.5,1,2),n=Ct(t.add(et(t,i.yyy))).toVar(),s=t.sub(n).add(et(n,i.xxx)).toVar(),a=hr(s.yzx,s.xyz).toVar(),o=Pn(a).toVar(),l=Fi(a.xyz,o.zxy).toVar(),u=mt(a.xyz,o.zxy).toVar(),h=s.sub(l).add(i.xxx.mul(1)).toVar(),d=s.sub(u).add(i.xxx.mul(2)).toVar(),c=s.sub(1).add(i.xxx.mul(3)).toVar();n.assign(yd(n,289));let p=yv(yv(yv(n.z.add(Pe(0,l.z,u.z,1))).add(n.y).add(Pe(0,l.y,u.y,1))).add(n.x).add(Pe(0,l.x,u.x,1))).toVar(),f=r.wyz.mul(1/7).sub(r.xzx).toVar(),m=p.sub(Ct(p.mul(f.z).mul(f.z)).mul(49)).toVar(),g=Ct(m.mul(f.z)).toVar(),v=Ct(m.sub(g.mul(7))).toVar(),y=g.mul(f.x).add(f.yyyy).toVar(),_=v.mul(f.x).add(f.yyyy).toVar(),b=$M(1,ui(y)).sub(ui(_)).toVar(),x=Pe(y.xy,_.xy).toVar(),w=Pe(y.zw,_.zw).toVar(),S=Ct(x).mul(2).add(1).toVar(),T=Ct(w).mul(2).add(1).toVar(),M=hr(b,Pe(0)).negate().toVar(),E=x.xzyw.add(S.xzyw.mul(M.xxyy)).toVar(),A=w.xzyw.add(T.xzyw.mul(M.zzww)).toVar(),P=J(E.xy,b.x).toVar(),N=J(E.zw,b.y).toVar(),D=J(A.xy,b.z).toVar(),O=J(A.zw,b.w).toVar(),z=S9(Pe(et(P,P),et(N,N),et(D,D),et(O,O))).toVar();P.mulAssign(z.x),N.mulAssign(z.y),D.mulAssign(z.z),O.mulAssign(z.w);let L=mt($M(.6,Pe(et(s,s),et(h,h),et(d,d),et(c,c))),0).toVar();return L.mulAssign(L),et(L.mul(L),Pe(et(P,s),et(N,h),et(D,d),et(O,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Tme=Xe(e=>{let t=e.x;return t.sub(Ct(t.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),M2e=Xe(e=>{let t=e.x;return Tme({x:t.mul(34).add(1).mul(t)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),Mme=Xe(e=>{let t=e.p,i=Ct(t).toVar(),r=t.sub(i).toVar();r.assign(r.mul(r).mul($M(3,r.mul(2))));let n=i.xxyy.add(Pe(0,1,0,1)).toVar(),s=iN(n.xyxy).toVar(),a=iN(s.xyxy.add(n.zzww)).toVar().add(i.zzzz).toVar(),o=iN(a).toVar(),l=iN(a.add(1)).toVar(),u=gr(o.mul(1/41)).toVar(),h=gr(l.mul(1/41)).toVar().mul(r.z).add(u.mul(Pn(r.z))).toVar(),d=h.yw.mul(r.x).add(h.xz.mul(Pn(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(Pn(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),E2e=Xe(e=>{let t=J(e.x).toVar(),i=B(0).toVar(),r=B(.5).toVar(),n=J(100).toVar();return Zr(5,()=>{i.addAssign(r.mul(function(s){return Mme({p:s})}(t))),t.assign(t.mul(2).add(n)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),Eme=Xe(e=>{let t=e.t;return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),A2e=Xe(e=>{let t=e.P,i=Ct(t).toVar(),r=i.add(J(1)).toVar();i.assign(yd(i,289)),r.assign(yd(r,289));let n=gr(t).toVar(),s=n.sub(J(1)).toVar(),a=Pe(i.x,r.x,i.x,r.x).toVar(),o=Pe(i.yy,r.yy).toVar(),l=Pe(i.zzzz).toVar(),u=Pe(r.zzzz).toVar(),h=yv(yv(a).add(o)).toVar(),d=yv(h.add(l)).toVar(),c=yv(h.add(u)).toVar(),p=d.div(7).toVar(),f=gr(Ct(p).div(7)).sub(.5).toVar();p.assign(gr(p));let m=Pe(.5).sub(ui(p)).sub(ui(f)).toVar(),g=hr(m,Pe(0)).toVar();p.subAssign(g.mul(hr(0,p).sub(.5))),f.subAssign(g.mul(hr(0,f).sub(.5)));let v=c.div(7).toVar(),y=gr(Ct(v).div(7)).sub(.5).toVar();v.assign(gr(v));let _=Pe(.5).sub(ui(v)).sub(ui(y)).toVar(),b=hr(_,Pe(0)).toVar();v.subAssign(b.mul(hr(0,v).sub(.5))),y.subAssign(b.mul(hr(0,y).sub(.5)));let x=J(p.x,f.x,m.x).toVar(),w=J(p.y,f.y,m.y).toVar(),S=J(p.z,f.z,m.z).toVar(),T=J(p.w,f.w,m.w).toVar(),M=J(v.x,y.x,_.x).toVar(),E=J(v.y,y.y,_.y).toVar(),A=J(v.z,y.z,_.z).toVar(),P=J(v.w,y.w,_.w).toVar(),N=S9(Pe(et(x,x),et(S,S),et(w,w),et(T,T))).toVar();x.mulAssign(N.x),S.mulAssign(N.y),w.mulAssign(N.z),T.mulAssign(N.w);let D=S9(Pe(et(M,M),et(A,A),et(E,E),et(P,P))).toVar();M.mulAssign(D.x),A.mulAssign(D.y),E.mulAssign(D.z),P.mulAssign(D.w);let O=et(x,n).toVar(),z=et(w,J(s.x,n.yz)).toVar(),L=et(S,J(n.x,s.y,n.z)).toVar(),V=et(T,J(s.xy,n.z)).toVar(),G=et(M,J(n.xy,s.z)).toVar(),Y=et(E,J(s.x,n.y,s.z)).toVar(),$=et(A,J(n.x,s.yz)).toVar(),Q=et(P,s).toVar(),ue=function(we){return Eme({t:we})}(n).toVar(),pe=ut(Pe(O,z,L,V),Pe(G,Y,$,Q),ue.z).toVar(),xe=ut(pe.xy,pe.zw,ue.y).toVar();return ut(xe.x,xe.y,ue.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Ame=Xe(e=>{let t=gr(e.p3.mul(.1031)).toVar();return t.addAssign(et(t,t.yzx.add(33.33))),gr(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),C2e=Xe(e=>{let t=gr(e.p3.mul(J(.1031,.103,.0973))).toVar();return t.addAssign(et(t,t.yxz.add(33.33))),gr(t.xxy.add(t.yxx).mul(t.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),P2e=Xe(e=>{let{a:t,b:i,k:r}=e,n=Qr(0,1,i.sub(t).mul(.5).div(r).add(.5)).toVar(),s=r.mul(n).mul(Pn(n)).toVar();return ut(i,t,n).sub(s)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),R2e=Xe(e=>{let{a:t,b:i,k:r}=e,n=Qr(1,0,t.sub(i).mul(.5).div(r).add(.5)).toVar(),s=r.mul(n).mul(Pn(n)).toVar();return ut(t,i,n).add(s)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),D2e=Xe(e=>{let{value:t,input_min:i,input_max:r,output_min:n,output_max:s}=e,a=r.sub(i).toVar(),o=s.sub(n).toVar(),l=t.sub(i).div(a).toVar();return n.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"}]}),N2e=Xe(e=>{let{x:t,style:i,smoothness:r,seed:n,quality:s}=e,a=Ha(Ct(t)).toVar(),o=gr(t).toVar(),l=B(8).toVar(),u=B(8).toVar(),h=B(8).toVar(),d=B(8).toVar(),c=B(8).toVar(),p=B(8).toVar(),f=Ha(0).toVar(),m=J(0).toVar(),g=De(s).toVar(),v=()=>({start:g.negate(),end:g,condition:"<=",type:"int"});M9(v(),v(),v(),({i:_,j:b,k:x})=>{let w=Ha(_,b,x).toVar(),S=J(w).add(T9(J(a.add(w)).add(n))).sub(o).toVar(),T=Yi(S).toVar();l.assign(VE(T,l,r)),Ve(T.lessThan(u),()=>{d.assign(u),u.assign(T),f.assign(Ha(_,b,x)),m.assign(S)}).ElseIf(T.lessThan(d),()=>{d.assign(T)})}),Ve(i.notEqual(De(0)).and(i.notEqual(De(5))).and(i.notEqual(De(7))),()=>{M9(v(),v(),v(),({i:_,j:b,k:x})=>{let w=f.add(Ha(_,b,x)).toVar(),S=J(w).add(T9(J(a.add(w)).add(n))).sub(o).toVar(),T=et(m.add(S).mul(.5),S.sub(m)).toVar(),M=et(m.add(S).mul(.5),Ut(S.sub(m))).toVar();c.assign(VE(T,c,r)),p.assign(Fi(p,M));let E=Ha(_,b,x).toVar();Ve(eK(Sme(E,f)),()=>{let A=J(E).add(T9(J(a.add(E)).add(n))).sub(o).toVar(),P=Yi(A).toVar();h.assign(VE(P,h,r))})})});let y=B(0).toVar();return Ve(i.equal(De(0)),()=>{y.assign(l)}).ElseIf(i.equal(De(1)),()=>{y.assign(h)}).ElseIf(i.equal(De(2)),()=>{y.assign(h.sub(l))}).ElseIf(i.equal(De(3)),()=>{let _=B(3).toVar(),b=mt(_.sub(ui(u.sub(d))),0).div(_).toVar();y.assign(Fi(u,d).sub(b.mul(b).mul(_).mul(1/4)))}).ElseIf(i.equal(De(4)),()=>{y.assign(EB(c.mul(5)))}).ElseIf(i.equal(De(5)),()=>{y.assign(Xl(l,3))}).ElseIf(i.equal(De(6)),()=>{let _=r.mul(.25).add(.0125).toVar(),b=Xl(r,3).mul(.25).add(.0125).toVar();y.assign(Qr(_.sub(_.mul(b)),_.add(_.mul(b)),p))}).ElseIf(i.equal(De(7)),()=>{y.assign(function(_){return Ame({p3:_})}(J(a.add(f)).add(n)))}),y}).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"}]}),BA=[Sg,lFe,Bx,hFe,vO]});function I2e(e,t,i,r){return gl(e.add(t).mul(i).mul(.001).add(O2e).add(r.mul(.1)))}function uFe(e,t,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 f=>gl(B2e({...c,p:f,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(f){let m=h$.get(f);if(m===void 0){let g=BA[f]??BA[0];m=Xe(v=>{let{n:y,scale:_,intensity:b,offset:x,movement:w}=v,S=gl(v.p);return S.add(y.mul(g(I2e(S,x,_,w))).mul(b))}).setLayout({name:`spe_displaceScalar${f}`,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"}]}),h$.set(f,m)}return m}(d);return f=>gl(p({...c,p:f}))}(e,i),n=J(r(t)).toVar(),s=J(function(u){return L2e({v:u})}(i)).toVar(),a=Ut(qn(i,s)).toVar(),o=J(r(gl(t.add(s)))).toVar(),l=J(r(gl(t.add(a)))).toVar();return{position:n,normal:gl(Ut(qn(o.sub(n),l.sub(n))))}}var gl,O2e,L2e,h$,B2e,E9,Cme,d1,F2,rN,Pme,dFe=U(()=>{bi(),eC(),gl=e=>e,O2e=1e-4,L2e=Xe(e=>{let t=gl(e.v);return Ut(gl(Ki(ui(t.x).greaterThan(ui(t.z)),J(t.y.negate(),t.x,0),J(0,t.z.negate(),t.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),h$=new Map,B2e=Xe(e=>{let{n:t,scale:i,intensity:r,offset:n,movement:s,smoothness:a}=e,o=gl(e.p),l=B(y2e(I2e(o,n,i,s),e.voronoiStyle,a,e.seed,e.quality)).toVar();return l.assign(v2e(l,e.lowCut,e.highCut,B(0),B(1))),l.assign(g2e(l,B(0),a.mul(.25))),l.assign(VE(l,B(1),a.mul(.25))),o.add(t.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"}]})}),cFe=U(()=>{da(),Na("color",(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:e.getColor("color"),calpha:Ew(r,i)}})}),pFe=U(()=>{bi(),da(),E9=e=>e,Cme=e=>e,Na("depth",(e,t,i)=>{let r,n=e.get("colors"),s=e.get("steps"),a=(e.getValue("colors")??n.array).length,o=e.getValue("smooth")===!0,l=(e.getValue("isVector")??1)>.5,u=(e.getValue("gradientType")??0)===0,h=(e.getValue("isWorldSpace")??0)>.5,d=e.getFloat("near"),c=e.getFloat("far");if(l){let g=e.getVec3("origin"),v=h?Jl:Ko;if(u){let y=Ut(e.getVec3("direction"));r=et(y,v.sub(g))}else r=Yi(v.sub(g))}else r=Yi(Jl.sub(qf));let p=r.sub(d).div(c.sub(d)).toVar(),f=Pe(n.element(0)).toVar();for(let g=1;g<a;g++){let v=E9(s.element(g-1)),y=E9(s.element(g)),_=Xt(p.sub(v).div(y.sub(v)),B(0),B(1)),b=o?Qr(B(0),B(1),_):_;f.assign(ut(f,Cme(n.element(g)),b))}let m=t.alpha.mul(f.a).mul(t.mask);return{color:f.rgb,calpha:$c(m,i,t.isMask)}})}),fFe=U(()=>{bi(),da(),ua(),Na("cavity",(e,t,i)=>{let r=Xt(e.getFloat("ridge"),0,2),n=Xt(e.getFloat("valley"),0,2),s=it.normalViewRenderTarget,a=it.resolution,o=$g("randomColor","vec3").x.toVar(),l=gu.toVar(),u=Me(B(1).div(a.x),B(1).div(a.y)).toVar(),h=(E,A)=>s.sample(l.add(Me(E,A)).toVar()).toVar(),d=h(B(0),u.y.negate()),c=h(B(0),u.y),p=h(u.x.negate(),B(0)),f=h(u.x,B(0)),m=E=>E.a.equal(o).and(et(E.xyz,E.xyz).greaterThan(.5)),g=m(d).and(m(c)).and(m(p)).and(m(f)),v=d.y.sub(c.y).add(f.x.sub(p.x)).toVar(),y=B(.5).div(mt(r.mul(r),B(1e-4))).toVar(),_=B(.7).div(mt(n.mul(n),B(1e-4))).toVar(),b=(E,A)=>Ki(E.lessThan(B(.5).div(A)),E.mul(B(1).sub(E.mul(A))),B(.25).div(A)),x=Ki(g,Ki(v.greaterThan(0),b(v,y).mul(2),b(v.negate(),_).mul(-2)),B(0)).toVar(),w=Ki(x.abs().lessThan(.001),B(0),x).toVar(),S=J(Xt(w.mul(.5).add(.5),0,1)),T=Ki(w.notEqual(0),B(1),B(0)),M=Ki(t.isMask,B(1),T);return{color:S,calpha:$c(t.alpha.mul(t.mask).mul(M),i,t.isMask)}})}),Aw=U(()=>{bi(),d1=Xe(e=>{let t=e.material?.vertexObjectNormal??null;return t?n4(t).transformNormalByInverseViewMatrix(_u).normalize():$Se}).once()().toVar("speVertexNormalWorld")}),mFe=U(()=>{bi(),Aw(),da(),eC(),Na("dust",(e,t,i)=>{let r=e.getFloat("coverage"),n=e.getFloat("softness"),s=e.getFloat("noiseStrength"),a=e.getFloat("noiseScale"),o=et(Ut(d1),J(0,1,0)),l=B(0).toVar();Ve(s.notEqual(0),()=>{let c=Sg(Ko.div(a).toVar().add(J(1.7,9.2,1)));l.assign(c.mul(s))});let u=mt(n,1e-4).toVar(),h=ut(u.add(1),u.add(1).negate(),Xt(r,0,1)).toVar(),d=Qr(h.sub(u),h.add(u),o.add(l)).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:$c(d,i,t.isMask)}})}),gFe=U(()=>{bi(),Aw(),da(),F2=(e,t)=>e.element(t),Na("fresnel",(e,t,i)=>{let r=F2(Mw,2).w.equal(-1),n=J(F2(_u,0).z,F2(_u,1).z,F2(_u,2).z).negate(),s=Jl.sub(qf),a=Ki(r,s,n),o=e.getFloat("bias").add(e.getFloat("scale").mul(Xl(ui(e.getFloat("factor").add(et(Ut(a),Ut(d1)))),e.getFloat("intensity")))),l=Xt(o,0,1).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:$c(l,i,t.isMask)}})}),vFe=U(()=>{bi(),da(),rN=e=>e,Pme=e=>e,Na("gradient",(e,t,i)=>{let r=e.get("colors"),n=e.get("steps"),s=(e.getValue("colors")??r.array).length,a=(e.getValue("steps")??n.array).length,o=Math.min(10,s,a),l=e.getInt("gradientType"),u=e.getBool("smooth"),h=e.getVec2("offset"),d=e.getVec2("morph"),c=e.getFloat("angle"),p=tr(),f=Pe(r.element(0)).toVar(),m=Me(d.div(p)).toVar(),g=Me(B(.5).add(m.x),m.y).toVar(),v=Me(Yo(c).mul(g.x).sub(Pa(c).mul(g.y)),Pa(c).mul(g.x).add(Yo(c).mul(g.y))).toVar(),y=Me(p.sub(.5).add(h).div(2).add(v.div(2))),_=B(et(y,v).div(et(v,v))).toVar();Ve(l.equal(De(1)),()=>{_.assign(CSe(p.add(d).mul(3),p.add(h).add(1)).add(c))}).ElseIf(l.equal(De(2)),()=>{let x=Mf(p.x.add(d.x).sub(.5).add(h.x),p.y.add(d.y).sub(.5).add(h.y)).mul(-1);_.assign(gr(c.div(fq).div(-2).add(x.div(fq).mul(.5))))});for(let x=1;x<o;x++){let w=rN(n.element(x-1)),S=rN(n.element(x)),T=Xt(_.sub(w).div(S.sub(w)),B(0),B(1)),M=rN(Ki(u,Qr(B(0),B(1),T),T));f.assign(ut(f,Pme(r.element(x)),M))}let b=t.alpha.mul(f.a).mul(t.mask);return{color:f.rgb,calpha:$c(b,i,t.isMask)}})}),yFe=U(()=>{bi(),da(),Na("matcap",(e,t,i)=>{let r=e.getFloat("rotation"),n=Ut($f.negate()),s=Ut(J(n.z,0,n.x.negate())),a=qn(n,s),o=Me(et(s,Ao),et(a,Ao)),l=Yo(r),u=Pa(r),h=Me(l.mul(o.x).sub(u.mul(o.y)),u.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=e.get("texture").sample(h),c=t.alpha.mul(t.mask);return{color:d.rgb,calpha:$c(c,i,t.isMask)}})}),_Fe=U(()=>{bi(),da(),eC(),Na("noise",(e,t,i)=>{try{if(new URLSearchParams(window.location.search).get("dbgnoise")==="0")return{color:J(0),calpha:B(0)}}catch{}let r=Math.trunc(e.getValue("noiseType")??0),n=B(mt(ui(e.getFloat("scale")),.001)).toVar(),s=J(Ko.div(e.getVec3("size"))).toVar();s.divAssign(n);let a=e.getFloat("move"),o=e.getVec4("colorA"),l=e.getVec4("colorC"),u=Pe(0).toVar();if(r===5){let d=e.getFloat("smoothness"),c=B(y2e(s.add(a),e.getInt("voronoiStyle"),d,e.getFloat("seed"),e.getInt("quality"))).toVar();c.assign(v2e(c,e.getFloat("lowCut"),e.getFloat("highCut"),B(0),B(1))),c.assign(g2e(c,B(0),d.mul(.25))),c.assign(VE(c,B(1),d.mul(.25))),u.assign(ut(o,l,c))}else{let d=BA[r]??BA[0],c=e.getVec4("colorB"),p=e.getVec4("colorD"),f=J(e.getVec2("distortion"),1).toVar(),m=J(e.getVec2("fA"),1).toVar(),g=J(e.getVec2("fB"),1).toVar(),v=J(d(s),d(s.add(J(1))),d(s.add(J(1)))).toVar(),y=J(d(s.add(f.mul(v)).add(m).add(a)),d(s.add(f.mul(v)).add(g).add(a)),d(s.mul(v))).toVar(),_=B(d(s.add(y))).toVar();u.assign(ut(o,c,Xt(_.mul(_).mul(4),B(0),B(1)))),u.assign(ut(u,l,Xt(Yi(v),B(0),B(1)))),u.assign(ut(u,p,Xt(Yi(y.x),B(0),B(1))))}let h=t.alpha.mul(u.a).mul(t.mask);return{color:Xt(u,B(0),B(1)).rgb,calpha:$c(h,i,t.isMask)}})}),bFe=U(()=>{bi(),da(),Na("normal",(e,t,i)=>({color:KSe(Ut(Ao)).mul(hr(J(.5),e.getVec3("cnormal"))),calpha:Ew(t.alpha.mul(t.mask),i)}))});function A9(e){return F2e({p:e})}function nN(e,t){return U2e({uv:e,a:t})}function V_(e,t,i,r,n){return z2e({uv:e,frequency:t,variation:i,zigzag:r,rotation:n})}function sN(e,t){let i={uv:t.uv,frequency:t.frequency,size:t.size,variation:t.variation,smoothness:t.smoothness,zigzag:t.zigzag,rotation:t.rotation};switch(e){case 1:return V2e(i);case 2:return G2e({...i,sides:t.sides});case 3:return j2e(i);case 4:return W2e(i);case 5:return H2e(i);case 6:return q2e(i);case 7:return $2e(i);default:return k2e(i)}}var G_,Rme,F2e,U2e,z2e,k2e,V2e,Dme,G2e,Nme,j2e,Ime,W2e,H2e,q2e,Ome,$2e,U2,C9,Lme,Bme,Fme,Ume,zme,P9,kme,_v,Vme,Gme,R9,jme,xFe=U(()=>{bi(),da(),G_=2*Math.PI,Rme=Math.PI/180,F2e=Xe(e=>{let t=gr(e.p.xyx.mul(.1031)).toVar();return t.addAssign(et(t,t.yzx.add(33.33))),gr(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),U2e=Xe(e=>{let t=e.uv,i=.5,r=B(e.a.mul(Rme)).toVar(),n=Me(Yo(r).mul(t.x.sub(i)).add(Pa(r).mul(t.y.sub(i))).add(i),Yo(r).mul(t.y.sub(i)).sub(Pa(r).mul(t.x.sub(i))).add(i));return gr(n)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),z2e=Xe(e=>{let t=Me(e.uv.mul(e.frequency)).toVar(),i=Me(Ct(t)).toVar(),r=B(yd(i.y,2)).toVar();t.x.addAssign(r.mul(e.zigzag));let n=Me(gr(t)).toVar();n.assign(n.mul(2).sub(1)),i.assign(Ct(t));let s=B(A9(i).mul(5).add(1)).toVar(),a=B(ut(B(1),s,e.variation)).toVar();return n.mulAssign(a),n}).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"}]}),k2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Yi(t).sub(e.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"}]}),V2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar(),i=B(Yi(t)).toVar(),r=B(Qr(e.smoothness.negate(),e.smoothness,i.sub(e.size))).toVar(),n=B(Qr(e.smoothness.negate(),e.smoothness,i.sub(e.size.mul(.5)))).toVar();return r.add(Pn(n))}).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"}]}),Dme=Xe(e=>{let t=B(B(G_).div(B(e.n))).toVar(),i=B(e.r.mul(uTe(t.mul(.5)))).toVar(),r=Me(e.p.yx.negate()).toVar(),n=B(t.mul(Ct(Mf(r.y,r.x).add(t.mul(.5)).div(t)))).toVar(),s=Me(Yo(n),Pa(n)).toVar();return r.assign(Me(s.x.mul(r.x).add(s.y.mul(r.y)),s.y.negate().mul(r.x).add(s.x.mul(r.y)))),Yi(r.sub(Me(e.r,Xt(r.y,i.negate(),i)))).mul(jc(r.x.sub(e.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),G2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Dme({p:t,r:e.size,n:e.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"}]}),Nme=Xe(e=>{let t=e.b,i=Me(ui(e.p)).toVar();i.assign(Ki(i.y.greaterThan(i.x),i.yx,i.xy));let r=Me(i.sub(t)).toVar(),n=B(mt(r.y,r.x)).toVar(),s=Me(Ki(n.greaterThan(0),r,Me(t.y.sub(i.x),n.negate()))).toVar();return jc(n).mul(Yi(mt(s,Me(0)))).add(e.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),j2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Nme({p:t,b:Me(e.size,e.size.mul(.25)),r:e.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"}]}),Ime=Xe(e=>{let t=e.b,i=Me(ui(e.p)).toVar(),r=Me(t.sub(i.mul(2))).toVar(),n=r.x.mul(t.x).sub(r.y.mul(t.y)),s=B(Xt(n.div(et(t,t)),B(-1),B(1))).toVar();return B(Yi(i.sub(t.mul(.5).mul(Me(Pn(s),s.add(1)))))).toVar().mul(jc(i.x.mul(t.y).add(i.y.mul(t.x)).sub(t.x.mul(t.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),W2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Qr(e.smoothness.negate(),e.smoothness,Ime({p:t,b:Me(e.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"}]}),H2e=Xe(e=>{let t=Me(e.uv.mul(e.frequency)).toVar(),i=Me(Ct(t)).toVar(),r=B(yd(i.y,2)).toVar();t.x.addAssign(r.add(e.zigzag.mul(r)));let n=B(Ct(t.x)).toVar();return yd(n,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"}]}),q2e=Xe(e=>{let t=Me(V_(e.uv,e.frequency,B(0),e.zigzag,e.rotation)).toVar(),i=B(Ct(e.uv.mul(e.frequency)).y).toVar(),r=B(A9(Me(i))).toVar(),n=B(ut(e.size,e.size.mul(r),e.variation)).toVar();return Qr(n.sub(e.smoothness),n.add(e.smoothness),ui(t.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"}]}),Ome=Xe(e=>{let{a:t,b:i,c:r,d:n}=e,s=Me(e.p.sub(Me(n,t)).mul(r)).toVar();s.x.assign(yd(s.x,G_)),Ve(s.x.greaterThan(Math.PI),()=>{s.x.assign(B(G_).sub(s.x))});let a=B(0).toVar(),o=B(G_).toVar();Zr(24,()=>{let h=B(a.add(o).mul(.5)).toVar(),d=B(h.sub(s.x).add(i.mul(r).mul(Pa(h)).mul(s.y.sub(i.mul(r).mul(Yo(h)))))).toVar();Ve(d.lessThan(0),()=>{a.assign(h)}).Else(()=>{o.assign(h)})});let l=B(a.add(o).mul(.5)).toVar(),u=Me(l,i.mul(r).mul(Yo(l))).toVar();return Yi(s.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"}]}),$2e=Xe(e=>{let t=B(e.frequency.x).toVar(),i=Me(e.uv.mul(t)).toVar(),r=Me(Ct(i)).toVar(),n=B(yd(r.y,2)).toVar();i.x.addAssign(n.mul(e.zigzag));let s=Me(i.x,gr(i.y)).toVar(),a=B(e.frequency.y.mul(.1)).toVar(),o=B(Ome({p:s,a:B(.5),b:B(.125),c:a.mul(G_),d:B(0)})).toVar(),l=B(A9(Me(r.y))).toVar(),u=B(ut(e.size,e.size.mul(l),e.variation)).toVar();return Qr(e.smoothness.negate(),e.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"}]}),Na("pattern",(e,t,i)=>{let r,n,s=e.getValue("style")??0,a=e.getValue("projection")??0,o=e.getValue("axis")??0,l=e.getFloat("blending"),u=e.getVec2("offset"),h=e.getVec4("colorA"),d=e.getVec4("colorB"),c=e.getVec2("frequency"),p=e.getFloat("size"),f=e.getFloat("variation"),m=e.getFloat("smoothness"),g=e.getFloat("zigzag"),v=e.getFloat("rotation"),y=e.getVec2("vertical"),_=e.getVec2("horizontal"),b=e.getInt("sides"),x={frequency:c,size:p,variation:f,smoothness:B(Xl(m,5)).toVar(),zigzag:g,rotation:v,sides:b};if(a===4){let T=J(Ko).toVar(),M=B(.0125).toVar(),E=Me(gr(T.xy.mul(M))).toVar(),A=Me(gr(T.zy.mul(M))).toVar(),P=Me(gr(T.xz.mul(M))).toVar();E.assign(nN(E.add(u),v)),A.assign(nN(A.add(u),v)),P.assign(nN(P.add(u),v));let N=B(sN(s,{uv:E,...x})).toVar(),D=B(sN(s,{uv:A,...x})).toVar(),O=B(sN(s,{uv:P,...x})).toVar(),z=B(Pn(l).mul(125).add(3)).toVar(),L=J(JA).toVar(),V=J(ui(Ut(L))).toVar();V.assign(Xl(V,J(z))),V.divAssign(et(V,J(1))),N.mulAssign(V.z),D.mulAssign(V.x),O.mulAssign(V.y),r=B(N.add(D).add(O)).toVar(),n=Me(E.mul(V.z).add(A.mul(V.x)).add(P.mul(V.y))).toVar()}else{let T=Me(0).toVar();if(a===0)T.assign(tr());else if(a===2){let M,E,A=J(Ko).toVar(),P=B(Yi(A)).toVar();o===0?(M=B(Mf(A.y,A.z)).toVar(),E=B(tO(A.x.div(P))).toVar()):o===1?(M=B(Mf(A.x,A.z)).toVar(),E=B(tO(A.y.div(P))).toVar()):(M=B(Mf(A.y,A.x)).toVar(),E=B(tO(A.z.div(P))).toVar()),T.assign(Me(M,E).div(Math.PI))}T.addAssign(u),T.assign(gr(T)),T.assign(nN(T,v)),r=sN(s,{uv:T,...x}),n=T}let w=Pe(ut(h,d,r)).toVar();w.a.assign(Xt(w.a,B(0),B(1))),w.a.mulAssign(hr(y.x,n.y).mul(hr(n.y,y.y))),w.a.mulAssign(hr(_.x,ui(n.x)).mul(hr(ui(n.x),_.y)));let S=t.alpha.mul(Xt(w.a,B(0),B(1))).mul(t.mask);return{color:Xt(w,Pe(0),Pe(1)).rgb,calpha:$c(S,i,t.isMask)}})}),wFe=U(()=>{bi(),Aw(),da(),eC(),U2=(e,t)=>e.element(t),Na("rainbow",(e,t,i)=>{let r=e.getFloat("filmThickness"),n=e.getFloat("movement"),s=e.getVec3("wavelengths"),a=e.getFloat("noiseStrength"),o=e.getFloat("noiseScale"),l=e.getVec3("offset"),u=B(0).toVar();t.noiseCompiledIn!==!1&&Ve(a.notEqual(0),()=>{let _=Ko.div(o).toVar(),b=Sg(_.mul(1.6).add(J(1.8,1.5,1.9).mul(Sg(_))).add(J(1.7,9.2,1)));u.assign(b.mul(a))});let h=s.mul(J(1,.8,.6)).add(1),d=U2(Mw,2).w.equal(-1),c=J(U2(_u,0).z,U2(_u,1).z,U2(_u,2).z).negate(),p=Jl.sub(qf),f=Ki(d,p,c),m=et(Ut(f.add(l.mul(-.001))),Ut(d1)),g=Yo(r.add(u).div(h).mul(m).add(n)).mul(.5).add(.5),v=J(Xt(g,0,2)).toVar(),y=Xt(v.r.add(v.g).add(v.b),0,1);return{color:v,calpha:$c(t.alpha.mul(y).mul(t.mask),i,t.isMask)}})}),SFe=U(()=>{bi(),Aw(),da(),ua(),C9=e=>e,Lme=e=>e,Bme=Zr,Fme=Zr,Ume=Xe(e=>{let t=e.x,i=J(et(t,J(127.1,311.7,74.7)),et(t,J(269.5,183.3,246.1)),et(t,J(113.5,271.9,124.6)));return gr(Pa(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),zme=Xe(e=>{let t=e.x,i=Ct(t).toVar(),r=gr(t).toVar(),n=B(100).toVar(),s=()=>({start:De(-1),end:De(1),condition:"<=",type:"int"});return Fme(s(),s(),s(),({i:a,j:o,k:l})=>{let u=J(a,o,l).toVar(),h=u.sub(r).add(function(c){return Ume({x:c})}(i.add(u))).toVar(),d=et(h,h).toVar();Ve(d.lessThan(n),()=>{n.assign(d)})}),n.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),Na("toon",(e,t,i)=>{let r=e.getInt("positioning"),n=e.get("colors"),s=e.get("steps"),a=e.getVec3("source"),o=e.getBool("isWorldSpace"),l=e.getFloat("noiseStrength"),u=e.getFloat("noiseScale"),h=e.getVec4("shadowColor"),d=e.getVec3("offset"),c=Ut(d1).toVar(),p=B(0).toVar();i.lightsAvailable===!0&&Ve(r.equal(De(0)),()=>{Bme({start:De(0),end:it.toonLightCount,condition:"<",type:"int"},({i:_})=>{let b=it.toonLightData.element(_).toVar(),x=b.xyz,w=b.w,S=Ki(w.greaterThan(.5),Ut(x),Ut(x.sub(Jl))),T=et(S,c).mul(.5).add(.5);p.assign(mt(p,T))}),p.assign(Xt(p,0,1))}),Ve(r.equal(De(1)),()=>{let _=ut(Ko,Jl,Ki(o,B(1),B(0))),b=Ut(a.sub(_));p.assign(et(b,c).mul(.5).add(.5))}).ElseIf(r.equal(De(2)),()=>{let _=qf.sub(d),b=Ut(_.sub(Jl));p.assign(et(b,c).mul(.5).add(.5))}),Ve(l.greaterThan(0),()=>{let _=Ko.div(u),b=B(1).sub(zme({x:_}));p.addAssign(b.mul(l))}),p.assign(Xt(p,0,1));let f=(e.getValue("colors")??n.array).length,m=(e.getValue("steps")??s.array).length,g=Math.min(10,f,m),v=Pe(n.element(0)).toVar();for(let _=1;_<g;_++){let b=C9(s.element(_-1)),x=C9(s.element(_)),w=Xt(p.sub(b).div(x.sub(b)),B(0),B(1));v.assign(ut(v,Lme(n.element(_)),Qr(0,1,w)))}i.lightsAvailable===!0&&Ve(r.equal(De(0)),()=>{let _=B(1),b=ut(v.rgb,h.rgb,h.a);v.rgb.assign(ut(b,v.rgb,_))});let y=t.alpha.mul(v.a).mul(t.mask);return{color:v.rgb,calpha:Ew(y,i)}})}),TFe=U(()=>{bi(),Aw(),da(),a2e(),ua(),P9=e=>e,kme=(e,t)=>e.element(t),_v=e=>e,Vme=e=>e,Gme=e=>e,Na("transmission",(e,t,i)=>{let r=e.getFloat("thickness"),n=e.getFloat("ior"),s=e.getFloat("roughness"),a=it.transmissionRenderTarget,o=it.transmissionSamplerSize,l=G=>kme(_u,G),u=Ut(J(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),h=Ut(Jl.sub(qf)),d=it.orthographicUniform,c=Ki(d.greaterThan(.5),u,h).toVar(),p=Ut(d1).toVar(),f=nTe(c,p,B(1).div(n)).toVar(),m=Ut(f).mul(r).mul(s2e).toVar(),g=G=>{let Y=it.unjitteredProjection.mul(_u).mul(Pe(G,1)),$=Y.xy.div(Y.w);return Me($.x.mul(.5).add(.5),$.y.mul(-.5).add(.5))},v=g(Jl.add(m).toVar()).toVar(),y=(g(Jl).toVar(),s.mul(Xt(n.mul(2).sub(2),B(0),B(1))).toVar()),_=sw(o.x).mul(y).toVar(),b=y,x=Fi(_.div(5.5),B(8.5)).toVar(),w=null,S="fit",T=!0,M=!1,E=12,A="white",P=1;try{let G=new URLSearchParams(window.location.search),Y=G.get("dbglod");Y!==null&&(w=Number(Y));let $=G.get("dbgtap");$==="ring"&&(S="ring"),($==="single"||$==="1")&&(S="single"),($==="r50"||$==="r75"||$==="full")&&(S=$),$==="singlewide"&&(S="singlewide"),($==="fit"||$==="singlefit")&&(S="fit");let Q=G.get("dbgwidth");Q!==null&&Number.isFinite(Number(Q))&&(P=Math.max(0,Number(Q))),$==="6"&&(S="ring",E=6),G.get("dbgwarp")==="0"&&(T=!1),G.get("dbgdither")==="1"&&(M=!0);let ue=G.get("dbgangle");(ue==="classic"||ue==="0")&&(A=ue)}catch{}w!==null&&Number.isFinite(w)&&x.assign(B(w));let N,D=(()=>{if(S==="singlewide")return Fi(x.add(1),B(8.5)).toVar();if(S!=="fit")return x;let G=it.transmissionActualSize.x.div(it.resolution.x),Y=b.mul(x).mul(5*P).mul(G).toVar();return Fi(sw(zb(x.mul(2)).add(Y.mul(Y).mul(3))).mul(.5),B(8.5)).toVar()})(),O=G=>a.sample(T?(Y=>{let $=it.transmissionActualSize.div(zb(Ct(D))),Q=Y.mul($).sub(.5),ue=Ct(Q),pe=Q.sub(ue),xe=pe.mul(pe).mul(Me(3,3).sub(pe.mul(2)));return ue.add(.5).add(xe).div($)})(G):G).level(D).rgb,z=S==="r50"?.5:S==="r75"?.75:1;if(S==="single"||S==="singlewide"||S==="fit")if(S==="fit"){let G=Ct(D).toVar(),Y=D.sub(G).toVar(),$=Rh(zb(Y.mul(2)).sub(1)).mul(1.1547).toVar(),Q=Me(zb(G)).div(it.transmissionActualSize).mul($).toVar(),ue=J(0).toVar(),pe=12;for(let xe=0;xe<pe;xe++){let we=_v(Xg(xe,pe,B(0))),re=_v(v.add(we.mul(Q)));ue.addAssign(Vme(Gme(a.sample(re).level(G)).rgb))}N=ue.div(pe).toVar()}else N=O(v).toVar();else{let G=Me(B(1).div(it.resolution.x),B(1).div(it.resolution.y)).toVar(),Y=jf(A==="classic"?Qo.xy.add(it.cameraJitterPx):Qo.xy).mul(6.28318530718);A==="white"&&(Y=Y.add(it.tapAngle));let $=Y.toVar(),Q=it.tapAngle.mul(13.7).toVar(),ue=it.tapAngle2.mul(5.3).toVar(),pe=Me(zb(Ct(D).add(1))).div(it.transmissionActualSize).toVar(),xe=jf(Qo.xy.add(Me(Q,ue))).toVar(),we=jf(Qo.xy.add(Me(ue.mul(1.71),Q.mul(2.39)))).toVar(),re=J(0).toVar();for(let Se=0;Se<E;Se++){let W=_v(Xg(Se,E,$)).mul(G).mul(b).mul(x.mul(10)).mul(z),k=_v(v.add(W));if(M){let K=P9(gr(xe.add(.7548776662*Se))),ie=P9(gr(we.add(.5698402911*Se))),j=_v(Me(K.sub(.5),ie.sub(.5)).mul(pe));k=_v(k.add(j))}re.addAssign(O(k))}N=re.div(E).toVar()}if(e.has("attenuationDistance")){let G=e.getFloat("attenuationDistance"),Y=J(e.getColor("attenuationColor")).toVar();Ve(G.greaterThan(0),()=>{let $=Xl(mt(Y,J(1e-4)),J(r.div(G)));N.mulAssign($)})}let L=t.alpha.mul(t.mask).toVar(),V=L.div(Xt(L.add(i.accumAlpha),B(1e-5),B(1))).toVar();return i.accumAlpha.addAssign(B(1).sub(i.accumAlpha).mul(t.alpha)),{color:N,calpha:V}})}),MFe=U(()=>{bi(),da(),ua(),CTe(),Na("reflection",(e,t,i)=>{let r=e.getFloat("blur"),n=e.getFloat("thickness"),s=e.getInt("steps"),a=e.getFloat("stepSize"),o=e.getValue("tracingMode")??0,l=it.reflectionRenderTarget,u=it.reflectionDepthPyramid,h=it.reflectionDepthPyramid,d=it.reflectionDepthLevels,c=it.reflectionEnvMap,p=it.reflectionPlanarTarget,f=it.reflectionPlanarEnabled,m=yg("__splinePlanarMirror","float"),g=f.greaterThan(.5).and(m.greaterThan(.5)),v=it.reflectionResolveTarget,y=it.reflectionResolveEnabled,_=it.orthographicUniform.greaterThan(.5),b=Ki(_,J(0,0,-1),Ut($f)).toVar(),x=Ut(Ao).toVar(),w=DA(b,x).toVar(),S=Xt(r.mul(.1),B(0),B(1)).toVar(),T=it.resolution,M=J(0).toVar(),E=y.greaterThan(.5).and(S.greaterThan(.05)).and(g.not()),A=Ut(uK(w,i4)).toVar(),P=Dq(c,A,S).toVar(),N=v.sample(gu).level(B(0)).toVar();Ve(E,()=>{let z=N.a.toVar();M.assign(ut(P,N.rgb.div(z.max(1e-4)),Xt(z.mul(2),B(0),B(1))))}).Else(()=>{M.assign(cK({dials:{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:o},surface:{originView:$f,normalV:x,screenUv:gu,fragWindowZ:MB},camera:{projectionMatrix:Mw,projectionMatrixInverse:wSe,worldMatrix:i4,near:xSe},resources:{colorMap:l,depthPyramid:u,depthPyramidNode:h,envMap:c},usePlanar:g,noisePixel:gu.mul(T).floor()}))}),Ve(g,()=>{let z=Me(B(1).sub(gu.x),gu.y).toVar(),L=B(d.sub(1)),V=Fi(sw(S.mul(T.y).mul(Pq).add(1)),L).toVar(),G=V.sub(1).max(0).floor().toVar(),Y=B(2).pow(V).sub(1).max(0).toVar(),$=Y.mul(.75).div(T.y).toVar();M.assign(Rq(p,z,$,Y.mul(.75),G))});let D=t.alpha.mul(t.mask).toVar(),O=D.div(Xt(D.add(i.accumAlpha),B(1e-5),B(1))).toVar();return i.accumAlpha.addAssign(B(1).sub(i.accumAlpha).mul(D)),{color:M,calpha:O}})}),EFe=U(()=>{bi(),Aw(),da(),ua(),R9=e=>e,jme=e=>e,Na("outline",(e,t,i)=>{let r=e.getColor("outlineColor"),n=e.getColor("contourColor"),s=e.getFloat("outlineWidth"),a=e.getFloat("contourWidth"),o=e.getFloat("outlineThreshold"),l=e.getFloat("contourThreshold"),u=e.getFloat("outlineSmoothing"),h=e.getFloat("contourFrequency"),d=e.getVec3("contourDirection"),c=e.getBool("positionalLines"),p=e.getBool("compensation"),f=it.normalRenderTarget,m=it.normalRenderTargetDepth,g=it.resolution,v=it.pixelRatio,y=$g("randomColor","vec3").x.toVar(),_=MB.toVar(),b=gu.toVar(),x=Me(B(1).div(g.x),B(1).div(g.y)).toVar(),w=it.pcssHalton,S=jf(Qo.xy.add(w)).mul(6.28318530718).toVar(),T=p.select(s.div(2),s),M=x.mul(T).mul(v).toVar(),E=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=ue=>Xg(ue,9,S).mul(x),P=[],N=B(0).toVar();for(let ue=0;ue<9;ue++){let[pe,xe]=E[ue],we=ue===4?b:R9(b.add(Me(M.x.mul(pe),M.y.mul(xe))).add(A(ue))),re=R9(we).toVar(),Se=jme(f.sample(re)).toVar();P.push(Se),Ve(Se.a.notEqual(y).and(Se.a.notEqual(0)),()=>{let W=m.sample(re).r.add(1e-4);Ve(_.greaterThan(W),()=>{N.assign(1)})})}let D=P[2].rgb.add(P[5].rgb.mul(2)).add(P[8].rgb).sub(P[0].rgb.add(P[3].rgb.mul(2)).add(P[6].rgb)),O=P[0].rgb.add(P[1].rgb.mul(2)).add(P[2].rgb).sub(P[6].rgb.add(P[7].rgb.mul(2)).add(P[8].rgb)),z=Rh(et(D,D).add(et(O,O))).mul(N.oneMinus()).toVar(),L=J(r).toVar(),V=Qr(o.sub(u),o.add(u),z).toVar(),G=Ut(d1).toVar(),Y=B(1).sub(l).toVar();Ve(c,()=>{let ue=Ko.mul(d),pe=ue.x.add(ue.y).add(ue.z).toVar(),xe=gr(pe.mul(h).mul(.01)),we=gq(pe.mul(h)),re=Qr(we.mul(a.mul(.01)),we.mul(a.mul(.02)),xe).toVar();Ve(re.lessThan(1).and(V.equal(0)),()=>{L.assign(n),V.assign(1)})}).Else(()=>{let ue=G.mul(d),pe=ue.x.add(ue.y).add(ue.z).toVar(),xe=gq(pe.mul(l)).toVar(),we=Pa(pe.mul(h)).toVar(),re=Qr(B(0),xe.mul(a),B(1).sub(we)).toVar();Ve(xe.greaterThan(Y.mul(.5)).and(re.lessThan(1)).and(V.equal(0)),()=>{L.assign(n),V.assign(B(1).sub(re))})});let $=t.alpha.mul(V).mul(t.mask).toVar(),Q=$.div(Xt($.add(i.accumAlpha),B(1e-5),B(1))).toVar();return i.accumAlpha.addAssign(B(1).sub(i.accumAlpha).mul($)),{color:L,calpha:Q}})}),AFe=U(()=>{bi(),da(),Na("vertexColor",(e,t,i)=>{let r=fTe(),n=t.alpha.mul(t.mask).mul(r.a);return{color:r.rgb,calpha:Ew(n,i)}})}),X2e=U(()=>{cFe(),pFe(),fFe(),mFe(),gFe(),vFe(),yFe(),_Fe(),bFe(),xFe(),wFe(),m2e(),SFe(),TFe(),MFe(),EFe(),AFe(),p2e()});function Wme(e){let t=e.data,i=[e.kind,e.type,`v=${!!t.visible}`,`m=${!!t.isMask}`,`p=${e.params.names().join(",")}`];if(e.type!=="light"){let r=xw[e.type];if(r!==void 0)for(let n of r)i.push(`${n}=${String(t[n])}`)}for(let[r,n]of e.uniformKinds)(n==="vec4array"||n==="floatArray")&&i.push(`${r}#${(e.params.getValue(r)??[]).length}`);if(e.type==="rainbow"&&i.push(`noise=${e.noiseCompiledIn!==!1}`,`forced=${e.noiseForced===!0}`),e.type==="displace"&&i.push(`dt=${String(t.displacementType)}`),e.type==="texture"||e.type==="video"||e.type==="matcap"){if(e.holders.length===0)throw new Error(`structuralKey: ${e.type} layer has no holder`);let r=t.texture??{};i.push(`holder=${e.holders.map(n=>n.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var CFe=U(()=>{Ed()});function ja(e,t=1){let i=new ot(e);return new zr(i.r,i.g,i.b,t)}function u$(e,t){if(e instanceof zr)return e;if(e instanceof ot)return new zr(e.r,e.g,e.b,1);if(typeof e=="number")return ja(e);if(typeof e=="object"&&e!==null&&"r"in e&&"g"in e&&"b"in e){let i=e;return new zr(i.r,i.g,i.b,i.a??1)}return t()}function Hme(){let e=new Array(10).fill(new ct(0,0,0,1)).map(t=>t.clone());return e[1]=new ct(1,1,1,1),e}function qme(){let e=new Array(10).fill(1);return e[0]=0,e}function eE(e,t){let i=e.material;if((i==null||i.isTSLNodeMaterial!==!0)&&(i=e.object?.material,i==null||i.isTSLNodeMaterial!==!0))return t;if(t.kind==="light"){let n=i.lightLayer;if(n==null)return t;let s=n.data?.category,a=t.data?.category;return s===a?n:t}let r=i.layers?.[t.structIndex];return r!==void 0&&r.type===t.type?r:t}function $me(e,t){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new Error(`[spe] ${e}.element() needs a build-time constant index (got ${String(t)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return t}function _i(e,t,i,r){let n,s,a=e.params;switch(i){case"float":n=Fe(Number(r??0));break;case"int":n=Fe(Number(r??0),"int");break;case"axis":n=Fe(["x","y","z"].indexOf(String(r)),"int");break;case"bool":n=Fe(!!r);break;case"vec2":n=Fe(r instanceof Z?r:new Z);break;case"vec3":n=Fe(r instanceof R?r:new R);break;case"vec4":n=Fe(r instanceof ct?r:new ct);break;case"color":{let o=u$(r,()=>ja(16777215));n=Fe(o),s=o;break}case"colorVec4":{let o=u$(r,()=>new zr(1,1,1,1)),l=new ct(o.r,o.g,o.b,o.a),u=Fe(l);u.onObjectUpdate(h=>{let d=eE(h,e).params.getLiveValue(t)??o;l.set(d.r,d.g,d.b,d.a)}),n=u,s=o;break}case"vec4array":{let o=Array.isArray(r)?r:[];n=function(l,u,h){let d=new Map;return{element(c){let p=$me(u,c),f=d.get(p);if(f===void 0){let m=Fe(h[p]??new ct);m.onObjectUpdate(g=>(eE(g,l).params.getValue(u)??h)[p]??Q2e),f=m,d.set(p,f)}return f},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 f=c[p];Array.isArray(f)?h[p].set(f[0]??0,f[1]??0,f[2]??0,f[3]??1):f&&typeof f=="object"&&h[p].set(f.x??0,f.y??0,f.z??0,f.w??1)}}}}(e,t,o.length>0?o:[new ct]),s=o;break}case"floatArray":{let o=Array.isArray(r)?r:[0];n=function(l,u,h){let d=new Map;return{element(c){let p=$me(u,c),f=d.get(p);if(f===void 0){let m=Fe(h[p]??0);m.onObjectUpdate(g=>{let v=eE(g,l).params.getValue(u);return Number((v??h)[p]??0)}),f=m,d.set(p,f)}return f},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])}}}(e,t,o.length>0?o:[0]),s=o;break}}i!=="vec4array"&&i!=="floatArray"&&i!=="colorVec4"&&(yK(n),n.onObjectUpdate(o=>{let l=eE(o,e).params.getValue(t);l!==void 0&&_K(n,l)})),a.set(t,n,s),e.uniformKinds.set(t,i)}function FA(e,t){let i=e.data;i.type!=="displace"?("alpha"in i&&e.params.has("alpha")&&e.params.setValue("alpha",Oh(i.alpha,t)*(i.visible?1:0)),i.type==="outline"&&e.params.has("compensation")&&e.params.setValue("compensation",!!i.compensation&&!!i.visible)):e.params.has("intensity")&&e.params.setValue("intensity",(Lt(i.intensity,t)??1)*(i.visible?1:0))}function Y2e(e,t){_i(e,"alpha","float",t.alpha??1),_i(e,"mode","int",t.mode??0),_i(e,"isMask","float",t.isMask?1:0)}function K2e(e,t,i,r){let n=new tE(e,t,i),s=i;if(_i(n,"alpha","float",Oh(s.alpha,r)),_i(n,"mode","int",s.mode??0),_i(n,"bumpMapIntensity","float",s.bumpMapIntensity??5),_i(n,"alphaOverride","float",Oh(s.alphaOverride,r)),i.visible)if(s.category==="lambert")_i(n,"emissive","color",r.color(s.emissive)??ja(0)),_i(n,"occlusion","bool",s.occlusion??!0);else if(s.category==="toon")_i(n,"shininess","float",s.shininess??30),_i(n,"specular","color",r.color(s.specular)??ja(1118481));else if(s.category==="physical"){_i(n,"roughness","float",s.roughness??.3),_i(n,"metalness","float",s.metalness??0),_i(n,"reflectivity","float",s.reflectivity??.5),_i(n,"occlusion","bool",s.occlusion??!0),_i(n,"normalScale","float",s.normalScale??1),_i(n,"aoMapIntensity","float",s.aoMapIntensity??1),_i(n,"emissive","color",s.emissive!==void 0?r.color(s.emissive)??ja(0):ja(0)),_i(n,"emissiveIntensity","float",s.emissiveIntensity??1);let a=s;a.clearcoat!==void 0&&(_i(n,"clearcoat","float",a.clearcoat),_i(n,"clearcoatRoughness","float",a.clearcoatRoughness??.1)),a.sheen!==void 0&&(_i(n,"sheen","float",a.sheen),_i(n,"sheenColor","color",a.sheenColor!==void 0?r.color(a.sheenColor)??ja(16777215):ja(16777215)),_i(n,"sheenRoughness","float",a.sheenRoughness??.5)),a.ior!==void 0&&(_i(n,"ior","float",a.ior),_i(n,"specularIntensity","float",a.specularIntensity??1),_i(n,"specularColor","color",a.specularColor!==void 0?r.color(a.specularColor)??ja(16777215):ja(16777215))),a.iridescence!==void 0&&(_i(n,"iridescence","float",a.iridescence),_i(n,"iridescenceIOR","float",a.iridescenceIOR??1.3),_i(n,"iridescenceThickness","float",a.iridescenceThickness??400))}else _i(n,"shininess","float",s.shininess??30),_i(n,"specular","color",s.specular!==void 0?r.color(s.specular)??ja(1118481):ja(1118481)),_i(n,"occlusion","bool",s.occlusion??!0);return n.node.alphaOverride=n.params.get("alphaOverride"),FA(n,r),n}function Z2e(e,t,i,r){let n=new UA("fragment",e,t,i),s=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("");n.holders.push(s);let a=i.texture.wrapping??(i.type==="texture"?1e3:1001),o=function(u,h,d,c){let p=vt(u.getTexture(h,d,c));return p.onRenderUpdate(()=>u.getTexture(h,d,c)),p}(s,a,i.texture.minFilter??1008,i.texture.magFilter??1006);n.params.set("texture",o);let l=Lt(i.texture.rotation??0,r)??0;if(i.type==="matcap")_i(n,"rotation","float",l*ht.DEG2RAD);else{let u=Fe(new Z(1,1));u.onRenderUpdate(()=>{let m=s.getTexture(a,i.texture.minFilter??1008,i.texture.magFilter??1006).image;u.value.set(m?.width??1,m?.height??1)}),n.params.set("textureSize",u),n.uniformKinds.set("textureSize","vec2");let h=Fe(s.loaded||s.isBuffer?1:0);h.onRenderUpdate(()=>s.loaded||s.isBuffer?1:0),n.params.set("loaded",h),n.uniformKinds.set("loaded","float"),_i(n,"crop","float",i.crop?1:0),_i(n,"projection","int",i.projection??0),_i(n,"axis","axis",i.axis),_i(n,"projectionAxis","axis",i.projectionAxis),_i(n,"side","int",i.side??0);let d=i.size?new Z(Lt(i.size[0],r)??0,Lt(i.size[1],r)??0):new Z(100,100);_i(n,"size","vec2",d),_i(n,"blending","float",i.blending??0);let c=new oi,p=new J2e([Lt(i.texture.repeat?.[0]??1,r)??1,Lt(i.texture.repeat?.[1]??1,r)??1],[Lt(i.texture.offset?.[0]??0,r)??0,Lt(i.texture.offset?.[1]??0,r)??0],l,c),f=Fe(c);yK(f),f.onObjectUpdate(m=>{let g=eE(m,n).params.getNodeValue("mat");g!==void 0&&_K(f,g)}),n.params.set("mat",f,p)}return Y2e(n,{alpha:Oh(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),FA(n,r),n}function PFe(e,t,i,r){if(i.type==="light")return K2e(e,t,i,r);if(i.type==="texture"||i.type==="video"||i.type==="matcap")return Z2e(e,t,i,r);if(i.type==="displace")return function(o,l,u,h){if(u.displacementType!=="noise")throw new Error;let d=new UA("vertex",o,l,u),c=(p,f)=>Lt(p,h)??f;return _i(d,"offset","vec3",new R(...u.offset.map(p=>c(p,0)))),_i(d,"scale","float",c(u.scale,10)),_i(d,"intensity","float",c(u.intensity,8)),_i(d,"movement","float",c(u.movement,1)),_i(d,"noiseType","int",u.noiseType??0),_i(d,"voronoiStyle","int",u.voronoiStyle??0),_i(d,"smoothness","float",c(u.smoothness,.5)),_i(d,"seed","float",c(u.seed,0)),_i(d,"highCut","float",c(u.highCut,1)),_i(d,"lowCut","float",c(u.lowCut,0)),_i(d,"quality","int",Lt(u.quality,h)??1),FA(d,h),d}(e,t,i,r);let n=new UA("fragment",e,t,i),s=il(i,r),a=d$[i.type]??d$.color;for(let[o,l]of Object.entries(a))_i(n,o,l.kind,s[o]??l.def());if(i.type==="transmission"){let o=typeof window<"u"?window.innerWidth:1,l=typeof window<"u"?window.innerHeight:1;_i(n,"aspectRatio","vec2",o>=l?new Z(l/o,1):new Z(1,o/l))}return Y2e(n,s),FA(n,r),n}var Xme,D9,d$,Q2e,J2e,UA,tE,Yme,_g,wK,RFe=U(()=>{oe(),vn(),Cd(),IB(),bi(),jt(),cB(),rl(),Ed(),bu(),oB(),da(),p2e(),dK(),m2e(),dFe(),X2e(),yB(),CFe(),Xme=e=>e,D9=e=>e,d$={color:{color:{kind:"color",def:()=>ja(eo)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>ja(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:()=>ja(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 R},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new R}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>ja(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:Hme},steps:{kind:"floatArray",def:qme},source:{kind:"vec3",def:()=>new R},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new zr(0,0,0,0)},offset:{kind:"vec3",def:()=>new R}},outline:{outlineColor:{kind:"color",def:()=>ja(16777215)},contourColor:{kind:"color",def:()=>ja(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 R(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 R},direction:{kind:"vec3",def:()=>new R(1,0,0)},colors:{kind:"vec4array",def:()=>[new ct(0,0,0,1),new ct(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new R(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new Z(1.7,9.2)},fB:{kind:"vec2",def:()=>new Z(8.3,2.8)},distortion:{kind:"vec2",def:()=>new Z(1,1)},colorA:{kind:"colorVec4",def:()=>new zr(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new zr(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new zr(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new zr(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 R(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:Hme},steps:{kind:"floatArray",def:qme},offset:{kind:"vec2",def:()=>new Z},morph:{kind:"vec2",def:()=>new Z},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 Z},colorA:{kind:"colorVec4",def:()=>new zr(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new zr(1,1,1,1)},frequency:{kind:"vec2",def:()=>new Z(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 Z(0,1)},horizontal:{kind:"vec2",def:()=>new Z(0,1)},sides:{kind:"int",def:()=>6}}},Q2e=new ct,J2e=class{constructor(e,t,i,r){this.repeat=e,this.offset=t,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 oi().makeRotation(this.rotation*ht.DEG2RAD))}},UA=class{constructor(e,t,i,r){this.kind=e,this.id=t,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new bK(t)}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(e){return this.params.has(e)}setValue(e,t){if(e==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof t=="number"&&t!==0&&this.onNoiseMismatch!==void 0){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(e,t),void(i(t)&&(this.noiseCompiledIn=!0))}this.params.setValue(e,t)}getNode(e){return this.params.has(e)?this.params.get(e):void 0}getValue(e){return this.params.getValue(e)}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(e=>e.loaded)}dispose(){for(let e of this.holders)e instanceof Rc||e.deref();this.holders.length=0}},tE=class extends UA{constructor(e,t,i){super("light",e,t,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},Yme={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"]}]},_g=class extends ei{constructor(e,t,i=!0,r,n=!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=cd.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=n,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(e,t),IA.add(this),this.addEventListener("dispose",()=>function(s){IA.delete(s)}(this))}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let e=this._structuralKey;if(e===null||this._structuralKeyVersion!==this.version){try{e=function(r){let n=r.lightLayer,s=n.data,a=u=>{if(!u)return-1;if(typeof u!="string"){let c=r.syntheticMapLayers?.get(u);return c!==void 0?`img(${Wme(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=${s.visible===!0}`,`lidx=${r.layers.indexOf(n)}`,`bump=${a(s.bumpMap)}`,`rough=${o?a(s.roughnessMap):-1}`,`metal=${o?a(s.metalnessMap):-1}`,`nrm=${o?a(s.normalMap):-1}`,`ao=${o?a(s.aoMap):-1}`,`emis=${o?a(s.emissiveMap):-1}`,`rch=${o?s.roughnessMapChannel??"luminance":""}`,`mch=${o?s.metalnessMapChannel??"b":""}`,`ach=${o?s.aoMapChannel??"r":""}`];for(let u of r.layers)l.push(Wme(u));return l.join("|")}(this),this.shapeBlendOptions!==null&&(e+=`|sb:${this.uuid}:${this._shapeBlendResources!==null?1:0}`)}catch{e=super.customProgramCacheKey()}this._structuralKey=e,this._structuralKeyVersion=this.version}let t=this.envNode instanceof hw?cd.version:0,i=this.physicalLobes();return`${e}|env${t}|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 e=ATe({transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.shapeBlendOptions!==null,data:this.root.data});this.depthPrepass=e,this.depthWrite=!e}getDepthPrepassTwin(e){let t=this.depthPrepassTwins[e];if(t===void 0){let i=this.root;t=new _g(i.data,i.lastContext,i.allowVariableSaves,i,!0),t.flatShading=this.flatShading,t.side=e,t.wireframe=!1,t.depthPrepassCutoff=eY,t.applyDepthPrepassPolicy(),this.depthPrepassTwins[e]=t,i.depthTwins.push(t)}return t}get vertexObjectNormal(){return this.shapeBlendObjectNormal??this.root.displacedObjectNormal}get category(){return this.lightLayer.category}envReflectiveInLow(){let e=!1;for(let t of this.layers){let i=t.data;if(i?.category==="physical"&&(e=!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!e}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(e,t,i=!1){(this.data!==e||i)&&this.reset0(e,t)}reset0(e,t){this.lastContext=t,this.data=e;let i=e.layers??ns.defaultTwoLayerData("phong").layers;for(let s of this.layers)s.dispose();for(let s of this.syntheticMapLayers.values())s.dispose();this.syntheticMapLayers.clear();let r=[];for(let s of i)try{let a=PFe(this.layerIdGen++,s.id,s.data,t.shared);a.type==="rainbow"&&this.armRainbowNoiseSpecialization(a),r.push(a)}catch(a){console.warn(`[spe] material layer '${s.data.type}' (${s.id}) failed to build \u2014 skipping this layer`,a)}this.layers=r,this.layers.reverse();for(let s=0;s<this.layers.length;s++)this.layers[s].structIndex=s;this.name=e.name??"Untitled Material";let n=this.layers.find(s=>s instanceof tE);if(n===void 0&&(n=K2e(0,"",{...hs.defaultData("light","phong"),visible:!1},t.shared)),this.lightLayer=n,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:B(0).toVar("accumAlpha"),lightsAvailable:this.lights&&(this.category==="phong"||this.category==="lambert"||this.category==="physical")},this.colorNode=Xe(()=>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 s=this.lightLayer.params,a=this.lightLayer.lightData;if(s.has("emissive")){let l=this.findTextureMapLayer(a.emissiveMap);this.emissiveNode=Xe(()=>{let u=J(s.getColor("emissive")).mul(s.getFloat("emissiveIntensity"));return l!==null&&(u=u.mul(function(h){let d,c=h.get("texture"),p=h.has("loaded")?h.getFloat("loaded"):B(1),{uvs:f,weights:m}=kE(h);if(m!==null){let g=J(To(c.sample(f[0])).rgb).toVar(),v=J(To(c.sample(f[1])).rgb).toVar(),y=J(To(c.sample(f[2])).rgb).toVar();d=hn(g.mul(m.z).add(v.mul(m.x)).add(y.mul(m.y)))}else d=hn(J(To(c.sample(f[0])).rgb));return hn(ut(J(0),d,p))}(l.params))),u})()}let o=this.findTextureMapLayer(a.aoMap);o!==null&&(this.aoNode=Xe(()=>ut(B(1),w9(o.params,a.aoMapChannel??"r"),s.getFloat("aoMapIntensity")))())}this.transparent=Sd(e,t.shared),this.applyDepthPrepassPolicy(),zE(this),this.needsUpdate=!0;for(let s of this.flavors)s?.syncFromRoot();for(let s of this.depthTwins)s.syncFromRoot();this.saveVariableLocations(t)}setTransparent(e,t){if(!this.isRoot)return void this.root.setTransparent(e,t);let i=this.transparent!==e;if(i){this.transparent=e,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=e,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=e,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||t?.markNeedsUpdateRendererDirty()}syncFromRoot(){let e=this.root;this.data=e.data,this.layers=e.layers,this.lightLayer=e.lightLayer,this.ctx=e.ctx,this.name=e.name,this.lights=e.lights,this.colorNode=e.colorNode,this.positionNode=e.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=e.emissiveNode,this.aoNode=e.aoNode,this.transparent=e.transparent,this.applyDepthPrepassPolicy(),this._applyShapeBlendGraph(),zE(this),this.needsUpdate=!0}getFlavor(e,t,i,r){if(!this.isRoot)return this.root.getFlavor(e,t,i,r);let n=i?6:(e?3:0)+t;if(n+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),n===0)return this;n-=1;let s=this.flavors[n];return s===void 0&&(s=new _g(this.data,this.lastContext,this.allowVariableSaves,this),s.flatShading=e,s.side=t,s.wireframe=i,r&&(s.shapeBlendOptions={...r},s.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},s._invalidateStructuralKey()),s.applyDepthPrepassPolicy(),this.flavors[n]=s),s}getShapeBlendBaseColor(){let e=this.layers.find(r=>r.kind==="fragment"&&r.type==="color"),t=e?.getValue("color"),i=e?.getValue("alpha");return{r:t?.r??1,g:t?.g??1,b:t?.b??1,a:i??1}}setShapeBlendResources(e){this._shapeBlendResources=e,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources||$L===null)return;let e=$L(this._shapeBlendResources);this.positionNode=e.position,this.shapeBlendObjectNormal=e.normal,this.normalNode=this.buildNormalNode(vq(n4(e.normal))),this.castShadowPositionNode=e.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=e.color,this.colorNode=Xe(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(e=>e instanceof tE)}findTextureMapLayer(e){if(!e)return null;if(typeof e!="string")return vA.is(e)?this.syntheticMapLayer(e):null;let t=this.layers.find(i=>i.uuid===e);return t===void 0||t.kind!=="fragment"?null:t.type==="texture"||t.type==="video"?t:null}syntheticMapLayer(e){if(!this.isRoot)return this.root.syntheticMapLayer(e);let t=this.syntheticMapLayers.get(e);if(t!==void 0)return t;try{let i=hs.defaultData("texture"),r={...i,visible:!1,texture:{...i.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],rotation:e.rotation??0,minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}},n=Z2e(this.layerIdGen++,`mapImage${this.layerIdGen}`,r,this.lastContext.shared);return this.syntheticMapLayers.set(e,n),n}catch(i){return console.warn("[spe] light-layer map image failed to build \u2014 skipped",i),null}}buildNormalNode(e){if(this.lights&&this.category==="physical"&&!this.wireframe){let n=this.lightLayer.lightData,s=this.findTextureMapLayer(n.normalMap);if(s!==null){let a=this.lightLayer.params.getFloat("normalScale");return Xe(()=>function(o,l,u){let h=J(u??Ao).toVar(),d=hn($f),c=o.get("texture"),p=o.has("loaded")?o.getFloat("loaded"):B(1),f=v=>{let y=Me(v).toVar(),_=J(To(c.sample(y)).rgb.mul(2).sub(1)).toVar(),b=J(ut(J(0,0,1),hn(_),p)).toVar();b.xy.mulAssign(l);let x=J(rw(d)).toVar(),w=J(nw(d)).toVar(),S=Me(rw(y)).toVar(),T=Me(nw(y)).toVar(),M=J(Ut(hn(h))).toVar(),E=J(qn(hn(w),M)).toVar(),A=J(qn(M,hn(x))).toVar(),P=J(hn(E).mul(S.x).add(hn(A).mul(T.x))).toVar(),N=J(hn(E).mul(S.y).add(hn(A).mul(T.y))).toVar(),D=B(mt(et(hn(P),hn(P)),et(hn(N),hn(N)))).toVar(),O=B(Ki(D.equal(0),B(0),Uc(AB).mul(nK(D)))).toVar();return hn(Ut(hn(P).mul(b.x.mul(O)).add(hn(N).mul(b.y.mul(O))).add(M.mul(b.z))))},{uvs:m,weights:g}=kE(o);if(g!==null){let v=f(m[0]),y=f(m[1]),_=f(m[2]);return hn(Ut(v.mul(g.z).add(y.mul(g.x)).add(_.mul(g.y))))}return f(m[0])}(s.params,a,e))()}}let t=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&this.category!=="lambert";if(t===null||!i||this.wireframe)return e;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return Xe(()=>function(n,s,a){let o=J(a??Ao).toVar(),l=hn($f),u=n.get("texture"),{uvs:h,weights:d}=kE(n);if(d!==null){let c=eN(l,hn(o),JD(u,h[0],s)),p=eN(l,hn(o),JD(u,h[1],s)),f=eN(l,hn(o),JD(u,h[2],s));return hn(Ut(c.mul(d.z).add(p.mul(d.x)).add(f.mul(d.y))))}return eN(l,hn(o),JD(u,h[0],s))}(t.params,r,e))()}buildVertexStack(){let e=this.layers.filter(i=>i.kind==="vertex");if(e.length===0)return this.positionNode=null,void(this.displacedObjectNormal=null);let t=function(i){let r=Bn("vec3","vDisplacedNormal");return{position:Xe(n=>{let s=gl(ow),a=gl(aK);for(let l=0;l<i.length;l++){let u=uFe(i[l],gl(ow),a);s=l===0?u.position:gl(s.add(u.position).mul(.5)),a=u.normal}let o=J(s).toVar();return r.assign(a),n.needsPreviousData?.()===!0&&DB.assign(o),o})(),normal:r}}(e.map(i=>i.params));this.positionNode=t.position,this.displacedObjectNormal=t.normal}displacedNormalView(){let e=this.root.displacedObjectNormal;return e===null?null:vq(n4(e))}maskSourceFor(e){let t=this.layers[e];if(t.kind==="fragment"&&t.isMaskEnabled)return null;let i=this.layers[e+1];return i!==void 0&&i.kind==="fragment"&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(e,t,i){let r=B(1);t!==null&&(r=this.evaluateMask(t));let n={alpha:i?.alpha??e.alphaNode,isMask:e.isMaskNode,mask:r,mode:e.modeNode,noiseCompiledIn:e.noiseCompiledIn},s=l2e(e.type)(e.params,n,this.ctx);return i?.color?{...s,color:i.color}:s}evaluateMask(e){let t=this.runLayerBuilder(e,null);return CB(t.color.mul(t.calpha))}buildColorStack(){let e=this.lightLayerIndex(),t=e===-1?0:e,i=null;for(let r=0;r<t;r++){let n=this.layers[r];if(n.kind!=="fragment")continue;if(i===null){let a=this._shapeBlendColorNode;i=D9(this.runLayerBuilder(n,this.maskSourceFor(r),a?{color:D9(a.rgb),alpha:Xme(a.w)}:void 0).color);continue}if(n.isMaskEnabled)continue;let s=this.runLayerBuilder(n,this.maskSourceFor(r));i=gO(i,s.color,s.calpha,n.modeNode)}return i??MSe(eo)}setup(e){e.context.setupClearcoatNormal=()=>hTe(Ao,"NORMAL","vec3"),super.setup(e)}setupLightingModel(){let e=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(t,i=null,r=null,n=!1){switch(t){case"physical":{let s=new c2e(r?.clearcoat===!0,r?.sheen===!0,r?.iridescence===!0,!1,!1,!1);return s.envIrradianceActive=n,s}case"lambert":return new Nx(!1);case"toon":{let s=new d2e;return s.aoOcclusionGate=i,s}default:return new Nx}}(this.category,e,this.physicalLobes(),this.envNode instanceof hw)}physicalLobes(){let e=this.lightLayer.params;return{clearcoat:e.has("clearcoat"),sheen:e.has("sheen"),iridescence:e.has("iridescence")}}setupVariants(e){if(!this.lights)return;let t=null,i=null;if(this.category==="physical"){let r=this.lightLayer.lightData,n=this.findTextureMapLayer(r.roughnessMap);n!==null&&(t=Xe(()=>w9(n.params,r.roughnessMapChannel??"luminance"))());let s=this.findTextureMapLayer(r.metalnessMap);s!==null&&(i=Xe(()=>w9(s.params,r.metalnessMapChannel??"b"))())}(function(r,n,s=null,a=null){if(r==="phong"||r==="toon")r4.assign(n.getFloat("shininess").max(1e-4)),nx.assign(n.getColor("specular"));else if(r==="physical"){let o=n.getFloat("metalness"),l=n.getFloat("roughness"),u=n.getFloat("reflectivity");if(s!==null&&(l=uw(s.mul(l))),a!==null&&(o=uw(Xt(a.mul(o),B(0),B(1)))),zSe.assign(o),hK.assign(Xt(l,B(.0525),B(1))),n.has("ior")){let h=n.getFloat("ior"),d=n.has("specularColor")?J(n.getColor("specularColor")):J(1),c=n.has("specularIntensity")?n.getFloat("specularIntensity"):B(1);rO.assign(h),nx.assign(Fi(tTe(rO.sub(1).div(rO.add(1))).mul(d),J(1)).mul(c)),o$.assign(ut(pl(nx),pl(Wl.rgb),o)),yq.assign(ut(c,B(1),o))}else{let h=J(u.pow(2).mul(.16));nx.assign(h),o$.assign(ut(h,pl(Wl.rgb),o)),yq.assign(B(1))}if(a$.assign(pl(Wl.rgb).mul(Pn(o))),n.has("clearcoat")&&(SSe.assign(n.getFloat("clearcoat")),iK.assign(Xt(n.getFloat("clearcoatRoughness"),B(.0525),B(1)))),n.has("sheen")){let h=n.has("sheenColor")?J(n.getColor("sheenColor")):J(1);aTe.assign(h.mul(n.getFloat("sheen"))),oTe.assign(Xt(n.getFloat("sheenRoughness"),B(.07),B(1)))}n.has("iridescence")&&(NSe.assign(n.getFloat("iridescence")),ISe.assign(n.getFloat("iridescenceIOR")),OSe.assign(n.getFloat("iridescenceThickness")))}})(this.category,this.lightLayer.params,t,i)}setupLighting(e){let t=this.lights===!0||this.lightsNode!==null,i=this.lights===!0?this.setupMaterialLightings(e):[],r=t?this.lightsNode??e.lightsNode:null,n=this.lights===!0?J(0):Wl.rgb,s=J(0),a=J(0);if(r&&(i.length>0||r.getScope().hasLights)){let o=this.setupLightingModel()||null,l=BSe(r,o,i,this.backdropNode,this.backdropAlphaNode),u=l,h=u._value??(u._value=u.getContext());s=h.reflectedLight.directSpecular,a=h.reflectedLight.indirectSpecular,n=l}return this.emissiveNode!==null&&this.emissiveNode!==void 0&&(mq.assign(J(this.emissiveNode)),n=n.add(mq)),Xe(()=>this.applyPostLighting(n,s,a))()}applyPostLighting(e,t,i){let r,n=this.ctx.accumAlpha,s=this.lights===!0,a=this.lightLayerIndex(),o=a===-1?0:a+1,l=B(1);if(s){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p)),r=function(f){let{outgoing:m,directSpecular:g,indirectSpecular:v,shadingAlpha:y,shadingBlend:_,mask:b,occlusion:x=null,ctx:w}=f,S=J(m).toVar();return Ve(eK(oK(S,pl(Wl.rgb))),()=>{let T=Xt(Yi(g.add(v)),B(0),B(1));w.accumAlpha.addAssign(Pn(w.accumAlpha).mul(y).mul(b).mul(T)),S.assign(gO(pl(Wl.rgb),S,y.mul(b),_)),S.mulAssign(u2e(x))}),S}({outgoing:e,directSpecular:t,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=J(e).toVar();let u=r,h=!1;for(let p=o;p<this.layers.length;p++){let f=this.layers[p];if(f.kind!=="fragment"||f.isMaskEnabled)continue;let m=this.runLayerBuilder(f,this.maskSourceFor(p));u=gO(u,m.color,m.calpha,f.modeNode),h=!0}if(h&&r.assign(u),!s){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"):B(1),c=s?n:n.mul(l);if(Wl.a.assign(c.mul(d)),Wl.a.lessThanEqual(USe("depthPrepassCutoff","float")).discard(),this.dithering){let p=lK(Qo.xy),f=J(.25/255,-.25/255,.25/255),m=ut(f.mul(2),f.mul(-2),p);r.assign(r.add(m))}return r}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}armRainbowNoiseSpecialization(e){let t=this.root.forceRainbowNoise.has(e.uuid),i=e.data;if(e.noiseForced=t,e.noiseCompiledIn=t||Gf(i.noiseStrength),e.noiseCompiledIn===!1){let r=e.uuid;e.onNoiseMismatch=n=>this.root.ensureRainbowNoiseCompiled(r,n)}}ensureRainbowNoiseCompiled(e,t){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(e,t);let i=this.data.layers?.data(e);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(e)&&!Gf(i.noiseStrength)||this.getLayerByUuid(e)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(e),this.reset0(this.data,this.lastContext),t!==void 0&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}updateByOp(e,t,i){if(this.isRoot)if(t!==void 0?this.data=t:t=this.data,this.setTransparent(Sd(t,i.shared),i.scene),e.path[0]==="layers"){let r=e.path[1];if(r===void 0)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(t,i);e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===r);if(!n)return;let s=t.layers.data(r);if(!s)return;this.updateLayerByOp(n,{...e,path:e.path.slice(2)},s,i)?this.reset0(t,i):zE(this)}else this.reset0(t,i);else this.root.updateByOp(e,t,i)}static hasVariableString(e){return typeof e=="string"||Array.isArray(e)&&e.some(t=>typeof t=="string")}updateLayerTextureByOp(e,t,i){if(t.path.length!==1||t.type!==0)return!0;let r=t.props,n=i.texture;if(!n)return!0;let s=e.data.texture;for(let o of Object.keys(r))if(o!=="repeat"&&o!=="offset"&&o!=="rotation"||_g.hasVariableString(n[o])||_g.hasVariableString(s?.[o]))return!0;if(e.type==="matcap")return"repeat"in r||"offset"in r||(e.data=i,e.setValue("rotation",(n.rotation??0)*ht.DEG2RAD),!1);let a=e.getValue("mat");if(!a)return!0;if(e.data=i,"repeat"in r){let o=n.repeat;a.repeat=[o?.[0]??1,o?.[1]??1]}if("offset"in r){let o=n.offset;a.offset=[o?.[0]??0,o?.[1]??0]}return"rotation"in r&&(a.rotation=n.rotation??0),a.updateMatrix(),!1}updateLayerByOp(e,t,i,r){if(t.path[0]==="texture")return this.updateLayerTextureByOp(e,t,i);if(t.path[0]!==void 0||t.type!==0)return!0;let n=t.props;if("type"in n||"category"in n||"visible"in n||"noiseType"in n)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let s of Object.keys(n)){if(s==="isMask")return!0;if(e.type==="rainbow"&&s==="noiseStrength"&&e.noiseCompiledIn!==void 0){let h=i[s];if((e.noiseForced===!0||Gf(h))!==e.noiseCompiledIn)return!0}let a=xw[e.type];if(a!==void 0&&a.includes(s))return!0;let o=SY[e.type];if(o!==void 0&&o.includes(s)){let h=e.getValue(s),d=n[s];if(Array.isArray(h)&&Array.isArray(d)&&h.length!==d.length)return!0}let l=i[s],u=e.data[s];if(s!=="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}e.data=i;for(let s of Object.keys(n))this.applyLayerValue(e,s,i,r.shared);return!1}applyLayerValue(e,t,i,r){let n=i;if((t==="alpha"||t==="visible"||t==="intensity")&&(FA(e,r),t!=="intensity"||e.type==="displace"))return;if(t==="alphaOverride"&&e instanceof tE)return void e.setValue("alphaOverride",Oh(n[t],r));if(!e.hasValue(t))return;let s=e.uniformKinds.get(t),a=n[t];switch(s){case"color":case"colorVec4":{let o=e.getValue(t),l=typeof a=="string"?r.color(a):u$(a,()=>o??new zr(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=e.getValue(t);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y));break}case"vec3":{let o=e.getValue(t);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=e.getValue(t);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=e.getValue(t);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":e.setValue(t,["x","y","z"].indexOf(String(a)));break;case"bool":e.setValue(t,!!a);break;default:(typeof a=="number"||typeof a=="boolean")&&e.setValue(t,a)}}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")return this.setTransparent(Sd(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));if(e[0]!=="layer")return;let r=e[1],n=e[2];if(!r||!n)return;let s=this.layers.find(l=>l.uuid===r);if(!s?.hasValue(n))return;if(n==="alpha")return this.setTransparent(Sd(this.data,i.shared),i.scene),void s.setValue(n,Math.max(0,Math.min(Number(t)/100,1)));let a=s.getValue(n),o=e[3];(o==="x"||o==="y"||o==="z")&&a?.isVector3||(o==="x"||o==="y")&&a?.isVector2?a[o]=Number(t):a instanceof Ri||s.setValue(n,t)}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{let r=i.data;"alpha"in r&&typeof r.alpha=="string"&&e.shared.getVariable(r.alpha,["material",this.uuid,"layer",i.id,"alpha"]);let n=i.data.type==="displace"?r.displacementType==="noise"?"displace_noise":"displace_map":i.data.type,s=Yme[n];if(s)for(let a of s){let o=r;for(let l of a.path??[])l in o&&(o=o[l]);for(let l of a.nums)l in o&&e.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)=>{e.shared.getVariable(u,["material",this.uuid,"layer",i.id,...a.path??[],l,h===0?"x":h===1?"y":"z"])})}})}clampUniformsForPreview(e,t){let i=(r,n,s)=>Math.min(Math.max(r,n),s);for(let r of this.layers)if(r.type==="displace"){let n=r.uniforms[`f${r.id}_intensity`];n.value=i(n.value,e,t)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(e=>e.assetsLoaded))return!1;for(let e of this.root.syntheticMapLayers.values())if(!e.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let e of this.layers)e.dispose();for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let e of this.flavors)e?.dispose();for(let e of this.depthTwins)e.dispose()}},wK=class extends _g{constructor(e,t,i){super(e,t,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}}});function ru(e,t){let i=$i(e.xyz);return $i(t.add(qn(i,qn(i,t).add(t.mul(e.w))).mul(2)))}function j_(e){let t=Bx(e),i=Bx(J(e.y.sub(19.1),e.z.add(33.4),e.x.add(47.2))),r=Bx(J(e.z.add(74.2),e.x.sub(124.5),e.y.add(99.4)));return J(t,i,r)}function Kme(e,t){return eMe({p:e,seed:t})}function Zme(e,t,i){return J(vO($i(e.add(J(i)).mul(t))),vO($i(e.add(J(i.add(20))).mul(t))),vO($i(e.add(J(i.sub(30))).mul(t))))}function N9(e){return{f:(t,i=0)=>_h(e.node(t)??e.getUniform(t,i)),v3:t=>$i(e.node(t)??e.getUniform(t,null)),v4:t=>Vl(e.node(t)??e.getUniform(t,null)),tex:t=>e.node(t)??e.getTexture(t,null)}}function DFe(e,t){switch(e){case"position":return function(i){let r=N9(i.registry);return Xe(()=>{let n=tr(),s=i.depTexture("uCurrentPosition"),a=i.depTexture("uCurrentVelocity"),o=i.depTexture("uCurrentEmissionRate"),l=Vl(s.sample(n)).toVar(),u=$i(l.xyz).toVar(),h=Vl(o.sample(n)).toVar(),d=_h(h.x).toVar(),c=_h(h.y).toVar(),p=_h(h.z).toVar(),f=$i(Vl(r.tex("uOriginalPosition").sample(n)).xyz.mul(r.v3("uEmitterSize"))).toVar(),m=Vl(a.sample(n)).toVar(),g=$i(m.xyz).toVar(),v=_h(m.w).toVar(),y=r.f("uMaxLifeTime",1),_=hr(.5,v),b=B(3).mul(_),x=g.mul(B(1).add(b)),w=g.mul(Fi(r.f("uFPSRatio",1),B(5)));u.addAssign(ut(w,x,_));let S=ru(r.v4("uWorldQuaternion"),f).add(r.v3("uWorldOffset"));u.assign(ut(u,S,d)),p.assign(ut(p,r.f("uTime"),d));let T=mt(y.sub(r.f("uTime").sub(p)),B(0)).div(y);return ut(Pe(0),Pe(u,T),c)})()}(t);case"velocity":return function(i){let r=N9(i.registry),n=i.features;return Xe(()=>{let s=tr(),a=i.depTexture("uCurrentPosition"),o=i.depTexture("uCurrentVelocity"),l=i.depTexture("uCurrentEmissionRate"),u=$i(Vl(a.sample(s)).xyz).toVar(),h=$i(Vl(r.tex("uOriginalPosition").sample(s)).xyz).toVar(),d=$i(Vl(r.tex("uDirections").sample(s)).xyz).toVar(),c=$i(Vl(o.sample(s)).xyz).toVar(),p=Vl(l.sample(s)).toVar(),f=_h(p.x).toVar(),m=_h(p.y).toVar(),g=_h(Vl(o.sample(s)).w).toVar(),v=B(1).sub(r.f("uRandomMassFactor").mul(function(S){return _h(S.dot(Me(12.9898,78.233)).sin().mul(43758.5453).fract())}(function(S){return S.xy}(h)).mul(.5).add(.5))).toVar(),y=r.f("uSpeed",1),_=r.f("uNoiseStrength"),b=r.f("uNoiseScale"),x=r.f("uNoiseSeed");Ve(m.equal(1),()=>{n.USE_CURL_NOISE&&(Ve(b.greaterThan(0),()=>{c.assign(Kme($i(u.mul(b).mul(.002)),x).mul(_.add(1)).mul(.05).mul(y))}),Ve(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Kme(u,x).mul(_).mul(.05).mul(y))})),n.USE_SIMPLEX_NOISE&&(Ve(b.greaterThan(0),()=>{c.assign(J(Bx($i(u.mul(b).mul(.001))).mul(_.add(1)).mul(.1)).mul(y))}),Ve(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(J(Bx($i(u.mul(_).mul(.001))).mul(.05)).mul(y))})),n.USE_FBM_NOISE&&(Ve(b.greaterThan(0),()=>{c.assign(Zme($i(u.mul(b).mul(.001)),_.add(1),x).mul(y))}),Ve(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Zme($i(u.mul(_).mul(.001)),_.add(1),x).mul(.1).mul(y))})),function(S,T,M,E,A){if(!S.features.USE_COLLIDER)return;let P=mt(T.f("uBounce").mul(2),B(.01)).toVar(),N=T.f("particleSize");if(S.features.USE_SPHERE_COLLIDER){let D=T.v3("uColliderSize"),O=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))).toVar(),z=$i(O.div(D)).toVar(),L=Yi(z).toVar();Ve(L.lessThanEqual(B(1).add(N.div(Yi(D)))).and(A.equal(0)),()=>{let V=z.mul(B(1).add(N.div(Yi(D)))),G=Ut($i(V.div(D.mul(D))));G=ru(T.v4("uColliderQuaternion"),G),E.assign(DA(E,G).mul(P)),A.assign(1)}).Else(()=>{A.assign(0)})}if(S.features.USE_BOX_COLLIDER){let D=$i(T.v3("uColliderSize").div(2)),O=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))).toVar(),z=$i(ui(O).sub(D)).toVar(),L=mt(z.x,mt(z.y,z.z)).toVar();Ve(L.lessThanEqual(N.mul(.5)).and(A.equal(0)),()=>{let V=J(0).toVar();Ve(z.x.greaterThan(z.y).and(z.x.greaterThan(z.z)),()=>{V.assign(J(jc(O.x),0,0))}).ElseIf(z.y.greaterThan(z.z),()=>{V.assign(J(0,jc(O.y),0))}).Else(()=>{V.assign(J(0,0,jc(O.z)))});let G=ru(T.v4("uColliderQuaternion"),$i(V));E.assign(DA(E,G).mul(P)),A.assign(1)}).Else(()=>{A.assign(0)})}}(i,r,u,c,g),function(S,T,M,E){if(!S.features.USE_ATTRACTOR)return;let A=T.f("uForceIntensity"),P=T.f("uForceDamping");if(S.features.USE_FORCE_LOCAL_SPACE){let N,D,O=T.f("particleSize");if(S.features.USE_SPHERE_COLLIDER){let z=T.v3("uColliderSize"),L=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos"))));N=Yi($i(L.div(z))).toVar(),D=B(1)}else{let z=$i(T.v3("uColliderSize").div(2)),L=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))),V=$i(ui(L).sub(z));N=mt(V.x,mt(V.y,V.z)).toVar(),D=O}Ve(N.lessThanEqual(D),()=>{let z=S.features.USE_SPHERE_COLLIDER?B(1).sub(N).mul(A):mt(B(1).sub(D.div(N)),B(0)).mul(A),L=$i(M.sub(T.v3("uColliderPos"))),V=Ut(L).mul(z);E.subAssign(V),E.mulAssign(P)})}else{let N=$i(M.sub(T.v3("uColliderPos"))),D=Ut(N).mul(A);E.subAssign(D),E.mulAssign(P)}}(i,r,u,c),function(S,T,M,E,A,P,N){if(!S.features.USE_VORTEX)return;let D=T.f("particleSize"),O=$i(T.v3("uColliderSize").div(2)),z=ru(T.v4("uColliderQuaternionInvert"),$i(M.sub(T.v3("uColliderPos")))).toVar(),L=$i(ui(z).sub(O)).toVar(),V=mt(L.x,mt(L.y,L.z)).toVar();Ve(V.lessThanEqual(D),()=>{let G=T.f("uForceIntensity"),Y=T.v3("uColliderPos").add(ru(T.v4("uColliderQuaternion"),J(0))),$=$i(Y.sub(M)).toVar(),Q=J(0,1,.01),ue=Ut(qn(Q,ru(T.v4("uColliderQuaternion"),$))).toVar(),pe=Yi($.mul(G).mul(3)).toVar();E.assign(ue.mul(pe).mul(.005));let xe=ru(T.v4("uWorldQuaternion"),A);E.addAssign(xe.mul(N).mul(B(1).sub(T.f("uForceDamping"))).div(P.mul(.5)))})}(i,r,u,c,d,v,y)});let w=n.USE_NORMALS?d:r.v3("uDirectionsAxis");return c.assign(ut(c,ru(r.v4("uWorldQuaternion"),w).mul(y),f)),c.addAssign(r.v3("uGravity").div(v.mul(.5)).mul(B(1).sub(g))),Pe(c,g)})()}(t);case"emissionRate":return function(i){let r=N9(i.registry);return Xe(()=>{let n=tr(),s=i.depTexture("uCurrentEmissionRate"),a=_h(Vl(r.tex("uIndex").sample(n)).x).toVar(),o=Vl(s.sample(n)).toVar(),l=_h(o.y).toVar(),u=_h(o.z).toVar(),h=r.f("uLastIndexEmitted"),d=r.f("uParticlesToEmit"),c=hr(h,a),p=hr(a,h.add(d).sub(1)),f=c.mul(p);return u.assign(ut(u,r.f("uTime"),f)),Pe(f,ut(l,B(1),f),u,1)})()}(t)}}var _h,$i,Vl,eMe,Qme,Jme,I9,tMe,NFe=U(()=>{bi(),eC(),_h=e=>e,$i=e=>e,Vl=e=>e,eMe=Xe(e=>{let t=$i(e.p.add(e.seed)).toVar(),i=J(.1,0,0),r=J(0,.1,0),n=J(0,0,.1),s=j_($i(t.sub(i))).toVar(),a=j_($i(t.add(i))).toVar(),o=j_($i(t.sub(r))).toVar(),l=j_($i(t.add(r))).toVar(),u=j_($i(t.sub(n))).toVar(),h=j_($i(t.add(n))).toVar(),d=l.z.sub(o.z).sub(h.y).add(u.y),c=h.x.sub(u.x).sub(a.z).add(s.z),p=a.y.sub(s.y).sub(l.x).add(o.x);return Ut(J(d,c,p).mul(5))})}),IFe=U(()=>{oe(),vn(),bi(),NFe(),Qme=class{constructor(){this.nodes=new Map,this.textureNodes=new Map}getUniform(e,t){let i=this.nodes.get(e);return i||(i=Fe(t),this.nodes.set(e,i)),i}getTexture(e,t){let i=this.textureNodes.get(e);return i||(i=vt(t??new Ri),this.textureNodes.set(e,i)),i}node(e){return this.nodes.get(e)??this.textureNodes.get(e)}adopt(e){for(let t of Object.keys(e)){let i=e[t].value;if(i instanceof Ri||i&&typeof i=="object"&&i.isTexture){let r=this.getTexture(t,i);r.value=i,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(n){r.value=n}}})}else{let r=this.getUniform(t,i);r.value=i,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(n){r.value=n}}})}}}},Jme=class{constructor(e,t,i,r){this.name=e,this.kind=t,this.initialTexture=i,this.currentIndex=0,this.registry=new Qme,this.depTextureNodes=new Map,this.dependencies=[],this.nodeMaterial=null,this._uniformsStore={};let n=()=>new Ui(r,r,{type:Wt,minFilter:yt,magFilter:yt,wrapS:vr,wrapT:vr,depthBuffer:!1});this.renderTargets=[n(),n()],this.material=Object.defineProperty({},"uniforms",{get:()=>this._uniformsStore,set:s=>{this.registry.adopt(s),this._uniformsStore=s}})}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()}},I9=new Cn,tMe=class{constructor(e,t,i,r){this.sizeX=e,this.sizeY=t,this.renderer=i,this.features=r,this.variables=[],this._copyMaterial=null,this._copyTextureNode=vt(new Ri)}addVariable(e,t,i){let r=new Jme(e,e==="uCurrentPosition"?"position":e==="uCurrentVelocity"?"velocity":"emissionRate",i,this.sizeX);return this.variables.push(r),r}setVariableDependencies(e,t){e.dependencies=t;for(let i of t)e.depTextureNodes.has(i.name)||e.depTextureNodes.set(i.name,vt(i.currentRenderTarget.texture))}init(){if(!this._copyMaterial){let e=new ei;e.name="WebGPUComputation.copy",e.fragmentNode=Pe(this._copyTextureNode),e.depthTest=!1,e.depthWrite=!1,e.blending=Di,this._copyMaterial=e}for(let e of this.variables){this._copyTextureNode.value=e.initialTexture;for(let i of e.renderTargets)this._renderQuad(this._copyMaterial,i);let t=new ei;t.name=`WebGPUComputation.${e.kind}`,t.fragmentNode=DFe(e.kind,{features:this.features,registry:e.registry,depTexture:i=>{let r=e.depTextureNodes.get(i);if(!r)throw new Error(`WebGPUComputationRenderer: variable "${e.name}" reads undeclared dependency "${i}"`);return r},resolution:new Z(this.sizeX,this.sizeY)}),t.depthTest=!1,t.depthWrite=!1,t.blending=Di,t.needsUpdate=!0,e.nodeMaterial=t}}compute(){for(let e of this.variables)if(e.nodeMaterial){for(let t of e.dependencies)e.depTextureNodes.get(t.name).value=t.currentRenderTarget.texture;this._renderQuad(e.nodeMaterial,e.nextRenderTarget)}for(let e of this.variables)e.advance()}getCurrentRenderTarget(e){return e.currentRenderTarget}_renderQuad(e,t){let i=this.renderer,r=i.getRenderTarget(),n=i.getMRT();i.setMRT(null),i.setRenderTarget(t),I9.material=e,I9.render(i),i.setRenderTarget(r),i.setMRT(n)}dispose(){for(let e of this.variables)e.dispose();this._copyMaterial?.dispose()}}});function ege(e,t){switch(e){case"linearFadeOut":return xh(B(1).sub(t));case"linearInOut":return xh(t.lessThan(.5).select(t,B(1).sub(t)));case"exponentialInOut":return xh(t.lessThan(.4).select(t.div(.4),t.greaterThan(.6).select(B(1).sub(t.sub(.6).div(.4)),B(1))));case"constant":return B(1);default:return t}}function tge(e){return xh(e.dot(Me(12.9898,78.233)).sin().mul(43758.5453).fract())}var xh,iMe,OFe=U(()=>{oe(),vn(),bi(),xh=e=>e,iMe=class extends ei{constructor(e,t){super(),this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this._uniformsStore={},this._uPosition=vt(new Ri),this._uTexture=vt(new Ri),this._uColor=Fe(new ct(1,1,1,1)),this._uColor2=Fe(new ct(1,1,1,1)),this._uSize=Fe(1),this._uSizeEnd=Fe(1),this._uWorldOffset=Fe(new R),this._uWorldQuaternion=Fe(new ct(0,0,0,1)),this._uRotation=Fe(0),this._uRotationEnd=Fe(0),this._center=Fe(new Z(.5,.5)),this._uRandScaleFactor=Fe(0),this._uRandRotationFactor=Fe(0),this.context=t,this.name="WebGPUParticleMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.lights=!1;let i=s=>({get value(){return s.value},set value(a){s.value=a}}),r=s=>({get value(){return s.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,s.value)}}),n=s=>({get value(){return s.value},set value(a){a&&a.isTexture&&(s.value=a)}});this._binders={uPosition:n(this._uPosition),uTexture:n(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(e),this._rebuildGraph()}get uniforms(){return this._uniformsStore}set uniforms(e){for(let t of Object.keys(e)){let i=this._binders[t];if(!i)continue;let r=e[t]?.value;Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i}),r!==void 0&&(i.value=r)}this._uniformsStore=e}updateState(e){let t=!1;if(e.coloring!==void 0){let i=e.coloring==="random";t||(t=i!==this.isColoringRandom),this.isColoringRandom=i}if(e.color!==void 0&&(this.uniforms.uColor.value=Array.isArray(e.color)?e.color:this.context.shared.color(e.color)),e.color2!==void 0&&(this.uniforms.uColor2.value=Array.isArray(e.color2)?e.color2:this.context.shared.color(e.color2)),e.size!==void 0){this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1];let i=e.size[0]!==e.size[1];t||(t=i!==this.useSizeEnd),this.useSizeEnd=i}e.ease!==void 0&&e.ease!==this.easeOpacity&&(this.easeOpacity=e.ease,t=!0),e.easeSize!==void 0&&e.easeSize!==this.easeSize&&(this.easeSize=e.easeSize,t=!0),t&&this._rebuildGraph(),this.needsUpdate=!0}_rebuildGraph(){let e=$g("particleRef","vec2"),t=this._uPosition,i=Xe(()=>{let n=t.sample(e).toVar(),s=xh(n.w).toVar(),a=n.xyz.sub(this._uWorldOffset);a=function(M,E){let A=M.xyz;return E.add(A.cross(A.cross(E).add(E.mul(M.w))).mul(2))}(this._uWorldQuaternion,a);let o=$g("position","vec3"),l=B(1).sub(s),u=this.useSizeEnd?o.mul(J(ut(this._uSize,this._uSizeEnd,l))):o.mul(J(xh(this._uSize).mul(ege(this.easeSize,l)))),h=PB,d=h.element(0).xyz.length(),c=h.element(1).xyz.length(),p=tge(e).toVar(),f=B(1).sub(xh(this._uRandScaleFactor).mul(p)),m=Me(d,c).mul(f).toVar(),g=2*Math.PI,v=p.mul(xh(this._uRandRotationFactor)).mul(g),y=B(1).sub(xh(this._uRotation)).mul(g),_=B(1).sub(xh(this._uRotationEnd)).mul(g),b=ut(y.add(v),_.add(v),s).toVar(),x=this._center,w=u.xy.sub(x.sub(Me(.5))).mul(m).toVar(),S=Me(Yo(b).mul(w.x).sub(Pa(b).mul(w.y)),Pa(b).mul(w.x).add(Yo(b).mul(w.y))).toVar(),T=GSe.mul(Pe(a,1)).toVar();return T.xy.addAssign(S),Mw.mul(T)}),r=Xe(()=>{let n=t.sample(e),s=xh(n.w).toVar();s.lessThanEqual(.005).discard();let a=B(1).sub(s),o=this.isColoringRandom?tge(e):a,l=ut(this._uColor,this._uColor2,o).toVar(),u=ege(this.easeOpacity,a).toVar(),h=this._uTexture.sample(tr()).toVar();return Pe(h.rgb.mul(l.rgb),xh(l.a).mul(h.a).mul(u))});this.vertexNode=i(),this.colorNode=r(),this.needsUpdate=!0}nodeMaterialDispose(){this.dispose()}}}),LFe=U(()=>{OY(),IFe(),OFe(),IY={createComputation:(e,t,i,r)=>new tMe(e,t,i,r),createMaterial:(e,t)=>new iMe(e,t)}});function rMe(e,t){return(i,r,n,s)=>{let a=n.mod(t).add(i.add(.5).div(e)).div(t),o=Ct(n.div(t)).add(r.add(.5).div(e)).div(t);return ax(s.sample(Me(a,o)))}}function ige(e){let t=Cr(ln(e.x).mul(65535).add(.5)),i=t.bitAnd(Cr(255)).toFloat().mul(.00392156862),r=t.shiftRight(Cr(8)).bitAnd(Cr(255)).toFloat().mul(.00392156862);return Pe(r,i,e.y,e.z)}function nMe(e){let{levelShiftX:t,scale:i,originOffset:r}=function(m){switch(m){case 5:return{levelShiftX:[4,6,12,24,48,96,192],scale:8*iE,originOffset:16};case 7:return{levelShiftX:[4,6,12,24,48,96,192,384,768,1536],scale:2*iE,originOffset:64};case 8:return{levelShiftX:[4,8,16,32,64,128,256,512,1024,2048,4096],scale:iE,originOffset:128};default:return{levelShiftX:[4,8,16,32,64,128,256,512],scale:4*iE,originOffset:32}}}(e.resolutionLevel),n=e.pyramidLevelSizes.length,s=n%2==0?n-3:n-2,a=n%2==0,o=Math.pow(2,e.resolutionLevel),l=e.pyramidLevelSizes[n-1]/o,u=rMe(o,l),h=e.pyramid1Size.width,d=e.pyramid1Size.height,c=e.pyramid2Size.width,p=e.pyramid2Size.height,f=NA(SK.map(([m,g,v])=>new R(m,g,v)));return m=>{let g=J(0).toVar(),v=J(0,0,1).toVar(),y=Pe(0).toVar(),_=m.toVar(),b=Ct(_.div(3)).toVar(),x=(A,P)=>Me(ln(A.x).add(P).add(.5).div(h),ln(A.y).add(.5).div(d)),w=(A,P)=>Me(ln(A.x).add(P).add(.5).div(c),ln(A.y).add(.5).div(p)),S=h-2,T=c-1,M=Me(0,0).toVar(),E=ax(e.pyramid2.sample(w(yO(M),T))).toVar();return Ve(b.lessThan(ln(E.x)),()=>{let A=B(0).toVar(),P=re=>{let Se=ax(E.add(Pe(A))).toVar(),W=Pe(ef(Se.yzw),A),k=ax(Pe(Pe(b).greaterThanEqual(W)).mul(Pe(Pe(b).lessThan(Se)))).toVar();M.mulAssign(2),M.addAssign(Me(0,1).mul(ln(k.x)).add(Me(1,1).mul(ln(k.y))).add(Me(1,0).mul(ln(k.z)))),A.assign(k.dot(W)),re?.()};for(let re=0;re<s;){let Se=t[re];P(()=>{T-=Se,E.assign(e.pyramid1.sample(x(yO(M),S)))}),re++;let W=t[re];P(()=>{S-=W,E.assign(e.pyramid2.sample(w(yO(M),T)))}),re++}a&&P(null);let N=ln(M.x).mod(o).toVar(),D=ln(M.y).mod(o).toVar(),O=Ct(ln(M.x).div(o)).add(Ct(ln(M.y).div(o)).mul(l)).toVar(),z=_.sub(A.mul(3)).mul(.0625).add(.03125),L=u(N,D,O,e.voxel).toVar(),V=ln(L.w).add(.5).mul(.00390625),G=ln(ax(e.triTable.sample(Me(z,V))).x).mul(2).toInt().toVar(),Y=J(N,D,O).add(ef(f.element(G))).toVar(),$=J(N,D,O).add(ef(f.element(G.add(1)))).toVar(),Q=u(ln(Y.x),ln(Y.y),ln(Y.z),e.potential).toVar(),ue=u(ln($.x),ln($.y),ln($.z),e.potential).toVar(),pe=ln(Q.x).div(ln(Q.x).sub(ln(ue.x)));y.assign(ut(ige(ef(Q.yzw)),ige(ef(ue.yzw)),pe)),g.assign(Y.add($.sub(Y).mul(pe)).sub(J(r)).mul(i));let xe=u(ln(Y.x),ln(Y.y),ln(Y.z),e.voxel),we=u(ln($.x),ln($.y),ln($.z),e.voxel);v.assign(Ut(ut(ef(xe.xyz),ef(we.xyz),pe)))}),{position:g,normal:v,color:y}}}function rge(e,t){e.needsPreviousData?.()===!0&&DB.assign(t)}function BFe(e){if(e.cached)return function(n){let s=()=>n.drawIndex?n.drawIndex.element(UE):UE;return{position:Xe(a=>{let o=ef(n.positions.element(s()).xyz).toVar();return rge(a,o),o})(),normal:_q(n.normals.element(s()).xyz),color:_q(n.colors.element(s()))}}(e.cached);let t=nMe(e),i=Bn("vec3","vShapeBlendNormal"),r=Bn("vec4","vShapeBlendColor");return{position:Xe(n=>{let{position:s,normal:a,color:o}=t(UE.toFloat());return i.assign(a),r.assign(o),rge(n,s),s})(),normal:i,color:r}}var ln,yO,ef,ax,iE,SK,TK=U(()=>{oe(),bi(),ln=e=>e,yO=e=>e,ef=e=>e,ax=e=>e,iE=2,SK=[[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 sMe(e,t){let i=Mt(e.xyz);return Mt(t.add(i.cross(i.cross(t).add(t.mul(Ae(e.w)))).mul(2)))}function aMe(e,t,i,r){let n=Xt(e,-1,1),s=e.sub(n).mul(2).add(1),a=Xt(B(.5).add(n.mul(.5).mul(t.sub(n.mul(s).mul(i))).div(r)),0,1);return Ae(ut(t,n.mul(s).mul(i),a).sub(n.mul(r).mul(a).mul(B(1).sub(a))))}function oMe(e,t,i,r,n){let s=B(0).toVar(),a=Ae(i.y),o=Ae(i.z),l=Ae(i.w),u=Ve(e.lessThan(.5),()=>{s.assign(Yi(t).sub(a))}).ElseIf(e.lessThan(1.5),()=>{let d=J(a,o,l),c=Yi(t.div(d)),p=Yi(t.div(d.mul(d)));s.assign(c.mul(c.sub(1)).div(p))}).ElseIf(e.lessThan(2.5),()=>{let d=J(a,o,l),c=ui(t).sub(d).toVar();s.assign(Yi(mt(c,J(0))).add(Fi(mt(Ae(c.x),mt(Ae(c.y),Ae(c.z))),0)))}).ElseIf(e.lessThan(3.5),()=>{let d=ui(Me(Yi(_O(t.xz)),Ae(t.y))).sub(Me(o,a)).toVar();s.assign(Fi(mt(Ae(d.x),Ae(d.y)),0).add(Yi(mt(d,Me(0)))))}).ElseIf(e.lessThan(4.5),()=>{let d=a,c=o,p=l,f=Me(Yi(_O(t.xz)),Ae(t.y)).toVar(),m=Me(p,d),g=Me(p.sub(c),d.mul(2)),v=Me(Ae(f.x).sub(Fi(Ae(f.x),Ae(f.y).lessThan(0).select(c,p))),ui(Ae(f.y)).sub(d)).toVar(),y=f.sub(m).add(g.mul(Xt(et(m.sub(f),g).div(et(g,g)),0,1))).toVar(),_=Ae(y.x).lessThan(0).and(Ae(v.y).lessThan(0)).select(B(-1),B(1));s.assign(_.mul(Rh(Fi(et(v,v),et(y,y)))))}).ElseIf(e.lessThan(5.5),()=>{let d=Me(Yi(_O(t.xy)).sub(a),Ae(t.z));s.assign(Yi(d).sub(o))}),h=()=>{let d=ui(Ae(t.x)).toVar(),c=Me(a,o),p=l,f=Ae(r.w),m=Ae(c.y).mul(d).greaterThan(Ae(c.x).mul(Ae(t.y))).select(et(Me(d,Ae(t.y)),c),Yi(Me(d,Ae(t.y)))),g=J(d,Ae(t.y),Ae(t.z));s.assign(Rh(et(g,g).add(p.mul(p)).sub(p.mul(m).mul(2))).sub(f))};return n?u.ElseIf(e.lessThan(6.5),h).Else(()=>{s.assign(n(t,i,r))}):u.Else(h),s}function c$(e,t=!0){let i=e.spatialDivisions,r=e.spatialn;return(n,s)=>{let a=t?Pe(0).toVar():Pe(0),o=B(1e3).toVar(),l=t?B(0).toVar():B(0),u=t?B(0).toVar():B(0),h=Ae(s.y).add(Ae(s.z).mul(i)).add(.5).div(i*i),d=(f,m)=>{let g=m.toVar();Zr(Hb,({i:v})=>{Ve(g.lessThan(1),()=>{Ya()}),g.mulAssign(.5),Ve(gr(g).greaterThanEqual(.5),()=>{let y=B(v).add(f).add(.5).mul(1/m4),_=e.shapeRow(y,0).toVar(),b=e.shapeRow(y,1).toVar(),x=e.shapeRow(y,2).toVar(),w=e.shapeRow(y,3).toVar(),S=sMe(wo(b),Mt(n.sub(Mt(_.xyz)))).div(Ae(w.z)).toVar(),T=oMe(Ae(x.x),Mt(S),wo(x),wo(w),e.meshSdf).sub(Ae(w.y)).mul(Ae(w.z)).toVar(),M=Ae(w.x).toVar(),E=Ae(_.w);if(o.assign(aMe(E,o,T,M)),t){let A=hr(-1.5,E).mul(hr(E,-.5)),P=Qr(u,0,T.negate()),N=ut(B(1),P,A);a.mulAssign(N),l.mulAssign(N),u.assign(mt(u,M)),M.addAssign(e.colorKBump);let D=e.shapeRow(y,4).toVar(),O=Qr(M,0,T).mul(Ae(D.a).greaterThanEqual(0).toFloat()).toVar();l.addAssign(O),a.addAssign(D.mul(O))}})})},c=f=>{let m=f.mul(4*Hb).toVar(),g=wo(e.spatialTex.sample(Me(Ae(s.x).mul(r).add(f).add(.5).div(r*i),h))).toVar();d(Ae(m),Ae(g.x)),d(Ae(m.add(Hb)),Ae(g.y)),d(Ae(m.add(2*Hb)),Ae(g.z)),d(Ae(m.add(3*Hb)),Ae(g.w))};r===1?c(B(0)):Zr(r,({i:f})=>{c(B(f).toVar())}),t&&a.divAssign(l);let p=ut(o,B(0),hr(1e20,o)).toVar();return{sdf:Ae(p),color:wo(a),colorDivisor:Ae(l)}}}function nge(e){let t=e.resolution,i=t-1,r=e.colorResolution,n=e.capacity,s=t/4,a=s-1,o=Fe(e.bboxHalf),l=Fe(e.bboxOffset),u=Fe(1e30),h=Fe(new R(0,0,0)),d=Fe(new R(s,s,s)),c=e.env.spatialDivisions,p=B(e.buildSeq).mul(0),f=e.sparseStorage??null,m=f?f.poolBricks:0,g=f?Math.ceil(m/4096):0,v=f?.meshlet??null,y=v?v.drawIndex:null,_=v?Math.floor(n/24):0,b=v?v.vertexBlocks:0,x=(q,fe,Be,F)=>{let ne=new by(q,fe,Be);return ne.format=aa,ne.type=Wt,ne.minFilter=yt,ne.magFilter=yt,ne.name=F,ne},w=f?x(256,256,4*Math.max(g,1),"SplineShapeBlend.ultraSdfPool"):e.reuseTextures?.sdfTexture??x(t,t,t,"SplineShapeBlend.ultraSdf");w.format=aa,w.type=Wt,w.minFilter=yt,w.magFilter=yt;let S=e.reuseTextures?.colorTexture??new by(r,r,r);S.name="SplineShapeBlend.ultraColor";let T=e.reuseTextures?.coarseTexture??new by(s,s,s);T.format=aa,T.type=Wt,T.minFilter=yt,T.magFilter=yt,T.name="SplineShapeBlend.ultraCoarse";let M=$n(8,"uint").toAtomic(),E=(q=0)=>M.element(q),A=f?$n(v?12:4,"int").toAtomic():null,P=q=>A.element(q),N=f?$n(Math.max(m,1),"float"):null,D=s*s*s,O=f?$n(D*(v?4:1),"float"):null,z=q=>De(Ae(q.x).add(Ae(q.y).mul(s)).add(Ae(q.z).mul(s*s))),L=q=>O.element(z(q)),V=q=>O.element(z(q).add(De(D))),G=q=>O.element(z(q).add(De(2*D))),Y=q=>O.element(z(q).add(De(3*D))),$=q=>O.element(q.add(De(3*D))),Q=f?$n(Math.max(m,1),"float"):null,ue=v?$n(3*Math.max(_,1),"float"):null,pe=q=>ue.element(q),xe=q=>pe(De(q)),we=q=>pe(De(q.add(_))),re=q=>pe(q.add(De(2*_))),Se=v?$n(Math.max(b,1),"float"):null,W=q=>Se.element(q),k=v?$n(24*Math.max(_,1),"uint"):null,K=q=>k.element(q),ie=v?Fe(0):null,j=v?Fe(new Ue):null,ae=v?Fe(2):null,se=NA(Array.from(e.numTrisTable)),H=NA(SK.map(([q,fe,Be])=>new R(q,fe,Be))),me=c$(e.env,!1),be=c$(e.env),ke=(q,fe)=>Mt(q.div(fe).mul(2).sub(1)),Te=(q,fe)=>Mt(q.div(fe).mul(c-1).floor()),Ze=Xe(()=>{for(let q=0;q<8;q++)kl(E(q),Cr(0))})(),ze=Xe(()=>{Ve(De(Sa).greaterThanEqual(De(n)),()=>{bn()}),e.buffers.positions.element(De(Sa)).assign(Pe(0))})(),qe=v?Xe(()=>{Ve(De(Sa).greaterThanEqual(De(n)),()=>{bn()}),y.element(De(Sa)).assign(Cr(p))})():null,Ne=Ef(T),ee=q=>Ae(wo(Ne.load(Ha(Xt(q,J(0),J(a))))).x),Ce=q=>Ae(L(Mt(Xt(q,J(0),J(a))))),He=(q,fe)=>{let Be=mt(q,0),F=Ct(Be.div(4096)),ne=Be.sub(F.mul(4096)),Ee=Ct(ne.div(64)),Ie=ne.sub(Ee.mul(64));return Mt(J(Ie,Ee,F).mul(4).add(fe))},pt=Xe(()=>{let q=J(cl).add(h).toVar();Ve(Ae(q.x).greaterThan(a).or(Ae(q.y).greaterThan(a)).or(Ae(q.z).greaterThan(a)),()=>{bn()});let fe=Mt(q.mul(4).add(J(1.5))),Be=(F=>{let ne=B(1e3).toVar();return Zr(m4,({i:Ee})=>{Ve(B(Ee).greaterThanEqual(Ae(e.npart)),()=>{Ya()});let Ie=B(Ee).add(.5).mul(1/m4),_e=e.env.shapeRow(Ie,0).toVar(),ye=e.env.shapeRow(Ie,1).toVar(),Ge=e.env.shapeRow(Ie,2).toVar(),at=e.env.shapeRow(Ie,3).toVar(),bt=sMe(wo(ye),Mt(F.sub(Mt(_e.xyz)))).div(Ae(at.z)).toVar(),Bt=oMe(Ae(Ge.x),Mt(bt),wo(Ge),wo(at),e.env.meshSdf).sub(Ae(at.y)).mul(Ae(at.z)).toVar();ne.assign(aMe(Ae(_e.w),ne,Bt,Ae(at.x)))}),Ae(ne)})(ke(fe,i));vg(T,Ha(q),Pe(Ae(Be.add(p)),0,0,0)).toStack()})(),tt=q=>{Ve(Ae(q.x).greaterThan(a).or(Ae(q.y).greaterThan(a)).or(Ae(q.z).greaterThan(a)),()=>{bn()})},Yt=f?Xe(()=>{let q=J(cl).toVar();tt(Mt(q)),L(Mt(q)).assign(Ae(B(-1).add(p))),v&&(V(Mt(q)).assign(Ae(B(-1).add(p))),G(Mt(q)).assign(Ae(B(-1).add(p))))})():null,ni=f?Xe(()=>{let q=J(cl).add(h).toVar();tt(Mt(q));let fe=ee(Mt(q)).toVar(),Be=Ce(Mt(q)).toVar();Ve(ui(fe).greaterThan(u).and(Be.greaterThan(-.5)),()=>{let F=yh(P(1),De(1)).toVar();N.element(F).assign(Be),L(Mt(q)).assign(Ae(B(-1).add(p)))})})():null,ar=f?Xe(()=>{let q=J(cl).add(h).toVar();tt(Mt(q));let fe=ee(Mt(q)).toVar(),Be=Ce(Mt(q)).toVar();Ve(ui(fe).lessThanEqual(u).and(Be.lessThan(-.5)),()=>{let F=B(-1).toVar(),ne=iO(P(1),De(1)).toVar();Ve(ne.greaterThanEqual(1),()=>{F.assign(Ae(N.element(ne.sub(1))))}).Else(()=>{yh(P(1),De(1));let Ee=yh(P(0),De(1)).toVar();Ve(Ee.lessThan(De(m)),()=>{F.assign(Ee.toFloat())}).Else(()=>{kl(P(2),De(1))})}),Ve(F.greaterThan(-.5),()=>{Q.element(De(F)).assign((Ee=>Ae(Ae(Ee.x).add(Ae(Ee.y).mul(256)).add(Ae(Ee.z).mul(65536))))(Mt(q))),L(Mt(q)).assign(Ae(F.add(p)))})})})():null,St=f?Xe(()=>{let q=Fv(P(0)).toVar(),fe=Fv(P(2)).toVar();if(kl(E(1),Cr(q)),kl(E(2),Cr(fe)),kl(P(2),De(0)),v){let Be=Fv(P(3)).toVar(),F=Fv(P(5)).toVar();kl(E(4),Cr(Be)),kl(E(5),Cr(F)),kl(P(5),De(0));let ne=Fv(P(6)).toVar(),Ee=Fv(P(8)).toVar();kl(E(6),Cr(ne)),kl(E(7),Cr(Ee)),kl(P(8),De(0))}})():null,Nt=v?Xe(()=>{let q=J(cl).toVar();Ve(Ae(q.x).greaterThanEqual(Ae(d.x)).or(Ae(q.y).greaterThanEqual(Ae(d.y))).or(Ae(q.z).greaterThanEqual(Ae(d.z))),()=>{bn()});let fe=Mt(q.add(h)).toVar();tt(Mt(fe));let Be=Ae(G(Mt(fe))).toVar();Ve(Be.greaterThan(-.5),()=>{let ne=yh(P(7),De(1)).toVar();W(ne).assign(Be),G(Mt(fe)).assign(Ae(B(-1).add(p)))});let F=Ae(V(Mt(fe))).toVar();Ve(F.lessThan(-.5),()=>{bn()}),V(Mt(fe)).assign(Ae(B(-1).add(p))),Zr(48,()=>{Ve(F.lessThan(-.5),()=>{Ya()});let ne=yh(P(4),De(1)).toVar();re(ne).assign(F),F.assign(Ae(xe(F)))})})():null,Qt=v?Xe(()=>{let q=J(cl).add(h).toVar();tt(Mt(q));let fe=B(0).toVar();Ve(Ce(Mt(q)).greaterThan(-.5),()=>{let Be=Mt(q.mul(4)).toVar(),F=Ml.map(([_e,ye,Ge])=>qr(Mt(J(Ae(Be.x).add(4*_e),Ae(Be.y).add(4*ye),Ae(Be.z).add(4*Ge)))).toVar()),ne=F[0];for(let _e=1;_e<8;_e++)ne=ne.add(F[_e]);let Ee=Ut(ne).toVar(),Ie=et(F[0],Ee);for(let _e=1;_e<8;_e++)Ie=Fi(Ie,et(F[_e],Ee));Ve(Ae(Ie).greaterThan(Ae(ae)),()=>{fe.assign(B(1))})}),Y(Mt(q)).assign(Ae(fe.add(p)))})():null,Ei=Math.min(4096,Math.max(m,1)),xi=()=>{let q=J(cl).toVar(),fe=Ct(Ae(q.x).mul(.25)).toVar(),Be=Ct(Ae(q.y).mul(.25)).toVar(),F=Be.mul(Ei).add(fe).toVar(),ne=J(Ae(q.x).sub(fe.mul(4)),Ae(q.y).sub(Be.mul(4)),Ae(q.z)).toVar();return{slot:Ae(F),local:Mt(ne)}},mi=q=>(fe=>{let Be=Ct(fe.div(65536)),F=fe.sub(Be.mul(65536)),ne=Ct(F.div(256)),Ee=F.sub(ne.mul(256));return Mt(J(Ee,ne,Be))})(Ae(Q.element(De(q)))),Ai=f?Xe(()=>{let q=J(cl).add(h.mul(4)).toVar(),fe=Mt(q.mul(.25).floor()).toVar(),Be=Ce(fe).toVar();Ve(Be.lessThan(-.5),()=>{bn()});let{sdf:F}=me(ke(Mt(q),i),Te(Mt(q),i));vg(w,Ha(He(Be,Mt(q.sub(fe.mul(4))))),Pe(Ae(F.add(p)),0,0,0)).toStack()})():null,Or=f?Xe(()=>{let{slot:q,local:fe}=xi();Ve(q.greaterThanEqual(m),()=>{bn()});let Be=mi(q).toVar();Ve(Ce(Mt(Be)).notEqual(q),()=>{bn()});let F=Mt(Be.mul(4).add(fe)).toVar(),{sdf:ne}=me(ke(Mt(F),i),Te(Mt(F),i));vg(w,Ha(He(q,Mt(fe))),Pe(Ae(ne.add(p)),0,0,0)).toStack()})():Xe(()=>{let q=J(cl).add(h.mul(4)).toVar(),fe=ee(Mt(q.mul(.25).floor())).toVar();Ve(ui(fe).greaterThan(u),()=>{vg(w,Ha(q),Pe(Ae(fe.add(p)),0,0,0)).toStack(),bn()});let{sdf:Be}=me(ke(Mt(q),i),Te(Mt(q),i));vg(w,Ha(q),Pe(Ae(Be.add(p)),0,0,0)).toStack()})(),Hr=Xe(()=>{let q=J(cl).add(h.mul(2)).toVar();Ve(Ae(q.x).greaterThan(r-1).or(Ae(q.y).greaterThan(r-1)).or(Ae(q.z).greaterThan(r-1)),()=>{bn()}),Ve(ui(ee(Mt(q.mul(.5).floor()))).greaterThan(u),()=>{bn()});let{color:fe,colorDivisor:Be}=be(ke(Mt(q),r-1),Te(Mt(q),r-1)),F=wo(Be.greaterThan(0).select(fe,Pe(0)));vg(S,Ha(q),Xt(wo(F.add(p)),Pe(0),Pe(1))).toStack()})(),ir=Ef(w),Zi=f?(q,fe,Be)=>{let F=Xt(J(q,fe,Be),J(0),J(i)),ne=F.mul(.25).floor(),Ee=Ce(Mt(ne)),Ie=Ae(wo(ir.load(Ha(He(Ee,Mt(F.sub(ne.mul(4))))))).x);return Ae(Ee.lessThan(-.5).select(ee(Mt(ne)),Ie))}:(q,fe,Be)=>Ae(wo(ir.load(Ha(Xt(J(q,fe,Be),J(0),J(i))))).x),qr=q=>{let fe=Ae(q.x),Be=Ae(q.y),F=Ae(q.z),ne=Zi(fe.add(1),Be,F).sub(Zi(fe.sub(1),Be,F)),Ee=Zi(fe,Be.add(1),F).sub(Zi(fe,Be.sub(1),F)),Ie=Zi(fe,Be,F.add(1)).sub(Zi(fe,Be,F.sub(1))),_e=ne.equal(0).and(Ee.equal(0)).and(Ie.equal(0));return Mt(_e.select(J(.199,.299,.399),Ut(J(ne,Ee,Ie))))},Oe=(q,fe,Be)=>{let F=((Ie,_e,ye)=>{let Ge=(at,bt,Bt,Jt)=>Zi(Ie.add(at),_e.add(bt),ye.add(Bt)).lessThan(0).toFloat().mul(Jt);return Ge(0,0,0,1).add(Ge(1,0,0,2)).add(Ge(0,1,0,8)).add(Ge(1,1,0,4)).add(Ge(0,0,1,16)).add(Ge(1,0,1,32)).add(Ge(0,1,1,128)).add(Ge(1,1,1,64))})(q,fe,Be).toVar(),ne=Ae(se.element(De(F))).toVar();Ve(ne.lessThan(.5),()=>{bn()});let Ee=yh(E(),Cr(ne)).toVar();Ve(B(Ee).add(ne).mul(3).lessThanEqual(n),()=>{let Ie=Ae(F).add(.5).mul(.00390625);Zr(5,({i:_e})=>{Ve(B(_e).greaterThanEqual(ne),()=>{Ya()});let ye=B(_e).toVar();Zr(3,({i:Ge})=>{let at=B(Ge).toVar();((bt,Bt,Jt,li,Ht,ki)=>{let ur=Ht.mul(.0625).add(.03125),Ci=Ae(wo(e.triTable.sample(Me(ur,li))).x).mul(2).toInt().toVar(),Si=J(bt,Bt,Jt).add(Mt(H.element(Ci))).toVar(),Vt=J(bt,Bt,Jt).add(Mt(H.element(Ci.add(1)))).toVar(),rr=Zi(Ae(Si.x),Ae(Si.y),Ae(Si.z)).toVar(),br=Zi(Ae(Vt.x),Ae(Vt.y),Ae(Vt.z)).toVar(),Dt=rr.div(rr.sub(br)).toVar(),qt=Si.add(Vt.sub(Si).mul(Dt)).toVar(),en=Mt(qt.div(i).mul(2).sub(1)).toVar(),zs=en.mul(o).add(J(l)),tn=Ut(ut(qr(Mt(Si)),qr(Mt(Vt)),Dt)),Kn=en.add(1).mul(.5),xr=wo(Ef(S,Kn,De(0))),In=ki.toVar();e.buffers.positions.element(In).assign(Pe(zs,1)),e.buffers.normals.element(In).assign(Pe(tn,0)),e.buffers.colors.element(In).assign(xr)})(q,fe,Be,Ie,ye.mul(3).add(at),De(Ee).add(De(ye)).mul(3).add(De(at)))})})})},eh=f?Xe(()=>{let{slot:q,local:fe}=xi();Ve(q.greaterThanEqual(m),()=>{bn()});let Be=mi(q).toVar();Ve(Ce(Mt(Be)).notEqual(q),()=>{bn()});let F=Ae(Be.x).mul(4).add(Ae(fe.x)).toVar(),ne=Ae(Be.y).mul(4).add(Ae(fe.y)).toVar(),Ee=Ae(Be.z).mul(4).add(Ae(fe.z)).toVar();Ve(F.greaterThanEqual(i).or(ne.greaterThanEqual(i)).or(Ee.greaterThanEqual(i)),()=>{bn()}),Oe(F,ne,Ee)})():Xe(()=>{let q=Ae(J(cl).x).toVar(),fe=Ae(J(cl).y).toVar(),Be=Ae(J(cl).z).toVar();Ve(q.greaterThanEqual(i).or(fe.greaterThanEqual(i)).or(Be.greaterThanEqual(i)),()=>{bn()}),Ve(ui(ee(Mt(J(q,fe,Be).mul(.25).floor()))).greaterThan(u),()=>{bn()}),Oe(q,fe,Be)})(),Rd=()=>{let q=J(oO).toVar(),fe=Ae(q.y).mul(Ei).add(Ae(q.x)).toVar(),Be=J(0).toVar(),F=B(0).toVar();return Ve(fe.lessThan(m),()=>{Be.assign(mi(fe)),Ve(Ce(Mt(Be)).equal(fe),()=>{F.assign(B(1))})}),{brick:Mt(Be),valid:Ae(F)}},wi=()=>{let q=J(oO).add(h).toVar(),fe=B(0).toVar();return Ve(Ae(q.x).lessThanEqual(a).and(Ae(q.y).lessThanEqual(a)).and(Ae(q.z).lessThanEqual(a)),()=>{Ve(Ce(Mt(q)).greaterThan(-.5),()=>{fe.assign(B(1))})}),{brick:Mt(q),valid:Ae(fe)}},Ml=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],Kc=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Dd=q=>Xe(()=>{let fe=hg("float",64),Be=hg("float",1),F=J(nO).toVar(),ne=De(Ae(F.x).add(Ae(F.y).mul(4)).add(Ae(F.z).mul(16))).toVar(),{brick:Ee,valid:Ie}=q(),_e=Ae(Y(Mt(Ee))).toVar(),ye=B(1).add(_e).toVar(),Ge=_e.greaterThan(.5),at=Ge.and(Ae(F.x).lessThan(2).and(Ae(F.y).lessThan(2)).and(Ae(F.z).lessThan(2))).or(Ge.not()),bt=Ae(Ee.x).mul(4).add(Ae(F.x).mul(ye)).toVar(),Bt=Ae(Ee.y).mul(4).add(Ae(F.y).mul(ye)).toVar(),Jt=Ae(Ee.z).mul(4).add(Ae(F.z).mul(ye)).toVar(),li=Ml.map(([Vt,rr,br])=>Zi(bt.add(ye.mul(Vt)),Bt.add(ye.mul(rr)),Jt.add(ye.mul(br))).toVar()),Ht=li[0].lessThan(0).toFloat();for(let Vt=1;Vt<8;Vt++)Ht=Ht.add(li[Vt].lessThan(0).toFloat());let ki=Ht.toVar(),ur=B(0).toVar();Ve(Ie.greaterThan(.5).and(at).and(bt.add(ye).lessThanEqual(i)).and(Bt.add(ye).lessThanEqual(i)).and(Jt.add(ye).lessThanEqual(i)).and(ki.greaterThan(.5)).and(ki.lessThan(7.5)),()=>{ur.assign(B(1))}),fe.element(ne).assign(ur.add(p)),Vb(),Ve(ne.equal(De(0)).and(Ie.greaterThan(.5)),()=>{let Vt=B(0).toVar();Zr(64,({i:br})=>{Vt.addAssign(Ae(fe.element(br)))});let rr=B(-1).toVar();Ve(Vt.greaterThan(.5),()=>{let br=iO(P(7),De(1)).toVar();Ve(br.greaterThanEqual(1),()=>{rr.assign(Ae(W(br.sub(1))))}).Else(()=>{yh(P(7),De(1));let Dt=yh(P(6),De(1)).toVar();Ve(Dt.lessThan(De(b)),()=>{rr.assign(Dt.toFloat())}).Else(()=>{kl(P(8),De(1))})}),Ve(rr.greaterThan(-.5),()=>{G(Mt(Ee)).assign(Ae(rr.add(p)))})}),Be.element(De(0)).assign(rr)}),Vb();let Ci=Ae(Be.element(De(0))).toVar(),Si=ur.greaterThan(.5).or(Ge.and(at).and(Ie.greaterThan(.5)).and(bt.add(ye).lessThanEqual(i)).and(Bt.add(ye).lessThanEqual(i)).and(Jt.add(ye).lessThanEqual(i)));Ve(Si.and(Ci.greaterThan(-.5)),()=>{let Vt=J(0).toVar(),rr=B(0).toVar();for(let[pa,Uh]of Kc)Ve(li[pa].lessThan(0).toFloat().notEqual(li[Uh].lessThan(0).toFloat()),()=>{let o0=li[pa].div(li[pa].sub(li[Uh])),[Jf,_1,Ni]=Ml[pa],[Su,Fw,Ld]=Ml[Uh];Vt.addAssign(J(Jf,_1,Ni).add(J(Su-Jf,Fw-_1,Ld-Ni).mul(o0)).mul(ye)),rr.addAssign(1)});let br=Mt(Vt.div(mt(rr,1))).toVar();Ve(rr.lessThan(.5),()=>{br.assign(J(ye.mul(.5)))});let Dt=J(bt,Bt,Jt).add(br).toVar(),qt=Mt(Dt.div(i).mul(2).sub(1)).toVar(),en=qt.mul(o).add(J(l)),zs=J(0).toVar(),tn=Mt(br.div(ye)).toVar();for(let pa=0;pa<8;pa++){let[Uh,o0,Jf]=Ml[pa],_1=Uh?Ae(tn.x):B(1).sub(Ae(tn.x)),Ni=o0?Ae(tn.y):B(1).sub(Ae(tn.y)),Su=Jf?Ae(tn.z):B(1).sub(Ae(tn.z));zs.addAssign(qr(Mt(J(bt.add(ye.mul(Uh)),Bt.add(ye.mul(o0)),Jt.add(ye.mul(Jf))))).mul(_1.mul(Ni).mul(Su)))}let Kn=Ut(zs),xr=qt.add(1).mul(.5),In=wo(Ef(S,xr,De(0))),xn=De(Ge.select(Ae(F.x).add(Ae(F.y).mul(2)).add(Ae(F.z).mul(4)),B(ne))).toVar(),Qs=De(Ci.mul(64)).add(xn).toVar();e.buffers.positions.element(Qs).assign(Pe(en,1)),e.buffers.normals.element(Qs).assign(Pe(Kn,0)),e.buffers.colors.element(Qs).assign(In)})})(),Nd=v?Dd(Rd):null,El=v?Dd(wi):null,ji=q=>Xe(()=>{let fe=hg("float",64),Be=hg("float",64),F=hg("float",48),ne=J(nO).toVar(),Ee=De(Ae(ne.x).add(Ae(ne.y).mul(4)).add(Ae(ne.z).mul(16))).toVar(),{brick:Ie,valid:_e}=q(),ye=Ae(Ie.x).mul(4).add(Ae(ne.x)).toVar(),Ge=Ae(Ie.y).mul(4).add(Ae(ne.y)).toVar(),at=Ae(Ie.z).mul(4).add(Ae(ne.z)).toVar(),bt=Zi(ye,Ge,at).lessThan(0).toFloat().toVar(),Bt=(Dt,qt,en)=>Ae($(De(Ct(Dt.mul(.25))).add(De(Ct(qt.mul(.25))).mul(s)).add(De(Ct(en.mul(.25))).mul(s*s)))),Jt=Dt=>Dt.mul(.5).fract().lessThan(.25),li=(Dt,qt)=>Dt.greaterThanEqual(qt).and(Dt.add(qt).lessThanEqual(i)),Ht=B(0).toVar(),ki=B(0).toVar(),ur=B(0).toVar(),Ci=B(1).toVar(),Si=B(1).toVar(),Vt=B(1).toVar(),rr=(Dt,qt,en,zs,tn,Kn,xr,In,xn)=>{let Qs=Bt(...xn[0]).add(Bt(...xn[1])).add(Bt(...xn[2])).add(Bt(...xn[3])).greaterThan(3.5).toVar(),pa=Zi(ye.add(en),Ge.add(zs),at.add(tn)).lessThan(0).toFloat(),Uh=Zi(ye.add(2*en),Ge.add(2*zs),at.add(2*tn)).lessThan(0).toFloat();Ve(_e.greaterThan(.5).and(Qs.not()).and(In.add(1).lessThanEqual(i)).and(li(Kn,B(1))).and(li(xr,B(1))).and(bt.notEqual(pa)),()=>{Dt.assign(B(1)),qt.assign(B(1))}),Ve(_e.greaterThan(.5).and(Qs).and(Jt(ye)).and(Jt(Ge)).and(Jt(at)).and(In.add(2).lessThanEqual(i)).and(li(Kn,B(2))).and(li(xr,B(2))).and(bt.notEqual(Uh)),()=>{Dt.assign(B(1)),qt.assign(B(2))})};rr(Ht,Ci,1,0,0,Ge,at,ye,[[ye,Ge.sub(1),at.sub(1)],[ye,Ge,at.sub(1)],[ye,Ge,at],[ye,Ge.sub(1),at]]),rr(ki,Si,0,1,0,at,ye,Ge,[[ye.sub(1),Ge,at.sub(1)],[ye.sub(1),Ge,at],[ye,Ge,at],[ye,Ge,at.sub(1)]]),rr(ur,Vt,0,0,1,ye,Ge,at,[[ye.sub(1),Ge.sub(1),at],[ye,Ge.sub(1),at],[ye,Ge,at],[ye.sub(1),Ge,at]]);let br=Ht.add(ki).add(ur).mul(2).toVar();fe.element(Ee).assign(br.add(p)),Vb(),Ve(Ee.equal(De(0)).and(_e.greaterThan(.5)),()=>{let Dt=B(0).toVar();Zr(64,({i:tn})=>{Be.element(tn).assign(Dt),Dt.addAssign(Ae(fe.element(tn)))}),yh(E(0),Cr(Dt));let qt=Ct(Dt.add(7).mul(1/8)).toVar(),en=B(-1).toVar(),zs=B(-1).toVar();Zr(48,({i:tn})=>{Ve(B(tn).greaterThanEqual(qt),()=>{Ya()});let Kn=B(tn).toVar(),xr=B(-1).toVar(),In=iO(P(4),De(1)).toVar();Ve(In.greaterThanEqual(1),()=>{xr.assign(Ae(re(In.sub(1))))}).Else(()=>{yh(P(4),De(1));let xn=yh(P(3),De(1)).toVar();Ve(xn.lessThan(De(_)),()=>{xr.assign(xn.toFloat())}).Else(()=>{kl(P(5),De(1))})}),F.element(De(Kn)).assign(xr),Ve(xr.greaterThan(-.5),()=>{we(xr).assign(Fi(Dt.sub(Kn.mul(8)),8)),xe(xr).assign(B(-1)),Ve(zs.greaterThan(-.5),()=>{xe(zs).assign(xr)}).Else(()=>{en.assign(xr)}),zs.assign(xr)})}),V(Mt(Ie)).assign(en)}),Vb(),Ve(br.greaterThan(.5),()=>{let Dt=(tn,Kn,xr)=>{let In=Ct(tn.mul(.25)),xn=Ct(Kn.mul(.25)),Qs=Ct(xr.mul(.25)),pa=De(In).add(De(xn).mul(s)).add(De(Qs).mul(s*s)),Uh=De(tn.sub(In.mul(4))).add(De(Kn.sub(xn.mul(4))).mul(4)).add(De(xr.sub(Qs.mul(4))).mul(16));return Cr(pa.mul(64).add(Uh))},qt=Ae(Be.element(Ee)).toVar(),en=(tn,Kn,xr)=>{let In=Ae(F.element(De(Ct(qt.mul(.125))))).toVar();Ve(In.greaterThan(-.5),()=>{let xn=qt.sub(Ct(qt.mul(.125)).mul(8)),Qs=De(In.mul(24).add(xn.mul(3))).toVar();K(Qs).assign(tn),K(Qs.add(De(1))).assign(Kn),K(Qs.add(De(2))).assign(xr)}),qt.addAssign(1)},zs=(tn,Kn)=>{Ve(tn.greaterThan(.5),()=>{let xr=Dt(...Kn[0]).toVar(),In=Dt(...Kn[1]).toVar(),xn=Dt(...Kn[2]).toVar(),Qs=Dt(...Kn[3]).toVar();Ve(bt.greaterThan(.5),()=>{en(xr,In,xn),en(xr,xn,Qs)}).Else(()=>{en(xr,Qs,xn),en(xr,xn,In)})})};zs(Ht,[[ye,Ge.sub(Ci),at.sub(Ci)],[ye,Ge,at.sub(Ci)],[ye,Ge,at],[ye,Ge.sub(Ci),at]]),zs(ki,[[ye.sub(Si),Ge,at.sub(Si)],[ye.sub(Si),Ge,at],[ye,Ge,at],[ye,Ge,at.sub(Si)]]),zs(ur,[[ye.sub(Vt),Ge.sub(Vt),at],[ye,Ge.sub(Vt),at],[ye,Ge,at],[ye.sub(Vt),Ge,at]])})})(),Id=v?ji(Rd):null,Od=v?ji(wi):null,Al=v?Xe(()=>{let q=hg("float",48),fe=hg("float",2),Be=J(nO).toVar(),F=De(Ae(Be.x).add(Ae(Be.y).mul(4)).add(Ae(Be.z).mul(16))).toVar(),ne=J(oO).toVar(),Ee=Ae(ne.y).mul(Ei).add(Ae(ne.x)).toVar();Ve(F.equal(De(0)),()=>{let Ge=B(0).toVar();Ve(Ee.lessThan(m),()=>{let bt=mi(Ee).toVar();Ve(Ce(Mt(bt)).equal(Ee),()=>{let Bt=B(0).toVar();Ve(Ae(ie).greaterThan(.5),()=>{let Jt=J(0).toVar(),li=J(0).toVar();for(let Ht=0;Ht<8;Ht++){let ki=Mt(bt.mul(4).add(J(4*(1&Ht),4*(Ht>>1&1),4*(Ht>>2&1)))),ur=Mt(ki.div(i).mul(2).sub(1)).mul(o).add(J(l)),Ci=j.mul(Pe(ur,1)).toVar(),Si=Ae(Ci.w);Jt.addAssign(J(Ae(Ci.x).lessThan(Si.negate()).toFloat(),Ae(Ci.y).lessThan(Si.negate()).toFloat(),Ae(Ci.z).lessThan(0).toFloat())),li.addAssign(J(Ae(Ci.x).greaterThan(Si).toFloat(),Ae(Ci.y).greaterThan(Si).toFloat(),Ae(Ci.z).greaterThan(Si).toFloat()))}Ve(mt(mt(Ae(Jt.x),mt(Ae(Jt.y),Ae(Jt.z))),mt(Ae(li.x),mt(Ae(li.y),Ae(li.z)))).greaterThan(7.5),()=>{Bt.assign(B(1))})}),Ve(Bt.lessThan(.5),()=>{let Jt=Ae(V(Mt(bt))).toVar();Zr(48,({i:li})=>{Ve(Jt.lessThan(-.5),()=>{Ya()}),q.element(li).assign(Jt),Ge.addAssign(Ae(we(Jt))),Jt.assign(Ae(xe(Jt)))})})})});let at=B(0).toVar();Ve(Ge.greaterThan(.5),()=>{let bt=yh(E(3),Cr(Ge.mul(3))).toVar();at.assign(B(bt))}),fe.element(De(0)).assign(at.add(p)),fe.element(De(1)).assign(Ge)}),Vb();let Ie=Ae(fe.element(De(1))).toVar(),_e=Ae(fe.element(De(0))).toVar(),ye=B(F).toVar();Zr(6,()=>{Ve(ye.greaterThanEqual(Ie),()=>{Ya()});let Ge=Ae(q.element(De(Ct(ye.mul(1/8))))).toVar(),at=ye.sub(Ct(ye.mul(1/8)).mul(8)),bt=De(Ge.mul(24).add(at.mul(3))).toVar(),Bt=De(_e.add(ye.mul(3))).toVar(),Jt=ur=>{let Ci=K(ur===0?bt:bt.add(De(ur))).toVar(),Si=De(Ci.shiftRight(Cr(6))).toVar(),Vt=De(Ci.bitAnd(Cr(63))).toVar(),rr=Ae((tn=>O.element(tn.add(De(2*D))))(Si)).toVar(),br=Ae($(Si)),Dt=Vt.bitAnd(De(3)),qt=Vt.shiftRight(De(2)).bitAnd(De(3)),en=Vt.shiftRight(De(4)).bitAnd(De(3)),zs=Dt.shiftRight(De(1)).add(qt.shiftRight(De(1)).mul(De(2))).add(en.shiftRight(De(1)).mul(De(4)));return{blockF:rr,li:De(br.greaterThan(.5).select(zs,Vt)).toVar()}},li=Jt(0),Ht=Jt(1),ki=Jt(2);Ve(li.blockF.greaterThan(-.5).and(Ht.blockF.greaterThan(-.5)).and(ki.blockF.greaterThan(-.5)),()=>{let ur=Ci=>Cr(De(Ci.blockF.mul(64)).add(Ci.li));y.element(Bt).assign(ur(li)),y.element(Bt.add(De(1))).assign(ur(Ht)),y.element(Bt.add(De(2))).assign(ur(ki))}).Else(()=>{y.element(Bt).assign(Cr(0)),y.element(Bt.add(De(1))).assign(Cr(0)),y.element(Bt.add(De(2))).assign(Cr(0))}),ye.addAssign(64)})})():null,As=Math.ceil(t/rE[0]),wu=Math.ceil(r/rE[0]),yn=Math.ceil(s/rE[0]),he=(q,fe)=>q.compute(fe,Array.isArray(fe)?rE:void 0),je=[Ei,Math.max(1,Math.ceil(m/Ei)),1];return{resolution:t,sparse:f!==null,poolBricks:m,meshlet:v!==null,vertexBlocks:b,needsInit:f!==null,sdfTexture:w,colorTexture:S,coarseTexture:T,counterAttribute:M.value,storageAttributes:[M,A,N,O,Q,ue,Se,k].filter(q=>q!==null).map(q=>q.value),uniforms:{bboxHalf:o,bboxOffset:l,activeThreshold:u,windowOrigin:h,...v?{windowSize:d,cullEnabled:ie,cullMVP:j,adaptCos:ae}:{}},kernels:{zero:he(Ze,1),clear:ze.compute([Math.ceil(n/256),1,1],[256,1,1]),coarse:he(pt,[yn,yn,yn]),...Yt?{init:he(Yt,[yn,yn,yn])}:{},...ni?{release:he(ni,[yn,yn,yn])}:{},...ar?{alloc:he(ar,[yn,yn,yn])}:{},...St?{stats:he(St,1)}:{},sdf:he(Or,f?je:[As,As,As]),...Ai?{sdfWindow:he(Ai,[As,As,As])}:{},color:he(Hr,[wu,wu,wu]),extract:v?he(Id,je):he(eh,f?je:[As,As,As]),...v?{clearDraw:qe.compute([Math.ceil(n/256),1,1],[256,1,1]),meshRelease:he(Nt,[yn,yn,yn]),verts:he(Nd,je),vertsWindow:he(El,[s,s,s]),extractWindow:he(Od,[s,s,s]),classify:he(Qt,[yn,yn,yn]),gather:he(Al,je)}:{}}}}var Ae,_O,Mt,wo,Hb,m4,rE,hg,FFe=U(()=>{oe(),vn(),bi(),jY(),TK(),Ae=e=>e,_O=e=>e,Mt=e=>e,wo=e=>e,Hb=24,m4=GY,rE=[4,4,4],hg=(e,t)=>mTe(e,t)});function UFe(e){let t=e.getAttribute("position");if(!t||t.count<3)return null;let i=e.getIndex(),r=Math.floor((i?i.count:t.count)/3);if(r===0)return null;let n=Math.max(1,Math.ceil(r/g4));n>1&&console.warn(`Spline shape blend: mesh child has ${r} triangles \u2014 baking every ${n}th (SDF detail reduced).`);let s=Math.floor(r/n),a=new Float32Array(12*s),o=new R(0,0,0),l=new R,u=0;for(let d=0;d<s;d++){let c=d*n*3;for(let p=0;p<3;p++){let f=i?i.getX(c+p):c+p;l.fromBufferAttribute(t,f),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+bO),o.y=Math.max(o.y,.05*h)*(1+bO),o.z=Math.max(o.z,.05*h)*(1+bO),{data:a,triCount:s,boxHalf:o}}function zFe(e){let t=Ef(e),i=LB;return(r,n,s)=>{let a=mt(J(Xs(n.z),Xs(n.w),Xs(s.w)),J(1e-5)).toVar(),o=Xs(n.y),l=J(o.mod(Cf).mul(i),Ct(o.div(Cf)).mul(i),0).toVar(),u=Xt(GE(r.div(a).mul(.5).add(.5)),J(0),J(1)).mul(i-1).toVar(),h=Fi(Ct(u),J(i-2)).toVar(),d=u.sub(h).toVar(),c=l.add(h).toVar(),p=(M,E,A)=>Xs(lMe(t.load(Ha(c.add(J(M,E,A))))).x),f=Xs(d.x),m=Xs(d.y),g=Xs(d.z),v=ut(p(0,0,0),p(1,0,0),f),y=ut(p(0,1,0),p(1,1,0),f),_=ut(p(0,0,1),p(1,0,1),f),b=ut(p(0,1,1),p(1,1,1),f),x=ut(ut(v,y,m),ut(_,b,m),g),w=mt(Xs(a.x),mt(Xs(a.y),Xs(a.z))),S=ui(r).sub(a),T=Yi(mt(S,J(0)));return Xs(x.mul(w).add(T))}}function kFe(e){let t=LB;return new R(e%Cf*t,Math.floor(e/Cf)*t,0)}var Xs,GE,lMe,LB,Cf,bO,g4,VFe=U(()=>{oe(),oe(),vn(),bi(),Xs=e=>e,GE=e=>e,lMe=e=>e,LB=48,Cf=4,bO=.08,g4=24576});function GFe(){if(xO!==null)return xO;let e=Xe(()=>{let i=Me(Ii(p$),Ii(f$)),r=Me(1).div(i),n=tr().mul(Ii(m$)).sub(Me(.5)).mul(2).add(Me(.5)).toVar();n.x.addAssign(Ii(nE));let s=n.div(i).toVar(),a=Ii(ox.sample(s).x).toVar();s.x.addAssign(Ii(r.x));let o=Ii(ox.sample(s).x).toVar();s.y.addAssign(Ii(r.y));let l=Ii(ox.sample(s).x).toVar();s.x.subAssign(Ii(r.x));let u=Ii(ox.sample(s).x).toVar(),h=a,d=h.add(o),c=d.add(l),p=c.add(u);return Pe(p,c,d,h)})(),t=new ei;return t.name="SplineShapeBlend.pyramid",t.fragmentNode=e,t.depthTest=!1,t.depthWrite=!1,t.blending=Di,t.needsUpdate=!0,xO=t,t}function z2(e,t,i=1){return new Ui(e,t,{count:i,format:mn,type:Wt,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:yt,magFilter:yt,wrapS:vr,wrapT:vr})}function jFe(){let e=Fx.length;if(e>0){for(let t of Fx)t.dispose();Fx.length=0}return e}var Ii,sge,Op,ox,p$,f$,nE,W_,m$,xO,O9,L9,qm,aN,B9,F9,U9,z9,k9,V9,G9,oN,sn,k2,age,g$,qb,sE,Fx,WFe=U(()=>{oe(),vn(),bi(),jY(),Vxe(),TK(),FFe(),VFe(),ua(),Ii=e=>e,sge=e=>e,Op=new Cn,ox=vt(new Ri),p$=Fe(1),f$=Fe(1),nE=Fe(0),W_=Fe(0),m$=Fe(1),xO=null,O9=!1,L9=!1,qm="",aN=!1,B9=!1,F9=!1,U9=!1,z9=!1,k9=!1,V9=!1,G9=!1,oN=!1;try{let e=new URLSearchParams(window.location.search);O9=e.get("dbgsbmarch")==="vertex",L9=e.get("dbgsbultra")==="0",qm=e.get("dbgsbchain")??"",aN=e.get("dbgsbnoclear")==="1",B9=e.get("dbgsbsparse")==="0",F9=e.get("dbgsbincr")==="0",U9=e.get("dbgsblod")==="1",z9=e.get("dbgsbpool")==="1",k9=e.get("dbgsbpool")==="0",V9=e.get("dbgsbmesh")==="0",G9=e.get("dbgsbadapt")==="0",oN=e.get("dbgsbcull")==="1"}catch{}sn={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},k2=24576,age=Math.cos(8*Math.PI/180),g$=class{constructor(e=0,t=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 Ue,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=vt(new Ri),this.spatialTexNode=vt(new Ri),this.potentialTexNode=vt(new Ri),this.voxelTexNode=vt(new Ri),this.pyramid1TexNode=vt(new Ri),this.pyramid2TexNode=vt(new Ri),this.npartUniform=Fe(0),this.spatialnUniform=Fe(1),this.spanUniform=Fe(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=e,this.poolHint=t,this.vertHint=i;let r=UI(),n=new Nr(r.triTable,16,256,aa,Wt);n.needsUpdate=!0;let s=new Nr(r.numTrisTable,256,1,aa,Wt);s.needsUpdate=!0,this.triTableTexNode=vt(n),this.numTrisTableTexNode=vt(s)}shapeRow(e,t){return this.shapesTex.sample(Me(e,(t+.5)/5))}_quadMaterial(e,t){let i=new ei;return i.name=e,i.fragmentNode=t,i.depthTest=!1,i.depthWrite=!1,i.blending=Di,i.needsUpdate=!0,i}_buildSpatialMaterial(e){let t=e.spatialDivisions,i=GY,r=this.npartUniform,n=this.spatialnUniform,s=this.spanUniform,a=e.spatialn,o=Xe(()=>{let l=Me(t*a,t**2),u=Ct(tr().mul(l)).toVar(),h=Ii(u.y).toVar(),d=h.sub(Ct(h.div(t)).mul(t)).toVar();h.assign(Ct(h.div(t)));let c=h,p=Ii(u.x).toVar(),f=p.sub(Ct(p.div(n)).mul(Ii(n))).toVar().mul(96).toVar();p.assign(Ct(p.div(n)));let m=J(p,d,c),g=m.div(t).mul(2).sub(1).sub(Ii(s)).toVar(),v=m.add(1).div(t).mul(2).sub(1).add(Ii(s)).toVar(),y=_=>{let b=B(0).toVar();for(let x=23;x>=0;x--){let w=_.add(x),S=w.add(.5).div(i),T=this.shapeRow(S,0),M=sge(T.xyz),E=Ii(T.w);b.mulAssign(2);let A=Ii(g.x).lessThan(Ii(M.x)).and(Ii(M.x).lessThan(Ii(v.x))).and(Ii(g.y).lessThan(Ii(M.y))).and(Ii(M.y).lessThan(Ii(v.y))).and(Ii(g.z).lessThan(Ii(M.z))).and(Ii(M.z).lessThan(Ii(v.z))).and(w.lessThan(Ii(r))).or(E.equal(-2));b.addAssign(A.select(B(1),B(0)))}return b};return Pe(y(f),y(f.add(24)),y(f.add(48)),y(f.add(72)))})();return this._quadMaterial("SplineShapeBlend.spatial",o)}_fieldEnv(e,t){return{shapeRow:(i,r)=>this.shapeRow(i,r),spatialTex:this.spatialTexNode,spatialDivisions:e.spatialDivisions,spatialn:e.spatialn,colorKBump:t,meshSdf:this._meshBaker?zFe(this._meshBaker.atlas):void 0}}_buildPotentialMaterial(e){let t=e.spatialDivisions,i=e.resolution,r=i-1,n=1/i,s=e.zLayersPerRow,a=e.basePyramidSize,o=c$(this._fieldEnv(e,2*n)),l=Xe(()=>{let u=Ct(tr().mul(Me(a,a))).toVar(),h=Ii(u.x).mod(i),d=Ii(u.y).mod(i),c=Ct(Ii(u.x).mul(n)).add(Ct(Ii(u.y).mul(n)).mul(s)),p=J(h,d,c),f=p.div(r).mul(2).sub(1).toVar(),m=Ct(p.div(r).mul(t-1)).toVar(),{sdf:g,color:v}=o(f,m),y=Cr(Ii(v.x).mul(255)),_=Cr(Ii(v.y).mul(255)),b=y.shiftLeft(Cr(8)).bitOr(_);return Pe(g,b.toFloat().mul(1525902e-11),Ii(v.z),Ii(v.w))})();return this._quadMaterial("SplineShapeBlend.potential",l)}_buildVoxelMaterial(e){let t=e.resolution,i=t-1,r=1/t,n=e.zLayersPerRow,s=e.basePyramidSize,a=rMe(t,n),o=this.potentialTexNode,l=()=>{let c=Ct(tr().mul(Me(s,s))).toVar();return{xi:Ii(c.x).mod(t).toVar(),yi:Ii(c.y).mod(t).toVar(),zi:Ct(Ii(c.x).mul(r)).add(Ct(Ii(c.y).mul(r)).mul(n)).toVar()}},u=(c,p,f)=>{let m=(g,v,y,_)=>Ii(a(c.add(g),p.add(v),f.add(y),o).x).lessThan(0).toFloat().mul(_);return m(0,0,0,1).add(m(1,0,0,2)).add(m(0,1,0,8)).add(m(1,1,0,4)).add(m(0,0,1,16)).add(m(1,0,1,32)).add(m(0,1,1,128)).add(m(1,1,1,64))},h=Xe(()=>{let{xi:c,yi:p,zi:f}=l(),m=((y,_,b)=>{let x=Ii(a(y.add(1),_,b,o).x).sub(Ii(a(y.sub(1),_,b,o).x)),w=Ii(a(y,_.add(1),b,o).x).sub(Ii(a(y,_.sub(1),b,o).x)),S=Ii(a(y,_,b.add(1),o).x).sub(Ii(a(y,_,b.sub(1),o).x));return x.equal(0).and(w.equal(0)).and(S.equal(0)).select(J(.199,.299,.399),Ut(J(x,w,S)))})(c,p,f).toVar(),g=Pe(m,0).toVar(),v=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(f.greaterThanEqual(i));return Ve(v.not(),()=>{g.assign(Pe(m,u(c,p,f)))}),g})(),d=Xe(()=>{let{xi:c,yi:p,zi:f}=l(),m=Pe(0).toVar(),g=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(f.greaterThanEqual(i));return Ve(g.not(),()=>{let v=u(c,p,f);m.assign(this.numTrisTableTexNode.sample(Me(v.add(.5).div(256),.5)))}),m})();return this._quadMaterial("SplineShapeBlend.voxel",aw({output:h,numTris:d}))}_spatialTargetFor(e){let t=e.resolutionLevel,i=this.spatialTargets[t];return i||(i=z2(e.spatialDivisions*e.spatialn,e.spatialDivisions**2),this.spatialTargets[t]=i),i}_targetsFor(e){let t=e.resolutionLevel,i=this._spatialTargetFor(e),r=this.potentialTargets[t];r||(r=z2(e.basePyramidSize,e.basePyramidSize),this.potentialTargets[t]=r);let n=this.voxelTargets[t];n||(n=z2(e.basePyramidSize,e.basePyramidSize,2),n.textures[0].name="output",n.textures[1].name="numTris",n.textures[1].format=aa,this.voxelTargets[t]=n);let s=this.pyramidTargets[t];return s||(s=[z2(e.pyramidTexture1Width,e.pyramidTexture1Height),z2(e.pyramidTexture2Width,e.pyramidTexture2Height)],this.pyramidTargets[t]=s),{spatial:i,potential:r,voxel:n,pyramid:s}}_marchResources(e){let t=this._targetsFor(e),i=e.pyramidLevelSizes.length%2==0?0:1,r=1-i;return{resolutionLevel:e.resolutionLevel,pyramidLevelSizes:e.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:t.pyramid[r].width,height:t.pyramid[r].height},pyramid2Size:{width:t.pyramid[i].width,height:t.pyramid[i].height}}}_maxMarchSlots(e){let t=e.backend?.device?.limits,i=Math.min(t?.maxStorageBufferBindingSize??134217728,t?.maxBufferSize??268435456);return 192*Math.floor(i/16/192)}_ensureMarchCapacity(e,t){if(this._marchBuffers!==null&&e<=this._marchCapacity)return!1;let i=Math.min(Math.max(t,k2),192*Math.ceil(1.5*e/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 n=r.value;n&&this._retiredStorage.push(n)}return this._marchBuffers={positions:$n(i,"vec4"),normals:$n(i,"vec4"),colors:$n(i,"vec4")},this._marchCapacity=i,this._computeNode=null,!0}update(e,t,i){if(sn.updates++,this._lastRenderer=t,i!==void 0&&(this._cullCamera=i),e._meshSdfBaked.size>0)for(let[T,M]of e._meshSdfBaked)M.owner!==this&&e._meshSdfBaked.delete(T);let r=(s=e,ewe.call(s)),n=t.backend?.isWebGPUBackend===!0;var s;if(n&&e._meshSdfWanted.size>0&&this._meshBaker===null&&(this._meshBaker=function(T,M){let E=LB,A=new by(Cf*E,Math.ceil(T/Cf)*E,E);A.format=aa,A.type=Wt,A.minFilter=yt,A.magFilter=yt,A.name="SplineShapeBlend.meshSdfAtlas";let P=B(M).mul(0),N=Fe(new R(0,0,0)),D=Fe(0),O=Fe(new R(1,1,1)),z=$n(3*g4,"vec4"),L=$=>z.element($),V=Xe(()=>{let $=J(cl).toVar();Ve(Xs($.x).greaterThanEqual(E).or(Xs($.y).greaterThanEqual(E)).or(Xs($.z).greaterThanEqual(E)),()=>{bn()});let Q=$.div(E-1).mul(2).sub(1).mul(O).toVar(),ue=B(1e30).toVar(),pe=B(1e15).toVar();Zr(g4,({i:we})=>{Ve(B(we).greaterThanEqual(Xs(D)),()=>{Ya()});let re=De(B(we).toVar()).mul(3).toVar(),Se=GE(L(re).xyz).toVar(),W=GE(L(re.add(De(1))).xyz).toVar(),k=GE(L(re.add(De(2))).xyz).toVar(),K=W.sub(Se).toVar(),ie=k.sub(Se).toVar(),j=Q.sub(Se).toVar(),ae=et(K,j).toVar(),se=et(ie,j).toVar(),H=Q.sub(W).toVar(),me=et(K,H).toVar(),be=et(ie,H).toVar(),ke=Q.sub(k).toVar(),Te=et(K,ke).toVar(),Ze=et(ie,ke).toVar(),ze=J(0).toVar(),qe=me.mul(Ze).sub(Te.mul(be)).toVar(),Ne=Te.mul(se).sub(ae.mul(Ze)).toVar(),ee=ae.mul(be).sub(me.mul(se)).toVar();Ve(ae.lessThanEqual(0).and(se.lessThanEqual(0)),()=>{ze.assign(Se)}).ElseIf(me.greaterThanEqual(0).and(be.lessThanEqual(me)),()=>{ze.assign(W)}).ElseIf(Ze.greaterThanEqual(0).and(Te.lessThanEqual(Ze)),()=>{ze.assign(k)}).ElseIf(ee.lessThanEqual(0).and(ae.greaterThanEqual(0)).and(me.lessThanEqual(0)),()=>{let pt=ae.div(ae.sub(me));ze.assign(Se.add(K.mul(pt)))}).ElseIf(Ne.lessThanEqual(0).and(se.greaterThanEqual(0)).and(Ze.lessThanEqual(0)),()=>{let pt=se.div(se.sub(Ze));ze.assign(Se.add(ie.mul(pt)))}).ElseIf(qe.lessThanEqual(0).and(be.sub(me).greaterThanEqual(0)).and(Te.sub(Ze).greaterThanEqual(0)),()=>{let pt=be.sub(me).div(be.sub(me).add(Te.sub(Ze)));ze.assign(W.add(k.sub(W).mul(pt)))}).Else(()=>{let pt=B(1).div(qe.add(Ne).add(ee)),tt=Ne.mul(pt),Yt=ee.mul(pt);ze.assign(Se.add(K.mul(tt)).add(ie.mul(Yt)))});let Ce=Q.sub(ze).toVar(),He=et(Ce,Ce).toVar();Ve(He.lessThan(ue),()=>{ue.assign(He);let pt=qn(K,ie),tt=et(Ce,pt).greaterThanEqual(0).select(B(1),B(-1));pe.assign(Rh(He).mul(tt))})});let xe=mt(Xs(O.x),mt(Xs(O.y),Xs(O.z)));vg(A,Ha($.add(N)),Pe(Xs(pe.div(xe).add(P)),0,0,0)).toStack()})(),G=Math.ceil(E/4),Y=V.compute([G,G,G],[4,4,4]);return{atlas:A,slots:T,kernel:Y,uniforms:{slotOrigin:N,triCount:D,boxHalf:O},setTriangles($,Q){let ue=z.value;ue.array.set($.subarray(0,12*Q)),ue.needsUpdate=!0}}}(Cf*Cf,++this._ultraBuildSeq)),e.npart===0)return this._meshBaker!==null&&e._meshSdfWanted.size>0&&this._bakeNextMeshChild(e,t),void(e.geometry.drawRange.count=0);this.npartUniform.value=e.npart,this.spatialnUniform.value=e.spatialn,this.spanUniform.value=e.spatialPassUniforms.span.value,e.shapesDataTexture.value&&(this.shapesTex.value=e.shapesDataTexture.value);let a=!O9&&n,o=a&&!L9&&e.ultraFieldResolution>0,l=o&&!k9&&(z9||e.ultraFieldResolution>=512)?Math.min(Math.pow(e.ultraFieldResolution/4,3),Math.max(function(T){let M=T/4;return Math.min(M*M*M,Math.max(8192,16*M*M))}(e.ultraFieldResolution),this._ultraWantedPoolBricks,this.poolHint)):0,u=l>0&&!V9,h=this._maxMarchSlots(t),d=u?Math.min(Math.floor(h/64),Math.max(function(T){let M=T/4;return Math.min(262144,Math.max(2048,2*M*M))}(e.ultraFieldResolution),this._ultraWantedVertexBlocks,this.vertHint)):0,c=this._meshBaker!==null,p=e.needsRebuild||this.level!==e.resolutionLevel||this.spatialnAtBuild!==e.spatialn||this._cachedAtBuild!==a||this._ultraResAtBuild!==(o?e.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 f=a&&this._ensureMarchCapacity(Math.min(Math.max(h,k2),Math.max(e.geometry.drawRange.count,this.capacityHint,o?Math.max(function(T){return Math.max(k2,192*Math.ceil(16*T*T/192))}(e.ultraFieldResolution),this._ultraWantedCapacity):k2)),h);if(f&&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=this._spatialTargetFor(e),g=o?null:this._targetsFor(e),v=p||f,y=o&&this._ultra!==null&&this._ultraResAtBuild===e.ultraFieldResolution&&!f&&this.level===e.resolutionLevel&&this.spatialnAtBuild===e.spatialn&&this._cachedAtBuild===a;if(v&&y)e.needsRebuild=!1,this._ultra.uniforms.bboxHalf.value=e.bboxSize/2,this._ultra.uniforms.bboxOffset.value=e.bboxOffset,this._ultraDrag&&(this._ultraDrag.uniforms.bboxHalf.value=e.bboxSize/2,this._ultraDrag.uniforms.bboxOffset.value=e.bboxOffset);else if(v){e.needsRebuild=!1;let T=this.spatialnAtBuild!==e.spatialn;this.level=e.resolutionLevel,this.spatialnAtBuild=e.spatialn,this._meshAtBuild=c,(T||this.spatialMaterial===null)&&(this.spatialMaterial?.dispose(),this.spatialMaterial=this._buildSpatialMaterial(e)),this.spatialTexNode.value=m.texture;let M=this._ultra,E=this._ultraDrag;if(this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,o){let N=e.ultraFieldResolution,D=M!==null&&this._ultraResAtBuild===N;if(D&&!f)this._ultra=M,M.uniforms.bboxHalf.value=e.bboxSize/2,M.uniforms.bboxOffset.value=e.bboxOffset,this._ultraDrag=E,E&&(E.uniforms.bboxHalf.value=e.bboxSize/2,E.uniforms.bboxOffset.value=e.bboxOffset);else{let O=D&&l===0&&!M.sparse;M&&!O&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),u&&this._drawIndex===null&&(this._drawIndex=$n(this._marchCapacity,"uint")),u&&this._vertexBuffers===null&&(this._vertexBuffers={positions:$n(64*d,"vec4"),normals:$n(64*d,"vec4"),colors:$n(64*d,"vec4")}),this._ultra=nge({resolution:N,colorResolution:N/2,bboxHalf:e.bboxSize/2,bboxOffset:e.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(e,2/(N/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:UI().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:O?{sdfTexture:M.sdfTexture,colorTexture:M.colorTexture,coarseTexture:M.coarseTexture}:void 0}),this._poolAtBuild=l,this._vertBlocksAtBuild=d;let z=U9&&N>=128&&!u?N/2:0;E&&(!D||z===0)&&this._ultraRetired.push(E.sdfTexture,E.colorTexture,E.coarseTexture),z>0&&(this._ultraDrag=nge({resolution:z,colorResolution:z/2,bboxHalf:e.bboxSize/2,bboxOffset:e.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(e,2/(z/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:UI().numTrisTable,buffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,reuseTextures:D&&E?{sdfTexture:E.sdfTexture,colorTexture:E.colorTexture,coarseTexture:E.coarseTexture}:void 0}))}this._ultraResAtBuild=N}else{M&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),E&&this._ultraRetired.push(E.sdfTexture,E.colorTexture,E.coarseTexture),(this._legacyMaterialsLevel!==e.resolutionLevel||T||this.potentialMaterial===null||this.voxelMaterial===null)&&(this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose(),this.potentialMaterial=this._buildPotentialMaterial(e),this.voxelMaterial=this._buildVoxelMaterial(e),this._legacyMaterialsLevel=e.resolutionLevel),this.potentialTexNode.value=g.potential.texture,this.voxelTexNode.value=g.voxel.textures[0];let N=e.pyramidLevelSizes.length%2==0?0:1,D=1-N;this.pyramid1TexNode.value=g.pyramid[D].texture,this.pyramid2TexNode.value=g.pyramid[N].texture,this._ultraResAtBuild=0}let A=e.material;A.defines===void 0&&(A.defines={}),qm.includes("nomat")||(A.defines.SHAPEBLEND=e.resolutionLevel),qm.includes("nomat")||A.setShapeBlendResources?.(o?{resolutionLevel:e.resolutionLevel,pyramidLevelSizes:e.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(e),cached:a?this._marchBuffers:void 0}),this._cachedAtBuild=a;let P=`${e.resolutionLevel}:${this._marchCapacity}`;this._computeNodeKey!==P&&(this._computeNode=null,this._computeNodeKey=P)}if(v)return this._builtOnce=!0,void(this._computeDirty=!0);this._meshBaker!==null&&e._meshSdfWanted.size>0&&this._bakeNextMeshChild(e,t);let _=this._passesRenderer!==t,b=r&&!F9&&!this._computeDirty&&!_&&!e._fieldDirtyFull;if(!(r||this._computeDirty||_)){if(o&&this._refinePending&&this._ultra!==null&&performance.now()-this._lastFieldChangeMs>250)return this._refinePending=!1,this._passesRenderer=t,sn.refines++,void this._runUltra(e,t,!1,this._ultra);if(o&&oN&&this._ultra!==null&&this._ultra.meshlet&&this._lastDispatched===this._ultra&&!this._ultraReadbackPending&&this._updateCullUniforms(e,this._ultra)&&(!this._hasGatherMVP||!this._lastGatherMVP.equals(this._ultra.uniforms.cullMVP.value))){this._lastGatherMVP.copy(this._ultra.uniforms.cullMVP.value),this._hasGatherMVP=!0,sn.regathers++;let T=t;return T.compute(this._ultra.kernels.zero),aN||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(e,t)}if(!e.drawRangeNeedsForceUpdate)return void sn.skips++;if(o)return void(this._ultraReadbackPending||this._runUltraReadback(e,t))}if(this._passesRenderer=t,qm.includes("none")&&sn.readbacksResolved>0)return void(this._computeDirty=!1);let x=t.getRenderTarget(),w=t.getMRT(),S=t.autoClear;if(t.setMRT(null),t.autoClear=!1,sn.lastPass="spatial",t.setRenderTarget(m),Op.material=this.spatialMaterial,Op.render(t),o){t.autoClear=S,t.setRenderTarget(x),t.setMRT(w);let T=this._ultraDrag!==null&&r&&!this._computeDirty;return this._refinePending=T,this._lastFieldChangeMs=performance.now(),this._runUltra(e,t,b,T?this._ultraDrag:this._ultra),void(this._computeDirty=!1)}return qm==="spatial"&&sn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(sn.lastPass="potential",t.setRenderTarget(g.potential),Op.material=this.potentialMaterial,Op.render(t),qm==="potential"&&sn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(sn.lastPass="voxel",t.setRenderTarget(g.voxel),Op.material=this.voxelMaterial,Op.render(t),qm==="voxel"&&sn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(sn.lastPass="pyramid",this._renderPyramid(e,t,g.voxel,g.pyramid),t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),sn.lastPass="march",a&&(this._computeNode===null&&(this._computeNode=function(T,M,E){let A=nMe(T);return Xe(()=>{let{position:P,normal:N,color:D}=A(Sa.toFloat());M.positions.element(Sa).assign(Pe(P,1)),M.normals.element(Sa).assign(Pe(N,0)),M.colors.element(Sa).assign(D)})().compute(E)}(this._marchResources(e),this._marchBuffers,this._marchCapacity)),t.compute(this._computeNode),sn.computes++),void(this._computeDirty=!1))))}_bakeNextMeshChild(e,t){let i=this._meshBaker;for(let[r,n]of e._meshSdfWanted){let s=Qxe(n);if(this._meshBakeFailed.get(r)===s)continue;let a=this._meshSlots.get(r);if(a===void 0){if(this._meshSlots.size>=i.slots)for(let u of this._meshSlots.keys())!e._meshSdfBaked.has(u)&&!e._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=UFe(n);if(o!==null)return i.setTriangles(o.data,o.triCount),i.uniforms.slotOrigin.value.copy(kFe(a)),i.uniforms.triCount.value=o.triCount,i.uniforms.boxHalf.value.copy(o.boxHalf),t.compute(i.kernel),e._meshSdfBaked.set(r,{slot:a,boxHalf:o.boxHalf.clone(),posVersion:s,owner:this}),void e._meshSdfWanted.delete(r);this._meshBakeFailed.set(r,s)}}_updateCullUniforms(e,t){if(!t.meshlet)return!1;let i=this._cullCamera;return oN&&i&&i.projectionMatrix!==void 0&&i.matrixWorldInverse!==void 0?(t.uniforms.cullMVP.value.multiplyMatrices(it.unjitteredProjection.value,i.matrixWorldInverse).multiply(e.matrixWorld),t.uniforms.cullEnabled.value=1,!0):(t.uniforms.cullEnabled.value=0,!1)}_runUltra(e,t,i,r){let n=t;sn.lastPass="ultra-kernels",sn.lastDispatchRes=r.resolution,sn.marchPositions=(r.meshlet?this._vertexBuffers:this._marchBuffers).positions.value,this._lastDispatched=r;let s=r.resolution,a=s/4,o=2/(s-1);r.uniforms.activeThreshold.value=B9?1e30:(3*Math.sqrt(3)+4)*o+.25*e._maxBlendK;let l=r.meshlet&&!G9;r.meshlet&&(r.uniforms.adaptCos.value=l?age:2);let u=0,h=0,d=0,c=a,p=a,f=a;if(i){let v=r.uniforms.activeThreshold.value+2/(e.spatialDivisions-1)+4/(s-1),y=x=>Math.floor(.5*(x+1)*(s-1)/4),_=x=>Math.min(a-1,Math.max(0,y(x))),b=x=>Math.min(a,Math.max(1,y(x)+1));if(u=_(e._fieldDirtyMin.x-v),h=_(e._fieldDirtyMin.y-v),d=_(e._fieldDirtyMin.z-v),c=b(e._fieldDirtyMax.x+v)-u,p=b(e._fieldDirtyMax.y+v)-h,f=b(e._fieldDirtyMax.z+v)-d,sn.fieldsWindowed++,l){let x=Math.min(a,u+c+1),w=Math.min(a,h+p+1),S=Math.min(a,d+f+1);u=Math.max(0,u-1),h=Math.max(0,h-1),d=Math.max(0,d-1),c=x-u,p=w-h,f=S-d}}else sn.fieldsFull++;sn.lastWindowBricks=c*p*f,r.uniforms.windowOrigin.value.set(u,h,d),r.uniforms.windowSize?.value.set(c,p,f);let m=u===0&&h===0&&d===0&&c===a&&p===a&&f===a,g=[Math.ceil(c/4),Math.ceil(p/4),Math.ceil(f/4)];r.meshlet&&this._updateCullUniforms(e,r)&&(this._lastGatherMVP.copy(r.uniforms.cullMVP.value),this._hasGatherMVP=!0),n.compute(r.kernels.zero),aN||n.compute(r.meshlet?r.kernels.clearDraw:r.kernels.clear),r.needsInit&&r.kernels.init&&(n.compute(r.kernels.init),r.needsInit=!1),n.compute(r.kernels.coarse,g),r.kernels.release&&n.compute(r.kernels.release,g),r.kernels.alloc&&n.compute(r.kernels.alloc,g),r.kernels.meshRelease&&n.compute(r.kernels.meshRelease,g),r.sparse?m?n.compute(r.kernels.sdf):n.compute(r.kernels.sdfWindow,[c,p,f]):n.compute(r.kernels.sdf,[c,p,f]),r.kernels.classify&&n.compute(r.kernels.classify,g),n.compute(r.kernels.color,[Math.ceil(c/2),Math.ceil(p/2),Math.ceil(f/2)]),r.meshlet?(m?(n.compute(r.kernels.verts),n.compute(r.kernels.extract)):(n.compute(r.kernels.vertsWindow,[c,p,f]),n.compute(r.kernels.extractWindow,[c,p,f])),n.compute(r.kernels.gather)):n.compute(r.kernels.extract),r.kernels.stats&&n.compute(r.kernels.stats),sn.computes++,this._ultraReadbackPending?this._ultraReadbackQueued=!0:this._runUltraReadback(e,t)}_disposeRetired(){for(let e of this._ultraRetired)e.dispose();if(this._ultraRetired.length=0,this._retiredStorage.length>0){let e=this._lastRenderer?.backend?.attributeUtils;if(e)for(let t of this._retiredStorage)e.destroyAttribute(t);this._retiredStorage.length=0}for(let e of this._onSettled)e();this._onSettled.length=0}runWhenSettled(e){this._onSettled.push(e)}transferSettleQueue(e){e._onSettled.push(...this._onSettled),this._onSettled.length=0}_runUltraReadback(e,t){let i=this._lastDispatched??this._ultra,r=t;this._ultraReadbackPending=!0,sn.readbackPending=!0,r.getArrayBufferAsync(i.counterAttribute).then(n=>{if(this._ultraReadbackPending=!1,sn.readbackPending=!1,this.retired)return;this._disposeRetired();let s=new Uint32Array(n),a=i.meshlet?Math.floor(s[3]/3):s[0];if(sn.readbacksResolved++,sn.lastTotal=a,i.sparse&&s.length>2&&s[2]>0&&(this._ultraWantedPoolBricks=Math.ceil(1.5*Math.max(s[1],i.poolBricks)),this._computeDirty=!0),i.meshlet&&s.length>5&&s[5]>0){let l=Math.min(24*s[4],this._maxMarchSlots(t));l>this._marchCapacity&&(this._ultraWantedCapacity=Math.max(this._ultraWantedCapacity,l),this._computeDirty=!0)}if(i.meshlet&&s.length>7&&s[7]>0){let l=Math.min(Math.ceil(1.5*s[6]),Math.floor(this._maxMarchSlots(t)/64));l>i.vertexBlocks&&(this._ultraWantedVertexBlocks=Math.max(this._ultraWantedVertexBlocks,l),this._computeDirty=!0)}let o=Math.floor(this._marchCapacity/3);if(e.geometry.drawRange.count=3*Math.min(Math.ceil(1.25*a),o),e.markSceneShadowsDirty(),e.drawRangeNeedsForceUpdate=!1,this._ultraReadbackQueued&&(this._ultraReadbackQueued=!1,this._runUltraReadback(e,t)),a>o){let l=Math.min(3*a,this._maxMarchSlots(t));l>this._marchCapacity&&(this._ultraWantedCapacity=l,this._computeDirty=!0)}}).catch(()=>{sn.readbackErrors++,this._ultraReadbackPending=!1,sn.readbackPending=!1})}_renderPyramid(e,t,i,r){let n=e.pyramidLevelSizes,s=n.length-1-1;nE.value=0,W_.value=0;for(let o=s;o>=0;o--){let l=o%2==s%2?r[0]:r[1],u=o===s?i:o%2==s%2?r[1]:r[0];ox.value=u.textures.length>1?u.textures[1]:u.texture,p$.value=u.width,f$.value=u.height;let h=n[o];o===2&&e.resolutionLevel%2!=0&&(h=3),m$.value=h,l.viewport.set(W_.value,0,h,h),t.setRenderTarget(l),Op.material=GFe(),Op.render(t),l.viewport.set(0,0,l.width,l.height);let d=nE.value;nE.value=W_.value,W_.value=d,o<s&&(W_.value+=n[o+1])}sn.lastPass="pyramid-readback";let a=n.length%2==0?0:1;t.readRenderTargetPixelsAsync(r[a],r[a].width-1,0,1,1).then(o=>{let l=o[0];sn.readbacksResolved++,sn.lastTotal=l,!this.retired&&(this._disposeRetired(),(3*l>e.geometry.drawRange.count||e.drawRangeNeedsForceUpdate)&&(e.geometry.drawRange.count=3*Math.floor(1.2*l)),e.drawRangeNeedsForceUpdate=!1,this._marchBuffers!==null&&e.geometry.drawRange.count>this._marchCapacity&&(this._computeDirty=!0))}).catch(()=>{})}dispose(){for(let n of[...this.spatialTargets,...this.potentialTargets,...this.voxelTargets,...this.pyramidTargets.flat()])n?.dispose();this.spatialMaterial?.dispose(),this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose();let e=this._lastRenderer?.backend?.attributeUtils,t=n=>{if(e&&n!==null)for(let s of[n.positions,n.normals,n.colors]){let a=s.value;a&&e.destroyAttribute(a)}},i=n=>{if(n!==null){for(let s of Object.values(n.kernels))s?.dispose?.();if(e)for(let s of n.storageAttributes)e.destroyAttribute(s)}};t(this._marchBuffers),t(this._vertexBuffers);let r=this._drawIndex?.value;e&&r&&e.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}},qb=new WeakMap,sE=new WeakMap,Fx=[]}),HFe=U(()=>{yB(),TK(),WFe(),$L=BFe,zY=e=>function(t){let i=qb.get(t);if(i?.wantsReplacement){let r=sE.get(t);sE.set(t,i),i.retired=!0;let n=new g$(i.capacityHint,i.poolHint,i.vertHint);i.transferSettleQueue(n),r&&n.runWhenSettled(()=>r.dispose()),i=n,qb.set(t,i)}return i||(i=new g$,qb.set(t,i)),i}(e),function(e){kY=e}({release:e=>function(t){let i=qb.get(t),r=sE.get(t);qb.delete(t),sE.delete(t),r&&Fx.push(r),i&&(i.retired=!0,Fx.push(i))}(e),drainRetired:jFe})});function qFe(){let e=jE.length;if(e>0){for(let t of jE)t.dispose();jE.length=0}return e}var hl,uo,nu,Oi,Xu,oge,j9,lge,hge,lN,uge,hN,dge,cge,W9,Lp,H_,V2,hMe,aE,jE,v4,q_,uMe,dMe,cMe,pMe,fMe,mMe,$Fe=U(()=>{oe(),vn(),bi(),zxe(),Uxe(),hl=[64,1,1],nu=(uo=jv)-1,Oi=(e,t)=>t!==void 0?Fe(e,t):Fe(e),Xu=(e,t)=>{let i=e.xyz,r=qn(i,t),n=qn(i,r);return t.add(r.mul(e.w).mul(2)).add(n.mul(2))},oge=e=>{let t=et(e,e);return t.lessThan(1e-10).select(Pe(0,0,0,1),e.mul(nK(mt(t,1e-20))))},j9=Xe(([e,t])=>{let i=e,r=t,n=et(i,r).add(1).toVar(),s=J(0).toVar();return Ve(n.lessThan(1e-7),()=>{n.assign(0),Ve(ui(i.x).greaterThan(ui(i.z)),()=>{s.assign(J(i.y.negate(),i.x,0))}).Else(()=>{s.assign(J(0,i.z.negate(),i.y))})}).Else(()=>{s.assign(qn(i,r))}),oge(Pe(s,n))}),lge=e=>e.sub(Ct(e.mul(1/289)).mul(289)),hge=e=>e.sub(Ct(e.mul(1/289)).mul(289)),lN=e=>hge(e.mul(34).add(10).mul(e)),uge=e=>Pe(1.79284291400159).sub(e.mul(.85373472095314)),hN=Xe(([e])=>{let t=e,i=1/6,r=1/3,n=Ct(t.add(et(t,J(r)))).toVar(),s=t.sub(n).add(et(n,J(i))).toVar(),a=hr(s.yzx,s.xyz).toVar(),o=J(1).sub(a).toVar(),l=Fi(a,o.zxy).toVar(),u=mt(a,o.zxy).toVar(),h=s.sub(l).add(i).toVar(),d=s.sub(u).add(r).toVar(),c=s.sub(.5).toVar();n.assign(lge(n));let p=lN(lN(lN(Pe(0,l.z,u.z,1).add(n.z)).add(n.y).add(Pe(0,l.y,u.y,1))).add(n.x).add(Pe(0,l.x,u.x,1))).toVar(),f=.142857142857,m=2*f,g=.5*f-1,v=f,y=p.sub(Ct(p.mul(v*v)).mul(49)).toVar(),_=Ct(y.mul(v)).toVar(),b=Ct(y.sub(_.mul(7))).toVar(),x=_.mul(m).add(g).toVar(),w=b.mul(m).add(g).toVar(),S=Pe(1).sub(ui(x)).sub(ui(w)).toVar(),T=Pe(x.xy,w.xy).toVar(),M=Pe(x.zw,w.zw).toVar(),E=Ct(T).mul(2).add(1).toVar(),A=Ct(M).mul(2).add(1).toVar(),P=hr(S,Pe(0)).negate().toVar(),N=T.xzyw.add(E.xzyw.mul(P.xxyy)).toVar(),D=M.xzyw.add(A.xzyw.mul(P.zzww)).toVar(),O=J(N.xy,S.x).toVar(),z=J(N.zw,S.y).toVar(),L=J(D.xy,S.z).toVar(),V=J(D.zw,S.w).toVar(),G=uge(Pe(et(O,O),et(z,z),et(L,L),et(V,V))).toVar();O.assign(O.mul(G.x)),z.assign(z.mul(G.y)),L.assign(L.mul(G.z)),V.assign(V.mul(G.w));let Y=mt(Pe(.5).sub(Pe(et(s,s),et(h,h),et(d,d),et(c,c))),Pe(0)).toVar();return Y.assign(Y.mul(Y)),et(Y.mul(Y),Pe(et(O,s),et(z,h),et(L,d),et(V,c))).mul(105)}),dge=class extends Hv{constructor(e,t,i,r,n){super(),this.tangentWorld=e,this.specularPower=t,this.specularIntensity=i,this.diffuseIntensity=r,this.ambientFloor=n}direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,n=Ut(_u.mul(Pe(this.tangentWorld,0)).xyz),s=t,a=lw,o=Ut(s.add(a)),l=mt(Yi(qn(n,s)),0),u=mt(Yi(qn(n,o)),0);r.directDiffuse.addAssign(i.mul(l).mul(this.diffuseIntensity).mul(Wl.rgb)),r.directSpecular.addAssign(i.mul(Xl(u,this.specularPower)).mul(this.specularIntensity).mul(J(1,.95,.9)))}indirect(e){let{irradiance:t,ambientOcclusion:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(1/Math.PI).add(this.ambientFloor).mul(Wl.rgb)),r.indirectDiffuse.mulAssign(i)}},cge=class extends Hv{direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,n=t,s=Ao,a=lw,o=Ut(n.add(a)),l=et(s,n).clamp(),u=et(s,o).clamp();r.directDiffuse.addAssign(i.mul(l).mul(.85).mul(Wl.rgb)),r.directSpecular.addAssign(i.mul(Xl(u,60)).mul(.3).mul(J(.3,.28,.25)))}indirect(e){let{irradiance:t,ambientOcclusion:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(1/Math.PI).add(.15).mul(Wl.rgb)),r.indirectDiffuse.mulAssign(i)}},W9=class extends ei{constructor(e){super(),this.model=e,this.lights=!0}setupLightingModel(){return this.model}},Lp=new kt,H_=new kt,V2=new R,hMe=class{constructor(){this.uNumStrands=Oi(0,"int"),this.uNumVerts=Oi(0,"int"),this.uDamping=Oi(.03),this.uLocalStiffness=Oi(.67),this.uGlobalStiffness=Oi(.5),this.uGlobalRange=Oi(.15),this.uStiffnessFalloff=Oi(.1),this.uGravity=Oi(0),this.uVspCoeff=Oi(.01),this.uVspThreshold=Oi(50),this.uKink=Oi(0),this.uKinkFreq=Oi(0),this.uUnitScale=Oi(100),this.uClumpStrength=Oi(0),this.uClumpSize=Oi(32,"int"),this.uClumpTipScale=Oi(1.5),this.uReset=Oi(1),this.uHasWind=Oi(0),this.uWind0=Oi(new R),this.uWind1=Oi(new R),this.uWind2=Oi(new R),this.uWind3=Oi(new R),this.uBoneQuat=Oi(new ct(0,0,0,1)),this.uBoneTrans=Oi(new R),this.uDeltaQuat=Oi(new ct(0,0,0,1)),this.uPrevBoneTrans=Oi(new R),this.uHairRoot=Oi(new ot),this.uHairMid=Oi(new ot),this.uHairTip=Oi(new ot),this.uHeadColor=Oi(new ot),this.uNoiseA=Oi(new ot),this.uNoiseB=Oi(new ot),this.uNoiseC=Oi(new ot),this.uNoiseD=Oi(new ot),this.uNoiseScale=Oi(.018),this.uNoiseMixHair=Oi(0),this.uNoiseMixHead=Oi(0),this.uWidth=Oi(.525),this.uSpecPow=Oi(40),this.uSpecInt=Oi(.4),this.uDiffInt=Oi(.6),this.uAmbInt=Oi(.25),this.uOpacity=Oi(1),this.uTipFade=Oi(.4),this.uColorSource=Oi(0),this.uShadeRoot=Oi(.6),this.uShadeTip=Oi(1.15),this.uShadowTexelWorld=Oi(0),this._armed=!1,this._uploadedGeneration=-1,this._prevBoneQuat=new kt,this._prevBonePos=new R,this._hasPrevBone=!1,this._renderer=null,this.initialPos=$n(tf,"vec4"),this.rootColors=$n(Px,"vec4"),this.positions=$n(tf,"vec4"),this.positionsPrev=$n(tf,"vec4"),this.positionsPrevPrev=$n(tf,"vec4"),this.tangents=$n(tf,"vec4"),this.restLengths=$n(tf,"float"),this.vspQuats=$n(Px,"vec4"),this.vspTrans=$n(Px,"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 Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumVerts),()=>{bn()});let t=e.div(uo).toVar(),i=e.sub(t.mul(uo)).toVar(),r=this.boneQuatNode(),n=this.boneTransNode(),s=this.initialPos.element(e).toVar(),a=Pe(Xu(r,s.xyz).add(n),s.w).toVar(),o=this.positions.element(e).toVar(),l=this.positionsPrev.element(e).toVar(),u=l.toVar();Ve(this.uReset.greaterThan(.5),()=>{o.assign(a),u.assign(a)});let h=a.toVar();Ve(o.w.greaterThan(0),()=>{let d=B(fg),c=EB(this.uDamping.negate().mul(d).mul(60)),p=o.xyz.add(o.xyz.sub(u.xyz).mul(c)).add(J(0,-1,0).mul(this.uGravity).mul(d).mul(d));h.assign(Pe(p,o.w))}),Ve(this.uGlobalStiffness.greaterThan(0).and(this.uGlobalRange.greaterThan(0)).and(h.w.greaterThan(0)).and(i.toFloat().lessThan(this.uGlobalRange.mul(uo))),()=>{let d=e.sub(i),c=this.initialPos.element(d),p=Ut(Xu(r,c.xyz)).y.mul(.5).add(.5),f=this.uGlobalStiffness.mul(Xl(mt(p,0),this.uStiffnessFalloff)),m=a.xyz.sub(h.xyz).mul(f);h.assign(Pe(h.xyz.add(m),h.w))}),Ve(this.uKink.greaterThan(0).and(h.w.greaterThan(0)),()=>{let d=i.toFloat().div(uo),c=t.sub(t.div(256).mul(256)).toFloat().mul(.0245),p=d.mul(this.uKinkFreq).mul(6.2831853).add(c),f=this.uKink.mul(d).mul(.15).mul(this.uUnitScale),m=Ut(a.xyz.sub(n)).toVar(),g=J(0).toVar();Ve(ui(m.y).lessThan(.99),()=>{g.assign(Ut(qn(m,J(0,1,0))))}).Else(()=>{g.assign(Ut(qn(m,J(1,0,0))))});let v=Ut(qn(m,g)),y=g.mul(Pa(p)).mul(f).add(v.mul(Yo(p.mul(1.3).add(c))).mul(f).mul(.7));h.assign(Pe(h.xyz.add(y),h.w))}),this.positionsPrevPrev.element(e).assign(l),this.positionsPrev.element(e).assign(o),this.positions.element(e).assign(h)})().compute(hl[0],hl)}_buildStrandLevel(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=e.mul(uo).toVar(),i=this.positionsPrevPrev.element(t.add(1)),r=this.positionsPrev.element(t),n=this.positionsPrev.element(t.add(1)),s=this.positions.element(t),a=this.positions.element(t.add(1)),o=n.xyz.sub(r.xyz),l=a.xyz.sub(s.xyz),u=o.div(mt(Yi(o),1e-7)),h=l.div(mt(Yi(l),1e-7)),d=j9(u,h).toVar(),c=s.xyz.sub(Xu(d,r.xyz)),p=this.uVspCoeff.toVar(),f=Yi(a.xyz.sub(n.xyz.mul(2)).add(i.xyz));Ve(f.greaterThan(this.uVspThreshold),()=>{p.assign(1)}),this.vspQuats.element(e).assign(d),this.vspTrans.element(e).assign(Pe(c,p))})().compute(hl[0],hl)}_buildVsp(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumVerts),()=>{bn()});let t=e.div(uo).toVar(),i=e.sub(t.mul(uo)).toVar();Ve(i.lessThan(2),()=>{bn()});let r=this.vspQuats.element(t),n=this.vspTrans.element(t),s=n.w,a=this.positions.element(e).toVar(),o=this.positionsPrev.element(e).toVar(),l=u=>Pe(u.xyz.mul(B(1).sub(s)).add(Xu(r,u.xyz).add(n.xyz).mul(s)),u.w);this.positions.element(e).assign(l(a)),this.positionsPrev.element(e).assign(l(o))})().compute(hl[0],hl)}_buildLocalShape(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=e.mul(uo).toVar(),i=Fi(this.uLocalStiffness,.95).mul(.5),r=this.boneQuatNode();Zr(nu-1,({i:n})=>{let s=t.add(n).add(1).toVar(),a=this.positions.element(s).toVar(),o=this.positions.element(s.add(1)).toVar(),l=this.positions.element(s.sub(1)),u=Xu(r,this.initialPos.element(s).xyz),h=Xu(r,this.initialPos.element(s.add(1)).xyz),d=Xu(r,this.initialPos.element(s.sub(1)).xyz),c=a.xyz.sub(l.xyz),p=h.sub(u),f=u.sub(d),m=j9(f.div(mt(Yi(f),1e-7)),c.div(mt(Yi(c),1e-7))),g=Xu(m,p).add(a.xyz).sub(o.xyz).mul(i);Ve(a.w.greaterThan(0),()=>{a.assign(Pe(a.xyz.sub(g),a.w))}),Ve(o.w.greaterThan(0),()=>{o.assign(Pe(o.xyz.add(g),o.w))}),this.positions.element(s).assign(a),this.positions.element(s.add(1)).assign(o)})})().compute(hl[0],hl)}_buildLengthWind(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=e.mul(uo).toVar();Ve(this.uHasWind.greaterThan(.5),()=>{let i=e.sub(e.div(20).mul(20)).toFloat().div(20),r=this.uWind0.mul(i).add(this.uWind1.mul(B(1).sub(i))).add(this.uWind2.mul(i)).add(this.uWind3.mul(B(1).sub(i))).toVar();Zr(nu-2,({i:n})=>{let s=t.add(n).add(2).toVar(),a=this.positions.element(s).toVar(),o=this.positions.element(s.add(1)),l=a.xyz.sub(o.xyz),u=qn(qn(l,r),l).negate();a.assign(Pe(a.xyz.add(u.mul(fg).mul(.1)),a.w)),this.positions.element(s).assign(a)})}),Zr(5,()=>{Zr(nu,({i})=>{let r=t.add(i).toVar(),n=this.positions.element(r).toVar(),s=this.positions.element(r.add(1)).toVar(),a=this.restLengths.element(r),o=s.xyz.sub(n.xyz),l=mt(Yi(o),1e-7),u=B(1).sub(a.div(l)),h=o.mul(u),d=n.w.greaterThan(0),c=s.w.greaterThan(0),p=d.select(c.select(B(.5),B(1)),B(0)),f=c.select(d.select(B(.5),B(1)),B(0));n.assign(Pe(n.xyz.add(h.mul(p)),n.w)),s.assign(Pe(s.xyz.sub(h.mul(f)),s.w)),this.positions.element(r).assign(n),this.positions.element(r.add(1)).assign(s)})}),Zr(nu,({i})=>{let r=t.add(i).add(1).toVar(),n=this.positions.element(r.sub(1)),s=this.positions.element(r).toVar(),a=s.xyz.sub(n.xyz),o=mt(Yi(a),1e-7),l=this.restLengths.element(r.sub(1));Ve(o.greaterThan(l),()=>{s.assign(Pe(n.xyz.add(a.div(o).mul(l)),s.w)),this.positions.element(r).assign(s)})}),Zr(uo,({i})=>{let r=t.add(i).toVar(),n=i.equal(uo-1).select(r.sub(1),r).toVar(),s=Ut(this.positions.element(n.add(1)).xyz.sub(this.positions.element(n).xyz));this.tangents.element(r).assign(Pe(s,0))})})().compute(hl[0],hl)}_buildClump(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumStrands),()=>{bn()});let t=this.uClumpSize.toVar(),i=e.div(t).mul(t).toVar();Ve(e.equal(i),()=>{bn()}),Ve(i.greaterThanEqual(this.uNumStrands),()=>{bn()});let r=e.mul(uo).toVar(),n=i.mul(uo).toVar();Zr(nu,({i:s})=>{let a=s.add(1).toVar(),o=a.toFloat().div(nu),l=this.uClumpStrength.mul(Xl(o,B(1).div(mt(this.uClumpTipScale,.5)))),u=r.add(a).toVar(),h=this.positions.element(u).toVar(),d=this.positions.element(n.add(a));h.assign(Pe(ut(h.xyz,d.xyz,l),h.w)),this.positions.element(u).assign(h)})})().compute(hl[0],hl)}_buildRigidFollow(){return Xe(()=>{let e=De(Sa).toVar();Ve(e.greaterThanEqual(this.uNumVerts),()=>{bn()});let t=this.uDeltaQuat,i=this.uPrevBoneTrans,r=this.boneTransNode(),n=a=>{let o=a.element(e).toVar();o.assign(Pe(Xu(t,o.xyz.sub(i)).add(r),o.w)),a.element(e).assign(o)};n(this.positions),n(this.positionsPrev),n(this.positionsPrevPrev);let s=this.tangents.element(e).toVar();s.assign(Pe(Xu(t,s.xyz),0)),this.tangents.element(e).assign(s)})().compute(hl[0],hl)}pastelNoise(e){let t=e.sub(this.boneTransNode()).mul(this.uNoiseScale),i=hN(t).mul(.5).add(.5),r=hN(t.add(J(31.7,17.3,53.1))).mul(.5).add(.5),n=hN(t.mul(.7).add(J(71.9,11.2,43.8))).mul(.5).add(.5),s=ut(this.uNoiseA,this.uNoiseB,i);return s=ut(s,this.uNoiseC,r.mul(.6)),s=ut(s,this.uNoiseD,n.mul(.25)),s}_buildRibbonMaterial(){let e=Bn("vec3","vHairTangent"),t=Bn("vec3","vHairNormal"),i=Bn("vec2","vHairUv"),r=Bn("float","vHairRand"),n=Bn("vec3","vHairInherit"),s=new W9(new dge(e,this.uSpecPow,this.uSpecInt,this.uDiffInt,this.uAmbInt));s.name="SplineHairRibbons",s.userData.hairShadowVariant="texel-floor-v6",s.transparent=!1,s.depthTest=!0,s.depthWrite=!0,s.side=Ur;let a=l=>Xe(()=>{let u=De(Sa).toVar(),h=u.div(nu).toVar(),d=u.sub(h.mul(nu)).toVar(),c=h.mul(uo).add(d).toVar(),p=De(UE).toVar(),f=p.bitAnd(1).toFloat().toVar(),m=p.shiftRight(1).bitAnd(1).toFloat().toVar(),g=this.positions.element(c).xyz.toVar(),v=this.positions.element(c.add(1)).xyz.toVar(),y=this.tangents.element(c).xyz,_=this.tangents.element(c.add(1)).xyz,b=ut(g,v,m).toVar(),x=ut(y,_,m).toVar(),w=Ut(qf.sub(b)),S=qn(x,w).toVar(),T=Yi(S).toVar();S.assign(T.greaterThan(1e-7).select(S.div(T),J(1,0,0)));let M=d.toFloat().div(nu),E=d.add(1).toFloat().div(nu),A=ut(M,E,m).toVar(),P=this.uWidth.mul(B(1).sub(A.mul(this.uTipFade))).toVar(),N=l?(()=>{let G=this.uShadowTexelWorld,Y=G.greaterThan(0).select(G.mul(1.5).clamp(B(2),B(8)),B(0));return mt(Y.sub(P),0).toVar()})():null;N&&P.addAssign(N);let D=f.mul(2).sub(1),O=b.add(S.mul(P).mul(D)).toVar();N&&O.assign(O.sub(w.mul(N)));let z=this.positionsPrev.element(c).xyz,L=this.positionsPrev.element(c.add(1)).xyz;DB.assign(ut(z,L,m).add(S.mul(P).mul(D)));let V=gr(Pa(h.toFloat().mul(12.9898)).mul(43758.5453));return r.assign(V),n.assign(this.rootColors.element(h).xyz),e.assign(x),t.assign(Ut(w.sub(x.mul(et(x,w))))),i.assign(Me(f,A)),O}),o=Xe(()=>{let l=i.y,u=ut(this.uHairRoot,this.uHairMid,Fi(l.mul(2),1)),h=l.lessThan(.5).select(u,ut(this.uHairMid,this.uHairTip,l.sub(.5).mul(2))).toVar(),d=n.mul(ut(this.uShadeRoot,this.uShadeTip,l));h.assign(this.uColorSource.greaterThan(.5).select(d,h)),h.assign(ut(h,this.pastelNoise(Jl),this.uNoiseMixHair));let c=B(1).sub(ui(i.x.sub(.5)).mul(2));return B(1).sub(l.mul(this.uTipFade)).mul(Xl(mt(c,0),.5)).toVar().lessThan(.25).discard(),r.greaterThanEqual(this.uOpacity).discard(),Pe(h,1)});return s.positionNode=a(!1)(),s.castShadowPositionNode=a(!0)(),s.normalNode=t,s.colorNode=o(),s.needsUpdate=!0,s}_buildScalpMaterial(){let e=new W9(new cge);e.name="SplineHairScalp";let t=Xe(()=>{let i=ut(this.uHeadColor,this.pastelNoise(Jl),this.uNoiseMixHead);return Pe(i,1)});return e.colorNode=t(),e.needsUpdate=!0,e}update(e,t){let i=t;if(i.backend?.isWebGPUBackend!==!0||(this._renderer=i,e.visible===!1))return;if(!this._armed){this._armed=!0;let o=e.ribbonMesh.material;e.ribbonMesh.material=this.ribbonMaterial,o.dispose?.();let l=e.scalpMesh.material;e.scalpMesh.material=this.scalpMaterial,l.dispose?.(),e.ribbonMesh.visible=!0}e.checkDataDrift();let r=e.activeGuideStrands,n=r*uo;e.generation!==this._uploadedGeneration&&(this._uploadedGeneration=e.generation,this.initialPos.value.array.set(e.roots.initialPositions),this.initialPos.value.needsUpdate=!0,this.restLengths.value.array.set(e.roots.restLengths),this.restLengths.value.needsUpdate=!0,this.rootColors.value.array.set(e.roots.rootColors),this.rootColors.value.needsUpdate=!0,e.ribbonMesh.geometry.instanceCount=r*nu,e.resetRequested=!0),this._syncUniforms(e),e.boneTransform(Lp,V2),this.uBoneQuat.value.set(Lp.x,Lp.y,Lp.z,Lp.w),this.uBoneTrans.value.copy(V2);let s=this._hasPrevBone&&(Math.abs(this._prevBoneQuat.dot(Lp))<.9999995||this._prevBonePos.distanceToSquared(V2)>1e-8),a=Math.floor(e.pendingSimSeconds/fg);a>4&&(a=4),e.pendingSimSeconds=Math.max(0,Math.min(e.pendingSimSeconds-a*fg,fg)),e.resetRequested&&a<1&&(a=1),a<1&&s&&(H_.copy(this._prevBoneQuat).invert().premultiply(Lp),this.uDeltaQuat.value.set(H_.x,H_.y,H_.z,H_.w),this.uPrevBoneTrans.value.copy(this._prevBonePos),this._dispatch(i,this.kRigidFollow,n));for(let o=0;o<a;o++){this.uReset.value=e.resetRequested&&o===0?1:0,e.simTime+=fg,this._updateWind(e),this._dispatch(i,this.kIntegrate,n),this._dispatch(i,this.kStrandLevel,r),this._dispatch(i,this.kVsp,n);for(let l=0;l<2;l++)this._dispatch(i,this.kLocalShape,r);this._dispatch(i,this.kLengthWind,r),e.data.clumpStrength>.001&&this._dispatch(i,this.kClump,r)}a>0&&(e.resetRequested=!1),this._prevBoneQuat.copy(Lp),this._prevBonePos.copy(V2),this._hasPrevBone=!0}_dispatch(e,t,i){t.count=i,e.compute(t)}_updateWind(e){let t=e.data,i=Math.max(e.roots.unitScale,.001),r=t.windStrength/i;this.uHasWind.value=t.windStrength>.001?1:0;let n=.7*e.simTime,s=Math.sin(n)*r,a=Math.cos(n)*r*.5;this.uWind0.value.set(s,0,a),this.uWind1.value.set(.7*s,.5*r,1.2*a),this.uWind2.value.set(.3*-s,0,.5*a),this.uWind3.value.set(.5*s,-.3*r,.8*-a)}_shadowTexelWorld(e){let t=e;for(;t.parent;)t=t.parent;let i=t;if(!i?.traverse)return 0;let r=0;return i.traverse(n=>{let s=n;if(s.isDirectionalLight!==!0||s.castShadow!==!0||s.visible===!1)return;let a=s.shadow?.camera,o=s.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(e){let t=e.data,i=e.roots.unitScale;this.uNumStrands.value=e.activeGuideStrands,this.uNumVerts.value=e.activeGuideStrands*uo,this.uDamping.value=t.damping,this.uLocalStiffness.value=t.localStiffness,this.uGlobalStiffness.value=t.globalStiffness,this.uGlobalRange.value=t.globalRange,this.uStiffnessFalloff.value=t.stiffnessFalloff,this.uGravity.value=t.gravity*i,this.uVspCoeff.value=t.vspCoefficient,this.uVspThreshold.value=.5*i,this.uKink.value=t.kink,this.uKinkFreq.value=t.kinkFrequency,this.uUnitScale.value=i,this.uClumpStrength.value=t.clumpStrength,this.uClumpSize.value=Math.max(1,Math.round(t.clumpSize)),this.uClumpTipScale.value=t.clumpTipScale;let r=(s,a)=>{s.value.setRGB(a.r,a.g,a.b,Xi)};r(this.uHairRoot,t.hairRootColor),r(this.uHairMid,t.hairMidColor),r(this.uHairTip,t.hairTipColor),r(this.uHeadColor,t.headColor),r(this.uNoiseA,t.noiseColorA),r(this.uNoiseB,t.noiseColorB),r(this.uNoiseC,t.noiseColorC),r(this.uNoiseD,t.noiseColorD);let n=t.noiseEnabled?1:0;this.uNoiseScale.value=t.noiseScale/Math.max(i,.001),this.uNoiseMixHair.value=t.noiseMixHair*n,this.uNoiseMixHead.value=t.noiseMixHead*n,this.uWidth.value=.003*t.hairWidth*od*e.widthWorldScale,this.uShadowTexelWorld.value=this._shadowTexelWorld(e),this.uColorSource.value=t.hairColorSource==="object"&&t.headShape==="object"&&t.baseObjectId?1:0,this.uShadeRoot.value=t.hairShadeRoot??.6,this.uShadeTip.value=t.hairShadeTip??1.15,this.uSpecPow.value=t.specularPower,this.uSpecInt.value=t.specularIntensity,this.uDiffInt.value=t.diffuseIntensity,this.uAmbInt.value=t.ambientIntensity,this.uOpacity.value=t.opacity,this.uTipFade.value=t.tipFade}dispose(){for(let t of[this.kIntegrate,this.kStrandLevel,this.kVsp,this.kLocalShape,this.kLengthWind,this.kClump,this.kRigidFollow])t.dispose();this.ribbonMaterial.dispose(),this.scalpMaterial.dispose();let e=this._renderer?.backend?.attributeUtils;if(e)for(let t of[this.initialPos,this.rootColors,this.positions,this.positionsPrev,this.positionsPrevPrev,this.tangents,this.restLengths,this.vspQuats,this.vspTrans])e.destroyAttribute(t.value);this._renderer=null}},aE=new WeakMap,jE=[]}),XFe=U(()=>{FY(),$Fe(),LY=e=>function(t){let i=aE.get(t);return i===void 0&&(i=new hMe,aE.set(t,i)),i}(e),function(e){BY=e}({release:e=>function(t){let i=aE.get(t);i!==void 0&&(aE.delete(t),jE.push(i))}(e),drainRetired:qFe})}),gMe=U(()=>{v4=`
|
|
6228
6228
|
const PI: f32 = 3.14159265358979323846;
|
|
6229
6229
|
|
|
6230
6230
|
const TRANSMITTANCE_TEXTURE_WIDTH: i32 = 256;
|
|
@@ -11224,7 +11224,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
11224
11224
|
outgoingLight *= ao;
|
|
11225
11225
|
}
|
|
11226
11226
|
`),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result});`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&d.push(`gl_FragColor.a *= ${h.result};`),d.push("#include <colorspace_fragment>",Nw,"#include <dithering_fragment>"),t=d.join(`
|
|
11227
|
-
`)}return t}}});function to(e,t){BK.set(e,t)}var BK,R$,io=U(()=>{BK=new Map,R$=new Set});function $Ue(e,t,i){if(t==="isMask"||e.type==="rainbow"&&t==="noiseStrength"&&e.noiseCompiledIn!==void 0&&(e.noiseForced===!0||Gf(i))!==e.noiseCompiledIn)return!0;let r=xw[e.type],n=SY[e.type];if(n!==void 0){let s=e.color;if(n.includes(t)){let a=s[t]?.value?.length;if(a!==void 0&&a!==i.length)return!0}}return r!==void 0&&r.includes(t)}function aj(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!==t.length)return!1;for(let[n,s]of t.entries()){let a=e[n];if(typeof s=="string"||typeof s=="number"&&typeof a=="string")return!0}return!1}let i=typeof e=="string",r=typeof t=="string";return i!==r||i&&r}function D$(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let n=!1,s=e;if("image"in s){let a=s.image,o=t.image(a),l=r;l.image instanceof Rc||l.image.deref(),l.image=o}if("video"in s){let a=s.video,o=t.video(a),l=r;l.image instanceof Rc||l.image.deref(),l.image=o}if("wrapping"in s&&(r.wrap=s.wrapping),"minFilter"in s&&(r.minFilter=s.minFilter),"magFilter"in s&&(r.magFilter=s.magFilter),"rotation"in s&&i.uniforms[`f${i.id}_rotation`])return i.uniforms[`f${i.id}_rotation`].value=(Lt(s.rotation??0,t)??0)*ht.DEG2RAD,n;if("repeat"in s||"offset"in s||"rotation"in s){let a="mat",o=i.uniforms[`f${i.id}_${a}`];if(!o)return n;if("repeat"in s){let l=s.repeat;aj(i.data.texture.repeat,l)&&(n=!0),o.repeat=zx(l,t).map((u,h)=>typeof l[h]=="string"?1/u:u)}if("offset"in s){let l=s.offset;aj(i.data.texture.offset,l)&&(n=!0),o.offset=zx(l,t).map((u,h)=>typeof l[h]=="string"?-u:u)}if("rotation"in s){let l=i.data.texture.rotation,u=s.rotation??0;(l===void 0||aj(l,u))&&(n=!0),o.rotation=Lt(u,t)??0}o.updateMatrix()}return n}var zEe=U(()=>{Sbe(),ca(),zn(),oe(),bu(),oB(),IK(),Ed()});function tl(e){return{alpha:new xt(e.alpha??1),mode:new gn(e.mode??0),isMask:new Co(e.isMask??!1)}}function Kge(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=(Lt(i.intensity,r)??1)*(i.visible?1:0),n):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=Oh(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=i.compensation&&i.visible)}return n}}var Xf,Vc,zx,lx,Fn,FK,ld,ca=U(()=>{oe(),jt(),OK(),jUe(),WUe(),HUe(),qUe(),zn(),oB(),rl(),io(),zEe(),Ed(),Ed(),Xf=(e,t)=>(e||(e=new R),e.x=Lt(e.x,t)??0,e.y=Lt(e.y,t)??0,e.z=Lt(e.z,t)??0,e),Vc=(e,t)=>(e||(e=new Z),e.x=Lt(e.x,t)??0,e.y=Lt(e.y,t)??0,e),zx=(e,t)=>{let i=e.map(r=>Lt(r,t)??0);return[i[0],i[1]]},lx=class{constructor(e,t,i,r,n){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let s in r)this.uniforms[`f${this.id}_${s}`]=r[s];for(let s in i)Kge(s,this,i,n)}get type(){return this.data.type}static create(e,t,i,r,n){if(i.type==="light")return ld.createLightLayer(e,t,i,r);if(i.type==="color")return function(o,l,u,h){let d=il(u,h),c=new rs(d.color??eo),p=tl(d),f=new T4(c,p.alpha),m=new pn(f.calpha,"f");return new Fn(o,l,u,{color:c,...p},f,p.mode,m,p.isMask,h)}(e,t,i,r);let s=(a=i.type,BK.get(a));var a;return s?s(e,t,i,r,n):(function(o){R$.has(o)||(R$.add(o),console.warn(`[spe] Material layer type "${o}" is not available in this runtime build (compiled out) \u2014 rendering flat red. Re-export the scene with its full layer set or load the full runtime build.`))}(i.type),function(o,l,u,h){let d=u,c=tl({alpha:typeof d.alpha=="string"?Number(h.getVariable(d.alpha)??100)/100:d.alpha,mode:d.mode,isMask:d.isMask}),p=new rs(1,0,0,1),f=new T4(p,c.alpha),m=new pn(f.calpha,"f");return new Fn(o,l,u,{color:p,...c},f,c.mode,m,c.isMask,h)}(e,t,i,r))}updateByOp(e,t,i){let r=e,n=!1;if(r.path[0]===void 0){for(let s of Object.keys(r.props))try{let a=this.data[s],o=t[s];if(Array.isArray(a)&&Array.isArray(o)){for(let[l,u]of o.entries()){let h=a[l];if(typeof u=="string"||typeof u=="number"&&typeof h=="string"){n=!0;break}}if(n)break}else if(typeof o=="string"&&typeof a=="number"||typeof o=="number"&&typeof a=="string"||typeof o=="string"&&typeof a=="string"&&o!==a){n=!0;break}}catch(a){console.error(a)}if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props||"noiseType"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):function(s,a,o,l){let u=!1;for(let[h,d]of Object.entries(s)){if(h==="bumpMap"||h==="roughnessMap"){u=!0;continue}if(!h||d===void 0)continue;if(Kge(h,o,l,a)){h==="visible"&&o.type==="light"&&(u=!0);continue}o.visible=l.visible;let c=o.uniforms[`f${o.id}_${h}`];if(c&&!(c instanceof FB))switch(u=u||$Ue(o,h,d),c.constructor){case rs:if(typeof d=="string"){let p=a.getColor(d);p&&(c.value=p);break}{let p=d;c.value instanceof MA?c.value=new zr(p.r,p.g,p.b,p.a):c.setRGBA(p);break}case zc:if(typeof d=="string"){let p=a.getColor(d);p&&(c.value=p);break}{let p=d;c.value instanceof MA?c.value=new zr(p.r,p.g,p.b,p.a):c.value.setRGBA(p.r,p.g,p.b,p.a);break}case Ka:{let p=d;c.value.setX(p[0]),c.value.setY(p[1]);break}case Lh:{let p=d;c.value.setX(p[0]),c.value.setY(p[1]),c.value.setZ(p[2]);break}case fd:D$(d,a,o);break;case Kg:c.value=d.map(p=>new ct(...p));break;default:c.value=d}}return u}(r.props,i.shared,this,t)||n}else if(r.path[0]==="texture")return!("texture"in t)&&!("video"in t)||D$(r.props,i.shared,this)||n;return n}dispose(){if(function(e){let t=typeof e=="string"?e:e.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Rc||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;if(this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t,e==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof t=="number"&&t!==0&&this.onNoiseMismatch!==void 0)){let r=this.onNoiseMismatch;this.onNoiseMismatch=void 0,r(t)&&(this.noiseCompiledIn=!0)}}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},Fn=class extends lx{constructor(e,t,i,r,n,s,a,o,l){super(e,t,i,r,l),this.params=r,this.color=n,this.mode=s,this.alpha=a,this.isMask=o}},FK=class extends lx{constructor(e,t,i,r,n,s){super(e,t,i,r,s),this.position=n}},ld=class extends lx{constructor(e,t,i,r,n,s){super(e,t,i,n,s),this.node=r}static createLightLayer(e,t,i,r){let n,s,a=new xt(Oh(i.alpha,r)),o=new gn(i.mode),l=new xt(i.bumpMapIntensity),u=new xt(Oh(i.alphaOverride,r));if(i.visible)if(i.category==="lambert"){n=new OEe;let h=new rs(r.color(i.emissive)??0),d=new Co(i.occlusion??!0);s={emissive:h,occlusion:d},n.emissive=h,n.occlusion=d}else if(i.category==="toon"){n=new BEe;let h=new xt(i.shininess??30),d=new rs(r.color(i.specular)??1118481);s={shininess:h,specular:d},n.shininess=h,n.specular=d}else if(i.category==="physical"){n=new LEe;let h=new xt(i.roughness??.3),d=new xt(i.metalness??0),c=new xt(i.reflectivity??.5),p=new Co(i.occlusion??!0);s={roughness:h,metalness:d,reflectivity:c,occlusion:p},n.roughness=h,n.metalness=d,n.reflectivity=c,n.occlusion=p}else{n=new FEe;let h=new xt(i.shininess??30),d=new rs(i.specular!==void 0?r.color(i.specular)??1118481:1118481),c=new Co(i.occlusion??!0);s={shininess:h,specular:d,occlusion:c},n.shininess=h,n.specular=d,n.occlusion=c}else n=new VB,s={};return n.alpha=new xt(1),n.shadingAlpha=a,n.shadingBlend=o,n.bumpMapIntensity=l,n.alphaOverride=u,s.alpha=n.shadingAlpha,s.mode=n.shadingBlend,s.bumpMapIntensity=n.bumpMapIntensity,s.alphaOverride=n.alphaOverride,new ld(e,t,i,n,s,r)}get category(){return this.node.category}}});function Vo(e,t,i,r,n,s,a=[]){let o=i;for(let l of a)l in o&&(o=o[l]);for(let l of e)l in o&&n.getVariable(o[l],["material",s,"layer",r,...a,String(l)]);for(let l of t)l in o&&o[l].forEach((u,h)=>{n.getVariable(u,["material",s,"layer",r,...a,String(l),h===0?"x":h===1?"y":"z"])})}function Zge(e,t,i){let r=e.depthPrepassTwins[i];return r===void 0&&(r=new kEe(e.flatShading,i,t),r.needsJitter=t.needsJitter,r.updateAfterBuild(),e.depthPrepassTwins[i]=r,t.depthTwins.push(r)),r}var vN,oj,lj,kEe,UK,VEe,hj,Qge,xv,uj,dj,Jge,Ym,e0e,GEe,cj,jEe,N$,WEe,HEe,qEe,$Ee,XEe,YEe,KEe,t0e,i0e,ZEe,QEe,JEe=U(()=>{oe(),Cd(),IB(),Xc(),NK(),jt(),ca(),OK(),zn(),mEe(),zEe(),Ed(),cB(),vN=class extends Dr{constructor(){super(void 0),this.isClassicNodeMaterial=!0,this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.depthPrepass=!1,this.depthPrepassTwins=[],this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}applyDepthPrepassPolicy(){let e=ATe({transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.defines?.SHAPEBLEND!==void 0,data:this.data});this.depthPrepass=e,this.depthWrite=!e}customProgramCacheKey(){return""}},oj=!1,lj=class extends vN{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.nodeExtensions=e.nodeExtensions,this.transparent=e.transparent,this.applyDepthPrepassPolicy(),this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}getDepthPrepassTwin(e){return Zge(this,this.root,e)}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i,r){return this.root.getFlavor(e,t,i,r)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}setTransparent(e,t){this.root.setTransparent(e,t)}ensureRainbowNoiseCompiled(e,t){return this.root.ensureRainbowNoiseCompiled(e,t)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},kEe=class extends lj{constructor(e,t,i){super(e,t,!1,i),this.isDepthPrepassMaterial=!0,this.cutoffUniform={value:eY},this.colorWrite=!1,this.depthWrite=!0}updateAfterBuild(){super.updateAfterBuild(),this.uniforms.alphaDiscardCutoff=this.cutoffUniform,this.colorWrite=!1,this.depthWrite=!0}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.uniforms=this.uniforms}applyDepthPrepassPolicy(){this.depthPrepass=!1}getDepthPrepassTwin(){return this}},UK=class extends vN{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.depthTwins=[],this.masks={},this.type="NodeMaterial",this.forceRainbowNoise=new Set,this.syntheticMapLayers=new Map,this.updaters=[],this.needsJitter=t.shared.needsJitter,Ys.startContext(this),this.reset0(e,t),Ys.endContext(this)}setTransparent(e,t){let i=this.transparent!==e;if(i){this.transparent=e,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=e,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=e,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||t?.markNeedsUpdateRendererDirty()}getDepthPrepassTwin(e){return Zge(this,this,e)}get nodeMaterial(){return this}getFlavor(e,t,i,r){let n=i?6:(e?3:0)+t;if(n+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),n===0)return this;this.flavors===void 0&&(this.flavors=[]),n-=1;let s=this.flavors[n];return s===void 0&&(s=new lj(e,t,i,this),s.needsJitter=this.needsJitter,this.flavors[n]=s,s.flatShading=e,s.side=t,s.updateAfterBuild(),r&&(s.defines.SHAPEBLEND=r.resolutionLevel,s.defines.SHAPEBLEND_C=r.useChildrenColors?1:0,s.applyDepthPrepassPolicy())),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}ensureRainbowNoiseCompiled(e,t){let i=this.data.layers?.data(e);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(e)&&!Gf(i.noiseStrength)||this.getLayerByUuid(e)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(e),Ys.startContext(this),this.reset0(this.data,this.lastContext),Ys.endContext(this),t!==void 0&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}reset(e,t,i=!1){Ys.startContext(this),(this.data!==e||i)&&this.reset0(e,t),Ys.endContext(this)}reset0(e,t){this.lastContext=t,this.data=e;let i=e.layers??ns.defaultTwoLayerData("phong").layers,r=[];for(let n of i)try{let s=lx.create(this.layerIdGen++,n.id,n.data,t.shared,this.forceRainbowNoise.has(n.id)?{forceRainbowNoise:!0}:void 0);if(s.type==="rainbow"&&s.noiseCompiledIn===!1){let a=n.id;s.onNoiseMismatch=o=>this.ensureRainbowNoiseCompiled(a,o)}r.push(s)}catch(s){console.warn(`[spe] material layer '${n.data.type}' (${n.id}) failed to build \u2014 skipping this layer`,s)}this.layers=r,this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.setTransparent(Sd(e,t.shared),t.scene),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.setTransparent(Sd(this.data,i.shared),i.scene),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],n=e[2];if(r&&n){let s=this.layers.find(a=>a.uuid===r);if(s?.hasValue(n))if(n==="alpha")this.setTransparent(Sd(this.data,i.shared),i.scene),s.setValue(n,Math.max(0,Math.min(Number(t)/100,1)));else{let a=s.getValue(n),o=e[3],l=e[4];if(a instanceof Ri){let u,h=a[o];return typeof h=="number"?u=Number(t):h.isVector2&&(u=h.toArray(),l==="x"?u[0]=Number(t):l==="y"&&(u[1]=Number(t))),void D$({[o]:u},i.shared,s)}(o==="x"||o==="y"||o==="z")&&a.isVector3||(o==="x"||o==="y")&&a.isVector2?a[o]=Number(t):s.setValue(n,t)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"]),i.data.type==="displace"?i.data.displacementType==="noise"?Vo(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],i.data,i.id,e.shared,this.uuid):Vo(["intensity"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="depth"?Vo(["near","far"],["origin","direction"],i.data,i.id,e.shared,this.uuid):i.data.type==="cavity"?Vo(["ridge","valley"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="fresnel"?Vo(["bias","scale","intensity","factor"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="dust"?Vo(["coverage","softness","noiseStrength","noiseScale"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="rainbow"?Vo(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],i.data,i.id,e.shared,this.uuid):i.data.type==="noise"?Vo(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],i.data,i.id,e.shared,this.uuid):i.data.type==="pattern"?Vo(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],i.data,i.id,e.shared,this.uuid):i.data.type==="outline"?Vo(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],i.data,i.id,e.shared,this.uuid):i.data.type==="toon"?Vo(["noiseStrength","noiseScale"],["offset","source"],i.data,i.id,e.shared,this.uuid):i.data.type==="transmission"?Vo(["roughness","thickness","ior"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="texture"||i.data.type==="video"?(Vo([],["size"],i.data,i.id,e.shared,this.uuid),Vo(["rotation"],["repeat","offset"],i.data,i.id,e.shared,this.uuid,["texture"])):i.data.type==="gradient"?Vo(["angle"],["offset","morph"],i.data,i.id,e.shared,this.uuid):i.data.type==="matcap"&&Vo(["rotation"],[],i.data,i.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof ld),this.lightLayer===void 0&&(this.lightLayer=new ld(0,"",{...hs.defaultData("light","phong"),visible:!1},new VB,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();for(let t of this.depthTwins)t.dispose();this.applyTextureMaps(e),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}syntheticMapNode(e,t){let i=this.syntheticMapLayers.get(e);if(i===void 0)try{let n=hs.defaultData("texture"),s={...n,visible:!1,texture:{...n.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}};i=lx.create(this.layerIdGen++,`mapImage${this.layerIdGen}`,s,t),this.syntheticMapLayers.set(e,i)}catch(n){return void console.warn("[spe] light-layer map image failed to build \u2014 skipped",n)}let r=i.color;return r instanceof M4?r:void 0}applyTextureMaps(e){let t=this.layers.find(a=>a instanceof ld);if(!t)return;let i=t.data,r=i.bumpMap,n=i.roughnessMap;t.node.bumpMap=void 0,t.node.roughnessMap=void 0;for(let a of this.syntheticMapLayers.values())a.dispose();this.syntheticMapLayers.clear(),vA.is(r)&&(t.node.bumpMap=this.syntheticMapNode(r,e)),vA.is(n)&&(t.node.roughnessMap=this.syntheticMapNode(n,e));let s=i;!oj&&(s.metalnessMap!==void 0||s.normalMap!==void 0||s.aoMap!==void 0||s.emissiveMap!==void 0||s.roughnessMapChannel!==void 0&&s.roughnessMapChannel!=="luminance"||s.clearcoat!==void 0||s.sheen!==void 0||s.ior!==void 0||s.iridescence!==void 0||s.emissive!==void 0&&typeof s.emissive=="object"&&(s.emissive.r>0||s.emissive.g>0||s.emissive.b>0))&&(oj=!0,console.warn("[spline] this document uses PBR material maps (metalness/normal/AO/emissive), which the classic WebGL pipeline does not render \u2014 the WebGPU renderer shows them"));for(let a=0;a<this.layers.length;++a){let o=this.layers[a];o instanceof Fn&&o.color instanceof M4&&(o.uuid===r&&(t.node.bumpMap=o.color),o.uuid===n&&(t.node.roughnessMap=o.color))}}updateByOp(e,t,i){if(Ys.startContext(this),t!==void 0?this.data=t:t=this.data,this.setTransparent(Sd(t,i.shared),i.scene),e.path[0]==="layers"){let r=i.shared,n=e.path[1];if(n===void 0)i.scene.markNeedsUpdateRendererDirty(),this.reset0(t,i);else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(a=>a.uuid===n);if(s){let a,o=t.layers.data(n);e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&(a="alpha"in e.props?{...e.props,alpha:Oh(e.props.alpha,r,["material",this.uuid,"layer",n,"alpha"])}:{...e.props,alphaOverride:Oh(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...a?{props:a}:{},path:e.path.slice(2)},o,i)&&this.reset0(t,i)}}}else this.reset0(t,i);Ys.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof Fn?t.color.mask=void 0:t instanceof ld&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof Fn&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof ld?r.node.mask=new ql(t.color,t.alpha,ql.MUL):r instanceof Fn&&(r.isMask.value||(r.color.mask=new ql(t.color,t.alpha,ql.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof Fn),t=this.layers.findIndex(i=>i instanceof ld);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let n=this.layers[r];if(n instanceof Fn){if(n.isMask.value)continue;i=new P$(i,n.color,n.alpha,n.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new pn("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof ld);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof Fn){if(r.isMask.value)continue;e=new P$(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof FK);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new ql(t,e[i].position,ql.ADD),t=new ql(t,new xt(.5).setReadonly(!0),ql.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.nodeExtensions.derivatives===!0,e.extensionFragDepth=this.nodeExtensions.fragDepth===!0,e.extensionDrawBuffers=this.nodeExtensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.nodeExtensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,n,s)=>Math.min(Math.max(r,n),s);for(let r of this.layers)if(r.type==="displace"){let n=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=n}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new EK;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.nodeExtensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();for(let t of this.depthTwins)t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose());for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear(),super.dispose();for(let e of this.depthTwins)e.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof Fn){let t=e.params.texture;if(t instanceof zA&&!t.image.loaded)return!1}for(let e of this.syntheticMapLayers.values()){let t=e.params?.texture;if(t instanceof zA&&!t.image.loaded)return!1}return!0}},Object.defineProperties(vN.prototype,{properties:{get:function(){return this.fragment.properties}}})}),XUe=U(()=>{JEe(),VEe=class extends UK{constructor(e,t,i){super(e,t,!1),this.isClassicSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}}}),YUe=U(()=>{Cd(),oe(),hj=`
|
|
11227
|
+
`)}return t}}});function to(e,t){BK.set(e,t)}var BK,R$,io=U(()=>{BK=new Map,R$=new Set});function $Ue(e,t,i){if(t==="isMask"||e.type==="rainbow"&&t==="noiseStrength"&&e.noiseCompiledIn!==void 0&&(e.noiseForced===!0||Gf(i))!==e.noiseCompiledIn)return!0;let r=xw[e.type],n=SY[e.type];if(n!==void 0){let s=e.color;if(n.includes(t)){let a=s[t]?.value?.length;if(a!==void 0&&a!==i.length)return!0}}return r!==void 0&&r.includes(t)}function aj(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!==t.length)return!1;for(let[n,s]of t.entries()){let a=e[n];if(typeof s=="string"||typeof s=="number"&&typeof a=="string")return!0}return!1}let i=typeof e=="string",r=typeof t=="string";return i!==r||i&&r}function D$(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let n=!1,s=e;if("image"in s){let a=s.image,o=t.image(a),l=r;l.image instanceof Rc||l.image.deref(),l.image=o}if("video"in s){let a=s.video,o=t.video(a),l=r;l.image instanceof Rc||l.image.deref(),l.image=o}if("wrapping"in s&&(r.wrap=s.wrapping),"minFilter"in s&&(r.minFilter=s.minFilter),"magFilter"in s&&(r.magFilter=s.magFilter),"rotation"in s&&i.uniforms[`f${i.id}_rotation`])return i.uniforms[`f${i.id}_rotation`].value=(Lt(s.rotation??0,t)??0)*ht.DEG2RAD,n;if("repeat"in s||"offset"in s||"rotation"in s){let a="mat",o=i.uniforms[`f${i.id}_${a}`];if(!o)return n;if("repeat"in s){let l=s.repeat;aj(i.data.texture.repeat,l)&&(n=!0),o.repeat=zx(l,t).map((u,h)=>typeof l[h]=="string"?1/u:u)}if("offset"in s){let l=s.offset;aj(i.data.texture.offset,l)&&(n=!0),o.offset=zx(l,t).map((u,h)=>typeof l[h]=="string"?-u:u)}if("rotation"in s){let l=i.data.texture.rotation,u=s.rotation??0;(l===void 0||aj(l,u))&&(n=!0),o.rotation=Lt(u,t)??0}o.updateMatrix()}return n}var zEe=U(()=>{Sbe(),ca(),zn(),oe(),bu(),oB(),IK(),Ed()});function tl(e){return{alpha:new xt(e.alpha??1),mode:new gn(e.mode??0),isMask:new Co(e.isMask??!1)}}function Kge(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=(Lt(i.intensity,r)??1)*(i.visible?1:0),n):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=Oh(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=i.compensation&&i.visible)}return n}}var Xf,Vc,zx,lx,Fn,FK,ld,ca=U(()=>{oe(),jt(),OK(),jUe(),WUe(),HUe(),qUe(),zn(),oB(),rl(),io(),zEe(),Ed(),Ed(),Xf=(e,t)=>(e||(e=new R),e.x=Lt(e.x,t)??0,e.y=Lt(e.y,t)??0,e.z=Lt(e.z,t)??0,e),Vc=(e,t)=>(e||(e=new Z),e.x=Lt(e.x,t)??0,e.y=Lt(e.y,t)??0,e),zx=(e,t)=>{let i=e.map(r=>Lt(r,t)??0);return[i[0],i[1]]},lx=class{constructor(e,t,i,r,n){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let s in r)this.uniforms[`f${this.id}_${s}`]=r[s];for(let s in i)Kge(s,this,i,n)}get type(){return this.data.type}static create(e,t,i,r,n){if(i.type==="light")return ld.createLightLayer(e,t,i,r);if(i.type==="color")return function(o,l,u,h){let d=il(u,h),c=new rs(d.color??eo),p=tl(d),f=new T4(c,p.alpha),m=new pn(f.calpha,"f");return new Fn(o,l,u,{color:c,...p},f,p.mode,m,p.isMask,h)}(e,t,i,r);let s=(a=i.type,BK.get(a));var a;return s?s(e,t,i,r,n):(function(o){R$.has(o)||(R$.add(o),console.warn(`[spe] Material layer type "${o}" is not available in this runtime build (compiled out) \u2014 rendering flat red. Re-export the scene with its full layer set or load the full runtime build.`))}(i.type),function(o,l,u,h){let d=u,c=tl({alpha:typeof d.alpha=="string"?Number(h.getVariable(d.alpha)??100)/100:d.alpha,mode:d.mode,isMask:d.isMask}),p=new rs(1,0,0,1),f=new T4(p,c.alpha),m=new pn(f.calpha,"f");return new Fn(o,l,u,{color:p,...c},f,c.mode,m,c.isMask,h)}(e,t,i,r))}updateByOp(e,t,i){let r=e,n=!1;if(r.path[0]===void 0){for(let s of Object.keys(r.props))try{let a=this.data[s],o=t[s];if(Array.isArray(a)&&Array.isArray(o)){for(let[l,u]of o.entries()){let h=a[l];if(typeof u=="string"||typeof u=="number"&&typeof h=="string"){n=!0;break}}if(n)break}else if(typeof o=="string"&&typeof a=="number"||typeof o=="number"&&typeof a=="string"||typeof o=="string"&&typeof a=="string"&&o!==a){n=!0;break}}catch(a){console.error(a)}if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props||"noiseType"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):function(s,a,o,l){let u=!1;for(let[h,d]of Object.entries(s)){if(h==="bumpMap"||h==="roughnessMap"){u=!0;continue}if(!h||d===void 0)continue;if(Kge(h,o,l,a)){h==="visible"&&o.type==="light"&&(u=!0);continue}o.visible=l.visible;let c=o.uniforms[`f${o.id}_${h}`];if(c&&!(c instanceof FB))switch(u=u||$Ue(o,h,d),c.constructor){case rs:if(typeof d=="string"){let p=a.getColor(d);p&&(c.value=p);break}{let p=d;c.value instanceof MA?c.value=new zr(p.r,p.g,p.b,p.a):c.setRGBA(p);break}case zc:if(typeof d=="string"){let p=a.getColor(d);p&&(c.value=p);break}{let p=d;c.value instanceof MA?c.value=new zr(p.r,p.g,p.b,p.a):c.value.setRGBA(p.r,p.g,p.b,p.a);break}case Ka:{let p=d;c.value.setX(p[0]),c.value.setY(p[1]);break}case Lh:{let p=d;c.value.setX(p[0]),c.value.setY(p[1]),c.value.setZ(p[2]);break}case fd:D$(d,a,o);break;case Kg:c.value=d.map(p=>new ct(...p));break;default:c.value=d}}return u}(r.props,i.shared,this,t)||n}else if(r.path[0]==="texture")return!("texture"in t)&&!("video"in t)||D$(r.props,i.shared,this)||n;return n}dispose(){if(function(e){let t=typeof e=="string"?e:e.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Rc||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;if(this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t,e==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof t=="number"&&t!==0&&this.onNoiseMismatch!==void 0)){let r=this.onNoiseMismatch;this.onNoiseMismatch=void 0,r(t)&&(this.noiseCompiledIn=!0)}}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},Fn=class extends lx{constructor(e,t,i,r,n,s,a,o,l){super(e,t,i,r,l),this.params=r,this.color=n,this.mode=s,this.alpha=a,this.isMask=o}},FK=class extends lx{constructor(e,t,i,r,n,s){super(e,t,i,r,s),this.position=n}},ld=class extends lx{constructor(e,t,i,r,n,s){super(e,t,i,n,s),this.node=r}static createLightLayer(e,t,i,r){let n,s,a=new xt(Oh(i.alpha,r)),o=new gn(i.mode),l=new xt(i.bumpMapIntensity),u=new xt(Oh(i.alphaOverride,r));if(i.visible)if(i.category==="lambert"){n=new OEe;let h=new rs(r.color(i.emissive)??0),d=new Co(i.occlusion??!0);s={emissive:h,occlusion:d},n.emissive=h,n.occlusion=d}else if(i.category==="toon"){n=new BEe;let h=new xt(i.shininess??30),d=new rs(r.color(i.specular)??1118481);s={shininess:h,specular:d},n.shininess=h,n.specular=d}else if(i.category==="physical"){n=new LEe;let h=new xt(i.roughness??.3),d=new xt(i.metalness??0),c=new xt(i.reflectivity??.5),p=new Co(i.occlusion??!0);s={roughness:h,metalness:d,reflectivity:c,occlusion:p},n.roughness=h,n.metalness=d,n.reflectivity=c,n.occlusion=p}else{n=new FEe;let h=new xt(i.shininess??30),d=new rs(i.specular!==void 0?r.color(i.specular)??1118481:1118481),c=new Co(i.occlusion??!0);s={shininess:h,specular:d,occlusion:c},n.shininess=h,n.specular=d,n.occlusion=c}else n=new VB,s={};return n.alpha=new xt(1),n.shadingAlpha=a,n.shadingBlend=o,n.bumpMapIntensity=l,n.alphaOverride=u,s.alpha=n.shadingAlpha,s.mode=n.shadingBlend,s.bumpMapIntensity=n.bumpMapIntensity,s.alphaOverride=n.alphaOverride,new ld(e,t,i,n,s,r)}get category(){return this.node.category}}});function Vo(e,t,i,r,n,s,a=[]){let o=i;for(let l of a)l in o&&(o=o[l]);for(let l of e)l in o&&n.getVariable(o[l],["material",s,"layer",r,...a,String(l)]);for(let l of t)l in o&&o[l].forEach((u,h)=>{n.getVariable(u,["material",s,"layer",r,...a,String(l),h===0?"x":h===1?"y":"z"])})}function Zge(e,t,i){let r=e.depthPrepassTwins[i];return r===void 0&&(r=new kEe(e.flatShading,i,t),r.needsJitter=t.needsJitter,r.updateAfterBuild(),e.depthPrepassTwins[i]=r,t.depthTwins.push(r)),r}var vN,oj,lj,kEe,UK,VEe,hj,Qge,xv,uj,dj,Jge,Ym,e0e,GEe,cj,jEe,N$,WEe,HEe,qEe,$Ee,XEe,YEe,KEe,t0e,i0e,ZEe,QEe,JEe=U(()=>{oe(),Cd(),IB(),Xc(),NK(),jt(),ca(),OK(),zn(),mEe(),zEe(),Ed(),cB(),vN=class extends Dr{constructor(){super(void 0),this.isClassicNodeMaterial=!0,this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.depthPrepass=!1,this.depthPrepassTwins=[],this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}applyDepthPrepassPolicy(){let e=ATe({transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.defines?.SHAPEBLEND!==void 0,data:this.data});this.depthPrepass=e,this.depthWrite=!e}customProgramCacheKey(){return""}},oj=!1,lj=class extends vN{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.nodeExtensions=e.nodeExtensions,this.transparent=e.transparent,this.applyDepthPrepassPolicy(),this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}getDepthPrepassTwin(e){return Zge(this,this.root,e)}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i,r){return this.root.getFlavor(e,t,i,r)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}setTransparent(e,t){this.root.setTransparent(e,t)}ensureRainbowNoiseCompiled(e,t){return this.root.ensureRainbowNoiseCompiled(e,t)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},kEe=class extends lj{constructor(e,t,i){super(e,t,!1,i),this.isDepthPrepassMaterial=!0,this.cutoffUniform={value:eY},this.colorWrite=!1,this.depthWrite=!0}updateAfterBuild(){super.updateAfterBuild(),this.uniforms.alphaDiscardCutoff=this.cutoffUniform,this.colorWrite=!1,this.depthWrite=!0}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.uniforms=this.uniforms}applyDepthPrepassPolicy(){this.depthPrepass=!1}getDepthPrepassTwin(){return this}},UK=class extends vN{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.depthTwins=[],this.masks={},this.type="NodeMaterial",this.forceRainbowNoise=new Set,this.syntheticMapLayers=new Map,this.updaters=[],this.needsJitter=t.shared.needsJitter,Ys.startContext(this),this.reset0(e,t),Ys.endContext(this)}setTransparent(e,t){let i=this.transparent!==e;if(i){this.transparent=e,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=e,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=e,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||t?.markNeedsUpdateRendererDirty()}getDepthPrepassTwin(e){return Zge(this,this,e)}get nodeMaterial(){return this}getFlavor(e,t,i,r){let n=i?6:(e?3:0)+t;if(n+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),n===0)return this;this.flavors===void 0&&(this.flavors=[]),n-=1;let s=this.flavors[n];return s===void 0&&(s=new lj(e,t,i,this),s.needsJitter=this.needsJitter,this.flavors[n]=s,s.flatShading=e,s.side=t,s.updateAfterBuild(),r&&(s.defines.SHAPEBLEND=r.resolutionLevel,s.defines.SHAPEBLEND_C=r.useChildrenColors?1:0,s.applyDepthPrepassPolicy())),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}ensureRainbowNoiseCompiled(e,t){let i=this.data.layers?.data(e);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(e)&&!Gf(i.noiseStrength)||this.getLayerByUuid(e)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(e),Ys.startContext(this),this.reset0(this.data,this.lastContext),Ys.endContext(this),t!==void 0&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}reset(e,t,i=!1){Ys.startContext(this),(this.data!==e||i)&&this.reset0(e,t),Ys.endContext(this)}reset0(e,t){this.lastContext=t,this.data=e;let i=e.layers??ns.defaultTwoLayerData("phong").layers,r=[];for(let n of i)try{let s=lx.create(this.layerIdGen++,n.id,n.data,t.shared,this.forceRainbowNoise.has(n.id)?{forceRainbowNoise:!0}:void 0);if(s.type==="rainbow"&&s.noiseCompiledIn===!1){let a=n.id;s.onNoiseMismatch=o=>this.ensureRainbowNoiseCompiled(a,o)}r.push(s)}catch(s){console.warn(`[spe] material layer '${n.data.type}' (${n.id}) failed to build \u2014 skipping this layer`,s)}this.layers=r,this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.setTransparent(Sd(e,t.shared),t.scene),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.setTransparent(Sd(this.data,i.shared),i.scene),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],n=e[2];if(r&&n){let s=this.layers.find(a=>a.uuid===r);if(s?.hasValue(n))if(n==="alpha")this.setTransparent(Sd(this.data,i.shared),i.scene),s.setValue(n,Math.max(0,Math.min(Number(t)/100,1)));else{let a=s.getValue(n),o=e[3],l=e[4];if(a instanceof Ri){let u,h=a[o];return typeof h=="number"?u=Number(t):h.isVector2&&(u=h.toArray(),l==="x"?u[0]=Number(t):l==="y"&&(u[1]=Number(t))),void D$({[o]:u},i.shared,s)}(o==="x"||o==="y"||o==="z")&&a.isVector3||(o==="x"||o==="y")&&a.isVector2?a[o]=Number(t):s.setValue(n,t)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"]),i.data.type==="displace"?i.data.displacementType==="noise"?Vo(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],i.data,i.id,e.shared,this.uuid):Vo(["intensity"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="depth"?Vo(["near","far"],["origin","direction"],i.data,i.id,e.shared,this.uuid):i.data.type==="cavity"?Vo(["ridge","valley"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="fresnel"?Vo(["bias","scale","intensity","factor"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="dust"?Vo(["coverage","softness","noiseStrength","noiseScale"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="rainbow"?Vo(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],i.data,i.id,e.shared,this.uuid):i.data.type==="noise"?Vo(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],i.data,i.id,e.shared,this.uuid):i.data.type==="pattern"?Vo(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],i.data,i.id,e.shared,this.uuid):i.data.type==="outline"?Vo(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],i.data,i.id,e.shared,this.uuid):i.data.type==="toon"?Vo(["noiseStrength","noiseScale"],["offset","source"],i.data,i.id,e.shared,this.uuid):i.data.type==="transmission"?Vo(["roughness","thickness","ior"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="texture"||i.data.type==="video"?(Vo([],["size"],i.data,i.id,e.shared,this.uuid),Vo(["rotation"],["repeat","offset"],i.data,i.id,e.shared,this.uuid,["texture"])):i.data.type==="gradient"?Vo(["angle"],["offset","morph"],i.data,i.id,e.shared,this.uuid):i.data.type==="matcap"&&Vo(["rotation"],[],i.data,i.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof ld),this.lightLayer===void 0&&(this.lightLayer=new ld(0,"",{...hs.defaultData("light","phong"),visible:!1},new VB,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();for(let t of this.depthTwins)t.dispose();this.applyTextureMaps(e),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}syntheticMapNode(e,t){let i=this.syntheticMapLayers.get(e);if(i===void 0)try{let n=hs.defaultData("texture"),s={...n,visible:!1,texture:{...n.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],rotation:e.rotation??0,minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}};i=lx.create(this.layerIdGen++,`mapImage${this.layerIdGen}`,s,t),this.syntheticMapLayers.set(e,i)}catch(n){return void console.warn("[spe] light-layer map image failed to build \u2014 skipped",n)}let r=i.color;return r instanceof M4?r:void 0}applyTextureMaps(e){let t=this.layers.find(a=>a instanceof ld);if(!t)return;let i=t.data,r=i.bumpMap,n=i.roughnessMap;t.node.bumpMap=void 0,t.node.roughnessMap=void 0;for(let a of this.syntheticMapLayers.values())a.dispose();this.syntheticMapLayers.clear(),vA.is(r)&&(t.node.bumpMap=this.syntheticMapNode(r,e)),vA.is(n)&&(t.node.roughnessMap=this.syntheticMapNode(n,e));let s=i;!oj&&(s.metalnessMap!==void 0||s.normalMap!==void 0||s.aoMap!==void 0||s.emissiveMap!==void 0||s.roughnessMapChannel!==void 0&&s.roughnessMapChannel!=="luminance"||s.clearcoat!==void 0||s.sheen!==void 0||s.ior!==void 0||s.iridescence!==void 0||s.emissive!==void 0&&typeof s.emissive=="object"&&(s.emissive.r>0||s.emissive.g>0||s.emissive.b>0))&&(oj=!0,console.warn("[spline] this document uses PBR material maps (metalness/normal/AO/emissive), which the classic WebGL pipeline does not render \u2014 the WebGPU renderer shows them"));for(let a=0;a<this.layers.length;++a){let o=this.layers[a];o instanceof Fn&&o.color instanceof M4&&(o.uuid===r&&(t.node.bumpMap=o.color),o.uuid===n&&(t.node.roughnessMap=o.color))}}updateByOp(e,t,i){if(Ys.startContext(this),t!==void 0?this.data=t:t=this.data,this.setTransparent(Sd(t,i.shared),i.scene),e.path[0]==="layers"){let r=i.shared,n=e.path[1];if(n===void 0)i.scene.markNeedsUpdateRendererDirty(),this.reset0(t,i);else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(a=>a.uuid===n);if(s){let a,o=t.layers.data(n);e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&(a="alpha"in e.props?{...e.props,alpha:Oh(e.props.alpha,r,["material",this.uuid,"layer",n,"alpha"])}:{...e.props,alphaOverride:Oh(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...a?{props:a}:{},path:e.path.slice(2)},o,i)&&this.reset0(t,i)}}}else this.reset0(t,i);Ys.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof Fn?t.color.mask=void 0:t instanceof ld&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof Fn&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof ld?r.node.mask=new ql(t.color,t.alpha,ql.MUL):r instanceof Fn&&(r.isMask.value||(r.color.mask=new ql(t.color,t.alpha,ql.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof Fn),t=this.layers.findIndex(i=>i instanceof ld);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let n=this.layers[r];if(n instanceof Fn){if(n.isMask.value)continue;i=new P$(i,n.color,n.alpha,n.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new pn("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof ld);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof Fn){if(r.isMask.value)continue;e=new P$(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof FK);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new ql(t,e[i].position,ql.ADD),t=new ql(t,new xt(.5).setReadonly(!0),ql.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.nodeExtensions.derivatives===!0,e.extensionFragDepth=this.nodeExtensions.fragDepth===!0,e.extensionDrawBuffers=this.nodeExtensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.nodeExtensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,n,s)=>Math.min(Math.max(r,n),s);for(let r of this.layers)if(r.type==="displace"){let n=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=n}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new EK;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.nodeExtensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();for(let t of this.depthTwins)t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose());for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear(),super.dispose();for(let e of this.depthTwins)e.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof Fn){let t=e.params.texture;if(t instanceof zA&&!t.image.loaded)return!1}for(let e of this.syntheticMapLayers.values()){let t=e.params?.texture;if(t instanceof zA&&!t.image.loaded)return!1}return!0}},Object.defineProperties(vN.prototype,{properties:{get:function(){return this.fragment.properties}}})}),XUe=U(()=>{JEe(),VEe=class extends UK{constructor(e,t,i){super(e,t,!1),this.isClassicSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}}}),YUe=U(()=>{Cd(),oe(),hj=`
|
|
11228
11228
|
vec2 receiverPlaneDepthBias(vec3 dcdx, vec3 dcdy)
|
|
11229
11229
|
{
|
|
11230
11230
|
float det = dcdx.x * dcdy.y - dcdx.y * dcdy.x;
|
|
@@ -12902,11 +12902,11 @@ void main() {
|
|
|
12902
12902
|
void main() {
|
|
12903
12903
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
12904
12904
|
gl_FragColor = texel;
|
|
12905
|
-
}`}),eke=new class{constructor(e){this._mesh=new Tr(Jze,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Qze)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}(eCe),Pj=null,Rj=null,tke=Bi.identity(),tCe=class{constructor(e,t,i,r){var n;this.uuid=e,this.width=t,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||NE.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height;this.renderer.dpr=H0e(s,a,this.dpr,this.isScreenSpace),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{if(s.target?.uuid!==void 0){let a=this.frameRoot?.find(s.target.uuid);a&&a.dispatchEvent({...s,target:a})}},this.scene2d=new jK(ht.generateUUID(),GW.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(Pj===null&&(Pj=document.createElement("canvas")),Pj),this.renderer=(n=this.canvas,Rj===null&&(Rj=new Hze(n)),Rj),this.promise=this.init(),this.renderTarget=new yr(1,1,{type:di,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 _X(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(e){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,e.blitTextureToTarget)e.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{eCe.uniforms.tDiffuse.value=this.canvasTexture;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.clear(),eke.render(e),e.setRenderTarget(t)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=e?.width??this.width,i=e?.height??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=tke,this.isScreenSpace&&(this.frameOverride.fill.color=Vr.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},iCe({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(e,t=window.devicePixelRatio){let i=Math.max(1,e?.width??this.width),r=Math.max(1,e?.height??this.height);this.dpr=t,this.width=i,this.height=r,this._innerApplySize();let n=function(s,a,o,l){let u=H0e(s,a,o,l),h=Math.max(o,512/Math.min(s,a)),d=Math.min(h,u);return{width:Math.max(1,Math.ceil(s*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,t,this.isScreenSpace);this.renderTarget.setSize(n.width,n.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(e),this.frameOverride?.requestRender()}applyFrame(e){let t=this.context.scene.find2D(e);if(t&&t instanceof Wc)return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.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(),t}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(e){return this.scene2d.find(e)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(e=>{e.removeEventListener("beginState",this.onFrameOverrideObjectEvent),e.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function iCe({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){if(e instanceof Wc&&t instanceof Wc||e instanceof Gg&&t instanceof Gg)for(let a=0,o=e.children.length;a<o;a++){let l=e.children[a],u=t.children[a];l&&u&&l.uuid===u.uuid&&ike({objectOverride:l,objectRoot:u,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s})}}function ike({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){let[a,o]=function(d){if(Dj(d))return[d.width,d.height];if(d instanceof N4){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof Gg){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(t),{width:l,height:u,position:h}=JAe({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=h,e.data={...e.data,position:h},e.states)for(let d in e.states)rke({stateId:d,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s});if(Dj(e)||e instanceof Gg)Dj(e)&&(e.width=l,e.height=u,e.data={...e.data,width:l,height:u}),iCe({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:o});else if(e instanceof N4){let d=t,c=a!==0?l/a:1,p=o!==0?u/o:1;e.path=function(f,m=1,g=1){if(m<=0||g<=0)return f;if(ZAe(f))return console.warn("Cannot scale invalid path",f),Cj([]);if(m===1&&g===1)return f;try{return Cj((0,Zze.parseSVG)(f).map(v=>{let y={...v};return"x"in y&&(y.x=y.x*m),"y"in y&&(y.y=y.y*g),"x1"in y&&(y.x1=y.x1*m),"x2"in y&&(y.x2=y.x2*m),"y1"in y&&(y.y1=y.y1*g),"y2"in y&&(y.y2=y.y2*g),"rx"in y&&(y.rx=y.rx*m),"ry"in y&&(y.ry=y.ry*g),y}))}catch(v){return console.warn("Error parsing SVG path",v),Cj([])}}(d.path,c,p),e.data={...e.data,path:e.path}}}function rke({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a}){let o=t.states?.[e],l=i.states?.[e];if(o&&l){let{width:u,height:h,position:d}=JAe({constraints:t.data,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:yy.isResizeable(l)?l.width:0,objectInitialHeight:yy.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:d}),yy.isResizeable(o)&&Object.assign(t.states[e],{width:u,height:h})}}function Dj(e){return e instanceof rC||e instanceof Wc||e instanceof VK||e instanceof GK}dB();var q0e,nke=class extends Un{constructor(e,t,i){super(e,t,i),this.isUIObject=!0,this.uiCanvas=new tCe(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=e?.width??this.dataPatched.geometry.width,r=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Ng(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.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,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Jr(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t);let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Ng(i,t,this.data.flatShading,this)}};_r(),yw("UIGeometry",(e,t,i)=>new nke(e,t,i)),iB=q0e={Scene2D:jK,UICanvas:tCe,loadHanaUIRUNTIME:function(){return P4||(P4=async()=>async function(e,t){return await e.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(e.Engine.prototype,"scene")||Object.defineProperty(e.Engine.prototype,"scene",{get:function(){let i=Object.create(e.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>e.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(()=>(xQ(),bQ)),D0e??function(){let e=typeof process<"u"?"2.0.80":void 0;return`https://cdn.spline.design/@splinetool/runtime${e?`@${e}`:""}/build/hana-ui.wasm`}())),YAe().then(()=>{})},setHanaUIWasmUrl:function(e){D0e=e}},NL!==null&&q0e.setHanaUIWasmUrl(NL),Nn("ui-2d"),VY(),bxe(),oe();var rCe,Nj,ske=class{constructor(){this.type="ShapePath",this.color=new ot,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new vE,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,s){return this.currentPath?.bezierCurveTo(e,t,i,r,n,s),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={loc:0,t:0};function t(u,h,d,c){let p=u.x,f=h.x,m=d.x,g=c.x,v=u.y,y=h.y,_=d.y,b=c.y,x=(g-m)*(v-_)-(b-_)*(p-m),w=(b-_)*(f-p)-(g-m)*(y-v),S=x/w,T=((f-p)*(v-_)-(y-v)*(p-m))/w;if(w===0&&x!==0||S<=0||S>=1||T<0||T>1)return null;if(x===0&&w===0){for(let M=0;M<2;M++){if(i(M===0?d:c,u,h),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}if(e.loc===2)return{x:+(p+e.t*(f-p)).toPrecision(10),y:+(v+e.t*(y-v)).toPrecision(10),t:e.t}}return null}for(let M=0;M<2;M++)if(i(M===0?d:c,u,h),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}return{x:+(p+S*(f-p)).toPrecision(10),y:+(v+S*(y-v)).toPrecision(10),t:S}}function i(u,h,d){let c,p=d.x-h.x,f=d.y-h.y,m=u.x-h.x,g=u.y-h.y,v=p*g-m*f;return u.x===h.x&&u.y===h.y?(e.loc=0,void(e.t=0)):u.x===d.x&&u.y===d.y?(e.loc=1,void(e.t=1)):void(v<-Number.EPSILON?e.loc=3:v>Number.EPSILON?e.loc=4:p*m<0||f*g<0?e.loc=5:Math.sqrt(p*p+f*f)<Math.sqrt(m*m+g*g)?e.loc=6:(c=p!==0?m/p:g/f,e.loc=2,e.t=c))}let r=0,n=999999999,s=-999999999,a=[];this.subPaths.forEach(u=>{let h=u.getPoints(),d=-999999999,c=999999999,p=-999999999,f=999999999;for(let m=0;m<h.length;m++){let g=h[m];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<f&&(f=g.x)}s<=p&&(s=p+1),n>=f&&(n=f-1),h.length&&a.push({curves:u.curves,points:h,isCW:z7.isClockWise(h),identifier:r++,boundingBox:new AX(new Z(f,c),new Z(p,d))})});let o=a.map(u=>function(h,d,c,p,f){(f==null||f==="")&&(f="nonzero");let m=new Z;h.boundingBox.getCenter(m);let g=function(w,S,T){let M=new Z;S.getCenter(M);let E=[];return T.forEach(A=>{A.boundingBox.containsPoint(M)&&function(P,N){let D=[],O=[];for(let z=1;z<P.length;z++){let L=P[z-1],V=P[z];for(let G=1;G<N.length;G++){let Y=t(L,V,N[G-1],N[G]);Y!==null&&D.find($=>$.t<=Y.t+Number.EPSILON&&$.t>=Y.t-Number.EPSILON)===void 0&&(D.push(Y),O.push(new Z(Y.x,Y.y)))}}return O}(w,A.points).forEach(P=>{E.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),E.sort((A,P)=>A.point.x-P.point.x),E}([new Z(c,m.y),new Z(p,m.y)],h.boundingBox,d);g.sort((w,S)=>w.point.x-S.point.x);let v=[],y=[];g.forEach(w=>{w.identifier===h.identifier?v.push(w):y.push(w)});let _=v[0].point.x,b=[],x=0;for(;x<y.length&&y[x].point.x<_;)b.length>0&&b[b.length-1]===y[x].identifier?b.pop():b.push(y[x].identifier),x++;if(b.push(h.identifier),f==="evenodd"){let w=b.length%2==0,S=b[b.length-2];return{identifier:h.identifier,isHole:w,for:S}}if(f==="nonzero"){let w=!0,S=null,T=null;for(let M=0;M<b.length;M++){let E=b[M];d[E]&&(w?(T=d[E].isCW,w=!1,S=E):T!==d[E].isCW&&(T=d[E].isCW,w=!0))}return{identifier:h.identifier,isHole:w,for:S}}console.warn('fill-rule: "'+f+'" is currently not implemented.')}(u,a,n,s,this.userData?.style.fillRule)),l=[];return a.forEach(u=>{let h=o[u.identifier];if(h&&!h.isHole){let d=new oA;d.curves=u.curves,o.filter(c=>c?.isHole&&c.for===u.identifier).forEach(c=>{if(c){let p=a[c.identifier],f=new vE;f.curves=p.curves,d.holes.push(f)}}),l.push(d)}}),l}},nCe=!1,$0e=new Promise(e=>{rCe=e}),X0e=!1;function Y0e(){if(nCe=!0,!X0e)return Nj||(Nj=async function(){let e=await import("./opentype.js");rCe(e),X0e=!0}(),Nj)}var ake=new class{async load(e,t,i=()=>{}){let{load:r}=await $0e;r(e,(n,s)=>{n||!s?i(n??"Something went wrong"):t(s)})}async parse(e){let{parse:t,Bidi:i}=await $0e;try{let r=t(e),n=new i,s=a=>r.charToGlyphIndex(a.char);return n.registerModifier("glyphIndex",null,s),n.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:n}}catch(r){console.error(r)}}};function oke(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}oe(),cY(),_r(),yw("TextGeometry",(e,t,i)=>new _B(e,t,i));var K0e={create:(e,t)=>new fH(e,t)};HW("TextGeometry",K0e),HW("InputGeometry",K0e),dY=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}async load(e){try{this._layoutErrorWarned=!1;let t=await async function(i){let r,n,s=!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),n=i.url,s=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!nCe)return{font:void 0,url:n,intercepted:s,arr:r,bidi:null};{let a=await ake.parse(r);if(a)return{font:a.font,url:n,intercepted:s,arr:r,bidi:a.bidi}}}}(e);t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)}catch(t){console.warn(`Could not load the font "${e.url??"(inline data)"}"`,t)}}warnLayoutError(e){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,e))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let n=r.tokenizer.tokens,s=[],a=0,o=i.length===n.length;for(let l=0;l<i.length;l++){let u=i[l].index,h=String.fromCharCode(i[l].unicode),d=n[a];if(oke(u,d)||o)s.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",f=[d.state.glyphIndex],m=[],g=!1;for(;!g;)a++,p=t.charAt(a),c+=p,f.push(e.charToGlyphIndex(p)),m=e.stringToGlyphs(c),m.length===1&&m[0].index===u&&(g=!0),a>t.length&&(g=!0);s.push({char:h,index:u,replacements:f,replacementChars:Array.from(c)}),a++}}return s}generateShapes(e,t,i){if(!this._isLoaded)return;let r=this.font,n=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,a=e.map(v=>this.getTextWidth(v,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,u=this.getCharWidth(`
|
|
12905
|
+
}`}),eke=new class{constructor(e){this._mesh=new Tr(Jze,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Qze)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}(eCe),Pj=null,Rj=null,tke=Bi.identity(),tCe=class{constructor(e,t,i,r){var n;this.uuid=e,this.width=t,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||NE.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height;this.renderer.dpr=H0e(s,a,this.dpr,this.isScreenSpace),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{if(s.target?.uuid!==void 0){let a=this.frameRoot?.find(s.target.uuid);a&&a.dispatchEvent({...s,target:a})}},this.scene2d=new jK(ht.generateUUID(),GW.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(Pj===null&&(Pj=document.createElement("canvas")),Pj),this.renderer=(n=this.canvas,Rj===null&&(Rj=new Hze(n)),Rj),this.promise=this.init(),this.renderTarget=new yr(1,1,{type:di,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 _X(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(e){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,e.blitTextureToTarget)e.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{eCe.uniforms.tDiffuse.value=this.canvasTexture;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.clear(),eke.render(e),e.setRenderTarget(t)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=e?.width??this.width,i=e?.height??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=tke,this.isScreenSpace&&(this.frameOverride.fill.color=Vr.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},iCe({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(e,t=window.devicePixelRatio){let i=Math.max(1,e?.width??this.width),r=Math.max(1,e?.height??this.height);this.dpr=t,this.width=i,this.height=r,this._innerApplySize();let n=function(s,a,o,l){let u=H0e(s,a,o,l),h=Math.max(o,512/Math.min(s,a)),d=Math.min(h,u);return{width:Math.max(1,Math.ceil(s*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,t,this.isScreenSpace);this.renderTarget.setSize(n.width,n.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(e),this.frameOverride?.requestRender()}applyFrame(e){let t=this.context.scene.find2D(e);if(t&&t instanceof Wc)return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.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(),t}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(e){return this.scene2d.find(e)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(e=>{e.removeEventListener("beginState",this.onFrameOverrideObjectEvent),e.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function iCe({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){if(e instanceof Wc&&t instanceof Wc||e instanceof Gg&&t instanceof Gg)for(let a=0,o=e.children.length;a<o;a++){let l=e.children[a],u=t.children[a];l&&u&&l.uuid===u.uuid&&ike({objectOverride:l,objectRoot:u,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s})}}function ike({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){let[a,o]=function(d){if(Dj(d))return[d.width,d.height];if(d instanceof N4){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof Gg){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(t),{width:l,height:u,position:h}=JAe({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=h,e.data={...e.data,position:h},e.states)for(let d in e.states)rke({stateId:d,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s});if(Dj(e)||e instanceof Gg)Dj(e)&&(e.width=l,e.height=u,e.data={...e.data,width:l,height:u}),iCe({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:o});else if(e instanceof N4){let d=t,c=a!==0?l/a:1,p=o!==0?u/o:1;e.path=function(f,m=1,g=1){if(m<=0||g<=0)return f;if(ZAe(f))return console.warn("Cannot scale invalid path",f),Cj([]);if(m===1&&g===1)return f;try{return Cj((0,Zze.parseSVG)(f).map(v=>{let y={...v};return"x"in y&&(y.x=y.x*m),"y"in y&&(y.y=y.y*g),"x1"in y&&(y.x1=y.x1*m),"x2"in y&&(y.x2=y.x2*m),"y1"in y&&(y.y1=y.y1*g),"y2"in y&&(y.y2=y.y2*g),"rx"in y&&(y.rx=y.rx*m),"ry"in y&&(y.ry=y.ry*g),y}))}catch(v){return console.warn("Error parsing SVG path",v),Cj([])}}(d.path,c,p),e.data={...e.data,path:e.path}}}function rke({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a}){let o=t.states?.[e],l=i.states?.[e];if(o&&l){let{width:u,height:h,position:d}=JAe({constraints:t.data,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:yy.isResizeable(l)?l.width:0,objectInitialHeight:yy.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:d}),yy.isResizeable(o)&&Object.assign(t.states[e],{width:u,height:h})}}function Dj(e){return e instanceof rC||e instanceof Wc||e instanceof VK||e instanceof GK}dB();var q0e,nke=class extends Un{constructor(e,t,i){super(e,t,i),this.isUIObject=!0,this.uiCanvas=new tCe(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=e?.width??this.dataPatched.geometry.width,r=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Ng(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.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,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Jr(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t);let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Ng(i,t,this.data.flatShading,this)}};_r(),yw("UIGeometry",(e,t,i)=>new nke(e,t,i)),iB=q0e={Scene2D:jK,UICanvas:tCe,loadHanaUIRUNTIME:function(){return P4||(P4=async()=>async function(e,t){return await e.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(e.Engine.prototype,"scene")||Object.defineProperty(e.Engine.prototype,"scene",{get:function(){let i=Object.create(e.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>e.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(()=>(xQ(),bQ)),D0e??function(){let e=typeof process<"u"?"2.0.82":void 0;return`https://cdn.spline.design/@splinetool/runtime${e?`@${e}`:""}/build/hana-ui.wasm`}())),YAe().then(()=>{})},setHanaUIWasmUrl:function(e){D0e=e}},NL!==null&&q0e.setHanaUIWasmUrl(NL),Nn("ui-2d"),VY(),bxe(),oe();var rCe,Nj,ske=class{constructor(){this.type="ShapePath",this.color=new ot,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new vE,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,s){return this.currentPath?.bezierCurveTo(e,t,i,r,n,s),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={loc:0,t:0};function t(u,h,d,c){let p=u.x,f=h.x,m=d.x,g=c.x,v=u.y,y=h.y,_=d.y,b=c.y,x=(g-m)*(v-_)-(b-_)*(p-m),w=(b-_)*(f-p)-(g-m)*(y-v),S=x/w,T=((f-p)*(v-_)-(y-v)*(p-m))/w;if(w===0&&x!==0||S<=0||S>=1||T<0||T>1)return null;if(x===0&&w===0){for(let M=0;M<2;M++){if(i(M===0?d:c,u,h),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}if(e.loc===2)return{x:+(p+e.t*(f-p)).toPrecision(10),y:+(v+e.t*(y-v)).toPrecision(10),t:e.t}}return null}for(let M=0;M<2;M++)if(i(M===0?d:c,u,h),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}return{x:+(p+S*(f-p)).toPrecision(10),y:+(v+S*(y-v)).toPrecision(10),t:S}}function i(u,h,d){let c,p=d.x-h.x,f=d.y-h.y,m=u.x-h.x,g=u.y-h.y,v=p*g-m*f;return u.x===h.x&&u.y===h.y?(e.loc=0,void(e.t=0)):u.x===d.x&&u.y===d.y?(e.loc=1,void(e.t=1)):void(v<-Number.EPSILON?e.loc=3:v>Number.EPSILON?e.loc=4:p*m<0||f*g<0?e.loc=5:Math.sqrt(p*p+f*f)<Math.sqrt(m*m+g*g)?e.loc=6:(c=p!==0?m/p:g/f,e.loc=2,e.t=c))}let r=0,n=999999999,s=-999999999,a=[];this.subPaths.forEach(u=>{let h=u.getPoints(),d=-999999999,c=999999999,p=-999999999,f=999999999;for(let m=0;m<h.length;m++){let g=h[m];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<f&&(f=g.x)}s<=p&&(s=p+1),n>=f&&(n=f-1),h.length&&a.push({curves:u.curves,points:h,isCW:z7.isClockWise(h),identifier:r++,boundingBox:new AX(new Z(f,c),new Z(p,d))})});let o=a.map(u=>function(h,d,c,p,f){(f==null||f==="")&&(f="nonzero");let m=new Z;h.boundingBox.getCenter(m);let g=function(w,S,T){let M=new Z;S.getCenter(M);let E=[];return T.forEach(A=>{A.boundingBox.containsPoint(M)&&function(P,N){let D=[],O=[];for(let z=1;z<P.length;z++){let L=P[z-1],V=P[z];for(let G=1;G<N.length;G++){let Y=t(L,V,N[G-1],N[G]);Y!==null&&D.find($=>$.t<=Y.t+Number.EPSILON&&$.t>=Y.t-Number.EPSILON)===void 0&&(D.push(Y),O.push(new Z(Y.x,Y.y)))}}return O}(w,A.points).forEach(P=>{E.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),E.sort((A,P)=>A.point.x-P.point.x),E}([new Z(c,m.y),new Z(p,m.y)],h.boundingBox,d);g.sort((w,S)=>w.point.x-S.point.x);let v=[],y=[];g.forEach(w=>{w.identifier===h.identifier?v.push(w):y.push(w)});let _=v[0].point.x,b=[],x=0;for(;x<y.length&&y[x].point.x<_;)b.length>0&&b[b.length-1]===y[x].identifier?b.pop():b.push(y[x].identifier),x++;if(b.push(h.identifier),f==="evenodd"){let w=b.length%2==0,S=b[b.length-2];return{identifier:h.identifier,isHole:w,for:S}}if(f==="nonzero"){let w=!0,S=null,T=null;for(let M=0;M<b.length;M++){let E=b[M];d[E]&&(w?(T=d[E].isCW,w=!1,S=E):T!==d[E].isCW&&(T=d[E].isCW,w=!0))}return{identifier:h.identifier,isHole:w,for:S}}console.warn('fill-rule: "'+f+'" is currently not implemented.')}(u,a,n,s,this.userData?.style.fillRule)),l=[];return a.forEach(u=>{let h=o[u.identifier];if(h&&!h.isHole){let d=new oA;d.curves=u.curves,o.filter(c=>c?.isHole&&c.for===u.identifier).forEach(c=>{if(c){let p=a[c.identifier],f=new vE;f.curves=p.curves,d.holes.push(f)}}),l.push(d)}}),l}},nCe=!1,$0e=new Promise(e=>{rCe=e}),X0e=!1;function Y0e(){if(nCe=!0,!X0e)return Nj||(Nj=async function(){let e=await import("./opentype.js");rCe(e),X0e=!0}(),Nj)}var ake=new class{async load(e,t,i=()=>{}){let{load:r}=await $0e;r(e,(n,s)=>{n||!s?i(n??"Something went wrong"):t(s)})}async parse(e){let{parse:t,Bidi:i}=await $0e;try{let r=t(e),n=new i,s=a=>r.charToGlyphIndex(a.char);return n.registerModifier("glyphIndex",null,s),n.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:n}}catch(r){console.error(r)}}};function oke(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}oe(),cY(),_r(),yw("TextGeometry",(e,t,i)=>new _B(e,t,i));var K0e={create:(e,t)=>new fH(e,t)};HW("TextGeometry",K0e),HW("InputGeometry",K0e),dY=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}async load(e){try{this._layoutErrorWarned=!1;let t=await async function(i){let r,n,s=!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),n=i.url,s=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!nCe)return{font:void 0,url:n,intercepted:s,arr:r,bidi:null};{let a=await ake.parse(r);if(a)return{font:a.font,url:n,intercepted:s,arr:r,bidi:a.bidi}}}}(e);t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)}catch(t){console.warn(`Could not load the font "${e.url??"(inline data)"}"`,t)}}warnLayoutError(e){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,e))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let n=r.tokenizer.tokens,s=[],a=0,o=i.length===n.length;for(let l=0;l<i.length;l++){let u=i[l].index,h=String.fromCharCode(i[l].unicode),d=n[a];if(oke(u,d)||o)s.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",f=[d.state.glyphIndex],m=[],g=!1;for(;!g;)a++,p=t.charAt(a),c+=p,f.push(e.charToGlyphIndex(p)),m=e.stringToGlyphs(c),m.length===1&&m[0].index===u&&(g=!0),a>t.length&&(g=!0);s.push({char:h,index:u,replacements:f,replacementChars:Array.from(c)}),a++}}return s}generateShapes(e,t,i){if(!this._isLoaded)return;let r=this.font,n=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,a=e.map(v=>this.getTextWidth(v,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,u=this.getCharWidth(`
|
|
12906
12906
|
`,t),h=t.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(a[0],o,t.horizontalAlign,e[0],u),c=this.getLineInitialOffsetY(s,e.length,l,n,t.verticalAlign),p=[],f=e.map(()=>[]),m=e.map(()=>[]);for(let v=0;v<e.length;v++){let y=e[v],_={features:{liga:!0},letterSpacing:t.letterSpacing},b=[];try{b=r.stringToGlyphs(y,_)}catch(M){this.warnLayoutError(M)}d=this.getLineInitialOffsetX(a[v],o,t.horizontalAlign,y,u);let x=[];try{x=this.reverseLigaturesTable(r,y,b)}catch(M){this.warnLayoutError(M)}let w=this.computeSpaceWidthForLine(e,v,t,i),S=0,T=b[0];T&&t.horizontalAlign===2&&T.leftSideBearing!==void 0&&(d-=T.leftSideBearing*n);try{this.font?.forEachGlyph(y,d,c,t.fontSize,_,(M,E,A,P,N)=>{let D=M.index===0?`
|
|
12907
12907
|
`:M.unicode?String.fromCharCode(M.unicode):void 0,O=x[S],z=0;if(D===`
|
|
12908
12908
|
`)z=h;else if(D===" ")z=w;else{let L=this.createPath(M,n,E,A,t);L&&(z=L.offsetX,p.push(L.path))}if(O&&O.replacements.length!==1){let L=O.replacements.map($=>(r.glyphs.get($).advanceWidth??0)*n),V=L.reduce(($,Q)=>$+Q,0),G=L.map($=>$/V),Y=E;for(let $=0;$<G.length;$++){let Q=z*G[$];m[v].push([Y,A]),f[v].push(Q),Y+=Q}}else m[v].push([E,A]),f[v].push(z);S++})}catch(M){this.warnLayoutError(M)}c-=s}let g=[];for(let v=0,y=p.length;v<y;v++)g.push(...p[v].toShapes());return{shapes:g,charWidths:f,lineWidths:a,charCoords:m}}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(e,t,i,r,n){return(i===3||i===2)&&r.indexOf(`
|
|
12909
|
-
`)>=0&&(e-=n),i===3?.5*t-.5*e:i===2?t-e:0}getLineInitialOffsetY(e,t,i,r,n){let s=t*e,a=e-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return n===3?-(i-s-o):n===2?-(.5*i-.5*s-o):o}createPath(e,t,i,r,n){let s=e.getPath(i,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");let a=new ske,o=(e.advanceWidth??1)*t;if(e)for(let l of s.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 wh)return d.v1;if(d instanceof pu||d instanceof uf)return d.v0}}(l.curves);u!==void 0&&l.currentPoint.distanceTo(u)>0&&l.lineTo(u.x,u.y)}),{offsetX:o,path:a}}getCharWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(e,t,i,r){let n=this.getCharWidth(" ",i),s=e[t];if(s){let a=this.countSpaces(s.trimEnd());if(i.horizontalAlign===4&&t<e.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-a*n))/a}return n}countSpaces(e){return(e.match(/ /g)||[]).length}},Nn("text"),jt();var sCe=null;function Z0e(){return sCe}function lke(e){let t=!1;return e.scene.objects.forEach(i=>{i.data.type==="Page"&&!t&&i.data.publish.gameControlObject&&e1.traverseModuleInstances(e,i.id,(r,n,s)=>{for(let a of s)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(t=!0)})}),t}Gr();var RN=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},Ij=e=>e*(Math.PI/180),DN=new Map,I4=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.addEventListener?e.addEventListener(r,i,!1):e.attachEvent&&e.attachEvent(r,i)},O4=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.removeEventListener?e.removeEventListener(r,i):e.detachEvent&&e.detachEvent(r,i)},aCe=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),Q0e=()=>{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}},Oj=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},Lj=(e,t,i)=>{let r=oCe(e);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+i;else{let s="";for(let a=0,o=t.length;a<o;a+=1)s+=t[a]+" "+i+", ";r[n]=s.slice(0,-2)}return r},oCe=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},Bj=(e,t)=>{for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},G$=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)};typeof window<"u"&&(lCe="ontouchstart"in window,hCe=!!window.PointerEvent,uCe=!!window.MSPointerEvent);var lCe,hCe,uCe,nb,J0e={start:"mousedown",move:"mousemove",end:"mouseup"},J2={};function zv(){}hCe?nb={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:uCe?nb={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:lCe?(nb={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},J2=J0e):nb=J0e,zv.prototype.on=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(t);return r},zv.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i},zv.prototype.trigger=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},t)})},zv.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=((i,r)=>{let n={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&Object.prototype.hasOwnProperty.call(r,s)?n[s]=r[s]:Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s]);return n})(t.options,e))},zv.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},I4(e,nb[t],i._domHandlers_[t]),J2[t]&&I4(e,J2[t],i._domHandlers_[t]),i},zv.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},O4(e,nb[t],i._domHandlers_[t]),J2[t]&&O4(e,J2[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var WK=zv;function xa(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,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(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=xa.id,xa.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}xa.prototype=new WK,xa.constructor=xa,xa.id=0,xa.prototype.buildEl=function(e){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},xa.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=(()=>{let n=oCe("borderRadius");for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]="50%");return n})(),i=Lj("transition","opacity",e),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)"},Bj(r.el,i),this.options.shape==="circle"&&Bj(r.back,t),Bj(r.front,t),this.applyStyles(r),this},xa.prototype.applyStyles=function(e){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this},xa.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},xa.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},xa.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},xa.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t},xa.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t},xa.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",n={};n.front=Lj("transition",["top","left"],r);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(n),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)},xa.prototype.restCallback=function(){var e=this,t={};t.front=Lj("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)},xa.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},xa.prototype.computeDirection=function(e){var t,i,r,n=e.angle.radian,s=Math.PI/4,a=Math.PI/2;if(n>s&&n<3*s&&!e.lockX?t="up":n>-s&&n<=s&&!e.lockY?t="left":n>3*-s&&n<=-s&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(i=n>-a&&n<a?"left":"right"),e.lockX||(r=n>0?"up":"down"),e.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:t},e.direction=this.direction,l)l[o]===this.direction[o]&&(u[o]=!0);if(u.x&&u.y&&u.angle)return e;(!u.x||!u.y)&&this.trigger("plain",e),u.x||this.trigger("plain:"+i,e),u.y||this.trigger("plain:"+r,e),u.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var hke=xa;function qs(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=qs.id,qs.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(t),(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}qs.prototype=new WK,qs.constructor=qs,qs.id=0,qs.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===i)return t[r];return!1}},qs.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"},qs.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}},qs.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,n={},s=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(e.x&&e.y)n={x:e.x-a,y:e.y-o};else if(e.top||e.right||e.bottom||e.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=e.top,l.style.right=e.right,l.style.bottom=e.bottom,l.style.left=e.left,l.style.position="absolute",s.zone.appendChild(l);var u=l.getBoundingClientRect();s.zone.removeChild(l),n=e,e={x:u.left+r.x,y:u.top+r.y}}var h=new hke(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:e,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Oj(h.ui.el,n),Oj(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},qs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},qs.prototype.bindNipple=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},qs.prototype.pressureFn=function(e,t,i){var r=this,n=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var s=e.force||e.pressure||e.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)},qs.prototype.onstart=function(e){var t=this,i=t.options,r=e;return e=aCe(e),t.updateBox(),G$(e,function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(s){if(Object.values(r.touches).findIndex(function(o){return o.identifier===s})<0){var a=[e[0]];a.identifier=s,t.processOnEnd(a)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))}),t.manager.bindDocument(),!1},qs.prototype.processOnStart=function(e){var t,i=this,r=i.options,n=i.manager.getIdentifier(e),s=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=i.getOrCreate(n,a);o.identifier!==n&&i.manager.removeIdentifier(o.identifier),o.identifier=n;var l=function(u){u.trigger("start",u),i.trigger("start "+u.id+":start",u),u.show(),s>0&&i.pressureFn(e,u,u.identifier),i.processOnMove(e)};if((t=i.idles.indexOf(o))>=0&&i.idles.splice(t,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(RN(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(e);l(o)}return o},qs.prototype.getOrCreate=function(e,t){var i,r=this,n=r.options;return/(semi|static)/.test(n.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):n.mode==="semi"?r.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(t,e)},qs.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.scroll;if((_=>isNaN(_.buttons)?_.pressure!==0:_.buttons!==0)(e)){if(!n)return console.error("Found zombie joystick with ID "+r),void t.manager.removeIdentifier(r);if(i.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:s.x+a.left,y:s.y+a.top}}n.identifier=r;var o=n.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=n.position.y),i.lockY&&(l.x=n.position.x);var u,h,d=RN(l,n.position),c=((_,b)=>{let x=b.x-_.x,w=b.y-_.y;return(S=>S*(180/Math.PI))(Math.atan2(w,x))})(l,n.position),p=Ij(c),f=d/o,m={distance:d,position:l};if(n.options.shape==="circle"?(u=Math.min(d,o),h=((_,b,x)=>{let w={x:0,y:0};return x=Ij(x),w.x=_.x-b*Math.cos(x),w.y=_.y-b*Math.sin(x),w})(n.position,u,c)):(h=((_,b,x)=>({x:Math.min(Math.max(_.x,b.x-x),b.x+x),y:Math.min(Math.max(_.y,b.y-x),b.y+x)}))(l,n.position,o),u=RN(h,n.position)),i.follow){if(d>o){let _=l.x-h.x,b=l.y-h.y;n.position.x+=_,n.position.y+=b,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",d=RN(l,n.position)}}else l=h,d=u;var g=l.x-n.position.x,v=l.y-n.position.y;n.frontPosition={x:g,y:v},i.dataOnly||Oj(n.ui.front,n.frontPosition);var y={identifier:n.identifier,position:l,force:f,pressure:e.force||e.pressure||e.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-v/o},raw:m,instance:n,lockX:i.lockX,lockY:i.lockY};(y=n.computeDirection(y)).angle={radian:Ij(180-c),degree:180-c},n.trigger("move",y),t.trigger("move "+n.id+":move",y)}else this.processOnEnd(e)},qs.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(i.dataOnly||n.hide(function(){i.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(i.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[s.id]=s.identifier))},qs.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()},qs.prototype.destroy=function(){var e=this;for(var t in e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()}),e.pressureIntervals)Object.prototype.hasOwnProperty.call(e.pressureIntervals,t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off(),e.pressureIntervals={},e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.manager=null};var uke=qs;function ia(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Q0e(),t._windowBound=!1,t.config(e),t.prepareCollections();var i=function(){var r;t.collections.forEach(function(n){n.forEach(function(s){r=s.el.getBoundingClientRect(),s.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){(r=>{DN.has(r)&&clearTimeout(DN.get(r)),DN.set(r,setTimeout(function(){DN.delete(r),r()},100))})(i)},t._onScroll=function(){t.scroll=Q0e()},t.collections}ia.prototype=new WK,ia.constructor=ia,ia.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return!(i=r.get(t))}),i}},ia.prototype.create=function(e){return this.createCollection(e)},ia.prototype.bindWindowEvents=function(){var e=this;e._windowBound||typeof window>"u"||(e._windowBound=!0,I4(window,"resize",e._onResize),I4(window,"scroll",e._onScroll))},ia.prototype.unbindWindowEvents=function(){var e=this;!e._windowBound||typeof window>"u"||(e._windowBound=!1,O4(window,"resize",e._onResize),O4(window,"scroll",e._onScroll))},ia.prototype.createCollection=function(e){var t=this,i=new uke(t,e);return t.bindCollection(i),t.collections.push(i),t.bindWindowEvents(),i},ia.prototype.bindCollection=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},ia.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)},ia.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)},ia.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier)===void 0&&(t=this.latest||0):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},ia.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t},ia.prototype.onmove=function(e){return this.onAny("move",e),!1},ia.prototype.onend=function(e){return this.onAny("end",e),!1},ia.prototype.oncancel=function(e){return this.onAny("end",e),!1},ia.prototype.onAny=function(e,t){var i,r=this,n="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=aCe(t);var s=function(a,o,l){l.ids.indexOf(o)>=0&&(l[n](a),a._found_=!0)};return G$(t,function(a){i=r.getIdentifier(a),G$(r.collections,s.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},ia.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.unbindWindowEvents(),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.collections=[],e.off()},ia.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1),i.collections.length===0&&i.unbindWindowEvents()};var dke=ia,Vx=null;function eve(){return Vx||(Vx=new dke),Vx}var cke={create:function(e){return eve().create(e)},destroy:function(){Vx&&(Vx.destroy(),Vx=null)},get factory(){return eve()}},pke=cke;Gr(),jt(),oe(),Ih(),xl(),jt();var dCe=null;function Fj(){return dCe}var cCe,Uj,fke=new Promise(e=>{cCe=e});function mke(e){return Uj||(Uj=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build",i=import("./physics.js"),[r,n]=await Promise.all([i,fetch(`${t}/physics.wasm`).then(s=>s.arrayBuffer())]);await r.init(n),cCe(r)}(),Uj)}function pCe(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||n<l||s<l||a<l||o<l}function of(e,t){let i=new At;if(t&&pCe(t))return i.setAttribute("position",new Et([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new Et([],3)),i.setIndex([]),i;let{positions:r,triIndices:n}=wY(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Et(r,3)),i.setIndex(n),t&&i.applyMatrix4(t),i}ss(),xl(),_r(),UY(),oe(),oe(),bw(),GA();var Er,gke=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target}disconnect(){Za(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>t.play()),this.actions.Animation.forEach(t=>{"runMode"in t.data&&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.Reset.forEach(t=>{t.dispatch()}),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(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},tve=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target,this.triggeringObjects=[];for(let a of t.triggeringObjects){let o=r.scene.find(a);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(e){return this.target==="all"||this.triggeringObjects.some(t=>t===e||t.isAncestorOf(e.uuid)||e.isAncestorOf(t.uuid))}disconnect(){Za(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.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(!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}};ss(),fke.then(e=>Er=e);var ta=new R,au=new kt,Km=new R,ive=(new Kr(0,0,0,"YXZ"),new Kr(0,0,0,"XYZ")),Yu=new R,zj=new R,kj=new R(1,1,1),sb=new kt,NN=new Ue,rve=new Ue,vke={type:"updateMatrix"},nve=new kt,Vj=new qa,Gj=.01,j$={type:"beginEvent",eventName:"Collision"},yke={type:"beginEvent",eventName:"Trigger"},L4=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);function ab(e){return function(t){return typeof t=="object"&&t!==null&&"booleanOp"in t}(Jv(e)?e.object:e)}var _ke=class{constructor(e){this.eventContext=e,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=t=>{if(t.bodyType()!==Er.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[i,r,n]=this.rigidBodyToMesh.get(t.handle);if(ta.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),au.copy(t.rotation()),i.matrixWorld.compose(ta,au,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(vke),n){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let a of s.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,i,r)=>{if(r===!1)return;let n,s;if(this.sensorToTriggerEvent[t]?(n=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(n=this.sensorToTriggerEvent[i],s=this.sharedGameControlGlobals.colliderToEntity.get(t)),n&&s&&n.isValidTriggeringObject(s))n.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===t||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(t)){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(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,t)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let h of o)h.data.target==="scene"&&this.dispatchCollisionEvent(h,a,t);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=e.isExport,this.sharedAssets=e.sharedAssets,this.renderer=e.renderer,this.requestRender=e.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(e=>{let t=e.dataPatched;for(let i of t.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(n=>n.data.type==="Destroy")?.data;if(r)for(let n of r.objects){let s=this.page.scene.find(n);s&&(s.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let i of t.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let n=this.page.scene.find(r);n&&(n.userData.hasDrag=!0)}})}_staticBVHIdOf(e){let t=this._staticBVHAttrIds.get(e);return t===void 0&&(t=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(e,t)),t}initBVH(){if(Fj()===null)return void Ma("collision-bvh","trigger/collision detection");let e=[],t=[];if(this.page.traverseChildren(i=>{let r,n=i instanceof Rx,s=ME(i);if(ex(i)||n||s)return;r=Jv(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(L4(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){e.push({geometry:o,matrixWorld:i.matrixWorld}),t.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)t.push(d)}}return!!ab(i)||void 0}),e.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===t.length&&i.signature.every((s,a)=>s===t[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=Qv(e.map(s=>of(s.geometry,s.matrixWorld)),!1),n=new(Fj())(r);this._staticBVHCache={signature:t,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(e,t,i){if(pCe(e.matrixWorld))return;let r=[],n="geometry"in e?e.geometry:void 0,s=t.dataPatched;if(n?.getAttribute("position")!==void 0&&r.push(of(n,e.shearScale)),s.physics.fusedBody){let a=this.gatherChildrenGeom(e,r);e.traverseObject(a),e.children.forEach(l=>l.updateMatrixWorld(!0));let o=e.cloner;o&&o.objectForSample===void 0&&s.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&s.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Er.RigidBodyDesc.dynamic(),a.setLinearDamping(s.physics.damping).setAngularDamping(s.physics.damping).setAdditionalMass(1e-9).setGravityScale(s.physics.gravityScale).enabledRotations(...s.physics.enabledRotation).enabledTranslations(...s.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Er.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Er.RigidBodyDesc.fixed();let u=Qv(r);(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ta,au,Km),e.position0=ta.clone().divideScalar(this.pixelsPerMeter),e.rotation0=au.clone(),ta.divideScalar(this.pixelsPerMeter),a.setTranslation(ta.x,ta.y,ta.z).setRotation(au),n?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Km.x/this.pixelsPerMeter,Km.y/this.pixelsPerMeter,Km.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(s.geometry===void 0||s.geometry.type==="SubdivGeometry"||s.geometry.type==="NonParametricGeometry"||s.geometry.type==="BooleanGeometry"||s.geometry.type==="VectorGeometry"||s.geometry.type==="StarGeometry"||s.geometry.type==="RectangleGeometry"||s.geometry.type==="EllipseGeometry"||s.geometry.type==="TriangleGeometry"||s.geometry.type==="TorusGeometry"||s.geometry.type==="HelixGeometry");try{this.addCollider(h,s.physics,u,t,d)}catch{try{this.addCollider(h,s.physics,u,t,!1)}catch(c){console.error(c)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[e,Km.clone(),s.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(h.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e)):this.fixedBodiesToWatch.push([e,h,(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).clone()]),e.rigidBody=h}}addBoundsTree(e){let t=[];if(e.geometry?.getAttribute("position")!==void 0&&e.geometry?.getAttribute("position").count>0&&t.push(of(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,t)),e.children.forEach(i=>i.updateMatrixWorld(!0)),t.length>0){let i=Qv(t,!1);e.bvhGeometry=i,i.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(Fj())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(e,t,i,r,n=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let s;i&&(s=t.colliderType==="trimesh"?Er.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Er.ColliderDesc.convexMesh(i.getAttribute("position").array,n?i.getIndex().array:void 0)),s.setFrictionCombineRule(Er.CoefficientCombineRule.Average).setRestitutionCombineRule(Er.CoefficientCombineRule.Average).setDensity(t.density).setFriction(t.friction).setRestitution(t.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(s,e);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Er.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){let i=ab(e);return(r,n)=>{if(n===0)return;if(i&&r.parent===e)return!0;let s;if(ex(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;s=r.object}else if(Jv(r))s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;n===1?e.hasNonUniformScale?r.matrixWorld.multiplyMatrices(e.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&&t.push(of(o,r.matrixWorld)),!!ab(r)||void 0}}activate(e){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=e,this.usePhysics=this.page.data.globalPhysics.usePhysics;let t=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=Z0e();if(r!==null?i=r.setup({manager:this,camera:t,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Ma("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 WAe(t,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 n=this.renderer.domElement.width/this.renderer.getPixelRatio(),s=this.renderer.domElement.height/this.renderer.getPixelRatio();Z0e()?.createJoysticks(this,n,s),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Er.World(new Er.Vector3(0,this.gravity,0)),this.events=new Er.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(a=>{let o;if(ex(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(Jv(a))o=a.object;else{if(ME(a)||t1(a)||a instanceof Rx)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=L4(u),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of u.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let v=new gke(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.initialDisabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;a.traverseVisible(y=>{y.userData.isFollowingObj=v})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let m=a.geometry;if(l!==void 0){let g=Er.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(ta,au,Km),a.position0=ta.clone().divideScalar(this.pixelsPerMeter),a.rotation0=au.clone(),ta.divideScalar(this.pixelsPerMeter),g.setTranslation(ta.x,ta.y,ta.z).setRotation(au);let v,y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=y,v=l.collider.type==="sphere"?Er.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Er.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Er.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),v.setFrictionCombineRule(Er.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(0).setRestitutionCombineRule(Er.CoefficientCombineRule.Min);let _=this.sharedGameControlGlobals.rapierWorld.createCollider(v,y);this.sharedGameControlGlobals.colliderToEntity.set(_.handle,o),ta.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Km.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),_.setTranslationWrtParent(ta);let b=new kt().setFromEuler(new Kr().setFromVector3(new R().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));_.setRotationWrtParent(b),_.setActiveEvents(Er.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else u.physics.rigidBody==="dynamic"||h||f||c||p||d?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,u.physics.fusedBody)):(m&&e.push(of(m,a.matrixWorld)),u.physics.fusedBody&&!ab(a)&&a.traverseObject((g,v)=>{if(v===0)return;let y;if(ex(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;y=g.object}else{if(ME(g)||t1(g)||g instanceof Rx)return;if(Jv(g))y=g.object;else if(y=g,y.dataPatched.cloner?.hideBase)return!0}let _=y.dataPatched;if(_.physics.enabled==="visibility"?!_.visible:!_.physics.enabled)return!0;let b=g.geometry;return b?.getAttribute("position")!==void 0&&e.push(of(b,g.matrixWorld)),!!ab(g)||void 0}),this.generateSensorColliderDescs(o,u.physics.fusedBody,t));return!(u.physics?.fusedBody!==!0&&!l&&!ab(a))||void 0}),e.length===0)return;let i=Qv(e),r=i.getIndex().count>0;if(!r&&t.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=Er.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);if(r){let a=Er.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Er.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Er.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s)}for(let[a,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new tve(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new Ue().compose(Yu.fromArray(t.data.position.map(n=>typeof n=="number"?n:0)),sb.setFromEuler(ive.fromArray(t.data.rotation.map(n=>typeof n=="number"?n:0))),kj);if(t.data.triggerZone==="box"){let n=new fn;n.min.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),n.max.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([n,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.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(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e){if(!this.isEnabled)return!0;let t=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),t=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,t=!1):this.initializationCounter===2&&this.gameControl&&(t=!this.gameControl.update(e)&&t),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(e===0)t=this.stepPhysics()&&t;else{let r=e/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let n=performance.now(),s=0,a=6;for(;this.accumulator>=i&&s<a&&(t=this.stepPhysics()&&t,this.accumulator-=i,s++,!(performance.now()-n>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=t}recordPhysicsPose(e){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ta,au,Km);let t=e;t.prevQ===void 0?(t.prevQ=au.clone(),t.prevT=ta.clone()):(t.prevQ.copy(au),t.prevT.copy(ta))}promoteMovedFixedBodies(){for(let e=this.fixedBodiesToWatch.length-1;e>=0;e--){let[t,i,r]=this.fixedBodiesToWatch[e];t.rigidBody===i?(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).equals(r)||(i.setBodyType(Er.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),this.fixedBodiesToWatch.splice(e,1)):this.fixedBodiesToWatch.splice(e,1)}}clampPushedBodies(){let e=this.gameControl?.object.rigidBody;if(e===void 0)return;let t=this.sharedGameControlGlobals.rapierWorld,i=e.linvel(),r=e.translation(),n=Math.hypot(i.x,i.z);for(let s=0;s<e.numColliders();s++){let a=e.collider(s);t.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(t.contactPair(a,o,v=>{let y=v.normal(),_=y.x*(u.x-r.x)+y.y*(u.y-r.y)+y.z*(u.z-r.z)<0?-1:1;if(Math.abs(y.y)>.7)return;let b=_*y.x,x=_*y.z,w=Math.hypot(b,x);if(w<1e-4)return;let S=(i.x*b+i.z*x)/w;S>h&&(h=S,d=b/w,c=x/w)}),h===-1/0)return;let p=i.x*d+i.z*c;if(p<-Gj)return;let f=l.linvel();if(n>Gj&&p>Gj){let v=f.x*d+f.z*c;if(v<=0)return;let y=Math.min(v,p);return void l.setLinvel({x:d*y,y:f.y,z:c*y},!0)}let m=f.x*d+f.z*c-Math.max(0,p);if(m<=0)return;let g=.5*m;l.setLinvel({x:f.x-d*g,y:f.y,z:f.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let e=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[t,i]of e)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(ta.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(au)):e.delete(t);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)t.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r,n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(t.cloner){for(let s of t.cloner.children)if(s.rigidBody===n){r=s;break}}e.dispatch(r),t.dispatchEvent(j$)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=rve.copy(e.matrixWorld).invert();e.traverseEntity((n,s)=>{if(t===!1&&s===1)return!0;for(let a of n.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new tve(a.id,a.data,n,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Er.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):Er.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Er.ActiveEvents.COLLISION_EVENTS),Yu.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),sb.setFromEuler(ive.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),NN.compose(Yu,sb,kj).premultiply(n.matrixWorld),i?(NN.decompose(Yu,sb,zj),o.setActiveCollisionTypes(Er.ActiveCollisionTypes.KINEMATIC_FIXED|Er.ActiveCollisionTypes.DYNAMIC_FIXED)):(NN.premultiply(r).decompose(Yu,sb,zj),e.rigidBody.bodyType()===Er.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===Er.RigidBodyType.Fixed?o.setActiveCollisionTypes(Er.ActiveCollisionTypes.KINEMATIC_FIXED|Er.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Er.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Er.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Yu.divideScalar(this.pixelsPerMeter),o.setTranslation(Yu.x,Yu.y,Yu.z),o.setRotation(sb),i)i.push([o,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(o,e.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,n,s]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(n===o||s.isValidTriggeringObject(lr.is(o)?o:o.object)===!1)continue;let l=rve.copy(n.matrixWorld).decompose(Yu,nve,zj).compose(Yu,nve,kj).multiply(r),u=NN.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof fn?e=h.intersectsBox(i,u):(Vj.radius=i,Vj.center.setFromMatrixPosition(u),e=h.intersectsSphere(Vj)),e?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),n.dispatchEvent(yke)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(d=>d!==o)}}}};ww(),oe(),BL(),Ir(),Yf();var jj=.02,sve=new R,ave=new R,bke=new R,Go=new R,zp=new R,ob=new R,Wj=new Ue,ove=new Ue,xke=new Ue,mh=new kt,Tv=new kt,lb=new Kr(0,0,0,"YXZ"),wke=new R(1,0,0),cc=new R(0,1,0),Ske=new R(0,0,1),lve=new R(1,1,1),hve=[],uve=e=>hve[e]??(hve[e]=new R),Hj=new R,Tke=new R,Mke=new R,Eke=new R,dve=new kt,Ake=new R,cve=new kt,ka=new Eh,ou=new fn,Cke={type:"requestRender"},Pke={type:"updateMatrix"},W$=class extends ws{constructor(e,t,i,r,n,s,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=n,this.cameraFollow=s,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new Ue,this.target0=new R,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Kr(0,0,0,"YXZ"),this.position0Cam=new R,this.quat0Cam=new kt,this.scale0Cam=new R,this.hiddenMatrix0Cam=new Ue,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Eh(new R(0,-40,0),new R(0,40,0)),matrix:new Ue,position:new R,rotation:new kt},this.euler=new Kr(0,0,0,"YXZ"),this.eulerDelta=new R,this.lastPosition=new R,this.lastCameraQuaternion=new kt,this.lastCameraPosition=new R,this.PI_2=Math.PI/2,this.prevMouse=new Z,this.velocityTarget=new R,this.velocity=new R,this.directionXZ=new R,this.rotVelocityStick=new R,this.rotVelocityTarget=new R,this.rotVelocity=new R,this.rotDirection=new R,this.nonColliderRotOffset=new Ue,this.nonColliderPosOffset=new Ue,this.firstPointerId=-1,this.rot=new R,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 Ue,this.objectToTarget=new R,this.objectToTarget0=new R,this.objectToCamXZ=new R,this.objectToCamXZ0=new R,this.targetToCamera=new R,this.targetToCamera0=new R,this.cameraPolarAxis0=new R,this.targetPos=new R,this.targetQuat=new kt,this.lerpFactorPos=new R().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new kt,this.objXZQuatInv=new kt,this.objXZRotMat=new Ue,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new R,this.pushedVelocity=new R,this.groundYRotation=0,this.objectRealQuat=new kt,this.colliderWorldQuat=new kt,this.groundNormal=new R,this.groundTilt=new kt,this.groundTiltInv=new kt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new R,this.quaternion=new kt,this.scale=new R,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Kl&&!nW&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(nW&&K1e<15.5&&!Kl?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?W$.isLocked=!0:W$.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=v:this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=n.sharedGameControlGlobals,e===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 f,m=new R(0,0,-1).applyQuaternion(this.camera.quaternion),g=new R().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(m.y)<1e-6?(g.y=0,m.y=0,f=g.projectOnVector(m)):f=g.y/m.y>0?m.multiplyScalar(g.y/m.y):m.multiplyScalar(g.length()),this.targetToCamera0.copy(f).negate();let v=this.camera.position.clone().add(f);this.objectToTarget0.subVectors(v,this.position);let y=new Kr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Yn&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??Tx.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??Tx.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??CL.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*jj/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*jj/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*jj/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new R().fromArray(i.collider.position.map(f=>typeof f=="number"?f:0)),c=new kt().setFromEuler(new Kr().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,lve),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let f=new It;f.push({fi:0,data:{...hs.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...hs.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=Cxe({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Tr(pY.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){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 t=new Kr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Yn?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 e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},AL.list.forEach(i=>{this.actions[i]=ha({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,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"),Za(this.actions.idle),Za(this.actions.move),Za(this.actions.run),Za(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(t=>{t.play()}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(t=>{t.stop()}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Go.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){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 t=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*t,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=zp.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*t,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(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(Go).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*t}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=Go.subVectors(this.path[1],this.position),o=zp.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=bke.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=zp.copy(n);s.y=0,n.set(0,n.y,s.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let s=Go;this.camera.getWorldDirection(s);let a=ob.copy(cc).multiplyScalar(s.dot(cc));s.sub(a);let o=zp.copy(this.directionXZ);o.x*=-1,this.rot.y=s.angleTo(o)*(s.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(lb.setFromVector3(this.rot),this.moveMode==="walk"&&(lb.x=0),n.applyEuler(lb),r&&(Tv.setFromUnitVectors(cc,this.groundNormal),n.applyQuaternion(Tv)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Hj,dve,Tke);let o=this.object.getWorldPosition(Mke).add(this.collider.position).sub(Hj);cve.copy(a.prevQ).invert().premultiply(dve);let l=ob.subVectors(Hj,a.prevT).add(Eke.copy(o).applyQuaternion(cve).sub(o)).divideScalar(t).divideScalar(this.pixelsPerMeter),u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Go.copy(n).divideScalar(this.pixelsPerMeter),0,t,!1);l.multiplyScalar(this.pixelsPerMeter);let h=lr.is(a)?a:a.object;if(u!==null&&this.lastHitObj!==h){let d;a instanceof Ph&&(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(j$));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),uve(s++).copy(u.normal1).applyQuaternion(a.quaternion))}if(s>0){for(let a=0;a<s;a++){let o=uve(a),l=o.dot(n);l<0&&n.addScaledVector(o,-l)}n.add(this.pushedVelocity)}else n.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(t),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*t,this.euler.y+=this.rotVelocity.y*t+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*t),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(cc,this.euler.y-this.euler0.y);let s=zp.copy(this.objectToCamXZ).normalize(),a=ob.copy(n).multiplyScalar(t);a.y=0;let o=a.sub(Go.copy(s).multiplyScalar(a.dot(s))).cross(s).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*t+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=ht.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=ht.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=ht.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(lb.copy(this.euler),lb.y=0,this.nonColliderRotOffset.makeRotationFromEuler(lb)),mh.setFromAxisAngle(wke,this.rot.x),Tv.setFromAxisAngle(cc,this.rot.y),Tv.multiply(mh),mh.setFromAxisAngle(Ske,this.rot.z),Tv.multiply(mh),this.quaternion.copy(Tv),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=zp.copy(n).multiplyScalar(t/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new R;for(let h=0;h<5;h++){let d=s.length(),c=ob.copy(s).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(s);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.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}}y.dispatch(_),p.dispatchEvent(j$)}}}let f=sve.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),m=ave.copy(c).multiplyScalar(a.time_of_impact).dot(f),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=a.time_of_impact*(m-this.offset)/m,o.addScaledVector(c,g)),s.copy(c).multiplyScalar(d-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),y=ob.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let _=v.add(y);_.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(_,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);b!==null&&b.time_of_impact===0&&(f.y=0,f.normalize())}s.addScaledVector(f,-s.dot(f))}}this.position.addScaledVector(o,this.pixelsPerMeter),Go.copy(this.position).divideScalar(this.pixelsPerMeter),mh.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,u=l!==void 0&&Ake.copy(Go).sub(l.translation()).lengthSq()>1;l!==void 0&&(u?(l.setTranslation(Go,!0),l.setRotation(mh,!0)):(l.setNextKinematicTranslation(Go),l.setNextKinematicRotation(mh)))}else{let s=this.onObject?1:5,a=n.multiplyScalar(t/s);for(let o=0;o<s;o++)this.position.add(a),this.collisionAdjustment(t/s)}else this.position.addScaledVector(n,t);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),a=this.targetToCamera.add(s);Wj.lookAt(a,s,cc).setPosition(a),Wj.decompose(this.targetPos,this.targetQuat,Go),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=ht.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=ht.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(Pke),!(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(Cke),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e,t=mh.setFromAxisAngle(cc,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?ht.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(t),e=this.cameraXAxis==="Limit"?ht.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):ht.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Go.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let r=Tv.setFromAxisAngle(i,e);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){180*cc.angleTo(e)/Math.PI<15||180*cc.angleTo(e)/Math.PI>85?mh.identity():mh.setFromUnitVectors(cc,e),this.groundTilt.slerp(mh,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=ave.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Wj.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Go,mh,zp).compose(Go,mh,lve);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(n=>{if(n===this.object||n.isDescendantOf(this.object)||!n.bvhGeometry||!n.bvhGeometry.boundsTree)return;ou.makeEmpty(),n.updateMatrixWorldRigid();let s=n.matrixWorldRigid,a=ove.copy(s).invert(),o=xke.copy(ove).multiply(i);ka.copy(this.collider.segment),ka.start.applyMatrix4(o),ka.end.applyMatrix4(o);let l=sve.copy(this.position).applyMatrix4(a);ou.expandByPoint(ka.start),ou.expandByPoint(ka.end),ou.min.addScalar(-this.collider.radius),ou.max.addScalar(this.collider.radius),n.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(ka.end),intersectsBounds:u=>u.intersectsBox(ou),intersectsTriangle:u=>{let h=Go,d=zp,c=u.closestPointToSegment(ka,h,d);if(c<this.collider.radius){let p=this.collider.radius-c,f=d.sub(h).normalize(),m=ob.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),ka.start.addScaledVector(f,p),ka.end.addScaledVector(f,p)}}})}),ou.makeEmpty(),ka.copy(this.collider.segment),ka.start.applyMatrix4(i),ka.end.applyMatrix4(i),ou.expandByPoint(ka.start),ou.expandByPoint(ka.end),ou.min.addScalar(-this.collider.radius),ou.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:n=>n.distanceToPoint(ka.end),intersectsBounds:n=>n.intersectsBox(ou),intersectsTriangle:n=>{let s=Go,a=zp,o=n.closestPointToSegment(ka,s,a);if(o<this.collider.radius){let l=this.collider.radius-o,u=a.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),t.addScaledVector(u,l),ka.start.addScaledVector(u,l),ka.end.addScaledVector(u,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}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()}},fCe=W$;fCe.isLocked=!1,oe(),GA(),bB(),ww(),bw();var mCe,gCe,qj,Rke=new Promise(e=>{mCe=e});function Dke(e){return qj||(qj=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.80/build";typeof window<"u"&&(gCe=new URL(t.endsWith("/")?t:`${t}/`,window.location.href).href);let i=import("./navmesh.js"),[r,n]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});mCe(a)}(),qj)}Gr();var vCe,mr,po,Nke=e=>`
|
|
12909
|
+
`)>=0&&(e-=n),i===3?.5*t-.5*e:i===2?t-e:0}getLineInitialOffsetY(e,t,i,r,n){let s=t*e,a=e-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return n===3?-(i-s-o):n===2?-(.5*i-.5*s-o):o}createPath(e,t,i,r,n){let s=e.getPath(i,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");let a=new ske,o=(e.advanceWidth??1)*t;if(e)for(let l of s.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 wh)return d.v1;if(d instanceof pu||d instanceof uf)return d.v0}}(l.curves);u!==void 0&&l.currentPoint.distanceTo(u)>0&&l.lineTo(u.x,u.y)}),{offsetX:o,path:a}}getCharWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(e,t,i,r){let n=this.getCharWidth(" ",i),s=e[t];if(s){let a=this.countSpaces(s.trimEnd());if(i.horizontalAlign===4&&t<e.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-a*n))/a}return n}countSpaces(e){return(e.match(/ /g)||[]).length}},Nn("text"),jt();var sCe=null;function Z0e(){return sCe}function lke(e){let t=!1;return e.scene.objects.forEach(i=>{i.data.type==="Page"&&!t&&i.data.publish.gameControlObject&&e1.traverseModuleInstances(e,i.id,(r,n,s)=>{for(let a of s)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(t=!0)})}),t}Gr();var RN=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},Ij=e=>e*(Math.PI/180),DN=new Map,I4=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.addEventListener?e.addEventListener(r,i,!1):e.attachEvent&&e.attachEvent(r,i)},O4=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.removeEventListener?e.removeEventListener(r,i):e.detachEvent&&e.detachEvent(r,i)},aCe=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),Q0e=()=>{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}},Oj=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},Lj=(e,t,i)=>{let r=oCe(e);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+i;else{let s="";for(let a=0,o=t.length;a<o;a+=1)s+=t[a]+" "+i+", ";r[n]=s.slice(0,-2)}return r},oCe=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},Bj=(e,t)=>{for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},G$=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)};typeof window<"u"&&(lCe="ontouchstart"in window,hCe=!!window.PointerEvent,uCe=!!window.MSPointerEvent);var lCe,hCe,uCe,nb,J0e={start:"mousedown",move:"mousemove",end:"mouseup"},J2={};function zv(){}hCe?nb={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:uCe?nb={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:lCe?(nb={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},J2=J0e):nb=J0e,zv.prototype.on=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(t);return r},zv.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i},zv.prototype.trigger=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},t)})},zv.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=((i,r)=>{let n={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&Object.prototype.hasOwnProperty.call(r,s)?n[s]=r[s]:Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s]);return n})(t.options,e))},zv.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},I4(e,nb[t],i._domHandlers_[t]),J2[t]&&I4(e,J2[t],i._domHandlers_[t]),i},zv.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},O4(e,nb[t],i._domHandlers_[t]),J2[t]&&O4(e,J2[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var WK=zv;function xa(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,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(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=xa.id,xa.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}xa.prototype=new WK,xa.constructor=xa,xa.id=0,xa.prototype.buildEl=function(e){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},xa.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=(()=>{let n=oCe("borderRadius");for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]="50%");return n})(),i=Lj("transition","opacity",e),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)"},Bj(r.el,i),this.options.shape==="circle"&&Bj(r.back,t),Bj(r.front,t),this.applyStyles(r),this},xa.prototype.applyStyles=function(e){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this},xa.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},xa.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},xa.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},xa.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t},xa.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t},xa.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",n={};n.front=Lj("transition",["top","left"],r);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(n),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)},xa.prototype.restCallback=function(){var e=this,t={};t.front=Lj("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)},xa.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},xa.prototype.computeDirection=function(e){var t,i,r,n=e.angle.radian,s=Math.PI/4,a=Math.PI/2;if(n>s&&n<3*s&&!e.lockX?t="up":n>-s&&n<=s&&!e.lockY?t="left":n>3*-s&&n<=-s&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(i=n>-a&&n<a?"left":"right"),e.lockX||(r=n>0?"up":"down"),e.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:t},e.direction=this.direction,l)l[o]===this.direction[o]&&(u[o]=!0);if(u.x&&u.y&&u.angle)return e;(!u.x||!u.y)&&this.trigger("plain",e),u.x||this.trigger("plain:"+i,e),u.y||this.trigger("plain:"+r,e),u.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var hke=xa;function qs(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=qs.id,qs.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(t),(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}qs.prototype=new WK,qs.constructor=qs,qs.id=0,qs.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===i)return t[r];return!1}},qs.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"},qs.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}},qs.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,n={},s=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(e.x&&e.y)n={x:e.x-a,y:e.y-o};else if(e.top||e.right||e.bottom||e.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=e.top,l.style.right=e.right,l.style.bottom=e.bottom,l.style.left=e.left,l.style.position="absolute",s.zone.appendChild(l);var u=l.getBoundingClientRect();s.zone.removeChild(l),n=e,e={x:u.left+r.x,y:u.top+r.y}}var h=new hke(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:e,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Oj(h.ui.el,n),Oj(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},qs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},qs.prototype.bindNipple=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},qs.prototype.pressureFn=function(e,t,i){var r=this,n=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var s=e.force||e.pressure||e.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)},qs.prototype.onstart=function(e){var t=this,i=t.options,r=e;return e=aCe(e),t.updateBox(),G$(e,function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(s){if(Object.values(r.touches).findIndex(function(o){return o.identifier===s})<0){var a=[e[0]];a.identifier=s,t.processOnEnd(a)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))}),t.manager.bindDocument(),!1},qs.prototype.processOnStart=function(e){var t,i=this,r=i.options,n=i.manager.getIdentifier(e),s=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=i.getOrCreate(n,a);o.identifier!==n&&i.manager.removeIdentifier(o.identifier),o.identifier=n;var l=function(u){u.trigger("start",u),i.trigger("start "+u.id+":start",u),u.show(),s>0&&i.pressureFn(e,u,u.identifier),i.processOnMove(e)};if((t=i.idles.indexOf(o))>=0&&i.idles.splice(t,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(RN(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(e);l(o)}return o},qs.prototype.getOrCreate=function(e,t){var i,r=this,n=r.options;return/(semi|static)/.test(n.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):n.mode==="semi"?r.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(t,e)},qs.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.scroll;if((_=>isNaN(_.buttons)?_.pressure!==0:_.buttons!==0)(e)){if(!n)return console.error("Found zombie joystick with ID "+r),void t.manager.removeIdentifier(r);if(i.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:s.x+a.left,y:s.y+a.top}}n.identifier=r;var o=n.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=n.position.y),i.lockY&&(l.x=n.position.x);var u,h,d=RN(l,n.position),c=((_,b)=>{let x=b.x-_.x,w=b.y-_.y;return(S=>S*(180/Math.PI))(Math.atan2(w,x))})(l,n.position),p=Ij(c),f=d/o,m={distance:d,position:l};if(n.options.shape==="circle"?(u=Math.min(d,o),h=((_,b,x)=>{let w={x:0,y:0};return x=Ij(x),w.x=_.x-b*Math.cos(x),w.y=_.y-b*Math.sin(x),w})(n.position,u,c)):(h=((_,b,x)=>({x:Math.min(Math.max(_.x,b.x-x),b.x+x),y:Math.min(Math.max(_.y,b.y-x),b.y+x)}))(l,n.position,o),u=RN(h,n.position)),i.follow){if(d>o){let _=l.x-h.x,b=l.y-h.y;n.position.x+=_,n.position.y+=b,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",d=RN(l,n.position)}}else l=h,d=u;var g=l.x-n.position.x,v=l.y-n.position.y;n.frontPosition={x:g,y:v},i.dataOnly||Oj(n.ui.front,n.frontPosition);var y={identifier:n.identifier,position:l,force:f,pressure:e.force||e.pressure||e.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-v/o},raw:m,instance:n,lockX:i.lockX,lockY:i.lockY};(y=n.computeDirection(y)).angle={radian:Ij(180-c),degree:180-c},n.trigger("move",y),t.trigger("move "+n.id+":move",y)}else this.processOnEnd(e)},qs.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(i.dataOnly||n.hide(function(){i.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(i.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[s.id]=s.identifier))},qs.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()},qs.prototype.destroy=function(){var e=this;for(var t in e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()}),e.pressureIntervals)Object.prototype.hasOwnProperty.call(e.pressureIntervals,t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off(),e.pressureIntervals={},e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.manager=null};var uke=qs;function ia(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Q0e(),t._windowBound=!1,t.config(e),t.prepareCollections();var i=function(){var r;t.collections.forEach(function(n){n.forEach(function(s){r=s.el.getBoundingClientRect(),s.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){(r=>{DN.has(r)&&clearTimeout(DN.get(r)),DN.set(r,setTimeout(function(){DN.delete(r),r()},100))})(i)},t._onScroll=function(){t.scroll=Q0e()},t.collections}ia.prototype=new WK,ia.constructor=ia,ia.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return!(i=r.get(t))}),i}},ia.prototype.create=function(e){return this.createCollection(e)},ia.prototype.bindWindowEvents=function(){var e=this;e._windowBound||typeof window>"u"||(e._windowBound=!0,I4(window,"resize",e._onResize),I4(window,"scroll",e._onScroll))},ia.prototype.unbindWindowEvents=function(){var e=this;!e._windowBound||typeof window>"u"||(e._windowBound=!1,O4(window,"resize",e._onResize),O4(window,"scroll",e._onScroll))},ia.prototype.createCollection=function(e){var t=this,i=new uke(t,e);return t.bindCollection(i),t.collections.push(i),t.bindWindowEvents(),i},ia.prototype.bindCollection=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},ia.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)},ia.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)},ia.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier)===void 0&&(t=this.latest||0):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},ia.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t},ia.prototype.onmove=function(e){return this.onAny("move",e),!1},ia.prototype.onend=function(e){return this.onAny("end",e),!1},ia.prototype.oncancel=function(e){return this.onAny("end",e),!1},ia.prototype.onAny=function(e,t){var i,r=this,n="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=aCe(t);var s=function(a,o,l){l.ids.indexOf(o)>=0&&(l[n](a),a._found_=!0)};return G$(t,function(a){i=r.getIdentifier(a),G$(r.collections,s.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},ia.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.unbindWindowEvents(),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.collections=[],e.off()},ia.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1),i.collections.length===0&&i.unbindWindowEvents()};var dke=ia,Vx=null;function eve(){return Vx||(Vx=new dke),Vx}var cke={create:function(e){return eve().create(e)},destroy:function(){Vx&&(Vx.destroy(),Vx=null)},get factory(){return eve()}},pke=cke;Gr(),jt(),oe(),Ih(),xl(),jt();var dCe=null;function Fj(){return dCe}var cCe,Uj,fke=new Promise(e=>{cCe=e});function mke(e){return Uj||(Uj=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build",i=import("./physics.js"),[r,n]=await Promise.all([i,fetch(`${t}/physics.wasm`).then(s=>s.arrayBuffer())]);await r.init(n),cCe(r)}(),Uj)}function pCe(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||n<l||s<l||a<l||o<l}function of(e,t){let i=new At;if(t&&pCe(t))return i.setAttribute("position",new Et([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new Et([],3)),i.setIndex([]),i;let{positions:r,triIndices:n}=wY(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Et(r,3)),i.setIndex(n),t&&i.applyMatrix4(t),i}ss(),xl(),_r(),UY(),oe(),oe(),bw(),GA();var Er,gke=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target}disconnect(){Za(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>t.play()),this.actions.Animation.forEach(t=>{"runMode"in t.data&&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.Reset.forEach(t=>{t.dispatch()}),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(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},tve=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target,this.triggeringObjects=[];for(let a of t.triggeringObjects){let o=r.scene.find(a);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(e){return this.target==="all"||this.triggeringObjects.some(t=>t===e||t.isAncestorOf(e.uuid)||e.isAncestorOf(t.uuid))}disconnect(){Za(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.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(!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}};ss(),fke.then(e=>Er=e);var ta=new R,au=new kt,Km=new R,ive=(new Kr(0,0,0,"YXZ"),new Kr(0,0,0,"XYZ")),Yu=new R,zj=new R,kj=new R(1,1,1),sb=new kt,NN=new Ue,rve=new Ue,vke={type:"updateMatrix"},nve=new kt,Vj=new qa,Gj=.01,j$={type:"beginEvent",eventName:"Collision"},yke={type:"beginEvent",eventName:"Trigger"},L4=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);function ab(e){return function(t){return typeof t=="object"&&t!==null&&"booleanOp"in t}(Jv(e)?e.object:e)}var _ke=class{constructor(e){this.eventContext=e,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=t=>{if(t.bodyType()!==Er.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[i,r,n]=this.rigidBodyToMesh.get(t.handle);if(ta.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),au.copy(t.rotation()),i.matrixWorld.compose(ta,au,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(vke),n){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let a of s.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,i,r)=>{if(r===!1)return;let n,s;if(this.sensorToTriggerEvent[t]?(n=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(n=this.sensorToTriggerEvent[i],s=this.sharedGameControlGlobals.colliderToEntity.get(t)),n&&s&&n.isValidTriggeringObject(s))n.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===t||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(t)){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(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,t)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let h of o)h.data.target==="scene"&&this.dispatchCollisionEvent(h,a,t);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=e.isExport,this.sharedAssets=e.sharedAssets,this.renderer=e.renderer,this.requestRender=e.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(e=>{let t=e.dataPatched;for(let i of t.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(n=>n.data.type==="Destroy")?.data;if(r)for(let n of r.objects){let s=this.page.scene.find(n);s&&(s.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let i of t.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let n=this.page.scene.find(r);n&&(n.userData.hasDrag=!0)}})}_staticBVHIdOf(e){let t=this._staticBVHAttrIds.get(e);return t===void 0&&(t=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(e,t)),t}initBVH(){if(Fj()===null)return void Ma("collision-bvh","trigger/collision detection");let e=[],t=[];if(this.page.traverseChildren(i=>{let r,n=i instanceof Rx,s=ME(i);if(ex(i)||n||s)return;r=Jv(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(L4(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){e.push({geometry:o,matrixWorld:i.matrixWorld}),t.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)t.push(d)}}return!!ab(i)||void 0}),e.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===t.length&&i.signature.every((s,a)=>s===t[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=Qv(e.map(s=>of(s.geometry,s.matrixWorld)),!1),n=new(Fj())(r);this._staticBVHCache={signature:t,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(e,t,i){if(pCe(e.matrixWorld))return;let r=[],n="geometry"in e?e.geometry:void 0,s=t.dataPatched;if(n?.getAttribute("position")!==void 0&&r.push(of(n,e.shearScale)),s.physics.fusedBody){let a=this.gatherChildrenGeom(e,r);e.traverseObject(a),e.children.forEach(l=>l.updateMatrixWorld(!0));let o=e.cloner;o&&o.objectForSample===void 0&&s.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&s.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Er.RigidBodyDesc.dynamic(),a.setLinearDamping(s.physics.damping).setAngularDamping(s.physics.damping).setAdditionalMass(1e-9).setGravityScale(s.physics.gravityScale).enabledRotations(...s.physics.enabledRotation).enabledTranslations(...s.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Er.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Er.RigidBodyDesc.fixed();let u=Qv(r);(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ta,au,Km),e.position0=ta.clone().divideScalar(this.pixelsPerMeter),e.rotation0=au.clone(),ta.divideScalar(this.pixelsPerMeter),a.setTranslation(ta.x,ta.y,ta.z).setRotation(au),n?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Km.x/this.pixelsPerMeter,Km.y/this.pixelsPerMeter,Km.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(s.geometry===void 0||s.geometry.type==="SubdivGeometry"||s.geometry.type==="NonParametricGeometry"||s.geometry.type==="BooleanGeometry"||s.geometry.type==="VectorGeometry"||s.geometry.type==="StarGeometry"||s.geometry.type==="RectangleGeometry"||s.geometry.type==="EllipseGeometry"||s.geometry.type==="TriangleGeometry"||s.geometry.type==="TorusGeometry"||s.geometry.type==="HelixGeometry");try{this.addCollider(h,s.physics,u,t,d)}catch{try{this.addCollider(h,s.physics,u,t,!1)}catch(c){console.error(c)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[e,Km.clone(),s.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(h.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e)):this.fixedBodiesToWatch.push([e,h,(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).clone()]),e.rigidBody=h}}addBoundsTree(e){let t=[];if(e.geometry?.getAttribute("position")!==void 0&&e.geometry?.getAttribute("position").count>0&&t.push(of(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,t)),e.children.forEach(i=>i.updateMatrixWorld(!0)),t.length>0){let i=Qv(t,!1);e.bvhGeometry=i,i.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(Fj())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(e,t,i,r,n=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let s;i&&(s=t.colliderType==="trimesh"?Er.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Er.ColliderDesc.convexMesh(i.getAttribute("position").array,n?i.getIndex().array:void 0)),s.setFrictionCombineRule(Er.CoefficientCombineRule.Average).setRestitutionCombineRule(Er.CoefficientCombineRule.Average).setDensity(t.density).setFriction(t.friction).setRestitution(t.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(s,e);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Er.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){let i=ab(e);return(r,n)=>{if(n===0)return;if(i&&r.parent===e)return!0;let s;if(ex(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;s=r.object}else if(Jv(r))s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;n===1?e.hasNonUniformScale?r.matrixWorld.multiplyMatrices(e.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&&t.push(of(o,r.matrixWorld)),!!ab(r)||void 0}}activate(e){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=e,this.usePhysics=this.page.data.globalPhysics.usePhysics;let t=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=Z0e();if(r!==null?i=r.setup({manager:this,camera:t,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Ma("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 WAe(t,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 n=this.renderer.domElement.width/this.renderer.getPixelRatio(),s=this.renderer.domElement.height/this.renderer.getPixelRatio();Z0e()?.createJoysticks(this,n,s),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Er.World(new Er.Vector3(0,this.gravity,0)),this.events=new Er.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(a=>{let o;if(ex(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(Jv(a))o=a.object;else{if(ME(a)||t1(a)||a instanceof Rx)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=L4(u),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of u.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let v=new gke(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.initialDisabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;a.traverseVisible(y=>{y.userData.isFollowingObj=v})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let m=a.geometry;if(l!==void 0){let g=Er.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(ta,au,Km),a.position0=ta.clone().divideScalar(this.pixelsPerMeter),a.rotation0=au.clone(),ta.divideScalar(this.pixelsPerMeter),g.setTranslation(ta.x,ta.y,ta.z).setRotation(au);let v,y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=y,v=l.collider.type==="sphere"?Er.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Er.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Er.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),v.setFrictionCombineRule(Er.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(0).setRestitutionCombineRule(Er.CoefficientCombineRule.Min);let _=this.sharedGameControlGlobals.rapierWorld.createCollider(v,y);this.sharedGameControlGlobals.colliderToEntity.set(_.handle,o),ta.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Km.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),_.setTranslationWrtParent(ta);let b=new kt().setFromEuler(new Kr().setFromVector3(new R().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));_.setRotationWrtParent(b),_.setActiveEvents(Er.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else u.physics.rigidBody==="dynamic"||h||f||c||p||d?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,u.physics.fusedBody)):(m&&e.push(of(m,a.matrixWorld)),u.physics.fusedBody&&!ab(a)&&a.traverseObject((g,v)=>{if(v===0)return;let y;if(ex(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;y=g.object}else{if(ME(g)||t1(g)||g instanceof Rx)return;if(Jv(g))y=g.object;else if(y=g,y.dataPatched.cloner?.hideBase)return!0}let _=y.dataPatched;if(_.physics.enabled==="visibility"?!_.visible:!_.physics.enabled)return!0;let b=g.geometry;return b?.getAttribute("position")!==void 0&&e.push(of(b,g.matrixWorld)),!!ab(g)||void 0}),this.generateSensorColliderDescs(o,u.physics.fusedBody,t));return!(u.physics?.fusedBody!==!0&&!l&&!ab(a))||void 0}),e.length===0)return;let i=Qv(e),r=i.getIndex().count>0;if(!r&&t.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=Er.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);if(r){let a=Er.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Er.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Er.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s)}for(let[a,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new tve(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new Ue().compose(Yu.fromArray(t.data.position.map(n=>typeof n=="number"?n:0)),sb.setFromEuler(ive.fromArray(t.data.rotation.map(n=>typeof n=="number"?n:0))),kj);if(t.data.triggerZone==="box"){let n=new fn;n.min.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),n.max.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([n,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.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(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e){if(!this.isEnabled)return!0;let t=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),t=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,t=!1):this.initializationCounter===2&&this.gameControl&&(t=!this.gameControl.update(e)&&t),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(e===0)t=this.stepPhysics()&&t;else{let r=e/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let n=performance.now(),s=0,a=6;for(;this.accumulator>=i&&s<a&&(t=this.stepPhysics()&&t,this.accumulator-=i,s++,!(performance.now()-n>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=t}recordPhysicsPose(e){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ta,au,Km);let t=e;t.prevQ===void 0?(t.prevQ=au.clone(),t.prevT=ta.clone()):(t.prevQ.copy(au),t.prevT.copy(ta))}promoteMovedFixedBodies(){for(let e=this.fixedBodiesToWatch.length-1;e>=0;e--){let[t,i,r]=this.fixedBodiesToWatch[e];t.rigidBody===i?(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).equals(r)||(i.setBodyType(Er.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),this.fixedBodiesToWatch.splice(e,1)):this.fixedBodiesToWatch.splice(e,1)}}clampPushedBodies(){let e=this.gameControl?.object.rigidBody;if(e===void 0)return;let t=this.sharedGameControlGlobals.rapierWorld,i=e.linvel(),r=e.translation(),n=Math.hypot(i.x,i.z);for(let s=0;s<e.numColliders();s++){let a=e.collider(s);t.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(t.contactPair(a,o,v=>{let y=v.normal(),_=y.x*(u.x-r.x)+y.y*(u.y-r.y)+y.z*(u.z-r.z)<0?-1:1;if(Math.abs(y.y)>.7)return;let b=_*y.x,x=_*y.z,w=Math.hypot(b,x);if(w<1e-4)return;let S=(i.x*b+i.z*x)/w;S>h&&(h=S,d=b/w,c=x/w)}),h===-1/0)return;let p=i.x*d+i.z*c;if(p<-Gj)return;let f=l.linvel();if(n>Gj&&p>Gj){let v=f.x*d+f.z*c;if(v<=0)return;let y=Math.min(v,p);return void l.setLinvel({x:d*y,y:f.y,z:c*y},!0)}let m=f.x*d+f.z*c-Math.max(0,p);if(m<=0)return;let g=.5*m;l.setLinvel({x:f.x-d*g,y:f.y,z:f.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let e=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[t,i]of e)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(ta.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(au)):e.delete(t);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)t.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r,n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(t.cloner){for(let s of t.cloner.children)if(s.rigidBody===n){r=s;break}}e.dispatch(r),t.dispatchEvent(j$)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=rve.copy(e.matrixWorld).invert();e.traverseEntity((n,s)=>{if(t===!1&&s===1)return!0;for(let a of n.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new tve(a.id,a.data,n,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Er.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):Er.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Er.ActiveEvents.COLLISION_EVENTS),Yu.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),sb.setFromEuler(ive.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),NN.compose(Yu,sb,kj).premultiply(n.matrixWorld),i?(NN.decompose(Yu,sb,zj),o.setActiveCollisionTypes(Er.ActiveCollisionTypes.KINEMATIC_FIXED|Er.ActiveCollisionTypes.DYNAMIC_FIXED)):(NN.premultiply(r).decompose(Yu,sb,zj),e.rigidBody.bodyType()===Er.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===Er.RigidBodyType.Fixed?o.setActiveCollisionTypes(Er.ActiveCollisionTypes.KINEMATIC_FIXED|Er.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Er.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Er.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Yu.divideScalar(this.pixelsPerMeter),o.setTranslation(Yu.x,Yu.y,Yu.z),o.setRotation(sb),i)i.push([o,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(o,e.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,n,s]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(n===o||s.isValidTriggeringObject(lr.is(o)?o:o.object)===!1)continue;let l=rve.copy(n.matrixWorld).decompose(Yu,nve,zj).compose(Yu,nve,kj).multiply(r),u=NN.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof fn?e=h.intersectsBox(i,u):(Vj.radius=i,Vj.center.setFromMatrixPosition(u),e=h.intersectsSphere(Vj)),e?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),n.dispatchEvent(yke)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(d=>d!==o)}}}};ww(),oe(),BL(),Ir(),Yf();var jj=.02,sve=new R,ave=new R,bke=new R,Go=new R,zp=new R,ob=new R,Wj=new Ue,ove=new Ue,xke=new Ue,mh=new kt,Tv=new kt,lb=new Kr(0,0,0,"YXZ"),wke=new R(1,0,0),cc=new R(0,1,0),Ske=new R(0,0,1),lve=new R(1,1,1),hve=[],uve=e=>hve[e]??(hve[e]=new R),Hj=new R,Tke=new R,Mke=new R,Eke=new R,dve=new kt,Ake=new R,cve=new kt,ka=new Eh,ou=new fn,Cke={type:"requestRender"},Pke={type:"updateMatrix"},W$=class extends ws{constructor(e,t,i,r,n,s,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=n,this.cameraFollow=s,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new Ue,this.target0=new R,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Kr(0,0,0,"YXZ"),this.position0Cam=new R,this.quat0Cam=new kt,this.scale0Cam=new R,this.hiddenMatrix0Cam=new Ue,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Eh(new R(0,-40,0),new R(0,40,0)),matrix:new Ue,position:new R,rotation:new kt},this.euler=new Kr(0,0,0,"YXZ"),this.eulerDelta=new R,this.lastPosition=new R,this.lastCameraQuaternion=new kt,this.lastCameraPosition=new R,this.PI_2=Math.PI/2,this.prevMouse=new Z,this.velocityTarget=new R,this.velocity=new R,this.directionXZ=new R,this.rotVelocityStick=new R,this.rotVelocityTarget=new R,this.rotVelocity=new R,this.rotDirection=new R,this.nonColliderRotOffset=new Ue,this.nonColliderPosOffset=new Ue,this.firstPointerId=-1,this.rot=new R,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 Ue,this.objectToTarget=new R,this.objectToTarget0=new R,this.objectToCamXZ=new R,this.objectToCamXZ0=new R,this.targetToCamera=new R,this.targetToCamera0=new R,this.cameraPolarAxis0=new R,this.targetPos=new R,this.targetQuat=new kt,this.lerpFactorPos=new R().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new kt,this.objXZQuatInv=new kt,this.objXZRotMat=new Ue,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new R,this.pushedVelocity=new R,this.groundYRotation=0,this.objectRealQuat=new kt,this.colliderWorldQuat=new kt,this.groundNormal=new R,this.groundTilt=new kt,this.groundTiltInv=new kt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new R,this.quaternion=new kt,this.scale=new R,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Kl&&!nW&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(nW&&K1e<15.5&&!Kl?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?W$.isLocked=!0:W$.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=v:this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=n.sharedGameControlGlobals,e===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 f,m=new R(0,0,-1).applyQuaternion(this.camera.quaternion),g=new R().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(m.y)<1e-6?(g.y=0,m.y=0,f=g.projectOnVector(m)):f=g.y/m.y>0?m.multiplyScalar(g.y/m.y):m.multiplyScalar(g.length()),this.targetToCamera0.copy(f).negate();let v=this.camera.position.clone().add(f);this.objectToTarget0.subVectors(v,this.position);let y=new Kr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Yn&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??Tx.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??Tx.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??CL.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*jj/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*jj/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*jj/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new R().fromArray(i.collider.position.map(f=>typeof f=="number"?f:0)),c=new kt().setFromEuler(new Kr().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,lve),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let f=new It;f.push({fi:0,data:{...hs.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...hs.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=Cxe({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Tr(pY.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){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 t=new Kr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Yn?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 e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},AL.list.forEach(i=>{this.actions[i]=ha({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,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"),Za(this.actions.idle),Za(this.actions.move),Za(this.actions.run),Za(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(t=>{t.play()}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(t=>{t.stop()}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Go.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){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 t=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*t,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=zp.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*t,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(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(Go).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*t}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=Go.subVectors(this.path[1],this.position),o=zp.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=bke.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=zp.copy(n);s.y=0,n.set(0,n.y,s.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let s=Go;this.camera.getWorldDirection(s);let a=ob.copy(cc).multiplyScalar(s.dot(cc));s.sub(a);let o=zp.copy(this.directionXZ);o.x*=-1,this.rot.y=s.angleTo(o)*(s.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(lb.setFromVector3(this.rot),this.moveMode==="walk"&&(lb.x=0),n.applyEuler(lb),r&&(Tv.setFromUnitVectors(cc,this.groundNormal),n.applyQuaternion(Tv)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Hj,dve,Tke);let o=this.object.getWorldPosition(Mke).add(this.collider.position).sub(Hj);cve.copy(a.prevQ).invert().premultiply(dve);let l=ob.subVectors(Hj,a.prevT).add(Eke.copy(o).applyQuaternion(cve).sub(o)).divideScalar(t).divideScalar(this.pixelsPerMeter),u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Go.copy(n).divideScalar(this.pixelsPerMeter),0,t,!1);l.multiplyScalar(this.pixelsPerMeter);let h=lr.is(a)?a:a.object;if(u!==null&&this.lastHitObj!==h){let d;a instanceof Ph&&(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(j$));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),uve(s++).copy(u.normal1).applyQuaternion(a.quaternion))}if(s>0){for(let a=0;a<s;a++){let o=uve(a),l=o.dot(n);l<0&&n.addScaledVector(o,-l)}n.add(this.pushedVelocity)}else n.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(t),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*t,this.euler.y+=this.rotVelocity.y*t+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*t),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(cc,this.euler.y-this.euler0.y);let s=zp.copy(this.objectToCamXZ).normalize(),a=ob.copy(n).multiplyScalar(t);a.y=0;let o=a.sub(Go.copy(s).multiplyScalar(a.dot(s))).cross(s).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*t+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=ht.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=ht.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=ht.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(lb.copy(this.euler),lb.y=0,this.nonColliderRotOffset.makeRotationFromEuler(lb)),mh.setFromAxisAngle(wke,this.rot.x),Tv.setFromAxisAngle(cc,this.rot.y),Tv.multiply(mh),mh.setFromAxisAngle(Ske,this.rot.z),Tv.multiply(mh),this.quaternion.copy(Tv),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=zp.copy(n).multiplyScalar(t/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new R;for(let h=0;h<5;h++){let d=s.length(),c=ob.copy(s).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(s);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.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}}y.dispatch(_),p.dispatchEvent(j$)}}}let f=sve.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),m=ave.copy(c).multiplyScalar(a.time_of_impact).dot(f),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=a.time_of_impact*(m-this.offset)/m,o.addScaledVector(c,g)),s.copy(c).multiplyScalar(d-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),y=ob.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let _=v.add(y);_.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(_,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);b!==null&&b.time_of_impact===0&&(f.y=0,f.normalize())}s.addScaledVector(f,-s.dot(f))}}this.position.addScaledVector(o,this.pixelsPerMeter),Go.copy(this.position).divideScalar(this.pixelsPerMeter),mh.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,u=l!==void 0&&Ake.copy(Go).sub(l.translation()).lengthSq()>1;l!==void 0&&(u?(l.setTranslation(Go,!0),l.setRotation(mh,!0)):(l.setNextKinematicTranslation(Go),l.setNextKinematicRotation(mh)))}else{let s=this.onObject?1:5,a=n.multiplyScalar(t/s);for(let o=0;o<s;o++)this.position.add(a),this.collisionAdjustment(t/s)}else this.position.addScaledVector(n,t);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),a=this.targetToCamera.add(s);Wj.lookAt(a,s,cc).setPosition(a),Wj.decompose(this.targetPos,this.targetQuat,Go),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=ht.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=ht.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(Pke),!(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(Cke),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e,t=mh.setFromAxisAngle(cc,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?ht.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(t),e=this.cameraXAxis==="Limit"?ht.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):ht.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Go.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let r=Tv.setFromAxisAngle(i,e);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){180*cc.angleTo(e)/Math.PI<15||180*cc.angleTo(e)/Math.PI>85?mh.identity():mh.setFromUnitVectors(cc,e),this.groundTilt.slerp(mh,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=ave.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Wj.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Go,mh,zp).compose(Go,mh,lve);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(n=>{if(n===this.object||n.isDescendantOf(this.object)||!n.bvhGeometry||!n.bvhGeometry.boundsTree)return;ou.makeEmpty(),n.updateMatrixWorldRigid();let s=n.matrixWorldRigid,a=ove.copy(s).invert(),o=xke.copy(ove).multiply(i);ka.copy(this.collider.segment),ka.start.applyMatrix4(o),ka.end.applyMatrix4(o);let l=sve.copy(this.position).applyMatrix4(a);ou.expandByPoint(ka.start),ou.expandByPoint(ka.end),ou.min.addScalar(-this.collider.radius),ou.max.addScalar(this.collider.radius),n.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(ka.end),intersectsBounds:u=>u.intersectsBox(ou),intersectsTriangle:u=>{let h=Go,d=zp,c=u.closestPointToSegment(ka,h,d);if(c<this.collider.radius){let p=this.collider.radius-c,f=d.sub(h).normalize(),m=ob.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),ka.start.addScaledVector(f,p),ka.end.addScaledVector(f,p)}}})}),ou.makeEmpty(),ka.copy(this.collider.segment),ka.start.applyMatrix4(i),ka.end.applyMatrix4(i),ou.expandByPoint(ka.start),ou.expandByPoint(ka.end),ou.min.addScalar(-this.collider.radius),ou.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:n=>n.distanceToPoint(ka.end),intersectsBounds:n=>n.intersectsBox(ou),intersectsTriangle:n=>{let s=Go,a=zp,o=n.closestPointToSegment(ka,s,a);if(o<this.collider.radius){let l=this.collider.radius-o,u=a.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),t.addScaledVector(u,l),ka.start.addScaledVector(u,l),ka.end.addScaledVector(u,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}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()}},fCe=W$;fCe.isLocked=!1,oe(),GA(),bB(),ww(),bw();var mCe,gCe,qj,Rke=new Promise(e=>{mCe=e});function Dke(e){return qj||(qj=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build";typeof window<"u"&&(gCe=new URL(t.endsWith("/")?t:`${t}/`,window.location.href).href);let i=import("./navmesh.js"),[r,n]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});mCe(a)}(),qj)}Gr();var vCe,mr,po,Nke=e=>`
|
|
12910
12910
|
(async function() {
|
|
12911
12911
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
12912
12912
|
import('${e}' + 'navmesh.js'),
|
|
@@ -12916,7 +12916,7 @@ void main() {
|
|
|
12916
12916
|
self.module = await wasmModule({ wasmBinary });
|
|
12917
12917
|
postMessage('ready');
|
|
12918
12918
|
})();
|
|
12919
|
-
`,Ike={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};Rke.then(e=>{vCe=e,mr=new e.Vec3,po=new e.Vec3});var Oke=new R,Lke=class{constructor(e=!1,t=!1){this.usePhysics=e,this.isExport=t,this.onPointerDown=i=>{if(vi.length!==1)return;let{raycaster:r,page:n}=this.eventContext;this.eventContext.updateRaycaster(i);let s=n.raycastWithClones(r);if(s.length!==0){if(this.gameControl){let a=Oke.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,s[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>n=>{let s;if(n instanceof kg){if(!n.objectForSample)return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(n.objectForSample.dataPatched.physics.fusedBody)return;s=n.object}else if(n instanceof Ph)s=n.object;else if(s=n,s.dataPatched.cloner?.disabled===!1&&s.dataPatched.cloner?.hideBase&&s.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!s.userData.navmesh)return;let a=s.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;n.updateMatrixWorldRigid();let o=L4(a),l=s.userData.hasDestroy,u=s.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 n&&n.geometry&&i.push(of(n.geometry,n.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return n.traverseObject((c,p)=>{if(p===0)return;let f;if(c instanceof kg){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;f=c.object}else if(c instanceof Ph)f=c.object;else if(f=c,c.dataPatched.cloner?.hideBase)return!0;let m=f.dataPatched;if(!m.visible&&m.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(of(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>n=>{let s;if(n instanceof kg)return;s=n instanceof Ph?n.object:n;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!s.userData.navmesh)return;let o=n.geometry,l=s.userData.hasDestroy===!0,u=s.userData.hasDrag===!0;if(L4(a)||l||u||s.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(of(o,n.matrixWorld))},this.navmeshWasm=vCe,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(t?Nke(gCe??"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
12919
|
+
`,Ike={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};Rke.then(e=>{vCe=e,mr=new e.Vec3,po=new e.Vec3});var Oke=new R,Lke=class{constructor(e=!1,t=!1){this.usePhysics=e,this.isExport=t,this.onPointerDown=i=>{if(vi.length!==1)return;let{raycaster:r,page:n}=this.eventContext;this.eventContext.updateRaycaster(i);let s=n.raycastWithClones(r);if(s.length!==0){if(this.gameControl){let a=Oke.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,s[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>n=>{let s;if(n instanceof kg){if(!n.objectForSample)return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(n.objectForSample.dataPatched.physics.fusedBody)return;s=n.object}else if(n instanceof Ph)s=n.object;else if(s=n,s.dataPatched.cloner?.disabled===!1&&s.dataPatched.cloner?.hideBase&&s.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!s.userData.navmesh)return;let a=s.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;n.updateMatrixWorldRigid();let o=L4(a),l=s.userData.hasDestroy,u=s.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 n&&n.geometry&&i.push(of(n.geometry,n.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return n.traverseObject((c,p)=>{if(p===0)return;let f;if(c instanceof kg){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;f=c.object}else if(c instanceof Ph)f=c.object;else if(f=c,c.dataPatched.cloner?.hideBase)return!0;let m=f.dataPatched;if(!m.visible&&m.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(of(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>n=>{let s;if(n instanceof kg)return;s=n instanceof Ph?n.object:n;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!s.userData.navmesh)return;let o=n.geometry,l=s.userData.hasDestroy===!0,u=s.userData.hasDrag===!0;if(L4(a)||l||u||s.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(of(o,n.matrixWorld))},this.navmeshWasm=vCe,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(t?Nke(gCe??"https://cdn.spline.design/@splinetool/runtime@2.0.82/build/"):`
|
|
12920
12920
|
(async function() {
|
|
12921
12921
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
12922
12922
|
import(self.location.origin + '/_libraries/navmesh.js'),
|
|
@@ -12991,7 +12991,7 @@ onmessage = function(messageEvent) {
|
|
|
12991
12991
|
[${PO}] { pointer-events: none; }
|
|
12992
12992
|
[${PO}] > * { pointer-events: auto; }
|
|
12993
12993
|
[${PO}] [data-spline-passthrough] { pointer-events: none; }
|
|
12994
|
-
`,qCe=class{constructor(e,t,i,r,n,s){this.container=e,this.host=t,this.observer=i,this.spline=r,this.previousSplineGlobal=n,this.removeLateLifecycleShim=s}static mount(e,t,i,r){if(typeof document>"u")return null;let n=t.parentElement;if(!n)return null;getComputedStyle(n).position==="static"&&(n.style.position="relative");let s=document.createElement("div");s.setAttribute(PO,"");let a=s.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${t.offsetLeft}px`,a.top=`${t.offsetTop}px`,a.width=`${t.offsetWidth}px`,a.height=`${t.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(t),l.observe(n);let u=document.createElement("style");u.textContent=f8e,s.appendChild(u);let h=new DOMParser().parseFromString(i,"text/html"),d=Array.from(h.querySelectorAll("script"));for(let y of d)y.remove();for(let y of Array.from(h.head.children))(y.tagName==="STYLE"||y.tagName==="LINK"&&y.rel==="stylesheet")&&s.appendChild(y);for(;h.body.firstChild;)s.appendChild(h.body.firstChild);n.insertBefore(s,t.nextSibling);let c=new Map,p=new OX(WCe(e,t,r),(y,_)=>{y==="warn"?console.warn(`[spline html] ${_}`):y==="error"&&console.error(`[spline html] ${_}`)},(y,_)=>{let b=c.get(y);if(b)for(let x of b)try{x(_)}catch(w){console.error(w)}}),f=(y,_)=>{try{return Promise.resolve(p.execute(y,_))}catch(b){return Promise.reject(b)}},m={ready:Promise.resolve(),setVariable:(y,_)=>f("setVariable",[y,_]),setVariables:y=>f("setVariables",[y]),getVariable:y=>f("getVariable",[y]),getVariables:()=>f("getVariables",[]),getAllObjects:()=>f("getAllObjects",[]),findObjectByName:y=>f("findObjectByName",[y]),findObjectById:y=>f("findObjectById",[y]),getGeometry:(y,_)=>f("getGeometry",[y,_??{}]),updateObject:(y,_)=>f("updateObject",[y,_]),createObject:(y,_)=>f("createObject",[y,_??{}]),createCustomMaterial:y=>f("createCustomMaterial",[y]),getTexture:(y,_)=>f("getTexture",[y,_??{}]),setMaterial:(y,_)=>f("setMaterial",[y,_]),cloneObject:(y,_)=>f("cloneObject",[y,_??{}]),removeObject:y=>f("removeObject",[y]),spawnObject:(y,_)=>f("spawnObject",[y,_??{}]),destroyObject:y=>f("destroyObject",[y]),setInstanceTransforms:(y,_)=>f("setInstanceTransforms",[y,_??null]),emitEvent:(y,_)=>f("emitEvent",[y,_]),emitEventReverse:(y,_)=>f("emitEventReverse",[y,_]),requestRender:()=>f("requestRender",[]),addEventListener:(y,_)=>{if(typeof _!="function")return;let b=c.get(y);b||(b=new Set,c.set(y,b),f("listenEvent",[y])),b.add(_)},removeEventListener:(y,_)=>{let b=c.get(y);!b||(b.delete(_),b.size===0&&(c.delete(y),f("unlistenEvent",[y])))}},g=window.spline;window.spline=m;let v=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let y=[],_=(x,w)=>{let S=new Set,T=x.addEventListener.bind(x),M=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(E,A,P)=>{if(T(E,A,P),!w.includes(E)||A==null)return;let N={type:E,listener:A};S.add(N),queueMicrotask(()=>{!S.delete(N)||((D,O,z)=>{let L=new Event(z);try{typeof O=="function"?O.call(D,L):O.handleEvent?.(L)}catch(V){console.error(V)}})(x,N.listener,N.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(E,A,P)=>{M(E,A,P);for(let N of S)N.type===E&&N.listener===A&&S.delete(N)}}),y.push(()=>{delete x.addEventListener,delete x.removeEventListener,S.clear()})};_(document,["DOMContentLoaded"]),_(window,["load"]);let b=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(w){console.error(w)}})}}),y.push(()=>{b?Object.defineProperty(window,"onload",b):delete window.onload}),()=>{for(let x of y)x()}}();for(let y of d){let _=document.createElement("script");for(let b of Array.from(y.attributes))_.setAttribute(b.name,b.value);y.src?_.async=!1:_.textContent=y.textContent,s.appendChild(_)}return new qCe(s,p,l,m,g,v)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function $Ce(e){return typeof e=="object"&&e!==null&&e.isMaterial===!0}function _ye(e){if(typeof e.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(!$Ce(e.material))return{options:e};let t=e.material;if(t.isNodeMaterial===!0){let i=bH()?.NodeMaterial;if(i!==void 0&&t instanceof i)return{options:{...e,material:void 0},material:t};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(t.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:{...e,material:void 0},material:t}}jt(),Ir(),oe(),Mxe(),bu(),Ir(),jt(),ELe(),Yf();var m8e=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),bye="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",g8e={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"},v8e={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},y8e={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')."},_8e={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"},b8e={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function kA(e,t){return e===void 0?[t[0],t[1],t[2]]:Array.isArray(e)?[e[0]??t[0],e[1]??t[1],e[2]??t[2]]:[e.x??t[0],e.y??t[1],e.z??t[2]]}function XCe(e){return typeof e=="number"?[e,e,e]:kA(e,[1,1,1])}function hX(e){let t=new zr(0,0,0,1);return t.setStyle(e),{r:t.r,g:t.g,b:t.b}}function xye(e,t){let i=e.material??(e.color!==void 0?{color:e.color}:void 0);if(i===void 0)return ns.defaultColorMaterial(wye(eo),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(t.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)||ot.NAMES[o]!==void 0}(i))return ns.defaultColorMaterial(hX(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)"}(t)}) 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($Ce(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?hX(i.color):wye(eo),n=ns.defaultColorMaterial(r,"physical","layer1","layer2"),s=n.layers.find(a=>a.data.type==="light");if(s){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(s.data,a)}if(i.alpha!==void 0){let a=n.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return n}function wye(e){return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}}function x8e(e){let t=df.defaultData("TextGeometry"),{text:i,...r}=e,n=r.fontSize;return n!==void 0&&r.width===void 0&&(r.width=350*n/16),n!==void 0&&r.height===void 0&&(r.height=50*n/16),Object.assign(t,r),i!==void 0&&Object.assign(t,{text:{textValue:String(i)}}),t}function uI(e){return Array.isArray(e)?e:!ArrayBuffer.isView(e)||e instanceof DataView?null:Array.from(e)}function w8e(e,t){return Z_e({userData:{type:e,...yH[e].normalizeInputs({parameters:t})}})}function S8e(e,t,i){let{objectType:r,geometryType:n}=e,s=function(l){let u={};for(let[h,d]of Object.entries(l))!m8e.has(h)&&d!==void 0&&(u[h]=d);return u}(t),a={states:new It,events:new It};if(r==="Mesh"&&n){if(n==="NonParametricGeometry"){let{geometry:l,doubleSide:u}=function(h){let d=uI(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=uI(h.indices);if(p&&p.length){let _=p.find(b=>!Number.isInteger(b)||b<0||b>=c);if(_!==void 0)throw new Error(`createObject('CustomMesh'): index ${_} is out of range (mesh has ${c} vertices).`)}else p=null;let f=new At;f.setAttribute("position",new Et(d,3));let m=uI(h.normals),g=m!==null&&m.length===d.length;g&&f.setAttribute("normal",new Et(m,3));let v=uI(h.uvs);v&&v.length===2*c&&f.setAttribute("uv",new Et(v,2));let y=!1;if(!g){let _=p??Array.from({length:c},(w,S)=>S),{closed:b,inverted:x}=function(w,S){let T=w.length/3,M=new Map,E=new Array(T);for(let D=0;D<T;D++){let O=`${Math.round(1e4*w[3*D])},${Math.round(1e4*w[3*D+1])},${Math.round(1e4*w[3*D+2])}`,z=M.get(O);z===void 0?(M.set(O,D),E[D]=D):E[D]=z}let A=new Map;for(let D=0;D+2<S.length;D+=3){let O=E[S[D]],z=E[S[D+1]],L=E[S[D+2]];for(let[V,G]of[[O,z],[z,L],[L,O]]){if(V===G)continue;let Y=V<G?V+"_"+G:G+"_"+V;A.set(Y,(A.get(Y)??0)+1)}}let P=A.size>0;for(let D of A.values())if(D!==2){P=!1;break}if(!P)return{closed:!1,inverted:!1};let N=0;for(let D=0;D+2<S.length;D+=3){let O=3*S[D],z=3*S[D+1],L=3*S[D+2],V=w[O],G=w[O+1],Y=w[O+2],$=w[z],Q=w[z+1],ue=w[z+2],pe=w[L],xe=w[L+1],we=w[L+2];N+=V*(Q*we-ue*xe)+G*(ue*pe-$*we)+Y*($*xe-Q*pe)}return{closed:!0,inverted:N<0}}(d,_);if(b&&x){for(let w=0;w+2<_.length;w+=3){let S=_[w+1];_[w+1]=_[w+2],_[w+2]=S}p=_}else b||(y=!0)}return p&&f.setIndex(p),g||f.computeVertexNormals(),{geometry:Z_e({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:f.toJSON().data}),doubleSide:y}}(s);Object.assign(a,_c.defaultData,{geometry:l,materials:[xye(t,i)]}),u&&(a.side=2)}else Object.assign(a,_c.defaultData,{geometry:n==="TextGeometry"?x8e(s):w8e(n,s),material:xye(t,i)});t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow)}else r==="Empty"?Object.assign(a,SL.defaultData):(Object.assign(a,TL.defaultData(r),s),t.color!==void 0&&(a.color=hX(t.color)));a.visible=t.visible??!0,a.position=kA(t.position,[0,0,0]),a.rotation=kA(t.rotation,[0,0,0]),a.scale=XCe(t.scale);let o=(n&&_8e[n])??b8e[r]??r;return a.name=t.name??YCe(o,i.scene.objects),a}function YCe(e,t){let i=new Set;if(t.traverse((n,s)=>{i.add(s.name??"")}),!i.has(e))return e;let r=2;for(;i.has(`${e} ${r}`);)r++;return`${e} ${r}`}function KCe(e,t){let i=ht.generateUUID();if(e.data.type==="Component")return{data:{...wf.fromComponentData(e),name:e.data.name+" Instance"},id:i,fi:e.fi,children:[]};t[e.id]=i;let r=e.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:r.animations.map(([n,s,a])=>{let o=ht.generateUUID(),l=a.indexOf(n);return[o,s,l!==-1?a.slice(0,l)+o+a.slice(l+n.length):a]})}),{...e,id:i,data:r,children:e.children.map(n=>KCe(n,t))}}function T8e(e){let t={};return function(i,r){return _x(i,r,null)??i}(KCe(e,t),t)}function M8e(e){let t=Array.isArray(e)?e[0]:e,i=t.layers?.map(E8e)??[],r=t.layers?.find(n=>n.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function E8e(e){return e.type==="texture"||e.type==="video"||e.type==="matcap"?{...e.data,updateTexture:t=>e.color.texture.image.updateSrc(t)}:{...e.data}}Yf(),ss(),uY(),bu();var cM=new zr(0,0,0,1),A8e={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:[]};jt(),jt();var C8e=new Z;function Sye(e){let t=new zr(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}return t}var ZCe=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r,renderer:n,htmlContentMode:s="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<J_e?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),t1(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=C8e.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=fA(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this._htmlContentMode=s,this.renderMode=t?"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=n??"webgl",n===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(()=>(UBe(),_Te)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",qJ,!0),a.addEventListener("pointerdown",n3,!0),a.addEventListener("pointermove",n3,!0),a.addEventListener("pointerup",k1,!0),a.addEventListener("pointercancel",k1,!0),a.addEventListener("pointerleave",k1,!0),window.addEventListener("keydown",$J,!0),window.addEventListener("keyup",XJ,!0)}(e)}async _initRenderer(){if(this.disposed)return null;let e=await this._createRenderer();return this.disposed?(this._disposeRenderer(e),null):e}_disposeRenderer(e){let t=function(r){let n=r.backend;if(n!==void 0)return n.isWebGLBackend===!0?n.gl??null:null;let s=r.getContext,a=typeof s=="function"?s.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(e);if(t&&!function(r,n){return vye.get(r)===n}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(e)||e.dispose());let i=t?function(r,n){let s=n.getExtension("WEBGL_lose_context");if(!s||n.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=yye(r,"webglcontextlost",u=>{u.preventDefault(),l(s)})});return oI.set(r,{gl:n,lost:o,stopListening:a}),()=>{n.isContextLost()||s.loseContext()}}(this.canvas,t):void 0;try{e.dispose()}finally{i?.()}}async _createRenderer(){if(function(e,t){vye.set(e,t)}(this.canvas,this),await async function(e){let t=oI.get(e);if(t&&(t.restoring??(t.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let n,s=()=>{},a=r.lost.then(l=>new Promise(u=>{s=yye(i,"webglcontextrestored",()=>u()),l.restoreContext()})),o=new Promise(l=>{n=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(n),s(),r.stopListening()}(e,t).finally(()=>{t.restoring=void 0,!t.gl.isContextLost()&&oI.get(e)===t&&oI.delete(e)})),await t.restoring,t.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:e,isWebGPUSupported:t}=await Promise.resolve().then(()=>(ij(),SO));t();let i=!0,r=!1,n=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"?n=!1:(l==="on"||l==="1"||l==="true"||l==="always")&&(n=!0)}catch{}let s=await e({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&n});return s.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},s.skyAnimationAllowed=!0,s}catch(e){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",e),this._rendererBackend="webgl"}{let{SplineRenderer:e,rendererGlobals:t}=await Promise.resolve().then(()=>(d0e(),O$));try{new URLSearchParams(window.location.search).get("taa")==="off"&&(t.taaEnabled.value=!1)}catch{}return new e({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"})}}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let e=window.devicePixelRatio||1,t=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=t*e,this.canvas.height=i*e;let r=this.canvas.getContext("2d");r&&(r.scale(e,e),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.",t/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(e,t,i){(function(n){let s="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(s+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(s)})(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;Fs.init();let r=await async function(c){let[p,f]=EM(mA.deserialize(new Uint8Array(c)));if((p.schema??0)!==132){let{updateDocumentSchema:m}=await Promise.resolve().then(()=>(J4(),V_e));m(p)}return f.result().data}(e);this._data=r;let n=function(c){let p=[];return c.scene.objects.traverse((f,m)=>{m.type==="Mesh"&&m.geometry.type==="NonParametricGeometry"&&m.geometry.data.draco!==void 0&&p.push(m)}),p}(r);r.version&&(0,c8e.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){Rwe=c}(this._wasmPath));let s=async function(){}();await Promise.all([s,n.length&&fye(this._wasmPath),ere(r)&&OLe(this._wasmPath),t4e(r)&&e4e(this._wasmPath),T4e(r)&&l4e(this._wasmPath),e1.physicsEnabled(r.scene.objects)&&mke(this._wasmPath),iie(r)&&Y0e(),xre(r)&&q4e(),jLe(r)&&GLe(),V0e(r)&&s.then(()=>qW()?.loadHanaUIRUNTIME()),lke(r)&&Dke(this._wasmPath)].filter(Boolean)),n.length&&await mye(n),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((f,m)=>{if(m.type!=="Page")return;let g=m.postprocessing;if(g&&typeof g=="object"&&g.enabled===!0)for(let[v,y]of Object.entries(g))v!=="enabled"&&y&&typeof y=="object"&&y.enabled===!0&&p.add(v)}),[...p]}(r);if(this._rendererBackend==="webgpu")try{if(await Promise.all([Promise.resolve().then(()=>(ij(),SO)),d8e(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"}this._rendererBackend!=="webgpu"&&await Promise.all([Promise.resolve().then(()=>(d0e(),O$)),u8e(o)]),function(c){XA=c}(this._rendererBackend==="webgpu"?"webgpu":"webgl");let l=new n8e(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(()=>($5e(),CAe)),p=performance.now();c(r,l.scene);let f=performance.now();console.log("Merged geometries in ",f-p," ms")}ere(r)&&this._scene.traverse(c=>{Fc(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{ex(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()),t1(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())}),iie(r)&&function(c){if(e1.physicsEnabled(c.scene.objects))return!0;let p=!1;return c.scene.objects.traverse((f,m)=>{if(m.events){if(Array.isArray(m.events)){for(let g of m.events)if(g.data.disabled!==!0&&g.data.type==="GameControl"&&g.data.collisionEnabled){p=!0;break}}else for(let g of Object.values(m.events))if(g.disabled!==!0&&g.type==="GameControl"&&g.collisionEnabled){p=!0;break}}}),p}(r)&&await Promise.all(u),V0e(r)){let c=[];this._scene.traverseEntity(p=>{(Xo(p)||p instanceof Ks)&&p.uiCanvas&&c.push(p.uiCanvas)}),await Promise.all(c.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),KK(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 f=this._sharedAssetsManager.getImage("SplineWatermark");await f.loadPromise;let m=f.getTexture(1001);this._renderer.pipeline.setWatermark(m)}}xre(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 Cze(this._renderer,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),t){let c=new oze(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new _ke(c),this._animationControls=new o8e(this._scene,this._requestRenderAutoMode),this._eventManager=new wze(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),t&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let d=r.scene.publish.htmlContent?.html;if(t&&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"?qCe.mount(this,this.canvas,d,c):HCe.mount(this,this.canvas,d,c))??void 0}}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){if(t==null)return void console.warn(`Variable ${e} was not updated: received ${t}. Pass a number, boolean or string.`);let r=t;if(typeof i.data.value=="number"){if(r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t),!Number.isFinite(r))return void console.warn(`Variable ${e} is a number variable and ${JSON.stringify(t)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()!=="false"&&!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let n=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,n),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&Eo.isTextValue(e)?Eo.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(!(t.uuid===o1||this._scene.isInvisibleObjects(t)||t instanceof Ks)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof WAe&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=Sye(e);this._scene?.activePage.setBackgroundColor(t),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,AE&&AE.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{_j.unsubscribe(e)}),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(e){e.removeEventListener("pointerdown",qJ,!0),e.removeEventListener("pointerdown",n3,!0),e.removeEventListener("pointermove",n3,!0),e.removeEventListener("pointerup",k1,!0),e.removeEventListener("pointercancel",k1,!0),e.removeEventListener("pointerleave",k1,!0),window.removeEventListener("keydown",$J,!0),window.removeEventListener("keyup",XJ,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Fs.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(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t,i=this._scene;if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);e.traverseAncestors(h=>{h instanceof Ks&&(t=h.name)});let r=this._sharedAssetsManager,n={shared:r,scene:this._scene},s=h=>{if(h===null||h==="Base State")return null;if(h&&e.data.states){let d=e.data.states.find(c=>c.data.name===h);return d?d.id:void 0}},a="material"in e?e.material:void 0,o=e.materialOverride,l={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,material:o??(a?M8e(a):void 0),parentUuid:e.parent instanceof Ks||e instanceof Og?void 0:e.parent?.uuid,emitEvent(h){e.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){e.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){e.visible&&(e.visible=!1,n.shared.requestRender())},show(){e.visible||(e.visible=!0,n.shared.requestRender())},get state(){let h=e.stateSelection;if(h!==null)return e.data.states.find(({id:d})=>d===h)?.data.name},set state(h){let d;if(h!==void 0){let c=typeof h=="string"?e.data.states.find(({id:p})=>p===h):e.data.states[h];if(c)d=c.id;else{let p=typeof h=="string"?s(h):void 0;p&&(d=p)}}e.changeSelectedState(d??null,n),e.currentState=d??null,e.dispatchEvent({type:"completeState",state:d??null}),n.shared.requestRender()},transition(h){let d=GCe;if(d===null)return Ma("transitions","obj.transition()"),{transition(b){return this},play(){return this},pause(){return this},reset(){return this},seek(b){return this}};let c,p,f=this,m=[],g=!1,v=()=>{p=new ECe({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},m.map(b=>b.runner))},y={update(b){p?.update(b),p?.isPlaying!==!0&&Fs.remove(y)}},_={transition({from:b,to:x,duration:w,delay:S,...T}){let M=s(b);M===void 0&&(M=c);let E=s(x);return c=E,m.push(new d(e,M,E,{state:E,repeat:0,delay:S??0,delayDirection:"start-once",direction:"normal",duration:w??1e3,...T,...T.easing===6?Pg.defaultData:T.easing===5?ew.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(b&&M||b==="Base State"&&!M)&&(f.state=M??void 0)},onComplete:()=>{f.state=E??void 0}})),v(),this},play(){return p?(g=!0,p.play(Fs.time),p.isPlaying&&Fs.add(y),this):this},pause(){return p?.stop(),Fs.remove(y),this},reset(){return this.pause(),g=!1,v(),p?.seek(0),this},seek(b){let x=m.reduce((w,S)=>w+S.runner.duration,0);return x>0&&p?.seek(b/1e3/x),this}};return _.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{g||_.play()}),_},set color(h){let d=Sye(h);if(WL.is(e))return void(e.color=d);if(!(e.type==="Mesh"&&"material"in e&&e instanceof bl))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=e.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(h),n.shared.requestRender()))}let f=Array.isArray(e.material)?e.material[0]:e.material,m=f.data.layers.find(g=>g.data.type==="color")?.id;if(m)f.updateByOp({type:0,path:["layers",m],props:{color:{...c}}},f.data,n);else{let g=f.data,v=g.layers.find(S=>S.data.type==="light");if(!v)return;let y=g.layers.indexOf(v)===0?v:null,_=g.layers.at(y?g.layers.indexOf(y)+1:0),b={type:4,fi:y?y.fi+(_?(_.fi-y.fi)/2:1):_?_.fi/2:1,id:ht.generateUUID(),data:{...hs.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(y?.id??null,1),w=g.layers.runOp({...b,fi:x[0]}).data;Object.assign(f.data,{layers:w}),f.updateByOp({...b,path:["layers"]},f.data,n)}}},u=_j(l,(h,d)=>{let c=e[h],p=function(f){return f.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(f,m,g){let v=Array.isArray(g)?g[0]:g;if(f[0]==="layers"){let y=parseInt(f[1]),_=v.layers[y],b=f[2];_&&b&&function(x,w,S){let T=x[0];try{if(function(M,E){return!!A8e[E]?.includes(M)}(T,S.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let M=parseInt(x[1]),E=S.getValue(T)?.[M];if(!E)throw new Error("Color index out of range");cM.setStyle(w),E.set(cM.r,cM.g,cM.b,cM.a)}else S.getValue(T)?.setStyle(w);else if(T==="texture"||T==="video"){let M=S.color;(function(E,A,P,N){let D=E[0];if(D==="repeat"||D==="offset"||D==="rotation"){let O=N.getNode("mat"),z=O&&typeof O.updateMatrix=="function"?O:N.getValue("mat");if(!z)return;if(D==="rotation")z.rotation=parseFloat(A);else{let L=E[1];if(L===void 0)A instanceof Array&&A.length===2&&Object.assign(z,{[D]:A});else{let V=z[D],G=parseInt(L)===0?[parseFloat(A),V[1]]:[V[0],parseFloat(A)];Object.assign(z,{[D]:G})}}z.updateMatrix()}else D==="wrapping"||D==="minFilter"||D==="magFilter"?D==="wrapping"?P.texture.wrap=A:P.texture[D]=A:D==="image"&&E[1]==="data"&&P.texture.image.updateSrc(A)})(x.slice(1),w,M,S)}else{let M=x[1],E=S.getValue(T);E?.isVector3&&M!==void 0||E?.isVector2&&M!==void 0?E.setComponent(parseInt(M),w):S.setValue(T,w)}}catch(M){console.error("Error setting material value",M)}}(f.slice(2),m,_)}else f[0]==="alpha"&&v.layers.forEach(y=>{y.type==="light"&&y.node.alphaOverride!==void 0&&(y.node.alphaOverride.value=m,m<1&&(v.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(e,h)?.writable&&(e[h]=d),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,u),u}setUIWasmUrl(e){(function(t){NL=t,iB?.setHanaUIWasmUrl(t)})(e)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if(typeof t=="string"){if(!t.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(t)).arrayBuffer();i=new Uint8Array(l)}}else i=t;let r=mA.deserialize(i),n="data"in r&&r.data.draco!==void 0;n&&await fye(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!s)return void console.warn(`Object ${e} not found`);if(s.data.type!=="Mesh"||!(s instanceof bl))return void console.warn(`Object ${e} is not a mesh`);let a=s,o={...a.data,geometry:r};n&&await mye([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]=Dg.patch(o,u)}return i}_applyDocumentTransaction(e){this._data=e.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let t of e.actual){let i=t.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...t,path:[]},this._sharedAssetsManager)}}_findEntity(e){return this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e)}_resolveParentId(e){if(e===void 0)return this._scene.activePage.uuid;let t=typeof e=="string"?e:e.uuid,i=this._findEntity(t);if(!i)throw new Error(`parent '${t}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(e){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof e!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let t=bH();if(t===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(ij(),SO)),t=bH()),t===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=e(t);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(e,t){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 e=="string"?e:e.uuid,n=this._findEntity(r);if(!n)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(n instanceof bl))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let s=typeof t=="function"?await this.createCustomMaterial(t):t;if(GL()!=="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=_ye({material:s});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return n.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(n.uuid),this._requestRenderAutoMode(),a.material}async createObject(e,t={}){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 n=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${bye}.`);let v=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),y=v8e[v];if(y)return{objectType:y};let _=g8e[v];if(_)return{objectType:"Mesh",geometryType:_};let b=y8e[v];throw b?new Error(`createObject: '${g}' is not supported \u2014 ${b}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${bye}, e.g. createObject('Cube', { width: 200 }).`)}(e);typeof t.material=="function"&&(t={...t,material:await this.createCustomMaterial(t.material)});let s,a,{options:o,material:l}=_ye(t);if(l!==void 0){if(n.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(GL()!=="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(n.geometryType==="TextGeometry"){if(!tY.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 Y0e(),a=t.font??Rb,r.shared.fonts[a]===void 0){if(a!==Rb){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}s={name:Rb,url:S_e}}}let u=this._resolveParentId(t.parent),h=S8e(n,o,r),d=ht.generateUUID(),[c,p]=EM(r);s&&(c.shared.fonts[Rb]=s),c.scene.objects.insertAfter(u,null,[{id:d,data:h,children:[]}]);let f=p.result();if(s&&this._sharedAssetsManager.addFont(Rb,s),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(f);let m=i.find(d);return l!==void 0&&m.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(m)}cloneObject(e,t={}){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 n=typeof e=="string"?e:e?.uuid,s=n?this._findEntity(n):void 0;if(!s)throw new Error(`cloneObject: '${n}' \u2014 no object with that name or uuid in the scene.`);if(s instanceof Ks)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(s.uuid);if(!a)throw new Error(`cloneObject: '${n}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,f,m){let g={...p.data};return f.position!==void 0&&(g.position=kA(f.position,[0,0,0])),f.rotation!==void 0&&(g.rotation=kA(f.rotation,[0,0,0])),f.scale!==void 0&&(g.scale=XCe(f.scale)),f.visible!==void 0&&(g.visible=f.visible),g.name=f.name??YCe(`${p.data.name??"Object"} Copy`,m),{...p,data:g}}(T8e(a),t,r.scene.objects),l=t.parent!==void 0?this._resolveParentId(t.parent):r.scene.objects.parent(s.uuid)??null,u=t.parent!==void 0?null:s.uuid,[h,d]=EM(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(e){let t=this._scene,i=this._data;if(this.disposed||!t||!i)return!1;let r=typeof e=="string"?e:e?.uuid,n=r?this._findEntity(r):void 0;if(!n)return!1;if(n instanceof Ks)throw new Error("removeObject: pages cannot be removed.");if(n.data.type==="PerspectiveCamera"||n.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(n.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 s=[];n.traverseEntity(l=>{s.push(l.uuid)});let[a,o]=EM(i);a.scene.objects.delete(n.uuid),this._applyDocumentTransaction(o.result());for(let l of s){let u=this._proxyObjectCache.get(l);u&&(_j.unsubscribe(u),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var HB=window,qB=HB.ShadowRoot&&(HB.ShadyCSS===void 0||HB.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ZK=Symbol(),QCe=new WeakMap,nC=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==ZK)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(qB&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=QCe.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&QCe.set(i,t))}return t}toString(){return this.cssText}},JCe=e=>new nC(typeof e=="string"?e:e+"",void 0,ZK),QK=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,n,s)=>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.")})(n)+e[s+1],e[0]);return new nC(i,e,ZK)},JK=(e,t)=>{qB?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),n=HB.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=i.cssText,e.appendChild(r)})},$B=qB?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return JCe(i)})(e):e;var eZ,XB=window,e3e=XB.trustedTypes,P8e=e3e?e3e.emptyScript:"",t3e=XB.reactiveElementPolyfillSupport,iZ={toAttribute(e,t){switch(t){case Boolean:e=e?P8e:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},i3e=(e,t)=>t!==e&&(t==t||e==e),tZ={attribute:!0,type:String,converter:iZ,reflect:!1,hasChanged:i3e},rZ="finalized",Qf=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let n=this._$Ep(r,i);n!==void 0&&(this._$Ev.set(n,r),t.push(n))}),t}static createProperty(t,i=tZ){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,n=this.getPropertyDescriptor(t,r,i);n!==void 0&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(n){let s=this[t];this[i]=n,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||tZ}static finalize(){if(this.hasOwnProperty(rZ))return!1;this[rZ]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let n of r)this.createProperty(n,i[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let n of r)i.unshift($B(n))}else t!==void 0&&i.push($B(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return JK(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=tZ){var n;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let a=(((n=r.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?r.converter:iZ).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(t,i){var r;let n=this.constructor,s=n._$Ev.get(t);if(s!==void 0&&this._$El!==s){let a=n.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:iZ;this._$El=s,this[s]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let n=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||i3e)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((n,s)=>this[s]=n),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(n=>{var s;return(s=n.hostUpdate)===null||s===void 0?void 0:s.call(n)}),this.update(r)):this._$Ek()}catch(n){throw i=!1,this._$Ek(),n}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var n;return(n=r.hostUpdated)===null||n===void 0?void 0:n.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Qf[rZ]=!0,Qf.elementProperties=new Map,Qf.elementStyles=[],Qf.shadowRootOptions={mode:"open"},t3e?.({ReactiveElement:Qf}),((eZ=XB.reactiveElementVersions)!==null&&eZ!==void 0?eZ:XB.reactiveElementVersions=[]).push("1.6.3");var nZ,YB=window,Ow=YB.trustedTypes,r3e=Ow?Ow.createPolicy("lit-html",{createHTML:e=>e}):void 0,aZ="$lit$",s0=`lit$${(Math.random()+"").slice(9)}$`,u3e="?"+s0,R8e=`<${u3e}>`,m1=document,aC=()=>m1.createComment(""),oC=e=>e===null||typeof e!="object"&&typeof e!="function",d3e=Array.isArray,D8e=e=>d3e(e)||typeof e?.[Symbol.iterator]=="function",sZ=`[
|
|
12994
|
+
`,qCe=class{constructor(e,t,i,r,n,s){this.container=e,this.host=t,this.observer=i,this.spline=r,this.previousSplineGlobal=n,this.removeLateLifecycleShim=s}static mount(e,t,i,r){if(typeof document>"u")return null;let n=t.parentElement;if(!n)return null;getComputedStyle(n).position==="static"&&(n.style.position="relative");let s=document.createElement("div");s.setAttribute(PO,"");let a=s.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${t.offsetLeft}px`,a.top=`${t.offsetTop}px`,a.width=`${t.offsetWidth}px`,a.height=`${t.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(t),l.observe(n);let u=document.createElement("style");u.textContent=f8e,s.appendChild(u);let h=new DOMParser().parseFromString(i,"text/html"),d=Array.from(h.querySelectorAll("script"));for(let y of d)y.remove();for(let y of Array.from(h.head.children))(y.tagName==="STYLE"||y.tagName==="LINK"&&y.rel==="stylesheet")&&s.appendChild(y);for(;h.body.firstChild;)s.appendChild(h.body.firstChild);n.insertBefore(s,t.nextSibling);let c=new Map,p=new OX(WCe(e,t,r),(y,_)=>{y==="warn"?console.warn(`[spline html] ${_}`):y==="error"&&console.error(`[spline html] ${_}`)},(y,_)=>{let b=c.get(y);if(b)for(let x of b)try{x(_)}catch(w){console.error(w)}}),f=(y,_)=>{try{return Promise.resolve(p.execute(y,_))}catch(b){return Promise.reject(b)}},m={ready:Promise.resolve(),setVariable:(y,_)=>f("setVariable",[y,_]),setVariables:y=>f("setVariables",[y]),getVariable:y=>f("getVariable",[y]),getVariables:()=>f("getVariables",[]),getAllObjects:()=>f("getAllObjects",[]),findObjectByName:y=>f("findObjectByName",[y]),findObjectById:y=>f("findObjectById",[y]),getGeometry:(y,_)=>f("getGeometry",[y,_??{}]),updateObject:(y,_)=>f("updateObject",[y,_]),createObject:(y,_)=>f("createObject",[y,_??{}]),createCustomMaterial:y=>f("createCustomMaterial",[y]),getTexture:(y,_)=>f("getTexture",[y,_??{}]),setMaterial:(y,_)=>f("setMaterial",[y,_]),cloneObject:(y,_)=>f("cloneObject",[y,_??{}]),removeObject:y=>f("removeObject",[y]),spawnObject:(y,_)=>f("spawnObject",[y,_??{}]),destroyObject:y=>f("destroyObject",[y]),setInstanceTransforms:(y,_)=>f("setInstanceTransforms",[y,_??null]),emitEvent:(y,_)=>f("emitEvent",[y,_]),emitEventReverse:(y,_)=>f("emitEventReverse",[y,_]),requestRender:()=>f("requestRender",[]),addEventListener:(y,_)=>{if(typeof _!="function")return;let b=c.get(y);b||(b=new Set,c.set(y,b),f("listenEvent",[y])),b.add(_)},removeEventListener:(y,_)=>{let b=c.get(y);!b||(b.delete(_),b.size===0&&(c.delete(y),f("unlistenEvent",[y])))}},g=window.spline;window.spline=m;let v=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let y=[],_=(x,w)=>{let S=new Set,T=x.addEventListener.bind(x),M=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(E,A,P)=>{if(T(E,A,P),!w.includes(E)||A==null)return;let N={type:E,listener:A};S.add(N),queueMicrotask(()=>{!S.delete(N)||((D,O,z)=>{let L=new Event(z);try{typeof O=="function"?O.call(D,L):O.handleEvent?.(L)}catch(V){console.error(V)}})(x,N.listener,N.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(E,A,P)=>{M(E,A,P);for(let N of S)N.type===E&&N.listener===A&&S.delete(N)}}),y.push(()=>{delete x.addEventListener,delete x.removeEventListener,S.clear()})};_(document,["DOMContentLoaded"]),_(window,["load"]);let b=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(w){console.error(w)}})}}),y.push(()=>{b?Object.defineProperty(window,"onload",b):delete window.onload}),()=>{for(let x of y)x()}}();for(let y of d){let _=document.createElement("script");for(let b of Array.from(y.attributes))_.setAttribute(b.name,b.value);y.src?_.async=!1:_.textContent=y.textContent,s.appendChild(_)}return new qCe(s,p,l,m,g,v)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function $Ce(e){return typeof e=="object"&&e!==null&&e.isMaterial===!0}function _ye(e){if(typeof e.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(!$Ce(e.material))return{options:e};let t=e.material;if(t.isNodeMaterial===!0){let i=bH()?.NodeMaterial;if(i!==void 0&&t instanceof i)return{options:{...e,material:void 0},material:t};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(t.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:{...e,material:void 0},material:t}}jt(),Ir(),oe(),Mxe(),bu(),Ir(),jt(),ELe(),Yf();var m8e=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),bye="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",g8e={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"},v8e={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},y8e={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')."},_8e={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"},b8e={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function kA(e,t){return e===void 0?[t[0],t[1],t[2]]:Array.isArray(e)?[e[0]??t[0],e[1]??t[1],e[2]??t[2]]:[e.x??t[0],e.y??t[1],e.z??t[2]]}function XCe(e){return typeof e=="number"?[e,e,e]:kA(e,[1,1,1])}function hX(e){let t=new zr(0,0,0,1);return t.setStyle(e),{r:t.r,g:t.g,b:t.b}}function xye(e,t){let i=e.material??(e.color!==void 0?{color:e.color}:void 0);if(i===void 0)return ns.defaultColorMaterial(wye(eo),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(t.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)||ot.NAMES[o]!==void 0}(i))return ns.defaultColorMaterial(hX(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)"}(t)}) 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($Ce(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?hX(i.color):wye(eo),n=ns.defaultColorMaterial(r,"physical","layer1","layer2"),s=n.layers.find(a=>a.data.type==="light");if(s){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(s.data,a)}if(i.alpha!==void 0){let a=n.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return n}function wye(e){return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}}function x8e(e){let t=df.defaultData("TextGeometry"),{text:i,...r}=e,n=r.fontSize;return n!==void 0&&r.width===void 0&&(r.width=350*n/16),n!==void 0&&r.height===void 0&&(r.height=50*n/16),Object.assign(t,r),i!==void 0&&Object.assign(t,{text:{textValue:String(i)}}),t}function uI(e){return Array.isArray(e)?e:!ArrayBuffer.isView(e)||e instanceof DataView?null:Array.from(e)}function w8e(e,t){return Z_e({userData:{type:e,...yH[e].normalizeInputs({parameters:t})}})}function S8e(e,t,i){let{objectType:r,geometryType:n}=e,s=function(l){let u={};for(let[h,d]of Object.entries(l))!m8e.has(h)&&d!==void 0&&(u[h]=d);return u}(t),a={states:new It,events:new It};if(r==="Mesh"&&n){if(n==="NonParametricGeometry"){let{geometry:l,doubleSide:u}=function(h){let d=uI(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=uI(h.indices);if(p&&p.length){let _=p.find(b=>!Number.isInteger(b)||b<0||b>=c);if(_!==void 0)throw new Error(`createObject('CustomMesh'): index ${_} is out of range (mesh has ${c} vertices).`)}else p=null;let f=new At;f.setAttribute("position",new Et(d,3));let m=uI(h.normals),g=m!==null&&m.length===d.length;g&&f.setAttribute("normal",new Et(m,3));let v=uI(h.uvs);v&&v.length===2*c&&f.setAttribute("uv",new Et(v,2));let y=!1;if(!g){let _=p??Array.from({length:c},(w,S)=>S),{closed:b,inverted:x}=function(w,S){let T=w.length/3,M=new Map,E=new Array(T);for(let D=0;D<T;D++){let O=`${Math.round(1e4*w[3*D])},${Math.round(1e4*w[3*D+1])},${Math.round(1e4*w[3*D+2])}`,z=M.get(O);z===void 0?(M.set(O,D),E[D]=D):E[D]=z}let A=new Map;for(let D=0;D+2<S.length;D+=3){let O=E[S[D]],z=E[S[D+1]],L=E[S[D+2]];for(let[V,G]of[[O,z],[z,L],[L,O]]){if(V===G)continue;let Y=V<G?V+"_"+G:G+"_"+V;A.set(Y,(A.get(Y)??0)+1)}}let P=A.size>0;for(let D of A.values())if(D!==2){P=!1;break}if(!P)return{closed:!1,inverted:!1};let N=0;for(let D=0;D+2<S.length;D+=3){let O=3*S[D],z=3*S[D+1],L=3*S[D+2],V=w[O],G=w[O+1],Y=w[O+2],$=w[z],Q=w[z+1],ue=w[z+2],pe=w[L],xe=w[L+1],we=w[L+2];N+=V*(Q*we-ue*xe)+G*(ue*pe-$*we)+Y*($*xe-Q*pe)}return{closed:!0,inverted:N<0}}(d,_);if(b&&x){for(let w=0;w+2<_.length;w+=3){let S=_[w+1];_[w+1]=_[w+2],_[w+2]=S}p=_}else b||(y=!0)}return p&&f.setIndex(p),g||f.computeVertexNormals(),{geometry:Z_e({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:f.toJSON().data}),doubleSide:y}}(s);Object.assign(a,_c.defaultData,{geometry:l,materials:[xye(t,i)]}),u&&(a.side=2)}else Object.assign(a,_c.defaultData,{geometry:n==="TextGeometry"?x8e(s):w8e(n,s),material:xye(t,i)});t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow)}else r==="Empty"?Object.assign(a,SL.defaultData):(Object.assign(a,TL.defaultData(r),s),t.color!==void 0&&(a.color=hX(t.color)));a.visible=t.visible??!0,a.position=kA(t.position,[0,0,0]),a.rotation=kA(t.rotation,[0,0,0]),a.scale=XCe(t.scale);let o=(n&&_8e[n])??b8e[r]??r;return a.name=t.name??YCe(o,i.scene.objects),a}function YCe(e,t){let i=new Set;if(t.traverse((n,s)=>{i.add(s.name??"")}),!i.has(e))return e;let r=2;for(;i.has(`${e} ${r}`);)r++;return`${e} ${r}`}function KCe(e,t){let i=ht.generateUUID();if(e.data.type==="Component")return{data:{...wf.fromComponentData(e),name:e.data.name+" Instance"},id:i,fi:e.fi,children:[]};t[e.id]=i;let r=e.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:r.animations.map(([n,s,a])=>{let o=ht.generateUUID(),l=a.indexOf(n);return[o,s,l!==-1?a.slice(0,l)+o+a.slice(l+n.length):a]})}),{...e,id:i,data:r,children:e.children.map(n=>KCe(n,t))}}function T8e(e){let t={};return function(i,r){return _x(i,r,null)??i}(KCe(e,t),t)}function M8e(e){let t=Array.isArray(e)?e[0]:e,i=t.layers?.map(E8e)??[],r=t.layers?.find(n=>n.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function E8e(e){return e.type==="texture"||e.type==="video"||e.type==="matcap"?{...e.data,updateTexture:t=>e.color.texture.image.updateSrc(t)}:{...e.data}}Yf(),ss(),uY(),bu();var cM=new zr(0,0,0,1),A8e={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:[]};jt(),jt();var C8e=new Z;function Sye(e){let t=new zr(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}return t}var ZCe=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r,renderer:n,htmlContentMode:s="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<J_e?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),t1(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=C8e.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=fA(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this._htmlContentMode=s,this.renderMode=t?"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=n??"webgl",n===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(()=>(UBe(),_Te)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",qJ,!0),a.addEventListener("pointerdown",n3,!0),a.addEventListener("pointermove",n3,!0),a.addEventListener("pointerup",k1,!0),a.addEventListener("pointercancel",k1,!0),a.addEventListener("pointerleave",k1,!0),window.addEventListener("keydown",$J,!0),window.addEventListener("keyup",XJ,!0)}(e)}async _initRenderer(){if(this.disposed)return null;let e=await this._createRenderer();return this.disposed?(this._disposeRenderer(e),null):e}_disposeRenderer(e){let t=function(r){let n=r.backend;if(n!==void 0)return n.isWebGLBackend===!0?n.gl??null:null;let s=r.getContext,a=typeof s=="function"?s.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(e);if(t&&!function(r,n){return vye.get(r)===n}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(e)||e.dispose());let i=t?function(r,n){let s=n.getExtension("WEBGL_lose_context");if(!s||n.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=yye(r,"webglcontextlost",u=>{u.preventDefault(),l(s)})});return oI.set(r,{gl:n,lost:o,stopListening:a}),()=>{n.isContextLost()||s.loseContext()}}(this.canvas,t):void 0;try{e.dispose()}finally{i?.()}}async _createRenderer(){if(function(e,t){vye.set(e,t)}(this.canvas,this),await async function(e){let t=oI.get(e);if(t&&(t.restoring??(t.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let n,s=()=>{},a=r.lost.then(l=>new Promise(u=>{s=yye(i,"webglcontextrestored",()=>u()),l.restoreContext()})),o=new Promise(l=>{n=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(n),s(),r.stopListening()}(e,t).finally(()=>{t.restoring=void 0,!t.gl.isContextLost()&&oI.get(e)===t&&oI.delete(e)})),await t.restoring,t.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:e,isWebGPUSupported:t}=await Promise.resolve().then(()=>(ij(),SO));t();let i=!0,r=!1,n=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"?n=!1:(l==="on"||l==="1"||l==="true"||l==="always")&&(n=!0)}catch{}let s=await e({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&n});return s.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},s.skyAnimationAllowed=!0,s}catch(e){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",e),this._rendererBackend="webgl"}{let{SplineRenderer:e,rendererGlobals:t}=await Promise.resolve().then(()=>(d0e(),O$));try{new URLSearchParams(window.location.search).get("taa")==="off"&&(t.taaEnabled.value=!1)}catch{}return new e({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"})}}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let e=window.devicePixelRatio||1,t=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=t*e,this.canvas.height=i*e;let r=this.canvas.getContext("2d");r&&(r.scale(e,e),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.",t/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(e,t,i){(function(n){let s="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(s+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(s)})(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;Fs.init();let r=await async function(c){let[p,f]=EM(mA.deserialize(new Uint8Array(c)));if((p.schema??0)!==132){let{updateDocumentSchema:m}=await Promise.resolve().then(()=>(J4(),V_e));m(p)}return f.result().data}(e);this._data=r;let n=function(c){let p=[];return c.scene.objects.traverse((f,m)=>{m.type==="Mesh"&&m.geometry.type==="NonParametricGeometry"&&m.geometry.data.draco!==void 0&&p.push(m)}),p}(r);r.version&&(0,c8e.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){Rwe=c}(this._wasmPath));let s=async function(){}();await Promise.all([s,n.length&&fye(this._wasmPath),ere(r)&&OLe(this._wasmPath),t4e(r)&&e4e(this._wasmPath),T4e(r)&&l4e(this._wasmPath),e1.physicsEnabled(r.scene.objects)&&mke(this._wasmPath),iie(r)&&Y0e(),xre(r)&&q4e(),jLe(r)&&GLe(),V0e(r)&&s.then(()=>qW()?.loadHanaUIRUNTIME()),lke(r)&&Dke(this._wasmPath)].filter(Boolean)),n.length&&await mye(n),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((f,m)=>{if(m.type!=="Page")return;let g=m.postprocessing;if(g&&typeof g=="object"&&g.enabled===!0)for(let[v,y]of Object.entries(g))v!=="enabled"&&y&&typeof y=="object"&&y.enabled===!0&&p.add(v)}),[...p]}(r);if(this._rendererBackend==="webgpu")try{if(await Promise.all([Promise.resolve().then(()=>(ij(),SO)),d8e(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"}this._rendererBackend!=="webgpu"&&await Promise.all([Promise.resolve().then(()=>(d0e(),O$)),u8e(o)]),function(c){XA=c}(this._rendererBackend==="webgpu"?"webgpu":"webgl");let l=new n8e(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(()=>($5e(),CAe)),p=performance.now();c(r,l.scene);let f=performance.now();console.log("Merged geometries in ",f-p," ms")}ere(r)&&this._scene.traverse(c=>{Fc(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{ex(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()),t1(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())}),iie(r)&&function(c){if(e1.physicsEnabled(c.scene.objects))return!0;let p=!1;return c.scene.objects.traverse((f,m)=>{if(m.events){if(Array.isArray(m.events)){for(let g of m.events)if(g.data.disabled!==!0&&g.data.type==="GameControl"&&g.data.collisionEnabled){p=!0;break}}else for(let g of Object.values(m.events))if(g.disabled!==!0&&g.type==="GameControl"&&g.collisionEnabled){p=!0;break}}}),p}(r)&&await Promise.all(u),V0e(r)){let c=[];this._scene.traverseEntity(p=>{(Xo(p)||p instanceof Ks)&&p.uiCanvas&&c.push(p.uiCanvas)}),await Promise.all(c.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),KK(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 f=this._sharedAssetsManager.getImage("SplineWatermark");await f.loadPromise;let m=f.getTexture(1001);this._renderer.pipeline.setWatermark(m)}}xre(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 Cze(this._renderer,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),t){let c=new oze(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new _ke(c),this._animationControls=new o8e(this._scene,this._requestRenderAutoMode),this._eventManager=new wze(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),t&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let d=r.scene.publish.htmlContent?.html;if(t&&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"?qCe.mount(this,this.canvas,d,c):HCe.mount(this,this.canvas,d,c))??void 0}}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){if(t==null)return void console.warn(`Variable ${e} was not updated: received ${t}. Pass a number, boolean or string.`);let r=t;if(typeof i.data.value=="number"){if(r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t),!Number.isFinite(r))return void console.warn(`Variable ${e} is a number variable and ${JSON.stringify(t)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()!=="false"&&!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let n=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,n),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&Eo.isTextValue(e)?Eo.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(!(t.uuid===o1||this._scene.isInvisibleObjects(t)||t instanceof Ks)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof WAe&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=Sye(e);this._scene?.activePage.setBackgroundColor(t),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,AE&&AE.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{_j.unsubscribe(e)}),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(e){e.removeEventListener("pointerdown",qJ,!0),e.removeEventListener("pointerdown",n3,!0),e.removeEventListener("pointermove",n3,!0),e.removeEventListener("pointerup",k1,!0),e.removeEventListener("pointercancel",k1,!0),e.removeEventListener("pointerleave",k1,!0),window.removeEventListener("keydown",$J,!0),window.removeEventListener("keyup",XJ,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Fs.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(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t,i=this._scene;if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);e.traverseAncestors(h=>{h instanceof Ks&&(t=h.name)});let r=this._sharedAssetsManager,n={shared:r,scene:this._scene},s=h=>{if(h===null||h==="Base State")return null;if(h&&e.data.states){let d=e.data.states.find(c=>c.data.name===h);return d?d.id:void 0}},a="material"in e?e.material:void 0,o=e.materialOverride,l={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,material:o??(a?M8e(a):void 0),parentUuid:e.parent instanceof Ks||e instanceof Og?void 0:e.parent?.uuid,emitEvent(h){e.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){e.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){e.visible&&(e.visible=!1,n.shared.requestRender())},show(){e.visible||(e.visible=!0,n.shared.requestRender())},get state(){let h=e.stateSelection;if(h!==null)return e.data.states.find(({id:d})=>d===h)?.data.name},set state(h){let d;if(h!==void 0){let c=typeof h=="string"?e.data.states.find(({id:p})=>p===h):e.data.states[h];if(c)d=c.id;else{let p=typeof h=="string"?s(h):void 0;p&&(d=p)}}e.changeSelectedState(d??null,n),e.currentState=d??null,e.dispatchEvent({type:"completeState",state:d??null}),n.shared.requestRender()},transition(h){let d=GCe;if(d===null)return Ma("transitions","obj.transition()"),{transition(b){return this},play(){return this},pause(){return this},reset(){return this},seek(b){return this}};let c,p,f=this,m=[],g=!1,v=()=>{p=new ECe({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},m.map(b=>b.runner))},y={update(b){p?.update(b),p?.isPlaying!==!0&&Fs.remove(y)}},_={transition({from:b,to:x,duration:w,delay:S,...T}){let M=s(b);M===void 0&&(M=c);let E=s(x);return c=E,m.push(new d(e,M,E,{state:E,repeat:0,delay:S??0,delayDirection:"start-once",direction:"normal",duration:w??1e3,...T,...T.easing===6?Pg.defaultData:T.easing===5?ew.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(b&&M||b==="Base State"&&!M)&&(f.state=M??void 0)},onComplete:()=>{f.state=E??void 0}})),v(),this},play(){return p?(g=!0,p.play(Fs.time),p.isPlaying&&Fs.add(y),this):this},pause(){return p?.stop(),Fs.remove(y),this},reset(){return this.pause(),g=!1,v(),p?.seek(0),this},seek(b){let x=m.reduce((w,S)=>w+S.runner.duration,0);return x>0&&p?.seek(b/1e3/x),this}};return _.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{g||_.play()}),_},set color(h){let d=Sye(h);if(WL.is(e))return void(e.color=d);if(!(e.type==="Mesh"&&"material"in e&&e instanceof bl))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=e.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(h),n.shared.requestRender()))}let f=Array.isArray(e.material)?e.material[0]:e.material,m=f.data.layers.find(g=>g.data.type==="color")?.id;if(m)f.updateByOp({type:0,path:["layers",m],props:{color:{...c}}},f.data,n);else{let g=f.data,v=g.layers.find(S=>S.data.type==="light");if(!v)return;let y=g.layers.indexOf(v)===0?v:null,_=g.layers.at(y?g.layers.indexOf(y)+1:0),b={type:4,fi:y?y.fi+(_?(_.fi-y.fi)/2:1):_?_.fi/2:1,id:ht.generateUUID(),data:{...hs.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(y?.id??null,1),w=g.layers.runOp({...b,fi:x[0]}).data;Object.assign(f.data,{layers:w}),f.updateByOp({...b,path:["layers"]},f.data,n)}}},u=_j(l,(h,d)=>{let c=e[h],p=function(f){return f.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(f,m,g){let v=Array.isArray(g)?g[0]:g;if(f[0]==="layers"){let y=parseInt(f[1]),_=v.layers[y],b=f[2];_&&b&&function(x,w,S){let T=x[0];try{if(function(M,E){return!!A8e[E]?.includes(M)}(T,S.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let M=parseInt(x[1]),E=S.getValue(T)?.[M];if(!E)throw new Error("Color index out of range");cM.setStyle(w),E.set(cM.r,cM.g,cM.b,cM.a)}else S.getValue(T)?.setStyle(w);else if(T==="texture"||T==="video"){let M=S.color;(function(E,A,P,N){let D=E[0];if(D==="repeat"||D==="offset"||D==="rotation"){let O=N.getNode("mat"),z=O&&typeof O.updateMatrix=="function"?O:N.getValue("mat");if(!z)return;if(D==="rotation")z.rotation=parseFloat(A);else{let L=E[1];if(L===void 0)A instanceof Array&&A.length===2&&Object.assign(z,{[D]:A});else{let V=z[D],G=parseInt(L)===0?[parseFloat(A),V[1]]:[V[0],parseFloat(A)];Object.assign(z,{[D]:G})}}z.updateMatrix()}else D==="wrapping"||D==="minFilter"||D==="magFilter"?D==="wrapping"?P.texture.wrap=A:P.texture[D]=A:D==="image"&&E[1]==="data"&&P.texture.image.updateSrc(A)})(x.slice(1),w,M,S)}else{let M=x[1],E=S.getValue(T);E?.isVector3&&M!==void 0||E?.isVector2&&M!==void 0?E.setComponent(parseInt(M),w):S.setValue(T,w)}}catch(M){console.error("Error setting material value",M)}}(f.slice(2),m,_)}else f[0]==="alpha"&&v.layers.forEach(y=>{y.type==="light"&&y.node.alphaOverride!==void 0&&(y.node.alphaOverride.value=m,m<1&&(v.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(e,h)?.writable&&(e[h]=d),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,u),u}setUIWasmUrl(e){(function(t){NL=t,iB?.setHanaUIWasmUrl(t)})(e)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if(typeof t=="string"){if(!t.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(t)).arrayBuffer();i=new Uint8Array(l)}}else i=t;let r=mA.deserialize(i),n="data"in r&&r.data.draco!==void 0;n&&await fye(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!s)return void console.warn(`Object ${e} not found`);if(s.data.type!=="Mesh"||!(s instanceof bl))return void console.warn(`Object ${e} is not a mesh`);let a=s,o={...a.data,geometry:r};n&&await mye([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]=Dg.patch(o,u)}return i}_applyDocumentTransaction(e){this._data=e.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let t of e.actual){let i=t.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...t,path:[]},this._sharedAssetsManager)}}_findEntity(e){return this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e)}_resolveParentId(e){if(e===void 0)return this._scene.activePage.uuid;let t=typeof e=="string"?e:e.uuid,i=this._findEntity(t);if(!i)throw new Error(`parent '${t}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(e){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof e!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let t=bH();if(t===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(ij(),SO)),t=bH()),t===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=e(t);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(e,t){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 e=="string"?e:e.uuid,n=this._findEntity(r);if(!n)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(n instanceof bl))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let s=typeof t=="function"?await this.createCustomMaterial(t):t;if(GL()!=="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=_ye({material:s});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return n.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(n.uuid),this._requestRenderAutoMode(),a.material}async createObject(e,t={}){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 n=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${bye}.`);let v=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),y=v8e[v];if(y)return{objectType:y};let _=g8e[v];if(_)return{objectType:"Mesh",geometryType:_};let b=y8e[v];throw b?new Error(`createObject: '${g}' is not supported \u2014 ${b}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${bye}, e.g. createObject('Cube', { width: 200 }).`)}(e);typeof t.material=="function"&&(t={...t,material:await this.createCustomMaterial(t.material)});let s,a,{options:o,material:l}=_ye(t);if(l!==void 0){if(n.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(GL()!=="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(n.geometryType==="TextGeometry"){if(!tY.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 Y0e(),a=t.font??Rb,r.shared.fonts[a]===void 0){if(a!==Rb){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}s={name:Rb,url:S_e}}}let u=this._resolveParentId(t.parent),h=S8e(n,o,r),d=ht.generateUUID(),[c,p]=EM(r);s&&(c.shared.fonts[Rb]=s),c.scene.objects.insertAfter(u,null,[{id:d,data:h,children:[]}]);let f=p.result();if(s&&this._sharedAssetsManager.addFont(Rb,s),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(f);let m=i.find(d);return l!==void 0&&m.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(m)}cloneObject(e,t={}){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 n=typeof e=="string"?e:e?.uuid,s=n?this._findEntity(n):void 0;if(!s)throw new Error(`cloneObject: '${n}' \u2014 no object with that name or uuid in the scene.`);if(s instanceof Ks)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(s.uuid);if(!a)throw new Error(`cloneObject: '${n}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,f,m){let g={...p.data};return f.position!==void 0&&(g.position=kA(f.position,[0,0,0])),f.rotation!==void 0&&(g.rotation=kA(f.rotation,[0,0,0])),f.scale!==void 0&&(g.scale=XCe(f.scale)),f.visible!==void 0&&(g.visible=f.visible),g.name=f.name??YCe(`${p.data.name??"Object"} Copy`,m),{...p,data:g}}(T8e(a),t,r.scene.objects),l=t.parent!==void 0?this._resolveParentId(t.parent):r.scene.objects.parent(s.uuid)??null,u=t.parent!==void 0?null:s.uuid,[h,d]=EM(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(e){let t=this._scene,i=this._data;if(this.disposed||!t||!i)return!1;let r=typeof e=="string"?e:e?.uuid,n=r?this._findEntity(r):void 0;if(!n)return!1;if(n instanceof Ks)throw new Error("removeObject: pages cannot be removed.");if(n.data.type==="PerspectiveCamera"||n.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(n.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 s=[];n.traverseEntity(l=>{s.push(l.uuid)});let[a,o]=EM(i);a.scene.objects.delete(n.uuid),this._applyDocumentTransaction(o.result());for(let l of s){let u=this._proxyObjectCache.get(l);u&&(_j.unsubscribe(u),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var HB=window,qB=HB.ShadowRoot&&(HB.ShadyCSS===void 0||HB.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ZK=Symbol(),QCe=new WeakMap,nC=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==ZK)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(qB&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=QCe.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&QCe.set(i,t))}return t}toString(){return this.cssText}},JCe=e=>new nC(typeof e=="string"?e:e+"",void 0,ZK),QK=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,n,s)=>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.")})(n)+e[s+1],e[0]);return new nC(i,e,ZK)},JK=(e,t)=>{qB?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),n=HB.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=i.cssText,e.appendChild(r)})},$B=qB?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return JCe(i)})(e):e;var eZ,XB=window,e3e=XB.trustedTypes,P8e=e3e?e3e.emptyScript:"",t3e=XB.reactiveElementPolyfillSupport,iZ={toAttribute(e,t){switch(t){case Boolean:e=e?P8e:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},i3e=(e,t)=>t!==e&&(t==t||e==e),tZ={attribute:!0,type:String,converter:iZ,reflect:!1,hasChanged:i3e},rZ="finalized",Qf=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let n=this._$Ep(r,i);n!==void 0&&(this._$Ev.set(n,r),t.push(n))}),t}static createProperty(t,i=tZ){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,n=this.getPropertyDescriptor(t,r,i);n!==void 0&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(n){let s=this[t];this[i]=n,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||tZ}static finalize(){if(this.hasOwnProperty(rZ))return!1;this[rZ]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let n of r)this.createProperty(n,i[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let n of r)i.unshift($B(n))}else t!==void 0&&i.push($B(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return JK(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=tZ){var n;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let a=(((n=r.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?r.converter:iZ).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(t,i){var r;let n=this.constructor,s=n._$Ev.get(t);if(s!==void 0&&this._$El!==s){let a=n.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:iZ;this._$El=s,this[s]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let n=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||i3e)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((n,s)=>this[s]=n),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(n=>{var s;return(s=n.hostUpdate)===null||s===void 0?void 0:s.call(n)}),this.update(r)):this._$Ek()}catch(n){throw i=!1,this._$Ek(),n}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var n;return(n=r.hostUpdated)===null||n===void 0?void 0:n.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Qf[rZ]=!0,Qf.elementProperties=new Map,Qf.elementStyles=[],Qf.shadowRootOptions={mode:"open"},t3e?.({ReactiveElement:Qf}),((eZ=XB.reactiveElementVersions)!==null&&eZ!==void 0?eZ:XB.reactiveElementVersions=[]).push("1.6.3");var nZ,YB=window,Ow=YB.trustedTypes,r3e=Ow?Ow.createPolicy("lit-html",{createHTML:e=>e}):void 0,aZ="$lit$",s0=`lit$${(Math.random()+"").slice(9)}$`,u3e="?"+s0,R8e=`<${u3e}>`,m1=document,aC=()=>m1.createComment(""),oC=e=>e===null||typeof e!="object"&&typeof e!="function",d3e=Array.isArray,D8e=e=>d3e(e)||typeof e?.[Symbol.iterator]=="function",sZ=`[
|
|
12995
12995
|
\f\r]`,sC=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,n3e=/-->/g,s3e=/>/g,p1=RegExp(`>|${sZ}(?:([^\\s"'>=/]+)(${sZ}*=${sZ}*(?:[^
|
|
12996
12996
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),a3e=/'/g,o3e=/"/g,c3e=/^(?:script|style|textarea|title)$/i,p3e=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),f3e=p3e(1),zit=p3e(2),g1=Symbol.for("lit-noChange"),ro=Symbol.for("lit-nothing"),l3e=new WeakMap,f1=m1.createTreeWalker(m1,129,null,!1);function m3e(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return r3e!==void 0?r3e.createHTML(t):t}var N8e=(e,t)=>{let i=e.length-1,r=[],n,s=t===2?"<svg>":"",a=sC;for(let o=0;o<i;o++){let l=e[o],u,h,d=-1,c=0;for(;c<l.length&&(a.lastIndex=c,h=a.exec(l),h!==null);)c=a.lastIndex,a===sC?h[1]==="!--"?a=n3e:h[1]!==void 0?a=s3e:h[2]!==void 0?(c3e.test(h[2])&&(n=RegExp("</"+h[2],"g")),a=p1):h[3]!==void 0&&(a=p1):a===p1?h[0]===">"?(a=n??sC,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,u=h[1],a=h[3]===void 0?p1:h[3]==='"'?o3e:a3e):a===o3e||a===a3e?a=p1:a===n3e||a===s3e?a=sC:(a=p1,n=void 0);let p=a===p1&&e[o+1].startsWith("/>")?" ":"";s+=a===sC?l+R8e:d>=0?(r.push(u),l.slice(0,d)+aZ+l.slice(d)+s0+p):l+s0+(d===-2?(r.push(void 0),o):p)}return[m3e(e,s+(e[i]||"<?>")+(t===2?"</svg>":"")),r]},v1=class{constructor({strings:t,_$litType$:i},r){let n;this.parts=[];let s=0,a=0,o=t.length-1,l=this.parts,[u,h]=N8e(t,i);if(this.el=v1.createElement(u,r),f1.currentNode=this.el.content,i===2){let d=this.el.content,c=d.firstChild;c.remove(),d.append(...c.childNodes)}for(;(n=f1.nextNode())!==null&&l.length<o;){if(n.nodeType===1){if(n.hasAttributes()){let d=[];for(let c of n.getAttributeNames())if(c.endsWith(aZ)||c.startsWith(s0)){let p=h[a++];if(d.push(c),p!==void 0){let f=n.getAttribute(p.toLowerCase()+aZ).split(s0),m=/([.?@])?(.*)/.exec(p);l.push({type:1,index:s,name:m[2],strings:f,ctor:m[1]==="."?lZ:m[1]==="?"?hZ:m[1]==="@"?uZ:Bw})}else l.push({type:6,index:s})}for(let c of d)n.removeAttribute(c)}if(c3e.test(n.tagName)){let d=n.textContent.split(s0),c=d.length-1;if(c>0){n.textContent=Ow?Ow.emptyScript:"";for(let p=0;p<c;p++)n.append(d[p],aC()),f1.nextNode(),l.push({type:2,index:++s});n.append(d[c],aC())}}}else if(n.nodeType===8)if(n.data===u3e)l.push({type:2,index:s});else{let d=-1;for(;(d=n.data.indexOf(s0,d+1))!==-1;)l.push({type:7,index:s}),d+=s0.length-1}s++}}static createElement(t,i){let r=m1.createElement("template");return r.innerHTML=t,r}};function Lw(e,t,i=e,r){var n,s,a,o;if(t===g1)return t;let l=r!==void 0?(n=i._$Co)===null||n===void 0?void 0:n[r]:i._$Cl,u=oC(t)?void 0:t._$litDirective$;return l?.constructor!==u&&((s=l?._$AO)===null||s===void 0||s.call(l,!1),u===void 0?l=void 0:(l=new u(e),l._$AT(e,i,r)),r!==void 0?((a=(o=i)._$Co)!==null&&a!==void 0?a:o._$Co=[])[r]=l:i._$Cl=l),l!==void 0&&(t=Lw(e,l._$AS(e,t.values),l,r)),t}var oZ=class{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;let{el:{content:r},parts:n}=this._$AD,s=((i=t?.creationScope)!==null&&i!==void 0?i:m1).importNode(r,!0);f1.currentNode=s;let a=f1.nextNode(),o=0,l=0,u=n[0];for(;u!==void 0;){if(o===u.index){let h;u.type===2?h=new y1(a,a.nextSibling,this,t):u.type===1?h=new u.ctor(a,u.name,u.strings,this,t):u.type===6&&(h=new dZ(a,this,t)),this._$AV.push(h),u=n[++l]}o!==u?.index&&(a=f1.nextNode(),o++)}return f1.currentNode=m1,s}v(t){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,i),i+=r.strings.length-2):r._$AI(t[i])),i++}},y1=class{constructor(t,i,r,n){var s;this.type=2,this._$AH=ro,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=r,this.options=n,this._$Cp=(s=n?.isConnected)===null||s===void 0||s}get _$AU(){var t,i;return(i=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&i!==void 0?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode,i=this._$AM;return i!==void 0&&t?.nodeType===11&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=Lw(this,t,i),oC(t)?t===ro||t==null||t===""?(this._$AH!==ro&&this._$AR(),this._$AH=ro):t!==this._$AH&&t!==g1&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):D8e(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==ro&&oC(this._$AH)?this._$AA.nextSibling.data=t:this.$(m1.createTextNode(t)),this._$AH=t}g(t){var i;let{values:r,_$litType$:n}=t,s=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=v1.createElement(m3e(n.h,n.h[0]),this.options)),n);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===s)this._$AH.v(r);else{let a=new oZ(s,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(t){let i=l3e.get(t.strings);return i===void 0&&l3e.set(t.strings,i=new v1(t)),i}T(t){d3e(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,n=0;for(let s of t)n===i.length?i.push(r=new y1(this.k(aC()),this.k(aC()),this,this.options)):r=i[n],r._$AI(s),n++;n<i.length&&(this._$AR(r&&r._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,i);t&&t!==this._$AB;){let n=t.nextSibling;t.remove(),t=n}}setConnected(t){var i;this._$AM===void 0&&(this._$Cp=t,(i=this._$AP)===null||i===void 0||i.call(this,t))}},Bw=class{constructor(t,i,r,n,s){this.type=1,this._$AH=ro,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ro}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,r,n){let s=this.strings,a=!1;if(s===void 0)t=Lw(this,t,i,0),a=!oC(t)||t!==this._$AH&&t!==g1,a&&(this._$AH=t);else{let o=t,l,u;for(t=s[0],l=0;l<s.length-1;l++)u=Lw(this,o[r+l],i,l),u===g1&&(u=this._$AH[l]),a||(a=!oC(u)||u!==this._$AH[l]),u===ro?t=ro:t!==ro&&(t+=(u??"")+s[l+1]),this._$AH[l]=u}a&&!n&&this.j(t)}j(t){t===ro?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},lZ=class extends Bw{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ro?void 0:t}},I8e=Ow?Ow.emptyScript:"",hZ=class extends Bw{constructor(){super(...arguments),this.type=4}j(t){t&&t!==ro?this.element.setAttribute(this.name,I8e):this.element.removeAttribute(this.name)}},uZ=class extends Bw{constructor(t,i,r,n,s){super(t,i,r,n,s),this.type=5}_$AI(t,i=this){var r;if((t=(r=Lw(this,t,i,0))!==null&&r!==void 0?r:ro)===g1)return;let n=this._$AH,s=t===ro&&n!==ro||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,a=t!==ro&&(n===ro||s);s&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){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,t):this._$AH.handleEvent(t)}},dZ=class{constructor(t,i,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Lw(this,t)}};var h3e=YB.litHtmlPolyfillSupport;h3e?.(v1,y1),((nZ=YB.litHtmlVersions)!==null&&nZ!==void 0?nZ:YB.litHtmlVersions=[]).push("2.8.0");var lC=(e,t,i)=>{var r,n;let s=(r=i?.renderBefore)!==null&&r!==void 0?r:t,a=s._$litPart$;if(a===void 0){let o=(n=i?.renderBefore)!==null&&n!==void 0?n:null;s._$litPart$=a=new y1(t.insertBefore(aC(),o),o,void 0,i??{})}return a._$AI(e),a};var cZ,pZ;var a0=class extends Qf{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;let r=super.createRenderRoot();return(t=(i=this.renderOptions).renderBefore)!==null&&t!==void 0||(i.renderBefore=r.firstChild),r}update(t){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=lC(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return g1}};a0.finalized=!0,a0._$litElement$=!0,(cZ=globalThis.litElementHydrateSupport)===null||cZ===void 0||cZ.call(globalThis,{LitElement:a0});var g3e=globalThis.litElementPolyfillSupport;g3e?.({LitElement:a0});((pZ=globalThis.litElementVersions)!==null&&pZ!==void 0?pZ:globalThis.litElementVersions=[]).push("3.3.3");var v3e=e=>t=>typeof t=="function"?((i,r)=>(customElements.define(i,r),r))(e,t):((i,r)=>{let{kind:n,elements:s}=r;return{kind:n,elements:s,finisher(a){customElements.define(i,a)}}})(e,t);var O8e=(e,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}},L8e=(e,t,i)=>{t.constructor.createProperty(i,e)};function Fh(e){return(t,i)=>i!==void 0?L8e(e,t,i):O8e(e,t)}var fZ,crt=((fZ=window.HTMLSlotElement)===null||fZ===void 0?void 0:fZ.prototype.assignedElements)!=null?(e,t)=>e.assignedElements(t):(e,t)=>e.assignedNodes(t).filter(i=>i.nodeType===Node.ELEMENT_NODE);var KB=window.IntersectionObserver!=null;var y3e=(e=32,t=2)=>{let i=e/2;return f3e` <style>
|
|
12997
12997
|
:host {
|