(function(Gn,si){typeof exports=="object"&&typeof module<"u"?si(exports):typeof define=="function"&&define.amd?define(["exports"],si):(Gn=typeof globalThis<"u"?globalThis:Gn||self,si(Gn.FloragComponents={}))})(this,function(Gn){"use strict";var UZ=Object.defineProperty;var cU=Gn=>{throw TypeError(Gn)};var kZ=(Gn,si,Tr)=>si in Gn?UZ(Gn,si,{enumerable:!0,configurable:!0,writable:!0,value:Tr}):Gn[si]=Tr;var ht=(Gn,si,Tr)=>kZ(Gn,typeof si!="symbol"?si+"":si,Tr),uU=(Gn,si,Tr)=>si.has(Gn)||cU("Cannot "+Tr);var zr=(Gn,si,Tr)=>(uU(Gn,si,"read from private field"),Tr?Tr.call(Gn):si.get(Gn)),_y=(Gn,si,Tr)=>si.has(Gn)?cU("Cannot add the same private member more than once"):si instanceof WeakSet?si.add(Gn):si.set(Gn,Tr),yM=(Gn,si,Tr,yy)=>(uU(Gn,si,"write to private field"),yy?yy.call(Gn,Tr):si.set(Gn,Tr),Tr);var Da,co,nm;const Ba=Symbol("$state"),xy=Symbol("legacy props"),by=!1;var xM=Array.isArray,hU=Array.prototype.indexOf,dU=Array.from,xm=Object.keys,Nd=Object.defineProperty,Io=Object.getOwnPropertyDescriptor,bM=Object.getOwnPropertyDescriptors,fU=Object.prototype,pU=Array.prototype,wy=Object.getPrototypeOf;function Bd(s){return typeof s=="function"}const Nt=()=>{};function mU(s){return s()}function bm(s){for(var e=0;efe(s))),e}function Mn(s,e){return qn!==null&&!fo&&Sm()&&qn.f&18&&(Lo===null||!Lo.includes(s))&&TU(),NU(s,e)}function NU(s,e){return s.equals(e)||(s.v,s.v=e,s.wv=XM(),LM(s,2048),Sm()&&Zn!==null&&Zn.f&1024&&!(Zn.f&96)&&(sa===null?XU([s]):sa.push(s))),e}function LM(s,e){var t=s.reactions;if(t!==null)for(var i=Sm(),n=t.length,r=0;r=_.v&&Mn(_,y+1)}OM(o)}return!0},ownKeys(l){fe(o);var c=Reflect.ownKeys(l).filter(d=>{var f=n.get(d);return f===void 0||f.v!==rs});for(var[u,h]of n)h.v!==rs&&!(u in l)&&c.push(u);return c},setPrototypeOf(){MU()}})}function OM(s,e=1){Mn(s,s.v+e)}var FM,NM,BM,zM;function Ay(){if(FM===void 0){FM=window,NM=/Firefox/.test(navigator.userAgent);var s=Element.prototype,e=Node.prototype;BM=Io(e,"firstChild").get,zM=Io(e,"nextSibling").get,s.__click=void 0,s.__className="",s.__attributes=null,s.__styles=null,s.__e=void 0,Text.prototype.__t=void 0}}function Vd(s=""){return document.createTextNode(s)}function Zl(s){return BM.call(s)}function Kl(s){return zM.call(s)}function $l(s,e){if(!Nn)return Zl(s);var t=Zl(oi);return t===null&&(t=oi.appendChild(Vd())),ra(t),t}function dt(s,e){if(!Nn){var t=Zl(s);return t instanceof Comment&&t.data===""?Kl(t):t}return oi}function Ln(s,e=1,t=!1){let i=Nn?oi:s;for(var n;e--;)n=i,i=Kl(i);if(!Nn)return i;var r=i==null?void 0:i.nodeType;if(t&&r!==3){var o=Vd();return i===null?n==null||n.after(o):i.before(o),ra(o),o}return ra(i),i}function GU(s){s.textContent=""}const VM=0,HU=1;let Tm=!1,Am=VM,Gd=!1,Hd=null,Bu=!1,Cy=!1;function GM(s){Bu=s}function HM(s){Cy=s}let Jl=[],zu=0,JZ=[],qn=null,fo=!1;function Vu(s){qn=s}let Zn=null;function Gu(s){Zn=s}let Lo=null;function WU(s){Lo=s}let Vr=null,bs=0,sa=null;function XU(s){sa=s}let WM=1,Cm=0,Va=!1;function XM(){return++WM}function Hu(s){var h;var e=s.f;if(e&2048)return!0;if(e&4096){var t=s.deps,i=(e&256)!==0;if(t!==null){var n,r,o=(e&512)!==0,a=i&&Zn!==null&&!Va,l=t.length;if(o||a){var c=s,u=c.parent;for(n=0;ns.wv)return!0}(!i||Zn!==null&&!Va)&&po(s,1024)}return!1}function YU(s,e){for(var t=e;t!==null;){if(t.f&128)try{t.fn(s);return}catch{t.f^=128}t=t.parent}throw Tm=!1,s}function jU(s){return(s.f&16384)===0&&(s.parent===null||(s.parent.f&128)===0)}function Pm(s,e,t,i){if(Tm){if(t===null&&(Tm=!1),jU(e))throw s;return}t!==null&&(Tm=!0);{YU(s,e);return}}function YM(s,e,t=!0){var i=s.reactions;if(i!==null)for(var n=0;n0)for(h.length=bs+Vr.length,d=0;d1e3){zu=0;try{xU()}catch(s){if(Hd!==null)Pm(s,Hd,null);else throw s}}zu++}function ZM(s){var e=s.length;if(e!==0){qM();var t=Bu;Bu=!0;try{for(var i=0;i1001)return;const s=Jl;Jl=[],ZM(s),Gd||(zu=0,Hd=null)}function Im(s){Am===VM&&(Gd||(Gd=!0,queueMicrotask(KU))),Hd=s;for(var e=s;e.parent!==null;){e=e.parent;var t=e.f;if(t&96){if(!(t&1024))return;e.f^=1024}}Jl.push(e)}function $U(s){var e=[],t=s.first;e:for(;t!==null;){var i=t.f,n=(i&32)!==0,r=n&&(i&1024)!==0,o=t.next;if(!r&&!(i&8192)){if(i&4)e.push(t);else if(n)t.f^=1024;else{var a=qn;try{qn=t,Hu(t)&&Dm(t)}catch(u){Pm(u,t,null,t.ctx)}finally{qn=a}}var l=t.first;if(l!==null){t=l;continue}}if(o===null){let u=t.parent;for(;u!==null;){if(s===u)break e;var c=u.next;if(c!==null){t=c;continue e}u=u.parent}}t=o}return e}function V(s){var e=Am,t=Jl;try{qM();const n=[];Am=HU,Jl=n,Gd=!1,ZM(t);var i=s==null?void 0:s();return gU(),(Jl.length>0||n.length>0)&&V(),zu=0,Hd=null,i}finally{Am=e,Jl=t}}async function Py(){await Promise.resolve(),V()}function fe(s){var e=s.f,t=(e&2)!==0;if(qn!==null&&!fo){Lo!==null&&Lo.includes(s)&&EU();var i=qn.deps;s.rv{Uo(e)}}function tk(s){const e=Ql(64,s,!0);return(t={})=>new Promise(i=>{t.outro?Xd(e,()=>{Uo(e),i(void 0)}):(Uo(e),i(void 0))})}function Lm(s){return Ql(4,s,!1)}function Ga(s,e){var t=In,i={effect:null,ran:!1};t.l.r1.push(i),i.effect=Xu(()=>{s(),!i.ran&&(i.ran=!0,Mn(t.l.r2,!0),ws(e))})}function Dy(){var s=In;Xu(()=>{if(fe(s.l.r2)){for(var e of s.l.r1){var t=e.effect;t.f&1024&&po(t,4096),Hu(t)&&Dm(t),e.ran=!1}s.l.r2.v=!1}})}function Xu(s){return Ql(8,s,!0)}function Iy(s,e=[],t=xt){const i=e.map(t);return Wd(()=>s(...i.map(fe)))}function Wd(s,e=0){return Ql(24|e,s,!0)}function Yu(s,e=!0){return Ql(40,s,!0,e)}function QM(s){var e=s.teardown;if(e!==null){const t=Cy,i=qn;HM(!0),Vu(null);try{e.call(null)}finally{HM(t),Vu(i)}}}function eE(s,e=!1){var t=s.first;for(s.first=s.last=null;t!==null;){var i=t.next;Uo(t,e),t=i}}function nk(s){for(var e=s.first;e!==null;){var t=e.next;e.f&32||Uo(e),e=t}}function Uo(s,e=!0){var t=!1;if((e||s.f&524288)&&s.nodes_start!==null){for(var i=s.nodes_start,n=s.nodes_end;i!==null;){var r=i===n?null:Kl(i);i.remove(),i=r}t=!0}eE(s,e&&!t),Rm(s,0),po(s,16384);var o=s.transitions;if(o!==null)for(const l of o)l.stop();QM(s);var a=s.parent;a!==null&&a.first!==null&&tE(s),s.next=s.prev=s.teardown=s.ctx=s.deps=s.fn=s.nodes_start=s.nodes_end=null}function tE(s){var e=s.parent,t=s.prev,i=s.next;t!==null&&(t.next=i),i!==null&&(i.prev=t),e!==null&&(e.first===s&&(e.first=i),e.last===s&&(e.last=t))}function Xd(s,e){var t=[];nE(s,t,!0),ik(t,()=>{Uo(s),e&&e()})}function ik(s,e){var t=s.length;if(t>0){var i=()=>--t||e();for(var n of s)n.out(i)}else e()}function nE(s,e,t){if(!(s.f&8192)){if(s.f^=8192,s.transitions!==null)for(const o of s.transitions)(o.is_global||t)&&e.push(o);for(var i=s.first;i!==null;){var n=i.next,r=(i.f&65536)!==0||(i.f&32)!==0;nE(i,e,r?t:!1),i=n}}}function Ly(s){iE(s,!0)}function iE(s,e){if(s.f&8192){s.f^=8192,s.f&1024||(s.f^=1024),Hu(s)&&(po(s,2048),Im(s));for(var t=s.first;t!==null;){var i=t.next,n=(t.f&65536)!==0||(t.f&32)!==0;iE(t,n?e:!1),t=i}if(s.transitions!==null)for(const r of s.transitions)(r.is_global||e)&&r.in()}}const rk=new Set,rE=new Set;function Um(s){var y;var e=this,t=e.ownerDocument,i=s.type,n=((y=s.composedPath)==null?void 0:y.call(s))||[],r=n[0]||s.target,o=0,a=s.__root;if(a){var l=n.indexOf(a);if(l!==-1&&(e===document||e===window)){s.__root=e;return}var c=n.indexOf(e);if(c===-1)return;l<=c&&(o=l)}if(r=n[o]||s.target,r!==e){Nd(s,"currentTarget",{configurable:!0,get(){return r||t}});var u=qn,h=Zn;Vu(null),Gu(null);try{for(var d,f=[];r!==null;){var m=r.assignedSlot||r.parentNode||r.host||null;try{var v=r["__"+i];if(v!==void 0&&!r.disabled)if(xM(v)){var[g,..._]=v;g.apply(r,[s,..._])}else v.call(r,s)}catch(w){d?f.push(w):d=w}if(s.cancelBubble||m===e||m===null)break;r=m}if(d){for(let w of f)queueMicrotask(()=>{throw w});throw d}}finally{s.__root=e,delete s.currentTarget,Vu(u),Gu(h)}}}function sk(s){var e=document.createElement("template");return e.innerHTML=s,e.content}function ec(s,e){var t=Zn;t.nodes_start===null&&(t.nodes_start=s,t.nodes_end=e)}function Kn(s,e){var t=(e&UU)!==0,i=(e&kU)!==0,n,r=!s.startsWith("");return()=>{if(Nn)return ec(oi,null),oi;n===void 0&&(n=sk(r?s:""+s),t||(n=Zl(n)));var o=i||NM?document.importNode(n,!0):n.cloneNode(!0);if(t){var a=Zl(o),l=o.lastChild;ec(a,l)}else ec(o,o);return o}}function Lt(){if(Nn)return ec(oi,null),oi;var s=document.createDocumentFragment(),e=document.createComment(""),t=Vd();return s.append(e,t),ec(e,t),s}function lt(s,e){if(Nn){Zn.nodes_end=oi,jl();return}s!==null&&s.before(e)}const ok=["touchstart","touchmove"];function ak(s){return ok.includes(s)}const lk=["textarea","script","style","title"];function ck(s){return lk.includes(s)}function sE(s,e){return oE(s,e)}function uk(s,e){Ay(),e.intro=e.intro??!1;const t=e.target,i=Nn,n=oi;try{for(var r=Zl(t);r&&(r.nodeType!==8||r.data!==TM);)r=Kl(r);if(!r)throw zd;za(!0),ra(r),jl();const o=oE(s,{...e,anchor:r});if(oi===null||oi.nodeType!==8||oi.data!==CM)throw Ey(),zd;return za(!1),o}catch(o){if(o===zd)return e.recover===!1&&bU(),Ay(),GU(t),za(!1),sE(s,e);throw o}finally{za(i),ra(n)}}const ju=new Map;function oE(s,{target:e,anchor:t,props:i={},events:n,context:r,intro:o=!0}){Ay();var a=new Set,l=h=>{for(var d=0;d{var h=t??e.appendChild(Vd());return Yu(()=>{if(r){Mt({});var d=In;d.c=r}n&&(i.$$events=n),Nn&&ec(h,null),c=s(h,i)||{},Nn&&(Zn.nodes_end=oi),r&&Et()}),()=>{var m;for(var d of a){e.removeEventListener(d,Um);var f=ju.get(d);--f===0?(document.removeEventListener(d,Um),ju.delete(d)):ju.set(d,f)}rE.delete(l),h!==t&&((m=h.parentNode)==null||m.removeChild(h))}});return Uy.set(c,u),c}let Uy=new WeakMap;function hk(s,e){const t=Uy.get(s);return t?(Uy.delete(s),t(e)):Promise.resolve()}function Tt(s){return new dk(s)}class dk{constructor(e){_y(this,Da);_y(this,co);var r;var t=new Map,i=(o,a)=>{var l=Mm(a);return t.set(o,l),l};const n=new Proxy({...e.props||{},$$events:{}},{get(o,a){return fe(t.get(a)??i(a,Reflect.get(o,a)))},has(o,a){return a===xy?!0:(fe(t.get(a)??i(a,Reflect.get(o,a))),Reflect.has(o,a))},set(o,a,l){return Mn(t.get(a)??i(a,l),l),Reflect.set(o,a,l)}});yM(this,co,(e.hydrate?uk:sE)(e.component,{target:e.target,anchor:e.anchor,props:n,context:e.context,intro:e.intro??!1,recover:e.recover})),(!((r=e==null?void 0:e.props)!=null&&r.$$host)||e.sync===!1)&&V(),yM(this,Da,n.$$events);for(const o of Object.keys(zr(this,co)))o==="$set"||o==="$destroy"||o==="$on"||Nd(this,o,{get(){return zr(this,co)[o]},set(a){zr(this,co)[o]=a},enumerable:!0});zr(this,co).$set=o=>{Object.assign(n,o)},zr(this,co).$destroy=()=>{hk(zr(this,co))}}$set(e){zr(this,co).$set(e)}$on(e,t){zr(this,Da)[e]=zr(this,Da)[e]||[];const i=(...n)=>t.call(this,...n);return zr(this,Da)[e].push(i),()=>{zr(this,Da)[e]=zr(this,Da)[e].filter(n=>n!==i)}}$destroy(){zr(this,co).$destroy()}}Da=new WeakMap,co=new WeakMap;const fk="5";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(fk),CU();function wi(s,e,t=!1){Nn&&jl();var i=s,n=null,r=null,o=rs,a=t?65536:0,l=!1;const c=(h,d=!0)=>{l=!0,u(d,h)},u=(h,d)=>{if(o===(o=h))return;let f=!1;if(Nn){const m=i.data===AM;!!o===m&&(i=VU(),ra(i),za(!1),f=!0)}o?(n?Ly(n):d&&(n=Yu(()=>d(i))),r&&Xd(r,()=>{r=null})):(r?Ly(r):d&&(r=Yu(()=>d(i))),n&&Xd(n,()=>{n=null})),f&&za(!0)};Wd(()=>{l=!1,e(c),l||u(null,null)},a),Nn&&(i=oi)}function aE(s,e,t,i,n){var a;Nn&&jl();var r=(a=e.$$slots)==null?void 0:a[t],o=!1;r===!0&&(r=e[t==="default"?"children":t],o=!0),r===void 0||r(s,o?()=>i:i)}function Wt(s,e,...t){var i=s,n=Nt,r;Wd(()=>{n!==(n=e())&&(r&&(Uo(r),r=null),r=Yu(()=>n(i,...t)))},65536),Nn&&(i=oi)}function Ss(s,e,t){Nn&&jl();var i=s,n,r;Wd(()=>{n!==(n=e())&&(r&&(Xd(r),r=null),n&&(r=Yu(()=>t(i,n))))},65536),Nn&&(i=oi)}function pk(s,e,t,i,n,r){let o=Nn;Nn&&jl();var a,l,c=null;Nn&&oi.nodeType===1&&(c=oi,jl());var u=Nn?oi:s,h;Wd(()=>{const d=e()||null;var f=d==="svg"?OU:null;d!==a&&(h&&(d===null?Xd(h,()=>{h=null,l=null}):d===l?Ly(h):Uo(h)),d&&d!==l&&(h=Yu(()=>{if(c=Nn?c:f?document.createElementNS(f,d):document.createElement(d),ec(c,c),i){Nn&&ck(d)&&c.append(document.createComment(""));var m=Nn?Zl(c):c.appendChild(Vd());Nn&&(m===null?za(!1):ra(m)),i(c,m)}Zn.nodes_end=c,u.before(c)})),a=d,a&&(l=a))},65536),o&&(za(!0),ra(u))}function mk(s,e){SM(()=>{var t=s.getRootNode(),i=t.host?t:t.head??t.ownerDocument.head;if(!i.querySelector("#"+e.hash)){const n=document.createElement("style");n.id=e.hash,n.textContent=e.code,i.appendChild(n)}})}function gk(s,e,t){Lm(()=>{var i=ws(()=>e(s,t==null?void 0:t())||{});if(i!=null&&i.destroy)return()=>i.destroy()})}function lE(s){var e,t,i="";if(typeof s=="string"||typeof s=="number")i+=s;else if(typeof s=="object")if(Array.isArray(s)){var n=s.length;for(e=0;eperformance.now(),mo={tick:s=>requestAnimationFrame(s),now:()=>xk(),tasks:new Set};function fE(){const s=mo.now();mo.tasks.forEach(e=>{e.c(s)||(mo.tasks.delete(e),e.f())}),mo.tasks.size!==0&&mo.tick(fE)}function bk(s){let e;return mo.tasks.size===0&&mo.tick(fE),{promise:new Promise(t=>{mo.tasks.add(e={c:s,f:t})}),abort(){mo.tasks.delete(e)}}}function wk(s,e,t){var i=Io(s,e);i&&i.set&&(s[e]=t,JM(()=>{s[e]=null}))}function pE(s,e){return s===e||(s==null?void 0:s[Ba])===e}function qu(s={},e,t,i){return Lm(()=>{var n,r;return Xu(()=>{n=r,r=[],ws(()=>{s!==t(...r)&&(e(s,...r),n&&pE(t(...n),s)&&e(null,...n))})}),()=>{SM(()=>{r&&pE(t(...r),s)&&e(null,...r)})}}),s}function go(s=!1){const e=In,t=e.l.u;if(!t)return;let i=()=>Wu(e.s);if(s){let n=0,r={};const o=xt(()=>{let a=!1;const l=e.s;for(const c in l)l[c]!==r[c]&&(r[c]=l[c],a=!0);return a&&n++,n});i=()=>fe(o)}t.b.length&&$e(()=>{mE(e,i),bm(t.b)}),Ht(()=>{const n=ws(()=>t.m.map(mU));return()=>{for(const r of n)typeof r=="function"&&r()}}),t.a.length&&Ht(()=>{mE(e,i),bm(t.a)})}function mE(s,e){if(s.l.s)for(const t of s.l.s)fe(t);e()}function At(s,e,t){var i;s.$$events||(s.$$events={}),(i=s.$$events)[e]||(i[e]=[]),s.$$events[e].push(t)}function Ct(s){for(var e in s)e in this&&(this[e]=s[e])}function Gr(s){In===null&&Ty(),Nu&&In.l!==null?Sk(In).m.push(s):Ht(()=>{const e=ws(s);if(typeof e=="function")return e})}function Ui(s){In===null&&Ty(),Gr(()=>()=>ws(s))}function Sk(s){var e=s.l;return e.u??(e.u={a:[],b:[],m:[]})}function ky(s,e,t){if(s==null)return e(void 0),t&&t(void 0),Nt;const i=ws(()=>s.subscribe(e,t));return i.unsubscribe?()=>i.unsubscribe():i}const Zu=[];function Yd(s,e){return{subscribe:Hn(s,e).subscribe}}function Hn(s,e=Nt){let t=null;const i=new Set;function n(a){if(EM(s,a)&&(s=a,t)){const l=!Zu.length;for(const c of i)c[1](),Zu.push(c,s);if(l){for(let c=0;c{i.delete(c),i.size===0&&t&&(t(),t=null)}}return{set:n,update:r,subscribe:o}}function Ha(s,e,t){const i=!Array.isArray(s),n=i?[s]:s;if(!n.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const r=e.length<2;return Yd(t,(o,a)=>{let l=!1;const c=[];let u=0,h=Nt;const d=()=>{if(u)return;h();const m=e(i?c[0]:c,o,a);r?o(m):h=typeof m=="function"?m:Nt},f=n.map((m,v)=>ky(m,g=>{c[v]=g,u&=~(1<{u|=1<e=t)(),e}let Om=!1,Oy=Symbol();function Rn(s,e,t){const i=t[e]??(t[e]={store:null,source:Mm(void 0),unsubscribe:Nt});if(i.store!==s&&!(Oy in t))if(i.unsubscribe(),i.store=s??null,s==null)i.source.v=void 0,i.unsubscribe=Nt;else{var n=!0;i.unsubscribe=ky(s,r=>{n?i.source.v=r:Mn(i.source,r)}),n=!1}return s&&Oy in t?km(s):fe(i.source)}function Fy(s,e){return s.set(e),e}function Pi(){const s={};function e(){JM(()=>{for(var t in s)s[t].unsubscribe();Nd(s,Oy,{enumerable:!1,value:!0})})}return[s,e]}function Mk(s){var e=Om;try{return Om=!1,[s(),Om]}finally{Om=e}}const Ek={get(s,e){if(!s.exclude.includes(e))return s.props[e]},set(s,e){return!1},getOwnPropertyDescriptor(s,e){if(!s.exclude.includes(e)&&e in s.props)return{enumerable:!0,configurable:!0,value:s.props[e]}},has(s,e){return s.exclude.includes(e)?!1:e in s.props},ownKeys(s){return Reflect.ownKeys(s.props).filter(e=>!s.exclude.includes(e))}};function an(s,e,t){return new Proxy({props:s,exclude:e},Ek)}const Tk={get(s,e){let t=s.props.length;for(;t--;){let i=s.props[t];if(Bd(i)&&(i=i()),typeof i=="object"&&i!==null&&e in i)return i[e]}},set(s,e,t){let i=s.props.length;for(;i--;){let n=s.props[i];Bd(n)&&(n=n());const r=Io(n,e);if(r&&r.set)return r.set(t),!0}return!1},getOwnPropertyDescriptor(s,e){let t=s.props.length;for(;t--;){let i=s.props[t];if(Bd(i)&&(i=i()),typeof i=="object"&&i!==null&&e in i){const n=Io(i,e);return n&&!n.configurable&&(n.configurable=!0),n}}},has(s,e){if(e===Ba||e===xy)return!1;for(let t of s.props)if(Bd(t)&&(t=t()),t!=null&&e in t)return!0;return!1},ownKeys(s){const e=[];for(let t of s.props){Bd(t)&&(t=t());for(const i in t)e.includes(i)||e.push(i)}return e}};function rn(...s){return new Proxy({props:s},Tk)}function H(s,e,t,i){var C;var n=(t&PU)!==0,r=!Nu||(t&RU)!==0,o=(t&IU)!==0,a=(t&LU)!==0,l=!1,c;o?[c,l]=Mk(()=>s[e]):c=s[e];var u=Ba in s||xy in s,h=o&&(((C=Io(s,e))==null?void 0:C.set)??(u&&e in s&&(T=>s[e]=T)))||void 0,d=i,f=!0,m=!1,v=()=>(m=!0,f&&(f=!1,a?d=ws(i):d=i),d);c===void 0&&i!==void 0&&(h&&r&&wU(),c=v(),h&&h(c));var g;if(r)g=()=>{var T=s[e];return T===void 0?v():(f=!0,m=!1,T)};else{var _=(n?xt:Em)(()=>s[e]);_.f|=131072,g=()=>{var T=fe(_);return T!==void 0&&(d=void 0),T===void 0?d:T}}if(!(t&DU))return g;if(h){var y=s.$$legacy;return function(T,A){return arguments.length>0?((!r||!A||y||l)&&h(A?g():T),T):g()}}var w=!1,x=Mm(c),M=xt(()=>{var T=g(),A=fe(x);return w?(w=!1,A):x.v=T});return n||(M.equals=My),function(T,A){if(arguments.length>0){const P=A?fe(M):r&&o?hr(T):T;return M.equals(P)||(w=!0,Mn(x,P),m&&d!==void 0&&(d=P),ws(()=>fe(M))),T}return fe(M)}}let gE;typeof HTMLElement=="function"&&(gE=class extends HTMLElement{constructor(e,t,i){super();ht(this,"$$ctor");ht(this,"$$s");ht(this,"$$c");ht(this,"$$cn",!1);ht(this,"$$d",{});ht(this,"$$r",!1);ht(this,"$$p_d",{});ht(this,"$$l",{});ht(this,"$$l_u",new Map);ht(this,"$$me");this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const n=this.$$c.$on(e,t);this.$$l_u.set(t,n)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const n=this.$$l_u.get(t);n&&(n(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(n){return r=>{const o=document.createElement("slot");n!=="default"&&(o.name=n),lt(r,o)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Ak(this);for(const n of this.$$s)n in i&&(n==="default"&&!this.$$d.children?(this.$$d.children=e(n),t.default=!0):t[n]=e(n));for(const n of this.attributes){const r=this.$$g_p(n.name);r in this.$$d||(this.$$d[r]=Fm(r,n.value,this.$$p_d,"toProp"))}for(const n in this.$$p_d)!(n in this.$$d)&&this[n]!==void 0&&(this.$$d[n]=this[n],delete this[n]);this.$$c=Tt({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=ek(()=>{Xu(()=>{var n;this.$$r=!0;for(const r of xm(this.$$c)){if(!((n=this.$$p_d[r])!=null&&n.reflect))continue;this.$$d[r]=this.$$c[r];const o=Fm(r,this.$$d[r],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,o)}this.$$r=!1})});for(const n in this.$$l)for(const r of this.$$l[n]){const o=this.$$c.$on(n,r);this.$$l_u.set(r,o)}this.$$l={}}}attributeChangedCallback(e,t,i){var n;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Fm(e,i,this.$$p_d,"toProp"),(n=this.$$c)==null||n.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return xm(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Fm(s,e,t,i){var r;const n=(r=t[s])==null?void 0:r.type;if(e=n==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[s])return e;if(i==="toAttribute")switch(n){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(n){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Ak(s){const e={};return s.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}function Pt(s,e,t,i,n,r){let o=class extends gE{constructor(){super(s,t,n),this.$$p_d=e}static get observedAttributes(){return xm(e).map(a=>(e[a].attribute||a).toLowerCase())}};return xm(e).forEach(a=>{Nd(o.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(l){var h;l=Fm(a,l,e),this.$$d[a]=l;var c=this.$$c;if(c){var u=(h=Io(c,a))==null?void 0:h.get;u?c[a]=l:c.$set({[a]:l})}}})}),i.forEach(a=>{Nd(o.prototype,a,{get(){var l;return(l=this.$$c)==null?void 0:l[a]}})}),s.element=o,o}(function(){function s(){for(var i=arguments.length,n=0;n"u"||!(Symbol.iterator in Object(s)))){var t=[],i=!0,n=!1,r=void 0;try{for(var o=s[Symbol.iterator](),a;!(i=(a=o.next()).done)&&(t.push(a.value),!(e&&t.length===e));i=!0);}catch(l){n=!0,r=l}finally{try{!i&&o.return!=null&&o.return()}finally{if(n)throw r}}return t}}function wE(s,e){if(s){if(typeof s=="string")return Ny(s,e);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Ny(s,e)}}function Ny(s,e){(e==null||e>s.length)&&(e=s.length);for(var t=0,i=new Array(e);t0&&arguments[0]!==void 0?arguments[0]:{},e=tc(s),t;return e.types!==void 0?t=e.types:e.split!==void 0&&(t=e.split),t!==void 0&&(e.types=(jd(t)||By(t)?String(t):"").split(",").map(function(i){return String(i).trim()}).filter(function(i){return/((line)|(word)|(char))/i.test(i)})),(e.absolute||e.position)&&(e.absolute=e.absolute||/absolute/.test(s.position)),e}function zy(s){var e=jd(s)||By(s)?String(s):"";return{none:!e,lines:/line/i.test(e),words:/word/i.test(e),chars:/char/i.test(e)}}function Bm(s){return s!==null&&typeof s=="object"}function Ok(s){return Bm(s)&&/^(1|3|11)$/.test(s.nodeType)}function Fk(s){return typeof s=="number"&&s>-1&&s%1===0}function Nk(s){return Bm(s)&&Fk(s.length)}function nc(s){return By(s)?s:s==null?[]:Nk(s)?Array.prototype.slice.call(s):[s]}function SE(s){var e=s;return jd(s)&&(/^(#[a-z]\w+)$/.test(s.trim())?e=document.getElementById(s.trim().slice(1)):e=document.querySelectorAll(s)),nc(e).reduce(function(t,i){return[].concat(Hr(t),Hr(nc(i).filter(Ok)))},[])}var Bk=Object.entries,zm="_splittype",vo={},zk=0;function ko(s,e,t){if(!Bm(s))return console.warn("[data.set] owner is not an object"),null;var i=s[zm]||(s[zm]=++zk),n=vo[i]||(vo[i]={});return t===void 0?e&&Object.getPrototypeOf(e)===Object.prototype&&(vo[i]=xE(xE({},n),e)):e!==void 0&&(n[e]=t),t}function ic(s,e){var t=Bm(s)?s[zm]:null,i=t&&vo[t]||{};return i}function ME(s){var e=s&&s[zm];e&&(delete s[e],delete vo[e])}function Vk(){Object.keys(vo).forEach(function(s){delete vo[s]})}function Gk(){Bk(vo).forEach(function(s){var e=bE(s,2),t=e[0],i=e[1],n=i.isRoot,r=i.isSplit;(!n||!r)&&(vo[t]=null,delete vo[t])})}function Hk(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:" ",t=s?String(s):"";return t.trim().replace(/\s+/g," ").split(e)}var Vy="\\ud800-\\udfff",EE="\\u0300-\\u036f\\ufe20-\\ufe23",TE="\\u20d0-\\u20f0",AE="\\ufe0e\\ufe0f",Wk="[".concat(Vy,"]"),Gy="[".concat(EE).concat(TE,"]"),Hy="\\ud83c[\\udffb-\\udfff]",Xk="(?:".concat(Gy,"|").concat(Hy,")"),CE="[^".concat(Vy,"]"),PE="(?:\\ud83c[\\udde6-\\uddff]){2}",RE="[\\ud800-\\udbff][\\udc00-\\udfff]",DE="\\u200d",IE="".concat(Xk,"?"),LE="[".concat(AE,"]?"),Yk="(?:"+DE+"(?:"+[CE,PE,RE].join("|")+")"+LE+IE+")*",jk=LE+IE+Yk,qk="(?:".concat(["".concat(CE).concat(Gy,"?"),Gy,PE,RE,Wk].join("|"),` )`),Zk=RegExp("".concat(Hy,"(?=").concat(Hy,")|").concat(qk).concat(jk),"g"),Kk=[DE,Vy,EE,TE,AE],$k=RegExp("[".concat(Kk.join(""),"]"));function Jk(s){return s.split("")}function UE(s){return $k.test(s)}function Qk(s){return s.match(Zk)||[]}function eO(s){return UE(s)?Qk(s):Jk(s)}function tO(s){return s==null?"":String(s)}function nO(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return s=tO(s),s&&jd(s)&&!e&&UE(s)?eO(s):s.split(e)}function Wy(s,e){var t=document.createElement(s);return e&&Object.keys(e).forEach(function(i){var n=e[i],r=jd(n)?n.trim():n;r===null||r===""||(i==="children"?t.append.apply(t,Hr(nc(r))):t.setAttribute(i,r))}),t}var Xy={splitClass:"",lineClass:"line",wordClass:"word",charClass:"char",types:["lines","words","chars"],absolute:!1,tagName:"div"};function iO(s,e){e=tc(Xy,e);var t=zy(e.types),i=e.tagName,n=s.nodeValue,r=document.createDocumentFragment(),o=[],a=[];return/^\s/.test(n)&&r.append(" "),o=Hk(n).reduce(function(l,c,u,h){var d,f;return t.chars&&(f=nO(c).map(function(m){var v=Wy(i,{class:"".concat(e.splitClass," ").concat(e.charClass),style:"display: inline-block;",children:m});return ko(v,"isChar",!0),a=[].concat(Hr(a),[v]),v})),t.words||t.lines?(d=Wy(i,{class:"".concat(e.wordClass," ").concat(e.splitClass),style:"display: inline-block; ".concat(t.words&&e.absolute?"position: relative;":""),children:t.chars?f:c}),ko(d,{isWord:!0,isWordStart:!0,isWordEnd:!0}),r.appendChild(d)):f.forEach(function(m){r.appendChild(m)}),u=w)&&(l=P,o.push(a=[])),a.push(x)),e.absolute&&ko(x,{top:P,left:E,width:T,height:A}))}),f&&f.removeChild(s),i.lines&&(d=o.map(function(x){var M=Wy(n,{class:"".concat(e.splitClass," ").concat(e.lineClass),style:"display: block; text-align: ".concat(_,"; width: 100%;")});ko(M,"isLine",!0);var C={height:0,top:1e4};return v.appendChild(M),x.forEach(function(T,A,P){var E=ic(T),I=E.isWordEnd,R=E.top,U=E.height,L=P[A+1];C.height=Math.max(C.height,U),C.top=Math.min(C.top,R),M.appendChild(T),I&&ic(L).isWordStart&&M.append(" ")}),e.absolute&&ko(M,{height:C.height,top:C.top}),M}),i.words||OE(v),s.replaceChildren(v)),e.absolute&&(s.style.width="".concat(s.style.width||u,"px"),s.style.height="".concat(c,"px"),nc(r).forEach(function(x){var M=ic(x),C=M.isLine,T=M.top,A=M.left,P=M.width,E=M.height,I=ic(x.parentElement),R=!C&&I.isLine;x.style.top="".concat(R?T-I.top:T,"px"),x.style.left=C?"".concat(h.left,"px"):"".concat(A-(R?h.left:0),"px"),x.style.height="".concat(E,"px"),x.style.width=C?"".concat(h.width,"px"):"".concat(P,"px"),x.style.position="absolute"})),f&&(m?f.insertBefore(s,m):f.appendChild(s)),d}var Ku=tc(Xy,{}),Vm=function(){_E(s,null,[{key:"clearData",value:function(){Vk()}},{key:"setDefaults",value:function(t){return Ku=tc(Ku,Nm(t)),Xy}},{key:"revert",value:function(t){SE(t).forEach(function(i){var n=ic(i),r=n.isSplit,o=n.html,a=n.cssWidth,l=n.cssHeight;r&&(i.innerHTML=o,i.style.width=a||"",i.style.height=l||"",ME(i))})}},{key:"create",value:function(t,i){return new s(t,i)}},{key:"data",get:function(){return vo}},{key:"defaults",get:function(){return Ku},set:function(t){Ku=tc(Ku,Nm(t))}}]);function s(e,t){Ck(this,s),this.isSplit=!1,this.settings=tc(Ku,Nm(t)),this.elements=SE(e),this.split()}return _E(s,[{key:"split",value:function(t){var i=this;this.revert(),this.elements.forEach(function(o){ko(o,"html",o.innerHTML)}),this.lines=[],this.words=[],this.chars=[];var n=[window.pageXOffset,window.pageYOffset];t!==void 0&&(this.settings=tc(this.settings,Nm(t)));var r=zy(this.settings.types);r.none||(this.elements.forEach(function(o){ko(o,"isRoot",!0);var a=kE(o,i.settings),l=a.words,c=a.chars;i.words=[].concat(Hr(i.words),Hr(l)),i.chars=[].concat(Hr(i.chars),Hr(c))}),this.elements.forEach(function(o){if(r.lines||i.settings.absolute){var a=oO(o,i.settings,n);i.lines=[].concat(Hr(i.lines),Hr(a))}}),this.isSplit=!0,window.scrollTo(n[0],n[1]),Gk())}},{key:"revert",value:function(){this.isSplit&&(this.lines=null,this.words=null,this.chars=null,this.isSplit=!1),s.revert(this.elements)}}]),s}();function oa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function FE(s,e){s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.__proto__=e}/*! * GSAP 3.12.7 * https://gsap.com * * @license Copyright 2008-2025, GreenSock. All rights reserved. * Subject to the terms at https://gsap.com/standard-license or for * Club GSAP members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */var Ms={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},$u={duration:.5,overwrite:!1,delay:0},Yy,dr,hi,Oo=1e8,Ar=1/Oo,jy=Math.PI*2,aO=jy/4,lO=0,NE=Math.sqrt,cO=Math.cos,uO=Math.sin,ir=function(e){return typeof e=="string"},Mi=function(e){return typeof e=="function"},aa=function(e){return typeof e=="number"},qy=function(e){return typeof e>"u"},Fo=function(e){return typeof e=="object"},ss=function(e){return e!==!1},Zy=function(){return typeof window<"u"},Gm=function(e){return Mi(e)||ir(e)},BE=typeof ArrayBuffer=="function"&&ArrayBuffer.isView||function(){},Cr=Array.isArray,Ky=/(?:-?\.?\d|\.)+/gi,zE=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Ju=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,$y=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,VE=/[+-]=-?[.\d]+/,GE=/[^,'"\[\]\s]+/gi,hO=/^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,vi,No,Jy,Qy,Es={},Hm={},HE,WE=function(e){return(Hm=eh(e,Es))&&ls},ex=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},qd=function(e,t){return!t&&console.warn(e)},XE=function(e,t){return e&&(Es[e]=t)&&Hm&&(Hm[e]=t)||Es},Zd=function(){return 0},dO={suppressEvents:!0,isStart:!0,kill:!1},Wm={suppressEvents:!0,kill:!1},fO={suppressEvents:!0},tx={},Wa=[],nx={},YE,Ts={},ix={},jE=30,Xm=[],rx="",sx=function(e){var t=e[0],i,n;if(Fo(t)||Mi(t)||(e=[e]),!(i=(t._gsap||{}).harness)){for(n=Xm.length;n--&&!Xm[n].targetTest(t););i=Xm[n]}for(n=e.length;n--;)e[n]&&(e[n]._gsap||(e[n]._gsap=new wT(e[n],i)))||e.splice(n,1);return e},rc=function(e){return e._gsap||sx(Zs(e))[0]._gsap},qE=function(e,t,i){return(i=e[t])&&Mi(i)?e[t]():qy(i)&&e.getAttribute&&e.getAttribute(t)||i},os=function(e,t){return(e=e.split(",")).forEach(t)||e},Ri=function(e){return Math.round(e*1e5)/1e5||0},ki=function(e){return Math.round(e*1e7)/1e7||0},Qu=function(e,t){var i=t.charAt(0),n=parseFloat(t.substr(2));return e=parseFloat(e),i==="+"?e+n:i==="-"?e-n:i==="*"?e*n:e/n},pO=function(e,t){for(var i=t.length,n=0;e.indexOf(t[n])<0&&++na;)o=o._prev;return o?(t._next=o._next,o._next=t):(t._next=e[i],e[i]=t),t._next?t._next._prev=t:e[n]=t,t._prev=o,t.parent=t._dp=e,t},qm=function(e,t,i,n){i===void 0&&(i="_first"),n===void 0&&(n="_last");var r=t._prev,o=t._next;r?r._next=o:e[i]===t&&(e[i]=o),o?o._prev=r:e[n]===t&&(e[n]=r),t._next=t._prev=t.parent=null},Xa=function(e,t){e.parent&&(!t||e.parent.autoRemoveChildren)&&e.parent.remove&&e.parent.remove(e),e._act=0},sc=function(e,t){if(e&&(!t||t._end>e._dur||t._start<0))for(var i=e;i;)i._dirty=1,i=i.parent;return e},vO=function(e){for(var t=e.parent;t&&t.parent;)t._dirty=1,t.totalDuration(),t=t.parent;return e},ox=function(e,t,i,n){return e._startAt&&(dr?e._startAt.revert(Wm):e.vars.immediateRender&&!e.vars.autoRevert||e._startAt.render(t,!0,n))},_O=function s(e){return!e||e._ts&&s(e.parent)},eT=function(e){return e._repeat?th(e._tTime,e=e.duration()+e._rDelay)*e:0},th=function(e,t){var i=Math.floor(e=ki(e/t));return e&&i===e?i-1:i},Zm=function(e,t){return(e-t._start)*t._ts+(t._ts>=0?0:t._dirty?t.totalDuration():t._tDur)},Km=function(e){return e._end=ki(e._start+(e._tDur/Math.abs(e._ts||e._rts||Ar)||0))},$m=function(e,t){var i=e._dp;return i&&i.smoothChildTiming&&e._ts&&(e._start=ki(i._time-(e._ts>0?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),Km(e),i._dirty||sc(i,e)),e},tT=function(e,t){var i;if((t._time||!t._dur&&t._initted||t._startAr)&&t.render(i,!0)),sc(e,t)._dp&&e._initted&&e._time>=e._dur&&e._ts){if(e._dur=0&&i.totalTime(i._tTime),i=i._dp;e._zTime=-1e-8}},Bo=function(e,t,i,n){return t.parent&&Xa(t),t._start=ki((aa(i)?i:i||e!==vi?qs(e,i,t):e._time)+t._delay),t._end=ki(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0)),QE(e,t,"_first","_last",e._sort?"_start":0),ax(t)||(e._recent=t),n||tT(e,t),e._ts<0&&$m(e,e._tTime),e},nT=function(e,t){return(Es.ScrollTrigger||ex("scrollTrigger",t))&&Es.ScrollTrigger.create(t,e)},iT=function(e,t,i,n,r){if(gx(e,t,r),!e._initted)return 1;if(!i&&e._pt&&!dr&&(e._dur&&e.vars.lazy!==!1||!e._dur&&e.vars.lazy)&&YE!==Ps.frame)return Wa.push(e),e._lazy=[r,n],1},yO=function s(e){var t=e.parent;return t&&t._ts&&t._initted&&!t._lock&&(t.rawTime()<0||s(t))},ax=function(e){var t=e.data;return t==="isFromStart"||t==="isStart"},xO=function(e,t,i,n){var r=e.ratio,o=t<0||!t&&(!e._start&&yO(e)&&!(!e._initted&&ax(e))||(e._ts<0||e._dp._ts<0)&&!ax(e))?0:1,a=e._rDelay,l=0,c,u,h;if(a&&e._repeat&&(l=Jd(0,e._tDur,t),u=th(l,a),e._yoyo&&u&1&&(o=1-o),u!==th(e._tTime,a)&&(r=1-o,e.vars.repeatRefresh&&e._initted&&e.invalidate())),o!==r||dr||n||e._zTime===Ar||!t&&e._zTime){if(!e._initted&&iT(e,t,n,i,l))return;for(h=e._zTime,e._zTime=t||(i?Ar:0),i||(i=t&&!h),e.ratio=o,e._from&&(o=1-o),e._time=0,e._tTime=l,c=e._pt;c;)c.r(o,c.d),c=c._next;t<0&&ox(e,t,i,!0),e._onUpdate&&!i&&Cs(e,"onUpdate"),l&&e._repeat&&!i&&e.parent&&Cs(e,"onRepeat"),(t>=e._tDur||t<0)&&e.ratio===o&&(o&&Xa(e,1),!i&&!dr&&(Cs(e,o?"onComplete":"onReverseComplete",!0),e._prom&&e._prom()))}else e._zTime||(e._zTime=t)},bO=function(e,t,i){var n;if(i>t)for(n=e._first;n&&n._start<=i;){if(n.data==="isPause"&&n._start>t)return n;n=n._next}else for(n=e._last;n&&n._start>=i;){if(n.data==="isPause"&&n._start0&&!n&&$m(e,e._tTime=e._tDur*a),e.parent&&Km(e),i||sc(e.parent,e),e},rT=function(e){return e instanceof Wr?sc(e):nh(e,e._dur)},wO={_start:0,endTime:Zd,totalDuration:Zd},qs=function s(e,t,i){var n=e.labels,r=e._recent||wO,o=e.duration()>=Oo?r.endTime(!1):e._dur,a,l,c;return ir(t)&&(isNaN(t)||t in n)?(l=t.charAt(0),c=t.substr(-1)==="%",a=t.indexOf("="),l==="<"||l===">"?(a>=0&&(t=t.replace(/=/,"")),(l==="<"?r._start:r.endTime(r._repeat>=0))+(parseFloat(t.substr(1))||0)*(c?(a<0?r:i).totalDuration()/100:1)):a<0?(t in n||(n[t]=o),n[t]):(l=parseFloat(t.charAt(a-1)+t.substr(a+1)),c&&i&&(l=l/100*(Cr(i)?i[0]:i).totalDuration()),a>1?s(e,t.substr(0,a-1),i)+l:o+l)):t==null?o:+t},$d=function(e,t,i){var n=aa(t[1]),r=(n?2:1)+(e<2?0:1),o=t[r],a,l;if(n&&(o.duration=t[1]),o.parent=i,e){for(a=o,l=i;l&&!("immediateRender"in a);)a=l.vars.defaults||{},l=ss(l.vars.inherit)&&l.parent;o.immediateRender=ss(a.immediateRender),e<2?o.runBackwards=1:o.startAt=t[r-1]}return new Oi(t[0],o,t[r+1])},Ya=function(e,t){return e||e===0?t(e):t},Jd=function(e,t,i){return it?t:i},Pr=function(e,t){return!ir(e)||!(t=hO.exec(e))?"":t[1]},SO=function(e,t,i){return Ya(i,function(n){return Jd(e,t,n)})},lx=[].slice,sT=function(e,t){return e&&Fo(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Fo(e[0]))&&!e.nodeType&&e!==No},MO=function(e,t,i){return i===void 0&&(i=[]),e.forEach(function(n){var r;return ir(n)&&!t||sT(n,1)?(r=i).push.apply(r,Zs(n)):i.push(n)})||i},Zs=function(e,t,i){return hi&&!t&&hi.selector?hi.selector(e):ir(e)&&!i&&(Jy||!rh())?lx.call((t||Qy).querySelectorAll(e),0):Cr(e)?MO(e,i):sT(e)?lx.call(e,0):e?[e]:[]},cx=function(e){return e=Zs(e)[0]||qd("Invalid scope")||{},function(t){var i=e.current||e.nativeElement||e;return Zs(t,i.querySelectorAll?i:i===e?qd("Invalid scope")||Qy.createElement("div"):e)}},oT=function(e){return e.sort(function(){return .5-Math.random()})},aT=function(e){if(Mi(e))return e;var t=Fo(e)?e:{each:e},i=oc(t.ease),n=t.from||0,r=parseFloat(t.base)||0,o={},a=n>0&&n<1,l=isNaN(n)||a,c=t.axis,u=n,h=n;return ir(n)?u=h={center:.5,edges:.5,end:1}[n]||0:!a&&l&&(u=n[0],h=n[1]),function(d,f,m){var v=(m||t).length,g=o[v],_,y,w,x,M,C,T,A,P;if(!g){if(P=t.grid==="auto"?0:(t.grid||[1,Oo])[1],!P){for(T=-1e8;T<(T=m[P++].getBoundingClientRect().left)&&PT&&(T=M),Mv?v-1:c?c==="y"?v/P:P:Math.max(P,v/P))||0)*(n==="edges"?-1:1),g.b=v<0?r-v:r,g.u=Pr(t.amount||t.each)||0,i=i&&v<0?yT(i):i}return v=(g[d]-g.min)/g.max||0,ki(g.b+(i?i(v):v)*g.v)+g.u}},ux=function(e){var t=Math.pow(10,((e+"").split(".")[1]||"").length);return function(i){var n=ki(Math.round(parseFloat(i)/e)*e*t);return(n-n%1)/t+(aa(i)?0:Pr(i))}},lT=function(e,t){var i=Cr(e),n,r;return!i&&Fo(e)&&(n=i=e.radius||Oo,e.values?(e=Zs(e.values),(r=!aa(e[0]))&&(n*=n)):e=ux(e.increment)),Ya(t,i?Mi(e)?function(o){return r=e(o),Math.abs(r-o)<=n?r:o}:function(o){for(var a=parseFloat(r?o.x:o),l=parseFloat(r?o.y:0),c=Oo,u=0,h=e.length,d,f;h--;)r?(d=e[h].x-a,f=e[h].y-l,d=d*d+f*f):d=Math.abs(e[h]-a),dn?r-o:o)})},Qd=function(e){for(var t=0,i="",n,r,o,a;~(n=e.indexOf("random(",t));)o=e.indexOf(")",n),a=e.charAt(n+7)==="[",r=e.substr(n+7,o-n-7).match(a?GE:Ky),i+=e.substr(t,n-t)+cT(a?r:+r[0],a?0:+r[1],+r[2]||1e-5),t=o+1;return i+e.substr(t,e.length-t)},hT=function(e,t,i,n,r){var o=t-e,a=n-i;return Ya(r,function(l){return i+((l-e)/o*a||0)})},RO=function s(e,t,i,n){var r=isNaN(e+t)?0:function(f){return(1-f)*e+f*t};if(!r){var o=ir(e),a={},l,c,u,h,d;if(i===!0&&(n=1)&&(i=null),o)e={p:e},t={p:t};else if(Cr(e)&&!Cr(t)){for(u=[],h=e.length,d=h-2,c=1;c(a=Math.abs(a))&&(l=o,r=a);return l},Cs=function(e,t,i){var n=e.vars,r=n[t],o=hi,a=e._ctx,l,c,u;if(r)return l=n[t+"Params"],c=n.callbackScope||e,i&&Wa.length&&Ym(),a&&(hi=a),u=l?r.apply(c,l):r.call(c),hi=o,u},ef=function(e){return Xa(e),e.scrollTrigger&&e.scrollTrigger.kill(!!dr),e.progress()<1&&Cs(e,"onInterrupt"),e},ih,fT=[],pT=function(e){if(e)if(e=!e.name&&e.default||e,Zy()||e.headless){var t=e.name,i=Mi(e),n=t&&!i&&e.init?function(){this._props=[]}:e,r={init:Zd,render:yx,add:px,kill:YO,modifier:XO,rawVars:0},o={targetTest:0,get:0,getSetter:_x,aliases:{},register:0};if(rh(),e!==n){if(Ts[t])return;As(n,As(jm(e,r),o)),eh(n.prototype,eh(r,jm(e,o))),Ts[n.prop=t]=n,e.targetTest&&(Xm.push(n),tx[t]=1),t=(t==="css"?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}XE(t,n),e.register&&e.register(ls,n,as)}else fT.push(e)},$n=255,tf={aqua:[0,$n,$n],lime:[0,$n,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,$n],navy:[0,0,128],white:[$n,$n,$n],olive:[128,128,0],yellow:[$n,$n,0],orange:[$n,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[$n,0,0],pink:[$n,192,203],cyan:[0,$n,$n],transparent:[$n,$n,$n,0]},hx=function(e,t,i){return e+=e<0?1:e>1?-1:0,(e*6<1?t+(i-t)*e*6:e<.5?i:e*3<2?t+(i-t)*(2/3-e)*6:t)*$n+.5|0},mT=function(e,t,i){var n=e?aa(e)?[e>>16,e>>8&$n,e&$n]:0:tf.black,r,o,a,l,c,u,h,d,f,m;if(!n){if(e.substr(-1)===","&&(e=e.substr(0,e.length-1)),tf[e])n=tf[e];else if(e.charAt(0)==="#"){if(e.length<6&&(r=e.charAt(1),o=e.charAt(2),a=e.charAt(3),e="#"+r+r+o+o+a+a+(e.length===5?e.charAt(4)+e.charAt(4):"")),e.length===9)return n=parseInt(e.substr(1,6),16),[n>>16,n>>8&$n,n&$n,parseInt(e.substr(7),16)/255];e=parseInt(e.substr(1),16),n=[e>>16,e>>8&$n,e&$n]}else if(e.substr(0,3)==="hsl"){if(n=m=e.match(Ky),!t)l=+n[0]%360/360,c=+n[1]/100,u=+n[2]/100,o=u<=.5?u*(c+1):u+c-u*c,r=u*2-o,n.length>3&&(n[3]*=1),n[0]=hx(l+1/3,r,o),n[1]=hx(l,r,o),n[2]=hx(l-1/3,r,o);else if(~e.indexOf("="))return n=e.match(zE),i&&n.length<4&&(n[3]=1),n}else n=e.match(Ky)||tf.transparent;n=n.map(Number)}return t&&!m&&(r=n[0]/$n,o=n[1]/$n,a=n[2]/$n,h=Math.max(r,o,a),d=Math.min(r,o,a),u=(h+d)/2,h===d?l=c=0:(f=h-d,c=u>.5?f/(2-h-d):f/(h+d),l=h===r?(o-a)/f+(oe||_<0)&&(i+=_-t),n+=_,M=n-i,w=M-o,(w>0||y)&&(C=++h.frame,d=M-h.time*1e3,h.time=M=M/1e3,o+=w+(w>=r?4:r-w),x=1),y||(l=c(v)),x)for(f=0;f=_&&f--},_listeners:a},h}(),rh=function(){return!nf&&Ps.wake()},xn={},IO=/^[\d.\-M][\d.\-,\s]/,LO=/["']/g,UO=function(e){for(var t={},i=e.substr(1,e.length-3).split(":"),n=i[0],r=1,o=i.length,a,l,c;r1&&i.config?i.config.apply(null,~e.indexOf("{")?[UO(t[1])]:kO(e).split(",").map(KE)):xn._CE&&IO.test(e)?xn._CE("",e):i},yT=function(e){return function(t){return 1-e(1-t)}},xT=function s(e,t){for(var i=e._first,n;i;)i instanceof Wr?s(i,t):i.vars.yoyoEase&&(!i._yoyo||!i._repeat)&&i._yoyo!==t&&(i.timeline?s(i.timeline,t):(n=i._ease,i._ease=i._yEase,i._yEase=n,i._yoyo=t)),i=i._next},oc=function(e,t){return e&&(Mi(e)?e:xn[e]||OO(e))||t},ac=function(e,t,i,n){i===void 0&&(i=function(l){return 1-t(1-l)}),n===void 0&&(n=function(l){return l<.5?t(l*2)/2:1-t((1-l)*2)/2});var r={easeIn:t,easeOut:i,easeInOut:n},o;return os(e,function(a){xn[a]=Es[a]=r,xn[o=a.toLowerCase()]=i;for(var l in r)xn[o+(l==="easeIn"?".in":l==="easeOut"?".out":".inOut")]=xn[a+"."+l]=r[l]}),r},bT=function(e){return function(t){return t<.5?(1-e(1-t*2))/2:.5+e((t-.5)*2)/2}},dx=function s(e,t,i){var n=t>=1?t:1,r=(i||(e?.3:.45))/(t<1?t:1),o=r/jy*(Math.asin(1/n)||0),a=function(u){return u===1?1:n*Math.pow(2,-10*u)*uO((u-o)*r)+1},l=e==="out"?a:e==="in"?function(c){return 1-a(1-c)}:bT(a);return r=jy/r,l.config=function(c,u){return s(e,c,u)},l},fx=function s(e,t){t===void 0&&(t=1.70158);var i=function(o){return o?--o*o*((t+1)*o+t)+1:0},n=e==="out"?i:e==="in"?function(r){return 1-i(1-r)}:bT(i);return n.config=function(r){return s(e,r)},n};os("Linear,Quad,Cubic,Quart,Quint,Strong",function(s,e){var t=e<5?e+1:e;ac(s+",Power"+(t-1),e?function(i){return Math.pow(i,t)}:function(i){return i},function(i){return 1-Math.pow(1-i,t)},function(i){return i<.5?Math.pow(i*2,t)/2:1-Math.pow((1-i)*2,t)/2})}),xn.Linear.easeNone=xn.none=xn.Linear.easeIn,ac("Elastic",dx("in"),dx("out"),dx()),function(s,e){var t=1/e,i=2*t,n=2.5*t,r=function(a){return a0?i+(i+this._rDelay)*this._repeat:i):this.totalDuration()&&this._dur},e.totalDuration=function(i){return arguments.length?(this._dirty=0,nh(this,this._repeat<0?i:(i-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur},e.totalTime=function(i,n){if(rh(),!arguments.length)return this._tTime;var r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for($m(this,i),!r._dp||r.parent||tT(r,this);r&&r.parent;)r.parent._time!==r._start+(r._ts>=0?r._tTime/r._ts:(r.totalDuration()-r._tTime)/-r._ts)&&r.totalTime(r._tTime,!0),r=r.parent;!this.parent&&this._dp.autoRemoveChildren&&(this._ts>0&&i0||!this._tDur&&!i)&&Bo(this._dp,this,this._start-this._delay)}return(this._tTime!==i||!this._dur&&!n||this._initted&&Math.abs(this._zTime)===Ar||!i&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=i),ZE(this,i,n)),this},e.time=function(i,n){return arguments.length?this.totalTime(Math.min(this.totalDuration(),i+eT(this))%(this._dur+this._rDelay)||(i?this._dur:0),n):this._time},e.totalProgress=function(i,n){return arguments.length?this.totalTime(this.totalDuration()*i,n):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.rawTime()>=0&&this._initted?1:0},e.progress=function(i,n){return arguments.length?this.totalTime(this.duration()*(this._yoyo&&!(this.iteration()&1)?1-i:i)+eT(this),n):this.duration()?Math.min(1,this._time/this._dur):this.rawTime()>0?1:0},e.iteration=function(i,n){var r=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(i-1)*r,n):this._repeat?th(this._tTime,r)+1:1},e.timeScale=function(i,n){if(!arguments.length)return this._rts===-1e-8?0:this._rts;if(this._rts===i)return this;var r=this.parent&&this._ts?Zm(this.parent._time,this):this._tTime;return this._rts=+i||0,this._ts=this._ps||i===-1e-8?0:this._rts,this.totalTime(Jd(-Math.abs(this._delay),this._tDur,r),n!==!1),Km(this),vO(this)},e.paused=function(i){return arguments.length?(this._ps!==i&&(this._ps=i,i?(this._pTime=this._tTime||Math.max(-this._delay,this.rawTime()),this._ts=this._act=0):(rh(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,this.progress()===1&&Math.abs(this._zTime)!==Ar&&(this._tTime-=Ar)))),this):this._ps},e.startTime=function(i){if(arguments.length){this._start=i;var n=this.parent||this._dp;return n&&(n._sort||!this.parent)&&Bo(n,this,i-this._delay),this}return this._start},e.endTime=function(i){return this._start+(ss(i)?this.totalDuration():this.duration())/Math.abs(this._ts||1)},e.rawTime=function(i){var n=this.parent||this._dp;return n?i&&(!this._ts||this._repeat&&this._time&&this.totalProgress()<1)?this._tTime%(this._dur+this._rDelay):this._ts?Zm(n.rawTime(i),this):this._tTime:this._tTime},e.revert=function(i){i===void 0&&(i=fO);var n=dr;return dr=i,(this._initted||this._startAt)&&(this.timeline&&this.timeline.revert(i),this.totalTime(-.01,i.suppressEvents)),this.data!=="nested"&&i.kill!==!1&&this.kill(),dr=n,this},e.globalTime=function(i){for(var n=this,r=arguments.length?i:n.rawTime();n;)r=n._start+r/(Math.abs(n._ts)||1),n=n._dp;return!this.parent&&this._sat?this._sat.globalTime(i):r},e.repeat=function(i){return arguments.length?(this._repeat=i===1/0?-2:i,rT(this)):this._repeat===-2?1/0:this._repeat},e.repeatDelay=function(i){if(arguments.length){var n=this._time;return this._rDelay=i,rT(this),n?this.time(n):this}return this._rDelay},e.yoyo=function(i){return arguments.length?(this._yoyo=i,this):this._yoyo},e.seek=function(i,n){return this.totalTime(qs(this,i),ss(n))},e.restart=function(i,n){return this.play().totalTime(i?-this._delay:0,ss(n)),this._dur||(this._zTime=-1e-8),this},e.play=function(i,n){return i!=null&&this.seek(i,n),this.reversed(!1).paused(!1)},e.reverse=function(i,n){return i!=null&&this.seek(i||this.totalDuration(),n),this.reversed(!0).paused(!1)},e.pause=function(i,n){return i!=null&&this.seek(i,n),this.paused(!0)},e.resume=function(){return this.paused(!1)},e.reversed=function(i){return arguments.length?(!!i!==this.reversed()&&this.timeScale(-this._rts||(i?-1e-8:0)),this):this._rts<0},e.invalidate=function(){return this._initted=this._act=0,this._zTime=-1e-8,this},e.isActive=function(){var i=this.parent||this._dp,n=this._start,r;return!!(!i||this._ts&&this._initted&&i.isActive()&&(r=i.rawTime(!0))>=n&&r1?(n?(o[i]=n,r&&(o[i+"Params"]=r),i==="onUpdate"&&(this._onUpdate=n)):delete o[i],this):o[i]},e.then=function(i){var n=this;return new Promise(function(r){var o=Mi(i)?i:$E,a=function(){var c=n.then;n.then=null,Mi(o)&&(o=o(n))&&(o.then||o===n)&&(n.then=c),r(o),n.then=c};n._initted&&n.totalProgress()===1&&n._ts>=0||!n._tTime&&n._ts<0?a():n._prom=a})},e.kill=function(){ef(this)},s}();As(rf.prototype,{_time:0,_start:0,_end:0,_tTime:0,_tDur:0,_dirty:0,_repeat:0,_yoyo:!1,parent:null,_initted:!1,_rDelay:0,_ts:1,_dp:0,ratio:0,_zTime:-1e-8,_prom:0,_ps:!1,_rts:1});var Wr=function(s){FE(e,s);function e(i,n){var r;return i===void 0&&(i={}),r=s.call(this,i)||this,r.labels={},r.smoothChildTiming=!!i.smoothChildTiming,r.autoRemoveChildren=!!i.autoRemoveChildren,r._sort=ss(i.sortChildren),vi&&Bo(i.parent||vi,oa(r),n),i.reversed&&r.reverse(),i.paused&&r.paused(!0),i.scrollTrigger&&nT(oa(r),i.scrollTrigger),r}var t=e.prototype;return t.to=function(n,r,o){return $d(0,arguments,this),this},t.from=function(n,r,o){return $d(1,arguments,this),this},t.fromTo=function(n,r,o,a){return $d(2,arguments,this),this},t.set=function(n,r,o){return r.duration=0,r.parent=this,Kd(r).repeatDelay||(r.repeat=0),r.immediateRender=!!r.immediateRender,new Oi(n,r,qs(this,o),1),this},t.call=function(n,r,o){return Bo(this,Oi.delayedCall(0,n,r),o)},t.staggerTo=function(n,r,o,a,l,c,u){return o.duration=r,o.stagger=o.stagger||a,o.onComplete=c,o.onCompleteParams=u,o.parent=this,new Oi(n,o,qs(this,l)),this},t.staggerFrom=function(n,r,o,a,l,c,u){return o.runBackwards=1,Kd(o).immediateRender=ss(o.immediateRender),this.staggerTo(n,r,o,a,l,c,u)},t.staggerFromTo=function(n,r,o,a,l,c,u,h){return a.startAt=o,Kd(a).immediateRender=ss(a.immediateRender),this.staggerTo(n,r,a,l,c,u,h)},t.render=function(n,r,o){var a=this._time,l=this._dirty?this.totalDuration():this._tDur,c=this._dur,u=n<=0?0:ki(n),h=this._zTime<0!=n<0&&(this._initted||!c),d,f,m,v,g,_,y,w,x,M,C,T;if(this!==vi&&u>l&&n>=0&&(u=l),u!==this._tTime||o||h){if(a!==this._time&&c&&(u+=this._time-a,n+=this._time-a),d=u,x=this._start,w=this._ts,_=!w,h&&(c||(a=this._zTime),(n||!r)&&(this._zTime=n)),this._repeat){if(C=this._yoyo,g=c+this._rDelay,this._repeat<-1&&n<0)return this.totalTime(g*100+n,r,o);if(d=ki(u%g),u===l?(v=this._repeat,d=c):(M=ki(u/g),v=~~M,v&&v===M&&(d=c,v--),d>c&&(d=c)),M=th(this._tTime,g),!a&&this._tTime&&M!==v&&this._tTime-M*g-this._dur<=0&&(M=v),C&&v&1&&(d=c-d,T=1),v!==M&&!this._lock){var A=C&&M&1,P=A===(C&&v&1);if(v=a&&n>=0)for(f=this._first;f;){if(m=f._next,(f._act||d>=f._start)&&f._ts&&y!==f){if(f.parent!==this)return this.render(n,r,o);if(f.render(f._ts>0?(d-f._start)*f._ts:(f._dirty?f.totalDuration():f._tDur)+(d-f._start)*f._ts,r,o),d!==this._time||!this._ts&&!_){y=0,m&&(u+=this._zTime=-1e-8);break}}f=m}else{f=this._last;for(var E=n<0?n:d;f;){if(m=f._prev,(f._act||E<=f._end)&&f._ts&&y!==f){if(f.parent!==this)return this.render(n,r,o);if(f.render(f._ts>0?(E-f._start)*f._ts:(f._dirty?f.totalDuration():f._tDur)+(E-f._start)*f._ts,r,o||dr&&(f._initted||f._startAt)),d!==this._time||!this._ts&&!_){y=0,m&&(u+=this._zTime=E?-1e-8:Ar);break}}f=m}}if(y&&!r&&(this.pause(),y.render(d>=a?0:-1e-8)._zTime=d>=a?1:-1,this._ts))return this._start=x,Km(this),this.render(n,r,o);this._onUpdate&&!r&&Cs(this,"onUpdate",!0),(u===l&&this._tTime>=this.totalDuration()||!u&&a)&&(x===this._start||Math.abs(w)!==Math.abs(this._ts))&&(this._lock||((n||!c)&&(u===l&&this._ts>0||!u&&this._ts<0)&&Xa(this,1),!r&&!(n<0&&!a)&&(u||a||!l)&&(Cs(this,u===l&&n>=0?"onComplete":"onReverseComplete",!0),this._prom&&!(u0)&&this._prom())))}return this},t.add=function(n,r){var o=this;if(aa(r)||(r=qs(this,r,n)),!(n instanceof rf)){if(Cr(n))return n.forEach(function(a){return o.add(a,r)}),this;if(ir(n))return this.addLabel(n,r);if(Mi(n))n=Oi.delayedCall(0,n);else return this}return this!==n?Bo(this,n,r):this},t.getChildren=function(n,r,o,a){n===void 0&&(n=!0),r===void 0&&(r=!0),o===void 0&&(o=!0),a===void 0&&(a=-1e8);for(var l=[],c=this._first;c;)c._start>=a&&(c instanceof Oi?r&&l.push(c):(o&&l.push(c),n&&l.push.apply(l,c.getChildren(!0,r,o)))),c=c._next;return l},t.getById=function(n){for(var r=this.getChildren(1,1,1),o=r.length;o--;)if(r[o].vars.id===n)return r[o]},t.remove=function(n){return ir(n)?this.removeLabel(n):Mi(n)?this.killTweensOf(n):(n.parent===this&&qm(this,n),n===this._recent&&(this._recent=this._last),sc(this))},t.totalTime=function(n,r){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=ki(Ps.time-(this._ts>0?n/this._ts:(this.totalDuration()-n)/-this._ts))),s.prototype.totalTime.call(this,n,r),this._forcing=0,this):this._tTime},t.addLabel=function(n,r){return this.labels[n]=qs(this,r),this},t.removeLabel=function(n){return delete this.labels[n],this},t.addPause=function(n,r,o){var a=Oi.delayedCall(0,r||Zd,o);return a.data="isPause",this._hasPause=1,Bo(this,a,qs(this,n))},t.removePause=function(n){var r=this._first;for(n=qs(this,n);r;)r._start===n&&r.data==="isPause"&&Xa(r),r=r._next},t.killTweensOf=function(n,r,o){for(var a=this.getTweensOf(n,o),l=a.length;l--;)qa!==a[l]&&a[l].kill(n,r);return this},t.getTweensOf=function(n,r){for(var o=[],a=Zs(n),l=this._first,c=aa(r),u;l;)l instanceof Oi?pO(l._targets,a)&&(c?(!qa||l._initted&&l._ts)&&l.globalTime(0)<=r&&l.globalTime(l.totalDuration())>r:!r||l.isActive())&&o.push(l):(u=l.getTweensOf(a,r)).length&&o.push.apply(o,u),l=l._next;return o},t.tweenTo=function(n,r){r=r||{};var o=this,a=qs(o,n),l=r,c=l.startAt,u=l.onStart,h=l.onStartParams,d=l.immediateRender,f,m=Oi.to(o,As({ease:r.ease||"none",lazy:!1,immediateRender:!1,time:a,overwrite:"auto",duration:r.duration||Math.abs((a-(c&&"time"in c?c.time:o._time))/o.timeScale())||Ar,onStart:function(){if(o.pause(),!f){var g=r.duration||Math.abs((a-(c&&"time"in c?c.time:o._time))/o.timeScale());m._dur!==g&&nh(m,g,0,1).render(m._time,!0,!0),f=1}u&&u.apply(m,h||[])}},r));return d?m.render(0):m},t.tweenFromTo=function(n,r,o){return this.tweenTo(r,As({startAt:{time:qs(this,n)}},o))},t.recent=function(){return this._recent},t.nextLabel=function(n){return n===void 0&&(n=this._time),dT(this,qs(this,n))},t.previousLabel=function(n){return n===void 0&&(n=this._time),dT(this,qs(this,n),1)},t.currentLabel=function(n){return arguments.length?this.seek(n,!0):this.previousLabel(this._time+Ar)},t.shiftChildren=function(n,r,o){o===void 0&&(o=0);for(var a=this._first,l=this.labels,c;a;)a._start>=o&&(a._start+=n,a._end+=n),a=a._next;if(r)for(c in l)l[c]>=o&&(l[c]+=n);return sc(this)},t.invalidate=function(n){var r=this._first;for(this._lock=0;r;)r.invalidate(n),r=r._next;return s.prototype.invalidate.call(this,n)},t.clear=function(n){n===void 0&&(n=!0);for(var r=this._first,o;r;)o=r._next,this.remove(r),r=o;return this._dp&&(this._time=this._tTime=this._pTime=0),n&&(this.labels={}),sc(this)},t.totalDuration=function(n){var r=0,o=this,a=o._last,l=Oo,c,u,h;if(arguments.length)return o.timeScale((o._repeat<0?o.duration():o.totalDuration())/(o.reversed()?-n:n));if(o._dirty){for(h=o.parent;a;)c=a._prev,a._dirty&&a.totalDuration(),u=a._start,u>l&&o._sort&&a._ts&&!o._lock?(o._lock=1,Bo(o,a,u-a._delay,1)._lock=0):l=u,u<0&&a._ts&&(r-=u,(!h&&!o._dp||h&&h.smoothChildTiming)&&(o._start+=u/o._ts,o._time-=u,o._tTime-=u),o.shiftChildren(-u,!1,-1/0),l=0),a._end>r&&a._ts&&(r=a._end),a=c;nh(o,o===vi&&o._time>r?o._time:r,1,1),o._dirty=0}return o._tDur},e.updateRoot=function(n){if(vi._ts&&(ZE(vi,Zm(n,vi)),YE=Ps.frame),Ps.frame>=jE){jE+=Ms.autoSleep||120;var r=vi._first;if((!r||!r._ts)&&Ms.autoSleep&&Ps._listeners.length<2){for(;r&&!r._ts;)r=r._next;r||Ps.sleep()}}},e}(rf);As(Wr.prototype,{_lock:0,_hasPause:0,_forcing:0});var FO=function(e,t,i,n,r,o,a){var l=new as(this._pt,e,t,0,1,CT,null,r),c=0,u=0,h,d,f,m,v,g,_,y;for(l.b=i,l.e=n,i+="",n+="",(_=~n.indexOf("random("))&&(n=Qd(n)),o&&(y=[i,n],o(y,e,t),i=y[0],n=y[1]),d=i.match($y)||[];h=$y.exec(n);)m=h[0],v=n.substring(c,h.index),f?f=(f+1)%5:v.substr(-5)==="rgba("&&(f=1),m!==d[u++]&&(g=parseFloat(d[u-1])||0,l._pt={_next:l._pt,p:v||u===1?v:",",s:g,c:m.charAt(1)==="="?Qu(g,m)-g:parseFloat(m)-g,m:f&&f<4?Math.round:0},c=$y.lastIndex);return l.c=c")}),x.duration();else{C={};for(A in m)A==="ease"||A==="easeEach"||VO(A,m[A],C,m.easeEach);for(A in C)for(U=C[A].sort(function(z,G){return z.t-G.t}),R=0,M=0;Ml-Ar&&!u?l:nc&&(d=c)),_=this._yoyo&&m&1,_&&(x=this._yEase,d=c-d),g=th(this._tTime,v),d===a&&!o&&this._initted&&m===g)return this._tTime=h,this;m!==g&&(w&&this._yEase&&xT(w,_),this.vars.repeatRefresh&&!_&&!this._lock&&d!==v&&this._initted&&(this._lock=o=1,this.render(ki(v*m),!0).invalidate()._lock=0))}if(!this._initted){if(iT(this,u?n:d,o,r,h))return this._tTime=0,this;if(a!==this._time&&!(o&&this.vars.repeatRefresh&&m!==g))return this;if(c!==this._dur)return this.render(n,r,o)}if(this._tTime=h,this._time=d,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=y=(x||this._ease)(d/c),this._from&&(this.ratio=y=1-y),d&&!a&&!r&&!m&&(Cs(this,"onStart"),this._tTime!==h))return this;for(f=this._pt;f;)f.r(y,f.d),f=f._next;w&&w.render(n<0?n:w._dur*w._ease(d/this._dur),r,o)||this._startAt&&(this._zTime=n),this._onUpdate&&!r&&(u&&ox(this,n,r,o),Cs(this,"onUpdate")),this._repeat&&m!==g&&this.vars.onRepeat&&!r&&this.parent&&Cs(this,"onRepeat"),(h===this._tDur||!h)&&this._tTime===h&&(u&&!this._onUpdate&&ox(this,n,!0,!0),(n||!c)&&(h===this._tDur&&this._ts>0||!h&&this._ts<0)&&Xa(this,1),!r&&!(u&&!a)&&(h||a||_)&&(Cs(this,h===l?"onComplete":"onReverseComplete",!0),this._prom&&!(h0)&&this._prom()))}return this},t.targets=function(){return this._targets},t.invalidate=function(n){return(!n||!this.vars.runBackwards)&&(this._startAt=0),this._pt=this._op=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(n),s.prototype.invalidate.call(this,n)},t.resetTo=function(n,r,o,a,l){nf||Ps.wake(),this._ts||this.play();var c=Math.min(this._dur,(this._dp._time-this._start)*this._ts),u;return this._initted||gx(this,c),u=this._ease(c/this._dur),BO(this,n,r,o,a,u,c,l)?this.resetTo(n,r,o,a,1):($m(this,0),this.parent||QE(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},t.kill=function(n,r){if(r===void 0&&(r="all"),!n&&(!r||r==="all"))return this._lazy=this._pt=0,this.parent?ef(this):this.scrollTrigger&&this.scrollTrigger.kill(!!dr),this;if(this.timeline){var o=this.timeline.totalDuration();return this.timeline.killTweensOf(n,r,qa&&qa.vars.overwrite!==!0)._first||ef(this),this.parent&&o!==this.timeline.totalDuration()&&nh(this,this._dur*this.timeline._tDur/o,0,1),this}var a=this._targets,l=n?Zs(n):a,c=this._ptLookup,u=this._pt,h,d,f,m,v,g,_;if((!r||r==="all")&&gO(a,l))return r==="all"&&(this._pt=0),ef(this);for(h=this._op=this._op||[],r!=="all"&&(ir(r)&&(v={},os(r,function(y){return v[y]=1}),r=v),r=zO(a,r)),_=a.length;_--;)if(~l.indexOf(a[_])){d=c[_],r==="all"?(h[_]=r,m=d,f={}):(f=h[_]=h[_]||{},m=r);for(v in m)g=d&&d[v],g&&((!("kill"in g.d)||g.d.kill(v)===!0)&&qm(this,g,"_pt"),delete d[v]),f!=="all"&&(f[v]=1)}return this._initted&&!this._pt&&u&&ef(this),this},e.to=function(n,r){return new e(n,r,arguments[2])},e.from=function(n,r){return $d(1,arguments)},e.delayedCall=function(n,r,o,a){return new e(r,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:n,onComplete:r,onReverseComplete:r,onCompleteParams:o,onReverseCompleteParams:o,callbackScope:a})},e.fromTo=function(n,r,o){return $d(2,arguments)},e.set=function(n,r){return r.duration=0,r.repeatDelay||(r.repeat=0),new e(n,r)},e.killTweensOf=function(n,r,o){return vi.killTweensOf(n,r,o)},e}(rf);As(Oi.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),os("staggerTo,staggerFrom,staggerFromTo",function(s){Oi[s]=function(){var e=new Wr,t=lx.call(arguments,0);return t.splice(s==="staggerFromTo"?5:4,0,0),e[s].apply(e,t)}});var vx=function(e,t,i){return e[t]=i},TT=function(e,t,i){return e[t](i)},GO=function(e,t,i,n){return e[t](n.fp,i)},HO=function(e,t,i){return e.setAttribute(t,i)},_x=function(e,t){return Mi(e[t])?TT:qy(e[t])&&e.setAttribute?HO:vx},AT=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e6)/1e6,t)},WO=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},CT=function(e,t){var i=t._pt,n="";if(!e&&t.b)n=t.b;else if(e===1&&t.e)n=t.e;else{for(;i;)n=i.p+(i.m?i.m(i.s+i.c*e):Math.round((i.s+i.c*e)*1e4)/1e4)+n,i=i._next;n+=t.c}t.set(t.t,t.p,n,t)},yx=function(e,t){for(var i=t._pt;i;)i.r(e,i.d),i=i._next},XO=function(e,t,i,n){for(var r=this._pt,o;r;)o=r._next,r.p===n&&r.modifier(e,t,i),r=o},YO=function(e){for(var t=this._pt,i,n;t;)n=t._next,t.p===e&&!t.op||t.op===e?qm(this,t,"_pt"):t.dep||(i=1),t=n;return!i},jO=function(e,t,i,n){n.mSet(e,t,n.m.call(n.tween,i,n.mt),n)},PT=function(e){for(var t=e._pt,i,n,r,o;t;){for(i=t._next,n=r;n&&n.pr>t.pr;)n=n._next;(t._prev=n?n._prev:o)?t._prev._next=t:r=t,(t._next=n)?n._prev=t:o=t,t=i}e._pt=r},as=function(){function s(t,i,n,r,o,a,l,c,u){this.t=i,this.s=r,this.c=o,this.p=n,this.r=a||AT,this.d=l||this,this.set=c||vx,this.pr=u||0,this._next=t,t&&(t._prev=this)}var e=s.prototype;return e.modifier=function(i,n,r){this.mSet=this.mSet||this.set,this.set=jO,this.m=i,this.mt=r,this.tween=n},s}();os(rx+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(s){return tx[s]=1}),Es.TweenMax=Es.TweenLite=Oi,Es.TimelineLite=Es.TimelineMax=Wr,vi=new Wr({sortChildren:!1,defaults:$u,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),Ms.stringFilter=_T;var lc=[],Jm={},qO=[],RT=0,ZO=0,xx=function(e){return(Jm[e]||qO).map(function(t){return t()})},bx=function(){var e=Date.now(),t=[];e-RT>2&&(xx("matchMediaInit"),lc.forEach(function(i){var n=i.queries,r=i.conditions,o,a,l,c;for(a in n)o=No.matchMedia(n[a]).matches,o&&(l=1),o!==r[a]&&(r[a]=o,c=1);c&&(i.revert(),l&&t.push(i))}),xx("matchMediaRevert"),t.forEach(function(i){return i.onMatch(i,function(n){return i.add(null,n)})}),RT=e,xx("matchMedia"))},DT=function(){function s(t,i){this.selector=i&&cx(i),this.data=[],this._r=[],this.isReverted=!1,this.id=ZO++,t&&this.add(t)}var e=s.prototype;return e.add=function(i,n,r){Mi(i)&&(r=n,n=i,i=Mi);var o=this,a=function(){var c=hi,u=o.selector,h;return c&&c!==o&&c.data.push(o),r&&(o.selector=cx(r)),hi=o,h=n.apply(o,arguments),Mi(h)&&o._r.push(h),hi=c,o.selector=u,o.isReverted=!1,h};return o.last=a,i===Mi?a(o,function(l){return o.add(null,l)}):i?o[i]=a:a},e.ignore=function(i){var n=hi;hi=null,i(this),hi=n},e.getTweens=function(){var i=[];return this.data.forEach(function(n){return n instanceof s?i.push.apply(i,n.getTweens()):n instanceof Oi&&!(n.parent&&n.parent.data==="nested")&&i.push(n)}),i},e.clear=function(){this._r.length=this.data.length=0},e.kill=function(i,n){var r=this;if(i?function(){for(var a=r.getTweens(),l=r.data.length,c;l--;)c=r.data[l],c.data==="isFlip"&&(c.revert(),c.getChildren(!0,!0,!1).forEach(function(u){return a.splice(a.indexOf(u),1)}));for(a.map(function(u){return{g:u._dur||u._delay||u._sat&&!u._sat.vars.immediateRender?u.globalTime(0):-1/0,t:u}}).sort(function(u,h){return h.g-u.g||-1/0}).forEach(function(u){return u.t.revert(i)}),l=r.data.length;l--;)c=r.data[l],c instanceof Wr?c.data!=="nested"&&(c.scrollTrigger&&c.scrollTrigger.revert(),c.kill()):!(c instanceof Oi)&&c.revert&&c.revert(i);r._r.forEach(function(u){return u(i,r)}),r.isReverted=!0}():this.data.forEach(function(a){return a.kill&&a.kill()}),this.clear(),n)for(var o=lc.length;o--;)lc[o].id===this.id&&lc.splice(o,1)},e.revert=function(i){this.kill(i||{})},s}(),KO=function(){function s(t){this.contexts=[],this.scope=t,hi&&hi.data.push(this)}var e=s.prototype;return e.add=function(i,n,r){Fo(i)||(i={matches:i});var o=new DT(0,r||this.scope),a=o.conditions={},l,c,u;hi&&!o.selector&&(o.selector=hi.selector),this.contexts.push(o),n=o.add("onMatch",n),o.queries=i;for(c in i)c==="all"?u=1:(l=No.matchMedia(i[c]),l&&(lc.indexOf(o)<0&&lc.push(o),(a[c]=l.matches)&&(u=1),l.addListener?l.addListener(bx):l.addEventListener("change",bx)));return u&&n(o,function(h){return o.add(null,h)}),this},e.revert=function(i){this.kill(i||{})},e.kill=function(i){this.contexts.forEach(function(n){return n.kill(i,!0)})},s}(),Qm={registerPlugin:function(){for(var e=arguments.length,t=new Array(e),i=0;i1){var n=e.map(function(u){return ls.quickSetter(u,t,i)}),r=n.length;return function(u){for(var h=r;h--;)n[h](u)}}e=e[0]||{};var o=Ts[t],a=rc(e),l=a.harness&&(a.harness.aliases||{})[t]||t,c=o?function(u){var h=new o;ih._pt=0,h.init(e,i?u+i:u,ih,0,[e]),h.render(1,h),ih._pt&&yx(1,ih)}:a.set(e,l);return o?c:function(u){return c(e,l,i?u+i:u,a,1)}},quickTo:function(e,t,i){var n,r=ls.to(e,As((n={},n[t]="+=0.1",n.paused=!0,n.stagger=0,n),i||{})),o=function(l,c,u){return r.resetTo(t,l,c,u)};return o.tween=r,o},isTweening:function(e){return vi.getTweensOf(e,!0).length>0},defaults:function(e){return e&&e.ease&&(e.ease=oc(e.ease,$u.ease)),JE($u,e||{})},config:function(e){return JE(Ms,e||{})},registerEffect:function(e){var t=e.name,i=e.effect,n=e.plugins,r=e.defaults,o=e.extendTimeline;(n||"").split(",").forEach(function(a){return a&&!Ts[a]&&!Es[a]&&qd(t+" effect requires "+a+" plugin.")}),ix[t]=function(a,l,c){return i(Zs(a),As(l||{},r),c)},o&&(Wr.prototype[t]=function(a,l,c){return this.add(ix[t](a,Fo(l)?l:(c=l)&&{},this),c)})},registerEase:function(e,t){xn[e]=oc(t)},parseEase:function(e,t){return arguments.length?oc(e,t):xn},getById:function(e){return vi.getById(e)},exportRoot:function(e,t){e===void 0&&(e={});var i=new Wr(e),n,r;for(i.smoothChildTiming=ss(e.smoothChildTiming),vi.remove(i),i._dp=0,i._time=i._tTime=vi._time,n=vi._first;n;)r=n._next,(t||!(!n._dur&&n instanceof Oi&&n.vars.onComplete===n._targets[0]))&&Bo(i,n,n._start-n._delay),n=r;return Bo(vi,i,0),i},context:function(e,t){return e?new DT(e,t):hi},matchMedia:function(e){return new KO(e)},matchMediaRefresh:function(){return lc.forEach(function(e){var t=e.conditions,i,n;for(n in t)t[n]&&(t[n]=!1,i=1);i&&e.revert()})||bx()},addEventListener:function(e,t){var i=Jm[e]||(Jm[e]=[]);~i.indexOf(t)||i.push(t)},removeEventListener:function(e,t){var i=Jm[e],n=i&&i.indexOf(t);n>=0&&i.splice(n,1)},utils:{wrap:CO,wrapYoyo:PO,distribute:aT,random:cT,snap:lT,normalize:AO,getUnit:Pr,clamp:SO,splitColor:mT,toArray:Zs,selector:cx,mapRange:hT,pipe:EO,unitize:TO,interpolate:RO,shuffle:oT},install:WE,effects:ix,ticker:Ps,updateRoot:Wr.updateRoot,plugins:Ts,globalTimeline:vi,core:{PropTween:as,globals:XE,Tween:Oi,Timeline:Wr,Animation:rf,getCache:rc,_removeLinkedListItem:qm,reverting:function(){return dr},context:function(e){return e&&hi&&(hi.data.push(e),e._ctx=hi),hi},suppressOverwrites:function(e){return Yy=e}}};os("to,from,fromTo,delayedCall,set,killTweensOf",function(s){return Qm[s]=Oi[s]}),Ps.add(Wr.updateRoot),ih=Qm.to({},{duration:0});var $O=function(e,t){for(var i=e._pt;i&&i.p!==t&&i.op!==t&&i.fp!==t;)i=i._next;return i},JO=function(e,t){var i=e._targets,n,r,o;for(n in t)for(r=i.length;r--;)o=e._ptLookup[r][n],o&&(o=o.d)&&(o._pt&&(o=$O(o,n)),o&&o.modifier&&o.modifier(t[n],e,i[r],n))},wx=function(e,t){return{name:e,rawVars:1,init:function(n,r,o){o._onInit=function(a){var l,c;if(ir(r)&&(l={},os(r,function(u){return l[u]=1}),r=l),t){l={};for(c in r)l[c]=t(r[c]);r=l}JO(a,r)}}}},ls=Qm.registerPlugin({name:"attr",init:function(e,t,i,n,r){var o,a,l;this.tween=i;for(o in t)l=e.getAttribute(o)||"",a=this.add(e,"setAttribute",(l||0)+"",t[o],n,r,0,0,o),a.op=o,a.b=l,this._props.push(o)},render:function(e,t){for(var i=t._pt;i;)dr?i.set(i.t,i.p,i.b,i):i.r(e,i.d),i=i._next}},{name:"endArray",init:function(e,t){for(var i=t.length;i--;)this.add(e,i,e[i]||0,t[i],0,0,0,0,0,1)}},wx("roundProps",ux),wx("modifiers"),wx("snap",lT))||Qm;Oi.version=Wr.version=ls.version="3.12.7",HE=1,Zy()&&rh(),xn.Power0,xn.Power1,xn.Power2,xn.Power3,xn.Power4,xn.Linear,xn.Quad,xn.Cubic,xn.Quart,xn.Quint,xn.Strong,xn.Elastic,xn.Back,xn.SteppedEase,xn.Bounce,xn.Sine,xn.Expo,xn.Circ;/*! * CSSPlugin 3.12.7 * https://gsap.com * * Copyright 2008-2025, GreenSock. All rights reserved. * Subject to the terms at https://gsap.com/standard-license or for * Club GSAP members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */var IT,Za,sh,Sx,cc,LT,Mx,QO=function(){return typeof window<"u"},la={},uc=180/Math.PI,oh=Math.PI/180,ah=Math.atan2,UT=1e8,Ex=/([A-Z])/g,eF=/(left|right|width|margin|padding|x)/i,tF=/[\s,\(]\S/,zo={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},Tx=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},nF=function(e,t){return t.set(t.t,t.p,e===1?t.e:Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},iF=function(e,t){return t.set(t.t,t.p,e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},rF=function(e,t){var i=t.s+t.c*e;t.set(t.t,t.p,~~(i+(i<0?-.5:.5))+t.u,t)},kT=function(e,t){return t.set(t.t,t.p,e?t.e:t.b,t)},OT=function(e,t){return t.set(t.t,t.p,e!==1?t.b:t.e,t)},sF=function(e,t,i){return e.style[t]=i},oF=function(e,t,i){return e.style.setProperty(t,i)},aF=function(e,t,i){return e._gsap[t]=i},lF=function(e,t,i){return e._gsap.scaleX=e._gsap.scaleY=i},cF=function(e,t,i,n,r){var o=e._gsap;o.scaleX=o.scaleY=i,o.renderTransform(r,o)},uF=function(e,t,i,n,r){var o=e._gsap;o[t]=i,o.renderTransform(r,o)},_i="transform",cs=_i+"Origin",hF=function s(e,t){var i=this,n=this.target,r=n.style,o=n._gsap;if(e in la&&r){if(this.tfm=this.tfm||{},e!=="transform")e=zo[e]||e,~e.indexOf(",")?e.split(",").forEach(function(a){return i.tfm[a]=ca(n,a)}):this.tfm[e]=o.x?o[e]:ca(n,e),e===cs&&(this.tfm.zOrigin=o.zOrigin);else return zo.transform.split(",").forEach(function(a){return s.call(i,a,t)});if(this.props.indexOf(_i)>=0)return;o.svg&&(this.svgo=n.getAttribute("data-svg-origin"),this.props.push(cs,t,"")),e=_i}(r||t)&&this.props.push(e,t,r[e])},FT=function(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},dF=function(){var e=this.props,t=this.target,i=t.style,n=t._gsap,r,o;for(r=0;r=0?zT[o]:"")+e},Cx=function(){QO()&&window.document&&(IT=window,Za=IT.document,sh=Za.documentElement,cc=Ax("div")||{style:{}},Ax("div"),_i=lh(_i),cs=_i+"Origin",cc.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",BT=!!lh("perspective"),Mx=ls.core.reverting,Sx=1)},VT=function(e){var t=e.ownerSVGElement,i=Ax("svg",t&&t.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),n=e.cloneNode(!0),r;n.style.display="block",i.appendChild(n),sh.appendChild(i);try{r=n.getBBox()}catch{}return i.removeChild(n),sh.removeChild(i),r},GT=function(e,t){for(var i=t.length;i--;)if(e.hasAttribute(t[i]))return e.getAttribute(t[i])},HT=function(e){var t,i;try{t=e.getBBox()}catch{t=VT(e),i=1}return t&&(t.width||t.height)||i||(t=VT(e)),t&&!t.width&&!t.x&&!t.y?{x:+GT(e,["x","cx","x1"])||0,y:+GT(e,["y","cy","y1"])||0,width:0,height:0}:t},WT=function(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&HT(e))},hc=function(e,t){if(t){var i=e.style,n;t in la&&t!==cs&&(t=_i),i.removeProperty?(n=t.substr(0,2),(n==="ms"||t.substr(0,6)==="webkit")&&(t="-"+t),i.removeProperty(n==="--"?t:t.replace(Ex,"-$1").toLowerCase())):i.removeAttribute(t)}},Ka=function(e,t,i,n,r,o){var a=new as(e._pt,t,i,0,1,o?OT:kT);return e._pt=a,a.b=n,a.e=r,e._props.push(i),a},XT={deg:1,rad:1,turn:1},fF={grid:1,flex:1},$a=function s(e,t,i,n){var r=parseFloat(i)||0,o=(i+"").trim().substr((r+"").length)||"px",a=cc.style,l=eF.test(t),c=e.tagName.toLowerCase()==="svg",u=(c?"client":"offset")+(l?"Width":"Height"),h=100,d=n==="px",f=n==="%",m,v,g,_;if(n===o||!r||XT[n]||XT[o])return r;if(o!=="px"&&!d&&(r=s(e,t,i,"px")),_=e.getCTM&&WT(e),(f||o==="%")&&(la[t]||~t.indexOf("adius")))return m=_?e.getBBox()[l?"width":"height"]:e[u],Ri(f?r/m*h:r/100*m);if(a[l?"width":"height"]=h+(d?o:n),v=n!=="rem"&&~t.indexOf("adius")||n==="em"&&e.appendChild&&!c?e:e.parentNode,_&&(v=(e.ownerSVGElement||{}).parentNode),(!v||v===Za||!v.appendChild)&&(v=Za.body),g=v._gsap,g&&f&&g.width&&l&&g.time===Ps.time&&!g.uncache)return Ri(r/g.width*h);if(f&&(t==="height"||t==="width")){var y=e.style[t];e.style[t]=h+n,m=e[u],y?e.style[t]=y:hc(e,t)}else(f||o==="%")&&!fF[Vo(v,"display")]&&(a.position=Vo(e,"position")),v===e&&(a.position="static"),v.appendChild(cc),m=cc[u],v.removeChild(cc),a.position="absolute";return l&&f&&(g=rc(v),g.time=Ps.time,g.width=v[u]),Ri(d?m*r/h:m&&r?h/m*r:0)},ca=function(e,t,i,n){var r;return Sx||Cx(),t in zo&&t!=="transform"&&(t=zo[t],~t.indexOf(",")&&(t=t.split(",")[0])),la[t]&&t!=="transform"?(r=af(e,n),r=t!=="transformOrigin"?r[t]:r.svg?r.origin:tg(Vo(e,cs))+" "+r.zOrigin+"px"):(r=e.style[t],(!r||r==="auto"||n||~(r+"").indexOf("calc("))&&(r=eg[t]&&eg[t](e,t,i)||Vo(e,t)||qE(e,t)||(t==="opacity"?1:0))),i&&!~(r+"").trim().indexOf(" ")?$a(e,t,r,i)+i:r},pF=function(e,t,i,n){if(!i||i==="none"){var r=lh(t,e,1),o=r&&Vo(e,r,1);o&&o!==i?(t=r,i=o):t==="borderColor"&&(i=Vo(e,"borderTopColor"))}var a=new as(this._pt,e.style,t,0,1,CT),l=0,c=0,u,h,d,f,m,v,g,_,y,w,x,M;if(a.b=i,a.e=n,i+="",n+="",n==="auto"&&(v=e.style[t],e.style[t]=n,n=Vo(e,t)||n,v?e.style[t]=v:hc(e,t)),u=[i,n],_T(u),i=u[0],n=u[1],d=i.match(Ju)||[],M=n.match(Ju)||[],M.length){for(;h=Ju.exec(n);)g=h[0],y=n.substring(l,h.index),m?m=(m+1)%5:(y.substr(-5)==="rgba("||y.substr(-5)==="hsla(")&&(m=1),g!==(v=d[c++]||"")&&(f=parseFloat(v)||0,x=v.substr((f+"").length),g.charAt(1)==="="&&(g=Qu(f,g)+x),_=parseFloat(g),w=g.substr((_+"").length),l=Ju.lastIndex-w.length,w||(w=w||Ms.units[t]||x,l===n.length&&(n+=w,a.e+=w)),x!==w&&(f=$a(e,t,v,w)||0),a._pt={_next:a._pt,p:y||c===1?y:",",s:f,c:_-f,m:m&&m<4||t==="zIndex"?Math.round:0});a.c=l-1;)a=r[c],la[a]&&(l=1,a=a==="transformOrigin"?cs:_i),hc(i,a);l&&(hc(i,_i),o&&(o.svg&&i.removeAttribute("transform"),n.scale=n.rotate=n.translate="none",af(i,1),o.uncache=1,FT(n)))}},eg={clearProps:function(e,t,i,n,r){if(r.data!=="isFromStart"){var o=e._pt=new as(e._pt,t,i,0,0,gF);return o.u=n,o.pr=-10,o.tween=r,e._props.push(i),1}}},of=[1,0,0,1,0,0],jT={},qT=function(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},ZT=function(e){var t=Vo(e,_i);return qT(t)?of:t.substr(7).match(zE).map(Ri)},Px=function(e,t){var i=e._gsap||rc(e),n=e.style,r=ZT(e),o,a,l,c;return i.svg&&e.getAttribute("transform")?(l=e.transform.baseVal.consolidate().matrix,r=[l.a,l.b,l.c,l.d,l.e,l.f],r.join(",")==="1,0,0,1,0,0"?of:r):(r===of&&!e.offsetParent&&e!==sh&&!i.svg&&(l=n.display,n.display="block",o=e.parentNode,(!o||!e.offsetParent&&!e.getBoundingClientRect().width)&&(c=1,a=e.nextElementSibling,sh.appendChild(e)),r=ZT(e),l?n.display=l:hc(e,"display"),c&&(a?o.insertBefore(e,a):o?o.appendChild(e):sh.removeChild(e))),t&&r.length>6?[r[0],r[1],r[4],r[5],r[12],r[13]]:r)},Rx=function(e,t,i,n,r,o){var a=e._gsap,l=r||Px(e,!0),c=a.xOrigin||0,u=a.yOrigin||0,h=a.xOffset||0,d=a.yOffset||0,f=l[0],m=l[1],v=l[2],g=l[3],_=l[4],y=l[5],w=t.split(" "),x=parseFloat(w[0])||0,M=parseFloat(w[1])||0,C,T,A,P;i?l!==of&&(T=f*g-m*v)&&(A=x*(g/T)+M*(-v/T)+(v*y-g*_)/T,P=x*(-m/T)+M*(f/T)-(f*y-m*_)/T,x=A,M=P):(C=HT(e),x=C.x+(~w[0].indexOf("%")?x/100*C.width:x),M=C.y+(~(w[1]||w[0]).indexOf("%")?M/100*C.height:M)),n||n!==!1&&a.smooth?(_=x-c,y=M-u,a.xOffset=h+(_*f+y*v)-_,a.yOffset=d+(_*m+y*g)-y):a.xOffset=a.yOffset=0,a.xOrigin=x,a.yOrigin=M,a.smooth=!!n,a.origin=t,a.originIsAbsolute=!!i,e.style[cs]="0px 0px",o&&(Ka(o,a,"xOrigin",c,x),Ka(o,a,"yOrigin",u,M),Ka(o,a,"xOffset",h,a.xOffset),Ka(o,a,"yOffset",d,a.yOffset)),e.setAttribute("data-svg-origin",x+" "+M)},af=function(e,t){var i=e._gsap||new wT(e);if("x"in i&&!t&&!i.uncache)return i;var n=e.style,r=i.scaleX<0,o="px",a="deg",l=getComputedStyle(e),c=Vo(e,cs)||"0",u,h,d,f,m,v,g,_,y,w,x,M,C,T,A,P,E,I,R,U,L,k,z,G,W,q,O,B,J,re,K,Q;return u=h=d=v=g=_=y=w=x=0,f=m=1,i.svg=!!(e.getCTM&&WT(e)),l.translate&&((l.translate!=="none"||l.scale!=="none"||l.rotate!=="none")&&(n[_i]=(l.translate!=="none"?"translate3d("+(l.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(l.rotate!=="none"?"rotate("+l.rotate+") ":"")+(l.scale!=="none"?"scale("+l.scale.split(" ").join(",")+") ":"")+(l[_i]!=="none"?l[_i]:"")),n.scale=n.rotate=n.translate="none"),T=Px(e,i.svg),i.svg&&(i.uncache?(W=e.getBBox(),c=i.xOrigin-W.x+"px "+(i.yOrigin-W.y)+"px",G=""):G=!t&&e.getAttribute("data-svg-origin"),Rx(e,G||c,!!G||i.originIsAbsolute,i.smooth!==!1,T)),M=i.xOrigin||0,C=i.yOrigin||0,T!==of&&(I=T[0],R=T[1],U=T[2],L=T[3],u=k=T[4],h=z=T[5],T.length===6?(f=Math.sqrt(I*I+R*R),m=Math.sqrt(L*L+U*U),v=I||R?ah(R,I)*uc:0,y=U||L?ah(U,L)*uc+v:0,y&&(m*=Math.abs(Math.cos(y*oh))),i.svg&&(u-=M-(M*I+C*U),h-=C-(M*R+C*L))):(Q=T[6],re=T[7],O=T[8],B=T[9],J=T[10],K=T[11],u=T[12],h=T[13],d=T[14],A=ah(Q,J),g=A*uc,A&&(P=Math.cos(-A),E=Math.sin(-A),G=k*P+O*E,W=z*P+B*E,q=Q*P+J*E,O=k*-E+O*P,B=z*-E+B*P,J=Q*-E+J*P,K=re*-E+K*P,k=G,z=W,Q=q),A=ah(-U,J),_=A*uc,A&&(P=Math.cos(-A),E=Math.sin(-A),G=I*P-O*E,W=R*P-B*E,q=U*P-J*E,K=L*E+K*P,I=G,R=W,U=q),A=ah(R,I),v=A*uc,A&&(P=Math.cos(A),E=Math.sin(A),G=I*P+R*E,W=k*P+z*E,R=R*P-I*E,z=z*P-k*E,I=G,k=W),g&&Math.abs(g)+Math.abs(v)>359.9&&(g=v=0,_=180-_),f=Ri(Math.sqrt(I*I+R*R+U*U)),m=Ri(Math.sqrt(z*z+Q*Q)),A=ah(k,z),y=Math.abs(A)>2e-4?A*uc:0,x=K?1/(K<0?-K:K):0),i.svg&&(G=e.getAttribute("transform"),i.forceCSS=e.setAttribute("transform","")||!qT(Vo(e,_i)),G&&e.setAttribute("transform",G))),Math.abs(y)>90&&Math.abs(y)<270&&(r?(f*=-1,y+=v<=0?180:-180,v+=v<=0?180:-180):(m*=-1,y+=y<=0?180:-180)),t=t||i.uncache,i.x=u-((i.xPercent=u&&(!t&&i.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-u)?-50:0)))?e.offsetWidth*i.xPercent/100:0)+o,i.y=h-((i.yPercent=h&&(!t&&i.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-h)?-50:0)))?e.offsetHeight*i.yPercent/100:0)+o,i.z=d+o,i.scaleX=Ri(f),i.scaleY=Ri(m),i.rotation=Ri(v)+a,i.rotationX=Ri(g)+a,i.rotationY=Ri(_)+a,i.skewX=y+a,i.skewY=w+a,i.transformPerspective=x+o,(i.zOrigin=parseFloat(c.split(" ")[2])||!t&&i.zOrigin||0)&&(n[cs]=tg(c)),i.xOffset=i.yOffset=0,i.force3D=Ms.force3D,i.renderTransform=i.svg?_F:BT?KT:vF,i.uncache=0,i},tg=function(e){return(e=e.split(" "))[0]+" "+e[1]},Dx=function(e,t,i){var n=Pr(t);return Ri(parseFloat(t)+parseFloat($a(e,"x",i+"px",n)))+n},vF=function(e,t){t.z="0px",t.rotationY=t.rotationX="0deg",t.force3D=0,KT(e,t)},dc="0deg",lf="0px",fc=") ",KT=function(e,t){var i=t||this,n=i.xPercent,r=i.yPercent,o=i.x,a=i.y,l=i.z,c=i.rotation,u=i.rotationY,h=i.rotationX,d=i.skewX,f=i.skewY,m=i.scaleX,v=i.scaleY,g=i.transformPerspective,_=i.force3D,y=i.target,w=i.zOrigin,x="",M=_==="auto"&&e&&e!==1||_===!0;if(w&&(h!==dc||u!==dc)){var C=parseFloat(u)*oh,T=Math.sin(C),A=Math.cos(C),P;C=parseFloat(h)*oh,P=Math.cos(C),o=Dx(y,o,T*P*-w),a=Dx(y,a,-Math.sin(C)*-w),l=Dx(y,l,A*P*-w+w)}g!==lf&&(x+="perspective("+g+fc),(n||r)&&(x+="translate("+n+"%, "+r+"%) "),(M||o!==lf||a!==lf||l!==lf)&&(x+=l!==lf||M?"translate3d("+o+", "+a+", "+l+") ":"translate("+o+", "+a+fc),c!==dc&&(x+="rotate("+c+fc),u!==dc&&(x+="rotateY("+u+fc),h!==dc&&(x+="rotateX("+h+fc),(d!==dc||f!==dc)&&(x+="skew("+d+", "+f+fc),(m!==1||v!==1)&&(x+="scale("+m+", "+v+fc),y.style[_i]=x||"translate(0, 0)"},_F=function(e,t){var i=t||this,n=i.xPercent,r=i.yPercent,o=i.x,a=i.y,l=i.rotation,c=i.skewX,u=i.skewY,h=i.scaleX,d=i.scaleY,f=i.target,m=i.xOrigin,v=i.yOrigin,g=i.xOffset,_=i.yOffset,y=i.forceCSS,w=parseFloat(o),x=parseFloat(a),M,C,T,A,P;l=parseFloat(l),c=parseFloat(c),u=parseFloat(u),u&&(u=parseFloat(u),c+=u,l+=u),l||c?(l*=oh,c*=oh,M=Math.cos(l)*h,C=Math.sin(l)*h,T=Math.sin(l-c)*-d,A=Math.cos(l-c)*d,c&&(u*=oh,P=Math.tan(c-u),P=Math.sqrt(1+P*P),T*=P,A*=P,u&&(P=Math.tan(u),P=Math.sqrt(1+P*P),M*=P,C*=P)),M=Ri(M),C=Ri(C),T=Ri(T),A=Ri(A)):(M=h,A=d,C=T=0),(w&&!~(o+"").indexOf("px")||x&&!~(a+"").indexOf("px"))&&(w=$a(f,"x",o,"px"),x=$a(f,"y",a,"px")),(m||v||g||_)&&(w=Ri(w+m-(m*M+v*T)+g),x=Ri(x+v-(m*C+v*A)+_)),(n||r)&&(P=f.getBBox(),w=Ri(w+n/100*P.width),x=Ri(x+r/100*P.height)),P="matrix("+M+","+C+","+T+","+A+","+w+","+x+")",f.setAttribute("transform",P),y&&(f.style[_i]=P)},yF=function(e,t,i,n,r){var o=360,a=ir(r),l=parseFloat(r)*(a&&~r.indexOf("rad")?uc:1),c=l-n,u=n+c+"deg",h,d;return a&&(h=r.split("_")[1],h==="short"&&(c%=o,c!==c%(o/2)&&(c+=c<0?o:-360)),h==="cw"&&c<0?c=(c+o*UT)%o-~~(c/o)*o:h==="ccw"&&c>0&&(c=(c-o*UT)%o-~~(c/o)*o)),e._pt=d=new as(e._pt,t,i,n,c,nF),d.e=u,d.u="deg",e._props.push(i),d},$T=function(e,t){for(var i in t)e[i]=t[i];return e},xF=function(e,t,i){var n=$T({},i._gsap),r="perspective,force3D,transformOrigin,svgOrigin",o=i.style,a,l,c,u,h,d,f,m;n.svg?(c=i.getAttribute("transform"),i.setAttribute("transform",""),o[_i]=t,a=af(i,1),hc(i,_i),i.setAttribute("transform",c)):(c=getComputedStyle(i)[_i],o[_i]=t,a=af(i,1),o[_i]=c);for(l in la)c=n[l],u=a[l],c!==u&&r.indexOf(l)<0&&(f=Pr(c),m=Pr(u),h=f!==m?$a(i,l,c,m):parseFloat(c),d=parseFloat(u),e._pt=new as(e._pt,a,l,h,d-h,Tx),e._pt.u=m||0,e._props.push(l));$T(a,n)};os("padding,margin,Width,Radius",function(s,e){var t="Top",i="Right",n="Bottom",r="Left",o=(e<3?[t,i,n,r]:[t+r,t+i,n+i,n+r]).map(function(a){return e<2?s+a:"border"+a+s});eg[e>1?"border"+s:s]=function(a,l,c,u,h){var d,f;if(arguments.length<4)return d=o.map(function(m){return ca(a,m,c)}),f=d.join(" "),f.split(d[0]).length===5?d[0]:f;d=(u+"").split(" "),f={},o.forEach(function(m,v){return f[m]=d[v]=d[v]||d[(v-1)/2|0]}),a.init(l,f,h)}});var JT={name:"css",register:Cx,targetTest:function(e){return e.style&&e.nodeType},init:function(e,t,i,n,r){var o=this._props,a=e.style,l=i.vars.startAt,c,u,h,d,f,m,v,g,_,y,w,x,M,C,T,A;Sx||Cx(),this.styles=this.styles||NT(e),A=this.styles.props,this.tween=i;for(v in t)if(v!=="autoRound"&&(u=t[v],!(Ts[v]&&ST(v,t,i,n,e,r)))){if(f=typeof u,m=eg[v],f==="function"&&(u=u.call(i,n,e,r),f=typeof u),f==="string"&&~u.indexOf("random(")&&(u=Qd(u)),m)m(this,e,v,u,i)&&(T=1);else if(v.substr(0,2)==="--")c=(getComputedStyle(e).getPropertyValue(v)+"").trim(),u+="",ja.lastIndex=0,ja.test(c)||(g=Pr(c),_=Pr(u)),_?g!==_&&(c=$a(e,v,c,_)+_):g&&(u+=g),this.add(a,"setProperty",c,u,n,r,0,0,v),o.push(v),A.push(v,0,a[v]);else if(f!=="undefined"){if(l&&v in l?(c=typeof l[v]=="function"?l[v].call(i,n,e,r):l[v],ir(c)&&~c.indexOf("random(")&&(c=Qd(c)),Pr(c+"")||c==="auto"||(c+=Ms.units[v]||Pr(ca(e,v))||""),(c+"").charAt(1)==="="&&(c=ca(e,v))):c=ca(e,v),d=parseFloat(c),y=f==="string"&&u.charAt(1)==="="&&u.substr(0,2),y&&(u=u.substr(2)),h=parseFloat(u),v in zo&&(v==="autoAlpha"&&(d===1&&ca(e,"visibility")==="hidden"&&h&&(d=0),A.push("visibility",0,a.visibility),Ka(this,a,"visibility",d?"inherit":"hidden",h?"inherit":"hidden",!h)),v!=="scale"&&v!=="transform"&&(v=zo[v],~v.indexOf(",")&&(v=v.split(",")[0]))),w=v in la,w){if(this.styles.save(v),x||(M=e._gsap,M.renderTransform&&!t.parseTransform||af(e,t.parseTransform),C=t.smoothOrigin!==!1&&M.smooth,x=this._pt=new as(this._pt,a,_i,0,1,M.renderTransform,M,0,-1),x.dep=1),v==="scale")this._pt=new as(this._pt,M,"scaleY",M.scaleY,(y?Qu(M.scaleY,y+h):h)-M.scaleY||0,Tx),this._pt.u=0,o.push("scaleY",v),v+="X";else if(v==="transformOrigin"){A.push(cs,0,a[cs]),u=mF(u),M.svg?Rx(e,u,0,C,0,this):(_=parseFloat(u.split(" ")[2])||0,_!==M.zOrigin&&Ka(this,M,"zOrigin",M.zOrigin,_),Ka(this,a,v,tg(c),tg(u)));continue}else if(v==="svgOrigin"){Rx(e,u,1,C,0,this);continue}else if(v in jT){yF(this,M,v,d,y?Qu(d,y+u):u);continue}else if(v==="smoothOrigin"){Ka(this,M,"smooth",M.smooth,u);continue}else if(v==="force3D"){M[v]=u;continue}else if(v==="transform"){xF(this,u,e);continue}}else v in a||(v=lh(v)||v);if(w||(h||h===0)&&(d||d===0)&&!tF.test(u)&&v in a)g=(c+"").substr((d+"").length),h||(h=0),_=Pr(u)||(v in Ms.units?Ms.units[v]:g),g!==_&&(d=$a(e,v,c,_)),this._pt=new as(this._pt,w?M:a,v,d,(y?Qu(d,y+h):h)-d,!w&&(_==="px"||v==="zIndex")&&t.autoRound!==!1?rF:Tx),this._pt.u=_||0,g!==_&&_!=="%"&&(this._pt.b=c,this._pt.r=iF);else if(v in a)pF.call(this,e,v,c,y?y+u:u);else if(v in e)this.add(e,v,c||e[v],y?y+u:u,n,r);else if(v!=="parseTransform"){ex(v,u);continue}w||(v in a?A.push(v,0,a[v]):typeof e[v]=="function"?A.push(v,2,e[v]()):A.push(v,1,c||e[v])),o.push(v)}}T&&PT(this)},render:function(e,t){if(t.tween._time||!Mx())for(var i=t._pt;i;)i.r(e,i.d),i=i._next;else t.styles.revert()},get:ca,aliases:zo,getSetter:function(e,t,i){var n=zo[t];return n&&n.indexOf(",")<0&&(t=n),t in la&&t!==cs&&(e._gsap.x||ca(e,"x"))?i&<===i?t==="scale"?lF:aF:(LT=i||{})&&(t==="scale"?cF:uF):e.style&&!qy(e.style[t])?sF:~t.indexOf("-")?oF:_x(e,t)},core:{_removeProperty:hc,_getMatrix:Px}};ls.utils.checkPrefix=lh,ls.core.getStyleSaver=NT,function(s,e,t,i){var n=os(s+","+e+","+t,function(r){la[r]=1});os(e,function(r){Ms.units[r]="deg",jT[r]=1}),zo[n[13]]=s+","+e,os(i,function(r){var o=r.split(":");zo[o[1]]=n[o[0]]})}("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY"),os("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(s){Ms.units[s]="px"}),ls.registerPlugin(JT);var Cn=ls.registerPlugin(JT)||ls;Cn.core.Tween;function Ix(s,e){if(new.target)return Tt({component:Ix,...s});Mt(e,!1);const t=1.06,i=.024,n=.125;function r(l,c){let u=null;return function(...h){const d=this;clearTimeout(u),u=setTimeout(()=>{l.apply(d,h)},c)}}function o(){let l=[],c,u=[];const h=new Map,d=()=>{const v=()=>{const x="hero-animation";if(h.get(x))return;h.set(x,!0),l.forEach(U=>U.revert());const M=document.querySelector(".hero-flora"),C=document.querySelector(".hero-ghnassia");if(!M||!C){h.set(x,!1);return}const A=window.getComputedStyle(M).transform;let P="0px";if(A!=="none"){const U=A.match(/matrix.*\((.+)\)/);U&&U[1]&&(P=U[1].split(", ")[5]||"0px")}const E=new Vm(M,{types:"chars"}),I=new Vm(C,{types:"chars"});l.push(E,I);const R=Cn.timeline({paused:!0});R.eventCallback("onStart",()=>{M.style.transform="translateY(0)",C.style.transform="translateY(0)"}),R.from(E.chars||[],{y:`${P}`,duration:t,ease:"Power4.out",stagger:{each:i}}),R.from(I.chars||[],{y:`${P}`,duration:t,ease:"Power4.out",stagger:{each:i}},"-=78%"),R.eventCallback("onComplete",()=>{const U=[...E.chars||[],...I.chars||[]].filter(Boolean);U.length>0&&U.forEach(L=>{L.style.transition="transform 0.4s ease",L.addEventListener("mouseenter",()=>{Cn.to(L,{y:"-1.5rem",ease:"power4.out",duration:n})});const k=()=>{Cn.to(L,{y:"0%",ease:"power4.in",duration:n})};L.addEventListener("mouseleave",k)}),h.set(x,!1)}),R.play(),setTimeout(()=>{h.set(x,!1)},100)},g=document.querySelector(".home-hero-container");if(g){const x=new ResizeObserver(r(()=>{h.get("hero-animation")||v()},300));x.observe(g),c=x}const _=r(()=>{h.get("hero-animation")||v()},300);window.addEventListener("resize",_);const y=document.querySelectorAll("[animate-text-duration]"),w=x=>{const M=x.id||`text-element-${Math.random().toString(36).substr(2,9)}`;if(h.get(M))return;h.set(M,!0);const C=l.find(E=>{var I;return(I=E.lines)==null?void 0:I.some(R=>R.firstChild===x)});C&&C.revert();const T=parseFloat(x.getAttribute("animate-text-duration")||"1"),A=parseFloat(x.getAttribute("animate-delay")||"0");x.textContent;const P=window.getComputedStyle(x);P.lineHeight,P.fontSize,requestAnimationFrame(()=>{const E=new Vm(x,{types:"lines,words",lineClass:"split-line"});l.push(E),Cn.set(x,{opacity:1}),E.lines&&(E.lines.forEach(I=>{I.style.overflowY="hidden",I.style.overflowX="visible",I.style.display="block",I.style.width="fit-content",I.style.whiteSpace="nowrap",I.style.position="relative",I.style.boxSizing="border-box";const R=document.createElement("div");R.innerHTML=I.innerHTML,R.style.display="inline-block",I.innerHTML="",I.appendChild(R)}),Cn.fromTo(E.lines.map(I=>I.firstChild),{y:"150%"},{y:"0%",duration:T,delay:A,stagger:{each:.2,ease:"power5.in"},scrollTrigger:{trigger:x,start:"top bottom",toggleActions:"play none none none"}})),setTimeout(()=>{h.set(M,!1)},100)})};return y.forEach(x=>{x.style.position="relative";const M=new ResizeObserver(r(()=>{const T=x.id||`text-element-${Math.random().toString(36).substr(2,9)}`;h.get(T)||w(x)},300));new ResizeObserver(r(()=>{w(x)},300)).observe(document.body),M.observe(x.parentElement),u.push(M)}),()=>{window.removeEventListener("resize",_),c&&c.disconnect(),u.forEach(x=>{x instanceof ResizeObserver&&x.disconnect()}),l.forEach(x=>x.revert()),Cn.killTweensOf(document.querySelectorAll(".hero-flora, .hero-ghnassia"))}},f=document.querySelector(".code-embed-4"),m=document.querySelector(".preface-loader-wrapper");if(f&&m){const v=()=>{Cn.to(m,{height:0,transformOrigin:"top bottom",duration:.8,delay:.3,ease:"Power4.out",onStart:()=>{d()},onComplete:()=>{m.style.visibility="hidden"}})},g=new MutationObserver(_=>{_.forEach(y=>{y.type==="attributes"&&y.attributeName==="style"&&parseFloat(f.style.opacity||"1")===1&&v()})});setTimeout(()=>{v()},1e3),g.observe(f,{attributes:!0})}else d()}let a=!1;return Gr(()=>{a||(o(),a=!0)}),go(),Et({$set:Ct,$on:(l,c)=>At(e,l,c)})}Pt(Ix,{},[],[],!0);var bF="1.1.20";function QT(s,e,t){return Math.max(s,Math.min(e,t))}function wF(s,e,t){return(1-t)*s+t*e}function SF(s,e,t,i){return wF(s,e,1-Math.exp(-t*i))}function MF(s,e){return(s%e+e)%e}var EF=class{constructor(){ht(this,"isRunning",!1);ht(this,"value",0);ht(this,"from",0);ht(this,"to",0);ht(this,"currentTime",0);ht(this,"lerp");ht(this,"duration");ht(this,"easing");ht(this,"onUpdate")}advance(s){var t;if(!this.isRunning)return;let e=!1;if(this.duration&&this.easing){this.currentTime+=s;const i=QT(0,this.currentTime/this.duration,1);e=i>=1;const n=e?1:this.easing(i);this.value=this.from+(this.to-this.from)*n}else this.lerp?(this.value=SF(this.value,this.to,this.lerp*60,s),Math.round(this.value)===this.to&&(this.value=this.to,e=!0)):(this.value=this.to,e=!0);e&&this.stop(),(t=this.onUpdate)==null||t.call(this,this.value,e)}stop(){this.isRunning=!1}fromTo(s,e,{lerp:t,duration:i,easing:n,onStart:r,onUpdate:o}){this.from=this.value=s,this.to=e,this.lerp=t,this.duration=i,this.easing=n,this.currentTime=0,this.isRunning=!0,r==null||r(),this.onUpdate=o}};function TF(s,e){let t;return function(...i){let n=this;clearTimeout(t),t=setTimeout(()=>{t=void 0,s.apply(n,i)},e)}}var AF=class{constructor(s,e,{autoResize:t=!0,debounce:i=250}={}){ht(this,"width",0);ht(this,"height",0);ht(this,"scrollHeight",0);ht(this,"scrollWidth",0);ht(this,"debouncedResize");ht(this,"wrapperResizeObserver");ht(this,"contentResizeObserver");ht(this,"resize",()=>{this.onWrapperResize(),this.onContentResize()});ht(this,"onWrapperResize",()=>{this.wrapper instanceof Window?(this.width=window.innerWidth,this.height=window.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)});ht(this,"onContentResize",()=>{this.wrapper instanceof Window?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)});this.wrapper=s,this.content=e,t&&(this.debouncedResize=TF(this.resize,i),this.wrapper instanceof Window?window.addEventListener("resize",this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){var s,e;(s=this.wrapperResizeObserver)==null||s.disconnect(),(e=this.contentResizeObserver)==null||e.disconnect(),this.wrapper===window&&this.debouncedResize&&window.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}},eA=class{constructor(){ht(this,"events",{})}emit(s,...e){var i;let t=this.events[s]||[];for(let n=0,r=t.length;n{var i;this.events[s]=(i=this.events[s])==null?void 0:i.filter(n=>e!==n)}}off(s,e){var t;this.events[s]=(t=this.events[s])==null?void 0:t.filter(i=>e!==i)}destroy(){this.events={}}},tA=100/6,Ja={passive:!1},CF=class{constructor(s,e={wheelMultiplier:1,touchMultiplier:1}){ht(this,"touchStart",{x:0,y:0});ht(this,"lastDelta",{x:0,y:0});ht(this,"window",{width:0,height:0});ht(this,"emitter",new eA);ht(this,"onTouchStart",s=>{const{clientX:e,clientY:t}=s.targetTouches?s.targetTouches[0]:s;this.touchStart.x=e,this.touchStart.y=t,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:s})});ht(this,"onTouchMove",s=>{const{clientX:e,clientY:t}=s.targetTouches?s.targetTouches[0]:s,i=-(e-this.touchStart.x)*this.options.touchMultiplier,n=-(t-this.touchStart.y)*this.options.touchMultiplier;this.touchStart.x=e,this.touchStart.y=t,this.lastDelta={x:i,y:n},this.emitter.emit("scroll",{deltaX:i,deltaY:n,event:s})});ht(this,"onTouchEnd",s=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:s})});ht(this,"onWheel",s=>{let{deltaX:e,deltaY:t,deltaMode:i}=s;const n=i===1?tA:i===2?this.window.width:1,r=i===1?tA:i===2?this.window.height:1;e*=n,t*=r,e*=this.options.wheelMultiplier,t*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:e,deltaY:t,event:s})});ht(this,"onWindowResize",()=>{this.window={width:window.innerWidth,height:window.innerHeight}});this.element=s,this.options=e,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,Ja),this.element.addEventListener("touchstart",this.onTouchStart,Ja),this.element.addEventListener("touchmove",this.onTouchMove,Ja),this.element.addEventListener("touchend",this.onTouchEnd,Ja)}on(s,e){return this.emitter.on(s,e)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,Ja),this.element.removeEventListener("touchstart",this.onTouchStart,Ja),this.element.removeEventListener("touchmove",this.onTouchMove,Ja),this.element.removeEventListener("touchend",this.onTouchEnd,Ja)}},PF=class{constructor({wrapper:s=window,content:e=document.documentElement,eventsTarget:t=s,smoothWheel:i=!0,syncTouch:n=!1,syncTouchLerp:r=.075,touchInertiaMultiplier:o=35,duration:a,easing:l=C=>Math.min(1,1.001-Math.pow(2,-10*C)),lerp:c=.1,infinite:u=!1,orientation:h="vertical",gestureOrientation:d="vertical",touchMultiplier:f=1,wheelMultiplier:m=1,autoResize:v=!0,prevent:g,virtualScroll:_,overscroll:y=!0,autoRaf:w=!1,anchors:x=!1,__experimental__naiveDimensions:M=!1}={}){ht(this,"_isScrolling",!1);ht(this,"_isStopped",!1);ht(this,"_isLocked",!1);ht(this,"_preventNextNativeScrollEvent",!1);ht(this,"_resetVelocityTimeout",null);ht(this,"__rafID",null);ht(this,"isTouching");ht(this,"time",0);ht(this,"userData",{});ht(this,"lastVelocity",0);ht(this,"velocity",0);ht(this,"direction",0);ht(this,"options");ht(this,"targetScroll");ht(this,"animatedScroll");ht(this,"animate",new EF);ht(this,"emitter",new eA);ht(this,"dimensions");ht(this,"virtualScroll");ht(this,"onScrollEnd",s=>{s instanceof CustomEvent||(this.isScrolling==="smooth"||this.isScrolling===!1)&&s.stopPropagation()});ht(this,"dispatchScrollendEvent",()=>{this.options.wrapper.dispatchEvent(new CustomEvent("scrollend",{bubbles:this.options.wrapper===window,detail:{lenisScrollEnd:!0}}))});ht(this,"onClick",s=>{const t=s.composedPath().find(i=>{var n;return i instanceof HTMLAnchorElement&&((n=i.getAttribute("href"))==null?void 0:n.startsWith("#"))});if(t){const i=t.getAttribute("href");if(i){const n=typeof this.options.anchors=="object"&&this.options.anchors?this.options.anchors:void 0;this.scrollTo(i,n)}}});ht(this,"onPointerDown",s=>{s.button===1&&this.reset()});ht(this,"onVirtualScroll",s=>{if(typeof this.options.virtualScroll=="function"&&this.options.virtualScroll(s)===!1)return;const{deltaX:e,deltaY:t,event:i}=s;if(this.emitter.emit("virtual-scroll",{deltaX:e,deltaY:t,event:i}),i.ctrlKey||i.lenisStopPropagation)return;const n=i.type.includes("touch"),r=i.type.includes("wheel");this.isTouching=i.type==="touchstart"||i.type==="touchmove";const o=e===0&&t===0;if(this.options.syncTouch&&n&&i.type==="touchstart"&&o&&!this.isStopped&&!this.isLocked){this.reset();return}const l=this.options.gestureOrientation==="vertical"&&t===0||this.options.gestureOrientation==="horizontal"&&e===0;if(o||l)return;let c=i.composedPath();c=c.slice(0,c.indexOf(this.rootElement));const u=this.options.prevent;if(c.find(g=>{var _,y,w;return g instanceof HTMLElement&&(typeof u=="function"&&(u==null?void 0:u(g))||((_=g.hasAttribute)==null?void 0:_.call(g,"data-lenis-prevent"))||n&&((y=g.hasAttribute)==null?void 0:y.call(g,"data-lenis-prevent-touch"))||r&&((w=g.hasAttribute)==null?void 0:w.call(g,"data-lenis-prevent-wheel")))}))return;if(this.isStopped||this.isLocked){i.preventDefault();return}if(!(this.options.syncTouch&&n||this.options.smoothWheel&&r)){this.isScrolling="native",this.animate.stop(),i.lenisStopPropagation=!0;return}let d=t;this.options.gestureOrientation==="both"?d=Math.abs(t)>Math.abs(e)?t:e:this.options.gestureOrientation==="horizontal"&&(d=e),(!this.options.overscroll||this.options.infinite||this.options.wrapper!==window&&(this.animatedScroll>0&&this.animatedScroll0||this.animatedScroll===this.limit&&t<0))&&(i.lenisStopPropagation=!0),i.preventDefault();const f=n&&this.options.syncTouch,v=n&&i.type==="touchend"&&Math.abs(d)>5;v&&(d=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+d,{programmatic:!1,...f?{lerp:v?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}})});ht(this,"onNativeScroll",()=>{if(this._resetVelocityTimeout!==null&&(clearTimeout(this._resetVelocityTimeout),this._resetVelocityTimeout=null),this._preventNextNativeScrollEvent){this._preventNextNativeScrollEvent=!1;return}if(this.isScrolling===!1||this.isScrolling==="native"){const s=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-s,this.direction=Math.sign(this.animatedScroll-s),this.isStopped||(this.isScrolling="native"),this.emit(),this.velocity!==0&&(this._resetVelocityTimeout=setTimeout(()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()},400))}});ht(this,"raf",s=>{const e=s-(this.time||s);this.time=s,this.animate.advance(e*.001),this.options.autoRaf&&(this.__rafID=requestAnimationFrame(this.raf))});window.lenisVersion=bF,(!s||s===document.documentElement)&&(s=window),this.options={wrapper:s,content:e,eventsTarget:t,smoothWheel:i,syncTouch:n,syncTouchLerp:r,touchInertiaMultiplier:o,duration:a,easing:l,lerp:c,infinite:u,gestureOrientation:d,orientation:h,touchMultiplier:f,wheelMultiplier:m,autoResize:v,prevent:g,virtualScroll:_,overscroll:y,autoRaf:w,anchors:x,__experimental__naiveDimensions:M},this.dimensions=new AF(s,e,{autoResize:v}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.anchors&&this.options.wrapper===window&&this.options.wrapper.addEventListener("click",this.onClick,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new CF(t,{touchMultiplier:f,wheelMultiplier:m}),this.virtualScroll.on("scroll",this.onVirtualScroll),this.options.autoRaf&&(this.__rafID=requestAnimationFrame(this.raf))}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),this.options.anchors&&this.options.wrapper===window&&this.options.wrapper.removeEventListener("click",this.onClick,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName(),this.__rafID&&cancelAnimationFrame(this.__rafID)}on(s,e){return this.emitter.on(s,e)}off(s,e){return this.emitter.off(s,e)}setScroll(s){this.isHorizontal?this.options.wrapper.scrollTo({left:s,behavior:"instant"}):this.options.wrapper.scrollTo({top:s,behavior:"instant"})}resize(){this.dimensions.resize(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){this.isStopped&&(this.reset(),this.isStopped=!1)}stop(){this.isStopped||(this.reset(),this.isStopped=!0)}scrollTo(s,{offset:e=0,immediate:t=!1,lock:i=!1,duration:n=this.options.duration,easing:r=this.options.easing,lerp:o=this.options.lerp,onStart:a,onComplete:l,force:c=!1,programmatic:u=!0,userData:h}={}){if(!((this.isStopped||this.isLocked)&&!c)){if(typeof s=="string"&&["top","left","start"].includes(s))s=0;else if(typeof s=="string"&&["bottom","right","end"].includes(s))s=this.limit;else{let d;if(typeof s=="string"?d=document.querySelector(s):s instanceof HTMLElement&&(s!=null&&s.nodeType)&&(d=s),d){if(this.options.wrapper!==window){const m=this.rootElement.getBoundingClientRect();e-=this.isHorizontal?m.left:m.top}const f=d.getBoundingClientRect();s=(this.isHorizontal?f.left:f.top)+this.animatedScroll}}if(typeof s=="number"){if(s+=e,s=Math.round(s),this.options.infinite?u&&(this.targetScroll=this.animatedScroll=this.scroll):s=QT(0,s,this.limit),s===this.targetScroll){a==null||a(this),l==null||l(this);return}if(this.userData=h??{},t){this.animatedScroll=this.targetScroll=s,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),l==null||l(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()});return}u||(this.targetScroll=s),this.animate.fromTo(this.animatedScroll,s,{duration:n,easing:r,lerp:o,onStart:()=>{i&&(this.isLocked=!0),this.isScrolling="smooth",a==null||a(this)},onUpdate:(d,f)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=d-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=d,this.setScroll(this.scroll),u&&(this.targetScroll=d),f||this.emit(),f&&(this.reset(),this.emit(),l==null||l(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()}),this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){this._preventNextNativeScrollEvent=!0,requestAnimationFrame(()=>{this._preventNextNativeScrollEvent=!1})}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){return this.options.__experimental__naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return this.options.orientation==="horizontal"}get actualScroll(){const s=this.options.wrapper;return this.isHorizontal?s.scrollX??s.scrollLeft:s.scrollY??s.scrollTop}get scroll(){return this.options.infinite?MF(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return this.limit===0?1:this.scroll/this.limit}get isScrolling(){return this._isScrolling}set isScrolling(s){this._isScrolling!==s&&(this._isScrolling=s,this.updateClassName())}get isStopped(){return this._isStopped}set isStopped(s){this._isStopped!==s&&(this._isStopped=s,this.updateClassName())}get isLocked(){return this._isLocked}set isLocked(s){this._isLocked!==s&&(this._isLocked=s,this.updateClassName())}get isSmooth(){return this.isScrolling==="smooth"}get className(){let s="lenis";return this.isStopped&&(s+=" lenis-stopped"),this.isLocked&&(s+=" lenis-locked"),this.isScrolling&&(s+=" lenis-scrolling"),this.isScrolling==="smooth"&&(s+=" lenis-smooth"),s}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}};function RF(s){Mn(s,s.v+1)}function DF(s){let e=0,t=js(0),i;return()=>{$M()&&(fe(t),Xu(()=>(e===0&&(i=ws(()=>s(()=>RF(t)))),e+=1,()=>{Py().then(()=>{e-=1,e===0&&(i==null||i(),i=void 0)})})))}}function cf(s){let e;const t=DF(n=>{let r=!1;const o=s.subscribe(a=>{e=a,r&&n()});return r=!0,o});function i(){return $M()?(t(),e):km(s)}return"set"in s?{get current(){return i()},set current(n){s.set(n)}}:{get current(){return i()}}}const Lx=Yd(null,s=>{const e=new PF({duration:1.2,easing:r=>Math.min(1,1.001-Math.pow(2,-10*r)),syncTouch:!0,syncTouchLerp:.025,touchInertiaMultiplier:5,touchMultiplier:2,infinite:!1,lerp:.085});function t(r){e.raf(r),requestAnimationFrame(t)}requestAnimationFrame(t),e.stop(),e.start();let i;function n(){clearTimeout(i),i=setTimeout(()=>{requestAnimationFrame(()=>{e.resize()})},300)}return window.addEventListener("load",n),document.querySelectorAll("img[loading='lazy']").forEach(r=>{r.addEventListener("load",n)}),s(e),()=>{e.destroy(),s(null)}});function IF(s,e){for(var t=0;tl?(r=n,n=m,a=o,o=g):i?n+=m:n=r+(m-r)/(g-a)*(o-a)},h=function(){r=n=i?0:n,a=o=0},d=function(m){var v=a,g=r,_=hf();return(m||m===0)&&m!==n&&u(m),o===a||_-a>c?0:(n+(i?g:-g))/((i?_:o)-v)*1e3};return{update:u,reset:h,getVelocity:d}},ff=function(e,t){return t&&!e._gsapAllow&&e.preventDefault(),e.changedTouches?e.changedTouches[0]:e},aA=function(e){var t=Math.max.apply(Math,e),i=Math.min.apply(Math,e);return Math.abs(t)>=Math.abs(i)?t:i},lA=function(){uf=fr.core.globals().ScrollTrigger,uf&&uf.core&&UF()},cA=function(e){return fr=e||sA(),!ng&&fr&&typeof document<"u"&&document.body&&(Rs=window,Qa=document,el=Qa.documentElement,ch=Qa.body,iA=[Rs,Qa,el,ch],fr.utils.clamp,rA=fr.core.context||function(){},pc="onpointerenter"in ch?"pointer":"mouse",nA=Di.isTouch=Rs.matchMedia&&Rs.matchMedia("(hover: none), (pointer: coarse)").matches?1:"ontouchstart"in Rs||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?2:0,_o=Di.eventTypes=("ontouchstart"in el?"touchstart,touchmove,touchcancel,touchend":"onpointerdown"in el?"pointerdown,pointermove,pointercancel,pointerup":"mousedown,mousemove,mouseup,mouseup").split(","),setTimeout(function(){return oA=0},500),lA(),ng=1),ng};jr.op=Xi,hn.cache=0;var Di=function(){function s(t){this.init(t)}var e=s.prototype;return e.init=function(i){ng||cA(fr)||console.warn("Please gsap.registerPlugin(Observer)"),uf||lA();var n=i.tolerance,r=i.dragMinimum,o=i.type,a=i.target,l=i.lineHeight,c=i.debounce,u=i.preventDefault,h=i.onStop,d=i.onStopDelay,f=i.ignore,m=i.wheelSpeed,v=i.event,g=i.onDragStart,_=i.onDragEnd,y=i.onDrag,w=i.onPress,x=i.onRelease,M=i.onRight,C=i.onLeft,T=i.onUp,A=i.onDown,P=i.onChangeX,E=i.onChangeY,I=i.onChange,R=i.onToggleX,U=i.onToggleY,L=i.onHover,k=i.onHoverEnd,z=i.onMove,G=i.ignoreCheck,W=i.isNormalizer,q=i.onGestureStart,O=i.onGestureEnd,B=i.onWheel,J=i.onEnable,re=i.onDisable,K=i.onClick,Q=i.scrollSpeed,ue=i.capture,le=i.allowClicks,_e=i.lockAxis,Fe=i.onLockAxis;this.target=a=us(a)||el,this.vars=i,f&&(f=fr.utils.toArray(f)),n=n||1e-9,r=r||0,m=m||1,Q=Q||1,o=o||"wheel,touch,pointer",c=c!==!1,l||(l=parseFloat(Rs.getComputedStyle(ch).lineHeight)||22);var Ie,Ee,me,xe,$,Ue,Me,oe=this,Te=0,Ye=0,Oe=i.passive||!u&&i.passive!==!1,j=nl(a,jr),Z=nl(a,Xi),pe=j(),he=Z(),te=~o.indexOf("touch")&&!~o.indexOf("pointer")&&_o[0]==="pointerdown",Se=df(a),ye=a.ownerDocument||Qa,Ae=[0,0,0],Ce=[0,0,0],Ge=0,De=function(){return Ge=hf()},Ve=function(at,ft){return(oe.event=at)&&f&&~f.indexOf(at.target)||ft&&te&&at.pointerType!=="touch"||G&&G(at,ft)},ze=function(){oe._vx.reset(),oe._vy.reset(),Ee.pause(),h&&h(oe)},Ze=function(){var at=oe.deltaX=aA(Ae),ft=oe.deltaY=aA(Ce),Qe=Math.abs(at)>=n,bt=Math.abs(ft)>=n;I&&(Qe||bt)&&I(oe,at,ft,Ae,Ce),Qe&&(M&&oe.deltaX>0&&M(oe),C&&oe.deltaX<0&&C(oe),P&&P(oe),R&&oe.deltaX<0!=Te<0&&R(oe),Te=oe.deltaX,Ae[0]=Ae[1]=Ae[2]=0),bt&&(A&&oe.deltaY>0&&A(oe),T&&oe.deltaY<0&&T(oe),E&&E(oe),U&&oe.deltaY<0!=Ye<0&&U(oe),Ye=oe.deltaY,Ce[0]=Ce[1]=Ce[2]=0),(xe||me)&&(z&&z(oe),me&&(g&&me===1&&g(oe),y&&y(oe),me=0),xe=!1),Ue&&!(Ue=!1)&&Fe&&Fe(oe),$&&(B(oe),$=!1),Ie=0},Le=function(at,ft,Qe){Ae[Qe]+=at,Ce[Qe]+=ft,oe._vx.update(at),oe._vy.update(ft),c?Ie||(Ie=requestAnimationFrame(Ze)):Ze()},ot=function(at,ft){_e&&!Me&&(oe.axis=Me=Math.abs(at)>Math.abs(ft)?"x":"y",Ue=!0),Me!=="y"&&(Ae[2]+=at,oe._vx.update(at,!0)),Me!=="x"&&(Ce[2]+=ft,oe._vy.update(ft,!0)),c?Ie||(Ie=requestAnimationFrame(Ze)):Ze()},tt=function(at){if(!Ve(at,1)){at=ff(at,u);var ft=at.clientX,Qe=at.clientY,bt=ft-oe.x,yt=Qe-oe.y,Rt=oe.isDragging;oe.x=ft,oe.y=Qe,(Rt||(bt||yt)&&(Math.abs(oe.startX-ft)>=r||Math.abs(oe.startY-Qe)>=r))&&(me=Rt?2:1,Rt||(oe.isDragging=!0),ot(bt,yt))}},mt=oe.onPress=function(je){Ve(je,1)||je&&je.button||(oe.axis=Me=null,Ee.pause(),oe.isPressed=!0,je=ff(je),Te=Ye=0,oe.startX=oe.x=je.clientX,oe.startY=oe.y=je.clientY,oe._vx.reset(),oe._vy.reset(),Xr(W?a:ye,_o[1],tt,Oe,!0),oe.deltaX=oe.deltaY=0,w&&w(oe))},ce=oe.onRelease=function(je){if(!Ve(je,1)){Yr(W?a:ye,_o[1],tt,!0);var at=!isNaN(oe.y-oe.startY),ft=oe.isDragging,Qe=ft&&(Math.abs(oe.x-oe.startX)>3||Math.abs(oe.y-oe.startY)>3),bt=ff(je);!Qe&&at&&(oe._vx.reset(),oe._vy.reset(),u&&le&&fr.delayedCall(.08,function(){if(hf()-Ge>300&&!je.defaultPrevented){if(je.target.click)je.target.click();else if(ye.createEvent){var yt=ye.createEvent("MouseEvents");yt.initMouseEvent("click",!0,!0,Rs,1,bt.screenX,bt.screenY,bt.clientX,bt.clientY,!1,!1,!1,!1,0,null),je.target.dispatchEvent(yt)}}})),oe.isDragging=oe.isGesturing=oe.isPressed=!1,h&&ft&&!W&&Ee.restart(!0),me&&Ze(),_&&ft&&_(oe),x&&x(oe,Qe)}},ve=function(at){return at.touches&&at.touches.length>1&&(oe.isGesturing=!0)&&q(at,oe.isDragging)},be=function(){return(oe.isGesturing=!1)||O(oe)},Xe=function(at){if(!Ve(at)){var ft=j(),Qe=Z();Le((ft-pe)*Q,(Qe-he)*Q,1),pe=ft,he=Qe,h&&Ee.restart(!0)}},We=function(at){if(!Ve(at)){at=ff(at,u),B&&($=!0);var ft=(at.deltaMode===1?l:at.deltaMode===2?Rs.innerHeight:1)*m;Le(at.deltaX*ft,at.deltaY*ft,0),h&&!W&&Ee.restart(!0)}},Be=function(at){if(!Ve(at)){var ft=at.clientX,Qe=at.clientY,bt=ft-oe.x,yt=Qe-oe.y;oe.x=ft,oe.y=Qe,xe=!0,h&&Ee.restart(!0),(bt||yt)&&ot(bt,yt)}},ut=function(at){oe.event=at,L(oe)},gt=function(at){oe.event=at,k(oe)},nt=function(at){return Ve(at)||ff(at,u)&&K(oe)};Ee=oe._dc=fr.delayedCall(d||.25,ze).pause(),oe.deltaX=oe.deltaY=0,oe._vx=Ox(0,50,!0),oe._vy=Ox(0,50,!0),oe.scrollX=j,oe.scrollY=Z,oe.isDragging=oe.isGesturing=oe.isPressed=!1,rA(this),oe.enable=function(je){return oe.isEnabled||(Xr(Se?ye:a,"scroll",kx),o.indexOf("scroll")>=0&&Xr(Se?ye:a,"scroll",Xe,Oe,ue),o.indexOf("wheel")>=0&&Xr(a,"wheel",We,Oe,ue),(o.indexOf("touch")>=0&&nA||o.indexOf("pointer")>=0)&&(Xr(a,_o[0],mt,Oe,ue),Xr(ye,_o[2],ce),Xr(ye,_o[3],ce),le&&Xr(a,"click",De,!0,!0),K&&Xr(a,"click",nt),q&&Xr(ye,"gesturestart",ve),O&&Xr(ye,"gestureend",be),L&&Xr(a,pc+"enter",ut),k&&Xr(a,pc+"leave",gt),z&&Xr(a,pc+"move",Be)),oe.isEnabled=!0,oe.isDragging=oe.isGesturing=oe.isPressed=xe=me=!1,oe._vx.reset(),oe._vy.reset(),pe=j(),he=Z(),je&&je.type&&mt(je),J&&J(oe)),oe},oe.disable=function(){oe.isEnabled&&(uh.filter(function(je){return je!==oe&&df(je.target)}).length||Yr(Se?ye:a,"scroll",kx),oe.isPressed&&(oe._vx.reset(),oe._vy.reset(),Yr(W?a:ye,_o[1],tt,!0)),Yr(Se?ye:a,"scroll",Xe,ue),Yr(a,"wheel",We,ue),Yr(a,_o[0],mt,ue),Yr(ye,_o[2],ce),Yr(ye,_o[3],ce),Yr(a,"click",De,!0),Yr(a,"click",nt),Yr(ye,"gesturestart",ve),Yr(ye,"gestureend",be),Yr(a,pc+"enter",ut),Yr(a,pc+"leave",gt),Yr(a,pc+"move",Be),oe.isEnabled=oe.isPressed=oe.isDragging=!1,re&&re(oe))},oe.kill=oe.revert=function(){oe.disable();var je=uh.indexOf(oe);je>=0&&uh.splice(je,1),ua===oe&&(ua=0)},uh.push(oe),W&&df(a)&&(ua=oe),oe.enable(v)},LF(s,[{key:"velocityX",get:function(){return this._vx.getVelocity()}},{key:"velocityY",get:function(){return this._vy.getVelocity()}}]),s}();Di.version="3.12.7",Di.create=function(s){return new Di(s)},Di.register=cA,Di.getAll=function(){return uh.slice()},Di.getById=function(s){return uh.filter(function(e){return e.vars.id===s})[0]},sA()&&fr.registerPlugin(Di);/*! * ScrollTrigger 3.12.7 * https://gsap.com * * @license Copyright 2008-2025, GreenSock. All rights reserved. * Subject to the terms at https://gsap.com/standard-license or for * Club GSAP members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */var Ut,hh,dn,ti,Ds,Bn,Fx,og,pf,mf,gf,ag,Rr,lg,Nx,qr,uA,hA,dh,dA,Bx,fA,Zr,zx,pA,mA,il,Vx,Gx,fh,Hx,cg,Wx,Xx,ug=1,Dr=Date.now,Yx=Dr(),Ks=0,vf=0,gA=function(e,t,i){var n=Is(e)&&(e.substr(0,6)==="clamp("||e.indexOf("max")>-1);return i["_"+t+"Clamp"]=n,n?e.substr(6,e.length-7):e},vA=function(e,t){return t&&(!Is(e)||e.substr(0,6)!=="clamp(")?"clamp("+e+")":e},kF=function s(){return vf&&requestAnimationFrame(s)},_A=function(){return lg=1},yA=function(){return lg=0},Ho=function(e){return e},_f=function(e){return Math.round(e*1e5)/1e5||0},xA=function(){return typeof window<"u"},bA=function(){return Ut||xA()&&(Ut=window.gsap)&&Ut.registerPlugin&&Ut},mc=function(e){return!!~Fx.indexOf(e)},wA=function(e){return(e==="Height"?Hx:dn["inner"+e])||Ds["client"+e]||Bn["client"+e]},SA=function(e){return tl(e,"getBoundingClientRect")||(mc(e)?function(){return Sg.width=dn.innerWidth,Sg.height=Hx,Sg}:function(){return ha(e)})},OF=function(e,t,i){var n=i.d,r=i.d2,o=i.a;return(o=tl(e,"getBoundingClientRect"))?function(){return o()[n]}:function(){return(t?wA(r):e["client"+r])||0}},FF=function(e,t){return!t||~Go.indexOf(e)?SA(e):function(){return Sg}},Wo=function(e,t){var i=t.s,n=t.d2,r=t.d,o=t.a;return Math.max(0,(i="scroll"+n)&&(o=tl(e,i))?o()-SA(e)()[r]:mc(e)?(Ds[i]||Bn[i])-wA(n):e[i]-e["offset"+n])},hg=function(e,t){for(var i=0;i0){for(n-=o,a=0;a=n)return i[a];return i[a-1]}else for(a=i.length,n+=o;a--;)if(i[a]<=n)return i[a];return i[0]}:function(n,r,o){o===void 0&&(o=.001);var a=t(n);return!r||Math.abs(a-n)i&&(n*=t/100),e=e.substr(0,i-1)),e=n+(e in gg?gg[e]*t:~e.indexOf("%")?parseFloat(e)*t/100:parseFloat(e)||0)}return e},_g=function(e,t,i,n,r,o,a,l){var c=r.startColor,u=r.endColor,h=r.fontSize,d=r.indent,f=r.fontWeight,m=ti.createElement("div"),v=mc(i)||tl(i,"pinType")==="fixed",g=e.indexOf("scroller")!==-1,_=v?Bn:i,y=e.indexOf("start")!==-1,w=y?c:u,x="border-color:"+w+";font-size:"+h+";color:"+w+";font-weight:"+f+";pointer-events:none;white-space:nowrap;font-family:sans-serif,Arial;z-index:1000;padding:4px 8px;border-width:0;border-style:solid;";return x+="position:"+((g||l)&&v?"fixed;":"absolute;"),(g||l||!v)&&(x+=(n===Xi?qx:Zx)+":"+(o+parseFloat(d))+"px;"),a&&(x+="box-sizing:border-box;text-align:left;width:"+a.offsetWidth+"px;"),m._isStart=y,m.setAttribute("class","gsap-marker-"+e+(t?" marker-"+t:"")),m.style.cssText=x,m.innerText=t||t===0?e+"-"+t:e,_.children[0]?_.insertBefore(m,_.children[0]):_.appendChild(m),m._offset=m["offset"+n.op.d2],yg(m,0,n,y),m},yg=function(e,t,i,n){var r={display:"block"},o=i[n?"os2":"p2"],a=i[n?"p2":"os2"];e._isFlipped=n,r[i.a+"Percent"]=n?-100:0,r[i.a]=n?"1px":0,r["border"+o+mh]=1,r["border"+a+mh]=0,r[i.p]=t+"px",Ut.set(e,r)},cn=[],Jx={},Ef,PA=function(){return Dr()-Ks>34&&(Ef||(Ef=requestAnimationFrame(da)))},gh=function(){(!Zr||!Zr.isPressed||Zr.startX>Bn.clientWidth)&&(hn.cache++,Zr?Ef||(Ef=requestAnimationFrame(da)):da(),Ks||xc("scrollStart"),Ks=Dr())},Qx=function(){mA=dn.innerWidth,pA=dn.innerHeight},Tf=function(e){hn.cache++,(e===!0||!Rr&&!fA&&!ti.fullscreenElement&&!ti.webkitFullscreenElement&&(!zx||mA!==dn.innerWidth||Math.abs(dn.innerHeight-pA)>dn.innerHeight*.25))&&og.restart(!0)},yc={},VF=[],RA=function s(){return sr(qt,"scrollEnd",s)||wc(!0)},xc=function(e){return yc[e]&&yc[e].map(function(t){return t()})||VF},Ls=[],DA=function(e){for(var t=0;tr,a=n._startClamp&&n.start>=r;(o||a)&&n.setPositions(a?r-1:n.start,o?Math.max(a?r:n.start+1,r):n.end,!0)}),kA(!1),Wx=0,i.forEach(function(n){return n&&n.render&&n.render(-1)}),hn.forEach(function(n){Ir(n)&&(n.smooth&&requestAnimationFrame(function(){return n.target.style.scrollBehavior="smooth"}),n.rec&&n(n.rec))}),IA(Gx,1),og.pause(),bc++,Kr=2,da(2),cn.forEach(function(n){return Ir(n.vars.onRefresh)&&n.vars.onRefresh(n)}),Kr=qt.isRefreshing=!1,xc("refresh")},tb=0,xg=1,Af,da=function(e){if(e===2||!Kr&&!cg){qt.isUpdating=!0,Af&&Af.update(0);var t=cn.length,i=Dr(),n=i-Yx>=50,r=t&&cn[0].scroll();if(xg=tb>r?-1:1,Kr||(tb=r),n&&(Ks&&!lg&&i-Ks>200&&(Ks=0,xc("scrollEnd")),gf=Yx,Yx=i),xg<0){for(qr=t;qr-- >0;)cn[qr]&&cn[qr].update(0,n);xg=1}else for(qr=0;qr20),i-=i-C}if(m&&(l[m]=e||-.001,e<0&&(e=0)),o){var A=e+i,P=o._isStart;g="scroll"+n.d2,yg(o,A,n,P&&A>20||!P&&(h?Math.max(Bn[g],Ds[g]):o.parentNode[g])<=A+1),h&&(c=ha(a),h&&(o.style[n.op.p]=c[n.op.p]-n.op.m-o._offset+Yi))}return f&&y&&(g=ha(y),f.seek(d),_=ha(y),f._caScrollDist=g[n.p]-_[n.p],e=e/f._caScrollDist*d),f&&f.seek(v),f?e:Math.round(e)},YF=/(webkit|moz|length|cssText|inset)/i,FA=function(e,t,i,n){if(e.parentNode!==t){var r=e.style,o,a;if(t===Bn){e._stOrig=r.cssText,a=Js(e);for(o in a)!+o&&!YF.test(o)&&a[o]&&typeof r[o]=="string"&&o!=="0"&&(r[o]=a[o]);r.top=i,r.left=n}else r.cssText=e._stOrig;Ut.core.getCache(e).uncache=1,t.appendChild(e)}},NA=function(e,t,i){var n=t,r=n;return function(o){var a=Math.round(e());return a!==n&&a!==r&&Math.abs(a-n)>3&&Math.abs(a-r)>3&&(o=a,i&&i()),r=n,n=Math.round(o),n}},Mg=function(e,t,i){var n={};n[t.p]="+="+i,Ut.set(e,n)},BA=function(e,t){var i=nl(e,t),n="_scroll"+t.p2,r=function o(a,l,c,u,h){var d=o.tween,f=l.onComplete,m={};c=c||i();var v=NA(i,c,function(){d.kill(),o.tween=0});return h=u&&h||0,u=u||a-c,d&&d.kill(),l[n]=a,l.inherit=!1,l.modifiers=m,m[n]=function(){return v(c+u*d.ratio+h*d.ratio*d.ratio)},l.onUpdate=function(){hn.cache++,o.tween&&da()},l.onComplete=function(){o.tween=0,f&&f.call(d)},d=o.tween=Ut.to(e,l),d};return e[n]=i,i.wheelHandler=function(){return r.tween&&r.tween.kill()&&(r.tween=0)},rr(e,"wheel",i.wheelHandler),qt.isTouch&&rr(e,"touchmove",i.wheelHandler),r},qt=function(){function s(t,i){hh||s.register(Ut)||console.warn("Please gsap.registerPlugin(ScrollTrigger)"),Vx(this),this.init(t,i)}var e=s.prototype;return e.init=function(i,n){if(this.progress=this.start=0,this.vars&&this.kill(!0,!0),!vf){this.update=this.refresh=this.kill=Ho;return}i=TA(Is(i)||yf(i)||i.nodeType?{trigger:i}:i,mg);var r=i,o=r.onUpdate,a=r.toggleClass,l=r.id,c=r.onToggle,u=r.onRefresh,h=r.scrub,d=r.trigger,f=r.pin,m=r.pinSpacing,v=r.invalidateOnRefresh,g=r.anticipatePin,_=r.onScrubComplete,y=r.onSnapComplete,w=r.once,x=r.snap,M=r.pinReparent,C=r.pinSpacer,T=r.containerAnimation,A=r.fastScrollEnd,P=r.preventOverlaps,E=i.horizontal||i.containerAnimation&&i.horizontal!==!1?jr:Xi,I=!h&&h!==0,R=us(i.scroller||dn),U=Ut.core.getCache(R),L=mc(R),k=("pinType"in i?i.pinType:tl(R,"pinType")||L&&"fixed")==="fixed",z=[i.onEnter,i.onLeave,i.onEnterBack,i.onLeaveBack],G=I&&i.toggleActions.split(" "),W="markers"in i?i.markers:mg.markers,q=L?0:parseFloat(Js(R)["border"+E.p2+mh])||0,O=this,B=i.onRefreshInit&&function(){return i.onRefreshInit(O)},J=OF(R,L,E),re=FF(R,L),K=0,Q=0,ue=0,le=nl(R,E),_e,Fe,Ie,Ee,me,xe,$,Ue,Me,oe,Te,Ye,Oe,j,Z,pe,he,te,Se,ye,Ae,Ce,Ge,De,Ve,ze,Ze,Le,ot,tt,mt,ce,ve,be,Xe,We,Be,ut,gt;if(O._startClamp=O._endClamp=!1,O._dir=E,g*=45,O.scroller=R,O.scroll=T?T.time.bind(T):le,Ee=le(),O.vars=i,n=n||i.animation,"refreshPriority"in i&&(dA=1,i.refreshPriority===-9999&&(Af=O)),U.tweenScroll=U.tweenScroll||{top:BA(R,Xi),left:BA(R,jr)},O.tweenTo=_e=U.tweenScroll[E.p],O.scrubDuration=function(Qe){ve=yf(Qe)&&Qe,ve?ce?ce.duration(Qe):ce=Ut.to(n,{ease:"expo",totalProgress:"+=0",inherit:!1,duration:ve,paused:!0,onComplete:function(){return _&&_(O)}}):(ce&&ce.progress(1).kill(),ce=0)},n&&(n.vars.lazy=!1,n._initted&&!O.isReverted||n.vars.immediateRender!==!1&&i.immediateRender!==!1&&n.duration()&&n.render(0,!0,!0),O.animation=n.pause(),n.scrollTrigger=O,O.scrubDuration(h),tt=0,l||(l=n.vars.id)),x&&((!gc(x)||x.push)&&(x={snapTo:x}),"scrollBehavior"in Bn.style&&Ut.set(L?[Bn,Ds]:R,{scrollBehavior:"auto"}),hn.forEach(function(Qe){return Ir(Qe)&&Qe.target===(L?ti.scrollingElement||Ds:R)&&(Qe.smooth=!1)}),Ie=Ir(x.snapTo)?x.snapTo:x.snapTo==="labels"?BF(n):x.snapTo==="labelsDirectional"?zF(n):x.directional!==!1?function(Qe,bt){return $x(x.snapTo)(Qe,Dr()-Q<500?0:bt.direction)}:Ut.utils.snap(x.snapTo),be=x.duration||{min:.1,max:2},be=gc(be)?mf(be.min,be.max):mf(be,be),Xe=Ut.delayedCall(x.delay||ve/2||.1,function(){var Qe=le(),bt=Dr()-Q<500,yt=_e.tween;if((bt||Math.abs(O.getVelocity())<10)&&!yt&&!lg&&K!==Qe){var Rt=(Qe-xe)/j,on=n&&!I?n.totalProgress():Rt,zt=bt?0:(on-mt)/(Dr()-gf)*1e3||0,Qt=Ut.utils.clamp(-Rt,1-Rt,ph(zt/2)*zt/.185),Kt=Rt+(x.inertia===!1?0:Qt),nn,Sn,ln=x,er=ln.onStart,fn=ln.onInterrupt,Pn=ln.onComplete;if(nn=Ie(Kt,O),yf(nn)||(nn=Kt),Sn=Math.max(0,Math.round(xe+nn*j)),Qe<=$&&Qe>=xe&&Sn!==Qe){if(yt&&!yt._initted&&yt.data<=ph(Sn-Qe))return;x.inertia===!1&&(Qt=nn-Rt),_e(Sn,{duration:be(ph(Math.max(ph(Kt-on),ph(nn-on))*.185/zt/.05||0)),ease:x.ease||"power3",data:ph(Sn-Qe),onInterrupt:function(){return Xe.restart(!0)&&fn&&fn(O)},onComplete:function(){O.update(),K=le(),n&&!I&&(ce?ce.resetTo("totalProgress",nn,n._tTime/n._tDur):n.progress(nn)),tt=mt=n&&!I?n.totalProgress():O.progress,y&&y(O),Pn&&Pn(O)}},Qe,Qt*j,Sn-Qe-Qt*j),er&&er(O,_e.tween)}}else O.isActive&&K!==Qe&&Xe.restart(!0)}).pause()),l&&(Jx[l]=O),d=O.trigger=us(d||f!==!0&&f),gt=d&&d._gsap&&d._gsap.stRevert,gt&&(gt=gt(O)),f=f===!0?d:us(f),Is(a)&&(a={targets:d,className:a}),f&&(m===!1||m===$s||(m=!m&&f.parentNode&&f.parentNode.style&&Js(f.parentNode).display==="flex"?!1:Fi),O.pin=f,Fe=Ut.core.getCache(f),Fe.spacer?Z=Fe.pinState:(C&&(C=us(C),C&&!C.nodeType&&(C=C.current||C.nativeElement),Fe.spacerIsNative=!!C,C&&(Fe.spacerState=wg(C))),Fe.spacer=te=C||ti.createElement("div"),te.classList.add("pin-spacer"),l&&te.classList.add("pin-spacer-"+l),Fe.pinState=Z=wg(f)),i.force3D!==!1&&Ut.set(f,{force3D:!0}),O.spacer=te=Fe.spacer,ot=Js(f),De=ot[m+E.os2],ye=Ut.getProperty(f),Ae=Ut.quickSetter(f,E.a,Yi),ib(f,te,ot),he=wg(f)),W){Ye=gc(W)?TA(W,CA):CA,oe=_g("scroller-start",l,R,E,Ye,0),Te=_g("scroller-end",l,R,E,Ye,0,oe),Se=oe["offset"+E.op.d2];var nt=us(tl(R,"content")||R);Ue=this.markerStart=_g("start",l,nt,E,Ye,Se,0,T),Me=this.markerEnd=_g("end",l,nt,E,Ye,Se,0,T),T&&(ut=Ut.quickSetter([Ue,Me],E.a,Yi)),!k&&!(Go.length&&tl(R,"fixedMarkers")===!0)&&(NF(L?Bn:R),Ut.set([oe,Te],{force3D:!0}),ze=Ut.quickSetter(oe,E.a,Yi),Le=Ut.quickSetter(Te,E.a,Yi))}if(T){var je=T.vars.onUpdate,at=T.vars.onUpdateParams;T.eventCallback("onUpdate",function(){O.update(0,0,1),je&&je.apply(T,at||[])})}if(O.previous=function(){return cn[cn.indexOf(O)-1]},O.next=function(){return cn[cn.indexOf(O)+1]},O.revert=function(Qe,bt){if(!bt)return O.kill(!0);var yt=Qe!==!1||!O.enabled,Rt=Rr;yt!==O.isReverted&&(yt&&(We=Math.max(le(),O.scroll.rec||0),ue=O.progress,Be=n&&n.progress()),Ue&&[Ue,Me,oe,Te].forEach(function(on){return on.style.display=yt?"none":"block"}),yt&&(Rr=O,O.update(yt)),f&&(!M||!O.isActive)&&(yt?HF(f,te,Z):ib(f,te,Js(f),Ve)),yt||O.update(yt),Rr=Rt,O.isReverted=yt)},O.refresh=function(Qe,bt,yt,Rt){if(!((Rr||!O.enabled)&&!bt)){if(f&&Qe&&Ks){rr(s,"scrollEnd",RA);return}!Kr&&B&&B(O),Rr=O,_e.tween&&!yt&&(_e.tween.kill(),_e.tween=0),ce&&ce.pause(),v&&n&&n.revert({kill:!1}).invalidate(),O.isReverted||O.revert(!0,!0),O._subPinOffset=!1;var on=J(),zt=re(),Qt=T?T.duration():Wo(R,E),Kt=j<=.01,nn=0,Sn=Rt||0,ln=gc(yt)?yt.end:i.end,er=i.endTrigger||d,fn=gc(yt)?yt.start:i.start||(i.start===0||!d?0:f?"0 0":"0 100%"),Pn=O.pinnedContainer=i.pinnedContainer&&us(i.pinnedContainer,O),F=d&&Math.max(0,cn.indexOf(O))||0,ee=F,de,N,ie,se,ne,ae,we,Pe,Re,He,qe,Ke,Je;for(W&&gc(yt)&&(Ke=Ut.getProperty(oe,E.p),Je=Ut.getProperty(Te,E.p));ee-- >0;)ae=cn[ee],ae.end||ae.refresh(0,1)||(Rr=O),we=ae.pin,we&&(we===d||we===f||we===Pn)&&!ae.isReverted&&(He||(He=[]),He.unshift(ae),ae.revert(!0,!0)),ae!==cn[ee]&&(F--,ee--);for(Ir(fn)&&(fn=fn(O)),fn=gA(fn,"start",O),xe=OA(fn,d,on,E,le(),Ue,oe,O,zt,q,k,Qt,T,O._startClamp&&"_startClamp")||(f?-.001:0),Ir(ln)&&(ln=ln(O)),Is(ln)&&!ln.indexOf("+=")&&(~ln.indexOf(" ")?ln=(Is(fn)?fn.split(" ")[0]:"")+ln:(nn=vg(ln.substr(2),on),ln=Is(fn)?fn:(T?Ut.utils.mapRange(0,T.duration(),T.scrollTrigger.start,T.scrollTrigger.end,xe):xe)+nn,er=d)),ln=gA(ln,"end",O),$=Math.max(xe,OA(ln||(er?"100% 0":Qt),er,on,E,le()+nn,Me,Te,O,zt,q,k,Qt,T,O._endClamp&&"_endClamp"))||-.001,nn=0,ee=F;ee--;)ae=cn[ee],we=ae.pin,we&&ae.start-ae._pinPush<=xe&&!T&&ae.end>0&&(de=ae.end-(O._startClamp?Math.max(0,ae.start):ae.start),(we===d&&ae.start-ae._pinPush=Wo(R,E)))de=Js(f),se=E===Xi,ie=le(),Ce=parseFloat(ye(E.a))+Sn,!Qt&&$>1&&(qe=(L?ti.scrollingElement||Ds:R).style,qe={style:qe,value:qe["overflow"+E.a.toUpperCase()]},L&&Js(Bn)["overflow"+E.a.toUpperCase()]!=="scroll"&&(qe.style["overflow"+E.a.toUpperCase()]="scroll")),ib(f,te,de),he=wg(f),N=ha(f,!0),Pe=k&&nl(R,se?jr:Xi)(),m?(Ve=[m+E.os2,j+Sn+Yi],Ve.t=te,ee=m===Fi?dg(f,E)+j+Sn:0,ee&&(Ve.push(E.d,ee+Yi),te.style.flexBasis!=="auto"&&(te.style.flexBasis=ee+Yi)),vh(Ve),Pn&&cn.forEach(function(et){et.pin===Pn&&et.vars.pinSpacing!==!1&&(et._subPinOffset=!0)}),k&&le(We)):(ee=dg(f,E),ee&&te.style.flexBasis!=="auto"&&(te.style.flexBasis=ee+Yi)),k&&(ne={top:N.top+(se?ie-xe:Pe)+Yi,left:N.left+(se?Pe:ie-xe)+Yi,boxSizing:"border-box",position:"fixed"},ne[vc]=ne["max"+mh]=Math.ceil(N.width)+Yi,ne[_c]=ne["max"+Kx]=Math.ceil(N.height)+Yi,ne[$s]=ne[$s+Sf]=ne[$s+bf]=ne[$s+Mf]=ne[$s+wf]="0",ne[Fi]=de[Fi],ne[Fi+Sf]=de[Fi+Sf],ne[Fi+bf]=de[Fi+bf],ne[Fi+Mf]=de[Fi+Mf],ne[Fi+wf]=de[Fi+wf],pe=XF(Z,ne,M),Kr&&le(0)),n?(Re=n._initted,Bx(1),n.render(n.duration(),!0,!0),Ge=ye(E.a)-Ce+j+Sn,Ze=Math.abs(j-Ge)>1,k&&Ze&&pe.splice(pe.length-2,2),n.render(0,!0,!0),Re||n.invalidate(!0),n.parent||n.totalTime(n.totalTime()),Bx(0)):Ge=j,qe&&(qe.value?qe.style["overflow"+E.a.toUpperCase()]=qe.value:qe.style.removeProperty("overflow-"+E.a));else if(d&&le()&&!T)for(N=d.parentNode;N&&N!==Bn;)N._pinOffset&&(xe-=N._pinOffset,$-=N._pinOffset),N=N.parentNode;He&&He.forEach(function(et){return et.revert(!1,!0)}),O.start=xe,O.end=$,Ee=me=Kr?We:le(),!T&&!Kr&&(Ee0?cn.slice(0,bt).reverse():cn.slice(bt+1);return(Is(Qe)?yt.filter(function(Rt){return Rt.vars.preventOverlaps===Qe}):yt).filter(function(Rt){return O.direction>0?Rt.end<=xe:Rt.start>=$})},O.update=function(Qe,bt,yt){if(!(T&&!yt&&!Qe)){var Rt=Kr===!0?We:O.scroll(),on=Qe?0:(Rt-xe)/j,zt=on<0?0:on>1?1:on||0,Qt=O.progress,Kt,nn,Sn,ln,er,fn,Pn,F;if(bt&&(me=Ee,Ee=T?le():Rt,x&&(mt=tt,tt=n&&!I?n.totalProgress():zt)),g&&f&&!Rr&&!ug&&Ks&&(!zt&&xeRt+(Rt-me)/(Dr()-gf)*g&&(zt=.9999)),zt!==Qt&&O.enabled){if(Kt=O.isActive=!!zt&&zt<1,nn=!!Qt&&Qt<1,fn=Kt!==nn,er=fn||!!zt!=!!Qt,O.direction=zt>Qt?1:-1,O.progress=zt,er&&!Rr&&(Sn=zt&&!Qt?0:zt===1?1:Qt===1?2:3,I&&(ln=!fn&&G[Sn+1]!=="none"&&G[Sn+1]||G[Sn],F=n&&(ln==="complete"||ln==="reset"||ln in n))),P&&(fn||F)&&(F||h||!n)&&(Ir(P)?P(O):O.getTrailing(P).forEach(function(ie){return ie.endAnimation()})),I||(ce&&!Rr&&!ug?(ce._dp._time-ce._start!==ce._time&&ce.render(ce._dp._time-ce._start),ce.resetTo?ce.resetTo("totalProgress",zt,n._tTime/n._tDur):(ce.vars.totalProgress=zt,ce.invalidate().restart())):n&&n.totalProgress(zt,!!(Rr&&(Q||Qe)))),f){if(Qe&&m&&(te.style[m+E.os2]=De),!k)Ae(_f(Ce+Ge*zt));else if(er){if(Pn=!Qe&&zt>Qt&&$+1>Rt&&Rt+1>=Wo(R,E),M)if(!Qe&&(Kt||Pn)){var ee=ha(f,!0),de=Rt-xe;FA(f,Bn,ee.top+(E===Xi?de:0)+Yi,ee.left+(E===Xi?0:de)+Yi)}else FA(f,te);vh(Kt||Pn?pe:he),Ze&&zt<1&&Kt||Ae(Ce+(zt===1&&!Pn?Ge:0))}}x&&!_e.tween&&!Rr&&!ug&&Xe.restart(!0),a&&(fn||w&&zt&&(zt<1||!Xx))&&pf(a.targets).forEach(function(ie){return ie.classList[Kt||w?"add":"remove"](a.className)}),o&&!I&&!Qe&&o(O),er&&!Rr?(I&&(F&&(ln==="complete"?n.pause().totalProgress(1):ln==="reset"?n.restart(!0).pause():ln==="restart"?n.restart(!0):n[ln]()),o&&o(O)),(fn||!Xx)&&(c&&fn&&jx(O,c),z[Sn]&&jx(O,z[Sn]),w&&(zt===1?O.kill(!1,1):z[Sn]=0),fn||(Sn=zt===1?1:3,z[Sn]&&jx(O,z[Sn]))),A&&!Kt&&Math.abs(O.getVelocity())>(yf(A)?A:2500)&&(xf(O.callbackAnimation),ce?ce.progress(1):xf(n,ln==="reverse"?1:!zt,1))):I&&o&&!Rr&&o(O)}if(Le){var N=T?Rt/T.duration()*(T._caScrollDist||0):Rt;ze(N+(oe._isFlipped?1:0)),Le(N)}ut&&ut(-Rt/T.duration()*(T._caScrollDist||0))}},O.enable=function(Qe,bt){O.enabled||(O.enabled=!0,rr(R,"resize",Tf),L||rr(R,"scroll",gh),B&&rr(s,"refreshInit",B),Qe!==!1&&(O.progress=ue=0,Ee=me=K=le()),bt!==!1&&O.refresh())},O.getTween=function(Qe){return Qe&&_e?_e.tween:ce},O.setPositions=function(Qe,bt,yt,Rt){if(T){var on=T.scrollTrigger,zt=T.duration(),Qt=on.end-on.start;Qe=on.start+Qt*Qe/zt,bt=on.start+Qt*bt/zt}O.refresh(!1,!1,{start:vA(Qe,yt&&!!O._startClamp),end:vA(bt,yt&&!!O._endClamp)},Rt),O.update()},O.adjustPinSpacing=function(Qe){if(Ve&&Qe){var bt=Ve.indexOf(E.d)+1;Ve[bt]=parseFloat(Ve[bt])+Qe+Yi,Ve[1]=parseFloat(Ve[1])+Qe+Yi,vh(Ve)}},O.disable=function(Qe,bt){if(O.enabled&&(Qe!==!1&&O.revert(!0,!0),O.enabled=O.isActive=!1,bt||ce&&ce.pause(),We=0,Fe&&(Fe.uncache=1),B&&sr(s,"refreshInit",B),Xe&&(Xe.pause(),_e.tween&&_e.tween.kill()&&(_e.tween=0)),!L)){for(var yt=cn.length;yt--;)if(cn[yt].scroller===R&&cn[yt]!==O)return;sr(R,"resize",Tf),L||sr(R,"scroll",gh)}},O.kill=function(Qe,bt){O.disable(Qe,bt),ce&&!bt&&ce.kill(),l&&delete Jx[l];var yt=cn.indexOf(O);yt>=0&&cn.splice(yt,1),yt===qr&&xg>0&&qr--,yt=0,cn.forEach(function(Rt){return Rt.scroller===O.scroller&&(yt=1)}),yt||Kr||(O.scroll.rec=0),n&&(n.scrollTrigger=null,Qe&&n.revert({kill:!1}),bt||n.kill()),Ue&&[Ue,Me,oe,Te].forEach(function(Rt){return Rt.parentNode&&Rt.parentNode.removeChild(Rt)}),Af===O&&(Af=0),f&&(Fe&&(Fe.uncache=1),yt=0,cn.forEach(function(Rt){return Rt.pin===f&&yt++}),yt||(Fe.spacer=0)),i.onKill&&i.onKill(O)},cn.push(O),O.enable(!1,!1),gt&>(O),n&&n.add&&!j){var ft=O.update;O.update=function(){O.update=ft,hn.cache++,xe||$||O.refresh()},Ut.delayedCall(.01,O.update),j=.01,xe=$=0}else O.refresh();f&&GF()},s.register=function(i){return hh||(Ut=i||bA(),xA()&&window.document&&s.enable(),hh=vf),hh},s.defaults=function(i){if(i)for(var n in i)mg[n]=i[n];return mg},s.disable=function(i,n){vf=0,cn.forEach(function(o){return o[n?"kill":"disable"](i)}),sr(dn,"wheel",gh),sr(ti,"scroll",gh),clearInterval(ag),sr(ti,"touchcancel",Ho),sr(Bn,"touchstart",Ho),fg(sr,ti,"pointerdown,touchstart,mousedown",_A),fg(sr,ti,"pointerup,touchend,mouseup",yA),og.kill(),hg(sr);for(var r=0;r0&&o.left+a0&&o.top+a=0&&Ls.splice(t,5),Ls.push(e,e.style.cssText,e.getBBox&&e.getAttribute("transform"),Ut.core.getCache(e),Vx())}}):Ls},qt.revert=function(s,e){return eb(!s,e)},qt.create=function(s,e){return new qt(s,e)},qt.refresh=function(s){return s?Tf(!0):(hh||qt.register())&&wc(!0)},qt.update=function(s){return++hn.cache&&da(s===!0?2:0)},qt.clearScrollMemory=IA,qt.maxScroll=function(s,e){return Wo(s,e?jr:Xi)},qt.getScrollFunc=function(s,e){return nl(us(s),e?jr:Xi)},qt.getById=function(s){return Jx[s]},qt.getAll=function(){return cn.filter(function(s){return s.vars.id!=="ScrollSmoother"})},qt.isScrolling=function(){return!!Ks},qt.snapDirectional=$x,qt.addEventListener=function(s,e){var t=yc[s]||(yc[s]=[]);~t.indexOf(e)||t.push(e)},qt.removeEventListener=function(s,e){var t=yc[s],i=t&&t.indexOf(e);i>=0&&t.splice(i,1)},qt.batch=function(s,e){var t=[],i={},n=e.interval||.016,r=e.batchMax||1e9,o=function(c,u){var h=[],d=[],f=Ut.delayedCall(n,function(){u(h,d),h=[],d=[]}).pause();return function(m){h.length||f.restart(!0),h.push(m.trigger),d.push(m),r<=h.length&&f.progress(1)}},a;for(a in e)i[a]=a.substr(0,2)==="on"&&Ir(e[a])&&a!=="onRefreshInit"?o(a,e[a]):e[a];return Ir(r)&&(r=r(),rr(qt,"refresh",function(){return r=e.batchMax()})),pf(s).forEach(function(l){var c={};for(a in i)c[a]=i[a];c.trigger=l,t.push(qt.create(c))}),t};var zA=function(e,t,i,n){return t>n?e(n):t<0&&e(0),i>n?(n-t)/(i-t):i<0?t/(t-i):1},rb=function s(e,t){t===!0?e.style.removeProperty("touch-action"):e.style.touchAction=t===!0?"auto":t?"pan-"+t+(Di.isTouch?" pinch-zoom":""):"none",e===Ds&&s(Bn,t)},Eg={auto:1,scroll:1},jF=function(e){var t=e.event,i=e.target,n=e.axis,r=(t.changedTouches?t.changedTouches[0]:t).target,o=r._gsap||Ut.core.getCache(r),a=Dr(),l;if(!o._isScrollT||a-o._isScrollT>2e3){for(;r&&r!==Bn&&(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth||!(Eg[(l=Js(r)).overflowY]||Eg[l.overflowX]));)r=r.parentNode;o._isScroll=r&&r!==i&&!mc(r)&&(Eg[(l=Js(r)).overflowY]||Eg[l.overflowX]),o._isScrollT=a}(o._isScroll||n==="x")&&(t.stopPropagation(),t._gsapAllow=!0)},VA=function(e,t,i,n){return Di.create({target:e,capture:!0,debounce:!1,lockAxis:!0,type:t,onWheel:n=n&&jF,onPress:n,onDrag:n,onScroll:n,onEnable:function(){return i&&rr(ti,Di.eventTypes[0],HA,!1,!0)},onDisable:function(){return sr(ti,Di.eventTypes[0],HA,!0)}})},qF=/(input|label|select|textarea)/i,GA,HA=function(e){var t=qF.test(e.target.tagName);(t||GA)&&(e._gsapAllow=!0,GA=t)},ZF=function(e){gc(e)||(e={}),e.preventDefault=e.isNormalizer=e.allowClicks=!0,e.type||(e.type="wheel,touch"),e.debounce=!!e.debounce,e.id=e.id||"normalizer";var t=e,i=t.normalizeScrollX,n=t.momentum,r=t.allowNestedScroll,o=t.onRelease,a,l,c=us(e.target)||Ds,u=Ut.core.globals().ScrollSmoother,h=u&&u.get(),d=il&&(e.content&&us(e.content)||h&&e.content!==!1&&!h.smooth()&&h.content()),f=nl(c,Xi),m=nl(c,jr),v=1,g=(Di.isTouch&&dn.visualViewport?dn.visualViewport.scale*dn.visualViewport.width:dn.outerWidth)/dn.innerWidth,_=0,y=Ir(n)?function(){return n(a)}:function(){return n||2.8},w,x,M=VA(c,e.type,!0,r),C=function(){return x=!1},T=Ho,A=Ho,P=function(){l=Wo(c,Xi),A=mf(il?1:0,l),i&&(T=mf(0,Wo(c,jr))),w=bc},E=function(){d._gsap.y=_f(parseFloat(d._gsap.y)+f.offset)+"px",d.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, "+parseFloat(d._gsap.y)+", 0, 1)",f.offset=f.cacheID=0},I=function(){if(x){requestAnimationFrame(C);var W=_f(a.deltaY/2),q=A(f.v-W);if(d&&q!==f.v+f.offset){f.offset=q-f.v;var O=_f((parseFloat(d&&d._gsap.y)||0)-f.offset);d.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, "+O+", 0, 1)",d._gsap.y=O+"px",f.cacheID=hn.cache,da()}return!0}f.offset&&E(),x=!0},R,U,L,k,z=function(){P(),R.isActive()&&R.vars.scrollY>l&&(f()>l?R.progress(1)&&f(l):R.resetTo("scrollY",l))};return d&&Ut.set(d,{y:"+=0"}),e.ignoreCheck=function(G){return il&&G.type==="touchmove"&&I()||v>1.05&&G.type!=="touchstart"||a.isGesturing||G.touches&&G.touches.length>1},e.onPress=function(){x=!1;var G=v;v=_f((dn.visualViewport&&dn.visualViewport.scale||1)/g),R.pause(),G!==v&&rb(c,v>1.01?!0:i?!1:"x"),U=m(),L=f(),P(),w=bc},e.onRelease=e.onGestureStart=function(G,W){if(f.offset&&E(),!W)k.restart(!0);else{hn.cache++;var q=y(),O,B;i&&(O=m(),B=O+q*.05*-G.velocityX/.227,q*=zA(m,O,B,Wo(c,jr)),R.vars.scrollX=T(B)),O=f(),B=O+q*.05*-G.velocityY/.227,q*=zA(f,O,B,Wo(c,Xi)),R.vars.scrollY=A(B),R.invalidate().duration(q).play(.01),(il&&R.vars.scrollY>=l||O>=l-1)&&Ut.to({},{onUpdate:z,duration:q})}o&&o(G)},e.onWheel=function(){R._ts&&R.pause(),Dr()-_>1e3&&(w=0,_=Dr())},e.onChange=function(G,W,q,O,B){if(bc!==w&&P(),W&&i&&m(T(O[2]===W?U+(G.startX-G.x):m()+W-O[1])),q){f.offset&&E();var J=B[2]===q,re=J?L+G.startY-G.y:f()+q-B[1],K=A(re);J&&re!==K&&(L+=K-re),f(K)}(q||W)&&da()},e.onEnable=function(){rb(c,i?!1:"x"),qt.addEventListener("refresh",z),rr(dn,"resize",z),f.smooth&&(f.target.style.scrollBehavior="auto",f.smooth=m.smooth=!1),M.enable()},e.onDisable=function(){rb(c,!0),sr(dn,"resize",z),qt.removeEventListener("refresh",z),M.kill()},e.lockAxis=e.lockAxis!==!1,a=new Di(e),a.iOS=il,il&&!f()&&f(1),il&&Ut.ticker.add(Ho),k=a._dc,R=Ut.to(a,{ease:"power4",paused:!0,inherit:!1,scrollX:i?"+=0.1":"+=0",scrollY:"+=0.1",modifiers:{scrollY:NA(f,f(),function(){return R.pause()})},onUpdate:da,onComplete:k.vars.onComplete}),a};qt.sort=function(s){if(Ir(s))return cn.sort(s);var e=dn.pageYOffset||0;return qt.getAll().forEach(function(t){return t._sortY=t.trigger?e+t.trigger.getBoundingClientRect().top:t.start+dn.innerHeight}),cn.sort(s||function(t,i){return(t.vars.refreshPriority||0)*-1e6+(t.vars.containerAnimation?1e6:t._sortY)-((i.vars.containerAnimation?1e6:i._sortY)+(i.vars.refreshPriority||0)*-1e6)})},qt.observe=function(s){return new Di(s)},qt.normalizeScroll=function(s){if(typeof s>"u")return Zr;if(s===!0&&Zr)return Zr.enable();if(s===!1){Zr&&Zr.kill(),Zr=s;return}var e=s instanceof Di?s:ZF(s);return Zr&&Zr.target===e.target&&Zr.kill(),mc(e.target)&&(Zr=e),e},qt.core={_getVelocityProp:Ox,_inputObserver:VA,_scrollers:hn,_proxies:Go,bridge:{ss:function(){Ks||xc("scrollStart"),Ks=Dr()},ref:function(){return Rr}}},bA()&&Ut.registerPlugin(qt);function WA(s){return Object.prototype.toString.call(s)==="[object Date]"}function sb(s,e,t,i){if(typeof t=="number"||WA(t)){const n=i-t,r=(t-e)/(s.dt||1/60),o=s.opts.stiffness*n,a=s.opts.damping*r,l=(o-a)*s.inv_mass,c=(r+l)*s.dt;return Math.abs(c)sb(s,e[r],t[r],i[r]));if(typeof t=="object"){const n={};for(const r in t)n[r]=sb(s,e[r],t[r],i[r]);return n}else throw new Error(`Cannot spring ${typeof t} values`)}}function KF(s,e={}){const t=Hn(s),{stiffness:i=.15,damping:n=.8,precision:r=.01}=e;let o,a,l,c=s,u=s,h=1,d=0,f=!1;function m(g,_={}){u=g;const y=l={};return s==null||_.hard||v.stiffness>=1&&v.damping>=1?(f=!0,o=mo.now(),c=g,t.set(s=u),Promise.resolve()):(_.soft&&(d=1/((_.soft===!0?.5:+_.soft)*60),h=0),a||(o=mo.now(),f=!1,a=bk(w=>{if(f)return f=!1,a=null,!1;h=Math.min(h+d,1);const x=Math.min(w-o,1e3/30),M={inv_mass:h,opts:v,settled:!0,dt:x*60/1e3},C=sb(M,c,s,u);return o=w,c=s,t.set(s=C),M.settled&&(a=null),!M.settled})),new Promise(w=>{a.promise.then(()=>{y===l&&w()})}))}const v={set:m,update:(g,_)=>m(g(u,s),_),subscribe:t.subscribe,stiffness:i,damping:n,precision:r};return v}function ob(s,e){if(new.target)return Tt({component:ob,...s});Mt(e,!1);const[t,i]=Pi(),n=()=>Rn(l,"$velocitySpring",t),r=()=>Rn(Lx,"$lenisController",t),o=()=>Rn(h,"$setted",t);let a;const l=KF(0,{stiffness:.1,damping:.5});let c=Yl(!1);const u=()=>{a.forEach((m,v)=>{const g=m.querySelector(".home-project-info");g&&(g.hasAttribute("data-initialized")||(g.setAttribute("data-x","0"),g.setAttribute("data-y","0"),g.setAttribute("data-initialized","true"),Cn.set(g,{x:0,y:0,zIndex:"300"})),m.addEventListener("mousemove",_=>{const y=m.getBoundingClientRect(),w=_.clientX-y.left,x=_.clientY-y.top,M=g.offsetWidth,C=g.offsetHeight,T=w-M/2,A=x-C/2;g.setAttribute("data-x",T.toString()),g.setAttribute("data-y",A.toString()),Cn.to(g,{x:T,y:A,duration:.8,ease:"elastic.out(1, 0.75)",overwrite:!0})}),m.addEventListener("mouseleave",()=>{g.style.transform=""})),Cn.fromTo(m,{y:"15svh"},{y:"-15svh",ease:"linear",scrollTrigger:{trigger:m,start:"-15% 65%",end:"115% 65%",scrub:!0}})})};let h=Hn(!1);const d=()=>{if(!o()){Fy(h,!0),document.body.style.setProperty("--scroll-velocity","0"),a=document.querySelectorAll("."),u();for(let m of a){const v=window.getComputedStyle(m).transform;let g=0;if(v&&v!=="none"){const A=v.match(/^matrix3d\((.+)\)$/);if(A){const P=A[1].split(", ").map(parseFloat);g=Math.atan2(P[1],P[0])*(180/Math.PI)}}m.removeAttribute("style"),m.style.transformStyle="flat";const _=m.querySelector(".home-project-image.original");_.style.zIndex="200";let y=8;const w=document.createElement("div");w.classList.add("clones-container"),w.style.zIndex="0",w.style.pointerEvents="none",w.style.position="absolute",w.style.width="100%";for(let A=0;A{A.style.opacity=`${P}`;const R=`-${E*1.25+(I*I/2||0)*.1}rem`,U=`${E*2}rem`,L=`${E*-.05*I}rem`,z=`calc(var(--scroll-velocity)*${I}*0.05rem)`;A.style.transform=`translateY(${z}) translate3d(${R}, ${U}, ${L})`};M(_,{opacity:1,translate:0,transformIndex:0});for(let[A,P]of x.reverse().entries()){const E=Cn.utils.interpolate(.85,.15,A/y),I=Cn.utils.interpolate(.25,4,A/y);M(P,{opacity:E,translate:I,transformIndex:A+1})}const T=m.querySelector(".home-project-info").querySelector(".info-offset");if(T){const A=window.matchMedia("(orientation: landscape) and (hover: hover) and (pointer: fine)"),P=()=>{A.matches?T.style.transform=`rotate(${-g}deg)`:T.style.transform=""};P(),A.addEventListener("change",P)}}}};Gr(()=>(d(),()=>{qt.getAll().forEach(m=>m.kill())})),Ga(()=>(r(),fe(c)),()=>{r()&&!fe(c)&&(Mn(c,!0),r().on("scroll",m=>{Fy(l,m.velocity)}))}),Ga(()=>n(),()=>{document.body.style.setProperty("--scroll-velocity",`${n()}`)}),Dy(),go();var f=Et({$set:Ct,$on:(m,v)=>At(e,m,v)});return i(),f}Pt(ob,{},[],[],!0);function ab(s,e){if(new.target)return Tt({component:ab,...s});Mt(e,!1);const t=n=>{const r=new Vm(n,{types:"chars,words"}),o=n.querySelector(".menu-item");o.style.display="flex",o.style.flexDirection="column",o.style.alignItems="center",o.style.justifyContent="center",o.style.overflow="hidden",o.style.height="2rem";const a=document.createElement("div");a.classList.add("clone-container"),a.style.position="absolute",a.style.transform="translateY(125%)",o.appendChild(a);const l=document.createElement("div");l.classList.add("original-container"),l.style.display="flex",o.appendChild(l);const c=Array.from(n.querySelectorAll(".word")),u=c.map(m=>{const v=m.cloneNode(!0);return v.classList.add("clone"),a.appendChild(v),v});a.style.display="flex";for(let m=0;m{if(l.appendChild(m),m!==c[c.length-1]){const v=document.createElement("span");v.innerHTML=" ",l.appendChild(v)}});const h=l.querySelectorAll(".word .char"),d=a.querySelectorAll(".word .char"),f=Cn.timeline({paused:!0});return f.to(h,{yPercent:-125,duration:.8,stagger:.06,ease:"power2.out"},0),f.to(d,{yPercent:-125,duration:.8,stagger:.06,ease:"power2.out"},0),n.addEventListener("mouseenter",()=>{f.timeScale(1),f.play()}),n.addEventListener("mouseleave",()=>{f.timeScale(2),f.reverse()}),{destroy:()=>{n.removeEventListener("mouseenter",()=>{f.timeScale(1),f.play()}),n.removeEventListener("mouseleave",()=>{f.timeScale(2),f.reverse()}),r.revert()}}},i=()=>{let n=[];const r=document.querySelectorAll(".menu-link"),o=()=>{n.forEach(a=>a.destroy()),n=[],window.innerWidth>window.innerHeight&&r.forEach(a=>{const l=t(a);n.push(l)})};return o(),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),n.forEach(a=>a.destroy())}};return Gr(()=>{const n=i();Ui(()=>{n&&n()})}),go(),Et({$set:Ct,$on:(n,r)=>At(e,n,r)})}Pt(ab,{},[],[],!0);function lb(s,e){if(new.target)return Tt({component:lb,...s});Mt(e,!1);const[t,i]=Pi(),n=()=>Rn(Lx,"$lenisController",t);let r,o,a,l=[],c=!1;const u=10,h=100,d=4e3;function f(A){const P=o.getBoundingClientRect();return{x:A.clientX-P.left,y:A.clientY-P.top}}function m(A,P){return Math.sqrt(Math.pow(P.x-A.x,2)+Math.pow(P.y-A.y,2))}function v(A){let P=0;for(let E=1;Ed&&l.shift(),w()}}function y(A){A.pointerType==="touch"&&(c=!1,n()&&n().start())}function w(){if(a.clearRect(0,0,o.width,o.height),l.length<=1)return;let A=[],P=[];A.push(l[l.length-1]);let E=0;for(let I=l.length-2;I>=0;I--){const R=m(l[I],l[I+1]);if(E+=R,E<=h)A.unshift(l[I]);else{P=l.slice(0,I+1),A.length>0&&A[0]!==l[I]&&A.unshift(l[I]);break}}if(P.length===0&&l.length>1&&(P=[l[0]]),P.length>0){a.beginPath(),a.moveTo(P[0].x,P[0].y);for(let I=1;I1){const I=v(A);let R=0;for(let U=0;U{if(r=document.querySelector(".drawing-canvas"),!r){console.error("Drawing canvas element not found");return}o=document.createElement("canvas"),o.width=r.clientWidth,o.height=r.clientHeight,o.style.display="block",a=o.getContext("2d"),a.lineCap="round",a.lineJoin="round",r.appendChild(o),r.style.cursor="none",o.addEventListener("pointerdown",g),o.addEventListener("pointermove",_),o.addEventListener("pointerup",y),o.addEventListener("pointercancel",y),window.addEventListener("resize",C);const A=document.querySelector("#download-btn"),P=document.querySelector("#reset-btn"),E=new IntersectionObserver(I=>{I[0].isIntersecting||x()},{threshold:0});return E.observe(r),A&&P&&(A.addEventListener("click",M),P.addEventListener("click",I=>{I.preventDefault(),x()})),()=>{o.removeEventListener("pointerdown",g),o.removeEventListener("pointermove",_),o.removeEventListener("pointerup",y),o.removeEventListener("pointercancel",y),window.removeEventListener("resize",C),E.disconnect(),A&&P&&(A.removeEventListener("click",M),P.removeEventListener("click",I=>{I.preventDefault(),x()}))}}),go();var T=Et({$set:Ct,$on:(A,P)=>At(e,A,P)});return i(),T}Pt(lb,{},[],[],!0);function cb(s,e){return new.target?Tt({component:cb,...s}):(Mt(e,!1),Gr(()=>{const t=document.querySelector(".whats-next-section");if(!t)return;const i=t.querySelector(".cta-row"),n=t.querySelector(".next-links"),r=t.querySelector(".section-container"),o=t.querySelector(".cta-heading");if(!i||!n)return;const a=t.classList.contains("black-bg"),l=a?"var(--jasmine)":"var(--website--black)",c=a?"var(--website--black)":"var(--website--white)";i.style.position="relative",n.style.position="relative";const u=new Map,h=new Map,d=Array.from(n.querySelectorAll(".next-link")),f=(G="#0B0B0B")=>` `;let m=null,v=null,g=null;r&&(m=r.getBoundingClientRect(),v=i.getBoundingClientRect(),g=v.left-m.left),d.forEach(G=>{const W=G;if(W.hasAttribute("surprise-links")){const O=W.getAttribute("surprise-links");if(O){const B=O.slice(1,-1).split(",");if(B.length>0){const J=Math.floor(Math.random()*B.length),re=B[J];W.setAttribute("href",`/projects/${re}`)}}}W.style.position="relative",W.style.zIndex="1",W.style.height=`${W.offsetHeight}px`;const q=W.querySelector("h1");q&&(q.style.height=`${q.offsetHeight}px`,q.style.overflow="visible",q.style.position="relative",u.set(q,q.innerHTML),W.querySelectorAll("*").forEach(O=>{h.set(O,O.style.color||"")}))});const _=G=>{const W=G.querySelector("h1");if(!W)return;let q=W.querySelector(".next-link-arrow");if(q){Cn.to(q,{opacity:1,duration:.2,delay:.15,ease:"power5.out"});return}const O=window.getComputedStyle(W);O.color;const B=O.textAlign,J=W.textContent||"";W.innerHTML=` ${f(c)} ${J} `,q=W.querySelector(".next-link-arrow"),Cn.fromTo(q,{opacity:0},{opacity:1,duration:.4,ease:"power5.in"})},y=G=>{const W=G.querySelector("h1");if(!W)return;const q=W.querySelector(".next-link-arrow");q&&Cn.to(q,{opacity:0,duration:.3,ease:"power3.inOut",onComplete:()=>{W&&u.has(W)&&(W.innerHTML=u.get(W)||"")}})},w=()=>{document.querySelectorAll(".next-link-arrow").forEach(W=>{const q=W;Cn.to(q,{opacity:0,duration:.3,ease:"power3.inOut",onComplete:()=>{if(!P){const O=q.closest("h1");O&&u.has(O)&&(O.innerHTML=u.get(O)||"")}}})})},x=()=>{const G=document.createElement("div");return G.style.cssText=` position: absolute; background-color: ${l}; z-index: 0; opacity: 0; pointer-events: none; `,r&&m&&g?(G.style.width=`${m.width}px`,G.style.left=`${-g}px`):(G.style.width="100%",G.style.left="0"),G},M=G=>{Cn.to(o,{opacity:G?0:1,duration:.25,ease:"power3.inOut"})},C=(G,W)=>{const q=!G.nextElementSibling,O=W?"transparent":a?"var(--website--white)":"var(--website--black)";Cn.to(G,{borderTopColor:O,duration:.1,ease:"linear"}),q&&Cn.to(G,{borderBottomColor:O,duration:.1,ease:"linear"});const B=G.nextElementSibling;B&&B.classList.contains("next-link")&&Cn.to(B,{borderTopColor:O,duration:.1,ease:"linear"})},T=(G,W)=>{const q=W?c:"";Cn.to(G.querySelectorAll("h1"),{color:(O,B)=>W?q:h.get(B)||"",duration:.025,delay:0,ease:"power4.in"})},A=(G,W)=>{if(!G||!G.parentNode)return;const q=G.getBoundingClientRect(),B=(W.clientY-q.top)/q.height<.5?"up":"down";G.style.transformOrigin=B==="down"?"top center":"bottom center",Cn.to(G,{scaleY:0,opacity:0,duration:.25,ease:"power3.inOut",onComplete:()=>{G.remove(),R=R.filter(J=>J!==G)}})};let P=null,E=null,I=null,R=[];const U=G=>{const W=G.currentTarget;E!==null&&(clearTimeout(E),E=null),I=W,E=setTimeout(()=>{if(I!==W||P===W)return;const q=P&&(P.nextElementSibling===W||P.previousElementSibling===W),O=W.offsetTop,B=W.offsetHeight,re=G.offsetY/B<.5?"down":"up";if(M(!0),T(W,!0),_(W),C(W,!0),P&&(T(P,!1),y(P),C(P,!1)),q&&R.length>0){const K=R[R.length-1];Cn.to(K,{top:`${O}px`,height:`${B}px`,duration:.3,ease:"power3.inOut"})}else{const K=x();if(i.appendChild(K),K.style.top=`${O}px`,K.style.height=`${B}px`,K.style.transform="scaleY(0)",K.style.transformOrigin=re==="down"?"top center":"bottom center",R.push(K),P&&!q&&R.length>1){const Q=R[R.length-2],ue=re==="down"?"up":"down";Q.style.transformOrigin=ue==="down"?"top center":"bottom center",Cn.to(Q,{scaleY:0,opacity:0,duration:.3,ease:"power3.inOut",onComplete:()=>{Q.remove(),R=R.filter(le=>le!==Q)}})}Cn.fromTo(K,{scaleY:0,opacity:0},{scaleY:1,opacity:1,duration:.3,ease:"power3.inOut"})}P=W,E=null},70)},L=G=>{if(E!==null&&(clearTimeout(E),E=null),I=null,!P)return;const W=G.relatedTarget;W&&W.closest(".next-link")!==null||(R.forEach(O=>A(O,G)),M(!1),C(P,!1),T(P,!1))},k=G=>{E!==null&&(clearTimeout(E),E=null),I=null,!(R.length===0&&!P)&&(R.forEach(W=>A(W,G)),M(!1),w(),P&&(C(P,!1),T(P,!1)),P=null)},z=G=>{if(R.length===0&&!P)return;const W=i.getBoundingClientRect();(G.clientXW.right+10||G.clientYW.bottom+10)&&(R.forEach(O=>A(O,G)),P=null)};return d.forEach(G=>{G.addEventListener("mouseenter",U),G.addEventListener("mouseleave",L)}),i.addEventListener("mouseleave",k),n.addEventListener("mouseleave",k),document.addEventListener("mousemove",G=>z(G)),()=>{document.removeEventListener("mousemove",z),d.forEach(G=>{G.removeEventListener("mouseenter",U),G.removeEventListener("mouseleave",L)}),i.removeEventListener("mouseleave",k),n.removeEventListener("mouseleave",k)}}),go(),Et({$set:Ct,$on:(t,i)=>At(e,t,i)}))}Pt(cb,{},[],[],!0);function ub(s,e){if(new.target)return Tt({component:ub,...s});Mt(e,!1);let t=[],i=[],n,r,o;const a=()=>{const c=window.innerWidth{const h=t.findIndex(f=>f.trigger===c);h>-1&&(t[h].kill(),t.splice(h,1));const d=c.parentElement;if(d&&(i=i.filter(f=>f.element===d?(d.removeEventListener(f.type,f.listener),!1):!0)),c.pause(),a()){const f=qt.create({trigger:c,start:"top bottom-=10%",end:"bottom top+=10%",onEnter:()=>{c.play().catch(m=>console.error("Video play failed:",c.src,m))},onLeave:()=>c.pause(),onEnterBack:()=>{c.play().catch(m=>console.error("Video play failed:",c.src,m))},onLeaveBack:()=>c.pause()});t.push(f)}else if(d){const f=()=>c.play().catch(v=>console.error("Hover play failed:",c.src,v)),m=()=>c.pause();d.addEventListener("mouseenter",f),i.push({element:d,type:"mouseenter",listener:f}),d.addEventListener("mouseleave",m),i.push({element:d,type:"mouseleave",listener:m})}};return Gr(()=>{const c=document.querySelectorAll(".fun-video video");c.forEach((h,d)=>{if(h.muted=!0,h.playsInline=!0,h.pause(),d===2){const f=()=>{h.duration>=4&&(h.currentTime=4),l(h),qt.refresh()};h.readyState>=h.HAVE_METADATA?f():h.addEventListener("loadedmetadata",f,{once:!0})}else l(h)});const u=()=>{console.log("ResizeObserver triggered, refreshing ScrollTriggers..."),qt.refresh()};return n=()=>{clearTimeout(o),o=setTimeout(()=>{console.log("Window resized, re-evaluating video behavior..."),c.forEach((h,d)=>{l(h)}),qt.refresh(),console.log("ScrollTriggers refreshed after resize handler.")},250)},window.addEventListener("resize",n),r=new ResizeObserver(u),r.observe(document.body),qt.refresh(),()=>{window.removeEventListener("resize",n),clearTimeout(o),r&&r.disconnect(),t.forEach(h=>h.kill()),t=[],i.forEach(h=>{h.element.removeEventListener(h.type,h.listener)}),i=[],c.forEach(h=>{h.pause()}),console.log("HandleHomeVideos cleanup complete.")}}),go(),Et({$set:Ct,$on:(c,u)=>At(e,c,u)})}Pt(ub,{},[],[],!0);function hb(s,e){if(new.target)return Tt({component:hb,...s});Mt(e,!1);const[t,i]=Pi(),n=()=>Rn(Lx,"$lenisController",t);let r,o;Cn.registerPlugin(qt);function a(m){if(!r)return;const{progress:v,limit:g}=m,_=window.innerHeight,y=g+_,w=Math.max(50,_/y*_);r.style.height=`${w}px`;const x=_-w,M=v*x;r.style.transform=`translateY(${M}px)`}function l(){r&&(r.style.backgroundColor="var(--jasmine)",r.style.width="0.5rem",r.style.position="fixed",r.style.inset="0% 0% 0% auto",r.style.zIndex="1200",r.style.cursor="pointer",r.style.mixBlendMode="difference",r.addEventListener("mouseenter",()=>{r.style.opacity="1"}),r.addEventListener("mouseleave",()=>{r.style.opacity="0.8"})),document.documentElement.style.scrollbarWidth="none",document.documentElement.style.msOverflowStyle="none",document.body.style.overflow="auto",document.body.style.overflowY="scroll";const m=document.createElement("style");m.textContent=` ::-webkit-scrollbar { display: none; } `,document.head.appendChild(m),n()&&a(n())}function c(){document.querySelectorAll(".home-project-instance").forEach(v=>{const g=v.querySelector(".home-project-info");g&&o&&(g.hasAttribute("data-initialized")||(g.setAttribute("data-x","0"),g.setAttribute("data-y","0"),g.setAttribute("data-initialized","true"),Cn.set(g,{x:0,y:0,zIndex:"300"})),v.addEventListener("mousemove",_=>{const y=_,w=v.getBoundingClientRect(),x=y.clientX-w.left,M=y.clientY-w.top,C=g.offsetWidth,T=g.offsetHeight,A=x-C/2,P=M-T/2;g.setAttribute("data-x",A.toString()),g.setAttribute("data-y",P.toString()),Cn.to(g,{x:A,y:P,duration:.8,ease:"elastic.out(1, 0.75)",overwrite:!0}),o.style.display="none"}),v.addEventListener("mouseleave",()=>{g.style.transform="",o.style.display="block"}))})}function u(){console.log("refresh"),n()&&(requestAnimationFrame(()=>{n().resize(),a(n())}),qt.refresh(!0))}function h(m){a(m)}let d=` background-color: var(--jasmine); width: 0.5rem; position: fixed; inset: 0% 0% 0% auto; z-index: 1200; cursor: pointer; mix-blend-mode: difference; `;Gr(()=>{r=document.querySelector(".custom-scrollbar"),document.querySelector(".custom-cursor"),o=document.querySelector(".custom-cursor-container"),r&&(r.style.cssText=d,l()),c(),window.addEventListener("resize",u),n()&&n().on("scroll",h);let m=null;return(()=>{m&&(m.disconnect(),m=null);const g=document.querySelector(".page-wrapper");g&&(m=new MutationObserver(_=>{let y=!1;for(const w of _)if(w.type==="childList"&&w.addedNodes.length>0?y=Array.from(w.addedNodes).some(x=>x.nodeType===Node.ELEMENT_NODE&&x.matches("section, div.some-large-component")):w.type==="attributes"&&(w.attributeName==="class"||w.attributeName==="style")&&w.target.matches(".home-project-instance, section, div.some-layout-element")&&(y=!0),y)break;y&&(console.log("significantChange"),u(),c())}),m.observe(g,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]}))})(),r&&(r.addEventListener("mouseenter",()=>{r.style.opacity="1"}),r.addEventListener("mouseleave",()=>{r.style.opacity="0.8"})),()=>{window.removeEventListener("resize",u),m&&m.disconnect(),n()&&n().off("scroll",h)}}),go();var f=Et({$set:Ct,$on:(m,v)=>At(e,m,v)});return i(),f}Pt(hb,{},[],[],!0);function db(s,e){return new.target?Tt({component:db,...s}):(Mt(e,!1),Gr(()=>{const t=document.querySelectorAll("video");console.log("Found videos:",t.length);const i=[];t.forEach(o=>{o.muted=!0,o.autoplay=!1,o.playsInline=!0,o.pause();const a=qt.create({trigger:o,start:"top bottom-=20%",end:"bottom top+=20%",onEnter:()=>{o.play().catch(l=>console.error("Video play failed:",o.src,l))}});i.push(a)});const n=()=>{qt.refresh()};window.addEventListener("resize",n);const r=new ResizeObserver(o=>{n()});return r.observe(document.body),()=>{window.removeEventListener("resize",n),r.disconnect(),i.forEach(o=>o.kill()),t.forEach(o=>{o.pause()})}}),go(),Et({$set:Ct,$on:(t,i)=>At(e,t,i)}))}Pt(db,{},[],[],!0);var $F=Kn(" ",1),JF=Kn(" ",1);function Tg(s,e){if(new.target)return Tt({component:Tg,...s});Mt(e,!1);let t=Yl(!1);function i(a){Promise.all([document.fonts.ready,new Promise(l=>{document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>l()):l()})]).then(()=>{requestAnimationFrame(()=>{a()})})}Gr(()=>{Cn.registerPlugin(qt),i(()=>{Mn(t,!0)})}),go();var n=Lt(),r=dt(n);{var o=a=>{var l=JF(),c=dt(l);Ix(c,{});var u=Ln(c,2);ab(u,{});var h=Ln(u,2);cb(h,{});var d=Ln(h,2);hb(d,{});var f=Ln(d,2);{var m=g=>{var _=$F(),y=dt(_);ub(y,{});var w=Ln(y,2);ob(w,{});var x=Ln(w,2);lb(x,{}),lt(g,_)},v=g=>{db(g,{})};wi(f,g=>{window.location.pathname==="/"?g(m):g(v,!1)})}lt(a,l)};wi(r,a=>{fe(t)&&a(o)})}return lt(s,n),wk(e,"whenDomIsReady",i),Et({whenDomIsReady:i,$set:Ct,$on:(a,l)=>At(e,a,l)})}customElements.define("florag-webflow-animations",Pt(Tg,{},[],["whenDomIsReady"],!0));/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */const _h="174",Us={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Sc={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},XA=0,fb=1,YA=2,QF=3,eN=0,pb=1,Cf=2,Xo=3,ks=0,ji=1,Ei=2,fa=0,Mc=1,Pf=2,mb=3,gb=4,jA=5,rl=100,qA=101,ZA=102,KA=103,$A=104,JA=200,QA=201,e2=202,t2=203,Ag=204,Cg=205,n2=206,i2=207,r2=208,s2=209,o2=210,a2=211,l2=212,c2=213,u2=214,Pg=0,Rg=1,Dg=2,Ec=3,Ig=4,Lg=5,Ug=6,kg=7,Rf=0,h2=1,d2=2,Yo=0,f2=1,p2=2,m2=3,g2=4,v2=5,Og=6,_2=7,vb="attached",y2="detached",Fg=300,pa=301,sl=302,yh=303,Df=304,xh=306,Os=1e3,pr=1001,bh=1002,En=1003,Ng=1004,tN=1004,Tc=1005,nN=1005,bn=1006,wh=1007,iN=1007,Fs=1008,rN=1008,Qs=1009,If=1010,Bg=1011,Ac=1012,Cc=1013,hs=1014,Un=1015,mr=1016,zg=1017,Vg=1018,Pc=1020,_b=35902,yb=1021,xb=1022,di=1023,bb=1024,wb=1025,Rc=1026,Dc=1027,Sh=1028,Mh=1029,Gg=1030,Eh=1031,sN=1032,Ic=1033,Lf=33776,Uf=33777,kf=33778,Of=33779,Hg=35840,Wg=35841,Xg=35842,Yg=35843,jg=36196,qg=37492,Zg=37496,Kg=37808,$g=37809,Jg=37810,Qg=37811,ev=37812,tv=37813,nv=37814,iv=37815,rv=37816,sv=37817,ov=37818,av=37819,lv=37820,cv=37821,Ff=36492,uv=36494,hv=36495,Sb=36283,dv=36284,fv=36285,pv=36286,x2=2200,b2=2201,w2=2202,Th=2300,Ah=2301,mv=2302,Lc=2400,Uc=2401,Nf=2402,gv=2500,Mb=2501,S2=0,Eb=1,vv=2,M2=3200,Ch=3201,oN=3202,aN=3203,ol=0,E2=1,jo="",Ni="srgb",Ii="srgb-linear",Bf="linear",Wn="srgb",lN=0,kc=7680,_v=7681,cN=7682,uN=7683,hN=34055,dN=34056,fN=5386,pN=512,mN=513,gN=514,vN=515,_N=516,yN=517,xN=518,yv=519,T2=512,A2=513,C2=514,Tb=515,P2=516,R2=517,D2=518,I2=519,zf=35044,Ph=35048,bN=35040,wN=35045,SN=35049,MN=35041,EN=35046,TN=35050,AN=35042,CN="100",Ab="300 es",yo=2e3,Vf=2001,PN={COMPUTE:"compute",RENDER:"render"};class qo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let r=0,o=n.length;r>8&255]+Lr[s>>16&255]+Lr[s>>24&255]+"-"+Lr[e&255]+Lr[e>>8&255]+"-"+Lr[e>>16&15|64]+Lr[e>>24&255]+"-"+Lr[t&63|128]+Lr[t>>8&255]+"-"+Lr[t>>16&255]+Lr[t>>24&255]+Lr[i&255]+Lr[i>>8&255]+Lr[i>>16&255]+Lr[i>>24&255]).toLowerCase()}function en(s,e,t){return Math.max(e,Math.min(t,s))}function Cb(s,e){return(s%e+e)%e}function RN(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function DN(s,e,t){return s!==e?(t-s)/(e-s):0}function Gf(s,e,t){return(1-t)*s+t*e}function IN(s,e,t,i){return Gf(s,e,1-Math.exp(-t*i))}function LN(s,e=1){return e-Math.abs(Cb(s,e*2)-e)}function UN(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function kN(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function ON(s,e){return s+Math.floor(Math.random()*(e-s+1))}function FN(s,e){return s+Math.random()*(e-s)}function NN(s){return s*(.5-Math.random())}function BN(s){s!==void 0&&(L2=s);let e=L2+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function zN(s){return s*Oc}function VN(s){return s*Rh}function GN(s){return(s&s-1)===0&&s!==0}function HN(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function WN(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function XN(s,e,t,i,n){const r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+i)/2),u=o((e+i)/2),h=r((e-i)/2),d=o((e-i)/2),f=r((i-e)/2),m=o((i-e)/2);switch(n){case"XYX":s.set(a*u,l*h,l*d,a*c);break;case"YZY":s.set(l*d,a*u,l*h,a*c);break;case"ZXZ":s.set(l*h,l*d,a*u,a*c);break;case"XZX":s.set(a*u,l*m,l*f,a*c);break;case"YXY":s.set(l*f,a*u,l*m,a*c);break;case"ZYZ":s.set(l*m,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function $r(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function sn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const qi={DEG2RAD:Oc,RAD2DEG:Rh,generateUUID:Ns,clamp:en,euclideanModulo:Cb,mapLinear:RN,inverseLerp:DN,lerp:Gf,damp:IN,pingpong:LN,smoothstep:UN,smootherstep:kN,randInt:ON,randFloat:FN,randFloatSpread:NN,seededRandom:BN,degToRad:zN,radToDeg:VN,isPowerOfTwo:GN,ceilPowerOfTwo:HN,floorPowerOfTwo:WN,setQuaternionFromProperEuler:XN,normalize:sn,denormalize:$r};class Ne{constructor(e=0,t=0){Ne.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=en(this.x,e.x,t.x),this.y=en(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=en(this.x,e,t),this.y=en(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(en(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(en(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*n+e.x,this.y=r*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Jt{constructor(e,t,i,n,r,o,a,l,c){Jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,o,a,l,c)}set(e,t,i,n,r,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=n,u[2]=a,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],f=i[5],m=i[8],v=n[0],g=n[3],_=n[6],y=n[1],w=n[4],x=n[7],M=n[2],C=n[5],T=n[8];return r[0]=o*v+a*y+l*M,r[3]=o*g+a*w+l*C,r[6]=o*_+a*x+l*T,r[1]=c*v+u*y+h*M,r[4]=c*g+u*w+h*C,r[7]=c*_+u*x+h*T,r[2]=d*v+f*y+m*M,r[5]=d*g+f*w+m*C,r[8]=d*_+f*x+m*T,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*r*u+i*a*l+n*r*c-n*o*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,d=a*l-u*r,f=c*r-o*l,m=t*h+i*d+n*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=h*v,e[1]=(n*c-u*i)*v,e[2]=(a*i-n*o)*v,e[3]=d*v,e[4]=(u*t-n*l)*v,e[5]=(n*r-a*t)*v,e[6]=f*v,e[7]=(i*l-c*t)*v,e[8]=(o*t-i*r)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-n*c,n*l,-n*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Pb.makeScale(e,t)),this}rotate(e){return this.premultiply(Pb.makeRotation(-e)),this}translate(e,t){return this.premultiply(Pb.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Pb=new Jt;function U2(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const YN={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Dh(s,e){return new YN[s](e)}function Hf(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function k2(){const s=Hf("canvas");return s.style.display="block",s}const O2={};function Fc(s){s in O2||(O2[s]=!0,console.warn(s))}function jN(s,e,t){return new Promise(function(i,n){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:n();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}function qN(s){const e=s.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function ZN(s){const e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const F2=new Jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),N2=new Jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function KN(){const s={enabled:!0,workingColorSpace:Ii,spaces:{},convert:function(n,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Wn&&(n.r=ma(n.r),n.g=ma(n.g),n.b=ma(n.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Wn&&(n.r=Ih(n.r),n.g=Ih(n.g),n.b=Ih(n.b))),n},fromWorkingColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},toWorkingColorSpace:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===jo?Bf:this.spaces[n].transfer},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,o){return n.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Ii]:{primaries:e,whitePoint:i,transfer:Bf,toXYZ:F2,fromXYZ:N2,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ni},outputColorSpaceConfig:{drawingBufferColorSpace:Ni}},[Ni]:{primaries:e,whitePoint:i,transfer:Wn,toXYZ:F2,fromXYZ:N2,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ni}}}),s}const mn=KN();function ma(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ih(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Lh;class B2{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Lh===void 0&&(Lh=Hf("canvas")),Lh.width=e.width,Lh.height=e.height;const i=Lh.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Lh}return t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Hf("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let o=0;o0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Fg)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Os:e.x=e.x-Math.floor(e.x);break;case pr:e.x=e.x<0?0:1;break;case bh:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Os:e.y=e.y-Math.floor(e.y);break;case pr:e.y=e.y<0?0:1;break;case bh:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ni.DEFAULT_IMAGE=null,ni.DEFAULT_MAPPING=Fg,ni.DEFAULT_ANISOTROPY=1;class Zt{constructor(e=0,t=0,i=0,n=1){Zt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*n+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],m=l[9],v=l[2],g=l[6],_=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-v)<.01&&Math.abs(m-g)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+v)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,x=(f+1)/2,M=(_+1)/2,C=(u+d)/4,T=(h+v)/4,A=(m+g)/4;return w>x&&w>M?w<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(w),n=C/i,r=T/i):x>M?x<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(x),i=C/n,r=A/n):M<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(M),i=T/r,n=A/r),this.set(i,n,r,t),this}let y=Math.sqrt((g-m)*(g-m)+(h-v)*(h-v)+(d-u)*(d-u));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(h-v)/y,this.z=(d-u)/y,this.w=Math.acos((c+f+_-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=en(this.x,e.x,t.x),this.y=en(this.y,e.y,t.y),this.z=en(this.z,e.z,t.z),this.w=en(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=en(this.x,e,t),this.y=en(this.y,e,t),this.z=en(this.z,e,t),this.w=en(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(en(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class xv extends qo{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Zt(0,0,e,t),this.scissorTest=!1,this.viewport=new Zt(0,0,e,t);const n={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const r=new ni(n,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);r.flipY=!1,r.generateMipmaps=i.generateMipmaps,r.internalFormat=i.internalFormat,this.textures=[];const o=i.count;for(let a=0;a=0?1:-1,w=1-_*_;if(w>Number.EPSILON){const M=Math.sqrt(w),C=Math.atan2(M,_*y);g=Math.sin(g*C)/M,a=Math.sin(a*C)/M}const x=a*y;if(l=l*g+d*x,c=c*g+f*x,u=u*g+m*x,h=h*g+v*x,g===1-a){const M=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=M,c*=M,u*=M,h*=M}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,n,r,o){const a=i[n],l=i[n+1],c=i[n+2],u=i[n+3],h=r[o],d=r[o+1],f=r[o+2],m=r[o+3];return e[t]=a*m+u*h+l*f-c*d,e[t+1]=l*m+u*d+c*h-a*f,e[t+2]=c*m+u*f+a*d-l*h,e[t+3]=u*m-a*h-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,n=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(n/2),h=a(r/2),d=l(i/2),f=l(n/2),m=l(r/2);switch(o){case"XYZ":this._x=d*u*h+c*f*m,this._y=c*f*h-d*u*m,this._z=c*u*m+d*f*h,this._w=c*u*h-d*f*m;break;case"YXZ":this._x=d*u*h+c*f*m,this._y=c*f*h-d*u*m,this._z=c*u*m-d*f*h,this._w=c*u*h+d*f*m;break;case"ZXY":this._x=d*u*h-c*f*m,this._y=c*f*h+d*u*m,this._z=c*u*m+d*f*h,this._w=c*u*h-d*f*m;break;case"ZYX":this._x=d*u*h-c*f*m,this._y=c*f*h+d*u*m,this._z=c*u*m-d*f*h,this._w=c*u*h+d*f*m;break;case"YZX":this._x=d*u*h+c*f*m,this._y=c*f*h+d*u*m,this._z=c*u*m-d*f*h,this._w=c*u*h-d*f*m;break;case"XZY":this._x=d*u*h-c*f*m,this._y=c*f*h-d*u*m,this._z=c*u*m+d*f*h,this._w=c*u*h+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+a+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(o-n)*f}else if(i>a&&i>h){const f=2*Math.sqrt(1+i-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(n+o)/f,this._z=(r+c)/f}else if(a>h){const f=2*Math.sqrt(1+a-i-h);this._w=(r-c)/f,this._x=(n+o)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-i-a);this._w=(o-n)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(en(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+n*c-r*l,this._y=n*u+o*l+r*a-i*c,this._z=r*u+o*c+i*l-n*a,this._w=o*u-i*a-n*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,n=this._y,r=this._z,o=this._w;let a=o*e._w+i*e._x+n*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=n,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*n+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*h+this._w*d,this._x=i*h+this._x*d,this._y=n*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class X{constructor(e=0,t=0,i=0){X.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(z2.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(z2.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*n-a*i),u=2*(a*t-r*n),h=2*(r*i-o*t);return this.x=t+l*c+o*h-a*u,this.y=i+l*u+a*c-r*h,this.z=n+l*h+r*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=en(this.x,e.x,t.x),this.y=en(this.y,e.y,t.y),this.z=en(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=en(this.x,e,t),this.y=en(this.y,e,t),this.z=en(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(en(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=n*l-r*a,this.y=r*o-i*l,this.z=i*a-n*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Db.copy(this).projectOnVector(e),this.sub(Db)}reflect(e){return this.sub(Db.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(en(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Db=new X,z2=new Tn;class yn{constructor(e=new X(1/0,1/0,1/0),t=new X(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,xo),xo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Xf),Sv.subVectors(this.max,Xf),Uh.subVectors(e.a,Xf),kh.subVectors(e.b,Xf),Oh.subVectors(e.c,Xf),ll.subVectors(kh,Uh),cl.subVectors(Oh,kh),Nc.subVectors(Uh,Oh);let t=[0,-ll.z,ll.y,0,-cl.z,cl.y,0,-Nc.z,Nc.y,ll.z,0,-ll.x,cl.z,0,-cl.x,Nc.z,0,-Nc.x,-ll.y,ll.x,0,-cl.y,cl.x,0,-Nc.y,Nc.x,0];return!Ib(t,Uh,kh,Oh,Sv)||(t=[1,0,0,0,1,0,0,0,1],!Ib(t,Uh,kh,Oh,Sv))?!1:(Mv.crossVectors(ll,cl),t=[Mv.x,Mv.y,Mv.z],Ib(t,Uh,kh,Oh,Sv))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,xo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(xo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ga),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const ga=[new X,new X,new X,new X,new X,new X,new X,new X],xo=new X,wv=new yn,Uh=new X,kh=new X,Oh=new X,ll=new X,cl=new X,Nc=new X,Xf=new X,Sv=new X,Mv=new X,Bc=new X;function Ib(s,e,t,i,n){for(let r=0,o=s.length-3;r<=o;r+=3){Bc.fromArray(s,r);const a=n.x*Math.abs(Bc.x)+n.y*Math.abs(Bc.y)+n.z*Math.abs(Bc.z),l=e.dot(Bc),c=t.dot(Bc),u=i.dot(Bc);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const tB=new yn,Yf=new X,Lb=new X;class fi{constructor(e=new X,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):tB.setFromPoints(e).getCenter(i);let n=0;for(let r=0,o=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yf.subVectors(e,this.center);const t=Yf.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Yf,n/i),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Lb.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yf.copy(e.center).add(Lb)),this.expandByPoint(Yf.copy(e.center).sub(Lb))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const va=new X,Ub=new X,Ev=new X,ul=new X,kb=new X,Tv=new X,Ob=new X;class hl{constructor(e=new X,t=new X(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,va)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=va.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(va.copy(this.origin).addScaledVector(this.direction,t),va.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Ub.copy(e).add(t).multiplyScalar(.5),Ev.copy(t).sub(e).normalize(),ul.copy(this.origin).sub(Ub);const r=e.distanceTo(t)*.5,o=-this.direction.dot(Ev),a=ul.dot(this.direction),l=-ul.dot(Ev),c=ul.lengthSq(),u=Math.abs(1-o*o);let h,d,f,m;if(u>0)if(h=o*l-a,d=o*a-l,m=r*u,h>=0)if(d>=-m)if(d<=m){const v=1/u;h*=v,d*=v,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=r,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d<=-m?(h=Math.max(0,-(-o*r+a)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=m?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(o*r+a)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=o>0?-r:r,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),n&&n.copy(Ub).addScaledVector(Ev,d),f}intersectSphere(e,t){va.subVectors(e.center,this.origin);const i=va.dot(this.direction),n=va.dot(va)-i*i,r=e.radius*e.radius;if(n>r)return null;const o=Math.sqrt(r-n),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,n=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,n=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),i>o||r>n||((r>i||isNaN(i))&&(i=r),(o=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||a>n)||((a>i||i!==i)&&(i=a),(l=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,va)!==null}intersectTriangle(e,t,i,n,r){kb.subVectors(t,e),Tv.subVectors(i,e),Ob.crossVectors(kb,Tv);let o=this.direction.dot(Ob),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ul.subVectors(this.origin,e);const l=a*this.direction.dot(Tv.crossVectors(ul,Tv));if(l<0)return null;const c=a*this.direction.dot(kb.cross(ul));if(c<0||l+c>o)return null;const u=-a*ul.dot(Ob);return u<0?null:this.at(u/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class _t{constructor(e,t,i,n,r,o,a,l,c,u,h,d,f,m,v,g){_t.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,o,a,l,c,u,h,d,f,m,v,g)}set(e,t,i,n,r,o,a,l,c,u,h,d,f,m,v,g){const _=this.elements;return _[0]=e,_[4]=t,_[8]=i,_[12]=n,_[1]=r,_[5]=o,_[9]=a,_[13]=l,_[2]=c,_[6]=u,_[10]=h,_[14]=d,_[3]=f,_[7]=m,_[11]=v,_[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new _t().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/Fh.setFromMatrixColumn(e,0).length(),r=1/Fh.setFromMatrixColumn(e,1).length(),o=1/Fh.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(n),c=Math.sin(n),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=o*u,f=o*h,m=a*u,v=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+m*c,t[5]=d-v*c,t[9]=-a*l,t[2]=v-d*c,t[6]=m+f*c,t[10]=o*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,m=c*u,v=c*h;t[0]=d+v*a,t[4]=m*a-f,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=f*a-m,t[6]=v+d*a,t[10]=o*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,m=c*u,v=c*h;t[0]=d-v*a,t[4]=-o*h,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*u,t[9]=v-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const d=o*u,f=o*h,m=a*u,v=a*h;t[0]=l*u,t[4]=m*c-f,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=f*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const d=o*l,f=o*c,m=a*l,v=a*c;t[0]=l*u,t[4]=v-d*h,t[8]=m*h+f,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=f*h+m,t[10]=d-v*h}else if(e.order==="XZY"){const d=o*l,f=o*c,m=a*l,v=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=o*u,t[9]=f*h-m,t[2]=m*h-f,t[6]=a*u,t[10]=v*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(nB,e,iB)}lookAt(e,t,i){const n=this.elements;return zs.subVectors(e,t),zs.lengthSq()===0&&(zs.z=1),zs.normalize(),dl.crossVectors(i,zs),dl.lengthSq()===0&&(Math.abs(i.z)===1?zs.x+=1e-4:zs.z+=1e-4,zs.normalize(),dl.crossVectors(i,zs)),dl.normalize(),Av.crossVectors(zs,dl),n[0]=dl.x,n[4]=Av.x,n[8]=zs.x,n[1]=dl.y,n[5]=Av.y,n[9]=zs.y,n[2]=dl.z,n[6]=Av.z,n[10]=zs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],f=i[13],m=i[2],v=i[6],g=i[10],_=i[14],y=i[3],w=i[7],x=i[11],M=i[15],C=n[0],T=n[4],A=n[8],P=n[12],E=n[1],I=n[5],R=n[9],U=n[13],L=n[2],k=n[6],z=n[10],G=n[14],W=n[3],q=n[7],O=n[11],B=n[15];return r[0]=o*C+a*E+l*L+c*W,r[4]=o*T+a*I+l*k+c*q,r[8]=o*A+a*R+l*z+c*O,r[12]=o*P+a*U+l*G+c*B,r[1]=u*C+h*E+d*L+f*W,r[5]=u*T+h*I+d*k+f*q,r[9]=u*A+h*R+d*z+f*O,r[13]=u*P+h*U+d*G+f*B,r[2]=m*C+v*E+g*L+_*W,r[6]=m*T+v*I+g*k+_*q,r[10]=m*A+v*R+g*z+_*O,r[14]=m*P+v*U+g*G+_*B,r[3]=y*C+w*E+x*L+M*W,r[7]=y*T+w*I+x*k+M*q,r[11]=y*A+w*R+x*z+M*O,r[15]=y*P+w*U+x*G+M*B,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],m=e[3],v=e[7],g=e[11],_=e[15];return m*(+r*l*h-n*c*h-r*a*d+i*c*d+n*a*f-i*l*f)+v*(+t*l*f-t*c*d+r*o*d-n*o*f+n*c*u-r*l*u)+g*(+t*c*h-t*a*f-r*o*h+i*o*f+r*a*u-i*c*u)+_*(-n*a*u-t*l*h+t*a*d+n*o*h-i*o*d+i*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],m=e[12],v=e[13],g=e[14],_=e[15],y=h*g*c-v*d*c+v*l*f-a*g*f-h*l*_+a*d*_,w=m*d*c-u*g*c-m*l*f+o*g*f+u*l*_-o*d*_,x=u*v*c-m*h*c+m*a*f-o*v*f-u*a*_+o*h*_,M=m*h*l-u*v*l-m*a*d+o*v*d+u*a*g-o*h*g,C=t*y+i*w+n*x+r*M;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=y*T,e[1]=(v*d*r-h*g*r-v*n*f+i*g*f+h*n*_-i*d*_)*T,e[2]=(a*g*r-v*l*r+v*n*c-i*g*c-a*n*_+i*l*_)*T,e[3]=(h*l*r-a*d*r-h*n*c+i*d*c+a*n*f-i*l*f)*T,e[4]=w*T,e[5]=(u*g*r-m*d*r+m*n*f-t*g*f-u*n*_+t*d*_)*T,e[6]=(m*l*r-o*g*r-m*n*c+t*g*c+o*n*_-t*l*_)*T,e[7]=(o*d*r-u*l*r+u*n*c-t*d*c-o*n*f+t*l*f)*T,e[8]=x*T,e[9]=(m*h*r-u*v*r-m*i*f+t*v*f+u*i*_-t*h*_)*T,e[10]=(o*v*r-m*a*r+m*i*c-t*v*c-o*i*_+t*a*_)*T,e[11]=(u*a*r-o*h*r-u*i*c+t*h*c+o*i*f-t*a*f)*T,e[12]=M*T,e[13]=(u*v*n-m*h*n+m*i*d-t*v*d-u*i*g+t*h*g)*T,e[14]=(m*a*n-o*v*n-m*i*l+t*v*l+o*i*g-t*a*g)*T,e[15]=(o*h*n-u*a*n+u*i*l-t*h*l-o*i*d+t*a*d)*T,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,o=e.x,a=e.y,l=e.z,c=r*o,u=r*a;return this.set(c*o+i,c*a-n*l,c*l+n*a,0,c*a+n*l,u*a+i,u*l-n*o,0,c*l-n*a,u*l+n*o,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,o){return this.set(1,i,r,0,e,1,o,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,u=o+o,h=a+a,d=r*c,f=r*u,m=r*h,v=o*u,g=o*h,_=a*h,y=l*c,w=l*u,x=l*h,M=i.x,C=i.y,T=i.z;return n[0]=(1-(v+_))*M,n[1]=(f+x)*M,n[2]=(m-w)*M,n[3]=0,n[4]=(f-x)*C,n[5]=(1-(d+_))*C,n[6]=(g+y)*C,n[7]=0,n[8]=(m+w)*T,n[9]=(g-y)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=Fh.set(n[0],n[1],n[2]).length();const o=Fh.set(n[4],n[5],n[6]).length(),a=Fh.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],bo.copy(this);const c=1/r,u=1/o,h=1/a;return bo.elements[0]*=c,bo.elements[1]*=c,bo.elements[2]*=c,bo.elements[4]*=u,bo.elements[5]*=u,bo.elements[6]*=u,bo.elements[8]*=h,bo.elements[9]*=h,bo.elements[10]*=h,t.setFromRotationMatrix(bo),i.x=r,i.y=o,i.z=a,this}makePerspective(e,t,i,n,r,o,a=yo){const l=this.elements,c=2*r/(t-e),u=2*r/(i-n),h=(t+e)/(t-e),d=(i+n)/(i-n);let f,m;if(a===yo)f=-(o+r)/(o-r),m=-2*o*r/(o-r);else if(a===Vf)f=-o/(o-r),m=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,r,o,a=yo){const l=this.elements,c=1/(t-e),u=1/(i-n),h=1/(o-r),d=(t+e)*c,f=(i+n)*u;let m,v;if(a===yo)m=(o+r)*h,v=-2*h;else if(a===Vf)m=r*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=v,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Fh=new X,bo=new _t,nB=new X(0,0,0),iB=new X(1,1,1),dl=new X,Av=new X,zs=new X,V2=new _t,G2=new Tn;class ds{constructor(e=0,t=0,i=0,n=ds.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],o=n[4],a=n[8],l=n[1],c=n[5],u=n[9],h=n[2],d=n[6],f=n[10];switch(t){case"XYZ":this._y=Math.asin(en(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-en(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(en(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-en(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(en(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-en(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return V2.makeRotationFromQuaternion(e),this.setFromRotationMatrix(V2,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return G2.setFromEuler(this),this.setFromQuaternion(G2,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ds.DEFAULT_ORDER="XYZ";class Cv{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),this.boundingBox!==null&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){n.children=[];for(let a=0;a0){n.animations=[];for(let a=0;a0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),m.length>0&&(i.nodes=m)}return i.object=n,i;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){wo.subVectors(n,t),ya.subVectors(i,t),Nb.subVectors(e,t);const o=wo.dot(wo),a=wo.dot(ya),l=wo.dot(Nb),c=ya.dot(ya),u=ya.dot(Nb),h=o*c-a*a;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-a*u)*d,m=(o*u-a*l)*d;return r.set(1-f-m,m,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,xa)===null?!1:xa.x>=0&&xa.y>=0&&xa.x+xa.y<=1}static getInterpolation(e,t,i,n,r,o,a,l){return this.getBarycoord(e,t,i,n,xa)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,xa.x),l.addScaledVector(o,xa.y),l.addScaledVector(a,xa.z),l)}static getInterpolatedAttribute(e,t,i,n,r,o){return Gb.setScalar(0),Hb.setScalar(0),Wb.setScalar(0),Gb.fromBufferAttribute(e,t),Hb.fromBufferAttribute(e,i),Wb.fromBufferAttribute(e,n),o.setScalar(0),o.addScaledVector(Gb,r.x),o.addScaledVector(Hb,r.y),o.addScaledVector(Wb,r.z),o}static isFrontFacing(e,t,i,n){return wo.subVectors(i,t),ya.subVectors(e,t),wo.cross(ya).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return wo.subVectors(this.c,this.b),ya.subVectors(this.a,this.b),wo.cross(ya).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return Zi.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return Zi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let o,a;zh.subVectors(n,i),Vh.subVectors(r,i),Bb.subVectors(e,i);const l=zh.dot(Bb),c=Vh.dot(Bb);if(l<=0&&c<=0)return t.copy(i);zb.subVectors(e,n);const u=zh.dot(zb),h=Vh.dot(zb);if(u>=0&&h<=u)return t.copy(n);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(zh,o);Vb.subVectors(e,r);const f=zh.dot(Vb),m=Vh.dot(Vb);if(m>=0&&f<=m)return t.copy(r);const v=f*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(i).addScaledVector(Vh,a);const g=u*m-f*h;if(g<=0&&h-u>=0&&f-m>=0)return q2.subVectors(r,n),a=(h-u)/(h-u+(f-m)),t.copy(n).addScaledVector(q2,a);const _=1/(g+v+d);return o=v*_,a=d*_,t.copy(i).addScaledVector(zh,o).addScaledVector(Vh,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Z2={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},fl={h:0,s:0,l:0},Rv={h:0,s:0,l:0};function Xb(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class rt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ni){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mn.toWorkingColorSpace(this,t),this}setRGB(e,t,i,n=mn.workingColorSpace){return this.r=e,this.g=t,this.b=i,mn.toWorkingColorSpace(this,n),this}setHSL(e,t,i,n=mn.workingColorSpace){if(e=Cb(e,1),t=en(t,0,1),i=en(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=Xb(o,r,e+1/3),this.g=Xb(o,r,e),this.b=Xb(o,r,e-1/3)}return mn.toWorkingColorSpace(this,n),this}setStyle(e,t=Ni){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ni){const i=Z2[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ma(e.r),this.g=ma(e.g),this.b=ma(e.b),this}copyLinearToSRGB(e){return this.r=Ih(e.r),this.g=Ih(e.g),this.b=Ih(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ni){return mn.fromWorkingColorSpace(Ur.copy(this),e),Math.round(en(Ur.r*255,0,255))*65536+Math.round(en(Ur.g*255,0,255))*256+Math.round(en(Ur.b*255,0,255))}getHexString(e=Ni){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mn.workingColorSpace){mn.fromWorkingColorSpace(Ur.copy(this),t);const i=Ur.r,n=Ur.g,r=Ur.b,o=Math.max(i,n,r),a=Math.min(i,n,r);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case i:l=(n-r)/h+(n0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Mc&&(i.blending=this.blending),this.side!==ks&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Ag&&(i.blendSrc=this.blendSrc),this.blendDst!==Cg&&(i.blendDst=this.blendDst),this.blendEquation!==rl&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Ec&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yv&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kc&&(i.stencilFail=this.stencilFail),this.stencilZFail!==kc&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==kc&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(t){const r=n(e.textures),o=n(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const n=t.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Jn extends Ki{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new rt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Rf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ba=cB();function cB(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),i=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,n[l]=24,n[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,n[l]=-c-1,n[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,n[l]=13,n[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,n[l]=24,n[l|256]=24):(i[l]=31744,i[l|256]=64512,n[l]=13,n[l|256]=13)}const r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;!(c&8388608);)c<<=1,u-=8388608;c&=-8388609,u+=947912704,r[l]=c|u}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:r,exponentTable:o,offsetTable:a}}function fs(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=en(s,-65504,65504),ba.floatView[0]=s;const e=ba.uint32View[0],t=e>>23&511;return ba.baseTable[t]+((e&8388607)>>ba.shiftTable[t])}function qf(s){const e=s>>10;return ba.uint32View[0]=ba.mantissaTable[ba.offsetTable[e]+(s&1023)]+ba.exponentTable[e],ba.floatView[0]}class zc{static toHalfFloat(e){return fs(e)}static fromHalfFloat(e){return qf(e)}}const Bi=new X,Dv=new Ne;let uB=0;class Bt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:uB++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=zf,this.updateRanges=[],this.gpuType=Un,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;nt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new yn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new X(-1/0,-1/0,-1/0),new X(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h0&&(n[l]=u,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const n=e.attributes;for(const c in n){const u=n[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r(e.far-e.near)**2))&&(K2.copy(r).invert(),Vc.copy(e.ray).applyMatrix4(K2),!(i.boundingBox!==null&&Vc.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Vc)))}_computeIntersections(e,t,i){let n;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=d.length;mt.far?null:{distance:c,point:Fv.clone(),object:s}}function Nv(s,e,t,i,n,r,o,a,l,c){s.getVertexPosition(a,Lv),s.getVertexPosition(l,Uv),s.getVertexPosition(c,kv);const u=_B(s,e,t,i,Lv,Uv,kv,J2);if(u){const h=new X;Zi.getBarycoord(J2,Lv,Uv,kv,h),n&&(u.uv=Zi.getInterpolatedAttribute(n,a,l,c,h,new Ne)),r&&(u.uv1=Zi.getInterpolatedAttribute(r,a,l,c,h,new Ne)),o&&(u.normal=Zi.getInterpolatedAttribute(o,a,l,c,h,new X),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new X,materialIndex:0};Zi.getNormal(Lv,Uv,kv,d.normal),u.face=d,u.barycoord=h}return u}class yi extends Gt{constructor(e=1,t=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const a=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],u=[],h=[];let d=0,f=0;m("z","y","x",-1,-1,i,t,e,o,r,0),m("z","y","x",1,-1,i,t,-e,o,r,1),m("x","z","y",1,1,e,i,t,n,o,2),m("x","z","y",1,-1,e,i,-t,n,o,3),m("x","y","z",1,-1,e,t,i,n,r,4),m("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(l),this.setAttribute("position",new It(c,3)),this.setAttribute("normal",new It(u,3)),this.setAttribute("uv",new It(h,2));function m(v,g,_,y,w,x,M,C,T,A,P){const E=x/T,I=M/A,R=x/2,U=M/2,L=C/2,k=T+1,z=A+1;let G=0,W=0;const q=new X;for(let O=0;O0?1:-1,u.push(q.x,q.y,q.z),h.push(J/T),h.push(1-O/A),G+=1}}for(let O=0;O0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Bv extends tn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new _t,this.projectionMatrix=new _t,this.projectionMatrixInverse=new _t,this.coordinateSystem=yo}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ml=new X,eC=new Ne,tC=new Ne;class zi extends Bv{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Rh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Oc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Rh*2*Math.atan(Math.tan(Oc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ml.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ml.x,ml.y).multiplyScalar(-e/ml.z),ml.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ml.x,ml.y).multiplyScalar(-e/ml.z)}getViewSize(e,t){return this.getViewBounds(e,eC,tC),t.subVectors(tC,eC)}setViewOffset(e,t,i,n,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Oc*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*n/l,t-=o.offsetY*i/c,n*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Wh=-90,Xh=1;let zv=class extends tn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new zi(Wh,Xh,e,t);n.layers=this.layers,this.add(n);const r=new zi(Wh,Xh,e,t);r.layers=this.layers,this.add(r);const o=new zi(Wh,Xh,e,t);o.layers=this.layers,this.add(o);const a=new zi(Wh,Xh,e,t);a.layers=this.layers,this.add(a);const l=new zi(Wh,Xh,e,t);l.layers=this.layers,this.add(l);const c=new zi(Wh,Xh,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,o,a,l]=t;for(const c of t)this.remove(c);if(e===yo)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Vf)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,n),e.render(t,r),e.setRenderTarget(i,1,n),e.render(t,o),e.setRenderTarget(i,2,n),e.render(t,a),e.setRenderTarget(i,3,n),e.render(t,l),e.setRenderTarget(i,4,n),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,n),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}};class Yh extends ni{constructor(e,t,i,n,r,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:pa,super(e,t,i,n,r,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Vv extends Bs{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];this.texture=new Yh(n,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:bn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},n=new yi(5,5,5),r=new Ti({name:"CubemapFromEquirect",uniforms:Hh(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:ji,blending:fa});r.uniforms.tEquirect.value=t;const o=new it(n,r),a=t.minFilter;return t.minFilter===Fs&&(t.minFilter=bn),new zv(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,n){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,n);e.setRenderTarget(r)}}class Qn extends tn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const wB={type:"move"};class Gv{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new X,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new X),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new X,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new X),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const v of e.hand.values()){const g=t.getJointPose(v,i),_=this._getHandJoint(c,v);g!==null&&(_.matrix.fromArray(g.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=g.radius),_.visible=g!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(wB)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Qn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class Hv{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new rt(e),this.density=t}clone(){return new Hv(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Wv{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new rt(e),this.near=t,this.far=i}clone(){return new Wv(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Kf extends tn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ds,this.environmentIntensity=1,this.environmentRotation=new ds,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class $f{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=zf,this.updateRanges=[],this.version=0,this.uuid=Ns()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;ne.far||t.push({distance:l,point:Jf.clone(),uv:Zi.getInterpolation(Jf,Xv,ep,Yv,iC,Kb,rC,new Ne),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function jv(s,e,t,i,n,r){Kh.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(Qf.x=r*Kh.x-n*Kh.y,Qf.y=n*Kh.x+r*Kh.y):Qf.copy(Kh),s.copy(e),s.x+=Qf.x,s.y+=Qf.y,s.applyMatrix4(nC)}const qv=new X,sC=new X;class $b extends tn{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,n=t.length;i0){let i,n;for(i=1,n=t.length;i0){qv.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(qv);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){qv.setFromMatrixPosition(e.matrixWorld),sC.setFromMatrixPosition(this.matrixWorld);const i=qv.distanceTo(sC)/e.zoom;t[0].object.visible=!0;let n,r;for(n=1,r=t.length;n=o)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||AB.getNormalMatrix(e),n=this.coplanarPoint(e1).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Hc=new fi,Qv=new X;class sp{constructor(e=new to,t=new to,i=new to,n=new to,r=new to,o=new to){this.planes=[e,t,i,n,r,o]}set(e,t,i,n,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=yo){const i=this.planes,n=e.elements,r=n[0],o=n[1],a=n[2],l=n[3],c=n[4],u=n[5],h=n[6],d=n[7],f=n[8],m=n[9],v=n[10],g=n[11],_=n[12],y=n[13],w=n[14],x=n[15];if(i[0].setComponents(l-r,d-c,g-f,x-_).normalize(),i[1].setComponents(l+r,d+c,g+f,x+_).normalize(),i[2].setComponents(l+o,d+u,g+m,x+y).normalize(),i[3].setComponents(l-o,d-u,g-m,x-y).normalize(),i[4].setComponents(l-a,d-h,g-v,x-w).normalize(),t===yo)i[5].setComponents(l+a,d+h,g+v,x+w).normalize();else if(t===Vf)i[5].setComponents(a,h,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hc)}intersectsSprite(e){return Hc.center.set(0,0,0),Hc.radius=.7071067811865476,Hc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hc)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,Qv.y=n.normal.y>0?e.max.y:e.min.y,Qv.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Qv)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function t1(s,e){return s-e}function CB(s,e){return s.z-e.z}function PB(s,e){return e.z-s.z}class RB{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,n){const r=this.pool,o=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];o.push(a),this.index++,a.start=e,a.count=t,a.z=i,a.index=n}reset(){this.list.length=0,this.index=0}}const ms=new _t,DB=new rt(1,1,1),n1=new sp,e0=new yn,Wc=new fi,op=new X,pC=new X,IB=new X,i1=new RB,kr=new it,t0=[];function LB(s,e,t=0){const i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const n=s.count;for(let r=0;r65535?new Uint32Array(n):new Uint16Array(n);t.setIndex(new Bt(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=e.getAttribute(i),r=t.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new yn);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,n=t.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(t1),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=i):(n=this._instanceInfo.length,this._instanceInfo.push(i));const r=this._matricesTexture;ms.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;const o=this._colorsTexture;return o&&(DB.toArray(o.image.data,n*4),o.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const n={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;n.vertexStart=this._nextVertexStart,n.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const o=e.getIndex();if(o!==null&&(n.indexStart=this._nextIndexStart,n.reservedIndexCount=i===-1?o.count:i),n.indexStart!==-1&&n.indexStart+n.reservedIndexCount>this._maxIndexCount||n.vertexStart+n.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(t1),l=this._availableGeometryIds.shift(),r[l]=n):(l=this._geometryCount,this._geometryCount++,r.push(n)),this.setGeometryAt(l,e),this._nextIndexStart=n.indexStart+n.reservedIndexCount,this._nextVertexStart=n.vertexStart+n.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,n=i.getIndex()!==null,r=i.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(n&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const u in i.attributes){const h=t.getAttribute(u),d=i.getAttribute(u);LB(h,d,l);const f=h.itemSize;for(let m=h.count,v=c;m=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let n=0,r=i.length;na).sort((o,a)=>i[o].vertexStart-i[a].vertexStart),r=this.geometry;for(let o=0,a=i.length;o=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[e];if(n.boundingBox===null){const r=new yn,o=i.index,a=i.attributes.position;for(let l=n.start,c=n.start+n.count;l=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[e];if(n.boundingSphere===null){const r=new fi;this.getBoundingBoxAt(e,e0),e0.getCenter(r.center);const o=i.index,a=i.attributes.position;let l=0;for(let c=n.start,u=n.start+n.count;ca.active);if(Math.max(...i.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Gt,this._initializeGeometry(r));const o=this.geometry;r.index&&Xc(r.index.array,o.index.array);for(const a in r.attributes)Xc(r.attributes[a].array,o.attributes[a].array)}raycast(e,t){const i=this._instanceInfo,n=this._geometryInfo,r=this.matrixWorld,o=this.geometry;kr.material=this.material,kr.geometry.index=o.index,kr.geometry.attributes=o.attributes,kr.geometry.boundingBox===null&&(kr.geometry.boundingBox=new yn),kr.geometry.boundingSphere===null&&(kr.geometry.boundingSphere=new fi);for(let a=0,l=i.length;a({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,n,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=n.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,m=f.image.data;d&&(ms.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),n1.setFromProjectionMatrix(ms,e.coordinateSystem));let v=0;if(this.sortObjects){ms.copy(this.matrixWorld).invert(),op.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ms),pC.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(ms);for(let y=0,w=l.length;y0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;ri)return;r1.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(r1);if(!(ce.far))return{distance:c,point:vC.clone().applyMatrix4(s.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:s}}const _C=new X,yC=new X;class no extends Gi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,r=t.count;n0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;rn.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class wC extends ni{constructor(e,t,i,n,r,o,a,l,c){super(e,t,i,n,r,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:bn,this.magFilter=r!==void 0?r:bn,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class UB extends wC{constructor(e,t,i,n,r,o,a,l){super({},e,t,i,n,r,o,a,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class kB extends ni{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=En,this.minFilter=En,this.generateMipmaps=!1,this.needsUpdate=!0}}class u0 extends ni{constructor(e,t,i,n,r,o,a,l,c,u,h,d){super(null,o,a,l,c,u,n,r,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class OB extends u0{constructor(e,t,i,n,r,o){super(e,t,i,r,o),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=pr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class FB extends u0{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,pa),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class h0 extends ni{constructor(e,t,i,n,r,o,a,l,c){super(e,t,i,n,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class a1 extends ni{constructor(e,t,i,n,r,o,a,l,c,u=Rc){if(u!==Rc&&u!==Dc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Rc&&(i=hs),i===void 0&&u===Dc&&(i=Pc),super(null,n,r,o,a,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:En,this.minFilter=l!==void 0?l:En,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new al(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class So{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let n=0;const r=i.length;let o;t?o=t:o=e*i[r-1];let a=0,l=r-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=i[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,i[n]===o)return n/(r-1);const u=i[n],d=i[n+1]-u,f=(o-u)/d;return(n+f)/(r-1)}getTangent(e,t){let n=e-1e-4,r=e+1e-4;n<0&&(n=0),r>1&&(r=1);const o=this.getPoint(n),a=this.getPoint(r),l=t||(o.isVector2?new Ne:new X);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new X,n=[],r=[],o=[],a=new X,l=new _t;for(let f=0;f<=e;f++){const m=f/e;n[f]=this.getTangentAt(m,new X)}r[0]=new X,o[0]=new X;let c=Number.MAX_VALUE;const u=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),o[0].crossVectors(n[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(en(n[f-1].dot(n[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(n[f],r[f])}if(t===!0){let f=Math.acos(en(r[0].dot(r[e]),-1,1));f/=e,n[0].dot(a.crossVectors(r[0],r[e]))>0&&(f=-f);for(let m=1;m<=e;m++)r[m].applyMatrix4(l.makeRotationAxis(n[m],f*m)),o[m].crossVectors(n[m],r[m])}return{tangents:n,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class d0 extends So{constructor(e=0,t=0,i=1,n=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Ne){const i=t,n=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)n;)r-=n;r0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%r]:(f0.subVectors(n[0],n[1]).add(n[0]),c=f0);const h=n[a%r],d=n[(a+1)%r];if(this.closed||a+2n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return i.set(EC(a,l.x,c.x,u.x,h.x),EC(a,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const o=n[r]-i,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class hp extends Gt{constructor(e=[new Ne(0,-.5),new Ne(.5,0),new Ne(0,.5)],t=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=en(n,0,Math.PI*2);const r=[],o=[],a=[],l=[],c=[],u=1/t,h=new X,d=new Ne,f=new X,m=new X,v=new X;let g=0,_=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,_=e[y+1].y-e[y].y,f.x=_*1,f.y=-g,f.z=_*0,v.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:g=e[y+1].x-e[y].x,_=e[y+1].y-e[y].y,f.x=_*1,f.y=-g,f.z=_*0,m.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),l.push(f.x,f.y,f.z),v.copy(m)}for(let y=0;y<=t;y++){const w=i+y*u*n,x=Math.sin(w),M=Math.cos(w);for(let C=0;C<=e.length-1;C++){h.x=e[C].x*x,h.y=e[C].y,h.z=e[C].x*M,o.push(h.x,h.y,h.z),d.x=y/t,d.y=C/(e.length-1),a.push(d.x,d.y);const T=l[3*C+0]*x,A=l[3*C+1],P=l[3*C+0]*M;c.push(T,A,P)}}for(let y=0;y0&&w(!0),t>0&&w(!1)),this.setIndex(u),this.setAttribute("position",new It(h,3)),this.setAttribute("normal",new It(d,3)),this.setAttribute("uv",new It(f,2));function y(){const x=new X,M=new X;let C=0;const T=(t-e)/i;for(let A=0;A<=r;A++){const P=[],E=A/r,I=E*(t-e)+e;for(let R=0;R<=n;R++){const U=R/n,L=U*l+a,k=Math.sin(L),z=Math.cos(L);M.x=I*k,M.y=-E*i+g,M.z=I*z,h.push(M.x,M.y,M.z),x.set(k,T,z).normalize(),d.push(x.x,x.y,x.z),f.push(U,1-E),P.push(m++)}v.push(P)}for(let A=0;A0||P!==0)&&(u.push(E,I,U),C+=3),(t>0||P!==r-1)&&(u.push(I,R,U),C+=3)}c.addGroup(_,C,0),_+=C}function w(x){const M=m,C=new Ne,T=new X;let A=0;const P=x===!0?e:t,E=x===!0?1:-1;for(let R=1;R<=n;R++)h.push(0,g*E,0),d.push(0,E,0),f.push(.5,.5),m++;const I=m;for(let R=0;R<=n;R++){const L=R/n*l+a,k=Math.cos(L),z=Math.sin(L);T.x=P*z,T.y=g*E,T.z=P*k,h.push(T.x,T.y,T.z),d.push(0,E,0),C.x=k*.5+.5,C.y=z*.5*E+.5,f.push(C.x,C.y),m++}for(let R=0;R.9&&T<.1&&(w<.2&&(o[y+0]+=1),x<.2&&(o[y+2]+=1),M<.2&&(o[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function f(y,w){const x=y*3;w.x=e[x+0],w.y=e[x+1],w.z=e[x+2]}function m(){const y=new X,w=new X,x=new X,M=new X,C=new Ne,T=new Ne,A=new Ne;for(let P=0,E=0;P80*i){l=u=e[0],c=h=e[1];for(let v=i;vu&&(u=d),f>h&&(h=f);m=Math.max(u-l,h-c),m=m!==0?32767/m:0}return dp(o,a,i,l,c,m,0),a}}function RC(s,e,t,i,n){let r,o;if(n===az(s,e,t,i)>0)for(r=e;r=e;r-=i)o=LC(r,s[r],s[r+1],o);return o&&w0(o,o.next)&&(pp(o),o=o.next),o}function Yc(s,e){if(!s)return s;e||(e=s);let t=s,i;do if(i=!1,!t.steiner&&(w0(t,t.next)||xi(t.prev,t,t.next)===0)){if(pp(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function dp(s,e,t,i,n,r,o){if(!s)return;!o&&r&&tz(s,i,n,r);let a=s,l,c;for(;s.prev!==s.next;){if(l=s.prev,c=s.next,r?jB(s,i,n,r):YB(s)){e.push(l.i/t|0),e.push(s.i/t|0),e.push(c.i/t|0),pp(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=qB(Yc(s),e,t),dp(s,e,t,i,n,r,2)):o===2&&ZB(s,e,t,i,n,r):dp(Yc(s),e,t,i,n,r,1);break}}}function YB(s){const e=s.prev,t=s,i=s.next;if(xi(e,t,i)>=0)return!1;const n=e.x,r=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=nr?n>o?n:o:r>o?r:o,f=a>l?a>c?a:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=f&&Qh(n,a,r,l,o,c,m.x,m.y)&&xi(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function jB(s,e,t,i){const n=s.prev,r=s,o=s.next;if(xi(n,r,o)>=0)return!1;const a=n.x,l=r.x,c=o.x,u=n.y,h=r.y,d=o.y,f=al?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,_=_1(f,m,e,t,i),y=_1(v,g,e,t,i);let w=s.prevZ,x=s.nextZ;for(;w&&w.z>=_&&x&&x.z<=y;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==n&&w!==o&&Qh(a,u,l,h,c,d,w.x,w.y)&&xi(w.prev,w,w.next)>=0||(w=w.prevZ,x.x>=f&&x.x<=v&&x.y>=m&&x.y<=g&&x!==n&&x!==o&&Qh(a,u,l,h,c,d,x.x,x.y)&&xi(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;w&&w.z>=_;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==n&&w!==o&&Qh(a,u,l,h,c,d,w.x,w.y)&&xi(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=v&&x.y>=m&&x.y<=g&&x!==n&&x!==o&&Qh(a,u,l,h,c,d,x.x,x.y)&&xi(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function qB(s,e,t){let i=s;do{const n=i.prev,r=i.next.next;!w0(n,r)&&DC(n,i,i.next,r)&&fp(n,r)&&fp(r,n)&&(e.push(n.i/t|0),e.push(i.i/t|0),e.push(r.i/t|0),pp(i),pp(i.next),i=s=r),i=i.next}while(i!==s);return Yc(i)}function ZB(s,e,t,i,n,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&rz(o,a)){let l=IC(o,a);o=Yc(o,o.next),l=Yc(l,l.next),dp(o,e,t,i,n,r,0),dp(l,e,t,i,n,r,0);return}a=a.next}o=o.next}while(o!==s)}function KB(s,e,t,i){const n=[];let r,o,a,l,c;for(r=0,o=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=r&&d>i&&(i=d,n=t.x=t.x&&t.x>=l&&r!==t.x&&Qh(on.x||t.x===n.x&&ez(n,t)))&&(n=t,u=h)),t=t.next;while(t!==a);return n}function ez(s,e){return xi(s.prev,s,e.prev)<0&&xi(e.next,s,s.next)<0}function tz(s,e,t,i){let n=s;do n.z===0&&(n.z=_1(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,nz(n)}function nz(s){let e,t,i,n,r,o,a,l,c=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;t=i}r.nextZ=null,c*=2}while(o>1);return s}function _1(s,e,t,i,n){return s=(s-t)*n|0,e=(e-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function iz(s){let e=s,t=s;do(e.x=(s-o)*(r-a)&&(s-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(n-o)*(i-a)}function rz(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!sz(s,e)&&(fp(s,e)&&fp(e,s)&&oz(s,e)&&(xi(s.prev,s,e.prev)||xi(s,e.prev,e))||w0(s,e)&&xi(s.prev,s,s.next)>0&&xi(e.prev,e,e.next)>0)}function xi(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function w0(s,e){return s.x===e.x&&s.y===e.y}function DC(s,e,t,i){const n=M0(xi(s,e,t)),r=M0(xi(s,e,i)),o=M0(xi(t,i,s)),a=M0(xi(t,i,e));return!!(n!==r&&o!==a||n===0&&S0(s,t,e)||r===0&&S0(s,i,e)||o===0&&S0(t,s,i)||a===0&&S0(t,e,i))}function S0(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function M0(s){return s>0?1:s<0?-1:0}function sz(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&DC(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function fp(s,e){return xi(s.prev,s,s.next)<0?xi(s,e,s.next)>=0&&xi(s,s.prev,e)>=0:xi(s,e,s.prev)<0||xi(s,s.next,e)<0}function oz(s,e){let t=s,i=!1;const n=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&n<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function IC(s,e){const t=new y1(s.i,s.x,s.y),i=new y1(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function LC(s,e,t,i){const n=new y1(s,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function pp(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function y1(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function az(s,e,t,i){let n=0;for(let r=e,o=t-i;r2&&s[e-1].equals(s[0])&&s.pop()}function kC(s,e){for(let t=0;tNumber.EPSILON){const he=Math.sqrt(Z),te=Math.sqrt(Oe*Oe+j*j),Se=xe.x-Ye/he,ye=xe.y+Te/he,Ae=$.x-j/te,Ce=$.y+Oe/te,Ge=((Ae-Se)*j-(Ce-ye)*Oe)/(Te*j-Ye*Oe);Ue=Se+Te*Ge-me.x,Me=ye+Ye*Ge-me.y;const De=Ue*Ue+Me*Me;if(De<=2)return new Ne(Ue,Me);oe=Math.sqrt(De/2)}else{let he=!1;Te>Number.EPSILON?Oe>Number.EPSILON&&(he=!0):Te<-Number.EPSILON?Oe<-Number.EPSILON&&(he=!0):Math.sign(Ye)===Math.sign(j)&&(he=!0),he?(Ue=-Ye,Me=Te,oe=Math.sqrt(Z)):(Ue=Te,Me=Ye,oe=Math.sqrt(Z/2))}return new Ne(Ue/oe,Me/oe)}const q=[];for(let me=0,xe=L.length,$=xe-1,Ue=me+1;me=0;me--){const xe=me/g,$=f*Math.cos(xe*Math.PI/2),Ue=m*Math.sin(xe*Math.PI/2)+v;for(let Me=0,oe=L.length;Me=0;){const Ue=$;let Me=$-1;Me<0&&(Me=me.length-1);for(let oe=0,Te=u+g*2;oe0)&&f.push(w,x,C),(_!==i-1||l0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class zC extends Ki{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new rt(16777215),this.specular=new rt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new rt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Rf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class VC extends Ki{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new rt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new rt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class GC extends Ki{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class HC extends Ki{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new rt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new rt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Rf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jc extends Ki{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=M2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class td extends Ki{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class WC extends Ki{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new rt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class XC extends Vi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function qc(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function YC(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function jC(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function b1(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,o=0;o!==i;++r){const a=t[r]*e;for(let l=0;l!==e;++l)n[o++]=s[a+l]}return n}function w1(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let o=r[i];if(o!==void 0)if(Array.isArray(o))do o=r[i],o!==void 0&&(e.push(r.time),t.push(...o)),r=s[n++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[i],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do o=r[i],o!==void 0&&(e.push(r.time),t.push(o)),r=s[n++];while(r!==void 0)}function hz(s,e,t,i,n=30){const r=s.clone();r.name=e;const o=[];for(let l=0;l=i)){h.push(c.times[f]);for(let v=0;vr.tracks[l].times[0]&&(a=r.tracks[l].times[0]);for(let l=0;l=a.times[m]){const _=m*h+u,y=_+h-u;v=a.values.slice(_,y)}else{const _=a.createInterpolant(),y=u,w=h-u;_.evaluate(r),v=_.resultBuffer.slice(y,w)}l==="quaternion"&&new Tn().fromArray(v).normalize().conjugate().toArray(v);const g=c.times.length;for(let _=0;_=r)){const a=t[1];e=r)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,r!==0||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=i.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(n!==void 0&&YC(n))for(let a=0,l=n.length;a!==l;++a){const c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===mv,r=e.length-1;let o=1;for(let a=1;a0){e[o]=e[r];for(let a=r*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Mo.prototype.TimeBufferType=Float32Array,Mo.prototype.ValueBufferType=Float32Array,Mo.prototype.DefaultInterpolation=Ah;class Zc extends Mo{constructor(e,t,i){super(e,t,i)}}Zc.prototype.ValueTypeName="bool",Zc.prototype.ValueBufferType=Array,Zc.prototype.DefaultInterpolation=Th,Zc.prototype.InterpolantFactoryMethodLinear=void 0,Zc.prototype.InterpolantFactoryMethodSmooth=void 0;class M1 extends Mo{}M1.prototype.ValueTypeName="color";class Kc extends Mo{}Kc.prototype.ValueTypeName="number";class KC extends nd{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(n-t);let c=e*a;for(let u=c+a;c!==u;c+=4)Tn.slerpFlat(r,0,o,c-a,o,c,l);return r}}class $c extends Mo{InterpolantFactoryMethodLinear(e){return new KC(this.times,this.values,this.getValueSize(),e)}}$c.prototype.ValueTypeName="quaternion",$c.prototype.InterpolantFactoryMethodSmooth=void 0;class Jc extends Mo{constructor(e,t,i){super(e,t,i)}}Jc.prototype.ValueTypeName="string",Jc.prototype.ValueBufferType=Array,Jc.prototype.DefaultInterpolation=Th,Jc.prototype.InterpolantFactoryMethodLinear=void 0,Jc.prototype.InterpolantFactoryMethodSmooth=void 0;class Qc extends Mo{}Qc.prototype.ValueTypeName="vector";class id{constructor(e="",t=-1,i=[],n=gv){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Ns(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(mz(i[o]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=i.length;r!==o;++r)t.push(Mo.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,o=[];for(let a=0;a1){const h=u[1];let d=n[h];d||(n[h]=d=[]),d.push(c)}}const o=[];for(const a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(h,d,f,m,v){if(f.length!==0){const g=[],_=[];w1(f,g,_,m),g.length!==0&&v.push(new h(d,g,_))}},n=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h{t&&t(r),this.manager.itemEnd(e)},0),r;if(Ea[e]!==void 0){Ea[e].push({onLoad:t,onProgress:i,onError:n});return}Ea[e]=[],Ea[e].push({onLoad:t,onProgress:i,onError:n});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Ea[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0;let v=0;const g=new ReadableStream({start(_){y();function y(){h.read().then(({done:w,value:x})=>{if(w)_.close();else{v+=x.byteLength;const M=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:f});for(let C=0,T=u.length;C{_.error(w)})}}});return new Response(g)}else throw new gz(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{Ma.add(e,c);const u=Ea[e];delete Ea[e];for(let h=0,d=u.length;h{const u=Ea[e];if(u===void 0)throw this.manager.itemError(e),c;delete Ea[e];for(let h=0,d=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class vz extends vr{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new gs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t=[];for(let i=0;i0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(n.uniforms[r]={},o.type){case"t":n.uniforms[r].value=i(o.value);break;case"c":n.uniforms[r].value=new rt().setHex(o.value);break;case"v2":n.uniforms[r].value=new Ne().fromArray(o.value);break;case"v3":n.uniforms[r].value=new X().fromArray(o.value);break;case"v4":n.uniforms[r].value=new Zt().fromArray(o.value);break;case"m3":n.uniforms[r].value=new Jt().fromArray(o.value);break;case"m4":n.uniforms[r].value=new _t().fromArray(o.value);break;default:n.uniforms[r].value=o.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(n.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)n.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(n.lights=e.lights),e.clipping!==void 0&&(n.clipping=e.clipping),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new Ne().fromArray(r)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(n.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(n.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapRotation!==void 0&&n.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(n.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(n.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(n.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(n.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return L0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:NC,SpriteMaterial:Gc,RawShaderMaterial:BC,ShaderMaterial:Ti,PointsMaterial:o0,MeshPhysicalMaterial:io,MeshStandardMaterial:mp,MeshPhongMaterial:zC,MeshToonMaterial:VC,MeshNormalMaterial:GC,MeshLambertMaterial:HC,MeshDepthMaterial:jc,MeshDistanceMaterial:td,MeshBasicMaterial:Jn,MeshMatcapMaterial:WC,LineDashedMaterial:XC,LineBasicMaterial:Vi,Material:Ki};return new t[e]}}class xl{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i0){const l=new E1(t);r=new gp(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c0){n=new gp(this.manager),n.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o{const g=new yn;g.min.fromArray(v.boxMin),g.max.fromArray(v.boxMax);const _=new fi;return _.radius=v.sphereRadius,_.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:g,sphereInitialized:v.sphereInitialized,sphere:_}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":o=new $b;break;case"Line":o=new Gi(a(e.geometry),l(e.material));break;case"LineLoop":o=new s1(a(e.geometry),l(e.material));break;case"LineSegments":o=new no(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new c0(a(e.geometry),l(e.material));break;case"Sprite":o=new tp(l(e.material));break;case"Group":o=new Qn;break;case"Bone":o=new $v;break;default:o=new tn}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let f=0;f"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Ma.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{n&&n(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Ma.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){n&&n(c),Ma.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Ma.add(e,l),r.manager.itemStart(e)}}let U0;class I1{static getContext(){return U0===void 0&&(U0=new(window.AudioContext||window.webkitAudioContext)),U0}static setContext(e){U0=e}}class uP extends vr{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new gs(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);I1.getContext().decodeAudioData(c,function(h){t(h)}).catch(a)}catch(c){a(c)}},i,n);function a(l){n?n(l):console.error(l),r.manager.itemError(e)}}}const hP=new _t,dP=new _t,tu=new _t;class Mz{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,tu.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,o=t.near*Math.tan(Oc*t.fov*.5)/t.zoom;let a,l;dP.elements[12]=-n,hP.elements[12]=n,a=-o*t.aspect+r,l=o*t.aspect+r,tu.elements[0]=2*t.near/(l-a),tu.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(tu),a=-o*t.aspect-r,l=o*t.aspect-r,tu.elements[0]=2*t.near/(l-a),tu.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(tu)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(dP),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(hP)}}class fP extends zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e,this.index=0}}class L1{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=pP(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=pP();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function pP(){return performance.now()}const nu=new X,mP=new Tn,Ez=new X,iu=new X;let gP=class extends tn{constructor(){super(),this.type="AudioListener",this.context=I1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new L1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(nu,mP,Ez),iu.set(0,0,-1).applyQuaternion(mP),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(nu.x,n),t.positionY.linearRampToValueAtTime(nu.y,n),t.positionZ.linearRampToValueAtTime(nu.z,n),t.forwardX.linearRampToValueAtTime(iu.x,n),t.forwardY.linearRampToValueAtTime(iu.y,n),t.forwardZ.linearRampToValueAtTime(iu.z,n),t.upX.linearRampToValueAtTime(i.x,n),t.upY.linearRampToValueAtTime(i.y,n),t.upZ.linearRampToValueAtTime(i.z,n)}else t.setPosition(nu.x,nu.y,nu.z),t.setOrientation(iu.x,iu.y,iu.z,i.x,i.y,i.z)}},U1=class extends tn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,o=n;r!==o;++r)t[r]=t[n+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let o=0;o!==r;++o)e[t+o]=e[i+o]}_slerp(e,t,i,n){Tn.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const o=this._workIndex*r;Tn.multiplyQuaternionsFlat(e,o,e,t,e,i),Tn.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,r){const o=1-n;for(let a=0;a!==r;++a){const l=t+a;e[l]=e[l]*o+e[i+a]*n}}_lerpAdditive(e,t,i,n,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[i+o]*n}}}const k1="\\[\\]\\.:\\/",Cz=new RegExp("["+k1+"]","g"),O1="[^"+k1+"]",Pz="[^"+k1.replace("\\.","")+"]",Rz=/((?:WC+[\/:])*)/.source.replace("WC",O1),Dz=/(WCOD+)?/.source.replace("WCOD",Pz),Iz=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",O1),Lz=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",O1),Uz=new RegExp("^"+Rz+Dz+Iz+Lz+"$"),kz=["material","materials","bones","map"];class Oz{constructor(e,t,i){const n=i||An.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class An{constructor(e,t,i){this.path=t,this.parsedPath=i||An.parseTrackName(t),this.node=An.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new An.Composite(e,t,i):new An(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Cz,"")}static parseTrackName(e){const t=Uz.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=i.nodeName.substring(n+1);kz.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let o=0;o=r){const h=r++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let f=0,m=n;f!==m;++f){const v=i[f],g=v[h],_=v[u];v[u]=g,v[h]=_}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[f.uuid]=h),e[h]=f,e.pop();for(let m=0,v=n;m!==v;++m){const g=i[m];g[h]=g[d],g.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(n!==void 0)return r[n];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);n=r.length,i[e]=n,o.push(e),a.push(t),r.push(h);for(let d=u,f=l.length;d!==f;++d){const m=l[d];h[d]=new An(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}}class xP{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,o=r.length,a=new Array(o),l={endingStart:Lc,endingEnd:Lc};for(let c=0;c!==o;++c){const u=r[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=b2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const n=this._clip.duration,r=e._clip.duration,o=r/n,a=n/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=r,l[1]=r+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const l=(e-r)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Mb:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case gv:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const o=i===w2;if(e===0)return r===-1?n:o&&(r&1)===1?t-n:n;if(i===x2){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<0){const a=Math.floor(n/t);n-=t*a,r+=Math.abs(a);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(r&1)===1)return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=Uc,n.endingEnd=Uc):(e?n.endingStart=this.zeroSlopeAtStart?Uc:Lc:n.endingStart=Nf,t?n.endingEnd=this.zeroSlopeAtEnd?Uc:Lc:n.endingEnd=Nf)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,l[0]=t,a[1]=r+e,l[1]=i,this}}const Nz=new Float32Array(1);class Bz extends qo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==r;++h){const d=n[h],f=d.name;let m=u[f];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new yP(An.create(i,f,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,r,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,SP).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const MP=new X,F0=new X;class Eo{constructor(e=new X,t=new X){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){MP.subVectors(e,this.start),F0.subVectors(this.end,this.start);const i=F0.dot(F0);let r=F0.dot(MP)/i;return t&&(r=en(r,0,1)),r}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const EP=new X;class jz extends tn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Gt,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{DP.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(DP,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class o4 extends no{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new Gt;n.setAttribute("position",new It(t,3)),n.setAttribute("color",new It(i,3));const r=new Vi({vertexColors:!0,toneMapped:!1});super(n,r),this.type="AxesHelper"}setColors(e,t,i){const n=new rt,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class IP{constructor(){this.type="ShapePath",this.color=new rt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new up,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,o){return this.currentPath.bezierCurveTo(e,t,i,n,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(_){const y=[];for(let w=0,x=_.length;wNumber.EPSILON){if(E<0&&(T=y[C],P=-P,A=y[M],E=-E),_.yA.y)continue;if(_.y===T.y){if(_.x===T.x)return!0}else{const I=E*(_.x-T.x)-P*(_.y-T.y);if(I===0)return!0;if(I<0)continue;x=!x}}else{if(_.y!==T.y)continue;if(A.x<=_.x&&_.x<=T.x||T.x<=_.x&&_.x<=A.x)return!0}}return x}const n=Ko.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,l;const c=[];if(r.length===1)return a=r[0],l=new vl,l.curves=a.curves,c.push(l),c;let u=!n(r[0].getPoints());u=e?!u:u;const h=[],d=[];let f=[],m=0,v;d[m]=void 0,f[m]=[];for(let _=0,y=r.length;_1){let _=!1,y=0;for(let w=0,x=d.length;w0&&_===!1&&(f=h)}let g;for(let _=0,y=d.length;_e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function l4(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function c4(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function G1(s,e,t,i){const n=u4(i);switch(t){case yb:return s*e;case bb:return s*e;case wb:return s*e*2;case Sh:return s*e/n.components*n.byteLength;case Mh:return s*e/n.components*n.byteLength;case Gg:return s*e*2/n.components*n.byteLength;case Eh:return s*e*2/n.components*n.byteLength;case xb:return s*e*3/n.components*n.byteLength;case di:return s*e*4/n.components*n.byteLength;case Ic:return s*e*4/n.components*n.byteLength;case Lf:case Uf:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case kf:case Of:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Wg:case Yg:return Math.max(s,16)*Math.max(e,8)/4;case Hg:case Xg:return Math.max(s,8)*Math.max(e,8)/2;case jg:case qg:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Zg:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Kg:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case $g:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Jg:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Qg:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case ev:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case tv:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case nv:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case iv:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case rv:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case sv:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case ov:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case av:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case lv:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case cv:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Ff:case uv:case hv:return Math.ceil(s/4)*Math.ceil(e/4)*16;case Sb:case dv:return Math.ceil(s/4)*Math.ceil(e/4)*8;case fv:case pv:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function u4(s){switch(s){case Qs:case If:return{byteLength:1,components:1};case Ac:case Bg:case mr:return{byteLength:2,components:1};case zg:case Vg:return{byteLength:2,components:4};case hs:case Cc:case Un:return{byteLength:4,components:1};case _b:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}class h4{static contain(e,t){return a4(e,t)}static cover(e,t){return l4(e,t)}static fill(e){return c4(e)}static getByteLength(e,t,i,n){return G1(e,t,i,n)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_h}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_h);/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */function LP(){let s=null,e=!1,t=null,i=null;function n(r,o){t(r,o),i=s.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=s.requestAnimationFrame(n),e=!0)},stop:function(){s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function d4(s){const e=new WeakMap;function t(a,l){const c=a.array,u=a.usage,h=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),a.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,l,c){const u=l.array,h=l.updateRanges;if(s.bindBuffer(c,a),h.length===0)s.bufferSubData(c,0,u);else{h.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`,P4=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,R4=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,D4=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,I4=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,L4=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,U4=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,k4=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,O4=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,F4=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 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; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 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 ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,N4=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,B4=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,z4=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,V4=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,G4=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,H4="gl_FragColor = linearToOutputTexel( gl_FragColor );",W4=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( 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.a ); } vec4 sRGBTransferOETF( 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.a ); }`,X4=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,Y4=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,j4=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,q4=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,Z4=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,K4=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,$4=`#ifdef USE_FOG varying float vFogDepth; #endif`,J4=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,Q4=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,e5=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,t5=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,n5=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,i5=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,r5=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,s5=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,o5=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,a5=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,l5=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,c5=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,u5=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,h5=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,d5=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #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 ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #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 ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #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 ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,f5=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,p5=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,m5=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,g5=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,v5=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,_5=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,y5=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,x5=`#ifdef USE_MAP uniform sampler2D map; #endif`,b5=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,w5=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,S5=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,M5=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,E5=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,T5=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,A5=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,C5=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`,P5=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,R5=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,D5=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,I5=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,L5=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,U5=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,k5=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,O5=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,F5=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,N5=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,B5=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,z5=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,V5=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,G5=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,H5=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,W5=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,X5=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,Y5=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,j5=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,q5=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,Z5=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,K5=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,$5=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,J5=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,Q5=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,eV=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,tV=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,nV=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,iV=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,rV=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,sV=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,oV=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,aV=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; 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 ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } 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 ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,lV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,cV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,uV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,hV=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const Ft={alphahash_fragment:f4,alphahash_pars_fragment:p4,alphamap_fragment:m4,alphamap_pars_fragment:g4,alphatest_fragment:v4,alphatest_pars_fragment:_4,aomap_fragment:y4,aomap_pars_fragment:x4,batching_pars_vertex:b4,batching_vertex:w4,begin_vertex:S4,beginnormal_vertex:M4,bsdfs:E4,iridescence_fragment:T4,bumpmap_pars_fragment:A4,clipping_planes_fragment:C4,clipping_planes_pars_fragment:P4,clipping_planes_pars_vertex:R4,clipping_planes_vertex:D4,color_fragment:I4,color_pars_fragment:L4,color_pars_vertex:U4,color_vertex:k4,common:O4,cube_uv_reflection_fragment:F4,defaultnormal_vertex:N4,displacementmap_pars_vertex:B4,displacementmap_vertex:z4,emissivemap_fragment:V4,emissivemap_pars_fragment:G4,colorspace_fragment:H4,colorspace_pars_fragment:W4,envmap_fragment:X4,envmap_common_pars_fragment:Y4,envmap_pars_fragment:j4,envmap_pars_vertex:q4,envmap_physical_pars_fragment:s5,envmap_vertex:Z4,fog_vertex:K4,fog_pars_vertex:$4,fog_fragment:J4,fog_pars_fragment:Q4,gradientmap_pars_fragment:e5,lightmap_pars_fragment:t5,lights_lambert_fragment:n5,lights_lambert_pars_fragment:i5,lights_pars_begin:r5,lights_toon_fragment:o5,lights_toon_pars_fragment:a5,lights_phong_fragment:l5,lights_phong_pars_fragment:c5,lights_physical_fragment:u5,lights_physical_pars_fragment:h5,lights_fragment_begin:d5,lights_fragment_maps:f5,lights_fragment_end:p5,logdepthbuf_fragment:m5,logdepthbuf_pars_fragment:g5,logdepthbuf_pars_vertex:v5,logdepthbuf_vertex:_5,map_fragment:y5,map_pars_fragment:x5,map_particle_fragment:b5,map_particle_pars_fragment:w5,metalnessmap_fragment:S5,metalnessmap_pars_fragment:M5,morphinstance_vertex:E5,morphcolor_vertex:T5,morphnormal_vertex:A5,morphtarget_pars_vertex:C5,morphtarget_vertex:P5,normal_fragment_begin:R5,normal_fragment_maps:D5,normal_pars_fragment:I5,normal_pars_vertex:L5,normal_vertex:U5,normalmap_pars_fragment:k5,clearcoat_normal_fragment_begin:O5,clearcoat_normal_fragment_maps:F5,clearcoat_pars_fragment:N5,iridescence_pars_fragment:B5,opaque_fragment:z5,packing:V5,premultiplied_alpha_fragment:G5,project_vertex:H5,dithering_fragment:W5,dithering_pars_fragment:X5,roughnessmap_fragment:Y5,roughnessmap_pars_fragment:j5,shadowmap_pars_fragment:q5,shadowmap_pars_vertex:Z5,shadowmap_vertex:K5,shadowmask_pars_fragment:$5,skinbase_vertex:J5,skinning_pars_vertex:Q5,skinning_vertex:eV,skinnormal_vertex:tV,specularmap_fragment:nV,specularmap_pars_fragment:iV,tonemapping_fragment:rV,tonemapping_pars_fragment:sV,transmission_fragment:oV,transmission_pars_fragment:aV,uv_pars_fragment:lV,uv_pars_vertex:cV,uv_vertex:uV,worldpos_vertex:hV,background_vert:`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,background_frag:`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,backgroundCube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,cube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,cube_frag:`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,depth_vert:`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,depth_frag:`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,distanceRGBA_vert:`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,distanceRGBA_frag:`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,equirect_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,equirect_frag:`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,linedashed_vert:`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,linedashed_frag:`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,meshbasic_vert:`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,meshbasic_frag:`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,meshlambert_vert:`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,meshlambert_frag:`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,meshmatcap_vert:`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,meshmatcap_frag:`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include 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 ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,meshnormal_vert:`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,meshnormal_frag:`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,meshphong_vert:`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,meshphong_frag:`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,meshphysical_vert:`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,meshphysical_frag:`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,meshtoon_vert:`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,meshtoon_frag:`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,points_vert:`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,points_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,shadow_vert:`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,shadow_frag:`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,sprite_vert:`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,sprite_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`},vt={common:{diffuse:{value:new rt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jt}},envmap:{envMap:{value:null},envMapRotation:{value:new Jt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jt},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new rt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new rt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0},uvTransform:{value:new Jt}},sprite:{diffuse:{value:new rt(16777215)},opacity:{value:1},center:{value:new Ne(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}}},Or={basic:{uniforms:Jr([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.fog]),vertexShader:Ft.meshbasic_vert,fragmentShader:Ft.meshbasic_frag},lambert:{uniforms:Jr([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new rt(0)}}]),vertexShader:Ft.meshlambert_vert,fragmentShader:Ft.meshlambert_frag},phong:{uniforms:Jr([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new rt(0)},specular:{value:new rt(1118481)},shininess:{value:30}}]),vertexShader:Ft.meshphong_vert,fragmentShader:Ft.meshphong_frag},standard:{uniforms:Jr([vt.common,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.roughnessmap,vt.metalnessmap,vt.fog,vt.lights,{emissive:{value:new rt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag},toon:{uniforms:Jr([vt.common,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.gradientmap,vt.fog,vt.lights,{emissive:{value:new rt(0)}}]),vertexShader:Ft.meshtoon_vert,fragmentShader:Ft.meshtoon_frag},matcap:{uniforms:Jr([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,{matcap:{value:null}}]),vertexShader:Ft.meshmatcap_vert,fragmentShader:Ft.meshmatcap_frag},points:{uniforms:Jr([vt.points,vt.fog]),vertexShader:Ft.points_vert,fragmentShader:Ft.points_frag},dashed:{uniforms:Jr([vt.common,vt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ft.linedashed_vert,fragmentShader:Ft.linedashed_frag},depth:{uniforms:Jr([vt.common,vt.displacementmap]),vertexShader:Ft.depth_vert,fragmentShader:Ft.depth_frag},normal:{uniforms:Jr([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,{opacity:{value:1}}]),vertexShader:Ft.meshnormal_vert,fragmentShader:Ft.meshnormal_frag},sprite:{uniforms:Jr([vt.sprite,vt.fog]),vertexShader:Ft.sprite_vert,fragmentShader:Ft.sprite_frag},background:{uniforms:{uvTransform:{value:new Jt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ft.background_vert,fragmentShader:Ft.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jt}},vertexShader:Ft.backgroundCube_vert,fragmentShader:Ft.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ft.cube_vert,fragmentShader:Ft.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ft.equirect_vert,fragmentShader:Ft.equirect_frag},distanceRGBA:{uniforms:Jr([vt.common,vt.displacementmap,{referencePosition:{value:new X},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ft.distanceRGBA_vert,fragmentShader:Ft.distanceRGBA_frag},shadow:{uniforms:Jr([vt.lights,vt.fog,{color:{value:new rt(0)},opacity:{value:1}}]),vertexShader:Ft.shadow_vert,fragmentShader:Ft.shadow_frag}};Or.physical={uniforms:Jr([Or.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jt},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jt},sheen:{value:0},sheenColor:{value:new rt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jt},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jt},attenuationDistance:{value:0},attenuationColor:{value:new rt(0)},specularColor:{value:new rt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jt},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jt}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag};const W0={r:0,b:0,g:0},ou=new ds,dV=new _t;function fV(s,e,t,i,n,r,o){const a=new rt(0);let l=r===!0?0:1,c,u,h=null,d=0,f=null;function m(w){let x=w.isScene===!0?w.background:null;return x&&x.isTexture&&(x=(w.backgroundBlurriness>0?t:e).get(x)),x}function v(w){let x=!1;const M=m(w);M===null?_(a,l):M&&M.isColor&&(_(M,1),x=!0);const C=s.xr.getEnvironmentBlendMode();C==="additive"?i.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(s.autoClear||x)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function g(w,x){const M=m(x);M&&(M.isCubeTexture||M.mapping===xh)?(u===void 0&&(u=new it(new yi(1,1,1),new Ti({name:"BackgroundCubeMaterial",uniforms:Hh(Or.backgroundCube.uniforms),vertexShader:Or.backgroundCube.vertexShader,fragmentShader:Or.backgroundCube.fragmentShader,side:ji,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(C,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),ou.copy(x.backgroundRotation),ou.x*=-1,ou.y*=-1,ou.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(ou.y*=-1,ou.z*=-1),u.material.uniforms.envMap.value=M,u.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(dV.makeRotationFromEuler(ou)),u.material.toneMapped=mn.getTransfer(M.colorSpace)!==Wn,(h!==M||d!==M.version||f!==s.toneMapping)&&(u.material.needsUpdate=!0,h=M,d=M.version,f=s.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new it(new es(2,2),new Ti({name:"BackgroundMaterial",uniforms:Hh(Or.background.uniforms),vertexShader:Or.background.vertexShader,fragmentShader:Or.background.fragmentShader,side:ks,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=mn.getTransfer(M.colorSpace)!==Wn,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||f!==s.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,f=s.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function _(w,x){w.getRGB(W0,Q2(s)),i.buffers.color.setClear(W0.r,W0.g,W0.b,x,o)}function y(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(w,x=1){a.set(w),l=x,_(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,_(a,l)},render:v,addToRenderList:g,dispose:y}}function pV(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},n=d(null);let r=n,o=!1;function a(E,I,R,U,L){let k=!1;const z=h(U,R,I);r!==z&&(r=z,c(r.object)),k=f(E,U,R,L),k&&m(E,U,R,L),L!==null&&e.update(L,s.ELEMENT_ARRAY_BUFFER),(k||o)&&(o=!1,x(E,I,R,U),L!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(L).buffer))}function l(){return s.createVertexArray()}function c(E){return s.bindVertexArray(E)}function u(E){return s.deleteVertexArray(E)}function h(E,I,R){const U=R.wireframe===!0;let L=i[E.id];L===void 0&&(L={},i[E.id]=L);let k=L[I.id];k===void 0&&(k={},L[I.id]=k);let z=k[U];return z===void 0&&(z=d(l()),k[U]=z),z}function d(E){const I=[],R=[],U=[];for(let L=0;L=0){const O=L[W];let B=k[W];if(B===void 0&&(W==="instanceMatrix"&&E.instanceMatrix&&(B=E.instanceMatrix),W==="instanceColor"&&E.instanceColor&&(B=E.instanceColor)),O===void 0||O.attribute!==B||B&&O.data!==B.data)return!0;z++}return r.attributesNum!==z||r.index!==U}function m(E,I,R,U){const L={},k=I.attributes;let z=0;const G=R.getAttributes();for(const W in G)if(G[W].location>=0){let O=k[W];O===void 0&&(W==="instanceMatrix"&&E.instanceMatrix&&(O=E.instanceMatrix),W==="instanceColor"&&E.instanceColor&&(O=E.instanceColor));const B={};B.attribute=O,O&&O.data&&(B.data=O.data),L[W]=B,z++}r.attributes=L,r.attributesNum=z,r.index=U}function v(){const E=r.newAttributes;for(let I=0,R=E.length;I=0){let q=L[G];if(q===void 0&&(G==="instanceMatrix"&&E.instanceMatrix&&(q=E.instanceMatrix),G==="instanceColor"&&E.instanceColor&&(q=E.instanceColor)),q!==void 0){const O=q.normalized,B=q.itemSize,J=e.get(q);if(J===void 0)continue;const re=J.buffer,K=J.type,Q=J.bytesPerElement,ue=K===s.INT||K===s.UNSIGNED_INT||q.gpuType===Cc;if(q.isInterleavedBufferAttribute){const le=q.data,_e=le.stride,Fe=q.offset;if(le.isInstancedInterleavedBuffer){for(let Ie=0;Ie0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),_=s.getParameter(s.MAX_VERTEX_ATTRIBS),y=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),w=s.getParameter(s.MAX_VARYING_VECTORS),x=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,C=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:y,maxVaryings:w,maxFragmentUniforms:x,vertexTextures:M,maxSamples:C}}function vV(s){const e=this;let t=null,i=0,n=!1,r=!1;const o=new to,a=new Jt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||i!==0||n;return n=d,i=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const m=h.clippingPlanes,v=h.clipIntersection,g=h.clipShadows,_=s.get(h);if(!n||m===null||m.length===0||r&&!g)r?u(null):c();else{const y=r?0:i,w=y*4;let x=_.clippingState||null;l.value=x,x=u(m,d,w,f);for(let M=0;M!==w;++M)x[M]=t[M];_.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,f,m){const v=h!==null?h.length:0;let g=null;if(v!==0){if(g=l.value,m!==!0||g===null){const _=f+v*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length<_)&&(g=new Float32Array(_));for(let w=0,x=f;w!==v;++w,x+=4)o.copy(h[w]).applyMatrix4(y,a),o.normal.toArray(g,x),g[x+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function _V(s){let e=new WeakMap;function t(o,a){return a===yh?o.mapping=pa:a===Df&&(o.mapping=sl),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===yh||a===Df)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new Vv(l.height);return c.fromEquirectangularTexture(s,o),e.set(o,c),o.addEventListener("dispose",n),t(c.texture,o.mapping)}else return null}}return o}function n(o){const a=o.target;a.removeEventListener("dispose",n);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}const sd=4,UP=[.125,.215,.35,.446,.526,.582],au=20,H1=new Ta,kP=new rt;let W1=null,X1=0,Y1=0,j1=!1;const lu=(1+Math.sqrt(5))/2,od=1/lu,OP=[new X(-lu,od,0),new X(lu,od,0),new X(-od,0,lu),new X(od,0,lu),new X(0,lu,-od),new X(0,lu,od),new X(-1,1,-1),new X(1,1,-1),new X(-1,1,1),new X(1,1,1)],yV=new X;class q1{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100,r={}){const{size:o=256,position:a=yV}=r;W1=this._renderer.getRenderTarget(),X1=this._renderer.getActiveCubeFace(),Y1=this._renderer.getActiveMipmapLevel(),j1=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,n,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=BP(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=NP(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?x:0,x,x),h.setRenderTarget(n),g&&h.render(v,l),h.render(e,l)}v.geometry.dispose(),v.material.dispose(),h.toneMapping=f,h.autoClear=d,e.background=_}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===pa||e.mapping===sl;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=BP()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=NP());const r=n?this._cubemapMaterial:this._equirectMaterial,o=new it(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;X0(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,H1)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodPlanes.length;for(let r=1;rau&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${au}`);const _=[];let y=0;for(let T=0;Tw-sd?n-w+sd:0),C=4*(this._cubeSize-x);X0(t,M,C,3*x,2*x),l.setRenderTarget(t),l.render(h,H1)}}function xV(s){const e=[],t=[],i=[];let n=s;const r=s-sd+1+UP.length;for(let o=0;os-sd?l=UP[o-s+sd-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,m=6,v=3,g=2,_=1,y=new Float32Array(v*m*f),w=new Float32Array(g*m*f),x=new Float32Array(_*m*f);for(let C=0;C2?0:-1,P=[T,A,0,T+2/3,A,0,T+2/3,A+1,0,T,A,0,T+2/3,A+1,0,T,A+1,0];y.set(P,v*m*C),w.set(d,g*m*C);const E=[C,C,C,C,C,C];x.set(E,_*m*C)}const M=new Gt;M.setAttribute("position",new Bt(y,v)),M.setAttribute("uv",new Bt(w,g)),M.setAttribute("faceIndex",new Bt(x,_)),e.push(M),n>sd&&n--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function FP(s,e,t){const i=new Bs(s,e,t);return i.texture.mapping=xh,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function X0(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function bV(s,e,t){const i=new Float32Array(au),n=new X(0,1,0);return new Ti({name:"SphericalGaussianBlur",defines:{n:au,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:Z1(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:fa,depthTest:!1,depthWrite:!1})}function NP(){return new Ti({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Z1(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:fa,depthTest:!1,depthWrite:!1})}function BP(){return new Ti({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Z1(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:fa,depthTest:!1,depthWrite:!1})}function Z1(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function wV(s){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===yh||l===Df,u=l===pa||l===sl;if(c||u){let h=e.get(a);const d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new q1(s)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const f=a.image;return c&&f&&f.height>0||u&&f&&n(f)?(t===null&&(t=new q1(s)),h=c?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",r),h.texture):null}}}return a}function n(a){let l=0;const c=6;for(let u=0;ue.maxTextureSize&&(M=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const C=new Float32Array(x*M*4*h),T=new Wf(C,x,M,h);T.type=Un,T.needsUpdate=!0;const A=w*4;for(let E=0;E0)return s;const n=e*t;let r=XP[n];if(r===void 0&&(r=new Float32Array(n),XP[n]=r),e!==0){i.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function $i(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t":" "} ${a}: ${t[o]}`)}return i.join(` `)}const JP=new Jt;function wG(s){mn._getMatrix(JP,mn.workingColorSpace,s);const e=`mat3( ${JP.elements.map(t=>t.toFixed(4))} )`;switch(mn.getTransfer(s)){case Bf:return[e,"LinearTransferOETF"];case Wn:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function QP(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),n=s.getShaderInfoLog(e).trim();if(i&&n==="")return"";const r=/ERROR: 0:(\d+)/.exec(n);if(r){const o=parseInt(r[1]);return t.toUpperCase()+` `+n+` `+bG(s.getShaderSource(e),o)}else return n}function SG(s,e){const t=wG(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}function MG(s,e){let t;switch(e){case f2:t="Linear";break;case p2:t="Reinhard";break;case m2:t="Cineon";break;case g2:t="ACESFilmic";break;case Og:t="AgX";break;case _2:t="Neutral";break;case v2:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const q0=new X;function EG(){mn.getLuminanceCoefficients(q0);const s=q0.x.toFixed(4),e=q0.y.toFixed(4),t=q0.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function TG(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(yp).join(` `)}function AG(s){const e=[];for(const t in s){const i=s[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function CG(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let n=0;n/gm;function $1(s){return s.replace(PG,DG)}const RG=new Map;function DG(s,e){let t=Ft[e];if(t===void 0){const i=RG.get(e);if(i!==void 0)t=Ft[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return $1(t)}const IG=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function nR(s){return s.replace(IG,LG)}function LG(s,e,t,i){let n="";for(let r=parseInt(e);r0&&(g+=` `),_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(yp).join(` `),_.length>0&&(_+=` `)):(g=[iR(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(yp).join(` `),_=[iR(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Yo?"#define TONE_MAPPING":"",t.toneMapping!==Yo?Ft.tonemapping_pars_fragment:"",t.toneMapping!==Yo?MG("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ft.colorspace_pars_fragment,SG("linearToOutputTexel",t.outputColorSpace),EG(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(yp).join(` `)),o=$1(o),o=eR(o,t),o=tR(o,t),a=$1(a),a=eR(a,t),a=tR(a,t),o=nR(o),a=nR(a),t.isRawShaderMaterial!==!0&&(y=`#version 300 es `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+g,_=["#define varying in",t.glslVersion===Ab?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ab?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+_);const w=y+g+o,x=y+_+a,M=$P(n,n.VERTEX_SHADER,w),C=$P(n,n.FRAGMENT_SHADER,x);n.attachShader(v,M),n.attachShader(v,C),t.index0AttributeName!==void 0?n.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(v,0,"position"),n.linkProgram(v);function T(I){if(s.debug.checkShaderErrors){const R=n.getProgramInfoLog(v).trim(),U=n.getShaderInfoLog(M).trim(),L=n.getShaderInfoLog(C).trim();let k=!0,z=!0;if(n.getProgramParameter(v,n.LINK_STATUS)===!1)if(k=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(n,v,M,C);else{const G=QP(n,M,"vertex"),W=QP(n,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(v,n.VALIDATE_STATUS)+` Material Name: `+I.name+` Material Type: `+I.type+` Program Info Log: `+R+` `+G+` `+W)}else R!==""?console.warn("THREE.WebGLProgram: Program Info Log:",R):(U===""||L==="")&&(z=!1);z&&(I.diagnostics={runnable:k,programLog:R,vertexShader:{log:U,prefix:g},fragmentShader:{log:L,prefix:_}})}n.deleteShader(M),n.deleteShader(C),A=new j0(n,v),P=CG(n,v)}let A;this.getUniforms=function(){return A===void 0&&T(this),A};let P;this.getAttributes=function(){return P===void 0&&T(this),P};let E=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=n.getProgramParameter(v,yG)),E},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=xG++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=C,this}let zG=0;class VG{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),r=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(n)===!1&&(o.add(n),n.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new GG(e),t.set(e,i)),i}}class GG{constructor(e){this.id=zG++,this.code=e,this.usedTimes=0}}function HG(s,e,t,i,n,r,o){const a=new Cv,l=new VG,c=new Set,u=[],h=n.logarithmicDepthBuffer,d=n.vertexTextures;let f=n.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(P){return c.add(P),P===0?"uv":`uv${P}`}function g(P,E,I,R,U){const L=R.fog,k=U.geometry,z=P.isMeshStandardMaterial?R.environment:null,G=(P.isMeshStandardMaterial?t:e).get(P.envMap||z),W=G&&G.mapping===xh?G.image.height:null,q=m[P.type];P.precision!==null&&(f=n.getMaxPrecision(P.precision),f!==P.precision&&console.warn("THREE.WebGLProgram.getParameters:",P.precision,"not supported, using",f,"instead."));const O=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,B=O!==void 0?O.length:0;let J=0;k.morphAttributes.position!==void 0&&(J=1),k.morphAttributes.normal!==void 0&&(J=2),k.morphAttributes.color!==void 0&&(J=3);let re,K,Q,ue;if(q){const je=Or[q];re=je.vertexShader,K=je.fragmentShader}else re=P.vertexShader,K=P.fragmentShader,l.update(P),Q=l.getVertexShaderID(P),ue=l.getFragmentShaderID(P);const le=s.getRenderTarget(),_e=s.state.buffers.depth.getReversed(),Fe=U.isInstancedMesh===!0,Ie=U.isBatchedMesh===!0,Ee=!!P.map,me=!!P.matcap,xe=!!G,$=!!P.aoMap,Ue=!!P.lightMap,Me=!!P.bumpMap,oe=!!P.normalMap,Te=!!P.displacementMap,Ye=!!P.emissiveMap,Oe=!!P.metalnessMap,j=!!P.roughnessMap,Z=P.anisotropy>0,pe=P.clearcoat>0,he=P.dispersion>0,te=P.iridescence>0,Se=P.sheen>0,ye=P.transmission>0,Ae=Z&&!!P.anisotropyMap,Ce=pe&&!!P.clearcoatMap,Ge=pe&&!!P.clearcoatNormalMap,De=pe&&!!P.clearcoatRoughnessMap,Ve=te&&!!P.iridescenceMap,ze=te&&!!P.iridescenceThicknessMap,Ze=Se&&!!P.sheenColorMap,Le=Se&&!!P.sheenRoughnessMap,ot=!!P.specularMap,tt=!!P.specularColorMap,mt=!!P.specularIntensityMap,ce=ye&&!!P.transmissionMap,ve=ye&&!!P.thicknessMap,be=!!P.gradientMap,Xe=!!P.alphaMap,We=P.alphaTest>0,Be=!!P.alphaHash,ut=!!P.extensions;let gt=Yo;P.toneMapped&&(le===null||le.isXRRenderTarget===!0)&&(gt=s.toneMapping);const nt={shaderID:q,shaderType:P.type,shaderName:P.name,vertexShader:re,fragmentShader:K,defines:P.defines,customVertexShaderID:Q,customFragmentShaderID:ue,isRawShaderMaterial:P.isRawShaderMaterial===!0,glslVersion:P.glslVersion,precision:f,batching:Ie,batchingColor:Ie&&U._colorsTexture!==null,instancing:Fe,instancingColor:Fe&&U.instanceColor!==null,instancingMorph:Fe&&U.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:le===null?s.outputColorSpace:le.isXRRenderTarget===!0?le.texture.colorSpace:Ii,alphaToCoverage:!!P.alphaToCoverage,map:Ee,matcap:me,envMap:xe,envMapMode:xe&&G.mapping,envMapCubeUVHeight:W,aoMap:$,lightMap:Ue,bumpMap:Me,normalMap:oe,displacementMap:d&&Te,emissiveMap:Ye,normalMapObjectSpace:oe&&P.normalMapType===E2,normalMapTangentSpace:oe&&P.normalMapType===ol,metalnessMap:Oe,roughnessMap:j,anisotropy:Z,anisotropyMap:Ae,clearcoat:pe,clearcoatMap:Ce,clearcoatNormalMap:Ge,clearcoatRoughnessMap:De,dispersion:he,iridescence:te,iridescenceMap:Ve,iridescenceThicknessMap:ze,sheen:Se,sheenColorMap:Ze,sheenRoughnessMap:Le,specularMap:ot,specularColorMap:tt,specularIntensityMap:mt,transmission:ye,transmissionMap:ce,thicknessMap:ve,gradientMap:be,opaque:P.transparent===!1&&P.blending===Mc&&P.alphaToCoverage===!1,alphaMap:Xe,alphaTest:We,alphaHash:Be,combine:P.combine,mapUv:Ee&&v(P.map.channel),aoMapUv:$&&v(P.aoMap.channel),lightMapUv:Ue&&v(P.lightMap.channel),bumpMapUv:Me&&v(P.bumpMap.channel),normalMapUv:oe&&v(P.normalMap.channel),displacementMapUv:Te&&v(P.displacementMap.channel),emissiveMapUv:Ye&&v(P.emissiveMap.channel),metalnessMapUv:Oe&&v(P.metalnessMap.channel),roughnessMapUv:j&&v(P.roughnessMap.channel),anisotropyMapUv:Ae&&v(P.anisotropyMap.channel),clearcoatMapUv:Ce&&v(P.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&v(P.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:De&&v(P.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&v(P.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&v(P.iridescenceThicknessMap.channel),sheenColorMapUv:Ze&&v(P.sheenColorMap.channel),sheenRoughnessMapUv:Le&&v(P.sheenRoughnessMap.channel),specularMapUv:ot&&v(P.specularMap.channel),specularColorMapUv:tt&&v(P.specularColorMap.channel),specularIntensityMapUv:mt&&v(P.specularIntensityMap.channel),transmissionMapUv:ce&&v(P.transmissionMap.channel),thicknessMapUv:ve&&v(P.thicknessMap.channel),alphaMapUv:Xe&&v(P.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(oe||Z),vertexColors:P.vertexColors,vertexAlphas:P.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!k.attributes.uv&&(Ee||Xe),fog:!!L,useFog:P.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:P.flatShading===!0,sizeAttenuation:P.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:_e,skinning:U.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:J,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:P.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:gt,decodeVideoTexture:Ee&&P.map.isVideoTexture===!0&&mn.getTransfer(P.map.colorSpace)===Wn,decodeVideoTextureEmissive:Ye&&P.emissiveMap.isVideoTexture===!0&&mn.getTransfer(P.emissiveMap.colorSpace)===Wn,premultipliedAlpha:P.premultipliedAlpha,doubleSided:P.side===Ei,flipSided:P.side===ji,useDepthPacking:P.depthPacking>=0,depthPacking:P.depthPacking||0,index0AttributeName:P.index0AttributeName,extensionClipCullDistance:ut&&P.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ut&&P.extensions.multiDraw===!0||Ie)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:P.customProgramCacheKey()};return nt.vertexUv1s=c.has(1),nt.vertexUv2s=c.has(2),nt.vertexUv3s=c.has(3),c.clear(),nt}function _(P){const E=[];if(P.shaderID?E.push(P.shaderID):(E.push(P.customVertexShaderID),E.push(P.customFragmentShaderID)),P.defines!==void 0)for(const I in P.defines)E.push(I),E.push(P.defines[I]);return P.isRawShaderMaterial===!1&&(y(E,P),w(E,P),E.push(s.outputColorSpace)),E.push(P.customProgramCacheKey),E.join()}function y(P,E){P.push(E.precision),P.push(E.outputColorSpace),P.push(E.envMapMode),P.push(E.envMapCubeUVHeight),P.push(E.mapUv),P.push(E.alphaMapUv),P.push(E.lightMapUv),P.push(E.aoMapUv),P.push(E.bumpMapUv),P.push(E.normalMapUv),P.push(E.displacementMapUv),P.push(E.emissiveMapUv),P.push(E.metalnessMapUv),P.push(E.roughnessMapUv),P.push(E.anisotropyMapUv),P.push(E.clearcoatMapUv),P.push(E.clearcoatNormalMapUv),P.push(E.clearcoatRoughnessMapUv),P.push(E.iridescenceMapUv),P.push(E.iridescenceThicknessMapUv),P.push(E.sheenColorMapUv),P.push(E.sheenRoughnessMapUv),P.push(E.specularMapUv),P.push(E.specularColorMapUv),P.push(E.specularIntensityMapUv),P.push(E.transmissionMapUv),P.push(E.thicknessMapUv),P.push(E.combine),P.push(E.fogExp2),P.push(E.sizeAttenuation),P.push(E.morphTargetsCount),P.push(E.morphAttributeCount),P.push(E.numDirLights),P.push(E.numPointLights),P.push(E.numSpotLights),P.push(E.numSpotLightMaps),P.push(E.numHemiLights),P.push(E.numRectAreaLights),P.push(E.numDirLightShadows),P.push(E.numPointLightShadows),P.push(E.numSpotLightShadows),P.push(E.numSpotLightShadowsWithMaps),P.push(E.numLightProbes),P.push(E.shadowMapType),P.push(E.toneMapping),P.push(E.numClippingPlanes),P.push(E.numClipIntersection),P.push(E.depthPacking)}function w(P,E){a.disableAll(),E.supportsVertexTextures&&a.enable(0),E.instancing&&a.enable(1),E.instancingColor&&a.enable(2),E.instancingMorph&&a.enable(3),E.matcap&&a.enable(4),E.envMap&&a.enable(5),E.normalMapObjectSpace&&a.enable(6),E.normalMapTangentSpace&&a.enable(7),E.clearcoat&&a.enable(8),E.iridescence&&a.enable(9),E.alphaTest&&a.enable(10),E.vertexColors&&a.enable(11),E.vertexAlphas&&a.enable(12),E.vertexUv1s&&a.enable(13),E.vertexUv2s&&a.enable(14),E.vertexUv3s&&a.enable(15),E.vertexTangents&&a.enable(16),E.anisotropy&&a.enable(17),E.alphaHash&&a.enable(18),E.batching&&a.enable(19),E.dispersion&&a.enable(20),E.batchingColor&&a.enable(21),P.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reverseDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),P.push(a.mask)}function x(P){const E=m[P.type];let I;if(E){const R=Or[E];I=pl.clone(R.uniforms)}else I=P.uniforms;return I}function M(P,E){let I;for(let R=0,U=u.length;R0?i.push(_):f.transparent===!0?n.push(_):t.push(_)}function l(h,d,f,m,v,g){const _=o(h,d,f,m,v,g);f.transmission>0?i.unshift(_):f.transparent===!0?n.unshift(_):t.unshift(_)}function c(h,d){t.length>1&&t.sort(h||XG),i.length>1&&i.sort(d||rR),n.length>1&&n.sort(d||rR)}function u(){for(let h=e,d=s.length;h=r.length?(o=new sR,r.push(o)):o=r[n],o}function t(){s=new WeakMap}return{get:e,dispose:t}}function jG(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new X,color:new rt};break;case"SpotLight":t={position:new X,direction:new X,color:new rt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new X,color:new rt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new X,skyColor:new rt,groundColor:new rt};break;case"RectAreaLight":t={color:new rt,position:new X,halfWidth:new X,halfHeight:new X};break}return s[e.id]=t,t}}}function qG(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let ZG=0;function KG(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function $G(s){const e=new jG,t=qG(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new X);const n=new X,r=new _t,o=new _t;function a(c){let u=0,h=0,d=0;for(let P=0;P<9;P++)i.probe[P].set(0,0,0);let f=0,m=0,v=0,g=0,_=0,y=0,w=0,x=0,M=0,C=0,T=0;c.sort(KG);for(let P=0,E=c.length;P0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_FLOAT_1,i.rectAreaLTC2=vt.LTC_FLOAT_2):(i.rectAreaLTC1=vt.LTC_HALF_1,i.rectAreaLTC2=vt.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const A=i.hash;(A.directionalLength!==f||A.pointLength!==m||A.spotLength!==v||A.rectAreaLength!==g||A.hemiLength!==_||A.numDirectionalShadows!==y||A.numPointShadows!==w||A.numSpotShadows!==x||A.numSpotMaps!==M||A.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=g,i.point.length=m,i.hemi.length=_,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=x,i.spotShadowMap.length=x,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=x+M-C,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=C,i.numLightProbes=T,A.directionalLength=f,A.pointLength=m,A.spotLength=v,A.rectAreaLength=g,A.hemiLength=_,A.numDirectionalShadows=y,A.numPointShadows=w,A.numSpotShadows=x,A.numSpotMaps=M,A.numLightProbes=T,i.version=ZG++)}function l(c,u){let h=0,d=0,f=0,m=0,v=0;const g=u.matrixWorldInverse;for(let _=0,y=c.length;_=o.length?(a=new oR(s),o.push(a)):a=o[r],a}function i(){e=new WeakMap}return{get:t,dispose:i}}const QG=`void main() { gl_Position = vec4( position, 1.0 ); }`,eH=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function tH(s,e,t){let i=new sp;const n=new Ne,r=new Ne,o=new Zt,a=new jc({depthPacking:Ch}),l=new td,c={},u=t.maxTextureSize,h={[ks]:ji,[ji]:ks,[Ei]:Ei},d=new Ti({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:QG,fragmentShader:eH}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new Gt;m.setAttribute("position",new Bt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new it(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=pb;let _=this.type;this.render=function(C,T,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||C.length===0)return;const P=s.getRenderTarget(),E=s.getActiveCubeFace(),I=s.getActiveMipmapLevel(),R=s.state;R.setBlending(fa),R.buffers.color.setClear(1,1,1,1),R.buffers.depth.setTest(!0),R.setScissorTest(!1);const U=_!==Xo&&this.type===Xo,L=_===Xo&&this.type!==Xo;for(let k=0,z=C.length;ku||n.y>u)&&(n.x>u&&(r.x=Math.floor(u/q.x),n.x=r.x*q.x,W.mapSize.x=r.x),n.y>u&&(r.y=Math.floor(u/q.y),n.y=r.y*q.y,W.mapSize.y=r.y)),W.map===null||U===!0||L===!0){const B=this.type!==Xo?{minFilter:En,magFilter:En}:{};W.map!==null&&W.map.dispose(),W.map=new Bs(n.x,n.y,B),W.map.texture.name=G.name+".shadowMap",W.camera.updateProjectionMatrix()}s.setRenderTarget(W.map),s.clear();const O=W.getViewportCount();for(let B=0;B0||T.map&&T.alphaTest>0){const R=E.uuid,U=T.uuid;let L=c[R];L===void 0&&(L={},c[R]=L);let k=L[U];k===void 0&&(k=E.clone(),L[U]=k,T.addEventListener("dispose",M)),E=k}if(E.visible=T.visible,E.wireframe=T.wireframe,P===Xo?E.side=T.shadowSide!==null?T.shadowSide:T.side:E.side=T.shadowSide!==null?T.shadowSide:h[T.side],E.alphaMap=T.alphaMap,E.alphaTest=T.alphaTest,E.map=T.map,E.clipShadows=T.clipShadows,E.clippingPlanes=T.clippingPlanes,E.clipIntersection=T.clipIntersection,E.displacementMap=T.displacementMap,E.displacementScale=T.displacementScale,E.displacementBias=T.displacementBias,E.wireframeLinewidth=T.wireframeLinewidth,E.linewidth=T.linewidth,A.isPointLight===!0&&E.isMeshDistanceMaterial===!0){const R=s.properties.get(E);R.light=A}return E}function x(C,T,A,P,E){if(C.visible===!1)return;if(C.layers.test(T.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&E===Xo)&&(!C.frustumCulled||i.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,C.matrixWorld);const U=e.update(C),L=C.material;if(Array.isArray(L)){const k=U.groups;for(let z=0,G=k.length;z=1):W.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),z=G>=2);let q=null,O={};const B=s.getParameter(s.SCISSOR_BOX),J=s.getParameter(s.VIEWPORT),re=new Zt().fromArray(B),K=new Zt().fromArray(J);function Q(ce,ve,be,Xe){const We=new Uint8Array(4),Be=s.createTexture();s.bindTexture(ce,Be),s.texParameteri(ce,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(ce,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ut=0;ut"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ne,u=new WeakMap;let h;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(j,Z){return f?new OffscreenCanvas(j,Z):Hf("canvas")}function v(j,Z,pe){let he=1;const te=Oe(j);if((te.width>pe||te.height>pe)&&(he=pe/Math.max(te.width,te.height)),he<1)if(typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&j instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&j instanceof ImageBitmap||typeof VideoFrame<"u"&&j instanceof VideoFrame){const Se=Math.floor(he*te.width),ye=Math.floor(he*te.height);h===void 0&&(h=m(Se,ye));const Ae=Z?m(Se,ye):h;return Ae.width=Se,Ae.height=ye,Ae.getContext("2d").drawImage(j,0,0,Se,ye),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+te.width+"x"+te.height+") to ("+Se+"x"+ye+")."),Ae}else return"data"in j&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+te.width+"x"+te.height+")."),j;return j}function g(j){return j.generateMipmaps}function _(j){s.generateMipmap(j)}function y(j){return j.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:j.isWebGL3DRenderTarget?s.TEXTURE_3D:j.isWebGLArrayRenderTarget||j.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function w(j,Z,pe,he,te=!1){if(j!==null){if(s[j]!==void 0)return s[j];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let Se=Z;if(Z===s.RED&&(pe===s.FLOAT&&(Se=s.R32F),pe===s.HALF_FLOAT&&(Se=s.R16F),pe===s.UNSIGNED_BYTE&&(Se=s.R8)),Z===s.RED_INTEGER&&(pe===s.UNSIGNED_BYTE&&(Se=s.R8UI),pe===s.UNSIGNED_SHORT&&(Se=s.R16UI),pe===s.UNSIGNED_INT&&(Se=s.R32UI),pe===s.BYTE&&(Se=s.R8I),pe===s.SHORT&&(Se=s.R16I),pe===s.INT&&(Se=s.R32I)),Z===s.RG&&(pe===s.FLOAT&&(Se=s.RG32F),pe===s.HALF_FLOAT&&(Se=s.RG16F),pe===s.UNSIGNED_BYTE&&(Se=s.RG8)),Z===s.RG_INTEGER&&(pe===s.UNSIGNED_BYTE&&(Se=s.RG8UI),pe===s.UNSIGNED_SHORT&&(Se=s.RG16UI),pe===s.UNSIGNED_INT&&(Se=s.RG32UI),pe===s.BYTE&&(Se=s.RG8I),pe===s.SHORT&&(Se=s.RG16I),pe===s.INT&&(Se=s.RG32I)),Z===s.RGB_INTEGER&&(pe===s.UNSIGNED_BYTE&&(Se=s.RGB8UI),pe===s.UNSIGNED_SHORT&&(Se=s.RGB16UI),pe===s.UNSIGNED_INT&&(Se=s.RGB32UI),pe===s.BYTE&&(Se=s.RGB8I),pe===s.SHORT&&(Se=s.RGB16I),pe===s.INT&&(Se=s.RGB32I)),Z===s.RGBA_INTEGER&&(pe===s.UNSIGNED_BYTE&&(Se=s.RGBA8UI),pe===s.UNSIGNED_SHORT&&(Se=s.RGBA16UI),pe===s.UNSIGNED_INT&&(Se=s.RGBA32UI),pe===s.BYTE&&(Se=s.RGBA8I),pe===s.SHORT&&(Se=s.RGBA16I),pe===s.INT&&(Se=s.RGBA32I)),Z===s.RGB&&pe===s.UNSIGNED_INT_5_9_9_9_REV&&(Se=s.RGB9_E5),Z===s.RGBA){const ye=te?Bf:mn.getTransfer(he);pe===s.FLOAT&&(Se=s.RGBA32F),pe===s.HALF_FLOAT&&(Se=s.RGBA16F),pe===s.UNSIGNED_BYTE&&(Se=ye===Wn?s.SRGB8_ALPHA8:s.RGBA8),pe===s.UNSIGNED_SHORT_4_4_4_4&&(Se=s.RGBA4),pe===s.UNSIGNED_SHORT_5_5_5_1&&(Se=s.RGB5_A1)}return(Se===s.R16F||Se===s.R32F||Se===s.RG16F||Se===s.RG32F||Se===s.RGBA16F||Se===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Se}function x(j,Z){let pe;return j?Z===null||Z===hs||Z===Pc?pe=s.DEPTH24_STENCIL8:Z===Un?pe=s.DEPTH32F_STENCIL8:Z===Ac&&(pe=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):Z===null||Z===hs||Z===Pc?pe=s.DEPTH_COMPONENT24:Z===Un?pe=s.DEPTH_COMPONENT32F:Z===Ac&&(pe=s.DEPTH_COMPONENT16),pe}function M(j,Z){return g(j)===!0||j.isFramebufferTexture&&j.minFilter!==En&&j.minFilter!==bn?Math.log2(Math.max(Z.width,Z.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?Z.mipmaps.length:1}function C(j){const Z=j.target;Z.removeEventListener("dispose",C),A(Z),Z.isVideoTexture&&u.delete(Z)}function T(j){const Z=j.target;Z.removeEventListener("dispose",T),E(Z)}function A(j){const Z=i.get(j);if(Z.__webglInit===void 0)return;const pe=j.source,he=d.get(pe);if(he){const te=he[Z.__cacheKey];te.usedTimes--,te.usedTimes===0&&P(j),Object.keys(he).length===0&&d.delete(pe)}i.remove(j)}function P(j){const Z=i.get(j);s.deleteTexture(Z.__webglTexture);const pe=j.source,he=d.get(pe);delete he[Z.__cacheKey],o.memory.textures--}function E(j){const Z=i.get(j);if(j.depthTexture&&(j.depthTexture.dispose(),i.remove(j.depthTexture)),j.isWebGLCubeRenderTarget)for(let he=0;he<6;he++){if(Array.isArray(Z.__webglFramebuffer[he]))for(let te=0;te=n.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+n.maxTextures),I+=1,j}function L(j){const Z=[];return Z.push(j.wrapS),Z.push(j.wrapT),Z.push(j.wrapR||0),Z.push(j.magFilter),Z.push(j.minFilter),Z.push(j.anisotropy),Z.push(j.internalFormat),Z.push(j.format),Z.push(j.type),Z.push(j.generateMipmaps),Z.push(j.premultiplyAlpha),Z.push(j.flipY),Z.push(j.unpackAlignment),Z.push(j.colorSpace),Z.join()}function k(j,Z){const pe=i.get(j);if(j.isVideoTexture&&Te(j),j.isRenderTargetTexture===!1&&j.version>0&&pe.__version!==j.version){const he=j.image;if(he===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(he.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(pe,j,Z);return}}t.bindTexture(s.TEXTURE_2D,pe.__webglTexture,s.TEXTURE0+Z)}function z(j,Z){const pe=i.get(j);if(j.version>0&&pe.__version!==j.version){K(pe,j,Z);return}t.bindTexture(s.TEXTURE_2D_ARRAY,pe.__webglTexture,s.TEXTURE0+Z)}function G(j,Z){const pe=i.get(j);if(j.version>0&&pe.__version!==j.version){K(pe,j,Z);return}t.bindTexture(s.TEXTURE_3D,pe.__webglTexture,s.TEXTURE0+Z)}function W(j,Z){const pe=i.get(j);if(j.version>0&&pe.__version!==j.version){Q(pe,j,Z);return}t.bindTexture(s.TEXTURE_CUBE_MAP,pe.__webglTexture,s.TEXTURE0+Z)}const q={[Os]:s.REPEAT,[pr]:s.CLAMP_TO_EDGE,[bh]:s.MIRRORED_REPEAT},O={[En]:s.NEAREST,[Ng]:s.NEAREST_MIPMAP_NEAREST,[Tc]:s.NEAREST_MIPMAP_LINEAR,[bn]:s.LINEAR,[wh]:s.LINEAR_MIPMAP_NEAREST,[Fs]:s.LINEAR_MIPMAP_LINEAR},B={[T2]:s.NEVER,[I2]:s.ALWAYS,[A2]:s.LESS,[Tb]:s.LEQUAL,[C2]:s.EQUAL,[D2]:s.GEQUAL,[P2]:s.GREATER,[R2]:s.NOTEQUAL};function J(j,Z){if(Z.type===Un&&e.has("OES_texture_float_linear")===!1&&(Z.magFilter===bn||Z.magFilter===wh||Z.magFilter===Tc||Z.magFilter===Fs||Z.minFilter===bn||Z.minFilter===wh||Z.minFilter===Tc||Z.minFilter===Fs)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(j,s.TEXTURE_WRAP_S,q[Z.wrapS]),s.texParameteri(j,s.TEXTURE_WRAP_T,q[Z.wrapT]),(j===s.TEXTURE_3D||j===s.TEXTURE_2D_ARRAY)&&s.texParameteri(j,s.TEXTURE_WRAP_R,q[Z.wrapR]),s.texParameteri(j,s.TEXTURE_MAG_FILTER,O[Z.magFilter]),s.texParameteri(j,s.TEXTURE_MIN_FILTER,O[Z.minFilter]),Z.compareFunction&&(s.texParameteri(j,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(j,s.TEXTURE_COMPARE_FUNC,B[Z.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(Z.magFilter===En||Z.minFilter!==Tc&&Z.minFilter!==Fs||Z.type===Un&&e.has("OES_texture_float_linear")===!1)return;if(Z.anisotropy>1||i.get(Z).__currentAnisotropy){const pe=e.get("EXT_texture_filter_anisotropic");s.texParameterf(j,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Z.anisotropy,n.getMaxAnisotropy())),i.get(Z).__currentAnisotropy=Z.anisotropy}}}function re(j,Z){let pe=!1;j.__webglInit===void 0&&(j.__webglInit=!0,Z.addEventListener("dispose",C));const he=Z.source;let te=d.get(he);te===void 0&&(te={},d.set(he,te));const Se=L(Z);if(Se!==j.__cacheKey){te[Se]===void 0&&(te[Se]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,pe=!0),te[Se].usedTimes++;const ye=te[j.__cacheKey];ye!==void 0&&(te[j.__cacheKey].usedTimes--,ye.usedTimes===0&&P(Z)),j.__cacheKey=Se,j.__webglTexture=te[Se].texture}return pe}function K(j,Z,pe){let he=s.TEXTURE_2D;(Z.isDataArrayTexture||Z.isCompressedArrayTexture)&&(he=s.TEXTURE_2D_ARRAY),Z.isData3DTexture&&(he=s.TEXTURE_3D);const te=re(j,Z),Se=Z.source;t.bindTexture(he,j.__webglTexture,s.TEXTURE0+pe);const ye=i.get(Se);if(Se.version!==ye.__version||te===!0){t.activeTexture(s.TEXTURE0+pe);const Ae=mn.getPrimaries(mn.workingColorSpace),Ce=Z.colorSpace===jo?null:mn.getPrimaries(Z.colorSpace),Ge=Z.colorSpace===jo||Ae===Ce?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,Z.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Z.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,Z.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);let De=v(Z.image,!1,n.maxTextureSize);De=Ye(Z,De);const Ve=r.convert(Z.format,Z.colorSpace),ze=r.convert(Z.type);let Ze=w(Z.internalFormat,Ve,ze,Z.colorSpace,Z.isVideoTexture);J(he,Z);let Le;const ot=Z.mipmaps,tt=Z.isVideoTexture!==!0,mt=ye.__version===void 0||te===!0,ce=Se.dataReady,ve=M(Z,De);if(Z.isDepthTexture)Ze=x(Z.format===Dc,Z.type),mt&&(tt?t.texStorage2D(s.TEXTURE_2D,1,Ze,De.width,De.height):t.texImage2D(s.TEXTURE_2D,0,Ze,De.width,De.height,0,Ve,ze,null));else if(Z.isDataTexture)if(ot.length>0){tt&&mt&&t.texStorage2D(s.TEXTURE_2D,ve,Ze,ot[0].width,ot[0].height);for(let be=0,Xe=ot.length;be0){const We=G1(Le.width,Le.height,Z.format,Z.type);for(const Be of Z.layerUpdates){const ut=Le.data.subarray(Be*We/Le.data.BYTES_PER_ELEMENT,(Be+1)*We/Le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,be,0,0,Be,Le.width,Le.height,1,Ve,ut)}Z.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,be,0,0,0,Le.width,Le.height,De.depth,Ve,Le.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,be,Ze,Le.width,Le.height,De.depth,0,Le.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else tt?ce&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,be,0,0,0,Le.width,Le.height,De.depth,Ve,ze,Le.data):t.texImage3D(s.TEXTURE_2D_ARRAY,be,Ze,Le.width,Le.height,De.depth,0,Ve,ze,Le.data)}else{tt&&mt&&t.texStorage2D(s.TEXTURE_2D,ve,Ze,ot[0].width,ot[0].height);for(let be=0,Xe=ot.length;be0){const be=G1(De.width,De.height,Z.format,Z.type);for(const Xe of Z.layerUpdates){const We=De.data.subarray(Xe*be/De.data.BYTES_PER_ELEMENT,(Xe+1)*be/De.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Xe,De.width,De.height,1,Ve,ze,We)}Z.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,De.width,De.height,De.depth,Ve,ze,De.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Ze,De.width,De.height,De.depth,0,Ve,ze,De.data);else if(Z.isData3DTexture)tt?(mt&&t.texStorage3D(s.TEXTURE_3D,ve,Ze,De.width,De.height,De.depth),ce&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,De.width,De.height,De.depth,Ve,ze,De.data)):t.texImage3D(s.TEXTURE_3D,0,Ze,De.width,De.height,De.depth,0,Ve,ze,De.data);else if(Z.isFramebufferTexture){if(mt)if(tt)t.texStorage2D(s.TEXTURE_2D,ve,Ze,De.width,De.height);else{let be=De.width,Xe=De.height;for(let We=0;We>=1,Xe>>=1}}else if(ot.length>0){if(tt&&mt){const be=Oe(ot[0]);t.texStorage2D(s.TEXTURE_2D,ve,Ze,be.width,be.height)}for(let be=0,Xe=ot.length;be0&&ve++;const Xe=Oe(Ve[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,ve,ot,Xe.width,Xe.height)}for(let Xe=0;Xe<6;Xe++)if(De){tt?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Xe,0,0,0,Ve[Xe].width,Ve[Xe].height,Ze,Le,Ve[Xe].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Xe,0,ot,Ve[Xe].width,Ve[Xe].height,0,Ze,Le,Ve[Xe].data);for(let We=0;We>Se),ze=Math.max(1,Z.height>>Se);te===s.TEXTURE_3D||te===s.TEXTURE_2D_ARRAY?t.texImage3D(te,Se,Ce,Ve,ze,Z.depth,0,ye,Ae,null):t.texImage2D(te,Se,Ce,Ve,ze,0,ye,Ae,null)}t.bindFramebuffer(s.FRAMEBUFFER,j),oe(Z)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,he,te,De.__webglTexture,0,Me(Z)):(te===s.TEXTURE_2D||te>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&te<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,he,te,De.__webglTexture,Se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function le(j,Z,pe){if(s.bindRenderbuffer(s.RENDERBUFFER,j),Z.depthBuffer){const he=Z.depthTexture,te=he&&he.isDepthTexture?he.type:null,Se=x(Z.stencilBuffer,te),ye=Z.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Ae=Me(Z);oe(Z)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ae,Se,Z.width,Z.height):pe?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ae,Se,Z.width,Z.height):s.renderbufferStorage(s.RENDERBUFFER,Se,Z.width,Z.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ye,s.RENDERBUFFER,j)}else{const he=Z.textures;for(let te=0;te{delete Z.__boundDepthTexture,delete Z.__depthDisposeCallback,he.removeEventListener("dispose",te)};he.addEventListener("dispose",te),Z.__depthDisposeCallback=te}Z.__boundDepthTexture=he}if(j.depthTexture&&!Z.__autoAllocateDepthBuffer){if(pe)throw new Error("target.depthTexture not supported in Cube render targets");_e(Z.__webglFramebuffer,j)}else if(pe){Z.__webglDepthbuffer=[];for(let he=0;he<6;he++)if(t.bindFramebuffer(s.FRAMEBUFFER,Z.__webglFramebuffer[he]),Z.__webglDepthbuffer[he]===void 0)Z.__webglDepthbuffer[he]=s.createRenderbuffer(),le(Z.__webglDepthbuffer[he],j,!1);else{const te=j.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Se=Z.__webglDepthbuffer[he];s.bindRenderbuffer(s.RENDERBUFFER,Se),s.framebufferRenderbuffer(s.FRAMEBUFFER,te,s.RENDERBUFFER,Se)}}else if(t.bindFramebuffer(s.FRAMEBUFFER,Z.__webglFramebuffer),Z.__webglDepthbuffer===void 0)Z.__webglDepthbuffer=s.createRenderbuffer(),le(Z.__webglDepthbuffer,j,!1);else{const he=j.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,te=Z.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,te),s.framebufferRenderbuffer(s.FRAMEBUFFER,he,s.RENDERBUFFER,te)}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ie(j,Z,pe){const he=i.get(j);Z!==void 0&&ue(he.__webglFramebuffer,j,j.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),pe!==void 0&&Fe(j)}function Ee(j){const Z=j.texture,pe=i.get(j),he=i.get(Z);j.addEventListener("dispose",T);const te=j.textures,Se=j.isWebGLCubeRenderTarget===!0,ye=te.length>1;if(ye||(he.__webglTexture===void 0&&(he.__webglTexture=s.createTexture()),he.__version=Z.version,o.memory.textures++),Se){pe.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(Z.mipmaps&&Z.mipmaps.length>0){pe.__webglFramebuffer[Ae]=[];for(let Ce=0;Ce0){pe.__webglFramebuffer=[];for(let Ae=0;Ae0&&oe(j)===!1){pe.__webglMultisampledFramebuffer=s.createFramebuffer(),pe.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,pe.__webglMultisampledFramebuffer);for(let Ae=0;Ae0)for(let Ce=0;Ce0)for(let Ce=0;Ce0){if(oe(j)===!1){const Z=j.textures,pe=j.width,he=j.height;let te=s.COLOR_BUFFER_BIT;const Se=j.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ye=i.get(j),Ae=Z.length>1;if(Ae)for(let Ce=0;Ce0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Z.__useRenderToTexture!==!1}function Te(j){const Z=o.render.frame;u.get(j)!==Z&&(u.set(j,Z),j.update())}function Ye(j,Z){const pe=j.colorSpace,he=j.format,te=j.type;return j.isCompressedTexture===!0||j.isVideoTexture===!0||pe!==Ii&&pe!==jo&&(mn.getTransfer(pe)===Wn?(he!==di||te!==Qs)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",pe)),Z}function Oe(j){return typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement?(c.width=j.naturalWidth||j.width,c.height=j.naturalHeight||j.height):typeof VideoFrame<"u"&&j instanceof VideoFrame?(c.width=j.displayWidth,c.height=j.displayHeight):(c.width=j.width,c.height=j.height),c}this.allocateTextureUnit=U,this.resetTextureUnits=R,this.setTexture2D=k,this.setTexture2DArray=z,this.setTexture3D=G,this.setTextureCube=W,this.rebindTextures=Ie,this.setupRenderTarget=Ee,this.updateRenderTargetMipmap=me,this.updateMultisampleRenderTarget=Ue,this.setupDepthRenderbuffer=Fe,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=oe}function aR(s,e){function t(i,n=jo){let r;const o=mn.getTransfer(n);if(i===Qs)return s.UNSIGNED_BYTE;if(i===zg)return s.UNSIGNED_SHORT_4_4_4_4;if(i===Vg)return s.UNSIGNED_SHORT_5_5_5_1;if(i===_b)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===If)return s.BYTE;if(i===Bg)return s.SHORT;if(i===Ac)return s.UNSIGNED_SHORT;if(i===Cc)return s.INT;if(i===hs)return s.UNSIGNED_INT;if(i===Un)return s.FLOAT;if(i===mr)return s.HALF_FLOAT;if(i===yb)return s.ALPHA;if(i===xb)return s.RGB;if(i===di)return s.RGBA;if(i===bb)return s.LUMINANCE;if(i===wb)return s.LUMINANCE_ALPHA;if(i===Rc)return s.DEPTH_COMPONENT;if(i===Dc)return s.DEPTH_STENCIL;if(i===Sh)return s.RED;if(i===Mh)return s.RED_INTEGER;if(i===Gg)return s.RG;if(i===Eh)return s.RG_INTEGER;if(i===Ic)return s.RGBA_INTEGER;if(i===Lf||i===Uf||i===kf||i===Of)if(o===Wn)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Lf)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Uf)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===kf)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Of)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Lf)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Uf)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===kf)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Of)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Hg||i===Wg||i===Xg||i===Yg)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Hg)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Wg)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Xg)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Yg)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===jg||i===qg||i===Zg)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===jg||i===qg)return o===Wn?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Zg)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Kg||i===$g||i===Jg||i===Qg||i===ev||i===tv||i===nv||i===iv||i===rv||i===sv||i===ov||i===av||i===lv||i===cv)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kg)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===$g)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Jg)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Qg)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ev)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===tv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===nv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===iv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===rv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===sv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ov)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===av)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===lv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===cv)return o===Wn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ff||i===uv||i===hv)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Ff)return o===Wn?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===uv)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===hv)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Sb||i===dv||i===fv||i===pv)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Ff)return r.COMPRESSED_RED_RGTC1_EXT;if(i===dv)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===fv)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===pv)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Pc?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const sH=` void main() { gl_Position = vec4( position, 1.0 ); }`,oH=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`;class aH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const n=new ni,r=e.properties.get(n);r.__webglTexture=t.texture,(t.depthNear!==i.depthNear||t.depthFar!==i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Ti({vertexShader:sH,fragmentShader:oH,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new it(new es(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class lH extends qo{constructor(e,t){super();const i=this;let n=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,m=null;const v=new aH,g=t.getContextAttributes();let _=null,y=null;const w=[],x=[],M=new Ne;let C=null;const T=new zi;T.viewport=new Zt;const A=new zi;A.viewport=new Zt;const P=[T,A],E=new fP;let I=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let Q=w[K];return Q===void 0&&(Q=new Gv,w[K]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(K){let Q=w[K];return Q===void 0&&(Q=new Gv,w[K]=Q),Q.getGripSpace()},this.getHand=function(K){let Q=w[K];return Q===void 0&&(Q=new Gv,w[K]=Q),Q.getHandSpace()};function U(K){const Q=x.indexOf(K.inputSource);if(Q===-1)return;const ue=w[Q];ue!==void 0&&(ue.update(K.inputSource,K.frame,c||o),ue.dispatchEvent({type:K.type,data:K.inputSource}))}function L(){n.removeEventListener("select",U),n.removeEventListener("selectstart",U),n.removeEventListener("selectend",U),n.removeEventListener("squeeze",U),n.removeEventListener("squeezestart",U),n.removeEventListener("squeezeend",U),n.removeEventListener("end",L),n.removeEventListener("inputsourceschange",k);for(let K=0;K=0&&(x[le]=null,w[le].disconnect(ue))}for(let Q=0;Q=x.length){x.push(ue),le=Fe;break}else if(x[Fe]===null){x[Fe]=ue,le=Fe;break}if(le===-1)break}const _e=w[le];_e&&_e.connect(ue)}}const z=new X,G=new X;function W(K,Q,ue){z.setFromMatrixPosition(Q.matrixWorld),G.setFromMatrixPosition(ue.matrixWorld);const le=z.distanceTo(G),_e=Q.projectionMatrix.elements,Fe=ue.projectionMatrix.elements,Ie=_e[14]/(_e[10]-1),Ee=_e[14]/(_e[10]+1),me=(_e[9]+1)/_e[5],xe=(_e[9]-1)/_e[5],$=(_e[8]-1)/_e[0],Ue=(Fe[8]+1)/Fe[0],Me=Ie*$,oe=Ie*Ue,Te=le/(-$+Ue),Ye=Te*-$;if(Q.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Ye),K.translateZ(Te),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),_e[10]===-1)K.projectionMatrix.copy(Q.projectionMatrix),K.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{const Oe=Ie+Te,j=Ee+Te,Z=Me-Ye,pe=oe+(le-Ye),he=me*Ee/j*Oe,te=xe*Ee/j*Oe;K.projectionMatrix.makePerspective(Z,pe,he,te,Oe,j),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function q(K,Q){Q===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(Q.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(n===null)return;let Q=K.near,ue=K.far;v.texture!==null&&(v.depthNear>0&&(Q=v.depthNear),v.depthFar>0&&(ue=v.depthFar)),E.near=A.near=T.near=Q,E.far=A.far=T.far=ue,(I!==E.near||R!==E.far)&&(n.updateRenderState({depthNear:E.near,depthFar:E.far}),I=E.near,R=E.far),T.layers.mask=K.layers.mask|2,A.layers.mask=K.layers.mask|4,E.layers.mask=T.layers.mask|A.layers.mask;const le=K.parent,_e=E.cameras;q(E,le);for(let Fe=0;Fe<_e.length;Fe++)q(_e[Fe],le);_e.length===2?W(E,T,A):E.projectionMatrix.copy(T.projectionMatrix),O(K,E,le)};function O(K,Q,ue){ue===null?K.matrix.copy(Q.matrixWorld):(K.matrix.copy(ue.matrixWorld),K.matrix.invert(),K.matrix.multiply(Q.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(Q.projectionMatrix),K.projectionMatrixInverse.copy(Q.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Rh*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return E},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(K){l=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(E)};let B=null;function J(K,Q){if(u=Q.getViewerPose(c||o),m=Q,u!==null){const ue=u.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let le=!1;ue.length!==E.cameras.length&&(E.cameras.length=0,le=!0);for(let Ie=0;Ie0&&(g.alphaTest.value=_.alphaTest);const y=e.get(_),w=y.envMap,x=y.envMapRotation;w&&(g.envMap.value=w,cu.copy(x),cu.x*=-1,cu.y*=-1,cu.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(cu.y*=-1,cu.z*=-1),g.envMapRotation.value.setFromMatrix4(cH.makeRotationFromEuler(cu)),g.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=_.reflectivity,g.ior.value=_.ior,g.refractionRatio.value=_.refractionRatio),_.lightMap&&(g.lightMap.value=_.lightMap,g.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,g.lightMapTransform)),_.aoMap&&(g.aoMap.value=_.aoMap,g.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,g.aoMapTransform))}function o(g,_){g.diffuse.value.copy(_.color),g.opacity.value=_.opacity,_.map&&(g.map.value=_.map,t(_.map,g.mapTransform))}function a(g,_){g.dashSize.value=_.dashSize,g.totalSize.value=_.dashSize+_.gapSize,g.scale.value=_.scale}function l(g,_,y,w){g.diffuse.value.copy(_.color),g.opacity.value=_.opacity,g.size.value=_.size*y,g.scale.value=w*.5,_.map&&(g.map.value=_.map,t(_.map,g.uvTransform)),_.alphaMap&&(g.alphaMap.value=_.alphaMap,t(_.alphaMap,g.alphaMapTransform)),_.alphaTest>0&&(g.alphaTest.value=_.alphaTest)}function c(g,_){g.diffuse.value.copy(_.color),g.opacity.value=_.opacity,g.rotation.value=_.rotation,_.map&&(g.map.value=_.map,t(_.map,g.mapTransform)),_.alphaMap&&(g.alphaMap.value=_.alphaMap,t(_.alphaMap,g.alphaMapTransform)),_.alphaTest>0&&(g.alphaTest.value=_.alphaTest)}function u(g,_){g.specular.value.copy(_.specular),g.shininess.value=Math.max(_.shininess,1e-4)}function h(g,_){_.gradientMap&&(g.gradientMap.value=_.gradientMap)}function d(g,_){g.metalness.value=_.metalness,_.metalnessMap&&(g.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,g.metalnessMapTransform)),g.roughness.value=_.roughness,_.roughnessMap&&(g.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,g.roughnessMapTransform)),_.envMap&&(g.envMapIntensity.value=_.envMapIntensity)}function f(g,_,y){g.ior.value=_.ior,_.sheen>0&&(g.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),g.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(g.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,g.sheenColorMapTransform)),_.sheenRoughnessMap&&(g.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,g.sheenRoughnessMapTransform))),_.clearcoat>0&&(g.clearcoat.value=_.clearcoat,g.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(g.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,g.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(g.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===ji&&g.clearcoatNormalScale.value.negate())),_.dispersion>0&&(g.dispersion.value=_.dispersion),_.iridescence>0&&(g.iridescence.value=_.iridescence,g.iridescenceIOR.value=_.iridescenceIOR,g.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(g.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,g.iridescenceMapTransform)),_.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),_.transmission>0&&(g.transmission.value=_.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),_.transmissionMap&&(g.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,g.transmissionMapTransform)),g.thickness.value=_.thickness,_.thicknessMap&&(g.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=_.attenuationDistance,g.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(g.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(g.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=_.specularIntensity,g.specularColor.value.copy(_.specularColor),_.specularColorMap&&(g.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,g.specularColorMapTransform)),_.specularIntensityMap&&(g.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,_){_.matcap&&(g.matcap.value=_.matcap)}function v(g,_){const y=e.get(_).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function hH(s,e,t,i){let n={},r={},o=[];const a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,w){const x=w.program;i.uniformBlockBinding(y,x)}function c(y,w){let x=n[y.id];x===void 0&&(m(y),x=u(y),n[y.id]=x,y.addEventListener("dispose",g));const M=w.program;i.updateUBOMapping(y,M);const C=e.render.frame;r[y.id]!==C&&(d(y),r[y.id]=C)}function u(y){const w=h();y.__bindingPointIndex=w;const x=s.createBuffer(),M=y.__size,C=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,x),s.bufferData(s.UNIFORM_BUFFER,M,C),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,w,x),x}function h(){for(let y=0;y0&&(x+=M-C),y.__size=x,y.__cache={},this}function v(y){const w={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(w.boundary=4,w.storage=4):y.isVector2?(w.boundary=8,w.storage=8):y.isVector3||y.isColor?(w.boundary=16,w.storage=12):y.isVector4?(w.boundary=16,w.storage=16):y.isMatrix3?(w.boundary=48,w.storage=48):y.isMatrix4?(w.boundary=64,w.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),w}function g(y){const w=y.target;w.removeEventListener("dispose",g);const x=o.indexOf(w.__bindingPointIndex);o.splice(x,1),s.deleteBuffer(n[w.id]),delete n[w.id],delete r[w.id]}function _(){for(const y in n)s.deleteBuffer(n[y]);o=[],n={},r={}}return{bind:l,update:c,dispose:_}}class J1{constructor(e={}){const{canvas:t=k2(),context:i=null,depth:n=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=i.getContextAttributes().alpha}else f=o;const m=new Uint32Array(4),v=new Int32Array(4);let g=null,_=null;const y=[],w=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ni,this.toneMapping=Yo,this.toneMappingExposure=1;const x=this;let M=!1,C=0,T=0,A=null,P=-1,E=null;const I=new Zt,R=new Zt;let U=null;const L=new rt(0);let k=0,z=t.width,G=t.height,W=1,q=null,O=null;const B=new Zt(0,0,z,G),J=new Zt(0,0,z,G);let re=!1;const K=new sp;let Q=!1,ue=!1;this.transmissionResolutionScale=1;const le=new _t,_e=new _t,Fe=new X,Ie=new Zt,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let me=!1;function xe(){return A===null?W:1}let $=i;function Ue(N,ie){return t.getContext(N,ie)}try{const N={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${_h}`),t.addEventListener("webglcontextlost",Xe,!1),t.addEventListener("webglcontextrestored",We,!1),t.addEventListener("webglcontextcreationerror",Be,!1),$===null){const ie="webgl2";if($=Ue(ie,N),$===null)throw Ue(ie)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Me,oe,Te,Ye,Oe,j,Z,pe,he,te,Se,ye,Ae,Ce,Ge,De,Ve,ze,Ze,Le,ot,tt,mt,ce;function ve(){Me=new SV($),Me.init(),tt=new aR($,Me),oe=new gV($,Me,e,tt),Te=new iH($,Me),oe.reverseDepthBuffer&&d&&Te.buffers.depth.setReversed(!0),Ye=new TV($),Oe=new WG,j=new rH($,Me,Te,Oe,oe,tt,Ye),Z=new _V(x),pe=new wV(x),he=new d4($),mt=new pV($,he),te=new MV($,he,Ye,mt),Se=new CV($,te,he,Ye),Ze=new AV($,oe,j),De=new vV(Oe),ye=new HG(x,Z,pe,Me,oe,mt,De),Ae=new uH(x,Oe),Ce=new YG,Ge=new JG(Me),ze=new fV(x,Z,pe,Te,Se,f,l),Ve=new tH(x,Se,oe),ce=new hH($,Ye,oe,Te),Le=new mV($,Me,Ye),ot=new EV($,Me,Ye),Ye.programs=ye.programs,x.capabilities=oe,x.extensions=Me,x.properties=Oe,x.renderLists=Ce,x.shadowMap=Ve,x.state=Te,x.info=Ye}ve();const be=new lH(x,$);this.xr=be,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const N=Me.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=Me.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(N){N!==void 0&&(W=N,this.setSize(z,G,!1))},this.getSize=function(N){return N.set(z,G)},this.setSize=function(N,ie,se=!0){if(be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}z=N,G=ie,t.width=Math.floor(N*W),t.height=Math.floor(ie*W),se===!0&&(t.style.width=N+"px",t.style.height=ie+"px"),this.setViewport(0,0,N,ie)},this.getDrawingBufferSize=function(N){return N.set(z*W,G*W).floor()},this.setDrawingBufferSize=function(N,ie,se){z=N,G=ie,W=se,t.width=Math.floor(N*se),t.height=Math.floor(ie*se),this.setViewport(0,0,N,ie)},this.getCurrentViewport=function(N){return N.copy(I)},this.getViewport=function(N){return N.copy(B)},this.setViewport=function(N,ie,se,ne){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,ie,se,ne),Te.viewport(I.copy(B).multiplyScalar(W).round())},this.getScissor=function(N){return N.copy(J)},this.setScissor=function(N,ie,se,ne){N.isVector4?J.set(N.x,N.y,N.z,N.w):J.set(N,ie,se,ne),Te.scissor(R.copy(J).multiplyScalar(W).round())},this.getScissorTest=function(){return re},this.setScissorTest=function(N){Te.setScissorTest(re=N)},this.setOpaqueSort=function(N){q=N},this.setTransparentSort=function(N){O=N},this.getClearColor=function(N){return N.copy(ze.getClearColor())},this.setClearColor=function(){ze.setClearColor(...arguments)},this.getClearAlpha=function(){return ze.getClearAlpha()},this.setClearAlpha=function(){ze.setClearAlpha(...arguments)},this.clear=function(N=!0,ie=!0,se=!0){let ne=0;if(N){let ae=!1;if(A!==null){const we=A.texture.format;ae=we===Ic||we===Eh||we===Mh}if(ae){const we=A.texture.type,Pe=we===Qs||we===hs||we===Ac||we===Pc||we===zg||we===Vg,Re=ze.getClearColor(),He=ze.getClearAlpha(),qe=Re.r,Ke=Re.g,Je=Re.b;Pe?(m[0]=qe,m[1]=Ke,m[2]=Je,m[3]=He,$.clearBufferuiv($.COLOR,0,m)):(v[0]=qe,v[1]=Ke,v[2]=Je,v[3]=He,$.clearBufferiv($.COLOR,0,v))}else ne|=$.COLOR_BUFFER_BIT}ie&&(ne|=$.DEPTH_BUFFER_BIT),se&&(ne|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),$.clear(ne)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Xe,!1),t.removeEventListener("webglcontextrestored",We,!1),t.removeEventListener("webglcontextcreationerror",Be,!1),ze.dispose(),Ce.dispose(),Ge.dispose(),Oe.dispose(),Z.dispose(),pe.dispose(),Se.dispose(),mt.dispose(),ce.dispose(),ye.dispose(),be.dispose(),be.removeEventListener("sessionstart",Qe),be.removeEventListener("sessionend",bt),yt.stop()};function Xe(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function We(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;const N=Ye.autoReset,ie=Ve.enabled,se=Ve.autoUpdate,ne=Ve.needsUpdate,ae=Ve.type;ve(),Ye.autoReset=N,Ve.enabled=ie,Ve.autoUpdate=se,Ve.needsUpdate=ne,Ve.type=ae}function Be(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function ut(N){const ie=N.target;ie.removeEventListener("dispose",ut),gt(ie)}function gt(N){nt(N),Oe.remove(N)}function nt(N){const ie=Oe.get(N).programs;ie!==void 0&&(ie.forEach(function(se){ye.releaseProgram(se)}),N.isShaderMaterial&&ye.releaseShaderCache(N))}this.renderBufferDirect=function(N,ie,se,ne,ae,we){ie===null&&(ie=Ee);const Pe=ae.isMesh&&ae.matrixWorld.determinant()<0,Re=er(N,ie,se,ne,ae);Te.setMaterial(ne,Pe);let He=se.index,qe=1;if(ne.wireframe===!0){if(He=te.getWireframeAttribute(se),He===void 0)return;qe=2}const Ke=se.drawRange,Je=se.attributes.position;let et=Ke.start*qe,st=(Ke.start+Ke.count)*qe;we!==null&&(et=Math.max(et,we.start*qe),st=Math.min(st,(we.start+we.count)*qe)),He!==null?(et=Math.max(et,0),st=Math.min(st,He.count)):Je!=null&&(et=Math.max(et,0),st=Math.min(st,Je.count));const Dt=st-et;if(Dt<0||Dt===1/0)return;mt.setup(ae,ne,Re,se,He);let kt,Ot=Le;if(He!==null&&(kt=he.get(He),Ot=ot,Ot.setIndex(kt)),ae.isMesh)ne.wireframe===!0?(Te.setLineWidth(ne.wireframeLinewidth*xe()),Ot.setMode($.LINES)):Ot.setMode($.TRIANGLES);else if(ae.isLine){let wt=ne.linewidth;wt===void 0&&(wt=1),Te.setLineWidth(wt*xe()),ae.isLineSegments?Ot.setMode($.LINES):ae.isLineLoop?Ot.setMode($.LINE_LOOP):Ot.setMode($.LINE_STRIP)}else ae.isPoints?Ot.setMode($.POINTS):ae.isSprite&&Ot.setMode($.TRIANGLES);if(ae.isBatchedMesh)if(ae._multiDrawInstances!==null)Fc("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ot.renderMultiDrawInstances(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount,ae._multiDrawInstances);else if(Me.get("WEBGL_multi_draw"))Ot.renderMultiDraw(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount);else{const wt=ae._multiDrawStarts,Yt=ae._multiDrawCounts,St=ae._multiDrawCount,vn=He?he.get(He).bytesPerElement:1,ui=Oe.get(ne).currentProgram.getUniforms();for(let pn=0;pn{function we(){if(ne.forEach(function(Pe){Oe.get(Pe).currentProgram.isReady()&&ne.delete(Pe)}),ne.size===0){ae(N);return}setTimeout(we,10)}Me.get("KHR_parallel_shader_compile")!==null?we():setTimeout(we,10)})};let at=null;function ft(N){at&&at(N)}function Qe(){yt.stop()}function bt(){yt.start()}const yt=new LP;yt.setAnimationLoop(ft),typeof self<"u"&&yt.setContext(self),this.setAnimationLoop=function(N){at=N,be.setAnimationLoop(N),N===null?yt.stop():yt.start()},be.addEventListener("sessionstart",Qe),be.addEventListener("sessionend",bt),this.render=function(N,ie){if(ie!==void 0&&ie.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),ie.parent===null&&ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),be.enabled===!0&&be.isPresenting===!0&&(be.cameraAutoUpdate===!0&&be.updateCamera(ie),ie=be.getCamera()),N.isScene===!0&&N.onBeforeRender(x,N,ie,A),_=Ge.get(N,w.length),_.init(ie),w.push(_),_e.multiplyMatrices(ie.projectionMatrix,ie.matrixWorldInverse),K.setFromProjectionMatrix(_e),ue=this.localClippingEnabled,Q=De.init(this.clippingPlanes,ue),g=Ce.get(N,y.length),g.init(),y.push(g),be.enabled===!0&&be.isPresenting===!0){const we=x.xr.getDepthSensingMesh();we!==null&&Rt(we,ie,-1/0,x.sortObjects)}Rt(N,ie,0,x.sortObjects),g.finish(),x.sortObjects===!0&&g.sort(q,O),me=be.enabled===!1||be.isPresenting===!1||be.hasDepthSensing()===!1,me&&ze.addToRenderList(g,N),this.info.render.frame++,Q===!0&&De.beginShadows();const se=_.state.shadowsArray;Ve.render(se,N,ie),Q===!0&&De.endShadows(),this.info.autoReset===!0&&this.info.reset();const ne=g.opaque,ae=g.transmissive;if(_.setupLights(),ie.isArrayCamera){const we=ie.cameras;if(ae.length>0)for(let Pe=0,Re=we.length;Pe0&&zt(ne,ae,N,ie),me&&ze.render(N),on(g,N,ie);A!==null&&T===0&&(j.updateMultisampleRenderTarget(A),j.updateRenderTargetMipmap(A)),N.isScene===!0&&N.onAfterRender(x,N,ie),mt.resetDefaultState(),P=-1,E=null,w.pop(),w.length>0?(_=w[w.length-1],Q===!0&&De.setGlobalState(x.clippingPlanes,_.state.camera)):_=null,y.pop(),y.length>0?g=y[y.length-1]:g=null};function Rt(N,ie,se,ne){if(N.visible===!1)return;if(N.layers.test(ie.layers)){if(N.isGroup)se=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(ie);else if(N.isLight)_.pushLight(N),N.castShadow&&_.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||K.intersectsSprite(N)){ne&&Ie.setFromMatrixPosition(N.matrixWorld).applyMatrix4(_e);const Pe=Se.update(N),Re=N.material;Re.visible&&g.push(N,Pe,Re,se,Ie.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||K.intersectsObject(N))){const Pe=Se.update(N),Re=N.material;if(ne&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),Ie.copy(N.boundingSphere.center)):(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),Ie.copy(Pe.boundingSphere.center)),Ie.applyMatrix4(N.matrixWorld).applyMatrix4(_e)),Array.isArray(Re)){const He=Pe.groups;for(let qe=0,Ke=He.length;qe0&&Qt(ae,ie,se),we.length>0&&Qt(we,ie,se),Pe.length>0&&Qt(Pe,ie,se),Te.buffers.depth.setTest(!0),Te.buffers.depth.setMask(!0),Te.buffers.color.setMask(!0),Te.setPolygonOffset(!1)}function zt(N,ie,se,ne){if((se.isScene===!0?se.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[ne.id]===void 0&&(_.state.transmissionRenderTarget[ne.id]=new Bs(1,1,{generateMipmaps:!0,type:Me.has("EXT_color_buffer_half_float")||Me.has("EXT_color_buffer_float")?mr:Qs,minFilter:Fs,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:mn.workingColorSpace}));const we=_.state.transmissionRenderTarget[ne.id],Pe=ne.viewport||I;we.setSize(Pe.z*x.transmissionResolutionScale,Pe.w*x.transmissionResolutionScale);const Re=x.getRenderTarget();x.setRenderTarget(we),x.getClearColor(L),k=x.getClearAlpha(),k<1&&x.setClearColor(16777215,.5),x.clear(),me&&ze.render(se);const He=x.toneMapping;x.toneMapping=Yo;const qe=ne.viewport;if(ne.viewport!==void 0&&(ne.viewport=void 0),_.setupLightsView(ne),Q===!0&&De.setGlobalState(x.clippingPlanes,ne),Qt(N,se,ne),j.updateMultisampleRenderTarget(we),j.updateRenderTargetMipmap(we),Me.has("WEBGL_multisampled_render_to_texture")===!1){let Ke=!1;for(let Je=0,et=ie.length;Je0),Je=!!se.morphAttributes.position,et=!!se.morphAttributes.normal,st=!!se.morphAttributes.color;let Dt=Yo;ne.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Dt=x.toneMapping);const kt=se.morphAttributes.position||se.morphAttributes.normal||se.morphAttributes.color,Ot=kt!==void 0?kt.length:0,wt=Oe.get(ne),Yt=_.state.lights;if(Q===!0&&(ue===!0||N!==E)){const On=N===E&&ne.id===P;De.setState(ne,N,On)}let St=!1;ne.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==Yt.state.version||wt.outputColorSpace!==Re||ae.isBatchedMesh&&wt.batching===!1||!ae.isBatchedMesh&&wt.batching===!0||ae.isBatchedMesh&&wt.batchingColor===!0&&ae.colorTexture===null||ae.isBatchedMesh&&wt.batchingColor===!1&&ae.colorTexture!==null||ae.isInstancedMesh&&wt.instancing===!1||!ae.isInstancedMesh&&wt.instancing===!0||ae.isSkinnedMesh&&wt.skinning===!1||!ae.isSkinnedMesh&&wt.skinning===!0||ae.isInstancedMesh&&wt.instancingColor===!0&&ae.instanceColor===null||ae.isInstancedMesh&&wt.instancingColor===!1&&ae.instanceColor!==null||ae.isInstancedMesh&&wt.instancingMorph===!0&&ae.morphTexture===null||ae.isInstancedMesh&&wt.instancingMorph===!1&&ae.morphTexture!==null||wt.envMap!==He||ne.fog===!0&&wt.fog!==we||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==De.numPlanes||wt.numIntersection!==De.numIntersection)||wt.vertexAlphas!==qe||wt.vertexTangents!==Ke||wt.morphTargets!==Je||wt.morphNormals!==et||wt.morphColors!==st||wt.toneMapping!==Dt||wt.morphTargetsCount!==Ot)&&(St=!0):(St=!0,wt.__version=ne.version);let vn=wt.currentProgram;St===!0&&(vn=nn(ne,ie,ae));let ui=!1,pn=!1,jt=!1;const Vt=vn.getUniforms(),Xn=wt.uniforms;if(Te.useProgram(vn.program)&&(ui=!0,pn=!0,jt=!0),ne.id!==P&&(P=ne.id,pn=!0),ui||E!==N){Te.buffers.depth.getReversed()?(le.copy(N.projectionMatrix),qN(le),ZN(le),Vt.setValue($,"projectionMatrix",le)):Vt.setValue($,"projectionMatrix",N.projectionMatrix),Vt.setValue($,"viewMatrix",N.matrixWorldInverse);const Vn=Vt.map.cameraPosition;Vn!==void 0&&Vn.setValue($,Fe.setFromMatrixPosition(N.matrixWorld)),oe.logarithmicDepthBuffer&&Vt.setValue($,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&Vt.setValue($,"isOrthographic",N.isOrthographicCamera===!0),E!==N&&(E=N,pn=!0,jt=!0)}if(ae.isSkinnedMesh){Vt.setOptional($,ae,"bindMatrix"),Vt.setOptional($,ae,"bindMatrixInverse");const On=ae.skeleton;On&&(On.boneTexture===null&&On.computeBoneTexture(),Vt.setValue($,"boneTexture",On.boneTexture,j))}ae.isBatchedMesh&&(Vt.setOptional($,ae,"batchingTexture"),Vt.setValue($,"batchingTexture",ae._matricesTexture,j),Vt.setOptional($,ae,"batchingIdTexture"),Vt.setValue($,"batchingIdTexture",ae._indirectTexture,j),Vt.setOptional($,ae,"batchingColorTexture"),ae._colorsTexture!==null&&Vt.setValue($,"batchingColorTexture",ae._colorsTexture,j));const ri=se.morphAttributes;if((ri.position!==void 0||ri.normal!==void 0||ri.color!==void 0)&&Ze.update(ae,se,vn),(pn||wt.receiveShadow!==ae.receiveShadow)&&(wt.receiveShadow=ae.receiveShadow,Vt.setValue($,"receiveShadow",ae.receiveShadow)),ne.isMeshGouraudMaterial&&ne.envMap!==null&&(Xn.envMap.value=He,Xn.flipEnvMap.value=He.isCubeTexture&&He.isRenderTargetTexture===!1?-1:1),ne.isMeshStandardMaterial&&ne.envMap===null&&ie.environment!==null&&(Xn.envMapIntensity.value=ie.environmentIntensity),pn&&(Vt.setValue($,"toneMappingExposure",x.toneMappingExposure),wt.needsLights&&fn(Xn,jt),we&&ne.fog===!0&&Ae.refreshFogUniforms(Xn,we),Ae.refreshMaterialUniforms(Xn,ne,W,G,_.state.transmissionRenderTarget[N.id]),j0.upload($,Sn(wt),Xn,j)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(j0.upload($,Sn(wt),Xn,j),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&Vt.setValue($,"center",ae.center),Vt.setValue($,"modelViewMatrix",ae.modelViewMatrix),Vt.setValue($,"normalMatrix",ae.normalMatrix),Vt.setValue($,"modelMatrix",ae.matrixWorld),ne.isShaderMaterial||ne.isRawShaderMaterial){const On=ne.uniformsGroups;for(let Vn=0,lr=On.length;Vn0&&j.useMultisampledRTT(N)===!1?ae=Oe.get(N).__webglMultisampledFramebuffer:Array.isArray(Ke)?ae=Ke[se]:ae=Ke,I.copy(N.viewport),R.copy(N.scissor),U=N.scissorTest}else I.copy(B).multiplyScalar(W).floor(),R.copy(J).multiplyScalar(W).floor(),U=re;if(se!==0&&(ae=F),Te.bindFramebuffer($.FRAMEBUFFER,ae)&&ne&&Te.drawBuffers(N,ae),Te.viewport(I),Te.scissor(R),Te.setScissorTest(U),we){const He=Oe.get(N.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+ie,He.__webglTexture,se)}else if(Pe){const He=Oe.get(N.texture),qe=ie;$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,He.__webglTexture,se,qe)}else if(N!==null&&se!==0){const He=Oe.get(N.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,He.__webglTexture,se)}P=-1},this.readRenderTargetPixels=function(N,ie,se,ne,ae,we,Pe){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Re=Oe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Pe!==void 0&&(Re=Re[Pe]),Re){Te.bindFramebuffer($.FRAMEBUFFER,Re);try{const He=N.texture,qe=He.format,Ke=He.type;if(!oe.textureFormatReadable(qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!oe.textureTypeReadable(Ke)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ie>=0&&ie<=N.width-ne&&se>=0&&se<=N.height-ae&&$.readPixels(ie,se,ne,ae,tt.convert(qe),tt.convert(Ke),we)}finally{const He=A!==null?Oe.get(A).__webglFramebuffer:null;Te.bindFramebuffer($.FRAMEBUFFER,He)}}},this.readRenderTargetPixelsAsync=async function(N,ie,se,ne,ae,we,Pe){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Re=Oe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Pe!==void 0&&(Re=Re[Pe]),Re){const He=N.texture,qe=He.format,Ke=He.type;if(!oe.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!oe.textureTypeReadable(Ke))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(ie>=0&&ie<=N.width-ne&&se>=0&&se<=N.height-ae){Te.bindFramebuffer($.FRAMEBUFFER,Re);const Je=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,Je),$.bufferData($.PIXEL_PACK_BUFFER,we.byteLength,$.STREAM_READ),$.readPixels(ie,se,ne,ae,tt.convert(qe),tt.convert(Ke),0);const et=A!==null?Oe.get(A).__webglFramebuffer:null;Te.bindFramebuffer($.FRAMEBUFFER,et);const st=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await jN($,st,4),$.bindBuffer($.PIXEL_PACK_BUFFER,Je),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,we),$.deleteBuffer(Je),$.deleteSync(st),we}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,ie=null,se=0){N.isTexture!==!0&&(Fc("WebGLRenderer: copyFramebufferToTexture function signature has changed."),ie=arguments[0]||null,N=arguments[1]);const ne=Math.pow(2,-se),ae=Math.floor(N.image.width*ne),we=Math.floor(N.image.height*ne),Pe=ie!==null?ie.x:0,Re=ie!==null?ie.y:0;j.setTexture2D(N,0),$.copyTexSubImage2D($.TEXTURE_2D,se,0,0,Pe,Re,ae,we),Te.unbindTexture()};const ee=$.createFramebuffer(),de=$.createFramebuffer();this.copyTextureToTexture=function(N,ie,se=null,ne=null,ae=0,we=null){N.isTexture!==!0&&(Fc("WebGLRenderer: copyTextureToTexture function signature has changed."),ne=arguments[0]||null,N=arguments[1],ie=arguments[2],we=arguments[3]||0,se=null),we===null&&(ae!==0?(Fc("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),we=ae,ae=0):we=0);let Pe,Re,He,qe,Ke,Je,et,st,Dt;const kt=N.isCompressedTexture?N.mipmaps[we]:N.image;if(se!==null)Pe=se.max.x-se.min.x,Re=se.max.y-se.min.y,He=se.isBox3?se.max.z-se.min.z:1,qe=se.min.x,Ke=se.min.y,Je=se.isBox3?se.min.z:0;else{const ri=Math.pow(2,-ae);Pe=Math.floor(kt.width*ri),Re=Math.floor(kt.height*ri),N.isDataArrayTexture?He=kt.depth:N.isData3DTexture?He=Math.floor(kt.depth*ri):He=1,qe=0,Ke=0,Je=0}ne!==null?(et=ne.x,st=ne.y,Dt=ne.z):(et=0,st=0,Dt=0);const Ot=tt.convert(ie.format),wt=tt.convert(ie.type);let Yt;ie.isData3DTexture?(j.setTexture3D(ie,0),Yt=$.TEXTURE_3D):ie.isDataArrayTexture||ie.isCompressedArrayTexture?(j.setTexture2DArray(ie,0),Yt=$.TEXTURE_2D_ARRAY):(j.setTexture2D(ie,0),Yt=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,ie.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ie.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,ie.unpackAlignment);const St=$.getParameter($.UNPACK_ROW_LENGTH),vn=$.getParameter($.UNPACK_IMAGE_HEIGHT),ui=$.getParameter($.UNPACK_SKIP_PIXELS),pn=$.getParameter($.UNPACK_SKIP_ROWS),jt=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,kt.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,kt.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,qe),$.pixelStorei($.UNPACK_SKIP_ROWS,Ke),$.pixelStorei($.UNPACK_SKIP_IMAGES,Je);const Vt=N.isDataArrayTexture||N.isData3DTexture,Xn=ie.isDataArrayTexture||ie.isData3DTexture;if(N.isDepthTexture){const ri=Oe.get(N),On=Oe.get(ie),Vn=Oe.get(ri.__renderTarget),lr=Oe.get(On.__renderTarget);Te.bindFramebuffer($.READ_FRAMEBUFFER,Vn.__webglFramebuffer),Te.bindFramebuffer($.DRAW_FRAMEBUFFER,lr.__webglFramebuffer);for(let cr=0;cr{if(s===e)return!0;if(!s||!e)return!1;const t=s.length;if(e.length!==t)return!1;for(let i=0;i{const s=[],i={items:s,remember:(n,r)=>{for(let a=0;a{for(let r=0;r{const s=nr("threlte-cache");if(!s)throw new Error("No cache found. The cache can only be used in a child component to .");return s},uR=Symbol(),fH=s=>typeof(s==null?void 0:s.subscribe)=="function",hR=(s,e,t)=>{const i=s().map(o=>fH(o)?cf(o):uR),n=xt(()=>s().map((o,a)=>i[a]===uR?o:i[a].current)),r=()=>{fe(n);let o;return ws(()=>{o=e(fe(n))}),o};t?$e(r):Ht(r)},Gs=Object.assign((s,e)=>hR(s,e,!1),{pre:(s,e)=>hR(s,e,!0)}),wn=(s,e)=>(s==null?void 0:s[`is${e}`])===!0,uu=s=>{const e=Hn(void 0),t=Hn(void 0);return s.then(i=>{e.set(i)}).catch(i=>{console.error("Error in asyncWritable:",i.message),t.set(i)}),Object.assign(Object.assign(s,e),{error:t,promise:s})},pH=typeof window<"u",mH=_h.replace("dev",""),dR=Number.parseInt(mH),pi=(s,e)=>{const t=Ha(s,r=>r);let i;const n=t.subscribe(async r=>{i&&i();const o=await e(r);o&&(i=o)});Ui(()=>{n(),i&&i()})},Yn=s=>{const e=Hn(s),t={set:i=>{t.current=i,e.set(i)},subscribe:e.subscribe,update:i=>{const n=i(t.current);t.current=n,e.set(n)},current:s};return t},gH=s=>({subscribe:s.subscribe,get current(){return s.current}}),fR=(s,e)=>{if(e.includes(".")){const t=e.split("."),i=t.pop();for(let n=0;n{const{dom:e,canvas:t}=s,i=Yn({width:e.offsetWidth,height:e.offsetHeight});Gr(()=>{const r=new ResizeObserver(()=>{const{offsetWidth:o,offsetHeight:a}=e;(i.current.width!==o||i.current.height!==a)&&i.set({width:o,height:a})});return r.observe(e),()=>{r.disconnect()}});const n={dom:e,canvas:t,size:gH(i)};return ur("threlte-dom-context",n),n},ew=()=>{const s=nr("threlte-dom-context");if(!s)throw new Error("useDOM can only be used in a child component to .");return s};function vH(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}class wl{constructor(){ht(this,"allVertices",{});ht(this,"isolatedVertices",{});ht(this,"connectedVertices",{});ht(this,"sortedConnectedValues",[]);ht(this,"needsSort",!1);ht(this,"emitter",vH());ht(this,"emit",this.emitter.emit.bind(this.emitter));ht(this,"on",this.emitter.on.bind(this.emitter));ht(this,"off",this.emitter.off.bind(this.emitter));ht(this,"getKey",e=>typeof e=="object"?e.key:e)}get sortedVertices(){return this.mapNodes(e=>e)}moveToIsolated(e){const t=this.connectedVertices[e];t&&(this.isolatedVertices[e]=t,delete this.connectedVertices[e])}moveToConnected(e){const t=this.isolatedVertices[e];t&&(this.connectedVertices[e]=t,delete this.isolatedVertices[e])}add(e,t,i){if(this.allVertices[e]&&this.allVertices[e].value!==void 0)throw new Error(`A node with the key ${e.toString()} already exists`);let n=this.allVertices[e];n?n.value===void 0&&(n.value=t):(n={value:t,previous:new Set,next:new Set},this.allVertices[e]=n);const r=n.next.size>0||n.previous.size>0;if(!(i!=null&&i.after)&&!(i!=null&&i.before)&&!r){this.isolatedVertices[e]=n,this.emit("node:added",{key:e,type:"isolated",value:t});return}else this.connectedVertices[e]=n;if(i!=null&&i.after){const o=Array.isArray(i.after)?i.after:[i.after];o.forEach(a=>{n.previous.add(this.getKey(a))}),o.forEach(a=>{const l=this.getKey(a),c=this.allVertices[l];c?(c.next.add(e),this.moveToConnected(l)):(this.allVertices[l]={value:void 0,previous:new Set,next:new Set([e])},this.connectedVertices[l]=this.allVertices[l])})}if(i!=null&&i.before){const o=Array.isArray(i.before)?i.before:[i.before];o.forEach(a=>{n.next.add(this.getKey(a))}),o.forEach(a=>{const l=this.getKey(a),c=this.allVertices[l];c?(c.previous.add(e),this.moveToConnected(l)):(this.allVertices[l]={value:void 0,previous:new Set([e]),next:new Set},this.connectedVertices[l]=this.allVertices[l])})}this.emit("node:added",{key:e,type:"connected",value:t}),this.needsSort=!0}remove(e){const t=this.getKey(e);if(this.isolatedVertices[t]){delete this.isolatedVertices[t],delete this.allVertices[t],this.emit("node:removed",{key:t,type:"isolated"});return}const n=this.connectedVertices[t];n&&(n.next.forEach(r=>{const o=this.connectedVertices[r];o&&(o.previous.delete(t),o.previous.size===0&&o.next.size===0&&this.moveToIsolated(r))}),n.previous.forEach(r=>{const o=this.connectedVertices[r];o&&(o.next.delete(t),o.previous.size===0&&o.next.size===0&&this.moveToIsolated(r))}),delete this.connectedVertices[t],delete this.allVertices[t],this.emit("node:removed",{key:t,type:"connected"}),this.needsSort=!0)}mapNodes(e){this.needsSort&&this.sort();const t=[];return this.forEachNode((i,n)=>{t.push(e(i,n))}),t}forEachNode(e){this.needsSort&&this.sort();let t=0;for(;t{const n=this.isolatedVertices[i];n.value!==void 0&&e(n.value,t++)})}getValueByKey(e){var t;return(t=this.allVertices[e])==null?void 0:t.value}getKeyByValue(e){return Reflect.ownKeys(this.connectedVertices).find(t=>this.connectedVertices[t].value===e)??Reflect.ownKeys(this.isolatedVertices).find(t=>this.isolatedVertices[t].value===e)}sort(){var o;const e=new Map,t=[],i=[],n=Reflect.ownKeys(this.connectedVertices).filter(a=>this.connectedVertices[a].value!==void 0);for(n.forEach(a=>{e.set(a,0)}),n.forEach(a=>{this.connectedVertices[a].next.forEach(c=>{this.connectedVertices[c]&&e.set(c,(e.get(c)||0)+1)})}),e.forEach((a,l)=>{a===0&&t.push(l)});t.length>0;){const a=t.shift();i.push(a);const l=n.find(c=>c===a);l&&((o=this.connectedVertices[l])==null||o.next.forEach(c=>{const u=(e.get(c)||0)-1;e.set(c,u),u===0&&t.push(c)}))}if(i.length!==n.length)throw new Error("The graph contains a cycle, and thus can not be sorted topologically.");const r=a=>a!==void 0;this.sortedConnectedValues=i.map(a=>this.connectedVertices[a].value).filter(r),this.needsSort=!1}clear(){this.allVertices={},this.isolatedVertices={},this.connectedVertices={},this.sortedConnectedValues=[],this.needsSort=!1}static isKey(e){return typeof e=="string"||typeof e=="symbol"}static isValue(e){return typeof e=="object"&&"key"in e}}class _H{constructor(e,t,i){ht(this,"key");ht(this,"stage");ht(this,"callback");ht(this,"runTask",!0);this.stage=e,this.key=t,this.callback=i}stop(){this.runTask=!1}start(){this.runTask=!0}run(e){this.runTask&&this.callback(e)}}class yH extends wl{constructor(t,i,n){super();ht(this,"key");ht(this,"scheduler");ht(this,"runTask",!0);ht(this,"callback",(t,i)=>i());ht(this,"removeTask",this.remove.bind(this));this.scheduler=t,this.key=i,this.start=this.start.bind(this),this.stop=this.stop.bind(this),n&&(this.callback=n.bind(this))}stop(){this.runTask=!1}start(){this.runTask=!0}get tasks(){return this.sortedVertices}createTask(t,i,n){const r=new _H(this,t,i);return this.add(t,r,n),r}getTask(t){return this.getValueByKey(t)}run(t){this.runTask&&this.callback(t,i=>{this.forEachNode(n=>{n.run(i??t)})})}runWithTiming(t){if(!this.runTask)return{};const i={};return this.callback(t,n=>{this.forEachNode(r=>{const o=performance.now();r.run(n??t);const a=performance.now()-o;i[r.key]=a})}),i}getSchedule(){return this.mapNodes(t=>t.key.toString())}}class xH extends wl{constructor(t){super();ht(this,"lastTime",performance.now());ht(this,"clampDeltaTo",.1);ht(this,"removeStage",this.remove.bind(this));t!=null&&t.clampDeltaTo&&(this.clampDeltaTo=t.clampDeltaTo),this.run=this.run.bind(this)}get stages(){return this.sortedVertices}createStage(t,i){const n=new yH(this,t,i==null?void 0:i.callback);return this.add(t,n,{after:i==null?void 0:i.after,before:i==null?void 0:i.before}),n}getStage(t){return this.getValueByKey(t)}run(t){const i=t-this.lastTime;this.forEachNode(n=>{n.run(Math.min(i/1e3,this.clampDeltaTo))}),this.lastTime=t}runWithTiming(t){const i=t-this.lastTime,n={},r=performance.now();return this.forEachNode(o=>{const a=performance.now(),l=o.runWithTiming(Math.min(i/1e3,this.clampDeltaTo)),c=performance.now()-a;n[o.key.toString()]={duration:c,tasks:l}}),{total:performance.now()-r,stages:n}}getSchedule(t={tasks:!0}){return{stages:this.mapNodes(i=>{if(i===void 0)throw new Error("Stage not found");return{key:i.key.toString(),tasks:t.tasks?i.getSchedule():void 0}})}}dispose(){this.clear()}}const bH=s=>{const e=new xH,t=e.createStage(Symbol("threlte-main-stage")),i={scheduler:e,frameInvalidated:!0,autoInvalidations:new Set,shouldAdvance:!1,advance:()=>{i.shouldAdvance=!0},autoRender:Yn(s.autoRender??!0),renderMode:Yn(s.renderMode??"on-demand"),invalidate(){i.frameInvalidated=!0},mainStage:t,shouldRender:()=>i.renderMode.current==="always"||i.renderMode.current==="on-demand"&&(i.frameInvalidated||i.autoInvalidations.size>0)||i.renderMode.current==="manual"&&i.shouldAdvance,renderStage:e.createStage(Symbol("threlte-render-stage"),{after:t,callback(n,r){i.shouldRender()&&r()}}),resetFrameInvalidation(){i.frameInvalidated=!1,i.shouldAdvance=!1}};return Ht(()=>{i.autoRender.set(s.autoRender??!0)}),Ht(()=>{i.renderMode.set(s.renderMode??"on-demand")}),Ui(()=>{i.scheduler.dispose()}),ur("threlte-scheduler-context",i),i},Z0=()=>{const s=nr("threlte-scheduler-context");if(!s)throw new Error("useScheduler can only be used in a child component to .");return s},tw=()=>{const{size:s}=ew(),{invalidate:e}=Z0(),t=new zi(75,0,.1,1e3);t.position.z=5,t.lookAt(0,0,0);const i=Yn(t);pi(s,r=>{if(i.current===t){const o=i.current;o.aspect=r.width/r.height,o.updateProjectionMatrix(),e()}});const n={camera:i};return ur("threlte-camera-context",n),n},mR=()=>{const s=nr("threlte-camera-context");if(!s)throw new Error("useCamera can only be used in a child component to .");return s},wH=()=>{const s={removeObjectFromDisposal:e=>{s.disposableObjects.delete(e)},disposableObjectMounted:e=>{const t=s.disposableObjects.get(e);t?s.disposableObjects.set(e,t+1):s.disposableObjects.set(e,1)},disposableObjectUnmounted:e=>{const t=s.disposableObjects.get(e);t&&t>0&&(s.disposableObjects.set(e,t-1),t-1<=0&&(s.shouldDispose=!0))},disposableObjects:new Map,shouldDispose:!1,dispose:async(e=!1)=>{await Py(),!(!s.shouldDispose&&!e)&&(s.disposableObjects.forEach((t,i)=>{var n;(t===0||e)&&((n=i==null?void 0:i.dispose)==null||n.call(i),s.disposableObjects.delete(i))}),s.shouldDispose=!1)}};return Ui(()=>{s.dispose(!0)}),ur("threlte-disposal-context",s),s},gR=()=>{const s=nr("threlte-disposal-context");if(!s)throw new Error("useDisposal can only be used in a child component to .");return s},vR=Symbol("threlte-parent-context"),nw=s=>{const e=Yn(s);return ur(vR,e),e},To=()=>nr(vR),K0=Symbol("threlte-parent-object3d-context"),SH=s=>{const e=Yd(s);return ur(K0,e),e},_R=s=>{const e=nr(K0),t=Hn(s),i=Ha([t,e],([n,r])=>n??r);return ur(K0,i),t},yR=()=>nr(K0);function ii(s,e,t){if(!pH)return{task:void 0,start:()=>{},stop:()=>{},started:Yd(!1)};let i,n,r;wl.isKey(s)?(i=s,n=e,r=t):(i=Symbol("useTask"),n=s,r=e);const o=Z0();let a=o.mainStage;if(r){if(r.stage)if(wl.isValue(r.stage))a=r.stage;else{const d=o.scheduler.getStage(r.stage);if(!d)throw new Error(`No stage found with key ${r.stage.toString()}`);a=d}else if(r.after)if(Array.isArray(r.after))for(let d=0;d{l.set(!0),((r==null?void 0:r.autoInvalidate)??!0)&&o.autoInvalidations.add(n),c.start()},h=()=>{l.set(!1),((r==null?void 0:r.autoInvalidate)??!0)&&o.autoInvalidations.delete(n),c.stop()};return(r==null?void 0:r.autoStart)??!0?u():h(),Ui(()=>{h(),a.removeTask(i)}),{task:c,start:u,stop:h,started:{subscribe:l.subscribe}}}const $0=s=>{const e={scene:new Kf};return ur("threlte-scene-context",e),e},xR=()=>{const s=nr("threlte-scene-context");if(!s)throw new Error("useScene can only be used in a child component to .");return s},MH=s=>{const{dispose:e}=gR(),{camera:t}=mR(),{scene:i}=xR(),{invalidate:n,renderStage:r,autoRender:o,scheduler:a,resetFrameInvalidation:l}=Z0(),{size:c,canvas:u}=ew(),h=s.createRenderer?s.createRenderer(u):new J1({canvas:u,powerPreference:"high-performance",antialias:!0,alpha:!0}),d=r.createTask(Symbol("threlte-auto-render-task"),()=>{h.render(i,t.current)}),f={renderer:h,colorManagementEnabled:Yn(s.colorManagementEnabled??!0),colorSpace:Yn(s.colorSpace??"srgb"),dpr:Yn(s.dpr??window.devicePixelRatio),shadows:Yn(s.shadows??Cf),toneMapping:Yn(s.toneMapping??Og),autoRenderTask:d};ur("threlte-renderer-context",f),pi([f.colorManagementEnabled],([g])=>{mn.enabled=g}),pi([f.colorSpace],([g])=>{"outputColorSpace"in h&&(h.outputColorSpace=g)}),pi([f.dpr],([g])=>{"setPixelRatio"in h&&h.setPixelRatio(g)});const{start:m,stop:v}=ii(()=>{var g;!("xr"in h)||(g=h.xr)!=null&&g.isPresenting||(h.setSize(c.current.width,c.current.height),n(),v())},{before:d,autoStart:!1,autoInvalidate:!1});return pi([c],()=>{m()}),pi([f.shadows],([g])=>{"shadowMap"in h&&(h.shadowMap.enabled=!!g,g&&g!==!0?h.shadowMap.type=g:g===!0&&(h.shadowMap.type=Cf))}),pi([f.toneMapping],([g])=>{"toneMapping"in h&&(h.toneMapping=g)}),pi([o],([g])=>(g?f.autoRenderTask.start():f.autoRenderTask.stop(),()=>{f.autoRenderTask.stop()})),"setAnimationLoop"in f.renderer&&f.renderer.setAnimationLoop(_=>{e(),a.run(_),l()}),Ui(()=>{if("dispose"in f.renderer){const g=f.renderer.dispose;g()}}),Ht(()=>{f.colorManagementEnabled.set(s.colorManagementEnabled??!0)}),Ht(()=>{f.colorSpace.set(s.colorSpace??"srgb")}),Ht(()=>{f.toneMapping.set(s.toneMapping??Og)}),Ht(()=>{f.shadows.set(s.shadows??Cf)}),Ht(()=>{f.dpr.set(s.dpr??window.devicePixelRatio)}),f},EH=()=>{const s=nr("threlte-renderer-context");if(!s)throw new Error("useRenderer can only be used in a child component to .");return s},bR=()=>{const s=Yn({});return ur("threlte-user-context",s),s},TH=()=>{const s=nr("threlte-user-context");if(!s)throw new Error("useUserContext can only be used in a child component to .");return s},AH=s=>{const{scene:e}=$0();return{scene:e,...pR(s),...cR(),...nw(e),...SH(e),...wH(),...bH(s),...tw(),...MH(s),...bR()}};function iw(s,e){if(new.target)return Tt({component:iw,...s});Mt(e,!0);let t=H(e,"children",7);AH(an(e,["$$slots","$$events","$$legacy","$$host","children"]));var n=Lt(),r=dt(n);return Wt(r,t),lt(s,n),Et({get children(){return t()},set children(o){t(o),V()},$set:Ct,$on:(o,a)=>At(e,o,a)})}Pt(iw,{children:{}},[],[],!0);var CH=Kn('
');const PH={hash:"svelte-1osucwe",code:"div.svelte-1osucwe {position:relative;width:100%;height:100%;}canvas.svelte-1osucwe {display:block;position:relative;width:100%;height:100%;}"};function rw(s,e){if(new.target)return Tt({component:rw,...s});Mt(e,!0),mk(s,PH);let t=H(e,"children",7),i=an(e,["$$slots","$$events","$$legacy","$$host","children"]),n=xs(void 0),r=xs(void 0);var o=CH(),a=$l(o),l=$l(a);{var c=u=>{iw(u,rn({get dom(){return fe(r)},get canvas(){return fe(n)}},()=>i,{children:(h,d)=>{var f=Lt(),m=dt(f);Wt(m,()=>t()??Nt),lt(h,f)},$$slots:{default:!0}}))};wi(l,u=>{fe(n)&&fe(r)&&u(c)})}return ql(a),qu(a,u=>Mn(n,u),()=>fe(n)),ql(o),qu(o,u=>Mn(r,u),()=>fe(r)),lt(s,o),Et({get children(){return t()},set children(u){t(u),V()},$set:Ct,$on:(u,h)=>At(e,u,h)})}Pt(rw,{children:{}},[],[],!0);const un=()=>{const s=Z0(),e=EH(),t=mR(),i=xR(),n=ew();return{advance:s.advance,autoRender:s.autoRender,autoRenderTask:e.autoRenderTask,camera:t.camera,colorManagementEnabled:e.colorManagementEnabled,colorSpace:e.colorSpace,dpr:e.dpr,invalidate:s.invalidate,mainStage:s.mainStage,renderer:e.renderer,renderMode:s.renderMode,renderStage:s.renderStage,scheduler:s.scheduler,shadows:e.shadows,shouldRender:s.shouldRender,dom:n.dom,canvas:n.canvas,size:n.size,toneMapping:e.toneMapping,get scene(){return i.scene},set scene(o){i.scene=o}}},RH=s=>typeof s=="object"&&s!==null,DH=()=>{const{invalidate:s}=un();let e;const t=Hn(),i=To(),n=yR(),r=nw(),o=_R();pi([t,r,i,n],([c,u,h,d])=>{if(e==null||e(),e=void 0,!u){s();return}if(c!==void 0){if(c){if(typeof c=="function")e=c({ref:u,parent:h,parentObject3D:d});else if(wn(c,"Object3D")&&wn(u,"Object3D"))e=()=>c==null?void 0:c.remove(u),c==null||c.add(u);else if(typeof c=="string"){const{target:f,key:m}=fR(h,c),v=f[m];e=()=>f[m]=v,f[m]=u}}}else wn(u,"Object3D")?(e=()=>d==null?void 0:d.remove(u),d==null||d.add(u)):RH(h)&&(wn(u,"Material")?h.material=u:wn(u,"BufferGeometry")&&(h.geometry=u));s()});const a=c=>{t.set(c)},l=c=>{r.set(c),wn(c,"Object3D")&&o.set(c)};return Ui(()=>{e==null||e(),s()}),{updateRef:l,updateAttach:a}},IH=s=>wn(s,"PerspectiveCamera")||wn(s,"OrthographicCamera"),LH=()=>{const{invalidate:s,size:e,camera:t}=un(),i=Hn(),n=Hn(!0),r=Hn(!1);return pi([i,r],([c,u])=>{!c||!u||(t.set(c),s())}),pi([i,n,e],([c,u,h])=>{!c||u||(wn(c,"OrthographicCamera")?(c.left=h.width/-2,c.right=h.width/2,c.top=h.height/2,c.bottom=h.height/-2,c.updateProjectionMatrix(),c.updateMatrixWorld(),s()):wn(c,"PerspectiveCamera")&&(c.aspect=h.width/h.height,c.updateProjectionMatrix(),c.updateMatrixWorld(),s()))}),{updateRef:c=>{IH(c)&&i.set(c)},updateManual:c=>{n.set(c)},updateMakeDefault:c=>{r.set(c)}}},UH=s=>{let e,t,i=!1;const n=()=>{e==null||e(),e=s==null?void 0:s(t)},r=o=>{t=o,i&&n()};return Gr(()=>{n(),i=!0}),Ui(()=>e==null?void 0:e()),{updateRef:r}},wR=Symbol("threlte-disposable-object-context"),kH=s=>typeof(s==null?void 0:s.dispose)=="function"&&!wn(s,"Scene"),OH=s=>{let e;const t=Hn(void 0),i=Hn(s),{disposableObjectMounted:n,disposableObjectUnmounted:r,removeObjectFromDisposal:o}=gR(),a=nr(wR),l=Ha([i,a??Hn(!0)],([h,d])=>h??d??!0);return ur(wR,l),pi([t,l],([h,d])=>{h===e?d?e&&n(e):e&&o(e):d&&(e&&r(e),h&&n(h)),e=h}),Ui(()=>{if(!km(l))return;const h=km(t);h&&r(h)}),{updateRef:h=>{kH(h)&&t.set(h)},updateDispose:h=>{i.set(h)}}},FH=s=>s!==null&&typeof s=="object"&&"addEventListener"in s&&"removeEventListener"in s,NH=(s={})=>{const e=n=>{var r;n!=null&&n.type&&((r=s[`on${n.type}`])==null||r.call(s,n))},t=(n,r)=>{const o=[];for(const a of Object.keys(r))a.startsWith("on")&&(n.addEventListener(a.slice(2),e),o.push(a));return()=>{for(let a=0;a{if(FH(n))return t(n,s)}}};let sw;const BH=s=>{sw=s},SR=()=>{const s=sw;return sw=void 0,s},zH=s=>{const t=nr("threlte-plugin-context");if(!t)return;const i=[],n=Object.values(t);if(n.length){const r=s();for(let o=0;otypeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s>"u"||s===null,MR=(s,e,t)=>{var i,n,r;return!Array.isArray(t)&&typeof t=="number"&&typeof((i=s[e])==null?void 0:i.setScalar)=="function"&&!((n=s[e])!=null&&n.isColor)?(o,a,l)=>{o[a].setScalar(l)}:typeof((r=s[e])==null?void 0:r.set)=="function"?Array.isArray(t)?(o,a,l)=>{o[a].set(...l)}:(o,a,l)=>{o[a].set(l)}:(o,a,l)=>{o[a]=l}},WH=()=>{const{invalidate:s}=un(),e=new Map,t=new Map,i=(r,o,a,l)=>{if(HH(a)){const h=e.get(o);if(h&&h.instance===r&&h.value===a)return;e.set(o,{instance:r,value:a})}const{key:c,target:u}=fR(r,o);if(a!=null){const h=t.get(o);if(h)h(u,c,a);else{const d=MR(u,c,a);t.set(o,d),d(u,c,a)}}else MR(u,c,a)(u,c,a);l.manualCamera||GH.has(c)&&(u.isPerspectiveCamera||u.isOrthographicCamera)&&u.updateProjectionMatrix()};return{updateProp:(r,o,a,l)=>{var c;!VH.has(o)&&!((c=l.pluginsProps)!=null&&c.includes(o))&&i(r,o,a,l),s()}}},XH=/^\s*class\s+/,YH=s=>typeof s!="function"?!1:XH.test(s.toString()),jH=s=>Array.isArray(s),qH=(s,e)=>YH(s)?jH(e)?new s(...e):new s:s;function xp(s,e){if(new.target)return Tt({component:xp,...s});Mt(e,!0);let t=H(e,"is",23,SR),i=H(e,"args",7),n=H(e,"attach",7),r=H(e,"manual",7,!1),o=H(e,"makeDefault",7,!1),a=H(e,"dispose",7),l=H(e,"ref",15),c=H(e,"oncreate",7),u=H(e,"children",7),h=an(e,["$$slots","$$events","$$legacy","$$host","is","args","attach","manual","makeDefault","dispose","ref","oncreate","children"]),d=xt(()=>qH(t(),i()));const f=UH(c());$e(()=>{l()!==fe(d)&&(l(fe(d)),f.updateRef(fe(d)))});const m=zH(()=>({get ref(){return fe(d)},get args(){return i()},get attach(){return n()},get manual(){return r()},get makeDefault(){return o()},get dispose(){return a()},get props(){return h}})),{updateProp:v}=WH();Object.keys(h).forEach(C=>{$e(()=>{v(fe(d),C,h[C],{manualCamera:r(),pluginsProps:m==null?void 0:m.pluginsProps})})});const g=DH();$e(()=>g.updateAttach(n())),$e(()=>g.updateRef(fe(d)));const _=LH();$e(()=>_.updateRef(fe(d))),$e(()=>_.updateManual(r())),$e(()=>_.updateMakeDefault(o()));const y=OH(a());$e(()=>y.updateRef(fe(d))),$e(()=>y.updateDispose(a()));const w=NH(h);$e(()=>w.updateRef(fe(d)));var x=Lt(),M=dt(x);return Wt(M,()=>u()??Nt,()=>({ref:fe(d)})),lt(s,x),Et({get is(){return t()},set is(C=SR()){t(C),V()},get args(){return i()},set args(C){i(C),V()},get attach(){return n()},set attach(C){n(C),V()},get manual(){return r()},set manual(C=!1){r(C),V()},get makeDefault(){return o()},set makeDefault(C=!1){o(C),V()},get dispose(){return a()},set dispose(C){a(C),V()},get ref(){return l()},set ref(C){l(C),V()},get oncreate(){return c()},set oncreate(C){c(C),V()},get children(){return u()},set children(C){u(C),V()},$set:Ct,$on:(C,T)=>At(e,C,T)})}Pt(xp,{is:{},args:{},attach:{},manual:{},makeDefault:{},dispose:{},ref:{},oncreate:{},children:{}},[],[],!0);const ZH={},pt=new Proxy(function(){},{apply(s,e,t){return xp(...t)},get(s,e){if(typeof e!="string")return xp;const t=ZH[e]||dH[e];if(t===void 0)throw new Error(`No Three.js module found for ${e}. Did you forget to extend the catalogue?`);return BH(t),xp}});function ow(s,e){const t="threlte-plugin-context";e&&ur(t,{...nr(t),[s]:e})}function hu(s,e){const{scheduler:t}=un();return t.getStage(s)??t.createStage(s,e)}function aw(s,e,t){const i=TH();if(!i)throw new Error("No user context store found, did you invoke this function outside of your main component?");return s?s&&!e?Ha(i,n=>n[s]):(i.update(n=>{if(s in n)return n;const r=typeof e=="function"?e():e;return n[s]=r,n}),i.current[s]):{subscribe:i.subscribe}}function bp(s,e){const{remember:t,clear:i}=Q1();let n;const r=()=>{var c;const l=new s(...(e==null?void 0:e.args)??[]);return(c=e==null?void 0:e.extend)==null||c.call(e,l),l};return{load:(l,c)=>{const u=async h=>{var d;if(n||(n=r()),"loadAsync"in n){const f=await n.loadAsync(h,c==null?void 0:c.onProgress);return((d=c==null?void 0:c.transform)==null?void 0:d.call(c,f))??f}else return new Promise((f,m)=>{n.load(h,v=>{var g;return f(((g=c==null?void 0:c.transform)==null?void 0:g.call(c,v))??v)},v=>{var g;return(g=c==null?void 0:c.onProgress)==null?void 0:g.call(c,v)},m)})};if(Array.isArray(l)){const h=l.map(f=>t(()=>u(f),[s,f]));return uu(Promise.all(h))}else if(typeof l=="string"){const h=t(()=>u(l),[s,l]);return uu(h)}else{const h=Object.values(l).map(f=>t(()=>u(f),[s,f]));return uu(Promise.all(h).then(f=>Object.fromEntries(Object.entries(l).map(([m],v)=>[m,f[v]]))))}},clear:l=>{Array.isArray(l)?l.forEach(c=>{i([s,c])}):typeof l=="string"?i([s,l]):Object.entries(l).forEach(([c,u])=>{i([s,c,u])})},loader:n}}function ER(s,e){if(e===S2)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===vv||e===Eb){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let l=0;lt&&l.add(I)}l.normalize(),m.setXYZ(_+M,l.x,l.y,l.z)}}return u.setAttribute("normal",m),u}class KH extends vr{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new t6(t)}),this.register(function(t){return new n6(t)}),this.register(function(t){return new h6(t)}),this.register(function(t){return new d6(t)}),this.register(function(t){return new f6(t)}),this.register(function(t){return new r6(t)}),this.register(function(t){return new s6(t)}),this.register(function(t){return new o6(t)}),this.register(function(t){return new a6(t)}),this.register(function(t){return new e6(t)}),this.register(function(t){return new l6(t)}),this.register(function(t){return new i6(t)}),this.register(function(t){return new u6(t)}),this.register(function(t){return new c6(t)}),this.register(function(t){return new JH(t)}),this.register(function(t){return new p6(t)}),this.register(function(t){return new m6(t)})}load(e,t,i,n){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=xl.extractUrlBase(e);o=xl.resolveURL(c,this.path)}else o=xl.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new gs(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(u){t(u),r.manager.itemEnd(e)},a)}catch(u){a(u)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){let r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===TR){try{o[gn.KHR_BINARY_GLTF]=new g6(e)}catch(h){n&&n(h);return}r=JSON.parse(o[gn.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new P6(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,n)}parseAsync(e,t){const i=this;return new Promise(function(n,r){i.parse(e,t,n,r)})}}function $H(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const gn={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class JH{constructor(e){this.parser=e,this.name=gn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class d6{constructor(e){this.parser=e,this.name=gn.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=n.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class f6{constructor(e){this.parser=e,this.name=gn.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=n.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class p6{constructor(e){this.name=gn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=n.byteOffset||0,c=n.byteLength||0,u=n.count,h=n.byteStride,d=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,d,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(f),u,h,d,n.mode,n.filter),f})})}else return null}}class m6{constructor(e){this.name=gn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=t.meshes[i.mesh];for(const c of n.primitives)if(c.mode!==ro.TRIANGLES&&c.mode!==ro.TRIANGLE_STRIP&&c.mode!==ro.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),h=u.isGroup?u.children:[u],d=c[0].count,f=[];for(const m of h){const v=new _t,g=new X,_=new Tn,y=new X(1,1,1),w=new Jh(m.geometry,m.material,d);for(let x=0;x0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const C6=new _t;class P6{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new $H,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);n=i&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||r&&o<98?this.textureLoader=new D0(this.options.manager):this.textureLoader=new cP(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new gs(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:i,userData:{}};return du(r,a,n),Aa(a,n),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let n=0,r=t.length;n{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())r(u,a.children[c])};return r(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i=2&&g.setY(P,C[T*l+1]),l>=3&&g.setZ(P,C[T*l+2]),l>=4&&g.setW(P,C[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,i){const n=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const d=(r.samplers||{})[o.sampler]||{};return u.magFilter=PR[d.magFilter]||bn,u.minFilter=PR[d.minFilter]||Fs,u.wrapS=RR[d.wrapS]||Os,u.wrapT=RR[d.wrapT]||Os,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==En&&u.minFilter!==bn,n.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=n.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(h){c=!0;const d=new Blob([h],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(h){return new Promise(function(d,f){let m=d;t.isImageBitmapLoader===!0&&(m=function(v){const g=new ni(v);g.needsUpdate=!0,d(g)}),t.load(xl.resolveURL(h,r.path),m,void 0,f)})}).then(function(h){return c===!0&&a.revokeObjectURL(l),Aa(h,o),h.userData.mimeType=o.mimeType||A6(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),h});return this.sourceCache[e]=u,u}assignTexture(e,t,i,n){const r=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),r.extensions[gn.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[gn.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[gn.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new o0,Ki.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new Vi,Ki.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(n||r||o){let a="ClonedMaterial:"+i.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),n&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return mp}loadMaterial(e){const t=this,i=this.json,n=this.extensions,r=i.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[gn.KHR_MATERIALS_UNLIT]){const h=n[gn.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),c.push(h.extendParams(a,r,t))}else{const h=r.pbrMetallicRoughness||{};if(a.color=new rt(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],Ii),a.opacity=d[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",h.baseColorTexture,Ni)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Ei);const u=r.alphaMode||hw.OPAQUE;if(u===hw.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===hw.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==Jn&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;a.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&o!==Jn&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==Jn){const h=r.emissiveFactor;a.emissive=new rt().setRGB(h[0],h[1],h[2],Ii)}return r.emissiveTexture!==void 0&&o!==Jn&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Ni)),Promise.all(c).then(function(){const h=new o(a);return r.name&&(h.name=r.name),Aa(h,r),t.associations.set(h,{materials:e}),r.extensions&&du(n,h,r),h})}createUniqueName(e){const t=An.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function r(a){return i[gn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return DR(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&E6(_,r),_.name=t.createUniqueName(r.name||"mesh_"+e),Aa(_,r),g.extensions&&du(n,_,g),t.assignFinalMaterial(_),h.push(_)}for(let f=0,m=h.length;f1?u=new Qn:c.length===1?u=c[0]:u=new tn,u!==c[0])for(let h=0,d=c.length;h{const h=new Map;for(const[d,f]of n.associations)(d instanceof Ki||d instanceof ni)&&h.set(d,f);return u.traverse(d=>{const f=n.associations.get(d);f!=null&&h.set(d,f)}),h};return n.associations=c(r),r})}_createAnimationTracks(e,t,i,n,r){const o=[],a=e.name?e.name:e.uuid,l=[];Sl[r.path]===Sl.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(a);let c;switch(Sl[r.path]){case Sl.weights:c=Kc;break;case Sl.rotation:c=$c;break;case Sl.position:case Sl.scale:c=Qc;break;default:switch(i.itemSize){case 1:c=Kc;break;case 2:case 3:default:c=Qc;break}break}const u=n.interpolation!==void 0?w6[n.interpolation]:Ah,h=this._getArrayFromAccessor(i);for(let d=0,f=l.length;d{const e={nodes:{},materials:{}};return s&&s.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e};function I6(s,e){const t=typeof s=="string"?e:s,i=bp(KH,{extend(o){t!=null&&t.dracoLoader&&o.setDRACOLoader(t.dracoLoader),t!=null&&t.meshoptDecoder&&o.setMeshoptDecoder(t.meshoptDecoder),t!=null&&t.ktx2Loader&&o.setKTX2Loader(t.ktx2Loader)}}),n=o=>i.load(o,{transform(a){return{...a,...D6(a.scene)}}}),r=typeof s=="string"?s:void 0;return r?n(r):{load:n}}const fu=s=>({subscribe:s.subscribe,get current(){return s.current}});let Sp=0;const pw=Yn(!1),J0=Yn(!1),mw=Yn(void 0),gw=Yn(0),vw=Yn(0),IR=Yn([]),_w=Yn(0),{onStart:yw,onLoad:xw,onError:bw}=eu;eu.onStart=(s,e,t)=>{yw==null||yw(s,e,t),J0.set(!0),mw.set(s),gw.set(e),vw.set(t);const i=(e-Sp)/(t-Sp);_w.set(i),i===1&&pw.set(!0)},eu.onLoad=()=>{xw==null||xw(),J0.set(!1)},eu.onError=s=>{bw==null||bw(s),IR.update(e=>[...e,s])},eu.onProgress=(s,e,t)=>{e===t&&(Sp=t),J0.set(!0),mw.set(s),gw.set(e),vw.set(t);const i=(e-Sp)/(t-Sp)||1;_w.set(i),i===1&&pw.set(!0)},fu(J0),fu(mw),fu(gw),fu(vw),fu(IR),fu(_w),fu(pw);const LR=(s,e)=>{const t=bp(D0,e),{renderer:i}=un();return t.load(s,{...e,transform:n=>{var r;return n.colorSpace=i.outputColorSpace,n.needsUpdate=!0,((r=e==null?void 0:e.transform)==null?void 0:r.call(e,n))??n}})};new X,new X,new X,new fi,new _t,new hl,new X;const UR=Symbol("THRELTE_SUSPENSE_CONTEXT_IDENTIFIER"),L6=s=>{const e=Yn(new Set),t=Yn(new Map),i=Hn(!1),n=()=>{e.current.size===0&&t.current.size===0&&i.set(!0)},r=Hn((s==null?void 0:s.final)??!1),o=f=>{e.update(m=>(m.add(f),m))},a=f=>{e.update(m=>(m.delete(f),m))},l=(f,m)=>{t.update(v=>(v.set(f,m),v))},c=f=>{t.update(m=>(m.delete(f),m))},u=Ha([e,t,r,i],([f,m,v,g])=>v&&g?!1:m.size>0?!0:f.size>0),h={suspend(f){o(f),f.catch(m=>{l(f,m)}).finally(()=>{a(f),n()})},onComponentDestroy(f){a(f),c(f),n()},suspended:u},d=Ha(t,f=>Array.from(f.values()));return ur(UR,h),{promises:e,suspended:u,errors:d,setFinal:f=>r.set(f??!1)}},Ml=()=>{const s=nr(UR),e=new Set,t=n=>(s&&(s.suspend(n),e.add(n)),n),i={suspended:Ha((s==null?void 0:s.suspended)??Yd(!1),n=>n)};return Ui(()=>{if(s){for(const n of e)s.onComponentDestroy(n);e.clear()}}),Object.assign(t,i)};var U6=Kn(" ",1);function kR(s,e){if(new.target)return Tt({component:kR,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(R,"$parent",t);let r=H(e,"textureUrl",7),o=H(e,"dataUrl",7,""),a=H(e,"animation",7,""),l=H(e,"loop",7,!0),c=H(e,"autoplay",7,!0),u=H(e,"fps",7,10),h=H(e,"filter",7,"nearest"),d=H(e,"alphaTest",7,.1),f=H(e,"delay",7,0),m=H(e,"transparent",7,!0),v=H(e,"flipX",7,!1),g=H(e,"startFrame",7,0),_=H(e,"endFrame",7,void 0),y=H(e,"rows",7,1),w=H(e,"columns",7,void 0),x=H(e,"totalFrames",7,0),M=H(e,"is",15),C=H(e,"ref",15),T=H(e,"onload",7),A=H(e,"onstart",7),P=H(e,"onend",7),E=H(e,"onloop",7),I=an(e,["$$slots","$$events","$$legacy","$$host","textureUrl","dataUrl","animation","loop","autoplay","fps","filter","alphaTest","delay","transparent","flipX","startFrame","endFrame","rows","columns","totalFrames","is","ref","onload","onstart","onend","onloop"]);const R=To(),U=["forward","reverse"],L=te=>{const Se=U.includes(te);return Se||console.warn(`frame tag direction: "${te}" is not supported.${o()!=""?` source dataURL: ${o()}`:` texture URL: ${r()}`}`),Se};let k=0,z=g(),G=0,W=v()?-1:1,q=0,O=0,B=xs(void 0),J,re=[],K="forward",Q,ue={w:0,h:0},le=0,_e=xs(!1);$e(()=>{Mn(_e,hr(n()!==void 0&&wn(n(),"Mesh")))}),$e(()=>{le=1e3/u()}),M(M()??(fe(_e)?new Jn:new Gc));const Fe=Ml(),Ie=Fe(LR(r(),{transform:te=>(te.matrixAutoUpdate=!1,te.generateMipmaps=!1,te.premultiplyAlpha=!1,te.wrapS=te.wrapT=Os,te.magFilter=te.minFilter=h()==="nearest"?En:bn,te)})),Ee=Fe(o()?bp(gs).load(o(),{transform:te=>{if(typeof te=="string")try{return JSON.parse(te)}catch{return}}}):uu(new Promise(te=>{const Se=Ie.subscribe(ye=>{ye&&(Se(),te(me(ye)))})}))),me=te=>{const{width:Se,height:ye}=te.image,Ae=w()??x();G=x();const Ce=Se/Ae,Ge=ye/y(),De={frames:{},meta:{app:"",image:"",format:"",frameTags:[],version:"1.0",size:{w:Se,h:ye},scale:1}};for(let Ve=0;Ve{var Ve,ze;const Se=ue.w/q,ye=ue.h/O,Ae=1/Se,Ce=1/ye,Ge=W>0?Ae*(te.x/q):Ae*(te.x/O)-fe(B).repeat.x,De=Math.abs(1-Ce)-Ce*(te.y/O);(Ve=fe(B))==null||Ve.offset.set(Ge,De),(ze=fe(B))==null||ze.updateMatrix()},$=te=>{var Se;J&&(Q=J==null?void 0:J.meta.frameTags.find(ye=>ye.name===te),K="forward",Q!=null&&Q.direction&&(K=L(Q==null?void 0:Q.direction)?Q.direction:"forward"),z=K==="forward"?(Q==null?void 0:Q.from)??0:(Q==null?void 0:Q.to)??G-1,xe(J.frames[re[z]].frame),(Se=A())==null||Se())};let Ue=!1;const Me=async()=>{Ue=!0,await Promise.all([Ie,Ee]),Ue&&(k=performance.now()-f(),Te())},oe=()=>{Ue=!1,Ye()},{start:Te,stop:Ye}=ii(()=>{var ze,Ze;if(!J)return;const te=performance.now(),Se=te-k,ye=re[z],{frame:Ae,duration:Ce}=J.frames[ye],Ge=Ce??le;if(Se<=Ge)return;k=te-Se%Ge;const De=K==="forward"?(Q==null?void 0:Q.from)??g()??0:(Q==null?void 0:Q.to)??_()??G-1,Ve=K==="forward"?(Q==null?void 0:Q.to)??_()??G-1:(Q==null?void 0:Q.from)??g()??0;switch(xe(Ae),K){case"forward":z+=1;break;case"reverse":z-=1;break}(K==="forward"&&z>Ve||K==="reverse"&&z{var Ae;if(te===void 0||Se===void 0)return;Mn(B,hr(te.clone())),J=Se,re=Object.keys(J.frames),G=re.length,ue=J.meta.size;const{sourceSize:ye}=Object.values(J.frames)[0];q=ye.w,O=ye.h,fe(B).repeat.set(1*W/(ue.w/q),1/(ue.h/O)),$(a()),(Ae=T())==null||Ae(),c()&&Me()}),$e(()=>{$(a()),c()&&Me()});var Oe=Lt(),j=dt(Oe);{var Z=te=>{var Se=U6(),ye=dt(Se);pt(ye,rn({get is(){return M()},get map(){return fe(B)},toneMapped:!1,side:Ei,shadowSide:Ei,get transparent(){return m()},get alphaTest(){return d()}},()=>I,{get ref(){return C()},set ref(Ce){C(Ce)}}));var Ae=Ln(ye,2);Ss(Ae,()=>pt.MeshDepthMaterial,(Ce,Ge)=>{Ge(Ce,{attach:"customDepthMaterial",depthPacking:Ch,get map(){return fe(B)},get alphaTest(){return d()}})}),lt(te,Se)},pe=te=>{var Se=Lt(),ye=dt(Se);{var Ae=Ce=>{pt(Ce,rn({get is(){return M()},get map(){return fe(B)},toneMapped:!1,get transparent(){return m()},get alphaTest(){return d()}},()=>I,{get ref(){return C()},set ref(Ge){C(Ge)}}))};wi(ye,Ce=>{fe(B)&&Ce(Ae)},!0)}lt(te,Se)};wi(j,te=>{fe(B)&&fe(_e)?te(Z):te(pe,!1)})}lt(s,Oe);var he=Et({play:Me,pause:oe,get textureUrl(){return r()},set textureUrl(te){r(te),V()},get dataUrl(){return o()},set dataUrl(te=""){o(te),V()},get animation(){return a()},set animation(te=""){a(te),V()},get loop(){return l()},set loop(te=!0){l(te),V()},get autoplay(){return c()},set autoplay(te=!0){c(te),V()},get fps(){return u()},set fps(te=10){u(te),V()},get filter(){return h()},set filter(te="nearest"){h(te),V()},get alphaTest(){return d()},set alphaTest(te=.1){d(te),V()},get delay(){return f()},set delay(te=0){f(te),V()},get transparent(){return m()},set transparent(te=!0){m(te),V()},get flipX(){return v()},set flipX(te=!1){v(te),V()},get startFrame(){return g()},set startFrame(te=0){g(te),V()},get endFrame(){return _()},set endFrame(te=void 0){_(te),V()},get rows(){return y()},set rows(te=1){y(te),V()},get columns(){return w()},set columns(te=void 0){w(te),V()},get totalFrames(){return x()},set totalFrames(te=0){x(te),V()},get is(){return M()},set is(te){M(te),V()},get ref(){return C()},set ref(te){C(te),V()},get onload(){return T()},set onload(te){T(te),V()},get onstart(){return A()},set onstart(te){A(te),V()},get onend(){return P()},set onend(te){P(te),V()},get onloop(){return E()},set onloop(te){E(te),V()},$set:Ct,$on:(te,Se)=>At(e,te,Se)});return i(),he}Pt(kR,{textureUrl:{},dataUrl:{},animation:{},loop:{},autoplay:{},fps:{},filter:{},alphaTest:{},delay:{},transparent:{},flipX:{},startFrame:{},endFrame:{},rows:{},columns:{},totalFrames:{},is:{},ref:{},onload:{},onstart:{},onend:{},onloop:{}},[],["play","pause"],!0);var k6=Kn(" ",1);function OR(s,e){if(new.target)return Tt({component:OR,...s});Mt(e,!0);let t=H(e,"thresholdAngle",7,1),i=H(e,"color",7,"#ffffff"),n=H(e,"ref",15),r=H(e,"children",7),o=an(e,["$$slots","$$events","$$legacy","$$host","thresholdAngle","color","ref","children"]);const a=cf(To()),l=xt(()=>{if(!wn(a.current,"Mesh"))throw new Error("Edges: component must be a child of a Mesh");return a.current.geometry});return n(new no),pt(s,rn({get is(){return n()}},()=>o,{children:(c,u)=>{var h=k6(),d=dt(h);const f=xt(()=>[fe(l),t()]);Ss(d,()=>pt.EdgesGeometry,(g,_)=>{_(g,{get args(){return fe(f)}})});var m=Ln(d,2);Ss(m,()=>pt.LineBasicMaterial,(g,_)=>{_(g,{get color(){return i()}})});var v=Ln(m,2);Wt(v,()=>r()??Nt,()=>({ref:n()})),lt(c,h)},$$slots:{default:!0}})),Et({get thresholdAngle(){return t()},set thresholdAngle(c=1){t(c),V()},get color(){return i()},set color(c="#ffffff"){i(c),V()},get ref(){return n()},set ref(c){n(c),V()},get children(){return r()},set children(c){r(c),V()},$set:Ct,$on:(c,u)=>At(e,c,u)})}Pt(OR,{thresholdAngle:{},color:{},ref:{},children:{}},[],[],!0);const pu=new X,Q0=new X,O6=new X,F6=new Ne,FR=(s,e,t)=>{const i=pu.setFromMatrixPosition(s.matrixWorld);i.project(e);const n=t.width/2,r=t.height/2;return[i.x*n+n,-(i.y*r)+r]},N6=(s,e)=>{const t=pu.setFromMatrixPosition(s.matrixWorld),i=Q0.setFromMatrixPosition(e.matrixWorld),n=t.sub(i),r=e.getWorldDirection(O6);return n.angleTo(r)>Math.PI/2},B6=(s,e,t,i)=>{const n=pu.setFromMatrixPosition(s.matrixWorld),r=Q0.copy(pu);r.project(e),t.setFromCamera(F6.set(r.x,r.y),e);const o=t.intersectObjects(i,!0);if(o.length){const a=o[0].distance;return n.distanceTo(t.ray.origin){if(wn(e,"OrthographicCamera"))return e.zoom;if(wn(e,"PerspectiveCamera")){const t=pu.setFromMatrixPosition(s.matrixWorld),i=Q0.setFromMatrixPosition(e.matrixWorld),n=e.fov*Math.PI/180,r=t.distanceTo(i);return 1/(2*Math.tan(n/2)*r)}else return 1},V6=(s,e,t)=>{const i=pu.setFromMatrixPosition(s.matrixWorld),n=Q0.setFromMatrixPosition(e.matrixWorld),r=i.distanceTo(n),o=(t[1]-t[0])/(e.far-e.near),a=t[1]-o*e.far;return Math.round(o*r+a)},ar=s=>Math.abs(s)<1e-10?0:s,NR=(s,e,t="")=>{const{elements:i}=s;return`${t}matrix3d( ${ar(e[0]*i[0])},${ar(e[1]*i[1])},${ar(e[2]*i[2])},${ar(e[3]*i[3])}, ${ar(e[4]*i[4])},${ar(e[5]*i[5])},${ar(e[6]*i[6])},${ar(e[7]*i[7])}, ${ar(e[8]*i[8])},${ar(e[9]*i[9])},${ar(e[10]*i[10])},${ar(e[11]*i[11])}, ${ar(e[12]*i[12])},${ar(e[13]*i[13])},${ar(e[14]*i[14])},${ar(e[15]*i[15])} )`},G6=(s=>e=>NR(e,s))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),H6=(s=>(e,t)=>NR(e,s(t),"translate(-50%,-50%)"))(s=>[1/s,1/s,1/s,1,-1/s,-1/s,-1/s,-1,1/s,1/s,1/s,1,1,1,1,1]),W6=(s,e,t)=>{if(wn(s,"OrthographicCamera"))return 1;if(wn(s,"PerspectiveCamera")){const{width:i,height:n}=t,r=s.getWorldPosition(pu).distanceTo(e),o=s.fov*Math.PI/180,l=2*Math.tan(o/2)*r*(i/n);return i/l}throw new Error("getViewportFactor needs a Perspective or Orthographic Camera")},X6=` #include #include void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); #include }`,BR=` #include void main() { #include gl_FragColor = vec4(0.0,0.0,0.0,0.0); }`,Y6=` #include #include void main() { vec2 center = vec2(0., 1.); float rotation = 0.0; // This is somewhat arbitrary, but it seems to work well // Need to figure out how to derive this dynamically if it even matters float size = 0.03; vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale = vec2( length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ), length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ) ); bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include }`;let e_=!1,t_=0,zR="",VR="",GR="";const HR=(s,e)=>{t_===1&&!e_?(zR=s.style.zIndex,VR=s.style.position,GR=s.style.pointerEvents,s.style.zIndex=`${Math.floor(e/2)}`,s.style.position="absolute",s.style.pointerEvents="none",e_=!0):t_===0&&e_&&(s.style.zIndex=zR,s.style.position=VR,s.style.pointerEvents=GR,e_=!1)};var j6=Kn(" ",1),q6=Kn("
"),Z6=Kn("
"),K6=Kn(" ",1);function WR(s,e){if(new.target)return Tt({component:WR,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(k,"$size",t),r=()=>Rn(U,"$camera",t);let o=H(e,"autoRender",7,!0),a=H(e,"eps",7,.001),l=H(e,"center",7,!1),c=H(e,"fullscreen",7,!1),u=H(e,"portal",7),h=H(e,"distanceFactor",7),d=H(e,"sprite",7,!1),f=H(e,"transform",7,!1),m=H(e,"occlude",7,!1),v=H(e,"castShadow",7),g=H(e,"receiveShadow",7),_=H(e,"material",7),y=H(e,"geometry",7),w=H(e,"zIndexRange",23,()=>[16777271,0]),x=H(e,"calculatePosition",7,FR),M=H(e,"as",7,"div"),C=H(e,"wrapperClass",7),T=H(e,"pointerEvents",7,"auto"),A=H(e,"ref",15),P=H(e,"visible",15),E=H(e,"style",7),I=H(e,"children",7),R=an(e,["$$slots","$$events","$$legacy","$$host","autoRender","eps","center","fullscreen","portal","distanceFactor","sprite","transform","occlude","castShadow","receiveShadow","material","geometry","zIndexRange","calculatePosition","as","wrapperClass","pointerEvents","ref","visible","style","children"]);P(!0);const{camera:U,scene:L,size:k,dom:z,canvas:G}=un(),W=new Qn;let q=document.createElement(M()),O=0,B=[0,0],J=xs(void 0),re=xs(void 0),K=!1;const Q=new it,ue=new O0;let le=xt(()=>m()&&m()!=="blending"||Array.isArray(m())&&m().length>0),_e=new _t,Fe=xt(()=>n().width),Ie=xt(()=>n().height),Ee=xt(()=>fe(Fe)/2),me=xt(()=>fe(Ie)/2),xe=xt(()=>r().projectionMatrix.elements[5]*fe(me)),$=xt(()=>W6(r(),new X,n()));$e(()=>{C()&&(q.className=C())}),$e(()=>(m()==="blending"&&(t_+=1,HR(G,w()[0])),()=>{t_-=1,HR(G,w()[0])}));const Ue=()=>{U.current.updateMatrixWorld(),W.updateWorldMatrix(!0,!1);const he=f()?B:x()(W,U.current,n());if(f()||Math.abs(O-U.current.zoom)>a()||Math.abs(B[0]-he[0])>a()||Math.abs(B[1]-he[1])>a()){const te=N6(W,U.current);let Se=!1;fe(le)&&(Array.isArray(m())?Se=m():m()!=="blending"&&(Se=[L]));const ye=P();if(Se){const Ge=B6(W,U.current,ue,Se);P(Ge&&!te)}else P(!te);ye!==P()&&(e.onvisibilitychange?e.onvisibilitychange(P()):q.style.display=P()?"block":"none");const Ae=Math.floor(w()[0]/2),Ce=m()?fe(le)?[w()[0],Ae]:[Ae-1,0]:w();if(q.style.zIndex=`${V6(W,U.current,Ce)}`,f()&&fe(J)&&fe(re)){const{isOrthographicCamera:Ge,top:De,left:Ve,bottom:ze,right:Ze}=U.current,Le=G6(U.current.matrixWorldInverse),ot=Ge?`scale(${fe(xe)})translate(${ar(-(Ze+Ve)/2)}px,${ar((De+ze)/2)}px)`:`translateZ(${fe(xe)}px)`;d()?(_e.copy(U.current.matrixWorldInverse).transpose().copyPosition(_e).scale(W.scale),_e.elements[3]=_e.elements[7]=_e.elements[11]=0,_e.elements[15]=1):_e.copy(W.matrixWorld),q.style.width=`${fe(Fe)}px`,q.style.height=`${fe(Ie)}px`,q.style.perspective=Ge?"":`${fe(xe)}px`,fe(J).style.transform=`${ot}${Le}translate(${fe(Ee)}px,${fe(me)}px)`,fe(re).style.transform=H6(_e,1/((h()||10)/400))}else{const Ge=h()===void 0?1:z6(W,U.current)*h();q.style.transform=`translate3d(${he[0]}px,${he[1]}px,0) scale(${Ge})`}B=he,O=U.current.zoom}if(!fe(le)&&!K)if(f()&&fe(J)){const te=fe(J).children[0];if(te!=null&&te.clientWidth&&(te!=null&&te.clientHeight)){const{isOrthographicCamera:Se}=U.current;if(Se||y()){const{scale:ye}=R;ye&&(Array.isArray(ye)?Q.scale.set(1/ye[0],1/ye[1],1/ye[2]):Q.scale.setScalar(1/ye))}else{const ye=(h()??10)/400,Ae=te.clientWidth*ye,Ce=te.clientHeight*ye;Q.scale.set(Ae,Ce,1)}K=!0}}else{const te=q.children[0];if(te!=null&&te.clientWidth&&(te!=null&&te.clientHeight)){const Se=1/fe($),ye=te.clientWidth*Se,Ae=te.clientHeight*Se;Q.scale.set(ye,Ae,1),K=!0}Q.lookAt(U.current.position)}},{start:Me,stop:oe}=ii(Ue,{autoStart:!1});Ht(()=>{if(o())return Me(),()=>{oe()}});let Te=xt(()=>(L.updateMatrixWorld(),x()(W,r(),n())));const Ye=he=>{const te=u()??z;if(!te){console.warn(": target is undefined.");return}return te.append(he),{destroy:()=>he.remove()}};var Oe=K6(),j=dt(Oe);pt(j,rn({is:W},()=>R,{get ref(){return A()},set ref(he){A(he)},children:(he,te)=>{var Se=Lt(),ye=dt(Se);{var Ae=Ce=>{pt(Ce,{is:Q,get castShadow(){return v()},get receiveShadow(){return g()},children:(Ge,De)=>{var Ve=j6(),ze=dt(Ve);{var Ze=ce=>{pt(ce,{get is(){return y()}})},Le=ce=>{var ve=Lt(),be=dt(ve);Ss(be,()=>pt.PlaneGeometry,(Xe,We)=>{We(Xe,{})}),lt(ce,ve)};wi(ze,ce=>{y()?ce(Ze):ce(Le,!1)})}var ot=Ln(ze,2);{var tt=ce=>{pt(ce,{get is(){return _()}})},mt=ce=>{var ve=Lt(),be=dt(ve);{var Xe=Be=>{var ut=Lt(),gt=dt(ut);Ss(gt,()=>pt.ShaderMaterial,(nt,je)=>{je(nt,{side:Ei,vertexShader:Y6,fragmentShader:BR})}),lt(Be,ut)},We=Be=>{var ut=Lt(),gt=dt(ut);Ss(gt,()=>pt.ShaderMaterial,(nt,je)=>{je(nt,{side:Ei,vertexShader:X6,fragmentShader:BR})}),lt(Be,ut)};wi(be,Be=>{f()?Be(We,!1):Be(Xe)},!0)}lt(ce,ve)};wi(ot,ce=>{_()?ce(tt):ce(mt,!1)})}lt(Ge,Ve)},$$slots:{default:!0}})};wi(ye,Ce=>{m()&&!fe(le)&&Ce(Ae)})}lt(he,Se)},$$slots:{default:!0}}));var Z=Ln(j,2);pk(Z,M,!1,(he,te)=>{gk(he,Ge=>Ye==null?void 0:Ye(Ge)),qu(he,Ge=>q=Ge,()=>q),Si(he,"position","absolute"),Si(he,"top","0"),Si(he,"left","0"),Iy(()=>{Si(he,"pointer-events",f()?"none":void 0),Si(he,"overflow",f()?"hidden":void 0),Si(he,"transform",f()?void 0:`translate3d(${fe(Te)[0]}px,${fe(Te)[1]}px,0)`),Si(he,"transform-origin",f()?void 0:"0 0")});var Se=Lt(),ye=dt(Se);{var Ae=Ge=>{var De=q6();Si(De,"position","absolute"),Si(De,"top","0"),Si(De,"left","0"),Si(De,"transform-style","preserve-3d"),Si(De,"pointer-events","none");var Ve=$l(De);Si(Ve,"position","absolute");var ze=$l(Ve),Ze=$l(ze);Wt(Ze,()=>I()??Nt,()=>({render:Ue,startRendering:Me,stopRendering:oe})),ql(ze),ql(Ve),qu(Ve,Le=>Mn(re,Le),()=>fe(re)),ql(De),qu(De,Le=>Mn(J,Le),()=>fe(J)),Iy(()=>{Si(De,"width",`${fe(Fe)}px`),Si(De,"height",`${fe(Ie)}px`),Si(Ve,"pointer-events",T()),dE(ze,cE(e.class)),uE(ze,"style",e.style)}),lt(Ge,De)},Ce=Ge=>{var De=Z6(),Ve=$l(De);Wt(Ve,()=>I()??Nt,()=>({render:Ue,startRendering:Me,stopRendering:oe})),ql(De),Iy(()=>{uE(De,"style",e.style),dE(De,cE(e.class)),Si(De,"position","absolute"),Si(De,"transform",l()?"translate3d(-50%,-50%,0)":"none"),Si(De,"top",c()?`${-fe(Ie)/2}px`:void 0),Si(De,"left",c()?`${-fe(Fe)/2}px`:void 0),Si(De,"width",c()?`${fe(Fe)}px`:void 0),Si(De,"height",c()?`${fe(Ie)}px`:void 0)}),lt(Ge,De)};wi(ye,Ge=>{f()?Ge(Ae):Ge(Ce,!1)})}lt(te,Se)}),lt(s,Oe);var pe=Et({render:Ue,startRendering:Me,stopRendering:oe,get autoRender(){return o()},set autoRender(he=!0){o(he),V()},get eps(){return a()},set eps(he=.001){a(he),V()},get center(){return l()},set center(he=!1){l(he),V()},get fullscreen(){return c()},set fullscreen(he=!1){c(he),V()},get portal(){return u()},set portal(he){u(he),V()},get distanceFactor(){return h()},set distanceFactor(he){h(he),V()},get sprite(){return d()},set sprite(he=!1){d(he),V()},get transform(){return f()},set transform(he=!1){f(he),V()},get occlude(){return m()},set occlude(he=!1){m(he),V()},get castShadow(){return v()},set castShadow(he){v(he),V()},get receiveShadow(){return g()},set receiveShadow(he){g(he),V()},get material(){return _()},set material(he){_(he),V()},get geometry(){return y()},set geometry(he){y(he),V()},get zIndexRange(){return w()},set zIndexRange(he=[16777271,0]){w(he),V()},get calculatePosition(){return x()},set calculatePosition(he=FR){x(he),V()},get as(){return M()},set as(he="div"){M(he),V()},get wrapperClass(){return C()},set wrapperClass(he){C(he),V()},get pointerEvents(){return T()},set pointerEvents(he="auto"){T(he),V()},get ref(){return A()},set ref(he){A(he),V()},get visible(){return P()},set visible(he){P(he),V()},get style(){return E()},set style(he){E(he),V()},get children(){return I()},set children(he){I(he),V()},$set:Ct,$on:(he,te)=>At(e,he,te)});return i(),pe}Pt(WR,{autoRender:{},eps:{},center:{},fullscreen:{},portal:{},distanceFactor:{},sprite:{},transform:{},occlude:{},castShadow:{},receiveShadow:{},material:{},geometry:{},zIndexRange:{},calculatePosition:{},as:{},wrapperClass:{},pointerEvents:{},ref:{},visible:{},style:{},children:{}},[],["render","startRendering","stopRendering"],!0);function XR(s,e){if(new.target)return Tt({component:XR,...s});Mt(e,!0);const{scene:t}=$0(),{camera:i}=tw(),{renderStage:n,renderer:r,toneMapping:o}=un();let a=H(e,"autoRender",7,!0),l=H(e,"toneMapping",7),c=H(e,"stage",7,n),u=H(e,"ref",15),h=H(e,"children",7);const d=Symbol("threlte-hud-render-stage");return $e(()=>{if(a())return c().createTask(d,()=>{const{autoClear:f}=r;r.autoClear=!1,r.toneMapping=l()??o.current,r.clearDepth(),r.render(t,i.current),r.autoClear=f,r.toneMapping=o.current}),()=>c().removeTask(d)}),pt(s,{is:t,attach:!1,get ref(){return u()},set ref(f){u(f)},children:(f,m)=>{var v=Lt(),g=dt(v);Wt(g,()=>h()??Nt,()=>({ref:t})),lt(f,v)},$$slots:{default:!0}}),Et({get autoRender(){return a()},set autoRender(f=!0){a(f),V()},get toneMapping(){return l()},set toneMapping(f){l(f),V()},get stage(){return c()},set stage(f=n){c(f),V()},get ref(){return u()},set ref(f){u(f),V()},get children(){return h()},set children(f){h(f),V()},$set:Ct,$on:(f,m)=>At(e,f,m)})}Pt(XR,{autoRender:{},toneMapping:{},stage:{},ref:{},children:{}},[],[],!0);function YR(s,e){if(new.target)return Tt({component:YR,...s});Mt(e,!0);let t=H(e,"speed",7,1),i=H(e,"floatIntensity",7,1),n=H(e,"floatingRange",23,()=>[-.1,.1]),r=H(e,"rotationSpeed",7,0),o=H(e,"rotationIntensity",7,0),a=H(e,"seed",23,()=>1e4*Math.random()),l=H(e,"ref",15),c=H(e,"children",7),u=an(e,["$$slots","$$events","$$legacy","$$host","speed","floatIntensity","floatingRange","rotationSpeed","rotationIntensity","seed","ref","children"]);const h=new Qn,d=new Qn;let f=a();const m=qi.mapLinear;let v=xt(()=>Array.isArray(t())?t():[t(),t(),t()]),g=xt(()=>Array.isArray(i())?i():[i(),i(),i()]),_=xt(()=>n().length===3?n():[[0,0],n(),[0,0]]),y=xt(()=>Array.isArray(r())?r():[r(),r(),r()]),w=xt(()=>Array.isArray(o())?o():[o(),o(),o()]);return ii(x=>{f+=x,d.position.x=m(Math.sin(f/4*fe(v)[0])/10,-.1,.1,...fe(_)[0])*fe(g)[0],d.position.y=m(Math.sin(f/4*fe(v)[1])/10,-.1,.1,...fe(_)[1])*fe(g)[1],d.position.z=m(Math.sin(f/4*fe(v)[2])/10,-.1,.1,...fe(_)[2])*fe(g)[2],d.rotation.x=Math.cos(f/4*fe(y)[0])/8*fe(w)[0],d.rotation.y=Math.sin(f/4*fe(y)[1])/8*fe(w)[1],d.rotation.z=Math.sin(f/4*fe(y)[2])/20*fe(w)[2],d.updateMatrix()}),pt(s,rn({is:h},()=>u,{children:(x,M)=>{pt(x,{is:d,matrixAutoUpdate:!1,get ref(){return l()},set ref(C){l(C)},children:(C,T)=>{var A=Lt(),P=dt(A);Wt(P,()=>c()??Nt,()=>({ref:d})),lt(C,A)},$$slots:{default:!0}})},$$slots:{default:!0}})),Et({get speed(){return t()},set speed(x=1){t(x),V()},get floatIntensity(){return i()},set floatIntensity(x=1){i(x),V()},get floatingRange(){return n()},set floatingRange(x=[-.1,.1]){n(x),V()},get rotationSpeed(){return r()},set rotationSpeed(x=0){r(x),V()},get rotationIntensity(){return o()},set rotationIntensity(x=0){o(x),V()},get seed(){return a()},set seed(x=1e4*Math.random()){a(x),V()},get ref(){return l()},set ref(x){l(x),V()},get children(){return c()},set children(x){c(x),V()},$set:Ct,$on:(x,M)=>At(e,x,M)})}Pt(YR,{speed:{},floatIntensity:{},floatingRange:{},rotationSpeed:{},rotationIntensity:{},seed:{},ref:{},children:{}},[],[],!0);function jR(s,e){if(new.target)return Tt({component:jR,...s});Mt(e,!0);let t=H(e,"url",7),i=H(e,"dracoLoader",7),n=H(e,"meshoptDecoder",7),r=H(e,"ktx2Loader",7),o=H(e,"gltf",15),a=H(e,"scene",15),l=H(e,"animations",15),c=H(e,"asset",15),u=H(e,"cameras",15),h=H(e,"scenes",15),d=H(e,"userData",15),f=H(e,"parser",15),m=H(e,"materials",15),v=H(e,"nodes",15),g=H(e,"onload",7),_=H(e,"onunload",7),y=H(e,"onerror",7),w=H(e,"children",7),x=an(e,["$$slots","$$events","$$legacy","$$host","url","dracoLoader","meshoptDecoder","ktx2Loader","gltf","scene","animations","asset","cameras","scenes","userData","parser","materials","nodes","onload","onunload","onerror","children"]);const M=I6({dracoLoader:i(),meshoptDecoder:n(),ktx2Loader:r()}),C=U=>{var L,k;o()&&((L=_())==null||L()),o(U),a(U.scene),l(U.animations),c(U.asset),u(U.cameras),h(U.scenes),d(U.userData),f(U.parser),m(U.materials),v(U.nodes),(k=g())==null||k(o())},T=U=>{var L;o(void 0),a(void 0),l(void 0),c(void 0),u(void 0),h(void 0),d(void 0),f(void 0),v(void 0),m(void 0),(L=y())==null||L(U)},A=Ml(),P=async U=>{try{const L=await A(M.load(U));C(L)}catch(L){T(L)}};$e(()=>{P(t())});var E=Lt(),I=dt(E);{var R=U=>{pt(U,rn({get is(){return a()}},()=>x,{children:(L,k)=>{var z=Lt(),G=dt(z);Wt(G,()=>w()??Nt,()=>({ref:a()})),lt(L,z)},$$slots:{default:!0}}))};wi(I,U=>{a()&&U(R)})}return lt(s,E),Et({get url(){return t()},set url(U){t(U),V()},get dracoLoader(){return i()},set dracoLoader(U){i(U),V()},get meshoptDecoder(){return n()},set meshoptDecoder(U){n(U),V()},get ktx2Loader(){return r()},set ktx2Loader(U){r(U),V()},get gltf(){return o()},set gltf(U){o(U),V()},get scene(){return a()},set scene(U){a(U),V()},get animations(){return l()},set animations(U){l(U),V()},get asset(){return c()},set asset(U){c(U),V()},get cameras(){return u()},set cameras(U){u(U),V()},get scenes(){return h()},set scenes(U){h(U),V()},get userData(){return d()},set userData(U){d(U),V()},get parser(){return f()},set parser(U){f(U),V()},get materials(){return m()},set materials(U){m(U),V()},get nodes(){return v()},set nodes(U){v(U),V()},get onload(){return g()},set onload(U){g(U),V()},get onunload(){return _()},set onunload(U){_(U),V()},get onerror(){return y()},set onerror(U){y(U),V()},get children(){return w()},set children(U){w(U),V()},$set:Ct,$on:(U,L)=>At(e,U,L)})}Pt(jR,{url:{},dracoLoader:{},meshoptDecoder:{},ktx2Loader:{},gltf:{},scene:{},animations:{},asset:{},cameras:{},scenes:{},userData:{},parser:{},materials:{},nodes:{},onload:{},onunload:{},onerror:{},children:{}},[],[],!0);var $6=Object.defineProperty,J6=(s,e,t)=>e in s?$6(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,zn=(s,e,t)=>J6(s,typeof e!="symbol"?e+"":e,t);const qR=(s,e)=>{const[t,i]=e.split("-");return Object.assign(s.style,{left:i==="left"?"0":i==="center"?"50%":"",right:i==="right"?"0":"",top:t==="top"?"0":t==="bottom"?"":"50%",bottom:t==="bottom"?"0":"",transform:`${i==="center"?"translateX(-50%)":""} ${t==="center"?"translateY(-50%)":""}`}),e},Q6=({placement:s,size:e,offset:t,id:i,className:n})=>{const r=document.createElement("div"),{top:o,left:a,right:l,bottom:c}=t;return Object.assign(r.style,{id:i,position:"absolute",zIndex:"1000",height:`${e}px`,width:`${e}px`,margin:`${o}px ${l}px ${c}px ${a}px`,borderRadius:"100%"}),qR(r,s),i&&(r.id=i),n&&(r.className=n),r},eW=s=>{const e=typeof s=="string"?document.querySelector(s):s;if(!e)throw Error("Invalid DOM element");return e};function ww(s,e,t){return Math.max(e,Math.min(t,s))}const tW=[["x",0,3],["y",1,4],["z",2,5]],ZR=new X;function KR({isSphere:s},e,t){s&&(ZR.set(0,0,1).applyQuaternion(t.quaternion),tW.forEach(([i,n,r])=>{const o=ZR[i];let a=e[n],l=a.userData.opacity;a.material.opacity=ww(o>=0?l:l/2,0,1),a=e[r],l=a.userData.opacity,a.material.opacity=ww(o>=0?l/2:l,0,1)}))}const nW=(s,e,t=10)=>Math.abs(s.clientX-e.x){JR.set((s.clientX-e.left)/e.width*2-1,-((s.clientY-e.top)/e.height)*2+1),$R.setFromCamera(JR,t);const n=$R.intersectObjects(i,!1),r=n.length?n[0]:null;return!r||!r.object.visible?null:r},Sw=1e-6,iW=2*Math.PI,eD=["x","y","z"],Mp=[...eD,"nx","ny","nz"],rW=["right","top","front","left","bottom","back"],tD=1.3,nD=(s,e=!0)=>{const{material:t,userData:i}=s,{color:n,opacity:r}=e?i.hover:i;t.color.set(n),t.opacity=r},mu=s=>JSON.parse(JSON.stringify(s)),sW=s=>{const e=s.type||"sphere",t=e==="sphere",i=s.resolution||t?64:128,{container:n}=s;s.container=void 0,s=JSON.parse(JSON.stringify(s)),s.container=n,rW.forEach((l,c)=>{s[l]&&(s[Mp[c]]=s[l])});const r={enabled:!0,color:16777215,opacity:1,scale:.7,labelColor:2236962,line:!1,border:{size:0,color:14540253},hover:{color:t?16777215:9688043,labelColor:2236962,opacity:1,scale:.7,border:{size:0,color:14540253}}},o={line:!1,scale:t?.45:.7,hover:{scale:t?.5:.7}},a={type:e,container:document.body,size:128,placement:"top-right",resolution:i,lineWidth:20,radius:t?1:.2,smoothness:18,animated:!0,speed:1,background:{enabled:!0,color:t?16777215:14739180,opacity:t?0:1,hover:{color:t?16777215:14739180,opacity:t?.2:1}},font:{family:"sans-serif",weight:900},offset:{top:10,left:10,bottom:10,right:10},corners:{enabled:!t,color:t?15915362:16777215,opacity:1,scale:t?.15:.2,radius:1,smoothness:18,hover:{color:t?16777215:9688043,opacity:1,scale:t?.2:.225}},edges:{enabled:!t,color:t?15915362:16777215,opacity:t?1:0,radius:t?1:.125,smoothness:18,scale:t?.15:1,hover:{color:t?16777215:9688043,opacity:1,scale:t?.2:1}},x:{...mu(r),...t?{label:"X",color:16725587,line:!0}:{label:"Right"}},y:{...mu(r),...t?{label:"Y",color:9100032,line:!0}:{label:"Top"}},z:{...mu(r),...t?{label:"Z",color:2920447,line:!0}:{label:"Front"}},nx:{...mu(o),label:t?"":"Left"},ny:{...mu(o),label:t?"":"Bottom"},nz:{...mu(o),label:t?"":"Back"}};return Mw(s,a),eD.forEach(l=>Mw(s[`n${l}`],mu(s[l]))),{...s,isSphere:t}};function Mw(s,...e){if(s instanceof HTMLElement||typeof s!="object"||s===null)return s;for(const t of e)for(const i in t)i!=="container"&&i in t&&(s[i]===void 0?s[i]=t[i]:typeof t[i]=="object"&&!Array.isArray(t[i])&&(s[i]=Mw(s[i]||{},t[i])));return s}const oW=(s,e=2)=>{const t=new rt,i=e*2,{isSphere:n,resolution:r,radius:o,font:a,corners:l,edges:c}=s,u=Mp.map(T=>({...s[T],radius:o}));n&&l.enabled&&u.push(l),n&&c.enabled&&u.push(c);const h=document.createElement("canvas"),d=h.getContext("2d");h.width=r*2+i*2,h.height=r*u.length+i*u.length;const[f,m]=M(u,r,a);u.forEach(({radius:T,label:A,color:P,labelColor:E,border:I,hover:{color:R,labelColor:U,border:L}},k)=>{const z=r*k+k*i+e;x(e,z,e,r,T,A,I,P,E),x(r+e*3,z,e,r,T,A,L??I,R??P,U??E)});const v=u.length,g=e/(r*2),_=e/(r*6),y=1/v,w=new h0(h);return w.repeat.set(.5-2*g,y-2*_),w.offset.set(g,1-_),Object.assign(w,{colorSpace:Ni,wrapS:Os,wrapT:Os,userData:{offsetX:g,offsetY:_,cellHeight:y}}),w;function x(T,A,P,E,I,R,U,L,k){if(I=I*(E/2),L!=null&&L!==""&&(z(),d.fillStyle=t.set(L).getStyle(),d.fill()),U&&U.size){const G=U.size*E/2;T+=G,A+=G,E-=U.size*E,I=Math.max(0,I-G),z(),d.strokeStyle=t.set(U.color).getStyle(),d.lineWidth=U.size*E,d.stroke()}R&&C(d,T+E/2,A+(E+P)/2,R,t.set(k).getStyle());function z(){d.beginPath(),d.moveTo(T+I,A),d.lineTo(T+E-I,A),d.arcTo(T+E,A,T+E,A+I,I),d.lineTo(T+E,A+E-I),d.arcTo(T+E,A+E,T+E-I,A+E,I),d.lineTo(T+I,A+E),d.arcTo(T,A+E,T,A+E-I,I),d.lineTo(T,A+I),d.arcTo(T,A,T+I,A,I),d.closePath()}}function M(T,A,P){const E=[...T].sort((O,B)=>{var J,re;return(((J=O.label)==null?void 0:J.length)||0)-(((re=B.label)==null?void 0:re.length)||0)}).pop().label,{family:I,weight:R}=P,U=n?Math.sqrt(Math.pow(A*.7,2)/2):A;let L=U,k=0,z=0;do{d.font=`${R} ${L}px ${I}`;const O=d.measureText(E);k=O.width,z=O.fontBoundingBoxDescent,L--}while(k>U&&L>0);const G=U/z,W=Math.min(U/k,G),q=Math.floor(L*W);return[`${R} ${q}px ${I}`,G]}function C(T,A,P,E,I){T.font=f,T.textAlign="center",T.textBaseline="middle",T.fillStyle=I,T.fillText(E,A,P+(n?m:0))}},aW=(s,e)=>s.offset.x=(e?.5:0)+s.userData.offsetX,Ew=(s,e)=>{const{offset:t,userData:{offsetY:i,cellHeight:n}}=s;t.y=1-(e+1)*n+i};function Tw(s,e,t=2,i=2){const n=t/2-s,r=i/2-s,o=s/t,a=(t-s)/t,l=s/i,c=(i-s)/i,u=[n,r,0,-n,r,0,-n,-r,0,n,-r,0],h=[a,c,o,c,o,l,a,l],d=[3*(e+1)+3,3*(e+1)+4,e+4,e+5,2*(e+1)+4,2,1,2*(e+1)+3,3,4*(e+1)+3,4,0],f=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11].map(C=>d[C]);let m,v,g,_,y,w,x,M;for(let C=0;C<4;C++){_=C<1||C>2?n:-n,y=C<2?r:-r,w=C<1||C>2?a:o,x=C<2?c:l;for(let T=0;T<=e;T++)m=Math.PI/2*(C+T/e),v=Math.cos(m),g=Math.sin(m),u.push(_+s*v,y+s*g,0),h.push(w+o*v,x+l*g),T{const t=new X,{isSphere:i,radius:n,smoothness:r}=s,o=Tw(n,r);return Mp.map((a,l)=>{const c=l<3,u=Mp[l],h=l?e.clone():e;Ew(h,l);const{enabled:d,scale:f,opacity:m,hover:v}=s[u],g={map:h,opacity:m,transparent:!0},_=i?new tp(new Gc(g)):new it(o,new Jn(g)),y=c?u:u[1];return _.position[y]=(c?1:-1)*(i?tD:1),i||_.lookAt(t.copy(_.position).multiplyScalar(1.7)),_.scale.setScalar(f),_.renderOrder=1,_.visible=d,_.userData={scale:f,opacity:m,hover:v},_})},cW=(s,e)=>{const{isSphere:t,corners:i}=s;if(!i.enabled)return[];const{color:n,opacity:r,scale:o,radius:a,smoothness:l,hover:c}=i,u=t?null:Tw(a,l),h={transparent:!0,opacity:r},d=[1,1,1,-1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,-1,-1].map(m=>m*.85),f=new X;return Array(d.length/3).fill(0).map((m,v)=>{if(t){const y=e.clone();Ew(y,6),h.map=y}else h.color=n;const g=t?new tp(new Gc(h)):new it(u,new Jn(h)),_=v*3;return g.position.set(d[_],d[_+1],d[_+2]),t&&g.position.normalize().multiplyScalar(1.7),g.scale.setScalar(o),g.lookAt(f.copy(g.position).multiplyScalar(2)),g.renderOrder=1,g.userData={color:n,opacity:r,scale:o,hover:c},g})},uW=(s,e,t)=>{const{isSphere:i,edges:n}=s;if(!n.enabled)return[];const{color:r,opacity:o,scale:a,hover:l,radius:c,smoothness:u}=n,h=i?null:Tw(c,u,1.2,.25),d={transparent:!0,opacity:o},f=[0,1,1,0,-1,1,1,0,1,-1,0,1,0,1,-1,0,-1,-1,1,0,-1,-1,0,-1,1,1,0,1,-1,0,-1,1,0,-1,-1,0].map(g=>g*.925),m=new X,v=new X(0,1,0);return Array(f.length/3).fill(0).map((g,_)=>{if(i){const x=e.clone();Ew(x,t),d.map=x}else d.color=r;const y=i?new tp(new Gc(d)):new it(h,new Jn(d)),w=_*3;return y.position.set(f[w],f[w+1],f[w+2]),i&&y.position.normalize().multiplyScalar(1.7),y.scale.setScalar(a),y.up.copy(v),y.lookAt(m.copy(y.position).multiplyScalar(2)),!i&&!y.position.y&&(y.rotation.z=Math.PI/2),y.renderOrder=1,y.userData={color:r,opacity:o,scale:a,hover:l},y})};function hW(s,e=!1){const t=s[0].index!==null,i=new Set(Object.keys(s[0].attributes)),n=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,l=new Gt;let c=0;for(let u=0;u{const{isSphere:t,background:{enabled:i,color:n,opacity:r,hover:o}}=e;let a;const l=new Jn({color:n,side:ji,opacity:r,transparent:!0,depthWrite:!1});if(!i)return null;if(t)a=new it(new _l(1.8,64,64),l);else{let c;s.forEach(u=>{const h=u.scale.x;u.scale.setScalar(.9),u.updateMatrix();const d=u.geometry.clone();d.applyMatrix4(u.matrix),c=c?hW([c,d]):d,u.scale.setScalar(h)}),a=new it(c,l)}return a.userData={color:n,opacity:r,hover:o},a},rD=new yn,n_=new X;class sD extends _p{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new It(e,3)),this.setAttribute("uv",new It(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),i.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new k0(t,6,1);return this.setAttribute("instanceStart",new ps(i,3,0)),this.setAttribute("instanceEnd",new ps(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new k0(t,6,1);return this.setAttribute("instanceColorStart",new ps(i,3,0)),this.setAttribute("instanceColorEnd",new ps(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new x1(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new yn);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),rD.setFromBufferAttribute(t),this.boundingBox.union(rD))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fi),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let r=0,o=e.count;r #include #include #include #include uniform float linewidth; uniform vec2 resolution; attribute vec3 instanceStart; attribute vec3 instanceEnd; attribute vec3 instanceColorStart; attribute vec3 instanceColorEnd; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #ifdef USE_DASH uniform float dashScale; attribute float instanceDistanceStart; attribute float instanceDistanceEnd; varying float vLineDistance; #endif void trimSegment( const in vec4 start, inout vec4 end ) { // trim end segment so it terminates between the camera plane and the near plane // conservative estimate of the near plane float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column float nearEstimate = - 0.5 * b / a; float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); end.xyz = mix( start.xyz, end.xyz, alpha ); } void main() { #ifdef USE_COLOR vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; #endif #ifdef USE_DASH vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; vUv = uv; #endif float aspect = resolution.x / resolution.y; // camera space vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); #ifdef WORLD_UNITS worldStart = start.xyz; worldEnd = end.xyz; #else vUv = uv; #endif // special case for perspective projection, and segments that terminate either in, or behind, the camera plane // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space // but we need to perform ndc-space calculations in the shader, so we must address this issue directly // perhaps there is a more elegant solution -- WestLangley bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column if ( perspective ) { if ( start.z < 0.0 && end.z >= 0.0 ) { trimSegment( start, end ); } else if ( end.z < 0.0 && start.z >= 0.0 ) { trimSegment( end, start ); } } // clip space vec4 clipStart = projectionMatrix * start; vec4 clipEnd = projectionMatrix * end; // ndc space vec3 ndcStart = clipStart.xyz / clipStart.w; vec3 ndcEnd = clipEnd.xyz / clipEnd.w; // direction vec2 dir = ndcEnd.xy - ndcStart.xy; // account for clip-space aspect ratio dir.x *= aspect; dir = normalize( dir ); #ifdef WORLD_UNITS vec3 worldDir = normalize( end.xyz - start.xyz ); vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); vec3 worldFwd = cross( worldDir, worldUp ); worldPos = position.y < 0.5 ? start: end; // height offset float hw = linewidth * 0.5; worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; // don't extend the line if we're rendering dashes because we // won't be rendering the endcaps #ifndef USE_DASH // cap extension worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; // add width to the box worldPos.xyz += worldFwd * hw; // endcaps if ( position.y > 1.0 || position.y < 0.0 ) { worldPos.xyz -= worldFwd * 2.0 * hw; } #endif // project the worldpos vec4 clip = projectionMatrix * worldPos; // shift the depth of the projected points so the line // segments overlap neatly vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; clip.z = clipPose.z * clip.w; #else vec2 offset = vec2( dir.y, - dir.x ); // undo aspect ratio adjustment dir.x /= aspect; offset.x /= aspect; // sign flip if ( position.x < 0.0 ) offset *= - 1.0; // endcaps if ( position.y < 0.0 ) { offset += - dir; } else if ( position.y > 1.0 ) { offset += dir; } // adjust for linewidth offset *= linewidth; // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... offset /= resolution.y; // select end vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; // back to clip space offset *= clip.w; clip.xy += offset; #endif gl_Position = clip; vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation #include #include #include } `,fragmentShader:` uniform vec3 diffuse; uniform float opacity; uniform float linewidth; #ifdef USE_DASH uniform float dashOffset; uniform float dashSize; uniform float gapSize; #endif varying float vLineDistance; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #include #include #include #include #include vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { float mua; float mub; vec3 p13 = p1 - p3; vec3 p43 = p4 - p3; vec3 p21 = p2 - p1; float d1343 = dot( p13, p43 ); float d4321 = dot( p43, p21 ); float d1321 = dot( p13, p21 ); float d4343 = dot( p43, p43 ); float d2121 = dot( p21, p21 ); float denom = d2121 * d4343 - d4321 * d4321; float numer = d1343 * d4321 - d1321 * d4343; mua = numer / denom; mua = clamp( mua, 0.0, 1.0 ); mub = ( d1343 + d4321 * ( mua ) ) / d4343; mub = clamp( mub, 0.0, 1.0 ); return vec2( mua, mub ); } void main() { #include #ifdef USE_DASH if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX #endif float alpha = opacity; #ifdef WORLD_UNITS // Find the closest points on the view ray and the line segment vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; vec3 lineDir = worldEnd - worldStart; vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); vec3 p1 = worldStart + lineDir * params.x; vec3 p2 = rayEnd * params.y; vec3 delta = p1 - p2; float len = length( delta ); float norm = len / linewidth; #ifndef USE_DASH #ifdef USE_ALPHA_TO_COVERAGE float dnorm = fwidth( norm ); alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); #else if ( norm > 0.5 ) { discard; } #endif #endif #else #ifdef USE_ALPHA_TO_COVERAGE // artifacts appear on some hardware if a derivative is taken within a conditional float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; float dlen = fwidth( len2 ); if ( abs( vUv.y ) > 1.0 ) { alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); } #else if ( abs( vUv.y ) > 1.0 ) { float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; if ( len2 > 1.0 ) discard; } #endif #endif vec4 diffuseColor = vec4( diffuse, alpha ); #include #include gl_FragColor = vec4( diffuseColor.rgb, alpha ); #include #include #include #include } `};let Aw=class extends Ti{constructor(e){super({type:"LineMaterial",uniforms:pl.clone(Or.line.uniforms),vertexShader:Or.line.vertexShader,fragmentShader:Or.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}};const Cw=new Zt,oD=new X,aD=new X,_r=new Zt,yr=new Zt,$o=new Zt,Pw=new X,Rw=new _t,xr=new Eo,lD=new X,i_=new yn,r_=new fi,Jo=new Zt;let Qo,gu;function cD(s,e,t){return Jo.set(0,0,-e,1).applyMatrix4(s.projectionMatrix),Jo.multiplyScalar(1/Jo.w),Jo.x=gu/t.width,Jo.y=gu/t.height,Jo.applyMatrix4(s.projectionMatrixInverse),Jo.multiplyScalar(1/Jo.w),Math.abs(Math.max(Jo.x,Jo.y))}function fW(s,e){const t=s.matrixWorld,i=s.geometry,n=i.attributes.instanceStart,r=i.attributes.instanceEnd,o=Math.min(i.instanceCount,n.count);for(let a=0,l=o;au&&yr.z>u)continue;if(_r.z>u){const _=_r.z-yr.z,y=(_r.z-u)/_;_r.lerp(yr,y)}else if(yr.z>u){const _=yr.z-_r.z,y=(yr.z-u)/_;yr.lerp(_r,y)}_r.applyMatrix4(i),yr.applyMatrix4(i),_r.multiplyScalar(1/_r.w),yr.multiplyScalar(1/yr.w),_r.x*=n.x/2,_r.y*=n.y/2,yr.x*=n.x/2,yr.y*=n.y/2,xr.start.copy(_r),xr.start.z=0,xr.end.copy(yr),xr.end.z=0;const f=xr.closestPointToPointParameter(Pw,!0);xr.at(f,lD);const m=qi.lerp(_r.z,yr.z,f),v=m>=-1&&m<=1,g=Pw.distanceTo(lD){const e=new rt,t=[],i=[],{isSphere:n}=s;if(Mp.forEach((a,l)=>{const{enabled:c,line:u,scale:h,color:d}=s[a];if(!c||!u)return;const f=l<3?1:-1,m=(n?tD-h/2:.975)*f;t.push(a.includes("x")?m:0,a.includes("y")?m:0,a.includes("z")?m:0,0,0,0);const v=e.set(d).toArray();i.push(...v,...v)}),!t.length)return null;const r=new uD().setPositions(t).setColors(i),o=new Aw({linewidth:s.lineWidth,vertexColors:!0,resolution:new Ne(window.innerWidth,window.innerHeight)});return new gW(r,o).computeLineDistances()},_W=s=>{const{corners:e,edges:t}=s,i=[],n=oW(s),r=lW(s,n);i.push(...r),e.enabled&&i.push(...cW(s,n)),t.enabled&&i.push(...uW(s,n,e.enabled?7:6));const o=dW(r,s),a=vW(s);return[i,o,a]},Ep=(s,e=!0)=>{const{material:t,userData:i}=s,{opacity:n,color:r,scale:o}=e?i.hover:i;s.scale.setScalar(o),t.opacity=n,t.map?aW(t.map,e):t.color.set(r)},cd=new _t,yW=new rd,xW=new Ne,vu=new X,hD=new Zt;class dD extends tn{constructor(e,t,i={}){super(),zn(this,"enabled",!0),zn(this,"camera"),zn(this,"renderer"),zn(this,"options"),zn(this,"target",new X),zn(this,"animated",!0),zn(this,"speed",1),zn(this,"animating",!1),zn(this,"_options"),zn(this,"_intersections"),zn(this,"_background",null),zn(this,"_viewport",[0,0,0,0]),zn(this,"_originalViewport",[0,0,0,0]),zn(this,"_originalScissor",[0,0,0,0]),zn(this,"_scene"),zn(this,"_camera"),zn(this,"_container"),zn(this,"_domElement"),zn(this,"_domRect"),zn(this,"_dragging",!1),zn(this,"_distance",0),zn(this,"_clock",new L1),zn(this,"_targetQuaternion",new Tn),zn(this,"_quaternionStart",new Tn),zn(this,"_quaternionEnd",new Tn),zn(this,"_pointerStart",new Ne),zn(this,"_focus",null),zn(this,"_placement"),zn(this,"_controls"),zn(this,"_controlsListeners"),this.camera=e,this.renderer=t,this._scene=new Kf().add(this),this.set(i)}get placement(){return this._placement}set placement(e){this._placement=qR(this._domElement,e),this.domUpdate()}set(e={}){this.dispose(),this.options=e,this._options=sW(e),this._camera=this._options.isSphere?new Ta(-1.8,1.8,1.8,-1.8,5,10):new zi(26,1,5,10),this._camera.position.set(0,0,7);const[t,i,n]=_W(this._options);i&&this.add(i),n&&this.add(n),this.add(...t),this._background=i,this._intersections=t;const{container:r,animated:o,speed:a}=this._options;return this.animated=o,this.speed=a,this._container=r?eW(r):document.body,this._domElement=Q6(this._options),this._domElement.onpointerdown=l=>this._onPointerDown(l),this._domElement.onpointermove=l=>this._onPointerMove(l),this._domElement.onpointerleave=()=>this._onPointerLeave(),this._container.appendChild(this._domElement),this._controls&&this.attachControls(this._controls),this.update(),this}render(){this.animating&&this._animate();const{renderer:e,_viewport:t}=this,i=e.getScissorTest(),n=e.autoClear;return e.autoClear=!1,e.setViewport(...t),i&&e.setScissor(...t),e.clear(!1,!0,!1),e.render(this._scene,this._camera),e.setViewport(...this._originalViewport),i&&e.setScissor(...this._originalScissor),e.autoClear=n,this}domUpdate(){this._domRect=this._domElement.getBoundingClientRect();const e=this.renderer,t=this._domRect,i=e.domElement.getBoundingClientRect();return this._viewport.splice(0,4,t.left-i.left,e.domElement.clientHeight-(t.top-i.top+t.height),t.width,t.height),e.getViewport(hD).toArray(this._originalViewport),e.getScissorTest()&&e.getScissor(hD).toArray(this._originalScissor),this}cameraUpdate(){return this._updateOrientation(),this}update(e=!0){return e&&this._controls&&this._controls.update(),this.domUpdate().cameraUpdate()}attachControls(e){return this.detachControls(),this.target=e.target,this._controlsListeners={start:()=>e.enabled=!1,end:()=>e.enabled=!0,change:()=>this.update(!1)},this.addEventListener("start",this._controlsListeners.start),this.addEventListener("end",this._controlsListeners.end),e.addEventListener("change",this._controlsListeners.change),this._controls=e,this}detachControls(){if(!(!this._controlsListeners||!this._controls))return this.target=new X().copy(this._controls.target),this.removeEventListener("start",this._controlsListeners.start),this.removeEventListener("end",this._controlsListeners.end),this._controls.removeEventListener("change",this._controlsListeners.change),this._controlsListeners=void 0,this._controls=void 0,this}dispose(){var e;this.detachControls(),this.children.forEach(t=>{var i,n,r,o;this.remove(t);const a=t;(i=a.material)==null||i.dispose(),(r=(n=a.material)==null?void 0:n.map)==null||r.dispose(),(o=a.geometry)==null||o.dispose()}),(e=this._domElement)==null||e.remove()}_updateOrientation(e=!0){e&&(this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()),KR(this._options,this._intersections,this.camera)}_animate(){const{position:e,quaternion:t}=this.camera;if(e.set(0,0,1),!this.animated){e.applyQuaternion(this._quaternionEnd).multiplyScalar(this._distance).add(this.target),t.copy(this._targetQuaternion),this._updateOrientation(),this.animating=!1,this.dispatchEvent({type:"change"}),this.dispatchEvent({type:"end"});return}this._controls&&(this._controls.enabled=!1);const i=this._clock.getDelta()*iW*this.speed;this._quaternionStart.rotateTowards(this._quaternionEnd,i),e.applyQuaternion(this._quaternionStart).multiplyScalar(this._distance).add(this.target),t.rotateTowards(this._targetQuaternion,i),this._updateOrientation(),requestAnimationFrame(()=>this.dispatchEvent({type:"change"})),this._quaternionStart.angleTo(this._quaternionEnd){if(!this._dragging){if(nW(a,this._pointerStart))return;this._dragging=!0}const l=xW.set(a.clientX,a.clientY).sub(this._pointerStart).multiplyScalar(1/this._domRect.width*Math.PI),c=yW.setFromVector3(vu.subVectors(this.camera.position,this.target));c.theta=r-l.x,c.phi=ww(o-l.y,Sw,Math.PI-Sw),this.camera.position.setFromSpherical(c).add(this.target),this.camera.lookAt(this.target),this.quaternion.copy(this.camera.quaternion).invert(),this._updateOrientation(!1),this.dispatchEvent({type:"change"})},i=()=>{if(document.removeEventListener("pointermove",t,!1),document.removeEventListener("pointerup",i,!1),!this._dragging)return this._handleClick(e);this._focus&&(Ep(this._focus,!1),this._focus=null),this._dragging=!1,this.dispatchEvent({type:"end"})};if(this.animating)return;e.preventDefault(),this._pointerStart.set(e.clientX,e.clientY);const n=new rd().setFromVector3(vu.subVectors(this.camera.position,this.target)),r=n.theta,o=n.phi;this._distance=n.radius,document.addEventListener("pointermove",t,!1),document.addEventListener("pointerup",i,!1),this.dispatchEvent({type:"start"})}_onPointerMove(e){!this.enabled||this._dragging||(this._background&&nD(this._background,!0),this._handleHover(e))}_onPointerLeave(){!this.enabled||this._dragging||(this._background&&nD(this._background,!1),this._focus&&Ep(this._focus,!1),this._domElement.style.cursor="")}_handleClick(e){const t=QR(e,this._domRect,this._camera,this._intersections);this._focus&&(Ep(this._focus,!1),this._focus=null),t&&(this._setOrientation(t.object.position),this.dispatchEvent({type:"change"}))}_handleHover(e){const t=QR(e,this._domRect,this._camera,this._intersections),i=(t==null?void 0:t.object)||null;this._focus!==i&&(this._domElement.style.cursor=i?"pointer":"",this._focus&&Ep(this._focus,!1),(this._focus=i)?Ep(i,!0):KR(this._options,this._intersections,this.camera))}}const fD={type:"change"},Dw={type:"start"},pD={type:"end"},s_=new hl,mD=new to,bW=Math.cos(70*qi.DEG2RAD),Qi=new X,vs=2*Math.PI,jn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Iw=1e-6;let gD=class extends H0{constructor(e,t=null){super(e,t),this.state=jn.NONE,this.enabled=!0,this.target=new X,this.cursor=new X,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Us.ROTATE,MIDDLE:Us.DOLLY,RIGHT:Us.PAN},this.touches={ONE:Sc.ROTATE,TWO:Sc.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new X,this._lastQuaternion=new Tn,this._lastTargetPosition=new X,this._quat=new Tn().setFromUnitVectors(e.up,new X(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new rd,this._sphericalDelta=new rd,this._scale=1,this._panOffset=new X,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new X,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=SW.bind(this),this._onPointerDown=wW.bind(this),this._onPointerUp=MW.bind(this),this._onContextMenu=DW.bind(this),this._onMouseWheel=AW.bind(this),this._onKeyDown=CW.bind(this),this._onTouchStart=PW.bind(this),this._onTouchMove=RW.bind(this),this._onMouseDown=EW.bind(this),this._onMouseMove=TW.bind(this),this._interceptControlDown=IW.bind(this),this._interceptControlUp=LW.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(fD),this.update(),this.state=jn.NONE}update(e=null){const t=this.object.position;Qi.copy(t).sub(this.target),Qi.applyQuaternion(this._quat),this._spherical.setFromVector3(Qi),this.autoRotate&&this.state===jn.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=vs:i>Math.PI&&(i-=vs),n<-Math.PI?n+=vs:n>Math.PI&&(n-=vs),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Qi.setFromSpherical(this._spherical),Qi.applyQuaternion(this._quatInverse),t.copy(this.target).add(Qi),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Qi.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new X(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new X(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Qi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(s_.origin.copy(this.object.position),s_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(s_.direction))Iw||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Iw||this._lastTargetPosition.distanceToSquared(this.target)>Iw?(this.dispatchEvent(fD),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?vs/60*this.autoRotateSpeed*e:vs/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Qi.setFromMatrixColumn(t,0),Qi.multiplyScalar(-e),this._panOffset.add(Qi)}_panUp(e,t){this.screenSpacePanning===!0?Qi.setFromMatrixColumn(t,1):(Qi.setFromMatrixColumn(t,0),Qi.crossVectors(this.object.up,Qi)),Qi.multiplyScalar(e),this._panOffset.add(Qi)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;Qi.copy(n).sub(this.target);let r=Qi.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),n=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=n/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(vs*this._rotateDelta.x/t.clientHeight),this._rotateUp(vs*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(vs*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-vs*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(vs*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-vs*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,r=Math.sqrt(i*i+n*n);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(vs*this._rotateDelta.x/t.clientHeight),this._rotateUp(vs*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,r=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tvD&&(this.dispatchEvent(Lw),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>vD||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(Lw),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=kn.NONE,this.keyState=kn.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(Lw),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(El.copy(this._panEnd).sub(this._panStart),El.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;El.x*=e,El.y*=t}El.multiplyScalar(this._eye.length()*this.panSpeed),a_.copy(this._eye).cross(this.object.up).setLength(El.x),a_.add(UW.copy(this.object.up).setLength(El.y)),this.object.position.add(a_),this.target.add(a_),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(El.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){c_.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=c_.length();e?(this._eye.copy(this.object.position).sub(this.target),_D.copy(this._eye).normalize(),l_.copy(this.object.up).normalize(),Fw.crossVectors(l_,_D).normalize(),l_.setLength(this._moveCurr.y-this._movePrev.y),Fw.setLength(this._moveCurr.x-this._movePrev.x),c_.copy(l_.add(Fw)),Ow.crossVectors(c_,this._eye).normalize(),e*=this.rotateSpeed,ud.setFromAxisAngle(Ow,e),this._eye.applyQuaternion(ud),this.object.up.applyQuaternion(ud),this._lastAxis.copy(Ow),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),ud.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(ud),this.object.up.applyQuaternion(ud)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===kn.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=qi.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=qi.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return o_.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),o_}_getMouseOnCircle(e,t){return o_.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),o_}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Rn(m,"$parent",t),r=()=>Rn(v,"$camera",t),o=()=>Rn(x,"$size",t);let a=H(e,"controls",7),l=H(e,"renderTask",7),c=H(e,"ref",15),u=H(e,"onstart",7),h=H(e,"onchange",7),d=H(e,"onend",7),f=an(e,["$$slots","$$events","$$legacy","$$host","controls","renderTask","ref","onstart","onchange","onend"]);const m=To(),{camera:v,renderer:g,dom:_,autoRenderTask:y,shouldRender:w,size:x,invalidate:M}=un();c(new dD(v.current,g));const C=new Zt,T=xt(()=>a()??n());ii(((P=l())==null?void 0:P.key)??Symbol("threlte-extras-gizmo-render"),()=>{if(w()){const E=g.toneMapping;g.getViewport(C),g.toneMapping=Yo,c().render(),g.setViewport(C),g.toneMapping=E}},{autoInvalidate:!1,...l()??{after:y}}),$e(()=>{c(c().camera=r(),!0)}),Ht(()=>{if(fe(T))if(fe(T)instanceof gD||fe(T)instanceof yD){c(c().target=fe(T).target,!0);const E=()=>{c().update(!1)};return fe(T).addEventListener("change",E),()=>fe(T).removeEventListener("change",E)}else{const E=()=>{"getTarget"in fe(T)&&typeof fe(T).getTarget=="function"&&(fe(T).getTarget(c().target),c().update())},I=()=>{fe(T).setPosition(...v.current.position.toArray())};return c().addEventListener("change",I),fe(T).addEventListener("update",E),()=>{c().removeEventListener("change",I),fe(T).removeEventListener("update",E)}}}),Ht(()=>{const E=I=>{var R;fe(T).enabled=!1,(R=u())==null||R(I)};return c().addEventListener("start",E),()=>c().removeEventListener("start",E)}),Ht(()=>{const E=I=>{var R;M(),(R=h())==null||R(I)};return c().addEventListener("change",E),()=>c().removeEventListener("change",E)}),Ht(()=>{const E=I=>{var R;fe(T).enabled=!0,(R=d())==null||R(I)};return c().addEventListener("end",E),()=>c().removeEventListener("end",E)}),$e(()=>{_&&(c().dispose(),c(new dD(v.current,g,{container:_,placement:"bottom-left",size:86,...f})),M())}),Ht(()=>{o(),c().update(),M()}),Ht(()=>()=>c().dispose());var A=Et({get controls(){return a()},set controls(E){a(E),V()},get renderTask(){return l()},set renderTask(E){l(E),V()},get ref(){return c()},set ref(E){c(E),V()},get onstart(){return u()},set onstart(E){u(E),V()},get onchange(){return h()},set onchange(E){h(E),V()},get onend(){return d()},set onend(E){d(E),V()},$set:Ct,$on:(E,I)=>At(e,E,I)});return i(),A}Pt(xD,{controls:{},renderTask:{},ref:{},onstart:{},onchange:{},onend:{}},[],[],!0);const ZW={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform sampler2D tDiffuse; uniform float h; varying vec2 vUv; void main() { vec4 sum = vec4( 0.0 ); sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051; sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918; sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245; sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633; sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531; sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245; sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918; sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051; gl_FragColor = sum; }`},KW={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform sampler2D tDiffuse; uniform float v; varying vec2 vUv; void main() { vec4 sum = vec4( 0.0 ); sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918; sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051; gl_FragColor = sum; }`};var $W=Kn(" ",1);function bD(s,e){if(new.target)return Tt({component:bD,...s});Mt(e,!0);let t=H(e,"opacity",7,1),i=H(e,"width",7,1),n=H(e,"height",7,1),r=H(e,"blur",7,1),o=H(e,"far",7,10),a=H(e,"smooth",7,!0),l=H(e,"resolution",7,512),c=H(e,"frames",7,1/0),u=H(e,"scale",7,10),h=H(e,"color",7,"#000000"),d=H(e,"depthWrite",7,!1),f=H(e,"ref",15),m=H(e,"children",7),v=an(e,["$$slots","$$events","$$legacy","$$host","opacity","width","height","blur","far","smooth","resolution","frames","scale","color","depthWrite","ref","children"]);const{scene:g,renderer:_}=un(),y=new Qn,w=xt(()=>i()*(Array.isArray(u())?u()[0]:u()||1)),x=xt(()=>n()*(Array.isArray(u())?u()[1]:u()||1)),M=xt(()=>{const O=new Bs(l(),l());return O.texture.generateMipmaps=!1,O.texture.colorSpace=_.outputColorSpace,O}),C=xt(()=>{const O=new Bs(l(),l());return O.texture.generateMipmaps=!1,O}),T=xt(()=>new es(fe(w),fe(x)).rotateX(Math.PI/2)),A=xt(()=>new it(fe(T))),P=xt(()=>{const O=new jc({depthTest:!1,depthWrite:!1});return O.onBeforeCompile=B=>{B.uniforms={...B.uniforms,uColor:{value:new rt(h()).convertSRGBToLinear()}},B.fragmentShader=`uniform vec3 uColor; ${B.fragmentShader}`,B.fragmentShader=B.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( uColor, ( 1.0 - fragCoordZ ) * 1.0 );"),B.fragmentShader=B.fragmentShader.replace("vec4(vec3(1.0-fragCoordZ),opacity);","vec4(uColor,(1.0-fragCoordZ)*1.0);")},O}),E=new Ti({...ZW,depthTest:!1}),I=new Ti({...KW,depthTest:!1}),R=xt(()=>new Ta(-fe(w)/2,fe(w)/2,fe(x)/2,-fe(x)/2,0,o()));$e(()=>fe(R).updateProjectionMatrix());const U=xt(()=>new Jn({map:fe(M).texture,transparent:!0,opacity:t(),depthWrite:d()})),L=O=>{fe(A).visible=!0,fe(A).material=E,E.uniforms.tDiffuse.value=fe(M).texture,E.uniforms.h.value=O*1/256,_.setRenderTarget(fe(C)),_.render(fe(A),fe(R)),fe(A).material=I,I.uniforms.tDiffuse.value=fe(C).texture,I.uniforms.v.value=O*1/256,_.setRenderTarget(fe(M)),_.render(fe(A),fe(R)),fe(A).visible=!1},k=()=>{const O=g.background;g.background=null;const B=g.overrideMaterial;g.overrideMaterial=fe(P);const J=_.getClearAlpha();_.setClearAlpha(0),_.setRenderTarget(fe(M)),_.render(g,fe(R)),g.overrideMaterial=B,L(r()),a()&&L(r()*.4),_.setRenderTarget(null),g.background=O,_.setClearAlpha(J)},z=()=>{k()},G=ii(()=>{k()},{autoStart:!1});let W=0;const q=ii(()=>{k(),W+=1,W>=c()&&q.stop()},{autoStart:!1});return $e(()=>{c()===Number.POSITIVE_INFINITY?G.start():W{fe(M).dispose(),fe(C).dispose(),fe(T).dispose(),fe(P).dispose(),E.dispose(),I.dispose(),fe(U).dispose()}),pt(s,rn({is:y},()=>v,{get ref(){return f()},set ref(O){f(O)},children:(O,B)=>{var J=Lt(),re=dt(J);Ss(re,()=>pt.Group,(K,Q)=>{Q(K,{"rotation.x":Math.PI/2,children:(ue,le)=>{var _e=$W(),Fe=dt(_e);Ss(Fe,()=>pt.Mesh,(me,xe)=>{xe(me,{"scale.y":-1,"rotation.x":-Math.PI/2,get material(){return fe(U)},get geometry(){return fe(T)}})});var Ie=Ln(Fe,2);pt(Ie,{get is(){return fe(R)},manual:!0});var Ee=Ln(Ie,2);Wt(Ee,()=>m()??Nt,()=>({ref:y})),lt(ue,_e)},$$slots:{default:!0}})}),lt(O,J)},$$slots:{default:!0}})),Et({refresh:z,get opacity(){return t()},set opacity(O=1){t(O),V()},get width(){return i()},set width(O=1){i(O),V()},get height(){return n()},set height(O=1){n(O),V()},get blur(){return r()},set blur(O=1){r(O),V()},get far(){return o()},set far(O=10){o(O),V()},get smooth(){return a()},set smooth(O=!0){a(O),V()},get resolution(){return l()},set resolution(O=512){l(O),V()},get frames(){return c()},set frames(O=1/0){c(O),V()},get scale(){return u()},set scale(O=10){u(O),V()},get color(){return h()},set color(O="#000000"){h(O),V()},get depthWrite(){return d()},set depthWrite(O=!1){d(O),V()},get ref(){return f()},set ref(O){f(O),V()},get children(){return m()},set children(O){m(O),V()},$set:Ct,$on:(O,B)=>At(e,O,B)})}Pt(bD,{opacity:{},width:{},height:{},blur:{},far:{},smooth:{},resolution:{},frames:{},scale:{},color:{},depthWrite:{},ref:{},children:{}},[],["refresh"],!0);class wD extends T1{constructor(e){super(e),this.type=mr}parse(e){const o=function(A,P){switch(A){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(P||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(P||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(P||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(P||""))}},u=` `,h=function(A,P,E){P=P||1024;let R=A.pos,U=-1,L=0,k="",z=String.fromCharCode.apply(null,new Uint16Array(A.subarray(R,R+128)));for(;0>(U=z.indexOf(u))&&L=A.byteLength||!(k=h(A)))&&o(1,"no header found"),(z=k.match(P))||o(3,"bad initial token"),L.valid|=1,L.programtype=z[1],L.string+=k+` `;k=h(A),k!==!1;){if(L.string+=k+` `,k.charAt(0)==="#"){L.comments+=k+` `;continue}if((z=k.match(E))&&(L.gamma=parseFloat(z[1])),(z=k.match(I))&&(L.exposure=parseFloat(z[1])),(z=k.match(R))&&(L.valid|=2,L.format=z[1]),(z=k.match(U))&&(L.valid|=4,L.height=parseInt(z[1],10),L.width=parseInt(z[2],10)),L.valid&2&&L.valid&4)break}return L.valid&2||o(3,"missing format specifier"),L.valid&4||o(3,"missing image size specifier"),L},f=function(A,P,E){const I=P;if(I<8||I>32767||A[0]!==2||A[1]!==2||A[2]&128)return new Uint8Array(A);I!==(A[2]<<8|A[3])&&o(3,"wrong scanline width");const R=new Uint8Array(4*P*E);R.length||o(4,"unable to allocate buffer space");let U=0,L=0;const k=4*I,z=new Uint8Array(4),G=new Uint8Array(k);let W=E;for(;W>0&&LA.byteLength&&o(1),z[0]=A[L++],z[1]=A[L++],z[2]=A[L++],z[3]=A[L++],(z[0]!=2||z[1]!=2||(z[2]<<8|z[3])!=I)&&o(3,"bad rgbe scanline format");let q=0,O;for(;q128;if(J&&(O-=128),(O===0||q+O>k)&&o(3,"bad scanline data"),J){const re=A[L++];for(let K=0;K{const{invalidate:e}=un();Gs(()=>[s.scene],([n])=>{const r=n.background,o=n.environment;return()=>{n.background=r,n.environment=o}});let t=xs(void 0),i=xs(void 0);Gs(()=>[s.scene],([n])=>{Mn(t,hr(n.background)),Mn(i,hr(n.environment))}),Ht(()=>{if(s.isBackground&&s.texture!==void 0)return s.scene.background=s.texture,e(),()=>{fe(t)!==void 0&&(s.scene.background=fe(t),e())}}),Ht(()=>{if(s.texture!==void 0)return s.scene.environment=s.texture,e(),()=>{fe(i)!==void 0&&(s.scene.environment=fe(i),e())}})},Tl={};function SD(s,e){if(new.target)return Tt({component:SD,...s});Mt(e,!0);const t=un();let i=H(e,"isBackground",7,!1),n=H(e,"scene",23,()=>t.scene),r=H(e,"texture",15),o=H(e,"urls",7);const a=Q1(),l=Ml();Nw({get scene(){return n()},get isBackground(){return i()},get texture(){return r()}});const c=xt(()=>{var d;return(d=o())==null?void 0:d[0]}),u=xt(()=>{var d;return((d=fe(c))==null?void 0:d.endsWith("hdr"))??!1}),h=xt(()=>{if(o()!==void 0)return fe(u)?(Tl.hdr??(Tl.hdr=new JW),Tl.hdr):(Tl.tex??(Tl.tex=new $C),Tl.tex)});return Ht(()=>{if(o()!==void 0&&fe(h)!==void 0){const d=l(a.remember(()=>fe(h).loadAsync(o()),o()));return d.then(f=>{r(f)}),()=>{d.then(f=>{f.dispose()})}}}),Et({get isBackground(){return i()},set isBackground(d=!1){i(d),V()},get scene(){return n()},set scene(d=t.scene){n(d),V()},get texture(){return r()},set texture(d){r(d),V()},get urls(){return o()},set urls(d){o(d),V()},$set:Ct,$on:(d,f)=>At(e,d,f)})}Pt(SD,{isBackground:{},scene:{},texture:{},urls:{}},[],[],!0);/*! fflate - fast JavaScript compression/decompression Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.8.2 */var so=Uint8Array,hd=Uint16Array,QW=Int32Array,MD=new so([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ED=new so([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),e8=new so([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),TD=function(s,e){for(var t=new hd(31),i=0;i<31;++i)t[i]=e+=1<>1|(ai&21845)<<1;Al=(Al&52428)>>2|(Al&13107)<<2,Al=(Al&61680)>>4|(Al&3855)<<4,Bw[ai]=((Al&65280)>>8|(Al&255)<<8)>>1}for(var Tp=function(s,e,t){for(var i=s.length,n=0,r=new hd(e);n>l]=c}else for(a=new hd(i),n=0;n>15-s[n]);return a},Ap=new so(288),ai=0;ai<144;++ai)Ap[ai]=8;for(var ai=144;ai<256;++ai)Ap[ai]=9;for(var ai=256;ai<280;++ai)Ap[ai]=7;for(var ai=280;ai<288;++ai)Ap[ai]=8;for(var PD=new so(32),ai=0;ai<32;++ai)PD[ai]=5;var r8=Tp(Ap,9,1),s8=Tp(PD,5,1),zw=function(s){for(var e=s[0],t=1;te&&(e=s[t]);return e},Ao=function(s,e,t){var i=e/8|0;return(s[i]|s[i+1]<<8)>>(e&7)&t},Vw=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},o8=function(s){return(s+7)/8|0},a8=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new so(s.subarray(e,t))},l8=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Co=function(s,e,t){var i=new Error(e||l8[s]);if(i.code=s,Error.captureStackTrace&&Error.captureStackTrace(i,Co),!t)throw i;return i},c8=function(s,e,t,i){var n=s.length,r=0;if(!n||e.f&&!e.l)return t||new so(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new so(n*3));var c=function(Ee){var me=t.length;if(Ee>me){var xe=new so(Math.max(me*2,Ee));xe.set(t),t=xe}},u=e.f||0,h=e.p||0,d=e.b||0,f=e.l,m=e.d,v=e.m,g=e.n,_=n*8;do{if(!f){u=Ao(s,h,1);var y=Ao(s,h+1,3);if(h+=3,y)if(y==1)f=r8,m=s8,v=9,g=5;else if(y==2){var C=Ao(s,h,31)+257,T=Ao(s,h+10,15)+4,A=C+Ao(s,h+5,31)+1;h+=14;for(var P=new so(A),E=new so(19),I=0;I>4;if(w<16)P[I++]=w;else{var z=0,G=0;for(w==16?(G=3+Ao(s,h,3),h+=2,z=P[I-1]):w==17?(G=3+Ao(s,h,7),h+=3):w==18&&(G=11+Ao(s,h,127),h+=7);G--;)P[I++]=z}}var W=P.subarray(0,C),q=P.subarray(C);v=zw(W),g=zw(q),f=Tp(W,v,1),m=Tp(q,g,1)}else Co(1);else{var w=o8(h)+4,x=s[w-4]|s[w-3]<<8,M=w+x;if(M>n){l&&Co(0);break}a&&c(d+x),t.set(s.subarray(w,M),d),e.b=d+=x,e.p=h=M*8,e.f=u;continue}if(h>_){l&&Co(0);break}}a&&c(d+131072);for(var O=(1<>4;if(h+=z&15,h>_){l&&Co(0);break}if(z||Co(2),re<256)t[d++]=re;else if(re==256){J=h,f=null;break}else{var K=re-254;if(re>264){var I=re-257,Q=MD[I];K=Ao(s,h,(1<>4;ue||Co(3),h+=ue&15;var q=i8[le];if(le>3){var Q=ED[le];q+=Vw(s,h)&(1<_){l&&Co(0);break}a&&c(d+131072);var _e=d+K;if(d>4>7||(s[0]<<8|s[1])%31)&&Co(6,"invalid zlib data"),(s[1]>>5&1)==1&&Co(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function u_(s,e){return c8(s.subarray(h8(s),-4),{i:2},e,e)}var d8=typeof TextDecoder<"u"&&new TextDecoder,f8=0;try{d8.decode(u8,{stream:!0}),f8=1}catch{}class p8 extends T1{constructor(e){super(e),this.type=mr}parse(e){const P=Math.pow(2.7182818,2.2);function E(F,ee){let de=0;for(let ie=0;ie<65536;++ie)(ie==0||F[ie>>3]&1<<(ie&7))&&(ee[de++]=ie);const N=de-1;for(;de<65536;)ee[de++]=0;return N}function I(F){for(let ee=0;ee<16384;ee++)F[ee]={},F[ee].len=0,F[ee].lit=0,F[ee].p=null}const R={l:0,c:0,lc:0};function U(F,ee,de,N,ie){for(;de>de&(1<0;--de){const N=ee+L[de]>>1;L[de]=ee,ee=N}for(let de=0;de<65537;++de){const N=F[de];N>0&&(F[de]=N|L[N]++<<6)}}function z(F,ee,de,N,ie,se){const ne=ee;let ae=0,we=0;for(;N<=ie;N++){if(ne.value-ee.value>de)return!1;U(6,ae,we,F,ne);const Pe=R.l;if(ae=R.c,we=R.lc,se[N]=Pe,Pe==63){if(ne.value-ee.value>de)throw new Error("Something wrong with hufUnpackEncTable");U(8,ae,we,F,ne);let Re=R.l+6;if(ae=R.c,we=R.lc,N+Re>ie+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Re--;)se[N++]=0;N--}else if(Pe>=59){let Re=Pe-59+2;if(N+Re>ie+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Re--;)se[N++]=0;N--}}k(se)}function G(F){return F&63}function W(F){return F>>6}function q(F,ee,de,N){for(;ee<=de;ee++){const ie=W(F[ee]),se=G(F[ee]);if(ie>>se)throw new Error("Invalid table entry");if(se>14){const ne=N[ie>>se-14];if(ne.len)throw new Error("Invalid table entry");if(ne.lit++,ne.p){const ae=ne.p;ne.p=new Array(ne.lit);for(let we=0;we0;ae--){const we=N[(ie<<14-se)+ne];if(we.len||we.p)throw new Error("Invalid table entry");we.len=se,we.lit=ee,ne++}}}return!0}const O={c:0,lc:0};function B(F,ee,de,N){F=F<<8|Le(de,N),ee+=8,O.c=F,O.lc=ee}const J={c:0,lc:0};function re(F,ee,de,N,ie,se,ne,ae,we){if(F==ee){N<8&&(B(de,N,ie,se),de=O.c,N=O.lc),N-=8;let Pe=de>>N;if(Pe=new Uint8Array([Pe])[0],ae.value+Pe>we)return!1;const Re=ne[ae.value-1];for(;Pe-- >0;)ne[ae.value++]=Re}else if(ae.value32767?ee-65536:ee}const ue={a:0,b:0};function le(F,ee){const de=Q(F),ie=Q(ee),se=de+(ie&1)+(ie>>1),ne=se,ae=se-ie;ue.a=ne,ue.b=ae}function _e(F,ee){const de=K(F),N=K(ee),ie=de-(N>>1)&65535,se=N+ie-32768&65535;ue.a=se,ue.b=ie}function Fe(F,ee,de,N,ie,se,ne){const ae=ne<16384,we=de>ie?ie:de;let Pe=1,Re,He;for(;Pe<=we;)Pe<<=1;for(Pe>>=1,Re=Pe,Pe>>=1;Pe>=1;){He=0;const qe=He+se*(ie-Re),Ke=se*Pe,Je=se*Re,et=N*Pe,st=N*Re;let Dt,kt,Ot,wt;for(;He<=qe;He+=Je){let Yt=He;const St=He+N*(de-Re);for(;Yt<=St;Yt+=st){const vn=Yt+et,ui=Yt+Ke,pn=ui+et;ae?(le(F[Yt+ee],F[ui+ee]),Dt=ue.a,Ot=ue.b,le(F[vn+ee],F[pn+ee]),kt=ue.a,wt=ue.b,le(Dt,kt),F[Yt+ee]=ue.a,F[vn+ee]=ue.b,le(Ot,wt),F[ui+ee]=ue.a,F[pn+ee]=ue.b):(_e(F[Yt+ee],F[ui+ee]),Dt=ue.a,Ot=ue.b,_e(F[vn+ee],F[pn+ee]),kt=ue.a,wt=ue.b,_e(Dt,kt),F[Yt+ee]=ue.a,F[vn+ee]=ue.b,_e(Ot,wt),F[ui+ee]=ue.a,F[pn+ee]=ue.b)}if(de&Pe){const vn=Yt+Ke;ae?le(F[Yt+ee],F[vn+ee]):_e(F[Yt+ee],F[vn+ee]),Dt=ue.a,F[vn+ee]=ue.b,F[Yt+ee]=Dt}}if(ie&Pe){let Yt=He;const St=He+N*(de-Re);for(;Yt<=St;Yt+=st){const vn=Yt+et;ae?le(F[Yt+ee],F[vn+ee]):_e(F[Yt+ee],F[vn+ee]),Dt=ue.a,F[vn+ee]=ue.b,F[Yt+ee]=Dt}}Re=Pe,Pe>>=1}return He}function Ie(F,ee,de,N,ie,se,ne,ae,we){let Pe=0,Re=0;const He=ne,qe=Math.trunc(N.value+(ie+7)/8);for(;N.value=14;){const Je=Pe>>Re-14&16383,et=ee[Je];if(et.len)Re-=et.len,re(et.lit,se,Pe,Re,de,N,ae,we,He),Pe=J.c,Re=J.lc;else{if(!et.p)throw new Error("hufDecode issues");let st;for(st=0;st=Dt&&W(F[et.p[st]])==(Pe>>Re-Dt&(1<>=Ke,Re-=Ke;Re>0;){const Je=ee[Pe<<14-Re&16383];if(Je.len)Re-=Je.len,re(Je.lit,se,Pe,Re,de,N,ae,we,He),Pe=J.c,Re=J.lc;else throw new Error("hufDecode issues")}return!0}function Ee(F,ee,de,N,ie,se){const ne={value:0},ae=de.value,we=Ze(ee,de),Pe=Ze(ee,de);de.value+=4;const Re=Ze(ee,de);if(de.value+=4,we<0||we>=65537||Pe<0||Pe>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const He=new Array(65537),qe=new Array(16384);I(qe);const Ke=N-(de.value-ae);if(z(F,de,Ke,we,Pe,He),Re>8*(N-(de.value-ae)))throw new Error("Something wrong with hufUncompress");q(He,we,Pe,qe),Ie(He,qe,F,de,Re,Pe,se,ie,ne)}function me(F,ee,de){for(let N=0;Nse||(ee[ie++]=F[de++],ie>se));)ee[ie++]=F[N++]}function Ue(F){let ee=F.byteLength;const de=new Array;let N=0;const ie=new DataView(F);for(;ee>0;){const se=ie.getInt8(N++);if(se<0){const ne=-se;ee-=ne+1;for(let ae=0;ae>8==255?ie+=N&255:(de[ie]=N,ie++),F.value++}function Te(F,ee){ee[0]=ve(F[0]),ee[1]=ve(F[1]),ee[2]=ve(F[5]),ee[3]=ve(F[6]),ee[4]=ve(F[14]),ee[5]=ve(F[15]),ee[6]=ve(F[27]),ee[7]=ve(F[28]),ee[8]=ve(F[2]),ee[9]=ve(F[4]),ee[10]=ve(F[7]),ee[11]=ve(F[13]),ee[12]=ve(F[16]),ee[13]=ve(F[26]),ee[14]=ve(F[29]),ee[15]=ve(F[42]),ee[16]=ve(F[3]),ee[17]=ve(F[8]),ee[18]=ve(F[12]),ee[19]=ve(F[17]),ee[20]=ve(F[25]),ee[21]=ve(F[30]),ee[22]=ve(F[41]),ee[23]=ve(F[43]),ee[24]=ve(F[9]),ee[25]=ve(F[11]),ee[26]=ve(F[18]),ee[27]=ve(F[24]),ee[28]=ve(F[31]),ee[29]=ve(F[40]),ee[30]=ve(F[44]),ee[31]=ve(F[53]),ee[32]=ve(F[10]),ee[33]=ve(F[19]),ee[34]=ve(F[23]),ee[35]=ve(F[32]),ee[36]=ve(F[39]),ee[37]=ve(F[45]),ee[38]=ve(F[52]),ee[39]=ve(F[54]),ee[40]=ve(F[20]),ee[41]=ve(F[22]),ee[42]=ve(F[33]),ee[43]=ve(F[38]),ee[44]=ve(F[46]),ee[45]=ve(F[51]),ee[46]=ve(F[55]),ee[47]=ve(F[60]),ee[48]=ve(F[21]),ee[49]=ve(F[34]),ee[50]=ve(F[37]),ee[51]=ve(F[47]),ee[52]=ve(F[50]),ee[53]=ve(F[56]),ee[54]=ve(F[59]),ee[55]=ve(F[61]),ee[56]=ve(F[35]),ee[57]=ve(F[36]),ee[58]=ve(F[48]),ee[59]=ve(F[49]),ee[60]=ve(F[57]),ee[61]=ve(F[58]),ee[62]=ve(F[62]),ee[63]=ve(F[63])}function Ye(F){const ee=.5*Math.cos(.7853975),de=.5*Math.cos(3.14159/16),N=.5*Math.cos(3.14159/8),ie=.5*Math.cos(3*3.14159/16),se=.5*Math.cos(5*3.14159/16),ne=.5*Math.cos(3*3.14159/8),ae=.5*Math.cos(7*3.14159/16),we=new Array(4),Pe=new Array(4),Re=new Array(4),He=new Array(4);for(let qe=0;qe<8;++qe){const Ke=qe*8;we[0]=N*F[Ke+2],we[1]=ne*F[Ke+2],we[2]=N*F[Ke+6],we[3]=ne*F[Ke+6],Pe[0]=de*F[Ke+1]+ie*F[Ke+3]+se*F[Ke+5]+ae*F[Ke+7],Pe[1]=ie*F[Ke+1]-ae*F[Ke+3]-de*F[Ke+5]-se*F[Ke+7],Pe[2]=se*F[Ke+1]-de*F[Ke+3]+ae*F[Ke+5]+ie*F[Ke+7],Pe[3]=ae*F[Ke+1]-se*F[Ke+3]+ie*F[Ke+5]-de*F[Ke+7],Re[0]=ee*(F[Ke+0]+F[Ke+4]),Re[3]=ee*(F[Ke+0]-F[Ke+4]),Re[1]=we[0]+we[3],Re[2]=we[1]-we[2],He[0]=Re[0]+Re[1],He[1]=Re[3]+Re[2],He[2]=Re[3]-Re[2],He[3]=Re[0]-Re[1],F[Ke+0]=He[0]+Pe[0],F[Ke+1]=He[1]+Pe[1],F[Ke+2]=He[2]+Pe[2],F[Ke+3]=He[3]+Pe[3],F[Ke+4]=He[3]-Pe[3],F[Ke+5]=He[2]-Pe[2],F[Ke+6]=He[1]-Pe[1],F[Ke+7]=He[0]-Pe[0]}for(let qe=0;qe<8;++qe)we[0]=N*F[16+qe],we[1]=ne*F[16+qe],we[2]=N*F[48+qe],we[3]=ne*F[48+qe],Pe[0]=de*F[8+qe]+ie*F[24+qe]+se*F[40+qe]+ae*F[56+qe],Pe[1]=ie*F[8+qe]-ae*F[24+qe]-de*F[40+qe]-se*F[56+qe],Pe[2]=se*F[8+qe]-de*F[24+qe]+ae*F[40+qe]+ie*F[56+qe],Pe[3]=ae*F[8+qe]-se*F[24+qe]+ie*F[40+qe]-de*F[56+qe],Re[0]=ee*(F[qe]+F[32+qe]),Re[3]=ee*(F[qe]-F[32+qe]),Re[1]=we[0]+we[3],Re[2]=we[1]-we[2],He[0]=Re[0]+Re[1],He[1]=Re[3]+Re[2],He[2]=Re[3]-Re[2],He[3]=Re[0]-Re[1],F[0+qe]=He[0]+Pe[0],F[8+qe]=He[1]+Pe[1],F[16+qe]=He[2]+Pe[2],F[24+qe]=He[3]+Pe[3],F[32+qe]=He[3]-Pe[3],F[40+qe]=He[2]-Pe[2],F[48+qe]=He[1]-Pe[1],F[56+qe]=He[0]-Pe[0]}function Oe(F){for(let ee=0;ee<64;++ee){const de=F[0][ee],N=F[1][ee],ie=F[2][ee];F[0][ee]=de+1.5747*ie,F[1][ee]=de-.1873*N-.4682*ie,F[2][ee]=de+1.8556*N}}function j(F,ee,de){for(let N=0;N<64;++N)ee[de+N]=zc.toHalfFloat(Z(F[N]))}function Z(F){return F<=1?Math.sign(F)*Math.pow(Math.abs(F),2.2):Math.sign(F)*Math.pow(P,Math.abs(F)-1)}function pe(F){return new DataView(F.array.buffer,F.offset.value,F.size)}function he(F){const ee=F.viewer.buffer.slice(F.offset.value,F.offset.value+F.size),de=new Uint8Array(Ue(ee)),N=new Uint8Array(de.length);return xe(de),$(de,N),new DataView(N.buffer)}function te(F){const ee=F.array.slice(F.offset.value,F.offset.value+F.size),de=u_(ee),N=new Uint8Array(de.length);return xe(de),$(de,N),new DataView(N.buffer)}function Se(F){const ee=F.viewer,de={value:F.offset.value},N=new Uint16Array(F.columns*F.lines*(F.inputChannels.length*F.type)),ie=new Uint8Array(8192);let se=0;const ne=new Array(F.inputChannels.length);for(let Je=0,et=F.inputChannels.length;Je=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(ae<=we)for(let Je=0;Je0;){const et=Ce(ee.buffer,de),st=ot(ee,de),Dt=st>>2&3,kt=(st>>4)-1,Ot=new Int8Array([kt])[0],wt=ot(ee,de);se.push({name:et,index:Ot,type:wt,compression:Dt}),ne-=et.length+3}const ae=fn.channels,we=new Array(F.inputChannels.length);for(let et=0;et=0&&(Pe.idx[kt.index]=et),st.offset=et)}}let Re,He,qe;if(ie.acCompressedSize>0)switch(ie.acCompression){case 0:Re=new Uint16Array(ie.totalAcUncompressedCount),Ee(F.array,ee,de,ie.acCompressedSize,Re,ie.totalAcUncompressedCount);break;case 1:const et=F.array.slice(de.value,de.value+ie.totalAcUncompressedCount),st=u_(et);Re=new Uint16Array(st.buffer),de.value+=ie.totalAcUncompressedCount;break}if(ie.dcCompressedSize>0){const et={array:F.array,offset:de,size:ie.dcCompressedSize};He=new Uint16Array(te(et).buffer),de.value+=ie.dcCompressedSize}if(ie.rleRawSize>0){const et=F.array.slice(de.value,de.value+ie.rleCompressedSize),st=u_(et);qe=Ue(st.buffer),de.value+=ie.rleCompressedSize}let Ke=0;const Je=new Array(we.length);for(let et=0;et>10,de=F&1023;return(F>>15?-1:1)*(ee?ee===31?de?NaN:1/0:Math.pow(2,ee-15)*(1+de/1024):6103515625e-14*(de/1024))}function be(F,ee){const de=F.getUint16(ee.value,!0);return ee.value+=2,de}function Xe(F,ee){return ve(be(F,ee))}function We(F,ee,de,N){const ie=de.value,se=[];for(;de.value>4]}}function ft(F,ee){const de=mt(F,ee),N=mt(F,ee);return[de,N]}function Qe(F,ee){const de=mt(F,ee),N=mt(F,ee),ie=mt(F,ee);return[de,N,ie]}function bt(F,ee,de,N,ie){if(N==="string"||N==="stringvector"||N==="iccProfile")return Ge(ee,de,ie);if(N==="chlist")return We(F,ee,de,ie);if(N==="chromaticities")return Be(F,de);if(N==="compression")return ut(F,de);if(N==="box2i")return gt(F,de);if(N==="envmap")return je(F,de);if(N==="tiledesc")return at(F,de);if(N==="lineOrder")return nt(F,de);if(N==="float")return mt(F,de);if(N==="v2f")return ft(F,de);if(N==="v3f")return Qe(F,de);if(N==="int")return ze(F,de);if(N==="rational")return De(F,de);if(N==="timecode")return Ve(F,de);if(N==="preview")return de.value+=ie,"skipped";de.value+=ie}function yt(F,ee){const de=Math.log2(F);return ee=="ROUND_DOWN"?Math.floor(de):Math.ceil(de)}function Rt(F,ee,de){let N=0;switch(F.levelMode){case"ONE_LEVEL":N=1;break;case"MIPMAP_LEVELS":N=yt(Math.max(ee,de),F.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return N}function on(F,ee,de,N){const ie=new Array(F);for(let se=0;seF.width?F.width-ne:F.blockWidth,F.lines=ae+F.blockHeight>F.height?F.height-ae:F.blockHeight;const we=F.columns*F.totalBytes,Re=F.sizeF.height?F.height-ie:F.blockHeight;const se=F.columns*F.totalBytes,ae=F.size=F.height)continue;const He=we*se,qe=(F.height-1-Re)*F.outLineWidth;for(let Ke=0;KeRe:se.scanOrder=Re=>se.height-1-Re,se.outputChannels==4?(se.format=di,se.colorSpace=Ii):(se.format=Sh,se.colorSpace=jo),F.spec.singleTile){se.blockHeight=F.tiles.ySize,se.blockWidth=F.tiles.xSize;const Re=Rt(F.tiles,se.width,se.height),He=on(Re,se.width,F.tiles.xSize,F.tiles.roundingMode),qe=on(Re,se.height,F.tiles.ySize,F.tiles.roundingMode);se.tileCount=He[0]*qe[0];for(let Ke=0;Ket.scene),l=H(e,"url",7);const c=Ml(),u=Q1();Nw({get scene(){return a()},get isBackground(){return o()},get texture(){return n()}});const h=xt(()=>{var _;return((_=l())==null?void 0:_.endsWith("exr"))??!1}),d=xt(()=>{var _;return((_=l())==null?void 0:_.endsWith("hdr"))??!1}),f=xt(()=>{if(l()!==void 0)return fe(h)?(oo.exr??(oo.exr=new p8),oo.exr):fe(d)?(oo.hdr??(oo.hdr=new wD),oo.hdr):(oo.tex??(oo.tex=new D0),oo.tex)});Ht(()=>{if(l()!==void 0&&fe(f)!==void 0){const _=c(u.remember(()=>fe(f).loadAsync(l()),[l()]));return _.then(y=>{y.mapping=yh,n(y)}),()=>{_.then(y=>{y.dispose()})}}});var m=Lt(),v=dt(m);{var g=_=>{var y=Lt();const w=xt(()=>r()===!0?{}:r());var x=dt(y);{var M=C=>{const T=xt(()=>[n(),fe(w).height??1,fe(w).radius??1,fe(w).resolution??128]);pt(C,{is:m8,oncreate:()=>()=>{i(void 0)},get args(){return fe(T)},get ref(){return i()},set ref(A){i(A)}})};wi(x,C=>{n()&&C(M)})}lt(_,y)};wi(v,_=>{r()&&_(g)})}return lt(s,m),Et({get skybox(){return i()},set skybox(_){i(_),V()},get texture(){return n()},set texture(_){n(_),V()},get ground(){return r()},set ground(_=!1){r(_),V()},get isBackground(){return o()},set isBackground(_=!1){o(_),V()},get scene(){return a()},set scene(_=t.scene){a(_),V()},get url(){return l()},set url(_){l(_),V()},$set:Ct,$on:(_,y)=>At(e,_,y)})}Pt(RD,{skybox:{},texture:{},ground:{},isBackground:{},scene:{},url:{}},[],[],!0);const g8=1,Gw=1e3,v8=256,DD=(s=()=>Gw,e=()=>Gw,t=()=>v8)=>{const i=new Vv(t()),n=new zv(g8,Gw,i);return Ht(()=>{const r=t();i.setSize(r,r)}),Ht(()=>{const r=s();for(const o of n.children)wn(o,"PerspectiveCamera")&&(o.near=r,o.updateProjectionMatrix())}),Ht(()=>{const r=e();for(const o of n.children)wn(o,"PerspectiveCamera")&&(o.far=r,o.updateProjectionMatrix())}),Ht(()=>()=>{i.dispose()}),{camera:n,renderTarget:i}};var _8=Kn(" ",1);function ID(s,e){if(new.target)return Tt({component:ID,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(T,"$started",t),r=un();let o=H(e,"far",7,1e3),a=H(e,"frames",7,1/0),l=H(e,"isBackground",7),c=H(e,"near",7,.1),u=H(e,"onupdatestart",7),h=H(e,"onupdatestop",7),d=H(e,"resolution",7,256),f=H(e,"scene",23,()=>r.scene),m=H(e,"visible",7),v=H(e,"children",7);const{scene:g}=$0(),{camera:_,renderTarget:y}=DD(()=>c(),()=>o(),()=>d());Nw({texture:y.texture,get scene(){return f()},get isBackground(){return l()}});const w=()=>{_.update(r.renderer,g)};let x=0;const{start:M,stop:C,started:T}=ii(()=>{var I;x{var I,R;n()&&(C(),(I=h())==null||I()),x=0,M(),(R=u())==null||R()};Gs(()=>[o(),c(),a(),d()],A);const P=xt(()=>m()?void 0:!1);pt(s,{is:g,get attach(){return fe(P)},children:(I,R)=>{var U=_8(),L=dt(U);pt(L,{is:_});var k=Ln(L,2);Wt(k,()=>v()??Nt,()=>({camera:_,renderTarget:y,restart:A,update:w})),lt(I,U)},$$slots:{default:!0}});var E=Et({camera:_,renderTarget:y,update:w,restart:A,get far(){return o()},set far(I=1e3){o(I),V()},get frames(){return a()},set frames(I=1/0){a(I),V()},get isBackground(){return l()},set isBackground(I){l(I),V()},get near(){return c()},set near(I=.1){c(I),V()},get onupdatestart(){return u()},set onupdatestart(I){u(I),V()},get onupdatestop(){return h()},set onupdatestop(I){h(I),V()},get resolution(){return d()},set resolution(I=256){d(I),V()},get scene(){return f()},set scene(I=r.scene){f(I),V()},get visible(){return m()},set visible(I){m(I),V()},get children(){return v()},set children(I){v(I),V()},$set:Ct,$on:(I,R)=>At(e,I,R)});return i(),E}Pt(ID,{far:{},frames:{},isBackground:{},near:{},onupdatestart:{},onupdatestop:{},resolution:{},scene:{},visible:{},children:{}},[],["camera","renderTarget","update","restart"],!0);const h_=Number.parseInt(_h.replace("dev","")),y8=` varying vec2 vUv; varying vec2 vPos; void main () { gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0); vUv = uv; vPos = position.xy; } `,x8=` // Majority from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44 varying vec2 vUv; varying vec2 vPos; uniform vec2 scale; uniform vec2 imageBounds; uniform float resolution; uniform vec3 color; uniform sampler2D map; uniform sampler2D colorProccessingTexture; uniform float radius; uniform float zoom; uniform float alphaThreshold; uniform float alphaSmoothing; uniform float brightness; uniform float contrast; uniform float monochromeStrength; uniform vec3 monochromeColor; uniform float negative; uniform vec3 hsl; uniform float grayscale; uniform float opacity; uniform int colorProcessingEnabled; uniform int colorProcessingTextureOverride; #define PI 3.14159265; vec2 aspect(vec2 size) { return size / min(size.x, size.y); } // from https://iquilezles.org/articles/distfunctions float udRoundBox(vec2 p, vec2 b, float r) { return length(max(abs(p) - b + r, 0.0)) - r; } float hueToRgb(float p, float q, float t) { if (t < 0.0f) t += 1.0f; if (t > 1.0f) t -= 1.0f; if (t < 1.0f / 6.0f) return p + (q - p) * 6.0f * t; if (t < 1.0f / 2.0f) return q; if (t < 2.0f / 3.0f) return p + (q - p) * (2.0f / 3.0f - t) * 6.0f; return p; } vec3 rgbToHsl(vec3 color) { float max = max(max(color.r, color.g), color.b); float min = min(min(color.r, color.g), color.b); float h, s, l = (max + min) / 2.0f; if (max == min) { h = s = 0.0f; } else { float d = max - min; s = l > 0.5f ? d / (2.0f - max - min) : d / (max + min); if (max == color.r) { h = (color.g - color.b) / d + (color.g < color.b ? 6.0f : 0.0f); } else if (max == color.g) { h = (color.b - color.r) / d + 2.0f; } else if (max == color.b) { h = (color.r - color.g) / d + 4.0f; } h /= 6.0f; } return vec3(h, s, l); } vec3 hslToRgb(vec3 hsl) { float h = hsl.x; float s = hsl.y; float l = hsl.z; float r, g, b; if (s == 0.0f) { r = g = b = l; } else { float q = l < 0.5f ? l * (1.0f + s) : l + s - l * s; float p = 2.0f * l - q; r = hueToRgb(p, q, h + 1.0f / 3.0f); g = hueToRgb(p, q, h); b = hueToRgb(p, q, h - 1.0f / 3.0f); } return vec3(r, g, b); } vec3 monochrome(float x, vec3 col) { return col * exp(4.0 * x - 1.0); } void processColors (inout vec4 colors) { vec4 strength = vec4(1.0); if (colorProcessingTextureOverride == 1) { strength = texture2D(colorProccessingTexture, vUv); float smoothedAlpha = smoothstep(1.0 - alphaThreshold - alphaSmoothing, 1.0 - alphaThreshold, strength.a + 0.0001); colors.a *= smoothedAlpha; if (gl_FragColor.a == 0.0) { discard; return; } } // BRIGHTNESS colors.rgb = max(colors.rgb + brightness, 0.0); // CONTRAST colors.rgb = max(((colors.rgb - 0.5) * max(contrast + 1.0, 0.0)) + 0.5, 0.0); // HSL vec3 hslColor = rgbToHsl(colors.rgb); hslColor.x = mod(hslColor.x + hsl.x * strength.r ,1.0); hslColor.y *= (1.0 + hsl.y * strength.g); hslColor.z += hsl.z * strength.b; colors.rgb = max(hslToRgb(hslColor), vec3(0.0)); // MONOCHROME colors.rgb = mix(colors.rgb, monochrome(hslColor.z, monochromeColor), monochromeStrength); } void main() { vec2 s = aspect(scale); vec2 i = aspect(imageBounds); float rs = s.x / s.y; float ri = i.x / i.y; vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x); vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new; vec2 uv = vUv * s / new + offset; vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5); vec2 res = vec2(scale * resolution); vec2 halfRes = 0.5 * res; float b = udRoundBox(vUv.xy * res - halfRes, halfRes, resolution * radius); vec3 a = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), smoothstep(0.0, 1.0, b)); gl_FragColor = texture2D(map, zUv) * vec4(color, opacity * a); if (colorProcessingEnabled == 1) { processColors(gl_FragColor); } if (gl_FragColor.a == 0.0) { discard; } #include #include <${h_>=154?"colorspace_fragment":"encodings_fragment"}> gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(1.0) - gl_FragColor.rgb, negative); } `;function Cp(s,e){if(new.target)return Tt({component:Cp,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(z,"$textureStore",t),r=()=>Rn(G,"$size",t),o=()=>Rn(W,"$parent",t);let a=H(e,"color",7,"white"),l=H(e,"zoom",7,1),c=H(e,"radius",7,0),u=H(e,"alphaThreshold",7,0),h=H(e,"alphaSmoothing",7,.1),d=H(e,"brightness",7,0),f=H(e,"contrast",7,0),m=H(e,"hue",7,0),v=H(e,"saturation",7,0),g=H(e,"lightness",7,0),_=H(e,"negative",7,!1),y=H(e,"opacity",7,1),w=H(e,"toneMapped",7,!0),x=H(e,"transparent",7,!1),M=H(e,"texture",7),C=H(e,"monochromeColor",7),T=H(e,"monochromeStrength",7),A=H(e,"colorProcessingTexture",7),P=H(e,"side",7),E=H(e,"url",7),I=H(e,"ref",15),R=H(e,"children",7),U=an(e,["$$slots","$$events","$$legacy","$$host","color","zoom","radius","alphaThreshold","alphaSmoothing","brightness","contrast","hue","saturation","lightness","negative","opacity","toneMapped","transparent","texture","monochromeColor","monochromeStrength","colorProcessingTexture","side","url","ref","children"]);const L=new Ti,k=Ml();let z=uu(Promise.resolve(void 0));$e(()=>{z=k(E()?LR(E()):uu(Promise.resolve(M())))});let{size:G}=un();const W=To(),q={color:{value:new rt(a())},scale:{value:new Ne},imageBounds:{value:new Ne(1,1)},resolution:{value:1024},map:{value:null},zoom:{value:l()},radius:{value:c()},alphaThreshold:{value:u()},alphaSmoothing:{value:h()},brightness:{value:d()},contrast:{value:f()},monochromeColor:{value:new rt(C())},monochromeStrength:{value:T()??0},negative:{value:_()?1:0},opacity:{value:y()},hsl:{value:new X(0,0,0)},colorProccessingTexture:{value:null},colorProcessingTextureOverride:{value:0},colorProcessingEnabled:{value:1}};$e(()=>{q.color.value.set(a())}),$e(()=>{var B,J;q.imageBounds.value.set(((B=n())==null?void 0:B.image.width)??0,((J=n())==null?void 0:J.image.height)??0)}),$e(()=>{q.resolution.value=Math.max(r().width,r().height)}),$e(()=>{q.zoom.value=l()}),$e(()=>{q.radius.value=c()}),$e(()=>{q.opacity.value=y()}),$e(()=>{q.alphaThreshold.value=u()}),$e(()=>{q.alphaSmoothing.value=h()}),$e(()=>{q.brightness.value=d()}),$e(()=>{q.contrast.value=f()}),$e(()=>{q.hsl.value.x=m()}),$e(()=>{q.hsl.value.z=g()}),$e(()=>{q.negative.value=_()?1:0}),$e(()=>{q.map.value=n()??null}),$e(()=>{q.colorProccessingTexture.value=A()??null}),$e(()=>{q.colorProcessingTextureOverride.value=A()?1:0}),$e(()=>{C()!==void 0?(q.monochromeColor.value.set(C()),q.monochromeStrength.value=T()??1):q.monochromeStrength.value=0}),$e(()=>{let B=0;const J=(C()?1:0)*(T()===void 0?1:T());for(const re of[d(),f(),m(),v(),g(),J,A()?1:0])if(re!==0){B=1;break}q.colorProcessingEnabled.value=B}),ii(()=>{const B=o();if(!wn(B,"Mesh"))return;q.scale.value.set(B.scale.x,B.scale.y);const J=B.geometry;if(J!==void 0&&"parameters"in J){const{width:re,height:K}=J.parameters;q.scale.value.set(q.scale.value.x*re,q.scale.value.y*K)}}),pt(s,rn({is:L,uniforms:q,get toneMapped(){return w()},get transparent(){return x()},get side(){return P()},vertexShader:y8,fragmentShader:x8},()=>U,{get ref(){return I()},set ref(B){I(B)},children:(B,J)=>{var re=Lt(),K=dt(re);Wt(K,()=>R()??Nt,()=>({ref:L})),lt(B,re)},$$slots:{default:!0}}));var O=Et({get color(){return a()},set color(B="white"){a(B),V()},get zoom(){return l()},set zoom(B=1){l(B),V()},get radius(){return c()},set radius(B=0){c(B),V()},get alphaThreshold(){return u()},set alphaThreshold(B=0){u(B),V()},get alphaSmoothing(){return h()},set alphaSmoothing(B=.1){h(B),V()},get brightness(){return d()},set brightness(B=0){d(B),V()},get contrast(){return f()},set contrast(B=0){f(B),V()},get hue(){return m()},set hue(B=0){m(B),V()},get saturation(){return v()},set saturation(B=0){v(B),V()},get lightness(){return g()},set lightness(B=0){g(B),V()},get negative(){return _()},set negative(B=!1){_(B),V()},get opacity(){return y()},set opacity(B=1){y(B),V()},get toneMapped(){return w()},set toneMapped(B=!0){w(B),V()},get transparent(){return x()},set transparent(B=!1){x(B),V()},get texture(){return M()},set texture(B){M(B),V()},get monochromeColor(){return C()},set monochromeColor(B){C(B),V()},get monochromeStrength(){return T()},set monochromeStrength(B){T(B),V()},get colorProcessingTexture(){return A()},set colorProcessingTexture(B){A(B),V()},get side(){return P()},set side(B){P(B),V()},get url(){return E()},set url(B){E(B),V()},get ref(){return I()},set ref(B){I(B),V()},get children(){return R()},set children(B){R(B),V()},$set:Ct,$on:(B,J)=>At(e,B,J)});return i(),O}Pt(Cp,{color:{},zoom:{},radius:{},alphaThreshold:{},alphaSmoothing:{},brightness:{},contrast:{},hue:{},saturation:{},lightness:{},negative:{},opacity:{},toneMapped:{},transparent:{},texture:{},monochromeColor:{},monochromeStrength:{},colorProcessingTexture:{},side:{},url:{},ref:{},children:{}},[],[],!0);const b8=` varying vec3 localPosition; varying vec4 worldPosition; uniform vec3 worldCamProjPosition; uniform vec3 worldPlanePosition; uniform float fadeDistance; uniform bool infiniteGrid; uniform bool followCamera; uniform int coord0; uniform int coord1; uniform int coord2; void main() { localPosition = vec3( position[coord0], position[coord1], position[coord2] ); if (infiniteGrid) { localPosition *= 1.0 + fadeDistance; } worldPosition = modelMatrix * vec4(localPosition, 1.0); if (followCamera) { worldPosition.xyz += (worldCamProjPosition - worldPlanePosition); localPosition = (inverse(modelMatrix) * worldPosition).xyz; } gl_Position = projectionMatrix * viewMatrix * worldPosition; } `,w8=` #define PI 3.141592653589793 varying vec3 localPosition; varying vec4 worldPosition; uniform vec3 worldCamProjPosition; uniform float cellSize; uniform float sectionSize; uniform vec3 cellColor; uniform vec3 sectionColor; uniform float fadeDistance; uniform float fadeStrength; uniform float cellThickness; uniform float sectionThickness; uniform vec3 backgroundColor; uniform float backgroundOpacity; uniform bool infiniteGrid; uniform int coord0; uniform int coord1; uniform int coord2; // 0 - default; 1 - lines; 2 - circles; 3 - polar uniform int gridType; // lineGrid coord for lines uniform int lineGridCoord; // circlegrid max radius uniform float circleGridMaxRadius; // polar grid dividers uniform float polarCellDividers; uniform float polarSectionDividers; float getSquareGrid(float size, float thickness, vec3 localPos) { vec2 coord = localPos.xy / size; vec2 grid = abs(fract(coord - 0.5) - 0.5) / fwidth(coord); float line = min(grid.x, grid.y) + 1.0 - thickness; return 1.0 - min(line, 1.0); } float getLinesGrid(float size, float thickness, vec3 localPos) { float coord = localPos[lineGridCoord] / size; float line = abs(fract(coord - 0.5) - 0.5) / fwidth(coord) - thickness * 0.2; return 1.0 - min(line, 1.0); } float getCirclesGrid(float size, float thickness, vec3 localPos) { float coord = length(localPos.xy) / size; float line = abs(fract(coord - 0.5) - 0.5) / fwidth(coord) - thickness * 0.2; if (!infiniteGrid && circleGridMaxRadius > 0. && coord > circleGridMaxRadius + thickness * 0.05) { discard; } return 1.0 - min(line, 1.0); } float getPolarGrid(float size, float thickness, float polarDividers, vec3 localPos) { float rad = length(localPos.xy) / size; vec2 coord = vec2(rad, atan(localPos.x, localPos.y) * polarDividers / PI) ; vec2 wrapped = vec2(coord.x, fract(coord.y / (2.0 * polarDividers)) * (2.0 * polarDividers)); vec2 coordWidth = fwidth(coord); vec2 wrappedWidth = fwidth(wrapped); vec2 width = (coord.y < -polarDividers * 0.5 || coord.y > polarDividers * 0.5 ? wrappedWidth : coordWidth) * (1.+thickness*0.25); // Compute anti-aliased world-space grid lines vec2 grid = abs(fract(coord - 0.5) - 0.5) / width; float line = min(grid.x, grid.y); if (!infiniteGrid && circleGridMaxRadius > 0.0 && rad > circleGridMaxRadius + thickness * 0.05) { discard; } return 1.0 - min(line, 1.0); } void main() { float g1 = 0.0; float g2 = 0.0; vec3 localPos = vec3(localPosition[coord0], localPosition[coord1], localPosition[coord2]); if (gridType == 0) { g1 = getSquareGrid(cellSize, cellThickness, localPos); g2 = getSquareGrid(sectionSize, sectionThickness, localPos); } else if (gridType == 1) { g1 = getLinesGrid(cellSize, cellThickness, localPos); g2 = getLinesGrid(sectionSize, sectionThickness, localPos); } else if (gridType == 2) { g1 = getCirclesGrid(cellSize, cellThickness, localPos); g2 = getCirclesGrid(sectionSize, sectionThickness, localPos); } else if (gridType == 3) { g1 = getPolarGrid(cellSize, cellThickness, polarCellDividers, localPos); g2 = getPolarGrid(sectionSize, sectionThickness, polarSectionDividers, localPos); } float dist = distance(worldCamProjPosition, worldPosition.xyz); float d = 1.0 - min(dist / fadeDistance, 1.0); float fadeFactor = pow(d, fadeStrength) * 0.95; vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2)); if (backgroundOpacity > 0.0) { float linesAlpha = clamp((g1 + g2) * fadeFactor, 0.0,1.0); vec3 finalColor = mix(backgroundColor, color, linesAlpha); float blendedAlpha = max(linesAlpha, backgroundOpacity * fadeFactor); gl_FragColor = vec4(finalColor, blendedAlpha); } else { gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength)); gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2); } if (gl_FragColor.a <= 0.0) { discard; } #include #include <${h_<154?"encodings_fragment":"colorspace_fragment"}> } `;var S8=Kn(" ",1);function LD(s,e){if(new.target)return Tt({component:LD,...s});Mt(e,!0);let t=H(e,"cellColor",7,"#000000"),i=H(e,"sectionColor",7,"#0000ee"),n=H(e,"cellSize",7,1),r=H(e,"backgroundColor",7,"#dadada"),o=H(e,"backgroundOpacity",7,0),a=H(e,"sectionSize",7,10),l=H(e,"plane",7,"xz"),c=H(e,"gridSize",23,()=>[20,20]),u=H(e,"followCamera",7,!1),h=H(e,"infiniteGrid",7,!1),d=H(e,"fadeDistance",7,100),f=H(e,"fadeStrength",7,1),m=H(e,"cellThickness",7,1),v=H(e,"sectionThickness",7,2),g=H(e,"side",7,Ei),_=H(e,"type",7,"grid"),y=H(e,"axis",7,"x"),w=H(e,"maxRadius",7,0),x=H(e,"cellDividers",7,6),M=H(e,"sectionDividers",7,2),C=H(e,"ref",15),T=H(e,"children",7),A=an(e,["$$slots","$$events","$$legacy","$$host","cellColor","sectionColor","cellSize","backgroundColor","backgroundOpacity","sectionSize","plane","gridSize","followCamera","infiniteGrid","fadeDistance","fadeStrength","cellThickness","sectionThickness","side","type","axis","maxRadius","cellDividers","sectionDividers","ref","children"]);const P=new it,{invalidate:E,camera:I}=un(),R=new to,U=new X(0,1,0),L=new X(0,0,0),k={x:0,y:1,z:2},z={xz:"xzy",xy:"xyz",zy:"zyx"},G={grid:0,lines:1,circular:2,polar:3},W={cellSize:{value:n()},sectionSize:{value:a()},cellColor:{value:new rt(t())},sectionColor:{value:new rt(i())},backgroundColor:{value:new rt(r())},backgroundOpacity:{value:o()},fadeDistance:{value:d()},fadeStrength:{value:f()},cellThickness:{value:m()},sectionThickness:{value:v()},infiniteGrid:{value:h()},followCamera:{value:u()},coord0:{value:0},coord1:{value:2},coord2:{value:1},gridType:{value:G.grid},lineGridCoord:{value:k[y()]},circleGridMaxRadius:{value:w()},polarCellDividers:{value:x()},polarSectionDividers:{value:M()},worldCamProjPosition:{value:new X},worldPlanePosition:{value:new X}};return $e(()=>{const q=z[l()],O=q.charAt(0),B=q.charAt(1),J=q.charAt(2);W.coord0.value=k[O],W.coord1.value=k[B],W.coord2.value=k[J],E()}),$e(()=>{W.cellSize.value=n(),E()}),$e(()=>{W.sectionSize.value=a(),E()}),$e(()=>{W.cellColor.value.set(t()),E()}),$e(()=>{W.sectionColor.value.set(i()),E()}),$e(()=>{W.backgroundColor.value.set(r()),E()}),$e(()=>{W.backgroundOpacity.value=o(),E()}),$e(()=>{W.fadeDistance.value=d(),E()}),$e(()=>{W.fadeStrength.value=f(),E()}),$e(()=>{W.cellThickness.value=m(),E()}),$e(()=>{W.sectionThickness.value=v(),E()}),$e(()=>{W.followCamera.value=u(),E()}),$e(()=>{W.infiniteGrid.value=h(),E()}),$e(()=>{switch(_()){case"grid":{W.gridType.value=G.grid;break}case"lines":{W.gridType.value=G.lines,W.lineGridCoord.value=k[y()];break}case"circular":{W.gridType.value=G.circular,W.circleGridMaxRadius.value=w();break}case"polar":{W.gridType.value=G.polar,W.circleGridMaxRadius.value=w(),W.polarCellDividers.value=x(),W.polarSectionDividers.value=M();break}}E()}),ii(()=>{R.setFromNormalAndCoplanarPoint(U,L).applyMatrix4(P.matrixWorld);const q=P.material,O=q.uniforms.worldCamProjPosition,B=q.uniforms.worldPlanePosition;R.projectPoint(I.current.position,O.value),B.value.set(0,0,0).applyMatrix4(P.matrixWorld)},{autoInvalidate:!1}),pt(s,rn({is:P,frustumCulled:!1},()=>A,{get ref(){return C()},set ref(q){C(q)},children:(q,O)=>{var B=S8(),J=dt(B);Ss(J,()=>pt.ShaderMaterial,(ue,le)=>{le(ue,{fragmentShader:w8,vertexShader:b8,uniforms:W,transparent:!0,get side(){return g()}})});var re=Ln(J,2);{var K=ue=>{var le=Lt(),_e=dt(le);Wt(_e,T,()=>({ref:P})),lt(ue,le)},Q=ue=>{var le=Lt(),_e=dt(le);const Fe=xt(()=>typeof c()=="number"?[c(),c()]:c());Ss(_e,()=>pt.PlaneGeometry,(Ie,Ee)=>{Ee(Ie,{get args(){return fe(Fe)}})}),lt(ue,le)};wi(re,ue=>{T()?ue(K):ue(Q,!1)})}lt(q,B)},$$slots:{default:!0}})),Et({get cellColor(){return t()},set cellColor(q="#000000"){t(q),V()},get sectionColor(){return i()},set sectionColor(q="#0000ee"){i(q),V()},get cellSize(){return n()},set cellSize(q=1){n(q),V()},get backgroundColor(){return r()},set backgroundColor(q="#dadada"){r(q),V()},get backgroundOpacity(){return o()},set backgroundOpacity(q=0){o(q),V()},get sectionSize(){return a()},set sectionSize(q=10){a(q),V()},get plane(){return l()},set plane(q="xz"){l(q),V()},get gridSize(){return c()},set gridSize(q=[20,20]){c(q),V()},get followCamera(){return u()},set followCamera(q=!1){u(q),V()},get infiniteGrid(){return h()},set infiniteGrid(q=!1){h(q),V()},get fadeDistance(){return d()},set fadeDistance(q=100){d(q),V()},get fadeStrength(){return f()},set fadeStrength(q=1){f(q),V()},get cellThickness(){return m()},set cellThickness(q=1){m(q),V()},get sectionThickness(){return v()},set sectionThickness(q=2){v(q),V()},get side(){return g()},set side(q=Ei){g(q),V()},get type(){return _()},set type(q="grid"){_(q),V()},get axis(){return y()},set axis(q="x"){y(q),V()},get maxRadius(){return w()},set maxRadius(q=0){w(q),V()},get cellDividers(){return x()},set cellDividers(q=6){x(q),V()},get sectionDividers(){return M()},set sectionDividers(q=2){M(q),V()},get ref(){return C()},set ref(q){C(q),V()},get children(){return T()},set children(q){T(q),V()},$set:Ct,$on:(q,O)=>At(e,q,O)})}Pt(LD,{cellColor:{},sectionColor:{},cellSize:{},backgroundColor:{},backgroundOpacity:{},sectionSize:{},plane:{},gridSize:{},followCamera:{},infiniteGrid:{},fadeDistance:{},fadeStrength:{},cellThickness:{},sectionThickness:{},side:{},type:{},axis:{},maxRadius:{},cellDividers:{},sectionDividers:{},ref:{},children:{}},[],[],!0);function UD(s,e){if(new.target)return Tt({component:UD,...s});Mt(e,!0);let t=H(e,"args",23,()=>[]),i=H(e,"radius",7,.05),n=H(e,"smoothness",7,4),r=H(e,"creaseAngle",7,.4),o=H(e,"steps",7,1),a=H(e,"ref",15),l=H(e,"children",7),c=an(e,["$$slots","$$events","$$legacy","$$host","args","radius","smoothness","creaseAngle","steps","ref","children"]);const u=1e-5,h=(y,w,x)=>{const M=new vl,C=x-u;return M.absarc(u,u,u,-Math.PI/2,-Math.PI,!0),M.absarc(u,w-C*2,u,Math.PI,Math.PI/2,!0),M.absarc(y-C*2,w-C*2,u,Math.PI/2,0,!0),M.absarc(y-C*2,u,u,0,-Math.PI/2,!0),M};let d=xt(()=>t()[0]??1),f=xt(()=>t()[1]??1),m=xt(()=>t()[2]??1),v=xt(()=>h(fe(d),fe(f),i())),g=xt(()=>({depth:fe(m)-i()*2,bevelEnabled:!0,bevelSegments:n()*2,steps:o(),bevelSize:i()-u,bevelThickness:i(),curveSegments:n()})),_=xt(()=>new ed(fe(v),fe(g)));return $e(()=>{fe(_).center(),lw(fe(_),r())}),pt(s,rn({get is(){return fe(_)}},()=>c,{get ref(){return a()},set ref(y){a(y)},children:(y,w)=>{var x=Lt(),M=dt(x);Wt(M,()=>l()??Nt,()=>({ref:fe(_)})),lt(y,x)},$$slots:{default:!0}})),Et({get args(){return t()},set args(y=[]){t(y),V()},get radius(){return i()},set radius(y=.05){i(y),V()},get smoothness(){return n()},set smoothness(y=4){n(y),V()},get creaseAngle(){return r()},set creaseAngle(y=.4){r(y),V()},get steps(){return o()},set steps(y=1){o(y),V()},get ref(){return a()},set ref(y){a(y),V()},get children(){return l()},set children(y){l(y),V()},$set:Ct,$on:(y,w)=>At(e,y,w)})}Pt(UD,{args:{},radius:{},smoothness:{},creaseAngle:{},steps:{},ref:{},children:{}},[],[],!0);const _u=new O0,Fr=new X,Cl=new X,mi=new Tn,kD={X:new X(1,0,0),Y:new X(0,1,0),Z:new X(0,0,1)},Hw={type:"change"},OD={type:"mouseDown",mode:null},FD={type:"mouseUp",mode:null},ND={type:"objectChange"};class M8 extends H0{constructor(e,t=null){super(void 0,t);const i=new R8(this);this._root=i;const n=new D8;this._gizmo=n,i.add(n);const r=new I8;this._plane=r,i.add(r);const o=this;function a(w,x){let M=x;Object.defineProperty(o,w,{get:function(){return M!==void 0?M:x},set:function(C){M!==C&&(M=C,r[w]=C,n[w]=C,o.dispatchEvent({type:w+"-changed",value:C}),o.dispatchEvent(Hw))}}),o[w]=x,r[w]=x,n[w]=x}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new X,c=new X,u=new Tn,h=new Tn,d=new X,f=new Tn,m=new X,v=new X,g=new X,_=0,y=new X;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",u),a("worldQuaternionStart",h),a("cameraPosition",d),a("cameraQuaternion",f),a("pointStart",m),a("pointEnd",v),a("rotationAxis",g),a("rotationAngle",_),a("eye",y),this._offset=new X,this._startNorm=new X,this._endNorm=new X,this._cameraScale=new X,this._parentPosition=new X,this._parentQuaternion=new Tn,this._parentQuaternionInv=new Tn,this._parentScale=new X,this._worldScaleStart=new X,this._worldQuaternionInv=new Tn,this._worldScale=new X,this._positionStart=new X,this._quaternionStart=new Tn,this._scaleStart=new X,this._getPointer=E8.bind(this),this._onPointerDown=A8.bind(this),this._onPointerHover=T8.bind(this),this._onPointerMove=C8.bind(this),this._onPointerUp=P8.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&_u.setFromCamera(e,this.camera);const t=Ww(this._gizmo.picker[this.mode],_u);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&_u.setFromCamera(e,this.camera);const t=Ww(this._plane,_u,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,OD.mode=this.mode,this.dispatchEvent(OD)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&_u.setFromCamera(e,this.camera);const o=Ww(this._plane,_u,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(n.position.applyQuaternion(mi.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),r==="world"&&(n.parent&&n.position.add(Fr.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Fr.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Cl.set(a,a,a)}else Fr.copy(this.pointStart),Cl.copy(this.pointEnd),Fr.applyQuaternion(this._worldQuaternionInv),Cl.applyQuaternion(this._worldQuaternionInv),Cl.divide(Fr),t.search("X")===-1&&(Cl.x=1),t.search("Y")===-1&&(Cl.y=1),t.search("Z")===-1&&(Cl.z=1);n.scale.copy(this._scaleStart).multiply(Cl),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Fr.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Fr.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(kD[t]),Fr.copy(kD[t]),r==="local"&&Fr.applyQuaternion(this.worldQuaternion),Fr.cross(this.eye),Fr.length()===0?l=!0:this.rotationAngle=this._offset.dot(Fr.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(mi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(mi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Hw),this.dispatchEvent(ND)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(FD.mode=this.mode,this.dispatchEvent(FD)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Hw),this.dispatchEvent(ND),this.pointStart.copy(this.pointEnd))}getRaycaster(){return _u}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function E8(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function T8(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function A8(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function C8(s){this.enabled&&this.pointerMove(this._getPointer(s))}function P8(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function Ww(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n.9&&(o.visible=!1)),this.axis==="Y"&&(mi.setFromEuler(d_.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(mi),Math.abs(ei.copy(yu).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(mi.setFromEuler(d_.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(mi),Math.abs(ei.copy(Rp).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(mi.setFromEuler(d_.set(0,Math.PI/2,0)),ei.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(zD.lookAt(BD,ei,yu)),o.quaternion.multiply(mi),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Fr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Fr.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Fr),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(ei.copy(Pp).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(ei.copy(yu).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(ei.copy(Rp).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(ei.copy(Rp).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(ei.copy(Pp).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(ei.copy(yu).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(f_.copy(i),ei.copy(this.eye).applyQuaternion(mi.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(zD.lookAt(this.eye,BD,yu)),o.name==="X"&&(mi.setFromAxisAngle(Pp,Math.atan2(-ei.y,ei.z)),mi.multiplyQuaternions(f_,mi),o.quaternion.copy(mi)),o.name==="Y"&&(mi.setFromAxisAngle(yu,Math.atan2(ei.x,ei.z)),mi.multiplyQuaternions(f_,mi),o.quaternion.copy(mi)),o.name==="Z"&&(mi.setFromAxisAngle(Rp,Math.atan2(ei.y,ei.x)),mi.multiplyQuaternions(f_,mi),o.quaternion.copy(mi))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class I8 extends it{constructor(){super(new es(1e5,1e5,2,2),new Jn({visible:!1,wireframe:!0,side:Ei,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),m_.copy(Pp).applyQuaternion(t==="local"?this.worldQuaternion:p_),Dp.copy(yu).applyQuaternion(t==="local"?this.worldQuaternion:p_),Ip.copy(Rp).applyQuaternion(t==="local"?this.worldQuaternion:p_),ei.copy(Dp),this.mode){case"translate":case"scale":switch(this.axis){case"X":ei.copy(this.eye).cross(m_),ea.copy(m_).cross(ei);break;case"Y":ei.copy(this.eye).cross(Dp),ea.copy(Dp).cross(ei);break;case"Z":ei.copy(this.eye).cross(Ip),ea.copy(Ip).cross(ei);break;case"XY":ea.copy(Ip);break;case"YZ":ea.copy(m_);break;case"XZ":ei.copy(Ip),ea.copy(Dp);break;case"XYZ":case"E":ea.set(0,0,0);break}break;case"rotate":default:ea.set(0,0,0)}ea.length()===0?this.quaternion.copy(this.cameraQuaternion):(VD.lookAt(Fr.set(0,0,0),ea,ei),this.quaternion.setFromRotationMatrix(VD)),super.updateMatrixWorld(e)}}const Xw=()=>aw("threlte-controls",{orbitControls:Hn(void 0),trackballControls:Hn(void 0)});var L8=Kn(" ",1);function GD(s,e){if(new.target)return Tt({component:GD,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(d,"$camera",t);let r=H(e,"autoPauseOrbitControls",7,!0),o=H(e,"autoPauseTrackballControls",7,!0),a=H(e,"object",7),l=H(e,"controls",15),c=H(e,"group",15),u=H(e,"children",7),h=an(e,["$$slots","$$events","$$legacy","$$host","autoPauseOrbitControls","autoPauseTrackballControls","object","controls","group","children"]);const{camera:d,dom:f,invalidate:m,scene:v}=un(),{orbitControls:g,trackballControls:_}=Xw(),y=Yn(!1),w=Hn(r()??!0);$e(()=>w.set(r()??!0));const x=Hn(o()??!0);$e(()=>x.set(o()??!0)),pi([g,y,w],([k,z,G])=>{if(!(!k||!k.enabled&&z))return k.enabled=!(z&&G),()=>{k.enabled=!0}}),pi([_,y,x],([k,z,G])=>{if(!(!k||!k.enabled&&z))return k.enabled=!(z&&G),()=>{k.enabled=!0}});const M=new Qn;let C=xt(()=>new M8(n(),f));$e(()=>{var k;return(k=fe(C))==null||k.attach(a()??M),()=>{var z;return(z=fe(C))==null?void 0:z.detach()}});const T=["enabled","axis","mode","translationSnap","rotationSnap","scaleSnap","space","size","showX","showY","showZ","visible","onmouseDown","onmouseUp","onobjectChange"];let A=xs(hr({})),P=xs(hr({}));$e(()=>{Mn(A,hr({})),Mn(P,hr({})),Object.keys(h).forEach(k=>{$e(()=>{T.includes(k)?fe(A)[k]=h[k]:fe(P)[k]=h[k]})})});const E=k=>{var z;m(),fe(C).dragging&&!y.current?y.set(!0):!fe(C).dragging&&y.current&&y.set(!1),(z=e.onchange)==null||z.call(e,k)};var I=L8(),R=dt(I);pt(R,rn({get is(){return fe(C)},onchange:E},()=>fe(A),{attach:({ref:k})=>{const z=k.getHelper();return v.add(z),()=>{v.remove(z)}},dispose:!1,oncreate:k=>()=>k.dispose(),get ref(){return l()},set ref(k){l(k)}}));var U=Ln(R,2);pt(U,rn({is:M},()=>fe(P),{get ref(){return c()},set ref(k){c(k)},children:(k,z)=>{var G=Lt(),W=dt(G);{var q=O=>{var B=Lt(),J=dt(B);Wt(J,u,()=>({ref:M})),lt(O,B)};wi(W,O=>{u()&&O(q)})}lt(k,G)},$$slots:{default:!0}})),lt(s,I);var L=Et({get autoPauseOrbitControls(){return r()},set autoPauseOrbitControls(k=!0){r(k),V()},get autoPauseTrackballControls(){return o()},set autoPauseTrackballControls(k=!0){o(k),V()},get object(){return a()},set object(k){a(k),V()},get controls(){return l()},set controls(k){l(k),V()},get group(){return c()},set group(k){c(k),V()},get children(){return u()},set children(k){u(k),V()},$set:Ct,$on:(k,z)=>At(e,k,z)});return i(),L}Pt(GD,{autoPauseOrbitControls:{},autoPauseTrackballControls:{},object:{},controls:{},group:{},children:{}},[],[],!0);function HD(s,e){if(new.target)return Tt({component:HD,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(l,"$parent",t);let r=H(e,"ref",15),o=H(e,"children",7),a=an(e,["$$slots","$$events","$$legacy","$$host","ref","children"]);const l=To(),{dom:c,invalidate:u}=un();if(!wn(n(),"Camera"))throw new Error("Parent missing: need to be a child of a ");const h=new gD(n(),c),{orbitControls:d}=Xw(),{start:f,stop:m}=ii(()=>{h.update()},{autoStart:!1,autoInvalidate:!1});$e(()=>{e.autoRotate||e.enableDamping?f():m()}),$e(()=>{const g=_=>{var y;u(),(y=e.onchange)==null||y.call(e,_)};return d.set(h),h.addEventListener("change",g),()=>{d.set(void 0),h.removeEventListener("change",g)}}),pt(s,rn({is:h},()=>a,{get ref(){return r()},set ref(g){r(g)},children:(g,_)=>{var y=Lt(),w=dt(y);Wt(w,()=>o()??Nt,()=>({ref:h})),lt(g,y)},$$slots:{default:!0}}));var v=Et({get ref(){return r()},set ref(g){r(g),V()},get children(){return o()},set children(g){o(g),V()},$set:Ct,$on:(g,_)=>At(e,g,_)});return i(),v}Pt(HD,{ref:{},children:{}},[],[],!0);function WD(s,e){if(new.target)return Tt({component:WD,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(l,"$parent",t);let r=H(e,"ref",15),o=H(e,"children",7),a=an(e,["$$slots","$$events","$$legacy","$$host","ref","children"]);const l=To(),{dom:c,invalidate:u}=un();if(!wn(n(),"Camera"))throw new Error("Parent missing: need to be a child of a ");const h=new yD(n(),c),{trackballControls:d}=Xw();ii(()=>{h.update()},{autoInvalidate:!1}),Ht(()=>{const m=v=>{var g;u(),(g=e.onchange)==null||g.call(e,v)};return d.set(h),h.addEventListener("change",m),()=>{d.set(void 0),h.removeEventListener("change",m)}}),pt(s,rn({is:h},()=>a,{get ref(){return r()},set ref(m){r(m)},children:(m,v)=>{var g=Lt(),_=dt(g);Wt(_,()=>o()??Nt,()=>({ref:h})),lt(m,g)},$$slots:{default:!0}}));var f=Et({get ref(){return r()},set ref(m){r(m),V()},get children(){return o()},set children(m){o(m),V()},$set:Ct,$on:(m,v)=>At(e,m,v)});return i(),f}Pt(WD,{ref:{},children:{}},[],[],!0);const XD=s=>`threlte-instanced-mesh-${s}`,U8=(s,e)=>{const t={instancedMesh:Yn(s),addInstance(i){t.instances.update(n=>(n.push(i),n))},removeInstance(i){t.instances.update(n=>{const r=n.indexOf(i);return r>-1&&n.splice(r,1),n})},instances:Yn([])};return ur(XD(e),t),t},k8=s=>{const e=nr(XD(s));if(!e)throw new Error(`No component found for id ${s}`);return e};var O8=Kn(" ",1);function Yw(s,e){if(new.target)return Tt({component:Yw,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(h,"$instances",t);let r=H(e,"instancedMesh",7),o=H(e,"id",7),a=H(e,"limit",7),l=H(e,"range",7),c=H(e,"update",7),u=H(e,"children",7);const{instances:h}=U8(r(),o()),d=new _t,f=new Float32Array(a()*16);for(let R=0;R{if(r().updateMatrix(),c()||!x){r().updateMatrixWorld(),v.copy(r().matrixWorld).invert(),r().instanceColor&&(r().instanceColor.needsUpdate=!0),r().instanceMatrix.needsUpdate=!0;for(let R=0,U=h.current.length;R{const R=Math.min(a(),l()!==void 0?l():a(),n().length);r().count=R,dR>=159?(r().instanceMatrix.clearUpdateRanges(),r().instanceMatrix.addUpdateRange(0,R*16)):r().instanceMatrix.updateRange.count=R*16,r().instanceColor&&(dR>=159?(r().instanceColor.clearUpdateRanges(),r().instanceColor.addUpdateRange(0,R*3)):r().instanceColor.updateRange.count=R*3)});var M=O8(),C=dt(M);const T=xt(()=>f.length/16);Ss(C,()=>pt.InstancedBufferAttribute,(R,U)=>{U(R,{attach:"instanceMatrix",get count(){return fe(T)},array:f,itemSize:16,usage:Ph})});var A=Ln(C,2);const P=xt(()=>m.length/3);Ss(A,()=>pt.InstancedBufferAttribute,(R,U)=>{U(R,{attach:"instanceColor",get count(){return fe(P)},array:m,itemSize:3,usage:Ph})});var E=Ln(A,2);Wt(E,()=>u()??Nt),lt(s,M);var I=Et({get instancedMesh(){return r()},set instancedMesh(R){r(R),V()},get id(){return o()},set id(R){o(R),V()},get limit(){return a()},set limit(R){a(R),V()},get range(){return l()},set range(R){l(R),V()},get update(){return c()},set update(R){c(R),V()},get children(){return u()},set children(R){u(R),V()},$set:Ct,$on:(R,U)=>At(e,R,U)});return i(),I}Pt(Yw,{instancedMesh:{},id:{},limit:{},range:{},update:{},children:{}},[],[],!0);function jw(s,e){if(new.target)return Tt({component:jw,...s});Mt(e,!0);let t=H(e,"id",7,"default"),i=H(e,"limit",7,1e3),n=H(e,"range",7,1e3),r=H(e,"update",7,!0),o=H(e,"ref",15),a=H(e,"children",7),l=an(e,["$$slots","$$events","$$legacy","$$host","id","limit","range","update","ref","children"]);const c=new Jh(null,null,0);return pt(s,rn({is:c,raycast:()=>null,matrixAutoUpdate:!1,args:[null,null,0]},()=>l,{get ref(){return o()},set ref(h){o(h)},children:(h,d)=>{Yw(h,{instancedMesh:c,get id(){return t()},get limit(){return i()},get range(){return n()},get update(){return r()},children:(f,m)=>{var v=Lt(),g=dt(v);Wt(g,()=>a()??Nt,()=>({ref:c})),lt(f,v)},$$slots:{default:!0}})},$$slots:{default:!0}})),Et({get id(){return t()},set id(h="default"){t(h),V()},get limit(){return i()},set limit(h=1e3){i(h),V()},get range(){return n()},set range(h=1e3){n(h),V()},get update(){return r()},set update(h=!0){r(h),V()},get ref(){return o()},set ref(h){o(h),V()},get children(){return a()},set children(h){a(h),V()},$set:Ct,$on:(h,d)=>At(e,h,d)})}Pt(jw,{id:{},limit:{},range:{},update:{},ref:{},children:{}},[],[],!0);const YD=new _t,jD=new _t,g_=[],Lp=new it;class F8 extends Qn{constructor(t,i){super();ht(this,"color");ht(this,"instancedMesh");ht(this,"instances");this.color=new rt("white"),this.instancedMesh=t,this.instances=i}get geometry(){var t;return(t=this.instancedMesh.current)==null?void 0:t.geometry}raycast(t,i){var a;const n=this.instancedMesh.current;if(n===void 0||n.geometry===void 0||n.material===void 0)return;Lp.geometry=n.geometry;const r=n.matrixWorld,o=this.instances.current.indexOf(this);if(!(o===-1||o>n.count)){n.getMatrixAt(o,YD),jD.multiplyMatrices(r,YD),Lp.matrixWorld=jD,wn(n.material,"Material")?Lp.material.side=n.material.side:Lp.material.side=((a=n.material[0])==null?void 0:a.side)??ks,Lp.raycast(t,g_);for(let l=0,c=g_.length;l{ur(qD,s)},ZD=()=>nr(qD)??"default";function qw(s,e){if(new.target)return Tt({component:qw,...s});Mt(e,!0);let t=H(e,"id",23,ZD),i=H(e,"ref",15),n=H(e,"children",7),r=an(e,["$$slots","$$events","$$legacy","$$host","id","ref","children"]);const{addInstance:o,removeInstance:a,instancedMesh:l,instances:c}=k8(t()),u=new F8(l,c);return o(u),Ui(()=>{a(u)}),pt(s,rn({is:u},()=>r,{get ref(){return i()},set ref(h){i(h)},children:(h,d)=>{var f=Lt(),m=dt(f);Wt(m,()=>n()??Nt,()=>({ref:u})),lt(h,f)},$$slots:{default:!0}})),Et({get id(){return t()},set id(h=ZD()){t(h),V()},get ref(){return i()},set ref(h){i(h),V()},get children(){return n()},set children(h){n(h),V()},$set:Ct,$on:(h,d)=>At(e,h,d)})}Pt(qw,{id:{},ref:{},children:{}},[],[],!0);function v_(s,e){if(new.target)return Tt({component:v_,...s});Mt(e,!0);let t=H(e,"meshes",7),i=H(e,"index",23,()=>t().length-1),n=H(e,"children",7),r=an(e,["$$slots","$$events","$$legacy","$$host","meshes","index","children"]);const o=t()[i()];var a=Lt(),l=dt(a);{var c=h=>{jw(h,rn({get geometry(){return o.geometry},get material(){return o.material},get id(){return o.uuid}},()=>r,{children:(d,f)=>{const m=xt(()=>i()-1);v_(d,rn({get meshes(){return t()},get index(){return fe(m)}},()=>r,{children:(v,g)=>{var _=Lt(),y=dt(_);Wt(y,()=>n()??Nt),lt(v,_)},$$slots:{default:!0}}))},$$slots:{default:!0}}))},u=h=>{var d=Lt(),f=dt(d);Wt(f,()=>n()??Nt),lt(h,d)};wi(l,h=>{i()>-1?h(c):h(u,!1)})}return lt(s,a),Et({get meshes(){return t()},set meshes(h){t(h),V()},get index(){return i()},set index(h=t.length-1){i(h),V()},get children(){return n()},set children(h){n(h),V()},$set:Ct,$on:(h,d)=>At(e,h,d)})}Pt(v_,{meshes:{},index:{},children:{}},[],[],!0);function KD(s,e){if(new.target)return Tt({component:KD,...s});Mt(e,!0);let t=H(e,"meshes",7),i=H(e,"children",7),n=an(e,["$$slots","$$events","$$legacy","$$host","meshes","children"]);const r=h=>(...d)=>(N8(h),qw(...d)),o=h=>h.filter(d=>d.isMesh).map(d=>r(d.uuid)),a=h=>Object.entries(h).reduce((d,[f,m])=>(m.isMesh&&(d[f]=r(m.uuid)),d),{});let l=xt(()=>Array.isArray(t())?o(t()):a(t())),c=xt(()=>Array.isArray(t())?t():Object.values(t())),u=xt(()=>fe(c).filter(h=>h.isMesh));return v_(s,rn({get meshes(){return fe(u)}},()=>n,{children:(h,d)=>{var f=Lt(),m=dt(f);Wt(m,()=>i()??Nt,()=>({components:fe(l)})),lt(h,f)},$$slots:{default:!0}})),Et({get meshes(){return t()},set meshes(h){t(h),V()},get children(){return i()},set children(h){i(h),V()},$set:Ct,$on:(h,d)=>At(e,h,d)})}Pt(KD,{meshes:{},children:{}},[],[],!0);function $D(s,e){if(new.target)return Tt({component:$D,...s});Mt(e,!0);const{renderer:t,camera:i,scene:n}=un();let r=H(e,"size",7,25),o=H(e,"focus",7,0),a=H(e,"samples",7,10);const l=Ft.shadowmap_pars_fragment;let c=xt(()=>` #define PENUMBRA_FILTER_SIZE float(${r()}) #define RGB_NOISE_FUNCTION(uv) (randRGB(uv)) vec3 randRGB(vec2 uv) { return vec3( fract(sin(dot(uv, vec2(12.75613, 38.12123))) * 13234.76575), fract(sin(dot(uv, vec2(19.45531, 58.46547))) * 43678.23431), fract(sin(dot(uv, vec2(23.67817, 78.23121))) * 93567.23423) ); } vec3 lowPassRandRGB(vec2 uv) { // 3x3 convolution (average) // can be implemented as separable with an extra buffer for a total of 6 samples instead of 9 vec3 result = vec3(0); result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, -1.0)); result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, 0.0)); result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, +1.0)); result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, -1.0)); result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, 0.0)); result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, +1.0)); result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, -1.0)); result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, 0.0)); result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, +1.0)); result *= 0.111111111; // 1.0 / 9.0 return result; } vec3 highPassRandRGB(vec2 uv) { // by subtracting the low-pass signal from the original signal, we're being left with the high-pass signal // hp(x) = x - lp(x) return RGB_NOISE_FUNCTION(uv) - lowPassRandRGB(uv) + 0.5; } 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; } float penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation return (zReceiver - zBlocker) / zBlocker; } float findBlocker(sampler2D shadowMap, vec2 uv, float compare, float angle) { float texelSize = 1.0 / float(textureSize(shadowMap, 0).x); float blockerDepthSum = float(${o()}); float blockers = 0.0; int j = 0; vec2 offset = vec2(0.); float depth = 0.; #pragma unroll_loop_start for(int i = 0; i < ${a()}; i ++) { offset = (vogelDiskSample(j, ${a()}, angle) * texelSize) * 2.0 * PENUMBRA_FILTER_SIZE; depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset)); if (depth < compare) { blockerDepthSum += depth; blockers++; } j++; } #pragma unroll_loop_end if (blockers > 0.0) { return blockerDepthSum / blockers; } return -1.0; } float vogelFilter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius, float angle) { float texelSize = 1.0 / float(textureSize(shadowMap, 0).x); float shadow = 0.0f; int j = 0; vec2 vogelSample = vec2(0.0); vec2 offset = vec2(0.0); #pragma unroll_loop_start for (int i = 0; i < ${a()}; i++) { vogelSample = vogelDiskSample(j, ${a()}, angle) * texelSize; offset = vogelSample * (1.0 + filterRadius * float(${r()})); shadow += step( zReceiver, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) ); j++; } #pragma unroll_loop_end return shadow * 1.0 / ${a()}.0; } float PCSS (sampler2D shadowMap, vec4 coords) { vec2 uv = coords.xy; float zReceiver = coords.z; // Assumed to be eye-space z in this code float angle = highPassRandRGB(gl_FragCoord.xy).r * PI2; float avgBlockerDepth = findBlocker(shadowMap, uv, zReceiver, angle); if (avgBlockerDepth == -1.0) { return 1.0; } float penumbraRatio = penumbraSize(zReceiver, avgBlockerDepth); return vogelFilter(shadowMap, uv, zReceiver, 1.25 * penumbraRatio, angle); }`);const u=()=>{n.traverse(h=>{var f,m;const d=h;d.material&&(t==null||t.properties.remove(d.material),(m=(f=d.material).dispose)==null||m.call(f))}),t!=null&&t.info.programs&&(t.info.programs.length=0),t==null||t.compile(n,i.current)};return $e(()=>{Ft.shadowmap_pars_fragment=l.replace("#ifdef USE_SHADOWMAP",`#ifdef USE_SHADOWMAP ${fe(c)}`).replace("#if defined( SHADOWMAP_TYPE_PCF )",` return PCSS(shadowMap, shadowCoord); #if defined( SHADOWMAP_TYPE_PCF )`),u()}),Ui(()=>{Ft.shadowmap_pars_fragment=l,u()}),Et({get size(){return r()},set size(h=25){r(h),V()},get focus(){return o()},set focus(h=0){o(h),V()},get samples(){return a()},set samples(h=10){a(h),V()},$set:Ct,$on:(h,d)=>At(e,h,d)})}Pt($D,{size:{},focus:{},samples:{}},[],[],!0);function JD(s,e){if(new.target)return Tt({component:JD,...s});Mt(e,!0);let t=H(e,"points",23,()=>[]),i=H(e,"shape",7,"none"),n=H(e,"shapeFunction",7,()=>1),r=H(e,"ref",15),o=H(e,"children",7),a=H(e,"props",7),l=t().length;const{invalidate:c}=un(),u=new Bt(new Float32Array(l*6),3),h=new Bt(new Float32Array(l*6),3),d=new Bt(new Float32Array(l*6),3),f=new Bt(new Float32Array(l*2),1),m=new Bt(new Float32Array(l*2),1),v=new Bt(new Float32Array(l*2),1),g=new Bt(new Float32Array(l*4),2),_=new Bt(new Uint16Array(l*6),1);i()==="taper"&&n(x=>1*Math.pow(4*x*(1-x),1));for(let x=0,M=0,C=0,T=0;x{if(x.length===0||x.length!==l)return;let M=0,C=0,T=0;const A=x[0];h.setXYZ(C,A.x,A.y,A.z),C+=1,h.setXYZ(C,A.x,A.y,A.z),C+=1;for(let E=0;E0&&E+1<=l&&(d.setXYZ(T,I.x,I.y,I.z),T+=1,d.setXYZ(T,I.x,I.y,I.z),T+=1)}const P=x[l-1];d.setXYZ(T,P.x,P.y,P.z),T+=1,d.setXYZ(T,P.x,P.y,P.z),T+=1,u.needsUpdate=!0,h.needsUpdate=!0,d.needsUpdate=!0,y.computeBoundingSphere(),c()};return $e(()=>w(t())),pt(s,rn({is:y},a,{get ref(){return r()},set ref(x){r(x)},children:(x,M)=>{var C=Lt(),T=dt(C);Wt(T,()=>o()??Nt,()=>({ref:y})),lt(x,C)},$$slots:{default:!0}})),Et({get points(){return t()},set points(x=[]){t(x),V()},get shape(){return i()},set shape(x="none"){i(x),V()},get shapeFunction(){return n()},set shapeFunction(x=()=>1){n(x),V()},get ref(){return r()},set ref(x){r(x),V()},get children(){return o()},set children(x){o(x),V()},get props(){return a()},set props(x){a(x),V()},$set:Ct,$on:(x,M)=>At(e,x,M)})}Pt(JD,{points:{},shape:{},shapeFunction:{},ref:{},children:{},props:{}},[],[],!0);const B8=` #include #include uniform float useDash; uniform float dashArray; uniform float dashOffset; uniform float dashRatio; uniform sampler2D alphaMap; uniform float useAlphaMap; varying vec2 vUV; varying vec4 vColor; varying float vCounters; vec4 CustomLinearTosRGB( 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.a ); } void main() { #include #include <${h_<154?"encodings_fragment":"colorspace_fragment"}> vec4 c = vColor; if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV ).r; if( useDash == 1. ){ c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio)); } gl_FragColor = CustomLinearTosRGB(c); } `,z8=` #include ${Ft.logdepthbuf_pars_vertex} ${Ft.fog_pars_vertex} attribute vec3 previous; attribute vec3 next; attribute float side; attribute float width; attribute float counters; uniform vec2 resolution; uniform float lineWidth; uniform vec3 color; uniform float opacity; uniform float sizeAttenuation; uniform float scaleDown; varying vec2 vUV; varying vec4 vColor; varying float vCounters; vec2 intoScreen(vec4 i) { return resolution * (0.5 * i.xy / i.w + 0.5); } void main() { float aspect = resolution.y / resolution.x; mat4 m = projectionMatrix * modelViewMatrix; vec4 currentClip = m * vec4( position, 1.0 ); vec4 prevClip = m * vec4( previous, 1.0 ); vec4 nextClip = m * vec4( next, 1.0 ); vec4 currentNormed = currentClip / currentClip.w; vec4 prevNormed = prevClip / prevClip.w; vec4 nextNormed = nextClip / nextClip.w; vec2 currentScreen = intoScreen(currentNormed); vec2 prevScreen = intoScreen(prevNormed); vec2 nextScreen = intoScreen(nextNormed); float actualWidth = lineWidth * width; vec2 dir; if(nextScreen == currentScreen) { dir = normalize( currentScreen - prevScreen ); } else if(prevScreen == currentScreen) { dir = normalize( nextScreen - currentScreen ); } else { vec2 inDir = currentScreen - prevScreen; vec2 outDir = nextScreen - currentScreen; vec2 fullDir = nextScreen - prevScreen; if(length(fullDir) > 0.0) { dir = normalize(fullDir); } else if(length(inDir) > 0.0){ dir = normalize(inDir); } else { dir = normalize(outDir); } } vec2 normal = vec2(-dir.y, dir.x); if(sizeAttenuation != 0.0) { normal /= currentClip.w; normal *= min(resolution.x, resolution.y); } if (scaleDown > 0.0) { float dist = length(nextNormed - prevNormed); normal *= smoothstep(0.0, scaleDown, dist); } vec2 offsetInScreen = actualWidth * normal * side * 0.5; vec2 withOffsetScreen = currentScreen + offsetInScreen; vec3 withOffsetNormed = vec3((2.0 * withOffsetScreen/resolution - 1.0), currentNormed.z); vCounters = counters; vColor = vec4( color, opacity ); vUV = uv; gl_Position = currentClip.w * vec4(withOffsetNormed, 1.0); ${Ft.logdepthbuf_vertex} ${Ft.fog_vertex} } `;function QD(s,e){if(new.target)return Tt({component:QD,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(y,"$size",t);let r=H(e,"opacity",7,1),o=H(e,"color",7,"#ffffff"),a=H(e,"dashOffset",7,0),l=H(e,"dashArray",7,0),c=H(e,"dashRatio",7,0),u=H(e,"attenuate",7,!0),h=H(e,"width",7,1),d=H(e,"scaleDown",7,0),f=H(e,"alphaMap",7),m=H(e,"ref",15),v=H(e,"children",7),g=an(e,["$$slots","$$events","$$legacy","$$host","opacity","color","dashOffset","dashArray","dashRatio","attenuate","width","scaleDown","alphaMap","ref","children"]),{invalidate:_,size:y}=un();const w={lineWidth:{value:h()},color:{value:new rt(o())},opacity:{value:r()},resolution:{value:new Ne(1,1)},sizeAttenuation:{value:u()?1:0},dashArray:{value:l()},dashOffset:{value:a()},dashRatio:{value:c()},useDash:{value:l()>0?1:0},scaleDown:{value:d()/10},alphaTest:{value:0},alphaMap:{value:f()},useAlphaMap:{value:f()?1:0}},x=new Ti({uniforms:w});$e(()=>{w.resolution.value.set(n().width,n().height),_()}),$e(()=>{w.dashRatio.value=c(),w.dashArray.value=l(),w.dashOffset.value=a(),w.lineWidth.value=h(),w.opacity.value=r(),w.color.value.set(o()),_()}),pt(s,rn({is:x,fragmentShader:B8,vertexShader:z8},()=>g,{get ref(){return m()},set ref(C){m(C)},children:(C,T)=>{var A=Lt(),P=dt(A);Wt(P,()=>v()??Nt,()=>({ref:x})),lt(C,A)},$$slots:{default:!0}}));var M=Et({get opacity(){return r()},set opacity(C=1){r(C),V()},get color(){return o()},set color(C="#ffffff"){o(C),V()},get dashOffset(){return a()},set dashOffset(C=0){a(C),V()},get dashArray(){return l()},set dashArray(C=0){l(C),V()},get dashRatio(){return c()},set dashRatio(C=0){c(C),V()},get attenuate(){return u()},set attenuate(C=!0){u(C),V()},get width(){return h()},set width(C=1){h(C),V()},get scaleDown(){return d()},set scaleDown(C=0){d(C),V()},get alphaMap(){return f()},set alphaMap(C){f(C),V()},get ref(){return m()},set ref(C){m(C),V()},get children(){return v()},set children(C){v(C),V()},$set:Ct,$on:(C,T)=>At(e,C,T)});return i(),M}Pt(QD,{opacity:{},color:{},dashOffset:{},dashArray:{},dashRatio:{},attenuate:{},width:{},scaleDown:{},alphaMap:{},ref:{},children:{}},[],[],!0);class __ extends it{constructor(){const e=__.SkyShader,t=new Ti({name:e.name,uniforms:pl.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:ji,depthWrite:!1});super(new yi(1,1,1),t),this.isSky=!0}}__.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new X},up:{value:new X(0,1,0)}},vertexShader:` uniform vec3 sunPosition; uniform float rayleigh; uniform float turbidity; uniform float mieCoefficient; uniform vec3 up; varying vec3 vWorldPosition; varying vec3 vSunDirection; varying float vSunfade; varying vec3 vBetaR; varying vec3 vBetaM; varying float vSunE; // constants for atmospheric scattering const float e = 2.71828182845904523536028747135266249775724709369995957; const float pi = 3.141592653589793238462643383279502884197169; // wavelength of used primaries, according to preetham const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 ); // this pre-calculation replaces older TotalRayleigh(vec3 lambda) function: // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn)) const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 ); // mie stuff // K coefficient for the primaries const float v = 4.0; const vec3 K = vec3( 0.686, 0.678, 0.666 ); // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 ); // earth shadow hack // cutoffAngle = pi / 1.95; const float cutoffAngle = 1.6110731556870734; const float steepness = 1.5; const float EE = 1000.0; float sunIntensity( float zenithAngleCos ) { zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 ); return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) ); } vec3 totalMie( float T ) { float c = ( 0.2 * T ) * 10E-18; return 0.434 * c * MieConst; } void main() { vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); vWorldPosition = worldPosition.xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); gl_Position.z = gl_Position.w; // set z to camera.far vSunDirection = normalize( sunPosition ); vSunE = sunIntensity( dot( vSunDirection, up ) ); vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 ); float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) ); // extinction (absorption + out scattering) // rayleigh coefficients vBetaR = totalRayleigh * rayleighCoefficient; // mie coefficients vBetaM = totalMie( turbidity ) * mieCoefficient; }`,fragmentShader:` varying vec3 vWorldPosition; varying vec3 vSunDirection; varying float vSunfade; varying vec3 vBetaR; varying vec3 vBetaM; varying float vSunE; uniform float mieDirectionalG; uniform vec3 up; // constants for atmospheric scattering const float pi = 3.141592653589793238462643383279502884197169; const float n = 1.0003; // refractive index of air const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius) // optical length at zenith for molecules const float rayleighZenithLength = 8.4E3; const float mieZenithLength = 1.25E3; // 66 arc seconds -> degrees, and the cosine of that const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324; // 3.0 / ( 16.0 * pi ) const float THREE_OVER_SIXTEENPI = 0.05968310365946075; // 1.0 / ( 4.0 * pi ) const float ONE_OVER_FOURPI = 0.07957747154594767; float rayleighPhase( float cosTheta ) { return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) ); } float hgPhase( float cosTheta, float g ) { float g2 = pow( g, 2.0 ); float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 ); return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse ); } void main() { vec3 direction = normalize( vWorldPosition - cameraPosition ); // optical length // cutoff angle at 90 to avoid singularity in next formula. float zenithAngle = acos( max( 0.0, dot( up, direction ) ) ); float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) ); float sR = rayleighZenithLength * inverse; float sM = mieZenithLength * inverse; // combined extinction factor vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) ); // in scattering float cosTheta = dot( direction, vSunDirection ); float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 ); vec3 betaRTheta = vBetaR * rPhase; float mPhase = hgPhase( cosTheta, mieDirectionalG ); vec3 betaMTheta = vBetaM * mPhase; vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) ); Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) ); // nightsky float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2] float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2] vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 ); vec3 L0 = vec3( 0.1 ) * Fex; // composition + solar disc float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ); L0 += ( vSunE * 19000.0 * Fex ) * sundisk; vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 ); vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) ); gl_FragColor = vec4( retColor, 1.0 ); #include #include }`};function eI(s,e){if(new.target)return Tt({component:eI,...s});Mt(e,!0);let t=H(e,"scale",7,1e3),i=H(e,"turbidity",7,10),n=H(e,"rayleigh",7,3),r=H(e,"mieCoefficient",7,.005),o=H(e,"mieDirectionalG",7,.7),a=H(e,"elevation",7,2),l=H(e,"azimuth",7,180),c=H(e,"setEnvironment",7,!0),u=H(e,"cubeMapSize",7,128),h=H(e,"webGLRenderTargetOptions",23,()=>({})),d=H(e,"ref",15),f=H(e,"children",7),m=an(e,["$$slots","$$events","$$legacy","$$host","scale","turbidity","rayleigh","mieCoefficient","mieDirectionalG","elevation","azimuth","setEnvironment","cubeMapSize","webGLRenderTargetOptions","ref","children"]);const v=new __,g=new X,{uniforms:_}=v.material,{renderer:y,scene:w,invalidate:x}=un();let M=xs(void 0),C;const T=()=>{Mn(M,hr(new Vv(u(),{type:mr,generateMipmaps:!0,minFilter:Fs,...h()}))),C=new zv(1,1.1,fe(M))},A=w.environment;$e(()=>{c()&&fe(M)?(w.environment=fe(M).texture,x()):c()||(w.environment=A,x())});const{start:P,stop:E}=ii(()=>{v.scale.setScalar(t()),_.turbidity.value=i(),_.rayleigh.value=n(),_.mieCoefficient.value=r(),_.mieDirectionalG.value=o();const I=qi.degToRad(90-a()),R=qi.degToRad(l());g.setFromSphericalCoords(1,I,R),_.sunPosition.value.copy(g),c()&&((!fe(M)||!C)&&T(),C==null||C.update(y,v)),x(),E()},{autoStart:!1,autoInvalidate:!1});return $e(()=>{t(),i(),n(),r(),o(),a(),l(),P()}),Ui(()=>{var I;v.material.dispose(),w.environment=A;try{(I=fe(M))==null||I.dispose()}catch(R){console.warn("Could not dispose renderTarget:",R)}}),pt(s,rn({is:v},()=>m,{get ref(){return d()},set ref(I){d(I)},children:(I,R)=>{var U=Lt(),L=dt(U);Wt(L,()=>f()??Nt,()=>({ref:v,sunPosition:g,renderTarget:fe(M)})),lt(I,U)},$$slots:{default:!0}})),Et({get scale(){return t()},set scale(I=1e3){t(I),V()},get turbidity(){return i()},set turbidity(I=10){i(I),V()},get rayleigh(){return n()},set rayleigh(I=3){n(I),V()},get mieCoefficient(){return r()},set mieCoefficient(I=.005){r(I),V()},get mieDirectionalG(){return o()},set mieDirectionalG(I=.7){o(I),V()},get elevation(){return a()},set elevation(I=2){a(I),V()},get azimuth(){return l()},set azimuth(I=180){l(I),V()},get setEnvironment(){return c()},set setEnvironment(I=!0){c(I),V()},get cubeMapSize(){return u()},set cubeMapSize(I=128){u(I),V()},get webGLRenderTargetOptions(){return h()},set webGLRenderTargetOptions(I={}){h(I),V()},get ref(){return d()},set ref(I){d(I),V()},get children(){return f()},set children(I){f(I),V()},$set:Ct,$on:(I,R)=>At(e,I,R)})}Pt(eI,{scale:{},turbidity:{},rayleigh:{},mieCoefficient:{},mieDirectionalG:{},elevation:{},azimuth:{},setEnvironment:{},cubeMapSize:{},webGLRenderTargetOptions:{},ref:{},children:{}},[],[],!0);function y_(s,e){if(new.target)return Tt({component:y_,...s});Mt(e,!0);let t=H(e,"name",7),i=H(e,"plugin",7),n=H(e,"children",7);ow(t(),i());var r=Lt(),o=dt(r);return Wt(o,()=>n()??Nt),lt(s,r),Et({get name(){return t()},set name(a){t(a),V()},get plugin(){return i()},set plugin(a){i(a),V()},get children(){return n()},set children(a){n(a),V()},$set:Ct,$on:(a,l)=>At(e,a,l)})}Pt(y_,{name:{},plugin:{},children:{}},[],[],!0);function tI(s,e){if(new.target)return Tt({component:tI,...s});Mt(e,!0);const{renderStage:t}=un();let i=H(e,"x",7,0),n=H(e,"y",7,0),r=H(e,"z",7,0),o=H(e,"precise",7,!1),a=H(e,"auto",7,!1),l=H(e,"ref",15),c=H(e,"onalign",7),u=H(e,"children",7),h=H(e,"stage",23,()=>hu("",{before:t})),d=an(e,["$$slots","$$events","$$legacy","$$host","x","y","z","precise","auto","ref","onalign","children","stage"]);const f=new Qn,m=new Qn,v=new Qn,g=()=>{var L;if(i()===!1&&n()===!1&&r()===!1)return;v.matrixWorld.identity();const M=new yn().setFromObject(m,o()),C=new X,T=new fi,A=M.max.x-M.min.x,P=M.max.y-M.min.y,E=M.max.z-M.min.z;M.getCenter(C),M.getBoundingSphere(T);const I=(n()||0)*P/2,R=(i()||0)*A/2,U=(r()||0)*E/2;v.position.set(i()===!1?0:-C.x+R,n()===!1?0:-C.y+I,r()===!1?0:-C.z+U),(L=c())==null||L({boundingBox:M,center:v.position.clone(),boundingSphere:T,container:f,depth:E,depthAlignment:U,height:P,verticalAlignment:I,width:A,horizontalAlignment:R})},{start:_,stop:y}=ii(()=>{g(),y()},{autoStart:!1,stage:h()}),w=_;Gs(()=>[i(),n(),r(),o()],_);const x=M=>{wn(M.ref,"Object3D")&&Gs.pre(()=>[M.ref],()=>(a()&&_(),()=>{a()&&_()}))};return pt(s,rn({is:f},()=>d,{get ref(){return l()},set ref(M){l(M)},children:(M,C)=>{pt(M,{is:v,children:(T,A)=>{pt(T,{is:m,children:(P,E)=>{y_(P,{name:"align",plugin:x,children:(I,R)=>{var U=Lt(),L=dt(U);Wt(L,()=>u()??Nt,()=>({align:_,ref:f})),lt(I,U)},$$slots:{default:!0}})},$$slots:{default:!0}})},$$slots:{default:!0}})},$$slots:{default:!0}})),Et({align:w,get x(){return i()},set x(M=0){i(M),V()},get y(){return n()},set y(M=0){n(M),V()},get z(){return r()},set z(M=0){r(M),V()},get precise(){return o()},set precise(M=!1){o(M),V()},get auto(){return a()},set auto(M=!1){a(M),V()},get ref(){return l()},set ref(M){l(M),V()},get onalign(){return c()},set onalign(M){c(M),V()},get children(){return u()},set children(M){u(M),V()},get stage(){return h()},set stage(M=hu("",{before:t})){h(M),V()},$set:Ct,$on:(M,C)=>At(e,M,C)})}Pt(tI,{x:{},y:{},z:{},precise:{},auto:{},ref:{},onalign:{},children:{},stage:{}},[],["align"],!0);const Zw=new _t;class x_{constructor(e){e=e||{},this.zNear=e.webGL===!0?-1:0,this.vertices={near:[new X,new X,new X,new X],far:[new X,new X,new X,new X]},e.projectionMatrix!==void 0&&this.setFromProjectionMatrix(e.projectionMatrix,e.maxFar||1e4)}setFromProjectionMatrix(e,t){const i=this.zNear,n=e.elements[2*4+3]===0;return Zw.copy(e).invert(),this.vertices.near[0].set(1,1,i),this.vertices.near[1].set(1,-1,i),this.vertices.near[2].set(-1,-1,i),this.vertices.near[3].set(-1,1,i),this.vertices.near.forEach(function(r){r.applyMatrix4(Zw)}),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach(function(r){r.applyMatrix4(Zw);const o=Math.abs(r.z);n?r.z*=Math.min(t/o,1):r.multiplyScalar(Math.min(t/o,1))}),this.vertices}split(e,t){for(;e.length>t.length;)t.push(new x_);t.length=e.length;for(let i=0;i 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); // Iridescence F0 approximation material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #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 ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #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 ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); // spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none] #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES ) DirectionalLight directionalLight; float linearDepth = (vViewPosition.z) / (shadowFar - cameraNear); #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #if defined( USE_SHADOWMAP ) && defined( CSM_FADE ) vec2 cascade; float cascadeCenter; float closestEdge; float margin; float csmx; float csmy; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) // NOTE: Depth gets larger away from the camera. // cascade.x is closer, cascade.y is further cascade = CSM_cascades[ i ]; cascadeCenter = ( cascade.x + cascade.y ) / 2.0; closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y; margin = 0.25 * pow( closestEdge, 2.0 ); csmx = cascade.x - margin / 2.0; csmy = cascade.y + margin / 2.0; if( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) { float dist = min( linearDepth - csmx, csmy - linearDepth ); float ratio = clamp( dist / margin, 0.0, 1.0 ); vec3 prevColor = directLight.color; directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter; directLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 ); ReflectedLight prevLight = reflectedLight; RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter; float blendRatio = shouldBlend ? ratio : 1.0; reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio ); reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio ); reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio ); reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio ); } #endif } #pragma unroll_loop_end #elif defined (USE_SHADOWMAP) #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif } #pragma unroll_loop_end #elif ( NUM_DIR_LIGHT_SHADOWS > 0 ) // note: no loop here - all CSM lights are in fact one light only getDirectionalLightInfo( directionalLights[0], directLight ); RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS) // compute the lights not casting shadows (if any) #pragma unroll_loop_start for ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES ) DirectionalLight directionalLight; #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 ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif `,lights_pars_begin:` #if defined( USE_CSM ) && defined( CSM_CASCADES ) uniform vec2 CSM_cascades[CSM_CASCADES]; uniform float cameraNear; uniform float shadowFar; #endif `+Ft.lights_pars_begin},iI=new _t,Kw=new x_({webGL:!0}),Ca=new X,Up=new yn,$w=[],Jw=[],Qw=new _t,rI=new _t,V8=new X(0,1,0);class G8{constructor(e){this.camera=e.camera,this.parent=e.parent,this.cascades=e.cascades||3,this.maxFar=e.maxFar||1e5,this.mode=e.mode||"practical",this.shadowMapSize=e.shadowMapSize||2048,this.shadowBias=e.shadowBias||1e-6,this.lightDirection=e.lightDirection||new X(1,-1,1).normalize(),this.lightIntensity=e.lightIntensity||3,this.lightNear=e.lightNear||1,this.lightFar=e.lightFar||2e3,this.lightMargin=e.lightMargin||200,this.customSplitsCallback=e.customSplitsCallback,this.fade=!1,this.mainFrustum=new x_({webGL:!0}),this.frustums=[],this.breaks=[],this.lights=[],this.shaders=new Map,this.createLights(),this.updateFrustums(),this.injectInclude()}createLights(){for(let e=0;el.distanceTo(o[2])?c=a[2]:c=o[2];let u=l.distanceTo(c);if(this.fade){const h=this.camera,d=Math.max(h.far,this.maxFar),f=r.vertices.far[0].z/(d-h.near),m=.25*Math.pow(f,2)*(d-h.near);u+=m}n.left=-u/2,n.right=u/2,n.top=u/2,n.bottom=-u/2,n.updateProjectionMatrix()}}getBreaks(){const e=this.camera,t=Math.min(e.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":i(this.cascades,e.near,t,this.breaks);break;case"logarithmic":n(this.cascades,e.near,t,this.breaks);break;case"practical":r(this.cascades,e.near,t,.5,this.breaks);break;case"custom":this.customSplitsCallback===void 0&&console.error("CSM: Custom split scheme callback not defined."),this.customSplitsCallback(this.cascades,e.near,t,this.breaks);break}function i(o,a,l,c){for(let u=1;u{let s;const e=new Set,t=o=>wn(o,"MeshStandardMaterial")||wn(o,"MeshPhongMaterial"),i=o=>{e.has(o)||(e.add(o),s==null||s(o))},n=o=>{t(o)?i(o):wn(o,"Mesh")&&(Array.isArray(o.material)?o.material.forEach(a=>{t(a)&&i(a)}):t(o.material)&&i(o.material))},r=o=>{s=o};return ow("csm",o=>{Gr(()=>{n(o.ref)})}),Ui(()=>s=void 0),{onNewMaterial:r,allMaterials:e}};var W8=Kn(" ",1);function sI(s,e){if(new.target)return Tt({component:sI,...s});Mt(e,!1);const[t,i]=Pi(),n=()=>Rn(_,"$csmStore",t),r=()=>Rn(m,"$defaultCamera",t);let o=H(e,"enabled",12,!0),a=H(e,"args",28,()=>({})),l=H(e,"camera",12,void 0),c=H(e,"configure",12,void 0),u=H(e,"lightIntensity",12,void 0),h=H(e,"lightColor",12,void 0),d=H(e,"lightDirection",28,()=>[1,-1,1]);const f=Hn(o()),{camera:m,scene:v,size:g}=un(),_=Yn(void 0);ii(()=>{var L;return(L=n())==null?void 0:L.update()},{autoInvalidate:!1});const{onNewMaterial:y,allMaterials:w}=H8(),x=()=>{var L,k;(L=n())==null||L.remove(),(k=n())==null||k.dispose(),Fy(_,void 0)};pi([g,_],([L,k])=>{k&&k.updateFrustums()});const M=Hn(l());pi([m,M,_],([L,k,z])=>{z&&(z.camera=k??L,a().maxFar!==void 0&&(z.maxFar=a().maxFar),a().mode!==void 0&&(z.mode=a().mode),z.updateFrustums())}),pi(f,L=>{var k;if(L){const z=new G8({camera:l()??r(),parent:v,...a()});(k=c())==null||k(z);for(const G of w)z.setupMaterial(G);y(G=>z.setupMaterial(G)),_.set(z)}else y(void 0),x()});const C=Hn(u()),T=Hn(h());pi([_,C,T],([L,k,z])=>{L==null||L.lights.forEach(G=>{k!==void 0&&(G.intensity=k/Math.PI),z!==void 0&&G.color.set(z)})});const A=Hn(d());pi([_,A],([L,k])=>{L==null||L.lightDirection.set(...k).normalize()}),Ui(x),Ga(()=>Wu(o()),()=>{f.set(o())}),Ga(()=>Wu(l()),()=>{M.set(l())}),Ga(()=>Wu(u()),()=>{C.set(u())}),Ga(()=>Wu(h()),()=>{T.set(h())}),Ga(()=>Wu(d()),()=>{A.set(d())}),Dy(),go();var P=W8(),E=dt(P);aE(E,e,"default",{});var I=Ln(E,2);{var R=L=>{var k=Lt(),z=dt(k);aE(z,e,"disabled",{}),lt(L,k)};wi(I,L=>{o()||L(R)})}lt(s,P);var U=Et({get enabled(){return o()},set enabled(L){o(L),V()},get args(){return a()},set args(L){a(L),V()},get camera(){return l()},set camera(L){l(L),V()},get configure(){return c()},set configure(L){c(L),V()},get lightIntensity(){return u()},set lightIntensity(L){u(L),V()},get lightColor(){return h()},set lightColor(L){h(L),V()},get lightDirection(){return d()},set lightDirection(L){d(L),V()},$set:Ct,$on:(L,k)=>At(e,L,k)});return i(),U}Pt(sI,{enabled:{},args:{},camera:{},configure:{},lightIntensity:{},lightColor:{},lightDirection:{}},["default","disabled"],[],!0);function oI(s,e){if(new.target)return Tt({component:oI,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(h,"$camera",t);let r=H(e,"follow",7,!0),o=H(e,"ref",15),a=H(e,"children",7),l=an(e,["$$slots","$$events","$$legacy","$$host","follow","ref","children"]);const c=new Qn,u=new Qn,{camera:h,renderStage:d}=un(),f=new Tn;let m=xt(()=>r()===!0?n():r()===!1?void 0:r());const v=hu("",{before:d}),{start:g,stop:_}=ii(()=>{var w;u.updateMatrix(),u.updateWorldMatrix(!1,!1),u.getWorldQuaternion(f),(w=fe(m))==null||w.getWorldQuaternion(c.quaternion).premultiply(f.invert())},{autoStart:!1,stage:v});$e(()=>{r()?g():_()}),pt(s,rn({is:u},()=>l,{get ref(){return o()},set ref(w){o(w)},children:(w,x)=>{pt(w,{is:c,children:(M,C)=>{var T=Lt(),A=dt(T);Wt(A,()=>a()??Nt,()=>({ref:u})),lt(M,T)},$$slots:{default:!0}})},$$slots:{default:!0}}));var y=Et({get follow(){return r()},set follow(w=!0){r(w),V()},get ref(){return o()},set ref(w){o(w),V()},get children(){return a()},set children(w){a(w),V()},$set:Ct,$on:(w,x)=>At(e,w,x)});return i(),y}Pt(oI,{follow:{},ref:{},children:{}},[],[],!0);const X8=` uniform vec3 glowColor; uniform float falloffAmount; uniform float glowSharpness; uniform float glowInternalRadius; varying vec3 vPosition; varying vec3 vNormal; void main() { // Normal vec3 normal = normalize(vNormal); if(!gl_FrontFacing) normal *= - 1.0; vec3 viewDirection = normalize(cameraPosition - vPosition); float fresnel = dot(viewDirection, normal); fresnel = pow(fresnel, glowInternalRadius + 0.1); float falloff = smoothstep(0., falloffAmount, fresnel); float fakeGlow = fresnel; fakeGlow += fresnel * glowSharpness; fakeGlow *= falloff; gl_FragColor = vec4(clamp(glowColor * fresnel, 0., 1.0), clamp(fakeGlow, 0., 1.0)); ${Ft.tonemapping_fragment} ${Ft.colorspace_fragment} }`,Y8=`varying vec3 vPosition; varying vec3 vNormal; void main() { vec4 modelPosition = modelMatrix * vec4(position, 1.0); gl_Position = projectionMatrix * viewMatrix * modelPosition; vec4 modelNormal = modelMatrix * vec4(normal, 0.0); vPosition = modelPosition.xyz; vNormal = modelNormal.xyz; }`;function aI(s,e){if(new.target)return Tt({component:aI,...s});Mt(e,!0);let t=H(e,"falloff",7,.1),i=H(e,"glowInternalRadius",7,6),n=H(e,"glowColor",7,"green"),r=H(e,"glowSharpness",7,1),o=H(e,"ref",15),a=H(e,"children",7),l=an(e,["$$slots","$$events","$$legacy","$$host","falloff","glowInternalRadius","glowColor","glowSharpness","ref","children"]);const c={falloff:{value:t()},glowInternalRadius:{value:i()},glowColor:{value:new rt(n())},glowSharpness:{value:r()}},u=new Ti({uniforms:c,fragmentShader:X8,vertexShader:Y8,transparent:!0,blending:Pf,depthTest:!1}),{invalidate:h}=un();return $e(()=>{u.uniforms.falloff.value=t(),h()}),$e(()=>{u.uniforms.glowInternalRadius.value=i(),h()}),$e(()=>{u.uniforms.glowColor.value.set(n()),h()}),$e(()=>{u.uniforms.glowSharpness.value=r(),h()}),pt(s,rn({is:u},()=>l,{get ref(){return o()},set ref(d){o(d)},children:(d,f)=>{var m=Lt(),v=dt(m);Wt(v,()=>a()??Nt,()=>({ref:u})),lt(d,m)},$$slots:{default:!0}})),Et({get falloff(){return t()},set falloff(d=.1){t(d),V()},get glowInternalRadius(){return i()},set glowInternalRadius(d=6){i(d),V()},get glowColor(){return n()},set glowColor(d="green"){n(d),V()},get glowSharpness(){return r()},set glowSharpness(d=1){r(d),V()},get ref(){return o()},set ref(d){o(d),V()},get children(){return a()},set children(d){a(d),V()},$set:Ct,$on:(d,f)=>At(e,d,f)})}Pt(aI,{falloff:{},glowInternalRadius:{},glowColor:{},glowSharpness:{},ref:{},children:{}},[],[],!0);const j8=` uniform sampler2D pointTexture; uniform float fade; uniform float opacity; varying vec3 vColor; void main() { float pointOpacity = 1.0; if (fade == 1.0) { float d = distance(gl_PointCoord, vec2(0.5, 0.5)); pointOpacity = 1.0 / (1.0 + exp(16.0 * (d - 0.25))); } gl_FragColor = vec4(vColor, pointOpacity * opacity); ${Ft.tonemapping_fragment} ${Ft.colorspace_fragment} }`,q8=`uniform float time; attribute float size; varying vec3 vColor; void main() { vColor = color; vec4 mvPosition = modelViewMatrix * vec4(position, 0.5); gl_PointSize = size * (30.0 / -mvPosition.z) * (3.0 + sin(time + 100.0)); gl_Position = projectionMatrix * mvPosition; }`;var Z8=Kn(" ",1);function lI(s,e){if(new.target)return Tt({component:lI,...s});Mt(e,!0);let t=H(e,"count",7,5e3),i=H(e,"radius",7,50),n=H(e,"depth",7,50),r=H(e,"factor",7,6),o=H(e,"saturation",7,1),a=H(e,"lightness",7,.8),l=H(e,"speed",7,1),c=H(e,"fade",7,!0),u=H(e,"opacity",7,1),h=H(e,"ref",15),d=H(e,"children",7),f=an(e,["$$slots","$$events","$$legacy","$$host","count","radius","depth","factor","saturation","lightness","speed","fade","opacity","ref","children"]);const m=new c0,v=new X,g=new rd,_=new rt,y=I=>v.setFromSpherical(g.set(I,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI));let w=new Bt(new Float32Array(t()*3),3),x=new Bt(new Float32Array(t()*3),3),M=new Bt(new Float32Array(t()),1);$e(()=>{w=new Bt(new Float32Array(t()*3),3),x=new Bt(new Float32Array(t()*3),3),M=new Bt(new Float32Array(t()),1)}),$e(()=>{const I=n()/t();let R=i()+n();for(let U=0;U{A.time.value+=I*l()},{autoStart:!1});$e(()=>l()===0?C():T());const A={time:{value:0},fade:{value:1},opacity:{value:1}},P=new Ti({uniforms:A,vertexShader:q8,fragmentShader:j8});$e(()=>{A.fade.value=c()?1:0}),$e(()=>{A.opacity.value=u()});const E=new Gt;return E.setAttribute("position",w),E.setAttribute("color",x),E.setAttribute("size",M),pt(s,rn({is:m},()=>f,{get ref(){return h()},set ref(I){h(I)},children:(I,R)=>{var U=Z8(),L=dt(U);pt(L,{is:E});var k=Ln(L,2);pt(k,{is:P,blending:Pf,depthWrite:!1,transparent:!0,vertexColors:!0});var z=Ln(k,2);Wt(z,()=>d()??Nt,()=>({ref:m})),lt(I,U)},$$slots:{default:!0}})),Et({get count(){return t()},set count(I=5e3){t(I),V()},get radius(){return i()},set radius(I=50){i(I),V()},get depth(){return n()},set depth(I=50){n(I),V()},get factor(){return r()},set factor(I=6){r(I),V()},get saturation(){return o()},set saturation(I=1){o(I),V()},get lightness(){return a()},set lightness(I=.8){a(I),V()},get speed(){return l()},set speed(I=1){l(I),V()},get fade(){return c()},set fade(I=!0){c(I),V()},get opacity(){return u()},set opacity(I=1){u(I),V()},get ref(){return h()},set ref(I){h(I),V()},get children(){return d()},set children(I){d(I),V()},$set:Ct,$on:(I,R)=>At(e,I,R)})}Pt(lI,{count:{},radius:{},depth:{},factor:{},saturation:{},lightness:{},speed:{},fade:{},opacity:{},ref:{},children:{}},[],[],!0);const cI=0,K8=1,uI=2,hI=2,eS=1.25,dI=1,Pl=6*4+4+4,b_=65535,$8=Math.pow(2,-24),tS=Symbol("SKIP_GENERATION");function fI(s){return s.index?s.index.count:s.attributes.position.count}function dd(s){return fI(s)/3}function pI(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function J8(s,e){if(!s.index){const t=s.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=pI(t,i);s.setIndex(new Bt(n,1));for(let r=0;rl-c);for(let l=0;lo.offset-a.offset),n=i[i.length-1];n.count=Math.min(t-n.offset,n.count);let r=0;return i.forEach(({count:o})=>r+=o),t!==r}function nS(s,e,t,i,n){let r=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,m=-1/0,v=-1/0,g=-1/0;for(let _=e*6,y=(e+t)*6;_l&&(l=C),wm&&(m=w);const T=s[_+2],A=s[_+3],P=T-A,E=T+A;Pc&&(c=E),Tv&&(v=T);const I=s[_+4],R=s[_+5],U=I-R,L=I+R;Uu&&(u=L),Ig&&(g=I)}i[0]=r,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=u,n[0]=h,n[1]=d,n[2]=f,n[3]=m,n[4]=v,n[5]=g}function e7(s,e=null,t=null,i=null){const n=s.attributes.position,r=s.index?s.index.array:null,o=dd(s),a=n.normalized;let l;e===null?(l=new Float32Array(o*6*4),t=0,i=o):(l=e,t=t||0,i=i||o);const c=n.array,u=n.offset||0;let h=3;n.isInterleavedBufferAttribute&&(h=n.data.stride);const d=["getX","getY","getZ"];for(let f=t;fA&&(A=M),C>A&&(A=C);const P=(A-T)/2,E=w*2;l[v+E+0]=T+P,l[v+E+1]=P+(Math.abs(T)+P)*$8}}return l}function Ci(s,e,t){return t.min.x=e[s],t.min.y=e[s+1],t.min.z=e[s+2],t.max.x=e[s+3],t.max.y=e[s+4],t.max.z=e[s+5],t}function vI(s){let e=-1,t=-1/0;for(let i=0;i<3;i++){const n=s[i+3]-s[i];n>t&&(t=n,e=i)}return e}function _I(s,e){e.set(s)}function yI(s,e,t){let i,n;for(let r=0;r<3;r++){const o=r+3;i=s[r],n=e[r],t[r]=in?i:n}}function w_(s,e,t){for(let i=0;i<3;i++){const n=e[s+2*i],r=e[s+2*i+1],o=n-r,a=n+r;ot[i+3]&&(t[i+3]=a)}}function kp(s){const e=s[3]-s[0],t=s[4]-s[1],i=s[5]-s[2];return 2*(e*t+t*i+i*e)}const Pa=32,t7=(s,e)=>s.candidate-e.candidate,Rl=new Array(Pa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),S_=new Float32Array(6);function n7(s,e,t,i,n,r){let o=-1,a=0;if(r===cI)o=vI(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(r===K8)o=vI(s),o!==-1&&(a=i7(t,i,n,o));else if(r===uI){const l=kp(s);let c=eS*n;const u=i*6,h=(i+n)*6;for(let d=0;d<3;d++){const f=e[d],g=(e[d+3]-f)/Pa;if(n=T.candidate?w_(x,t,T.rightCacheBounds):(w_(x,t,T.leftCacheBounds),T.count++)}}for(let x=0;x=Pa&&(C=Pa-1);const T=Rl[C];T.count++,w_(w,t,T.bounds)}const _=Rl[Pa-1];_I(_.bounds,_.rightCacheBounds);for(let w=Pa-2;w>=0;w--){const x=Rl[w],M=Rl[w+1];yI(x.bounds,M.rightCacheBounds,x.rightCacheBounds)}let y=0;for(let w=0;w=l;)a--;if(o=l;)a--;if(oo7)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Op[t+6]=c/4,c=oS(c,a),Op[t+7]=l,c}}function l7(s,e){const t=(s.index?s.index.count:s.attributes.position.count)/3,i=t>2**16,n=i?4:2,r=e?new SharedArrayBuffer(t*n):new ArrayBuffer(t*n),o=i?new Uint32Array(r):new Uint16Array(r);for(let a=0,l=o.length;a=r&&(_=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),T<=a||P>=r)return w(C+T),M.offset=C,M.count=T,M;const E=n7(M.boundingData,A,e,C,T,l);if(E.axis===-1)return w(C+T),M.offset=C,M.count=T,M;const I=m(h,f,e,C,T,E);if(I===C||I===C+T)w(C+T),M.offset=C,M.count=T;else{M.splitAxis=E.axis;const R=new iS,U=C,L=I-C;M.left=R,nS(e,U,L,R.boundingData,g),x(R,U,L,g,P+1);const k=new iS,z=I,G=T-L;M.right=k,nS(e,z,G,k.boundingData,g),x(k,z,G,g,P+1)}return M}}function u7(s,e){const t=s.geometry;e.indirect&&(s._indirectBuffer=l7(t,e.useSharedArrayBuffer),Q8(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),s._indirectBuffer||J8(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=e7(t),r=e.indirect?mI(t,e.range):gI(t,e.range);s._roots=r.map(o=>{const a=c7(s,n,o.offset,o.count,e),l=sS(a),c=new i(Pl*l);return a7(0,a,c),c})}class Ra{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,n=-1/0;for(let r=0,o=e.length;rn?l:n}this.min=i,this.max=n}setFromPoints(e,t){let i=1/0,n=-1/0;for(let r=0,o=t.length;rn?l:n}this.min=i,this.max=n}isSeparated(e){return this.min>e.max||e.min>this.max}}Ra.prototype.setFromBox=function(){const s=new X;return function(t,i){const n=i.min,r=i.max;let 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++){s.x=n.x*l+r.x*(1-l),s.y=n.y*c+r.y*(1-c),s.z=n.z*u+r.z*(1-u);const h=t.dot(s);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();const h7=function(){const s=new X,e=new X,t=new X;return function(n,r,o){const a=n.start,l=s,c=r.start,u=e;t.subVectors(a,c),s.subVectors(n.end,n.start),e.subVectors(r.end,r.start);const h=t.dot(u),d=u.dot(l),f=u.dot(u),m=t.dot(l),g=l.dot(l)*f-d*d;let _,y;g!==0?_=(h*d-m*f)/g:_=0,y=(h+_*d)/f,o.x=_,o.y=y}}(),aS=function(){const s=new Ne,e=new X,t=new X;return function(n,r,o,a){h7(n,r,s);let l=s.x,c=s.y;if(l>=0&&l<=1&&c>=0&&c<=1){n.at(l,o),r.at(c,a);return}else if(l>=0&&l<=1){c<0?r.at(0,a):r.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?n.at(0,o):n.at(1,o),r.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=n.start:u=n.end;let h;c<0?h=r.start:h=r.end;const d=e,f=t;if(n.closestPointToPoint(h,!0,e),r.closestPointToPoint(u,!0,t),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),d7=function(){const s=new X,e=new X,t=new to,i=new Eo;return function(r,o){const{radius:a,center:l}=r,{a:c,b:u,c:h}=o;if(i.start=c,i.end=u,i.closestPointToPoint(l,!0,s).distanceTo(l)<=a||(i.start=c,i.end=h,i.closestPointToPoint(l,!0,s).distanceTo(l)<=a)||(i.start=u,i.end=h,i.closestPointToPoint(l,!0,s).distanceTo(l)<=a))return!0;const v=o.getPlane(t);if(Math.abs(v.distanceToPoint(l))<=a){const _=v.projectPoint(l,e);if(o.containsPoint(_))return!0}return!1}}(),f7=1e-15;function lS(s){return Math.abs(s)new X),this.satBounds=new Array(4).fill().map(()=>new Ra),this.points=[this.a,this.b,this.c],this.sphere=new fi,this.plane=new to,this.needsUpdate=!0}intersectsSphere(e){return d7(e,this)}update(){const e=this.a,t=this.b,i=this.c,n=this.points,r=this.satAxes,o=this.satBounds,a=r[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);const c=r[1],u=o[1];c.subVectors(e,t),u.setFromPoints(c,n);const h=r[2],d=o[2];h.subVectors(t,i),d.setFromPoints(h,n);const f=r[3],m=o[3];f.subVectors(i,e),m.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Po.prototype.closestPointToSegment=function(){const s=new X,e=new X,t=new Eo;return function(n,r=null,o=null){const{start:a,end:l}=n,c=this.points;let u,h=1/0;for(let d=0;d<3;d++){const f=(d+1)%3;t.start.copy(c[d]),t.end.copy(c[f]),aS(t,n,s,e),u=s.distanceToSquared(e),u=2){(x===1?_.start:_.end).copy(f),w=2;break}if(w++,w===2&&x===-1)break}}return w}return function(g,_=null,y=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(s.copy(g),s.update(),g=s);const w=this.plane,x=g.plane;if(Math.abs(w.normal.dot(x.normal))>1-1e-10){const M=this.satBounds,C=this.satAxes;t[0]=g.a,t[1]=g.b,t[2]=g.c;for(let P=0;P<4;P++){const E=M[P],I=C[P];if(i.setFromPoints(I,t),E.isSeparated(i))return!1}const T=g.satBounds,A=g.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let P=0;P<4;P++){const E=T[P],I=A[P];if(i.setFromPoints(I,e),E.isSeparated(i))return!1}for(let P=0;P<4;P++){const E=C[P];for(let I=0;I<4;I++){const R=A[I];if(r.crossVectors(E,R),i.setFromPoints(r,e),n.setFromPoints(r,t),i.isSeparated(n))return!1}}return _&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}else{const M=m(this,x,h);if(M===1&&g.containsPoint(h.end))return _&&(_.start.copy(h.end),_.end.copy(h.end)),!0;if(M!==2)return!1;const C=m(g,w,d);if(C===1&&this.containsPoint(d.end))return _&&(_.start.copy(d.end),_.end.copy(d.end)),!0;if(C!==2)return!1;if(h.delta(a),d.delta(l),a.dot(l)<0){let U=d.start;d.start=d.end,d.end=U}const T=h.start.dot(a),A=h.end.dot(a),P=d.start.dot(a),E=d.end.dot(a),I=A0?_.start.copy(h.start):_.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?_.end.copy(h.end):_.end.copy(d.end)),!0)}}}(),Po.prototype.distanceToPoint=function(){const s=new X;return function(t){return this.closestPointToPoint(t,s),t.distanceTo(s)}}(),Po.prototype.distanceToTriangle=function(){const s=new X,e=new X,t=["a","b","c"],i=new Eo,n=new Eo;return function(o,a=null,l=null){const c=a||l?i: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;const f=t[h],m=o[f];this.closestPointToPoint(m,s),d=m.distanceToSquared(s),dnew X),this.satAxes=new Array(3).fill().map(()=>new X),this.satBounds=new Array(3).fill().map(()=>new Ra),this.alignedSatBounds=new Array(3).fill().map(()=>new Ra),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}ns.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,n=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const d=1*c|2*u|4*h,f=n[d];f.x=c?i.x:t.x,f.y=u?i.y:t.y,f.z=h?i.z:t.z,f.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,a=n[0];for(let c=0;c<3;c++){const u=o[c],h=r[c],d=1<new Eo),t=new Array(12).fill().map(()=>new Eo),i=new X,n=new X;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(n),this.closestPointToPoint(n,i),o.closestPointToPoint(i,n),l&&l.copy(i),c&&c.copy(n)),0;const u=a*a,h=o.min,d=o.max,f=this.points;let m=1/0;for(let g=0;g<8;g++){const _=f[g];n.copy(_).clamp(h,d);const y=_.distanceToSquared(n);if(ynew Po)}}const lo=new p7;class m7{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const li=new m7;let Dl,fd;const pd=[],E_=new cS(()=>new yn);function g7(s,e,t,i,n,r){Dl=E_.getPrimitive(),fd=E_.getPrimitive(),pd.push(Dl,fd),li.setBuffer(s._roots[e]);const o=uS(0,s.geometry,t,i,n,r);li.clearBuffer(),E_.releasePrimitive(Dl),E_.releasePrimitive(fd),pd.pop(),pd.pop();const a=pd.length;return a>0&&(fd=pd[a-1],Dl=pd[a-2]),o}function uS(s,e,t,i,n=null,r=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=li;let u=s*2;if(ts(u,l)){const d=_s(s,c),f=Hs(u,l);return Ci(s,a,Dl),i(d,f,!1,o,r+s,Dl)}else{let E=function(R){const{uint16Array:U,uint32Array:L}=li;let k=R*2;for(;!ts(k,U);)R=ao(R),k=R*2;return _s(R,L)},I=function(R){const{uint16Array:U,uint32Array:L}=li;let k=R*2;for(;!ts(k,U);)R=Ws(R,L),k=R*2;return _s(R,L)+Hs(k,U)};const d=ao(s),f=Ws(s,c);let m=d,v=f,g,_,y,w;if(n&&(y=Dl,w=fd,Ci(m,a,y),Ci(v,a,w),g=n(y),_=n(w),_(Fp.copy(e).clamp(u.min,u.max),Fp.distanceToSquared(e)),intersectsBounds:(u,h,d)=>d{u.closestPointToPoint(e,Fp);const d=e.distanceToSquared(Fp);return da?null:{distance:c,point:n.clone()}}function y7(s,e,t,i,n,r,o,a,l,c,u){md.fromBufferAttribute(e,r),gd.fromBufferAttribute(e,o),vd.fromBufferAttribute(e,a);const h=_7(s,md,gd,vd,P_,l,c,u);if(h){i&&(T_.fromBufferAttribute(i,r),A_.fromBufferAttribute(i,o),C_.fromBufferAttribute(i,a),h.uv=Zi.getInterpolation(P_,md,gd,vd,T_,A_,C_,new Ne)),n&&(T_.fromBufferAttribute(n,r),A_.fromBufferAttribute(n,o),C_.fromBufferAttribute(n,a),h.uv1=Zi.getInterpolation(P_,md,gd,vd,T_,A_,C_,new Ne)),t&&(wI.fromBufferAttribute(t,r),SI.fromBufferAttribute(t,o),MI.fromBufferAttribute(t,a),h.normal=Zi.getInterpolation(P_,md,gd,vd,wI,SI,MI,new X),h.normal.dot(s.direction)>0&&h.normal.multiplyScalar(-1));const d={a:r,b:o,c:a,normal:new X,materialIndex:0};Zi.getNormal(md,gd,vd,d.normal),h.face=d,h.faceIndex=r}return h}function R_(s,e,t,i,n,r,o){const a=i*3;let l=a+0,c=a+1,u=a+2;const h=s.index;s.index&&(l=h.getX(l),c=h.getX(c),u=h.getX(u));const{position:d,normal:f,uv:m,uv1:v}=s.attributes,g=y7(t,d,f,m,v,l,c,u,e,r,o);return g?(g.faceIndex=i,n&&n.push(g),g):null}function Wi(s,e,t,i){const n=s.a,r=s.b,o=s.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),n.x=i.getX(a),n.y=i.getY(a),n.z=i.getZ(a),r.x=i.getX(l),r.y=i.getY(l),r.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function x7(s,e,t,i,n,r,o,a){const{geometry:l,_indirectBuffer:c}=s;for(let u=i,h=i+n;uC&&(C=R),UT&&(T=U),LA&&(A=L)}return l[d+0]!==w||l[d+1]!==x||l[d+2]!==M||l[d+3]!==C||l[d+4]!==T||l[d+5]!==A?(l[d+0]=w,l[d+1]=x,l[d+2]=M,l[d+3]=C,l[d+4]=T,l[d+5]=A,!0):!1}else{const _=d+8,y=o[d+6],w=_+f,x=y+f;let M=m,C=!1,T=!1;e?M||(C=e.has(w),T=e.has(x),M=!C&&!T):(C=!0,T=!0);const A=M||C,P=M||T;let E=!1;A&&(E=h(_,f,M));let I=!1;P&&(I=h(y,f,M));const R=E||I;if(R)for(let U=0;U<3;U++){const L=_+U,k=y+U,z=l[L],G=l[L+3],W=l[k],q=l[k+3];l[d+U]=zq?G:q}return R}}}function Il(s,e,t,i,n){let r,o,a,l,c,u;const h=1/t.direction.x,d=1/t.direction.y,f=1/t.direction.z,m=t.origin.x,v=t.origin.y,g=t.origin.z;let _=e[s],y=e[s+3],w=e[s+1],x=e[s+3+1],M=e[s+2],C=e[s+3+2];return h>=0?(r=(_-m)*h,o=(y-m)*h):(r=(y-m)*h,o=(_-m)*h),d>=0?(a=(w-v)*d,l=(x-v)*d):(a=(x-v)*d,l=(w-v)*d),r>l||a>o||((a>r||isNaN(r))&&(r=a),(l=0?(c=(M-g)*f,u=(C-g)*f):(c=(C-g)*f,u=(M-g)*f),r>u||c>o)?!1:((c>r||r!==r)&&(r=c),(u=i)}function M7(s,e,t,i,n,r,o,a){const{geometry:l,_indirectBuffer:c}=s;for(let u=i,h=i+n;u=0;let v,g;m?(v=ao(s),g=Ws(s,l)):(v=Ws(s,l),g=ao(s));const y=Il(v,o,i,n,r)?fS(v,e,t,i,n,r):null;if(y){const M=y.point[d];if(m?M<=o[g+h]:M>=o[g+h+3])return y}const x=Il(g,o,i,n,r)?fS(g,e,t,i,n,r):null;return y&&x?y.distance<=x.distance?y:x:y||x||null}}const D_=new yn,_d=new Po,yd=new Po,Np=new _t,EI=new ns,I_=new ns;function R7(s,e,t,i){li.setBuffer(s._roots[e]);const n=pS(0,s,t,i);return li.clearBuffer(),n}function pS(s,e,t,i,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=li;let l=s*2;if(n===null&&(t.boundingBox||t.computeBoundingBox(),EI.set(t.boundingBox.min,t.boundingBox.max,i),n=EI),ts(l,o)){const u=e.geometry,h=u.index,d=u.attributes.position,f=t.index,m=t.attributes.position,v=_s(s,a),g=Hs(l,o);if(Np.copy(i).invert(),t.boundsTree)return Ci(s,r,I_),I_.matrix.copy(Np),I_.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>I_.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let w=v*3,x=(g+v)*3;wmS.distanceToBox(M),intersectsBounds:(M,C,T)=>T{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Bp.distanceToBox(A),intersectsBounds:(A,P,E)=>E{for(let E=A,I=A+P;EC&&(C=L),kT&&(T=k),zA&&(A=z)}}return l[d+0]!==w||l[d+1]!==x||l[d+2]!==M||l[d+3]!==C||l[d+4]!==T||l[d+5]!==A?(l[d+0]=w,l[d+1]=x,l[d+2]=M,l[d+3]=C,l[d+4]=T,l[d+5]=A,!0):!1}else{const _=d+8,y=o[d+6],w=_+f,x=y+f;let M=m,C=!1,T=!1;e?M||(C=e.has(w),T=e.has(x),M=!C&&!T):(C=!0,T=!0);const A=M||C,P=M||T;let E=!1;A&&(E=h(_,f,M));let I=!1;P&&(I=h(y,f,M));const R=E||I;if(R)for(let U=0;U<3;U++){const L=_+U,k=y+U,z=l[L],G=l[L+3],W=l[k],q=l[k+3];l[d+U]=zq?G:q}return R}}}function F7(s,e,t,i,n,r,o){li.setBuffer(s._roots[e]),gS(0,s,t,i,n,r,o),li.clearBuffer()}function gS(s,e,t,i,n,r,o){const{float32Array:a,uint16Array:l,uint32Array:c}=li,u=s*2;if(ts(u,l)){const d=_s(s,c),f=Hs(u,l);M7(e,t,i,d,f,n,r,o)}else{const d=ao(s);Il(d,a,i,r,o)&&gS(d,e,t,i,n,r,o);const f=Ws(s,c);Il(f,a,i,r,o)&&gS(f,e,t,i,n,r,o)}}const N7=["x","y","z"];function B7(s,e,t,i,n,r){li.setBuffer(s._roots[e]);const o=vS(0,s,t,i,n,r);return li.clearBuffer(),o}function vS(s,e,t,i,n,r){const{float32Array:o,uint16Array:a,uint32Array:l}=li;let c=s*2;if(ts(c,a)){const h=_s(s,l),d=Hs(c,a);return E7(e,t,i,h,d,n,r)}else{const h=rS(s,l),d=N7[h],m=i.direction[d]>=0;let v,g;m?(v=ao(s),g=Ws(s,l)):(v=Ws(s,l),g=ao(s));const y=Il(v,o,i,n,r)?vS(v,e,t,i,n,r):null;if(y){const M=y.point[d];if(m?M<=o[g+h]:M>=o[g+h+3])return y}const x=Il(g,o,i,n,r)?vS(g,e,t,i,n,r):null;return y&&x?y.distance<=x.distance?y:x:y||x||null}}const U_=new yn,xd=new Po,bd=new Po,zp=new _t,TI=new ns,k_=new ns;function z7(s,e,t,i){li.setBuffer(s._roots[e]);const n=_S(0,s,t,i);return li.clearBuffer(),n}function _S(s,e,t,i,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=li;let l=s*2;if(n===null&&(t.boundingBox||t.computeBoundingBox(),TI.set(t.boundingBox.min,t.boundingBox.max,i),n=TI),ts(l,o)){const u=e.geometry,h=u.index,d=u.attributes.position,f=t.index,m=t.attributes.position,v=_s(s,a),g=Hs(l,o);if(zp.copy(i).invert(),t.boundsTree)return Ci(s,r,k_),k_.matrix.copy(zp),k_.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>k_.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let w=v,x=g+v;wyS.distanceToBox(M),intersectsBounds:(M,C,T)=>T{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:A=>Vp.distanceToBox(A),intersectsBounds:(A,P,E)=>E{for(let E=A,I=A+P;Enew yn),wd=new yn,Sd=new yn,xS=new yn,bS=new yn;let wS=!1;function j7(s,e,t,i){if(wS)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");wS=!0;const n=s._roots,r=e._roots;let o,a=0,l=0;const c=new _t().copy(t).invert();for(let u=0,h=n.length;ul.slice()),index:o?o.array.slice():null,indirectBuffer:r?r.slice():null}:a={roots:n,index:o?o.array:null,indirectBuffer:r},a}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:n,roots:r,indirectBuffer:o}=e,a=new SS(t,{...i,[tS]:!0});if(a._roots=r,a._indirectBuffer=o||null,i.setIndex){const l=t.getIndex();if(l===null){const c=new Bt(e.index,1,!1);t.setIndex(c)}else l.array!==n&&(l.array.set(n),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...q7,[tS]:!1},t),t.useSharedArrayBuffer&&!Y7())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[tS]||(u7(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new yn))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?O7:S7)(this,e)}traverse(e,t=0){const i=this._roots[t],n=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(a,l=0){const c=a*2,u=r[c+15]===b_;if(u){const h=n[a+6],d=r[c+14];e(l,u,new Float32Array(i,a*4,6),h,d)}else{const h=a+Pl/4,d=n[a+6],f=n[a+7];e(l,u,new Float32Array(i,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(e,t=ks,i=0,n=1/0){const r=this._roots,o=this.geometry,a=[],l=t.isMaterial,c=Array.isArray(t),u=o.groups,h=l?t.side:t,d=this.indirect?F7:A7;for(let f=0,m=r.length;fh(d,f,m,v,g)?!0:i(d,f,this,a,m,v,t)}else o||(a?o=(h,d,f,m)=>i(h,d,this,a,f,m,t):o=(h,d,f)=>f);let l=!1,c=0;const u=this._roots;for(let h=0,d=u.length;h{const v=this.resolveTriangleIndex(m);Wi(o,v*3,a,l)}:m=>{Wi(o,m*3,a,l)},u=lo.getPrimitive(),h=e.geometry.index,d=e.geometry.attributes.position,f=e.indirect?m=>{const v=e.resolveTriangleIndex(m);Wi(u,v*3,h,d)}:m=>{Wi(u,m*3,h,d)};if(r){const m=(v,g,_,y,w,x,M,C)=>{for(let T=_,A=_+y;TN_.intersectsBox(i),intersectsTriangle:i=>N_.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},n={},r=0,o=1/0){return(this.indirect?X7:k7)(this,e,t,i,n,r,o)}closestPointToPoint(e,t={},i=0,n=1/0){return v7(this,e,t,i,n)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Ci(0,new Float32Array(i),AI),e.union(AI)}),e}}function Z7(s){switch(s){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function K7(s){switch(s){case 1:return Sh;case 2:return Gg;case 3:return di;case 4:return di}}function CI(s){switch(s){case 1:return Mh;case 2:return Eh;case 3:return Ic;case 4:return Ic}}class PI extends gr{constructor(){super(),this.minFilter=En,this.magFilter=En,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,i=e.itemSize,n=e.count;if(t!==null){if(i*n%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=n*i/t}const r=e.itemSize,o=e.count,a=e.normalized,l=e.array.constructor,c=l.BYTES_PER_ELEMENT;let u=this._forcedType,h=r;if(u===null)switch(l){case Float32Array:u=Un;break;case Uint8Array:case Uint16Array:case Uint32Array:u=hs;break;case Int8Array:case Int16Array:case Int32Array:u=Cc;break}let d,f,m,v,g=Z7(r);switch(u){case Un:m=1,f=K7(r),a&&c===1?(v=l,g+="8",l===Uint8Array?d=Qs:(d=If,g+="_SNORM")):(v=Float32Array,g+="32F",d=Un);break;case Cc:g+=c*8+"I",m=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,f=CI(r),c===1?(v=Int8Array,d=If):c===2?(v=Int16Array,d=Bg):(v=Int32Array,d=Cc);break;case hs:g+=c*8+"UI",m=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,f=CI(r),c===1?(v=Uint8Array,d=Qs):c===2?(v=Uint16Array,d=Ac):(v=Uint32Array,d=hs);break}h===3&&(f===di||f===Ic)&&(h=4);const _=Math.ceil(Math.sqrt(o))||1,y=h*_*_,w=new v(y),x=e.normalized;e.normalized=!1;for(let M=0;M=2&&(w[C+1]=e.getY(M)/m),r>=3&&(w[C+2]=e.getZ(M)/m,h===4&&(w[C+3]=1)),r>=4&&(w[C+3]=e.getW(M)/m)}e.normalized=x,this.internalFormat=g,this.format=f,this.type=d,this.image.width=_,this.image.height=_,this.image.data=w,this.needsUpdate=!0,this.dispose(),e.itemSize=i,e.count=n}}class $7 extends PI{constructor(){super(),this._forcedType=hs}}class J7 extends PI{constructor(){super(),this._forcedType=Un}}class RI{constructor(){this.index=new $7,this.position=new J7,this.bvhBounds=new gr,this.bvhContents=new gr,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(eX(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const i=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const n=pI(fI(t));this._cachedIndexAttr=new Bt(n,1,!1)}Q7(t,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:i,bvhContents:n}=this;e&&e.dispose(),t&&t.dispose(),i&&i.dispose(),n&&n.dispose()}}function Q7(s,e,t){const i=t.array,n=s.index?s.index.array:null;for(let r=0,o=e.length;r= dist; } bool intersectsTriangle( vec3 rayOrigin, vec3 rayDirection, vec3 a, vec3 b, vec3 c, out vec3 barycoord, out vec3 norm, out float dist, out float side ) { // https://stackoverflow.com/questions/42740765/intersection-between-line-and-triangle-in-3d vec3 edge1 = b - a; vec3 edge2 = c - a; norm = cross( edge1, edge2 ); float det = - dot( rayDirection, norm ); float invdet = 1.0 / det; vec3 AO = rayOrigin - a; vec3 DAO = cross( AO, rayDirection ); vec4 uvt; uvt.x = dot( edge2, DAO ) * invdet; uvt.y = - dot( edge1, DAO ) * invdet; uvt.z = dot( AO, norm ) * invdet; uvt.w = 1.0 - uvt.x - uvt.y; // set the hit information barycoord = uvt.wxy; // arranged in A, B, C order dist = uvt.z; side = sign( det ); norm = side * normalize( norm ); // add an epsilon to avoid misses between triangles uvt += vec4( TRI_INTERSECT_EPSILON ); return all( greaterThanEqual( uvt, vec4( 0.0 ) ) ); } bool intersectTriangles( // geometry info and triangle range sampler2D positionAttr, usampler2D indexAttr, uint offset, uint count, // ray vec3 rayOrigin, vec3 rayDirection, // outputs inout float minDistance, inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord, inout float side, inout float dist ) { bool found = false; vec3 localBarycoord, localNormal; float localDist, localSide; for ( uint i = offset, l = offset + count; i < l; i ++ ) { uvec3 indices = uTexelFetch1D( indexAttr, i ).xyz; vec3 a = texelFetch1D( positionAttr, indices.x ).rgb; vec3 b = texelFetch1D( positionAttr, indices.y ).rgb; vec3 c = texelFetch1D( positionAttr, indices.z ).rgb; if ( intersectsTriangle( rayOrigin, rayDirection, a, b, c, localBarycoord, localNormal, localDist, localSide ) && localDist < minDistance ) { found = true; minDistance = localDist; faceIndices = uvec4( indices.xyz, i ); faceNormal = localNormal; side = localSide; barycoord = localBarycoord; dist = localDist; } } return found; } bool intersectsBVHNodeBounds( vec3 rayOrigin, vec3 rayDirection, sampler2D bvhBounds, uint currNodeIndex, out float dist ) { uint cni2 = currNodeIndex * 2u; vec3 boundsMin = texelFetch1D( bvhBounds, cni2 ).xyz; vec3 boundsMax = texelFetch1D( bvhBounds, cni2 + 1u ).xyz; return intersectsBounds( rayOrigin, rayDirection, boundsMin, boundsMax, dist ); } // use a macro to hide the fact that we need to expand the struct into separate fields #define bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ) _bvhIntersectFirstHit( bvh.position, bvh.index, bvh.bvhBounds, bvh.bvhContents, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ) bool _bvhIntersectFirstHit( // bvh info sampler2D bvh_position, usampler2D bvh_index, sampler2D bvh_bvhBounds, usampler2D bvh_bvhContents, // ray vec3 rayOrigin, vec3 rayDirection, // output variables split into separate variables due to output precision inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord, inout float side, inout float dist ) { // stack needs to be twice as long as the deepest tree we expect because // we push both the left and right child onto the stack every traversal int ptr = 0; uint stack[ BVH_STACK_DEPTH ]; stack[ 0 ] = 0u; float triangleDistance = INFINITY; bool found = false; while ( ptr > - 1 && ptr < BVH_STACK_DEPTH ) { uint currNodeIndex = stack[ ptr ]; ptr --; // check if we intersect the current bounds float boundsHitDistance; if ( ! intersectsBVHNodeBounds( rayOrigin, rayDirection, bvh_bvhBounds, currNodeIndex, boundsHitDistance ) || boundsHitDistance > triangleDistance ) { continue; } uvec2 boundsInfo = uTexelFetch1D( bvh_bvhContents, currNodeIndex ).xy; bool isLeaf = bool( boundsInfo.x & 0xffff0000u ); if ( isLeaf ) { uint count = boundsInfo.x & 0x0000ffffu; uint offset = boundsInfo.y; found = intersectTriangles( bvh_position, bvh_index, offset, count, rayOrigin, rayDirection, triangleDistance, faceIndices, faceNormal, barycoord, side, dist ) || found; } else { uint leftIndex = currNodeIndex + 1u; uint splitAxis = boundsInfo.x & 0x0000ffffu; uint rightIndex = boundsInfo.y; bool leftToRight = rayDirection[ splitAxis ] >= 0.0; uint c1 = leftToRight ? leftIndex : rightIndex; uint c2 = leftToRight ? rightIndex : leftIndex; // set c2 in the stack so we traverse it later. We need to keep track of a pointer in // the stack while we traverse. The second pointer added is the one that will be // traversed first ptr ++; stack[ ptr ] = c2; ptr ++; stack[ ptr ] = c1; } } return found; } `,iX=` struct BVH { usampler2D index; sampler2D position; sampler2D bvhBounds; usampler2D bvhContents; }; `,rX=` ${tX} ${nX} `,sX=`#define ENVMAP_TYPE_CUBE_UV precision highp isampler2D; precision highp usampler2D; varying vec3 vWorldPosition; varying vec3 vNormal; varying mat4 vModelMatrixInverse; #ifdef USE_INSTANCING_COLOR varying vec3 vInstanceColor; #endif #ifdef ENVMAP_TYPE_CUBEM uniform samplerCube envMap; #else uniform sampler2D envMap; #endif uniform float bounces; ${iX} ${rX} uniform BVH bvh; uniform float ior; uniform bool correctMips; uniform vec2 resolution; uniform float fresnel; uniform mat4 modelMatrix; uniform mat4 projectionMatrixInverse; uniform mat4 viewMatrixInverse; uniform float aberrationStrength; uniform vec3 color; float fresnelFunc(vec3 viewDirection, vec3 worldNormal) { return pow( 1.0 + dot( viewDirection, worldNormal), 10.0 ); } vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 normal, float ior, mat4 modelMatrixInverse) { vec3 rayOrigin = ro; vec3 rayDirection = rd; rayDirection = refract(rayDirection, normal, 1.0 / ior); rayOrigin = vWorldPosition + rayDirection * 0.001; rayOrigin = (modelMatrixInverse * vec4(rayOrigin, 1.0)).xyz; rayDirection = normalize((modelMatrixInverse * vec4(rayDirection, 0.0)).xyz); for(float i = 0.0; i < bounces; i++) { uvec4 faceIndices = uvec4( 0u ); vec3 faceNormal = vec3( 0.0, 0.0, 1.0 ); vec3 barycoord = vec3( 0.0 ); float side = 1.0; float dist = 0.0; bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ); vec3 hitPos = rayOrigin + rayDirection * max(dist - 0.001, 0.0); vec3 tempDir = refract(rayDirection, faceNormal, ior); if (length(tempDir) != 0.0) { rayDirection = tempDir; break; } rayDirection = reflect(rayDirection, faceNormal); rayOrigin = hitPos + rayDirection * 0.01; } rayDirection = normalize((modelMatrix * vec4(rayDirection, 0.0)).xyz); return rayDirection; } #include #include #ifdef ENVMAP_TYPE_CUBEM vec4 textureGradient(samplerCube envMap, vec3 rayDirection, vec3 directionCamPerfect) { return textureGrad(envMap, rayDirection, dFdx(correctMips ? directionCamPerfect: rayDirection), dFdy(correctMips ? directionCamPerfect: rayDirection)); } #else vec4 textureGradient(sampler2D envMap, vec3 rayDirection, vec3 directionCamPerfect) { vec2 uvv = equirectUv( rayDirection ); vec2 smoothUv = equirectUv( directionCamPerfect ); return textureGrad(envMap, uvv, dFdx(correctMips ? smoothUv : uvv), dFdy(correctMips ? smoothUv : uvv)); } #endif void main() { vec2 uv = gl_FragCoord.xy / resolution; vec3 directionCamPerfect = (projectionMatrixInverse * vec4(uv * 2.0 - 1.0, 0.0, 1.0)).xyz; directionCamPerfect = (viewMatrixInverse * vec4(directionCamPerfect, 0.0)).xyz; directionCamPerfect = normalize(directionCamPerfect); vec3 normal = vNormal; vec3 rayOrigin = cameraPosition; vec3 rayDirection = normalize(vWorldPosition - cameraPosition); vec3 finalColor; #ifdef CHROMATIC_ABERRATIONS vec3 rayDirectionG = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior, 1.0), vModelMatrixInverse); #ifdef FAST_CHROMA vec3 rayDirectionR = normalize(rayDirectionG + 1.0 * vec3(aberrationStrength / 2.0)); vec3 rayDirectionB = normalize(rayDirectionG - 1.0 * vec3(aberrationStrength / 2.0)); #else vec3 rayDirectionR = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior * (1.0 - aberrationStrength), 1.0), vModelMatrixInverse); vec3 rayDirectionB = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior * (1.0 + aberrationStrength), 1.0), vModelMatrixInverse); #endif float finalColorR = textureGradient(envMap, rayDirectionR, directionCamPerfect).r; float finalColorG = textureGradient(envMap, rayDirectionG, directionCamPerfect).g; float finalColorB = textureGradient(envMap, rayDirectionB, directionCamPerfect).b; finalColor = vec3(finalColorR, finalColorG, finalColorB); #else rayDirection = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior, 1.0), vModelMatrixInverse); finalColor = textureGradient(envMap, rayDirection, directionCamPerfect).rgb; #endif finalColor *= color; #ifdef USE_INSTANCING_COLOR finalColor *= vInstanceColor; #endif vec3 viewDirection = normalize(vWorldPosition - cameraPosition); float nFresnel = fresnelFunc(viewDirection, normal) * fresnel; gl_FragColor = vec4(mix(finalColor, vec3(1.0), nFresnel), 1.0); ${Ft.tonemapping_fragment} ${Ft.colorspace_fragment} }`,oX=`uniform mat4 viewMatrixInverse; varying vec3 vWorldPosition; varying vec3 vNormal; varying mat4 vModelMatrixInverse; #ifdef USE_INSTANCING_COLOR varying vec3 vInstanceColor; #endif void main() { vec4 transformedNormal = vec4(normal, 0.0); vec4 transformedPosition = vec4(position, 1.0); #ifdef USE_INSTANCING transformedNormal = instanceMatrix * transformedNormal; transformedPosition = instanceMatrix * transformedPosition; #endif #ifdef USE_INSTANCING vModelMatrixInverse = inverse(modelMatrix * instanceMatrix); #else vModelMatrixInverse = inverse(modelMatrix); #endif #ifdef USE_INSTANCING_COLOR vInstanceColor = instanceColor.rgb; #endif vWorldPosition = (modelMatrix * transformedPosition).xyz; vNormal = normalize((viewMatrixInverse * vec4(normalMatrix * transformedNormal.xyz, 0.0)).xyz); gl_Position = projectionMatrix * viewMatrix * modelMatrix * transformedPosition; }`;function DI(s,e){if(new.target)return Tt({component:DI,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(x,"$parent",t),r=()=>Rn(_,"$size",t);let o=H(e,"envMap",7),a=H(e,"bounces",7,2),l=H(e,"ior",7,2.4),c=H(e,"fresnel",7,0),u=H(e,"aberrationStrength",7,0),h=H(e,"color",7,"white"),d=H(e,"fastChroma",7,!0),f=H(e,"ref",15),m=an(e,["$$slots","$$events","$$legacy","$$host","envMap","bounces","ior","fresnel","aberrationStrength","color","fastChroma","ref"]);const v={envMap:{value:null},bounces:{value:2},ior:{value:2.4},correctMips:{value:!0},aberrationStrength:{value:.01},fresnel:{value:0},bvh:{value:new RI},color:{value:new rt("white")},resolution:{value:new Ne},viewMatrixInverse:{value:new _t},projectionMatrixInverse:{value:new _t}},g=new Ti({fragmentShader:sX,vertexShader:oX,uniforms:v}),{size:_,invalidate:y,camera:w}=un(),x=To();let M={};const C=(E,I,R)=>{var O;const U=wn(E,"CubeTexture"),k=((U?(O=E.image[0])==null?void 0:O.width:E==null?void 0:E.image.width)??1024)/4,z=Math.floor(Math.log2(k)),G=Math.pow(2,z),W=3*Math.max(G,16*7),q=4*G;U&&(M.ENVMAP_TYPE_CUBEM=""),M.CUBEUV_TEXEL_WIDTH=`${1/W}`,M.CUBEUV_TEXEL_HEIGHT=`${1/q}`,M.CUBEUV_MAX_MIP=`${z}.0`,I>0&&(M.CHROMATIC_ABERRATIONS=""),R&&(M.FAST_CHROMA="")};$e(()=>{C(o(),u(),d())}),Gr(()=>{var E;n()&&n()instanceof it&&n().geometry&&(v.bvh.value=new RI,v.bvh.value.updateFrom(new SS((E=n())==null?void 0:E.geometry.clone().toNonIndexed(),{strategy:uI})))}),ii(()=>{v.viewMatrixInverse.value=w.current.matrixWorld,v.projectionMatrixInverse.value=w.current.projectionMatrixInverse},{autoInvalidate:!1});const T=new rt(h());$e(()=>{T.set(h()),y()});const A=xt(()=>[r().width,r().height]);pt(s,rn({is:g,get"uniforms.envMap.value"(){return o()},get"uniforms.bounces.value"(){return a()},get"uniforms.ior.value"(){return l()},get"uniforms.fresnel.value"(){return c()},get"uniforms.aberrationStrength.value"(){return u()},"uniforms.color.value":T,get"uniforms.resolution.value"(){return fe(A)},defines:M},()=>m,{get ref(){return f()},set ref(E){f(E)}}));var P=Et({get envMap(){return o()},set envMap(E){o(E),V()},get bounces(){return a()},set bounces(E=2){a(E),V()},get ior(){return l()},set ior(E=2.4){l(E),V()},get fresnel(){return c()},set fresnel(E=0){c(E),V()},get aberrationStrength(){return u()},set aberrationStrength(E=0){u(E),V()},get color(){return h()},set color(E="white"){h(E),V()},get fastChroma(){return d()},set fastChroma(E=!0){d(E),V()},get ref(){return f()},set ref(E){f(E),V()},$set:Ct,$on:(E,I)=>At(e,E,I)});return i(),P}Pt(DI,{envMap:{},bounces:{},ior:{},fresnel:{},aberrationStrength:{},color:{},fastChroma:{},ref:{}},[],[],!0);class aX extends ed{constructor(e,t={}){const i=t.font;if(i===void 0)super();else{const n=i.generateShapes(e,t.size);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(n,t)}this.type="TextGeometry"}}class lX extends vr{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new gs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){const l=r.parse(JSON.parse(a));t&&t(l)},i,n)}parse(e){return new cX(e)}}class cX{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const i=[],n=uX(e,t,this.data);for(let r=0,o=n.length;rRn(fe(T),"$loadedFont",t);let r=H(e,"text",7),o=H(e,"font",7,"https://cdn.jsdelivr.net/npm/three/examples/fonts/helvetiker_regular.typeface.json"),a=H(e,"size",7),l=H(e,"depth",7),c=H(e,"curveSegments",7),u=H(e,"bevelEnabled",7),h=H(e,"bevelThickness",7),d=H(e,"bevelSize",7),f=H(e,"bevelOffset",7),m=H(e,"bevelSegments",7),v=H(e,"smooth",7),g=H(e,"extrudePath",7),_=H(e,"steps",7),y=H(e,"UVGenerator",7),w=H(e,"ref",15),x=H(e,"children",7),M=an(e,["$$slots","$$events","$$legacy","$$host","text","font","size","depth","curveSegments","bevelEnabled","bevelThickness","bevelSize","bevelOffset","bevelSegments","smooth","extrudePath","steps","UVGenerator","ref","children"]);const C=Ml();let T=xt(()=>C(typeof o()=="string"?bp(lX).load(o()):uu(new Promise(L=>L(o()))))),A=xt(()=>{if(n())return new aX(r(),{font:n(),size:a(),depth:l(),curveSegments:c(),bevelEnabled:u(),bevelThickness:h(),bevelSize:d(),bevelOffset:f(),bevelSegments:m(),extrudePath:g(),steps:_(),UVGenerator:y()})}),P=xt(()=>{if(fe(A))return v()===0?fe(A):lw(fe(A),v())});var E=Lt(),I=dt(E);{var R=L=>{pt(L,rn({get is(){return fe(P)}},()=>M,{get ref(){return w()},set ref(k){w(k)},children:(k,z)=>{var G=Lt(),W=dt(G);Wt(W,()=>x()??Nt,()=>({ref:fe(P)})),lt(k,G)},$$slots:{default:!0}}))};wi(I,L=>{fe(P)&&L(R)})}lt(s,E);var U=Et({get text(){return r()},set text(L){r(L),V()},get font(){return o()},set font(L="https://cdn.jsdelivr.net/npm/three/examples/fonts/helvetiker_regular.typeface.json"){o(L),V()},get size(){return a()},set size(L){a(L),V()},get depth(){return l()},set depth(L){l(L),V()},get curveSegments(){return c()},set curveSegments(L){c(L),V()},get bevelEnabled(){return u()},set bevelEnabled(L){u(L),V()},get bevelThickness(){return h()},set bevelThickness(L){h(L),V()},get bevelSize(){return d()},set bevelSize(L){d(L),V()},get bevelOffset(){return f()},set bevelOffset(L){f(L),V()},get bevelSegments(){return m()},set bevelSegments(L){m(L),V()},get smooth(){return v()},set smooth(L){v(L),V()},get extrudePath(){return g()},set extrudePath(L){g(L),V()},get steps(){return _()},set steps(L){_(L),V()},get UVGenerator(){return y()},set UVGenerator(L){y(L),V()},get ref(){return w()},set ref(L){w(L),V()},get children(){return x()},set children(L){x(L),V()},$set:Ct,$on:(L,k)=>At(e,L,k)});return i(),U}Pt(II,{text:{},font:{},size:{},depth:{},curveSegments:{},bevelEnabled:{},bevelThickness:{},bevelSize:{},bevelOffset:{},bevelSegments:{},smooth:{},extrudePath:{},steps:{},UVGenerator:{},ref:{},children:{}},[],[],!0);var Hp={exports:{}};/*! Tweakpane 3.1.10 (c) 2016 cocopon, licensed under the MIT license. */var dX=Hp.exports,LI;function fX(){return LI||(LI=1,function(s,e){(function(t,i){i(e)})(dX,function(t){class i{constructor(p){const[b,D]=p.split("-"),Y=b.split(".");this.major=parseInt(Y[0],10),this.minor=parseInt(Y[1],10),this.patch=parseInt(Y[2],10),this.prerelease=D??null}toString(){const p=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[p,this.prerelease].join("-"):p}}class n{constructor(p){this.controller_=p}get element(){return this.controller_.view.element}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(p){this.controller_.viewProps.set("disabled",p)}get hidden(){return this.controller_.viewProps.get("hidden")}set hidden(p){this.controller_.viewProps.set("hidden",p)}dispose(){this.controller_.viewProps.set("disposed",!0)}}class r{constructor(p){this.target=p}}class o extends r{constructor(p,b,D,Y){super(p),this.value=b,this.presetKey=D,this.last=Y??!0}}class a extends r{constructor(p,b,D){super(p),this.value=b,this.presetKey=D}}class l extends r{constructor(p,b){super(p),this.expanded=b}}class c extends r{constructor(p,b){super(p),this.index=b}}function u(S){return S}function h(S){return S==null}function d(S,p){if(S.length!==p.length)return!1;for(let b=0;b"View has been already disposed",invalidparams:S=>`Invalid parameters for '${S.name}'`,nomatchingcontroller:S=>`No matching controller for '${S.key}'`,nomatchingview:S=>`No matching view for '${JSON.stringify(S.params)}'`,notbindable:()=>"Value is not bindable",propertynotfound:S=>`Property '${S.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class v{static alreadyDisposed(){return new v({type:"alreadydisposed"})}static notBindable(){return new v({type:"notbindable"})}static propertyNotFound(p){return new v({type:"propertynotfound",context:{name:p}})}static shouldNeverHappen(){return new v({type:"shouldneverhappen"})}constructor(p){var b;this.message=(b=m[p.type](p.context))!==null&&b!==void 0?b:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=p.type}}class g{constructor(p,b,D){this.obj_=p,this.key_=b,this.presetKey_=D??b}static isBindable(p){return!(p===null||typeof p!="object"&&typeof p!="function")}get key(){return this.key_}get presetKey(){return this.presetKey_}read(){return this.obj_[this.key_]}write(p){this.obj_[this.key_]=p}writeProperty(p,b){const D=this.read();if(!g.isBindable(D))throw v.notBindable();if(!(p in D))throw v.propertyNotFound(p);D[p]=b}}class _ extends n{get label(){return this.controller_.props.get("label")}set label(p){this.controller_.props.set("label",p)}get title(){var p;return(p=this.controller_.valueController.props.get("title"))!==null&&p!==void 0?p:""}set title(p){this.controller_.valueController.props.set("title",p)}on(p,b){const D=b.bind(this);return this.controller_.valueController.emitter.on(p,()=>{D(new r(this))}),this}}class y{constructor(){this.observers_={}}on(p,b){let D=this.observers_[p];return D||(D=this.observers_[p]=[]),D.push({handler:b}),this}off(p,b){const D=this.observers_[p];return D&&(this.observers_[p]=D.filter(Y=>Y.handler!==b)),this}emit(p,b){const D=this.observers_[p];D&&D.forEach(Y=>{Y.handler(b)})}}const w="tp";function x(S){return(b,D)=>[w,"-",S,"v",b?`_${b}`:"",D?`-${D}`:""].join("")}function M(S,p){return b=>p(S(b))}function C(S){return S.rawValue}function T(S,p){S.emitter.on("change",M(C,p)),p(S.rawValue)}function A(S,p,b){T(S.value(p),b)}function P(S,p,b){b?S.classList.add(p):S.classList.remove(p)}function E(S,p){return b=>{P(S,p,b)}}function I(S,p){T(S,b=>{p.textContent=b??""})}const R=x("btn");class U{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(R()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("button");D.classList.add(R("b")),b.viewProps.bindDisabled(D),this.element.appendChild(D),this.buttonElement=D;const Y=p.createElement("div");Y.classList.add(R("t")),I(b.props.value("title"),Y),this.buttonElement.appendChild(Y)}}class L{constructor(p,b){this.emitter=new y,this.onClick_=this.onClick_.bind(this),this.props=b.props,this.viewProps=b.viewProps,this.view=new U(p,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class k{constructor(p,b){var D;this.constraint_=b==null?void 0:b.constraint,this.equals_=(D=b==null?void 0:b.equals)!==null&&D!==void 0?D:(Y,ge)=>Y===ge,this.emitter=new y,this.rawValue_=p}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(p){this.setRawValue(p,{forceEmit:!1,last:!0})}setRawValue(p,b){const D=b??{forceEmit:!1,last:!0},Y=this.constraint_?this.constraint_.constrain(p):p,ge=this.rawValue_;this.equals_(ge,Y)&&!D.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=Y,this.emitter.emit("change",{options:D,previousRawValue:ge,rawValue:Y,sender:this}))}}class z{constructor(p){this.emitter=new y,this.value_=p}get rawValue(){return this.value_}set rawValue(p){this.setRawValue(p,{forceEmit:!1,last:!0})}setRawValue(p,b){const D=b??{forceEmit:!1,last:!0},Y=this.value_;Y===p&&!D.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=p,this.emitter.emit("change",{options:D,previousRawValue:Y,rawValue:this.value_,sender:this}))}}function G(S,p){const b=p==null?void 0:p.constraint,D=p==null?void 0:p.equals;return!b&&!D?new z(S):new k(S,p)}class W{constructor(p){this.emitter=new y,this.valMap_=p;for(const b in this.valMap_)this.valMap_[b].emitter.on("change",()=>{this.emitter.emit("change",{key:b,sender:this})})}static createCore(p){return Object.keys(p).reduce((D,Y)=>Object.assign(D,{[Y]:G(p[Y])}),{})}static fromObject(p){const b=this.createCore(p);return new W(b)}get(p){return this.valMap_[p].rawValue}set(p,b){this.valMap_[p].rawValue=b}value(p){return this.valMap_[p]}}function q(S,p){const D=Object.keys(p).reduce((Y,ge)=>{if(Y===void 0)return;const ke=p[ge],ct=ke(S[ge]);return ct.succeeded?Object.assign(Object.assign({},Y),{[ge]:ct.value}):void 0},{});return D}function O(S,p){return S.reduce((b,D)=>{if(b===void 0)return;const Y=p(D);if(!(!Y.succeeded||Y.value===void 0))return[...b,Y.value]},[])}function B(S){return S===null?!1:typeof S=="object"}function J(S){return p=>b=>{if(!p&&b===void 0)return{succeeded:!1,value:void 0};if(p&&b===void 0)return{succeeded:!0,value:void 0};const D=S(b);return D!==void 0?{succeeded:!0,value:D}:{succeeded:!1,value:void 0}}}function re(S){return{custom:p=>J(p)(S),boolean:J(p=>typeof p=="boolean"?p:void 0)(S),number:J(p=>typeof p=="number"?p:void 0)(S),string:J(p=>typeof p=="string"?p:void 0)(S),function:J(p=>typeof p=="function"?p:void 0)(S),constant:p=>J(b=>b===p?p:void 0)(S),raw:J(p=>p)(S),object:p=>J(b=>{if(B(b))return q(b,p)})(S),array:p=>J(b=>{if(Array.isArray(b))return O(b,p)})(S)}}const K={optional:re(!0),required:re(!1)};function Q(S,p){const b=K.required.object(p)(S);return b.succeeded?b.value:void 0}function ue(S){console.warn([`Missing '${S.key}' of ${S.target} in ${S.place}.`,"Please rebuild plugins with the latest core package."].join(" "))}function le(S){return S&&S.parentElement&&S.parentElement.removeChild(S),null}class _e{constructor(p){this.value_=p}static create(p){return[new _e(p),(b,D)=>{p.setRawValue(b,D)}]}get emitter(){return this.value_.emitter}get rawValue(){return this.value_.rawValue}}const Fe=x("");function Ie(S,p){return E(S,Fe(void 0,p))}class Ee extends W{constructor(p){var b;super(p),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=_e.create(G(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(b=this.get("parent"))===null||b===void 0||b.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(p){var b,D,Y;const ge=p??{};return new Ee(W.createCore({disabled:(b=ge.disabled)!==null&&b!==void 0?b:!1,disposed:!1,hidden:(D=ge.hidden)!==null&&D!==void 0?D:!1,parent:(Y=ge.parent)!==null&&Y!==void 0?Y:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(p){T(this.globalDisabled_,Ie(p,"disabled")),A(this,"hidden",Ie(p,"hidden"))}bindDisabled(p){T(this.globalDisabled_,b=>{p.disabled=b})}bindTabIndex(p){T(this.globalDisabled_,b=>{p.tabIndex=b?-1:0})}handleDispose(p){this.value("disposed").emitter.on("change",b=>{b&&p()})}getGlobalDisabled_(){const p=this.get("parent");return(p?p.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(p){var b;const D=p.previousRawValue;D==null||D.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(b=this.get("parent"))===null||b===void 0||b.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}function me(){return["veryfirst","first","last","verylast"]}const xe=x(""),$={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class Ue{constructor(p){this.parent_=null,this.blade=p.blade,this.view=p.view,this.viewProps=p.viewProps;const b=this.view.element;this.blade.value("positions").emitter.on("change",()=>{me().forEach(D=>{b.classList.remove(xe(void 0,$[D]))}),this.blade.get("positions").forEach(D=>{b.classList.add(xe(void 0,$[D]))})}),this.viewProps.handleDispose(()=>{le(b)})}get parent(){return this.parent_}set parent(p){if(this.parent_=p,!("parent"in this.viewProps.valMap_)){ue({key:"parent",target:Ee.name,place:"BladeController.parent"});return}this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}}const Me="http://www.w3.org/2000/svg";function oe(S){S.offsetHeight}function Te(S,p){const b=S.style.transition;S.style.transition="none",p(),S.style.transition=b}function Ye(S){return S.ontouchstart!==void 0}function Oe(){return globalThis}function j(){return Oe().document}function Z(S){const p=S.ownerDocument.defaultView;return p&&"document"in p?S.getContext("2d",{willReadFrequently:!0}):null}const pe={check:'',dropdown:'',p2dpad:''};function he(S,p){const b=S.createElementNS(Me,"svg");return b.innerHTML=pe[p],b}function te(S,p,b){S.insertBefore(p,S.children[b])}function Se(S){S.parentElement&&S.parentElement.removeChild(S)}function ye(S){for(;S.children.length>0;)S.removeChild(S.children[0])}function Ae(S){for(;S.childNodes.length>0;)S.removeChild(S.childNodes[0])}function Ce(S){return S.relatedTarget?S.relatedTarget:"explicitOriginalTarget"in S?S.explicitOriginalTarget:null}const Ge=x("lbl");function De(S,p){const b=S.createDocumentFragment();return p.split(` `).map(Y=>S.createTextNode(Y)).forEach((Y,ge)=>{ge>0&&b.appendChild(S.createElement("br")),b.appendChild(Y)}),b}class Ve{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(Ge()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("div");D.classList.add(Ge("l")),A(b.props,"label",ge=>{h(ge)?this.element.classList.add(Ge(void 0,"nol")):(this.element.classList.remove(Ge(void 0,"nol")),Ae(D),D.appendChild(De(p,ge)))}),this.element.appendChild(D),this.labelElement=D;const Y=p.createElement("div");Y.classList.add(Ge("v")),this.element.appendChild(Y),this.valueElement=Y}}class ze extends Ue{constructor(p,b){const D=b.valueController.viewProps;super(Object.assign(Object.assign({},b),{view:new Ve(p,{props:b.props,viewProps:D}),viewProps:D})),this.props=b.props,this.valueController=b.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}const Ze={id:"button",type:"blade",accept(S){const p=K,b=Q(S,{title:p.required.string,view:p.required.constant("button"),label:p.optional.string});return b?{params:b}:null},controller(S){return new ze(S.document,{blade:S.blade,props:W.fromObject({label:S.params.label}),valueController:new L(S.document,{props:W.fromObject({title:S.params.title}),viewProps:S.viewProps})})},api(S){return!(S.controller instanceof ze)||!(S.controller.valueController instanceof L)?null:new _(S.controller)}};class Le extends Ue{constructor(p){super(p),this.value=p.value}}function ot(){return new W({positions:G([],{equals:d})})}class tt extends W{constructor(p){super(p)}static create(p){const b={completed:!0,expanded:p,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},D=W.createCore(b);return new tt(D)}get styleExpanded(){var p;return(p=this.get("temporaryExpanded"))!==null&&p!==void 0?p:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const p=this.get("expandedHeight");return this.get("shouldFixHeight")&&!h(p)?`${p}px`:"auto"}bindExpandedClass(p,b){const D=()=>{this.styleExpanded?p.classList.add(b):p.classList.remove(b)};A(this,"expanded",D),A(this,"temporaryExpanded",D)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function mt(S,p){let b=0;return Te(p,()=>{S.set("expandedHeight",null),S.set("temporaryExpanded",!0),oe(p),b=p.clientHeight,S.set("temporaryExpanded",null),oe(p)}),b}function ce(S,p){p.style.height=S.styleHeight}function ve(S,p){S.value("expanded").emitter.on("beforechange",()=>{if(S.set("completed",!1),h(S.get("expandedHeight"))){const b=mt(S,p);b>0&&S.set("expandedHeight",b)}S.set("shouldFixHeight",!0),oe(p)}),S.emitter.on("change",()=>{ce(S,p)}),ce(S,p),p.addEventListener("transitionend",b=>{b.propertyName==="height"&&S.cleanUpTransition()})}class be extends n{constructor(p,b){super(p),this.rackApi_=b}}function Xe(S,p){return S.addBlade(Object.assign(Object.assign({},p),{view:"button"}))}function We(S,p){return S.addBlade(Object.assign(Object.assign({},p),{view:"folder"}))}function Be(S,p){const b=p??{};return S.addBlade(Object.assign(Object.assign({},b),{view:"separator"}))}function ut(S,p){return S.addBlade(Object.assign(Object.assign({},p),{view:"tab"}))}class gt{constructor(p){this.emitter=new y,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=p}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(p){for(const b of this.allItems())if(p(b))return b;return null}includes(p){return this.cache_.has(p)}add(p,b){if(this.includes(p))throw v.shouldNeverHappen();const D=b!==void 0?b:this.items_.length;this.items_.splice(D,0,p),this.cache_.add(p);const Y=this.extract_(p);Y&&(Y.emitter.on("add",this.onSubListAdd_),Y.emitter.on("remove",this.onSubListRemove_),Y.allItems().forEach(ge=>{this.cache_.add(ge)})),this.emitter.emit("add",{index:D,item:p,root:this,target:this})}remove(p){const b=this.items_.indexOf(p);if(b<0)return;this.items_.splice(b,1),this.cache_.delete(p);const D=this.extract_(p);D&&(D.emitter.off("add",this.onSubListAdd_),D.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:b,item:p,root:this,target:this})}onSubListAdd_(p){this.cache_.add(p.item),this.emitter.emit("add",{index:p.index,item:p.item,root:this,target:p.target})}onSubListRemove_(p){this.cache_.delete(p.item),this.emitter.emit("remove",{index:p.index,item:p.item,root:this,target:p.target})}}class nt extends n{constructor(p){super(p),this.onBindingChange_=this.onBindingChange_.bind(this),this.emitter_=new y,this.controller_.binding.emitter.on("change",this.onBindingChange_)}get label(){return this.controller_.props.get("label")}set label(p){this.controller_.props.set("label",p)}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}refresh(){this.controller_.binding.read()}onBindingChange_(p){const b=p.sender.target.read();this.emitter_.emit("change",{event:new o(this,b,this.controller_.binding.target.presetKey,p.options.last)})}}class je extends ze{constructor(p,b){super(p,b),this.binding=b.binding}}class at extends n{constructor(p){super(p),this.onBindingUpdate_=this.onBindingUpdate_.bind(this),this.emitter_=new y,this.controller_.binding.emitter.on("update",this.onBindingUpdate_)}get label(){return this.controller_.props.get("label")}set label(p){this.controller_.props.set("label",p)}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}refresh(){this.controller_.binding.read()}onBindingUpdate_(p){const b=p.sender.target.read();this.emitter_.emit("update",{event:new a(this,b,this.controller_.binding.target.presetKey)})}}class ft extends ze{constructor(p,b){super(p,b),this.binding=b.binding,this.viewProps.bindDisabled(this.binding.ticker),this.viewProps.handleDispose(()=>{this.binding.dispose()})}}function Qe(S){return S instanceof Rt?S.apiSet_:S instanceof be?S.rackApi_.apiSet_:null}function bt(S,p){const b=S.find(D=>D.controller_===p);if(!b)throw v.shouldNeverHappen();return b}function yt(S,p,b){if(!g.isBindable(S))throw v.notBindable();return new g(S,p,b)}class Rt extends n{constructor(p,b){super(p),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.onRackInputChange_=this.onRackInputChange_.bind(this),this.onRackMonitorUpdate_=this.onRackMonitorUpdate_.bind(this),this.emitter_=new y,this.apiSet_=new gt(Qe),this.pool_=b;const D=this.controller_.rack;D.emitter.on("add",this.onRackAdd_),D.emitter.on("remove",this.onRackRemove_),D.emitter.on("inputchange",this.onRackInputChange_),D.emitter.on("monitorupdate",this.onRackMonitorUpdate_),D.children.forEach(Y=>{this.setUpApi_(Y)})}get children(){return this.controller_.rack.children.map(p=>bt(this.apiSet_,p))}addInput(p,b,D){const Y=D??{},ge=this.controller_.view.element.ownerDocument,ke=this.pool_.createInput(ge,yt(p,b,Y.presetKey),Y),ct=new nt(ke);return this.add(ct,Y.index)}addMonitor(p,b,D){const Y=D??{},ge=this.controller_.view.element.ownerDocument,ke=this.pool_.createMonitor(ge,yt(p,b),Y),ct=new at(ke);return this.add(ct,Y.index)}addFolder(p){return We(this,p)}addButton(p){return Xe(this,p)}addSeparator(p){return Be(this,p)}addTab(p){return ut(this,p)}add(p,b){this.controller_.rack.add(p.controller_,b);const D=this.apiSet_.find(Y=>Y.controller_===p.controller_);return D&&this.apiSet_.remove(D),this.apiSet_.add(p),p}remove(p){this.controller_.rack.remove(p.controller_)}addBlade(p){const b=this.controller_.view.element.ownerDocument,D=this.pool_.createBlade(b,p),Y=this.pool_.createBladeApi(D);return this.add(Y,p.index)}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}setUpApi_(p){this.apiSet_.find(D=>D.controller_===p)||this.apiSet_.add(this.pool_.createBladeApi(p))}onRackAdd_(p){this.setUpApi_(p.bladeController)}onRackRemove_(p){if(p.isRoot){const b=bt(this.apiSet_,p.bladeController);this.apiSet_.remove(b)}}onRackInputChange_(p){const b=p.bladeController;if(b instanceof je){const D=bt(this.apiSet_,b),Y=b.binding;this.emitter_.emit("change",{event:new o(D,Y.target.read(),Y.target.presetKey,p.options.last)})}else if(b instanceof Le){const D=bt(this.apiSet_,b);this.emitter_.emit("change",{event:new o(D,b.value.rawValue,void 0,p.options.last)})}}onRackMonitorUpdate_(p){if(!(p.bladeController instanceof ft))throw v.shouldNeverHappen();const b=bt(this.apiSet_,p.bladeController),D=p.bladeController.binding;this.emitter_.emit("update",{event:new a(b,D.target.read(),D.target.presetKey)})}}class on extends be{constructor(p,b){super(p,new Rt(p.rackController,b)),this.emitter_=new y,this.controller_.foldable.value("expanded").emitter.on("change",D=>{this.emitter_.emit("fold",{event:new l(this,D.sender.rawValue)})}),this.rackApi_.on("change",D=>{this.emitter_.emit("change",{event:D})}),this.rackApi_.on("update",D=>{this.emitter_.emit("update",{event:D})})}get expanded(){return this.controller_.foldable.get("expanded")}set expanded(p){this.controller_.foldable.set("expanded",p)}get title(){return this.controller_.props.get("title")}set title(p){this.controller_.props.set("title",p)}get children(){return this.rackApi_.children}addInput(p,b,D){return this.rackApi_.addInput(p,b,D)}addMonitor(p,b,D){return this.rackApi_.addMonitor(p,b,D)}addFolder(p){return this.rackApi_.addFolder(p)}addButton(p){return this.rackApi_.addButton(p)}addSeparator(p){return this.rackApi_.addSeparator(p)}addTab(p){return this.rackApi_.addTab(p)}add(p,b){return this.rackApi_.add(p,b)}remove(p){this.rackApi_.remove(p)}addBlade(p){return this.rackApi_.addBlade(p)}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}}class zt extends Ue{constructor(p){super({blade:p.blade,view:p.view,viewProps:p.rackController.viewProps}),this.rackController=p.rackController}}class Qt{constructor(p,b){const D=x(b.viewName);this.element=p.createElement("div"),this.element.classList.add(D()),b.viewProps.bindClassModifiers(this.element)}}function Kt(S,p){for(let b=0;bb instanceof p)}onSetAdd_(p){this.updatePositions_();const b=p.target===p.root;if(this.emitter.emit("add",{bladeController:p.item,index:p.index,isRoot:b,sender:this}),!b)return;const D=p.item;if(D.viewProps.emitter.on("change",this.onChildViewPropsChange_),D.blade.value("positions").emitter.on("change",this.onChildPositionsChange_),D.viewProps.handleDispose(this.onChildDispose_),D instanceof je)D.binding.emitter.on("change",this.onChildInputChange_);else if(D instanceof ft)D.binding.emitter.on("update",this.onChildMonitorUpdate_);else if(D instanceof Le)D.value.emitter.on("change",this.onChildValueChange_);else{const Y=ln(D);if(Y){const ge=Y.emitter;ge.on("layout",this.onDescendantLayout_),ge.on("inputchange",this.onDescendantInputChange_),ge.on("monitorupdate",this.onDescendantMonitorUpdate_)}}}onSetRemove_(p){this.updatePositions_();const b=p.target===p.root;if(this.emitter.emit("remove",{bladeController:p.item,isRoot:b,sender:this}),!b)return;const D=p.item;if(D instanceof je)D.binding.emitter.off("change",this.onChildInputChange_);else if(D instanceof ft)D.binding.emitter.off("update",this.onChildMonitorUpdate_);else if(D instanceof Le)D.value.emitter.off("change",this.onChildValueChange_);else{const Y=ln(D);if(Y){const ge=Y.emitter;ge.off("layout",this.onDescendantLayout_),ge.off("inputchange",this.onDescendantInputChange_),ge.off("monitorupdate",this.onDescendantMonitorUpdate_)}}}updatePositions_(){const p=this.bcSet_.items.filter(Y=>!Y.viewProps.get("hidden")),b=p[0],D=p[p.length-1];this.bcSet_.items.forEach(Y=>{const ge=[];Y===b&&(ge.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&ge.push("veryfirst")),Y===D&&(ge.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&ge.push("verylast")),Y.blade.set("positions",ge)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(p){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(b=>b.viewProps.get("disposed")).forEach(b=>{this.bcSet_.remove(b)})}onChildInputChange_(p){const b=Kt(this.find(je),p.sender);if(!b)throw v.alreadyDisposed();this.emitter.emit("inputchange",{bladeController:b,options:p.options,sender:this})}onChildMonitorUpdate_(p){const b=nn(this.find(ft),p.sender);if(!b)throw v.alreadyDisposed();this.emitter.emit("monitorupdate",{bladeController:b,sender:this})}onChildValueChange_(p){const b=Sn(this.find(Le),p.sender);if(!b)throw v.alreadyDisposed();this.emitter.emit("inputchange",{bladeController:b,options:p.options,sender:this})}onDescendantLayout_(p){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onDescendantInputChange_(p){this.emitter.emit("inputchange",{bladeController:p.bladeController,options:p.options,sender:this})}onDescendantMonitorUpdate_(p){this.emitter.emit("monitorupdate",{bladeController:p.bladeController,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class Pn extends Ue{constructor(p,b){super(Object.assign(Object.assign({},b),{view:new Qt(p,{viewName:"brk",viewProps:b.viewProps})})),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const D=new fn({blade:b.root?void 0:b.blade,viewProps:b.viewProps});D.emitter.on("add",this.onRackAdd_),D.emitter.on("remove",this.onRackRemove_),this.rack=D,this.viewProps.handleDispose(()=>{for(let Y=this.rack.children.length-1;Y>=0;Y--)this.rack.children[Y].viewProps.set("disposed",!0)})}onRackAdd_(p){p.isRoot&&te(this.view.element,p.bladeController.view.element,p.index)}onRackRemove_(p){p.isRoot&&Se(p.bladeController.view.element)}}const F=x("cnt");class ee{constructor(p,b){var D;this.className_=x((D=b.viewName)!==null&&D!==void 0?D:"fld"),this.element=p.createElement("div"),this.element.classList.add(this.className_(),F()),b.viewProps.bindClassModifiers(this.element),this.foldable_=b.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),A(this.foldable_,"completed",E(this.element,this.className_(void 0,"cpl")));const Y=p.createElement("button");Y.classList.add(this.className_("b")),A(b.props,"title",$t=>{h($t)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),b.viewProps.bindDisabled(Y),this.element.appendChild(Y),this.buttonElement=Y;const ge=p.createElement("div");ge.classList.add(this.className_("i")),this.element.appendChild(ge);const ke=p.createElement("div");ke.classList.add(this.className_("t")),I(b.props.value("title"),ke),this.buttonElement.appendChild(ke),this.titleElement=ke;const ct=p.createElement("div");ct.classList.add(this.className_("m")),this.buttonElement.appendChild(ct);const Xt=b.containerElement;Xt.classList.add(this.className_("c")),this.element.appendChild(Xt),this.containerElement=Xt}}class de extends zt{constructor(p,b){var D;const Y=tt.create((D=b.expanded)!==null&&D!==void 0?D:!0),ge=new Pn(p,{blade:b.blade,root:b.root,viewProps:b.viewProps});super(Object.assign(Object.assign({},b),{rackController:ge,view:new ee(p,{containerElement:ge.view.element,foldable:Y,props:b.props,viewName:b.root?"rot":void 0,viewProps:b.viewProps})})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=b.props,this.foldable=Y,ve(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}const N={id:"folder",type:"blade",accept(S){const p=K,b=Q(S,{title:p.required.string,view:p.required.constant("folder"),expanded:p.optional.boolean});return b?{params:b}:null},controller(S){return new de(S.document,{blade:S.blade,expanded:S.params.expanded,props:W.fromObject({title:S.params.title}),viewProps:S.viewProps})},api(S){return S.controller instanceof de?new on(S.controller,S.pool):null}};class ie extends Le{constructor(p,b){const D=b.valueController.viewProps;super(Object.assign(Object.assign({},b),{value:b.valueController.value,view:new Ve(p,{props:b.props,viewProps:D}),viewProps:D})),this.props=b.props,this.valueController=b.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}class se extends n{}const ne=x("spr");class ae{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(ne()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("hr");D.classList.add(ne("r")),this.element.appendChild(D)}}class we extends Ue{constructor(p,b){super(Object.assign(Object.assign({},b),{view:new ae(p,{viewProps:b.viewProps})}))}}const Pe={id:"separator",type:"blade",accept(S){const b=Q(S,{view:K.required.constant("separator")});return b?{params:b}:null},controller(S){return new we(S.document,{blade:S.blade,viewProps:S.viewProps})},api(S){return S.controller instanceof we?new se(S.controller):null}},Re=x("tbi");class He{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(Re()),b.viewProps.bindClassModifiers(this.element),A(b.props,"selected",ge=>{ge?this.element.classList.add(Re(void 0,"sel")):this.element.classList.remove(Re(void 0,"sel"))});const D=p.createElement("button");D.classList.add(Re("b")),b.viewProps.bindDisabled(D),this.element.appendChild(D),this.buttonElement=D;const Y=p.createElement("div");Y.classList.add(Re("t")),I(b.props.value("title"),Y),this.buttonElement.appendChild(Y),this.titleElement=Y}}class qe{constructor(p,b){this.emitter=new y,this.onClick_=this.onClick_.bind(this),this.props=b.props,this.viewProps=b.viewProps,this.view=new He(p,{props:b.props,viewProps:b.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class Ke{constructor(p,b){this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new qe(p,{props:b.itemProps,viewProps:Ee.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.cc_=new Pn(p,{blade:ot(),viewProps:Ee.create()}),this.props=b.props,A(this.props,"selected",D=>{this.itemController.props.set("selected",D),this.contentController.viewProps.set("hidden",!D)})}get itemController(){return this.ic_}get contentController(){return this.cc_}onItemClick_(){this.props.set("selected",!0)}}class Je{constructor(p,b){this.controller_=p,this.rackApi_=b}get title(){var p;return(p=this.controller_.itemController.props.get("title"))!==null&&p!==void 0?p:""}set title(p){this.controller_.itemController.props.set("title",p)}get selected(){return this.controller_.props.get("selected")}set selected(p){this.controller_.props.set("selected",p)}get children(){return this.rackApi_.children}addButton(p){return this.rackApi_.addButton(p)}addFolder(p){return this.rackApi_.addFolder(p)}addSeparator(p){return this.rackApi_.addSeparator(p)}addTab(p){return this.rackApi_.addTab(p)}add(p,b){this.rackApi_.add(p,b)}remove(p){this.rackApi_.remove(p)}addInput(p,b,D){return this.rackApi_.addInput(p,b,D)}addMonitor(p,b,D){return this.rackApi_.addMonitor(p,b,D)}addBlade(p){return this.rackApi_.addBlade(p)}}class et extends be{constructor(p,b){super(p,new Rt(p.rackController,b)),this.onPageAdd_=this.onPageAdd_.bind(this),this.onPageRemove_=this.onPageRemove_.bind(this),this.onSelect_=this.onSelect_.bind(this),this.emitter_=new y,this.pageApiMap_=new Map,this.rackApi_.on("change",D=>{this.emitter_.emit("change",{event:D})}),this.rackApi_.on("update",D=>{this.emitter_.emit("update",{event:D})}),this.controller_.tab.selectedIndex.emitter.on("change",this.onSelect_),this.controller_.pageSet.emitter.on("add",this.onPageAdd_),this.controller_.pageSet.emitter.on("remove",this.onPageRemove_),this.controller_.pageSet.items.forEach(D=>{this.setUpPageApi_(D)})}get pages(){return this.controller_.pageSet.items.map(p=>{const b=this.pageApiMap_.get(p);if(!b)throw v.shouldNeverHappen();return b})}addPage(p){const b=this.controller_.view.element.ownerDocument,D=new Ke(b,{itemProps:W.fromObject({selected:!1,title:p.title}),props:W.fromObject({selected:!1})});this.controller_.add(D,p.index);const Y=this.pageApiMap_.get(D);if(!Y)throw v.shouldNeverHappen();return Y}removePage(p){this.controller_.remove(p)}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}setUpPageApi_(p){const b=this.rackApi_.apiSet_.find(Y=>Y.controller_===p.contentController);if(!b)throw v.shouldNeverHappen();const D=new Je(p,b);this.pageApiMap_.set(p,D)}onPageAdd_(p){this.setUpPageApi_(p.item)}onPageRemove_(p){if(!this.pageApiMap_.get(p.item))throw v.shouldNeverHappen();this.pageApiMap_.delete(p.item)}onSelect_(p){this.emitter_.emit("select",{event:new c(this,p.rawValue)})}}const st=-1;class Dt{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=G(!0),this.selectedIndex=G(st),this.items_=[]}add(p,b){const D=b??this.items_.length;this.items_.splice(D,0,p),p.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(p){const b=this.items_.indexOf(p);b<0||(this.items_.splice(b,1),p.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=st,this.empty.rawValue=!0;return}const p=this.items_.findIndex(b=>b.rawValue);p<0?(this.items_.forEach((b,D)=>{b.rawValue=D===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((b,D)=>{b.rawValue=D===p}),this.selectedIndex.rawValue=p),this.empty.rawValue=!1}onItemSelectedChange_(p){if(p.rawValue){const b=this.items_.findIndex(D=>D===p.sender);this.items_.forEach((D,Y)=>{D.rawValue=Y===b}),this.selectedIndex.rawValue=b}else this.keepSelection_()}}const kt=x("tab");class Ot{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(kt(),F()),b.viewProps.bindClassModifiers(this.element),T(b.empty,E(this.element,kt(void 0,"nop")));const D=p.createElement("div");D.classList.add(kt("t")),this.element.appendChild(D),this.itemsElement=D;const Y=p.createElement("div");Y.classList.add(kt("i")),this.element.appendChild(Y);const ge=b.contentsElement;ge.classList.add(kt("c")),this.element.appendChild(ge),this.contentsElement=ge}}class wt extends zt{constructor(p,b){const D=new Pn(p,{blade:b.blade,viewProps:b.viewProps}),Y=new Dt;super({blade:b.blade,rackController:D,view:new Ot(p,{contentsElement:D.view.element,empty:Y.empty,viewProps:b.viewProps})}),this.onPageAdd_=this.onPageAdd_.bind(this),this.onPageRemove_=this.onPageRemove_.bind(this),this.pageSet_=new gt(()=>null),this.pageSet_.emitter.on("add",this.onPageAdd_),this.pageSet_.emitter.on("remove",this.onPageRemove_),this.tab=Y}get pageSet(){return this.pageSet_}add(p,b){this.pageSet_.add(p,b)}remove(p){this.pageSet_.remove(this.pageSet_.items[p])}onPageAdd_(p){const b=p.item;te(this.view.itemsElement,b.itemController.view.element,p.index),b.itemController.viewProps.set("parent",this.viewProps),this.rackController.rack.add(b.contentController,p.index),this.tab.add(b.props.value("selected"))}onPageRemove_(p){const b=p.item;Se(b.itemController.view.element),b.itemController.viewProps.set("parent",null),this.rackController.rack.remove(b.contentController),this.tab.remove(b.props.value("selected"))}}const Yt={id:"tab",type:"blade",accept(S){const p=K,b=Q(S,{pages:p.required.array(p.required.object({title:p.required.string})),view:p.required.constant("tab")});return!b||b.pages.length===0?null:{params:b}},controller(S){const p=new wt(S.document,{blade:S.blade,viewProps:S.viewProps});return S.params.pages.forEach(b=>{const D=new Ke(S.document,{itemProps:W.fromObject({selected:!1,title:b.title}),props:W.fromObject({selected:!1})});p.add(D)}),p},api(S){return S.controller instanceof wt?new et(S.controller,S.pool):null}};function St(S,p){const b=S.accept(p.params);if(!b)return null;const D=K.optional.boolean(p.params.disabled).value,Y=K.optional.boolean(p.params.hidden).value;return S.controller({blade:ot(),document:p.document,params:Object.assign(Object.assign({},b.params),{disabled:D,hidden:Y}),viewProps:Ee.create({disabled:D,hidden:Y})})}class vn{constructor(){this.disabled=!1,this.emitter=new y}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class ui{constructor(p,b){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=p,this.emitter=new y,this.interval_=b,this.setTimer_()}get disabled(){return this.disabled_}set disabled(p){this.disabled_=p,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const p=this.doc_.defaultView;p&&p.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const p=this.doc_.defaultView;p&&(this.timerId_=p.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class pn{constructor(p){this.onValueChange_=this.onValueChange_.bind(this),this.reader=p.reader,this.writer=p.writer,this.emitter=new y,this.value=p.value,this.value.emitter.on("change",this.onValueChange_),this.target=p.target,this.read()}read(){const p=this.target.read();p!==void 0&&(this.value.rawValue=this.reader(p))}write_(p){this.writer(this.target,p)}onValueChange_(p){this.write_(p.rawValue),this.emitter.emit("change",{options:p.options,rawValue:p.rawValue,sender:this})}}function jt(S,p){for(;S.lengthS.length?b.splice(0,b.length-S.length):jt(b,S.length),b}class On{constructor(p){this.onTick_=this.onTick_.bind(this),this.reader_=p.reader,this.target=p.target,this.emitter=new y,this.value=p.value,this.ticker=p.ticker,this.ticker.emitter.on("tick",this.onTick_),this.read()}dispose(){this.ticker.dispose()}read(){const p=this.target.read();if(p===void 0)return;const b=this.value.rawValue,D=this.reader_(p);this.value.rawValue=ri(b,D),this.emitter.emit("update",{rawValue:D,sender:this})}onTick_(p){this.read()}}class Vn{constructor(p){this.constraints=p}constrain(p){return this.constraints.reduce((b,D)=>D.constrain(b),p)}}function lr(S,p){if(S instanceof p)return S;if(S instanceof Vn){const b=S.constraints.reduce((D,Y)=>D||(Y instanceof p?Y:null),null);if(b)return b}return null}class cr{constructor(p){this.values=W.fromObject({max:p.max,min:p.min})}constrain(p){const b=this.values.get("max"),D=this.values.get("min");return Math.min(Math.max(p,D),b)}}class Ul{constructor(p){this.values=W.fromObject({options:p})}get options(){return this.values.get("options")}constrain(p){const b=this.values.get("options");return b.length===0||b.filter(Y=>Y.value===p).length>0?p:b[0].value}}class im{constructor(p){this.values=W.fromObject({max:p.max,min:p.min})}get maxValue(){return this.values.get("max")}get minValue(){return this.values.get("min")}constrain(p){const b=this.values.get("max"),D=this.values.get("min");let Y=p;return h(D)||(Y=Math.max(Y,D)),h(b)||(Y=Math.min(Y,b)),Y}}class kl{constructor(p,b=0){this.step=p,this.origin=b}constrain(p){const b=this.origin%this.step,D=Math.round((p-b)/this.step);return b+D*this.step}}const Ia=x("lst");class ny{constructor(p,b){this.onValueChange_=this.onValueChange_.bind(this),this.props_=b.props,this.element=p.createElement("div"),this.element.classList.add(Ia()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("select");D.classList.add(Ia("s")),b.viewProps.bindDisabled(D),this.element.appendChild(D),this.selectElement=D;const Y=p.createElement("div");Y.classList.add(Ia("m")),Y.appendChild(he(p,"dropdown")),this.element.appendChild(Y),b.value.emitter.on("change",this.onValueChange_),this.value_=b.value,A(this.props_,"options",ge=>{ye(this.selectElement),ge.forEach(ke=>{const ct=p.createElement("option");ct.textContent=ke.text,this.selectElement.appendChild(ct)}),this.update_()})}update_(){const p=this.props_.get("options").map(b=>b.value);this.selectElement.selectedIndex=p.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class na{constructor(p,b){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=b.props,this.value=b.value,this.viewProps=b.viewProps,this.view=new ny(p,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(p){const b=p.currentTarget;this.value.rawValue=this.props.get("options")[b.selectedIndex].value}}const La=x("pop");class Ol{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(La()),b.viewProps.bindClassModifiers(this.element),T(b.shows,E(this.element,La(void 0,"v")))}}class Fl{constructor(p,b){this.shows=G(!1),this.viewProps=b.viewProps,this.view=new Ol(p,{shows:this.shows,viewProps:this.viewProps})}}const rm=x("txt");class Au{constructor(p,b){this.onChange_=this.onChange_.bind(this),this.element=p.createElement("div"),this.element.classList.add(rm()),b.viewProps.bindClassModifiers(this.element),this.props_=b.props,this.props_.emitter.on("change",this.onChange_);const D=p.createElement("input");D.classList.add(rm("i")),D.type="text",b.viewProps.bindDisabled(D),this.element.appendChild(D),this.inputElement=D,b.value.emitter.on("change",this.onChange_),this.value_=b.value,this.refresh()}refresh(){const p=this.props_.get("formatter");this.inputElement.value=p(this.value_.rawValue)}onChange_(){this.refresh()}}class Nl{constructor(p,b){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=b.parser,this.props=b.props,this.value=b.value,this.viewProps=b.viewProps,this.view=new Au(p,{props:b.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(p){const D=p.currentTarget.value,Y=this.parser_(D);h(Y)||(this.value.rawValue=Y),this.view.refresh()}}function sm(S){return String(S)}function om(S){return S==="false"?!1:!!S}function Cu(S){return sm(S)}class am{constructor(p){this.text=p}evaluate(){return Number(this.text)}toString(){return this.text}}const iy={"**":(S,p)=>Math.pow(S,p),"*":(S,p)=>S*p,"/":(S,p)=>S/p,"%":(S,p)=>S%p,"+":(S,p)=>S+p,"-":(S,p)=>S-p,"<<":(S,p)=>S<>":(S,p)=>S>>p,">>>":(S,p)=>S>>>p,"&":(S,p)=>S&p,"^":(S,p)=>S^p,"|":(S,p)=>S|p};class Xs{constructor(p,b,D){this.left=b,this.operator=p,this.right=D}evaluate(){const p=iy[this.operator];if(!p)throw new Error(`unexpected binary operator: '${this.operator}`);return p(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const lm={"+":S=>S,"-":S=>-S,"~":S=>~S};class ry{constructor(p,b){this.operator=p,this.expression=b}evaluate(){const p=lm[this.operator];if(!p)throw new Error(`unexpected unary operator: '${this.operator}`);return p(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function Pd(S){return(p,b)=>{for(let D=0;Dp.startsWith(Y,b))[0];return D?(b+=D.length,b+=Ua(p,b).length,{cursor:b,operator:D}):null}function cy(S,p){return(b,D)=>{const Y=S(b,D);if(!Y)return null;D=Y.cursor;let ge=Y.evaluable;for(;;){const ke=ia(p,b,D);if(!ke)break;D=ke.cursor;const ct=S(b,D);if(!ct)return null;D=ct.cursor,ge=new Xs(ke.operator,ge,ct.evaluable)}return ge?{cursor:D,evaluable:ge}:null}}const _j=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((S,p)=>cy(S,p),Mr);function p3(S,p){return p+=Ua(S,p).length,_j(S,p)}function yj(S){const p=p3(S,0);return!p||p.cursor+Ua(S,p.cursor).length!==S.length?null:p.evaluable}function Oa(S){var p;const b=yj(S);return(p=b==null?void 0:b.evaluate())!==null&&p!==void 0?p:null}function m3(S){if(typeof S=="number")return S;if(typeof S=="string"){const p=Oa(S);if(!h(p))return p}return 0}function xj(S){return String(S)}function Er(S){return p=>p.toFixed(Math.max(Math.min(S,20),0))}const bj=Er(0);function uy(S){return bj(S)+"%"}function g3(S){return String(S)}function $S(S){return S}function dm({primary:S,secondary:p,forward:b,backward:D}){let Y=!1;function ge(ke){Y||(Y=!0,ke(),Y=!1)}S.emitter.on("change",ke=>{ge(()=>{p.setRawValue(b(S,p),ke.options)})}),p.emitter.on("change",ke=>{ge(()=>{S.setRawValue(D(S,p),ke.options)}),ge(()=>{p.setRawValue(b(S,p),ke.options)})}),ge(()=>{p.setRawValue(b(S,p),{forceEmit:!1,last:!0})})}function ys(S,p){const b=S*(p.altKey?.1:1)*(p.shiftKey?10:1);return p.upKey?+b:p.downKey?-b:0}function fm(S){return{altKey:S.altKey,downKey:S.key==="ArrowDown",shiftKey:S.shiftKey,upKey:S.key==="ArrowUp"}}function Fa(S){return{altKey:S.altKey,downKey:S.key==="ArrowLeft",shiftKey:S.shiftKey,upKey:S.key==="ArrowRight"}}function wj(S){return S==="ArrowUp"||S==="ArrowDown"}function v3(S){return wj(S)||S==="ArrowLeft"||S==="ArrowRight"}function JS(S,p){var b,D;const Y=p.ownerDocument.defaultView,ge=p.getBoundingClientRect();return{x:S.pageX-(((b=Y&&Y.scrollX)!==null&&b!==void 0?b:0)+ge.left),y:S.pageY-(((D=Y&&Y.scrollY)!==null&&D!==void 0?D:0)+ge.top)}}class Iu{constructor(p){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=p,this.emitter=new y,p.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),p.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),p.addEventListener("touchend",this.onTouchEnd_),p.addEventListener("mousedown",this.onMouseDown_)}computePosition_(p){const b=this.elem_.getBoundingClientRect();return{bounds:{width:b.width,height:b.height},point:p?{x:p.x,y:p.y}:null}}onMouseDown_(p){var b;p.preventDefault(),(b=p.currentTarget)===null||b===void 0||b.focus();const D=this.elem_.ownerDocument;D.addEventListener("mousemove",this.onDocumentMouseMove_),D.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:p.altKey,data:this.computePosition_(JS(p,this.elem_)),sender:this,shiftKey:p.shiftKey})}onDocumentMouseMove_(p){this.emitter.emit("move",{altKey:p.altKey,data:this.computePosition_(JS(p,this.elem_)),sender:this,shiftKey:p.shiftKey})}onDocumentMouseUp_(p){const b=this.elem_.ownerDocument;b.removeEventListener("mousemove",this.onDocumentMouseMove_),b.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:p.altKey,data:this.computePosition_(JS(p,this.elem_)),sender:this,shiftKey:p.shiftKey})}onTouchStart_(p){p.preventDefault();const b=p.targetTouches.item(0),D=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:p.altKey,data:this.computePosition_(b?{x:b.clientX-D.left,y:b.clientY-D.top}:void 0),sender:this,shiftKey:p.shiftKey}),this.lastTouch_=b}onTouchMove_(p){const b=p.targetTouches.item(0),D=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:p.altKey,data:this.computePosition_(b?{x:b.clientX-D.left,y:b.clientY-D.top}:void 0),sender:this,shiftKey:p.shiftKey}),this.lastTouch_=b}onTouchEnd_(p){var b;const D=(b=p.targetTouches.item(0))!==null&&b!==void 0?b:this.lastTouch_,Y=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:p.altKey,data:this.computePosition_(D?{x:D.clientX-Y.left,y:D.clientY-Y.top}:void 0),sender:this,shiftKey:p.shiftKey})}}function gi(S,p,b,D,Y){const ge=(S-p)/(b-p);return D+ge*(Y-D)}function _3(S){return String(S.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function tr(S,p,b){return Math.min(Math.max(S,p),b)}function y3(S,p){return(S%p+p)%p}const uo=x("txt");class Sj{constructor(p,b){this.onChange_=this.onChange_.bind(this),this.props_=b.props,this.props_.emitter.on("change",this.onChange_),this.element=p.createElement("div"),this.element.classList.add(uo(),uo(void 0,"num")),b.arrayPosition&&this.element.classList.add(uo(void 0,b.arrayPosition)),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("input");D.classList.add(uo("i")),D.type="text",b.viewProps.bindDisabled(D),this.element.appendChild(D),this.inputElement=D,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=b.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(uo()),this.inputElement.classList.add(uo("i"));const Y=p.createElement("div");Y.classList.add(uo("k")),this.element.appendChild(Y),this.knobElement=Y;const ge=p.createElementNS(Me,"svg");ge.classList.add(uo("g")),this.knobElement.appendChild(ge);const ke=p.createElementNS(Me,"path");ke.classList.add(uo("gb")),ge.appendChild(ke),this.guideBodyElem_=ke;const ct=p.createElementNS(Me,"path");ct.classList.add(uo("gh")),ge.appendChild(ct),this.guideHeadElem_=ct;const Xt=p.createElement("div");Xt.classList.add(x("tt")()),this.knobElement.appendChild(Xt),this.tooltipElem_=Xt,b.value.emitter.on("change",this.onChange_),this.value=b.value,this.refresh()}onDraggingChange_(p){if(p.rawValue===null){this.element.classList.remove(uo(void 0,"drg"));return}this.element.classList.add(uo(void 0,"drg"));const b=p.rawValue/this.props_.get("draggingScale"),D=b+(b>0?-1:b<0?1:0),Y=tr(-D,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${D+Y},0 L${D},4 L${D+Y},8`,`M ${b},-1 L${b},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${b},4`);const ge=this.props_.get("formatter");this.tooltipElem_.textContent=ge(this.value.rawValue),this.tooltipElem_.style.left=`${b}px`}refresh(){const p=this.props_.get("formatter");this.inputElement.value=p(this.value.rawValue)}onChange_(){this.refresh()}}class pm{constructor(p,b){var D;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.baseStep_=b.baseStep,this.parser_=b.parser,this.props=b.props,this.sliderProps_=(D=b.sliderProps)!==null&&D!==void 0?D:null,this.value=b.value,this.viewProps=b.viewProps,this.dragging_=G(null),this.view=new Sj(p,{arrayPosition:b.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const Y=new Iu(this.view.knobElement);Y.emitter.on("down",this.onPointerDown_),Y.emitter.on("move",this.onPointerMove_),Y.emitter.on("up",this.onPointerUp_)}constrainValue_(p){var b,D;const Y=(b=this.sliderProps_)===null||b===void 0?void 0:b.get("minValue"),ge=(D=this.sliderProps_)===null||D===void 0?void 0:D.get("maxValue");let ke=p;return Y!==void 0&&(ke=Math.max(ke,Y)),ge!==void 0&&(ke=Math.min(ke,ge)),ke}onInputChange_(p){const D=p.currentTarget.value,Y=this.parser_(D);h(Y)||(this.value.rawValue=this.constrainValue_(Y)),this.view.refresh()}onInputKeyDown_(p){const b=ys(this.baseStep_,fm(p));b!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+b),{forceEmit:!1,last:!1})}onInputKeyUp_(p){ys(this.baseStep_,fm(p))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(p){if(!p.point)return null;const b=p.point.x-p.bounds.width/2;return this.constrainValue_(this.originRawValue_+b*this.props.get("draggingScale"))}onPointerMove_(p){const b=this.computeDraggingValue_(p.data);b!==null&&(this.value.setRawValue(b,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(p){const b=this.computeDraggingValue_(p.data);b!==null&&(this.value.setRawValue(b,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const QS=x("sld");class Mj{constructor(p,b){this.onChange_=this.onChange_.bind(this),this.props_=b.props,this.props_.emitter.on("change",this.onChange_),this.element=p.createElement("div"),this.element.classList.add(QS()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("div");D.classList.add(QS("t")),b.viewProps.bindTabIndex(D),this.element.appendChild(D),this.trackElement=D;const Y=p.createElement("div");Y.classList.add(QS("k")),this.trackElement.appendChild(Y),this.knobElement=Y,b.value.emitter.on("change",this.onChange_),this.value=b.value,this.update_()}update_(){const p=tr(gi(this.value.rawValue,this.props_.get("minValue"),this.props_.get("maxValue"),0,100),0,100);this.knobElement.style.width=`${p}%`}onChange_(){this.update_()}}class Ej{constructor(p,b){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.baseStep_=b.baseStep,this.value=b.value,this.viewProps=b.viewProps,this.props=b.props,this.view=new Mj(p,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Iu(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(p,b){p.point&&this.value.setRawValue(gi(tr(p.point.x,0,p.bounds.width),0,p.bounds.width,this.props.get("minValue"),this.props.get("maxValue")),b)}onPointerDownOrMove_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerUp_(p){this.handlePointerEvent_(p.data,{forceEmit:!0,last:!0})}onKeyDown_(p){const b=ys(this.baseStep_,Fa(p));b!==0&&this.value.setRawValue(this.value.rawValue+b,{forceEmit:!1,last:!1})}onKeyUp_(p){ys(this.baseStep_,Fa(p))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const eM=x("sldtxt");class Tj{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(eM());const D=p.createElement("div");D.classList.add(eM("s")),this.sliderView_=b.sliderView,D.appendChild(this.sliderView_.element),this.element.appendChild(D);const Y=p.createElement("div");Y.classList.add(eM("t")),this.textView_=b.textView,Y.appendChild(this.textView_.element),this.element.appendChild(Y)}}class tM{constructor(p,b){this.value=b.value,this.viewProps=b.viewProps,this.sliderC_=new Ej(p,{baseStep:b.baseStep,props:b.sliderProps,value:b.value,viewProps:this.viewProps}),this.textC_=new pm(p,{baseStep:b.baseStep,parser:b.parser,props:b.textProps,sliderProps:b.sliderProps,value:b.value,viewProps:b.viewProps}),this.view=new Tj(p,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}}function mm(S,p){S.write(p)}function hy(S){const p=K;if(Array.isArray(S))return p.required.array(p.required.object({text:p.required.string,value:p.required.raw}))(S).value;if(typeof S=="object")return p.required.raw(S).value}function x3(S){if(S==="inline"||S==="popup")return S}function zl(S){const p=K;return p.required.object({max:p.optional.number,min:p.optional.number,step:p.optional.number})(S).value}function b3(S){if(Array.isArray(S))return S;const p=[];return Object.keys(S).forEach(b=>{p.push({text:b,value:S[b]})}),p}function nM(S){return h(S)?null:new Ul(b3(S))}function Aj(S){const p=S?lr(S,kl):null;return p?p.step:null}function dy(S,p){const b=S&&lr(S,kl);return b?_3(b.step):Math.max(_3(p),2)}function Id(S){const p=Aj(S);return p??1}function Ld(S,p){var b;const D=S&&lr(S,kl),Y=Math.abs((b=D==null?void 0:D.step)!==null&&b!==void 0?b:p);return Y===0?.1:Math.pow(10,Math.floor(Math.log10(Y))-1)}const fy=x("ckb");class Cj{constructor(p,b){this.onValueChange_=this.onValueChange_.bind(this),this.element=p.createElement("div"),this.element.classList.add(fy()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("label");D.classList.add(fy("l")),this.element.appendChild(D);const Y=p.createElement("input");Y.classList.add(fy("i")),Y.type="checkbox",D.appendChild(Y),this.inputElement=Y,b.viewProps.bindDisabled(this.inputElement);const ge=p.createElement("div");ge.classList.add(fy("w")),D.appendChild(ge);const ke=he(p,"check");ge.appendChild(ke),b.value.emitter.on("change",this.onValueChange_),this.value=b.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class Pj{constructor(p,b){this.onInputChange_=this.onInputChange_.bind(this),this.value=b.value,this.viewProps=b.viewProps,this.view=new Cj(p,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(p){const b=p.currentTarget;this.value.rawValue=b.checked}}function Rj(S){const p=[],b=nM(S.options);return b&&p.push(b),new Vn(p)}const Dj={id:"input-bool",type:"input",accept:(S,p)=>{if(typeof S!="boolean")return null;const D=Q(p,{options:K.optional.custom(hy)});return D?{initialValue:S,params:D}:null},binding:{reader:S=>om,constraint:S=>Rj(S.params),writer:S=>mm},controller:S=>{const p=S.document,b=S.value,D=S.constraint,Y=D&&lr(D,Ul);return Y?new na(p,{props:new W({options:Y.values.value("options")}),value:b,viewProps:S.viewProps}):new Pj(p,{value:b,viewProps:S.viewProps})}},Lu=x("col");class Ij{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(Lu()),b.foldable.bindExpandedClass(this.element,Lu(void 0,"expanded")),A(b.foldable,"completed",E(this.element,Lu(void 0,"cpl")));const D=p.createElement("div");D.classList.add(Lu("h")),this.element.appendChild(D);const Y=p.createElement("div");Y.classList.add(Lu("s")),D.appendChild(Y),this.swatchElement=Y;const ge=p.createElement("div");if(ge.classList.add(Lu("t")),D.appendChild(ge),this.textElement=ge,b.pickerLayout==="inline"){const ke=p.createElement("div");ke.classList.add(Lu("p")),this.element.appendChild(ke),this.pickerElement=ke}else this.pickerElement=null}}function Lj(S,p,b){const D=tr(S/255,0,1),Y=tr(p/255,0,1),ge=tr(b/255,0,1),ke=Math.max(D,Y,ge),ct=Math.min(D,Y,ge),Xt=ke-ct;let $t=0,Dn=0;const Fn=(ct+ke)/2;return Xt!==0&&(Dn=Xt/(1-Math.abs(ke+ct-1)),D===ke?$t=(Y-ge)/Xt:Y===ke?$t=2+(ge-D)/Xt:$t=4+(D-Y)/Xt,$t=$t/6+($t<0?1:0)),[$t*360,Dn*100,Fn*100]}function Uj(S,p,b){const D=(S%360+360)%360,Y=tr(p/100,0,1),ge=tr(b/100,0,1),ke=(1-Math.abs(2*ge-1))*Y,ct=ke*(1-Math.abs(D/60%2-1)),Xt=ge-ke/2;let $t,Dn,Fn;return D>=0&&D<60?[$t,Dn,Fn]=[ke,ct,0]:D>=60&&D<120?[$t,Dn,Fn]=[ct,ke,0]:D>=120&&D<180?[$t,Dn,Fn]=[0,ke,ct]:D>=180&&D<240?[$t,Dn,Fn]=[0,ct,ke]:D>=240&&D<300?[$t,Dn,Fn]=[ct,0,ke]:[$t,Dn,Fn]=[ke,0,ct],[($t+Xt)*255,(Dn+Xt)*255,(Fn+Xt)*255]}function kj(S,p,b){const D=tr(S/255,0,1),Y=tr(p/255,0,1),ge=tr(b/255,0,1),ke=Math.max(D,Y,ge),ct=Math.min(D,Y,ge),Xt=ke-ct;let $t;Xt===0?$t=0:ke===D?$t=60*(((Y-ge)/Xt%6+6)%6):ke===Y?$t=60*((ge-D)/Xt+2):$t=60*((D-Y)/Xt+4);const Dn=ke===0?0:Xt/ke,Fn=ke;return[$t,Dn*100,Fn*100]}function w3(S,p,b){const D=y3(S,360),Y=tr(p/100,0,1),ge=tr(b/100,0,1),ke=ge*Y,ct=ke*(1-Math.abs(D/60%2-1)),Xt=ge-ke;let $t,Dn,Fn;return D>=0&&D<60?[$t,Dn,Fn]=[ke,ct,0]:D>=60&&D<120?[$t,Dn,Fn]=[ct,ke,0]:D>=120&&D<180?[$t,Dn,Fn]=[0,ke,ct]:D>=180&&D<240?[$t,Dn,Fn]=[0,ct,ke]:D>=240&&D<300?[$t,Dn,Fn]=[ct,0,ke]:[$t,Dn,Fn]=[ke,0,ct],[($t+Xt)*255,(Dn+Xt)*255,(Fn+Xt)*255]}function Oj(S,p,b){const D=b+p*(100-Math.abs(2*b-100))/200;return[S,D!==0?p*(100-Math.abs(2*b-100))/D:0,b+p*(100-Math.abs(2*b-100))/(2*100)]}function Fj(S,p,b){const D=100-Math.abs(b*(200-p)/100-100);return[S,D!==0?p*b/D:0,b*(200-p)/(2*100)]}function Uu(S){return[S[0],S[1],S[2]]}function S3(S,p){return[S[0],S[1],S[2],p]}const Nj={hsl:{hsl:(S,p,b)=>[S,p,b],hsv:Oj,rgb:Uj},hsv:{hsl:Fj,hsv:(S,p,b)=>[S,p,b],rgb:w3},rgb:{hsl:Lj,hsv:kj,rgb:(S,p,b)=>[S,p,b]}};function py(S,p){return[p==="float"?1:S==="rgb"?255:360,p==="float"?1:S==="rgb"?255:100,p==="float"?1:S==="rgb"?255:100]}function Bj(S,p){return S===p?p:y3(S,p)}function zj(S,p,b){var D;const Y=py(p,b);return[p==="rgb"?tr(S[0],0,Y[0]):Bj(S[0],Y[0]),tr(S[1],0,Y[1]),tr(S[2],0,Y[2]),tr((D=S[3])!==null&&D!==void 0?D:1,0,1)]}function M3(S,p,b,D){const Y=py(p,b),ge=py(p,D);return S.map((ke,ct)=>ke/Y[ct]*ge[ct])}function Vj(S,p,b){const D=M3(S,p.mode,p.type,"int"),Y=Nj[p.mode][b.mode](...D);return M3(Y,b.mode,"int",b.type)}function my(S,p){return typeof S!="object"||h(S)?!1:p in S&&typeof S[p]=="number"}class _n{static black(p="int"){return new _n([0,0,0],"rgb",p)}static fromObject(p,b="int"){const D="a"in p?[p.r,p.g,p.b,p.a]:[p.r,p.g,p.b];return new _n(D,"rgb",b)}static toRgbaObject(p,b="int"){return p.toRgbaObject(b)}static isRgbColorObject(p){return my(p,"r")&&my(p,"g")&&my(p,"b")}static isRgbaColorObject(p){return this.isRgbColorObject(p)&&my(p,"a")}static isColorObject(p){return this.isRgbColorObject(p)}static equals(p,b){if(p.mode!==b.mode)return!1;const D=p.comps_,Y=b.comps_;for(let ge=0;geb.inputElement)];return this.alphaViews_&&p.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),p}}function Hj(S){return S==="int"?"int":S==="float"?"float":void 0}function iM(S){const p=K;return Q(S,{alpha:p.optional.boolean,color:p.optional.object({alpha:p.optional.boolean,type:p.optional.custom(Hj)}),expanded:p.optional.boolean,picker:p.optional.custom(x3)})}function ku(S){return S?.1:1}function Ou(S){var p;return(p=S.color)===null||p===void 0?void 0:p.type}function Wj(S,p){return S.alpha===p.alpha&&S.mode===p.mode&&S.notation===p.notation&&S.type===p.type}function ho(S,p){const b=S.match(/^(.+)%$/);return Math.min(b?parseFloat(b[1])*.01*p:parseFloat(S),p)}const Xj={deg:S=>S,grad:S=>S*360/400,rad:S=>S*360/(2*Math.PI),turn:S=>S*360};function E3(S){const p=S.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!p)return parseFloat(S);const b=parseFloat(p[1]),D=p[2];return Xj[D](b)}function T3(S){const p=S.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!p)return null;const b=[ho(p[1],255),ho(p[2],255),ho(p[3],255)];return isNaN(b[0])||isNaN(b[1])||isNaN(b[2])?null:b}function A3(S){return p=>{const b=T3(p);return b?new _n(b,"rgb",S):null}}function C3(S){const p=S.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!p)return null;const b=[ho(p[1],255),ho(p[2],255),ho(p[3],255),ho(p[4],1)];return isNaN(b[0])||isNaN(b[1])||isNaN(b[2])||isNaN(b[3])?null:b}function P3(S){return p=>{const b=C3(p);return b?new _n(b,"rgb",S):null}}function R3(S){const p=S.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!p)return null;const b=[E3(p[1]),ho(p[2],100),ho(p[3],100)];return isNaN(b[0])||isNaN(b[1])||isNaN(b[2])?null:b}function D3(S){return p=>{const b=R3(p);return b?new _n(b,"hsl",S):null}}function I3(S){const p=S.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!p)return null;const b=[E3(p[1]),ho(p[2],100),ho(p[3],100),ho(p[4],1)];return isNaN(b[0])||isNaN(b[1])||isNaN(b[2])||isNaN(b[3])?null:b}function L3(S){return p=>{const b=I3(p);return b?new _n(b,"hsl",S):null}}function U3(S){const p=S.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(p)return[parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16),parseInt(p[3]+p[3],16)];const b=S.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return b?[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)]:null}function Yj(S){const p=U3(S);return p?new _n(p,"rgb","int"):null}function k3(S){const p=S.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(p)return[parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16),parseInt(p[3]+p[3],16),gi(parseInt(p[4]+p[4],16),0,255,0,1)];const b=S.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return b?[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16),gi(parseInt(b[4],16),0,255,0,1)]:null}function jj(S){const p=k3(S);return p?new _n(p,"rgb","int"):null}function O3(S){const p=S.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!p)return null;const b=[parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])];return isNaN(b[0])||isNaN(b[1])||isNaN(b[2])?null:b}function F3(S){return p=>{const b=O3(p);return b?new _n(b,"rgb",S):null}}function N3(S){const p=S.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!p)return null;const b=[parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]),parseFloat(p[4])];return isNaN(b[0])||isNaN(b[1])||isNaN(b[2])||isNaN(b[3])?null:b}function B3(S){return p=>{const b=N3(p);return b?new _n(b,"rgb",S):null}}const qj=[{parser:U3,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:k3,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:T3,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:C3,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:R3,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:I3,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:O3,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:N3,result:{alpha:!0,mode:"rgb",notation:"object"}}];function Zj(S){return qj.reduce((p,{parser:b,result:D})=>p||(b(S)?D:null),null)}function rM(S,p="int"){const b=Zj(S);return b?b.notation==="hex"&&p!=="float"?Object.assign(Object.assign({},b),{type:"int"}):b.notation==="func"?Object.assign(Object.assign({},b),{type:p}):null:null}const z3={int:[Yj,jj,A3("int"),P3("int"),D3("int"),L3("int"),F3("int"),B3("int")],float:[A3("float"),P3("float"),D3("float"),L3("float"),F3("float"),B3("float")]};function Kj(S){const p=z3[S];return b=>{if(typeof b!="string")return _n.black(S);const D=p.reduce((Y,ge)=>Y||ge(b),null);return D??_n.black(S)}}function sM(S){const p=z3[S];return b=>p.reduce((D,Y)=>D||Y(b),null)}function V3(S){const p=tr(Math.floor(S),0,255).toString(16);return p.length===1?`0${p}`:p}function G3(S,p="#"){const b=Uu(S.getComponents("rgb")).map(V3).join("");return`${p}${b}`}function oM(S,p="#"){const b=S.getComponents("rgb"),D=[b[0],b[1],b[2],b[3]*255].map(V3).join("");return`${p}${D}`}function H3(S,p){const b=Er(p==="float"?2:0);return`rgb(${Uu(S.getComponents("rgb",p)).map(Y=>b(Y)).join(", ")})`}function $j(S){return p=>H3(p,S)}function gy(S,p){const b=Er(2),D=Er(p==="float"?2:0);return`rgba(${S.getComponents("rgb",p).map((ge,ke)=>(ke===3?b:D)(ge)).join(", ")})`}function Jj(S){return p=>gy(p,S)}function Qj(S){const p=[Er(0),uy,uy];return`hsl(${Uu(S.getComponents("hsl")).map((D,Y)=>p[Y](D)).join(", ")})`}function eq(S){const p=[Er(0),uy,uy,Er(2)];return`hsla(${S.getComponents("hsl").map((D,Y)=>p[Y](D)).join(", ")})`}function W3(S,p){const b=Er(p==="float"?2:0),D=["r","g","b"];return`{${Uu(S.getComponents("rgb",p)).map((ge,ke)=>`${D[ke]}: ${b(ge)}`).join(", ")}}`}function tq(S){return p=>W3(p,S)}function X3(S,p){const b=Er(2),D=Er(p==="float"?2:0),Y=["r","g","b","a"];return`{${S.getComponents("rgb",p).map((ke,ct)=>{const Xt=ct===3?b:D;return`${Y[ct]}: ${Xt(ke)}`}).join(", ")}}`}function nq(S){return p=>X3(p,S)}const iq=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:G3},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:oM},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:Qj},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:eq},...["int","float"].reduce((S,p)=>[...S,{format:{alpha:!1,mode:"rgb",notation:"func",type:p},stringifier:$j(p)},{format:{alpha:!0,mode:"rgb",notation:"func",type:p},stringifier:Jj(p)},{format:{alpha:!1,mode:"rgb",notation:"object",type:p},stringifier:tq(p)},{format:{alpha:!0,mode:"rgb",notation:"object",type:p},stringifier:nq(p)}],[])];function aM(S){return iq.reduce((p,b)=>p||(Wj(b.format,S)?b.stringifier:null),null)}const gm=x("apl");class rq{constructor(p,b){this.onValueChange_=this.onValueChange_.bind(this),this.value=b.value,this.value.emitter.on("change",this.onValueChange_),this.element=p.createElement("div"),this.element.classList.add(gm()),b.viewProps.bindClassModifiers(this.element),b.viewProps.bindTabIndex(this.element);const D=p.createElement("div");D.classList.add(gm("b")),this.element.appendChild(D);const Y=p.createElement("div");Y.classList.add(gm("c")),D.appendChild(Y),this.colorElem_=Y;const ge=p.createElement("div");ge.classList.add(gm("m")),this.element.appendChild(ge),this.markerElem_=ge;const ke=p.createElement("div");ke.classList.add(gm("p")),this.markerElem_.appendChild(ke),this.previewElem_=ke,this.update_()}update_(){const p=this.value.rawValue,b=p.getComponents("rgb"),D=new _n([b[0],b[1],b[2],0],"rgb"),Y=new _n([b[0],b[1],b[2],255],"rgb"),ge=["to right",gy(D),gy(Y)];this.colorElem_.style.background=`linear-gradient(${ge.join(",")})`,this.previewElem_.style.backgroundColor=gy(p);const ke=gi(b[3],0,1,0,100);this.markerElem_.style.left=`${ke}%`}onValueChange_(){this.update_()}}class sq{constructor(p,b){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=b.value,this.viewProps=b.viewProps,this.view=new rq(p,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Iu(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(p,b){if(!p.point)return;const D=p.point.x/p.bounds.width,Y=this.value.rawValue,[ge,ke,ct]=Y.getComponents("hsv");this.value.setRawValue(new _n([ge,ke,ct,D],"hsv"),b)}onPointerDown_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerMove_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerUp_(p){this.handlePointerEvent_(p.data,{forceEmit:!0,last:!0})}onKeyDown_(p){const b=ys(ku(!0),Fa(p));if(b===0)return;const D=this.value.rawValue,[Y,ge,ke,ct]=D.getComponents("hsv");this.value.setRawValue(new _n([Y,ge,ke,ct+b],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(p){ys(ku(!0),Fa(p))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const Ud=x("coltxt");function oq(S){const p=S.createElement("select"),b=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"}];return p.appendChild(b.reduce((D,Y)=>{const ge=S.createElement("option");return ge.textContent=Y.text,ge.value=Y.value,D.appendChild(ge),D},S.createDocumentFragment())),p}class aq{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(Ud()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("div");D.classList.add(Ud("m")),this.modeElem_=oq(p),this.modeElem_.classList.add(Ud("ms")),D.appendChild(this.modeSelectElement),b.viewProps.bindDisabled(this.modeElem_);const Y=p.createElement("div");Y.classList.add(Ud("mm")),Y.appendChild(he(p,"dropdown")),D.appendChild(Y),this.element.appendChild(D);const ge=p.createElement("div");ge.classList.add(Ud("w")),this.element.appendChild(ge),this.textsElem_=ge,this.textViews_=b.textViews,this.applyTextViews_(),T(b.colorMode,ke=>{this.modeElem_.value=ke})}get modeSelectElement(){return this.modeElem_}get textViews(){return this.textViews_}set textViews(p){this.textViews_=p,this.applyTextViews_()}applyTextViews_(){ye(this.textsElem_);const p=this.element.ownerDocument;this.textViews_.forEach(b=>{const D=p.createElement("div");D.classList.add(Ud("c")),D.appendChild(b.element),this.textsElem_.appendChild(D)})}}function lq(S){return Er(S==="float"?2:0)}function cq(S,p,b){const D=py(S,p)[b];return new cr({min:0,max:D})}function lM(S,p,b){return new pm(S,{arrayPosition:b===0?"fst":b===2?"lst":"mid",baseStep:ku(!1),parser:p.parser,props:W.fromObject({draggingScale:p.colorType==="float"?.01:1,formatter:lq(p.colorType)}),value:G(0,{constraint:cq(p.colorMode,p.colorType,b)}),viewProps:p.viewProps})}class uq{constructor(p,b){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=b.colorType,this.parser_=b.parser,this.value=b.value,this.viewProps=b.viewProps,this.colorMode=G(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(p),this.view=new aq(p,{colorMode:this.colorMode,textViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(p){const b={colorMode:this.colorMode.rawValue,colorType:this.colorType_,parser:this.parser_,viewProps:this.viewProps},D=[lM(p,b,0),lM(p,b,1),lM(p,b,2)];return D.forEach((Y,ge)=>{dm({primary:this.value,secondary:Y.value,forward:ke=>ke.rawValue.getComponents(this.colorMode.rawValue,this.colorType_)[ge],backward:(ke,ct)=>{const Xt=this.colorMode.rawValue,$t=ke.rawValue.getComponents(Xt,this.colorType_);return $t[ge]=ct.rawValue,new _n(S3(Uu($t),$t[3]),Xt,this.colorType_)}})}),D}onModeSelectChange_(p){const b=p.currentTarget;this.colorMode.rawValue=b.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.textViews=[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view]}}const cM=x("hpl");class hq{constructor(p,b){this.onValueChange_=this.onValueChange_.bind(this),this.value=b.value,this.value.emitter.on("change",this.onValueChange_),this.element=p.createElement("div"),this.element.classList.add(cM()),b.viewProps.bindClassModifiers(this.element),b.viewProps.bindTabIndex(this.element);const D=p.createElement("div");D.classList.add(cM("c")),this.element.appendChild(D);const Y=p.createElement("div");Y.classList.add(cM("m")),this.element.appendChild(Y),this.markerElem_=Y,this.update_()}update_(){const p=this.value.rawValue,[b]=p.getComponents("hsv");this.markerElem_.style.backgroundColor=H3(new _n([b,100,100],"hsv"));const D=gi(b,0,360,0,100);this.markerElem_.style.left=`${D}%`}onValueChange_(){this.update_()}}class dq{constructor(p,b){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=b.value,this.viewProps=b.viewProps,this.view=new hq(p,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Iu(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(p,b){if(!p.point)return;const D=gi(tr(p.point.x,0,p.bounds.width),0,p.bounds.width,0,360),Y=this.value.rawValue,[,ge,ke,ct]=Y.getComponents("hsv");this.value.setRawValue(new _n([D,ge,ke,ct],"hsv"),b)}onPointerDown_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerMove_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerUp_(p){this.handlePointerEvent_(p.data,{forceEmit:!0,last:!0})}onKeyDown_(p){const b=ys(ku(!1),Fa(p));if(b===0)return;const D=this.value.rawValue,[Y,ge,ke,ct]=D.getComponents("hsv");this.value.setRawValue(new _n([Y+b,ge,ke,ct],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(p){ys(ku(!1),Fa(p))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const uM=x("svp"),Y3=64;class fq{constructor(p,b){this.onValueChange_=this.onValueChange_.bind(this),this.value=b.value,this.value.emitter.on("change",this.onValueChange_),this.element=p.createElement("div"),this.element.classList.add(uM()),b.viewProps.bindClassModifiers(this.element),b.viewProps.bindTabIndex(this.element);const D=p.createElement("canvas");D.height=Y3,D.width=Y3,D.classList.add(uM("c")),this.element.appendChild(D),this.canvasElement=D;const Y=p.createElement("div");Y.classList.add(uM("m")),this.element.appendChild(Y),this.markerElem_=Y,this.update_()}update_(){const p=Z(this.canvasElement);if(!p)return;const D=this.value.rawValue.getComponents("hsv"),Y=this.canvasElement.width,ge=this.canvasElement.height,ke=p.getImageData(0,0,Y,ge),ct=ke.data;for(let Dn=0;DnD.rawValue.getComponents()[3],backward:(D,Y)=>{const ge=D.rawValue.getComponents();return ge[3]=Y.rawValue,new _n(ge,D.rawValue.mode)}}),this.textC_=new uq(p,{colorType:b.colorType,parser:Oa,value:this.value,viewProps:this.viewProps}),this.view=new Gj(p,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:b.supportsAlpha,svPaletteView:this.svPaletteC_.view,textView:this.textC_.view,viewProps:this.viewProps})}get textController(){return this.textC_}}const hM=x("colsw");class gq{constructor(p,b){this.onValueChange_=this.onValueChange_.bind(this),b.value.emitter.on("change",this.onValueChange_),this.value=b.value,this.element=p.createElement("div"),this.element.classList.add(hM()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("div");D.classList.add(hM("sw")),this.element.appendChild(D),this.swatchElem_=D;const Y=p.createElement("button");Y.classList.add(hM("b")),b.viewProps.bindDisabled(Y),this.element.appendChild(Y),this.buttonElement=Y,this.update_()}update_(){const p=this.value.rawValue;this.swatchElem_.style.backgroundColor=oM(p)}onValueChange_(){this.update_()}}class vq{constructor(p,b){this.value=b.value,this.viewProps=b.viewProps,this.view=new gq(p,{value:this.value,viewProps:this.viewProps})}}class dM{constructor(p,b){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=b.value,this.viewProps=b.viewProps,this.foldable_=tt.create(b.expanded),this.swatchC_=new vq(p,{value:this.value,viewProps:this.viewProps});const D=this.swatchC_.view.buttonElement;D.addEventListener("blur",this.onButtonBlur_),D.addEventListener("click",this.onButtonClick_),this.textC_=new Nl(p,{parser:b.parser,props:W.fromObject({formatter:b.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new Ij(p,{foldable:this.foldable_,pickerLayout:b.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=b.pickerLayout==="popup"?new Fl(p,{viewProps:this.viewProps}):null;const Y=new mq(p,{colorType:b.colorType,supportsAlpha:b.supportsAlpha,value:this.value,viewProps:this.viewProps});Y.view.allFocusableElements.forEach(ge=>{ge.addEventListener("blur",this.onPopupChildBlur_),ge.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=Y,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(Y.view.element),dm({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:ge=>ge.rawValue,backward:(ge,ke)=>ke.rawValue})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),ve(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(p){if(!this.popC_)return;const b=this.view.element,D=p.relatedTarget;(!D||!b.contains(D))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(p){if(!this.popC_)return;const b=this.popC_.view.element,D=Ce(p);D&&b.contains(D)||D&&D===this.swatchC_.view.buttonElement&&!Ye(b.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(p){this.popC_?p.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&p.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function _q(S,p){return _n.isColorObject(S)?_n.fromObject(S,p):_n.black(p)}function yq(S){return Uu(S.getComponents("rgb")).reduce((p,b)=>p<<8|Math.floor(b)&255,0)}function xq(S){return S.getComponents("rgb").reduce((p,b,D)=>{const Y=Math.floor(D===3?b*255:b)&255;return p<<8|Y},0)>>>0}function bq(S){return new _n([S>>16&255,S>>8&255,S&255],"rgb")}function wq(S){return new _n([S>>24&255,S>>16&255,S>>8&255,gi(S&255,0,255,0,1)],"rgb")}function Sq(S){return typeof S!="number"?_n.black():bq(S)}function Mq(S){return typeof S!="number"?_n.black():wq(S)}function Eq(S){const p=aM(S);return p?(b,D)=>{mm(b,p(D))}:null}function Tq(S){const p=S?xq:yq;return(b,D)=>{mm(b,p(D))}}function Aq(S,p,b){const D=p.toRgbaObject(b);S.writeProperty("r",D.r),S.writeProperty("g",D.g),S.writeProperty("b",D.b),S.writeProperty("a",D.a)}function Cq(S,p,b){const D=p.toRgbaObject(b);S.writeProperty("r",D.r),S.writeProperty("g",D.g),S.writeProperty("b",D.b)}function Pq(S,p){return(b,D)=>{S?Aq(b,D,p):Cq(b,D,p)}}function fM(S){var p;return!!(S!=null&&S.alpha||!((p=S==null?void 0:S.color)===null||p===void 0)&&p.alpha)}function Rq(S){return S?p=>oM(p,"0x"):p=>G3(p,"0x")}function Dq(S){return"color"in S||"view"in S&&S.view==="color"}const Iq={id:"input-color-number",type:"input",accept:(S,p)=>{if(typeof S!="number"||!Dq(p))return null;const b=iM(p);return b?{initialValue:S,params:b}:null},binding:{reader:S=>fM(S.params)?Mq:Sq,equals:_n.equals,writer:S=>Tq(fM(S.params))},controller:S=>{const p=fM(S.params),b="expanded"in S.params?S.params.expanded:void 0,D="picker"in S.params?S.params.picker:void 0;return new dM(S.document,{colorType:"int",expanded:b??!1,formatter:Rq(p),parser:sM("int"),pickerLayout:D??"popup",supportsAlpha:p,value:S.value,viewProps:S.viewProps})}};function Lq(S){return _n.isRgbaColorObject(S)}function Uq(S){return p=>_q(p,S)}function kq(S,p){return b=>S?X3(b,p):W3(b,p)}const Oq={id:"input-color-object",type:"input",accept:(S,p)=>{if(!_n.isColorObject(S))return null;const b=iM(p);return b?{initialValue:S,params:b}:null},binding:{reader:S=>Uq(Ou(S.params)),equals:_n.equals,writer:S=>Pq(Lq(S.initialValue),Ou(S.params))},controller:S=>{var p;const b=_n.isRgbaColorObject(S.initialValue),D="expanded"in S.params?S.params.expanded:void 0,Y="picker"in S.params?S.params.picker:void 0,ge=(p=Ou(S.params))!==null&&p!==void 0?p:"int";return new dM(S.document,{colorType:ge,expanded:D??!1,formatter:kq(b,ge),parser:sM(ge),pickerLayout:Y??"popup",supportsAlpha:b,value:S.value,viewProps:S.viewProps})}},Fq={id:"input-color-string",type:"input",accept:(S,p)=>{if(typeof S!="string"||"view"in p&&p.view==="text")return null;const b=rM(S,Ou(p));if(!b||!aM(b))return null;const Y=iM(p);return Y?{initialValue:S,params:Y}:null},binding:{reader:S=>{var p;return Kj((p=Ou(S.params))!==null&&p!==void 0?p:"int")},equals:_n.equals,writer:S=>{const p=rM(S.initialValue,Ou(S.params));if(!p)throw v.shouldNeverHappen();const b=Eq(p);if(!b)throw v.notBindable();return b}},controller:S=>{const p=rM(S.initialValue,Ou(S.params));if(!p)throw v.shouldNeverHappen();const b=aM(p);if(!b)throw v.shouldNeverHappen();const D="expanded"in S.params?S.params.expanded:void 0,Y="picker"in S.params?S.params.picker:void 0;return new dM(S.document,{colorType:p.type,expanded:D??!1,formatter:b,parser:sM(p.type),pickerLayout:Y??"popup",supportsAlpha:p.alpha,value:S.value,viewProps:S.viewProps})}};class Gl{constructor(p){this.components=p.components,this.asm_=p.assembly}constrain(p){const b=this.asm_.toComponents(p).map((D,Y)=>{var ge,ke;return(ke=(ge=this.components[Y])===null||ge===void 0?void 0:ge.constrain(D))!==null&&ke!==void 0?ke:D});return this.asm_.fromComponents(b)}}const j3=x("pndtxt");class Nq{constructor(p,b){this.textViews=b.textViews,this.element=p.createElement("div"),this.element.classList.add(j3()),this.textViews.forEach(D=>{const Y=p.createElement("div");Y.classList.add(j3("a")),Y.appendChild(D.element),this.element.appendChild(Y)})}}function Bq(S,p,b){return new pm(S,{arrayPosition:b===0?"fst":b===p.axes.length-1?"lst":"mid",baseStep:p.axes[b].baseStep,parser:p.parser,props:p.axes[b].textProps,value:G(0,{constraint:p.axes[b].constraint}),viewProps:p.viewProps})}class pM{constructor(p,b){this.value=b.value,this.viewProps=b.viewProps,this.acs_=b.axes.map((D,Y)=>Bq(p,b,Y)),this.acs_.forEach((D,Y)=>{dm({primary:this.value,secondary:D.value,forward:ge=>b.assembly.toComponents(ge.rawValue)[Y],backward:(ge,ke)=>{const ct=b.assembly.toComponents(ge.rawValue);return ct[Y]=ke.rawValue,b.assembly.fromComponents(ct)}})}),this.view=new Nq(p,{textViews:this.acs_.map(D=>D.view)})}}function q3(S,p){return"step"in S&&!h(S.step)?new kl(S.step,p):null}function Z3(S){return!h(S.max)&&!h(S.min)?new cr({max:S.max,min:S.min}):!h(S.max)||!h(S.min)?new im({max:S.max,min:S.min}):null}function zq(S){const p=lr(S,cr);if(p)return[p.values.get("min"),p.values.get("max")];const b=lr(S,im);return b?[b.minValue,b.maxValue]:[void 0,void 0]}function Vq(S,p){const b=[],D=q3(S,p);D&&b.push(D);const Y=Z3(S);Y&&b.push(Y);const ge=nM(S.options);return ge&&b.push(ge),new Vn(b)}const Gq={id:"input-number",type:"input",accept:(S,p)=>{if(typeof S!="number")return null;const b=K,D=Q(p,{format:b.optional.function,max:b.optional.number,min:b.optional.number,options:b.optional.custom(hy),step:b.optional.number});return D?{initialValue:S,params:D}:null},binding:{reader:S=>m3,constraint:S=>Vq(S.params,S.initialValue),writer:S=>mm},controller:S=>{var p;const b=S.value,D=S.constraint,Y=D&&lr(D,Ul);if(Y)return new na(S.document,{props:new W({options:Y.values.value("options")}),value:b,viewProps:S.viewProps});const ge=(p="format"in S.params?S.params.format:void 0)!==null&&p!==void 0?p:Er(dy(D,b.rawValue)),ke=D&&lr(D,cr);return ke?new tM(S.document,{baseStep:Id(D),parser:Oa,sliderProps:new W({maxValue:ke.values.value("max"),minValue:ke.values.value("min")}),textProps:W.fromObject({draggingScale:Ld(D,b.rawValue),formatter:ge}),value:b,viewProps:S.viewProps}):new pm(S.document,{baseStep:Id(D),parser:Oa,props:W.fromObject({draggingScale:Ld(D,b.rawValue),formatter:ge}),value:b,viewProps:S.viewProps})}};class Hl{constructor(p=0,b=0){this.x=p,this.y=b}getComponents(){return[this.x,this.y]}static isObject(p){if(h(p))return!1;const b=p.x,D=p.y;return!(typeof b!="number"||typeof D!="number")}static equals(p,b){return p.x===b.x&&p.y===b.y}toObject(){return{x:this.x,y:this.y}}}const K3={toComponents:S=>S.getComponents(),fromComponents:S=>new Hl(...S)},kd=x("p2d");class Hq{constructor(p,b){this.element=p.createElement("div"),this.element.classList.add(kd()),b.viewProps.bindClassModifiers(this.element),T(b.expanded,E(this.element,kd(void 0,"expanded")));const D=p.createElement("div");D.classList.add(kd("h")),this.element.appendChild(D);const Y=p.createElement("button");Y.classList.add(kd("b")),Y.appendChild(he(p,"p2dpad")),b.viewProps.bindDisabled(Y),D.appendChild(Y),this.buttonElement=Y;const ge=p.createElement("div");if(ge.classList.add(kd("t")),D.appendChild(ge),this.textElement=ge,b.pickerLayout==="inline"){const ke=p.createElement("div");ke.classList.add(kd("p")),this.element.appendChild(ke),this.pickerElement=ke}else this.pickerElement=null}}const Wl=x("p2dp");class Wq{constructor(p,b){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.invertsY_=b.invertsY,this.maxValue_=b.maxValue,this.element=p.createElement("div"),this.element.classList.add(Wl()),b.layout==="popup"&&this.element.classList.add(Wl(void 0,"p")),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("div");D.classList.add(Wl("p")),b.viewProps.bindTabIndex(D),this.element.appendChild(D),this.padElement=D;const Y=p.createElementNS(Me,"svg");Y.classList.add(Wl("g")),this.padElement.appendChild(Y),this.svgElem_=Y;const ge=p.createElementNS(Me,"line");ge.classList.add(Wl("ax")),ge.setAttributeNS(null,"x1","0"),ge.setAttributeNS(null,"y1","50%"),ge.setAttributeNS(null,"x2","100%"),ge.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(ge);const ke=p.createElementNS(Me,"line");ke.classList.add(Wl("ax")),ke.setAttributeNS(null,"x1","50%"),ke.setAttributeNS(null,"y1","0"),ke.setAttributeNS(null,"x2","50%"),ke.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(ke);const ct=p.createElementNS(Me,"line");ct.classList.add(Wl("l")),ct.setAttributeNS(null,"x1","50%"),ct.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(ct),this.lineElem_=ct;const Xt=p.createElement("div");Xt.classList.add(Wl("m")),this.padElement.appendChild(Xt),this.markerElem_=Xt,b.value.emitter.on("change",this.onValueChange_),this.value=b.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[p,b]=this.value.rawValue.getComponents(),D=this.maxValue_,Y=gi(p,-D,+D,0,100),ge=gi(b,-D,+D,0,100),ke=this.invertsY_?100-ge:ge;this.lineElem_.setAttributeNS(null,"x2",`${Y}%`),this.lineElem_.setAttributeNS(null,"y2",`${ke}%`),this.markerElem_.style.left=`${Y}%`,this.markerElem_.style.top=`${ke}%`}onValueChange_(){this.update_()}onFoldableChange_(){this.update_()}}function $3(S,p,b){return[ys(p[0],Fa(S)),ys(p[1],fm(S))*(b?1:-1)]}class Xq{constructor(p,b){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=b.value,this.viewProps=b.viewProps,this.baseSteps_=b.baseSteps,this.maxValue_=b.maxValue,this.invertsY_=b.invertsY,this.view=new Wq(p,{invertsY:this.invertsY_,layout:b.layout,maxValue:this.maxValue_,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Iu(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(p,b){if(!p.point)return;const D=this.maxValue_,Y=gi(p.point.x,0,p.bounds.width,-D,+D),ge=gi(this.invertsY_?p.bounds.height-p.point.y:p.point.y,0,p.bounds.height,-D,+D);this.value.setRawValue(new Hl(Y,ge),b)}onPointerDown_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerMove_(p){this.handlePointerEvent_(p.data,{forceEmit:!1,last:!1})}onPointerUp_(p){this.handlePointerEvent_(p.data,{forceEmit:!0,last:!0})}onPadKeyDown_(p){v3(p.key)&&p.preventDefault();const[b,D]=$3(p,this.baseSteps_,this.invertsY_);b===0&&D===0||this.value.setRawValue(new Hl(this.value.rawValue.x+b,this.value.rawValue.y+D),{forceEmit:!1,last:!1})}onPadKeyUp_(p){const[b,D]=$3(p,this.baseSteps_,this.invertsY_);b===0&&D===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class Yq{constructor(p,b){var D,Y;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=b.value,this.viewProps=b.viewProps,this.foldable_=tt.create(b.expanded),this.popC_=b.pickerLayout==="popup"?new Fl(p,{viewProps:this.viewProps}):null;const ge=new Xq(p,{baseSteps:[b.axes[0].baseStep,b.axes[1].baseStep],invertsY:b.invertsY,layout:b.pickerLayout,maxValue:b.maxValue,value:this.value,viewProps:this.viewProps});ge.view.allFocusableElements.forEach(ke=>{ke.addEventListener("blur",this.onPopupChildBlur_),ke.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=ge,this.textC_=new pM(p,{assembly:K3,axes:b.axes,parser:b.parser,value:this.value,viewProps:this.viewProps}),this.view=new Hq(p,{expanded:this.foldable_.value("expanded"),pickerLayout:b.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(D=this.view.buttonElement)===null||D===void 0||D.addEventListener("blur",this.onPadButtonBlur_),(Y=this.view.buttonElement)===null||Y===void 0||Y.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),dm({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:ke=>ke.rawValue,backward:(ke,ct)=>ct.rawValue})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),ve(this.foldable_,this.view.pickerElement))}onPadButtonBlur_(p){if(!this.popC_)return;const b=this.view.element,D=p.relatedTarget;(!D||!b.contains(D))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(p){if(!this.popC_)return;const b=this.popC_.view.element,D=Ce(p);D&&b.contains(D)||D&&D===this.view.buttonElement&&!Ye(b.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(p){this.popC_?p.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&p.key==="Escape"&&this.view.buttonElement.focus()}}class Od{constructor(p=0,b=0,D=0){this.x=p,this.y=b,this.z=D}getComponents(){return[this.x,this.y,this.z]}static isObject(p){if(h(p))return!1;const b=p.x,D=p.y,Y=p.z;return!(typeof b!="number"||typeof D!="number"||typeof Y!="number")}static equals(p,b){return p.x===b.x&&p.y===b.y&&p.z===b.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const J3={toComponents:S=>S.getComponents(),fromComponents:S=>new Od(...S)};function jq(S){return Od.isObject(S)?new Od(S.x,S.y,S.z):new Od}function qq(S,p){S.writeProperty("x",p.x),S.writeProperty("y",p.y),S.writeProperty("z",p.z)}function Zq(S,p){return new Gl({assembly:J3,components:[Na("x"in S?S.x:void 0,p.x),Na("y"in S?S.y:void 0,p.y),Na("z"in S?S.z:void 0,p.z)]})}function mM(S,p){return{baseStep:Id(p),constraint:p,textProps:W.fromObject({draggingScale:Ld(p,S),formatter:Er(dy(p,S))})}}const Kq={id:"input-point3d",type:"input",accept:(S,p)=>{if(!Od.isObject(S))return null;const b=K,D=Q(p,{x:b.optional.custom(zl),y:b.optional.custom(zl),z:b.optional.custom(zl)});return D?{initialValue:S,params:D}:null},binding:{reader:S=>jq,constraint:S=>Zq(S.params,S.initialValue),equals:Od.equals,writer:S=>qq},controller:S=>{const p=S.value,b=S.constraint;if(!(b instanceof Gl))throw v.shouldNeverHappen();return new pM(S.document,{assembly:J3,axes:[mM(p.rawValue.x,b.components[0]),mM(p.rawValue.y,b.components[1]),mM(p.rawValue.z,b.components[2])],parser:Oa,value:p,viewProps:S.viewProps})}};class Fd{constructor(p=0,b=0,D=0,Y=0){this.x=p,this.y=b,this.z=D,this.w=Y}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(p){if(h(p))return!1;const b=p.x,D=p.y,Y=p.z,ge=p.w;return!(typeof b!="number"||typeof D!="number"||typeof Y!="number"||typeof ge!="number")}static equals(p,b){return p.x===b.x&&p.y===b.y&&p.z===b.z&&p.w===b.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const Q3={toComponents:S=>S.getComponents(),fromComponents:S=>new Fd(...S)};function $q(S){return Fd.isObject(S)?new Fd(S.x,S.y,S.z,S.w):new Fd}function Jq(S,p){S.writeProperty("x",p.x),S.writeProperty("y",p.y),S.writeProperty("z",p.z),S.writeProperty("w",p.w)}function Qq(S,p){return new Gl({assembly:Q3,components:[Na("x"in S?S.x:void 0,p.x),Na("y"in S?S.y:void 0,p.y),Na("z"in S?S.z:void 0,p.z),Na("w"in S?S.w:void 0,p.w)]})}function eZ(S,p){return{baseStep:Id(p),constraint:p,textProps:W.fromObject({draggingScale:Ld(p,S),formatter:Er(dy(p,S))})}}const tZ={id:"input-point4d",type:"input",accept:(S,p)=>{if(!Fd.isObject(S))return null;const b=K,D=Q(p,{x:b.optional.custom(zl),y:b.optional.custom(zl),z:b.optional.custom(zl),w:b.optional.custom(zl)});return D?{initialValue:S,params:D}:null},binding:{reader:S=>$q,constraint:S=>Qq(S.params,S.initialValue),equals:Fd.equals,writer:S=>Jq},controller:S=>{const p=S.value,b=S.constraint;if(!(b instanceof Gl))throw v.shouldNeverHappen();return new pM(S.document,{assembly:Q3,axes:p.rawValue.getComponents().map((D,Y)=>eZ(D,b.components[Y])),parser:Oa,value:p,viewProps:S.viewProps})}};function nZ(S){const p=[],b=nM(S.options);return b&&p.push(b),new Vn(p)}const iZ={id:"input-string",type:"input",accept:(S,p)=>{if(typeof S!="string")return null;const D=Q(p,{options:K.optional.custom(hy)});return D?{initialValue:S,params:D}:null},binding:{reader:S=>g3,constraint:S=>nZ(S.params),writer:S=>mm},controller:S=>{const p=S.document,b=S.value,D=S.constraint,Y=D&&lr(D,Ul);return Y?new na(p,{props:new W({options:Y.values.value("options")}),value:b,viewProps:S.viewProps}):new Nl(p,{parser:ge=>ge,props:W.fromObject({formatter:$S}),value:b,viewProps:S.viewProps})}},vm={monitor:{defaultInterval:200,defaultLineCount:3}},eU=x("mll");class rZ{constructor(p,b){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=b.formatter,this.element=p.createElement("div"),this.element.classList.add(eU()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("textarea");D.classList.add(eU("i")),D.style.height=`calc(var(--bld-us) * ${b.lineCount})`,D.readOnly=!0,b.viewProps.bindDisabled(D),this.element.appendChild(D),this.textareaElem_=D,b.value.emitter.on("change",this.onValueUpdate_),this.value=b.value,this.update_()}update_(){const p=this.textareaElem_,b=p.scrollTop===p.scrollHeight-p.clientHeight,D=[];this.value.rawValue.forEach(Y=>{Y!==void 0&&D.push(this.formatter_(Y))}),p.textContent=D.join(` `),b&&(p.scrollTop=p.scrollHeight)}onValueUpdate_(){this.update_()}}class gM{constructor(p,b){this.value=b.value,this.viewProps=b.viewProps,this.view=new rZ(p,{formatter:b.formatter,lineCount:b.lineCount,value:this.value,viewProps:this.viewProps})}}const tU=x("sgl");class sZ{constructor(p,b){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=b.formatter,this.element=p.createElement("div"),this.element.classList.add(tU()),b.viewProps.bindClassModifiers(this.element);const D=p.createElement("input");D.classList.add(tU("i")),D.readOnly=!0,D.type="text",b.viewProps.bindDisabled(D),this.element.appendChild(D),this.inputElement=D,b.value.emitter.on("change",this.onValueUpdate_),this.value=b.value,this.update_()}update_(){const p=this.value.rawValue,b=p[p.length-1];this.inputElement.value=b!==void 0?this.formatter_(b):""}onValueUpdate_(){this.update_()}}class vM{constructor(p,b){this.value=b.value,this.viewProps=b.viewProps,this.view=new sZ(p,{formatter:b.formatter,value:this.value,viewProps:this.viewProps})}}const oZ={id:"monitor-bool",type:"monitor",accept:(S,p)=>{if(typeof S!="boolean")return null;const D=Q(p,{lineCount:K.optional.number});return D?{initialValue:S,params:D}:null},binding:{reader:S=>om},controller:S=>{var p;return S.value.rawValue.length===1?new vM(S.document,{formatter:Cu,value:S.value,viewProps:S.viewProps}):new gM(S.document,{formatter:Cu,lineCount:(p=S.params.lineCount)!==null&&p!==void 0?p:vm.monitor.defaultLineCount,value:S.value,viewProps:S.viewProps})}},Xl=x("grl");class aZ{constructor(p,b){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=p.createElement("div"),this.element.classList.add(Xl()),b.viewProps.bindClassModifiers(this.element),this.formatter_=b.formatter,this.props_=b.props,this.cursor_=b.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const D=p.createElementNS(Me,"svg");D.classList.add(Xl("g")),D.style.height=`calc(var(--bld-us) * ${b.lineCount})`,this.element.appendChild(D),this.svgElem_=D;const Y=p.createElementNS(Me,"polyline");this.svgElem_.appendChild(Y),this.lineElem_=Y;const ge=p.createElement("div");ge.classList.add(Xl("t"),x("tt")()),this.element.appendChild(ge),this.tooltipElem_=ge,b.value.emitter.on("change",this.onValueUpdate_),this.value=b.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const p=this.svgElem_.getBoundingClientRect(),b=this.value.rawValue.length-1,D=this.props_.get("minValue"),Y=this.props_.get("maxValue"),ge=[];this.value.rawValue.forEach((Dn,Fn)=>{if(Dn===void 0)return;const Fu=gi(Fn,0,b,0,p.width),_m=gi(Dn,D,Y,p.height,0);ge.push([Fu,_m].join(","))}),this.lineElem_.setAttributeNS(null,"points",ge.join(" "));const ke=this.tooltipElem_,ct=this.value.rawValue[this.cursor_.rawValue];if(ct===void 0){ke.classList.remove(Xl("t","a"));return}const Xt=gi(this.cursor_.rawValue,0,b,0,p.width),$t=gi(ct,D,Y,p.height,0);ke.style.left=`${Xt}px`,ke.style.top=`${$t}px`,ke.textContent=`${this.formatter_(ct)}`,ke.classList.contains(Xl("t","a"))||(ke.classList.add(Xl("t","a"),Xl("t","in")),oe(ke),ke.classList.remove(Xl("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class lZ{constructor(p,b){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props_=b.props,this.value=b.value,this.viewProps=b.viewProps,this.cursor_=G(-1),this.view=new aZ(p,{cursor:this.cursor_,formatter:b.formatter,lineCount:b.lineCount,props:this.props_,value:this.value,viewProps:this.viewProps}),!Ye(p))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const D=new Iu(this.view.element);D.emitter.on("down",this.onGraphPointerDown_),D.emitter.on("move",this.onGraphPointerMove_),D.emitter.on("up",this.onGraphPointerUp_)}}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(p){const b=this.view.element.getBoundingClientRect();this.cursor_.rawValue=Math.floor(gi(p.offsetX,0,b.width,0,this.value.rawValue.length))}onGraphPointerDown_(p){this.onGraphPointerMove_(p)}onGraphPointerMove_(p){if(!p.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(gi(p.data.point.x,0,p.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function _M(S){return"format"in S&&!h(S.format)?S.format:Er(2)}function cZ(S){var p;return S.value.rawValue.length===1?new vM(S.document,{formatter:_M(S.params),value:S.value,viewProps:S.viewProps}):new gM(S.document,{formatter:_M(S.params),lineCount:(p=S.params.lineCount)!==null&&p!==void 0?p:vm.monitor.defaultLineCount,value:S.value,viewProps:S.viewProps})}function uZ(S){var p,b,D;return new lZ(S.document,{formatter:_M(S.params),lineCount:(p=S.params.lineCount)!==null&&p!==void 0?p:vm.monitor.defaultLineCount,props:W.fromObject({maxValue:(b="max"in S.params?S.params.max:null)!==null&&b!==void 0?b:100,minValue:(D="min"in S.params?S.params.min:null)!==null&&D!==void 0?D:0}),value:S.value,viewProps:S.viewProps})}function nU(S){return"view"in S&&S.view==="graph"}const hZ={id:"monitor-number",type:"monitor",accept:(S,p)=>{if(typeof S!="number")return null;const b=K,D=Q(p,{format:b.optional.function,lineCount:b.optional.number,max:b.optional.number,min:b.optional.number,view:b.optional.string});return D?{initialValue:S,params:D}:null},binding:{defaultBufferSize:S=>nU(S)?64:1,reader:S=>m3},controller:S=>nU(S.params)?uZ(S):cZ(S)},dZ={id:"monitor-string",type:"monitor",accept:(S,p)=>{if(typeof S!="string")return null;const b=K,D=Q(p,{lineCount:b.optional.number,multiline:b.optional.boolean});return D?{initialValue:S,params:D}:null},binding:{reader:S=>g3},controller:S=>{var p;const b=S.value;return b.rawValue.length>1||"multiline"in S.params&&S.params.multiline?new gM(S.document,{formatter:$S,lineCount:(p=S.params.lineCount)!==null&&p!==void 0?p:vm.monitor.defaultLineCount,value:b,viewProps:S.viewProps}):new vM(S.document,{formatter:$S,value:b,viewProps:S.viewProps})}};function fZ(S,p){var b;const D=S.accept(p.target.read(),p.params);if(h(D))return null;const Y=K,ge={target:p.target,initialValue:D.initialValue,params:D.params},ke=S.binding.reader(ge),ct=S.binding.constraint?S.binding.constraint(ge):void 0,Xt=G(ke(D.initialValue),{constraint:ct,equals:S.binding.equals}),$t=new pn({reader:ke,target:p.target,value:Xt,writer:S.binding.writer(ge)}),Dn=Y.optional.boolean(p.params.disabled).value,Fn=Y.optional.boolean(p.params.hidden).value,Fu=S.controller({constraint:ct,document:p.document,initialValue:D.initialValue,params:D.params,value:$t.value,viewProps:Ee.create({disabled:Dn,hidden:Fn})});return new je(p.document,{binding:$t,blade:ot(),props:W.fromObject({label:"label"in p.params?(b=Y.optional.string(p.params.label).value)!==null&&b!==void 0?b:null:p.target.key}),valueController:Fu})}function pZ(S,p){return p===0?new vn:new ui(S,p??vm.monitor.defaultInterval)}function mZ(S,p){var b,D,Y;const ge=K,ke=S.accept(p.target.read(),p.params);if(h(ke))return null;const ct={target:p.target,initialValue:ke.initialValue,params:ke.params},Xt=S.binding.reader(ct),$t=(D=(b=ge.optional.number(p.params.bufferSize).value)!==null&&b!==void 0?b:S.binding.defaultBufferSize&&S.binding.defaultBufferSize(ke.params))!==null&&D!==void 0?D:1,Dn=ge.optional.number(p.params.interval).value,Fn=new On({reader:Xt,target:p.target,ticker:pZ(p.document,Dn),value:Vt($t)}),Fu=ge.optional.boolean(p.params.disabled).value,_m=ge.optional.boolean(p.params.hidden).value,ym=S.controller({document:p.document,params:ke.params,value:Fn.value,viewProps:Ee.create({disabled:Fu,hidden:_m})});return new ft(p.document,{binding:Fn,blade:ot(),props:W.fromObject({label:"label"in p.params?(Y=ge.optional.string(p.params.label).value)!==null&&Y!==void 0?Y:null:p.target.key}),valueController:ym})}class gZ{constructor(){this.pluginsMap_={blades:[],inputs:[],monitors:[]}}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(p){p.type==="blade"?this.pluginsMap_.blades.unshift(p):p.type==="input"?this.pluginsMap_.inputs.unshift(p):p.type==="monitor"&&this.pluginsMap_.monitors.unshift(p)}createInput(p,b,D){const Y=b.read();if(h(Y))throw new v({context:{key:b.key},type:"nomatchingcontroller"});const ge=this.pluginsMap_.inputs.reduce((ke,ct)=>ke??fZ(ct,{document:p,target:b,params:D}),null);if(ge)return ge;throw new v({context:{key:b.key},type:"nomatchingcontroller"})}createMonitor(p,b,D){const Y=this.pluginsMap_.monitors.reduce((ge,ke)=>ge??mZ(ke,{document:p,params:D,target:b}),null);if(Y)return Y;throw new v({context:{key:b.key},type:"nomatchingcontroller"})}createBlade(p,b){const D=this.pluginsMap_.blades.reduce((Y,ge)=>Y??St(ge,{document:p,params:b}),null);if(!D)throw new v({type:"nomatchingview",context:{params:b}});return D}createBladeApi(p){if(p instanceof je)return new nt(p);if(p instanceof ft)return new at(p);if(p instanceof Pn)return new Rt(p,this);const b=this.pluginsMap_.blades.reduce((D,Y)=>D??Y.api({controller:p,pool:this}),null);if(!b)throw v.shouldNeverHappen();return b}}function vZ(){const S=new gZ;return[SZ,Kq,tZ,iZ,Gq,Fq,Oq,Iq,Dj,oZ,dZ,hZ,Ze,N,Pe,Yt].forEach(p=>{S.register(p)}),S}function _Z(S){return Hl.isObject(S)?new Hl(S.x,S.y):new Hl}function yZ(S,p){S.writeProperty("x",p.x),S.writeProperty("y",p.y)}function Na(S,p){if(!S)return;const b=[],D=q3(S,p);D&&b.push(D);const Y=Z3(S);return Y&&b.push(Y),new Vn(b)}function xZ(S,p){return new Gl({assembly:K3,components:[Na("x"in S?S.x:void 0,p.x),Na("y"in S?S.y:void 0,p.y)]})}function iU(S,p){const[b,D]=S?zq(S):[];if(!h(b)||!h(D))return Math.max(Math.abs(b??0),Math.abs(D??0));const Y=Id(S);return Math.max(Math.abs(Y)*10,Math.abs(p)*10)}function bZ(S,p){const b=p instanceof Gl?p.components[0]:void 0,D=p instanceof Gl?p.components[1]:void 0,Y=iU(b,S.x),ge=iU(D,S.y);return Math.max(Y,ge)}function rU(S,p){return{baseStep:Id(p),constraint:p,textProps:W.fromObject({draggingScale:Ld(p,S),formatter:Er(dy(p,S))})}}function wZ(S){if(!("y"in S))return!1;const p=S.y;return p&&"inverted"in p?!!p.inverted:!1}const SZ={id:"input-point2d",type:"input",accept:(S,p)=>{if(!Hl.isObject(S))return null;const b=K,D=Q(p,{expanded:b.optional.boolean,picker:b.optional.custom(x3),x:b.optional.custom(zl),y:b.optional.object({inverted:b.optional.boolean,max:b.optional.number,min:b.optional.number,step:b.optional.number})});return D?{initialValue:S,params:D}:null},binding:{reader:S=>_Z,constraint:S=>xZ(S.params,S.initialValue),equals:Hl.equals,writer:S=>yZ},controller:S=>{const p=S.document,b=S.value,D=S.constraint;if(!(D instanceof Gl))throw v.shouldNeverHappen();const Y="expanded"in S.params?S.params.expanded:void 0,ge="picker"in S.params?S.params.picker:void 0;return new Yq(p,{axes:[rU(b.rawValue.x,D.components[0]),rU(b.rawValue.y,D.components[1])],expanded:Y??!1,invertsY:wZ(S.params),maxValue:bZ(b.rawValue,D),parser:Oa,pickerLayout:ge??"popup",value:b,viewProps:S.viewProps})}};class sU extends n{constructor(p){super(p),this.emitter_=new y,this.controller_.valueController.value.emitter.on("change",b=>{this.emitter_.emit("change",{event:new o(this,b.rawValue)})})}get label(){return this.controller_.props.get("label")}set label(p){this.controller_.props.set("label",p)}get options(){return this.controller_.valueController.props.get("options")}set options(p){this.controller_.valueController.props.set("options",p)}get value(){return this.controller_.valueController.value.rawValue}set value(p){this.controller_.valueController.value.rawValue=p}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}}class oU extends n{constructor(p){super(p),this.emitter_=new y,this.controller_.valueController.value.emitter.on("change",b=>{this.emitter_.emit("change",{event:new o(this,b.rawValue)})})}get label(){return this.controller_.props.get("label")}set label(p){this.controller_.props.set("label",p)}get maxValue(){return this.controller_.valueController.sliderController.props.get("maxValue")}set maxValue(p){this.controller_.valueController.sliderController.props.set("maxValue",p)}get minValue(){return this.controller_.valueController.sliderController.props.get("minValue")}set minValue(p){this.controller_.valueController.sliderController.props.set("minValue",p)}get value(){return this.controller_.valueController.value.rawValue}set value(p){this.controller_.valueController.value.rawValue=p}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}}class aU extends n{constructor(p){super(p),this.emitter_=new y,this.controller_.valueController.value.emitter.on("change",b=>{this.emitter_.emit("change",{event:new o(this,b.rawValue)})})}get label(){return this.controller_.props.get("label")}set label(p){this.controller_.props.set("label",p)}get formatter(){return this.controller_.valueController.props.get("formatter")}set formatter(p){this.controller_.valueController.props.set("formatter",p)}get value(){return this.controller_.valueController.value.rawValue}set value(p){this.controller_.valueController.value.rawValue=p}on(p,b){const D=b.bind(this);return this.emitter_.on(p,Y=>{D(Y.event)}),this}}const MZ=function(){return{id:"list",type:"blade",accept(S){const p=K,b=Q(S,{options:p.required.custom(hy),value:p.required.raw,view:p.required.constant("list"),label:p.optional.string});return b?{params:b}:null},controller(S){const p=new Ul(b3(S.params.options)),b=G(S.params.value,{constraint:p}),D=new na(S.document,{props:new W({options:p.values.value("options")}),value:b,viewProps:S.viewProps});return new ie(S.document,{blade:S.blade,props:W.fromObject({label:S.params.label}),valueController:D})},api(S){return!(S.controller instanceof ie)||!(S.controller.valueController instanceof na)?null:new sU(S.controller)}}}();function EZ(S){return S.reduce((p,b)=>Object.assign(p,{[b.presetKey]:b.read()}),{})}function TZ(S,p){S.forEach(b=>{const D=p[b.target.presetKey];D!==void 0&&b.writer(b.target,b.reader(D))})}class AZ extends on{constructor(p,b){super(p,b)}get element(){return this.controller_.view.element}importPreset(p){const b=this.controller_.rackController.rack.find(je).map(D=>D.binding);TZ(b,p),this.refresh()}exportPreset(){const p=this.controller_.rackController.rack.find(je).map(b=>b.binding.target);return EZ(p)}refresh(){this.controller_.rackController.rack.find(je).forEach(p=>{p.binding.read()}),this.controller_.rackController.rack.find(ft).forEach(p=>{p.binding.read()})}}class CZ extends de{constructor(p,b){super(p,{expanded:b.expanded,blade:b.blade,props:b.props,root:!0,viewProps:b.viewProps})}}const PZ={id:"slider",type:"blade",accept(S){const p=K,b=Q(S,{max:p.required.number,min:p.required.number,view:p.required.constant("slider"),format:p.optional.function,label:p.optional.string,value:p.optional.number});return b?{params:b}:null},controller(S){var p,b;const D=(p=S.params.value)!==null&&p!==void 0?p:0,Y=new cr({max:S.params.max,min:S.params.min}),ge=new tM(S.document,{baseStep:1,parser:Oa,sliderProps:new W({maxValue:Y.values.value("max"),minValue:Y.values.value("min")}),textProps:W.fromObject({draggingScale:Ld(void 0,D),formatter:(b=S.params.format)!==null&&b!==void 0?b:xj}),value:G(D,{constraint:Y}),viewProps:S.viewProps});return new ie(S.document,{blade:S.blade,props:W.fromObject({label:S.params.label}),valueController:ge})},api(S){return!(S.controller instanceof ie)||!(S.controller.valueController instanceof tM)?null:new oU(S.controller)}},RZ=function(){return{id:"text",type:"blade",accept(S){const p=K,b=Q(S,{parse:p.required.function,value:p.required.raw,view:p.required.constant("text"),format:p.optional.function,label:p.optional.string});return b?{params:b}:null},controller(S){var p;const b=new Nl(S.document,{parser:S.params.parse,props:W.fromObject({formatter:(p=S.params.format)!==null&&p!==void 0?p:D=>String(D)}),value:G(S.params.value),viewProps:S.viewProps});return new ie(S.document,{blade:S.blade,props:W.fromObject({label:S.params.label}),valueController:b})},api(S){return!(S.controller instanceof ie)||!(S.controller.valueController instanceof Nl)?null:new aU(S.controller)}}}();function DZ(S){const p=S.createElement("div");return p.classList.add(x("dfw")()),S.body&&S.body.appendChild(p),p}function lU(S,p,b){if(S.querySelector(`style[data-tp-style=${p}]`))return;const D=S.createElement("style");D.dataset.tpStyle=p,D.textContent=b,S.head.appendChild(D)}class IZ extends AZ{constructor(p){var b,D;const Y=p??{},ge=(b=Y.document)!==null&&b!==void 0?b:j(),ke=vZ(),ct=new CZ(ge,{expanded:Y.expanded,blade:ot(),props:W.fromObject({title:Y.title}),viewProps:Ee.create()});super(ct,ke),this.pool_=ke,this.containerElem_=(D=Y.container)!==null&&D!==void 0?D:DZ(ge),this.containerElem_.appendChild(this.element),this.doc_=ge,this.usesDefaultWrapper_=!Y.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw v.alreadyDisposed();return this.doc_}dispose(){const p=this.containerElem_;if(!p)throw v.alreadyDisposed();if(this.usesDefaultWrapper_){const b=p.parentElement;b&&b.removeChild(p)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(p){("plugin"in p?[p.plugin]:"plugins"in p?p.plugins:[]).forEach(D=>{this.pool_.register(D),this.embedPluginStyle_(D)})}embedPluginStyle_(p){p.css&&lU(this.document,`plugin-${p.id}`,p.css)}setUpDefaultPlugins_(){lU(this.document,"default",'.tp-tbiv_b,.tp-coltxtv_ms,.tp-ckbv_i,.tp-rotv_b,.tp-fldv_b,.tp-mllv_i,.tp-sglv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-mllv_i,.tp-sglv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--mo-fg);height:var(--bld-us);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-mllv_i::-webkit-scrollbar,.tp-sglv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-mllv_i::-webkit-scrollbar-corner,.tp-sglv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-mllv_i::-webkit-scrollbar-thumb,.tp-sglv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-rotv{--font-family: var(--tp-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-br: var(--tp-base-border-radius, 6px);--cnt-h-p: var(--tp-container-horizontal-padding, 4px);--cnt-v-p: var(--tp-container-vertical-padding, 4px);--elm-br: var(--tp-element-border-radius, 2px);--bld-s: var(--tp-blade-spacing, 4px);--bld-us: var(--tp-blade-unit-size, 20px);--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tabv_c .tp-brkv>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-v-p))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tabv_c .tp-brkv>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tabv_c .tp-brkv>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tabv_c .tp-brkv>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--bld-s)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tabv_c .tp-brkv>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tabv_c .tp-brkv>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-v-p)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tabv_c .tp-brkv>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tabv_c .tp-brkv>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-v-p)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tabv_c .tp-brkv>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tabv_c .tp-brkv>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tabv_c .tp-brkv>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tabv_c .tp-brkv>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--elm-br);border-bottom-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tabv_c .tp-brkv .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tabv_c .tp-brkv>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tabv_c .tp-brkv>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--elm-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--bld-us) + 4px);line-height:calc(var(--bld-us) + 4px);overflow:hidden;padding-left:var(--cnt-h-p);padding-right:calc(4px + var(--bld-us) + var(--cnt-h-p));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-h-p) + (var(--bld-us) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-v-p);padding-top:var(--cnt-v-p);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--elm-br);cursor:pointer;display:block;height:var(--bld-us);position:relative;width:var(--bld-us)}.tp-ckbv_w svg{bottom:0;display:block;height:16px;left:0;margin:auto;opacity:0;position:absolute;right:0;top:0;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--bld-us)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--bld-s);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-h-p));right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--bld-s)}.tp-colpv_rgb{display:flex;margin-top:var(--bld-s);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-v-p);padding-top:calc(var(--cnt-v-p) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--elm-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--bld-us)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--bld-us);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--elm-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--bld-us);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{bottom:0;left:0;position:absolute;right:0;top:0}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--elm-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--elm-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;bottom:0;left:0;position:absolute;right:0;top:0}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--elm-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;cursor:pointer;display:block;height:var(--bld-us);left:0;margin:0;outline:none;padding:0;position:absolute;top:0;width:var(--bld-us)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--elm-br);bottom:0;content:"";display:block;left:0;position:absolute;right:0;top:0}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--elm-br);color:var(--lbl-fg);cursor:pointer;height:var(--bld-us);line-height:var(--bld-us);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv.tp-fldv-not .tp-fldv_b{display:none}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--bld-us) + 4px);width:var(--bs-br)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--bld-us)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-h-p);padding-right:var(--cnt-h-p)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:160px}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding:0 4px}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--bld-us)*3);line-height:var(--bld-us);padding:0 4px;resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--bld-us);margin-right:4px;position:relative;width:var(--bld-us)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--bld-s);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-h-p));right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-p2dpv{padding-left:calc(var(--bld-us) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:6px;box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:168px;padding:var(--cnt-v-p) var(--cnt-h-p);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--bld-us);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;bottom:0;content:"";display:block;height:2px;left:0;margin:auto;position:absolute;right:0;top:0}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";display:block;height:2px;left:0;margin-bottom:auto;margin-top:auto;position:absolute;right:0;top:0}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--elm-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--bld-us) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_c{padding-bottom:var(--cnt-v-p);padding-left:4px;padding-top:var(--cnt-v-p)}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--bld-us) + 4px);width:var(--bs-br)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-h-p) + 4px);padding-right:calc(var(--cnt-h-p) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);bottom:2px;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--bld-us) + 4px);line-height:calc(var(--bld-us) + 4px);opacity:.5;overflow:hidden;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-txtv{position:relative}.tp-txtv_i{padding:0 4px}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:-3px;position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--bld-us) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--elm-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--font-family);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--bld-us) + var(--cnt-h-p));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0}.tp-rotv.tp-rotv-not .tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-v-p))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-v-p))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}'),this.pool_.getAll().forEach(p=>{this.embedPluginStyle_(p)}),this.registerPlugin({plugins:[PZ,MZ,Yt,RZ]})}}const LZ=new i("3.1.10");t.BladeApi=n,t.ButtonApi=_,t.FolderApi=on,t.InputBindingApi=nt,t.ListApi=sU,t.MonitorBindingApi=at,t.Pane=IZ,t.SeparatorApi=se,t.SliderApi=oU,t.TabApi=et,t.TabPageApi=Je,t.TextApi=aU,t.TpChangeEvent=o,t.VERSION=LZ,Object.defineProperty(t,"__esModule",{value:!0})})}(Hp,Hp.exports)),Hp.exports}var pX=fX();function mX(){var s=Object.create(null);function e(n,r){var o=n.id,a=n.name,l=n.dependencies;l===void 0&&(l=[]);var c=n.init;c===void 0&&(c=function(){});var u=n.getTransferables;if(u===void 0&&(u=null),!s[o])try{l=l.map(function(d){return d&&d.isWorkerModule&&(e(d,function(f){if(f instanceof Error)throw f}),d=s[d.id].value),d}),c=i("<"+a+">.init",c),u&&(u=i("<"+a+">.getTransferables",u));var h=null;typeof c=="function"?h=c.apply(void 0,l):console.error("worker module init function failed to rehydrate"),s[o]={id:o,value:h,getTransferables:u},r(h)}catch(d){d&&d.noLog||console.error(d),r(d)}}function t(n,r){var o,a=n.id,l=n.args;(!s[a]||typeof s[a].value!="function")&&r(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var c=(o=s[a]).value.apply(o,l);c&&typeof c.then=="function"?c.then(u,function(h){return r(h instanceof Error?h:new Error(""+h))}):u(c)}catch(h){r(h)}function u(h){try{var d=s[a].getTransferables&&s[a].getTransferables(h);(!d||!Array.isArray(d)||!d.length)&&(d=void 0),r(h,d)}catch(f){console.error(f),r(f)}}}function i(n,r){var o=void 0;self.troikaDefine=function(l){return o=l};var a=URL.createObjectURL(new Blob(["/** "+n.replace(/\*/g,"")+` **/ troikaDefine( `+r+` )`],{type:"application/javascript"}));try{importScripts(a)}catch(l){console.error(l)}return URL.revokeObjectURL(a),delete self.troikaDefine,o}self.addEventListener("message",function(n){var r=n.data,o=r.messageId,a=r.action,l=r.data;try{a==="registerModule"&&e(l,function(c){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:{isCallable:typeof c=="function"}})}),a==="callModule"&&t(l,function(c,u){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:c},u||void 0)})}catch(c){postMessage({messageId:o,success:!1,error:c.stack})}})}function gX(s){var e=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];return e._getInitResult().then(function(n){if(typeof n=="function")return n.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")})};return e._getInitResult=function(){var t=s.dependencies,i=s.init;t=Array.isArray(t)?t.map(function(r){return r&&(r=r.onMainThread||r,r._getInitResult&&(r=r._getInitResult())),r}):[];var n=Promise.all(t).then(function(r){return i.apply(null,r)});return e._getInitResult=function(){return n},n},e}var UI=function(){var s=!1;if(typeof window<"u"&&typeof window.document<"u")try{var e=new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"})));e.terminate(),s=!0}catch(t){typeof process<"u"&&process.env.NODE_ENV==="test"||console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return UI=function(){return s},s},vX=0,_X=0,MS=!1,Wp=Object.create(null),Xp=Object.create(null),ES=Object.create(null);function Md(s){if((!s||typeof s.init!="function")&&!MS)throw new Error("requires `options.init` function");var e=s.dependencies,t=s.init,i=s.getTransferables,n=s.workerId,r=gX(s);n==null&&(n="#default");var o="workerModule"+ ++vX,a=s.name||o,l=null;e=e&&e.map(function(u){return typeof u=="function"&&!u.workerModuleData&&(MS=!0,u=Md({workerId:n,name:"<"+a+"> function dependency: "+u.name,init:`function(){return ( `+B_(u)+` )}`}),MS=!1),u&&u.workerModuleData&&(u=u.workerModuleData),u});function c(){for(var u=[],h=arguments.length;h--;)u[h]=arguments[h];if(!UI())return r.apply(void 0,u);if(!l){l=kI(n,"registerModule",c.workerModuleData);var d=function(){l=null,Xp[n].delete(d)};(Xp[n]||(Xp[n]=new Set)).add(d)}return l.then(function(f){var m=f.isCallable;if(m)return kI(n,"callModule",{id:o,args:u});throw new Error("Worker module function was called but `init` did not return a callable function")})}return c.workerModuleData={isWorkerModule:!0,id:o,name:a,dependencies:e,init:B_(t),getTransferables:i&&B_(i)},c.onMainThread=r,c}function yX(s){Xp[s]&&Xp[s].forEach(function(e){e()}),Wp[s]&&(Wp[s].terminate(),delete Wp[s])}function B_(s){var e=s.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function xX(s){var e=Wp[s];if(!e){var t=B_(mX);e=Wp[s]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+s.replace(/\*/g,"")+` **/ ;(`+t+")()"],{type:"application/javascript"}))),e.onmessage=function(i){var n=i.data,r=n.messageId,o=ES[r];if(!o)throw new Error("WorkerModule response with empty or unknown messageId");delete ES[r],o(n)}}return e}function kI(s,e,t){return new Promise(function(i,n){var r=++_X;ES[r]=function(o){o.success?i(o.result):n(new Error("Error in worker "+e+" call: "+o.error))},xX(s).postMessage({messageId:r,action:e,data:t})})}function z_(){var s=function(e){function t(q,O,B,J,re,K,Q,ue){var le=1-Q;ue.x=le*le*q+2*le*Q*B+Q*Q*re,ue.y=le*le*O+2*le*Q*J+Q*Q*K}function i(q,O,B,J,re,K,Q,ue,le,_e){var Fe=1-le;_e.x=Fe*Fe*Fe*q+3*Fe*Fe*le*B+3*Fe*le*le*re+le*le*le*Q,_e.y=Fe*Fe*Fe*O+3*Fe*Fe*le*J+3*Fe*le*le*K+le*le*le*ue}function n(q,O){for(var B=/([MLQCZ])([^MLQCZ]*)/g,J,re,K,Q,ue;J=B.exec(q);){var le=J[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map(function(_e){return parseFloat(_e)});switch(J[1]){case"M":Q=re=le[0],ue=K=le[1];break;case"L":(le[0]!==Q||le[1]!==ue)&&O("L",Q,ue,Q=le[0],ue=le[1]);break;case"Q":{O("Q",Q,ue,Q=le[2],ue=le[3],le[0],le[1]);break}case"C":{O("C",Q,ue,Q=le[4],ue=le[5],le[0],le[1],le[2],le[3]);break}case"Z":(Q!==re||ue!==K)&&O("L",Q,ue,re,K);break}}}function r(q,O,B){B===void 0&&(B=16);var J={x:0,y:0};n(q,function(re,K,Q,ue,le,_e,Fe,Ie,Ee){switch(re){case"L":O(K,Q,ue,le);break;case"Q":{for(var me=K,xe=Q,$=1;$0;)ye[Ae]=arguments[Ae+2];var Ce=Oe[Se]||(Oe[Se]=B.getUniformLocation(j,Se));B["uniform"+te].apply(B,[Ce].concat(ye))},setAttribute:function(te,Se,ye,Ae,Ce){var Ge=Ye[te];Ge||(Ge=Ye[te]={buf:B.createBuffer(),loc:B.getAttribLocation(j,te),data:null}),B.bindBuffer(B.ARRAY_BUFFER,Ge.buf),B.vertexAttribPointer(Ge.loc,Se,B.FLOAT,!1,0,0),B.enableVertexAttribArray(Ge.loc),re?B.vertexAttribDivisor(Ge.loc,Ae):Fe("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(Ge.loc,Ae),Ce!==Ge.data&&(B.bufferData(B.ARRAY_BUFFER,Ce,ye),Ge.data=Ce)}})}}}Q[Ue].transaction(Te)},me=function(Ue,Me){le++;try{B.activeTexture(B.TEXTURE0+le);var oe=ue[Ue];oe||(oe=ue[Ue]=B.createTexture(),B.bindTexture(B.TEXTURE_2D,oe),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.NEAREST),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.NEAREST)),B.bindTexture(B.TEXTURE_2D,oe),Me(oe,le)}finally{le--}},xe=function(Ue,Me,oe){var Te=B.createFramebuffer();_e.push(Te),B.bindFramebuffer(B.FRAMEBUFFER,Te),B.activeTexture(B.TEXTURE0+Me),B.bindTexture(B.TEXTURE_2D,Ue),B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Ue,0);try{oe(Te)}finally{B.deleteFramebuffer(Te),B.bindFramebuffer(B.FRAMEBUFFER,_e[--_e.length-1]||null)}},$=function(){K={},Q={},ue={},le=-1,_e.length=0};var re=typeof WebGL2RenderingContext<"u"&&B instanceof WebGL2RenderingContext,K={},Q={},ue={},le=-1,_e=[];B.canvas.addEventListener("webglcontextlost",function(Ue){$(),Ue.preventDefault()},!1),l.set(B,J={gl:B,isWebGL2:re,getExtension:Fe,withProgram:Ee,withTexture:me,withTextureFramebuffer:xe,handleContextLoss:$})}O(J)}function h(q,O,B,J,re,K,Q,ue){Q===void 0&&(Q=15),ue===void 0&&(ue=null),u(q,function(le){var _e=le.gl,Fe=le.withProgram,Ie=le.withTexture;Ie("copy",function(Ee,me){_e.texImage2D(_e.TEXTURE_2D,0,_e.RGBA,re,K,0,_e.RGBA,_e.UNSIGNED_BYTE,O),Fe("copy",o,a,function(xe){var $=xe.setUniform,Ue=xe.setAttribute;Ue("aUV",2,_e.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),$("1i","image",me),_e.bindFramebuffer(_e.FRAMEBUFFER,ue||null),_e.disable(_e.BLEND),_e.colorMask(Q&8,Q&4,Q&2,Q&1),_e.viewport(B,J,re,K),_e.scissor(B,J,re,K),_e.drawArrays(_e.TRIANGLES,0,3)})})})}function d(q,O,B){var J=q.width,re=q.height;u(q,function(K){var Q=K.gl,ue=new Uint8Array(J*re*4);Q.readPixels(0,0,J,re,Q.RGBA,Q.UNSIGNED_BYTE,ue),q.width=O,q.height=B,h(Q,ue,0,0,J,re)})}var f=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:h,resizeWebGLCanvasWithoutClearing:d});function m(q,O,B,J,re,K){K===void 0&&(K=1);var Q=new Uint8Array(q*O),ue=J[2]-J[0],le=J[3]-J[1],_e=[];r(B,function(Ue,Me,oe,Te){_e.push({x1:Ue,y1:Me,x2:oe,y2:Te,minX:Math.min(Ue,oe),minY:Math.min(Me,Te),maxX:Math.max(Ue,oe),maxY:Math.max(Me,Te)})}),_e.sort(function(Ue,Me){return Ue.maxX-Me.maxX});for(var Fe=0;FeOe.minX&&Me-TeOe.minY){var j=_(Ue,Me,Oe.x1,Oe.y1,Oe.x2,Oe.y2);jMe!=Ye.y2>Me&&Ue<(Ye.x2-Ye.x1)*(Me-Ye.y1)/(Ye.y2-Ye.y1)+Ye.x1;Oe&&(oe+=Ye.y1p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function v(Te,Ye){var Oe=36,j=0,Z=new Map,pe=Ye&&new Map,he;return Te.split(",").forEach(function te(Se){if(Se.indexOf("+")!==-1)for(var ye=+Se;ye--;)te(he);else{he=Se;var Ae=Se.split(">"),Ce=Ae[0],Ge=Ae[1];Ce=String.fromCodePoint(j+=parseInt(Ce,Oe)),Ge=String.fromCodePoint(j+=parseInt(Ge,Oe)),Z.set(Ce,Ge),Ye&&pe.set(Ge,Ce)}}),{map:Z,reverseMap:pe}}var g,_,y;function w(){if(!g){var Te=v(m.pairs,!0),Ye=Te.map,Oe=Te.reverseMap;g=Ye,_=Oe,y=v(m.canonical,!1).map}}function x(Te){return w(),g.get(Te)||null}function M(Te){return w(),_.get(Te)||null}function C(Te){return w(),y.get(Te)||null}var T=i.L,A=i.R,P=i.EN,E=i.ES,I=i.ET,R=i.AN,U=i.CS,L=i.B,k=i.S,z=i.ON,G=i.BN,W=i.NSM,q=i.AL,O=i.LRO,B=i.RLO,J=i.LRE,re=i.RLE,K=i.PDF,Q=i.LRI,ue=i.RLI,le=i.FSI,_e=i.PDI;function Fe(Te,Ye){for(var Oe=125,j=new Uint32Array(Te.length),Z=0;Z0)ot--;else if(mt>0){for(tt=0;!Ze[Ze.length-1]._isolate;)Ze.pop();var Be=Ze[Ze.length-1]._isolInitIndex;Be!=null&&(Se.set(Be,ce),Se.set(ce,Be)),Ze.pop(),mt--}Le=Ze[Ze.length-1],te[ce]=Le._level,Le._override&&he(ce,Le._override)}else ve&K?(ot===0&&(tt>0?tt--:!Le._isolate&&Ze.length>1&&(Ze.pop(),Le=Ze[Ze.length-1])),te[ce]=Le._level):ve&L&&(te[ce]=Ae.level);else te[ce]=Le._level,Le._override&&ve!==G&&he(ce,Le._override)}for(var ut=[],gt=null,nt=Ae.start;nt<=Ae.end;nt++){var je=j[nt];if(!(je&l)){var at=te[nt],ft=je&r,Qe=je===_e;gt&&at===gt._level?(gt._end=nt,gt._endsWithIsolInit=ft):ut.push(gt={_start:nt,_end:nt,_level:at,_startsWithPDI:Qe,_endsWithIsolInit:ft})}}for(var bt=[],yt=0;yt=0;Pn--)if(!(j[Pn]&l)){fn=te[Pn];break}var F=Kt[Kt.length-1],ee=te[F],de=Ae.level;if(!(j[F]&r)){for(var N=F+1;N<=Ae.end;N++)if(!(j[N]&l)){de=te[N];break}}bt.push({_seqIndices:Kt,_sosType:Math.max(fn,er)%2?A:T,_eosType:Math.max(de,ee)%2?A:T})}}for(var ie=0;ie=0;Ke--)if(!(j[ne[Ke]]&l)){qe=j[ne[Ke]];break}he(He,qe&(r|_e)?z:qe)}}if(pe.get(P))for(var Je=0;Je=-1;st--){var Dt=st===-1?ae:j[ne[st]];if(Dt&o){Dt===q&&he(et,R);break}}}if(pe.get(q))for(var kt=0;kt=0&&(St=j[ne[ui]],!!(St&l));ui--);for(var pn=wt+1;pn=0&&j[ne[Xn]]&(I|l);Xn--)he(ne[Xn],P);for(jt++;jt=0&&j[ne[Vn]]&l;Vn--)he(ne[Vn],z);for(var lr=ri+1;lr=0;Au--){var Nl=La[Au].char;if(Nl===rm||Nl===M(C(Fl))||x(C(Nl))===Fl){na.push([La[Au].seqIndex,Ol]),La.length=Au;break}}}na.sort(function(Br,Ys){return Br[0]-Ys[0]})}for(var sm=0;sm=0;Ua--){var sy=ne[Ua];if(j[sy]&ny){var Bl=j[sy]&Ia?A:T;Bl!==Pe?Xs=Bl:Xs=Pe;break}}}if(Xs){if(j[ne[Cu]]=j[ne[am]]=Xs,Xs!==Pe){for(var Pu=Cu+1;Pu=0;Ru--)if(j[ne[Ru]]&l)oy=Ru;else{um=j[ne[Ru]]&Ia?A:T;break}for(var ay=we,Du=Do+1;Du=0&&d(Te[Dd])&c;Dd--)te[Dd]=Ae.level}}return{levels:te,paragraphs:ye};function ly(Br,Ys){for(var Mr=Br;Mr=te&&d(Te[Ae])&c;Ae--)ye[Ae]=he.level;for(var Ce=he.level,Ge=1/0,De=0;DeCe&&(Ce=Ve),Ve=Ge;ze--)for(var Ze=0;Ze=ze){for(var Le=Ze;Ze+1=ze;)Ze++;Ze>Le&&pe.push([Le+te,Ze+te])}}}),pe}function Me(Te,Ye,Oe,j){var Z=oe(Te,Ye,Oe,j),pe=[].concat(Te);return Z.forEach(function(he,te){pe[te]=(Ye.levels[he]&1?xe(Te[he]):null)||Te[he]}),pe.join("")}function oe(Te,Ye,Oe,j){for(var Z=Ue(Te,Ye,Oe,j),pe=[],he=0;he/gm;function t(i,n){let r=Ft[n];return r?TS(r):i}return s.replace(e,t)}const br=[];for(let s=0;s<256;s++)br[s]=(s<16?"0":"")+s.toString(16);function bX(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(br[s&255]+br[s>>8&255]+br[s>>16&255]+br[s>>24&255]+"-"+br[e&255]+br[e>>8&255]+"-"+br[e>>16&15|64]+br[e>>24&255]+"-"+br[t&63|128]+br[t>>8&255]+"-"+br[t>>16&255]+br[t>>24&255]+br[i&255]+br[i>>8&255]+br[i>>16&255]+br[i>>24&255]).toUpperCase()}const xu=Object.assign||function(){let s=arguments[0];for(let e=1,t=arguments.length;es.type,set:c=>{s.type=c}},isDerivedFrom:{writable:!0,configurable:!0,value:function(c){const u=this.baseMaterial;return c===u||u.isDerivedMaterial&&u.isDerivedFrom(c)||!1}},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return s.customProgramCacheKey()+"|"+t}},onBeforeCompile:{get(){return r},set(c){this[n]=c}},copy:{writable:!0,configurable:!0,value:function(c){return s.copy.call(this,c),!s.isShaderMaterial&&!s.isDerivedMaterial&&(xu(this.extensions,c.extensions),xu(this.defines,c.defines),xu(this.uniforms,pl.clone(c.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const c=new s.constructor;return a(c).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let c=this._depthMaterial;return c||(c=this._depthMaterial=AS(s.isDerivedMaterial?s.getDepthMaterial():new jc({depthPacking:Ch}),e),c.defines.IS_DEPTH_MATERIAL="",c.uniforms=this.uniforms),c}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let c=this._distanceMaterial;return c||(c=this._distanceMaterial=AS(s.isDerivedMaterial?s.getDistanceMaterial():new td,e),c.defines.IS_DISTANCE_MATERIAL="",c.uniforms=this.uniforms),c}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:c,_distanceMaterial:u}=this;c&&c.dispose(),u&&u.dispose(),s.dispose.call(this)}}};return i[t]=o,new o}function MX(s,{vertexShader:e,fragmentShader:t},i,n){let{vertexDefs:r,vertexMainIntro:o,vertexMainOutro:a,vertexTransform:l,fragmentDefs:c,fragmentMainIntro:u,fragmentMainOutro:h,fragmentColorTransform:d,customRewriter:f,timeUniform:m}=i;if(r=r||"",o=o||"",a=a||"",c=c||"",u=u||"",h=h||"",(l||f)&&(e=TS(e)),(d||f)&&(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm,` //!BEGIN_POST_CHUNK $1 $& //!END_POST_CHUNK `),t=TS(t)),f){let v=f({vertexShader:e,fragmentShader:t});e=v.vertexShader,t=v.fragmentShader}if(d){let v=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,g=>(v.push(g),"")),h=`${d} ${v.join(` `)} ${h}`}if(m){const v=` uniform float ${m}; `;r=v+r,c=v+c}return l&&(e=`vec3 troika_position_${n}; vec3 troika_normal_${n}; vec2 troika_uv_${n}; ${e} `,r=`${r} void troikaVertexTransform${n}(inout vec3 position, inout vec3 normal, inout vec2 uv) { ${l} } `,o=` troika_position_${n} = vec3(position); troika_normal_${n} = vec3(normal); troika_uv_${n} = vec2(uv); troikaVertexTransform${n}(troika_position_${n}, troika_normal_${n}, troika_uv_${n}); ${o} `,e=e.replace(/\b(position|normal|uv)\b/g,(v,g,_,y)=>/\battribute\s+vec[23]\s+$/.test(y.substr(0,_))?g:`troika_${g}_${n}`),s.map&&s.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${n}`))),e=zI(e,n,r,o,a),t=zI(t,n,c,u,h),{vertexShader:e,fragmentShader:t}}function zI(s,e,t,i,n){return(i||n||t)&&(s=s.replace(FI,` ${t} void troikaOrigMain${e}() {`),s+=` void main() { ${i} troikaOrigMain${e}(); ${n} }`),s}function EX(s,e){return s==="uniforms"?void 0:typeof e=="function"?e.toString():e}let TX=0;const VI=new Map;function AX(s){const e=JSON.stringify(s,EX);let t=VI.get(e);return t==null&&VI.set(e,t=++TX),t}/*! Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering. Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE */function CX(){return typeof window>"u"&&(self.window=self),function(s){var e={parse:function(n){var r=e._bin,o=new Uint8Array(n);if(r.readASCII(o,0,4)=="ttcf"){var a=4;r.readUshort(o,a),a+=2,r.readUshort(o,a),a+=2;var l=r.readUint(o,a);a+=4;for(var c=[],u=0;u>>o&1&&r++;return r},e._lctf.readClassDef=function(n,r){var o=e._bin,a=[],l=o.readUshort(n,r);if(r+=2,l==1){var c=o.readUshort(n,r);r+=2;var u=o.readUshort(n,r);r+=2;for(var h=0;h0&&(l.featureParams=a+c);var u=o.readUshort(n,r);r+=2,l.tab=[];for(var h=0;h0&&(l.default=e._lctf.readLangSysTable(n,a+c));var u=o.readUshort(n,r);r+=2;for(var h=0;h255?-1:e.CFF.glyphByUnicode(n,e.CFF.tableSE[r])},e.CFF.readEncoding=function(n,r,o){e._bin;var a=[".notdef"],l=n[r];if(r++,l!=0)throw"error: unknown encoding format: "+l;var c=n[r];r++;for(var u=0;u>4,y=15&g;if(_!=15&&v.push(_),y!=15&&v.push(y),y==15)break}for(var w="",x=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],M=0;M=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(var u=0;u=1&&u.fmt<=2){d=l.readUshort(n,o),o+=2;var f=l.readUshort(n,o);o+=2;var m=e._lctf.numOfOnes(d),v=e._lctf.numOfOnes(f);if(u.fmt==1){u.pairsets=[];var g=l.readUshort(n,o);o+=2;for(var _=0;_=1&&u.fmt<=2){if(u.fmt==1)u.delta=l.readShort(n,o),o+=2;else if(u.fmt==2){var d=l.readUshort(n,o);o+=2,u.newg=l.readUshorts(n,o,d),o+=2*u.newg.length}}else if(r==2&&u.fmt==1){d=l.readUshort(n,o),o+=2,u.seqs=[];for(var f=0;f>>8;if((m&=15)!=0)throw"unknown kern table format: "+m;r=e.kern.readFormat0(n,r,h)}return h},e.kern.parseV1=function(n,r,o,a){var l=e._bin;l.readFixed(n,r),r+=4;var c=l.readUint(n,r);r+=4;for(var u={glyph1:[],rval:[]},h=0;h>>8;if((f&=15)!=0)throw"unknown kern table format: "+f;r=e.kern.readFormat0(n,r,u)}return u},e.kern.readFormat0=function(n,r,o){var a=e._bin,l=-1,c=a.readUshort(n,r);r+=2,a.readUshort(n,r),r+=2,a.readUshort(n,r),r+=2,a.readUshort(n,r),r+=2;for(var u=0;u=l.map.length?0:l.map[r];if(l.format==4){for(var c=-1,u=0;ur?0:65535&(l.idRangeOffset[c]!=0?l.glyphIdArray[r-l.startCount[c]+(l.idRangeOffset[c]>>1)-(l.idRangeOffset.length-c)]:r+l.idDelta[c])}if(l.format==12){if(r>l.groups[l.groups.length-1][1])return 0;for(u=0;u-1?e.U._simpleGlyph(a,o):e.U._compoGlyph(a,r,o))},e.U._simpleGlyph=function(n,r){for(var o=0;ol)){for(var g=!0,_=0,y=0;yl)){for(g=!0,y=0;y>1,c.length=0,h=!0;else if(R=="o3"||R=="o23")c.length%2!=0&&!h&&(d=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0;else if(R=="o4")c.length>1&&!h&&(d=c.shift()+a.nominalWidthX,h=!0),f&&e.U.P.closePath(l),g+=c.pop(),e.U.P.moveTo(l,v,g),f=!0;else if(R=="o5")for(;c.length>0;)v+=c.shift(),g+=c.shift(),e.U.P.lineTo(l,v,g);else if(R=="o6"||R=="o7")for(var U=c.length,L=R=="o6",k=0;kMath.abs(A-g)?v=T+c.shift():g=A+c.shift(),e.U.P.curveTo(l,_,y,w,x,P,E),e.U.P.curveTo(l,M,C,T,A,v,g));else if(R=="o14"){if(c.length>0&&!h&&(d=c.shift()+o.nominalWidthX,h=!0),c.length==4){var W=c.shift(),q=c.shift(),O=c.shift(),B=c.shift(),J=e.CFF.glyphBySE(o,O),re=e.CFF.glyphBySE(o,B);e.U._drawCFF(o.CharStrings[J],r,o,a,l),r.x=W,r.y=q,e.U._drawCFF(o.CharStrings[re],r,o,a,l)}f&&(e.U.P.closePath(l),f=!1)}else if(R=="o19"||R=="o20")c.length%2!=0&&!h&&(d=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0,m+=u+7>>3;else if(R=="o21")c.length>2&&!h&&(d=c.shift()+a.nominalWidthX,h=!0),g+=c.pop(),v+=c.pop(),f&&e.U.P.closePath(l),e.U.P.moveTo(l,v,g),f=!0;else if(R=="o22")c.length>1&&!h&&(d=c.shift()+a.nominalWidthX,h=!0),v+=c.pop(),f&&e.U.P.closePath(l),e.U.P.moveTo(l,v,g),f=!0;else if(R=="o25"){for(;c.length>6;)v+=c.shift(),g+=c.shift(),e.U.P.lineTo(l,v,g);_=v+c.shift(),y=g+c.shift(),w=_+c.shift(),x=y+c.shift(),v=w+c.shift(),g=x+c.shift(),e.U.P.curveTo(l,_,y,w,x,v,g)}else if(R=="o26")for(c.length%2&&(v+=c.shift());c.length>0;)_=v,y=g+c.shift(),v=w=_+c.shift(),g=(x=y+c.shift())+c.shift(),e.U.P.curveTo(l,_,y,w,x,v,g);else if(R=="o27")for(c.length%2&&(g+=c.shift());c.length>0;)y=g,w=(_=v+c.shift())+c.shift(),x=y+c.shift(),v=w+c.shift(),g=x,e.U.P.curveTo(l,_,y,w,x,v,g);else if(R=="o10"||R=="o29"){var K=R=="o10"?a:o;if(c.length==0)console.debug("error: empty stack");else{var Q=c.pop(),ue=K.Subrs[Q+K.Bias];r.x=v,r.y=g,r.nStems=u,r.haveWidth=h,r.width=d,r.open=f,e.U._drawCFF(ue,r,o,a,l),v=r.x,g=r.y,u=r.nStems,h=r.haveWidth,d=r.width,f=r.open}}else if(R=="o30"||R=="o31"){var le=c.length,_e=(G=0,R=="o31");for(G+=le-(U=-3&le);G>>1|(21845&f)<<1;m=(61680&(m=(52428&m)>>>2|(13107&m)<<2))>>>4|(3855&m)<<4,d[f]=((65280&m)>>>8|(255&m)<<8)>>>1}var v=function(R,U,L){for(var k=R.length,z=0,G=new t(U);z>>O]=B}return W},g=new e(288);for(f=0;f<144;++f)g[f]=8;for(f=144;f<256;++f)g[f]=9;for(f=256;f<280;++f)g[f]=7;for(f=280;f<288;++f)g[f]=8;var _=new e(32);for(f=0;f<32;++f)_[f]=5;var y=v(g,9),w=v(_,5),x=function(R){for(var U=R[0],L=1;LU&&(U=R[L]);return U},M=function(R,U,L){var k=U/8|0;return(R[k]|R[k+1]<<8)>>(7&U)&L},C=function(R,U){var L=U/8|0;return(R[L]|R[L+1]<<8|R[L+2]<<16)>>(7&U)},T=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],A=function(R,U,L){var k=new Error(U||T[R]);if(k.code=R,Error.captureStackTrace&&Error.captureStackTrace(k,A),!L)throw k;return k},P=function(R,U,L){var k=R.length;if(!k||L&&!L.l&&k<5)return U||new e(0);var z=!U||L,G=!L||L.i;L||(L={}),U||(U=new e(3*k));var W,q=function(Le){var ot=U.length;if(Le>ot){var tt=new e(Math.max(2*ot,Le));tt.set(U),U=tt}},O=L.f||0,B=L.p||0,J=L.b||0,re=L.l,K=L.d,Q=L.m,ue=L.n,le=8*k;do{if(!re){L.f=O=M(R,B,1);var _e=M(R,B+1,3);if(B+=3,!_e){var Fe=R[(Oe=((W=B)/8|0)+(7&W&&1)+4)-4]|R[Oe-3]<<8,Ie=Oe+Fe;if(Ie>k){G&&A(0);break}z&&q(J+Fe),U.set(R.subarray(Oe,Ie),J),L.b=J+=Fe,L.p=B=8*Ie;continue}if(_e==1)re=y,K=w,Q=9,ue=5;else if(_e==2){var Ee=M(R,B,31)+257,me=M(R,B+10,15)+4,xe=Ee+M(R,B+5,31)+1;B+=14;for(var $=new e(xe),Ue=new e(19),Me=0;Me>>4)<16)$[Me++]=Oe;else{var Z=0,pe=0;for(Oe==16?(pe=3+M(R,B,3),B+=2,Z=$[Me-1]):Oe==17?(pe=3+M(R,B,7),B+=3):Oe==18&&(pe=11+M(R,B,127),B+=7);pe--;)$[Me++]=Z}}var he=$.subarray(0,Ee),te=$.subarray(Ee);Q=x(he),ue=x(te),re=v(he,Q),K=v(te,ue)}else A(1);if(B>le){G&&A(0);break}}z&&q(J+131072);for(var Se=(1<>>4;if((B+=15&Z)>le){G&&A(0);break}if(Z||A(2),Ce<256)U[J++]=Ce;else{if(Ce==256){Ae=B,re=null;break}var Ge=Ce-254;if(Ce>264){var De=n[Me=Ce-257];Ge=M(R,B,(1<>>4;if(Ve||A(3),B+=15&Ve,te=h[ze],ze>3&&(De=r[ze],te+=C(R,B)&(1<le){G&&A(0);break}z&&q(J+131072);for(var Ze=J+Ge;JLe.length)&&(tt=Le.length);var mt=new(Le instanceof t?t:Le instanceof i?i:e)(tt-ot);return mt.set(Le.subarray(ot,tt)),mt}(U,0,J)},E=new e(0),I=typeof TextDecoder<"u"&&new TextDecoder;try{I.decode(E,{stream:!0})}catch{}return s.convert_streams=function(R){var U=new DataView(R),L=0;function k(){var Ee=U.getUint16(L);return L+=2,Ee}function z(){var Ee=U.getUint32(L);return L+=4,Ee}function G(Ee){Fe.setUint16(Ie,Ee),Ie+=2}function W(Ee){Fe.setUint32(Ie,Ee),Ie+=4}for(var q={signature:z(),flavor:z(),length:z(),numTables:k(),reserved:k(),totalSfntSize:z(),majorVersion:k(),minorVersion:k(),metaOffset:z(),metaLength:z(),metaOrigLength:z(),privOffset:z(),privLength:z()},O=0;Math.pow(2,O)<=q.numTables;)O++;O--;for(var B=16*Math.pow(2,O),J=16*q.numTables-B,re=12,K=[],Q=0;Q{let[R,U]=I.split("+");R=parseInt(R,36),U=U?parseInt(U,36):0,u.set(E+=R,A[P]);for(let L=U;L--;)u.set(++E,A[P])})}}return u.get(T)||c}const d=1,f=2,m=3,v=4,g=[null,"isol","init","fina","medi"];function _(T){const A=new Uint8Array(T.length);let P=c,E=d,I=-1;for(let R=0;R65535&&R++)}return A}function y(T,A){const P=[];for(let I=0;I65535&&I++,P.push(s.U.codeToGlyph(T,R))}const E=T.GSUB;if(E){const{lookupList:I,featureList:R}=E;let U;const L=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws|ccmp)$/,k=[];R.forEach(z=>{if(L.test(z.tag))for(let G=0;G=0;k--)if(A[k]!==-1&&(!L||L(A[k])))return k;return-1}function R(L){return x(T,L)===1}function U(L,k){for(let z=0;z<3;z++)P[k*3+z]+=L[z]||0}}function x(T,A){const P=T.GDEF&&T.GDEF.glyphClassDef;return P?s.U._getGlyphClass(A,P):0}function M(...T){for(let A=0;A0},forEachGlyph(L,k,z,G){let W=0;const q=1/U.unitsPerEm*k,O=y(T,L);let B=0;const J=w(T,O);return O.forEach((re,K)=>{if(re!==-1){let Q=A[re];if(!Q){const{cmds:ue,crds:le}=s.U.glyphToPath(T,re);let _e="",Fe=0;for(let $=0,Ue=ue.length;$1?",":"")+le[Fe++]}let Ie,Ee,me,xe;if(le.length){Ie=Ee=1/0,me=xe=-1/0;for(let $=0,Ue=le.length;$me&&(me=Me),oe>xe&&(xe=oe)}}else Ie=me=Ee=xe=0;Q=A[re]={index:re,advanceWidth:T.hmtx.aWidth[re],xMin:Ie,yMin:Ee,xMax:me,yMax:xe,path:_e}}G.call(null,Q,W+J[K*3]*q,J[K*3+1]*q,B),W+=J[K*3+2]*q,z&&(W+=z*k)}B+=L.codePointAt(B)>65535?2:1}),W}};return U}return function(A){const P=new Uint8Array(A,0,4),E=s._bin.readASCII(P,0,4);if(E==="wOFF")A=e(A);else if(E==="wOF2")throw new Error("woff2 fonts not supported");return C(s.parse(A)[0])}}const DX=Md({name:"Typr Font Parser",dependencies:[CX,PX,RX],init(s,e,t){const i=s(),n=e();return t(i,n)}});/*! Custom bundle of @unicode-font-resolver/client v1.0.2 (https://github.com/lojjic/unicode-font-resolver) for use in Troika text rendering. Original MIT license applies */function IX(){return function(s){var e=function(){this.buckets=new Map};e.prototype.add=function(w){var x=w>>5;this.buckets.set(x,(this.buckets.get(x)||0)|1<<(31&w))},e.prototype.has=function(w){var x=this.buckets.get(w>>5);return x!==void 0&&(x&1<<(31&w))!=0},e.prototype.serialize=function(){var w=[];return this.buckets.forEach(function(x,M){w.push((+M).toString(36)+":"+x.toString(36))}),w.join(",")},e.prototype.deserialize=function(w){var x=this;this.buckets.clear(),w.split(",").forEach(function(M){var C=M.split(":");x.buckets.set(parseInt(C[0],36),parseInt(C[1],36))})};var t=Math.pow(2,8),i=t-1,n=~i;function r(w){var x=function(C){return C&n}(w).toString(16),M=function(C){return(C&n)+t-1}(w).toString(16);return"codepoint-index/plane"+(w>>16)+"/"+x+"-"+M+".json"}function o(w,x){var M=w&i,C=x.codePointAt(M/6|0);return((C=(C||48)-48)&1<65535&&(B++,O=B)},O=0;O65535&&(re++,J=re)},J=0;J65535&&(re++,R[re]=R[re-1])}return{fontUrls:Array.from(I.keys()),chars:R}})},Object.defineProperty(s,"__esModule",{value:!0}),s}({})}function LX(s,e){const t=Object.create(null),i=Object.create(null);function n(o,a){const l=c=>{console.error(`Failure loading font ${o}`,c)};try{const c=new XMLHttpRequest;c.open("get",o,!0),c.responseType="arraybuffer",c.onload=function(){if(c.status>=400)l(new Error(c.statusText));else if(c.status>0)try{const u=s(c.response);u.src=o,a(u)}catch(u){l(u)}},c.onerror=l,c.send()}catch(c){l(c)}}function r(o,a){let l=t[o];l?a(l):i[o]?i[o].push(a):(i[o]=[a],n(o,c=>{c.src=o,t[o]=c,i[o].forEach(u=>u(c)),delete i[o]}))}return function(o,a,{lang:l,fonts:c=[],style:u="normal",weight:h="normal",unicodeFontsURL:d}={}){const f=new Uint8Array(o.length),m=[];o.length||y();const v=new Map,g=[];if(u!=="italic"&&(u="normal"),typeof h!="number"&&(h=h==="bold"?700:400),c&&!Array.isArray(c)&&(c=[c]),c=c.slice().filter(x=>!x.lang||x.lang.test(l)).reverse(),c.length){let T=0;(function A(P=0){for(let E=P,I=o.length;E0&&/\s/.test(o[E]))f[E]=f[E-1],T===2&&(g[g.length-1][1]=E);else for(let U=f[E],L=c.length;U<=L;U++)if(U===L){const k=T===2?g[g.length-1]:g[g.length]=[E,E];k[1]=E,T=2}else{f[E]=U;const{src:k,unicodeRange:z}=c[U];if(!z||w(R,z)){const G=t[k];if(!G){r(k,()=>{A(E)});return}if(G.supportsCodePoint(R)){let W=v.get(G);typeof W!="number"&&(W=m.length,m.push(G),v.set(G,W)),f[E]=W,T=1;break}}}R>65535&&E+1o.substring(M[0],M[1]+1)).join(` `);e.getFontsForString(x,{lang:l||void 0,style:u,weight:h,dataUrl:d}).then(({fontUrls:M,chars:C})=>{const T=m.length;let A=0;g.forEach(E=>{for(let I=0,R=E[1]-E[0];I<=R;I++)f[E[0]+I]=C[A++]+T;A++});let P=0;M.forEach((E,I)=>{r(E,R=>{m[I+T]=R,++P===M.length&&y()})})})}else y()}function y(){a({chars:f,fonts:m})}function w(x,M){for(let C=0;C{let P,E;const I=[];for(let R=0;R-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),m=m.replace(/\r\n/g,` `).replace(/\r/g,` `)),y=+y,M=+M,T=+T,C=C||"normal",E=+E,o({text:m,lang:g,style:x,weight:w,fonts:typeof v=="string"?[{src:v}]:v,unicodeFontsURL:z,preResolvedFonts:G},K=>{re.fontLoad=h()-J;const Q=isFinite(T);let ue=null,le=null,_e=null,Fe=null,Ie=null,Ee=null,me=null,xe=null,$=0,Ue=0,Me=I!=="nowrap";const oe=new Map,Te=h();let Ye=E,Oe=0,j=new d;const Z=[j];K.forEach(ye=>{const{fontObj:Ae}=ye,{ascender:Ce,descender:Ge,unitsPerEm:De,lineGap:Ve,capHeight:ze,xHeight:Ze}=Ae;let Le=oe.get(Ae);if(!Le){const ve=y/De,be=C==="normal"?(Ce-Ge+Ve)*ve:C*y,Xe=(be-(Ce-Ge)*ve)/2,We=Math.min(be,(Ce-Ge)*ve),Be=(Ce+Ge)/2*ve+We/2;Le={index:oe.size,src:Ae.src,fontObj:Ae,fontSizeMult:ve,unitsPerEm:De,ascender:Ce*ve,descender:Ge*ve,capHeight:ze*ve,xHeight:Ze*ve,lineHeight:be,baseline:-Xe-Ce*ve,caretTop:Be,caretBottom:Be-We},oe.set(Ae,Le)}const{fontSizeMult:ot}=Le,tt=m.slice(ye.start,ye.end+1);let mt,ce;Ae.forEachGlyph(tt,y,M,(ve,be,Xe,We)=>{be+=Oe,We+=ye.start,mt=be,ce=ve;const Be=m.charAt(We),ut=ve.advanceWidth*ot,gt=j.count;let nt;if("isEmpty"in ve||(ve.isWhitespace=!!Be&&new RegExp(n).test(Be),ve.canBreakAfter=!!Be&&r.test(Be),ve.isEmpty=ve.xMin===ve.xMax||ve.yMin===ve.yMax||i.test(Be)),!ve.isWhitespace&&!ve.isEmpty&&Ue++,Me&&Q&&!ve.isWhitespace&&be+ut+Ye>T&>){if(j.glyphAt(gt-1).glyphObj.canBreakAfter)nt=new d,Ye=-be;else for(let at=gt;at--;)if(at===0&&R==="break-word"){nt=new d,Ye=-be;break}else if(j.glyphAt(at).glyphObj.canBreakAfter){nt=j.splitAt(at+1);const ft=nt.glyphAt(0).x;Ye-=ft;for(let Qe=nt.count;Qe--;)nt.glyphAt(Qe).x-=ft;break}nt&&(j.isSoftWrapped=!0,j=nt,Z.push(j),$=T)}let je=j.glyphAt(j.count);je.glyphObj=ve,je.x=be+Ye,je.y=Xe,je.width=ut,je.charIndex=We,je.fontData=Le,Be===` `&&(j=new d,Z.push(j),Ye=-(be+ut+M*y)+E)}),Oe=mt+ce.advanceWidth*ot+M*y});let pe=0;Z.forEach(ye=>{let Ae=!0;for(let Ce=ye.count;Ce--;){const Ge=ye.glyphAt(Ce);Ae&&!Ge.glyphObj.isWhitespace&&(ye.width=Ge.x+Ge.width,ye.width>$&&($=ye.width),Ae=!1);let{lineHeight:De,capHeight:Ve,xHeight:ze,baseline:Ze}=Ge.fontData;De>ye.lineHeight&&(ye.lineHeight=De);const Le=Ze-ye.baseline;Le<0&&(ye.baseline+=Le,ye.cap+=Le,ye.ex+=Le),ye.cap=Math.max(ye.cap,ye.baseline+Ve),ye.ex=Math.max(ye.ex,ye.baseline+ze)}ye.baseline-=pe,ye.cap-=pe,ye.ex-=pe,pe+=ye.lineHeight});let he=0,te=0;if(U&&(typeof U=="number"?he=-U:typeof U=="string"&&(he=-$*(U==="left"?0:U==="center"?.5:U==="right"?1:c(U)))),L&&(typeof L=="number"?te=-L:typeof L=="string"&&(te=L==="top"?0:L==="top-baseline"?-Z[0].baseline:L==="top-cap"?-Z[0].cap:L==="top-ex"?-Z[0].ex:L==="middle"?pe/2:L==="bottom"?pe:L==="bottom-baseline"?-Z[Z.length-1].baseline:c(L)*pe)),!k){const ye=e.getEmbeddingLevels(m,A);ue=new Uint16Array(Ue),le=new Uint8Array(Ue),_e=new Float32Array(Ue*2),Fe={},me=[1/0,1/0,-1/0,-1/0],xe=[],W&&(Ee=new Float32Array(m.length*4)),O&&(Ie=new Uint8Array(Ue*3));let Ae=0,Ce=-1,Ge=-1,De,Ve;if(Z.forEach((ze,Ze)=>{let{count:Le,width:ot}=ze;if(Le>0){let tt=0;for(let We=Le;We--&&ze.glyphAt(We).glyphObj.isWhitespace;)tt++;let mt=0,ce=0;if(P==="center")mt=($-ot)/2;else if(P==="right")mt=$-ot;else if(P==="justify"&&ze.isSoftWrapped){let We=0;for(let Be=Le-tt;Be--;)ze.glyphAt(Be).glyphObj.isWhitespace&&We++;ce=($-ot)/We}if(ce||mt){let We=0;for(let Be=0;Be=Be){let at=je,ft=je;for(;ftut)break;ftbe=We;for(let We=0;We1&&u(Ee,Ce,Qe),Ce=nt}if(O){const{charIndex:nt}=Be;for(;nt>Ge;)Ge++,O.hasOwnProperty(Ge)&&(Ve=O[Ge])}if(!be.isWhitespace&&!be.isEmpty){const nt=Ae++,{fontSizeMult:je,src:at,index:ft}=Be.fontData,Qe=Fe[at]||(Fe[at]={});Qe[ut]||(Qe[ut]={path:be.path,pathBounds:[be.xMin,be.yMin,be.xMax,be.yMax]});const bt=Be.x+he,yt=Be.y+ze.baseline+te;_e[nt*2]=bt,_e[nt*2+1]=yt;const Rt=bt+be.xMin*je,on=yt+be.yMin*je,zt=bt+be.xMax*je,Qt=yt+be.yMax*je;Rtme[2]&&(me[2]=zt),Qt>me[3]&&(me[3]=Qt),nt%q===0&&(De={start:nt,end:nt,rect:[1/0,1/0,-1/0,-1/0]},xe.push(De)),De.end++;const Kt=De.rect;if(RtKt[2]&&(Kt[2]=zt),Qt>Kt[3]&&(Kt[3]=Qt),ue[nt]=ut,le[nt]=ft,O){const nn=nt*3;Ie[nn]=Ve>>16&255,Ie[nn+1]=Ve>>8&255,Ie[nn+2]=Ve&255}}}}}),Ee){const ze=m.length-Ce;ze>1&&u(Ee,Ce,ze)}}const Se=[];oe.forEach(({index:ye,src:Ae,unitsPerEm:Ce,ascender:Ge,descender:De,lineHeight:Ve,capHeight:ze,xHeight:Ze})=>{Se[ye]={src:Ae,unitsPerEm:Ce,ascender:Ge,descender:De,lineHeight:Ve,capHeight:ze,xHeight:Ze}}),re.typesetting=h()-Te,B({glyphIds:ue,glyphFontIndices:le,glyphPositions:_e,glyphData:Fe,fontData:Se,caretPositions:Ee,glyphColors:Ie,chunkedBounds:xe,fontSize:y,topBaseline:te+Z[0].baseline,blockBounds:[he,te-pe,he+$,te],visibleBounds:me,timings:re})})}function l(m,v){a({...m,metricsOnly:!0},g=>{const[_,y,w,x]=g.blockBounds;v({width:w-_,height:x-y})})}function c(m){let v=m.match(/^([\d.]+)%$/),g=v?parseFloat(v[1]):NaN;return isNaN(g)?0:g/100}function u(m,v,g){const _=m[v*4],y=m[v*4+1],w=m[v*4+2],x=m[v*4+3],M=(y-_)/g;for(let C=0;C(Object.defineProperty(m,v,{get(){return this.data[this.index*f.length+g]},set(y){this.data[this.index*f.length+g]=y}}),m),{data:null,index:0}),{typeset:a,measure:l}}const bu=()=>(self.performance||Date).now(),V_=z_();let GI;function OX(s,e,t,i,n,r,o,a,l,c,u=!0){return u?NX(s,e,t,i,n,r,o,a,l,c).then(null,h=>(GI||(console.warn("WebGL SDF generation failed, falling back to JS",h),GI=!0),XI(s,e,t,i,n,r,o,a,l,c))):XI(s,e,t,i,n,r,o,a,l,c)}const G_=[],FX=5;let CS=0;function HI(){const s=bu();for(;G_.length&&bu()-snew Promise((e,t)=>{G_.push(()=>{const i=bu();try{V_.webgl.generateIntoCanvas(...s),e({timing:bu()-i})}catch(n){t(n)}}),CS||(CS=setTimeout(HI,0))}),BX=4,zX=2e3,WI={};let VX=0;function XI(s,e,t,i,n,r,o,a,l,c){const u="TroikaTextSDFGenerator_JS_"+VX++%BX;let h=WI[u];return h||(h=WI[u]={workerModule:Md({name:u,workerId:u,dependencies:[z_,bu],init(d,f){const m=d().javascript.generate;return function(...v){const g=f();return{textureData:m(...v),timing:f()-g}}},getTransferables(d){return[d.textureData.buffer]}}),requests:0,idleTimer:null}),h.requests++,clearTimeout(h.idleTimer),h.workerModule(s,e,t,i,n,r).then(({textureData:d,timing:f})=>{const m=bu(),v=new Uint8Array(d.length*4);for(let g=0;g{yX(u)},zX)),{timing:f}})}function GX(s){s._warm||(V_.webgl.isSupported(s),s._warm=!0)}const HX=V_.webglUtils.resizeWebGLCanvasWithoutClearing,Yp={unicodeFontsURL:null,sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},WX=new rt;function Ed(){return(self.performance||Date).now()}const YI=Object.create(null);function XX(s,e){s=jX({},s);const t=Ed(),i=[];if(s.font&&i.push({label:"user",src:qX(s.font)}),s.font=i,s.text=""+s.text,s.sdfGlyphSize=s.sdfGlyphSize||Yp.sdfGlyphSize,s.unicodeFontsURL=s.unicodeFontsURL||Yp.unicodeFontsURL,s.colorRanges!=null){let d={};for(let f in s.colorRanges)if(s.colorRanges.hasOwnProperty(f)){let m=s.colorRanges[f];typeof m!="number"&&(m=WX.set(m).getHex()),d[f]=m}s.colorRanges=d}Object.freeze(s);const{textureWidth:n,sdfExponent:r}=Yp,{sdfGlyphSize:o}=s,a=n/o*4;let l=YI[o];if(!l){const d=document.createElement("canvas");d.width=n,d.height=o*256/a,l=YI[o]={glyphCount:0,sdfGlyphSize:o,sdfCanvas:d,sdfTexture:new ni(d,void 0,void 0,void 0,bn,bn),contextLost:!1,glyphsByFont:new Map},l.sdfTexture.generateMipmaps=!1,YX(l)}const{sdfTexture:c,sdfCanvas:u}=l;ZI(s).then(d=>{const{glyphIds:f,glyphFontIndices:m,fontData:v,glyphPositions:g,fontSize:_,timings:y}=d,w=[],x=new Float32Array(f.length*4);let M=0,C=0;const T=Ed(),A=v.map(U=>{let L=l.glyphsByFont.get(U.src);return L||l.glyphsByFont.set(U.src,L=new Map),L});f.forEach((U,L)=>{const k=m[L],{src:z,unitsPerEm:G}=v[k];let W=A[k].get(U);if(!W){const{path:re,pathBounds:K}=d.glyphData[z][U],Q=Math.max(K[2]-K[0],K[3]-K[1])/o*(Yp.sdfMargin*o+.5),ue=l.glyphCount++,le=[K[0]-Q,K[1]-Q,K[2]+Q,K[3]+Q];A[k].set(U,W={path:re,atlasIndex:ue,sdfViewBox:le}),w.push(W)}const{sdfViewBox:q}=W,O=g[C++],B=g[C++],J=_/G;x[M++]=O+q[0]*J,x[M++]=B+q[1]*J,x[M++]=O+q[2]*J,x[M++]=B+q[3]*J,f[L]=W.atlasIndex}),y.quads=(y.quads||0)+(Ed()-T);const P=Ed();y.sdf={};const E=u.height,I=Math.ceil(l.glyphCount/a),R=Math.pow(2,Math.ceil(Math.log2(I*o)));R>E&&(console.info(`Increasing SDF texture size ${E}->${R}`),HX(u,n,R),c.dispose()),Promise.all(w.map(U=>jI(U,l,s.gpuAccelerateSDF).then(({timing:L})=>{y.sdf[U.atlasIndex]=L}))).then(()=>{w.length&&!l.contextLost&&(qI(l),c.needsUpdate=!0),y.sdfTotal=Ed()-P,y.total=Ed()-t,e(Object.freeze({parameters:s,sdfTexture:c,sdfGlyphSize:o,sdfExponent:r,glyphBounds:x,glyphAtlasIndices:f,glyphColors:d.glyphColors,caretPositions:d.caretPositions,chunkedBounds:d.chunkedBounds,ascender:d.ascender,descender:d.descender,lineHeight:d.lineHeight,capHeight:d.capHeight,xHeight:d.xHeight,topBaseline:d.topBaseline,blockBounds:d.blockBounds,visibleBounds:d.visibleBounds,timings:d.timings}))})}),Promise.resolve().then(()=>{l.contextLost||GX(u)})}function jI({path:s,atlasIndex:e,sdfViewBox:t},{sdfGlyphSize:i,sdfCanvas:n,contextLost:r},o){if(r)return Promise.resolve({timing:-1});const{textureWidth:a,sdfExponent:l}=Yp,c=Math.max(t[2]-t[0],t[3]-t[1]),u=Math.floor(e/4),h=u%(a/i)*i,d=Math.floor(u/(a/i))*i,f=e%4;return OX(i,i,s,t,c,l,n,h,d,f,o)}function YX(s){const e=s.sdfCanvas;e.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),s.contextLost=!0}),e.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),s.contextLost=!1;const i=[];s.glyphsByFont.forEach(n=>{n.forEach(r=>{i.push(jI(r,s,!0))})}),Promise.all(i).then(()=>{qI(s),s.sdfTexture.needsUpdate=!0})})}function jX(s,e){for(let t in e)e.hasOwnProperty(t)&&(s[t]=e[t]);return s}let H_;function qX(s){return H_||(H_=typeof document>"u"?{}:document.createElement("a")),H_.href=s,H_.href}function qI(s){if(typeof createImageBitmap!="function"){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:t}=s,{width:i,height:n}=e,r=s.sdfCanvas.getContext("webgl");let o=t.image.data;(!o||o.length!==i*n*4)&&(o=new Uint8Array(i*n*4),t.image={width:i,height:n,data:o},t.flipY=!1,t.isDataTexture=!0),r.readPixels(0,0,i,n,r.RGBA,r.UNSIGNED_BYTE,o)}}const ZI=Md({name:"Typesetter",dependencies:[Md({name:"Typesetter",dependencies:[kX,UX,OI],init(s,e,t){return s(e,t())}})],init(s){return function(e){return new Promise(t=>{s.typeset(e,t)})}},getTransferables(s){const e=[];for(let t in s)s[t]&&s[t].buffer&&e.push(s[t].buffer);return e}});ZI.onMainThread;const KI={};function ZX(s){let e=KI[s];return e||(e=KI[s]=new es(1,1,s,s).translate(.5,.5,0)),e}const KX="aTroikaGlyphBounds",$I="aTroikaGlyphIndex",$X="aTroikaGlyphColor";let JX=class extends _p{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new fi,this.boundingBox=new yn}computeBoundingSphere(){}computeBoundingBox(){}set detail(e){if(e!==this._detail){this._detail=e,(typeof e!="number"||e<1)&&(e=1);let t=ZX(e);["position","normal","uv"].forEach(i=>{this.attributes[i]=t.attributes[i].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,i,n,r){this.updateAttributeData(KX,e,4),this.updateAttributeData($I,t,1),this.updateAttributeData($X,r,3),this._blockBounds=i,this._chunkedBounds=n,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:i}=this;if(t){const{PI:n,floor:r,min:o,max:a,sin:l,cos:c}=Math,u=n/2,h=n*2,d=Math.abs(t),f=e[0]/d,m=e[2]/d,v=r((f+u)/h)!==r((m+u)/h)?-d:o(l(f)*d,l(m)*d),g=r((f-u)/h)!==r((m-u)/h)?d:a(l(f)*d,l(m)*d),_=r((f+n)/h)!==r((m+n)/h)?d*2:a(d-c(f)*d,d-c(m)*d);i.min.set(v,e[1],t<0?-_:0),i.max.set(g,e[3],t<0?0:_)}else i.min.set(e[0],e[1],0),i.max.set(e[2],e[3],0);i.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute($I).count,i=this._chunkedBounds;if(i)for(let n=i.length;n--;){t=i[n].end;let r=i[n].rect;if(r[1]e.y&&r[0]e.x)break}this.instanceCount=t}updateAttributeData(e,t,i){const n=this.getAttribute(e);t?n&&n.array.length===t.length?(n.array.set(t),n.needsUpdate=!0):(this.setAttribute(e,new Zo(t,i)),delete this._maxInstanceCount,this.dispose()):n&&this.deleteAttribute(e)}};const QX=` uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform vec4 uTroikaTotalBounds; uniform vec4 uTroikaClipRect; uniform mat3 uTroikaOrient; uniform bool uTroikaUseGlyphColors; uniform float uTroikaEdgeOffset; uniform float uTroikaBlurRadius; uniform vec2 uTroikaPositionOffset; uniform float uTroikaCurveRadius; attribute vec4 aTroikaGlyphBounds; attribute float aTroikaGlyphIndex; attribute vec3 aTroikaGlyphColor; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec3 vTroikaGlyphColor; varying vec2 vTroikaGlyphDimensions; `,e9=` vec4 bounds = aTroikaGlyphBounds; bounds.xz += uTroikaPositionOffset.x; bounds.yw -= uTroikaPositionOffset.y; vec4 outlineBounds = vec4( bounds.xy - uTroikaEdgeOffset - uTroikaBlurRadius, bounds.zw + uTroikaEdgeOffset + uTroikaBlurRadius ); vec4 clippedBounds = vec4( clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw), clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw) ); vec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy); position.xy = mix(bounds.xy, bounds.zw, clippedXY); uv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy); float rad = uTroikaCurveRadius; if (rad != 0.0) { float angle = position.x / rad; position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad); normal.xz = vec2(sin(angle), cos(angle)); } position = uTroikaOrient * position; normal = uTroikaOrient * normal; vTroikaGlyphUV = clippedXY.xy; vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]); float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize; vec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize; vec2 txStartUV = txUvPerSquare * vec2( mod(floor(aTroikaGlyphIndex / 4.0), txCols), floor(floor(aTroikaGlyphIndex / 4.0) / txCols) ); vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare); vTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0); `,t9=` uniform sampler2D uTroikaSDFTexture; uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform float uTroikaSDFExponent; uniform float uTroikaEdgeOffset; uniform float uTroikaFillOpacity; uniform float uTroikaBlurRadius; uniform vec3 uTroikaStrokeColor; uniform float uTroikaStrokeWidth; uniform float uTroikaStrokeOpacity; uniform bool uTroikaSDFDebug; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec2 vTroikaGlyphDimensions; float troikaSdfValueToSignedDistance(float alpha) { // Inverse of exponential encoding in webgl-sdf-generator float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y); float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension; float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0); return signedDist; } float troikaGlyphUvToSdfValue(vec2 glyphUV) { vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV); vec4 rgba = texture2D(uTroikaSDFTexture, textureUV); float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1 return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a; } float troikaGlyphUvToDistance(vec2 uv) { return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv)); } float troikaGetAADist() { #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300 return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5; #else return vTroikaGlyphDimensions.x / 64.0; #endif } float troikaGetFragDistValue() { vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize); float distance = troikaGlyphUvToDistance(clampedGlyphUV); // Extrapolate distance when outside bounds: distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions); return distance; } float troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) { #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL) float alpha = step(-distanceOffset, -distance); #else float alpha = smoothstep( distanceOffset + aaDist, distanceOffset - aaDist, distance ); #endif return alpha; } `,n9=` float aaDist = troikaGetAADist(); float fragDistance = troikaGetFragDistValue(); float edgeAlpha = uTroikaSDFDebug ? troikaGlyphUvToSdfValue(vTroikaGlyphUV) : troikaGetEdgeAlpha(fragDistance, uTroikaEdgeOffset, max(aaDist, uTroikaBlurRadius)); #if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL) vec4 fillRGBA = gl_FragColor; fillRGBA.a *= uTroikaFillOpacity; vec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity); if (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb; gl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep( -uTroikaStrokeWidth - aaDist, -uTroikaStrokeWidth + aaDist, fragDistance )); gl_FragColor.a *= edgeAlpha; #endif if (edgeAlpha == 0.0) { discard; } `;function i9(s){const e=AS(s,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new Ne},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new Zt(0,0,0,0)},uTroikaClipRect:{value:new Zt(0,0,0,0)},uTroikaEdgeOffset:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new Ne},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new rt},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new Jt},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:QX,vertexTransform:e9,fragmentDefs:t9,fragmentColorTransform:n9,customRewriter({vertexShader:t,fragmentShader:i}){let n=/\buniform\s+vec3\s+diffuse\b/;return n.test(i)&&(i=i.replace(n,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),n.test(t)||(t=t.replace(FI,`uniform vec3 diffuse; $& vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse; `))),{vertexShader:t,fragmentShader:i}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const PS=new Jn({color:16777215,side:Ei,transparent:!0}),JI=8421504,QI=new _t,W_=new X,RS=new X,jp=[],r9=new X,DS="+x+y";function eL(s){return Array.isArray(s)?s[0]:s}let tL=()=>{const s=new it(new es(1,1),PS);return tL=()=>s,s},nL=()=>{const s=new it(new es(1,1,32,1),PS);return nL=()=>s,s};const s9={type:"syncstart"},o9={type:"synccomplete"},iL=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],a9=iL.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let ci=class extends it{constructor(){const e=new JX;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=JI,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=DS,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(s9),XX({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const i=this._queuedSyncs;i&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{i.forEach(n=>n&&n())})),this.dispatchEvent(o9),e&&e()})))}onBeforeRender(e,t,i,n,r,o){this.sync(),r.isTroikaTextMaterial&&this._prepareForRender(r)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return i9(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=PS.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function i(){t.removeEventListener("dispose",i),e.dispose()})),this.hasOutline()){let i=e._outlineMtl;return i||(i=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),i.isTextOutlineMaterial=!0,i.depthWrite=!1,i.map=null,e.addEventListener("dispose",function n(){e.removeEventListener("dispose",n),i.dispose()})),[i,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return eL(this.material).getDepthMaterial()}get customDistanceMaterial(){return eL(this.material).getDistanceMaterial()}_prepareForRender(e){const t=e.isTextOutlineMaterial,i=e.uniforms,n=this.textRenderInfo;if(n){const{sdfTexture:a,blockBounds:l}=n;i.uTroikaSDFTexture.value=a,i.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),i.uTroikaSDFGlyphSize.value=n.sdfGlyphSize,i.uTroikaSDFExponent.value=n.sdfExponent,i.uTroikaTotalBounds.value.fromArray(l),i.uTroikaUseGlyphColors.value=!t&&!!n.glyphColors;let c=0,u=0,h=0,d,f,m,v=0,g=0;if(t){let{outlineWidth:y,outlineOffsetX:w,outlineOffsetY:x,outlineBlur:M,outlineOpacity:C}=this;c=this._parsePercent(y)||0,u=Math.max(0,this._parsePercent(M)||0),d=C,v=this._parsePercent(w)||0,g=this._parsePercent(x)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(m=this.strokeColor,i.uTroikaStrokeColor.value.set(m??JI),f=this.strokeOpacity,f==null&&(f=1)),d=this.fillOpacity;i.uTroikaEdgeOffset.value=c,i.uTroikaPositionOffset.value.set(v,g),i.uTroikaBlurRadius.value=u,i.uTroikaStrokeWidth.value=h,i.uTroikaStrokeOpacity.value=f,i.uTroikaFillOpacity.value=d??1,i.uTroikaCurveRadius.value=this.curveRadius||0;let _=this.clipRect;if(_&&Array.isArray(_)&&_.length===4)i.uTroikaClipRect.value.fromArray(_);else{const y=(this.fontSize||.1)*100;i.uTroikaClipRect.value.set(l[0]-y,l[1]-y,l[2]+y,l[3]+y)}this.geometry.applyClipRect(i.uTroikaClipRect.value)}i.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const r=t?this.outlineColor||0:this.color;if(r==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new rt;(r!==a._input||typeof r=="object")&&a.set(a._input=r)}let o=this.orientation||DS;if(o!==e._orientation){let a=i.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let l=o!==DS&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,u,h,d]=l;W_.set(0,0,0)[u]=c==="-"?1:-1,RS.set(0,0,0)[d]=h==="-"?-1:1,QI.lookAt(r9,W_.cross(RS),RS),a.setFromMatrix4(QI)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),i=t?parseFloat(t[1]):NaN;e=(isNaN(i)?0:i/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new Ne){t.copy(e);const i=this.curveRadius;return i&&(t.x=Math.atan2(e.x,Math.abs(i)-Math.abs(e.z))*Math.abs(i)),t}worldPositionToTextCoords(e,t=new Ne){return W_.copy(e),this.localPositionToTextCoords(this.worldToLocal(W_),t)}raycast(e,t){const{textRenderInfo:i,curveRadius:n}=this;if(i){const r=i.blockBounds,o=n?nL():tL(),a=o.geometry,{position:l,uv:c}=a.attributes;for(let u=0;u{this[i]=e[i]}),this}clone(){return new this.constructor().copy(this)}};iL.forEach(s=>{const e="_private_"+s;Object.defineProperty(ci.prototype,s,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})}),new yn,new rt;class l9{constructor(e){var t;this._charts=new Map,this._width=400,this._height=110,this._backgroundOpacity=.7,this._perf=e.perf,this._backgroundOpacity=(t=e.backgroundOpacity)!=null?t:this._backgroundOpacity,this.wrapper=document.createElement("div"),this.wrapper.id="three-perf-ui",this.wrapper.style.position="fixed",this.wrapper.style.bottom="0",this.wrapper.style.left="0",this.wrapper.style.width=this._width+"px",this.wrapper.style.height=this._height+"px",e.domElement.appendChild(this.wrapper),this.canvas=document.createElement("canvas"),this.canvas.width=this._width,this.canvas.height=this._height,this.canvas.style.position="absolute",this.wrapper.appendChild(this.canvas),this.initCanvas()}setScale(e){this.wrapper.style.width=e*this.width+"px",this.wrapper.style.height=e*this.height+"px",this._renderer.setSize(this._width*e,this._height*e,!0)}initCanvas(){this._renderer=new J1({canvas:this.canvas,antialias:!0,alpha:!0}),this._renderer.setClearColor(0,this._backgroundOpacity),this._renderer.setPixelRatio(window.devicePixelRatio),this._scene=new Kf,this._camera=new Ta(0,this._width,0,-this._height,.1,100),this._camera.position.set(0,0,10),this._camera.lookAt(0,0,0),this._camera.updateProjectionMatrix(),this._scene.add(this._camera),this._scene.userData.useStats=!1;const e=new ci;e.anchorX="right",e.position.set(45,-8,0),e.text="0.000",e.fontSize=15,e.color="rgb(253, 151, 31)",e.sync(),this._scene.add(e);const t=new ci;t.anchorX="right",t.position.set(65,-7,0),t.text="ms",t.fontSize=9,t.color="rgb(255, 255, 255)",t.sync(),this._scene.add(t);const i=new ci;i.anchorX="right",i.position.set(65,-22,0),i.text="GPU",i.fontSize=9,i.color="rgb(253, 151, 31)",i.sync(),this._scene.add(i);const n=new ci;n.anchorX="right",n.position.set(115,-8,0),n.text="0.000",n.fontSize=15,n.color="rgb(66, 226, 46)",n.sync(),this._scene.add(n);const r=new ci;r.anchorX="right",r.position.set(135,-7,0),r.text="ms",r.fontSize=9,r.color="rgb(255, 255, 255)",r.sync(),this._scene.add(r);const o=new ci;o.anchorX="right",o.position.set(135,-22,0),o.text="CPU",o.fontSize=9,o.color="rgb(66, 226, 46)",o.sync(),this._scene.add(o);const a=new ci;a.anchorX="center",a.position.set(165,-8,0),a.text="0",a.fontSize=15,a.color="rgb(238, 38, 110)",a.sync(),this._scene.add(a);const l=new ci;l.anchorX="center",l.position.set(175,-22,0),l.text="FPS",l.fontSize=9,l.color="rgb(238, 38, 110)",l.sync(),this._scene.add(l);const c=new ci;c.anchorX="right",c.position.set(235,-8,0),c.text="0",c.fontSize=15,c.color="#ffffff",c.sync(),this._scene.add(c);const u=new ci;u.anchorX="right",u.position.set(235,-22,0),u.text="calls",u.fontSize=9,u.color="rgb(101, 197, 188)",u.sync(),this._scene.add(u);const h=new ci;h.anchorX="right",h.position.set(315,-8,0),h.text="0",h.fontSize=15,h.color="#ffffff",h.sync(),this._scene.add(h);const d=new ci;d.anchorX="right",d.position.set(315,-22,0),d.text="triangles",d.fontSize=9,d.color="rgb(101, 197, 188)",d.sync(),this._scene.add(d);const f=new ci;f.anchorX="right",f.position.set(365,-8,0),f.text="0",f.fontSize=15,f.color="#ffffff",f.sync(),this._scene.add(f);const m=new ci;m.anchorX="right",m.position.set(365,-22,0),m.text="passes",m.fontSize=9,m.color="rgb(101, 197, 188)",m.sync(),this._scene.add(m),this._basicInfoElements={gpuValue:e,cpuValue:n,fpsValue:a,callsValue:c,trianglesValue:h,renderpassesValue:f};const v=new ci;v.anchorX="right",v.position.set(65,-39,0),v.text="0",v.fontSize=15,v.color="#ffffff",v.sync(),this._scene.add(v);const g=new ci;g.anchorX="right",g.position.set(65,-53,0),g.text="geometries",g.fontSize=9,g.color="rgb(101, 197, 188)",g.sync(),this._scene.add(g);const _=new ci;_.anchorX="right",_.position.set(135,-39,0),_.text="0",_.fontSize=15,_.color="#ffffff",_.sync(),this._scene.add(_);const y=new ci;y.anchorX="right",y.position.set(135,-53,0),y.text="textures",y.fontSize=9,y.color="rgb(101, 197, 188)",y.sync(),this._scene.add(y);const w=new ci;w.anchorX="right",w.position.set(205,-39,0),w.text="0",w.fontSize=15,w.color="#ffffff",w.sync(),this._scene.add(w);const x=new ci;x.anchorX="right",x.position.set(205,-53,0),x.text="shaders",x.fontSize=9,x.color="rgb(101, 197, 188)",x.sync(),this._scene.add(x);const M=new ci;M.anchorX="right",M.position.set(275,-39,0),M.text="0",M.fontSize=15,M.color="#ffffff",M.sync(),this._scene.add(M);const C=new ci;C.anchorX="right",C.position.set(275,-53,0),C.text="lines",C.fontSize=9,C.color="rgb(101, 197, 188)",C.sync(),this._scene.add(C);const T=new ci;T.anchorX="right",T.position.set(345,-39,0),T.text="0",T.fontSize=15,T.color="#ffffff",T.sync(),this._scene.add(T);const A=new ci;A.anchorX="right",A.position.set(345,-53,0),A.text="points",A.fontSize=9,A.color="rgb(101, 197, 188)",A.sync(),this._scene.add(A),this._memInfoElements={geometriesValue:v,geometriesLabel:g,texturesValue:_,texturesLabel:y,shadersValue:w,shadersLabel:x,linesValue:M,linesLabel:C,pointsValue:T,pointsLabel:A};const P=new Gt;let E=new Float32Array(60*3);for(let G=0;G<60;G++)E[3*G+0]=this._width/59*G,E[3*G+1]=-110,E[3*G+2]=0;let I=new Bt(E,3);I.usage=Ph,P.setAttribute("position",I);const R=new Gi(P,new Vi({color:"rgb(253, 151, 31)"}));this._scene.add(R),this._charts.set("gpu",R);const U=new Gt;E=new Float32Array(60*3);for(let G=0;G<60;G++)E[3*G+0]=this._width/59*G,E[3*G+1]=-110,E[3*G+2]=0;I=new Bt(E,3),I.usage=Ph,U.setAttribute("position",I);const L=new Gi(U,new Vi({color:"rgb(66, 226, 46)"}));this._scene.add(L),this._charts.set("cpu",L);const k=new Gt;E=new Float32Array(60*3);for(let G=0;G<60;G++)E[3*G+0]=this._width/59*G,E[3*G+1]=-110,E[3*G+2]=0;I=new Bt(E,3),I.usage=Ph,k.setAttribute("position",I);const z=new Gi(k,new Vi({color:"rgb(238, 38, 110)"}));this._scene.add(z),this._charts.set("fps",z)}update(){var e,t;if(this._perf.chart&&this._perf.showGraph)for(const i in this._perf.chart.data){const n=this._perf.chart.data[i];if(!this._charts.get(i)||!n)continue;const o=this._charts.get(i).geometry.attributes.position;let a=0;for(let l=0;la&&(a=n[l]);a=Math.max(a,20);for(let l=0;l{t.visible=e}),this._perf.showGraph?this.height=this._perf.memory?110:70:this.height=this._perf.memory?70:40,this.wrapper.style.height=this._perf.scale*this.height+"px"}toggleMemoryInfo(e){for(const t in this._memInfoElements)this._memInfoElements[t].visible=e;this.width=380,this._perf.showGraph?this.height=this._perf.memory?110:70:this.height=this._perf.memory?70:40,this.wrapper.style.width=this._perf.scale*this.width+"px",this.wrapper.style.height=this._perf.scale*this.height+"px"}setBackgroundOpacity(e){this._backgroundOpacity=e,this._renderer.setClearColor(0,this._backgroundOpacity),this.render()}get width(){return this._width}set width(e){this._width=e,this._camera.right=e,this._camera.updateProjectionMatrix(),this._renderer.setSize(this._perf.scale*this._width,this._perf.scale*this._height),this.render()}get height(){return this._height}set height(e){this._height=e,this._camera.bottom=-e,this._camera.updateProjectionMatrix(),this._renderer.setSize(this._perf.scale*this._width,this._perf.scale*this._height),this.render()}}const ta={value:0,fpsLimit:60,isOverLimit:0},qp=s=>(s==null?void 0:s.reduce((e,t)=>e+t,0))/s.length;class c9{constructor(e){this.names=[""],this.finished=[],this.paused=!1,this.overClock=!1,this.queryHasResult=!1,this.queryCreated=!1,this.isWebGL2=!0,this.memAccums=[],this.gpuAccums=[],this.activeAccums=[],this.logsAccums={mem:[],gpu:[],cpu:[],fps:[],fpsFixed:[]},this.fpsChart=[],this.gpuChart=[],this.cpuChart=[],this.memChart=[],this.paramLogger=()=>{},this.glFinish=()=>{},this.chartLogger=()=>{},this.chartLen=60,this.logsPerSecond=10,this.maxMemory=1500,this.chartHz=10,this.startCpuProfiling=!1,this.lastCalculateFixed=0,this.chartFrame=0,this.gpuTimeProcess=0,this.chartTime=0,this.activeQueries=0,this.circularId=0,this.detected=0,this.frameId=0,this.rafId=0,this.idleCbId=0,this.checkQueryId=0,this.uuid=void 0,this.currentCpu=0,this.currentMem=0,this.paramFrame=0,this.paramTime=0,this.now=()=>{},this.t0=0,this.nextFps=t=>{const i=16.666666666666668,n=i-t.timeRemaining(),r=i*ta.fpsLimit/10/n;r<0||(ta.value=r,ta.isOverLimit<25?ta.isOverLimit++:this.perf.overclockingFps=!0)},this.nextFrame=t=>{this.frameId++;const i=t||this.now();let n=i-this.paramTime,r=0;if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=i;else if(i>=this.paramTime){this.maxMemory=window.performance.memory?window.performance.memory.jsHeapSizeLimit/1048576:0;const o=this.frameId-this.paramFrame,a=o*1e3/n,l=this.perf.overclockingFps?ta.value:a;if(r=this.isWebGL2?this.gpuAccums[0]:this.gpuAccums[0]/n,this.isWebGL2?this.gpuAccums[0]=0:Promise.all(this.finished).then(()=>{this.gpuAccums[0]=0,this.finished=[]}),this.currentMem=Math.round(window.performance&&window.performance.memory?window.performance.memory.usedJSHeapSize/1048576:0),window.performance&&this.startCpuProfiling){window.performance.mark("cpu-finished");const c=performance.measure("cpu-duration","cpu-started","cpu-finished");this.currentCpu=c.duration,this.logsAccums.cpu.push(this.currentCpu),this.startCpuProfiling=!1}this.logsAccums.mem.push(this.currentMem),this.logsAccums.fpsFixed.push(a),this.logsAccums.fps.push(l),this.logsAccums.gpu.push(r),this.overClock&&typeof window.requestIdleCallback<"u"&&(ta.isOverLimit>0&&l>a?ta.isOverLimit--:this.perf.overclockingFps&&(this.perf.overclockingFps=!1)),i>=this.paramTime+1e3/this.logsPerSecond&&(this.paramLogger({cpu:qp(this.logsAccums.cpu),gpu:qp(this.logsAccums.gpu),mem:qp(this.logsAccums.mem),fps:qp(this.logsAccums.fps),duration:Math.round(n),maxMemory:this.maxMemory,frameCount:o}),this.logsAccums.mem=[],this.logsAccums.fps=[],this.logsAccums.gpu=[],this.logsAccums.cpu=[],this.paramFrame=this.frameId,this.paramTime=i),this.overClock&&i-this.lastCalculateFixed>=2*1e3&&(this.lastCalculateFixed=t,ta.fpsLimit=Math.round(qp(this.logsAccums.fpsFixed)/10)*100,this.perf.fpsLimit=ta.fpsLimit/10,this.logsAccums.fpsFixed=[],this.paramFrame=this.frameId,this.paramTime=i)}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=i,this.circularId=0;else{const o=i-this.chartTime;let a=this.chartHz*o/1e3;for(;--a>0&&this.detected;){const c=(this.frameId-this.chartFrame)/o*1e3,u=this.perf.overclockingFps?ta.value:c;this.fpsChart[this.circularId%this.chartLen]=u;const h=1e3/this.currentMem,d=this.currentCpu,f=(this.isWebGL2?this.gpuAccums[1]*2:Math.round(this.gpuAccums[1]/n*100))+4;f>0&&(this.gpuChart[this.circularId%this.chartLen]=f),d>0&&(this.cpuChart[this.circularId%this.chartLen]=d),h>0&&(this.memChart[this.circularId%this.chartLen]=h);for(let m=0;mwindow.performance&&window.performance.now?window.performance.now():Date.now(),this.initGpu(),this.is120hz()}initGpu(){this.uuid=qi.generateUUID(),this.gl&&(this.isWebGL2=!0,this.extension||(this.extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")),this.extension===null&&(this.isWebGL2=!1))}is120hz(){let e=0;const t=i=>{++e<20?this.rafId=window.requestAnimationFrame(t):(this.detected=Math.ceil(1e3*e/(i-this.t0)/70),window.cancelAnimationFrame(this.rafId)),this.t0||(this.t0=i)};this.rafId=window.requestAnimationFrame(t)}addUI(e){this.names.indexOf(e)===-1&&(this.names.push(e),this.gpuAccums.push(0),this.activeAccums.push(!1))}startGpu(){const e=this.gl,t=this.extension;if(!(!e||!t)&&this.isWebGL2){let i=!1,n,r;if(this.query){this.queryHasResult=!1;let o=this.query;if(i=e.getQueryParameter(o,e.QUERY_RESULT_AVAILABLE),n=e.getParameter(t.GPU_DISJOINT_EXT),i&&!n){r=e.getQueryParameter(this.query,e.QUERY_RESULT);const a=r*1e-6;(i||n)&&(e.deleteQuery(this.query),o=null),i&&a>0&&(n||this.activeAccums.forEach((l,c)=>{this.gpuAccums[c]=a}))}}(i||!this.query)&&(this.queryCreated=!0,this.query=e.createQuery(),e.beginQuery(t.TIME_ELAPSED_EXT,this.query))}}endGpu(){const e=this.extension,t=this.gl;this.isWebGL2&&this.queryCreated&&t.getQuery(e.TIME_ELAPSED_EXT,t.CURRENT_QUERY)&&t.endQuery(e.TIME_ELAPSED_EXT)}begin(e){this.startGpu(),this.updateAccums(e)}end(e){this.endGpu(),this.updateAccums(e)}updateAccums(e){let t=this.names.indexOf(e);t===-1&&(t=this.names.length,this.addUI(e));const i=this.now();this.activeAccums[t]=!this.activeAccums[t],this.t0=i}}tn.prototype.updateMatrixWorld,tn.prototype.updateWorldMatrix,tn.prototype.updateMatrix;const rL=["calls","triangles","points","lines"],sL=["gpu","cpu","mem","fps"];class u9{constructor(e){var t,i,n,r,o,a,l,c,u,h,d,f;this.gui=new pX.Pane,this.accumulated={totalFrames:0,log:{i:0,maxMemory:0,gpu:0,mem:0,cpu:0,fps:0,duration:0,frameCount:0},gl:{calls:0,triangles:0,points:0,lines:0,counts:0},max:{log:{i:0,maxMemory:0,gpu:0,mem:0,cpu:0,fps:0,duration:0,frameCount:0},gl:{calls:0,triangles:0,points:0,lines:0,counts:0}}},this.renderPassesNumber=0,this._keypressed="",this._guiVisible=!0,this.actionToCallUI="dev",this.keypressHandler=M=>{if(!this.actionToCallUI)return;this._keypressed+=M.key;const C=this._keypressed.split("");for(;C.length>this.actionToCallUI.length;)C.shift();C.join("")===this.actionToCallUI&&(this._keypressed="",this.guiVisible=!this.guiVisible)},this.afterRender=()=>{this._enabled&&(this.perfEngine.paused||(this.perfEngine.nextFrame(window.performance.now()),this.perfEngine.overClock&&typeof window.requestIdleCallback<"u"&&(this.perfEngine.idleCbId=requestIdleCallback(this.perfEngine.nextFps))),this.perfEngine&&this.perfEngine.end("profiler"),window.performance&&(window.performance.mark("cpu-started"),this.perfEngine.startCpuProfiling=!0),this.deepAnalyze)},this.deepAnalyze=(t=e.deepAnalyze)!=null?t:!1,this.threeRenderer=e.renderer,this.ui=new l9({perf:this,domElement:e.domElement,backgroundOpacity:e.backgroundOpacity}),this._visible=(i=e.visible)!=null?i:!0,this._enabled=(n=e.enabled)!=null?n:!0,this.scale=(r=e.scale)!=null?r:1,this.anchorX=(o=e.anchorX)!=null?o:"left",this.anchorY=(a=e.anchorY)!=null?a:"top",this.showGraph=(l=e.showGraph)!=null?l:!0,this.memory=(c=e.memory)!=null?c:!0,this.actionToCallUI=(u=e.actionToCallUI)!=null?u:"",this.guiVisible=(h=e.guiVisible)!=null?h:!1,this.gui.element.parentElement.style.width="300px",window.addEventListener("keypress",this.keypressHandler);const m=(d=e.overClock)!=null?d:!0;this.perfEngine=new c9({perf:this,trackGPU:!0,overClock:m,chartLen:120,chartHz:60,logsPerSecond:(f=e.logsPerSecond)!=null?f:10,gl:e.renderer.getContext(),chartLogger:M=>{this.chart=M},paramLogger:M=>{if(!this._enabled)return;const C={maxMemory:M.maxMemory,gpu:M.gpu,cpu:M.cpu,mem:M.mem,fps:M.fps,totalTime:M.duration,frameCount:M.frameCount};this.log=C;const T=this.accumulated,A=this.threeRenderer.info.render;T.totalFrames++,T.gl.calls+=A.calls,T.gl.triangles+=A.triangles,T.gl.points+=A.points,T.gl.lines+=A.lines,T.log.gpu+=M.gpu,T.log.cpu+=M.cpu,T.log.mem+=M.mem,T.log.fps+=M.fps;for(let P=0;PT.max.gl[E]&&(T.max.gl[E]=I)}for(let P=0;PT.max.log[E]&&(T.max.log[E]=I)}this.accumulated=T,this.ui.update()}});const v=e.renderer.getContext();let g=null,_=null;const y=v.getExtension("WEBGL_debug_renderer_info"),w=v.getParameter(v.VERSION);y!=null&&(g=v.getParameter(y.UNMASKED_RENDERER_WEBGL),_=v.getParameter(y.UNMASKED_VENDOR_WEBGL)),_||(_="Unknown vendor"),g||(g=v.getParameter(v.RENDERER)),this.startTime=performance.now(),this.infos={version:w,renderer:g,vendor:_},this.rendererRender=this.threeRenderer.render,this.threeRenderer.info.autoReset=!1,this.threeRenderer.render=(M,C)=>{this.renderPassesNumber++,this.rendererRender.call(this.threeRenderer,M,C)},this.guiFolder=this.gui.addFolder({title:"Settings"});const x=this.guiFolder.addFolder({title:"ThreePerf"});x.addInput(this,"visible",{label:"Visible"}),x.addInput(this,"enabled",{label:"Enabled"}),x.addInput(this,"anchorX",{label:"xAnchor",options:{left:"left",right:"right"}}),x.addInput(this,"anchorY",{label:"yAnchor",options:{top:"top",bottom:"bottom"}}),x.addInput(this,"backgroundOpacity",{label:"Background opacity",min:0,max:1,step:.1}),x.addInput(this,"memory",{label:"Memory"}),x.addInput(this,"showGraph",{label:"Charts"}),x.addInput(this,"scale",{label:"Scale",min:.1,max:2,step:.1}),x.addInput(this,"logsPerSecond",{label:"LogsPerSecond",min:1,max:60,step:1}),console.log("ThreePerf inited.")}begin(){this.perfEngine.begin("profiler")}end(){this.afterRender(),this.renderPassesNumber=0,this.threeRenderer.info.reset()}dispose(){var e;this.ui.dispose(),(e=this.gui.element.parentElement)==null||e.remove(),window.removeEventListener("keypress",this.keypressHandler)}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get visible(){return this._visible}set visible(e){this._visible=e,this.ui.toggleVisibility(e)}get guiVisible(){return this._guiVisible}set guiVisible(e){this._guiVisible=e,this.gui.element.parentElement.style.display=e?"block":"none"}get anchorX(){return this._anchorX}set anchorX(e){this._anchorX=e,this._anchorX==="left"?(this.ui.wrapper.style.left="0",this.ui.wrapper.style.right=""):(this.ui.wrapper.style.left="",this.ui.wrapper.style.right="0")}get anchorY(){return this._anchorY}set anchorY(e){this._anchorY=e,this._anchorY==="top"?(this.ui.wrapper.style.top="0",this.ui.wrapper.style.bottom=""):(this.ui.wrapper.style.top="",this.ui.wrapper.style.bottom="0")}get showGraph(){return this._showGraph}set showGraph(e){this._showGraph=e,this.ui.toggleCharts(e)}get memory(){return this._memory}set memory(e){this._memory=e,this.ui.toggleMemoryInfo(e)}get scale(){return this._scale}set scale(e){this._scale=e,this.ui.setScale(e)}get logsPerSecond(){return this.perfEngine.logsPerSecond}set logsPerSecond(e){this.perfEngine.logsPerSecond=e}get backgroundOpacity(){return this.ui._backgroundOpacity}set backgroundOpacity(e){this.ui.setBackgroundOpacity(e)}}function oL(s,e){if(new.target)return Tt({component:oL,...s});Mt(e,!0);let t=H(e,"domElement",23,()=>document.body),i=H(e,"logsPerSecond",7,10),n=H(e,"showGraph",7,!0),r=H(e,"memory",7,!0),o=H(e,"enabled",7,!0),a=H(e,"visible",7,!0),l=H(e,"actionToCallUI",7,""),c=H(e,"guiVisible",7,!1),u=H(e,"backgroundOpacity",7,.7),h=H(e,"scale",7,1),d=H(e,"anchorX",7,"left"),f=H(e,"anchorY",7,"top");const{renderer:m,renderStage:v,mainStage:g}=un();let _;return $e(()=>{t(),_==null||_.dispose(),_=new u9({domElement:t(),renderer:m})}),$e(()=>{_.logsPerSecond=i(),_.showGraph=n(),_.memory=r(),_.enabled=o(),_.visible=a(),_.actionToCallUI=l(),_.guiVisible=c(),_.backgroundOpacity=u(),_.scale=h(),_.anchorX=d(),_.anchorY=f()}),ii(()=>{_.begin()},{stage:hu("monitor-begin",{before:g})}),ii(()=>{_.end()},{stage:hu("monitor-end",{after:v})}),Ui(()=>{_&&_.dispose()}),Et({get domElement(){return t()},set domElement(y=document.body){t(y),V()},get logsPerSecond(){return i()},set logsPerSecond(y=10){i(y),V()},get showGraph(){return n()},set showGraph(y=!0){n(y),V()},get memory(){return r()},set memory(y=!0){r(y),V()},get enabled(){return o()},set enabled(y=!0){o(y),V()},get visible(){return a()},set visible(y=!0){a(y),V()},get actionToCallUI(){return l()},set actionToCallUI(y=""){l(y),V()},get guiVisible(){return c()},set guiVisible(y=!1){c(y),V()},get backgroundOpacity(){return u()},set backgroundOpacity(y=.7){u(y),V()},get scale(){return h()},set scale(y=1){h(y),V()},get anchorX(){return d()},set anchorX(y="left"){d(y),V()},get anchorY(){return f()},set anchorY(y="top"){f(y),V()},$set:Ct,$on:(y,w)=>At(e,y,w)})}Pt(oL,{domElement:{},logsPerSecond:{},showGraph:{},memory:{},enabled:{},visible:{},actionToCallUI:{},guiVisible:{},backgroundOpacity:{},scale:{},anchorX:{},anchorY:{}},[],[],!0);const h9=` #include #include #include uniform float thickness; uniform bool screenspace; uniform vec2 size; void main() { #if defined (USE_SKINNING) #include #include #include #include #include #endif #include #include #include #include vec4 tNormal = vec4(normal, 0.0); vec4 tPosition = vec4(transformed, 1.0); #ifdef USE_INSTANCING tNormal = instanceMatrix * tNormal; tPosition = instanceMatrix * tPosition; #endif if (!screenspace) { vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness; gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); } else { vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition; vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal; vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0; clipPosition.xy += offset; gl_Position = clipPosition; } }`,d9=` uniform vec3 color; uniform float opacity; void main(){ gl_FragColor = vec4(color, opacity); #include #include <${h_>=154?"colorspace_fragment":"encodings_fragment"}> } `;var f9=Kn(" ",1),p9=Kn(" ",1);function aL(s,e){if(new.target)return Tt({component:aL,...s});Mt(e,!0);let t=H(e,"color",7,"black"),i=H(e,"screenspace",7,!1),n=H(e,"opacity",7,1),r=H(e,"transparent",7,!1),o=H(e,"thickness",7,.05),a=H(e,"toneMapped",7,!0),l=H(e,"angle",23,()=>Math.PI),c=H(e,"polygonOffset",7,!1),u=H(e,"polygonOffsetFactor",7,0),h=H(e,"renderOrder",7,0),d=H(e,"children",7),f=H(e,"ref",15),m=an(e,["$$slots","$$events","$$legacy","$$host","color","screenspace","opacity","transparent","thickness","toneMapped","angle","polygonOffset","polygonOffsetFactor","renderOrder","children","ref"]);const{renderer:v}=un(),g={screenspace:{value:i()},color:{value:new rt(t())},opacity:{value:n()},thickness:{value:o()},size:{value:new Ne}},_=new Qn,y=new Ti({side:ji,uniforms:g,vertexShader:h9,fragmentShader:d9}),w=To();let x=cf(w),M=xt(()=>{if(wn(x.current,"Mesh"))return lw(x.current.geometry,l())}),C=xt(()=>{if(wn(x.current,"Mesh")){if(wn(x.current,"SkinnedMesh")){const T=new Kv;return T.bind(x.current.skeleton,x.current.bindMatrix),T}else if(wn(x.current,"InstancedMesh")){const T=new Jh(void 0,void 0,x.current.count);return T.instanceMatrix=x.current.instanceMatrix,T}return new it}});return $e(()=>{fe(C)&&(fe(C).renderOrder=h())}),$e(()=>{y.transparent=r()}),$e(()=>{y.toneMapped=a()}),$e(()=>{y.polygonOffset=c()}),$e(()=>{y.polygonOffsetFactor=u()}),$e(()=>{y.uniforms.screenspace.value=i()}),$e(()=>{y.uniforms.color.value.set(t())}),$e(()=>{y.uniforms.opacity.value=n()}),$e(()=>{y.uniforms.thickness.value=o()}),$e(()=>{v.getDrawingBufferSize(y.uniforms.size.value)}),pt(s,rn({is:_},()=>m,{get ref(){return f()},set ref(T){f(T)},children:(T,A)=>{var P=p9(),E=dt(P);pt(E,{get is(){return fe(C)},children:(R,U)=>{var L=f9(),k=dt(L);pt(k,{get is(){return fe(M)}});var z=Ln(k,2);pt(z,{is:y}),lt(R,L)},$$slots:{default:!0}});var I=Ln(E,2);Wt(I,()=>d()??Nt,()=>({ref:_})),lt(T,P)},$$slots:{default:!0}})),Et({get color(){return t()},set color(T="black"){t(T),V()},get screenspace(){return i()},set screenspace(T=!1){i(T),V()},get opacity(){return n()},set opacity(T=1){n(T),V()},get transparent(){return r()},set transparent(T=!1){r(T),V()},get thickness(){return o()},set thickness(T=.05){o(T),V()},get toneMapped(){return a()},set toneMapped(T=!0){a(T),V()},get angle(){return l()},set angle(T=Math.PI){l(T),V()},get polygonOffset(){return c()},set polygonOffset(T=!1){c(T),V()},get polygonOffsetFactor(){return u()},set polygonOffsetFactor(T=0){u(T),V()},get renderOrder(){return h()},set renderOrder(T=0){h(T),V()},get children(){return d()},set children(T){d(T),V()},get ref(){return f()},set ref(T){f(T),V()},$set:Ct,$on:(T,A)=>At(e,T,A)})}Pt(aL,{color:{},screenspace:{},opacity:{},transparent:{},thickness:{},toneMapped:{},angle:{},polygonOffset:{},polygonOffsetFactor:{},renderOrder:{},children:{},ref:{}},[],[],!0);function lL(s,e){if(new.target)return Tt({component:lL,...s});Mt(e,!0);let t=H(e,"id",7,1),i=H(e,"colorWrite",7,!1),n=H(e,"depthWrite",7,!1),r=H(e,"ref",15),o=H(e,"children",7),a=an(e,["$$slots","$$events","$$legacy","$$host","id","colorWrite","depthWrite","ref","children"]);const l=new it;Ht(()=>{const{material:u}=l;Array.isArray(u)||(u.colorWrite=i(),u.depthWrite=n(),u.stencilWrite=!0,u.stencilRef=t(),u.stencilFunc=yv,u.stencilFail=_v,u.stencilZFail=_v,u.stencilZPass=_v)});const c=xt(()=>-t());return pt(s,rn({is:l,get renderOrder(){return fe(c)}},()=>a,{get ref(){return r()},set ref(u){r(u)},children:(u,h)=>{var d=Lt(),f=dt(d);Wt(f,()=>o()??Nt,()=>({ref:l})),lt(u,d)},$$slots:{default:!0}})),Et({get id(){return t()},set id(u=1){t(u),V()},get colorWrite(){return i()},set colorWrite(u=!1){i(u),V()},get depthWrite(){return n()},set depthWrite(u=!1){n(u),V()},get ref(){return r()},set ref(u){r(u),V()},get children(){return o()},set children(u){o(u),V()},$set:Ct,$on:(u,h)=>At(e,u,h)})}Pt(lL,{id:{},colorWrite:{},depthWrite:{},ref:{},children:{}},[],[],!0);function cL(s,e){if(new.target)return Tt({component:cL,...s});Mt(e,!0);const t=cf(Ml().suspended),{renderer:i}=un();return Ht(()=>(t.current||(i.shadowMap.autoUpdate=!1,i.shadowMap.needsUpdate=!0),()=>{i.shadowMap.autoUpdate=!0,i.shadowMap.needsUpdate=!0})),Et({$set:Ct,$on:(n,r)=>At(e,n,r)})}Pt(cL,{},[],[],!0);function uL(s,e){if(new.target)return Tt({component:uL,...s});Mt(e,!0);let t=H(e,"ref",15),i=H(e,"children",7),n=an(e,["$$slots","$$events","$$legacy","$$host","ref","children"]);const r=new $b;return ow("detailed",o=>{if(To().current!==r)return;let l,c=o.props.distance,u=o.props.hysteresis;const h=xt(()=>wn(o.ref,"Object3D")?o.ref:void 0),d=xt(()=>o.props.distance??0),f=xt(()=>o.props.hysteresis??0),m=(_,y,w)=>{r.addLevel(_,y,w)},v=_=>{const y=r.levels.findIndex(w=>w.object===_);y>-1&&r.levels.splice(y,1)},g=(_,y,w)=>{ws(()=>{const x=r.levels.find(M=>M.object===_);x&&(x.distance=y,x.hysteresis=w)})};return Gs.pre(()=>[fe(h),fe(d),fe(f)],([_,y,w])=>{_!==l&&(l&&v(l),_&&m(_,y,w),l=_),_&&(y!==c||w!==u)&&(g(_,y,w),c=y,u=w)}),Ui(()=>{fe(h)&&v(fe(h))}),{pluginProps:["distance","hysteresis"]}}),pt(s,rn({is:r},()=>n,{get ref(){return t()},set ref(o){t(o)},children:(o,a)=>{var l=Lt(),c=dt(l);Wt(c,()=>i()??Nt,()=>({ref:r})),lt(o,l)},$$slots:{default:!0}})),Et({get ref(){return t()},set ref(o){t(o),V()},get children(){return i()},set children(o){i(o),V()},$set:Ct,$on:(o,a)=>At(e,o,a)})}Pt(uL,{ref:{},children:{}},[],[],!0);const m9=`void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; } `,g9="void main() {}";function hL(s,e){if(new.target)return Tt({component:hL,...s});Mt(e,!0);let t=H(e,"children",7),i=H(e,"ref",15),n=an(e,["$$slots","$$events","$$legacy","$$host","children","ref"]);var r=Lt(),o=dt(r);return Ss(o,()=>pt.ShaderMaterial,(a,l)=>{l(a,rn({fragmentShader:m9,vertexShader:g9},()=>n,{get ref(){return i()},set ref(c){i(c)},children:(c,u)=>{var h=Lt(),d=dt(h);Wt(d,()=>t()??Nt,i),lt(c,h)},$$slots:{default:!0}}))}),lt(s,r),Et({get children(){return t()},set children(a){t(a),V()},get ref(){return i()},set ref(a){i(a),V()},$set:Ct,$on:(a,l)=>At(e,a,l)})}Pt(hL,{children:{},ref:{}},[],[],!0);const dL=new yn;function fL(s,e){if(new.target)return Tt({component:fL,...s});Mt(e,!0);const{renderStage:t}=un();let i=H(e,"axis",7),n=H(e,"auto",7,!1),r=H(e,"box",7,dL),o=H(e,"precise",7),a=H(e,"onresize",7),l=H(e,"stage",23,()=>hu("",{before:t})),c=H(e,"ref",15),u=H(e,"children",7),h=an(e,["$$slots","$$events","$$legacy","$$host","axis","auto","box","precise","onresize","stage","ref","children"]);c(new Qn);const d=new Qn,f=new Qn,m=()=>{var P;f.matrixWorld.identity();const{max:w,min:x}=r().setFromObject(d,o()),M=w.x-x.x,C=w.y-x.y,T=w.z-x.z,A=i()==="x"?M:i()==="y"?C:i()==="z"?T:Math.max(M,C,T);f.scale.setScalar(1/A),(P=a())==null||P()},{start:v,stop:g}=ii(()=>{m(),g()},{autoStart:!1,stage:l()}),_=v;Gs(()=>[i(),o()],v);const y=w=>{wn(w.ref,"Object3D")&&Gs.pre(()=>[w.ref],()=>(n()&&v(),()=>{n()&&v()}))};return pt(s,rn({get is(){return c()}},()=>h,{children:(w,x)=>{pt(w,{is:f,children:(M,C)=>{pt(M,{is:d,children:(T,A)=>{y_(T,{name:"resize",plugin:y,children:(P,E)=>{var I=Lt(),R=dt(I);Wt(R,()=>u()??Nt,()=>({ref:c(),resize:v})),lt(P,I)},$$slots:{default:!0}})},$$slots:{default:!0}})},$$slots:{default:!0}})},$$slots:{default:!0}})),Et({resize:_,get axis(){return i()},set axis(w){i(w),V()},get auto(){return n()},set auto(w=!1){n(w),V()},get box(){return r()},set box(w=dL){r(w),V()},get precise(){return o()},set precise(w){o(w),V()},get onresize(){return a()},set onresize(w){a(w),V()},get stage(){return l()},set stage(w=hu("",{before:t})){l(w),V()},get ref(){return c()},set ref(w){c(w),V()},get children(){return u()},set children(w){u(w),V()},$set:Ct,$on:(w,x)=>At(e,w,x)})}Pt(fL,{axis:{},auto:{},box:{},precise:{},onresize:{},stage:{},ref:{},children:{}},[],["resize"],!0);var v9=Kn(" ",1);function pL(s,e){if(new.target)return Tt({component:pL,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(E,"$started",t);let r=H(e,"background",7,"auto"),o=H(e,"far",7,1e3),a=H(e,"fog",7,"auto"),l=H(e,"frames",7,1/0),c=H(e,"near",7,.1),u=H(e,"onupdatestart",7),h=H(e,"onupdatestop",7),d=H(e,"resolution",7,256),f=H(e,"children",7),m=H(e,"ref",15),v=an(e,["$$slots","$$events","$$legacy","$$host","background","far","fog","frames","near","onupdatestart","onupdatestop","resolution","children","ref"]);const{camera:g,renderTarget:_}=DD(()=>c(),()=>o(),()=>d()),{renderer:y,scene:w}=un(),x=new Qn,M=new Qn;let C=0;const T=()=>{var U;if(C{var U,L;n()&&(P(),(U=h())==null||U()),C=0,A(),(L=u())==null||L()};Gs(()=>[r(),o(),c(),a(),l(),d()],I),pt(s,rn({is:x},()=>v,{get ref(){return m()},set ref(U){m(U)},children:(U,L)=>{var k=v9(),z=dt(k);pt(z,{is:g});var G=Ln(z,2);pt(G,{is:M,children:(W,q)=>{var O=Lt(),B=dt(O);Wt(B,()=>f()??Nt,()=>({camera:g,ref:x,renderTarget:_,restart:I,update:T})),lt(W,O)},$$slots:{default:!0}}),lt(U,k)},$$slots:{default:!0}}));var R=Et({camera:g,renderTarget:_,update:T,restart:I,get background(){return r()},set background(U="auto"){r(U),V()},get far(){return o()},set far(U=1e3){o(U),V()},get fog(){return a()},set fog(U="auto"){a(U),V()},get frames(){return l()},set frames(U=1/0){l(U),V()},get near(){return c()},set near(U=.1){c(U),V()},get onupdatestart(){return u()},set onupdatestart(U){u(U),V()},get onupdatestop(){return h()},set onupdatestop(U){h(U),V()},get resolution(){return d()},set resolution(U=256){d(U),V()},get children(){return f()},set children(U){f(U),V()},get ref(){return m()},set ref(U){m(U),V()},$set:Ct,$on:(U,L)=>At(e,U,L)});return i(),R}Pt(pL,{background:{},far:{},fog:{},frames:{},near:{},onupdatestart:{},onupdatestop:{},resolution:{},children:{},ref:{}},[],["camera","renderTarget","update","restart"],!0);const mL=(s,e)=>{s.save();let t=s.fillStyle;s.fillStyle=e,s.fillRect(0,0,s.canvas.width,s.canvas.height),s.fillStyle=t,s.restore()},_9=new rt,gL=(s,e=[])=>{for(const t of e)s.addColorStop(t.offset,_9.set(t.color).getStyle());return s};function vL(s,e){if(new.target)return Tt({component:vL,...s});Mt(e,!0);let t=H(e,"width",7,1024),i=H(e,"height",7,1024),n=H(e,"startX",7,0),r=H(e,"startY",7,0),o=H(e,"endX",7,0),a=H(e,"endY",23,i),l=H(e,"stops",23,()=>[{offset:0,color:"black"},{offset:1,color:"white"}]),c=H(e,"attach",7,"map"),u=H(e,"children",7),h=H(e,"ref",15),d=an(e,["$$slots","$$events","$$legacy","$$host","width","height","startX","startY","endX","endY","stops","attach","children","ref"]);const f=new OffscreenCanvas(0,0),m=f.getContext("2d"),v=new h0(f);$e(()=>{f.width=t()}),$e(()=>{f.height=i()}),Gs(()=>[e.wrapS,e.wrapT],()=>{v.needsUpdate=!0,_()});const g=xt(()=>{const y=m==null?void 0:m.createLinearGradient(n(),r(),o(),a());return y!==void 0&&gL(y,l()),y}),{invalidate:_}=un();return Ht(()=>{fe(g)!==void 0&&m!==null&&(mL(m,fe(g)),v.needsUpdate=!0,_())}),pt(s,rn({is:v,get attach(){return c()}},()=>d,{get ref(){return h()},set ref(y){h(y)},children:(y,w)=>{var x=Lt(),M=dt(x);Wt(M,()=>u()??Nt,()=>({ref:v})),lt(y,x)},$$slots:{default:!0}})),Et({get width(){return t()},set width(y=1024){t(y),V()},get height(){return i()},set height(y=1024){i(y),V()},get startX(){return n()},set startX(y=0){n(y),V()},get startY(){return r()},set startY(y=0){r(y),V()},get endX(){return o()},set endX(y=0){o(y),V()},get endY(){return a()},set endY(y=i){a(y),V()},get stops(){return l()},set stops(y=[{offset:0,color:"black"},{offset:1,color:"white"}]){l(y),V()},get attach(){return c()},set attach(y="map"){c(y),V()},get children(){return u()},set children(y){u(y),V()},get ref(){return h()},set ref(y){h(y),V()},$set:Ct,$on:(y,w)=>At(e,y,w)})}Pt(vL,{width:{},height:{},startX:{},startY:{},endX:{},endY:{},stops:{},attach:{},children:{},ref:{}},[],[],!0);function _L(s,e){if(new.target)return Tt({component:_L,...s});Mt(e,!0);let t=H(e,"width",7,1024),i=H(e,"height",7,1024),n=H(e,"innerRadius",7,0),r=H(e,"outerRadius",7,"auto"),o=H(e,"stops",23,()=>[{offset:0,color:"black"},{offset:1,color:"white"}]),a=H(e,"attach",7,"map"),l=H(e,"children",7),c=H(e,"ref",15),u=an(e,["$$slots","$$events","$$legacy","$$host","width","height","innerRadius","outerRadius","stops","attach","children","ref"]);const h=new OffscreenCanvas(0,0),d=h.getContext("2d"),f=new h0(h);$e(()=>{h.width=t()}),$e(()=>{h.height=i()}),Gs(()=>[e.wrapS,e.wrapT],()=>{f.needsUpdate=!0,_()});let m=xt(()=>.5*t()),v=xt(()=>.5*i());const g=xt(()=>{const y=d==null?void 0:d.createRadialGradient(fe(m),fe(v),n(),fe(m),fe(v),r()==="auto"?Math.hypot(fe(m),fe(v)):r());return y!==void 0&&gL(y,o()),y}),{invalidate:_}=un();return Ht(()=>{fe(g)!==void 0&&d!==null&&(mL(d,fe(g)),f.needsUpdate=!0,_())}),pt(s,rn({is:f},()=>u,{get attach(){return a()},get ref(){return c()},set ref(y){c(y)},children:(y,w)=>{var x=Lt(),M=dt(x);Wt(M,()=>l()??Nt,()=>({ref:f})),lt(y,x)},$$slots:{default:!0}})),Et({get width(){return t()},set width(y=1024){t(y),V()},get height(){return i()},set height(y=1024){i(y),V()},get innerRadius(){return n()},set innerRadius(y=0){n(y),V()},get outerRadius(){return r()},set outerRadius(y="auto"){r(y),V()},get stops(){return o()},set stops(y=[{offset:0,color:"black"},{offset:1,color:"white"}]){o(y),V()},get attach(){return a()},set attach(y="map"){a(y),V()},get children(){return l()},set children(y){l(y),V()},get ref(){return c()},set ref(y){c(y),V()},$set:Ct,$on:(y,w)=>At(e,y,w)})}Pt(_L,{width:{},height:{},innerRadius:{},outerRadius:{},stops:{},attach:{},children:{},ref:{}},[],[],!0);class y9{constructor(e){_y(this,nm,xs(!1));Gs(()=>[e()],([t])=>{const i=new IntersectionObserver(n=>{for(const r of n)this.isOffscreen=!r.isIntersecting});return i.observe(t),()=>{i.disconnect()}})}get isOffscreen(){return fe(zr(this,nm))}set isOffscreen(e){Mn(zr(this,nm),hr(e))}}nm=new WeakMap;function IS(s,e){if(new.target)return Tt({component:IS,...s});Mt(e,!0);let t=H(e,"dom",7),i=H(e,"children",7);const n=new y9(()=>t()),r=un();pR({dom:t(),canvas:r.canvas}),cR();const{scene:o}=$0();nw(o),_R(o);const{camera:a}=tw();bR();const{renderer:l,renderStage:c,canvas:u}=un(),h=new Zt,d=new Zt;let f;const{start:m,stop:v}=ii(Symbol(""),()=>{if(n.isOffscreen)return;const{left:y,bottom:w,width:x,height:M}=t().getBoundingClientRect(),{bottom:C,left:T}=u.getBoundingClientRect(),A=C-w,P=y-T;l.getScissor(d),l.getViewport(h),f=l.getScissorTest(),l.setViewport(P,A,x,M),l.setScissor(P,A,x,M),l.setScissorTest(!0),l.render(o,a.current),l.setViewport(h),l.setScissor(d),l.setScissorTest(f)},{stage:c,autoStart:!1});Ht(()=>{n.isOffscreen?v():m()});var g=Lt(),_=dt(g);return Wt(_,()=>i()??Nt),lt(s,g),Et({get dom(){return t()},set dom(y){t(y),V()},get children(){return i()},set children(y){i(y),V()},$set:Ct,$on:(y,w)=>At(e,y,w)})}Pt(IS,{dom:{},children:{}},[],[],!0);function yL(s,e){if(new.target)return Tt({component:yL,...s});Mt(e,!0);let t=H(e,"dom",7),i=H(e,"children",7);var n=Lt(),r=dt(n);{var o=a=>{IS(a,{get dom(){return t()},children:(l,c)=>{var u=Lt(),h=dt(u);Wt(h,()=>i()??Nt),lt(l,u)},$$slots:{default:!0}})};wi(r,a=>{t()&&a(o)})}return lt(s,n),Et({get dom(){return t()},set dom(a){t(a),V()},get children(){return i()},set children(a){i(a),V()},$set:Ct,$on:(a,l)=>At(e,a,l)})}Pt(yL,{dom:{},children:{}},[],[],!0);class x9{constructor(e,t=" .:-=+*#%@",i={}){const n=i.resolution||.15,r=i.scale||1,o=i.color||!1,a=i.alpha||!1,l=i.block||!1,c=i.invert||!1,u=i.strResolution||"low";let h,d;const f=document.createElement("div");f.style.cursor="default";const m=document.createElement("table");f.appendChild(m);let v,g,_;this.setSize=function(L,k){h=L,d=k,e.setSize(L,k),y()},this.render=function(L,k){e.render(L,k),U(m)},this.domElement=f;function y(){v=Math.floor(h*n),g=Math.floor(d*n),T.width=v,T.height=g,_=e.domElement,_.style.backgroundColor&&(m.rows[0].cells[0].style.backgroundColor=_.style.backgroundColor,m.rows[0].cells[0].style.color=_.style.color),m.cellSpacing=0,m.cellPadding=0;const L=m.style;L.whiteSpace="pre",L.margin="0px",L.padding="0px",L.letterSpacing=R+"px",L.fontFamily=M,L.fontSize=E+"px",L.lineHeight=I+"px",L.textAlign="left",L.textDecoration="none"}const w=" .,:;i1tfLCG08@".split(""),x=" CGO08@".split(""),M="courier new, monospace",C=e.domElement,T=document.createElement("canvas");if(!T.getContext)return;const A=T.getContext("2d");if(!A.getImageData)return;let P=o?x:w;t&&(P=t);const E=2/n*r,I=2/n*r;let R=0;if(u=="low")switch(r){case 1:R=-1;break;case 2:case 3:R=-2.1;break;case 4:R=-3.1;break;case 5:R=-4.15;break}if(u=="medium")switch(r){case 1:R=0;break;case 2:R=-1;break;case 3:R=-1.04;break;case 4:case 5:R=-2.1;break}if(u=="high")switch(r){case 1:case 2:R=0;break;case 3:case 4:case 5:R=-1;break}function U(L){A.clearRect(0,0,v,g),A.drawImage(C,0,0,v,g);const k=A.getImageData(0,0,v,g).data;let z="";for(let G=0;G"+ue+"":z+=ue}z+="
"}L.innerHTML=`${z}`}}}function xL(s,e){if(new.target)return Tt({component:xL,...s});Mt(e,!0);const t=" .:-+*=%@#";let i=H(e,"autoRender",7,!0),n=H(e,"bgColor",7,"#000000"),r=H(e,"camera",7),o=H(e,"characters",7,t),a=H(e,"fgColor",7,"#ffffff"),l=H(e,"onstart",7),c=H(e,"onstop",7),u=H(e,"options",23,()=>({})),h=H(e,"scene",7),d=H(e,"children",7);const{autoRender:f,camera:m,renderStage:v,renderer:g,canvas:_,dom:y,scene:w,size:x}=un(),M=xt(()=>o()||t),C=xt(()=>{const k=new x9(g,fe(M),u());return k.domElement.style.position="absolute",k.domElement.style.top="0px",k.domElement.style.left="0px",k.domElement.style.pointerEvents="none",k}),T=()=>fe(C),A=cf(x);$e(()=>{fe(C).setSize(A.current.width,A.current.height)}),$e(()=>{fe(C).domElement.style.color=a()}),$e(()=>{fe(C).domElement.style.backgroundColor=n()}),Ht(()=>{_.style.opacity="0";const k=fe(C).domElement;return y.appendChild(k),()=>{_.style.opacity="1",y.removeChild(k)}});const{start:P,stop:E}=ii(()=>{fe(C).render(h()??w,r()??m.current)},{autoInvalidate:!1,autoStart:!1,stage:v}),I=()=>{var k;P(),(k=l())==null||k()},R=()=>{var k;E(),(k=c())==null||k()};Ht(()=>{if(i())return I(),()=>{R()}}),Ht(()=>{const k=f.current;return f.set(!i()),()=>{f.set(k)}});var U=Lt(),L=dt(U);return Wt(L,()=>d()??Nt,()=>({asciiEffect:fe(C)})),lt(s,U),Et({getEffect:T,start:I,stop:R,get autoRender(){return i()},set autoRender(k=!0){i(k),V()},get bgColor(){return n()},set bgColor(k="#000000"){n(k),V()},get camera(){return r()},set camera(k){r(k),V()},get characters(){return o()},set characters(k=t){o(k),V()},get fgColor(){return a()},set fgColor(k="#ffffff"){a(k),V()},get onstart(){return l()},set onstart(k){l(k),V()},get onstop(){return c()},set onstop(k){c(k),V()},get options(){return u()},set options(k={}){u(k),V()},get scene(){return h()},set scene(k){h(k),V()},get children(){return d()},set children(k){d(k),V()},$set:Ct,$on:(k,z)=>At(e,k,z)})}Pt(xL,{autoRender:{},bgColor:{},camera:{},characters:{},fgColor:{},onstart:{},onstop:{},options:{},scene:{},children:{}},[],["getEffect","start","stop"],!0),typeof window<"u"&&document.createElement("div");var b9=Kn(" ",1);function bL(s,e){if(new.target)return Tt({component:bL,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(f,"$suspended",t),r=()=>Rn(m,"$errors",t);let o=H(e,"final",7,!1),a=H(e,"onload",7),l=H(e,"onsuspend",7),c=H(e,"onerror",7),u=H(e,"error",7),h=H(e,"fallback",7),d=H(e,"children",7);const{suspended:f,errors:m,setFinal:v}=L6({final:o()});Ht(()=>v(o())),Ht(()=>{var A;n()||(A=a())==null||A()}),Ht(()=>{var A;n()&&((A=l())==null||A())}),Ht(()=>{var A;r().length>0&&((A=c())==null||A(r()))});const g=new Qn,_=yR();pi([_,f,m],([A,P,E])=>{if(A){if(P||E.length){A.remove(g);return}return A.add(g),()=>{A.remove(g)}}});var y=b9(),w=dt(y);pt(w,{is:g,attach:!1,children:(A,P)=>{var E=Lt(),I=dt(E);Wt(I,()=>d()??Nt,()=>({suspended:n(),errors:r()})),lt(A,E)},$$slots:{default:!0}});var x=Ln(w,2);{var M=A=>{var P=Lt(),E=dt(P);Wt(E,()=>u()??Nt,()=>({errors:r()})),lt(A,P)},C=A=>{var P=Lt(),E=dt(P);{var I=R=>{var U=Lt(),L=dt(U);Wt(L,()=>h()??Nt),lt(R,U)};wi(E,R=>{n()&&R(I)},!0)}lt(A,P)};wi(x,A=>{r().length?A(M):A(C,!1)})}lt(s,y);var T=Et({get final(){return o()},set final(A=!1){o(A),V()},get onload(){return a()},set onload(A){a(A),V()},get onsuspend(){return l()},set onsuspend(A){l(A),V()},get onerror(){return c()},set onerror(A){c(A),V()},get error(){return u()},set error(A){u(A),V()},get fallback(){return h()},set fallback(A){h(A),V()},get children(){return d()},set children(A){d(A),V()},$set:Ct,$on:(A,P)=>At(e,A,P)});return i(),T}Pt(bL,{final:{},onload:{},onsuspend:{},onerror:{},error:{},fallback:{},children:{}},[],[],!0);const w9=()=>{const s={portals:Yn(new Map),addPortal(e,t){s.portals.update(i=>(i.has(t)?console.warn(`Portal with id ${t} already exists. Skipping portal creation.`):i.set(t,e),i))},removePortal(e){s.portals.update(t=>(t.has(e)?t.delete(e):console.warn(`Portal with id ${e} does not exist. Skipping portal removal.`),t))},getPortal(e){return Ha(s.portals,t=>t.get(e))},hasPortal(e){return s.portals.current.has(e)}};return s},wL=()=>aw("threlte-portals",w9());function SL(s,e){if(new.target)return Tt({component:SL,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(fe(d),"$portal",t),r=()=>Rn(h,"$target",t);let o=H(e,"id",7,"default"),a=H(e,"object",7),l=H(e,"children",7);const{getPortal:c}=wL(),u=Hn([]),h=Hn();let d=xt(()=>c(o()));$e(()=>h.set(a()??n())),pi([u,h],([y,w])=>{if(w!==void 0){for(const x of y)w.children.includes(x)||w.add(x);return()=>{for(const x of y)w.children.includes(x)&&w.remove(x)}}});const f=new tn;f.add=y=>(u.update(w=>(w.push(y),w)),y),f.remove=y=>(u.update(w=>(w.splice(w.indexOf(y),1),w)),y);var m=Lt(),v=dt(m);{var g=y=>{pt(y,{is:f,attach:!1,children:(w,x)=>{var M=Lt(),C=dt(M);Wt(C,()=>l()??Nt),lt(w,M)},$$slots:{default:!0}})};wi(v,y=>{r()&&y(g)})}lt(s,m);var _=Et({get id(){return o()},set id(y="default"){o(y),V()},get object(){return a()},set object(y){a(y),V()},get children(){return l()},set children(y){l(y),V()},$set:Ct,$on:(y,w)=>At(e,y,w)});return i(),_}Pt(SL,{id:{},object:{},children:{}},[],[],!0);function ML(s,e){if(new.target)return Tt({component:ML,...s});Mt(e,!0);const[t,i]=Pi(),n=()=>Rn(o,"$parent",t);let r=H(e,"id",7,"default");const o=To();if(!n())throw new Error(" must be used within a component.");const{addPortal:a,removePortal:l}=wL();pi(o,u=>{if(!(!u||!wn(u,"Object3D")))return a(u,r()),()=>{l(r())}});var c=Et({get id(){return r()},set id(u="default"){r(u),V()},$set:Ct,$on:(u,h)=>At(e,u,h)});return i(),c}Pt(ML,{id:{}},[],[],!0);function S9(){var s=Object.create(null);function e(n,r){var o=n.id,a=n.name,l=n.dependencies;l===void 0&&(l=[]);var c=n.init;c===void 0&&(c=function(){});var u=n.getTransferables;if(u===void 0&&(u=null),!s[o])try{l=l.map(function(d){return d&&d.isWorkerModule&&(e(d,function(f){if(f instanceof Error)throw f}),d=s[d.id].value),d}),c=i("<"+a+">.init",c),u&&(u=i("<"+a+">.getTransferables",u));var h=null;typeof c=="function"?h=c.apply(void 0,l):console.error("worker module init function failed to rehydrate"),s[o]={id:o,value:h,getTransferables:u},r(h)}catch(d){d&&d.noLog||console.error(d),r(d)}}function t(n,r){var o,a=n.id,l=n.args;(!s[a]||typeof s[a].value!="function")&&r(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var c=(o=s[a]).value.apply(o,l);c&&typeof c.then=="function"?c.then(u,function(h){return r(h instanceof Error?h:new Error(""+h))}):u(c)}catch(h){r(h)}function u(h){try{var d=s[a].getTransferables&&s[a].getTransferables(h);(!d||!Array.isArray(d)||!d.length)&&(d=void 0),r(h,d)}catch(f){console.error(f),r(f)}}}function i(n,r){var o=void 0;self.troikaDefine=function(l){return o=l};var a=URL.createObjectURL(new Blob(["/** "+n.replace(/\*/g,"")+` **/ troikaDefine( `+r+` )`],{type:"application/javascript"}));try{importScripts(a)}catch(l){console.error(l)}return URL.revokeObjectURL(a),delete self.troikaDefine,o}self.addEventListener("message",function(n){var r=n.data,o=r.messageId,a=r.action,l=r.data;try{a==="registerModule"&&e(l,function(c){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:{isCallable:typeof c=="function"}})}),a==="callModule"&&t(l,function(c,u){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:c},u||void 0)})}catch(c){postMessage({messageId:o,success:!1,error:c.stack})}})}function M9(s){var e=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];return e._getInitResult().then(function(n){if(typeof n=="function")return n.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")})};return e._getInitResult=function(){var t=s.dependencies,i=s.init;t=Array.isArray(t)?t.map(function(r){return r&&r._getInitResult?r._getInitResult():r}):[];var n=Promise.all(t).then(function(r){return i.apply(null,r)});return e._getInitResult=function(){return n},n},e}var EL=function(){var s=!1;if(typeof window<"u"&&typeof window.document<"u")try{var e=new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"})));e.terminate(),s=!0}catch(t){typeof process<"u"&&process.env.NODE_ENV==="test"||console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return EL=function(){return s},s},E9=0,T9=0,LS=!1,Zp=Object.create(null),Kp=Object.create(null),US=Object.create(null);function Td(s){if((!s||typeof s.init!="function")&&!LS)throw new Error("requires `options.init` function");var e=s.dependencies,t=s.init,i=s.getTransferables,n=s.workerId;if(!EL())return M9(s);n==null&&(n="#default");var r="workerModule"+ ++E9,o=s.name||r,a=null;e=e&&e.map(function(c){return typeof c=="function"&&!c.workerModuleData&&(LS=!0,c=Td({workerId:n,name:"<"+o+"> function dependency: "+c.name,init:`function(){return ( `+X_(c)+` )}`}),LS=!1),c&&c.workerModuleData&&(c=c.workerModuleData),c});function l(){for(var c=[],u=arguments.length;u--;)c[u]=arguments[u];if(!a){a=TL(n,"registerModule",l.workerModuleData);var h=function(){a=null,Kp[n].delete(h)};(Kp[n]||(Kp[n]=new Set)).add(h)}return a.then(function(d){var f=d.isCallable;if(f)return TL(n,"callModule",{id:r,args:c});throw new Error("Worker module function was called but `init` did not return a callable function")})}return l.workerModuleData={isWorkerModule:!0,id:r,name:o,dependencies:e,init:X_(t),getTransferables:i&&X_(i)},l}function A9(s){Kp[s]&&Kp[s].forEach(function(e){e()}),Zp[s]&&(Zp[s].terminate(),delete Zp[s])}function X_(s){var e=s.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function C9(s){var e=Zp[s];if(!e){var t=X_(S9);e=Zp[s]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+s.replace(/\*/g,"")+` **/ ;(`+t+")()"],{type:"application/javascript"}))),e.onmessage=function(i){var n=i.data,r=n.messageId,o=US[r];if(!o)throw new Error("WorkerModule response with empty or unknown messageId");delete US[r],o(n)}}return e}function TL(s,e,t){return new Promise(function(i,n){var r=++T9;US[r]=function(o){o.success?i(o.result):n(new Error("Error in worker "+e+" call: "+o.error))},C9(s).postMessage({messageId:r,action:e,data:t})})}const AL=/\bvoid\s+main\s*\(\s*\)\s*{/g;function kS(s){const e=/^[ \t]*#include +<([\w\d./]+)>/gm;function t(i,n){let r=Ft[n];return r?kS(r):i}return s.replace(e,t)}const wr=[];for(let s=0;s<256;s++)wr[s]=(s<16?"0":"")+s.toString(16);function P9(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(wr[s&255]+wr[s>>8&255]+wr[s>>16&255]+wr[s>>24&255]+"-"+wr[e&255]+wr[e>>8&255]+"-"+wr[e>>16&15|64]+wr[e>>24&255]+"-"+wr[t&63|128]+wr[t>>8&255]+"-"+wr[t>>16&255]+wr[t>>24&255]+wr[i&255]+wr[i>>8&255]+wr[i>>16&255]+wr[i>>24&255]).toUpperCase()}const wu=Object.assign||function(){let s=arguments[0];for(let e=1,t=arguments.length;es.type,set:c=>{s.type=c}},isDerivedFrom:{writable:!0,configurable:!0,value:function(c){const u=this.baseMaterial;return c===u||u.isDerivedMaterial&&u.isDerivedFrom(c)||!1}},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return s.customProgramCacheKey()+"|"+t}},onBeforeCompile:{get(){return r},set(c){this[n]=c}},copy:{writable:!0,configurable:!0,value:function(c){return s.copy.call(this,c),!s.isShaderMaterial&&!s.isDerivedMaterial&&(wu(this.extensions,c.extensions),wu(this.defines,c.defines),wu(this.uniforms,pl.clone(c.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const c=new s.constructor;return a(c).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let c=this._depthMaterial;return c||(c=this._depthMaterial=OS(s.isDerivedMaterial?s.getDepthMaterial():new jc({depthPacking:Ch}),e),c.defines.IS_DEPTH_MATERIAL="",c.uniforms=this.uniforms),c}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let c=this._distanceMaterial;return c||(c=this._distanceMaterial=OS(s.isDerivedMaterial?s.getDistanceMaterial():new td,e),c.defines.IS_DISTANCE_MATERIAL="",c.uniforms=this.uniforms),c}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:c,_distanceMaterial:u}=this;c&&c.dispose(),u&&u.dispose(),s.dispose.call(this)}}};return i[t]=o,new o}function I9(s,{vertexShader:e,fragmentShader:t},i,n){let{vertexDefs:r,vertexMainIntro:o,vertexMainOutro:a,vertexTransform:l,fragmentDefs:c,fragmentMainIntro:u,fragmentMainOutro:h,fragmentColorTransform:d,customRewriter:f,timeUniform:m}=i;if(r=r||"",o=o||"",a=a||"",c=c||"",u=u||"",h=h||"",(l||f)&&(e=kS(e)),(d||f)&&(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm,` //!BEGIN_POST_CHUNK $1 $& //!END_POST_CHUNK `),t=kS(t)),f){let v=f({vertexShader:e,fragmentShader:t});e=v.vertexShader,t=v.fragmentShader}if(d){let v=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,g=>(v.push(g),"")),h=`${d} ${v.join(` `)} ${h}`}if(m){const v=` uniform float ${m}; `;r=v+r,c=v+c}return l&&(e=`vec3 troika_position_${n}; vec3 troika_normal_${n}; vec2 troika_uv_${n}; ${e} `,r=`${r} void troikaVertexTransform${n}(inout vec3 position, inout vec3 normal, inout vec2 uv) { ${l} } `,o=` troika_position_${n} = vec3(position); troika_normal_${n} = vec3(normal); troika_uv_${n} = vec2(uv); troikaVertexTransform${n}(troika_position_${n}, troika_normal_${n}, troika_uv_${n}); ${o} `,e=e.replace(/\b(position|normal|uv)\b/g,(v,g,_,y)=>/\battribute\s+vec[23]\s+$/.test(y.substr(0,_))?g:`troika_${g}_${n}`),s.map&&s.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${n}`))),e=RL(e,n,r,o,a),t=RL(t,n,c,u,h),{vertexShader:e,fragmentShader:t}}function RL(s,e,t,i,n){return(i||n||t)&&(s=s.replace(AL,` ${t} void troikaOrigMain${e}() {`),s+=` void main() { ${i} troikaOrigMain${e}(); ${n} }`),s}function L9(s,e){return s==="uniforms"?void 0:typeof e=="function"?e.toString():e}let U9=0;const DL=new Map;function k9(s){const e=JSON.stringify(s,L9);let t=DL.get(e);return t==null&&DL.set(e,t=++U9),t}/*! Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering. Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE */function O9(){return typeof window>"u"&&(self.window=self),function(s){var e={parse:function(n){var r=e._bin,o=new Uint8Array(n);if(r.readASCII(o,0,4)=="ttcf"){var a=4;r.readUshort(o,a),a+=2,r.readUshort(o,a),a+=2;var l=r.readUint(o,a);a+=4;for(var c=[],u=0;u>>o&1&&r++;return r},e._lctf.readClassDef=function(n,r){var o=e._bin,a=[],l=o.readUshort(n,r);if(r+=2,l==1){var c=o.readUshort(n,r);r+=2;var u=o.readUshort(n,r);r+=2;for(var h=0;h0&&(l.featureParams=a+c);var u=o.readUshort(n,r);r+=2,l.tab=[];for(var h=0;h0&&(l.default=e._lctf.readLangSysTable(n,a+c));var u=o.readUshort(n,r);r+=2;for(var h=0;h255?-1:e.CFF.glyphByUnicode(n,e.CFF.tableSE[r])},e.CFF.readEncoding=function(n,r,o){e._bin;var a=[".notdef"],l=n[r];if(r++,l!=0)throw"error: unknown encoding format: "+l;var c=n[r];r++;for(var u=0;u>4,y=15&g;if(_!=15&&v.push(_),y!=15&&v.push(y),y==15)break}for(var w="",x=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],M=0;M=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(var u=0;u=1&&u.fmt<=2){d=l.readUshort(n,o),o+=2;var f=l.readUshort(n,o);o+=2;var m=e._lctf.numOfOnes(d),v=e._lctf.numOfOnes(f);if(u.fmt==1){u.pairsets=[];var g=l.readUshort(n,o);o+=2;for(var _=0;_=1&&u.fmt<=2){if(u.fmt==1)u.delta=l.readShort(n,o),o+=2;else if(u.fmt==2){var d=l.readUshort(n,o);o+=2,u.newg=l.readUshorts(n,o,d),o+=2*u.newg.length}}else if(r==2&&u.fmt==1){d=l.readUshort(n,o),o+=2,u.seqs=[];for(var f=0;f>>8;if((m&=15)!=0)throw"unknown kern table format: "+m;r=e.kern.readFormat0(n,r,h)}return h},e.kern.parseV1=function(n,r,o,a){var l=e._bin;l.readFixed(n,r),r+=4;var c=l.readUint(n,r);r+=4;for(var u={glyph1:[],rval:[]},h=0;h>>8;if((f&=15)!=0)throw"unknown kern table format: "+f;r=e.kern.readFormat0(n,r,u)}return u},e.kern.readFormat0=function(n,r,o){var a=e._bin,l=-1,c=a.readUshort(n,r);r+=2,a.readUshort(n,r),r+=2,a.readUshort(n,r),r+=2,a.readUshort(n,r),r+=2;for(var u=0;u=l.map.length?0:l.map[r];if(l.format==4){for(var c=-1,u=0;ur?0:65535&(l.idRangeOffset[c]!=0?l.glyphIdArray[r-l.startCount[c]+(l.idRangeOffset[c]>>1)-(l.idRangeOffset.length-c)]:r+l.idDelta[c])}if(l.format==12){if(r>l.groups[l.groups.length-1][1])return 0;for(u=0;u-1?e.U._simpleGlyph(a,o):e.U._compoGlyph(a,r,o))},e.U._simpleGlyph=function(n,r){for(var o=0;ol)){for(var g=!0,_=0,y=0;yl)){for(g=!0,y=0;y>1,c.length=0,h=!0;else if(R=="o3"||R=="o23")c.length%2!=0&&!h&&(d=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0;else if(R=="o4")c.length>1&&!h&&(d=c.shift()+a.nominalWidthX,h=!0),f&&e.U.P.closePath(l),g+=c.pop(),e.U.P.moveTo(l,v,g),f=!0;else if(R=="o5")for(;c.length>0;)v+=c.shift(),g+=c.shift(),e.U.P.lineTo(l,v,g);else if(R=="o6"||R=="o7")for(var U=c.length,L=R=="o6",k=0;kMath.abs(A-g)?v=T+c.shift():g=A+c.shift(),e.U.P.curveTo(l,_,y,w,x,P,E),e.U.P.curveTo(l,M,C,T,A,v,g));else if(R=="o14"){if(c.length>0&&!h&&(d=c.shift()+o.nominalWidthX,h=!0),c.length==4){var W=c.shift(),q=c.shift(),O=c.shift(),B=c.shift(),J=e.CFF.glyphBySE(o,O),re=e.CFF.glyphBySE(o,B);e.U._drawCFF(o.CharStrings[J],r,o,a,l),r.x=W,r.y=q,e.U._drawCFF(o.CharStrings[re],r,o,a,l)}f&&(e.U.P.closePath(l),f=!1)}else if(R=="o19"||R=="o20")c.length%2!=0&&!h&&(d=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0,m+=u+7>>3;else if(R=="o21")c.length>2&&!h&&(d=c.shift()+a.nominalWidthX,h=!0),g+=c.pop(),v+=c.pop(),f&&e.U.P.closePath(l),e.U.P.moveTo(l,v,g),f=!0;else if(R=="o22")c.length>1&&!h&&(d=c.shift()+a.nominalWidthX,h=!0),v+=c.pop(),f&&e.U.P.closePath(l),e.U.P.moveTo(l,v,g),f=!0;else if(R=="o25"){for(;c.length>6;)v+=c.shift(),g+=c.shift(),e.U.P.lineTo(l,v,g);_=v+c.shift(),y=g+c.shift(),w=_+c.shift(),x=y+c.shift(),v=w+c.shift(),g=x+c.shift(),e.U.P.curveTo(l,_,y,w,x,v,g)}else if(R=="o26")for(c.length%2&&(v+=c.shift());c.length>0;)_=v,y=g+c.shift(),v=w=_+c.shift(),g=(x=y+c.shift())+c.shift(),e.U.P.curveTo(l,_,y,w,x,v,g);else if(R=="o27")for(c.length%2&&(g+=c.shift());c.length>0;)y=g,w=(_=v+c.shift())+c.shift(),x=y+c.shift(),v=w+c.shift(),g=x,e.U.P.curveTo(l,_,y,w,x,v,g);else if(R=="o10"||R=="o29"){var K=R=="o10"?a:o;if(c.length==0)console.debug("error: empty stack");else{var Q=c.pop(),ue=K.Subrs[Q+K.Bias];r.x=v,r.y=g,r.nStems=u,r.haveWidth=h,r.width=d,r.open=f,e.U._drawCFF(ue,r,o,a,l),v=r.x,g=r.y,u=r.nStems,h=r.haveWidth,d=r.width,f=r.open}}else if(R=="o30"||R=="o31"){var le=c.length,_e=(G=0,R=="o31");for(G+=le-(U=-3&le);G>>1|(21845&f)<<1;m=(61680&(m=(52428&m)>>>2|(13107&m)<<2))>>>4|(3855&m)<<4,d[f]=((65280&m)>>>8|(255&m)<<8)>>>1}var v=function(R,U,L){for(var k=R.length,z=0,G=new t(U);z>>O]=B}return W},g=new e(288);for(f=0;f<144;++f)g[f]=8;for(f=144;f<256;++f)g[f]=9;for(f=256;f<280;++f)g[f]=7;for(f=280;f<288;++f)g[f]=8;var _=new e(32);for(f=0;f<32;++f)_[f]=5;var y=v(g,9),w=v(_,5),x=function(R){for(var U=R[0],L=1;LU&&(U=R[L]);return U},M=function(R,U,L){var k=U/8|0;return(R[k]|R[k+1]<<8)>>(7&U)&L},C=function(R,U){var L=U/8|0;return(R[L]|R[L+1]<<8|R[L+2]<<16)>>(7&U)},T=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],A=function(R,U,L){var k=new Error(U||T[R]);if(k.code=R,Error.captureStackTrace&&Error.captureStackTrace(k,A),!L)throw k;return k},P=function(R,U,L){var k=R.length;if(!k||L&&!L.l&&k<5)return U||new e(0);var z=!U||L,G=!L||L.i;L||(L={}),U||(U=new e(3*k));var W,q=function(Le){var ot=U.length;if(Le>ot){var tt=new e(Math.max(2*ot,Le));tt.set(U),U=tt}},O=L.f||0,B=L.p||0,J=L.b||0,re=L.l,K=L.d,Q=L.m,ue=L.n,le=8*k;do{if(!re){L.f=O=M(R,B,1);var _e=M(R,B+1,3);if(B+=3,!_e){var Fe=R[(Oe=((W=B)/8|0)+(7&W&&1)+4)-4]|R[Oe-3]<<8,Ie=Oe+Fe;if(Ie>k){G&&A(0);break}z&&q(J+Fe),U.set(R.subarray(Oe,Ie),J),L.b=J+=Fe,L.p=B=8*Ie;continue}if(_e==1)re=y,K=w,Q=9,ue=5;else if(_e==2){var Ee=M(R,B,31)+257,me=M(R,B+10,15)+4,xe=Ee+M(R,B+5,31)+1;B+=14;for(var $=new e(xe),Ue=new e(19),Me=0;Me>>4)<16)$[Me++]=Oe;else{var Z=0,pe=0;for(Oe==16?(pe=3+M(R,B,3),B+=2,Z=$[Me-1]):Oe==17?(pe=3+M(R,B,7),B+=3):Oe==18&&(pe=11+M(R,B,127),B+=7);pe--;)$[Me++]=Z}}var he=$.subarray(0,Ee),te=$.subarray(Ee);Q=x(he),ue=x(te),re=v(he,Q),K=v(te,ue)}else A(1);if(B>le){G&&A(0);break}}z&&q(J+131072);for(var Se=(1<>>4;if((B+=15&Z)>le){G&&A(0);break}if(Z||A(2),Ce<256)U[J++]=Ce;else{if(Ce==256){Ae=B,re=null;break}var Ge=Ce-254;if(Ce>264){var De=n[Me=Ce-257];Ge=M(R,B,(1<>>4;if(Ve||A(3),B+=15&Ve,te=h[ze],ze>3&&(De=r[ze],te+=C(R,B)&(1<le){G&&A(0);break}z&&q(J+131072);for(var Ze=J+Ge;JLe.length)&&(tt=Le.length);var mt=new(Le instanceof t?t:Le instanceof i?i:e)(tt-ot);return mt.set(Le.subarray(ot,tt)),mt}(U,0,J)},E=new e(0),I=typeof TextDecoder<"u"&&new TextDecoder;try{I.decode(E,{stream:!0})}catch{}return s.convert_streams=function(R){var U=new DataView(R),L=0;function k(){var Ee=U.getUint16(L);return L+=2,Ee}function z(){var Ee=U.getUint32(L);return L+=4,Ee}function G(Ee){Fe.setUint16(Ie,Ee),Ie+=2}function W(Ee){Fe.setUint32(Ie,Ee),Ie+=4}for(var q={signature:z(),flavor:z(),length:z(),numTables:k(),reserved:k(),totalSfntSize:z(),majorVersion:k(),minorVersion:k(),metaOffset:z(),metaLength:z(),metaOrigLength:z(),privOffset:z(),privLength:z()},O=0;Math.pow(2,O)<=q.numTables;)O++;O--;for(var B=16*Math.pow(2,O),J=16*q.numTables-B,re=12,K=[],Q=0;Q{let[R,U]=I.split("+");R=parseInt(R,36),U=U?parseInt(U,36):0,u.set(E+=R,A[P]);for(let L=U;L--;)u.set(++E,A[P])})}}return u.get(T)||c}const d=1,f=2,m=3,v=4,g=[null,"isol","init","fina","medi"];function _(T){const A=new Uint8Array(T.length);let P=c,E=d,I=-1;for(let R=0;R65535&&R++)}return A}function y(T,A){const P=[];for(let I=0;I65535&&I++,P.push(s.U.codeToGlyph(T,R))}const E=T.GSUB;if(E){const{lookupList:I,featureList:R}=E;let U;const L=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws|ccmp)$/,k=[];R.forEach(z=>{if(L.test(z.tag))for(let G=0;G=0;k--)if(A[k]!==-1&&(!L||L(A[k])))return k;return-1}function R(L){return x(T,L)===1}function U(L,k){for(let z=0;z<3;z++)P[k*3+z]+=L[z]||0}}function x(T,A){const P=T.GDEF&&T.GDEF.glyphClassDef;return P?s.U._getGlyphClass(A,P):0}function M(...T){for(let A=0;A0},forEachGlyph(L,k,z,G){let W=0;const q=1/U.unitsPerEm*k,O=y(T,L);let B=0;const J=w(T,O);return O.forEach((re,K)=>{if(re!==-1){let Q=A[re];if(!Q){const{cmds:ue,crds:le}=s.U.glyphToPath(T,re);let _e="",Fe=0;for(let $=0,Ue=ue.length;$1?",":"")+le[Fe++]}let Ie,Ee,me,xe;if(le.length){Ie=Ee=1/0,me=xe=-1/0;for(let $=0,Ue=le.length;$me&&(me=Me),oe>xe&&(xe=oe)}}else Ie=me=Ee=xe=0;Q=A[re]={index:re,advanceWidth:T.hmtx.aWidth[re],xMin:Ie,yMin:Ee,xMax:me,yMax:xe,path:_e}}G.call(null,Q,W+J[K*3]*q,J[K*3+1]*q,B),W+=J[K*3+2]*q,z&&(W+=z*k)}B+=L.codePointAt(B)>65535?2:1}),W}};return U}return function(A){const P=new Uint8Array(A,0,4),E=s._bin.readASCII(P,0,4);if(E==="wOFF")A=e(A);else if(E==="wOF2")throw new Error("woff2 fonts not supported");return C(s.parse(A)[0])}}const B9=Td({name:"Typr Font Parser",dependencies:[O9,F9,N9],init(s,e,t){const i=s(),n=e();return t(i,n)}});/*! Custom bundle of @unicode-font-resolver/client v1.0.2 (https://github.com/lojjic/unicode-font-resolver) for use in Troika text rendering. Original MIT license applies */function z9(){return function(s){var e=function(){this.buckets=new Map};e.prototype.add=function(w){var x=w>>5;this.buckets.set(x,(this.buckets.get(x)||0)|1<<(31&w))},e.prototype.has=function(w){var x=this.buckets.get(w>>5);return x!==void 0&&(x&1<<(31&w))!=0},e.prototype.serialize=function(){var w=[];return this.buckets.forEach(function(x,M){w.push((+M).toString(36)+":"+x.toString(36))}),w.join(",")},e.prototype.deserialize=function(w){var x=this;this.buckets.clear(),w.split(",").forEach(function(M){var C=M.split(":");x.buckets.set(parseInt(C[0],36),parseInt(C[1],36))})};var t=Math.pow(2,8),i=t-1,n=~i;function r(w){var x=function(C){return C&n}(w).toString(16),M=function(C){return(C&n)+t-1}(w).toString(16);return"codepoint-index/plane"+(w>>16)+"/"+x+"-"+M+".json"}function o(w,x){var M=w&i,C=x.codePointAt(M/6|0);return((C=(C||48)-48)&1<65535&&(B++,O=B)},O=0;O65535&&(re++,J=re)},J=0;J65535&&(re++,R[re]=R[re-1])}return{fontUrls:Array.from(I.keys()),chars:R}})},Object.defineProperty(s,"__esModule",{value:!0}),s}({})}function V9(s,e){const t=Object.create(null),i=Object.create(null);function n(o,a){const l=c=>{console.error(`Failure loading font ${o}`,c)};try{const c=new XMLHttpRequest;c.open("get",o,!0),c.responseType="arraybuffer",c.onload=function(){if(c.status>=400)l(new Error(c.statusText));else if(c.status>0)try{const u=s(c.response);u.src=o,a(u)}catch(u){l(u)}},c.onerror=l,c.send()}catch(c){l(c)}}function r(o,a){let l=t[o];l?a(l):i[o]?i[o].push(a):(i[o]=[a],n(o,c=>{c.src=o,t[o]=c,i[o].forEach(u=>u(c)),delete i[o]}))}return function(o,a,{lang:l,fonts:c=[],style:u="normal",weight:h="normal",unicodeFontsURL:d}={}){const f=new Uint8Array(o.length),m=[];o.length||y();const v=new Map,g=[];if(u!=="italic"&&(u="normal"),typeof h!="number"&&(h=h==="bold"?700:400),c&&!Array.isArray(c)&&(c=[c]),c=c.slice().filter(x=>!x.lang||x.lang.test(l)).reverse(),c.length){let T=0;(function A(P=0){for(let E=P,I=o.length;E{A(E)});return}if(G.supportsCodePoint(R)){let W=v.get(G);typeof W!="number"&&(W=m.length,m.push(G),v.set(G,W)),f[E]=W,T=1;break}}}R>65535&&E+1o.substring(M[0],M[1]+1)).join(` `);e.getFontsForString(x,{lang:l||void 0,style:u,weight:h,dataUrl:d}).then(({fontUrls:M,chars:C})=>{const T=m.length;let A=0;g.forEach(E=>{for(let I=0,R=E[1]-E[0];I<=R;I++)f[E[0]+I]=C[A++]+T;A++});let P=0;M.forEach((E,I)=>{r(E,R=>{m[I+T]=R,++P===M.length&&y()})})})}else y()}function y(){a({chars:f,fonts:m})}function w(x,M){for(let C=0;C{let P,E;const I=[];for(let R=0;R-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),m=m.replace(/\r\n/g,` `).replace(/\r/g,` `)),y=+y,M=+M,T=+T,C=C||"normal",E=+E,o({text:m,lang:g,style:x,weight:w,fonts:typeof v=="string"?[{src:v}]:v,unicodeFontsURL:z,preResolvedFonts:G},K=>{re.fontLoad=h()-J;const Q=isFinite(T);let ue=null,le=null,_e=null,Fe=null,Ie=null,Ee=null,me=null,xe=null,$=0,Ue=0,Me=I!=="nowrap";const oe=new Map,Te=h();let Ye=E,Oe=0,j=new d;const Z=[j];K.forEach(ye=>{const{fontObj:Ae}=ye,{ascender:Ce,descender:Ge,unitsPerEm:De,lineGap:Ve,capHeight:ze,xHeight:Ze}=Ae;let Le=oe.get(Ae);if(!Le){const ve=y/De,be=C==="normal"?(Ce-Ge+Ve)*ve:C*y,Xe=(be-(Ce-Ge)*ve)/2,We=Math.min(be,(Ce-Ge)*ve),Be=(Ce+Ge)/2*ve+We/2;Le={index:oe.size,src:Ae.src,fontObj:Ae,fontSizeMult:ve,unitsPerEm:De,ascender:Ce*ve,descender:Ge*ve,capHeight:ze*ve,xHeight:Ze*ve,lineHeight:be,baseline:-Xe-Ce*ve,caretTop:Be,caretBottom:Be-We},oe.set(Ae,Le)}const{fontSizeMult:ot}=Le,tt=m.slice(ye.start,ye.end+1);let mt,ce;Ae.forEachGlyph(tt,y,M,(ve,be,Xe,We)=>{be+=Oe,We+=ye.start,mt=be,ce=ve;const Be=m.charAt(We),ut=ve.advanceWidth*ot,gt=j.count;let nt;if("isEmpty"in ve||(ve.isWhitespace=!!Be&&new RegExp(n).test(Be),ve.canBreakAfter=!!Be&&r.test(Be),ve.isEmpty=ve.xMin===ve.xMax||ve.yMin===ve.yMax||i.test(Be)),!ve.isWhitespace&&!ve.isEmpty&&Ue++,Me&&Q&&!ve.isWhitespace&&be+ut+Ye>T&>){if(j.glyphAt(gt-1).glyphObj.canBreakAfter)nt=new d,Ye=-be;else for(let at=gt;at--;)if(at===0&&R==="break-word"){nt=new d,Ye=-be;break}else if(j.glyphAt(at).glyphObj.canBreakAfter){nt=j.splitAt(at+1);const ft=nt.glyphAt(0).x;Ye-=ft;for(let Qe=nt.count;Qe--;)nt.glyphAt(Qe).x-=ft;break}nt&&(j.isSoftWrapped=!0,j=nt,Z.push(j),$=T)}let je=j.glyphAt(j.count);je.glyphObj=ve,je.x=be+Ye,je.y=Xe,je.width=ut,je.charIndex=We,je.fontData=Le,Be===` `&&(j=new d,Z.push(j),Ye=-(be+ut+M*y)+E)}),Oe=mt+ce.advanceWidth*ot+M*y});let pe=0;Z.forEach(ye=>{let Ae=!0;for(let Ce=ye.count;Ce--;){const Ge=ye.glyphAt(Ce);Ae&&!Ge.glyphObj.isWhitespace&&(ye.width=Ge.x+Ge.width,ye.width>$&&($=ye.width),Ae=!1);let{lineHeight:De,capHeight:Ve,xHeight:ze,baseline:Ze}=Ge.fontData;De>ye.lineHeight&&(ye.lineHeight=De);const Le=Ze-ye.baseline;Le<0&&(ye.baseline+=Le,ye.cap+=Le,ye.ex+=Le),ye.cap=Math.max(ye.cap,ye.baseline+Ve),ye.ex=Math.max(ye.ex,ye.baseline+ze)}ye.baseline-=pe,ye.cap-=pe,ye.ex-=pe,pe+=ye.lineHeight});let he=0,te=0;if(U&&(typeof U=="number"?he=-U:typeof U=="string"&&(he=-$*(U==="left"?0:U==="center"?.5:U==="right"?1:c(U)))),L&&(typeof L=="number"?te=-L:typeof L=="string"&&(te=L==="top"?0:L==="top-baseline"?-Z[0].baseline:L==="top-cap"?-Z[0].cap:L==="top-ex"?-Z[0].ex:L==="middle"?pe/2:L==="bottom"?pe:L==="bottom-baseline"?-Z[Z.length-1].baseline:c(L)*pe)),!k){const ye=e.getEmbeddingLevels(m,A);ue=new Uint16Array(Ue),le=new Uint8Array(Ue),_e=new Float32Array(Ue*2),Fe={},me=[1/0,1/0,-1/0,-1/0],xe=[],W&&(Ee=new Float32Array(m.length*4)),O&&(Ie=new Uint8Array(Ue*3));let Ae=0,Ce=-1,Ge=-1,De,Ve;if(Z.forEach((ze,Ze)=>{let{count:Le,width:ot}=ze;if(Le>0){let tt=0;for(let We=Le;We--&&ze.glyphAt(We).glyphObj.isWhitespace;)tt++;let mt=0,ce=0;if(P==="center")mt=($-ot)/2;else if(P==="right")mt=$-ot;else if(P==="justify"&&ze.isSoftWrapped){let We=0;for(let Be=Le-tt;Be--;)ze.glyphAt(Be).glyphObj.isWhitespace&&We++;ce=($-ot)/We}if(ce||mt){let We=0;for(let Be=0;Be=Be){let at=je,ft=je;for(;ftut)break;ftbe=We;for(let We=0;We1&&u(Ee,Ce,Qe),Ce=nt}if(O){const{charIndex:nt}=Be;for(;nt>Ge;)Ge++,O.hasOwnProperty(Ge)&&(Ve=O[Ge])}if(!be.isWhitespace&&!be.isEmpty){const nt=Ae++,{fontSizeMult:je,src:at,index:ft}=Be.fontData,Qe=Fe[at]||(Fe[at]={});Qe[ut]||(Qe[ut]={path:be.path,pathBounds:[be.xMin,be.yMin,be.xMax,be.yMax]});const bt=Be.x+he,yt=Be.y+ze.baseline+te;_e[nt*2]=bt,_e[nt*2+1]=yt;const Rt=bt+be.xMin*je,on=yt+be.yMin*je,zt=bt+be.xMax*je,Qt=yt+be.yMax*je;Rtme[2]&&(me[2]=zt),Qt>me[3]&&(me[3]=Qt),nt%q===0&&(De={start:nt,end:nt,rect:[1/0,1/0,-1/0,-1/0]},xe.push(De)),De.end++;const Kt=De.rect;if(RtKt[2]&&(Kt[2]=zt),Qt>Kt[3]&&(Kt[3]=Qt),ue[nt]=ut,le[nt]=ft,O){const nn=nt*3;Ie[nn]=Ve>>16&255,Ie[nn+1]=Ve>>8&255,Ie[nn+2]=Ve&255}}}}}),Ee){const ze=m.length-Ce;ze>1&&u(Ee,Ce,ze)}}const Se=[];oe.forEach(({index:ye,src:Ae,unitsPerEm:Ce,ascender:Ge,descender:De,lineHeight:Ve,capHeight:ze,xHeight:Ze})=>{Se[ye]={src:Ae,unitsPerEm:Ce,ascender:Ge,descender:De,lineHeight:Ve,capHeight:ze,xHeight:Ze}}),re.typesetting=h()-Te,B({glyphIds:ue,glyphFontIndices:le,glyphPositions:_e,glyphData:Fe,fontData:Se,caretPositions:Ee,glyphColors:Ie,chunkedBounds:xe,fontSize:y,topBaseline:te+Z[0].baseline,blockBounds:[he,te-pe,he+$,te],visibleBounds:me,timings:re})})}function l(m,v){a({...m,metricsOnly:!0},g=>{const[_,y,w,x]=g.blockBounds;v({width:w-_,height:x-y})})}function c(m){let v=m.match(/^([\d.]+)%$/),g=v?parseFloat(v[1]):NaN;return isNaN(g)?0:g/100}function u(m,v,g){const _=m[v*4],y=m[v*4+1],w=m[v*4+2],x=m[v*4+3],M=(y-_)/g;for(let C=0;C(Object.defineProperty(m,v,{get(){return this.data[this.index*f.length+g]},set(y){this.data[this.index*f.length+g]=y}}),m),{data:null,index:0}),{typeset:a,measure:l}}const Su=()=>(self.performance||Date).now(),Y_=z_();let IL;function W9(s,e,t,i,n,r,o,a,l,c,u=!0){return u?Y9(s,e,t,i,n,r,o,a,l,c).then(null,h=>(IL||(console.warn("WebGL SDF generation failed, falling back to JS",h),IL=!0),kL(s,e,t,i,n,r,o,a,l,c))):kL(s,e,t,i,n,r,o,a,l,c)}const j_=[],X9=5;let FS=0;function LL(){const s=Su();for(;j_.length&&Su()-snew Promise((e,t)=>{j_.push(()=>{const i=Su();try{Y_.webgl.generateIntoCanvas(...s),e({timing:Su()-i})}catch(n){t(n)}}),FS||(FS=setTimeout(LL,0))}),j9=4,q9=2e3,UL={};let Z9=0;function kL(s,e,t,i,n,r,o,a,l,c){const u="TroikaTextSDFGenerator_JS_"+Z9++%j9;let h=UL[u];return h||(h=UL[u]={workerModule:Td({name:u,workerId:u,dependencies:[z_,Su],init(d,f){const m=d().javascript.generate;return function(...v){const g=f();return{textureData:m(...v),timing:f()-g}}},getTransferables(d){return[d.textureData.buffer]}}),requests:0,idleTimer:null}),h.requests++,clearTimeout(h.idleTimer),h.workerModule(s,e,t,i,n,r).then(({textureData:d,timing:f})=>{const m=Su(),v=new Uint8Array(d.length*4);for(let g=0;g{A9(u)},q9)),{timing:f}})}function K9(s){s._warm||(Y_.webgl.isSupported(s),s._warm=!0)}const $9=Y_.webglUtils.resizeWebGLCanvasWithoutClearing,$p={unicodeFontsURL:null,sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},J9=new rt;function Ad(){return(self.performance||Date).now()}const OL=Object.create(null);function FL(s,e){s=tY({},s);const t=Ad(),i=[];if(s.font&&i.push({label:"user",src:nY(s.font)}),s.font=i,s.text=""+s.text,s.sdfGlyphSize=s.sdfGlyphSize||$p.sdfGlyphSize,s.unicodeFontsURL=s.unicodeFontsURL||$p.unicodeFontsURL,s.colorRanges!=null){let h={};for(let d in s.colorRanges)if(s.colorRanges.hasOwnProperty(d)){let f=s.colorRanges[d];typeof f!="number"&&(f=J9.set(f).getHex()),h[d]=f}s.colorRanges=h}Object.freeze(s);const{textureWidth:n,sdfExponent:r}=$p,{sdfGlyphSize:o}=s,a=n/o*4;let l=OL[o];if(!l){const h=document.createElement("canvas");h.width=n,h.height=o*256/a,l=OL[o]={glyphCount:0,sdfGlyphSize:o,sdfCanvas:h,sdfTexture:new ni(h,void 0,void 0,void 0,bn,bn),contextLost:!1,glyphsByFont:new Map},l.sdfTexture.generateMipmaps=!1,Q9(l)}const{sdfTexture:c,sdfCanvas:u}=l;iY(s).then(h=>{const{glyphIds:d,glyphFontIndices:f,fontData:m,glyphPositions:v,fontSize:g,timings:_}=h,y=[],w=new Float32Array(d.length*4);let x=0,M=0;const C=Ad(),T=m.map(R=>{let U=l.glyphsByFont.get(R.src);return U||l.glyphsByFont.set(R.src,U=new Map),U});d.forEach((R,U)=>{const L=f[U],{src:k,unitsPerEm:z}=m[L];let G=T[L].get(R);if(!G){const{path:J,pathBounds:re}=h.glyphData[k][R],K=Math.max(re[2]-re[0],re[3]-re[1])/o*($p.sdfMargin*o+.5),Q=l.glyphCount++,ue=[re[0]-K,re[1]-K,re[2]+K,re[3]+K];T[L].set(R,G={path:J,atlasIndex:Q,sdfViewBox:ue}),y.push(G)}const{sdfViewBox:W}=G,q=v[M++],O=v[M++],B=g/z;w[x++]=q+W[0]*B,w[x++]=O+W[1]*B,w[x++]=q+W[2]*B,w[x++]=O+W[3]*B,d[U]=G.atlasIndex}),_.quads=(_.quads||0)+(Ad()-C);const A=Ad();_.sdf={};const P=u.height,E=Math.ceil(l.glyphCount/a),I=Math.pow(2,Math.ceil(Math.log2(E*o)));I>P&&(console.info(`Increasing SDF texture size ${P}->${I}`),$9(u,n,I),c.dispose()),Promise.all(y.map(R=>NL(R,l,s.gpuAccelerateSDF).then(({timing:U})=>{_.sdf[R.atlasIndex]=U}))).then(()=>{y.length&&!l.contextLost&&(BL(l),c.needsUpdate=!0),_.sdfTotal=Ad()-A,_.total=Ad()-t,e(Object.freeze({parameters:s,sdfTexture:c,sdfGlyphSize:o,sdfExponent:r,glyphBounds:w,glyphAtlasIndices:d,glyphColors:h.glyphColors,caretPositions:h.caretPositions,chunkedBounds:h.chunkedBounds,ascender:h.ascender,descender:h.descender,lineHeight:h.lineHeight,capHeight:h.capHeight,xHeight:h.xHeight,topBaseline:h.topBaseline,blockBounds:h.blockBounds,visibleBounds:h.visibleBounds,timings:h.timings}))})}),Promise.resolve().then(()=>{l.contextLost||K9(u)})}function NL({path:s,atlasIndex:e,sdfViewBox:t},{sdfGlyphSize:i,sdfCanvas:n,contextLost:r},o){if(r)return Promise.resolve({timing:-1});const{textureWidth:a,sdfExponent:l}=$p,c=Math.max(t[2]-t[0],t[3]-t[1]),u=Math.floor(e/4),h=u%(a/i)*i,d=Math.floor(u/(a/i))*i,f=e%4;return W9(i,i,s,t,c,l,n,h,d,f,o)}function Q9(s){const e=s.sdfCanvas;e.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),s.contextLost=!0}),e.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),s.contextLost=!1;const i=[];s.glyphsByFont.forEach(n=>{n.forEach(r=>{i.push(NL(r,s,!0))})}),Promise.all(i).then(()=>{BL(s),s.sdfTexture.needsUpdate=!0})})}function eY({font:s,characters:e,sdfGlyphSize:t},i){let n=Array.isArray(e)?e.join(` `):""+e;FL({font:s,sdfGlyphSize:t,text:n},i)}function tY(s,e){for(let t in e)e.hasOwnProperty(t)&&(s[t]=e[t]);return s}let q_;function nY(s){return q_||(q_=typeof document>"u"?{}:document.createElement("a")),q_.href=s,q_.href}function BL(s){if(typeof createImageBitmap!="function"){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:t}=s,{width:i,height:n}=e,r=s.sdfCanvas.getContext("webgl");let o=t.image.data;(!o||o.length!==i*n*4)&&(o=new Uint8Array(i*n*4),t.image={width:i,height:n,data:o},t.flipY=!1,t.isDataTexture=!0),r.readPixels(0,0,i,n,r.RGBA,r.UNSIGNED_BYTE,o)}}const iY=Td({name:"Typesetter",dependencies:[Td({name:"Typesetter",dependencies:[H9,G9,OI],init(s,e,t){return s(e,t())}})],init(s){return function(e){return new Promise(t=>{s.typeset(e,t)})}},getTransferables(s){const e=[];for(let t in s)s[t]&&s[t].buffer&&e.push(s[t].buffer);return e}}),zL={};function rY(s){let e=zL[s];return e||(e=zL[s]=new es(1,1,s,s).translate(.5,.5,0)),e}const sY="aTroikaGlyphBounds",VL="aTroikaGlyphIndex",oY="aTroikaGlyphColor";class aY extends _p{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new fi,this.boundingBox=new yn}computeBoundingSphere(){}computeBoundingBox(){}set detail(e){if(e!==this._detail){this._detail=e,(typeof e!="number"||e<1)&&(e=1);let t=rY(e);["position","normal","uv"].forEach(i=>{this.attributes[i]=t.attributes[i].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,i,n,r){this.updateAttributeData(sY,e,4),this.updateAttributeData(VL,t,1),this.updateAttributeData(oY,r,3),this._blockBounds=i,this._chunkedBounds=n,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:i}=this;if(t){const{PI:n,floor:r,min:o,max:a,sin:l,cos:c}=Math,u=n/2,h=n*2,d=Math.abs(t),f=e[0]/d,m=e[2]/d,v=r((f+u)/h)!==r((m+u)/h)?-d:o(l(f)*d,l(m)*d),g=r((f-u)/h)!==r((m-u)/h)?d:a(l(f)*d,l(m)*d),_=r((f+n)/h)!==r((m+n)/h)?d*2:a(d-c(f)*d,d-c(m)*d);i.min.set(v,e[1],t<0?-_:0),i.max.set(g,e[3],t<0?0:_)}else i.min.set(e[0],e[1],0),i.max.set(e[2],e[3],0);i.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(VL).count,i=this._chunkedBounds;if(i)for(let n=i.length;n--;){t=i[n].end;let r=i[n].rect;if(r[1]e.y&&r[0]e.x)break}this.instanceCount=t}updateAttributeData(e,t,i){const n=this.getAttribute(e);t?n&&n.array.length===t.length?(n.array.set(t),n.needsUpdate=!0):(this.setAttribute(e,new Zo(t,i)),delete this._maxInstanceCount,this.dispose()):n&&this.deleteAttribute(e)}}const lY=` uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform vec4 uTroikaTotalBounds; uniform vec4 uTroikaClipRect; uniform mat3 uTroikaOrient; uniform bool uTroikaUseGlyphColors; uniform float uTroikaDistanceOffset; uniform float uTroikaBlurRadius; uniform vec2 uTroikaPositionOffset; uniform float uTroikaCurveRadius; attribute vec4 aTroikaGlyphBounds; attribute float aTroikaGlyphIndex; attribute vec3 aTroikaGlyphColor; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec3 vTroikaGlyphColor; varying vec2 vTroikaGlyphDimensions; `,cY=` vec4 bounds = aTroikaGlyphBounds; bounds.xz += uTroikaPositionOffset.x; bounds.yw -= uTroikaPositionOffset.y; vec4 outlineBounds = vec4( bounds.xy - uTroikaDistanceOffset - uTroikaBlurRadius, bounds.zw + uTroikaDistanceOffset + uTroikaBlurRadius ); vec4 clippedBounds = vec4( clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw), clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw) ); vec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy); position.xy = mix(bounds.xy, bounds.zw, clippedXY); uv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy); float rad = uTroikaCurveRadius; if (rad != 0.0) { float angle = position.x / rad; position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad); normal.xz = vec2(sin(angle), cos(angle)); } position = uTroikaOrient * position; normal = uTroikaOrient * normal; vTroikaGlyphUV = clippedXY.xy; vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]); float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize; vec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize; vec2 txStartUV = txUvPerSquare * vec2( mod(floor(aTroikaGlyphIndex / 4.0), txCols), floor(floor(aTroikaGlyphIndex / 4.0) / txCols) ); vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare); vTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0); `,uY=` uniform sampler2D uTroikaSDFTexture; uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform float uTroikaSDFExponent; uniform float uTroikaDistanceOffset; uniform float uTroikaFillOpacity; uniform float uTroikaOutlineOpacity; uniform float uTroikaBlurRadius; uniform vec3 uTroikaStrokeColor; uniform float uTroikaStrokeWidth; uniform float uTroikaStrokeOpacity; uniform bool uTroikaSDFDebug; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec2 vTroikaGlyphDimensions; float troikaSdfValueToSignedDistance(float alpha) { // Inverse of exponential encoding in webgl-sdf-generator float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y); float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension; float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0); return signedDist; } float troikaGlyphUvToSdfValue(vec2 glyphUV) { vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV); vec4 rgba = texture2D(uTroikaSDFTexture, textureUV); float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1 return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a; } float troikaGlyphUvToDistance(vec2 uv) { return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv)); } float troikaGetAADist() { #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300 return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5; #else return vTroikaGlyphDimensions.x / 64.0; #endif } float troikaGetFragDistValue() { vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize); float distance = troikaGlyphUvToDistance(clampedGlyphUV); // Extrapolate distance when outside bounds: distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions); return distance; } float troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) { #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL) float alpha = step(-distanceOffset, -distance); #else float alpha = smoothstep( distanceOffset + aaDist, distanceOffset - aaDist, distance ); #endif return alpha; } `,hY=` float aaDist = troikaGetAADist(); float fragDistance = troikaGetFragDistValue(); float edgeAlpha = uTroikaSDFDebug ? troikaGlyphUvToSdfValue(vTroikaGlyphUV) : troikaGetEdgeAlpha(fragDistance, uTroikaDistanceOffset, max(aaDist, uTroikaBlurRadius)); #if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL) vec4 fillRGBA = gl_FragColor; fillRGBA.a *= uTroikaFillOpacity; vec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity); if (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb; gl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep( -uTroikaStrokeWidth - aaDist, -uTroikaStrokeWidth + aaDist, fragDistance )); gl_FragColor.a *= edgeAlpha; #endif if (edgeAlpha == 0.0) { discard; } `;function dY(s){const e=OS(s,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new Ne},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new Zt(0,0,0,0)},uTroikaClipRect:{value:new Zt(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new Ne},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new rt},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new Jt},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:lY,vertexTransform:cY,fragmentDefs:uY,fragmentColorTransform:hY,customRewriter({vertexShader:t,fragmentShader:i}){let n=/\buniform\s+vec3\s+diffuse\b/;return n.test(i)&&(i=i.replace(n,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),n.test(t)||(t=t.replace(AL,`uniform vec3 diffuse; $& vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse; `))),{vertexShader:t,fragmentShader:i}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const NS=new Jn({color:16777215,side:Ei,transparent:!0}),GL=8421504,HL=new _t,Z_=new X,BS=new X,Jp=[],fY=new X,zS="+x+y";function WL(s){return Array.isArray(s)?s[0]:s}let XL=()=>{const s=new it(new es(1,1),NS);return XL=()=>s,s},YL=()=>{const s=new it(new es(1,1,32,1),NS);return YL=()=>s,s};const pY={type:"syncstart"},mY={type:"synccomplete"},jL=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],gY=jL.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let qL=class extends it{constructor(){const e=new aY;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=GL,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=zS,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(pY),FL({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const i=this._queuedSyncs;i&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{i.forEach(n=>n&&n())})),this.dispatchEvent(mY),e&&e()})))}onBeforeRender(e,t,i,n,r,o){this.sync(),r.isTroikaTextMaterial&&this._prepareForRender(r)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return dY(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=NS.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function i(){t.removeEventListener("dispose",i),e.dispose()})),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let i=e._outlineMtl;return i||(i=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),i.isTextOutlineMaterial=!0,i.depthWrite=!1,i.map=null,e.addEventListener("dispose",function n(){e.removeEventListener("dispose",n),i.dispose()})),[i,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return WL(this.material).getDepthMaterial()}get customDistanceMaterial(){return WL(this.material).getDistanceMaterial()}_prepareForRender(e){const t=e.isTextOutlineMaterial,i=e.uniforms,n=this.textRenderInfo;if(n){const{sdfTexture:a,blockBounds:l}=n;i.uTroikaSDFTexture.value=a,i.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),i.uTroikaSDFGlyphSize.value=n.sdfGlyphSize,i.uTroikaSDFExponent.value=n.sdfExponent,i.uTroikaTotalBounds.value.fromArray(l),i.uTroikaUseGlyphColors.value=!t&&!!n.glyphColors;let c=0,u=0,h=0,d,f,m,v=0,g=0;if(t){let{outlineWidth:y,outlineOffsetX:w,outlineOffsetY:x,outlineBlur:M,outlineOpacity:C}=this;c=this._parsePercent(y)||0,u=Math.max(0,this._parsePercent(M)||0),d=C,v=this._parsePercent(w)||0,g=this._parsePercent(x)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(m=this.strokeColor,i.uTroikaStrokeColor.value.set(m??GL),f=this.strokeOpacity,f==null&&(f=1)),d=this.fillOpacity;i.uTroikaDistanceOffset.value=c,i.uTroikaPositionOffset.value.set(v,g),i.uTroikaBlurRadius.value=u,i.uTroikaStrokeWidth.value=h,i.uTroikaStrokeOpacity.value=f,i.uTroikaFillOpacity.value=d??1,i.uTroikaCurveRadius.value=this.curveRadius||0;let _=this.clipRect;if(_&&Array.isArray(_)&&_.length===4)i.uTroikaClipRect.value.fromArray(_);else{const y=(this.fontSize||.1)*100;i.uTroikaClipRect.value.set(l[0]-y,l[1]-y,l[2]+y,l[3]+y)}this.geometry.applyClipRect(i.uTroikaClipRect.value)}i.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const r=t?this.outlineColor||0:this.color;if(r==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new rt;(r!==a._input||typeof r=="object")&&a.set(a._input=r)}let o=this.orientation||zS;if(o!==e._orientation){let a=i.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let l=o!==zS&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,u,h,d]=l;Z_.set(0,0,0)[u]=c==="-"?1:-1,BS.set(0,0,0)[d]=h==="-"?-1:1,HL.lookAt(fY,Z_.cross(BS),BS),a.setFromMatrix4(HL)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),i=t?parseFloat(t[1]):NaN;e=(isNaN(i)?0:i/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new Ne){t.copy(e);const i=this.curveRadius;return i&&(t.x=Math.atan2(e.x,Math.abs(i)-Math.abs(e.z))*Math.abs(i)),t}worldPositionToTextCoords(e,t=new Ne){return Z_.copy(e),this.localPositionToTextCoords(this.worldToLocal(Z_),t)}raycast(e,t){const{textRenderInfo:i,curveRadius:n}=this;if(i){const r=i.blockBounds,o=n?YL():XL(),a=o.geometry,{position:l,uv:c}=a.attributes;for(let u=0;u{this[i]=e[i]}),this}clone(){return new this.constructor().copy(this)}};jL.forEach(s=>{const e="_private_"+s;Object.defineProperty(qL.prototype,s,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})}),new yn,new rt;function ZL(s,e){if(new.target)return Tt({component:ZL,...s});Mt(e,!0);let t=H(e,"font",7),i=H(e,"characters",7),n=H(e,"sdfGlyphSize",7),r=H(e,"ref",15),o=H(e,"onsync",7),a=H(e,"children",7),l=an(e,["$$slots","$$events","$$legacy","$$host","font","characters","sdfGlyphSize","ref","onsync","children"]);const c=new qL,{invalidate:u}=un(),h=async()=>{await Py(),c.sync(()=>{var m;u(),(m=o())==null||m()})},d=["text","anchorX","anchorY","curveRadius","direction","font","fontSize","letterSpacing","lineHeight","maxWidth","overflowWrap","textAlign","textIndent","whiteSpace","material","color","depthOffset","clipRect","glyphGeometryDetail","sdfGlyphSize","outlineWidth","outlineColor","outlineOpacity","outlineBlur","outlineOffsetX","outlineOffsetY","strokeWidth","strokeColor","strokeOpacity","fillOpacity","characters","colorRanges"];Gs(()=>d.map(m=>l[m]),()=>{h()});const f=Ml();return $e(()=>{f(new Promise(m=>eY({font:t(),characters:i(),sdfGlyphSize:n()},m)))}),pt(s,rn({is:c},()=>l,{get font(){return t()},get characters(){return i()},get sdfGlyphSize(){return n()},get ref(){return r()},set ref(m){r(m)},children:(m,v)=>{var g=Lt(),_=dt(g);Wt(_,()=>a()??Nt,()=>({ref:c})),lt(m,g)},$$slots:{default:!0}})),Et({get font(){return t()},set font(m){t(m),V()},get characters(){return i()},set characters(m){i(m),V()},get sdfGlyphSize(){return n()},set sdfGlyphSize(m){n(m),V()},get ref(){return r()},set ref(m){r(m),V()},get onsync(){return o()},set onsync(m){o(m),V()},get children(){return a()},set children(m){a(m),V()},$set:Ct,$on:(m,v)=>At(e,m,v)})}Pt(ZL,{font:{},characters:{},sdfGlyphSize:{},ref:{},onsync:{},children:{}},[],[],!0);const Mu=new Map,vY={audioListeners:Mu,addAudioListener:(s,e="default")=>{if(Mu.has(e)){console.warn(`An AudioListener with the id "${e}" has already been added, aborting.`);return}Mu.set(e,s)},removeAudioListener:(s="default")=>{if(!Mu.has(s)){console.warn(`No AudioListener with the id "${s}" found, aborting.`);return}Mu.delete(s)},getAudioListener:(s="default")=>{if(!Mu.has(s)){console.warn(`No AudioListener with the id "${s}" found, aborting.`);return}return Mu.get(s)}};function VS(){return aw("threlte-audio",vY)}function KL(s,e){if(new.target)return Tt({component:KL,...s});Mt(e,!0);let t=H(e,"id",7),i=H(e,"masterVolume",7),n=H(e,"ref",15),r=H(e,"children",7),o=an(e,["$$slots","$$events","$$legacy","$$host","id","masterVolume","ref","children"]);const a=new gP,l=a.context,c=()=>a.context.resume();$e(()=>{i()!==void 0&&a.setMasterVolume(i())});const{addAudioListener:u,removeAudioListener:h}=VS();return u(a,t()),Ui(()=>{h(t())}),pt(s,rn({is:a},()=>o,{get ref(){return n()},set ref(d){n(d)},children:(d,f)=>{var m=Lt(),v=dt(m);Wt(v,()=>r()??Nt,()=>({ref:a})),lt(d,m)},$$slots:{default:!0}})),Et({audioContext:l,resumeContext:c,get id(){return t()},set id(d){t(d),V()},get masterVolume(){return i()},set masterVolume(d){i(d),V()},get ref(){return n()},set ref(d){n(d),V()},get children(){return r()},set children(d){r(d),V()},$set:Ct,$on:(d,f)=>At(e,d,f)})}Pt(KL,{id:{},masterVolume:{},ref:{},children:{}},[],["audioContext","resumeContext"],!0);const $L=(s,e={})=>{const t=Yn(!1),i=Yn(!1),n=Yn(!1);let r=!1;const o=bp(uP),a=async g=>{var _,y,w;t.set(!1);try{if(typeof g=="string"){const x=await o.load(g,{onProgress(M){var C;(C=e.onprogress)==null||C.call(e,M)}});s.setBuffer(x)}else g instanceof AudioBuffer?s.setBuffer(g):g instanceof HTMLMediaElement?s.setMediaElementSource(g):g instanceof AudioBufferSourceNode?s.setNodeSource(g):g instanceof MediaStream&&s.setMediaStreamSource(g);t.set(!0),s.buffer?(_=e.onload)==null||_.call(e,s.buffer):(y=e.onload)==null||y.call(e)}catch(x){(w=e.onerror)==null||w.call(e,x)}},l=g=>{s.setVolume(g??1)},c=g=>{s.setPlaybackRate(g??1)},u=async g=>{if(!t.current){n.set(!0);return}if(!(s.context.state!=="running"&&(await s.context.resume(),r)))return s.play(g)},h=()=>s.pause(),d=()=>s.source?s.stop():s,f=g=>{i.set(g??!1)},m=g=>{s.source&&s.detune&&s.setDetune(g??0)},v=g=>{s.setLoop(g??!1)};return pi([t,i,n],([g,_,y])=>{if(!g){s.isPlaying&&d();return}(_||y)&&u()}),Ui(()=>{try{r=!0,d()}catch(g){console.warn("Error while destroying audio",g)}}),{setVolume:l,setSrc:a,setPlaybackRate:c,setAutoPlay:f,setDetune:m,setLoop:v,play:u,pause:h,stop:d}};function JL(s,e){if(new.target)return Tt({component:JL,...s});Mt(e,!0);let t=H(e,"src",7),i=H(e,"id",7),n=H(e,"volume",7),r=H(e,"playbackRate",7),o=H(e,"autoplay",7),a=H(e,"detune",7),l=H(e,"loop",7),c=H(e,"ref",15),u=H(e,"children",7),h=an(e,["$$slots","$$events","$$legacy","$$host","src","id","volume","playbackRate","autoplay","detune","loop","ref","children"]);const{getAudioListener:d}=VS(),f=d(i());if(!f)throw new Error(`No Audiolistener with id ${i()} found.`);const m=new U1(f),{setAutoPlay:v,setDetune:g,setLoop:_,setPlaybackRate:y,setSrc:w,setVolume:x,...M}=$L(m,h),C=M.pause,T=M.play,A=M.stop;return Ht(()=>v(o())),Ht(()=>void w(t())),Ht(()=>x(n())),Ht(()=>y(r())),Ht(()=>_(l())),Ht(()=>g(a())),pt(s,rn({is:m},()=>h,{get ref(){return c()},set ref(P){c(P)},children:(P,E)=>{var I=Lt(),R=dt(I);Wt(R,()=>u()??Nt,()=>({ref:m})),lt(P,I)},$$slots:{default:!0}})),Et({pause:C,play:T,stop:A,get src(){return t()},set src(P){t(P),V()},get id(){return i()},set id(P){i(P),V()},get volume(){return n()},set volume(P){n(P),V()},get playbackRate(){return r()},set playbackRate(P){r(P),V()},get autoplay(){return o()},set autoplay(P){o(P),V()},get detune(){return a()},set detune(P){a(P),V()},get loop(){return l()},set loop(P){l(P),V()},get ref(){return c()},set ref(P){c(P),V()},get children(){return u()},set children(P){u(P),V()},$set:Ct,$on:(P,E)=>At(e,P,E)})}Pt(JL,{src:{},id:{},volume:{},playbackRate:{},autoplay:{},detune:{},loop:{},ref:{},children:{}},[],["pause","play","stop"],!0);function QL(s,e){if(new.target)return Tt({component:QL,...s});Mt(e,!0);let t=H(e,"src",7),i=H(e,"id",7),n=H(e,"volume",7),r=H(e,"playbackRate",7),o=H(e,"autoplay",7),a=H(e,"detune",7),l=H(e,"loop",7),c=H(e,"directionalCone",7),u=H(e,"refDistance",7),h=H(e,"rolloffFactor",7),d=H(e,"distanceModel",7),f=H(e,"maxDistance",7),m=H(e,"ref",15),v=H(e,"children",7),g=an(e,["$$slots","$$events","$$legacy","$$host","src","id","volume","playbackRate","autoplay","detune","loop","directionalCone","refDistance","rolloffFactor","distanceModel","maxDistance","ref","children"]);const{getAudioListener:_}=VS(),y=_(i());if(!y)throw new Error(`No Audiolistener with id ${i()} found.`);const w=new _P(y);Ht(()=>{u()!==void 0&&w.setRefDistance(u()),h()!==void 0&&w.setRolloffFactor(h()),d()!==void 0&&w.setDistanceModel(d()),f()!==void 0&&w.setMaxDistance(f()),c()!==void 0&&w.setDirectionalCone(c().coneInnerAngle,c().coneOuterAngle,c().coneOuterGain)});const{setAutoPlay:x,setDetune:M,setLoop:C,setPlaybackRate:T,setSrc:A,setVolume:P,...E}=$L(w,g),I=E.pause,R=E.play,U=E.stop;return Ht(()=>x(o())),Ht(()=>void A(t())),Ht(()=>P(n())),Ht(()=>T(r())),Ht(()=>C(l())),Ht(()=>M(a())),pt(s,rn({is:w},()=>g,{get ref(){return m()},set ref(L){m(L)},children:(L,k)=>{var z=Lt(),G=dt(z);Wt(G,()=>v()??Nt,()=>({ref:w})),lt(L,z)},$$slots:{default:!0}})),Et({pause:I,play:R,stop:U,get src(){return t()},set src(L){t(L),V()},get id(){return i()},set id(L){i(L),V()},get volume(){return n()},set volume(L){n(L),V()},get playbackRate(){return r()},set playbackRate(L){r(L),V()},get autoplay(){return o()},set autoplay(L){o(L),V()},get detune(){return a()},set detune(L){a(L),V()},get loop(){return l()},set loop(L){l(L),V()},get directionalCone(){return c()},set directionalCone(L){c(L),V()},get refDistance(){return u()},set refDistance(L){u(L),V()},get rolloffFactor(){return h()},set rolloffFactor(L){h(L),V()},get distanceModel(){return d()},set distanceModel(L){d(L),V()},get maxDistance(){return f()},set maxDistance(L){f(L),V()},get ref(){return m()},set ref(L){m(L),V()},get children(){return v()},set children(L){v(L),V()},$set:Ct,$on:(L,k)=>At(e,L,k)})}Pt(QL,{src:{},id:{},volume:{},playbackRate:{},autoplay:{},detune:{},loop:{},directionalCone:{},refDistance:{},rolloffFactor:{},distanceModel:{},maxDistance:{},ref:{},children:{}},[],["pause","play","stop"],!0);var _Y=Object.defineProperty,yY=(s,e,t)=>e in s?_Y(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Nr=(s,e,t)=>(yY(s,typeof e!="symbol"?e+"":e,t),t);const e3=/\bvoid\s+main\s*\(\s*\)\s*{/g;function GS(s){const e=/^[ \t]*#include +<([\w\d./]+)>/gm;function t(i,n){let r=Ft[n];return r?GS(r):i}return s.replace(e,t)}const Sr=[];for(let s=0;s<256;s++)Sr[s]=(s<16?"0":"")+s.toString(16);function xY(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Sr[s&255]+Sr[s>>8&255]+Sr[s>>16&255]+Sr[s>>24&255]+"-"+Sr[e&255]+Sr[e>>8&255]+"-"+Sr[e>>16&15|64]+Sr[e>>24&255]+"-"+Sr[t&63|128]+Sr[t>>8&255]+"-"+Sr[t>>16&255]+Sr[t>>24&255]+Sr[i&255]+Sr[i>>8&255]+Sr[i>>16&255]+Sr[i>>24&255]).toUpperCase()}const Eu=Object.assign||function(){let s=arguments[0];for(let e=1,t=arguments.length;es.type,set:c=>{s.type=c}},isDerivedFrom:{writable:!0,configurable:!0,value:function(c){const u=this.baseMaterial;return c===u||u.isDerivedMaterial&&u.isDerivedFrom(c)||!1}},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return s.customProgramCacheKey()+"|"+t}},onBeforeCompile:{get(){return r},set(c){this[n]=c}},copy:{writable:!0,configurable:!0,value:function(c){return s.copy.call(this,c),!s.isShaderMaterial&&!s.isDerivedMaterial&&(Eu(this.extensions,c.extensions),Eu(this.defines,c.defines),Eu(this.uniforms,pl.clone(c.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const c=new s.constructor;return a(c).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let c=this._depthMaterial;return c||(c=this._depthMaterial=K_(s.isDerivedMaterial?s.getDepthMaterial():new jc({depthPacking:Ch}),e),c.defines.IS_DEPTH_MATERIAL="",c.uniforms=this.uniforms),c}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let c=this._distanceMaterial;return c||(c=this._distanceMaterial=K_(s.isDerivedMaterial?s.getDistanceMaterial():new td,e),c.defines.IS_DISTANCE_MATERIAL="",c.uniforms=this.uniforms),c}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:c,_distanceMaterial:u}=this;c&&c.dispose(),u&&u.dispose(),s.dispose.call(this)}}};return i[t]=o,new o}function SY(s,{vertexShader:e,fragmentShader:t},i,n){let{vertexDefs:r,vertexMainIntro:o,vertexMainOutro:a,vertexTransform:l,fragmentDefs:c,fragmentMainIntro:u,fragmentMainOutro:h,fragmentColorTransform:d,customRewriter:f,timeUniform:m}=i;if(r=r||"",o=o||"",a=a||"",c=c||"",u=u||"",h=h||"",(l||f)&&(e=GS(e)),(d||f)&&(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm,` //!BEGIN_POST_CHUNK $1 $& //!END_POST_CHUNK `),t=GS(t)),f){let v=f({vertexShader:e,fragmentShader:t});e=v.vertexShader,t=v.fragmentShader}if(d){let v=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,g=>(v.push(g),"")),h=`${d} ${v.join(` `)} ${h}`}if(m){const v=` uniform float ${m}; `;r=v+r,c=v+c}return l&&(e=`vec3 troika_position_${n}; vec3 troika_normal_${n}; vec2 troika_uv_${n}; ${e} `,r=`${r} void troikaVertexTransform${n}(inout vec3 position, inout vec3 normal, inout vec2 uv) { ${l} } `,o=` troika_position_${n} = vec3(position); troika_normal_${n} = vec3(normal); troika_uv_${n} = vec2(uv); troikaVertexTransform${n}(troika_position_${n}, troika_normal_${n}, troika_uv_${n}); ${o} `,e=e.replace(/\b(position|normal|uv)\b/g,(v,g,_,y)=>/\battribute\s+vec[23]\s+$/.test(y.substr(0,_))?g:`troika_${g}_${n}`),s.map&&s.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${n}`))),e=i3(e,n,r,o,a),t=i3(t,n,c,u,h),{vertexShader:e,fragmentShader:t}}function i3(s,e,t,i,n){return(i||n||t)&&(s=s.replace(e3,` ${t} void troikaOrigMain${e}() {`),s+=` void main() { ${i} troikaOrigMain${e}(); ${n} }`),s}function MY(s,e){return s==="uniforms"?void 0:typeof e=="function"?e.toString():e}let EY=0;const r3=new Map;function TY(s){const e=JSON.stringify(s,MY);let t=r3.get(e);return t==null&&r3.set(e,t=++EY),t}const AY={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function CY(s){let e=AY[s.type];return e?Or[e]:s}function s3(s){let e=/\buniform\s+(int|float|vec[234]|mat[34])\s+([A-Za-z_][\w]*)/g,t=Object.create(null),i;for(;(i=e.exec(s))!==null;)t[i[2]]=i[1];return t}function PY(s){let e=[],t="";const i=K_(s,{chained:!0,customRewriter({vertexShader:r,fragmentShader:o}){let a=[],l=[],c=[],u=s3(r),h=s3(o);return e.forEach(d=>{let f=u[d],m=h[d];const v=f||m;if(v){const g=new RegExp(`\\buniform\\s+${v}\\s+${d}\\s*;`,"g"),_=new RegExp(`\\b${d}\\b`,"g"),y=`troika_attr_${d}`,w=`troika_vary_${d}`;if(a.push(`attribute ${v} ${y};`),f&&(r=r.replace(g,""),r=r.replace(_,y)),m){o=o.replace(g,""),o=o.replace(_,w);let x=`varying ${m} ${w};`;a.push(x),c.push(x),l.push(`${w} = ${y};`)}}}),r=`${a.join(` `)} ${r.replace(e3,` $& ${l.join(` `)}`)}`,c.length&&(o=`${c.join(` `)} ${o}`),{vertexShader:r,fragmentShader:o}}});i.setUniformNames=function(r){e=r||[];const o=e.sort().join("|");o!==t&&(t=o,this.needsUpdate=!0)};const n=i.customProgramCacheKey();return i.customProgramCacheKey=function(){return n+"|"+t},i.isInstancedUniformsMaterial=!0,i}class RY extends Jh{constructor(e,t,i){super(e,t,i),this._maxCount=i,this._instancedUniformNames=[]}get geometry(){let e=this._derivedGeometry;const t=this._baseGeometry;return(!e||e.baseGeometry!==t)&&(e=this._derivedGeometry=Object.create(t),e.baseGeometry=t,e.attributes=Object.create(t.attributes),t.addEventListener("dispose",function i(){t.removeEventListener("dispose",i),e.dispose()})),e}set geometry(e){this._baseGeometry=e}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=new Jn);return(!e||e.baseMaterial!==t)&&(e=this._derivedMaterial=PY(t),t.addEventListener("dispose",function i(){t.removeEventListener("dispose",i),e.dispose()})),e.setUniformNames(this._instancedUniformNames),e}set material(e){if(Array.isArray(e))throw new Error("InstancedUniformsMesh does not support multiple materials");for(;e&&e.isInstancedUniformsMaterial;)e=e.baseMaterial;this._baseMaterial=e}get customDepthMaterial(){return this.material.getDepthMaterial()}get customDistanceMaterial(){return this.material.getDistanceMaterial()}setUniformAt(e,t,i){const n=this.geometry.attributes,r=`troika_attr_${e}`;let o=n[r];if(!o){const a=DY(this._baseMaterial,e),l=IY(a);if(o=n[r]=new Zo(new Float32Array(l*this._maxCount),l),a!==null)for(let c=0;ct!==e)}}function o3(s,e,t){let i=s.itemSize;i===1?s.setX(e,t):i===2?s.setXY(e,t.x,t.y):i===3?t.isColor?s.setXYZ(e,t.r,t.g,t.b):s.setXYZ(e,t.x,t.y,t.z):i===4?s.setXYZW(e,t.x,t.y,t.z,t.w):t.toArray?t.toArray(s.array,e*i):s.set(t,e*i)}function DY(s,e){let t=s.uniforms;return t&&t[e]||(t=CY(s).uniforms,t&&t[e])?t[e].value:null}function IY(s){return s==null?0:typeof s=="number"?1:s.isVector2?2:s.isVector3||s.isColor?3:s.isVector4||s.isQuaternion?4:s.elements?s.elements.length:Array.isArray(s)?s.length:0}const LY=(s,e)=>{const t=s.split(` `),i=/vMapUv|vAlphaMapUv|vNormalMapUv/g;return t.map(n=>!n.includes("varying")&&!n.includes("uniform")?n.replace(i,e):n).join(` `)},UY=(s,e)=>{const t={USE_UV:""};return e&&(t.TRI_GEOMETRY=""),K_(s,{defines:t,uniforms:{animationData:{value:null},animationDataSize:{value:0},billboarding:{value:0},flipX:{value:0},flipY:{value:0},spritesheetData:{value:null},dataSize:{value:new Ne(0,0)},tint:{value:new Zt(0,0,0,0)}},vertexDefs:` uniform float billboarding; flat varying int vId; `,vertexMainOutro:` vId = gl_InstanceID; if(billboarding == 1.){ vec3 instancePosition = vec3(instanceMatrix[3]); vec3 instanceScale = vec3(length(instanceMatrix[0]), length(instanceMatrix[1]), length(instanceMatrix[2])); vec3 cameraRight_worldspace = vec3(modelViewMatrix[0][0], modelViewMatrix[1][0], modelViewMatrix[2][0]); vec3 cameraUp_worldspace = vec3(modelViewMatrix[0][1], modelViewMatrix[1][1], modelViewMatrix[2][1]); vec3 vertexPosition_worldspace = instancePosition + cameraRight_worldspace * position.x * instanceScale.x + cameraUp_worldspace * position.y * instanceScale.y; gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition_worldspace, 1.0); } `,customRewriter:({vertexShader:i,fragmentShader:n})=>(n=n.replace("void main() {",`void main() { float y = float(vId / animationDataSize) / float(animationDataSize); float x = mod(float(vId),float(animationDataSize)) / float(animationDataSize); float spritesheetFrameId = texture2D(animationData, vec2(x,y)).r; // x,y,w,h vec4 frameMeta = readData(spritesheetFrameId, 0.f); vec2 fSize = frameMeta.zw; vec2 fOffset = vec2(frameMeta.xy); vec2 transformedPlaneUv = vUv + vec2(0.,0.); // todo == 1. caused a flickering bug. look into Precision/interpolation? if(flipX > 0.){ transformedPlaneUv.x = 1. - transformedPlaneUv.x; } if(flipY > 0.){ transformedPlaneUv.y = 1. - transformedPlaneUv.y; } vec2 spriteUv = fSize * transformedPlaneUv + fOffset ; #ifdef TRI_GEOMETRY // Shift UVs if mesh uses triangle geometry // TODO optimize ugly math if(vUv.y>0.5 || vUv.x<0.25 || vUv.x>0.75){ discard; } vec2 zoomCenter = vec2(fSize.x * 0.5,0.) + fOffset; float zoomFactor = 2.; vec2 shiftedUV = spriteUv - zoomCenter; shiftedUV *= zoomFactor; shiftedUV += zoomCenter; spriteUv = shiftedUV; #endif `),n=` uniform sampler2D animationData; uniform int animationDataSize; uniform sampler2D spritesheetData; uniform float startTime; uniform float time; uniform float flipX; uniform float flipY; uniform vec2 dataSize; uniform vec4 tint; flat varying int vId; vec4 readData(float col, float row) { float wStep = 1.f / dataSize.x; float wHalfStep = wStep * 0.5f; float hStep = 1.f / dataSize.y; float hHalfStep = 1.f / dataSize.y * 0.5f; return texture2D(spritesheetData, vec2(col * wStep + wHalfStep, row * hStep + hHalfStep)); } vec2 zoomUV(vec2 uv, vec2 zoomCenter, float zoomFactor) { // Shift UVs so that the zoom center is the origin vec2 shiftedUV = uv - zoomCenter; // Scale (zoom) the UV coordinates shiftedUV *= zoomFactor; // Shift back shiftedUV += zoomCenter; return shiftedUV; } ${n} `,n=n.replace("vec4 sampledDiffuseColor = texture2D( map, vMapUv );",` vec4 sampledDiffuseColor = texture2D( map, vMapUv ); if(tint.w == 1.){ vec3 hue_term = 1.0 - min(abs(vec3(tint.x) - vec3(0,2.0,1.0)), 1.0); hue_term.x = 1.0 - dot(hue_term.yz, vec2(1)); vec3 res = vec3(dot(sampledDiffuseColor.xyz, hue_term.xyz), dot(sampledDiffuseColor.xyz, hue_term.zxy), dot(sampledDiffuseColor.xyz, hue_term.yzx)); res = mix(vec3(dot(res, vec3(0.2, 0.5, 0.3))), res, tint.y); res = res * tint.z; sampledDiffuseColor = vec4(res, sampledDiffuseColor.a); } // sampledDiffuseColor = vec4(texture2D(animationData, vUv).rgb, 1.); `),n=LY(n,"spriteUv"),{vertexShader:i,fragmentShader:n})})},kY=s=>{const{frames:e,animationLengths:t,animations:i}=s,n=Math.max(e.length,t.length,...Object.values(i).map(f=>f.length)),r=2+Object.values(i).length,o=e.flat().concat(new Array((n-e.length)*4).fill(0)),a=t.map(f=>[f,0,0,0]).flat().concat(new Array((n-t.length)*4).fill(0)),l=[],c=new Map;for(let f=0;f[...g,0,0]).flat().concat(new Array((n-i[m].length)*4).fill(0));l.push(...v)}const u=[...o,...a,...l],h=new Float32Array(u);h.set(u);const d=new gr(h,n,r,di,Un);return d.type=Un,d.minFilter=En,d.magFilter=En,d.wrapS=pr,d.wrapT=Os,d.needsUpdate=!0,{dataTexture:d,dataWidth:n,dataHeight:r,animMap:c}},OY=()=>{const s=new Gt,e=new Float32Array([0,1,0,-1,-1,0,1,-1,0]);s.setAttribute("position",new Bt(e,3));const t=new Float32Array([.5,1,0,0,1,0]);return s.setAttribute("uv",new Bt(t,2)),s.computeVertexNormals(),s},FY=new Ta(-1,1,1,-1,0,1);class NY extends Gt{constructor(){super(),this.setAttribute("position",new It([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new It([0,2,0,0,2,0],2))}}const BY=new NY;class zY{constructor(e){this._mesh=new it(BY,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,FY)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class VY{constructor(e,t,i){this.variables=[],this.currentTextureIndex=0;let n=Un;const r={passThruTexture:{value:null}},o=c(h(),r),a=new zY(o);this.setDataType=function(d){return n=d,this},this.addVariable=function(d,f,m){const v=this.createShaderMaterial(f),g={name:d,initialValueTexture:m,material:v,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:En,magFilter:En};return this.variables.push(g),g},this.setVariableDependencies=function(d,f){d.dependencies=f},this.init=function(){if(i.capabilities.maxVertexTextures===0)return"No support for vertex shader textures.";for(let d=0;d uniform sampler2D instructionsTexture; uniform sampler2D spritesheetData; uniform vec2 dataSize; uniform float fps; uniform float deltaTime; // read spritesheet metadata vec4 readData(float col, float row, sampler2D tex) { float wStep = 1.f / dataSize.x; float wHalfStep = wStep * 0.5f; float hStep = 1.f / dataSize.y; float hHalfStep = 1.f / dataSize.y * 0.5f; return texture2D(spritesheetData, vec2(col * wStep + wHalfStep, row * hStep + hHalfStep)); } void main() { // OUTPUT FROM THIS SHADER // progressValue.r - picked animation frame // progressValue.g - previous progress state (for pause, reverse & pingpong consistency) // progressValue.b - not used yet // progressValue.a - previous animationID vec2 cellSize = 1.0 / resolution.xy; vec2 uv = gl_FragCoord.xy * cellSize; vec4 progressValue = texture2D( progress, uv ); vec4 instructions = texture2D( instructionsTexture, uv); // FREEZE FRAME - return to save calculations? if(instructions.a >=10.){ progressValue.r = instructions.a - 10.; progressValue.a = instructions.x; progressValue.g = progressValue.g; gl_FragColor = progressValue; return; } progressValue.b = 0.; // todo shouldn't be rounding here, pick float animationId = round(instructions.x); float offset = instructions.g; float animLength = readData(animationId, 1.f, spritesheetData).r; float totalTime = animLength / fps; // new delta is % of animation float newProgress = deltaTime / totalTime; // add new delta to saved progress float frameTimedId = mod(progressValue.g + newProgress, 1.); // frameTimedId = 0.; // float frameTimedId = progressValue.g; // save for use in next frame float playMode = mod(instructions.b, 10.); // forward if(playMode == 0.){ frameTimedId = progressValue.g + newProgress; } // reverse if(playMode == 1.){ frameTimedId = progressValue.g - newProgress; } // 2 - pause - do nothing if(playMode == 2.){ frameTimedId = progressValue.g; } // //todo pingpong // if(playMode == 3.){ // } // loop (play once over 10.) if(instructions.b < 10.){ frameTimedId = mod(frameTimedId, 1.); } // todo This could be optional and user would reset manually, // todo allowing for consistent movement across multiple animations // todo for example - running steps being syncec // start anim from beginning if animationID changes if(progressValue.a != instructions.x){ frameTimedId = 0.; } float frameId = floor(animLength * frameTimedId); float spritesheetFrameId = readData(frameId, 2.f + animationId, spritesheetData).r; // Picked sprite frame that goes to material progressValue.r = spritesheetFrameId; progressValue.a = instructions.x; progressValue.g = frameTimedId; gl_FragColor = progressValue; } `,HY=(s=512)=>{const e=new Float32Array(s**2*4);for(let i=0;i{if(s<=0)return 1;let e=1;for(;e{const t=WY(Math.sqrt(e)),i=new VY(t,t,s),n=i.createTexture(),r=i.addVariable("progress",GY,n),o=HY(t);r.material.uniforms.instructionsTexture={value:o},r.material.uniforms.spritesheetData={value:null},r.material.uniforms.fps={value:0},r.material.uniforms.deltaTime={value:0},r.material.uniforms.dataSize={value:new Ne},i.setVariableDependencies(r,[r]);const a=i.init();a!==null&&console.error(a);let l=!1;return{gpuCompute:i,animationRunner:r,progressDataTexture:o,utils:{updateAnimationAt:(c,u)=>{const h=c*4;o.image.data[h]=u,l=!0},updateOffsetAt:(c,u)=>{const h=c*4;o.image.data[h+1]=u,l=!0},updatePlaymodeAt:(c,u)=>{const h=c*4;o.image.data[h+2]=u,l=!0},updateFrameAt:(c,u)=>{const h=c*4;o.image.data[h+3]=u+10,l=!0}},update:()=>{l&&(o.needsUpdate=!0,l=!1),i.compute()}}};class YY{constructor(){Nr(this,"_previousTime"),Nr(this,"_currentTime"),Nr(this,"_startTime"),Nr(this,"_delta"),Nr(this,"_elapsed"),Nr(this,"_timescale"),Nr(this,"_useFixedDelta"),Nr(this,"_fixedDelta"),Nr(this,"_usePageVisibilityAPI"),Nr(this,"_pageVisibilityHandler"),this._previousTime=0,this._currentTime=0,this._startTime=HS(),this._delta=0,this._elapsed=0,this._timescale=1,this._useFixedDelta=!1,this._fixedDelta=16.67,this._usePageVisibilityAPI=typeof document<"u"&&document.hidden!==void 0,this._usePageVisibilityAPI===!0&&(this._pageVisibilityHandler=jY.bind(this),document.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disableFixedDelta(){return this._useFixedDelta=!1,this}dispose(){return this._usePageVisibilityAPI===!0&&document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this}enableFixedDelta(){return this._useFixedDelta=!0,this}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getFixedDelta(){return this._fixedDelta/1e3}getTimescale(){return this._timescale}reset(){return this._currentTime=HS()-this._startTime,this}setFixedDelta(e){return this._fixedDelta=e*1e3,this}setTimescale(e){return this._timescale=e,this}update(){return this._useFixedDelta===!0?this._delta=this._fixedDelta:(this._previousTime=this._currentTime,this._currentTime=HS()-this._startTime,this._delta=this._currentTime-this._previousTime),this._delta*=this._timescale,this._elapsed+=this._delta,this}}function HS(){return(typeof performance>"u"?Date:performance).now()}function jY(){document.hidden===!1&&this.reset()}const WS={FORWARD:0,REVERSE:1,PAUSE:2,PINGPONG:3};class qY extends RY{constructor(e,t,i,n={geometry:"quad"}){let r;n.geometry||(n.geometry="quad"),n.geometry==="tri"&&(r=OY()),n.geometry==="quad"&&(r=new es(1,1)),n.geometry&&typeof n.geometry!="string"&&(r=n.geometry);const o=UY(e,(n==null?void 0:n.geometry)==="tri");super(r,o,t),Nr(this,"_spriteMaterial"),Nr(this,"_spritesheet"),Nr(this,"_animationMap"),Nr(this,"_fps",15),Nr(this,"_timer"),Nr(this,"compute"),this.instanceMatrix.clearUpdateRanges(),this.instanceMatrix.addUpdateRange(0,t*16),this.instanceColor&&(this.instanceColor.clearUpdateRanges(),this.instanceColor.addUpdateRange(0,t*3)),this.compute=XY(i,t),this._spriteMaterial=o,n.spritesheet&&this.updateSpritesheet(n.spritesheet),this._timer=new YY,this._animationMap=new Map,this._spriteMaterial.uniforms.animationData.value=this.compute.gpuCompute.getCurrentRenderTarget(this.compute.animationRunner).texture,this._spriteMaterial.uniforms.animationDataSize.value=this.compute.progressDataTexture.image.width}updateSpritesheet(e){const{dataTexture:t,dataWidth:i,dataHeight:n,animMap:r}=kY(e);this._spriteMaterial.uniforms.spritesheetData.value=t,this._spriteMaterial.uniforms.dataSize.value.x=i,this._spriteMaterial.uniforms.dataSize.value.y=n,this.compute.animationRunner.material.uniforms.dataSize.value=new Ne(i,n),this.compute.animationRunner.material.uniforms.spritesheetData.value=t,this._animationMap=r}get spritesheet(){return this._spritesheet}set spritesheet(e){this.updateSpritesheet(e),this._spritesheet=e}get animationMap(){return this._animationMap}get animation(){return{setAt:(e,t)=>{this.compute.utils.updateAnimationAt(e,this._animationMap.get(t)||0)}}}get frame(){return{setAt:(e,t,i)=>{var n;let r=t;i&&(r=(n=this.spritesheet)==null?void 0:n.animations[i][t][0]),this.compute.utils.updateFrameAt(e,r)},unsetAt:e=>{this.compute.utils.updateFrameAt(e,-10)},unsetAll:()=>{for(let e=0;e{this.compute.utils.updatePlaymodeAt(e,WS[t])},setAll:e=>{for(let t=0;t=10?10:0;this.compute.utils.updatePlaymodeAt(t,i+WS[e])}}}}get billboarding(){return{setAt:(e,t)=>{this.setUniformAt("billboarding",e,t?1:0)},setAll:e=>{this._spriteMaterial.uniforms.billboarding.value=e?1:0},unsetAll:()=>{this.unsetUniform("billboarding")}}}get offset(){return{setAt:(e,t)=>{this.compute.utils.updateOffsetAt(e,t)},randomizeAll:(e=1)=>{for(let t=0;t{const i=this.compute.progressDataTexture.image.data[e*4+2]%10;this.compute.utils.updatePlaymodeAt(e,i+(t?0:10))},setAll:e=>{for(let t=0;t{this.setUniformAt("flipX",e,t?1:0)},setGlobal:e=>{this._spriteMaterial.uniforms.flipX.value=e?1:0},unsetAll:()=>{this.unsetUniform("flipX")}}}get flipY(){return{setAt:(e,t)=>{this.setUniformAt("flipY",e,t?1:0)},setGlobal:e=>{this._spriteMaterial.uniforms.flipY.value=e?1:0},unsetAll:()=>{this.unsetUniform("flipY")}}}play(e,t=!0,i="FORWARD"){return{at:n=>{this.compute.utils.updateAnimationAt(n,this._animationMap.get(e)||0),this.compute.utils.updatePlaymodeAt(n,WS[i]+(t?0:10))}}}get hueShift(){const e=new Zt;return{setGlobal:t=>{t?e.set(t.h,t.s,t.v,1):e.setW(0),this._spriteMaterial.uniforms.tint.value=e}}}get fps(){return this._fps}set fps(e){this._fps=e,this.compute.animationRunner.material.uniforms.fps.value=e}update(){this._timer.update();const e=this._timer.getDelta();this.compute.animationRunner.material.uniforms.deltaTime.value=e,this.compute.update()}}var a3={exports:{}};a3.exports=$_,a3.exports.default=$_;function $_(s,e,t){t=t||2;var i=e&&e.length,n=i?e[0]*t:s.length,r=l3(s,0,n,t,!0),o=[];if(!r||r.next===r.prev)return o;var a,l,c,u,h,d,f;if(i&&(r=QY(s,e,r,t)),s.length>80*t){a=c=s[0],l=u=s[1];for(var m=t;mc&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return Qp(r,o,t,a,l,f,0),o}function l3(s,e,t,i,n){var r,o;if(n===jS(s,e,t,i)>0)for(r=e;r=e;r-=i)o=h3(r,s[r],s[r+1],o);return o&&J_(o,o.next)&&(tm(o),o=o.next),o}function Tu(s,e){if(!s)return s;e||(e=s);var t=s,i;do if(i=!1,!t.steiner&&(J_(t,t.next)||bi(t.prev,t,t.next)===0)){if(tm(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Qp(s,e,t,i,n,r,o){if(s){!o&&r&&rj(s,i,n,r);for(var a=s,l,c;s.prev!==s.next;){if(l=s.prev,c=s.next,r?KY(s,i,n,r):ZY(s)){e.push(l.i/t|0),e.push(s.i/t|0),e.push(c.i/t|0),tm(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=$Y(Tu(s),e,t),Qp(s,e,t,i,n,r,2)):o===2&&JY(s,e,t,i,n,r):Qp(Tu(s),e,t,i,n,r,1);break}}}}function ZY(s){var e=s.prev,t=s,i=s.next;if(bi(e,t,i)>=0)return!1;for(var n=e.x,r=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=nr?n>o?n:o:r>o?r:o,f=a>l?a>c?a:c:l>c?l:c,m=i.next;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=f&&Cd(n,a,r,l,o,c,m.x,m.y)&&bi(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function KY(s,e,t,i){var n=s.prev,r=s,o=s.next;if(bi(n,r,o)>=0)return!1;for(var a=n.x,l=r.x,c=o.x,u=n.y,h=r.y,d=o.y,f=al?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,_=XS(f,m,e,t,i),y=XS(v,g,e,t,i),w=s.prevZ,x=s.nextZ;w&&w.z>=_&&x&&x.z<=y;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==n&&w!==o&&Cd(a,u,l,h,c,d,w.x,w.y)&&bi(w.prev,w,w.next)>=0||(w=w.prevZ,x.x>=f&&x.x<=v&&x.y>=m&&x.y<=g&&x!==n&&x!==o&&Cd(a,u,l,h,c,d,x.x,x.y)&&bi(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;w&&w.z>=_;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==n&&w!==o&&Cd(a,u,l,h,c,d,w.x,w.y)&&bi(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=v&&x.y>=m&&x.y<=g&&x!==n&&x!==o&&Cd(a,u,l,h,c,d,x.x,x.y)&&bi(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function $Y(s,e,t){var i=s;do{var n=i.prev,r=i.next.next;!J_(n,r)&&c3(n,i,i.next,r)&&em(n,r)&&em(r,n)&&(e.push(n.i/t|0),e.push(i.i/t|0),e.push(r.i/t|0),tm(i),tm(i.next),i=s=r),i=i.next}while(i!==s);return Tu(i)}function JY(s,e,t,i,n,r){var o=s;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&aj(o,a)){var l=u3(o,a);o=Tu(o,o.next),l=Tu(l,l.next),Qp(o,e,t,i,n,r,0),Qp(l,e,t,i,n,r,0);return}a=a.next}o=o.next}while(o!==s)}function QY(s,e,t,i){var n=[],r,o,a,l,c;for(r=0,o=e.length;r=t.next.y&&t.next.y!==t.y){var a=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>r&&(r=a,o=t.x=t.x&&t.x>=c&&i!==t.x&&Cd(no.x||t.x===o.x&&ij(o,t)))&&(o=t,h=d)),t=t.next;while(t!==l);return o}function ij(s,e){return bi(s.prev,s,e.prev)<0&&bi(e.next,s,s.next)<0}function rj(s,e,t,i){var n=s;do n.z===0&&(n.z=XS(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,sj(n)}function sj(s){var e,t,i,n,r,o,a,l,c=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;t=i}r.nextZ=null,c*=2}while(o>1);return s}function XS(s,e,t,i,n){return s=(s-t)*n|0,e=(e-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function oj(s){var e=s,t=s;do(e.x=(s-o)*(r-a)&&(s-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(n-o)*(i-a)}function aj(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!lj(s,e)&&(em(s,e)&&em(e,s)&&cj(s,e)&&(bi(s.prev,s,e.prev)||bi(s,e.prev,e))||J_(s,e)&&bi(s.prev,s,s.next)>0&&bi(e.prev,e,e.next)>0)}function bi(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function J_(s,e){return s.x===e.x&&s.y===e.y}function c3(s,e,t,i){var n=ey(bi(s,e,t)),r=ey(bi(s,e,i)),o=ey(bi(t,i,s)),a=ey(bi(t,i,e));return!!(n!==r&&o!==a||n===0&&Q_(s,t,e)||r===0&&Q_(s,i,e)||o===0&&Q_(t,s,i)||a===0&&Q_(t,e,i))}function Q_(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function ey(s){return s>0?1:s<0?-1:0}function lj(s,e){var t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&c3(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function em(s,e){return bi(s.prev,s,s.next)<0?bi(s,e,s.next)>=0&&bi(s,s.prev,e)>=0:bi(s,e,s.prev)<0||bi(s,s.next,e)<0}function cj(s,e){var t=s,i=!1,n=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&n<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function u3(s,e){var t=new YS(s.i,s.x,s.y),i=new YS(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function h3(s,e,t,i){var n=new YS(s,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function tm(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function YS(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}$_.deviation=function(s,e,t,i){var n=e&&e.length,r=n?e[0]*t:s.length,o=Math.abs(jS(s,0,r,t));if(n)for(var a=0,l=e.length;a0&&(i+=s[n-1].length,t.holes.push(i))}return t},new Ne,new Ne;var d3;(s=>{function e(n){let r=n.slice();return r.sort(s.POINT_COMPARATOR),s.makeHullPresorted(r)}s.makeHull=e;function t(n){if(n.length<=1)return n.slice();let r=[];for(let a=0;a=2;){const c=r[r.length-1],u=r[r.length-2];if((c.x-u.x)*(l.y-u.y)>=(c.y-u.y)*(l.x-u.x))r.pop();else break}r.push(l)}r.pop();let o=[];for(let a=n.length-1;a>=0;a--){const l=n[a];for(;o.length>=2;){const c=o[o.length-1],u=o[o.length-2];if((c.x-u.x)*(l.y-u.y)>=(c.y-u.y)*(l.x-u.x))o.pop();else break}o.push(l)}return o.pop(),r.length==1&&o.length==1&&r[0].x==o[0].x&&r[0].y==o[0].y?r:r.concat(o)}s.makeHullPresorted=t;function i(n,r){return n.xr.x?1:n.yr.y?1:0}s.POINT_COMPARATOR=i})(d3||(d3={}));function qS(s,e){if(new.target)return Tt({component:qS,...s});Mt(e,!0);let t=H(e,"id",7,0),i=H(e,"position",23,()=>[0,0,0]),n=H(e,"scale",23,()=>[1,1]),r=H(e,"animationName",7),o=H(e,"playmode",7),a=H(e,"billboarding",7),l=H(e,"offset",7),c=H(e,"loop",7),u=H(e,"flipX",7),h=H(e,"flipY",7),d=H(e,"frameId",7);const{updatePosition:f,sprite:m}=nr("instanced-sprite-ctx");return $e(()=>{i()!==void 0&&f(t(),i(),n())}),$e(()=>{r()!==void 0&&m.animation.setAt(t(),r())}),$e(()=>{o()!==void 0&&m.playmode.setAt(t(),o())}),$e(()=>{a()!==void 0&&m.billboarding.setAt(t(),a())}),$e(()=>{l()!==void 0&&m.offset.setAt(t(),l())}),$e(()=>{c()!==void 0&&m.loop.setAt(t(),c())}),$e(()=>{u()!==void 0&&m.flipX.setAt(t(),u())}),$e(()=>{h()!==void 0&&m.flipY.setAt(t(),h())}),$e(()=>{d()!==void 0&&m.frame.setAt(t(),d(),r())}),Et({get id(){return t()},set id(v=0){t(v),V()},get position(){return i()},set position(v=[0,0,0]){i(v),V()},get scale(){return n()},set scale(v=[1,1]){n(v),V()},get animationName(){return r()},set animationName(v){r(v),V()},get playmode(){return o()},set playmode(v){o(v),V()},get billboarding(){return a()},set billboarding(v){a(v),V()},get offset(){return l()},set offset(v){l(v),V()},get loop(){return c()},set loop(v){c(v),V()},get flipX(){return u()},set flipX(v){u(v),V()},get flipY(){return h()},set flipY(v){h(v),V()},get frameId(){return d()},set frameId(v){d(v),V()},$set:Ct,$on:(v,g)=>At(e,v,g)})}Pt(qS,{id:{},position:{},scale:{},animationName:{},playmode:{},billboarding:{},offset:{},loop:{},flipX:{},flipY:{},frameId:{}},[],[],!0);function f3(s,e){if(new.target)return Tt({component:f3,...s});Mt(e,!0);let t=H(e,"autoUpdate",7,!0),i=H(e,"baseMaterial",7,Jn),n=H(e,"fps",7,15),r=H(e,"billboarding",7),o=H(e,"playmode",7,"FORWARD"),a=H(e,"count",7,1e3),l=H(e,"alphaTest",7,.1),c=H(e,"transparent",7,!0),u=H(e,"hueShift",7),h=H(e,"randomPlaybackOffset",7,!1),d=H(e,"spritesheet",7),f=H(e,"ref",15),m=H(e,"children",7),v=an(e,["$$slots","$$events","$$legacy","$$host","autoUpdate","baseMaterial","fps","billboarding","playmode","count","alphaTest","transparent","hueShift","randomPlaybackOffset","spritesheet","ref","children"]);const g=new(i())({transparent:c(),alphaTest:l(),side:Ei}),{renderer:_}=un(),y=new qY(g,a(),_);f(y);const w=Hn(new Map);$e(()=>{d()&&(y.spritesheet=d().spritesheet,w.set(y.animationMap),y.material.map=d().texture,y.material.needsUpdate=!0)}),$e(()=>{y.material.alphaTest=l()}),$e(()=>{y.material.transparent=c()}),$e(()=>{y.fps=n()}),$e(()=>y.hueShift.setGlobal(u())),$e(()=>{if(r()===void 0){y.billboarding.unsetAll();return}else y.billboarding.setAll(r())}),$e(()=>{if(o()===void 0){y.playmode.setAll("PAUSE");return}else y.playmode.setAll(o())});let x=xs(!1);$e(()=>{if(fe(x)===!1&&h()&&y.offset.randomizeAll(h()===!0?100:h()),fe(x)===!0&&!h())for(let A=0;A{C.makeScale(E[0],E[1],1),C.setPosition(...P),y.setMatrixAt(A,C),M=!0};return ur("instanced-sprite-ctx",{sprite:y,count:a(),animationMap:w,updatePosition:T}),ii(()=>{t()&&y.update(),M&&(y.instanceMatrix.needsUpdate=!0,M=!1)}),y.update(),pt(s,rn({is:y,frustumCulled:!1},()=>v,{children:(A,P)=>{var E=Lt(),I=dt(E);Wt(I,()=>m()??Nt,()=>({Instance:qS})),lt(A,E)},$$slots:{default:!0}})),Et({get autoUpdate(){return t()},set autoUpdate(A=!0){t(A),V()},get baseMaterial(){return i()},set baseMaterial(A=Jn){i(A),V()},get fps(){return n()},set fps(A=15){n(A),V()},get billboarding(){return r()},set billboarding(A){r(A),V()},get playmode(){return o()},set playmode(A="FORWARD"){o(A),V()},get count(){return a()},set count(A=1e3){a(A),V()},get alphaTest(){return l()},set alphaTest(A=.1){l(A),V()},get transparent(){return c()},set transparent(A=!0){c(A),V()},get hueShift(){return u()},set hueShift(A){u(A),V()},get randomPlaybackOffset(){return h()},set randomPlaybackOffset(A=!1){h(A),V()},get spritesheet(){return d()},set spritesheet(A){d(A),V()},get ref(){return f()},set ref(A){f(A),V()},get children(){return m()},set children(A){m(A),V()},$set:Ct,$on:(A,P)=>At(e,A,P)})}Pt(f3,{autoUpdate:{},baseMaterial:{},fps:{},billboarding:{},playmode:{},count:{},alphaTest:{},transparent:{},hueShift:{},randomPlaybackOffset:{},spritesheet:{},ref:{},children:{}},[],[],!0);var uj=Kn(" ",1),hj=Kn(" ",1),dj=Kn(" ",1),fj=Kn(" ",1),pj=Kn(" ",1),mj=Kn(" ",1),gj=Kn('
');function ty(s,e){if(new.target)return Tt({component:ty,...s});Mt(e,!1);let t=Yl(),i=Yl(1),n=Yl(),r=Yl(),o=Yl(),a=0,l=0;const c=()=>{fe(r)&&Cn.fromTo(fe(r).rotation,{y:60*qi.DEG2RAD},{y:-60*qi.DEG2RAD,scrollTrigger:{trigger:fe(t),start:"top bottom",end:"bottom top",scrub:!0}}),fe(o)&&Cn.fromTo(fe(o).rotation,{y:0*qi.DEG2RAD},{y:-35*qi.DEG2RAD,scrollTrigger:{trigger:fe(t),start:"top bottom",end:"bottom top",scrub:!0}})},u=f=>{a=f.clientX/window.innerWidth*2-1,l=-(f.clientY/window.innerHeight)*2+1,fe(n)&&(IM(n,fe(n).rotation.y=a*5*qi.DEG2RAD),IM(n,fe(n).rotation.x=l*5*qi.DEG2RAD))};Gr(()=>{const f=()=>{fe(t)&&Mn(i,fe(t).clientWidth/fe(t).clientHeight)};return f(),window.addEventListener("resize",f),window.addEventListener("mousemove",u),()=>{window.removeEventListener("resize",f),window.removeEventListener("mousemove",u),qt.getAll().forEach(m=>m.kill())}}),Ga(()=>fe(r),()=>{fe(r)&&c()}),Dy(),go();var h=gj(),d=$l(h);return rw(d,{children:(f,m)=>{var v=mj(),g=dt(v);const _=Em(()=>[50,fe(i),.1,100]),y=Em(()=>-5*qi.DEG2RAD),w=Em(()=>2.5*qi.DEG2RAD);pt.PerspectiveCamera(g,{get args(){return fe(_)},makeDefault:!0,position:[0,2,25],get"rotation.x"(){return fe(y)},get"rotation.z"(){return fe(w)},zoom:2.5});var x=Ln(g,2);pt.Group(x,{position:[0,-.5,0],get ref(){return fe(n)},set ref(M){Mn(n,M)},children:(M,C)=>{var T=pj(),A=dt(T);pt.Mesh(A,{name:"flora-person",children:(E,I)=>{var R=uj(),U=dt(R);pt.PlaneGeometry(U,{args:[1.2,5]});var L=Ln(U,2);Cp(L,{transparent:!0,side:2,alphaSmoothing:1,toneMapped:!1,url:"https://cdn.prod.website-files.com/67a0fb16e98014c2e8572448/67c0f925d2b40212f348b3a7_flora.png"}),lt(E,R)},$$slots:{default:!0}});var P=Ln(A,2);pt.Group(P,{get ref(){return fe(r)},set ref(E){Mn(r,E)},children:(E,I)=>{var R=fj(),U=dt(R);pt.Mesh(U,{name:"flora-shadow","rotation.x":Math.PI/1.9,position:[-.3,-2.6,1.75],children:(k,z)=>{var G=hj(),W=dt(G);pt.PlaneGeometry(W,{args:[1,5]});var q=Ln(W,2);Cp(q,{transparent:!0,side:2,alphaSmoothing:1,toneMapped:!1,url:"https://cdn.prod.website-files.com/67a0fb16e98014c2e8572448/67c0f92a0f6906a8aa87c079_flora-shadow.png"}),lt(k,G)},$$slots:{default:!0}});var L=Ln(U,2);pt.Mesh(L,{name:"flora-frame",position:[0,2,-5],get ref(){return fe(o)},set ref(k){Mn(o,k)},children:(k,z)=>{var G=dj(),W=dt(G);pt.PlaneGeometry(W,{args:[3.75,5.5]});var q=Ln(W,2);Cp(q,{side:2,alphaSmoothing:1,transparent:!0,toneMapped:!1,url:"https://cdn.prod.website-files.com/67a0fb16e98014c2e8572448/67cb7bdf05f61be36a9907fd_e951ed124eeb253405d21f874ab3bfd9.png"}),lt(k,G)},$$slots:{default:!0},$$legacy:!0}),lt(E,R)},$$slots:{default:!0},$$legacy:!0}),lt(M,T)},$$slots:{default:!0},$$legacy:!0}),lt(f,v)},$$slots:{default:!0}}),ql(h),qu(h,f=>Mn(t,f),()=>fe(t)),lt(s,h),Et({$set:Ct,$on:(f,m)=>At(e,f,m)})}customElements.define("florag-three-canvas",Pt(ty,{},[],[],!0));const vj={WebflowExport:Tg,FloraThreeCanvas:ty};typeof window<"u"&&(window.FloragComponents=vj),Gn.FloraThreeCanvas=ty,Gn.WebflowExport=Tg,Object.defineProperty(Gn,Symbol.toStringTag,{value:"Module"})});