a),i.children){let a=pA(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return r}function Gq(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=zp(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function zp(n,t){if(!Fh(t))return t;if(n instanceof gr){let e=pA(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ke)return Gq(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=zp(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof yr)return mA(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=zp(s,t[i]);r=r||o!==void 0,o===void 0&&(o=s),e[i]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function mA(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!Fh(t))return t;if(!Fh(n))return So.apply(n,t);let e=new Set;for(let i of Object.keys(n))e.add(i);for(let i of Object.keys(t))e.add(i);let r=new yr;for(let i of e){let s=mA(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function wI(n,t){let e={cur:[],result:[],len:0};return n=Gp(n,t,e)??n,[n,e.result]}function Sv(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function wv(n){n&&(n.len-=1)}function jq(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function AI(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Gp(s.data,t,Sv(e,o));wv(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=AI(s.children,t,e);return c!==void 0?r=!0:c=s.children,{...s,id:o,data:l,children:c}});if(r)return i}function Hq(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Gp(s.data,t,Sv(e,o));return wv(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i}function Gp(n,t,e){if(n instanceof gr){let r=AI(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof ke)return Hq(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=Gp(s,t,Sv(e,o));return wv(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i):void 0}else if(n&&typeof n=="object"&&!Bh(n)){let r={},i=!1;for(let[s,o]of Object.entries(n))if(s!=="name"&&s!=="variableId"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=Gp(o,t,Sv(e,s));wv(e),i=i||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&jq(e),r}else return}}var Vh;(t=>{function n(e,r){let i=Sr.zoom(r,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=n})(Vh||(Vh={}));var Lr;(a=>{function n(l,c){return{...l,path:l.path.slice(c)}}a.drop=n;function t(l,c){return e(l,c)?.data??l}a.applySimple=t;function e(l,c){let u=c.path;for(var h=[];;){let d;if(l instanceof yr&&c.type===0&&(d=l.runOp({...c,path:u.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===u.length&&(l instanceof gr||l instanceof ke||l instanceof Qe?d=l.runOp(c):d=Nh.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=u[g],v=h[g];if(v instanceof gr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof ke){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Qe){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof yr){let x={...v,[y]:m};m=Object.setPrototypeOf(x,yr.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],p;if(l instanceof gr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof ke){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,c){for(let u=0;uc.props[u]!==void 0):!1}a.subsumed=o})(Lr||(Lr={}));var jp;(l=>{function n(){return[]}l.empty=n;function t(c,u){let h=[];for(let d of c){let[f,...p]=d.path;f===u&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(c,u){return c.map(h=>({...h,path:[u,...h.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function i(c,u){return[...c.filter(d=>!u.some(f=>Lr.subsumed(d,f))),...u]}l.compress=i;function s(c,u){return c.every(h=>u.every(d=>Lr.commutative(h,d)))}l.commutative=s;function o(c,u){for(let h of u){let d=a(c,h);d!==null&&(c=d.data)}return c}l.applyAll=o;function a(c,u){var h=c;let d=[],f=[];for(let p of u)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Sr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Sr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=wI(h,{[p.id]:m});h=v;for(let S=0;ST.includes(C)?p.id:M),m=b,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let T=m,b=Sr.zoom(h,w.slice(0,w.length-2)),M=b.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:T}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(b.layers)),b.layers=M}g=p.id}d.push({type:0,path:w,props:{[A]:m}}),f.push({type:0,path:w,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Lh)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(jp||(jp={}));var EI=Symbol(),Wq=Symbol(),Ev=Symbol(),Lc=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let s=r;for(;!(i instanceof Av);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ev];r&&r(),delete this._children[t]}}}},yA=class extends Lc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Nh.runOp(this._current,t),t.path)}},vA=class extends Lc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Qe.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},TI={get(n,t){if(t===Ev)return()=>{n._parent=null};if(t===EI)return n._current;if(t===Wq)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e[t],o=Tv(n,t,s);return o!==s?(r===void 0&&(r={},n._children=r),r[t]=o,o):s},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},qq={...TI,set(n,t,e){let r={type:0,props:{[t]:zr(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},Yq={...TI,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},kh=class extends Lc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ev]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=Tv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,i,s){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Sr.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var Av=class extends Lc{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){gA(this.ts,e,t),gA(this.actual,r,t),gA(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Tv(n,t,e){return e instanceof gr?new kh(n,t,e):e instanceof ke?new Uh(n,t,e):e instanceof Qe?new Proxy(new vA(n,t,e),Yq):e!==null&&typeof e=="object"?Bh(e)?e:new Proxy(new yA(n,t,e),qq):e}function xA(n){let t=new Av(n);return[Tv(t,"",n),t]}function bl(n,t){let[e,r]=xA(n);return t(e),r.result()}function zr(n){return n instanceof kh||n instanceof Uh?n._current:n!==null&&typeof n=="object"?n[EI]:n}var Sr;(i=>{function n(s,o){if(o.length===s.length)for(var a=0;a{delete c[u]}),c}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof gr||s instanceof kh)&&typeof o=="string")return s.data(o);if((s instanceof ke||s instanceof Uh)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function r(s,o,a=0){for(;a(Pv(),this?this.unpack(t,e):Ao.prototype.unpack.call(CI,t,e)));wl=e>-1?e:t.length,ne=0,AA=0,wo=0,Sl=null,wA=LI,Zn=null,qe=t;try{sr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw qe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ao){if(_n=this,this.structures)return Zt=this.structures,Cv();(!Zt||Zt.length>0)&&(Zt=[])}else _n=CI,(!Zt||Zt.length>0)&&(Zt=[]);return Cv()}unpackMultiple(t,e){let r,i=0;try{zh=!0;let s=t.length,o=this?this.unpack(t,s):Dv.unpack(t,s);if(e){for(e(o);ne=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],s=e[r];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Cv(){try{if(!_n.trusted&&!zh){let t=Zt.sharedLength||0;twl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!zh)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Zt.restoreStructures&&PI(),Pv(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function PI(){for(let n in Zt.restoreStructures)Zt[n]=Zt.restoreStructures[n];Zt.restoreStructures=null}function Xr(){let n=qe[ne++];if(n<160)if(n<128){if(n<64)return n;{let t=Zt[n&63]||_n.getStructures&&BI()[n&63];return t?(t.read||(t.read=MA(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,_n.mapsAsObjects){let t={};for(let e=0;e=ne)return Sl.slice(ne-us,(ne+=t)-us);if(wo==0&&wl<140){let e=t<16?CA(t):NI(t);if(e!=null)return e}return EA(t)}else{let t;switch(n){case 192:return null;case 193:return Zn?(t=Xr(),t>0?Zn[1].slice(Zn.position1,Zn.position1+=t):Zn[0].slice(Zn.position0,Zn.position0-=t)):TA;case 194:return!1;case 195:return!0;case 196:return bA(qe[ne++]);case 197:return t=sr.getUint16(ne),ne+=2,bA(t);case 198:return t=sr.getUint32(ne),ne+=4,bA(t);case 199:return Bc(qe[ne++]);case 200:return t=sr.getUint16(ne),ne+=2,Bc(t);case 201:return t=sr.getUint32(ne),ne+=4,Bc(t);case 202:if(t=sr.getFloat32(ne),_n.useFloat32>2){let e=Iv[(qe[ne]&127)<<1|qe[ne+1]>>7];return ne+=4,(e*t+(t>0?.5:-.5)>>0)/e}return ne+=4,t;case 203:return t=sr.getFloat64(ne),ne+=8,t;case 204:return qe[ne++];case 205:return t=sr.getUint16(ne),ne+=2,t;case 206:return t=sr.getUint32(ne),ne+=4,t;case 207:return _n.int64AsNumber?(t=sr.getUint32(ne)*4294967296,t+=sr.getUint32(ne+4)):t=sr.getBigUint64(ne),ne+=8,t;case 208:return sr.getInt8(ne++);case 209:return t=sr.getInt16(ne),ne+=2,t;case 210:return t=sr.getInt32(ne),ne+=4,t;case 211:return _n.int64AsNumber?(t=sr.getInt32(ne)*4294967296,t+=sr.getUint32(ne+4)):t=sr.getBigInt64(ne),ne+=8,t;case 212:if(t=qe[ne++],t==114)return RI(qe[ne++]&63);{let e=yn[t];if(e)return e.read?(ne++,e.read(Xr())):e.noBuffer?(ne++,e()):e(qe.subarray(ne,++ne));throw new Error("Unknown extension "+t)}case 213:return t=qe[ne],t==114?(ne++,RI(qe[ne++]&63,qe[ne++])):Bc(2);case 214:return Bc(4);case 215:return Bc(8);case 216:return Bc(16);case 217:return t=qe[ne++],wo>=ne?Sl.slice(ne-us,(ne+=t)-us):Kq(t);case 218:return t=sr.getUint16(ne),ne+=2,wo>=ne?Sl.slice(ne-us,(ne+=t)-us):Qq(t);case 219:return t=sr.getUint32(ne),ne+=4,wo>=ne?Sl.slice(ne-us,(ne+=t)-us):Zq(t);case 220:return t=sr.getUint16(ne),ne+=2,II(t);case 221:return t=sr.getUint32(ne),ne+=4,II(t);case 222:return t=sr.getUint16(ne),ne+=2,DI(t);case 223:return t=sr.getUint32(ne),ne+=4,DI(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var Xq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function MA(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>Xq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Xr);return n.highByte===0&&(n.read=_I(t,n.read)),i()}let r={};for(let i=0,s=n.length;ifunction(){let e=qe[ne++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Zt[r]||BI()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=MA(i,n)),i.read()};function BI(){let n=kI(()=>(qe=null,_n.getStructures()));return Zt=_n._mergeStructures(n,Zt)}var EA=_v,Kq=_v,Qq=_v,Zq=_v;function _v(n){let t;if(n<16&&(t=CA(n)))return t;if(n>64&&SA)return SA.decode(qe.subarray(ne,ne+=n));let e=ne+n,r=[];for(t="";ne65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=Vi.apply(String,r),r.length=0)}return r.length>0&&(t+=Vi.apply(String,r)),t}function II(n){let t=new Array(n);for(let e=0;e0){ne=t;return}e[r]=i}return Vi.apply(String,e)}function CA(n){if(n<4)if(n<2){if(n===0)return"";{let t=qe[ne++];if((t&128)>1){ne-=1;return}return Vi(t)}}else{let t=qe[ne++],e=qe[ne++];if((t&128)>0||(e&128)>0){ne-=2;return}if(n<3)return Vi(t,e);let r=qe[ne++];if((r&128)>0){ne-=3;return}return Vi(t,e,r)}else{let t=qe[ne++],e=qe[ne++],r=qe[ne++],i=qe[ne++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){ne-=4;return}if(n<6){if(n===4)return Vi(t,e,r,i);{let s=qe[ne++];if((s&128)>0){ne-=5;return}return Vi(t,e,r,i,s)}}else if(n<8){let s=qe[ne++],o=qe[ne++];if((s&128)>0||(o&128)>0){ne-=6;return}if(n<7)return Vi(t,e,r,i,s,o);let a=qe[ne++];if((a&128)>0){ne-=7;return}return Vi(t,e,r,i,s,o,a)}else{let s=qe[ne++],o=qe[ne++],a=qe[ne++],l=qe[ne++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){ne-=8;return}if(n<10){if(n===8)return Vi(t,e,r,i,s,o,a,l);{let c=qe[ne++];if((c&128)>0){ne-=9;return}return Vi(t,e,r,i,s,o,a,l,c)}}else if(n<12){let c=qe[ne++],u=qe[ne++];if((c&128)>0||(u&128)>0){ne-=10;return}if(n<11)return Vi(t,e,r,i,s,o,a,l,c,u);let h=qe[ne++];if((h&128)>0){ne-=11;return}return Vi(t,e,r,i,s,o,a,l,c,u,h)}else{let c=qe[ne++],u=qe[ne++],h=qe[ne++],d=qe[ne++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){ne-=12;return}if(n<14){if(n===12)return Vi(t,e,r,i,s,o,a,l,c,u,h,d);{let f=qe[ne++];if((f&128)>0){ne-=13;return}return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f)}}else{let f=qe[ne++],p=qe[ne++];if((f&128)>0||(p&128)>0){ne-=14;return}if(n<15)return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f,p);let m=qe[ne++];if((m&128)>0){ne-=15;return}return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f,p,m)}}}}}function bA(n){return _n.copyBuffers?Uint8Array.prototype.slice.call(qe,ne,ne+=n):qe.subarray(ne,ne+=n)}function Bc(n){let t=qe[ne++];if(yn[t])return yn[t](qe.subarray(ne,ne+=n));throw new Error("Unknown extension type "+t)}var OI=new Array(4096);function FI(){let n=qe[ne++];if(n>=160&&n<192){if(n=n-160,wo>=ne)return Sl.slice(ne-us,(ne+=n)-us);if(!(wo==0&&wl<180))return EA(n)}else return ne--,Xr();let t=(n<<5^(n>1?sr.getUint16(ne):n>0?qe[ne]:0))&4095,e=OI[t],r=ne,i=ne+n-3,s,o=0;if(e&&e.bytes==n){for(;r{var e=Xr();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Zt[n];return i&&i.isShared&&((Zt.restoreStructures||(Zt.restoreStructures=[]))[n]=i),Zt[n]=e,e.read=MA(e,r),e.read()},VI=typeof self=="object"?self:global;yn[0]=()=>{};yn[0].noBuffer=!0;yn[101]=()=>{let n=Xr();return(VI[n[0]]||Error)(n[1])};yn[105]=n=>{let t=sr.getUint32(ne-4);ya||(ya=new Map);let e=qe[ne],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};ya.set(t,i);let s=Xr();return i.used?Object.assign(r,s):(i.target=s,s)};yn[112]=n=>{let t=sr.getUint32(ne-4),e=ya.get(t);return e.used=!0,e.target};yn[115]=()=>new Set(Xr());var PA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");yn[116]=n=>{let t=n[0],e=PA[t];if(!e)throw new Error("Could not find typed array for code "+t);return new VI[e](Uint8Array.prototype.slice.call(n,1).buffer)};yn[120]=()=>{let n=Xr();return new RegExp(n[0],n[1])};yn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=ne;ne+=t-4,Zn=[Xr(),Xr()],Zn.position0=0,Zn.position1=0;let r=ne;ne=e;try{return Xr()}finally{ne=r}};yn[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function kI(n){let t=wl,e=ne,r=AA,i=us,s=wo,o=Sl,a=wA,l=ya,c=Zn,u=new Uint8Array(qe.slice(0,wl)),h=Zt,d=Zt.slice(0,Zt.length),f=_n,p=zh,m=n();return wl=t,ne=e,AA=r,us=i,wo=s,Sl=o,wA=a,ya=l,Zn=c,qe=u,zh=p,Zt=h,Zt.splice(0,Zt.length,...d),_n=f,sr=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),m}function Pv(){qe=null,ya=null,Zt=null}function UI(n){n.unpack?yn[n.type]=n.unpack:yn[n.type]=n}var Iv=new Array(147);for(let n=0;n<256;n++)Iv[n]=+("1e"+Math.floor(45.15-n*.30103));var Dv=new Ao({useRecords:!1}),Jq=Dv.unpack,$q=Dv.unpackMultiple,e9=Dv.unpack,Ov={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},t9=new Float32Array(1),fhe=new Uint8Array(t9.buffer,0,4);var Rv;try{Rv=new TextEncoder}catch{}var Lv,IA,Bv=typeof Buffer<"u",_A=Bv?Buffer.allocUnsafeSlow:Uint8Array,HI=Bv?Buffer:Uint8Array,zI=Bv?4294967296:2144337920,Se,ti,he=0,Eo,To=null,r9=/[\u0080-\uFFFF]/,Yp=Symbol("record-id"),Nc=class extends Ao{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=HI.prototype.utf8Write?function(b,M,C){return Se.utf8Write(b,M,C)}:Rv&&Rv.encodeInto?function(b,M){return Rv.encodeInto(b,Se.subarray(M)).written}:!1,u=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,S=0;this.pack=this.encode=function(b,M){if(Se||(Se=new _A(8192),ti=new DataView(Se.buffer,0,8192),he=0),Eo=Se.length-10,Eo-he<2048?(Se=new _A(Se.length),ti=new DataView(Se.buffer,0,Se.length),Eo=Se.length-10,he=0):he=he+7&2147483640,r=he,a=u.structuredClone?new Map:null,u.bundleStrings?(To=["",""],Se[he++]=214,Se[he++]=98,To.position=he-r,he+=4):To=null,i=u.structures,i){i.uninitialized&&(i=u._mergeStructures(u.getStructures()));let C=i.sharedLength||0;if(C>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let P=0;PEo&&T(he),u.offset=he;let C=n9(Se.subarray(r,he),a.idsToInsert);return a=null,C}return M&qI?(Se.start=r,Se.end=he,Se):Se.subarray(r,he)}finally{if(i){if(S<10&&S++,x>1e4)i.transitions=null,S=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let C=0,P=v.length;CC&&(i=i.slice(0,C));let P=Se.subarray(r,he);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(b)):(l=C,P)}}M&h9&&(he=r)}};let w=b=>{he>Eo&&(Se=T(he));var M=typeof b,C;if(M==="string"){let P=b.length;if(To&&P>=8&&P<4096){let D=r9.test(b);To[D?0:1]+=b,Se[he++]=193,w(D?-P:P);return}let I;P<32?I=1:P<256?I=2:P<65536?I=3:I=5;let _=P*3;if(he+_>Eo&&(Se=T(he+_)),P<64||!c){let D,L,j,V=he+I;for(D=0;D>6|192,Se[V++]=L&63|128):(L&64512)===55296&&((j=b.charCodeAt(D+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),D++,Se[V++]=L>>18|240,Se[V++]=L>>12&63|128,Se[V++]=L>>6&63|128,Se[V++]=L&63|128):(Se[V++]=L>>12|224,Se[V++]=L>>6&63|128,Se[V++]=L&63|128);C=V-he-I}else C=c(b,he+I,_);C<32?Se[he++]=160|C:C<256?(I<2&&Se.copyWithin(he+2,he+1,he+1+C),Se[he++]=217,Se[he++]=C):C<65536?(I<3&&Se.copyWithin(he+3,he+2,he+2+C),Se[he++]=218,Se[he++]=C>>8,Se[he++]=C&255):(I<5&&Se.copyWithin(he+5,he+3,he+3+C),Se[he++]=219,ti.setUint32(he,C),he+=4),he+=C}else if(M==="number")if(b>>>0===b)b<64?Se[he++]=b:b<256?(Se[he++]=204,Se[he++]=b):b<65536?(Se[he++]=205,Se[he++]=b>>8,Se[he++]=b&255):(Se[he++]=206,ti.setUint32(he,b),he+=4);else if(b>>0===b)b>=-32?Se[he++]=256+b:b>=-128?(Se[he++]=208,Se[he++]=b+256):b>=-32768?(Se[he++]=209,ti.setInt16(he,b),he+=2):(Se[he++]=210,ti.setInt32(he,b),he+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Se[he++]=202,ti.setFloat32(he,b);let I;if(P<4||(I=b*Iv[(Se[he]&127)<<1|Se[he+1]>>7])>>0===I){he+=4;return}else he--}Se[he++]=203,ti.setFloat64(he,b),he+=8}else if(M==="object")if(!b)Se[he++]=192;else{if(a){let I=a.get(b);if(I){if(!I.id){let _=a.idsToInsert||(a.idsToInsert=[]);I.id=_.push(I)}Se[he++]=214,Se[he++]=112,ti.setUint32(he,I.id),he+=4;return}else a.set(b,{offset:he-r})}let P=b.constructor;if(P===Object)A(b,!0);else if(P===Array){C=b.length,C<16?Se[he++]=144|C:C<65536?(Se[he++]=220,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=221,ti.setUint32(he,C),he+=4);for(let I=0;I>8,Se[he++]=C&255):(Se[he++]=223,ti.setUint32(he,C),he+=4);for(let[I,_]of b)w(I),w(_)}else{for(let I=0,_=Lv.length;I<_;I++){let D=IA[I];if(b instanceof D){let L=Lv[I];if(L.write){L.type&&(Se[he++]=212,Se[he++]=L.type,Se[he++]=0),w(L.write.call(this,b));return}let j=Se,V=ti,H=he;Se=null;let W;try{W=L.pack.call(this,b,q=>(Se=j,j=null,he+=q,he>Eo&&T(he),{target:Se,targetView:ti,position:he-q}),w)}finally{j&&(Se=j,ti=V,he=H,Eo=Se.length-10)}W&&(W.length+he>Eo&&T(W.length+he),he=i9(W,Se,he,L.type));return}}A(b,!b.hasOwnProperty)}}else if(M==="boolean")Se[he++]=b?195:194;else if(M==="bigint"){if(b=-(BigInt(1)<0)Se[he++]=207,ti.setBigUint64(he,b);else if(this.largeBigIntToFloat)Se[he++]=203,ti.setFloat64(he,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");he+=8}else if(M==="undefined")this.encodeUndefinedAsNil?Se[he++]=192:(Se[he++]=212,Se[he++]=0,Se[he++]=0);else if(M==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?b=>{let M=Object.keys(b),C=M.length;C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,ti.setUint32(he,C),he+=4);let P;for(let I=0;I{Se[he++]=222;let C=he-r;he+=2;let P=0;for(let I in b)(M||b.hasOwnProperty(I))&&(w(I),w(b[I]),P++);Se[C+++r]=P>>8,Se[C+r]=P&255}:b=>{let M=Object.keys(b),C,P=o.transitions||(o.transitions=Object.create(null)),I=0;for(let D=0,L=M.length;D=96&&m?(Se[he++]=((_-=96)&31)+96,Se[he++]=_>>5):Se[he++]=_;else{_=o.nextId,_||(_=64),_=y&&(_=g),o.nextId=_+1);let D=M.highByte=_>=96&&m?_-96>>5:-1;P[Yp]=_,o[_-64]=M,_=0?(Se[he++]=(_&31)+96,Se[he++]=D):Se[he++]=_):(D>=0?(Se[he++]=213,Se[he++]=114,Se[he++]=(_&31)+96,Se[he++]=D):(Se[he++]=212,Se[he++]=114,Se[he++]=_),I&&(x+=S*I),v.length>=p&&(v.shift()[Yp]=0),v.push(P),w(M))}for(let D=0,L=M.length;D{let M;if(b>16777216){if(b-r>zI)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(zI,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(b-r<<2,Se.length-1)>>12)+1<<12;let C=new _A(M);return ti=new DataView(C.buffer,0,M),Se.copy?Se.copy(C,0,r,b):C.set(Se.slice(r,b)),he-=r,r=0,Eo=C.length-10,Se=C}}useBuffer(t){Se=t,ti=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),he=0}};IA=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,qp];Lv=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,n.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?GI(n,16,t):jI(Bv?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==HI&&this.structuredClone?GI(n,PA.indexOf(e.name),t):jI(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function GI(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),o)}function jI(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:s}=t(e+5);r[i++]=198,s.setUint32(i,e),i+=4}r.set(n,i)}function i9(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function n9(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;n.copyWithin(s+r,s,i),r-=6;let a=s+r;n[a++]=214,n[a++]=105,n[a++]=o>>24,n[a++]=o>>16&255,n[a++]=o>>8&255,n[a++]=o&255,i=s}return n}function Al(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");IA.unshift(n.Class),Lv.unshift(n)}UI(n)}var WI=new Nc({useRecords:!1}),s9=WI.pack,o9=WI.pack;var{NEVER:a9,ALWAYS:l9,DECIMAL_ROUND:c9,DECIMAL_FIT:u9}=Ov,qI=512,h9=1024;var YI=new Nc({structuredClone:!0});Al({Class:Qe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Qe.prototype),n}});Al({Class:ke.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ke.prototype),n}});Al({Class:gr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,gr.prototype),n}});Al({Class:Hp.prototype.constructor,type:4,write(n){return n.id},read(n){return new Hp(n)}});Al({Class:Wp.prototype.constructor,type:5,write(n){return n.data},read(n){return new Wp(n)}});Al({Class:yr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,yr.prototype),n}});function d9(n){var t=0;if(n.length===0)return t;for(let e=0;e{function n(i){return YI.pack(i)}r.serialize=n;function t(i){return YI.unpack(i)}r.deserialize=t;function e(i){return d9(n(DA(i))).toString()}r.checksum=e})(Nv||(Nv={}));var XI;(e=>{function n(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=n;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(XI||(XI={}));function RA(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var Yi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseHover"]:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Start"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Conditional"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseUp"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MousePress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyUp"]:["Transition","Animation","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","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","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","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"]},KI;(e=>{function n(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=n;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,actions:new ke}:{type:r,disabled:!1,key:void 0,actions:new ke}}e.defaultData=t})(KI||(KI={}));var Fv;(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(Fv||(Fv={}));var OA;(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:Fv.propertyDefaultData(i),rOperand:{...Fv.valueDefaultData}}}r.comparisonDefaultData=n;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}r.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}r.stateDefaultData=e})(OA||(OA={}));var QI;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(QI||(QI={}));var ZI;(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,inActions:new ke,outActions:new ke,condition:OA.distanceDefaultData(r)}}e.defaultData=t})(ZI||(ZI={}));var JI;(t=>t.defaultData={type:"DragDrop",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 ke,drop:new ke}})(JI||(JI={}));var Vv;(t=>t.defaultData={type:"Follow",disabled:!1,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 ke})(Vv||(Vv={}));var kv;(t=>t.defaultData={type:"LookAt",disabled:!1,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})(kv||(kv={}));var $I;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,actions:new ke}}e.defaultData=t})($I||($I={}));var eD;(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ke}}e.defaultData=t})(eD||(eD={}));var tD;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,actions:new ke}}e.defaultData=t})(tD||(tD={}));var rD;(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,target:"character",actions:new ke}}e.defaultData=t})(rD||(rD={}));var iD;(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new ke,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(iD||(iD={}));var Uv;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function i(){let a={size:"mobile",operator:"<",actions:new ke},l={size:"tablet",operator:"<",actions:new ke},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new ke},u=new ke;return u.push({id:we.generateUUID(),fi:0,data:a},{id:we.generateUUID(),fi:1,data:l},{id:we.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:u}}o.defaultData=i;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new ke}}o.defaultBreakpointData=s})(Uv||(Uv={}));var zv;(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"]};function t(i){return i.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new ke,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(zv||(zv={}));var nD;(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",successActions:new ke,errorActions:new ke,userAPIId:""}}e.defaultData=t})(nD||(nD={}));var sD;(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",actions:new ke,userWebhookId:""}}e.defaultData=t})(sD||(sD={}));var oD;(e=>{function n(r){return r.type==="AIAssistantListener"}e.is=n;function t(){return{disabled:!1,type:"AIAssistantListener",actions:new ke,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=t})(oD||(oD={}));var aD;(e=>{function n(r){return r.type==="AIAssistantTrigger"}e.is=n;function t(){return{disabled:!1,description:"",type:"AIAssistantTrigger",actions:new ke}}e.defaultData=t})(aD||(aD={}));var hs="personal camera",Tl="a218fcc3-276b-49b9-b485-49037fd14f5f",hD=2960946,ii=5526619;var Vs;(f=>{function n(p,m){return p[0]===m[0]&&p[1]===m[1]}f.isEqual=n;function t(p,m,g){return[p[0]+(m[0]-p[0])*g,p[1]+(m[1]-p[1])*g]}f.lerp=t;function e(p,m){return[p[0]+m[0],p[1]+m[1]]}f.add=e;function r(p,m){return[p[0]-m[0],p[1]-m[1]]}f.sub=r;function i(p,m){return[p[0]*m[0],p[1]*m[1]]}f.multiply=i;function s(p,m){return[p[0]/m[0],p[1]/m[1]]}f.divide=s;function o(p,m){return Math.pow(m[0]-p[0],2)+Math.pow(m[1]-p[1],2)}f.distanceSquared=o;function a(p,m){return Math.sqrt(o(p,m))}f.distance=a;function l(p,m){return p[0]*m[0]+p[1]*m[1]}f.dot=l;function c(p,m){return[p[0]*m,p[1]*m]}f.scalarMultiply=c;function u(p,m,g){let y=f.sub(m,p),v=f.sub(g,p),x=f.dot(y,v)/f.dot(y,y),S=f.scalarMultiply(y,x);return f.add(p,S)}f.projectionOnto=u;function h(p,m,g){return a(p,u(p,m,g))}f.projectionOntoDistance=h;function d(p,m){return[(p[0]+m[0])*.5,(p[1]+m[1])*.5]}f.center=d})(Vs||(Vs={}));var Mo;(a=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}a.isEqual=n;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}a.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}a.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}a.div=r;function i(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}a.mul=i;function s(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}a.dist=s;function o(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}a.lerp=o})(Mo||(Mo={}));var Xp;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s,r[2]+(i[2]-r[2])*s,r[3]+(i[3]-r[3])*s]}e.lerp=t})(Xp||(Xp={}));var lD;(o=>{let n=180/Math.PI,t=Math.PI/180;function e(a){return typeof a=="number"?a*n:a}function r(a){return typeof a=="number"?a*t:a}function i(a){return[e(a[0]),e(a[1]),e(a[2])]}o.radToDeg=i;function s(a){return[r(a[0]),r(a[1]),r(a[2])]}o.degToRad=s})(lD||(lD={}));var El;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}h.isRGB=n,h.white={r:1,g:1,b:1},h.red={r:1,g:0,b:0},h.black={r:0,g:0,b:0};function i(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}h.toRgb255a1=i;function s(d){return{r:d.r,g:d.g,b:d.b}}h.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}h.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}h.toHex=a;function l(d,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}h.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}h.equalsFixed=c;function u(d,f,p){return{r:d.r+(f.r-d.r)*p,g:d.g+(f.g-d.g)*p,b:d.b+(f.b-d.b)*p}}h.lerp=u})(ri||(ri={}));var bt;(c=>{c.white={...ri.white,a:1},c.transparent={...ri.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function r(u,h){return{...ri.fromHex(u),a:h}}c.fromHexAndA=r;function i(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=i;function s(u,h){return ri.equals(u,h)&&u.a===h.a}c.equals=s;function o(u,h){return ri.equalsFixed(u,h)&&u.a.toFixed(2)===h.a.toFixed(2)}c.equalsFixed=o;function a(u,h,d){return{r:u.r+(h.r-u.r)*d,g:u.g+(h.g-u.g)*d,b:u.b+(h.b-u.b)*d,a:u.a+(h.a-u.a)*d}}c.lerp=a;function l({r:u,g:h,b:d,a:f}=c.white){return`rgba(${u*255}, ${h*255}, ${d*255}, ${f})`}c.toStyle=l})(bt||(bt={}));var Gv;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Gv||(Gv={}));var cD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(cD||(cD={}));var uD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(uD||(uD={}));var va;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(va||(va={}));function LA(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var ks;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(ks||(ks={}));var Ml;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}i.getZoom=r})(Ml||(Ml={}));var Co;(e=>{function n(r,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[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"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*i,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(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.defaultData=n;function t(r,i){let s={...r};if(BA.forEach(o=>{Object.assign(s,{[o]:i[o]??r[o]})}),s.radial={...r.radial},i.radial){let o=r.radial,a=i.radial;NA.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},i.linear){let o=r.linear,a=i.linear;FA.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},i.grid){let o=r.grid,a=i.grid;VA.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},i.toObject){let o=r.toObject,a=i.toObject;kA.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},i.randomnessObject){let o=r.randomnessObject,a=i.randomnessObject;UA.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Co||(Co={}));var jv;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(jv||(jv={}));var BA=["count"],NA=["radius","start","end","position","scale","rotation"],FA=["position","scale","rotation"],VA=["count","size"],kA=["count","position","scale","rotation"],UA=["strength","scale","rotation","position","movement","seed","freqScale"];var Hv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Hv||(Hv={}));var Wv;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:bt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:bt.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(r==="DirectionalLight")return{type:r,color:bt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Wv||(Wv={}));var Gh;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(Gh||(Gh={}));var Cl;(t=>t.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]})(Cl||(Cl={}));var zA;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(zA||(zA={}));var GA;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})(GA||(GA={}));var qv;(t=>t.defaultData={...GA.defaultData,...zA.defaultData})(qv||(qv={}));var dD;(t=>{function n(e,r){let i=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&i.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&i.push(o)}return i}t.getMaterialData=n})(dD||(dD={}));var jh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(jh||(jh={}));var fD;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(fD||(fD={}));function mD(n){return n.type!=="displace"}var pD;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(pD||(pD={}));var Yv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],gD=["wrapping","image","video","name","minFilter","magFilter"],Gr;(i=>{function n(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let c=s.texture;c&&Object.assign(c,a)}}i.patch=n;function t(s,o){return s==="light"&&o?e(o):r(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,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{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:jh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...o,type:"color",color:ri.fromHex(ii)};case"depth":return{...o,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{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,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{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ri.fromHex(6710886),a:1},colorB:{...ri.fromHex(6710886),a:1},colorC:{...ri.fromHex(16777215),a:1},colorD:{...ri.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"fresnel":return{...o,type:"fresnel",color:bt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,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:bt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:bt.fromHexAndA(0,1),contourColor:bt.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{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};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{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ri.fromHex(0),a:1},colorB:{...ri.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}}}})(Gr||(Gr={}));var Kr;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function t(u){let h="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,p])=>{h+=`${f}${p}`,Array.isArray(p)?p.forEach(m=>h+=`${m}`):typeof p=="object"?Object.values(p).forEach(m=>{typeof m=="number"?h+=`${m.toFixed(4)}`:h+=`${m}`}):h+=`${p}`})}),h}c.getHash=t;function e(){return{layers:new ke}}c.defaultEmptyData=e;function r(u="layer1",h="layer2"){return s("phong",u,h)}c.defaultData=r;function i(u,h){return{...u,name:h}}c.withName=i;function s(u,h="layer1",d="layer2"){let f=new ke;return f.push({fi:0,data:Gr.defaultData("light",u),id:h}),f.push({fi:1,data:Gr.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=s;function o(u){let h=Gr.defaultData("texture");u&&Object.assign(h.texture,{image:u});let d=new ke;return d.push({fi:0,data:h,id:"layer1"}),d.push({fi:1,data:{...Gr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Gr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=o;function a(u,h="phong",d="layer1",f="layer2"){let p=Gr.defaultData("texture");Object.assign(p.texture,{image:u});let m=new ke;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:Gr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerTextureData=a;function l(u,h="phong",d="layer1",f="layer2"){let p=Gr.defaultData("video");Object.assign(p.texture,{video:u});let m=new ke;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:Gr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Kr||(Kr={}));var Hh;(t=>{function n(){return{points:new ke,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Hh||(Hh={}));var Wh;(t=>{function n(){return{points:new ke,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(Wh||(Wh={}));var jA={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Xv;(t=>{function n(e,r){let i={...e};return HA.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(Xv||(Xv={}));var Kv={shape:jA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},HA=["depth","offset","angle","twist","startScale","endScale"];var Kp;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=t})(Kp||(Kp={}));var Qv;(t=>{function n(e,r){let i={...e};return Object.assign(i,r),i.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Xv.merge(i.extrusion,r.extrusion))),i}t.merge=n})(Qv||(Qv={}));var xa;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Wh.defaultData(),extrusion:Kv};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Hh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,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(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="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")}t.defaultData=n})(xa||(xa={}));var Zv=["width","height","depth"];var Jv;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:ri.white,near:.1,far:2e3})(Jv||(Jv={}));var qh;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(qh||(qh={}));var WA;(t=>t.defaultData={softShadowQuality:"low"})(WA||(WA={}));var qA;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(qA||(qA={}));var YA;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(YA||(YA={}));var Pl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Pl||(Pl={}));var XA;(t=>t.defaultData={playCamera:hs,gameControlObject:null})(XA||(XA={}));var $v;(t=>t.defaultData={backgroundColor:bt.fromHexAndA(hD,1),postprocessing:qh.defaultData,fog:Jv.defaultData,globalPhysics:Pl.defaultData,ambient:qA.defaultData,ao:YA.defaultData,shadow:WA.defaultData,publish:XA.defaultData})($v||($v={}));var e0;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(e0||(e0={}));var yD;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(yD||(yD={}));var Yh;(i=>{i.identity={...Gv.identity,hiddenMatrix:El.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function r(s,o){return hv({position:Mo.isEqual(s.position,o.position)?void 0:o.position,rotation:Mo.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Mo.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:El.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(Yh||(Yh={}));var vi;(t=>t.defaultData={states:new ke,events:new ke,visible:!0,raycastLock:!1,physics:Cl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Yh.identity,cloner:null})(vi||(vi={}));var t0;(t=>t.defaultData={type:"Empty",...vi.defaultData})(t0||(t0={}));var vD;(t=>t.defaultData={type:"ParticleCollider",...e0.defaultData,...vi.defaultData})(vD||(vD={}));var xD;(t=>t.defaultData={type:"Component",...vi.defaultData})(xD||(xD={}));var bD;(t=>t.defaultData={type:"Particle",...vi.defaultData,...Gh.defaultData})(bD||(bD={}));var _l;(t=>t.defaultData={type:"Mesh",...vi.defaultData,...qv.defaultData})(_l||(_l={}));var Fc;(t=>t.defaultData={...vi.defaultData,...Yh.identity,position:[0,0,Ml.DefaultTargetOffset],...Ml.defaultData})(Fc||(Fc={}));var r0;(e=>{function n(r){return{...vi.defaultData,...Wv.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(r0||(r0={}));var Xh;(e=>{function n(r,i,s=0){for(;s{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...vi.defaultData,...a,component:o,overrides:new yr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function i(o){let a=Yh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(Po||(Po={}));var ba;(e=>{e.defaultData={type:"Page",...vi.defaultData,physics:{...Cl.defaultData,fusedBody:!1},...$v.defaultData,camera:Fc.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ba||(ba={}));var i0;(o=>(o.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:El.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Cl.defaultData,states:new ke,events:new ke,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Ml.defaultData},o.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"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},o.defaultMeshObject={name:"Rectangle",...vi.defaultData,..._l.defaultData,geometry:xa.defaultData("RectangleGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultBooleanObject={name:"Boolean",...vi.defaultData,..._l.defaultData,geometry:xa.defaultData("BooleanGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultTextObject={name:"Text",...vi.defaultData,..._l.defaultData,geometry:xa.defaultData("TextGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultInputObject={name:"Input",...vi.defaultData,..._l.defaultData,geometry:xa.defaultData("InputGeometry"),material:Kr.defaultTwoLayerData("phong","layer1","layer2")}))(i0||(i0={}));var Sa;(i=>{function n(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new yr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new yr})))):ks.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=n;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=bl(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Gr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=bl(a.materials,l=>{for(let c=0;c0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...jv.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")u(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))u(["materials",f],p);else if(c[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}i.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Yh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),ks.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Qv.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Co.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Co.merge(a.cloner,o.cloner)});else if(Hv.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=ri.clone(l.color))}return a}i.patch=r})(Sa||(Sa={}));var Kh;(t=>t.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,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})(Kh||(Kh={}));var Us;(t=>t.defaultData={orbitControls:Kh.defaultData,playPage:Tl,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let i=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?i=30:(r===4||r===11||r===9)&&(i=-30),[120,[i,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70}},stopRaycast:!0,hdTransmission:!1})(Us||(Us={}));var KA;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(KA||(KA={}));var QA;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(QA||(QA={}));var wa;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...KA.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:QA.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(wa||(wa={}));var Il;(e=>{function n(r){return r.find(i=>i.data.type==="Page"&&i.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,i,s){r.scene.objects.traverseFrom(i,(o,a)=>{if(a.type==="Instance"){let l=Qh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Il||(Il={}));var Aa;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:r0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,h=[]){let d=[],f=i0.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...h);let p=new gr;return p.push({fi:1,id:Tl,data:{...ba.defaultData,name:"Scene 1"},children:d}),p}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Us.defaultData,styles:wa.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new gr,publish:Us.defaultData,styles:wa.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Us.defaultData,styles:wa.defaultData()}},c.emptyData=function(){return{objects:new gr,publish:{...Us.defaultData},styles:wa.defaultData()}};function a(u){return{...c.defaultData,objects:qi(u,gr.prototype)}}c.withObjs=a;function l(u,h){return a([{id:u,data:h,children:[],fi:0}])}c.withObj=l})(Aa||(Aa={}));var Zh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Zh||(Zh={}));var n0;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new ke}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(n0||(n0={}));var SD;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new ke,queries:new ke,autoStart:!0}))(SD||(SD={}));var Br;(s=>{function n(o){return o.textValue!==void 0}s.isTextValue=n;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return n(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function i(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=i})(Br||(Br={}));var ZA;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(ZA||(ZA={}));var wD;(t=>t.all=[...ZA.all,"components"])(wD||(wD={}));var AD;(t=>{function n(){return{images:new Qe,videos:new Qe,colors:new Qe,audios:new Qe,particles:new Qe,fonts:new Qe,materials:new Qe,components:new Qe,variables:new Qe,userAPIs:new Qe,userWebhooks:new Qe}}t.defaultData=n})(AD||(AD={}));var zs;(t=>{function n(){return{images:new Qe,videos:new Qe,colors:new Qe,audios:new Qe,particles:new Qe,fonts:new Qe,materials:new Qe,components:new Qe,variables:new Qe,userAPIs:new Qe,userWebhooks:new Qe}}t.defaultData=n})(zs||(zs={}));var vn;(s=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},qi(o,Qe.prototype)}s.defaultColors=n;function t(){return qi({},Qe.prototype)}s.defaultImages=t;function e(){return{catelogs:new Qe,materials:new Qe,images:new Qe,videos:new Qe,colors:new Qe,audios:new Qe,particles:new Qe,fonts:new Qe,variables:new ke,userAPIs:new Qe,userWebhooks:new Qe,lib:zs.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function i(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),c=Math.floor((o-l*3600)/60),u=Math.round(o-l*3600-c*60);return{textValue:[l,c,u]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),c=Math.round(o-l*60);return{textValue:[l,c]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=i})(vn||(vn={}));var Jh;(t=>t.list=["idle","move","jump","run"])(Jh||(Jh={}));var $h;(e=>(e.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 ke,move:new ke,jump:new ke,run:new ke},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:bt.fromHexAndA(3728051,1)}}))($h||($h={}));function ED(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,i=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Pn(zr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...zr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Ea(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Ta(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,s)=>{i===void 0&&(r.materials[s]=Kr.defaultData(),i=r.materials[s]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Kr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Kr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==yr.prototype&&t(i.material)})})}function p9(n){Object.assign(n.scene.publish,{orbitControls:{...Kh.defaultData,...zr(n.scene.publish.orbitControls)}})}function m9(n){Object.assign(n.scene.publish.settings,{video:{...Us.defaultData.settings.video,...zr(n.scene.publish.settings.video)}})}function g9(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[i,s]of Object.entries(r))if((Yv.includes(i)||typeof s=="boolean")&&delete r[i],i==="texture")for(let[o,a]of Object.entries(s))(gD.includes(o)||typeof a=="boolean")&&delete s[o]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function y9(n){n.scene.publish.withBackground=!0}function v9(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function x9(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(i=>i+1),r.linear.scale=r.linear.scale.map(i=>i+1))})}function b9(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function S9(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=zr(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=zr(e).booleanExclude!==!0)}})}function w9(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function A9(n){function t(r){Object.setPrototypeOf(r,yr.prototype),r.texture&&Object.setPrototypeOf(r.texture,yr.prototype)}function e(r){Object.setPrototypeOf(r,yr.prototype);for(let i in r)t(r[i])}n.scene.objects.traverse((r,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=zr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let i={...zr(t),colors:e,steps:r};Object.assign(t,i)}})}function E9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function MD(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&JA(r)}):"material"in e&&typeof e.material!="string"&&JA(e.material)}),Object.values(n.shared.materials).forEach(t=>JA(t))}function T9(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function M9(n){n.shared.audios=qi({},Qe.prototype)}function C9(n){n.shared.videos=qi({},Qe.prototype)}function P9(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let i={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(t,{[e]:i})}})}function _9(n){Object.entries(zr(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(zr(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function I9(n){n.scene.publish.settings.web.preload=!1}function CD(n){n.layers&&n.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 PD(n){n.layers&&n.layers.forEach(t=>{mD(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 D9(n){n.shared.fonts=qi({},Qe.prototype)}function O9(n){return n.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function R9(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let s=Kr.defaultTwoLayerData("phong"),o=typeof i.color=="string"?n.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=O9(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...vi.defaultData,..._l.defaultData,flatShading:!1,wireframe:!1,geometry:{...xa.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:zr(i.states),events:zr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=zr(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function L9(n){let t={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((e,r)=>{r.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new ke,move:new ke,jump:new ke}});else{let s=new ke;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:we.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(u,Pn(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(u,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...u},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ke({fi:0,id:we.generateUUID(),data:c},{fi:1,id:we.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function B9(n){n.scene.objects.traverse((t,e)=>{function r(i,s){let o=new ke,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Pn(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Pn(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:u,id:c,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(c=>c.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:we.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function _D(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Gr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function ID(n){Ea(n,_D),Ta(n,_D)}function N9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function F9(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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"}})})}function V9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Kr.defaultTwoLayerData("phong"))})}function k9(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function U9(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function z9(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)}function G9(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function j9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function H9(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function W9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=$h.defaultDataThirdPerson.navmesh)})})}function q9(n){n.scene.styles||(n.scene.styles=wa.defaultData())}function DD(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Y9(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}),Ta(n,DD),Ea(n,DD)}function X9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ke})})})}function K9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function OD(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function RD(n,t){if(t<1&&(Ta(n,ED),Ea(n,ED),n.schema=1),t<2&&(p9(n),n.schema=2),t<3&&(g9(n),n.schema=3),t<4&&(y9(n),n.schema=4),t<5&&(v9(n),n.schema=5),t<6&&(x9(n),n.schema=6),t<7&&(b9(n),n.schema=7),t<8&&(n.schema=8),t<9&&(MD(n),n.schema=9),t<10&&(E9(n),n.schema=10),t<11&&(T9(n),n.schema=11),t<12&&(MD(n),n.schema=12),t<13&&(M9(n),n.schema=13),t<14&&(P9(n),n.schema=14),t<15&&(_9(n),n.schema=15),t<16&&(I9(n),n.schema=16),t<17&&(Ta(n,CD),Ea(n,CD),n.schema=17),t<18&&(Ta(n,TD),Ea(n,TD),n.schema=18),t<19&&(m9(n),n.schema=19),t<20&&(D9(n),R9(n),n.schema=20),t<21&&(L9(n),B9(n),n.schema=21),t<22&&(ID(n),n.schema=22),t<23&&(N9(n),n.schema=23),t<24&&(F9(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(C9(n),t<25&&(n.schema=25)),t<26&&(S9(n),n.schema=26),t<27&&(w9(n),n.schema=27),t<28&&(ID(n),n.schema=28),t<29&&(A9(n),n.schema=29),t<30&&(V9(n),n.schema=30),t<31&&(k9(n),n.schema=31),t<33&&(U9(n),n.schema=33),t<34&&(z9(n),n.schema=34),t<35&&(G9(n),n.schema=35),t<36&&(j9(n),n.schema=36),t<37&&(H9(n),n.schema=37),t<38&&(Ta(n,PD),Ea(n,PD),n.schema=38),t<39&&(W9(n),n.schema=39),t<40&&(q9(n),n.schema=40),t<41&&(Y9(n),n.schema=41),t<42&&(X9(n),n.schema=42),t<43&&(K9(n),n.schema=43),t<99){Ta(n,OD),Ea(n,OD),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=hs);let e=zr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=Tl,r.insertBefore(null,null,[{id:Tl,data:{...ba.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Pn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Pn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Pl.defaultData,...Pn(n.scene.environment,"usePhysics","gravity")},camera:zr(n.scene.ownerCamera)??ba.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Aa.TRASH_CAN_ID&&r.move(Tl,o.fi,o.id);let i=0,s=0;n.shared.penumbraSize&&n.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(i,2)],i+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Cl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function LD(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function Q9(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function Z9(n){Array.isArray(zr(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var ed=180/Math.PI;function BD(n){n.rotation=n.rotation.slice(0,3).map(t=>t*ed)}function ND(n){BD(n),n.type==="Page"&&BD(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*ed))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ed),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ed),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ed,t.extrusion.twist*=ed),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(zr(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function J9(n){n.shared.variables=qi({},Qe.prototype)}function $9(n){let t=zr(n.shared.variables);n.shared.variables=qi(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),ke.prototype)}var _o=115;function FD(n,t){t(n.data);for(let e of n.children)FD(e,t)}function e7(n){let t=n.schema??104;t!==_o&&t<105&&(FD(n.asset,ND),n.schema=105)}function t7(n){n.shared.particles=qi({},Qe.prototype),n.shared.lib&&(n.shared.lib.particles=zs.defaultData().particles)}function r7(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function i7(n){n.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function n7(n){n.scene.objects.traverse((t,e)=>{Array.isArray(zr(e.events))!==!1&&e.events?.forEach(r=>{let i=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode=i??"Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode=i==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(o=>{r.gameActions[o]?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),a.type==="Animation"&&(a.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(s=>{s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Once"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}),r.outActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}))})})}function s7(n){n.shared.userAPIs=qi({},Qe.prototype),n.shared.userWebhooks=qi({},Qe.prototype),n.shared.lib&&(n.shared.lib.userAPIs=zs.defaultData().userAPIs,n.shared.lib.userWebhooks=zs.defaultData().userWebhooks)}function s0(n){let t=n.schema??0;if(t!==_o){console.warn("updating from ",t,"to ",_o),RD(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Us.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Ta(n,LD),Ea(n,LD),n.schema=101),t<102&&(Q9(n),n.schema=102),t<104&&(n.shared.catelogs=new Qe,n.shared.lib=zs.defaultData(),n.schema=104),t<105&&(J9(n),n.scene.objects.traverse((e,r)=>{ND(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))e7(e);t<106&&($9(n),n.schema=106),t<107&&(n.shared.lib.variables=zs.defaultData().variables,n.schema=107),t<109&&(t7(n),n.schema=109),t<110&&(r7(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{Z9(r)}),n.schema=111),t<112&&(i7(n),n.schema=112),t<113&&(n7(n),n.schema=113),t<114&&(n.scene.publish.settings.web.imageQuality===void 0&&(n.scene.publish.settings.web.imageQuality=70),n.schema=114),t<115&&(s7(n),n.schema=115)}}var Qh;(c=>{c.defaultData={schema:_o,scene:Aa.defaultData,frames:new Qe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Zh.defaultData),shared:{...vn.emptyData(),colors:vn.defaultColors()}},c.emptyDataForImports=function(){let u=Aa.emptyDataWithPage();return{schema:_o,scene:u,frames:new Qe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Zh.defaultData),shared:{...vn.emptyData(),colors:vn.defaultColors(),images:vn.defaultImages()}}},c.emptyData=function(){return{schema:_o,scene:Aa.emptyDataWithPage(),frames:new Qe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Zh.defaultData),shared:vn.emptyData()}},c.clipboard2dData=function(){return{schema:_o,scene:Aa.emptyData(),frames:new Qe,shared:vn.emptyData()}},c.collabHelper={...jp,updateSchema(u){return(u.schema??0)<_o?bl(u,s0):(u.schema??0)-_o}};function s(u){let h=c.collabHelper.updateSchema(u);return typeof h=="number"?h===0?u:null:h.data}c.updateSchemaDirectly=s;function o(u){return{...u,shared:{...u.shared,lib:zs.defaultData()}}}c.withoutLib=o;function a(u,h){let d=u.scene.objects.get(h);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[h];if(f)return f.asset}}c.getComponentData=a;function l(u){let h=Object.values(u.shared.userAPIs);for(let d of h){let f=d.headers;for(let p of f)if(p.data.key.toLowerCase()==="authorization"&&p.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(Qh||(Qh={}));var o0;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(o0||(o0={}));var VD;(t=>{function n(e){return!0}t.is=n})(VD||(VD={}));var a0;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(i,s){return{position:s?.position??i.position,rotation:s?.rotation??i.rotation,scale:s?.scale??i.scale,shear:s?.shear??i.shear}}r.merge=t;function e(i,s){return hv({position:Vs.isEqual(i.position,s.position)?void 0:s.position,rotation:i.rotation===s.rotation?void 0:s.rotation,scale:Vs.isEqual(i.scale,s.scale)?void 0:s.scale,shear:i.shear&&s.shear&&Vs.isEqual(i.shear,s.shear)?void 0:s.shear})}r.diff=e})(a0||(a0={}));var $A;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})($A||($A={}));var kD;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(kD||(kD={}));var l0;(t=>t.defaultData={opacity:1,fill:{color:bt.fromHexAndA(ii,1),enabled:!0},stroke:{color:bt.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:bt.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:bt.from0to1([0,0,0,1]),enabled:!1,spread:0}})(l0||(l0={}));var Ma;(s=>{function n(o,a){return{name:a}}s.newEmpty=n;function t(o,a){if(a===void 0)return o;let l={...o},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in a&&a[u]!==void 0&&Object.assign(l,{[u]:a[u]});return l}function e(o,a){if(a===void 0)return o;let l={...o};return"fill"in l&&"fill"in a&&a.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...a.fill}}),"stroke"in l&&"stroke"in a&&a.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...a.stroke}}),"layerBlur"in l&&"layerBlur"in a&&a.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...a.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in a&&a.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...a.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in a&&a.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...a.dropShadow}}),"innerShadow"in l&&"innerShadow"in a&&a.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...a.innerShadow}}),l}function r(o,a){if(a===void 0)return o;let l={...o};return Object.assign(l,a0.merge(l,a)),l=t(l,a),l=e(l,a),l}s.patch=r;function i(o,a){let l,c=[];for(let[u,h]of Object.entries(a))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=h);return c}s.toOps=i})(Ma||(Ma={}));var Qp;(t=>t.defaultData={...a0.defaultData,...$A.defaultData,states:new ke,events:new ke,visible:!0,raycastLock:!1})(Qp||(Qp={}));var td;(t=>t.defaultData={...Qp.defaultData,...l0.defaultData})(td||(td={}));var c0;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(c0||(c0={}));var e1;(t=>t.defaultData={...td.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(e1||(e1={}));var rd;(t=>t.defaultData={...td.defaultData,...c0.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(rd||(rd={}));var t1;(t=>t.defaultData={...td.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"})(t1||(t1={}));var r1;(t=>t.defaultData={...td.defaultData,type:"path2d",path:"",name:"Path"})(r1||(r1={}));var UD;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(UD||(UD={}));var Zp;(t=>t.defaultData={...Qp.defaultData,name:"Group",type:"group2d"})(Zp||(Zp={}));var i1;(t=>t.defaultData=()=>({...Qp.defaultData,...c0.defaultData,...l0.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:bt.fromHexAndA(4737101,1),enabled:!0},stroke:{color:bt.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(i1||(i1={}));var Ca;(s=>{function n(o){switch(o){case"rectangle2d":return{...rd.defaultData};case"ellipse2d":return{...e1.defaultData};case"text2d":return{...t1.defaultData};case"vector2d":return{...rd.defaultData};case"path2d":return{...r1.defaultData};case"frame2d":return{...i1.defaultData()};case"group2d":return{...Zp.defaultData}}}s.defaultData=n;function t(o){return"width"in o&&"height"in o?[typeof o.width=="number"?o.width*.5:0,typeof o.height=="number"?o.height*.5:0]:[0,0]}s.getPivot=t;function e(o){return o.type==="rectangle2d"||o.type==="ellipse2d"||o.type==="text2d"||o.type==="frame2d"}s.isResizeable=e;function r(o){return o.type==="frame2d"&&o.autoLayout!==void 0}s.isAutoLayoutable=r;function i(o){return o.type==="rectangle2d"||o.type==="frame2d"}s.hasCorners=i})(Ca||(Ca={}));var u0;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new gr},e.emptyData=function(){return{type:"scene2d",objects:new gr}}))(u0||(u0={}));function Gs(n,t=!1){let e=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,l=new _e,c=0;for(let u=0;ue&&(e=i,t=r)}return t}function s1(n,t){t.set(n)}function o1(n,t,e){let r,i;for(let s=0;s<3;s++){let o=s+3;r=n[s],i=t[s],e[s]=ri?r:i}}function Jp(n,t,e){for(let r=0;r<3;r++){let i=t[n+2*r],s=t[n+2*r+1],o=i-s,a=i+s;oe[r+3]&&(e[r+3]=a)}}function id(n){let t=n[3]-n[0],e=n[4]-n[1],r=n[5]-n[2];return 2*(t*e+e*r+r*t)}function l7(n,t){if(!n.index){let e=n.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new r(4*e)):i=new Uint16Array(new r(2*e)),n.setIndex(new Xe(i,1));for(let s=0;si-s);for(let i=0;il&&(l=T),y&&Sp&&(p=S);let b=n[v+2],M=n[v+3],C=b-M,P=b+M;Cc&&(c=P),y&&bm&&(m=b);let I=n[v+4],_=n[v+5],D=I-_,L=I+_;Du&&(u=L),y&&Ig&&(g=I)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=c,r[5]=u,y&&(i[0]=h,i[1]=d,i[2]=f,i[3]=p,i[4]=m,i[5]=g)}function u7(n,t,e,r){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t*6,h=(t+e)*6;ua&&(a=d);let f=n[u+2];fl&&(l=f);let p=n[u+4];pc&&(c=p)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function h7(n,t,e,r,i){let s=e,o=e+r-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]=a;)o--;if(sn.candidate-t.candidate,Dl=new Array(Pa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),h0=new Float32Array(6);function f7(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=n1(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=n1(n),o!==-1&&(a=p7(e,r,i,o));else if(s===2){let l=id(n),c=1.25*i,u=r*6,h=(r+i)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/Pa;if(i=T.candidate?Jp(S,e,T.rightCacheBounds):(Jp(S,e,T.leftCacheBounds),T.count++)}}for(let S=0;S=Pa&&(A=Pa-1);let T=Dl[A];T.count++,Jp(x,e,T.bounds)}let y=Dl[Pa-1];s1(y.bounds,y.rightCacheBounds);for(let x=Pa-2;x>=0;x--){let S=Dl[x],w=Dl[x+1];o1(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;xA&&(A=x),S>A&&(A=S);let T=(A-w)/2,b=y*2;s[f+b+0]=w+T,s[f+b+1]=T+(Math.abs(w)+T)*GD,wt[y+3]&&(t[y+3]=A)}}return s}function g7(n,t){function e(y){d&&d(y/f)}function r(y,v,x,S=null,w=0){if(!p&&w>=l&&(p=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),x<=u||w>=l)return e(v+x),y.offset=v,y.count=x,y;let A=f7(y.boundingData,S,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let T=h7(a,o,v,x,A);if(T===v||T===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new Vc,M=v,C=T-v;y.left=b,b.boundingData=new Float32Array(6),l1(o,M,C,b.boundingData,s),r(b,M,C,s,w+1);let P=new Vc,I=T,_=x-C;y.right=P,P.boundingData=new Float32Array(6),l1(o,I,_,P.boundingData,s),r(P,I,_,s,w+1)}return y}l7(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=m7(n,i),a=n.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=n.index.count/3,p=!1,m=[],g=c7(n);if(g.length===1){let y=g[0],v=new Vc;v.boundingData=i,u7(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new Vc;v.boundingData=new Float32Array(6),l1(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function WD(n,t){let e=g7(n,t),r,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;uMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=x/4,x=c(x,y),i[d+7]=v,x}}}var In=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=r,this.max=i}setFromPoints(t,e){let r=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=r,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};In.prototype.setFromBox=function(){let n=new E;return function(e,r){let i=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){n.x=i.x*l+s.x*(1-l),n.y=i.y*c+s.y*(1-c),n.z=i.z*u+s.z*(1-u);let h=e.dot(n);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var vme=function(){let n=new In;return function(e,r){let i=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,c=r.satBounds;for(let u=0;u<3;u++){let h=o[u],d=s[u];if(n.setFromPoints(d,a),h.isSeparated(n))return!1}for(let u=0;u<3;u++){let h=c[u],d=l[u];if(n.setFromPoints(d,i),h.isSeparated(n))return!1}}}();var y7=function(){let n=new E,t=new E,e=new E;return function(i,s,o){let a=i.start,l=n,c=s.start,u=t;e.subVectors(a,c),n.subVectors(i.end,i.start),t.subVectors(s.end,s.start);let h=e.dot(u),d=u.dot(l),f=u.dot(u),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),$p=function(){let n=new k,t=new E,e=new E;return function(i,s,o,a){y7(i,s,n);let l=n.x,c=n.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let h;c<0?h=s.start:h=s.end;let d=t,f=e;if(i.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),qD=function(){let n=new E,t=new E,e=new kr,r=new Ti;return function(s,o){let{radius:a,center:l}=s,{a:c,b:u,c:h}=o;if(r.start=c,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var v7=1e-15;function nd(n){return Math.abs(n)new E),this.satBounds=new Array(4).fill().map(()=>new In),this.points=[this.a,this.b,this.c],this.sphere=new Rr,this.plane=new kr,this.needsUpdate=!0}intersectsSphere(t){return qD(t,this)}update(){let t=this.a,e=this.b,r=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let c=s[1],u=o[1];c.subVectors(t,e),u.setFromPoints(c,i);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,i);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Dn.prototype.closestPointToSegment=function(){let n=new E,t=new E,e=new Ti;return function(i,s=null,o=null){let{start:a,end:l}=i,c=this.points,u,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[f]),$p(e,i,n,t),u=n.distanceToSquared(t),u1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let T=v[A],b=x[A];if(r.setFromPoints(b,e),T.isSeparated(r))return!1}let S=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let T=S[A],b=w[A];if(r.setFromPoints(b,t),T.isSeparated(r))return!1}for(let A=0;A<4;A++){let T=x[A];for(let b=0;b<4;b++){let M=w[b];if(s.crossVectors(T,M),r.setFromPoints(s,t),i.setFromPoints(s,e),r.isSeparated(i))return!1}}return p&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,S=0;for(let D=0;D<3;D++){let L=v[D],j=v[(D+1)%3];c.start.copy(L),c.end.copy(j),c.delta(o);let V=x?u.start:u.end,H=nd(y.distanceToPoint(L));if(nd(y.normal.dot(o))&&H){u.copy(c),S=2;break}if((y.intersectLine(c,V)||H)&&!nd(V.distanceTo(j))){if(S++,x)break;x=!0}}if(S===1&&f.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(S!==2)return!1;let w=f.points,A=!1,T=0;for(let D=0;D<3;D++){let L=w[D],j=w[(D+1)%3];c.start.copy(L),c.end.copy(j),c.delta(a);let V=A?h.start:h.end,H=nd(g.distanceToPoint(L));if(nd(g.normal.dot(a))&&H){h.copy(c),T=2;break}if((g.intersectLine(c,V)||H)&&!nd(V.distanceTo(j))){if(T++,A)break;A=!0}}if(T===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(T!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let D=h.start;h.start=h.end,h.end=D}let b=u.start.dot(o),M=u.end.dot(o),C=h.start.dot(o),P=h.end.dot(o),I=M0?p.start.copy(u.start):p.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?p.end.copy(u.end):p.end.copy(h.end)),!0)}}}();Dn.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Dn.prototype.distanceToTriangle=function(){let n=new E,t=new E,e=["a","b","c"],r=new Ti,i=new Ti;return function(o,a=null,l=null){let c=a||l?r:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,n),d=p.distanceToSquared(n),dnew E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new In),this.alignedSatBounds=new Array(3).fill().map(()=>new In),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};On.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let d=1*c|2*u|4*h,f=i[d];f.x=c?r.x:e.x,f.y=u?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){let u=o[c],h=s[c],d=1<new Ti),e=new Array(12).fill().map(()=>new Ti),r=new E,i=new E;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,r),o.closestPointToPoint(r,i),l&&l.copy(r),c&&c.copy(i)),0;let u=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(h,d);let v=y.distanceToSquared(i);if(v0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new E,materialIndex:0};Cr.getNormal(sd,od,ad,u.normal),c.face=u,c.faceIndex=s}return c}function u1(n,t,e,r,i){let s=r*3,o=n.index.getX(s),a=n.index.getX(s+1),l=n.index.getX(s+2),{position:c,normal:u,uv:h,uv1:d}=n.attributes,f=b7(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function QD(n,t,e,r,i,s){for(let o=r,a=r+i;o=0,f,p;d?(f=ud(n),p=hd(n,a)):(f=hd(n,a),p=ud(n));let g=S0(f,s,r,v0)?b0(f,t,e,r):null;if(g){let x=g.point[u];if(d?x<=s[p+c]:x>=s[p+c+3])return g}let v=S0(p,s,r,v0)?b0(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var $D=function(){let n,t,e=[],r=new ld(()=>new Ht);return function(...o){n=r.getPrimitive(),t=r.getPrimitive(),e.push(n,t);let a=i(...o);r.releasePrimitive(n),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],n=e[l-2]),a};function i(s,o,a,l,c=null,u=0,h=0){function d(x){let S=x*2,w=Ol,A=Rl;for(;!_a(S,w);)x=ud(x),S=x*2;return kc(x,A)}function f(x){let S=x*2,w=Ol,A=Rl;for(;!_a(S,w);)x=hd(x,A),S=x*2;return kc(x,A)+cd(S,w)}let p=s*2,m=fd,g=Ol,y=Rl;if(_a(p,g)){let x=kc(s,y),S=cd(p,g);return fs(s,m,n),l(x,S,!1,h,u+s,n)}else{let x=ud(s),S=hd(s,y),w=x,A=S,T,b,M,C;if(c&&(M=n,C=t,fs(w,m,M),fs(A,m,C),T=c(M),b=c(C),bi.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(c),b.b.applyMatrix4(c),b.c.applyMatrix4(c),b.needsUpdate=!0;for(let M=w*3,C=(A+w)*3;Mnew Dn),Do=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Do.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,i=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Do.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:i,roots:s}=t,o=new Do(e,{...r,[f1]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Xe(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[f1]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[f1]||(this._roots=WD(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Ht))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,i=e.attributes.position,s,o,a,l,c=0,u=this._roots;for(let d=0,f=u.length;dA&&(A=I),_T&&(T=_),Db&&(b=D)}return l[d+0]!==x||l[d+1]!==S||l[d+2]!==w||l[d+3]!==A||l[d+4]!==T||l[d+5]!==b?(l[d+0]=x,l[d+1]=S,l[d+2]=w,l[d+3]=A,l[d+4]=T,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,S=v+f,w=p,A=!1,T=!1;t?w||(A=t.has(x),T=t.has(S),w=!A&&!T):(A=!0,T=!0);let b=w||A,M=w||T,C=!1;b&&(C=h(y,f,w));let P=!1;M&&(P=h(v,f,w));let I=C||P;if(I)for(let _=0;_<3;_++){let D=y+_,L=v+_,j=l[D],V=l[D+3],H=l[L],W=l[L+3];l[d+_]=jW?V:W}return I}}}traverse(t,e=0){let r=this._roots[e],i=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let c=a*2,u=s[c+15]===65535;if(u){let h=i[a+6],d=s[c+14];t(l,u,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];t(l,u,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Hn){let r=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,c=o?e.side:e;for(let u=0,h=r.length;u{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Io.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:h1(f,p,i,c,m,g,s)}else l||(c?l=(d,f,p,m)=>h1(d,f,i,c,p,m,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(pd(d),u=$D(0,i,a,l,o,h),em(),u)break;h+=d.byteLength}return Io.releasePrimitive(s),u}bvhcast(t,e,r){let{intersectsRanges:i,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,c=t.geometry.attributes.position;md.copy(e).invert();let u=Io.getPrimitive(),h=Io.getPrimitive();if(s){let f=function(p,m,g,y,v,x,S,w){for(let A=g,T=g+y;Am1.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(p1.copy(v),p1.applyMatrix4(md),t.shapecast({intersectsBounds:x=>p1.intersectsBox(x),intersectsRange:(x,S,w,A,T)=>i(f,p,x,S,g,y,A,T)}))});return Io.releasePrimitive(u),Io.releasePrimitive(h),d}intersectsBox(t,e){return Uc.set(t.min,t.max,e),Uc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Uc.intersectsBox(r),intersectsTriangle:r=>Uc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Uc.set(t.boundingBox.min,t.boundingBox.max,e),Uc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=Io.getPrimitive(),f=Io.getPrimitive(),p=w0,m=A7,g=null,y=null;i&&(g=E7,y=T7);let v=1/0,x=null,S=null;return md.copy(e).invert(),tm.matrix.copy(md),this.shapecast({boundsTraverseOrder:w=>Uc.distanceToBox(w),intersectsBounds:(w,A,T)=>T{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:T=>tm.distanceToBox(T),intersectsBounds:(T,b,M)=>M{for(let M=T*3,C=(T+b)*3;M(rm.copy(t).clamp(u.min,u.max),rm.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d{u.closestPointToPoint(t,rm);let d=t.distanceToSquared(rm);return d{fs(0,new Float32Array(r),tO),t.union(tO)}),t}};var cf=ta(iO());var M7=.5*(Math.sqrt(3)-1),im=(3-Math.sqrt(3))/6,C7=1/3,Oo=1/6,hge=(Math.sqrt(5)-1)/4,dge=(5-Math.sqrt(5))/20,nm=n=>Math.floor(n)|0,nO=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),y1=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function A0(n=Math.random){let t=oO(n),e=new Float64Array(t).map(i=>nO[i%12*2]),r=new Float64Array(t).map(i=>nO[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*M7,h=nm(s+u),d=nm(o+u),f=(h+d)*im,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let S=g-v+im,w=y-x+im,A=g-1+2*im,T=y-1+2*im,b=h&255,M=d&255,C=.5-g*g-y*y;if(C>=0){let _=b+t[M],D=e[_],L=r[_];C*=C,a=C*C*(D*g+L*y)}let P=.5-S*S-w*w;if(P>=0){let _=b+v+t[M+x],D=e[_],L=r[_];P*=P,l=P*P*(D*S+L*w)}let I=.5-A*A-T*T;if(I>=0){let _=b+1+t[M+1],D=e[_],L=r[_];I*=I,c=I*I*(D*A+L*T)}return 70*(a+l+c)}}function sO(n=Math.random){let t=oO(n),e=new Float64Array(t).map(s=>y1[s%12*3]),r=new Float64Array(t).map(s=>y1[s%12*3+1]),i=new Float64Array(t).map(s=>y1[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*C7,p=nm(o+f),m=nm(a+f),g=nm(l+f),y=(p+m+g)*Oo,v=p-y,x=m-y,S=g-y,w=o-v,A=a-x,T=l-S,b,M,C,P,I,_;w>=A?A>=T?(b=1,M=0,C=0,P=1,I=1,_=0):w>=T?(b=1,M=0,C=0,P=1,I=0,_=1):(b=0,M=0,C=1,P=1,I=0,_=1):At){s=o;break}else t1&&(i=1-i,s=1-s),js.a.fromBufferAttribute(this.positionAttribute,t*3),js.b.fromBufferAttribute(this.positionAttribute,t*3+1),js.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(js.a,i).addScaledVector(js.b,s).addScaledVector(js.c,1-(i+s)),js.getNormal(r),this}};var lO=ta(v1()),P7=new ue,_7=new ue,I7=new ue,gd;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(gd||(gd={}));var yd=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Tt&&(r=r.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===r)return!0;i=i.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let s of this.children)gd.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)gd.is(o)&&o.traverseObject(r,i+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,i=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,lO.SVD)(i),l=P7.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),c=_7.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),u=I7.copy(c).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,i){this.updateWorldMatrix(!0,!1);let s=new ue().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ue?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),i!==void 0&&(this.children.pop(),this.children.splice(i,0,r)),this}copy(r,i=!1){return super.copy(r,i),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,i,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var x1=class extends yd(Tt){},D7=n=>n.type==="Mesh",Nr=class extends x1{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new Nr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return 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 D7(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}};var zc=new E,Gc=new E,vd=new ue,uO=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],O7=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],R7=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],cO=(n,t,e)=>{n.updateEntityBoxSize(zc,Gc),vd.copy(t).multiply(n.matrixWorld),Gc.x===0&&Gc.y===0&&Gc.z===0?e.push(new E(zc.x,zc.y,zc.z).applyMatrix4(vd)):uO.forEach(r=>{e.push(r.clone().multiply(Gc).add(zc).applyMatrix4(vd))})},sm=class extends Ht{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(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new E);return}cO(o,r,s)}}):cO(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(vd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Gc).multiplyScalar(.5),this.getCenter(zc),vd.copy(this.matrix).setPosition(zc),this.vertices=uO.map(e=>e.clone().multiply(Gc).applyMatrix4(vd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=O7.map(([e,r])=>new Ti(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=R7.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Hs={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var S1=class extends bp{constructor(){super()}getPoints(t=12){let e=[],r,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var w1=.001;function A1(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=w1}function b1(n,t){let e=new E(...n.position),r=new E(...n.controlNext.position),i=new E(...t.controlPrevious.position),s=new E(...t.position);return A1(e,r,s)&&A1(e,i,s)}function M0(n){let t=n.points.map(u=>new E(...u.data.position)),e=[n.points[0]],r=new E(...e[0].data.position);for(let u=0;uw1&&(m=new Ec(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>w1&&(m=new Ec(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=m}for(let u=0;u{u&&c.add(u)}),c}var yt;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(yt||(yt={}));var Ro=n=>yt.is(n),L7={type:"completeState",isfromEntity:!0},B7=["x","y","z"],E1=new E,N7=new E().set(0,1,0),xd=n=>class extends yd(n){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.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new sm;this._recursiveBBox=new sm;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let i=this.children[r];if(yt.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(yt.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let i=r.parent;if(yt.is(i))r=i;else return}return r}forInstancesRec(r){this.instances.forEach(i=>{i.disposed||r(i),i.forInstancesRec(r)})}super_Entity(r,i){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)Sa.toOps(this.data,o.data).forEach(l=>{let c=Vh.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,i)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=Sa.patch(this.data,o),Sa.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched,i),this.stateSelection=r,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(r,i){r.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Ro(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let i;return this.traverseEntity(s=>{s.uuid===r&&(i=s)}),i}traverseSortNextHelper(){let r=this.parent;if(r){let i=r.children,s=i.indexOf(this)+1;if(yt.is(i[s]))return i[s];if(yt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&yt.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let i=this;for(;r>0&&i!==null;)i=i.parent,r-=1;return i}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let i=this.parent;for(;i;){if(r===i)return!0;i=i.parent}return!1}countToAccestor(r){let i=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(r){for(let i of this.children)Ro(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{yt.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Ro(o)&&o.isConcreteEntity&&o.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Ro(o)&&o.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Ro(i)&&i.visible&&i.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,i=!1){return super.copy(r,i),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Ro(r))}isAncestorOf(r){if(this.uuid===r)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===r&&(i=!0)}),i}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*we.RAD2DEG,this.rotation.y*we.RAD2DEG,this.rotation.z*we.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Dh(i,r)}getTransformValues(r,i,s){return i[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,B7[a]])??o)}updateTransformState(r,i){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),s=!0),r.rotation&&(E1.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(we.DEG2RAD),this.rotation.setFromVector3(E1),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,i)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??El.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)yt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{yt.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Dh(i,r)}updateByObjUpdateOp(r,i){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},i,!1)}updateByOp(r,i,s,o){let a=this.data;this.data=i;let l=r,c=Lt(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Sr.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let h=Sr.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,Sa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Lt(r.path,["overrides"])){let u=[],h=[...r.path];for(u.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)u.push(h[1]),h.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=s.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(So.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Sr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=Xh.resolve(i.overrides,u),d.updateByOp(r,Lr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let h;for(let d of Po.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of Po.rootOverrideProps)if(Lt(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=So.filterOp(h.overrideData,u);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=So.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=i:f=Lr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,i,s){if(this.dataPatched=i,r.path.length===0&&r.type===0)r.props.type!==void 0&&!ks.is(r.props.type)&&Hs.changeEntityProptotype(this,i,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Hs.changeEntityProptotype(this,i,s);for(let o of this.children)yt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,i,s)}updateByPatchedOp(r,i,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),r.path[0]==="morphTargetInfluences"&&r.type===0){let a=i.morphTargetInfluences.get(r.path[1])?.data.name;a&&this.updateMorphInfluences(a,s.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",a]))}if(Lt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Lt(r.path,["cloner"])!==null){let o=Lr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=r.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=M0(c.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=null;try{d=u.curves.length?u.getPointAt(h):null}catch(g){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(g))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ue;l.updateMatrixWorld();let p=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let g=new ue().extractRotation(l.matrixWorld),y=u.getTangentAt(h).applyMatrix4(g).add(d),v=new ue().lookAt(d,y,N7),x=E1.setFromEuler(new nr().setFromRotationMatrix(v)).multiplyScalar(we.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(L7)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let i=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return i=!0,!0}),i&&r.reloadSplats()}updateState_Entity(r,i){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(r,i)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Hs.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,i){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Hs.Cloner(this,r),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,i.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var C0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=we.clamp(e.thetaLength,0,360);let r=e.width/2,i=e.radiusTop??r,s=e.radiusBottom??r;return i===s?(i=r,s=r):i>s?(i=r,s=s*r/i):(i=i*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=n.parameters,p;return l===0?(p=new _e,p.setAttribute("position",new Te([],3))):h||f?p=new om(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):p=new Mc(c,u,r,i,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"CylinderGeometry"}})}};function Ll(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function hO(n){return new k(n.y,-n.x)}var om=class extends _e{constructor(t,e,r,i,s,o,a,l,c,u,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let p=[],m=[],g=[],y=[],v=0,x=r/2,S=new E,w=new E;f&&t==0&&(t=c),f&&e==0&&(e=u);let A=new k(t,x),T=new k(e,-x),b=null,M=null,C=null,P=null,I=A.clone().sub(T),_=0,D=0,L=0;d>0&&(_=Math.min(t,e)*(1-d),D=t-_,L=e-_);let j=A.clone();j.x-=_;let V=Math.PI-I.angle(),H=I.angle(),W=Math.tan(H/2),q=Math.tan(V/2),Q=W+q,G=d?Q:q,Z=d?Q:W;if(c=Math.min(c,(t-D)/G,I.length()/Q),u=Math.min(u,(e-L)/Z,I.length()/Q),c>0){let re=c/W;b=A.clone().sub(new k(re,c)),d&&(C=b.clone(),C.x-=_-Q*c),A.sub(I.clone().setLength(re))}if(u>0){let re=u/q;M=T.clone().sub(new k(re,-u)),T.add(I.clone().setLength(re)),d&&(P=M.clone(),P.x-=_-Q*u,j.sub(I.clone().setLength(re)))}I=A.clone().sub(T);let te=I.length()<.5,$=[];for(let re=0;re<=i;re++){let J=[],Ae=re/i,xe=Ae*l+a,de=new k(Math.sin(xe),Math.cos(xe));P&&M?(Y(J,Ae,de,V,u,P,-1,!0),Y(J,Ae,de,H,u,M,-1,!1)):M?(oe(J,de,M.x,0,-1),Y(J,Ae,de,H,u,M,-1,!1)):o||oe(J,de,e,L,-1);let De=hO(I).normalize();if(Ll(De,de,S),!te)for(let Ce=0;Ce<=s;Ce++){let ze=Ce/s,Ue=I.clone().multiplyScalar(ze).add(T);Ll(Ue,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}if(C&&b?(Y(J,Ae,de,V,c,b,1,!1),Y(J,Ae,de,H,c,C,1,!0)):b?(Y(J,Ae,de,V,c,b,1,!1),oe(J,de,b.x,0,1)):o||oe(J,de,t,D,1),d&&!te){let Ce=hO(I).multiplyScalar(-1).normalize();Ll(Ce,de,S);for(let ze=0;ze<=s;ze++){let Ue=ze/s,Ve=I.clone().multiplyScalar(-Ue).add(j);Ll(Ve,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}}d&&!o&&J.push(J[0]),$.push(J)}for(let re=0;re<$.length-1;re++)for(let J=0;J<$[0].length-1;J++){if(o&&d&&J==s)continue;let Ae=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],De=$[re][J+1],Ce=m[de*3+0],ze=m[de*3+2];p.push(Ae,xe,De),(Ce!=0||ze!=0)&&p.push(xe,de,De)}lp.push(Ve,Oe,Ye):(Ve,Oe,Ye)=>p.push(Ve,Ye,Oe),ze=new k((t+e+D+L)/4,0);Ll(ze,xe,De),m.push(De.x,De.y,De.z),g.push(de.x,0,de.y),y.push(.5,.5);let Ue=v++;for(let Ve of J){let Oe=m.slice(Ve*3,Ve*3+3);m.push(...Oe),g.push(de.x,0,de.y);let Ye=y.slice(Ve*2,Ve*2+2);y.push(...Ye),v++}for(let Ve=Ue+1;Ve0||u>0||l<360?d=new om(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new al(t/2,r,i,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var fO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a===0?c=new mi(t,e,r,i,s,o):c=new M1(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},T1=Math.PI/2,M1=class extends _e{constructor(t=1,e=1,r=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry",i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],u=[],h=[],d=[],f=0;p("z","y","x",-1,-1,r,e,t,o,s),p("z","y","x",1,-1,r,e,-t,o,s),p("x","z","y",1,1,t,r,e,i,o),p("x","z","y",1,-1,t,r,-e,i,o),p("x","y","z",1,-1,t,e,r,i,s),p("x","y","z",-1,-1,t,e,-r,i,s),a>0&&(m("z","y","x",-1,-1,1,r,e,t,o),m("z","y","x",1,-1,-1,r,e,t,o),m("z","y","x",-1,1,-1,r,e,t,o),m("z","y","x",1,1,1,r,e,t,o),m("x","y","z",-1,-1,-1,t,e,r,i),m("x","y","z",1,-1,1,t,e,r,i),m("x","y","z",-1,1,1,t,e,r,i),m("x","y","z",1,1,-1,t,e,r,i),m("y","x","z",-1,-1,1,e,t,r,s),m("y","x","z",1,-1,-1,e,t,r,s),m("y","x","z",1,1,1,e,t,r,s),m("y","x","z",-1,1,-1,e,t,r,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(d,2));function p(y,v,x,S,w,A,T,b,M,C){let P=(A-2*a)/M,I=(T-2*a)/C,_=A/2-a,D=T/2-a,L=b/2,j=M+1,V=C+1,H=0,W=new E;for(let q=0;q0?1:-1,h.push(W.x,W.y,W.z),d.push(G/M),d.push(1-q/C),H+=1}}for(let q=0;q0?(M,C,P)=>c.push(M,C,P):(M,C,P)=>c.push(M,P,C);for(let M=0;M<=l;M++){let C=[],P=T1*(1-M/l),I=Math.cos(P),_=Math.sin(P),D=0;for(let L=0;L<=M;L++){let j=Math.cos(D),V=Math.sin(D);S.x=I*j,S.y=_,S.z=I*V;let H=w.clone().addScaledVector(S,a);u.push(y*H.x,v*H.y,x*H.z),h.push(y*S.x,v*S.y,x*S.z),d.push(0,0),C.push(f++),D+=T1/M}A.push(C)}let b=A.length-1;for(let M=0;MS.subVectors(W,q).normalize(),A=(W,q)=>Array(W).fill(void 0).map(q),T=A(t.length/3,(W,q)=>new E().fromArray(t,q*3).setLength(i)),b=[],M=1e6;for(let W=0;Wxe[0]==Z)}b.push(oe)}let C=[];{let W=0,q=0,Q,G,Z=f==3;for(let te=0;te<=o;te++){Q=te*(te+1)/2,G=(te+1)*(te+2)/2;for(let $=0;$A(f,()=>p.clone()));for(let W=0;Woe.add(ie),te).multiplyScalar(1/f);for(let oe=0;oeJ[xe]);a.push(...Ae.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...Ae.map(xe=>(w(xe,P),[S.x,S.y,S.z])).flat())}}let H=[];for(let W=0;W$%M==W),Z=j[W][q],te=j[Q][G];for(let $=0;${a.push(J[0].x,J[0].y,J[0].z),c.push(J[1].x,J[1].y,J[1].z)})}H.push(Z[0][0],te[x][0],Z[x][0],te[0][0])}}for(;H.length;){let W,q,Q,G;[W,q]=H.splice(0,2);let Z=[W];for(;W!=q;)Z.push(q),Q=H.indexOf(q),G=Q%2,q=H.splice(Q-G,2)[1-G];S.subVectors(Z[0],Z[1]).cross(p.subVectors(Z[0],Z[2])).normalize();let te=S.dot(Z[0])<0;te&&S.negate();for(let $=1;$<=Z.length-2;$++)[Z[$+ +te],Z[$+1-+te],Z[0]].forEach(Y=>{a.push(Y.x,Y.y,Y.z),c.push(S.x,S.y,S.z)})}}function h(){let d=new E;for(let T=0;T{C<0&&T.x===1&&(l[b]=T.x-1),M.x===0&&M.z===0&&(l[b]=C/2/Math.PI+.5)};for(let T=0,b=0;T.9&&I<.1&&(b<.2&&(l[T+0]+=1),M<.2&&(l[T+2]+=1),C<.2&&(l[T+4]+=1))}function w(T){return Math.atan2(T.z,-T.x)}function A(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(t){return new Bl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var pO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new am(t*.5,s,o):new Gu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},am=class extends Bl{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[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],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new am(t.radius,t.corner,t.cornerSides)}};var lm=1e-12,bd=class{constructor(t){this.position=new k;this.startPosition=new k;this.uuid=we.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new bd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Sd=class extends bd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Sd(this.parent).copy(this)}},Ws=class extends bd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Sd(this),new Sd(this))}static create(e,r){let i=new Ws(e,new k(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let i=0,s=this.controls.length;in,wd=new k,P0=new k,F7=new k,V7=new k,k7=new k,U7=new k,yO=new E,vO=new E;function xO(n){let t=new k;t.addVectors(n.v0,wd.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new k;return e.addVectors(n.v2,P0.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new an(n.v0,t,e,n.v2)}function cm(n,t,e=Number.EPSILON){return Math.abs(n-t)Math.PI&&(u*=-1),cm(c,a)?h=(a+c)*(r/u-.5)*8/3/(o-l):h=(o+l)*(r/u-.5)*8/3/(c-a),i.set(t.x-h*a,t.y+h*o),s.set(e.x+h*c,e.y-h*l),[i,s]}function I1(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function gO(n,t){return C1(n.position,n.controls[1].position,t.position)&&C1(n.position,t.controls[0].position,t.position)}function EO(n,t,e,r,i=.5){let s=wd.subVectors(t,n).multiplyScalar(i).add(n),o=P0.subVectors(e,t).multiplyScalar(i).add(t),a=F7.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=V7.subVectors(o,s).multiplyScalar(i).add(s),u=k7.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=U7.subVectors(u,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,r.x,r.y]}function TO(n,t,e=12,r=!0){let i=vO.set(0,0,0),s,o=0,a=[];for(let l=0;l1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),n}function MO(n,t,e,r=12,i=!0){let s=vO.set(0,0,0),o=0,a=[];for(let l=0;l1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),a}function D1(n,t=12,e=!1){let r=[];for(let i=0,s=n.length;i0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Nl(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Nl(n[0].roundedCurveCorner,t)*.5),r}function Nl(n,t=12){return n&&n instanceof Ac?t*2:n&&(n instanceof ln||n instanceof xp)?1:n&&n instanceof ku?t*n.points.length:t}function CO(n,t,e=12,r=!0){let i,s=0;for(let o=0;o1&&!(cm(n[s-1],n[1],lm)&&cm(n[s-2],n[0],lm))&&(n.push(n[0],n[1]),s++),n}var O1=new k,j7=new k,H7=new k,W7=new k,q7=new k,Y7=new k,Xt=class extends ua{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new kr(new E(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=we.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let s=new Xt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Ws.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Xt.createFromState(o)),r!==void 0&&i!==void 0&&s.applySize(r,i),s.update(),s}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 r=0,i=this.points.length;rthis.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=r;for(let o=0,a=this.shapeHoles.length;o0){let r=this.points.length;for(let i=0,s=this.shapeHoles.length;i=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let i=O1.set(e,r);for(let s=0,o=this.points.length;s=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(i=>i.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;eo+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=D1(this.points,e,!1),this.roundedCurveDivisions=D1(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return MO(e,this.curves,r,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),CO(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=Nl(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(I1(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(O1.set(i.x,i.y))/h}let c=0;for(let h=0;h2){let r=0;for(let i=0,s=this.points.length;i0&&!u){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(c,m*.499),v=Math.min(c,g*.499),x=Math.min(y,v),S=1-x/m,w=x/g,A=h.getPointAt(S,O1),T=d.getPointAt(w,j7);this._subSplitCurve(h,f,S,A,void 0),this._subSplitCurve(d,p,w,void 0,T);let b;if(this.useCubicForRoundedCorners){let M=_1(A,o.position,T)/2,C=Math.tan(M)*A.distanceTo(o.position),[P,I]=SO(A,T,C,H7,W7),_=wO(P,I,o.position),[D,L]=AO(_,A,T,C,q7,Y7);b=new an(A.clone(),D.clone(),L.clone(),T.clone())}else b=new Yn(A.clone(),o.position.clone(),T.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+r,0,b),r++}}}}_subSplitCurve(e,r,i,s,o){if(e instanceof ln)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,c=a.getUtoTmapping(i,0),u=EO(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),o!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new Xt(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let i=0;i{let s=new Xt;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let i=(o,a)=>{a instanceof an&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,c;for(l=0,c=o.length;l0?o[l-1]:null,p;d instanceof an?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof ln&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&i(p,f),a.push(p))}let u=o[o.length-1],h=!1;return u instanceof an?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof ln&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof ua&&(this.shapeHoles=e.holes.map(o=>{let a=new Xt;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let i=this.getPointByUuid(e);i&&(r.position!==void 0&&i.position.fromArray(r.position),r.roundness!==void 0&&(i.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var L1=Math.PI*2;function R1({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function X7(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),s=Math.cos(n+t),o=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function PO(n,t,e,r){let i=n*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(s)}function K7(n,t,e,r,i,s,o,a,l,c){let u=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let m=p*i/s*a,g=p*-s/i*o,y=m+(n+e)/2,v=g+(t+r)/2,x=(o-m)/i,S=(a-g)/s,w=(-o-m)/i,A=(-a-g)/s,T=PO(1,0,x,S),b=PO(x,S,w,A);return!c&&b>0&&(b-=L1),c&&b<0&&(b+=L1),{centerx:y,centery:v,ang1:T,ang2:b}}function _O({px:n,py:t,cx:e,cy:r,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(n-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=K7(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(L1/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x{let{x:S,y:w}=R1(x[0],i,s,m,g),{x:A,y:T}=R1(x[1],i,s,m,g),{x:b,y:M}=R1(x[2],i,s,m,g);return{x1:S,y1:w,x2:A,y2:T,x:b,y:M}})}var zt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(zt||(zt={}));var jr;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(jr||(jr={}));function ut(n,t){if(!n)throw t||"Assertion Failed!"}var ot=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s0?i0?(e.t-r.t)*i+(e.t-t.t)*s:0},n.transEval=function(t,e,r){ut(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?i0?(e.s-r.s)*i+(e.s-t.s)*s:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,s){var o,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(o=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,e.s)):(o=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,i.s)):s.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(o=n.transEval(t,r,e),a=n.transEval(r,e,i),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,e.t)):(o=n.transSign(t,r,e),a=-n.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,i.t)):s.t=(r.t+e.t)/2},n}(),um=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),_0=function(){function n(t){this.side=t,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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Ad=function(){function n(){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}return n}(),IO=function(){function n(){var t=new Ad,e=new um,r=new _0(0),i=new _0(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new _0(0),r=new _0(1);t.Sym.sidethis.size||this.leq(r[i].key,r[s].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;ut(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),B1=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),RO=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),Z7=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new RO,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new RO;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),J7=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,s=e.eUp,o=r.eUp;if(s.Dst===i)return o.Dst===i?ot.vertLeq(s.Org,o.Org)?ot.edgeSign(o.Dst,s.Org,o.Org)<=0:ot.edgeSign(s.Dst,o.Org,s.Org)>=0:ot.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ot.edgeSign(s.Dst,i,s.Org)>=0;var a=ot.edgeEval(s.Dst,i,s.Org),l=ot.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ut(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ut(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new B1;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case zt.ODD:return(e&1)!==0;case zt.NONZERO:return e!==0;case zt.POSITIVE:return e>0;case zt.NEGATIVE:return e<0;case zt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=n.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){n.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,o),a=s.eUp,o=s}return a},n.addRightEdges=function(t,e,r,i,s,o){var a,l,c,u,h=!0;c=r;do ut(ot.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=n.regionBelow(e).eUp.Rprev),l=e,u=s;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&n.checkForRightSplice(t,l)&&(n.addWinding(c,u),n.deleteRegion(t,l),t.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,ut(l.windingNumber-c.winding===a.windingNumber),o&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=ot.vertL1dist(e,t),s=ot.vertL1dist(r,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,s,o)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp;if(ot.vertLeq(i.Org,s.Org)){if(ot.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ot.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=r.dirty=!0)}else{if(ot.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o;if(ut(!ot.vertEq(i.Dst,s.Dst)),ot.vertLeq(i.Dst,s.Dst)){if(ot.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(ot.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,u,h,d=new Ad,f,p;if(ut(!ot.vertEq(c,l)),ut(ot.edgeSign(l,t.event,o)<=0),ut(ot.edgeSign(c,t.event,a)>=0),ut(o!==t.event&&a!==t.event),ut(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(ot.vertLeq(o,a)){if(ot.edgeSign(c,o,a)>0)return!1}else if(ot.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),ot.intersect(l,o,c,a,d),ut(Math.min(o.t,l.t)<=d.t),ut(d.t<=Math.max(a.t,c.t)),ut(Math.min(c.s,l.s)<=d.s),ut(d.s<=Math.max(a.s,o.s)),ot.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=ot.vertLeq(o,a)?o:a,ot.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ot.vertEq(d,o)||ot.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!ot.vertEq(l,t.event)&&ot.edgeSign(l,t.event,d)>=0||!ot.vertEq(c,t.event)&&ot.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),r=e,e=n.topRightRegion(e),p=n.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,s.Onext,i.Rprev,p,!0),!0):(ot.edgeSign(l,t.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ot.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,o,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,s;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=r.eUp,i.Dst!==s.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(s),r=n.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(n.addWinding(s,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,s=r.Onext,o=n.regionBelow(e),a=e.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),ot.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=n.topLeftRegion(t,e),s=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),o),c=!0),ot.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,o,null),c=!0),c){n.addRightEdges(t,e,r.Onext,s,s,!0);return}ot.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,s,o,a,l;if(i=e.eUp,ot.vertEq(i.Org,r)){ut(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ot.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}ut(!1),e=n.topRightRegion(e),l=n.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(ut(s!==o),n.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),ot.edgeGoesLeft(s)||(s=null),n.addRightEdges(t,e,o.Onext,a,s,!0)},n.connectLeftVertex=function(t,e){var r,i,s,o,a,l,c=new B1;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,ot.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=ot.vertLeq(a.Dst,o.Dst)?r:i,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}s.fixUpperEdge?n.fixUpperEdge(t,s,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);ut(i!==null);var s=n.regionBelow(i),o=s.eUp,a=n.finishLeftRegions(t,s,null);a.Onext===o?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,o,o,!0)},n.addSentinel=function(t,e,r,i){var s=new B1,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},n.initEdgeDict=function(t){t.dict=new Z7(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,s,o),n.addSentinel(t,i,s,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ut(e.fixUpperEdge),ut(++r===1)),ut(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,i=e.Lnext,ot.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,s=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)s++;for(s+=8,e=t.pq=new Q7(s,ot.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,s;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,s=r.anEdge,ut(s.Lnext!==s),s.Lnext.Lnext===s&&(n.addWinding(s.Onext,s),t.mesh.delete(s));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ot.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),$7=function(){function n(){this.mesh=new IO,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=zt.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,i,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],c[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],sl[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],i=f[v],u[0]=r.coords[0]-i.coords[0],u[1]=r.coords[1]-i.coords[1],u[2]=r.coords[2]-i.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-i.coords[0],h[1]=e.coords[1]-i.coords[1],h[2]=e.coords[2]-i.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.sthis.bmax[0]&&(this.bmax[0]=c.s),c.tthis.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ot.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ot.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(ot.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ot.edgeGoesLeft(i.Lnext)||ot.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ot.edgeGoesRight(r.Lprev)||ot.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,e===jr.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==i);this.elements[u++]=s,this.elements[u++]=o,s+=o}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new IO),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,s,o){if(t===void 0&&(t=zt.ODD),e===void 0&&(e=jr.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),J7.computeInterior(this,o);var a=this.mesh;return e===jr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===jr.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function qs(n){var t=n.windingRule,e=t===void 0?zt.ODD:t,r=n.elementType,i=r===void 0?jr.POLYGONS:r,s=n.polySize,o=s===void 0?3:s,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,u=c===void 0?[0,0,1]:c,h=n.contours,d=h===void 0?[]:h,f=n.strict,p=f===void 0?!0:f,m=n.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new $7;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var v=0;vthis.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},hm=I0;hm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var FO=ta(NO()),dm={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},U1={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},z1={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},k1=(n,t)=>([e,r])=>(r=e?n:n+t)<=r),Vl=class extends _e{constructor(e,r,i=0,s=12,o=3,a=zt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let c=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(P=>{let I=P.extractShapePointsToFlatArray([],s),_=[];for(let D=I.length-1;D>=1;D-=2){let L=I[D-1],j=I[D-0];_.push(L,j)}return _}),h=[],d=[];for(let P=0;PI.position)).getSize(new k).length()*.1:h[0].length===0?f=i:f=(0,FO.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=qs({windingRule:a,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{p=dm}let m;try{m=qs({windingRule:zt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=U1}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let P=0;Pv&&(v=D),LS&&(S=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=S-x,this._buffer=new hm(this._computeBufferEstimatedSize(p));let w=[],A=[];for(let P=p.elementCount-1;P>=0;P--){let I=P>=g,_=P*2,D=p.elements[_+0],L=p.elements[_+1],j=D+L,V={start:D,count:L,normals:[],continuous:[],concave:[]},H=D,W=j-1,q=D+1,Q=this._shape.roundedCurves.length;do{let Y=H-D,oe=p.vertices[W*2+0],ie=p.vertices[W*2+1],re=p.vertices[H*2+0],J=p.vertices[H*2+1],Ae=p.vertices[q*2+0],xe=p.vertices[q*2+1],de=re-oe,De=J-ie,Ce=Math.sqrt(de*de+De*De);de/=Ce,De/=Ce;let ze=re-Ae,Ue=J-xe,Ve=Math.sqrt(ze*ze+Ue*Ue);ze/=Ve,Ue/=Ve,V.normals[Y*2+0]=-Ue,V.normals[Y*2+1]=ze,V.concave[Y]=de*Ue-De*ze>0;let Oe=p.vertexIndices[H];if(Array.isArray(Oe))V.continuous[Y]=!1;else{let[Ye,F]=this._shape.getCurveIndexFromVertexId(Oe-1,!0);if(F>0&&F<1)V.continuous[Y]=!0;else{let N=F===1?Ye+1:Ye-1;N=(N+Q)%Q;let B=F===1?0:1,ae=this._shape.roundedCurves[Ye].getTangent(F),ge=this._shape.roundedCurves[N].getTangent(B);V.continuous[Y]=ae.dot(ge)>.95}}I&&(V.normals[Y*2+0]*=-1,V.normals[Y*2+1]*=-1),[W,H,q]=[H,q,q+1],q>=j&&(q-=L)}while(q!==D+1);let G=[];G.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(D*2,j*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((Y,oe)=>[oe,oe]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(D*2,j*2)});let Z=0;for(let Y=1;Y<=this._bevelSegments;Y++){let oe=Y/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,re=[],J=[],Ae=[],xe=[],de=0;for(let Ce=0;Ceae&&(ge-=Math.PI*2);let me=ge-ae;if(V.continuous[Ce]||I){let Le=ae+me/2,Ne=Math.cos(Le)*ie,Re=Math.sin(Le)*ie;re[2*de+0]=Ve+Ne*(I?-1:1),re[2*de+1]=Oe+Re*(I?-1:1),xe[de]=Ce,de++}else{let Le=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Ne=0;Ne<=Le;Ne++){let Re=ae+me*(Ne/Le),pe=Math.cos(Re)*ie,nt=Math.sin(Re)*ie;re[2*de+0]=Ve+pe,re[2*de+1]=Oe+nt,xe[de]=Ce,de++}}}else re[2*de+0]=Ve+Ye,re[2*de+1]=Oe+F,xe[de]=Ce,J[Ce]=de,de++,re[2*de+0]=Ve,re[2*de+1]=Oe,xe[de]=Ce,de++,re[2*de+0]=Ve+N,re[2*de+1]=Oe+B,xe[de]=Ce,Ae[Ce]=de,de++}let De=qs({windingRule:zt.POSITIVE,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[re],edgeCreateCallback:Ce=>{let Ue=Ce.Org.idx,Ve=xe[Ue],Oe=xe[(Ue+1)%xe.length];Ce.idx=[Ve,Oe],Ce.Sym.idx=[Oe,Ve]},vertexIdCallback:Ce=>{let ze=Ce.Lprev.idx;return[ze?ze[1]:0,Ce.idx?Ce.idx[0]:0]}});if(!De)throw console.log("Error"),new Error(`error generating bevel geometry for ${Y}'th loop`);if(!De.vertexCount){let Ce=(Y-1)/this._bevelSegments*Math.PI/2;Z=(1-Math.sin(Ce))*this._bevel;break}for(let Ce=0;Ce{let re=0,J=Y.boundary.vertexIndices.length;for(;reme){let Ne=ge/me,Re=0;for(let pe=1;pe(Re+1)*Ne&&(Re++,B=this._buildBevelVert(V,ie,(Ce+Re)%J,Re/(me-1),Ue),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B)}else{let Ne=me/ge,Re=0;for(let pe=1;pe(Re+1)*Ne&&(Re++,N=this._buildBevelVert(V,oe,(De+Re)%re,Re/(ge-1),Ue),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N)}De=(De+ge)%re,Ce=(Ce+me)%J,xe=(xe+1)%Ae}while(xe!==ze)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(G,V,w),I){let Y=[];for(let oe=w.length-1;oe>=$+2;oe-=3){let ie=w[oe-2],re=w[oe-1],J=w[oe-0];Y.push(J,re,ie)}w.splice($,w.length-$,...Y)}if(I){let Y=[];for(let oe=G[G.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=G[G.length-1].boundary.vertices[oe-1],re=G[G.length-1].boundary.vertices[oe-0];Y.push(ie,re)}A.push(Y)}if(!I){let Y=G[G.length-1],oe;try{oe=qs({windingRule:G.length>1?zt.POSITIVE:zt.ODD,elementType:jr.POLYGONS,vertexSize:2,strict:!0,contours:[Y.insetPoints,...A]})}catch{oe=z1}if(!oe)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel0,d=e.continuous[u]||f);let p=Math.cos(r.angle),m=Math.sin(r.angle),g=i*2,y=u*2,v=h*2,x=r.boundary.vertices[g+0],S=r.boundary.vertices[g+1],w=(1-m)*this._bevel,A=(x-this._minX)/this._width,T=(S-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),T=1);let b=e.normals[y+0],M=e.normals[y+1],C=e.normals[v+0],P=e.normals[v+1];if(f){let j=C-b,V=P-M;b=b+j*(1-s),M=M+V*(1-s);let H=Math.sqrt(b*b+M*M);b/=H,M/=H}let I=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=I*3,D=I*2,L={i,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1,pathBevelUCoord:o};return this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=b*p,this._buffer.normals[_+1]=M*p,this._buffer.normals[_+2]=m,this._buffer.uvs[D+0]=A,this._buffer.uvs[D+1]=T,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=b*p,this._buffer.normals[_+4]=M*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[D+2]=T,this._buffer.uvs[D+3]=A),d||(this.forPathBevel?(I+=1,_+=3,D+=2):(I+=2,_+=6,D+=4),L.topP=I+0,L.bottomP=I+1,this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=C*p,this._buffer.normals[_+1]=P*p,this._buffer.normals[_+2]=m,this._buffer.uvs[D+0]=A,this._buffer.uvs[D+1]=T,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=C*p,this._buffer.normals[_+4]=P*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[D+2]=T,this._buffer.uvs[D+3]=A)),this.vertexCache[a]=L,L}clone(){let e=new Vl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ga(this.userData),e}};var Ed=class extends _e{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=zt.ODD;this.elementType=jr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:zt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let p=0,m=s.length/2;pm&&(m=T),by&&(y=b)}let v=m-p,x=y-g;for(let S=0,w=d;S0&&o.update());let l=o??new Xt(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:s,roundness:a}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:s,windingRule:o}=n.parameters;n.shape.roundness=s;let a;return t<=0?a=new Ed(n.shape,i,{windingRule:o}):a=new Td(n.shape,t,e,i,r,o),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var kO=Math.PI*2,Cd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=we.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Xt?n.shape:new Xt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=t*.5,h=e*.5,d=nY(c,u,h,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return i===0?(f=new _e,f.setAttribute("position",new Te([],3))):f=Rn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function nY(n,t,e,r,i,s){if(r>=kO)return i>30||i%4===0?(oY(n,t,e,s),Math.round(i/4)):VO(n,r,i,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=_O({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?sY(n,o.x,o.y,c,i,t,e,s):VO(n,r,i,t,e,s)}function sY(n,t,e,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(Md(t,e));for(let c=0,u=r.length;c0?UO(n,s,o,a):n.addPoint(Md(0,0)),l}function VO(n,t,e,r,i,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,c=Math.sin(l)*r,u=Math.cos(l)*i;n.addPoint(Md(c,u))}return t0?UO(n,r,i,s):n.addPoint(Md(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&zO(n,r,i,s)),1}function oY(n,t,e,r=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;n.addPoint(O0(i-t,s,i-t,s-l,i-t,s+l)),n.addPoint(O0(i,s+e,i-a,s+e,i+a,s+e)),n.addPoint(O0(i+t,s,i+t,s+l,i+t,s-l)),n.addPoint(O0(i,s-e,i+a,s-e,i-a,s-e)),r>0&&zO(n,t,e,r)}function Md(n,t){return new Ws(we.generateUUID(),new k(n,t))}function O0(n,t,e,r,i,s){let o=Md(n,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(i,s),o}function UO(n,t,e,r){GO(n,t,e,r).forEach(s=>n.addPoint(s))}function zO(n,t,e,r){let i=GO(n,t,e,r),s=new Xt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function GO(n,t,e,r){let i=r*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new k(i/t,s/e),a=n.points.map(l=>{let c=l.clone();return c.uuid=we.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),u=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}var jO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:h}=n.parameters,d=new fm(!1,t,e,r,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},G1=new po([0,0,0],1),fm=class extends _e{constructor(t=!0,e=1,r=1,i=1,s=1,o=1,a=1,l=1,c=1,u=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new E,m=new E,g=p(),y=p(),v=p(),x,S,w,A,T,b,M,C,P=p(),I=p(),_=p(),D=p(),L=p(),j=p(),V=p(),H=p(),W=r-2*l+.001,q=W/o,Q=Math.ceil(a*o),G=Q+1,Z=W/Q,te=-W/2,$=u+1,Y=2*Math.PI/u,oe=Math.PI/2/d,ie=.01,re=Math.min((1-h/100)*l,l-ie),J=l-re,Ae=0,xe=2,de=d*xe+xe,De=$*de/xe,Ce=De+$*G,ze=Math.max(0,$*(G+de)),[Ue,Ve,Oe]=[3,3,2].map(Ge=>Array(ze*Ge).fill(0)),Ye=[],F=s-l;function N(Ge,Be){let et=Math.PI/2;b=Be*Z,C=2*Math.PI*(b%q)/q+et,b+=te,M=Math.sin(C)*F,T=Math.cos(C)*F,t?Ge.set(T,M,b):Ge.set(T,b,M)}N(m,-1e-10),N(g,0),P.copy(m),N(m,1);let B=m.distanceTo(g),ae=f?0:J+re,ge=B*Q+2*ae,me=re,Le=ge-ae;for(let Ge=0;Ge<=Q;Ge++){N(y,Ge),H.subVectors(y,P).normalize(),P.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),V.crossVectors(H,j).normalize();let Be=Ge===0,et=Ge===Q,st=Be?3*Math.PI/2:oe,Bt=Be?me:Le,dr=Be?$:Ce,Tr=Be?0:ze-$,K=H.clone().multiplyScalar(Be?-J:J).add(y),ye=H.clone().multiplyScalar(Be?-1:1).normalize();for(let Me=0;Me<$;Me++){let je=Me*Y;if(I.addVectors(m.copy(j).multiplyScalar(l*Math.cos(je)),g.copy(V).multiplyScalar(l*Math.sin(je))),_.copy(I).normalize(),Be||et){f||(Ae=Tr+Me,[0,1,2].forEach(He=>{Ue[Ae*3+He]=K.getComponent(He),Ve[Ae*3+He]=ye.getComponent(He)}),Oe[Ae*2]=+et,Oe[Ae*2+1]=Me/u),g.copy(_).multiplyScalar(re),v.addVectors(y,g);for(let He=0;He{Ue[Ae*3+Vr]=g.getComponent(Vr),Ve[Ae*3+Vr]=L.getComponent(Vr)});let Fr=+Be+Math.sin(_t);Oe[Ae*2]=(Bt+J*Fr)/ge,Oe[Ae*2+1]=Me/u}}g.addVectors(y,I),Ae=De+Ge*$+Me,[0,1,2].forEach(He=>{Ue[Ae*3+He]=g.getComponent(He),Ve[Ae*3+He]=_.getComponent(He)}),Oe[Ae*2]=(ae+Ge*B)/ge,Oe[Ae*2+1]=Me/u}}let Ne=G+2*d+xe,Re=1,[pe,nt]=[+f,Ne-1];for(let Ge=pe;Ge<=nt-1;Ge++){let Be=f&&Ge===nt-1;for(let et=0;et<$-1;et++)x=Ge*$+et,S=x+1,w=(Be?et:x)+$,A=(Be?et+1:S)+$,Ge===0?Ye.push(S,A,w):Ge===Ne-2?Ye.push(x,S,w):Ye.push(x,S,w,S,A,w)}this.setIndex(Ye),this.setAttribute("position",new Te(Ue,3)),this.setAttribute("normal",new Te(Ve,3)),this.setAttribute("uv",new Te(Oe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,i=Array.from(this.getIndex().array),s,o,a,l,c=6*(e-1)*t.radialSegments,u=e,h=u===e;for(let d=0;d{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=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}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new ua;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Uu(i.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var Lo=new ue,j1=new Tt,R0=new E,kl=class extends pr{constructor(){super(),this.uuid=we.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new fr().getNormalMatrix(t);for(let r=0,i=this.vertices.length;r0)for(let d=0;d0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u0,S=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,T=0;if(T=u(T,0,0),T=u(T,1,g),T=u(T,2,y),T=u(T,3,v),T=u(T,4,x),T=u(T,5,S),T=u(T,6,w),T=u(T,7,A),r.push(T),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),S){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(w&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function u(p,m,g){return g?p|1<0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new kl().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",L0.call(new Xe(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",qO.call(new Xe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",YO.call(new Xe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",YO.call(new Xe(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a0){let i=new Te(t.skinIndices.length*4,4);e.setAttribute("skinIndex",XO.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Te(t.skinWeights.length*4,4);e.setAttribute("skinWeight",XO.call(i,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new _e,r=t.geometry;if(t.isPoints||t.isLine){let i=new Te(r.vertices.length*3,3),s=new Te(r.colors.length*3,3);if(e.setAttribute("position",L0.call(i,r.vertices)),e.setAttribute("color",qO.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Te(r.lineDistances.length,1);e.setAttribute("lineDistance",aY.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};kl.prototype.isGeometry=!0;var H1=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,i,s,o=t.faces;for(i=0;i0,o=i[1]&&i[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let y=0;y0){d=[];for(let y=0;y0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new E,r,i,s,o,a,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],h=u!==void 0&&u.length>0,d=[],f=new Map;uY(l,c,d,f);let p=[],m,g,y,v,x,S,w;for(let ie of Array.from(f.keys())){for(g=f.get(ie),y=new E,x=3/8,S=1/8,w=g.faces.length,w!=2&&(x=.5,S=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o3&&(A=3/(8*r)),T=1-r*Number(A),b=A,r<=2&&(r==2?(T=3/4,b=1/8):r==1||r==0),I=P.clone().multiplyScalar(T),e.set(0,0,0),o=0;o0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new F0(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete n.geometry,Object.assign(s,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new Ju(e).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Pi);let o=100/Pi.x;Object.assign(s.parameters,{width:100,height:Pi.y*o,depth:Pi.z*o}),t(this.build(s))})}};var V0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Xt?n.shape:new Xt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=t*.5,u=e*.5,h=0,d=0,f=2*Math.PI/r;for(let m=0;m0){{let Ve=Q.clone().add(G).multiplyScalar(.5),Oe=S.clone().sub(Ve).normalize(),F=x.clone().sub(Ve).normalize().add(Oe).normalize().multiplyScalar(-1),N=$.clone().sub(te);H(Ve,N,F,T.angle())}let ze,Ue;{let Ve=new E;mm(C,xe,Ve);let Oe=$.clone().add(Z).multiplyScalar(.5);Oe=hY(Oe,G,S);let Ye=$.clone().sub(Z);[ze,Ue]=H(Oe,Ye,Ve,_,Z.y)}{let Ve=ze,Oe=Ve.clone().setY(0).normalize(),Ye=new E(0,-1,0),F=Oe.clone().cross(Ye);W(Ve,Oe,Ye,F)}V.concat(Ue);{let Ve=T.angle(),Oe=Math.PI-Ve,Ye=S.clone();Ye.y-=o/Math.sin(Ve-Math.PI/2);let F=new E,N=[];for(let ae=0;aee&&A>r?Math.min(S*e/w,S*r/A):w>e?S*e/w:A>r?S*r/A:S}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let p=u.x,m=h.x,g=h.y,y=u.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let S=0,w=t.points.length;S0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Rn.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};var ZO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=we.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,u;return c===0?(u=new _e,u.setAttribute("position",new Te([],3))):u=new Bs(.5*t,i,s,o,a,l,c*we.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var JO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,s=new Li(t,e,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var $O=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,angle:i,cornerRadius:s,cornerSegments:o}=n.parameters,a=new K1(t,e,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},K1=class extends _e{constructor(t=1,e=1,r=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],u=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-u,i),i*=Math.PI/180;let h=[],d=Math.PI/2,f=(ie=0,re=0,J=0)=>new E(ie,re,J),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,S=+y,[w,A,T]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(ie,re=!1)=>Math.sin(ie-Math.PI/(1+ +re)),M=(ie,re=!1)=>Math.cos(ie-Math.PI/(1+ +re));T.y=Math.sin(i)*e-g;let C=Math.cos(i)*e-v,P=w.z-u;i<=d?(T.z=Math.min(C,P),T.z==P&&(T.y-=(C-P)/Math.tan(d-i))):A.z=Math.min(A.z-C-v,w.z-u),p.subVectors(w,A),m.subVectors(T,A);let I=Math.min(p.length(),m.length())*s/100,_=I*Math.tan(i/2),D=I/Math.cos(i/2),L=p.clone().normalize().add(m.normalize()).setLength(D).add(A);p.set(0,b(i,!0),M(i,!0)),h.push([T,p.clone()]);let j=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let re=d+i+ie*j;p.set(0,Math.sin(re)*_,Math.cos(re)*_),p.add(L),m.set(0,b(re),M(re)),h.push([p.clone(),m.clone()])}h.push([w,f(0,1,0)]);let V=Math.sin(j/2)*_*2,H=h.length-1,W=h[0][0].distanceTo(h[1][0]),q=h[H-1][0].distanceTo(h[H][0]),Q=W+V*o+q;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(W+ie*V)/Q);h[H].push(0);let[G,Z,te]=h[0],$,Y,oe;for(let ie=1;ie>16&255,g:n>>8&255,b:n&255}}function yY(n,t,e){return(n<<16)+(t<<8)+e}function vY(n,t,e){return n=Math.round(n),t=Math.round(t),e=Math.round(e),"#"+[n,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function xY(n){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(r,i,s,o)=>String(i+i+s+s+o+o));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var sR={parseRgba:fY,hsvToRgb:pY,rgbToHsv:mY,hexToRgb:gY,rgbToHex:yY,rgbToHexString:vY,hexStringToRgb:xY};var Q1=class{add(t,e,r){if(typeof arguments[0]!="string")for(let i in arguments[0])this.add(i,arguments[0][i],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],e&&this[i][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},Z1=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},fe=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+fe.version}static addUnaryOp(t){return fe.max_unop_len=Math.max(t.length,fe.max_unop_len),fe.unary_ops[t]=1,fe}static addBinaryOp(t,e,r){return fe.max_binop_len=Math.max(t.length,fe.max_binop_len),fe.binary_ops[t]=e,r?fe.right_associative.add(t):fe.right_associative.delete(t),fe}static addIdentifierChar(t){return fe.additional_identifier_chars.add(t),fe}static addLiteral(t,e){return fe.literals[t]=e,fe}static removeUnaryOp(t){return delete fe.unary_ops[t],t.length===fe.max_unop_len&&(fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops)),fe}static removeAllUnaryOps(){return fe.unary_ops={},fe.max_unop_len=0,fe}static removeIdentifierChar(t){return fe.additional_identifier_chars.delete(t),fe}static removeBinaryOp(t){return delete fe.binary_ops[t],t.length===fe.max_binop_len&&(fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops)),fe.right_associative.delete(t),fe}static removeAllBinaryOps(){return fe.binary_ops={},fe.max_binop_len=0,fe}static removeLiteral(t){return delete fe.literals[t],fe}static removeAllLiterals(){return fe.literals={},fe}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new fe(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return fe.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!fe.binary_ops[String.fromCharCode(t)]||fe.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return fe.isIdentifierStart(t)||fe.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(fe.hooks[t]){let r={context:this,node:e};return fe.hooks.run(t,r),r.node}return e}searchHook(t){if(fe.hooks[t]){let e={context:this};return fe.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===fe.SPACE_CODE||t===fe.TAB_CODE||t===fe.LF_CODE||t===fe.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:fe.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,i;for(;this.index0;){if(fe.binary_ops.hasOwnProperty(t)&&(!fe.isIdentifierStart(this.code)||this.index+t.lengths.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;i.length>2&&u(i[i.length-2]);)a=i.pop(),e=i.pop().value,o=i.pop(),t={type:fe.BINARY_EXP,operator:e,left:o,right:a},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),i.push(s,t)}for(l=i.length-1,t=i[l];l>1;)t={type:fe.BINARY_EXP,operator:i[l-1].value,left:i[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,fe.isDecimalDigit(t)||t===fe.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===fe.SQUOTE_CODE||t===fe.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===fe.OBRACK_CODE)i=this.gobbleArray();else{for(e=this.expr.substr(this.index,fe.max_unop_len),r=e.length;r>0;){if(fe.unary_ops.hasOwnProperty(e)&&(!fe.isIdentifierStart(this.code)||this.index+e.length=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===fe.COMMA_CODE){if(this.index++,i++,i!==e.length){if(t===fe.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===fe.CBRACK_CODE)for(let o=e.length;o":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops);fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops);var jc=n=>new fe(n).parse(),SY=Object.getOwnPropertyNames(fe);SY.forEach(n=>{jc[n]===void 0&&n!=="prototype"&&(jc[n]=fe[n])});jc.Jsep=fe;var wY="ConditionalExpression",AY={name:"ternary",init(n){n.hooks.add("after-expression",function(e){if(e.node&&this.code===n.QUMARK_CODE){this.index++;let r=e.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===n.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:wY,test:r,consequent:i,alternate:s},r.operator&&n.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&n.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};jc.plugins.register(AY);function Ia(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(i){i(e)}),(r=n.get("*"))&&r.slice().map(function(i){i(t,e)})}}}var Dd=class{constructor(t,e,r){this.id=t;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(t=>t());this.emitter=Ia();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await PY(this.userAPI,t),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let r=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=r,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0};e?.integration?.type==="OpenAI"?this.result={content:""}:e.method==="GET"&&e.url!==""&&(this.prefetchPromise=this.prefetch(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=vo(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?vo(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(t){await this.callUserAPI(t)}async callUserAPI(t){await this._debouncedCallUserAPI(t)}update(t,e,r=!0){this.userAPI=t,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&r&&this._debouncedPrefetch(e)}retrieveValue(t){if(this.result)try{return Sr.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?Sr.zoom(this.result,t):this.result;if(CY(e))return Object.entries(e);if(MY(e))return e.map((r,i)=>[i.toString(),r]);throw TY(e)?new Error("This path points to a value, use retrieveValue() instead. "+t?.join(".")):new Error("Path error"+t?.join("."))}}dispose(){}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}get autostart(){return this.userAPI.autoStart}};function EY(n){let t=new Headers;return n.headers.forEach(e=>{e.data.key!==""&&t.append(e.data.key,e.data.value)}),t}function TY(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null}function MY(n){return Array.isArray(n)}function CY(n){return typeof n=="object"&&n!==null}async function PY(n,t,e=new AbortController){let r,i=n.url,s=n.proxy?.enabled??!1;if(s)i=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${n.proxy.fileId}/external-api/request?uuidexternalapi=${n.proxy.proxyId}`;else if(n.integration?.type==="OpenAI"){let a=U0(n.integration.prompt===""?[]:JSON.parse(n.integration.prompt),t),l=n.integration.behavior===""?[]:U0(JSON.parse(n.integration.behavior),t);r=`{
			"model": "${n.integration.model}",
			"messages": [${n.integration.useBehavior?`
			{
				"role": "system",
				"content": "${l}"
			},`:""}
			{
				"role": "user",
				"content": "${a}"
			}
			]
		}`}else n.method==="POST"&&n.body&&(r=U0(JSON.parse(n.body),t));let o=await fetch(i,{method:s?"GET":n.method,headers:s?void 0:EY(n),signal:e.signal,body:r});if(!o.ok)throw new Error("status:"+o.status+"_:_"+o.statusText);if(n.integration?.type==="OpenAI"){let a=await o.json();return s&&(a=a.response),{content:a.choices[0].message.content}}else{let a=await o.json();return s&&(a=a.response),a}}var oR=(n,t)=>{if(typeof n=="string"){let e=t.getVariable(n);if(e)return oR(e,t)}return Br.isBoolean(n)?Br.getDisplayedValue(n).toLowerCase():Br.getDisplayedValue(n)},U0=(n,t)=>n.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
`:"")+U0(e.children,t);if(e.type==="variable"){let i=t.getVariable(e.variableId);if(i!==void 0)return oR(i,t)}}return""}).join("");var _Y=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],IY=["0","1","2","3","4","5","6","7","8","9","."],DY=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function OY(n){return typeof n!="string"?!1:!isNaN(n)&&!isNaN(parseFloat(n))}jc.addBinaryOp("^",11,!0);function z0(n,t,e="number"){let r="";for(let o=0;o{let d=h.events?.find(f=>f.id===a.objId);d&&(c=d)}),c!==void 0&&c.data.type==="AIAssistantListener"){let u=l?.computeAnalysisForListenerEvent(c.data);if(u!==void 0){r+=u;continue}}}r+=l?.voice??0;continue}if("id"in a){let l=n[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",n);return}let c=t.getVariable(a.id),u=Br.getDisplayedValue(c);e==="number"&&Br.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?u=parseFloat(u).toString():e==="boolean"&&Br.isBoolean(c)?u=c?"true":"false":e==="boolean"&&Br.isTextValue(c)&&!Array.isArray(c.textValue)&&(u='"'+u+'"'),r+=u;continue}else if(e==="string"){a.name!=='"'&&(a.name!=="+"||a.escaped)&&(r+=a.name),a.name==="+"&&!a.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+a.name);continue}if(a.name==="and"){r+="&&";continue}if(a.name==="or"){r+="||";continue}if(a.name==="True"){r+="true";continue}if(a.name==="False"){r+="false";continue}if(e==="boolean"&&!OY(a.name)&&!IY.includes(a.name)&&!_Y.includes(a.name)&&!DY.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(n.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let i;try{i=jc(r)}catch(o){console.error(r,o);return}let s;try{s=Wt(i)}catch(o){console.error(r,i,o)}return s}function Wt(n){switch(n.type){case"BinaryExpression":switch(n.operator){case"==":return Number(Wt(n.left)===Wt(n.right));case"!=":return Number(Wt(n.left)!==Wt(n.right));case">":return Number(Wt(n.left)>Wt(n.right));case">=":return Number(Wt(n.left)>=Wt(n.right));case"<":return Number(Wt(n.left)=1)try{t=Wt(n.arguments[0])}catch(r){console.warn(r)}if(n.arguments.length>=2)try{e=Wt(n.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[n.callee.name].apply(null,n.arguments.map(Wt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+n.type)}}var RY=new ue,LY=new ue;function BY(n,t,e){let r=[new E,new E,new E],i=[new E,new E,new E];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((s,o)=>{let a=i[o],l=we.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ue().makeBasis(r[0],r[1],r[2])}var aR=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Cd.create({parameters:jA}).userData.shape;return{path:n.path??Wh.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:s,extrusion:{...Kv,...e.extrusion}}),shapeData:o}}static build(n){if(n.path.points.length>=2){let e=new J1(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new _e,{userData:{...n,type:"PathGeometry"}})}},J1=class extends _e{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!nR(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:i,offset:s}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),s=Math.max(0,Math.min(s,1));let o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((i+s)*o):Math.ceil(Math.min(1,i+s)*o),c=Math.min(Math.max(2,l-a+1),o+2),u=[],h=[];for(let W=0;W{u[W]=u[W].clone().lerp(u[q],Q),h[W]=BY(h[W],h[q],Q)},f=0,p=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&g&&(m=g,d(u.length-1,u.length-2,1-m)),i===0){let W=u.length-1;u[W].copy(u[0]),h[W].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:A,vertices:T}=this._computeShapePoints(S),b=0,M;x==="round"&&(M=new Vl(this.inputs.shapeData,2*y,y,S,v,void 0,!0),b=M.getAttribute("position").count);let C=0,P=0;A.sort((W,q)=>W.start-q.start),A.forEach(W=>{W.verticesStart=C,W.verticesCount=W.continuous.reduce((q,Q,G)=>q+(G===0||!Q?2:1),0),P+=W.verticesCount,C=P});let I=P*c,_,D=0;if(this._isOpenEnded()&&x==="flat"){try{_=qs({windingRule:zt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{_=z1}D=_.vertexCount}let L=I+2*D+b*2,j=I+2*D,V={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},H=[];if(A.forEach(W=>{this._extrudeRegion(W,T,h,u,V,H,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,I,H,V,h[0],u[0],!1),this._closeEnd(_,I+D,H,V,h[h.length-1],u[u.length-1],!0)),M){V.positions.set(M.getAttribute("position").array,j*3),V.normals.set(M.getAttribute("normal").array,j*3),V.uvs.set(M.getAttribute("uv").array,j*2);for(let G=j;GG+j)),j+=b,V.positions.set(M.getAttribute("position").array,j*3),V.normals.set(M.getAttribute("normal").array,j*3),V.uvs.set(M.getAttribute("uv").array,j*2);let q=H.length;H.push(...M.getIndex().array.map(G=>G+j)),this.setAttribute("position",new Xe(V.positions,3)),this.setAttribute("normal",new Xe(V.normals,3)),this.setAttribute("uv",new Xe(V.uvs,2)),this.setIndex(H);let Q=RY;Q.copy(h[h.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(Q,j,L),Q.copy(h[0]).setPosition(u[0]).multiply(LY.makeScale(1,1,-1)),this.applyMatrix4OnRange(Q,j-b,j),this.reverseIndicesOnRange(W,q)}else this.setAttribute("position",new Xe(V.positions,3)),this.setAttribute("normal",new Xe(V.normals,3)),this.setAttribute("uv",new Xe(V.uvs,2)),this.setIndex(H)}_extractPathPoints(){let r=M0(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let i=[r[0]];return r.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let r=[],i=e.length,s=this.inputs.path.isClosed,o=new E,a=new E,l=new E,c=new E,u=new E(0,1,0);for(let g=0;g0&&(p*=-1);for(let g=1;g{let p=f===0?0:f===s-1?1:(f-r)/(s-(i===0?0:1)-(r+(1-i)));u.makeRotationZ(we.lerp(o,o+a,p)*we.DEG2RAD);let m=we.lerp(l,c,p);h.makeScale(m,m,m),d.multiply(u).multiply(h)}),e}_computeShapePoints(e=12,r=zt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],S=g[v-0];y.push(x,S)}return y}),a;try{a=qs({windingRule:r,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=dm}let l;try{l=qs({windingRule:zt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=U1}if(!a)throw new Error("error generating geometry");let c=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;mh&&(h=v),xf&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=c,y=m*2,v=a.elements[y+0],x=a.elements[y+1],S=v+x,w={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(w);let A=v,T=S-1,b=v+1,M=i.roundedCurves.length;do{let C=A-v,P=a.vertices[T*2+0],I=a.vertices[T*2+1],_=a.vertices[A*2+0],D=a.vertices[A*2+1],L=a.vertices[b*2+0],j=a.vertices[b*2+1],V=_-P,H=D-I,W=Math.sqrt(V*V+H*H);V/=W,H/=W;let q=_-L,Q=D-j,G=Math.sqrt(q*q+Q*Q);q/=G,Q/=G,w.normals[C*2+0]=-Q,w.normals[C*2+1]=q;let Z=a.vertexIndices[A];if(Array.isArray(Z))w.continuous[C]=!1;else{let[te,$]=i.getCurveIndexFromVertexId(Z-1,!0);if($>0&&$<1)w.continuous[C]=!0;else{let Y=$===1?te+1:te-1;Y=(Y+M)%M;let oe=$===1?0:1,ie=i.roundedCurves[te].getTangent($),re=i.roundedCurves[Y].getTangent(oe);w.continuous[C]=ie.dot(re)>.95}}g&&(w.normals[C*2+0]*=-1,w.normals[C*2+1]*=-1),[T,A,b]=[A,b,b+1],b>=S&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,r,i,s,o){let a=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,r,i,s,o,a,l){let c=new E,u=new E,h=new E,d=new E,f=new k;i.forEach((m,g)=>{let y=s[g],v=e.verticesStart*i.length+e.verticesCount*g;for(let x=0;x{this.update(e),r?.requestRender()})}async updateFont(e,r){let i=r.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:c,textTransform:u}=e,h=Br.getDisplayedValue(c),d=u===2?h.toUpperCase():u===3?h.toLowerCase():h,f=UY(e,r,d),{shapes:p,charWidths:m,charCoords:g}=r.generateShapes(f,e),y=(typeof i=="number"?i:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(A=>new Xt().fromShape(A,!0));this.vectorShapes=x;let S=x.map(A=>Rn.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?zt.NONZERO:zt.ODD,subdivisions:this.isLowResolution&&o>0?kY:VY}})),w=S.length?Gs(S):lR();w.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([A,T])=>{this.setAttribute(A,T)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=qi(new _e,Hc.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,i])=>{this.setAttribute(r,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}})}get text(){return this.userData.parameters.text??""}};function UY(n,t,e){let r=[""],i="";for(let s of e)i+=s,s===" "||s===`
`?(r[r.length-1]+=i,i="",s===`
`&&r.push("")):t.getTextWidth(r[r.length-1]+i,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+i,n)>n.width&&(i.length===1?(r[r.length-1]+=i,i=""):(r[r.length-1]+=i.slice(0,-1),i=i[i.length-1],r.push(""))));return r[r.length-1]+=i,r}var uR,j0=new Promise(n=>{uR=n}),cR=!1;var G0;function hR(){if(cR)return;if(G0)return G0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.35/build",i=import("./process.js"),[s,o]=await Promise.all([i,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});uR(l),cR=!0}return G0=n(),G0}var zY=["font"];function Da(n,t,e,r){let i,s,o;n.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(n)),o=[[],["extrusion"]]):(s={...n},o=[[]]);for(let c of o){let u=s;for(let h of c)u=u[h];for(i in u){let h=u[i];LA(h)&&!zY.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),LA(u[i])&&(u[i]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let c=Xt.createFromState(s.shape,s.width,s.height);a.shape=c}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),a.geometry=new Ju().parse(s),a.geometry.groups.length===0){let c=a.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(s.type==="SubdivGeometry"){let c=new ni(s,e);return c.data=n,c}else{if(s.type==="TextGeometry")return new Hc(s,t);if(s.type==="InputGeometry")return new Hc(s,t);if(s.type==="UIGeometry")return Id.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=$1(a)}catch(c){console.error(c)}if(!l){let c=Xt.createFromState(Hh.defaultData(),100,100);a.shape=c,l=$1(a)}return l}var GY=new ue;function gm(n,t,e,r){let i=n.position.array,s=n.normal.array,o=GY.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=i.length;u{lt=n});var dR=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),fR=new Uint32Array([0,1,2,3]),pR=new Uint8Array([4]),ni=class extends _e{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked,s=Mo.div(r,i);this.subdividedGeometry&&gm(this.subdividedGeometry.attributes,...s),this.originalGeometry&&gm(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Od.fromArray(s));let a=Od.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=ni.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mi(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ni.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Rr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;H0.setFromBufferAttribute(r),H0.getCenter(i),e.boundingSphere.radius=i.distanceTo(H0.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),H0.getSize(Od);let s={width:Od.x,height:Od.y,depth:Od.z};return this.userData.parameters=s,s}static build(e,r,i,s){let o,a,l,c=e?.phongAngle??35;i===!1&&(c=-1),r&&(lt.free_bvh(r),lt.free_subdivision_surface(r));try{o=ni.allocate(e,s)}catch(u){console.error(u,e),o=ni.allocate({positionWASM:dR,indexWASM:fR,verticesPerFaceWASM:pR},s)}if(lt.set_destination_refinement_level(o,0),a=ni.buildLevel(o,!0,c),e.subdivisions>0)try{lt.set_destination_refinement_level(o,e.subdivisions),l=ni.buildLevel(o,!1,c)}catch{try{lt.set_destination_refinement_level(o,e.subdivisions-1),l=ni.buildLevel(o,!1,c)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,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 s=e.shape!==void 0||e.path!==void 0?r.geometry:Da(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=Wc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:c}=iE(a,u,s,h),{positions:a,indices:l,verticesPerFace:c}}static allocate(e,r){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=dR,s=fR,o=pR);let c=i.length,u=s.length,h=o.length,d=i.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=lt._malloc(p),v=new Float32Array(lt.HEAPF32.buffer,y,d),x=new Uint32Array(lt.HEAPU32.buffer,y+m,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let S;e?.scaleBaked?.some(A=>A!==1)&&(S=new ue().makeScale(...e.scaleBaked)),r&&(S?S.premultiply(r):S=r);let w=S?lt.alloc_subdivision_surface2(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,S.elements):lt.alloc_subdivision_surface(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return lt._free(y),w}static buildLevel(e,r,i,s,o){let a=o?lt.get_mesh_data2(e,r?lt.Level.CONTROL:lt.Level.REFINED,i,o.elements):lt.get_mesh_data(e,r?lt.Level.CONTROL:lt.Level.REFINED,i),l=8,c=lt.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=lt.HEAPU32[c[h]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let p=lt.HEAPU32[c[h]>>2],m=lt.HEAPF32.subarray(p>>2,(p>>2)+u[h]);h++;let g=lt.HEAPU32[c[h]>>2],y=lt.HEAPU32.subarray(g>>2,(g>>2)+u[h]);h++;let v=lt.HEAPU32[c[h]>>2],x=lt.HEAPU32.subarray(v>>2,(v>>2)+u[h]);if(h++,s===void 0){let S=new _e;if(S.setIndex(new po(x,1)),S.setAttribute("position",new Te(f,3)),S.setAttribute("normal",new Te(m,3)),r){S.setAttribute("faceMap",new po(y,1));let w=new Float32Array(m.length/3*4).fill(0);S.setAttribute("color",new Xe(w,4))}return lt.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,lt.free_mesh_data(a)}static freeSubdivPointer(e){lt.free_bvh(e),lt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let s=lt.get_wireframe_data_for_base_level(e),o=4,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=lt.HEAPU32[a[c]>>2],h=lt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=lt.HEAPU32[a[c]>>2],f=lt.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let p=new _e;p.setAttribute("position",new Te(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=lt.HEAPU32[l[u]>>2],d=new Float32Array(lt.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=lt.HEAPU32[l[u]>>2],p=new Uint32Array(lt.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=lt.HEAPU32[l[u]>>2],g=new Uint8Array(lt.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return lt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var mR=["getX","getY","getZ"];function Wc(n,t){let e={},r=t?t.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c=360){let d=l.length/2/c;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let u=0;for(let d=0;d=0;d-=2)n.push(l[d],l[d+1],0),i.push(h++);return s.push(h),{indices:i,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&aWY,calcBooleanTopological:()=>HY,freeMeshSet:()=>KY,getMeshSet:()=>qY,hasOpenEdges:()=>YY,transformMeshSet:()=>XY});var gR,yR=new Promise(n=>{gR=n});var q0;function vR(){if(q0)return q0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.9.35/build",i=import("./boolean.js"),[s,o]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});gR(l)}return q0=n(),q0}var Mt,Rd;yR.then(n=>Mt=n);function jY(n,t,e){let r,i;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?i=n.getClosedTorusIndicesForBooleanOrSubdiv():i=n.getIndex();let{positions:s,triIndices:o}=Wc(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=iE(s,o,n);a=c.length,r=[];for(let u=0,h=0;u>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=Mt.HEAPU32[s[a]>>2],c=new Float32Array(Mt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=Mt.HEAPU32[s[a]>>2],h=new Uint32Array(Mt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=Mt.HEAPU32[s[a]>>2],f=new Uint8Array(Mt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return Mt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function WY(n,t,e,r){Rd===void 0&&(Rd=Mt.init_csg());let i=xR(n),s=Mt.csg_calc(Rd,i,n.length,r,bR(t));Mt._free(i);let o=5,a=Mt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=Mt.HEAPU32[a[c]>>2],h=Mt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Mt.HEAPU32[a[c]>>2],f=Mt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=l[c];e.setAttribute("position",new Te(h,3)),e.setAttribute("normal",new Te(f,3));let m=Mt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rr),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Mt.free_mesh_data(s),p}function qY(n,t,e){if(Mt===void 0)return-1;let r,i,s;if(t&&n.userData.positions!==void 0){let y=n.userData;s=y.verticesPerFace.length,r=y.positions,i=Array(y.verticesPerFace.reduce((v,x)=>v+x,0)+s);for(let v=0,x=0,S=0;vQY[n.type].create(n);function Ld(n){return n!==null&&"booleanOp"in n}var Bd=class extends xd(Ut){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!Ld(this.parent)&&this.visible,Ld(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ms.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ld(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Bd&&(e.freeBooleanPointer(),Ld(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&Ld(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ld(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Y0=new Ht;function ym(n,t=0,e=n.count,r,i){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=t;hl&&(l=d),f>c&&(c=f),p>u&&(u=p)}Y0.min.set(s,o,a),Y0.max.set(l,c,u),Y0.getCenter(r),Y0.getSize(i).multiplyScalar(.5)}var ZY=new _e,JY=new on,mr=class extends Bd{constructor(t,e){super(ZY,JY),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ym(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Oa=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Oa.uuidContext===null)throw new Error("plz startContext");Oa.uuidContext===Oa.globalContext?this.uuid="_gid"+Oa.uuidContext.nodeContextUuid++:this.uuid="_uid"+Oa.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Oa.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e??this.getType(t,e);let i=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,i,s,o){return""}generate(t,e,r,i,s){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},or=Oa;or.globalContext={nodeContextUuid:0},or.uuidContext=Oa.globalContext;var vm=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var nE=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},_i=new nE;var tt=class extends or{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,i,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=we.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,i)):super.build(e,r,i);if(o)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,s);let u=this.generate(e,l,i);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,i)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var ar=class extends tt{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var Hr=class extends ar{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof k?e:new k(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var Xi=class extends ar{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof E?e:new E(e,r,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var vr=class extends We{constructor(e,r,i,s){super(e,r,i);this.isColorA=!0;this.a=s}setRGBA(e,r,i,s){super.setRGB(e,r,i),this.a=s}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,r="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var Ln=class extends ar{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof vr?e:new vr(e.r,e.g,e.b,e.a)}generateReadonly(e,r,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var $Y=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,SR=/[a-z_0-9]+/gi,Ee=class extends tt{constructor(e,r,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,i,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,i,s,o){let a,l=0,c=this.src;if(this.includes)for(let h=0;h1?(l=u[1],a=u[2],c=u[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,i,s,o){return e.format(this.name,this.getType(e),r)}},qt=sE;qt.PI="PI",qt.PI2="PI2",qt.RECIPROCAL_PI="RECIPROCAL_PI",qt.RECIPROCAL_PI2="RECIPROCAL_PI2",qt.LOG2="LOG2",qt.EPSILON="EPSILON";var tX=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
)*?)}`,"gim"),rX=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Nd=class extends tt{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,i,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=tX.exec(e);if(r){let i=r[2],s;for(;s=rX.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Fd=class extends tt{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(s,this.getType(e),r)}};_i.addKeyword("uv",function(){return new Fd});_i.addKeyword("uv2",function(){return new Fd(1)});var qc=class extends tt{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??qc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case mn:return["Linear"];case at:return["sRGB"];default:return[]}}generate(e,r){let i=this.input.build(e,"v4"),s=this.getType(e),o=qc.Nodes[this.method],a=e.include(o);if(a===qc.LINEAR_TO_LINEAR)return e.format(i,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+i+", "+l+" )",s,r)}else return e.format(a+"( "+i+" )",s,r)}fromEncoding(e){let r=qc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=qc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},xn=qc;xn.Nodes={LinearToLinear:new Ee(["vec4 LinearToLinear( in vec4 value ) {","	return value;","}"].join(`
`)),sRGBToLinear:new Ee(["vec4 sRGBToLinear( in vec4 value ) {","	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
`)),LinearTosRGB:new Ee(["vec4 LinearTosRGB( in vec4 value ) {","	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
`))},xn.LINEAR_TO_LINEAR="LinearToLinear",xn.SRGB_TO_LINEAR="sRGBToLinear",xn.LINEAR_TO_SRGB="LinearTosRGB";var Kt=class extends Ee{constructor(e="",r,i,s,o){super(e,o,s,i,r);this.nodeType="Expression"}};var bn=class extends ar{constructor(e=new er,r,i,s){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new Fd,this.bias=i,this.project=s!==void 0?s:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let i=this.getTexture(e,r),s=this.uv.build(e,this.project?"v4":"v2"),o=this.bias?this.bias.build(e,"f"):void 0;o===void 0&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=o?"tex2DBias":"tex2D",o?l=a+"( "+i+", "+s+", "+o+" )":l=a+"( "+i+", "+s+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new xn(new Kt("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,r)}};var Fe=class extends ar{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,i,s,o,a){return e.format(this.value+(this.value%1?"":".0"),s,r)}};var xm=class extends tt{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,i,s,o){s=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",c=[];if(a.inputs){for(let u=0;ue.getTypeLength(r)?i:r}generate(e,r){let i=this.getType(e);this.type=i;let s=this.a.build(e,i),o=this.b.build(e,i);return e.format("( "+s+" "+this.op+" "+o+" )",i,r)}},ki=oE;ki.ADD="+",ki.SUB="-",ki.MUL="*",ki.DIV="/";var lr=class extends tt{constructor(e,r=lr.ABS,i,s){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:s=r,typeof i!="string"?this.c=i:s=i,this.method=s,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case lr.MIX:case lr.CLAMP:case lr.REFRACT:case lr.SMOOTHSTEP:case lr.FACEFORWARD:return 3;case lr.MIN:case lr.MAX:case lr.MOD:case lr.STEP:case lr.REFLECT:case lr.DISTANCE:case lr.DOT:case lr.CROSS:case lr.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0;return r>i&&r>s?this.a.getType(e):i>s?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case lr.LENGTH:case lr.DISTANCE:case lr.DOT:return"f";case lr.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let i,s,o,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case lr.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,r);case lr.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,r);case lr.CROSS:i=this.a.build(e,"v3"),s=this.b.build(e,"v3");break;case lr.STEP:i=this.a.build(e,a===1?"f":u),s=this.b.build(e,u);break;case lr.MIN:case lr.MAX:case lr.MOD:i=this.a.build(e,u),s=this.b.build(e,l===1?"f":u);break;case lr.REFRACT:i=this.a.build(e,u),s=this.b.build(e,u),o=this.c.build(e,"f");break;case lr.MIX:i=this.a.build(e,u),s=this.b.build(e,u),o=this.c.build(e,c===1?"f":u);break;default:i=this.a.build(e,u),this.b&&(s=this.b.build(e,u)),this.c&&(o=this.c.build(e,u));break}let d=[];d.push(i),s&&d.push(s),o&&d.push(o);let f=this.getNumInputs(e);if(d.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",h,r)}},ft=lr;ft.RAD="radians",ft.DEG="degrees",ft.EXP="exp",ft.EXP2="exp2",ft.LOG="log",ft.LOG2="log2",ft.SQRT="sqrt",ft.INV_SQRT="inversesqrt",ft.FLOOR="floor",ft.CEIL="ceil",ft.NORMALIZE="normalize",ft.FRACT="fract",ft.SATURATE="saturate",ft.SIN="sin",ft.COS="cos",ft.TAN="tan",ft.ASIN="asin",ft.ACOS="acos",ft.ARCTAN="atan",ft.ABS="abs",ft.SIGN="sign",ft.LENGTH="length",ft.NEGATE="negate",ft.INVERT="invert",ft.MIN="min",ft.MAX="max",ft.MOD="mod",ft.STEP="step",ft.REFLECT="reflect",ft.DISTANCE="distance",ft.DOT="dot",ft.CROSS="cross",ft.POW="pow",ft.MIX="mix",ft.CLAMP="clamp",ft.REFRACT="refract",ft.SMOOTHSTEP="smoothstep",ft.FACEFORWARD="faceforward";var Vd=class extends tt{constructor(e,r,i){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=i}bilinearCubeUV(e,r,i,s){let o=new xm(Vd.Nodes.bilinearCubeUV,[r,i,s]);this.colorSpaceTL=this.colorSpaceTL??new xn(new Kt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(o.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new xn(new Kt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(o.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new xn(new Kt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(o.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new xn(new Kt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(o.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new Kt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Kt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Kt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Kt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Kt("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=o,l}generate(e,r){if(e.isShader("fragment")){let i=this.uv,s=this.bias||e.context.roughness,o=new xm(Vd.Nodes.roughnessToMip,[s]),a=new ft(o,Vd.Nodes.m0,Vd.Nodes.cubeUV_maxMipLevel,ft.CLAMP),l=new ft(a,ft.FLOOR),c=new ft(a,ft.FRACT),u=this.bilinearCubeUV(e,this.value,i,l),h=this.bilinearCubeUV(e,this.value,i,new ki(l,new Fe(1).setReadonly(!0),ki.ADD)),d=new ft(u,h,c,ft.MIX);return e.format(d.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},kd=Vd;kd.Nodes=function(){let e=new Nd(`struct TextureCubeUVData {
			vec4 tl;
			vec4 tr;
			vec4 br;
			vec4 bl;
			vec2 f;
		}`),r=new qt("float cubeUV_maxMipLevel 8.0",!0),i=new qt("float cubeUV_minMipLevel 4.0",!0),s=new qt("float cubeUV_maxTileSize 256.0",!0),o=new qt("float cubeUV_minTileSize 16.0",!0),a=new Ee(`float getFace(vec3 direction) {
				vec3 absDirection = abs(direction);
				float face = -1.0;
				if (absDirection.x > absDirection.z) {
					if (absDirection.x > absDirection.y)
						face = direction.x > 0.0 ? 0.0 : 3.0;
					else
						face = direction.y > 0.0 ? 1.0 : 4.0;
				} else {
					if (absDirection.z > absDirection.y)
						face = direction.z > 0.0 ? 2.0 : 5.0;
					else
						face = direction.y > 0.0 ? 1.0 : 4.0;
				}
				return face;
		}`);a.useKeywords=!1;let l=new Ee(`vec2 getUV(vec3 direction, float face) {
				vec2 uv;
				if (face == 0.0) {
					uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
				} else if (face == 1.0) {
					uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
				} else if (face == 2.0) {
					uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
				} else if (face == 3.0) {
					uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
				} else if (face == 4.0) {
					uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
				} else {
					uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
				}
				return 0.5 * (uv + 1.0);
		}`);l.useKeywords=!1;let c=new Ee(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
			float face = getFace(direction);
			float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
			mipInt = max(mipInt, cubeUV_minMipLevel);
			float faceSize = exp2(mipInt);
			float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
			vec2 uv = getUV(direction, face) * (faceSize - 1.0);
			vec2 f = fract(uv);
			uv += 0.5 - f;
			if (face > 2.0) {
				uv.y += faceSize;
				face -= 3.0;
			}
			uv.x += face * faceSize;
			if(mipInt < cubeUV_maxMipLevel){
				uv.y += 2.0 * cubeUV_maxTileSize;
			}
			uv.y += filterInt * 2.0 * cubeUV_minTileSize;
			uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
			uv *= texelSize;
			vec4 tl = texture2D(envMap, uv);
			uv.x += texelSize;
			vec4 tr = texture2D(envMap, uv);
			uv.y += texelSize;
			vec4 br = texture2D(envMap, uv);
			uv.x -= texelSize;
			vec4 bl = texture2D(envMap, uv);
			return TextureCubeUVData( tl, tr, br, bl, f );
		}`,[e,a,l,r,i,s,o]);c.useKeywords=!1;let u=new qt("float r0 1.0",!0),h=new qt("float v0 0.339",!0),d=new qt("float m0 -2.0",!0),f=new qt("float r1 0.8",!0),p=new qt("float v1 0.276",!0),m=new qt("float m1 -1.0",!0),g=new qt("float r4 0.4",!0),y=new qt("float v4 0.046",!0),v=new qt("float m4 2.0",!0),x=new qt("float r5 0.305",!0),S=new qt("float v5 0.016",!0),w=new qt("float m5 3.0",!0),A=new qt("float r6 0.21",!0),T=new qt("float v6 0.0038",!0),b=new qt("float m6 4.0",!0),M=[u,h,d,f,p,m,g,y,v,x,S,w,A,T,b],C=new Ee(`float roughnessToMip(float roughness) {
			float mip = 0.0;
			if (roughness >= r1) {
				mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
			} else if (roughness >= r4) {
				mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
			} else if (roughness >= r5) {
				mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
			} else if (roughness >= r6) {
				mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
			} else {
				mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
			}
			return mip;
		}`,M);return{bilinearCubeUV:c,roughnessToMip:C,m0:d,cubeUV_maxMipLevel:r}}();var Yc=class extends tt{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Yc.VIEW}getShared(){return this.scope===Yc.WORLD}build(e,r,i,s){let o=e.context[this.scope+"Normal"];return o?o.build(e,r,i,s):super.build(e,r,i)}generate(e,r,i,s,o){let a;switch(this.scope){case Yc.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case Yc.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case Yc.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}},Ui=Yc;Ui.LOCAL="local",Ui.WORLD="world",Ui.VIEW="view",Ui.NORMAL="normal";_i.addKeyword("viewNormal",function(){return new Ui(Ui.VIEW)});_i.addKeyword("localNormal",function(){return new Ui(Ui.NORMAL)});_i.addKeyword("worldNormal",function(){return new Ui(Ui.WORLD)});var Bo=class extends tt{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Bo.LOCAL}getType(){switch(this.scope){case Bo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Bo.LOCAL:case Bo.WORLD:return!1}return!0}generate(e,r,i,s,o){let a;switch(this.scope){case Bo.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case Bo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case Bo.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Bo.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}},Bn=Bo;Bn.LOCAL="local",Bn.WORLD="world",Bn.VIEW="view",Bn.PROJECTION="projection";_i.addKeyword("position",function(){return new Bn});_i.addKeyword("worldPosition",function(){return new Bn(Bn.WORLD)});_i.addKeyword("viewPosition",function(){return new Bn(Bn.VIEW)});var Ys=class extends tt{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Ys.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Ys.SPHERE:return"v2"}return this.type}generate(e,r){let i=this.getUnique(e);if(e.isShader("fragment")){let s;switch(this.scope){case Ys.VECTOR:{let o=new Ui(Ui.VIEW),a=e.context.roughness,l=o.build(e,"v3"),c=new Bn(Bn.VIEW).build(e,"v3"),u=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${c} ), ${l} )`;u&&(h=`normalize( mix( ${h}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${h}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${d};`),s="reflectVec"):s=d;break}case Ys.CUBE:{let o=new Ys(Ys.VECTOR).build(e,"v3"),a="vec3( -"+o+".x, "+o+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),s="reflectCubeVec"):s=a;break}case Ys.SPHERE:{let a="normalize( ( viewMatrix * vec4( "+new Ys(Ys.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),s="reflectSphereVec"):s=a;break}}return e.format(s,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},No=Ys;No.CUBE="cube",No.SPHERE="sphere",No.VECTOR="vector";var X0=class extends tt{constructor(e=new bn,r,i){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new kd(this.value,r??new No(No.VECTOR),i),this.irradianceNode=new kd(this.value,new Ui(Ui.WORLD),new Fe(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};var K0=class extends ar{constructor(e=new Fu,r,i){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new No,this.bias=i}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let i=this.getTexture(e,r),s=this.uv?.build(e,"v3"),o=this.bias?this.bias.build(e,"f"):void 0;o===void 0&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f"));let a;o?a="texCubeBias( "+i+", "+s+", "+o+" )":a="texCube( "+i+", "+s+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new xn(new Kt("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,r)}};var wR=`
uniform int frameIndex;
uniform vec2 resolution;
uniform mat4 previousModelViewMatrix;
uniform mat4 previousProjectionMatrix;

varying vec4 vCurrentPosition;
varying vec4 vPreviousPosition;
`,AR=`
layout(location = 1) out vec4 gVelocity;

uniform int frameIndex;
uniform vec2 resolution;

varying vec4 vCurrentPosition;
varying vec4 vPreviousPosition;

const vec2 haltonSequence[16] = vec2[16](
vec2( 0.000000,-0.333334),
vec2(-0.500000, 0.333334),
vec2( 0.500000,-0.777778),
vec2(-0.750000,-0.111112),
vec2( 0.250000, 0.555556),
vec2(-0.250000,-0.555556),
vec2( 0.750000, 0.111112),
vec2(-0.875000, 0.777778),
vec2(0.125000, -0.925926),
vec2(-0.375000, -0.259260),
vec2(0.625000, 0.407408),
vec2(-0.625000, -0.703704),
vec2(0.375000, -0.037038),
vec2(-0.125000, 0.629630),
vec2(0.875000, -0.481482),
vec2(-0.937500, 0.185186));

vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {
  const float goldenAngle = 2.399963f; // radians
  float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));
  float theta = float(sampleIndex) * goldenAngle + angle;
  float sine = sin(theta);
  float cosine = cos(theta);
  return vec2(cosine, sine) * r;
}

// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso
float getNoiseInterleavedGradient(vec2 screenPos) {
    vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
    return fract(magic.z * fract(dot(screenPos, magic.xy)));
}

`,ER=`
// TODO: This could be generated CPU side and passed to the shader every frame
const vec2 haltonSequence[16] = vec2[16](
vec2( 0.000000,-0.333334),
vec2(-0.500000, 0.333334),
vec2( 0.500000,-0.777778),
vec2(-0.750000,-0.111112),
vec2( 0.250000, 0.555556),
vec2(-0.250000,-0.555556),
vec2( 0.750000, 0.111112),
vec2(-0.875000, 0.777778),
vec2(0.125000, -0.925926),
vec2(-0.375000, -0.259260),
vec2(0.625000, 0.407408),
vec2(-0.625000, -0.703704),
vec2(0.375000, -0.037038),
vec2(-0.125000, 0.629630),
vec2(0.875000, -0.481482),
vec2(-0.937500, 0.185186));

// TODO: Pass correct view size
vec2 offset = haltonSequence[frameIndex];
offset.x /= resolution.x;
offset.y /= resolution.y;

vec4 currentPosition = gl_Position;
vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);

// We want to calculate the velocity with unjittered positions
// so that things that are not moving get a velocity = 0
vCurrentPosition = currentPosition;
vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);
#ifdef OUTLINE_COMPENSATION
vPreviousPosition.xy += OUTLINE_COMPENSATION;
#endif
gl_Position = currentPositionJittered;

`,TR=`
vec2 oldPos = vPreviousPosition.xy;
    oldPos /= vPreviousPosition.w;
    oldPos.xy = (oldPos.xy+1.)/2.0;

vec2 newPos = vCurrentPosition.xy;
    newPos /= vCurrentPosition.w;
    newPos.xy = (newPos.xy+1.)/2.0;

vec2 velocity = (newPos - oldPos);

// Discard fully transparent pixels 
if (gl_FragColor.a <= 0.0) discard;

gVelocity = vec4(velocity, 0.0, 1.0);
`,MR=`
layout(location = 1) out vec4 gVelocity;
`,CR=`
    // Discard fully transparent pixels 
    if (gl_FragColor.a <= 0.0) discard;

    gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
`;var PR=["x","y","z","w"],iX=["float","vec2","vec3","vec4"],nX={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},sX={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ud=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,i){let s=this.getIncludes(r,i);if(!s)return"";let o="";s=s.sort(t);for(let a=0;a","#include "].join(`
`),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
`),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
					accumAlpha += (1.0 - accumAlpha) * alpha;
				}`,""].join(`
`)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(wR),this.addFragmentParsCode(AR),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r0?r+1:"";this.addVaryCode("varying vec2 vUv"+i+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+i+";"),this.addVertexFinalCode("vUv"+i+" = uv"+i+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ?  ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(ER),this.addFragmentFinalCode(TR)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
`}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
`}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+`
`}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
`}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,i="varying",s="V",o=""){let a=this.getVars(i),l=a[t];if(!l){let c=a.length;l={name:r||"node"+s+c+(o?"_"+o:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,i){return this.getVar(t,e,r,this.shader,"T",i)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
`)}getVarListCode(t,e){e=e??"";let r="";for(let i=0,s=t.length;i 0.5 ) {
					if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 )  {
						lalpha = 0.0;
					}
				}
				
				lalpha *= mask;

				calpha =  lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return col;
			}`);s=e.include(c);break;case 4:s=e.include(Hd.Nodes.triplanar);break;default:s=e.include(Hd.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let o=[];if(o.push("normal"),o.push(this.texture.generate(e,"t")),o.push(this.textureSize.build(e,"v2")),o.push(this.crop.build(e,"f")),o.push(this.mat.build(e,"mat3")),o.push(this.size.build(e,"v2")),o.push(this.blending.build(e,"f")),o.push(this.isMask.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),this.projection.value===4){let a=`${i}_writeUvs`,l=a+"0",c=a+"1",u=a+"2",h=`${i}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(h,"vec3"),o.push(l),o.push(c),o.push(u),o.push(h)}else{let a=`${i}_writeUvs`;e.addFragmentVariable(a,"vec2"),o.push(a)}return e.format(s+"("+o.join(",")+")",this.getType(e),r)}},Gl=Hd;Gl.Nodes=function(){let e=new Ee(`
vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
                vec3 posN = normalize(position);
                float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
                float scaledHeight = position.y / (size.y * 0.5);
                float v =  (scaledHeight / 2.) + .5;

                vec2 calculatedUv = vec2(u,v);
				vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
				writeUv = uvs;

                vec2 df = fwidth(uvs);
               	if(df.x > 0.5) df.x = 0.;

				#ifdef GL_EXT_shader_texture_lod
                vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
				#else
                vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
				#endif

				vec3 col = tmp.rgb;
				float lalpha = alpha * tmp.a;
				if ( crop > 0.5 ) {
					if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 )  {
						lalpha = 0.0;
					}
				}

				lalpha *= mask;
				
				calpha =  lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return col;
			}
`),r=new Ee(`
vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
                vec3 posN = normalize(vPosition);
                float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
                float v = 0.5 + asin(posN.y) / 3.1415;

                vec2 calculatedUv = vec2(u,v);
				vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
				writeUv = uvs;

                vec2 df = fwidth(uvs);
               	if(df.x > 0.5) df.x = 0.;
				#ifdef GL_EXT_shader_texture_lod
                vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
				#else
                vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
				#endif

				vec3 col = tmp.rgb;
				float lalpha = alpha * tmp.a;
				if ( crop > 0.5 ) {
					if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 )  {
						lalpha = 0.0;
					}
				}

				lalpha *= mask;

				calpha =  lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return col;
			}
`),i=new Ee(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
				vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
				writeUv = uvs;

				vec4 tmp = texture2D( tex, uvs );

				vec3 col = tmp.rgb;

				float lalpha = alpha * tmp.a;
				if ( crop > 0.5 ) {
					if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 )  {
						lalpha = 0.0;
					}
				}
				
				lalpha *= mask;

				calpha =  lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return col;
			}`),s=new Ee(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {
				vec3 p = position;
				vec2 uv0 = (1.0 + p.xy) / 2.0;     
				vec2 uv1 = (1.0 + p.zy) / 2.0;		
				vec2 uv2 = (1.0 + p.xz) / 2.0;		
	
				uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
				uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
				uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;

				// Range from 3 to 128 seems to be good
				float exponent = (1.0 - blending) * 125.0 + 3.0;

				vec3 n = vObjectNormal;
				vec3 weights = abs(normalize(n));
				weights = pow(weights, vec3(exponent));
				weights /= dot(weights, vec3(1.0));

				// Write out all sets of UVs that we generated
				writeUvs0 = uv0;
				writeUvs1 = uv1;
				writeUvs2 = uv2;
				writeWeights = weights;

				// Derivatives for LOD
				vec2 df0 = fwidth(uv0);
				vec2 df1 = fwidth(uv1);
				vec2 df2 = fwidth(uv2);
				if (df0.x > 0.5) df0.x = 0.0;
				if (df1.x > 0.5) df1.x = 0.0;
				if (df2.x > 0.5) df2.x = 0.0;

				#ifdef GL_EXT_shader_texture_lod
                	vec4 tmp = 
						texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + 
						texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + 
						texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
				#else
                	vec4 tmp = 
						textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + 
						textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + 
						textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
				#endif

				vec3 col = tmp.rgb;
				float lalpha = alpha * tmp.a;

				// Apply cropping across all 3 planes
				if ( crop > 0.5 ) {
					if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 )  {
						lalpha = 0.0;
					}
					if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 )  {
						lalpha = 0.0;
					}
					if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 )  {
						lalpha = 0.0;
					}
				}

				lalpha *= mask;
				calpha =  lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return col;//n * 0.5 + 0.5;
			}			
			`);return{cylindrical:e,spherical:r,uv:i,triplanar:s}}();var Wd=class extends tt{constructor(e,r,i,s,o,a,l,c,u,h,d,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=i,this.far=s,this.isVector=o,this.isWorldSpace=a,this.origin=l,this.direction=c,this.colors=u,this.steps=h,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let i=`g${this.uuid.toString().replace(/-/g,"")}`,s=new Ee(`vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[${i}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
               vec4 color = colors[0];
               #ifdef ${i}_IS_VECTOR
                   #ifdef ${i}_LINEAR
                       #ifdef ${i}_WORLDSPACE
                       float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
                       #else
                       float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
                       #endif
                   #else
                       #ifdef ${i}_WORLDSPACE
                           float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
                       #else
                           float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
                       #endif
                   #endif
               #else
                   float dist = length(vWPosition - cameraPosition);
			       float depth = ( dist - near ) / ( far - near );
               #endif


              float p;
              #ifdef ${i}_SMOOTH
				for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
						p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
						color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
					}
              #else
                for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
                   p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
                   color = mix(color, colors[i], p);
                 }
              #endif

               float lalpha = alpha * color.a * mask;
               calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
			   accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
			   
               return color.rgb;
			}`,[Wd.Nodes.vectorLinearWorldSpaceDepth,Wd.Nodes.vectorLinearObjectSpaceDepth,Wd.Nodes.vectorSphericalObjectSpaceDepth,Wd.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${i}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${i}_SMOOTH`),this.isVector.value>.5&&e.define(`${i}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${i}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${i}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let o=e.include(s),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(o+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},qd=Wd;qd.Nodes=function(){let e=new Ee(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
               vec3 n = normalize(direction);
               float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
               return ( dist - near ) / ( far - near );
            }`),r=new Ee(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
               vec3 n = normalize(direction);
               float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
               return ( dist - near ) / ( far - near );
            }`),i=new Ee(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
               float dist = length(vWPosition - origin);
               return ( dist - near ) / ( far - near );
            }`),s=new Ee(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
               float dist = length(position - origin);
               return ( dist - near ) / ( far - near );
            }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:i,vectorSphericalObjectSpaceDepth:s}}();var bm=class extends tt{constructor(e,r,i,s,o,a,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=i,this.intensity=s,this.factor=o,this.isMask=c,this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=new Ee(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
					float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );

					float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
					calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
					accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

					return color;
				}`),s=e.include(i),o=[];return o.push(this.color.build(e,"c")),o.push(this.bias.build(e,"f")),o.push(this.scale.build(e,"f")),o.push(this.intensity.build(e,"f")),o.push(this.factor.build(e,"f")),o.push(this.isMask.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(s+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var cE=class extends tt{constructor(e,r,i,s,o,a,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=i,this.steps=s,this.offset=o,this.morph=a,this.angle=l,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(cE.Nodes.gradient),s=[];return s.push(this.gradientType.build(e,"i")),s.push(this.smooth.build(e,"b")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.offset.build(e,"v2")),s.push(this.morph.build(e,"v2")),s.push(this.angle.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Yd=cE;Yd.Nodes=function(){return{gradient:new Ee(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
				vec4 color = colors[0];
				vec2 m = morph / vUv.xy;
				vec2 rot = vec2( 0.5 + m.x, m.y );
				vec2 dt = vec2(
					cos( angle ) * rot.x - sin( angle ) * rot.y,
					sin( angle ) * rot.x + cos( angle ) * rot.y
				);
				vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;
				float t = dot( pt, dt ) / dot( dt, dt );
				if ( gradientType == 1 ) {
					t = distance (
						( vUv + morph ) * 3.0,
						( vUv + offset ) + 1.0
					) + angle;
				} else if ( gradientType == 2 ) {
					float polar = atan(
						vUv.x + morph.x - 0.5 + offset.x,
						vUv.y + morph.y - 0.5 + offset.y
					) * -1.0;
					t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );
				}

				float p;
				if (smoothed) {
					for ( int i = 1; i < GRAD_MAX; i++ ) {
						p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
						color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
					}

				} else {
					for ( int i = 1; i < GRAD_MAX; i++ ) {
						p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
						color = mix(color, colors[i], p);
					}
				}

				float lalpha = alpha * color.a * mask;
				calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
				
				return color.xyz;
			}`)}}();var uE=class extends tt{constructor(e,r,i,s,o){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=s,this.alpha=r,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=o}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=e.include(uE.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let s=[];return s.push(this.texture.generate(e,"t")),s.push("normal"),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),s.push(this.rotation.build(e,"f")),e.format(i+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Xd=uE;Xd.Nodes=function(){return{matcap:new Ee(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
					vec3 viewDir = normalize( vViewPosition );
					vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
					vec3 y = cross( viewDir, x );
					vec2 uv = vec2( dot( x, normal ), dot( y, normal ) );
					uv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv;
					uv = uv * 0.495 + 0.5;
					vec4 matcapColor = texture2D( matcapTex, uv );

					float lalpha = alpha * mask;
					calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
					accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
					
					return matcapColor.rgb;
            	}`)}}();var Sm=(o=>(o.SIMPLEX="simplex3d",o.SIMPLEX_FRACTAL="simplex3dFractal",o.ASHIMA="simplexAshima",o.FBM="fbm",o.PERLIN="perlin",o.VORONOI="voronoi",o))(Sm||{}),zi=function(){let t=new Ee(`vec3 random3(vec3 c) {
			float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
			vec3 r;
			r.z = fract(512.0*j);
			j *= .125;
			r.x = fract(512.0*j);
			j *= .125;
			r.y = fract(512.0*j);
			return r-0.5;
		}`),e=new Ee(`float simplex3d(vec3 p) {
			 vec3 s = floor(p + dot(p, vec3(F3)));
			 vec3 x = p - s + dot(s, vec3(G3));
			 
			 vec3 e = step(vec3(0.0), x - x.yzx);
			 vec3 i1 = e*(1.0 - e.zxy);
			 vec3 i2 = 1.0 - e.zxy*(1.0 - e);
				
			 vec3 x1 = x - i1 + G3;
			 vec3 x2 = x - i2 + 2.0*G3;
			 vec3 x3 = x - 1.0 + 3.0*G3;
			 
			 vec4 w, d;
			 
			 w.x = dot(x, x);
			 w.y = dot(x1, x1);
			 w.z = dot(x2, x2);
			 w.w = dot(x3, x3);
			 
			 w = max(0.6 - w, 0.0);
			 
			 d.x = dot(random3(s), x);
			 d.y = dot(random3(s + i1), x1);
			 d.z = dot(random3(s + i2), x2);
			 d.w = dot(random3(s + 1.0), x3);
			 
			 w *= w;
			 w *= w;
			 d *= w;
			 
			 return dot(d, vec4(52.0));
		}`,[t]);e.keywords.F3=new qt("float F3 0.3333333"),e.keywords.G3=new qt("float G3 0.1666667");let r=new Ee(`float simplex3dFractal(vec3 m) {
			mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
			mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
			mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
			return 0.5333333 * simplex3d(m * rot1)
				 + 0.2666667 * simplex3d(2.0 * m * rot2)
				 + 0.1333333 * simplex3d(4.0 * m * rot3)
				 + 0.0666667 * simplex3d(8.0 * m);
		}`,[e]),i=new Ee("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new Ee("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new Ee(`float simplexAshima(vec3 v) {
		  const vec2  C = vec2(1.0/6.0, 1.0/3.0) ;
		  const vec4  D = vec4(0.0, 0.5, 1.0, 2.0);
		  vec3 i  = floor(v + dot(v, C.yyy) );
		  vec3 x0 =   v - i + dot(i, C.xxx) ;
		  vec3 g = step(x0.yzx, x0.xyz);
		  vec3 l = 1.0 - g;
		  vec3 i1 = min( g.xyz, l.zxy );
		  vec3 i2 = max( g.xyz, l.zxy );
		  vec3 x1 = x0 - i1 + 1.0 * C.xxx;
		  vec3 x2 = x0 - i2 + 2.0 * C.xxx;
		  vec3 x3 = x0 - 1. + 3.0 * C.xxx;
		  i = mod(i, 289.0 ); 
		  vec4 p = permute( permute( permute( 
					 i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
				   + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) 
				   + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
		  float n_ = 1.0/7.0; // N=7
		  vec3  ns = n_ * D.wyz - D.xzx;
		  vec4 j = p - 49.0 * floor(p * ns.z *ns.z);  //  mod(p,N*N)
		  vec4 x_ = floor(j * ns.z);
		  vec4 y_ = floor(j - 7.0 * x_ );    // mod(j,N)
		  vec4 x = x_ *ns.x + ns.yyyy;
		  vec4 y = y_ *ns.x + ns.yyyy;
		  vec4 h = 1.0 - abs(x) - abs(y);
		  vec4 b0 = vec4( x.xy, y.xy );
		  vec4 b1 = vec4( x.zw, y.zw );
		  vec4 s0 = floor(b0)*2.0 + 1.0;
		  vec4 s1 = floor(b1)*2.0 + 1.0;
		  vec4 sh = -step(h, vec4(0.0));
		  vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
		  vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
		  vec3 p0 = vec3(a0.xy,h.x);
		  vec3 p1 = vec3(a0.zw,h.y);
		  vec3 p2 = vec3(a1.xy,h.z);
		  vec3 p3 = vec3(a1.zw,h.w);
		  vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
		  p0 *= norm.x;
		  p1 *= norm.y;
		  p2 *= norm.z;
		  p3 *= norm.w;
		  vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
		  m = m * m;
		  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), 
										dot(p2,x2), dot(p3,x3) ) );
		}`,[i,s]),a=new Ee("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new Ee("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new Ee(`float noise(vec3 p){
			vec3 a = floor(p);
			vec3 d = p - a;
			d = d * d * (3.0 - 2.0 * d);
			vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
			vec4 k1 = perm(b.xyxy);
			vec4 k2 = perm(k1.xyxy + b.zzww);
			vec4 c = k2 + a.zzzz;
			vec4 k3 = perm(c);
			vec4 k4 = perm(c + 1.0);
			vec4 o1 = fract(k3 * (1.0 / 41.0));
			vec4 o2 = fract(k4 * (1.0 / 41.0));
			vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
			vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
			return o4.y * d.y + o4.x * (1.0 - d.y);
		}`,[l]),u=new Ee(`float fbm(vec3 x) {
			float v = 0.0;
			float a = 0.5;
			vec3 shift = vec3(100);
			for (int i = 0; i < NUM_OCTAVES; ++i) {
				v += a * noise(x);
				x = x * 2.0 + shift;
				a *= 0.5;
			}
			return v;
		}`,[c]);u.keywords.NUM_OCTAVES=new qt(`int NUM_OCTAVES ${5}`);let h=new Ee("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new Ee(`float perlin(vec3 P){
		  vec3 Pi0 = floor(P);
		  vec3 Pi1 = Pi0 + vec3(1.0);
		  Pi0 = mod(Pi0, 289.0);
		  Pi1 = mod(Pi1, 289.0);
		  vec3 Pf0 = fract(P);
		  vec3 Pf1 = Pf0 - vec3(1.0);
		  vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
		  vec4 iy = vec4(Pi0.yy, Pi1.yy);
		  vec4 iz0 = Pi0.zzzz;
		  vec4 iz1 = Pi1.zzzz;
		  vec4 ixy = permute(permute(ix) + iy);
		  vec4 ixy0 = permute(ixy + iz0);
		  vec4 ixy1 = permute(ixy + iz1);
		  vec4 gx0 = ixy0 / 7.0;
		  vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
		  gx0 = fract(gx0);
		  vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
		  vec4 sz0 = step(gz0, vec4(0.0));
		  gx0 -= sz0 * (step(0.0, gx0) - 0.5);
		  gy0 -= sz0 * (step(0.0, gy0) - 0.5);
		  vec4 gx1 = ixy1 / 7.0;
		  vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
		  gx1 = fract(gx1);
		  vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
		  vec4 sz1 = step(gz1, vec4(0.0));
		  gx1 -= sz1 * (step(0.0, gx1) - 0.5);
		  gy1 -= sz1 * (step(0.0, gy1) - 0.5);
		  vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
		  vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
		  vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
		  vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
		  vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
		  vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
		  vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
		  vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
		  vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
		  g000 *= norm0.x;
		  g010 *= norm0.y;
		  g100 *= norm0.z;
		  g110 *= norm0.w;
		  vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
		  g001 *= norm1.x;
		  g011 *= norm1.y;
		  g101 *= norm1.z;
		  g111 *= norm1.w;
		  float n000 = dot(g000, Pf0);
		  float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
		  float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
		  float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
		  float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
		  float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
		  float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
		  float n111 = dot(g111, Pf1);
		  vec3 fade_xyz = fade(Pf0);
		  vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
		  vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
		  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); 
		  return 2.2 * n_xyz;
		}`,[i,s,h]),f=new Ee(`float hashwithoutsine13(vec3 p3)
		{
			p3  = fract(p3 * .1031);
			p3 += dot(p3, p3.yzx + 33.33);
			return fract((p3.x + p3.y) * p3.z);
		}`),p=new Ee(`vec3 hashwithoutsine33(vec3 p3)
		{
			p3 = fract(p3 * vec3(.1031, .1030, .0973));
			p3 += dot(p3, p3.yxz+33.33);
			return fract((p3.xxy + p3.yxx)*p3.zyx);
		}`),m=new Ee(`float metric(in vec3 p)
		{
			// L2 
			return length(p);

			// Chebyshev 
			// vec3 a = abs(p);
			// return max(a.x, max(a.y, a.z));
		}`),g=new Ee(`float smin( float a, float b, float k )
		{
			float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);
			float correction = k * h * (1.0 - h);
			return mix(b, a, h) - correction;
		}`),y=new Ee(`float smax( float a, float b, float k )
		{
			float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
			float correction = k * h * (1.0 - h);
			return mix(a, b, h) + correction;
		}`),v=new Ee(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
			// Compute width of each interval
			float input_width = input_max - input_min;
			float output_width = output_max - output_min;
		
			// Convert input range into a 0-1 range 
			float scaled = (value - input_min) / input_width;
		
			// Convert the 0-1 range into a value in output range
			return output_min + (scaled * output_width);
		}`),x=new Ee(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) 
		{
			// Integer and fractional parts of this point's coordinates
			ivec3 p = ivec3(floor(x));
			vec3 f = fract(x);

			// Different variables that we will use to construct noise:
			//
			// f1: distance to the closest feature point
			// f2: distance to the second closest feature point
			// e: distance to the closest edge (cell boundary)
			//
			// We also compute "smooth" versions of all of the above quantites, essentially
			// replacing "hard" minimums with "smooth" minimums (described by IQ)
			float f1_smooth = 8.0;
			float f1 = 8.0;
			float f2_smooth = 8.0;
			float f2 = 8.0;
			float e_smooth = 8.0;
			float e = 8.0;

			// Variables stored from closest cell
			ivec3 mb;
			vec3 mr; 

			int steps = quality;
			
			for (int x = -steps; x <= steps; x++) 
			for (int y = -steps; y <= steps; y++)
			for (int z = -steps; z <= steps; z++)
			{
				ivec3 b = ivec3(x, y, z);
				vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
				float d = length(r);
				
				f1_smooth = smin(d, f1_smooth, smoothness);

				// Store un-smoothed distances too 
				if (d < f1) 
				{
					f2 = f1;
					f1 = d;

					mb = ivec3(x, y, z);
					mr = r;
				} 
				else if (d < f2) 
				{
					f2 = d;
				}
			}	
			
			float id = hashwithoutsine13(vec3(p + mb) + seed);

			// Second pass for edge distance  
			for (int x = -steps; x <= steps; x++) 
			for (int y = -steps; y <= steps; y++)
			for (int z = -steps; z <= steps; z++)
			{
				// Start search at the cell that contains the closest point to "x" (found in 1st pass)
				ivec3 b = mb + ivec3(x, y, z);
				vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
				float d1 = dot(0.5 * (mr + r), (r - mr)); 				// IQ normalizes "r - mr" but that breaks things for the smooth version?
				float d2 = dot(0.5 * (mr + r), normalize(r - mr));

				e_smooth = smin(d1, e_smooth, smoothness);

				e = min(e, d2);

				// Also compute a smooth version of F2 in this pass
				{
					ivec3 b = ivec3(x, y, z);
					if (b != mb) 
					{
						vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
						float d = length(r);

						f2_smooth = smin(d, f2_smooth, smoothness);
					}
				}
			}

			// Different visualization modes 
			if (style == 0) 
			{
				return f1_smooth;
			}
			if (style == 1) 
			{
				return f2_smooth;
			}
			if (style == 2) 
			{
				return f2_smooth - f1_smooth;
				
				// "Pebbles" also cool
				//return step(0.2, f2_smooth - f1_smooth);
			}
			if (style == 3) 
			{
				// This one is really good for rock / stone effects
				float a = f1; 
				float b = f2;
				float k = 3.0;
				float h = max(k - abs(a - b), 0.0) / k;
				float final = min(a, b) - h * h * k * (1.0 / 4.0);
				return final;
			}
			if (style == 4) 
			{
				// Some random adjustments to make this style stand out more 
				return exp(5.0 * e_smooth);
			}
			if (style == 5) 
			{
				return pow(f1_smooth, 3.0);
			}
			if (style == 6) 
			{				
				const float eps = 0.0125;

				// Thicker lines as the user increases the smoothness slider
				float thickness = smoothness * 0.25 + eps;

				// Blurrier lines as the user increases the smoothness slider
				float blur = pow(smoothness, 3.0) * 0.25 + eps;

				return smoothstep(
					thickness - thickness * blur, 
					thickness + thickness * blur, 
					e
				);
			}
			if (style == 7) 
			{
				return hashwithoutsine13(vec3(p + mb) + seed);
			}
		}
	`,[f,p,m,g,y,v]);return{simplex:e,simplexFractal:r,simplexAshima:o,fbm:u,perlin:d,voronoi:x}}();var Kd=class extends tt{constructor(e,r,i,s,o,a,l,c,u,h,d,f,p,m,g,y,v,x,S){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=i,this.fA=s,this.fB=o,this.distortion=a,this.colorA=l,this.colorB=c,this.colorC=u,this.colorD=h,this.noiseType=f,this.voronoiStyle=m,this.highCut=g,this.lowCut=y,this.smoothness=v,this.seed=x,this.quality=S,this.isMask=p,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,i,s,o){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(Sm)[this.noiseType.value],l=a=="voronoi"?`
		float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality);

		// Apply clipping to colors
		v = remap(v, lowCut, highCut, 0.0, 1.0);
		v = smax(v, 0.0, smoothness * 0.25);
		v = smin(v, 1.0, smoothness * 0.25);

		// Note that the voronoi mode only uses colors "A" and "C" from the UI 
		vec4 color = mix(colorA, colorC, v); 
		`:`
		vec3 q = vec3(${a}(st),
					   ${a}(st + vec3(1.0)),
					   ${a}(st + vec3(1.0)));
		vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
					  ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), 
					  ${a}(st * q));
		float f = ${a}(st + r);
		vec4 color;
		color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
		color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
		color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
		`,c=new Ee(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) 
			{
                // Prevent scale of zero 
				scale = max(abs(scale), 0.001);

				vec3 st = position / size;
				st /= scale;

				${l}

				float lalpha = alpha * color.a * mask;
				calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return clamp(color, 0.0, 1.0).rgb;
			}`,[zi.simplex,zi.simplexFractal,zi.simplexAshima,zi.fbm,zi.perlin,zi.voronoi]),u=e.include(c),h=[];return h.push(this.scale.build(e,"f")),h.push(this.size.build(e,"v3")),h.push(this.move.build(e,"f")),h.push(this.fA.build(e,"v2")),h.push(this.fB.build(e,"v2")),h.push(this.distortion.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.colorC.build(e,"v4")),h.push(this.colorD.build(e,"v4")),h.push(this.voronoiStyle.build(e,"i")),h.push(this.highCut.build(e,"f")),h.push(this.lowCut.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.seed.build(e,"f")),h.push(this.quality.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(u+"("+h.join(",")+")",this.getType(e),r)}};Kd.numOctaves=5;var hE=class extends tt{constructor(e,r,i,s,o,a,l,c,u,h,d,f,p,m,g,y){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=i,this.contourWidth=s,this.contourThreshold=o,this.outlineThreshold=a,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=h,this.compensation=d,this.resolution=f,this.normalMap=p,this.depthMap=m,this.pixelRatio=g,this.alpha=y,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let i=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${i}_offset`),this.firstTime){let s=this.outlineWidth.build(e,"f"),o=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(s,"uniform float"),e.addVertexParsVariable(o,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
                vID = randomColor.r;
                vec2 ${i}_offset = vec2(0.0);
                if (${a}) {
                    vec4 ${i}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
                    // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
                    // normals face the camera directly. So we hackily fix this by offsetting the normal
                    // by a tiny amount.
                    vec3 ${i}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
                    ${i}_offset = normalize(${i}_clipNormal.xy) / ${o} * (${s} / 2.0) * ${i}_clipPosition.w * 2.0 * ${l};
                    ${i}_clipPosition.xy += ${i}_offset;
                    // TODO(MAX): To handle multiple outline layers, we only want to extrude
                    // if this offset is the biggest of all the potential offsets
                    gl_Position = ${i}_clipPosition;
                }
            `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=e.include(hE.Nodes.outline),o=[];return o.push(this.outlineColor.build(e,"c")),o.push(this.contourColor.build(e,"c")),o.push(this.outlineWidth.build(e,"f")),o.push(this.contourWidth.build(e,"f")),o.push(this.contourThreshold.build(e,"f")),o.push(this.outlineThreshold.build(e,"f")),o.push(this.contourFrequency.build(e,"f")),o.push(this.outlineSmoothing.build(e,"f")),o.push(this.contourDirection.build(e,"v3")),o.push(this.positionalLines.build(e,"b")),o.push(this.resolution.build(e,"v2")),o.push(this.normalMap.getTexture(e,"t")),o.push(this.depthMap.getTexture(e,"t")),o.push(this.pixelRatio.build(e,"f")),o.push(this.compensation.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.calpha),this.firstTime=!this.firstTime,e.format(s+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Qd=hE;Qd.Nodes=function(){let e=new Ee(`
float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
{
    vec2 halton = haltonSequence[frameIndex];
    float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
    float temporalAngle  = temporalOffset * PI2;

    vec2 texelSize = (vec2(1.0) / resolution);
    vec2 offsetSize = texelSize * outlineWidth * pixelRatio;

    vec2 uvSamples[9];
    vec4 normalSamples[9];

	uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);
	uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);
	uvSamples[2] = uv + vec2(  offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);
	uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);
	uvSamples[4] = uv;
	uvSamples[5] = uv + vec2(  offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);
	uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);
	uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);
	uvSamples[8] = uv + vec2(  offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);


    normalSamples[0] = texture2D(t, uvSamples[0]);
    normalSamples[1] = texture2D(t, uvSamples[1]);
    normalSamples[2] = texture2D(t, uvSamples[2]);
    normalSamples[3] = texture2D(t, uvSamples[3]);
    normalSamples[4] = texture2D(t, uvSamples[4]);
    normalSamples[5] = texture2D(t, uvSamples[5]);
    normalSamples[6] = texture2D(t, uvSamples[6]);
    normalSamples[7] = texture2D(t, uvSamples[7]);
    normalSamples[8] = texture2D(t, uvSamples[8]);

    float depthBias = 0.0001;
    // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?!
    if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }


    if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {
        float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;
        if (gl_FragCoord.z > depthAtSample) {
           return 0.0;
        }
    }

    vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);
  	vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);

    float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
    return edgeNormal;
}
`);return{outline:new Ee(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {
                vec3 result = outlineColor;
                float resultAlpha = 0.0;

                vec3 N = normalize(vWNormal);
                vec2 nuv = (gl_FragCoord.xy / resolution);
                float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);
                resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);

                //resultAlpha = 1.0;
                //result = vec3(sobelSample);

                float t = 1.0 - contourThreshold;
                if(positionalLines) {
                    vec3 NDir = position * contourDirection;
                    float NT = NDir.x + NDir.y + NDir.z;
                    float f  = fract(NT * contourFrequency * 0.01);
                    float df = fwidth(NT * contourFrequency);

                    float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);
                    if (g < 1.0 && resultAlpha == 0.0) {
                        result = contourColor;
                        resultAlpha = 1.0;
                    }
                 }
                 else {
                    vec3 NDir = N * contourDirection;
                    float NT = NDir.x + NDir.y + NDir.z;
                    float df = fwidth(NT * contourThreshold);
                    float f = sin(NT * 1.0 * contourFrequency);
                    float g = smoothstep(0.0, df * contourWidth, 1.0 - f);

                    if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {
                        result = contourColor;
                        resultAlpha = 1.0 - g;
                    }
                 }

                 float lalpha = alpha * resultAlpha * mask;
                 calpha =  lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
                 accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
				 
                 return result;
             }`,[e])}}();var Fo=class extends tt{constructor(e,r,i,s,o,a,l,c,u,h,d,f,p,m,g,y,v,x){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=i,this.blending=s,this.offset=o,this.colorA=a,this.colorB=l,this.frequency=c,this.size=u,this.variation=h,this.smoothness=d,this.zigzag=f,this.rotation=p,this.vertical=m,this.horizontal=g,this.sides=y,this.isMask=x,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let i;switch(this.style.value){case 0:i="circle";break;case 1:i="ring";break;case 2:i="polygon";break;case 3:i="xcross";break;case 4:i="diamond";break;case 5:i="checkerboard";break;case 6:i="line";break;case 7:i="wave";break;default:i="circle";break}let s=`g${this.uuid.toString().replace(/-/g,"")}`,o=new Ee(`float hashwithoutsine12(vec2 p)
				{
					vec3 p3 = fract(vec3(p.xyx) * .1031);
					p3 += dot(p3, p3.yzx + 33.33);
					return fract((p3.x + p3.y) * p3.z);
				}`),a=new Ee(`vec2 rotate_uv(in vec2 uv, float a, bool repeat) 
				{
					const float mid = 0.5;
					float radians = a * (PI / 180.0);
					vec2 rotated = vec2(
						cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,
						cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid
					);
					return repeat ? fract(rotated): rotated;
				}`),l="";if(this.projection.value===4){let d=this.style.value===2?`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f=this.style.value===2?`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,p=this.style.value===2?`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;l=`
				vec3 p = position;
				float factor = 0.0125;
				vec2 uv0 = fract(p.xy * factor);
				vec2 uv1 = fract(p.zy * factor);
				vec2 uv2 = fract(p.xz * factor);
				
				uv0 = rotate_uv(uv0 + offset, rotation, true);
				uv1 = rotate_uv(uv1 + offset, rotation, true);
				uv2 = rotate_uv(uv2 + offset, rotation, true);
	
				float d0 = ${d};
				float d1 = ${f};
				float d2 = ${p};
				
				// Range from 3 to 128 seems to be good
				float exponent = (1.0 - blending) * 125.0 + 3.0;

				vec3 n = vObjectNormal;
				vec3 weights = abs(normalize(n));
				weights = pow(weights, vec3(exponent));
				weights /= dot(weights, vec3(1.0));
				d0 *= weights.z;
				d1 *= weights.x;
				d2 *= weights.y;
				float draw = d0 + d1 + d2;
	
				vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;
				`}else{let d=this.style.value===2?`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f="";this.axis.value===0?f=`float radius = length(p);
					float theta = atan(p.y, p.z);
					float phi = acos(p.x / radius);`:this.axis.value===1?f=`float radius = length(p);
					float theta = atan(p.x, p.z);
					float phi = acos(p.y / radius);`:(this.axis.value,f=`float radius = length(p);
					float theta = atan(p.y, p.x);
					float phi = acos(p.z / radius);`);let p="";switch(this.projection.value){case 0:p="custom_uv = vUv.st;";break;case 1:break;case 2:p=`
							vec3 p = position;
							${f}
							custom_uv = vec2(theta, phi);
							custom_uv /= PI;
							`;break;case 3:break;default:break}l=`
				vec2 custom_uv;
				${p}
	
				custom_uv += offset;
				custom_uv = fract(custom_uv);
				custom_uv = rotate_uv(custom_uv, rotation, true);
	
				float draw = ${d};
				`}let c=new Ee(`vec3 ${s}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
					const float TWO_PI = PI * 2.0;
					float smoothness_remapped = pow(smoothness, 5.0);	

					${l}

					// Construct final output color
					vec4 color = mix(colorA, colorB, draw);
					color.a = clamp(color.a, 0.0, 1.0);

					// Apply cuts
					color.a *= 
						step(vertical.x, custom_uv.y) * 
						step(custom_uv.y, vertical.y);
					color.a *= 
						step(horizontal.x, abs(custom_uv.x)) * 
						step(abs(custom_uv.x), horizontal.y);

					// Accumulate alpha 
					float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;
					calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
					accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

					return clamp(color, 0.0, 1.0).rgb;
				}`,[a,o,Fo.DrawFunctions.circle,Fo.DrawFunctions.ring,Fo.DrawFunctions.polygon,Fo.DrawFunctions.cross,Fo.DrawFunctions.diamond,Fo.DrawFunctions.checkerboard,Fo.DrawFunctions.line,Fo.DrawFunctions.wave]),u=e.include(c),h=[];return h.push("normal"),h.push(this.blending.build(e,"f")),h.push(this.style.build(e,"i")),h.push(this.offset.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.frequency.build(e,"v2")),h.push(this.size.build(e,"f")),h.push(this.variation.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.zigzag.build(e,"f")),h.push(this.rotation.build(e,"f")),h.push(this.vertical.build(e,"v2")),h.push(this.horizontal.build(e,"v2")),h.push(this.sides.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(u+"("+h.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},Zd=Fo;Zd.DrawFunctions=function(){let e=new Ee(`float hashwithoutsine12(vec2 p) {
				vec3 p3 = fract(vec3(p.xyx) * 0.1031);
				p3 += dot(p3, p3.yzx + 33.33);
				return fract((p3.x + p3.y) * p3.z);
			}`),r=new Ee(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
                // Create tiles in UV-space
                uv *= frequency;

                // Integer coords
                vec2 i = floor(uv);

                // Offset every other row based on zigzag param, then compute fractional coords
                float row_offset = mod(i.y, 2.0);
                uv.x += row_offset * zigzag;
                vec2 f = fract(uv);

				// Rotate the tile itself:
				// const float mid = 0.5;
				// f = vec2(
				// 	cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid,
				// 	cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid
				// );
				// f = fract(f);

                f = f * 2.0 - 1.0;

				// Recompute integer coords after shifting - then, random value per tile 
				i = floor(uv);
				float rand = (hashwithoutsine12(i) * 5.0 + 1.0);
				float jitter = mix(1.0, rand, variation);
				f *= jitter;

                return f;
            }`,[e]),i=new Ee(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
                return smoothstep(
                    -smoothness, 
                     smoothness, 
                     length(f) - size
                );
            }`,[r]),s=new Ee(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);

				float d = length(f);
                const float inner_width = 0.5;

                float outer = smoothstep(-smoothness, smoothness, d - size);
                float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
				return outer + (1.0 - inner);   
            }`,[r]),o=new Ee(`float sdf_ngon(in vec2 p, in float r, in int n) {
                float an = (PI * 2.0) / float(n);
                float he = r * tan(0.5 * an);
                
                // Rotate to first sector
                p = -p.yx; 
                float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);
                vec2  cs = vec2(cos(bn), sin(bn));
                p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;
            
                // Side of polygon
                return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);
            }
            
            float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {
                vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
                return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
            }`,[r]),a=new Ee(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
                p = abs(p); 
				p = (p.y > p.x) ? p.yx : p.xy;
                vec2  q = p - b;
                float k = max(q.y, q.x);
                vec2  w = (k > 0.0) ? q : vec2(b.y - p.x, -k);
                return sign(k) * length(max(w, 0.0)) + r;
            }
            
            // Avoid namespace conflicts 
            float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
                return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
            }`,[r]),l=new Ee(`float ndot(vec2 a, vec2 b) { 
                return a.x*b.x - a.y*b.y; 
            }
            
            float sdf_diamond(in vec2 p, in vec2 b) {
                p = abs(p);
                float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);
                float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));
                return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);
            }

            float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
	            return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
            }`,[r]),c=new Ee(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                uv *= frequency;
                vec2 i = floor(uv);

                float offset = mod(i.y, 2.0);

                uv.x += offset + zigzag * offset;
                float x = floor(uv.x);
                
                return mod(x, 2.0);
            }`),u=new Ee(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
				
				// Different approach for variation param here
				float row = floor(uv * frequency).y;
				float rand = hashwithoutsine12(vec2(row));
				float s = mix(size, size * rand, variation);

				return smoothstep(
					s - smoothness, 
					s + smoothness, 
					abs(f.y)
				);
            }`,[r]),h=new Ee(`// Uses bisection 
            float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
                // Convert all data to a primitive cosine wave
                p = c * (p - vec2(d, a));
                
                const float TWO_PI = PI * 2.0;

                // Reduce to principal half cycle
                p.x = mod(p.x, TWO_PI); 
                if (p.x > PI) {
                    p.x = TWO_PI - p.x;
                }
            
                // Find zero of derivative (minimize distance)
                float xa = 0.0;
                float xb = TWO_PI;

                // 24 bit precision
                for (int i = 0; i < 24; i++) {
                    float x = 0.5 * (xa + xb);
                    float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));
                    if (y < 0.0) xa = x; 
                    else xb = x;
                }
                float x = 0.5 * (xa + xb);
                
                // Compute distance    
                vec2 q = vec2(x, b * c * cos(x));
                return length(p - q) / c;
            }

            float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
                float repeat = frequency.x;
                uv *= repeat;
                vec2 i = floor(uv);
                float row_offset = mod(i.y, 2.0);
                uv.x += row_offset * zigzag;
                vec2 f = vec2(uv.x, fract(uv.y));

                // Generalized cosine: y(x) = a + b * cos(cx + d)
                const float amplitude = 0.125;
                float wave_frequency = frequency.y * 0.1;
                float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);

				// Different approach for variation param here
				float rand = hashwithoutsine12(vec2(i.y));
				float s = mix(size, size * rand, variation);

                return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
            }`);return{tileAndCenter:r,circle:i,ring:s,polygon:o,cross:a,diamond:l,checkerboard:c,line:u,wave:h}}();var dE=class extends tt{constructor(e,r,i,s,o,a,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=i,this.noiseStrength=s,this.noiseScale=o,this.offset=a,this.isMask=c,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(dE.Nodes.rainbow),s=[];return s.push(this.filmThickness.build(e,"f")),s.push(this.movement.build(e,"f")),s.push(this.wavelengths.build(e,"v3")),s.push(this.noiseStrength.build(e,"f")),s.push(this.noiseScale.build(e,"f")),s.push(this.offset.build(e,"v3")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Jd=dE;Jd.Nodes=function(){let e=new Ee(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
                 vec3 st = position / noiseScale;
				 vec3 q = vec3(simplex3d(st),
							  simplex3d(st + vec3(1.0)),
							  simplex3d(st + vec3(1.0)));

				 vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
							  simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
							  simplex3d(st * q));

                 float noise = simplex3d(st + r);

                 return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
             }`,[zi.simplex]);return{rainbow:new Ee(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
				vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);

				float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);

				float lalpha = alpha * rainbowContribution * mask;
				calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
				accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));

				return res;
             }`,[e])}}();var fE=class extends tt{constructor(e,r,i,s,o,a,l,c,u,h){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=i,this.source=s,this.isWorldSpace=o,this.noiseStrength=a,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let i=e.include(fE.Nodes.toon),s=[];return s.push(this.positioning.build(e,"i")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.source.build(e,"v3")),s.push(this.isWorldSpace.build(e,"b")),s.push(this.noiseStrength.build(e,"f")),s.push(this.noiseScale.build(e,"f")),s.push(this.shadowColor.build(e,"v4")),s.push(this.offset.build(e,"v3")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},$d=fE;$d.Nodes=function(){let e=new Ee(`float rand(float n) {
				return fract(sin(n) * 43758.5453123);
			}`),r=new Ee(`float hash1(float p) { 
				p = fract(p * 0.011); 
				p *= p + 7.5; 
				p *= p + p; 
				return fract(p); 
			}`),i=new Ee(`float valueNoise(vec3 x) {
				const vec3 step = vec3(110, 241, 171);
			
				vec3 i = floor(x);
				vec3 f = fract(x);
			 
				// For performance, compute the base input to a 1D hash from the integer part of the argument and the 
				// incremental change to the 1D based on the 3D -> 1D wrapping
				float n = dot(i, step);
			
				vec3 u = f * f * (3.0 - 2.0 * f);
				return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
							   mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
						   mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
							   mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
			}`,[r]),s=new Ee(`vec3 hash3(vec3 x) {
				x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
						 dot(x,vec3(269.5, 183.3, 246.1)),
						 dot(x,vec3(113.5, 271.9, 124.6)));
			
				return fract(sin(x)*43758.5453123);
			}`),o=new Ee(`vec3 voronoiNoise(in vec3 x)
			{
				vec3 p = floor(x);
				vec3 f = fract(x);

				float id = 0.0;
				vec2 res = vec2(100.0);

				for(int k=-1; k<=1; k++)
				for(int j=-1; j<=1; j++)
				for(int i=-1; i<=1; i++)
				{
					vec3 b = vec3(float(i), float(j), float(k));

					// Comment out the "+ hash(p + b);" part below to get "square" cells
					vec3 r = vec3(b) - f + hash3(p + b);
					float d = dot(r, r);

					if (d < res.x)
					{
						id = dot(p + b, vec3(1.0, 57.0, 113.0));
						res = vec2(d, res.x);			
					}
					else if (d < res.y)
					{
						res.y = d;
					}
				}

				return vec3(sqrt(res), abs(id));
			}
			`,[s]);return{toon:new Ee(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {
				float t = 0.0;
				float shadow = 1.0;

				if (positioning == 0) {

					// Can't do this mode if lighting is "none"
					#if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))

						// Algorithm from Chapter 10 of Graphics Shaders
						const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
						vec3 lpos;
						vec3 l;
						float dproduct;

						#if (NUM_POINT_LIGHTS > 0)

							#if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
								PointLightShadow pointLightShadow;
							#endif 

							#pragma unroll_loop_start
							for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
								// Light positions are in view-space for some reason?
								lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
								l = normalize(lpos - worldPosition);
								
								dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
								
								// TODO: we want to use "intensity" but it isn't available in the shader code
								//dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);

								t = max(t, dproduct);

								// Accumulate shadow contribution
								#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
									pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
									shadow *= getPointShadow( 
											pointShadowMap[UNROLLED_LOOP_INDEX], 
											pointLightShadow.shadowMapSize, 
											pointLightShadow.shadowBias, 
											pointLightShadow.shadowRadius,
											vPointShadowCoord[UNROLLED_LOOP_INDEX], 
											pointLightShadow.shadowCameraNear, 
											pointLightShadow.shadowCameraFar);
								#endif
							}
							#pragma unroll_loop_end

						#endif

						#if NUM_DIR_LIGHTS > 0 
							
							#if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
								DirectionalLightShadow directionalLightShadow;
							#endif 

							#pragma unroll_loop_start
							for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
								// Use the direction vector for directional lights instead
								l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
		
								dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
								t = max(t, dproduct);

								// Accumulate shadow contribution
								#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
									directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
									shadow *= getShadow( 
										UNROLLED_LOOP_INDEX,
										directionalShadowMap[UNROLLED_LOOP_INDEX], 
										directionalLightShadow.shadowMapSize, 
										directionalLightShadow.shadowBias, 
										directionalLightShadow.shadowRadius, 
										vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
								#endif
							}
							#pragma unroll_loop_end

						#endif

						#if NUM_SPOT_LIGHTS > 0 
							
							#if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
								SpotLightShadow spotLightShadow;
							#endif 

							#pragma unroll_loop_start
							for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
								lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
								l = normalize(lpos - worldPosition);
								
								dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
								t = max(t, dproduct);

								// Accumulate shadow contribution
								#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
									spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
									shadow *= getShadow(
										UNROLLED_LOOP_INDEX,
										spotShadowMap[UNROLLED_LOOP_INDEX], 
										spotLightShadow.shadowMapSize, 
										spotLightShadow.shadowBias, 
										spotLightShadow.shadowRadius, 
										vSpotLightCoord[UNROLLED_LOOP_INDEX]);
								#endif
							}
							#pragma unroll_loop_end

						#endif

						t = clamp(t, 0.0, 1.0);
				
					#endif

				} else if (positioning == 1) {
					
					vec3 origin = mix(position, worldPosition, float(isWorldSpace));
					vec3 direction = normalize(source - origin);
					t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;	

				} else {

					vec3 origin = worldPosition;
					vec3 source = cameraPosition - offset;
					vec3 direction = normalize(source - origin);
					t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;	
					
				}

				if (noiseStrength > 0.0) {
					// Distort with noise
					vec3 st = position / noiseScale;
					
					// Voronoi "smooth" noise
					float noise = 1.0 - voronoiNoise(st).x;

					// Voronoi cellular noise
					//float noise = 1.0 - rand(voronoiNoise(st).z);

					// Position warp noise
					// vec3 offset = vec3(
					// 	simplex3d(st),
					// 	simplex3d(st + vec3(111.1, 143.89, 217.19)),
					// 	simplex3d(st + vec3(171.1, 247.89, 117.23))
					// );
					// st += offset;
					// float noise = valueNoise(st);

					t += noise * noiseStrength;
				}

				t = clamp(t, 0.0, 1.0);

				// Compute ramp color
				float p;
				vec4 color = colors[0];
				for (int i = 1; i < COLORS_MAX; i++) {
					p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
					color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
				}

				// Incorporate custom shadow color
				if (positioning == 0) {

					vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
					color.rgb = mix(blendedShadow, color.rgb, shadow);
				
				}

				// Accumulate alpha as usual
				float lalpha = alpha * color.a * mask;
				calpha =  lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
				accumAlpha += (1.0 - accumAlpha) * lalpha;

				return color.xyz;

            }`,[zi.simplex,e,i,o])}}();var IR=function(){return{textureBicubic:new Ee(`float w0( float a ) {
            return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
        }
    
        float w1( float a ) {
            return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
        }
    
        float w2( float a ){
            return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
        }
    
        float w3( float a ) {
            return ( 1.0 / 6.0 ) * ( a * a * a );
        }
    
        // g0 and g1 are the two amplitude functions
        float g0( float a ) {
            return w0( a ) + w1( a );
        }
    
        float g1( float a ) {
            return w2( a ) + w3( a );
        }
    
        // h0 and h1 are the two offset functions
        float h0( float a ) {
            return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
        }
    
        float h1( float a ) {
            return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
        }
    
        vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
            uv = uv * texelSize.zw + 0.5;
    
            vec2 iuv = floor( uv );
            vec2 fuv = fract( uv );
    
            float g0x = g0( fuv.x );
            float g1x = g1( fuv.x );
            float h0x = h0( fuv.x );
            float h1x = h1( fuv.x );
            float h0y = h0( fuv.y );
            float h1y = h1( fuv.y );
    
            vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
            vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
            vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
            vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
    
            return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + 
                   g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
        }

        vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
            vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
            vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
            vec2 fLodSizeInv = 1.0 / fLodSize;
            vec2 cLodSizeInv = 1.0 / cLodSize;
            vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
            vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
            return mix( fSample, cSample, fract( lod ) );
        }`)}}();function DR(n,t){return n>=t?new k(t/n,1):new k(1,n/t)}var pE=class extends tt{constructor(e,r,i,s,o,a,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=i,this.transmissionSamplerSize=s,this.transmissionSamplerMap=o,this.transmissionDepthMap=a,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,$e.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let i=e.include(pE.Nodes.transmission),s=[];return s.push(this.thickness.build(e,"f")),s.push(this.ior.build(e,"f")),s.push(this.roughness.build(e,"f")),s.push(this.transmissionSamplerSize.build(e,"v2")),s.push(this.transmissionSamplerMap.getTexture(e,"t")),s.push(this.transmissionDepthMap.getTexture(e,"t")),s.push(this.aspectRatio.build(e,"v2")),s.push("normal"),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ef=pE;ef.Nodes=function(){let e=new Ee(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
                // Slightly modified version of this:
                // https://www.shadertoy.com/view/ltScRG

				// Special case for blur == 0.0
				if (lod == 0.0) {
					#ifdef TEXTURE_LOD_EXT
					return texture2DLodEXT( sp, U, 0.0).rgb;
					#else
					return textureLod( sp, U, 0.0).rgb;
					#endif
				}
				
				vec2 texelSize = vec2(1.0) / resolution;
                vec2 halton = haltonSequence[frameIndex];
                float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
                float temporalAngle  = temporalOffset * PI2;
				vec3 res = vec3(0.0);
                vec2 uv = vec2(0.0);
                vec2 offset = vec2(0.0);
                vec2 vogelSample = vec2(0.0);
                for (int i = 0; i < NUM_SAMPLES; i++) {
                    vogelSample =  vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;
                    offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20
                    uv = U + offset;
                    float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));
                    if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {
                        uv = unrefractedU;
                        lod = lod > 4.0 ? lod : lod / 2.0;
                    }
                    res += textureLod(sp, uv, lod).rgb;
                }
                return res / float(NUM_SAMPLES);
            }`),r=new Ee(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
		        // Direction of refracted light.
		        vec3 refractionVector = refract( -v,  n, 1.0 / ior );
		        
				// Compute rotation-independant scaling of the model matrix.
		        vec3 modelScale;
		        modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		        modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		        modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );

		        // The thickness is specified in local space
		        return normalize( refractionVector ) * thickness * modelScale;
	        }`),i=new Ee(`float applyIorToRoughness( float roughness, float ior ) {
				// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
				// an IOR of 1.5 results in the default amount of microfacet refraction.
				return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
			}`),s=new Ee(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
				// Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see
				// also the code in convertTransmission.ts, which runs during export
				#ifdef IS_THREEJS_EXPORT
					float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);
					return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;
				#else
					float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
					float lod = applyIorToRoughness(roughness, ior);
					return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
				#endif
			}`,[IR.textureBicubic,i,e]),o=new Ee(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;

				// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
				vec4 ndcPos = projMatrix * viewMatrix *  vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;

				vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );
				vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;
				unrefractedCoords += 1.0;
				unrefractedCoords /= 2.0;

				// Sample framebuffer to get pixel the refracted ray hits.
				return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
    		}`,[s,r]);return{transmission:new Ee(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
                vec3 v = vec3(0.);
                if (isOrthographic) {
                    v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
                } else {
                    v = normalize(vWPosition - cameraPosition);
                }
                vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness,  vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );
                
				float lalpha = alpha * mask;
				calpha =  lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
				accumAlpha += ( 1.0 - accumAlpha ) * alpha;

				return transmission;
            }`,[o])}}();var mE=(e=>(e.NOISE="noise",e.MAP="map",e))(mE||{}),gE=class extends tt{constructor(e,r,i,s,o,a,l,c,u,h,d){super("v3");this.displacementTypeIndex=new Dt(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(mE)[this.displacementTypeIndex.value]==="map"&&(this.mat=new zd(this.movementOrTexture.value.matrix)),this.cropOrOffset=i,this.scale=h,this.noiseFunctionIndex=d,this.voronoiStyle=s,this.smoothness=o,this.seed=a,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let i,s=[];switch(s.push("displaced_position"),s.push("displaced_normal"),Object.values(mE)[this.displacementTypeIndex.value]){case"map":{i=e.include(gE.Nodes.map),s.push(this.movementOrTexture.getTexture(e,"t")),s.push("uv"),s.push(this.cropOrOffset.build(e,"f")),this.mat&&s.push(this.mat.build(e,"mat3"));break}case"noise":{let a=Object.values(Sm)[this.noiseFunctionIndex.value],l=new Ee(`vec3 orthogonal(vec3 v) {
							return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
						}`),c=a=="voronoi"?`
					float v = ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
					v = remap(v, lowCut, highCut, 0.0, 1.0);
					v = smax(v, 0.0, smoothness * 0.25);
					v = smin(v, 1.0, smoothness * 0.25);

					return p + n * v * intensity;
					`:`
					return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
					`,u=new Ee(`vec3 distorted(vec3 p, vec3 n,