total-recall-brain 3.25.0 → 3.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4623,11 +4623,11 @@ function InsertStackElement(node, body) {
|
|
|
4623
4623
|
`}})),wne=o(((e,t)=>{t.exports=n;function n(e,t,n,r){this.from=e,this.to=t,this.length=n,this.coefficient=r}})),Tne=o(((e,t)=>{t.exports=n;function n(e,t){var r;if(e||={},t){for(r in t)if(t.hasOwnProperty(r)){var i=e.hasOwnProperty(r),a=typeof t[r];!i||typeof e[r]!==a?e[r]=t[r]:a===`object`&&(e[r]=n(e[r],t[r]))}}return e}})),Ng=o(((e,t)=>{function n(e){i(e);let t=r(e);return e.on=t.on,e.off=t.off,e.fire=t.fire,e}function r(e){let t=Object.create(null);return{on:function(n,r,i){if(typeof r!=`function`)throw Error(`callback is expected to be a function`);let a=t[n];return a||=t[n]=[],a.push({callback:r,ctx:i}),e},off:function(n,r){if(typeof n>`u`)return t=Object.create(null),e;if(t[n]){if(typeof r!=`function`)delete t[n];else{let e=t[n];for(let t=0;t<e.length;++t)e[t].callback===r&&e.splice(t,1)}}return e},fire:function(n){let r=t[n];if(!r)return e;let i;arguments.length>1&&(i=Array.prototype.slice.call(arguments,1));for(let e=0;e<r.length;++e){let t=r[e];t.callback.apply(t.ctx,i)}return e}}}function i(e){if(!e)throw Error(`Eventify cannot use falsy object as events subject`);let t=[`on`,`fire`,`off`];for(let n=0;n<t.length;++n)if(e.hasOwnProperty(t[n]))throw Error(`Subject cannot be eventified, since it already has property '`+t[n]+`'`)}t.exports=n})),Ene=o(((e,t)=>{t.exports=n,t.exports.random=n,t.exports.randomIterator=l;function n(e){return new r(typeof e==`number`?e:+new Date)}function r(e){this.seed=e}r.prototype.next=c,r.prototype.nextDouble=s,r.prototype.uniform=s,r.prototype.gaussian=i,r.prototype.random=s;function i(){var e,t,n;do t=this.nextDouble()*2-1,n=this.nextDouble()*2-1,e=t*t+n*n;while(e>=1||e===0);return t*Math.sqrt(-2*Math.log(e)/e)}r.prototype.levy=a;function a(){var e=3/2,t=(o(1+e)*Math.sin(Math.PI*e/2)/(o((1+e)/2)*e*2**((e-1)/2)))**(1/e);return this.gaussian()*t/Math.abs(this.gaussian())**(1/e)}function o(e){return Math.sqrt(2*Math.PI/e)*(1/Math.E*(e+1/(12*e-1/(10*e))))**e}function s(){var e=this.seed;return e=e+2127912214+(e<<12)&4294967295,e=(e^3345072700^e>>>19)&4294967295,e=e+374761393+(e<<5)&4294967295,e=(e+3550635116^e<<9)&4294967295,e=e+4251993797+(e<<3)&4294967295,e=(e^3042594569^e>>>16)&4294967295,this.seed=e,(e&268435455)/268435456}function c(e){return Math.floor(this.nextDouble()*e)}function l(e,t){var r=t||n();if(typeof r.next!=`function`)throw Error(`customRandom does not match expected API: next() function is missing`);return{forEach:a,shuffle:i};function i(){var t,n,i;for(t=e.length-1;t>0;--t)n=r.next(t+1),i=e[n],e[n]=e[t],e[t]=i;return e}function a(t){var n,i,a;for(n=e.length-1;n>0;--n)i=r.next(n+1),a=e[i],e[i]=e[n],e[n]=a,t(a);e.length&&t(e[0])}}})),Pg=o(((e,t)=>{t.exports=l;var n=Mg(),r=yne(),i=bne(),a=xne(),o=Sne(),s=Cne(),c={};function l(e){var t=wne(),l=Tne(),d=Ng();if(e){if(e.springCoeff!==void 0)throw Error(`springCoeff was renamed to springCoefficient`);if(e.dragCoeff!==void 0)throw Error(`dragCoeff was renamed to dragCoefficient`)}e=l(e,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var f=c[e.dimensions];if(!f){var p=e.dimensions;f={Body:n(p,e.debug),createQuadTree:r(p),createBounds:i(p),createDragForce:a(p),createSpringForce:o(p),integrate:s(p)},c[p]=f}var m=f.Body,h=f.createQuadTree,g=f.createBounds,_=f.createDragForce,v=f.createSpringForce,y=f.integrate,b=e=>new m(e),x=Ene().random(42),S=[],C=[],w=h(e,x),T=g(S,e,x),E=v(e,x),D=_(e),O=0,k=[],A=new Map,j=0;te(`nbody`,P),te(`spring`,re);var ee={bodies:S,quadTree:w,springs:C,settings:e,addForce:te,removeForce:ne,getForces:N,step:function(){for(var t=0;t<k.length;++t)k[t](j);var n=y(S,e.timeStep,e.adaptiveTimeStepWeight);return j+=1,n},addBody:function(e){if(!e)throw Error(`Body is required`);return S.push(e),e},addBodyAt:function(e){if(!e)throw Error(`Body position is required`);var t=b(e);return S.push(t),t},removeBody:function(e){if(e){var t=S.indexOf(e);if(!(t<0))return S.splice(t,1),S.length===0&&T.reset(),!0}},addSpring:function(e,n,r,i){if(!e||!n)throw Error(`Cannot add null spring to force simulator`);typeof r!=`number`&&(r=-1);var a=new t(e,n,r,i>=0?i:-1);return C.push(a),a},getTotalMovement:function(){return O},removeSpring:function(e){if(e){var t=C.indexOf(e);if(t>-1)return C.splice(t,1),!0}},getBestNewBodyPosition:function(e){return T.getBestNewPosition(e)},getBBox:M,getBoundingBox:M,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(t){return t===void 0?e.gravity:(e.gravity=t,w.options({gravity:t}),this)},theta:function(t){return t===void 0?e.theta:(e.theta=t,w.options({theta:t}),this)},random:x};return u(e,ee),d(ee),ee;function M(){return T.update(),T.box}function te(e,t){if(A.has(e))throw Error(`Force `+e+` is already added`);A.set(e,t),k.push(t)}function ne(e){var t=k.indexOf(A.get(e));t<0||(k.splice(t,1),A.delete(e))}function N(){return A}function P(){if(S.length!==0){w.insertBodies(S);for(var e=S.length;e--;){var t=S[e];t.isPinned||(t.reset(),w.updateBodyForce(t),D.update(t))}}}function re(){for(var e=C.length;e--;)E.update(C[e])}}function u(e,t){for(var n in e)d(e,t,n)}function d(e,t,n){e.hasOwnProperty(n)&&typeof t[n]!=`function`&&(t[n]=Number.isFinite(e[n])?function(r){if(r!==void 0){if(!Number.isFinite(r))throw Error(`Value of `+n+` should be a valid number.`);return e[n]=r,t}return e[n]}:function(r){return r===void 0?e[n]:(e[n]=r,t)})}})),Dne=l(o(((e,t)=>{t.exports=r,t.exports.simulator=Pg();var n=Ng();function r(e,t){if(!e)throw Error(`Graph structure cannot be undefined`);var r=(t&&t.createSimulator||Pg())(t);if(Array.isArray(t))throw Error(`Physics settings is expected to be an object`);var a=e.version>19?A:k;t&&typeof t.nodeMass==`function`&&(a=t.nodeMass);var o=new Map,s={},c=0,l=r.settings.springTransform||i;b(),_();var u=!1,d={step:function(){if(c===0)return f(!0),!0;var e=r.step();d.lastMove=e,d.fire(`step`);var t=e/c<=.01;return f(t),t},getNodePosition:function(e){return O(e).pos},setNodePosition:function(e){var t=O(e);t.setPosition.apply(t,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(e){var t=s[e];if(t)return{from:t.from.pos,to:t.to.pos}},getGraphRect:function(){return r.getBBox()},forEachBody:p,pinNode:function(e,t){var n=O(e.id);n.isPinned=!!t},isNodePinned:function(e){return O(e.id).isPinned},dispose:function(){e.off(`changed`,y),d.fire(`disposed`)},getBody:g,getSpring:h,getForceVectorLength:m,simulator:r,graph:e,lastMove:0};return n(d),d;function f(e){u!==e&&(u=e,v(e))}function p(e){o.forEach(e)}function m(){var e=0,t=0;return p(function(n){e+=Math.abs(n.force.x),t+=Math.abs(n.force.y)}),Math.sqrt(e*e+t*t)}function h(t,n){var r;if(n===void 0)r=typeof t==`object`?t.id:t;else{var i=e.hasLink(t,n);if(!i)return;r=i.id}return s[r]}function g(e){return o.get(e)}function _(){e.on(`changed`,y)}function v(e){d.fire(`stable`,e)}function y(t){for(var n=0;n<t.length;++n){var r=t[n];r.changeType===`add`?(r.node&&x(r.node.id),r.link&&C(r.link)):r.changeType===`remove`&&(r.node&&S(r.node),r.link&&w(r.link))}c=e.getNodesCount()}function b(){c=0,e.forEachNode(function(e){x(e.id),c+=1}),e.forEachLink(C)}function x(t){var n=o.get(t);if(!n){var i=e.getNode(t);if(!i)throw Error(`initBody() was called with unknown node id`);var a=i.position;if(!a){var s=T(i);a=r.getBestNewBodyPosition(s)}n=r.addBodyAt(a),n.id=t,o.set(t,n),E(t),D(i)&&(n.isPinned=!0)}}function S(e){var t=e.id,n=o.get(t);n&&(o.delete(t),r.removeBody(n))}function C(e){E(e.fromId),E(e.toId);var t=o.get(e.fromId),n=o.get(e.toId),i=r.addSpring(t,n,e.length);l(e,i),s[e.id]=i}function w(t){var n=s[t.id];if(n){var i=e.getNode(t.fromId),a=e.getNode(t.toId);i&&E(i.id),a&&E(a.id),delete s[t.id],r.removeSpring(n)}}function T(e){var t=[];if(!e.links)return t;for(var n=Math.min(e.links.length,2),r=0;r<n;++r){var i=e.links[r],a=i.fromId===e.id?o.get(i.toId):o.get(i.fromId);a&&a.pos&&t.push(a)}return t}function E(e){var t=o.get(e);if(t.mass=a(e),Number.isNaN(t.mass))throw Error(`Node mass should be a number`)}function D(e){return e&&(e.isPinned||e.data&&e.data.isPinned)}function O(e){var t=o.get(e);return t||=(x(e),o.get(e)),t}function k(t){var n=e.getLinks(t);return n?1+n.length/3:1}function A(t){var n=e.getLinks(t);return n?1+n.size/3:1}}function i(){}}))(),1);function Fg(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var One=typeof global==`object`&&global&&global.Object===Object&&global,kne=typeof self==`object`&&self&&self.Object===Object&&self,Ig=One||kne||Function(`return this`)(),Lg=function(){return Ig.Date.now()},Ane=/\s/;function jne(e){for(var t=e.length;t--&&Ane.test(e.charAt(t)););return t}var Mne=/^\s+/;function Nne(e){return e&&e.slice(0,jne(e)+1).replace(Mne,``)}var Rg=Ig.Symbol,zg=Object.prototype,Pne=zg.hasOwnProperty,Fne=zg.toString,Bg=Rg?Rg.toStringTag:void 0;function Ine(e){var t=Pne.call(e,Bg),n=e[Bg];try{e[Bg]=void 0;var r=!0}catch{}var i=Fne.call(e);return r&&(t?e[Bg]=n:delete e[Bg]),i}var Lne=Object.prototype.toString;function Vg(e){return Lne.call(e)}var Hg=`[object Null]`,Ug=`[object Undefined]`,Wg=Rg?Rg.toStringTag:void 0;function Gg(e){return e==null?e===void 0?Ug:Hg:Wg&&Wg in Object(e)?Ine(e):Vg(e)}function Kg(e){return typeof e==`object`&&!!e}var qg=`[object Symbol]`;function Jg(e){return typeof e==`symbol`||Kg(e)&&Gg(e)==qg}var Yg=NaN,Xg=/^[-+]0x[0-9a-f]+$/i,Zg=/^0b[01]+$/i,Qg=/^0o[0-7]+$/i,$g=parseInt;function e_(e){if(typeof e==`number`)return e;if(Jg(e))return Yg;if(Fg(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Fg(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Nne(e);var n=Zg.test(e);return n||Qg.test(e)?$g(e.slice(2),n?2:8):Xg.test(e)?Yg:+e}var t_=`Expected a function`,n_=Math.max,r_=Math.min;function i_(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(t_);t=e_(t)||0,Fg(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?n_(e_(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?r_(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Lg();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Lg())}function x(){var e=Lg(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function a_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o_(e){if(Array.isArray(e))return e}function s_(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function c_(e,t,n){return Object.defineProperty(e,"prototype",{writable:!1}),e}function l_(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function u_(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4624
4624
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function d_(e,t){return o_(e)||l_(e,t)||f_(e,t)||u_()}function f_(e,t){if(e){if(typeof e==`string`)return a_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a_(e,t):void 0}}var p_=c_(function e(t,n){var r=n.default,i=r===void 0?null:r,a=n.triggerUpdate,o=a===void 0||a,s=n.onChange,c=s===void 0?function(e,t){}:s;s_(this,e),this.name=t,this.defaultVal=i,this.triggerUpdate=o,this.onChange=c});function m_(e){var t=e.stateInit,n=t===void 0?function(){return{}}:t,r=e.props,i=r===void 0?{}:r,a=e.methods,o=a===void 0?{}:a,s=e.aliases,c=s===void 0?{}:s,l=e.init,u=l===void 0?function(){}:l,d=e.update,f=d===void 0?function(){}:d,p=Object.keys(i).map(function(e){return new p_(e,i[e])});return function e(){var t=[...arguments],r=!!(this instanceof e&&this.constructor),i=r?t.shift():void 0,a=t[0],s=a===void 0?{}:a,l=Object.assign({},n instanceof Function?n(s):n,{initialised:!1}),d={};function m(e){return h(e,s),g(),m}var h=function(e,t){u.call(m,e,l,t),l.initialised=!0},g=i_(function(){l.initialised&&(f.call(m,l,d),d={})},1);return p.forEach(function(e){m[e.name]=t(e);function t(e){var t=e.name,n=e.triggerUpdate,r=n!==void 0&&n,i=e.onChange,a=i===void 0?function(e,t){}:i,o=e.defaultVal,s=o===void 0?null:o;return function(e){var n=l[t];if(!arguments.length)return n;var i=e===void 0?s:e;return l[t]=i,a.call(m,i,l,n),!d.hasOwnProperty(t)&&(d[t]=n),r&&g(),m}}}),Object.keys(o).forEach(function(e){m[e]=function(){var t,n=[...arguments];return(t=o[e]).call.apply(t,[m,l].concat(n))}}),Object.entries(c).forEach(function(e){var t=d_(e,2),n=t[0];return m[n]=m[t[1]]}),m.resetProps=function(){return p.forEach(function(e){m[e.name](e.defaultVal)}),m},m.resetProps(),l._rerender=g,r&&i&&m(i),m}}var h_=(function(e){return typeof e==`function`?e:typeof e==`string`?function(t){return t[e]}:function(t){return e}});function g_(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function __(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function v_(e){let t,n,r;e.length===2?(t=e===g_||e===__?e:Rne,n=e,r=e):(t=g_,n=(t,n)=>g_(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function Rne(){return 0}function y_(e){return e===null?NaN:+e}function*zne(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var b_=v_(g_),x_=b_.right;b_.left,v_(y_).center;var S_=class extends Map{constructor(e,t=Hne){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(C_(this,e))}has(e){return super.has(C_(this,e))}set(e,t){return super.set(Bne(this,e),t)}delete(e){return super.delete(Vne(this,e))}};function C_({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Bne({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Vne({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Hne(e){return typeof e==`object`&&e?e.valueOf():e}function Une(e=g_){if(e===g_)return w_;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function w_(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:+(e>t))}var Wne=Math.sqrt(50),Gne=Math.sqrt(10),Kne=Math.sqrt(2);function T_(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Wne?10:a>=Gne?5:a>=Kne?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?T_(e,t,n*2):[s,c,l]}function E_(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?T_(t,e,n):T_(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function D_(e,t,n){return t=+t,e=+e,n=+n,T_(e,t,n)[2]}function O_(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?D_(t,e,n):D_(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function k_(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n<t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function A_(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function j_(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?w_:Une(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));j_(e,t,u,d,i)}let a=e[t],o=n,s=r;for(M_(e,n,t),i(e[r],a)>0&&M_(e,n,r);o<s;){for(M_(e,o,s),++o,--s;i(e[o],a)<0;)++o;for(;i(e[s],a)>0;)--s}i(e[n],a)===0?M_(e,n,s):(++s,M_(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function M_(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function N_(e,t,n){if(e=Float64Array.from(zne(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return A_(e);if(t>=1)return k_(e);var r,i=(r-1)*t,a=Math.floor(i),o=k_(j_(e,a).subarray(0,a+1));return o+(A_(e.subarray(a+1))-o)*(i-a)}}function P_(e,t,n=y_){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function F_(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function I_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function L_(e){if(Array.isArray(e))return e}function R_(e){if(Array.isArray(e))return I_(e)}function z_(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function B_(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function V_(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function H_(e,t){return e.get(z_(e,t))}function U_(e,t,n){B_(e,t),t.set(e,n)}function W_(e,t,n){return e.set(z_(e,t),n),n}function G_(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,ev(r.key),r)}}function K_(e,t,n){return t&&G_(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function q_(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function J_(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Y_(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4625
4625
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function X_(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4626
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Z_(e,t){return L_(e)||J_(e,t)||tv(e,t)||Y_()}function Q_(e){return R_(e)||q_(e)||tv(e)||X_()}function $_(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function ev(e){var t=$_(e,`string`);return typeof t==`symbol`?t:t+``}function tv(e,t){if(e){if(typeof e==`string`)return I_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I_(e,t):void 0}}var nv=new WeakMap,rv=new WeakMap,iv=new WeakMap,av=new WeakMap,ov=new WeakMap,sv=new WeakMap,cv=function(){function e(){V_(this,e),U_(this,nv,new Map),U_(this,rv,new Map),U_(this,iv,function(e){return e}),U_(this,av,function(){return{}}),U_(this,ov,function(){}),U_(this,sv,function(){})}return K_(e,[{key:`getObj`,value:function(e){return H_(nv,this).get(H_(iv,this).call(this,e))}},{key:`getData`,value:function(e){return H_(rv,this).get(e)}},{key:`entries`,value:function(){return Q_(H_(rv,this).entries()).map(function(e){var t=Z_(e,2),n=t[0];return[t[1],n]})}},{key:`id`,value:function(e){return W_(iv,this,h_(e)),this}},{key:`onCreateObj`,value:function(e){return W_(av,this,e),this}},{key:`onUpdateObj`,value:function(e){return W_(ov,this,e),this}},{key:`onRemoveObj`,value:function(e){return W_(sv,this,e),this}},{key:`digest`,value:function(e){var t=this;e.filter(function(e){return!H_(nv,t).has(H_(iv,t).call(t,e))}).forEach(function(e){var n=H_(av,t).call(t,e);H_(nv,t).set(H_(iv,t).call(t,e),n),H_(rv,t).set(n,e)});var n=new Map(e.map(function(e){return[H_(iv,t).call(t,e),e]}));return H_(nv,this).forEach(function(e,r){n.has(r)?H_(ov,t).call(t,e,n.get(r)):(H_(sv,t).call(t,e,r),H_(nv,t).delete(r),H_(rv,t).delete(e))}),this}},{key:`clear`,value:function(){return this.digest([]),this}}])}();function lv(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function uv(e,t){switch(arguments.length){case 0:break;case 1:typeof e==`function`?this.interpolator(e):this.range(e);break;default:this.domain(e),typeof t==`function`?this.interpolator(t):this.range(t)}return this}var dv=Symbol(`implicit`);function fv(){var e=new S_,t=[],n=[],r=dv;function i(i){let a=e.get(i);if(a===void 0){if(r!==dv)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new S_;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return fv(t,n).unknown(r)},lv.apply(i,arguments),i}function pv(){var e=fv().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=F_(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return pv(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},lv.apply(d(),arguments)}function mv(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return mv(t())},e}function hv(){return mv(pv.apply(null,arguments).paddingInner(1))}function gv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _v(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function vv(){}var yv=.7,bv=1/yv,xv=`\\s*([+-]?\\d+)\\s*`,Sv=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Cv=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,wv=/^#([0-9a-f]{3,8})$/,Tv=RegExp(`^rgb\\(${xv},${xv},${xv}\\)$`),Ev=RegExp(`^rgb\\(${Cv},${Cv},${Cv}\\)$`),Dv=RegExp(`^rgba\\(${xv},${xv},${xv},${Sv}\\)$`),Ov=RegExp(`^rgba\\(${Cv},${Cv},${Cv},${Sv}\\)$`),kv=RegExp(`^hsl\\(${Sv},${Cv},${Cv}\\)$`),Av=RegExp(`^hsla\\(${Sv},${Cv},${Cv},${Sv}\\)$`),jv={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};gv(vv,Fv,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mv,formatHex:Mv,formatHex8:Nv,formatHsl:qne,formatRgb:Pv,toString:Pv});function Mv(){return this.rgb().formatHex()}function Nv(){return this.rgb().formatHex8()}function qne(){return Kv(this).formatHsl()}function Pv(){return this.rgb().formatRgb()}function Fv(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=wv.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Iv(t):n===3?new zv(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lv(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lv(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Tv.exec(e))?new zv(t[1],t[2],t[3],1):(t=Ev.exec(e))?new zv(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Dv.exec(e))?Lv(t[1],t[2],t[3],t[4]):(t=Ov.exec(e))?Lv(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kv.exec(e))?Gv(t[1],t[2]/100,t[3]/100,1):(t=Av.exec(e))?Gv(t[1],t[2]/100,t[3]/100,t[4]):jv.hasOwnProperty(e)?Iv(jv[e]):e===`transparent`?new zv(NaN,NaN,NaN,0):null}function Iv(e){return new zv(e>>16&255,e>>8&255,e&255,1)}function Lv(e,t,n,r){return r<=0&&(e=t=n=NaN),new zv(e,t,n,r)}function Jne(e){return e instanceof vv||(e=Fv(e)),e?(e=e.rgb(),new zv(e.r,e.g,e.b,e.opacity)):new zv}function Rv(e,t,n,r){return arguments.length===1?Jne(e):new zv(e,t,n,r??1)}function zv(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gv(zv,Rv,_v(vv,{brighter(e){return e=e==null?bv:bv**+e,new zv(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yv:yv**+e,new zv(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zv(Uv(this.r),Uv(this.g),Uv(this.b),Hv(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Bv,formatHex:Bv,formatHex8:Yne,formatRgb:Vv,toString:Vv}));function Bv(){return`#${Wv(this.r)}${Wv(this.g)}${Wv(this.b)}`}function Yne(){return`#${Wv(this.r)}${Wv(this.g)}${Wv(this.b)}${Wv((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vv(){let e=Hv(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Uv(this.r)}, ${Uv(this.g)}, ${Uv(this.b)}${e===1?`)`:`, ${e})`}`}function Hv(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Uv(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wv(e){return e=Uv(e),(e<16?`0`:``)+e.toString(16)}function Gv(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new qv(e,t,n,r)}function Kv(e){if(e instanceof qv)return new qv(e.h,e.s,e.l,e.opacity);if(e instanceof vv||(e=Fv(e)),!e)return new qv;if(e instanceof qv)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new qv(o,s,c,e.opacity)}function Xne(e,t,n,r){return arguments.length===1?Kv(e):new qv(e,t,n,r??1)}function qv(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gv(qv,Xne,_v(vv,{brighter(e){return e=e==null?bv:bv**+e,new qv(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yv:yv**+e,new qv(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new zv(Xv(e>=240?e-240:e+120,i,r),Xv(e,i,r),Xv(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new qv(Jv(this.h),Yv(this.s),Yv(this.l),Hv(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Hv(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Jv(this.h)}, ${Yv(this.s)*100}%, ${Yv(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Jv(e){return e=(e||0)%360,e<0?e+360:e}function Yv(e){return Math.max(0,Math.min(1,e||0))}function Xv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Zv=e=>()=>e;function Zne(e,t){return function(n){return e+n*t}}function Qne(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function $ne(e){return(e=+e)==1?Qv:function(t,n){return n-t?Qne(t,n,e):Zv(isNaN(t)?n:t)}}function Qv(e,t){var n=t-e;return n?Zne(e,n):Zv(isNaN(e)?t:e)}var $v=(function e(t){var n=$ne(t);function r(e,t){var r=n((e=Rv(e)).r,(t=Rv(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Qv(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function ere(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function tre(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function nre(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=ry(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function rre(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ey(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function ire(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=ry(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var ty=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ny=new RegExp(ty.source,`g`);function are(e){return function(){return e}}function ore(e){return function(t){return e(t)+``}}function sre(e,t){var n=ty.lastIndex=ny.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=ty.exec(e))&&(i=ny.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:ey(r,i)})),n=ny.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?ore(c[0].x):are(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function ry(e,t){var n=typeof t,r;return t==null||n===`boolean`?Zv(t):(n===`number`?ey:n===`string`?(r=Fv(t))?(t=r,$v):sre:t instanceof Fv?$v:t instanceof Date?rre:tre(t)?ere:Array.isArray(t)?nre:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?ire:ey)(e,t)}function iy(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function cre(e,t){t===void 0&&(t=e,e=ry);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return function(e){var t=Math.max(0,Math.min(r-1,Math.floor(e*=r)));return a[t](e-t)}}function lre(e){return function(){return e}}function ay(e){return+e}var oy=[0,1];function sy(e){return e}function cy(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:lre(isNaN(t)?NaN:.5)}function ure(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function dre(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=cy(i,r),a=n(o,a)):(r=cy(r,i),a=n(a,o)),function(e){return a(r(e))}}function fre(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=cy(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=x_(e,t,1,r)-1;return a[n](i[n](t))}}function ly(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function uy(){var e=oy,t=oy,n=ry,r,i,a,o=sy,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==sy&&(o=ure(e[0],e[n-1])),s=n>2?fre:dre,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),ey))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,ay),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=iy,u()},d.clamp=function(e){return arguments.length?(o=e?!0:sy,u()):o!==sy},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function dy(){return uy()(sy,sy)}function pre(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function fy(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function py(e){return e=fy(Math.abs(e)),e?e[1]:NaN}function mre(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function hre(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var gre=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function my(e){if(!(t=gre.exec(e)))throw Error(`invalid format: `+e);var t;return new hy({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}my.prototype=hy.prototype;function hy(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}hy.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function _re(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var gy;function vre(e,t){var n=fy(e,t);if(!n)return gy=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(gy=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+fy(e,Math.max(0,t+a-1))[0]}function _y(e,t){var n=fy(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var vy={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:pre,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>_y(e*100,t),r:_y,s:vre,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function yy(e){return e}var by=Array.prototype.map,xy=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function yre(e){var t=e.grouping===void 0||e.thousands===void 0?yy:mre(by.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?yy:hre(by.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=my(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):vy[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=vy[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=_re(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&gy!==void 0?xy[8+gy/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(py(t)/3)))*3,r=10**-n,i=l((e=my(e),e.type=`f`,e),{suffix:xy[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var Sy,Cy,wy;bre({thousands:`,`,grouping:[3],currency:[`$`,``]});function bre(e){return Sy=yre(e),Cy=Sy.format,wy=Sy.formatPrefix,Sy}function xre(e){return Math.max(0,-py(Math.abs(e)))}function Sre(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(py(t)/3)))*3-py(Math.abs(e)))}function Cre(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,py(t)-py(e))+1}function Ty(e,t,n,r){var i=O_(e,t,n),a;switch(r=my(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Sre(i,o))&&(r.precision=a),wy(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Cre(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=xre(i))&&(r.precision=a-(r.type===`%`)*2)}return Cy(r)}function Ey(e){var t=e.domain;return e.ticks=function(e){var n=t();return E_(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Ty(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=D_(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Dy(){var e=dy();return e.copy=function(){return ly(e,Dy())},lv.apply(e,arguments),Ey(e)}function Oy(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,ay),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return Oy(e).unknown(t)},e=arguments.length?Array.from(e,ay):[0,1],Ey(n)}function ky(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),e[n]=t.floor(i),e[r]=t.ceil(a),e}function Ay(e){return Math.log(e)}function jy(e){return Math.exp(e)}function wre(e){return-Math.log(-e)}function Tre(e){return-Math.exp(-e)}function Ere(e){return isFinite(e)?+(`1e`+e):e<0?0:e}function Dre(e){return e===10?Ere:e===Math.E?Math.exp:t=>e**+t}function Ore(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function My(e){return(t,n)=>-e(-t,n)}function Ny(e){let t=e(Ay,jy),n=t.domain,r=10,i,a;function o(){return i=Ore(r),a=Dre(r),n()[0]<0?(i=My(i),a=My(a),e(wre,Tre)):e(Ay,jy),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s<o;c&&([o,s]=[s,o]);let l=i(o),u=i(s),d,f,p=e==null?10:+e,m=[];if(!(r%1)&&u-l<p){if(l=Math.floor(l),u=Math.ceil(u),o>0){for(;l<=u;++l)for(d=1;d<r;++d)if(f=l<0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}m.length*2<p&&(m=E_(o,s,p))}else m=E_(l,u,Math.min(u-l,p)).map(a);return c?m.reverse():m},t.tickFormat=(e,n)=>{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=my(n)).precision==null&&(n.trim=!0),n=Cy(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*r<r-.5&&(t*=r),t<=o?n(e):``}},t.nice=()=>n(ky(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function Py(){let e=Ny(uy()).domain([1,10]);return e.copy=()=>ly(e,Py()).base(e.base()),lv.apply(e,arguments),e}function Fy(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function Iy(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function Ly(e){var t=1,n=e(Fy(t),Iy(t));return n.constant=function(n){return arguments.length?e(Fy(t=+n),Iy(t)):t},Ey(n)}function Ry(){var e=Ly(uy());return e.copy=function(){return ly(e,Ry()).constant(e.constant())},lv.apply(e,arguments)}function zy(e){return function(t){return t<0?-((-t)**+e):t**+e}}function kre(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Are(e){return e<0?-e*e:e*e}function By(e){var t=e(sy,sy),n=1;function r(){return n===1?e(sy,sy):n===.5?e(kre,Are):e(zy(n),zy(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},Ey(t)}function Vy(){var e=By(uy());return e.copy=function(){return ly(e,Vy()).exponent(e.exponent())},lv.apply(e,arguments),e}function jre(){return Vy.apply(null,arguments).exponent(.5)}function Hy(e){return Math.sign(e)*e*e}function Mre(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function Uy(){var e=dy(),t=[0,1],n=!1,r;function i(t){var i=Mre(e(t));return isNaN(i)?r:n?Math.round(i):i}return i.invert=function(t){return e.invert(Hy(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(n){return arguments.length?(e.range((t=Array.from(n,ay)).map(Hy)),i):t.slice()},i.rangeRound=function(e){return i.range(e).round(!0)},i.round=function(e){return arguments.length?(n=!!e,i):n},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Uy(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},lv.apply(i,arguments),Ey(i)}function Wy(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r<i;)n[r-1]=P_(e,r/i);return a}function a(e){return e==null||isNaN(e=+e)?r:t[x_(n,e)]}return a.invertExtent=function(r){var i=t.indexOf(r);return i<0?[NaN,NaN]:[i>0?n[i-1]:e[0],i<n.length?n[i]:e[e.length-1]]},a.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(g_),i()},a.range=function(e){return arguments.length?(t=Array.from(e),i()):t.slice()},a.unknown=function(e){return arguments.length?(r=e,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return Wy().domain(e).range(t).unknown(r)},lv.apply(a,arguments)}function Gy(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[x_(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return Gy().domain([e,t]).range(i).unknown(a)},lv.apply(Ey(o),arguments)}function Ky(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[x_(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return Ky().domain(e).range(t).unknown(n)},lv.apply(i,arguments)}var qy=new Date,Jy=new Date;function Yy(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>Yy(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e){if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}}),n&&(i.count=(t,r)=>(qy.setTime(+t),Jy.setTime(+r),e(qy),e(Jy),Math.floor(n(qy,Jy))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var Xy=Yy(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Xy.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Yy(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Xy),Xy.range;var Zy=1e3,Qy=Zy*60,$y=Qy*60,eb=$y*24,tb=eb*7,nb=eb*30,rb=eb*365,ib=Yy(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Zy)},(e,t)=>(t-e)/Zy,e=>e.getUTCSeconds());ib.range;var ab=Yy(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Zy)},(e,t)=>{e.setTime(+e+t*Qy)},(e,t)=>(t-e)/Qy,e=>e.getMinutes());ab.range;var ob=Yy(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Qy)},(e,t)=>(t-e)/Qy,e=>e.getUTCMinutes());ob.range;var sb=Yy(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Zy-e.getMinutes()*Qy)},(e,t)=>{e.setTime(+e+t*$y)},(e,t)=>(t-e)/$y,e=>e.getHours());sb.range;var cb=Yy(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*$y)},(e,t)=>(t-e)/$y,e=>e.getUTCHours());cb.range;var lb=Yy(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Qy)/eb,e=>e.getDate()-1);lb.range;var ub=Yy(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/eb,e=>e.getUTCDate()-1);ub.range;var db=Yy(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/eb,e=>Math.floor(e/eb));db.range;function fb(e){return Yy(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Qy)/tb)}var pb=fb(0),mb=fb(1),Nre=fb(2),Pre=fb(3),hb=fb(4),Fre=fb(5),Ire=fb(6);pb.range,mb.range,Nre.range,Pre.range,hb.range,Fre.range,Ire.range;function gb(e){return Yy(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/tb)}var _b=gb(0),vb=gb(1),yb=gb(2),bb=gb(3),xb=gb(4),Sb=gb(5),Cb=gb(6);_b.range,vb.range,yb.range,bb.range,xb.range,Sb.range,Cb.range;var wb=Yy(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());wb.range;var Tb=Yy(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());Tb.range;var Eb=Yy(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Eb.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Yy(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),Eb.range;var Db=Yy(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Db.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Yy(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),Db.range;function Ob(e,t,n,r,i,a){let o=[[ib,1,Zy],[ib,5,5*Zy],[ib,15,15*Zy],[ib,30,30*Zy],[a,1,Qy],[a,5,5*Qy],[a,15,15*Qy],[a,30,30*Qy],[i,1,$y],[i,3,3*$y],[i,6,6*$y],[i,12,12*$y],[r,1,eb],[r,2,2*eb],[n,1,tb],[t,1,nb],[t,3,3*nb],[e,1,rb]];function s(e,t,n){let r=t<e;r&&([e,t]=[t,e]);let i=n&&typeof n.range==`function`?n:c(e,t,n),a=i?i.range(e,+t+1):[];return r?a.reverse():a}function c(t,n,r){let i=Math.abs(n-t)/r,a=v_(([,,e])=>e).right(o,i);if(a===o.length)return e.every(O_(t/rb,n/rb,r));if(a===0)return Xy.every(Math.max(O_(t,n,r),1));let[s,c]=o[i/o[a-1][2]<o[a][2]/i?a-1:a];return s.every(c)}return[s,c]}var[kb,Ab]=Ob(Db,Tb,_b,db,cb,ob),[jb,Mb]=Ob(Eb,wb,pb,lb,sb,ab);function Nb(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Pb(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Fb(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function Ib(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=Ub(i),u=Wb(i),d=Ub(a),f=Wb(a),p=Ub(o),m=Wb(o),h=Ub(s),g=Wb(s),_=Ub(c),v=Wb(c),y={a:M,A:te,b:ne,B:N,c:null,d:dx,e:dx,f:gx,g:Dx,G:kx,H:fx,I:px,j:mx,L:hx,m:_x,M:vx,p:P,q:re,Q:Qx,s:$x,S:yx,u:bx,U:xx,V:Cx,w:wx,W:Tx,x:null,X:null,y:Ex,Y:Ox,Z:Ax,"%":Zx},b={a:ie,A:ae,b:oe,B:se,c:null,d:jx,e:jx,f:Ix,g:qx,G:Yx,H:Mx,I:Nx,j:Px,L:Fx,m:Lx,M:Rx,p:ce,q:le,Q:Qx,s:$x,S:zx,u:Bx,U:Vx,V:Ux,w:Wx,W:Gx,x:null,X:null,y:Kx,Y:Jx,Z:Xx,"%":Zx},x={a:E,A:D,b:O,B:k,c:A,d:tx,e:tx,f:sx,g:Zb,G:Xb,H:rx,I:rx,j:nx,L:ox,m:ex,M:ix,p:T,q:$b,Q:lx,s:ux,S:ax,u:Kb,U:qb,V:Jb,w:Gb,W:Yb,x:j,X:ee,y:Zb,Y:Xb,Z:Qb,"%":cx};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i<o;)e.charCodeAt(i)===37&&(r.push(e.slice(a,i)),(c=Lb[s=e.charAt(++i)])==null?c=s===`e`?` `:`0`:s=e.charAt(++i),(l=t[s])&&(s=l(n,c)),r.push(s),a=i+1);return r.push(e.slice(a,i)),r.join(``)}}function C(e,t){return function(n){var r=Fb(1900,void 0,1),i=w(r,e,n+=``,0),a,o;if(i!=n.length)return null;if(`Q`in r)return new Date(r.Q);if(`s`in r)return new Date(r.s*1e3+(`L`in r?r.L:0));if(t&&!(`Z`in r)&&(r.Z=0),`p`in r&&(r.H=r.H%12+r.p*12),r.m===void 0&&(r.m=`q`in r?r.q:0),`V`in r){if(r.V<1||r.V>53)return null;`w`in r||(r.w=1),`Z`in r?(a=Pb(Fb(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?vb.ceil(a):vb(a),a=ub.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=Nb(Fb(r.y,0,1)),o=a.getDay(),a=o>4||o===0?mb.ceil(a):mb(a),a=lb.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?Pb(Fb(r.y,0,1)).getUTCDay():Nb(Fb(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,Pb(r)):Nb(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i<a;){if(r>=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in Lb?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function ee(e,t,n){return w(e,r,t,n)}function M(e){return o[e.getDay()]}function te(e){return a[e.getDay()]}function ne(e){return c[e.getMonth()]}function N(e){return s[e.getMonth()]}function P(e){return i[+(e.getHours()>=12)]}function re(e){return 1+~~(e.getMonth()/3)}function ie(e){return o[e.getUTCDay()]}function ae(e){return a[e.getUTCDay()]}function oe(e){return c[e.getUTCMonth()]}function se(e){return s[e.getUTCMonth()]}function ce(e){return i[+(e.getUTCHours()>=12)]}function le(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var Lb={"-":``,_:` `,0:`0`},Rb=/^\s*\d+/,zb=/^%/,Bb=/[\\^$*+?|[\]().{}]/g;function Vb(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a<n?Array(n-a+1).join(t)+i:i)}function Hb(e){return e.replace(Bb,`\\$&`)}function Ub(e){return RegExp(`^(?:`+e.map(Hb).join(`|`)+`)`,`i`)}function Wb(e){return new Map(e.map((e,t)=>[e.toLowerCase(),t]))}function Gb(e,t,n){var r=Rb.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Kb(e,t,n){var r=Rb.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function qb(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Jb(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Yb(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function Xb(e,t,n){var r=Rb.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Zb(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Qb(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function $b(e,t,n){var r=Rb.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function ex(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function tx(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function nx(e,t,n){var r=Rb.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function rx(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function ix(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function ax(e,t,n){var r=Rb.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function ox(e,t,n){var r=Rb.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function sx(e,t,n){var r=Rb.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function cx(e,t,n){var r=zb.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function lx(e,t,n){var r=Rb.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function ux(e,t,n){var r=Rb.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function dx(e,t){return Vb(e.getDate(),t,2)}function fx(e,t){return Vb(e.getHours(),t,2)}function px(e,t){return Vb(e.getHours()%12||12,t,2)}function mx(e,t){return Vb(1+lb.count(Eb(e),e),t,3)}function hx(e,t){return Vb(e.getMilliseconds(),t,3)}function gx(e,t){return hx(e,t)+`000`}function _x(e,t){return Vb(e.getMonth()+1,t,2)}function vx(e,t){return Vb(e.getMinutes(),t,2)}function yx(e,t){return Vb(e.getSeconds(),t,2)}function bx(e){var t=e.getDay();return t===0?7:t}function xx(e,t){return Vb(pb.count(Eb(e)-1,e),t,2)}function Sx(e){var t=e.getDay();return t>=4||t===0?hb(e):hb.ceil(e)}function Cx(e,t){return e=Sx(e),Vb(hb.count(Eb(e),e)+(Eb(e).getDay()===4),t,2)}function wx(e){return e.getDay()}function Tx(e,t){return Vb(mb.count(Eb(e)-1,e),t,2)}function Ex(e,t){return Vb(e.getFullYear()%100,t,2)}function Dx(e,t){return e=Sx(e),Vb(e.getFullYear()%100,t,2)}function Ox(e,t){return Vb(e.getFullYear()%1e4,t,4)}function kx(e,t){var n=e.getDay();return e=n>=4||n===0?hb(e):hb.ceil(e),Vb(e.getFullYear()%1e4,t,4)}function Ax(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+Vb(t/60|0,`0`,2)+Vb(t%60,`0`,2)}function jx(e,t){return Vb(e.getUTCDate(),t,2)}function Mx(e,t){return Vb(e.getUTCHours(),t,2)}function Nx(e,t){return Vb(e.getUTCHours()%12||12,t,2)}function Px(e,t){return Vb(1+ub.count(Db(e),e),t,3)}function Fx(e,t){return Vb(e.getUTCMilliseconds(),t,3)}function Ix(e,t){return Fx(e,t)+`000`}function Lx(e,t){return Vb(e.getUTCMonth()+1,t,2)}function Rx(e,t){return Vb(e.getUTCMinutes(),t,2)}function zx(e,t){return Vb(e.getUTCSeconds(),t,2)}function Bx(e){var t=e.getUTCDay();return t===0?7:t}function Vx(e,t){return Vb(_b.count(Db(e)-1,e),t,2)}function Hx(e){var t=e.getUTCDay();return t>=4||t===0?xb(e):xb.ceil(e)}function Ux(e,t){return e=Hx(e),Vb(xb.count(Db(e),e)+(Db(e).getUTCDay()===4),t,2)}function Wx(e){return e.getUTCDay()}function Gx(e,t){return Vb(vb.count(Db(e)-1,e),t,2)}function Kx(e,t){return Vb(e.getUTCFullYear()%100,t,2)}function qx(e,t){return e=Hx(e),Vb(e.getUTCFullYear()%100,t,2)}function Jx(e,t){return Vb(e.getUTCFullYear()%1e4,t,4)}function Yx(e,t){var n=e.getUTCDay();return e=n>=4||n===0?xb(e):xb.ceil(e),Vb(e.getUTCFullYear()%1e4,t,4)}function Xx(){return`+0000`}function Zx(){return`%`}function Qx(e){return+e}function $x(e){return Math.floor(e/1e3)}var eS,tS,nS;rS({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function rS(e){return eS=Ib(e),tS=eS.format,eS.parse,nS=eS.utcFormat,eS.utcParse,eS}function iS(e){return new Date(e)}function aS(e){return e instanceof Date?+e:+new Date(+e)}function oS(e,t,n,r,i,a,o,s,c,l){var u=dy(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)<e?p:s(e)<e?m:o(e)<e?h:a(e)<e?g:r(e)<e?i(e)<e?_:v:n(e)<e?y:b)(e)}return u.invert=function(e){return new Date(d(e))},u.domain=function(e){return arguments.length?f(Array.from(e,aS)):f().map(iS)},u.ticks=function(t){var n=f();return e(n[0],n[n.length-1],t??10)},u.tickFormat=function(e,t){return t==null?x:l(t)},u.nice=function(e){var n=f();return(!e||typeof e.range!=`function`)&&(e=t(n[0],n[n.length-1],e??10)),e?f(ky(n,e)):u},u.copy=function(){return ly(u,oS(e,t,n,r,i,a,o,s,c,l))},u}function sS(){return lv.apply(oS(jb,Mb,Eb,wb,pb,lb,sb,ab,ib,tS).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function cS(){return lv.apply(oS(kb,Ab,Db,Tb,_b,ub,cb,ob,ib,nS).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function lS(){var e=0,t=1,n,r,i,a,o=sy,s=!1,c;function l(e){return e==null||isNaN(e=+e)?c:o(i===0?.5:(e=(a(e)-n)*i,s?Math.max(0,Math.min(1,e)):e))}l.domain=function(o){return arguments.length?([e,t]=o,n=a(e=+e),r=a(t=+t),i=n===r?0:1/(r-n),l):[e,t]},l.clamp=function(e){return arguments.length?(s=!!e,l):s},l.interpolator=function(e){return arguments.length?(o=e,l):o};function u(e){return function(t){var n,r;return arguments.length?([n,r]=t,o=e(n,r),l):[o(0),o(1)]}}return l.range=u(ry),l.rangeRound=u(iy),l.unknown=function(e){return arguments.length?(c=e,l):c},function(o){return a=o,n=o(e),r=o(t),i=n===r?0:1/(r-n),l}}function uS(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function dS(){var e=Ey(lS()(sy));return e.copy=function(){return uS(e,dS())},uv.apply(e,arguments)}function fS(){var e=Ny(lS()).domain([1,10]);return e.copy=function(){return uS(e,fS()).base(e.base())},uv.apply(e,arguments)}function pS(){var e=Ly(lS());return e.copy=function(){return uS(e,pS()).constant(e.constant())},uv.apply(e,arguments)}function mS(){var e=By(lS());return e.copy=function(){return uS(e,mS()).exponent(e.exponent())},uv.apply(e,arguments)}function hS(){return mS.apply(null,arguments).exponent(.5)}function gS(){var e=[],t=sy;function n(n){if(n!=null&&!isNaN(n=+n))return t((x_(e,n,1)-1)/(e.length-1))}return n.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(g_),n},n.interpolator=function(e){return arguments.length?(t=e,n):t},n.range=function(){return e.map((n,r)=>t(r/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(n,r)=>N_(e,r/t))},n.copy=function(){return gS(t).domain(e)},uv.apply(n,arguments)}function _S(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=sy,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*e<r*a?s:c),l(d?Math.max(0,Math.min(1,e)):e))}p.domain=function(l){return arguments.length?([e,t,n]=l,i=u(e=+e),a=u(t=+t),o=u(n=+n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[e,t,n]},p.clamp=function(e){return arguments.length?(d=!!e,p):d},p.interpolator=function(e){return arguments.length?(l=e,p):l};function m(e){return function(t){var n,r,i;return arguments.length?([n,r,i]=t,l=cre(e,[n,r,i]),p):[l(0),l(.5),l(1)]}}return p.range=m(ry),p.rangeRound=m(iy),p.unknown=function(e){return arguments.length?(f=e,p):f},function(l){return u=l,i=l(e),a=l(t),o=l(n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function vS(){var e=Ey(_S()(sy));return e.copy=function(){return uS(e,vS())},uv.apply(e,arguments)}function yS(){var e=Ny(_S()).domain([.1,1,10]);return e.copy=function(){return uS(e,yS()).base(e.base())},uv.apply(e,arguments)}function bS(){var e=Ly(_S());return e.copy=function(){return uS(e,bS()).constant(e.constant())},uv.apply(e,arguments)}function xS(){var e=By(_S());return e.copy=function(){return uS(e,xS()).exponent(e.exponent())},uv.apply(e,arguments)}function SS(){return xS.apply(null,arguments).exponent(.5)}function CS(e){for(var t=e.length/6|0,n=Array(t),r=0;r<t;)n[r]=`#`+e.slice(r*6,++r*6);return n}var wS=CS(`a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928`);function TS(e){"@babel/helpers - typeof";return TS=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},TS(e)}var ES=/^\s+/,DS=/\s+$/;function OS(e,t){if(e||=``,t||={},e instanceof OS)return e;if(!(this instanceof OS))return new OS(e,t);var n=kS(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}OS.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=$S(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=NS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=NS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=jS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=jS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return FS(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return IS(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(eC(this._r,255)*100)+`%`,g:Math.round(eC(this._g,255)*100)+`%`,b:Math.round(eC(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(eC(this._r,255)*100)+`%, `+Math.round(eC(this._g,255)*100)+`%, `+Math.round(eC(this._b,255)*100)+`%)`:`rgba(`+Math.round(eC(this._r,255)*100)+`%, `+Math.round(eC(this._g,255)*100)+`%, `+Math.round(eC(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:ZS[FS(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+LS(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?`GradientType = 1, `:``;if(e){var i=OS(e);n=`#`+LS(i._r,i._g,i._b,i._a)}return`progid:DXImageTransform.Microsoft.gradient(`+r+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return OS(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(VS,arguments)},brighten:function(){return this._applyModification(HS,arguments)},darken:function(){return this._applyModification(US,arguments)},desaturate:function(){return this._applyModification(RS,arguments)},saturate:function(){return this._applyModification(zS,arguments)},greyscale:function(){return this._applyModification(BS,arguments)},spin:function(){return this._applyModification(WS,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(JS,arguments)},complement:function(){return this._applyCombination(GS,arguments)},monochromatic:function(){return this._applyCombination(YS,arguments)},splitcomplement:function(){return this._applyCombination(qS,arguments)},triad:function(){return this._applyCombination(KS,[3])},tetrad:function(){return this._applyCombination(KS,[4])}},OS.fromRatio=function(e,t){if(TS(e)==`object`){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=r===`a`?e[r]:oC(e[r]));e=n}return OS(e,t)};function kS(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;return typeof e==`string`&&(e=dC(e)),TS(e)==`object`&&(uC(e.r)&&uC(e.g)&&uC(e.b)?(t=AS(e.r,e.g,e.b),o=!0,s=String(e.r).substr(-1)===`%`?`prgb`:`rgb`):uC(e.h)&&uC(e.s)&&uC(e.v)?(r=oC(e.s),i=oC(e.v),t=PS(e.h,r,i),o=!0,s=`hsv`):uC(e.h)&&uC(e.s)&&uC(e.l)&&(r=oC(e.s),a=oC(e.l),t=MS(e.h,r,a),o=!0,s=`hsl`),e.hasOwnProperty(`a`)&&(n=e.a)),n=$S(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}function AS(e,t,n){return{r:eC(e,255)*255,g:eC(t,255)*255,b:eC(n,255)*255}}function jS(e,t,n){e=eC(e,255),t=eC(t,255),n=eC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4}a/=6}return{h:a,s:o,l:s}}function MS(e,t,n){var r,i,a;e=eC(e,360),t=eC(t,100),n=eC(n,100);function o(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function NS(e,t,n){e=eC(e,255),t=eC(t,255),n=eC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4}a/=6}return{h:a,s:o,v:s}}function PS(e,t,n){e=eC(e,360)*6,t=eC(t,100),n=eC(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),c=r%6,l=[n,o,a,a,s,n][c],u=[s,n,n,o,a,a][c],d=[a,a,s,n,n,o][c];return{r:l*255,g:u*255,b:d*255}}function FS(e,t,n,r){var i=[aC(Math.round(e).toString(16)),aC(Math.round(t).toString(16)),aC(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join(``)}function IS(e,t,n,r,i){var a=[aC(Math.round(e).toString(16)),aC(Math.round(t).toString(16)),aC(Math.round(n).toString(16)),aC(sC(r))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join(``)}function LS(e,t,n,r){return[aC(sC(r)),aC(Math.round(e).toString(16)),aC(Math.round(t).toString(16)),aC(Math.round(n).toString(16))].join(``)}OS.equals=function(e,t){return!e||!t?!1:OS(e).toRgbString()==OS(t).toRgbString()},OS.random=function(){return OS.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function RS(e,t){t=t===0?0:t||10;var n=OS(e).toHsl();return n.s-=t/100,n.s=tC(n.s),OS(n)}function zS(e,t){t=t===0?0:t||10;var n=OS(e).toHsl();return n.s+=t/100,n.s=tC(n.s),OS(n)}function BS(e){return OS(e).desaturate(100)}function VS(e,t){t=t===0?0:t||10;var n=OS(e).toHsl();return n.l+=t/100,n.l=tC(n.l),OS(n)}function HS(e,t){t=t===0?0:t||10;var n=OS(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(t/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(t/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(t/100)))),OS(n)}function US(e,t){t=t===0?0:t||10;var n=OS(e).toHsl();return n.l-=t/100,n.l=tC(n.l),OS(n)}function WS(e,t){var n=OS(e).toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,OS(n)}function GS(e){var t=OS(e).toHsl();return t.h=(t.h+180)%360,OS(t)}function KS(e,t){if(isNaN(t)||t<=0)throw Error(`Argument to polyad must be a positive number`);for(var n=OS(e).toHsl(),r=[OS(e)],i=360/t,a=1;a<t;a++)r.push(OS({h:(n.h+a*i)%360,s:n.s,l:n.l}));return r}function qS(e){var t=OS(e).toHsl(),n=t.h;return[OS(e),OS({h:(n+72)%360,s:t.s,l:t.l}),OS({h:(n+216)%360,s:t.s,l:t.l})]}function JS(e,t,n){t||=6,n||=30;var r=OS(e).toHsl(),i=360/n,a=[OS(e)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(OS(r));return a}function YS(e,t){t||=6;for(var n=OS(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(OS({h:r,s:i,v:a})),a=(a+s)%1;return o}OS.mix=function(e,t,n){n=n===0?0:n||50;var r=OS(e).toRgb(),i=OS(t).toRgb(),a=n/100;return OS({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},OS.readability=function(e,t){var n=OS(e),r=OS(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},OS.isReadable=function(e,t,n){var r=OS.readability(e,t),i,a=!1;switch(i=fC(n),i.level+i.size){case`AAsmall`:case`AAAlarge`:a=r>=4.5;break;case`AAlarge`:a=r>=3;break;case`AAAsmall`:a=r>=7}return a},OS.mostReadable=function(e,t,n){var r=null,i=0,a,o,s,c;n||={},o=n.includeFallbackColors,s=n.level,c=n.size;for(var l=0;l<t.length;l++)a=OS.readability(e,t[l]),a>i&&(i=a,r=OS(t[l]));return OS.isReadable(e,r,{level:s,size:c})||!o?r:(n.includeFallbackColors=!1,OS.mostReadable(e,[`#fff`,`#000`],n))};var XS=OS.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},ZS=OS.hexNames=QS(XS);function QS(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function $S(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function eC(e,t){rC(e)&&(e=`100%`);var n=iC(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function tC(e){return Math.min(1,Math.max(0,e))}function nC(e){return parseInt(e,16)}function rC(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function iC(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function aC(e){return e.length==1?`0`+e:``+e}function oC(e){return e<=1&&(e=e*100+`%`),e}function sC(e){return Math.round(parseFloat(e)*255).toString(16)}function cC(e){return nC(e)/255}var lC=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function uC(e){return!!lC.CSS_UNIT.exec(e)}function dC(e){e=e.replace(ES,``).replace(DS,``).toLowerCase();var t=!1;if(XS[e])e=XS[e],t=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var n;return(n=lC.rgb.exec(e))?{r:n[1],g:n[2],b:n[3]}:(n=lC.rgba.exec(e))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=lC.hsl.exec(e))?{h:n[1],s:n[2],l:n[3]}:(n=lC.hsla.exec(e))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=lC.hsv.exec(e))?{h:n[1],s:n[2],v:n[3]}:(n=lC.hsva.exec(e))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=lC.hex8.exec(e))?{r:nC(n[1]),g:nC(n[2]),b:nC(n[3]),a:cC(n[4]),format:t?`name`:`hex8`}:(n=lC.hex6.exec(e))?{r:nC(n[1]),g:nC(n[2]),b:nC(n[3]),format:t?`name`:`hex`}:(n=lC.hex4.exec(e))?{r:nC(n[1]+``+n[1]),g:nC(n[2]+``+n[2]),b:nC(n[3]+``+n[3]),a:cC(n[4]+``+n[4]),format:t?`name`:`hex8`}:(n=lC.hex3.exec(e))?{r:nC(n[1]+``+n[1]),g:nC(n[2]+``+n[2]),b:nC(n[3]+``+n[3]),format:t?`name`:`hex`}:!1}function fC(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}function pC(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mC(e){if(Array.isArray(e))return e}function hC(e){if(Array.isArray(e))return pC(e)}function gC(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function _C(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function vC(e,t,n){return t=kC(t),RC(e,jC()?Reflect.construct(t,n||[],kC(e).constructor):t.apply(e,n))}function yC(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function bC(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function xC(e,t){return e.get(gC(e,t))}function SC(e,t,n){yC(e,t),t.set(e,n)}function CC(e,t,n){return e.set(gC(e,t),n),n}function wC(e,t,n){if(jC())return Reflect.construct.apply(null,arguments);var r=[null];return r.push.apply(r,t),new(e.bind.apply(e,r))}function TC(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,GC(r.key),r)}}function EC(e,t,n){return t&&TC(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function DC(e,t,n){return(t=GC(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function OC(){return OC=typeof Reflect<`u`&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=VC(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},OC.apply(null,arguments)}function kC(e){return kC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},kC(e)}function AC(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&zC(e,t)}function jC(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(jC=function(){return!!e})()}function MC(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function NC(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function PC(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4627
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
4628
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function IC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function LC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?IC(Object(n),!0).forEach(function(t){DC(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IC(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function RC(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return _C(e)}function zC(e,t){return zC=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zC(e,t)}function BC(e,t){return mC(e)||NC(e,t)||qC(e,t)||PC()}function VC(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=kC(e))!==null;);return e}function HC(e,t,n,r){var i=OC(kC(e.prototype),t,n);return typeof i==`function`?function(e){return i.apply(n,e)}:i}function UC(e){return hC(e)||MC(e)||qC(e)||FC()}function WC(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function GC(e){var t=WC(e,`string`);return typeof t==`symbol`?t:t+``}function KC(e){"@babel/helpers - typeof";return KC=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},KC(e)}function qC(e,t){if(e){if(typeof e==`string`)return pC(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pC(e,t):void 0}}var JC=function(e){e instanceof Array?e.forEach(JC):(e.map&&e.map.dispose(),e.dispose())},YC=function(e){e.geometry&&e.geometry.dispose(),e.material&&JC(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(YC)},XC=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),YC(t)}},ZC=new WeakMap,QC=new WeakMap,$C=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=r.dataBindAttr,a=i===void 0?`__data`:i,o=r.objBindAttr,s=o===void 0?`__threeObj`:o;return bC(this,t),n=vC(this,t),DC(n,`scene`,void 0),SC(n,ZC,void 0),SC(n,QC,void 0),n.scene=e,CC(ZC,n,a),CC(QC,n,s),n.onRemoveObj(function(){}),n}return AC(t,e),EC(t,[{key:`onCreateObj`,value:function(e){var n=this;return HC(t,`onCreateObj`,this)([function(t){var r=e(t);return t[xC(QC,n)]=r,r[xC(ZC,n)]=t,n.scene.add(r),r}]),this}},{key:`onRemoveObj`,value:function(e){var n=this;return HC(t,`onRemoveObj`,this)([function(r,i){var a=HC(t,`getData`,n)([r]);e(r,i),n.scene.remove(r),YC(r),delete a[xC(QC,n)]}]),this}}])}(cv),ew=function(e){return isNaN(e)?parseInt(OS(e).toHex(),16):e},tw=function(e){return isNaN(e)?OS(e).getAlpha():1},nw=fv(wS);function rw(e,t,n){!t||typeof n!=`string`||e.filter(function(e){return!e[n]}).forEach(function(e){e[n]=nw(t(e))})}function iw(e,t){var n=e.nodes,r=e.links,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=i.nodeFilter,o=a===void 0?function(){return!0}:a,s=i.onLoopError,c=s===void 0?function(e){throw`Invalid DAG structure! Found cycle in node path: ${e.join(` -> `)}.`}:s,l={};n.forEach(function(e){return l[t(e)]={data:e,out:[],depth:-1,skip:!o(e)}}),r.forEach(function(e){var n=e.source,r=e.target,i=c(n),a=c(r);if(!l.hasOwnProperty(i))throw`Missing source node with id: ${i}`;if(!l.hasOwnProperty(a))throw`Missing target node with id: ${a}`;var o=l[i],s=l[a];o.out.push(s);function c(e){return KC(e)===`object`?t(e):e}});var u=[];return d(Object.values(l)),Object.assign.apply(Object,[{}].concat(UC(Object.entries(l).filter(function(e){return!BC(e,2)[1].skip}).map(function(e){var t=BC(e,2),n=t[0],r=t[1];return DC({},n,r.depth)}))));function d(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=function(){var i=e[a];if(n.indexOf(i)!==-1){var o=[].concat(UC(n.slice(n.indexOf(i))),[i]).map(function(e){return t(e.data)});return u.some(function(e){return e.length===o.length&&e.every(function(e,t){return e===o[t]})})||(u.push(o),c(o)),1}r>i.depth&&(i.depth=r,d(i.out,[].concat(UC(n),[i]),r+ +!i.skip))},a=0,o=e.length;a<o;a++)if(i())continue}}var aw=window.THREE?window.THREE:{Group:gc,Mesh:Zl,MeshLambertMaterial:wd,Color:Cc,BufferGeometry:wl,BufferAttribute:cl,Matrix4:Hs,Vector3:U,SphereGeometry:ad,CylinderGeometry:ku,TubeGeometry:sd,ConeGeometry:Au,Line:bu,LineBasicMaterial:fu,QuadraticBezierCurve3:nd,CubicBezierCurve3:Qu,Box3:Bc},ow={graph:Tg,forcelayout:Dne.default},sw=2,cw=new aw.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,lw=new aw.BufferGeometry().applyMatrix4?`applyMatrix4`:`applyMatrix`,uw=m_({props:{jsonUrl:{onChange:function(e,t){var n=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(e){return e.json()}).then(function(e){t.fetchingJson=!1,t.onFinishLoading(e),n.graphData(e)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var n=t.d3ForceLayout.force(`charge`);n&&n.strength(e>2?-60:-30),e<3&&r(t.graphData.nodes,`z`),e<2&&r(t.graphData.nodes,`y`);function r(e,t){e.forEach(function(e){delete e[t],delete e[`v${t}`]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine===`d3`&&(t.graphData.nodes||[]).forEach(function(e){e.fx=e.fy=e.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:`id`},nodeVal:{default:`val`},nodeResolution:{default:8},nodeColor:{default:`color`},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:`source`},linkTarget:{default:`target`},linkVisibility:{default:!0},linkColor:{default:`color`},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:`d3`},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,n){return n===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!==`ngraph`;return e.engineRunning&&n(),r(),i(),this;function n(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin?(e.engineRunning=!1,e.onEngineStop()):(e.layout[t?`tick`:`step`](),e.onEngineTick());var n=h_(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(r){var i=BC(r,2),a=i[0],o=i[1];if(o){var s=t?a:e.layout.getNodePosition(a[e.nodeId]),c=n(a);(!e.nodePositionUpdate||!e.nodePositionUpdate(c?o.children[0]:o,{x:s.x,y:s.y,z:s.z},a)||c)&&(o.position.x=s.x,o.position.y=s.y||0,o.position.z=s.z||0)}});var r=h_(e.linkWidth),i=h_(e.linkCurvature),a=h_(e.linkCurveRotation),o=h_(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(n){var i=BC(n,2),a=i[0],c=i[1];if(c){var l=t?a:e.layout.getLinkPosition(e.layout.graph.getLink(a.source,a.target).id),u=l[t?`source`:`from`],d=l[t?`target`:`to`];if(!(!u||!d||!u.hasOwnProperty(`x`)||!d.hasOwnProperty(`x`))){s(a);var f=o(a);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(f?c.children[1]:c,{start:{x:u.x,y:u.y,z:u.z},end:{x:d.x,y:d.y,z:d.z}},a)&&!f)){var p=30,m=a.__curve,h=c.children.length?c.children[0]:c;if(h.type===`Line`){if(m){var g=m.getPoints(p);h.geometry.getAttribute(`position`).array.length!==g.length*3&&h.geometry[cw](`position`,new aw.BufferAttribute(new Float32Array(g.length*3),3)),h.geometry.setFromPoints(g)}else{var _=h.geometry.getAttribute(`position`);(!_||!_.array||_.array.length!==6)&&h.geometry[cw](`position`,_=new aw.BufferAttribute(new Float32Array(6),3)),_.array[0]=u.x,_.array[1]=u.y||0,_.array[2]=u.z||0,_.array[3]=d.x,_.array[4]=d.y||0,_.array[5]=d.z||0,_.needsUpdate=!0}h.geometry.computeBoundingSphere()}else if(h.type===`Mesh`){if(m){h.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(h.position.set(0,0,0),h.rotation.set(0,0,0),h.scale.set(1,1,1));var v=Math.ceil(r(a)*10)/10/2,y=new aw.TubeGeometry(m,p,v,e.linkResolution,!1);h.geometry.dispose(),h.geometry=y}else{if(!h.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var b=Math.ceil(r(a)*10)/10/2,x=new aw.CylinderGeometry(b,b,1,e.linkResolution,1,!1);x[lw](new aw.Matrix4().makeTranslation(0,1/2,0)),x[lw](new aw.Matrix4().makeRotationX(Math.PI/2)),h.geometry.dispose(),h.geometry=x}var S=new aw.Vector3(u.x,u.y||0,u.z||0),C=new aw.Vector3(d.x,d.y||0,d.z||0),w=S.distanceTo(C);h.position.x=S.x,h.position.y=S.y,h.position.z=S.z,h.scale.z=w,h.parent.localToWorld(C),h.lookAt(C)}}}}}});function s(n){var r=t?n:e.layout.getLinkPosition(e.layout.graph.getLink(n.source,n.target).id),o=r[t?`source`:`from`],s=r[t?`target`:`to`];if(!(!o||!s||!o.hasOwnProperty(`x`)||!s.hasOwnProperty(`x`))){var c=i(n);if(!c)n.__curve=null;else{var l=new aw.Vector3(o.x,o.y||0,o.z||0),u=new aw.Vector3(s.x,s.y||0,s.z||0),d=l.distanceTo(u),f,p=a(n);if(d>0){var m=s.x-o.x,h=s.y-o.y||0,g=new aw.Vector3().subVectors(u,l),_=g.clone().multiplyScalar(c).cross(m!==0||h!==0?new aw.Vector3(0,0,1):new aw.Vector3(0,1,0)).applyAxisAngle(g.normalize(),p).add(new aw.Vector3().addVectors(l,u).divideScalar(2));f=new aw.QuadraticBezierCurve3(l,_,u)}else{var v=c*70,y=-p,b=y+Math.PI/2;f=new aw.CubicBezierCurve3(l,new aw.Vector3(v*Math.cos(b),v*Math.sin(b),0).add(l),new aw.Vector3(v*Math.cos(y),v*Math.sin(y),0).add(l),u)}n.__curve=f}}}}function r(){var n=h_(e.linkDirectionalArrowRelPos),r=h_(e.linkDirectionalArrowLength),i=h_(e.nodeVal);e.arrowDataMapper.entries().forEach(function(a){var o=BC(a,2),s=o[0],c=o[1];if(c){var l=t?s:e.layout.getLinkPosition(e.layout.graph.getLink(s.source,s.target).id),u=l[t?`source`:`from`],d=l[t?`target`:`to`];if(!(!u||!d||!u.hasOwnProperty(`x`)||!d.hasOwnProperty(`x`))){var f=Math.cbrt(Math.max(0,i(u)||1))*e.nodeRelSize,p=Math.cbrt(Math.max(0,i(d)||1))*e.nodeRelSize,m=r(s),h=n(s),g=s.__curve?function(e){return s.__curve.getPoint(e)}:function(e){var t=function(e,t,n,r){return t[e]+(n[e]-t[e])*r||0};return{x:t(`x`,u,d,e),y:t(`y`,u,d,e),z:t(`z`,u,d,e)}},_=s.__curve?s.__curve.getLength():Math.sqrt([`x`,`y`,`z`].map(function(e){return((d[e]||0)-(u[e]||0))**2}).reduce(function(e,t){return e+t},0)),v=f+m+(_-f-p-m)*h,y=g(v/_),b=g((v-m)/_);[`x`,`y`,`z`].forEach(function(e){return c.position[e]=b[e]});var x=wC(aw.Vector3,UC([`x`,`y`,`z`].map(function(e){return y[e]})));c.parent.localToWorld(x),c.lookAt(x)}}})}function i(){var n=h_(e.linkDirectionalParticleSpeed),r=h_(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(i){var a=e.particlesDataMapper.getObj(i),o=a&&a.children,s=i.__singleHopPhotonsObj&&i.__singleHopPhotonsObj.children;if(!((!s||!s.length)&&(!o||!o.length))){var c=t?i:e.layout.getLinkPosition(e.layout.graph.getLink(i.source,i.target).id),l=c[t?`source`:`from`],u=c[t?`target`:`to`];if(!(!l||!u||!l.hasOwnProperty(`x`)||!u.hasOwnProperty(`x`))){var d=n(i),f=Math.abs(r(i)),p=i.__curve?function(e){return i.__curve.getPoint(e)}:function(e){var t=function(e,t,n,r){return t[e]+(n[e]-t[e])*r||0};return{x:t(`x`,l,u,e),y:t(`y`,l,u,e),z:t(`z`,l,u,e)}};[].concat(UC(o||[]),UC(s||[])).forEach(function(e,t){var n=e.parent.__linkThreeObjType===`singleHopPhotons`;if(e.hasOwnProperty(`__progressRatio`)||(e.__progressRatio=n?+(d<0):(t+f)/o.length),e.__progressRatio+=d,e.__progressRatio>=1||e.__progressRatio<0){if(!n)e.__progressRatio%=1,e.__progressRatio<0&&e.__progressRatio++;else{e.parent.remove(e),XC(e);return}}var r=e.__progressRatio,i=p(r);e.geometry.type!==`SphereGeometry`&&e.lookAt(i.x,i.y,i.z),[`x`,`y`,`z`].forEach(function(t){return e.position[t]=i[t]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new aw.Group;n.__linkThreeObjType=`singleHopPhotons`,t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var r=h_(e.linkDirectionalParticleThreeObject)(t);if(r&&e.linkDirectionalParticleThreeObject===r&&(r=r.clone()),!r){var i=h_(e.linkDirectionalParticleWidth),a=Math.ceil(i(t)*10)/10/2,o=e.linkDirectionalParticleResolution,s=new aw.SphereGeometry(a,o,o),c=h_(e.linkColor),l=h_(e.linkDirectionalParticleColor)(t)||c(t)||`#f0f0f0`,u=new aw.Color(ew(l)),d=e.linkOpacity*3,f=new aw.MeshLambertMaterial({color:u,transparent:!0,opacity:d});r=new aw.Mesh(s,f)}t.__singleHopPhotonsObj.add(r)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var n=function e(n){var r=[];if(n.geometry){n.geometry.computeBoundingBox();var i=new aw.Box3;i.copy(n.geometry.boundingBox).applyMatrix4(n.matrixWorld),r.push(i)}return r.concat.apply(r,UC((n.children||[]).filter(function(e){return!e.hasOwnProperty(`__graphObjType`)||e.__graphObjType===`node`&&t(e.__data)}).map(e)))}(e.graphScene);return n.length?Object.assign.apply(Object,UC([`x`,`y`,`z`].map(function(e){return DC({},e,[A_(n,function(t){return t.min[e]}),k_(n,function(t){return t.max[e]})])}))):null}},stateInit:function(){return{d3ForceLayout:pne().force(`link`,Qte()).force(`charge`,mne()).force(`center`,ete()).force(`dagRadial`,null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new $C(e,{objBindAttr:`__threeObj`}),t.linkDataMapper=new $C(e,{objBindAttr:`__lineObj`}),t.arrowDataMapper=new $C(e,{objBindAttr:`__arrowObj`}),t.particlesDataMapper=new $C(e,{objBindAttr:`__photonsObj`})},update:function(e,t){var n=function(e){return e.some(function(e){return t.hasOwnProperty(e)})};if(e.engineRunning=!1,typeof e.onUpdate==`function`&&e.onUpdate(),e.nodeAutoColorBy!==null&&n([`nodeAutoColorBy`,`graphData`,`nodeColor`])&&rw(e.graphData.nodes,h_(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n([`linkAutoColorBy`,`graphData`,`linkColor`])&&rw(e.graphData.links,h_(e.linkAutoColorBy),e.linkColor),e._flushObjects||n([`graphData`,`nodeThreeObject`,`nodeThreeObjectExtend`,`nodeVal`,`nodeColor`,`nodeVisibility`,`nodeRelSize`,`nodeResolution`,`nodeOpacity`])){var r=h_(e.nodeThreeObject),i=h_(e.nodeThreeObjectExtend),a=h_(e.nodeVal),o=h_(e.nodeColor),s=h_(e.nodeVisibility),c={},l={};(e._flushObjects||n([`nodeThreeObject`,`nodeThreeObjectExtend`]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(t){var n=r(t),a=i(t);n&&e.nodeThreeObject===n&&(n=n.clone());var o;return n&&!a?o=n:(o=new aw.Mesh,o.__graphDefaultObj=!0,n&&a&&o.add(n)),o.__graphObjType=`node`,o}).onUpdateObj(function(t,n){if(t.__graphDefaultObj){var r=a(n)||1,i=Math.cbrt(r)*e.nodeRelSize,s=e.nodeResolution;(!t.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||t.geometry.parameters.radius!==i||t.geometry.parameters.widthSegments!==s)&&(c.hasOwnProperty(r)||(c[r]=new aw.SphereGeometry(i,s,s)),t.geometry.dispose(),t.geometry=c[r]);var u=o(n),d=new aw.Color(ew(u||`#ffffaa`)),f=e.nodeOpacity*tw(u);(t.material.type!==`MeshLambertMaterial`||!t.material.color.equals(d)||t.material.opacity!==f)&&(l.hasOwnProperty(u)||(l[u]=new aw.MeshLambertMaterial({color:d,transparent:!0,opacity:f})),t.material.dispose(),t.material=l[u])}}).digest(e.graphData.nodes.filter(s))}if(e._flushObjects||n([`graphData`,`linkThreeObject`,`linkThreeObjectExtend`,`linkMaterial`,`linkColor`,`linkWidth`,`linkVisibility`,`linkResolution`,`linkOpacity`,`linkDirectionalArrowLength`,`linkDirectionalArrowColor`,`linkDirectionalArrowResolution`,`linkDirectionalParticles`,`linkDirectionalParticleWidth`,`linkDirectionalParticleColor`,`linkDirectionalParticleResolution`,`linkDirectionalParticleThreeObject`])){var u=h_(e.linkThreeObject),d=h_(e.linkThreeObjectExtend),f=h_(e.linkMaterial),p=h_(e.linkVisibility),m=h_(e.linkColor),h=h_(e.linkWidth),g={},_={},v={},y=e.graphData.links.filter(p);if((e._flushObjects||n([`linkThreeObject`,`linkThreeObjectExtend`,`linkWidth`]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(e){var t=e.__data&&e.__data.__singleHopPhotonsObj;t&&(t.parent.remove(t),XC(t),delete e.__data.__singleHopPhotonsObj)}).onCreateObj(function(t){var n=u(t),r=d(t);n&&e.linkThreeObject===n&&(n=n.clone());var i;if(!n||r){if(h(t))i=new aw.Mesh;else{var a=new aw.BufferGeometry;a[cw](`position`,new aw.BufferAttribute(new Float32Array(6),3)),i=new aw.Line(a)}}var o;return n?r?(o=new aw.Group,o.__graphDefaultObj=!0,o.add(i),o.add(n)):o=n:(o=i,o.__graphDefaultObj=!0),o.renderOrder=10,o.__graphObjType=`link`,o}).onUpdateObj(function(t,n){if(t.__graphDefaultObj){var r=t.children.length?t.children[0]:t,i=Math.ceil(h(n)*10)/10,a=!!i;if(a){var o=i/2,s=e.linkResolution;if(!r.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||r.geometry.parameters.radiusTop!==o||r.geometry.parameters.radialSegments!==s){if(!g.hasOwnProperty(i)){var c=new aw.CylinderGeometry(o,o,1,s,1,!1);c[lw](new aw.Matrix4().makeTranslation(0,1/2,0)),c[lw](new aw.Matrix4().makeRotationX(Math.PI/2)),g[i]=c}r.geometry.dispose(),r.geometry=g[i]}}var l=f(n);if(l)r.material=l;else{var u=m(n),d=new aw.Color(ew(u||`#f0f0f0`)),p=e.linkOpacity*tw(u),y=a?`MeshLambertMaterial`:`LineBasicMaterial`;if(r.material.type!==y||!r.material.color.equals(d)||r.material.opacity!==p){var b=a?_:v;b.hasOwnProperty(u)||(b[u]=new aw[y]({color:d,transparent:p<1,opacity:p,depthWrite:p>=1})),r.material.dispose(),r.material=b[u]}}}}).digest(y),e.linkDirectionalArrowLength||t.hasOwnProperty(`linkDirectionalArrowLength`)){var b=h_(e.linkDirectionalArrowLength),x=h_(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var e=new aw.Mesh(void 0,new aw.MeshLambertMaterial({transparent:!0}));return e.__linkThreeObjType=`arrow`,e}).onUpdateObj(function(t,n){var r=b(n),i=e.linkDirectionalArrowResolution;if(!t.geometry.type.match(/^Cone(Buffer)?Geometry$/)||t.geometry.parameters.height!==r||t.geometry.parameters.radialSegments!==i){var a=new aw.ConeGeometry(r*.25,r,i);a.translate(0,r/2,0),a.rotateX(Math.PI/2),t.geometry.dispose(),t.geometry=a}var o=x(n)||m(n)||`#f0f0f0`;t.material.color=new aw.Color(ew(o)),t.material.opacity=e.linkOpacity*3*tw(o)}).digest(y.filter(b))}if(e.linkDirectionalParticles||t.hasOwnProperty(`linkDirectionalParticles`)){var S=h_(e.linkDirectionalParticles),C=h_(e.linkDirectionalParticleWidth),w=h_(e.linkDirectionalParticleColor),T=h_(e.linkDirectionalParticleThreeObject),E={},D={};e.particlesDataMapper.onCreateObj(function(){var e=new aw.Group;return e.__linkThreeObjType=`photons`,e.__photonDataMapper=new $C(e),e}).onUpdateObj(function(t,n){var r=!!t.children.length&&t.children[0],i=T(n),a,o;if(i)a=i.geometry,o=i.material;else{var s=Math.ceil(C(n)*10)/10/2,c=e.linkDirectionalParticleResolution;r&&r.geometry.parameters.radius===s&&r.geometry.parameters.widthSegments===c?a=r.geometry:(D.hasOwnProperty(s)||(D[s]=new aw.SphereGeometry(s,c,c)),a=D[s]);var l=w(n)||m(n)||`#f0f0f0`,u=new aw.Color(ew(l)),d=e.linkOpacity*3;r&&r.material.color.equals(u)&&r.material.opacity===d?o=r.material:(E.hasOwnProperty(l)||(E[l]=new aw.MeshLambertMaterial({color:u,transparent:!0,opacity:d})),o=E[l])}r&&(r.geometry!==a&&r.geometry.dispose(),r.material!==o&&r.material.dispose());var f=Math.round(Math.abs(S(n)));t.__photonDataMapper.id(function(e){return e.idx}).onCreateObj(function(){return new aw.Mesh(a,o)}).onUpdateObj(function(e){e.geometry=a,e.material=o}).digest(UC(Array(f)).map(function(e,t){return{idx:t}}))}).digest(y.filter(S))}}if(e._flushObjects=!1,n([`graphData`,`nodeId`,`linkSource`,`linkTarget`,`numDimensions`,`forceEngine`,`dagMode`,`dagNodeFilter`,`dagLevelDistance`])){e.engineRunning=!1,e.graphData.links.forEach(function(t){t.source=t[e.linkSource],t.target=t[e.linkTarget]});var O=e.forceEngine!==`ngraph`,k;if(O){(k=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var A=e.d3ForceLayout.force(`link`);A&&A.id(function(t){return t[e.nodeId]}).links(e.graphData.links);var j=e.dagMode&&iw(e.graphData,function(t){return t[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),ee=Math.max.apply(Math,UC(Object.values(j||[]))),M=e.dagLevelDistance||e.graphData.nodes.length/(ee||1)*sw*([`radialin`,`radialout`].indexOf(e.dagMode)===-1?1:.7);if([`lr`,`rl`,`td`,`bu`,`zin`,`zout`].includes(t.dagMode)){var te=[`lr`,`rl`].includes(t.dagMode)?`fx`:[`td`,`bu`].includes(t.dagMode)?`fy`:`fz`;e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(e){return delete e[te]})}if([`lr`,`rl`,`td`,`bu`,`zin`,`zout`].includes(e.dagMode)){var ne=[`rl`,`td`,`zout`].includes(e.dagMode),N=function(t){return(j[t[e.nodeId]]-ee/2)*M*(ne?-1:1)},P=[`lr`,`rl`].includes(e.dagMode)?`fx`:[`td`,`bu`].includes(e.dagMode)?`fy`:`fz`;e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(e){return e[P]=N(e)})}e.d3ForceLayout.force(`dagRadial`,[`radialin`,`radialout`].indexOf(e.dagMode)===-1?null:wg(function(t){var n=j[t[e.nodeId]]||-1;return(e.dagMode===`radialin`?ee-n:n)*M}).strength(function(t){return+!!e.dagNodeFilter(t)}))}else{var re=ow.graph();e.graphData.nodes.forEach(function(t){re.addNode(t[e.nodeId])}),e.graphData.links.forEach(function(e){re.addLink(e.source,e.target)}),k=ow.forcelayout(re,LC({dimensions:e.numDimensions},e.ngraphPhysics)),k.graph=re}for(var ie=0;ie<e.warmupTicks&&!(O&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);ie++)k[O?`tick`:`step`]();e.layout=k,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function dw(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=function(t){function r(){var t;bC(this,r);var i=[...arguments];return t=vC(this,r,[].concat(i)),t.__kapsuleInstance=wC(e,[].concat(UC(n?[t]:[]),i)),t}return AC(r,t),EC(r)}(t);return Object.keys(e()).forEach(function(e){return r.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}}),r}var fw=dw(uw,(window.THREE?window.THREE:{Group:gc}).Group,!0),pw=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.envMapRotation.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`),mw=new WeakMap,hw=new WeakMap,gw=new WeakMap,Lre=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=pw,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1&&(this.getRenderObjectData(e),!0)}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,object:r}=e;if(t={geometryId:n.id,worldMatrix:r.matrixWorld.clone()},r.center&&(t.center=r.center.clone()),r.morphTargetInfluences&&(t.morphTargetInfluences=r.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),e.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}let{environmentIntensity:i,environmentRotation:a}=e.scene;t.environmentIntensity=i,t.environmentRotation=a.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=gw.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},gw.set(e,t)),t}getMaterialData(e){let t=hw.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:0}:t[n]=r.clone():t[n]=r)}hw.set(e,t)}return t}equals(e,t,n){let{object:r,material:i,geometry:a}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(r.matrixWorld)!==!0)return o.worldMatrix.copy(r.matrixWorld),!1;let s=this.getMaterialData(e.material);if(s._renderId!==n){s._renderId=n;for(let e in s){let t=s[e],n=i[e];if(e!==`_renderId`&&e!==`_equal`){if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),s._equal=!1,!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,s._equal=!1,!1}else if(t!==n)return s[e]=n,s._equal=!1,!1}}if(s.transmission>0){let{width:t,height:n}=e.context;if(o.bufferWidth!==t||o.bufferHeight!==n)return o.bufferWidth=t,o.bufferHeight=n,s._equal=!1,!1}s._equal=!0}else if(s._equal===!1)return!1;if(o.geometryId!==a.id)return o.geometryId=a.id,!1;let c=this.getGeometryData(e.geometry);if(c._renderId!==n){c._renderId=n;let e=a.attributes,t=c.attributes,r=0,i=0;for(let t in e)r++;for(let n in t){i++;let r=t[n],a=e[n];if(a===void 0)return delete t[n],c._equal=!1,!1;let o=a.isInterleavedBufferAttribute?a.data.uuid:a.id,s=a.isInterleavedBufferAttribute?a.data.version:a.version;if(r.id!==o||r.version!==s)return r.id=o,r.version=s,c._equal=!1,!1}if(i!==r)return c.attributes=this.getAttributesData(e),c._equal=!1,!1;let o=a.index,s=c.indexId,l=c.indexVersion,u=o?o.id:null,d=o?o.version:null;if(s!==u||l!==d)return c.indexId=u,c.indexVersion=d,c._equal=!1,!1;if(c.drawRange.start!==a.drawRange.start||c.drawRange.count!==a.drawRange.count)return c.drawRange.start=a.drawRange.start,c.drawRange.count=a.drawRange.count,c._equal=!1,!1;c._equal=!0}else if(c._equal===!1)return!1;if(o.morphTargetInfluences){let e=!1;for(let t=0;t<o.morphTargetInfluences.length;t++)o.morphTargetInfluences[t]!==r.morphTargetInfluences[t]&&(o.morphTargetInfluences[t]=r.morphTargetInfluences[t],e=!0);if(e)return!1}if(o.lights){for(let e=0;e<t.length;e++)if(o.lights[e].map!==t[e].map)return!1}let l=e.scene;return l.environment!==null&&i.envMap===null&&(o.environmentIntensity!==l.environmentIntensity||o.environmentRotation.equals(l.environmentRotation)===!1)?(o.environmentIntensity=l.environmentIntensity,o.environmentRotation.copy(l.environmentRotation),!1):o.center&&o.center.equals(r.center)===!1?(o.center.copy(r.center),!1):(e.bundle!==null&&(o.version=e.bundle.version),!0)}getLightsData(e,t){t.length=0;for(let n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){let n=mw.get(e);return n===void 0&&(n={renderId:-1,lightsData:[]},mw.set(e,n)),n.renderId===t?n.lightsData:(n.renderId=t,this.getLightsData(e.getLights(),n.lightsData),n.lightsData)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.getLights(e.lightsNode,n);return this.equals(e,a,n)!==!0}},Rre=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function zre(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
4629
|
-
`).map(e=>{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!
|
|
4630
|
-
`)}`}};function vw(e,t=0){let n=3735928559^t,r=1103547991^t;if(Array.isArray(e))for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var yw=e=>vw(e),bw=e=>vw(e),xw=(...e)=>vw(e),Bre=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),Sw=new WeakMap;function Cw(e){return Bre.get(e)}function ww(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Tw(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new Cc(...t):n===`vec2`?new H(...t):n===`vec3`?new U(...t):n===`vec4`?new Ls(...t):n===`mat2`?new Kf(...t):n===`mat3`?new xs(...t):n===`mat4`?new Hs(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?Hre(t[0]):null}function Ew(e){let t=Sw.get(e);return t===void 0&&(t={},Sw.set(e,t)),t}function Vre(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function Hre(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Dw={VERTEX:`vertex`,FRAGMENT:`fragment`},Ow={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},kw={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},Ure=[`fragment`,`vertex`],Aw=[`setup`,`analyze`,`generate`],jw=[...Ure,`compute`],Mw=[`x`,`y`,`z`,`w`],Wre={analyze:`setup`,generate:`analyze`},Gre=0,Nw=class e extends Wo{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=Ow.NONE,this.updateBeforeType=Ow.NONE,this.updateAfterType=Ow.NONE,this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=Gre++,this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new _w)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=_s.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,Ow.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Ow.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Ow.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let e in r){if(e.startsWith(`_`)===!0)continue;let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}}}return t}getCacheKey(e=!1,t=null){if(e||=this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);let n=[];for(let{property:r,childNode:i}of this._getChildren(t))n.push(yw(r.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=xw(bw(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return`void`}getNodeType(e,t=null){let n=e.getDataFromNode(this),r;return t===null?(r=n.type,r===void 0&&(r=this.generateNodeType(e),n.type=r)):(n.typeFromOutput=n.typeFromOutput||{},r=n.typeFromOutput[t],r===void 0&&(r=this.generateNodeType(e,t),n.typeFromOutput[t]=r)),r}generateNodeType(e,t=null){let n=e.getNodeProperties(this);return n.outputNode?n.outputNode.getNodeType(e,t):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t),r=null;if(n&&n!==this)r=n;else if(e.context.overrideNodes){let t=e.context.overrideNodes.get(this);if(t){let n=e.getDataFromNode(this);n.isOverwritten===!0?r=n.sharedNode:(n.isOverwritten=!0,r=t(e).overrideNode(this,null),n.sharedNode=r)}}return r||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){B(`Abstract function.`)}updateAfter(){B(`Abstract function.`)}update(){B(`Abstract function.`)}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){let n=this._beforeNodes;this._beforeNodes=null;for(let r of n)r.build(e,t);this._beforeNodes=n}let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=Wre[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){e.addNode(this),this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}e.addSequentialNode(this)}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){if(this.generate.length<2){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(B(`Node: Recursion detected.`,this),a=`/* Recursion detected. */`):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``;a===``&&t!==null&&t!==`void`&&t!==`OutputType`&&(V(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};Nw.captureStackTrace=!1;var Pw=class extends Nw{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},Fw=class extends Nw{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},Iw=class extends Nw{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},Kre=class extends Iw{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){V(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(V(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},qre=Mw.join(``),Jre=class extends Nw{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Mw.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===qre.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},Yre=class extends Iw{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Mw[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Xre=class extends Iw{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Mw[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Lw=class extends Nw{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}generateNodeType(){return this.nodeType===null?ww(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=ww(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=Vre(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Tw(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){B(`Abstract function.`)}},Rw=/float|u?int/,zw=class extends Lw{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return Rw.test(n)&&Rw.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Zre=class extends Nw{static get type(){return`MemberNode`}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!==`void`}generateNodeType(e){return this.hasMember(e)===!1?`float`:this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return`float`;let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){B(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+`.`+this.property}},Bw=null,Vw=new Map;function W(e,t){if(Vw.has(e)){B(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);Vw.set(e,t),e!==`assign`&&(Nw.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Nw.prototype[e+`Assign`]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}var Qre=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),Hw=e=>Qre(e).split(``).sort().join(``);Nw.prototype.assign=function(...e){if(this.isStackNode!==!0)return Bw===null?V(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new _w):Bw.assign(this,...e),this;{let t=Vw.get(`assign`);return this.addToStack(t(...e))}},Nw.prototype.toVarIntent=function(){return this},Nw.prototype.get=function(e){return new Zre(this,e)};var Uw={};function Ww(e,t,n){Uw[e]=Uw[t]=Uw[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Jre(this,e),this._cache[e]=t),t},set(t){this[e].assign(sT(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();Nw.prototype[`set`+r]=Nw.prototype[`set`+i]=Nw.prototype[`set`+a]=function(t){let n=Hw(e);return new Yre(this,n,sT(t))},Nw.prototype[`flip`+r]=Nw.prototype[`flip`+i]=Nw.prototype[`flip`+a]=function(){let t=Hw(e);return new Xre(this,t)}}var Gw=[`x`,`y`,`z`,`w`],Kw=[`r`,`g`,`b`,`a`],qw=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=Gw[e],n=Kw[e],r=qw[e];Ww(t,n,r);for(let i=0;i<4;i++){t=Gw[e]+Gw[i],n=Kw[e]+Kw[i],r=qw[e]+qw[i],Ww(t,n,r);for(let a=0;a<4;a++){t=Gw[e]+Gw[i]+Gw[a],n=Kw[e]+Kw[i]+Kw[a],r=qw[e]+qw[i]+qw[a],Ww(t,n,r);for(let o=0;o<4;o++)t=Gw[e]+Gw[i]+Gw[a]+Gw[o],n=Kw[e]+Kw[i]+Kw[a]+Kw[o],r=qw[e]+qw[i]+qw[a]+qw[o],Ww(t,n,r)}}}for(let e=0;e<32;e++)Uw[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Pw(this,new zw(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(sT(t))}};Object.defineProperties(Nw.prototype,Uw);var $re=function(e,t=null){let n=ww(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?sT(rT(e,t)):n===`shader`?e.isFn?e:K(e):e},eie=function(e,t=null){for(let n in e)e[n]=sT(e[n],t);return e},tie=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=sT(e[r],t);return e},Jw=function(e,t=null,n=null,r=null){function i(e){return r===null?e=sT(e):(e=sT(Object.assign(e,r)),r.intent===!0&&(e=e.toVarIntent())),e}let a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(V(`TSL: "${n}" parameter length is less than minimum required.`,new _w),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(V(`TSL: "${n}" parameter length exceeds limit.`,new _w),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...uT(l(t)))):n===null?a=(...n)=>i(new e(t,...uT(l(n)))):(n=sT(n),a=(...r)=>i(new e(t,...uT(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},nie=function(e,...t){return new e(...uT(t))},rie=class extends Nw{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){if(n){let r=t.layout.inputs;if(Yw(n)){let t=n;for(let n=0;n<r.length;n++){let r=t[n];r&&r.isNode&&r.build(e)}}else{let t=n[0];for(let n of r){let r=t[n.name];r&&r.isNode&&r.build(e)}}}let r=e.buildFunctionNode(t);e.addInclude(r);let i=n?iie(n):null;c=r.call(i)}else{let r=new Proxy(e,{get:(e,t,n)=>{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?aie(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=sT(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function Yw(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}function iie(e){let t;return lT(e),t=Yw(e)?[...e]:e[0],t}function aie(e){let t=0;return lT(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield sT(t)};else{if(e.length>0){if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof Nw&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i))}else a=Reflect.get(n,r,i);a=sT(a)}return a}})}var oie=class extends Nw{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new rie(this,e)}setup(){return this.call()}},sie=[!1,!0],cie=[0,1,2,3],lie=[-1,-2],Xw=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Zw=new Map;for(let e of sie)Zw.set(e,new zw(e));var Qw=new Map;for(let e of cie)Qw.set(e,new zw(e,`uint`));var $w=new Map([...Qw].map(e=>new zw(e.value,`int`)));for(let e of lie)$w.set(e,new zw(e,`int`));var eT=new Map([...$w].map(e=>new zw(e.value)));for(let e of Xw)eT.set(e,new zw(e));for(let e of Xw)eT.set(-e,new zw(-e));var tT={bool:Zw,uint:Qw,ints:$w,float:eT},nT=new Map([...Zw,...eT]),rT=(e,t)=>nT.has(e)?nT.get(e):e.isNode===!0?e:new zw(e,t),iT=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return V(`TSL: Invalid parameter for the type "${e}".`,new _w),new zw(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[Tw(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return cT(t.get(n[0]));if(n.length===1){let t=rT(n[0],e);return t.nodeType===e?cT(t):cT(new Fw(t,e))}return cT(new Kre(n.map(e=>rT(e)),e))}};function aT(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}var uie=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function oT(e,t){return new oie(e,t)}var sT=(e,t=null)=>$re(e,t),cT=(e,t=null)=>sT(e,t).toVarIntent(),lT=(e,t=null)=>new eie(e,t),uT=(e,t=null)=>new tie(e,t),dT=(e,t=null,n=null,r=null)=>new Jw(e,t,n,r),G=(e,...t)=>new nie(e,...t),fT=(e,t=null,n=null,r={})=>new Jw(e,t,n,{...r,intent:!0}),die=0,fie=class extends Nw{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:V(`TSL: Invalid layout type.`,new _w),t=null)),this.shaderNode=new oT(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+die++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return V(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function K(e,t=null){let n=new fie(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var pT=e=>{Bw=e},mT=()=>Bw,hT=(...e)=>Bw.If(...e);function gT(e){return Bw&&Bw.addToStack(e),e}W(`toStack`,gT);var pie=new iT(`color`),q=new iT(`float`,tT.float),_T=new iT(`int`,tT.ints),vT=new iT(`uint`,tT.uint),yT=new iT(`bool`,tT.bool),bT=new iT(`vec2`),xT=new iT(`ivec2`),ST=new iT(`uvec2`),mie=new iT(`bvec2`),J=new iT(`vec3`),CT=new iT(`ivec3`),wT=new iT(`uvec3`),hie=new iT(`bvec3`),TT=new iT(`vec4`),ET=new iT(`ivec4`),DT=new iT(`uvec4`),gie=new iT(`bvec4`),OT=new iT(`mat2`),kT=new iT(`mat3`),AT=new iT(`mat4`);W(`toColor`,pie),W(`toFloat`,q),W(`toInt`,_T),W(`toUint`,vT),W(`toBool`,yT),W(`toVec2`,bT),W(`toIVec2`,xT),W(`toUVec2`,ST),W(`toBVec2`,mie),W(`toVec3`,J),W(`toIVec3`,CT),W(`toUVec3`,wT),W(`toBVec3`,hie),W(`toVec4`,TT),W(`toIVec4`,ET),W(`toUVec4`,DT),W(`toBVec4`,gie),W(`toMat2`,OT),W(`toMat3`,kT),W(`toMat4`,AT),W(`element`,dT(Pw).setParameterLength(2)),W(`convert`,(e,t)=>new Fw(sT(e),t)),W(`append`,e=>(B(`TSL: .append() has been renamed to .toStack().`,new _w),gT(e)));var jT=class extends Nw{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1,r=null){super(e),this.name=t,this.varying=n,this.placeholderNode=sT(r),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return t===`output`?e.getOutputType():t}customCacheKey(){return yw(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){let n=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${n}`,this)}return e.getPropertyName(t)}},MT=(e,t,n=null)=>new jT(e,t,!1,n),NT=(e,t,n=null)=>new jT(e,t,!0,n),PT=G(jT,`vec4`,`DiffuseColor`),FT=G(jT,`vec3`,`DiffuseContribution`),IT=G(jT,`vec3`,`EmissiveColor`),LT=G(jT,`float`,`Roughness`),RT=G(jT,`float`,`Metalness`),zT=G(jT,`float`,`Clearcoat`),BT=G(jT,`float`,`ClearcoatRoughness`),VT=G(jT,`vec3`,`Sheen`),HT=G(jT,`float`,`SheenRoughness`),UT=G(jT,`float`,`Iridescence`),WT=G(jT,`float`,`IridescenceIOR`),GT=G(jT,`float`,`IridescenceThickness`),KT=G(jT,`float`,`AlphaT`),qT=G(jT,`float`,`Anisotropy`),JT=G(jT,`vec3`,`AnisotropyT`),YT=G(jT,`vec3`,`AnisotropyB`),XT=G(jT,`color`,`SpecularColor`),ZT=G(jT,`color`,`SpecularColorBlended`),QT=G(jT,`float`,`SpecularF90`),$T=G(jT,`float`,`Shininess`),eE=G(jT,`output`,`Output`),tE=G(jT,`float`,`dashSize`),nE=G(jT,`float`,`gapSize`),rE=G(jT,`float`,`IOR`),iE=G(jT,`float`,`Transmission`),aE=G(jT,`float`,`Thickness`),oE=G(jT,`float`,`AttenuationDistance`),sE=G(jT,`color`,`AttenuationColor`),cE=G(jT,`float`,`Dispersion`),lE=G(jT,`float`,`AmbientOcclusion`,!1,1),uE=class extends Nw{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1,r=null){super(`string`),this.name=e,this.shared=t,this.order=n,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},_ie=(e,t=1,n=null)=>new uE(e,!1,t,n),dE=(e,t=0,n=null)=>new uE(e,!0,t,n);Ow.FRAME;var fE=dE(`render`,0,Ow.RENDER),vie=_ie(`object`,1,Ow.OBJECT),pE=class extends Lw{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=vie}setName(e){return this.name=e,this}label(e){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new _w),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},mE=(e,t)=>{let n=uie(t||e);if(n===e&&(e=Tw(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new pE(e,n)},hE=class extends Iw{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},yie=(...e)=>{let t;if(e.length===1){let n=e[0];t=new hE(null,n.length,n)}else{let n=e[0],r=e[1];t=new hE(n,r)}return sT(t)};W(`toArray`,(e,t)=>yie(Array(t).fill(e))),W(`assign`,dT(class extends Iw{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return Mw.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${l}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=a)}else u=`${a} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=a));return l.initialized=!0,e.format(u,o,t)}}).setParameterLength(2));var bie=class extends Iw{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}generateNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)V(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(V(`TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(V(`TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}return`${n.build(e,`property`)}( ${t.join(`, `)} )`}};W(`call`,(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?uT(t):lT(t[0]),new bie(sT(e),t)));var xie={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},gE=class e extends Iw{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(xie[this.op],t)}generateNodeType(e,t=null){let n=this.op,r=this.aNode,i=this.bNode,a=r.getNodeType(e),o=i?i.getNodeType(e):null;if(a===`void`||o===`void`)return t||`void`;if(n===`%`)return a;if(n===`~`||n===`&`||n===`|`||n===`^`||n===`>>`||n===`<<`)return e.getIntegerType(a);if(n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`!`){let t=e.getTypeLength(a);return t>1?`bvec${t}`:`bool`}if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===ko;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`)return r&&e.isVector(o)?e.format(`not( ${c} )`,t):e.format(`( ${n} ${c} )`,o,t);if(n===`~`)return e.format(`( ${n} ${c} )`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},_E=fT(gE,`+`).setParameterLength(2,1/0).setName(`add`),vE=fT(gE,`-`).setParameterLength(2,1/0).setName(`sub`),yE=fT(gE,`*`).setParameterLength(2,1/0).setName(`mul`),bE=fT(gE,`/`).setParameterLength(2,1/0).setName(`div`),xE=fT(gE,`%`).setParameterLength(2).setName(`mod`),Sie=fT(gE,`==`).setParameterLength(2).setName(`equal`),Cie=fT(gE,`!=`).setParameterLength(2).setName(`notEqual`),wie=fT(gE,`<`).setParameterLength(2).setName(`lessThan`),Tie=fT(gE,`>`).setParameterLength(2).setName(`greaterThan`),Eie=fT(gE,`<=`).setParameterLength(2).setName(`lessThanEqual`),Die=fT(gE,`>=`).setParameterLength(2).setName(`greaterThanEqual`),Oie=fT(gE,`&&`).setParameterLength(2,1/0).setName(`and`),kie=fT(gE,`||`).setParameterLength(2,1/0).setName(`or`),Aie=fT(gE,`!`).setParameterLength(1).setName(`not`),jie=fT(gE,`^^`).setParameterLength(2).setName(`xor`),Mie=fT(gE,`&`).setParameterLength(2).setName(`bitAnd`),Nie=fT(gE,`~`).setParameterLength(1).setName(`bitNot`),Pie=fT(gE,`|`).setParameterLength(2).setName(`bitOr`),Fie=fT(gE,`^`).setParameterLength(2).setName(`bitXor`),Iie=fT(gE,`<<`).setParameterLength(2).setName(`shiftLeft`),Lie=fT(gE,`>>`).setParameterLength(2).setName(`shiftRight`),Rie=K(([e])=>(e.addAssign(1),e)),zie=K(([e])=>(e.subAssign(1),e)),Bie=K(([e])=>{let t=_T(e).toConst();return e.addAssign(1),t}),Vie=K(([e])=>{let t=_T(e).toConst();return e.subAssign(1),t});W(`add`,_E),W(`sub`,vE),W(`mul`,yE),W(`div`,bE),W(`mod`,xE),W(`equal`,Sie),W(`notEqual`,Cie),W(`lessThan`,wie),W(`greaterThan`,Tie),W(`lessThanEqual`,Eie),W(`greaterThanEqual`,Die),W(`and`,Oie),W(`or`,kie),W(`not`,Aie),W(`xor`,jie),W(`bitAnd`,Mie),W(`bitNot`,Nie),W(`bitOr`,Pie),W(`bitXor`,Fie),W(`shiftLeft`,Iie),W(`shiftRight`,Lie),W(`incrementBefore`,Rie),W(`decrementBefore`,zie),W(`increment`,Bie),W(`decrement`,Vie);var Y=class e extends Iw{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=3;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}generateNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=vE(1,n);else if(i===e.RECIPROCAL)a=bE(1,n);else if(i===e.DIFFERENCE)a=FE(vE(n,r));else if(i===e.TRANSFORM_DIRECTION){let e,i;t.isMatrix(n.getNodeType(t))?(e=n,i=r):(e=r,i=n),a=AE(yE(e,TT(J(i),0)).xyz)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(B(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Y.ALL=`all`,Y.ANY=`any`,Y.RADIANS=`radians`,Y.DEGREES=`degrees`,Y.EXP=`exp`,Y.EXP2=`exp2`,Y.LOG=`log`,Y.LOG2=`log2`,Y.SQRT=`sqrt`,Y.INVERSE_SQRT=`inversesqrt`,Y.FLOOR=`floor`,Y.CEIL=`ceil`,Y.NORMALIZE=`normalize`,Y.FRACT=`fract`,Y.SIN=`sin`,Y.SINH=`sinh`,Y.COS=`cos`,Y.COSH=`cosh`,Y.TAN=`tan`,Y.TANH=`tanh`,Y.ASIN=`asin`,Y.ASINH=`asinh`,Y.ACOS=`acos`,Y.ACOSH=`acosh`,Y.ATAN=`atan`,Y.ATANH=`atanh`,Y.ABS=`abs`,Y.SIGN=`sign`,Y.LENGTH=`length`,Y.NEGATE=`negate`,Y.ONE_MINUS=`oneMinus`,Y.DFDX=`dFdx`,Y.DFDY=`dFdy`,Y.ROUND=`round`,Y.RECIPROCAL=`reciprocal`,Y.TRUNC=`trunc`,Y.FWIDTH=`fwidth`,Y.TRANSPOSE=`transpose`,Y.DETERMINANT=`determinant`,Y.INVERSE=`inverse`,Y.EQUALS=`equals`,Y.MIN=`min`,Y.MAX=`max`,Y.STEP=`step`,Y.REFLECT=`reflect`,Y.DISTANCE=`distance`,Y.DIFFERENCE=`difference`,Y.DOT=`dot`,Y.CROSS=`cross`,Y.POW=`pow`,Y.TRANSFORM_DIRECTION=`transformDirection`,Y.MIX=`mix`,Y.CLAMP=`clamp`,Y.REFRACT=`refract`,Y.SMOOTHSTEP=`smoothstep`,Y.FACEFORWARD=`faceforward`;var SE=q(1e-6),Hie=q(Math.PI);Math.PI*2,Math.PI*2,Math.PI*.5;var Uie=fT(Y,Y.ALL).setParameterLength(1),Wie=fT(Y,Y.ANY).setParameterLength(1),Gie=fT(Y,Y.RADIANS).setParameterLength(1),Kie=fT(Y,Y.DEGREES).setParameterLength(1),CE=fT(Y,Y.EXP).setParameterLength(1),wE=fT(Y,Y.EXP2).setParameterLength(1),TE=fT(Y,Y.LOG).setParameterLength(1),EE=fT(Y,Y.LOG2).setParameterLength(1),DE=fT(Y,Y.SQRT).setParameterLength(1),qie=fT(Y,Y.INVERSE_SQRT).setParameterLength(1),OE=fT(Y,Y.FLOOR).setParameterLength(1),kE=fT(Y,Y.CEIL).setParameterLength(1),AE=fT(Y,Y.NORMALIZE).setParameterLength(1),jE=fT(Y,Y.FRACT).setParameterLength(1),ME=fT(Y,Y.SIN).setParameterLength(1),Jie=fT(Y,Y.SINH).setParameterLength(1),NE=fT(Y,Y.COS).setParameterLength(1),Yie=fT(Y,Y.COSH).setParameterLength(1),Xie=fT(Y,Y.TAN).setParameterLength(1),Zie=fT(Y,Y.TANH).setParameterLength(1),Qie=fT(Y,Y.ASIN).setParameterLength(1),$ie=fT(Y,Y.ASINH).setParameterLength(1),PE=fT(Y,Y.ACOS).setParameterLength(1),eae=fT(Y,Y.ACOSH).setParameterLength(1),tae=fT(Y,Y.ATAN).setParameterLength(1,2),nae=fT(Y,Y.ATANH).setParameterLength(1),FE=fT(Y,Y.ABS).setParameterLength(1),IE=fT(Y,Y.SIGN).setParameterLength(1),LE=fT(Y,Y.LENGTH).setParameterLength(1),RE=fT(Y,Y.NEGATE).setParameterLength(1),rae=fT(Y,Y.ONE_MINUS).setParameterLength(1),zE=fT(Y,Y.DFDX).setParameterLength(1),BE=fT(Y,Y.DFDY).setParameterLength(1),iae=fT(Y,Y.ROUND).setParameterLength(1),aae=fT(Y,Y.RECIPROCAL).setParameterLength(1),oae=fT(Y,Y.TRUNC).setParameterLength(1),VE=fT(Y,Y.FWIDTH).setParameterLength(1),sae=fT(Y,Y.TRANSPOSE).setParameterLength(1),cae=fT(Y,Y.DETERMINANT).setParameterLength(1),lae=fT(Y,Y.INVERSE).setParameterLength(1),HE=fT(Y,Y.MIN).setParameterLength(2,1/0),UE=fT(Y,Y.MAX).setParameterLength(2,1/0),WE=fT(Y,Y.STEP).setParameterLength(2),uae=fT(Y,Y.REFLECT).setParameterLength(2),dae=fT(Y,Y.DISTANCE).setParameterLength(2),fae=fT(Y,Y.DIFFERENCE).setParameterLength(2),GE=fT(Y,Y.DOT).setParameterLength(2),KE=fT(Y,Y.CROSS).setParameterLength(2),qE=fT(Y,Y.POW).setParameterLength(2),JE=e=>yE(e,e),pae=e=>yE(e,e,e),YE=e=>yE(e,e,e,e),mae=fT(Y,Y.TRANSFORM_DIRECTION).setParameterLength(2),hae=(e,t)=>AE(yE(t,TT(J(e),0)).xyz),gae=(e,t)=>AE(TT(J(e),0).mul(t).xyz),_ae=e=>yE(IE(e),qE(FE(e),1/3)),XE=e=>GE(e,e),ZE=fT(Y,Y.MIX).setParameterLength(3),QE=(e,t=0,n=1)=>new Y(Y.CLAMP,sT(e),sT(t),sT(n)),$E=e=>QE(e),eD=fT(Y,Y.REFRACT).setParameterLength(3),tD=fT(Y,Y.SMOOTHSTEP).setParameterLength(3),vae=fT(Y,Y.FACEFORWARD).setParameterLength(3),yae=K(([e])=>jE(ME(xE(GE(e.xy,bT(12.9898,78.233)),Hie)).mul(43758.5453)));W(`all`,Uie),W(`any`,Wie),W(`radians`,Gie),W(`degrees`,Kie),W(`exp`,CE),W(`exp2`,wE),W(`log`,TE),W(`log2`,EE),W(`sqrt`,DE),W(`inverseSqrt`,qie),W(`floor`,OE),W(`ceil`,kE),W(`normalize`,AE),W(`fract`,jE),W(`sin`,ME),W(`sinh`,Jie),W(`cos`,NE),W(`cosh`,Yie),W(`tan`,Xie),W(`tanh`,Zie),W(`asin`,Qie),W(`asinh`,$ie),W(`acos`,PE),W(`acosh`,eae),W(`atan`,tae),W(`atanh`,nae),W(`abs`,FE),W(`sign`,IE),W(`length`,LE),W(`lengthSq`,XE),W(`negate`,RE),W(`oneMinus`,rae),W(`dFdx`,zE),W(`dFdy`,BE),W(`round`,iae),W(`reciprocal`,aae),W(`trunc`,oae),W(`fwidth`,VE),W(`min`,HE),W(`max`,UE),W(`step`,(e,t)=>WE(t,e)),W(`reflect`,uae),W(`distance`,dae),W(`dot`,GE),W(`cross`,KE),W(`pow`,qE),W(`pow2`,JE),W(`pow3`,pae),W(`pow4`,YE),W(`transformDirection`,mae),W(`transformNormalByViewMatrix`,hae),W(`transformNormalByInverseViewMatrix`,gae),W(`mix`,(e,t,n)=>ZE(t,n,e)),W(`clamp`,QE),W(`refract`,eD),W(`smoothstep`,(e,t,n)=>tD(t,n,e)),W(`faceForward`,vae),W(`difference`,fae),W(`saturate`,$E),W(`cbrt`,_ae),W(`transpose`,sae),W(`determinant`,cae),W(`inverse`,lae),W(`rand`,yae);var nD=dT(class extends Nw{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}generateNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?MT(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(B(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
4626
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Z_(e,t){return L_(e)||J_(e,t)||tv(e,t)||Y_()}function Q_(e){return R_(e)||q_(e)||tv(e)||X_()}function $_(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function ev(e){var t=$_(e,`string`);return typeof t==`symbol`?t:t+``}function tv(e,t){if(e){if(typeof e==`string`)return I_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I_(e,t):void 0}}var nv=new WeakMap,rv=new WeakMap,iv=new WeakMap,av=new WeakMap,ov=new WeakMap,sv=new WeakMap,cv=function(){function e(){V_(this,e),U_(this,nv,new Map),U_(this,rv,new Map),U_(this,iv,function(e){return e}),U_(this,av,function(){return{}}),U_(this,ov,function(){}),U_(this,sv,function(){})}return K_(e,[{key:`getObj`,value:function(e){return H_(nv,this).get(H_(iv,this).call(this,e))}},{key:`getData`,value:function(e){return H_(rv,this).get(e)}},{key:`entries`,value:function(){return Q_(H_(rv,this).entries()).map(function(e){var t=Z_(e,2),n=t[0];return[t[1],n]})}},{key:`id`,value:function(e){return W_(iv,this,h_(e)),this}},{key:`onCreateObj`,value:function(e){return W_(av,this,e),this}},{key:`onUpdateObj`,value:function(e){return W_(ov,this,e),this}},{key:`onRemoveObj`,value:function(e){return W_(sv,this,e),this}},{key:`digest`,value:function(e){var t=this;e.filter(function(e){return!H_(nv,t).has(H_(iv,t).call(t,e))}).forEach(function(e){var n=H_(av,t).call(t,e);H_(nv,t).set(H_(iv,t).call(t,e),n),H_(rv,t).set(n,e)});var n=new Map(e.map(function(e){return[H_(iv,t).call(t,e),e]}));return H_(nv,this).forEach(function(e,r){n.has(r)?H_(ov,t).call(t,e,n.get(r)):(H_(sv,t).call(t,e,r),H_(nv,t).delete(r),H_(rv,t).delete(e))}),this}},{key:`clear`,value:function(){return this.digest([]),this}}])}();function lv(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function uv(e,t){switch(arguments.length){case 0:break;case 1:typeof e==`function`?this.interpolator(e):this.range(e);break;default:this.domain(e),typeof t==`function`?this.interpolator(t):this.range(t)}return this}var dv=Symbol(`implicit`);function fv(){var e=new S_,t=[],n=[],r=dv;function i(i){let a=e.get(i);if(a===void 0){if(r!==dv)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new S_;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return fv(t,n).unknown(r)},lv.apply(i,arguments),i}function pv(){var e=fv().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=F_(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return pv(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},lv.apply(d(),arguments)}function mv(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return mv(t())},e}function hv(){return mv(pv.apply(null,arguments).paddingInner(1))}function gv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _v(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function vv(){}var yv=.7,bv=1/yv,xv=`\\s*([+-]?\\d+)\\s*`,Sv=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Cv=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,wv=/^#([0-9a-f]{3,8})$/,Tv=RegExp(`^rgb\\(${xv},${xv},${xv}\\)$`),Ev=RegExp(`^rgb\\(${Cv},${Cv},${Cv}\\)$`),Dv=RegExp(`^rgba\\(${xv},${xv},${xv},${Sv}\\)$`),Ov=RegExp(`^rgba\\(${Cv},${Cv},${Cv},${Sv}\\)$`),kv=RegExp(`^hsl\\(${Sv},${Cv},${Cv}\\)$`),Av=RegExp(`^hsla\\(${Sv},${Cv},${Cv},${Sv}\\)$`),jv={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};gv(vv,Iv,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mv,formatHex:Mv,formatHex8:Nv,formatHsl:Pv,formatRgb:Fv,toString:Fv});function Mv(){return this.rgb().formatHex()}function Nv(){return this.rgb().formatHex8()}function Pv(){return qv(this).formatHsl()}function Fv(){return this.rgb().formatRgb()}function Iv(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=wv.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Lv(t):n===3?new Bv(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Rv(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Rv(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Tv.exec(e))?new Bv(t[1],t[2],t[3],1):(t=Ev.exec(e))?new Bv(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Dv.exec(e))?Rv(t[1],t[2],t[3],t[4]):(t=Ov.exec(e))?Rv(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kv.exec(e))?Kv(t[1],t[2]/100,t[3]/100,1):(t=Av.exec(e))?Kv(t[1],t[2]/100,t[3]/100,t[4]):jv.hasOwnProperty(e)?Lv(jv[e]):e===`transparent`?new Bv(NaN,NaN,NaN,0):null}function Lv(e){return new Bv(e>>16&255,e>>8&255,e&255,1)}function Rv(e,t,n,r){return r<=0&&(e=t=n=NaN),new Bv(e,t,n,r)}function qne(e){return e instanceof vv||(e=Iv(e)),e?(e=e.rgb(),new Bv(e.r,e.g,e.b,e.opacity)):new Bv}function zv(e,t,n,r){return arguments.length===1?qne(e):new Bv(e,t,n,r??1)}function Bv(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gv(Bv,zv,_v(vv,{brighter(e){return e=e==null?bv:bv**+e,new Bv(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yv:yv**+e,new Bv(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Bv(Wv(this.r),Wv(this.g),Wv(this.b),Uv(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Vv,formatHex:Vv,formatHex8:Jne,formatRgb:Hv,toString:Hv}));function Vv(){return`#${Gv(this.r)}${Gv(this.g)}${Gv(this.b)}`}function Jne(){return`#${Gv(this.r)}${Gv(this.g)}${Gv(this.b)}${Gv((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hv(){let e=Uv(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Wv(this.r)}, ${Wv(this.g)}, ${Wv(this.b)}${e===1?`)`:`, ${e})`}`}function Uv(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wv(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Gv(e){return e=Wv(e),(e<16?`0`:``)+e.toString(16)}function Kv(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Jv(e,t,n,r)}function qv(e){if(e instanceof Jv)return new Jv(e.h,e.s,e.l,e.opacity);if(e instanceof vv||(e=Iv(e)),!e)return new Jv;if(e instanceof Jv)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Jv(o,s,c,e.opacity)}function Yne(e,t,n,r){return arguments.length===1?qv(e):new Jv(e,t,n,r??1)}function Jv(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gv(Jv,Yne,_v(vv,{brighter(e){return e=e==null?bv:bv**+e,new Jv(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yv:yv**+e,new Jv(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Bv(Zv(e>=240?e-240:e+120,i,r),Zv(e,i,r),Zv(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Jv(Yv(this.h),Xv(this.s),Xv(this.l),Uv(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Uv(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Yv(this.h)}, ${Xv(this.s)*100}%, ${Xv(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Yv(e){return e=(e||0)%360,e<0?e+360:e}function Xv(e){return Math.max(0,Math.min(1,e||0))}function Zv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Qv=e=>()=>e;function Xne(e,t){return function(n){return e+n*t}}function Zne(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Qne(e){return(e=+e)==1?$v:function(t,n){return n-t?Zne(t,n,e):Qv(isNaN(t)?n:t)}}function $v(e,t){var n=t-e;return n?Xne(e,n):Qv(isNaN(e)?t:e)}var ey=(function e(t){var n=Qne(t);function r(e,t){var r=n((e=zv(e)).r,(t=zv(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=$v(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function $ne(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function ere(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function tre(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=iy(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function nre(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ty(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function rre(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=iy(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var ny=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ry=new RegExp(ny.source,`g`);function ire(e){return function(){return e}}function are(e){return function(t){return e(t)+``}}function ore(e,t){var n=ny.lastIndex=ry.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=ny.exec(e))&&(i=ry.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:ty(r,i)})),n=ry.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?are(c[0].x):ire(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function iy(e,t){var n=typeof t,r;return t==null||n===`boolean`?Qv(t):(n===`number`?ty:n===`string`?(r=Iv(t))?(t=r,ey):ore:t instanceof Iv?ey:t instanceof Date?nre:ere(t)?$ne:Array.isArray(t)?tre:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?rre:ty)(e,t)}function ay(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function sre(e,t){t===void 0&&(t=e,e=iy);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return function(e){var t=Math.max(0,Math.min(r-1,Math.floor(e*=r)));return a[t](e-t)}}function cre(e){return function(){return e}}function oy(e){return+e}var sy=[0,1];function cy(e){return e}function ly(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:cre(isNaN(t)?NaN:.5)}function lre(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function ure(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=ly(i,r),a=n(o,a)):(r=ly(r,i),a=n(a,o)),function(e){return a(r(e))}}function dre(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=ly(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=x_(e,t,1,r)-1;return a[n](i[n](t))}}function uy(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function dy(){var e=sy,t=sy,n=iy,r,i,a,o=cy,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==cy&&(o=lre(e[0],e[n-1])),s=n>2?dre:ure,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),ty))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,oy),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=ay,u()},d.clamp=function(e){return arguments.length?(o=e?!0:cy,u()):o!==cy},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function fy(){return dy()(cy,cy)}function fre(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function py(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function my(e){return e=py(Math.abs(e)),e?e[1]:NaN}function pre(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function mre(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var hre=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function hy(e){if(!(t=hre.exec(e)))throw Error(`invalid format: `+e);var t;return new gy({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}hy.prototype=gy.prototype;function gy(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}gy.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function gre(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var _y;function _re(e,t){var n=py(e,t);if(!n)return _y=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(_y=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+py(e,Math.max(0,t+a-1))[0]}function vy(e,t){var n=py(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var yy={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:fre,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>vy(e*100,t),r:vy,s:_re,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function by(e){return e}var xy=Array.prototype.map,Sy=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function vre(e){var t=e.grouping===void 0||e.thousands===void 0?by:pre(xy.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?by:mre(xy.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=hy(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):yy[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=yy[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=gre(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&_y!==void 0?Sy[8+_y/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(my(t)/3)))*3,r=10**-n,i=l((e=hy(e),e.type=`f`,e),{suffix:Sy[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var Cy,wy,Ty;yre({thousands:`,`,grouping:[3],currency:[`$`,``]});function yre(e){return Cy=vre(e),wy=Cy.format,Ty=Cy.formatPrefix,Cy}function bre(e){return Math.max(0,-my(Math.abs(e)))}function xre(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(my(t)/3)))*3-my(Math.abs(e)))}function Sre(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,my(t)-my(e))+1}function Ey(e,t,n,r){var i=O_(e,t,n),a;switch(r=hy(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=xre(i,o))&&(r.precision=a),Ty(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Sre(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=bre(i))&&(r.precision=a-(r.type===`%`)*2)}return wy(r)}function Dy(e){var t=e.domain;return e.ticks=function(e){var n=t();return E_(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Ey(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=D_(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Oy(){var e=fy();return e.copy=function(){return uy(e,Oy())},lv.apply(e,arguments),Dy(e)}function ky(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,oy),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return ky(e).unknown(t)},e=arguments.length?Array.from(e,oy):[0,1],Dy(n)}function Ay(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),e[n]=t.floor(i),e[r]=t.ceil(a),e}function jy(e){return Math.log(e)}function My(e){return Math.exp(e)}function Cre(e){return-Math.log(-e)}function wre(e){return-Math.exp(-e)}function Tre(e){return isFinite(e)?+(`1e`+e):e<0?0:e}function Ere(e){return e===10?Tre:e===Math.E?Math.exp:t=>e**+t}function Dre(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function Ny(e){return(t,n)=>-e(-t,n)}function Py(e){let t=e(jy,My),n=t.domain,r=10,i,a;function o(){return i=Dre(r),a=Ere(r),n()[0]<0?(i=Ny(i),a=Ny(a),e(Cre,wre)):e(jy,My),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s<o;c&&([o,s]=[s,o]);let l=i(o),u=i(s),d,f,p=e==null?10:+e,m=[];if(!(r%1)&&u-l<p){if(l=Math.floor(l),u=Math.ceil(u),o>0){for(;l<=u;++l)for(d=1;d<r;++d)if(f=l<0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}m.length*2<p&&(m=E_(o,s,p))}else m=E_(l,u,Math.min(u-l,p)).map(a);return c?m.reverse():m},t.tickFormat=(e,n)=>{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=hy(n)).precision==null&&(n.trim=!0),n=wy(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*r<r-.5&&(t*=r),t<=o?n(e):``}},t.nice=()=>n(Ay(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function Fy(){let e=Py(dy()).domain([1,10]);return e.copy=()=>uy(e,Fy()).base(e.base()),lv.apply(e,arguments),e}function Iy(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function Ly(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function Ry(e){var t=1,n=e(Iy(t),Ly(t));return n.constant=function(n){return arguments.length?e(Iy(t=+n),Ly(t)):t},Dy(n)}function zy(){var e=Ry(dy());return e.copy=function(){return uy(e,zy()).constant(e.constant())},lv.apply(e,arguments)}function By(e){return function(t){return t<0?-((-t)**+e):t**+e}}function Ore(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function kre(e){return e<0?-e*e:e*e}function Vy(e){var t=e(cy,cy),n=1;function r(){return n===1?e(cy,cy):n===.5?e(Ore,kre):e(By(n),By(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},Dy(t)}function Hy(){var e=Vy(dy());return e.copy=function(){return uy(e,Hy()).exponent(e.exponent())},lv.apply(e,arguments),e}function Are(){return Hy.apply(null,arguments).exponent(.5)}function Uy(e){return Math.sign(e)*e*e}function jre(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function Wy(){var e=fy(),t=[0,1],n=!1,r;function i(t){var i=jre(e(t));return isNaN(i)?r:n?Math.round(i):i}return i.invert=function(t){return e.invert(Uy(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(n){return arguments.length?(e.range((t=Array.from(n,oy)).map(Uy)),i):t.slice()},i.rangeRound=function(e){return i.range(e).round(!0)},i.round=function(e){return arguments.length?(n=!!e,i):n},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Wy(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},lv.apply(i,arguments),Dy(i)}function Gy(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r<i;)n[r-1]=P_(e,r/i);return a}function a(e){return e==null||isNaN(e=+e)?r:t[x_(n,e)]}return a.invertExtent=function(r){var i=t.indexOf(r);return i<0?[NaN,NaN]:[i>0?n[i-1]:e[0],i<n.length?n[i]:e[e.length-1]]},a.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(g_),i()},a.range=function(e){return arguments.length?(t=Array.from(e),i()):t.slice()},a.unknown=function(e){return arguments.length?(r=e,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return Gy().domain(e).range(t).unknown(r)},lv.apply(a,arguments)}function Ky(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[x_(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return Ky().domain([e,t]).range(i).unknown(a)},lv.apply(Dy(o),arguments)}function qy(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[x_(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return qy().domain(e).range(t).unknown(n)},lv.apply(i,arguments)}var Jy=new Date,Yy=new Date;function Xy(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>Xy(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e){if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}}),n&&(i.count=(t,r)=>(Jy.setTime(+t),Yy.setTime(+r),e(Jy),e(Yy),Math.floor(n(Jy,Yy))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var Zy=Xy(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Zy.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Xy(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Zy),Zy.range;var Qy=1e3,$y=Qy*60,eb=$y*60,tb=eb*24,nb=tb*7,rb=tb*30,ib=tb*365,ab=Xy(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Qy)},(e,t)=>(t-e)/Qy,e=>e.getUTCSeconds());ab.range;var ob=Xy(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Qy)},(e,t)=>{e.setTime(+e+t*$y)},(e,t)=>(t-e)/$y,e=>e.getMinutes());ob.range;var sb=Xy(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*$y)},(e,t)=>(t-e)/$y,e=>e.getUTCMinutes());sb.range;var cb=Xy(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Qy-e.getMinutes()*$y)},(e,t)=>{e.setTime(+e+t*eb)},(e,t)=>(t-e)/eb,e=>e.getHours());cb.range;var lb=Xy(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*eb)},(e,t)=>(t-e)/eb,e=>e.getUTCHours());lb.range;var ub=Xy(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*$y)/tb,e=>e.getDate()-1);ub.range;var db=Xy(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/tb,e=>e.getUTCDate()-1);db.range;var fb=Xy(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/tb,e=>Math.floor(e/tb));fb.range;function pb(e){return Xy(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*$y)/nb)}var mb=pb(0),hb=pb(1),Mre=pb(2),Nre=pb(3),gb=pb(4),Pre=pb(5),Fre=pb(6);mb.range,hb.range,Mre.range,Nre.range,gb.range,Pre.range,Fre.range;function _b(e){return Xy(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/nb)}var vb=_b(0),yb=_b(1),bb=_b(2),xb=_b(3),Sb=_b(4),Cb=_b(5),wb=_b(6);vb.range,yb.range,bb.range,xb.range,Sb.range,Cb.range,wb.range;var Tb=Xy(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Tb.range;var Eb=Xy(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());Eb.range;var Db=Xy(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Db.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Xy(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),Db.range;var Ob=Xy(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Ob.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Xy(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),Ob.range;function kb(e,t,n,r,i,a){let o=[[ab,1,Qy],[ab,5,5*Qy],[ab,15,15*Qy],[ab,30,30*Qy],[a,1,$y],[a,5,5*$y],[a,15,15*$y],[a,30,30*$y],[i,1,eb],[i,3,3*eb],[i,6,6*eb],[i,12,12*eb],[r,1,tb],[r,2,2*tb],[n,1,nb],[t,1,rb],[t,3,3*rb],[e,1,ib]];function s(e,t,n){let r=t<e;r&&([e,t]=[t,e]);let i=n&&typeof n.range==`function`?n:c(e,t,n),a=i?i.range(e,+t+1):[];return r?a.reverse():a}function c(t,n,r){let i=Math.abs(n-t)/r,a=v_(([,,e])=>e).right(o,i);if(a===o.length)return e.every(O_(t/ib,n/ib,r));if(a===0)return Zy.every(Math.max(O_(t,n,r),1));let[s,c]=o[i/o[a-1][2]<o[a][2]/i?a-1:a];return s.every(c)}return[s,c]}var[Ab,jb]=kb(Ob,Eb,vb,fb,lb,sb),[Mb,Nb]=kb(Db,Tb,mb,ub,cb,ob);function Pb(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Fb(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Ib(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function Lb(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=Wb(i),u=Gb(i),d=Wb(a),f=Gb(a),p=Wb(o),m=Gb(o),h=Wb(s),g=Gb(s),_=Wb(c),v=Gb(c),y={a:M,A:te,b:ne,B:N,c:null,d:fx,e:fx,f:_x,g:Ox,G:Ax,H:px,I:mx,j:hx,L:gx,m:vx,M:yx,p:P,q:re,Q:$x,s:eS,S:bx,u:xx,U:Sx,V:wx,w:Tx,W:Ex,x:null,X:null,y:Dx,Y:kx,Z:jx,"%":Qx},b={a:ie,A:ae,b:oe,B:se,c:null,d:Mx,e:Mx,f:Lx,g:Jx,G:Xx,H:Nx,I:Px,j:Fx,L:Ix,m:Rx,M:zx,p:ce,q:le,Q:$x,s:eS,S:Bx,u:Vx,U:Hx,V:Wx,w:Gx,W:Kx,x:null,X:null,y:qx,Y:Yx,Z:Zx,"%":Qx},x={a:E,A:D,b:O,B:k,c:A,d:nx,e:nx,f:cx,g:Qb,G:Zb,H:ix,I:ix,j:rx,L:sx,m:tx,M:ax,p:T,q:ex,Q:ux,s:dx,S:ox,u:qb,U:Jb,V:Yb,w:Kb,W:Xb,x:j,X:ee,y:Qb,Y:Zb,Z:$b,"%":lx};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i<o;)e.charCodeAt(i)===37&&(r.push(e.slice(a,i)),(c=Rb[s=e.charAt(++i)])==null?c=s===`e`?` `:`0`:s=e.charAt(++i),(l=t[s])&&(s=l(n,c)),r.push(s),a=i+1);return r.push(e.slice(a,i)),r.join(``)}}function C(e,t){return function(n){var r=Ib(1900,void 0,1),i=w(r,e,n+=``,0),a,o;if(i!=n.length)return null;if(`Q`in r)return new Date(r.Q);if(`s`in r)return new Date(r.s*1e3+(`L`in r?r.L:0));if(t&&!(`Z`in r)&&(r.Z=0),`p`in r&&(r.H=r.H%12+r.p*12),r.m===void 0&&(r.m=`q`in r?r.q:0),`V`in r){if(r.V<1||r.V>53)return null;`w`in r||(r.w=1),`Z`in r?(a=Fb(Ib(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?yb.ceil(a):yb(a),a=db.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=Pb(Ib(r.y,0,1)),o=a.getDay(),a=o>4||o===0?hb.ceil(a):hb(a),a=ub.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?Fb(Ib(r.y,0,1)).getUTCDay():Pb(Ib(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,Fb(r)):Pb(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i<a;){if(r>=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in Rb?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function ee(e,t,n){return w(e,r,t,n)}function M(e){return o[e.getDay()]}function te(e){return a[e.getDay()]}function ne(e){return c[e.getMonth()]}function N(e){return s[e.getMonth()]}function P(e){return i[+(e.getHours()>=12)]}function re(e){return 1+~~(e.getMonth()/3)}function ie(e){return o[e.getUTCDay()]}function ae(e){return a[e.getUTCDay()]}function oe(e){return c[e.getUTCMonth()]}function se(e){return s[e.getUTCMonth()]}function ce(e){return i[+(e.getUTCHours()>=12)]}function le(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var Rb={"-":``,_:` `,0:`0`},zb=/^\s*\d+/,Bb=/^%/,Vb=/[\\^$*+?|[\]().{}]/g;function Hb(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a<n?Array(n-a+1).join(t)+i:i)}function Ub(e){return e.replace(Vb,`\\$&`)}function Wb(e){return RegExp(`^(?:`+e.map(Ub).join(`|`)+`)`,`i`)}function Gb(e){return new Map(e.map((e,t)=>[e.toLowerCase(),t]))}function Kb(e,t,n){var r=zb.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function qb(e,t,n){var r=zb.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function Jb(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Yb(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Xb(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function Zb(e,t,n){var r=zb.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Qb(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function $b(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function ex(e,t,n){var r=zb.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function tx(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function nx(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function rx(e,t,n){var r=zb.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function ix(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function ax(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function ox(e,t,n){var r=zb.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function sx(e,t,n){var r=zb.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function cx(e,t,n){var r=zb.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function lx(e,t,n){var r=Bb.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function ux(e,t,n){var r=zb.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function dx(e,t,n){var r=zb.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function fx(e,t){return Hb(e.getDate(),t,2)}function px(e,t){return Hb(e.getHours(),t,2)}function mx(e,t){return Hb(e.getHours()%12||12,t,2)}function hx(e,t){return Hb(1+ub.count(Db(e),e),t,3)}function gx(e,t){return Hb(e.getMilliseconds(),t,3)}function _x(e,t){return gx(e,t)+`000`}function vx(e,t){return Hb(e.getMonth()+1,t,2)}function yx(e,t){return Hb(e.getMinutes(),t,2)}function bx(e,t){return Hb(e.getSeconds(),t,2)}function xx(e){var t=e.getDay();return t===0?7:t}function Sx(e,t){return Hb(mb.count(Db(e)-1,e),t,2)}function Cx(e){var t=e.getDay();return t>=4||t===0?gb(e):gb.ceil(e)}function wx(e,t){return e=Cx(e),Hb(gb.count(Db(e),e)+(Db(e).getDay()===4),t,2)}function Tx(e){return e.getDay()}function Ex(e,t){return Hb(hb.count(Db(e)-1,e),t,2)}function Dx(e,t){return Hb(e.getFullYear()%100,t,2)}function Ox(e,t){return e=Cx(e),Hb(e.getFullYear()%100,t,2)}function kx(e,t){return Hb(e.getFullYear()%1e4,t,4)}function Ax(e,t){var n=e.getDay();return e=n>=4||n===0?gb(e):gb.ceil(e),Hb(e.getFullYear()%1e4,t,4)}function jx(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+Hb(t/60|0,`0`,2)+Hb(t%60,`0`,2)}function Mx(e,t){return Hb(e.getUTCDate(),t,2)}function Nx(e,t){return Hb(e.getUTCHours(),t,2)}function Px(e,t){return Hb(e.getUTCHours()%12||12,t,2)}function Fx(e,t){return Hb(1+db.count(Ob(e),e),t,3)}function Ix(e,t){return Hb(e.getUTCMilliseconds(),t,3)}function Lx(e,t){return Ix(e,t)+`000`}function Rx(e,t){return Hb(e.getUTCMonth()+1,t,2)}function zx(e,t){return Hb(e.getUTCMinutes(),t,2)}function Bx(e,t){return Hb(e.getUTCSeconds(),t,2)}function Vx(e){var t=e.getUTCDay();return t===0?7:t}function Hx(e,t){return Hb(vb.count(Ob(e)-1,e),t,2)}function Ux(e){var t=e.getUTCDay();return t>=4||t===0?Sb(e):Sb.ceil(e)}function Wx(e,t){return e=Ux(e),Hb(Sb.count(Ob(e),e)+(Ob(e).getUTCDay()===4),t,2)}function Gx(e){return e.getUTCDay()}function Kx(e,t){return Hb(yb.count(Ob(e)-1,e),t,2)}function qx(e,t){return Hb(e.getUTCFullYear()%100,t,2)}function Jx(e,t){return e=Ux(e),Hb(e.getUTCFullYear()%100,t,2)}function Yx(e,t){return Hb(e.getUTCFullYear()%1e4,t,4)}function Xx(e,t){var n=e.getUTCDay();return e=n>=4||n===0?Sb(e):Sb.ceil(e),Hb(e.getUTCFullYear()%1e4,t,4)}function Zx(){return`+0000`}function Qx(){return`%`}function $x(e){return+e}function eS(e){return Math.floor(e/1e3)}var tS,nS,rS;iS({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function iS(e){return tS=Lb(e),nS=tS.format,tS.parse,rS=tS.utcFormat,tS.utcParse,tS}function aS(e){return new Date(e)}function oS(e){return e instanceof Date?+e:+new Date(+e)}function sS(e,t,n,r,i,a,o,s,c,l){var u=fy(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)<e?p:s(e)<e?m:o(e)<e?h:a(e)<e?g:r(e)<e?i(e)<e?_:v:n(e)<e?y:b)(e)}return u.invert=function(e){return new Date(d(e))},u.domain=function(e){return arguments.length?f(Array.from(e,oS)):f().map(aS)},u.ticks=function(t){var n=f();return e(n[0],n[n.length-1],t??10)},u.tickFormat=function(e,t){return t==null?x:l(t)},u.nice=function(e){var n=f();return(!e||typeof e.range!=`function`)&&(e=t(n[0],n[n.length-1],e??10)),e?f(Ay(n,e)):u},u.copy=function(){return uy(u,sS(e,t,n,r,i,a,o,s,c,l))},u}function cS(){return lv.apply(sS(Mb,Nb,Db,Tb,mb,ub,cb,ob,ab,nS).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function lS(){return lv.apply(sS(Ab,jb,Ob,Eb,vb,db,lb,sb,ab,rS).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function uS(){var e=0,t=1,n,r,i,a,o=cy,s=!1,c;function l(e){return e==null||isNaN(e=+e)?c:o(i===0?.5:(e=(a(e)-n)*i,s?Math.max(0,Math.min(1,e)):e))}l.domain=function(o){return arguments.length?([e,t]=o,n=a(e=+e),r=a(t=+t),i=n===r?0:1/(r-n),l):[e,t]},l.clamp=function(e){return arguments.length?(s=!!e,l):s},l.interpolator=function(e){return arguments.length?(o=e,l):o};function u(e){return function(t){var n,r;return arguments.length?([n,r]=t,o=e(n,r),l):[o(0),o(1)]}}return l.range=u(iy),l.rangeRound=u(ay),l.unknown=function(e){return arguments.length?(c=e,l):c},function(o){return a=o,n=o(e),r=o(t),i=n===r?0:1/(r-n),l}}function dS(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function fS(){var e=Dy(uS()(cy));return e.copy=function(){return dS(e,fS())},uv.apply(e,arguments)}function pS(){var e=Py(uS()).domain([1,10]);return e.copy=function(){return dS(e,pS()).base(e.base())},uv.apply(e,arguments)}function mS(){var e=Ry(uS());return e.copy=function(){return dS(e,mS()).constant(e.constant())},uv.apply(e,arguments)}function hS(){var e=Vy(uS());return e.copy=function(){return dS(e,hS()).exponent(e.exponent())},uv.apply(e,arguments)}function gS(){return hS.apply(null,arguments).exponent(.5)}function _S(){var e=[],t=cy;function n(n){if(n!=null&&!isNaN(n=+n))return t((x_(e,n,1)-1)/(e.length-1))}return n.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(g_),n},n.interpolator=function(e){return arguments.length?(t=e,n):t},n.range=function(){return e.map((n,r)=>t(r/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(n,r)=>N_(e,r/t))},n.copy=function(){return _S(t).domain(e)},uv.apply(n,arguments)}function vS(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=cy,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*e<r*a?s:c),l(d?Math.max(0,Math.min(1,e)):e))}p.domain=function(l){return arguments.length?([e,t,n]=l,i=u(e=+e),a=u(t=+t),o=u(n=+n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[e,t,n]},p.clamp=function(e){return arguments.length?(d=!!e,p):d},p.interpolator=function(e){return arguments.length?(l=e,p):l};function m(e){return function(t){var n,r,i;return arguments.length?([n,r,i]=t,l=sre(e,[n,r,i]),p):[l(0),l(.5),l(1)]}}return p.range=m(iy),p.rangeRound=m(ay),p.unknown=function(e){return arguments.length?(f=e,p):f},function(l){return u=l,i=l(e),a=l(t),o=l(n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function yS(){var e=Dy(vS()(cy));return e.copy=function(){return dS(e,yS())},uv.apply(e,arguments)}function bS(){var e=Py(vS()).domain([.1,1,10]);return e.copy=function(){return dS(e,bS()).base(e.base())},uv.apply(e,arguments)}function xS(){var e=Ry(vS());return e.copy=function(){return dS(e,xS()).constant(e.constant())},uv.apply(e,arguments)}function SS(){var e=Vy(vS());return e.copy=function(){return dS(e,SS()).exponent(e.exponent())},uv.apply(e,arguments)}function CS(){return SS.apply(null,arguments).exponent(.5)}function wS(e){for(var t=e.length/6|0,n=Array(t),r=0;r<t;)n[r]=`#`+e.slice(r*6,++r*6);return n}var TS=wS(`a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928`);function ES(e){"@babel/helpers - typeof";return ES=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ES(e)}var DS=/^\s+/,OS=/\s+$/;function kS(e,t){if(e||=``,t||={},e instanceof kS)return e;if(!(this instanceof kS))return new kS(e,t);var n=AS(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}kS.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=eC(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=PS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=PS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=MS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=MS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return IS(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return LS(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(tC(this._r,255)*100)+`%`,g:Math.round(tC(this._g,255)*100)+`%`,b:Math.round(tC(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(tC(this._r,255)*100)+`%, `+Math.round(tC(this._g,255)*100)+`%, `+Math.round(tC(this._b,255)*100)+`%)`:`rgba(`+Math.round(tC(this._r,255)*100)+`%, `+Math.round(tC(this._g,255)*100)+`%, `+Math.round(tC(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:QS[IS(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+RS(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?`GradientType = 1, `:``;if(e){var i=kS(e);n=`#`+RS(i._r,i._g,i._b,i._a)}return`progid:DXImageTransform.Microsoft.gradient(`+r+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return kS(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(HS,arguments)},brighten:function(){return this._applyModification(US,arguments)},darken:function(){return this._applyModification(WS,arguments)},desaturate:function(){return this._applyModification(zS,arguments)},saturate:function(){return this._applyModification(BS,arguments)},greyscale:function(){return this._applyModification(VS,arguments)},spin:function(){return this._applyModification(GS,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(YS,arguments)},complement:function(){return this._applyCombination(KS,arguments)},monochromatic:function(){return this._applyCombination(XS,arguments)},splitcomplement:function(){return this._applyCombination(JS,arguments)},triad:function(){return this._applyCombination(qS,[3])},tetrad:function(){return this._applyCombination(qS,[4])}},kS.fromRatio=function(e,t){if(ES(e)==`object`){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=r===`a`?e[r]:sC(e[r]));e=n}return kS(e,t)};function AS(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;return typeof e==`string`&&(e=fC(e)),ES(e)==`object`&&(dC(e.r)&&dC(e.g)&&dC(e.b)?(t=jS(e.r,e.g,e.b),o=!0,s=String(e.r).substr(-1)===`%`?`prgb`:`rgb`):dC(e.h)&&dC(e.s)&&dC(e.v)?(r=sC(e.s),i=sC(e.v),t=FS(e.h,r,i),o=!0,s=`hsv`):dC(e.h)&&dC(e.s)&&dC(e.l)&&(r=sC(e.s),a=sC(e.l),t=NS(e.h,r,a),o=!0,s=`hsl`),e.hasOwnProperty(`a`)&&(n=e.a)),n=eC(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}function jS(e,t,n){return{r:tC(e,255)*255,g:tC(t,255)*255,b:tC(n,255)*255}}function MS(e,t,n){e=tC(e,255),t=tC(t,255),n=tC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4}a/=6}return{h:a,s:o,l:s}}function NS(e,t,n){var r,i,a;e=tC(e,360),t=tC(t,100),n=tC(n,100);function o(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function PS(e,t,n){e=tC(e,255),t=tC(t,255),n=tC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4}a/=6}return{h:a,s:o,v:s}}function FS(e,t,n){e=tC(e,360)*6,t=tC(t,100),n=tC(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),c=r%6,l=[n,o,a,a,s,n][c],u=[s,n,n,o,a,a][c],d=[a,a,s,n,n,o][c];return{r:l*255,g:u*255,b:d*255}}function IS(e,t,n,r){var i=[oC(Math.round(e).toString(16)),oC(Math.round(t).toString(16)),oC(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join(``)}function LS(e,t,n,r,i){var a=[oC(Math.round(e).toString(16)),oC(Math.round(t).toString(16)),oC(Math.round(n).toString(16)),oC(cC(r))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join(``)}function RS(e,t,n,r){return[oC(cC(r)),oC(Math.round(e).toString(16)),oC(Math.round(t).toString(16)),oC(Math.round(n).toString(16))].join(``)}kS.equals=function(e,t){return!e||!t?!1:kS(e).toRgbString()==kS(t).toRgbString()},kS.random=function(){return kS.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function zS(e,t){t=t===0?0:t||10;var n=kS(e).toHsl();return n.s-=t/100,n.s=nC(n.s),kS(n)}function BS(e,t){t=t===0?0:t||10;var n=kS(e).toHsl();return n.s+=t/100,n.s=nC(n.s),kS(n)}function VS(e){return kS(e).desaturate(100)}function HS(e,t){t=t===0?0:t||10;var n=kS(e).toHsl();return n.l+=t/100,n.l=nC(n.l),kS(n)}function US(e,t){t=t===0?0:t||10;var n=kS(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(t/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(t/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(t/100)))),kS(n)}function WS(e,t){t=t===0?0:t||10;var n=kS(e).toHsl();return n.l-=t/100,n.l=nC(n.l),kS(n)}function GS(e,t){var n=kS(e).toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,kS(n)}function KS(e){var t=kS(e).toHsl();return t.h=(t.h+180)%360,kS(t)}function qS(e,t){if(isNaN(t)||t<=0)throw Error(`Argument to polyad must be a positive number`);for(var n=kS(e).toHsl(),r=[kS(e)],i=360/t,a=1;a<t;a++)r.push(kS({h:(n.h+a*i)%360,s:n.s,l:n.l}));return r}function JS(e){var t=kS(e).toHsl(),n=t.h;return[kS(e),kS({h:(n+72)%360,s:t.s,l:t.l}),kS({h:(n+216)%360,s:t.s,l:t.l})]}function YS(e,t,n){t||=6,n||=30;var r=kS(e).toHsl(),i=360/n,a=[kS(e)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(kS(r));return a}function XS(e,t){t||=6;for(var n=kS(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(kS({h:r,s:i,v:a})),a=(a+s)%1;return o}kS.mix=function(e,t,n){n=n===0?0:n||50;var r=kS(e).toRgb(),i=kS(t).toRgb(),a=n/100;return kS({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},kS.readability=function(e,t){var n=kS(e),r=kS(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},kS.isReadable=function(e,t,n){var r=kS.readability(e,t),i,a=!1;switch(i=pC(n),i.level+i.size){case`AAsmall`:case`AAAlarge`:a=r>=4.5;break;case`AAlarge`:a=r>=3;break;case`AAAsmall`:a=r>=7}return a},kS.mostReadable=function(e,t,n){var r=null,i=0,a,o,s,c;n||={},o=n.includeFallbackColors,s=n.level,c=n.size;for(var l=0;l<t.length;l++)a=kS.readability(e,t[l]),a>i&&(i=a,r=kS(t[l]));return kS.isReadable(e,r,{level:s,size:c})||!o?r:(n.includeFallbackColors=!1,kS.mostReadable(e,[`#fff`,`#000`],n))};var ZS=kS.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},QS=kS.hexNames=$S(ZS);function $S(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function eC(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function tC(e,t){iC(e)&&(e=`100%`);var n=aC(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function nC(e){return Math.min(1,Math.max(0,e))}function rC(e){return parseInt(e,16)}function iC(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function aC(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function oC(e){return e.length==1?`0`+e:``+e}function sC(e){return e<=1&&(e=e*100+`%`),e}function cC(e){return Math.round(parseFloat(e)*255).toString(16)}function lC(e){return rC(e)/255}var uC=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function dC(e){return!!uC.CSS_UNIT.exec(e)}function fC(e){e=e.replace(DS,``).replace(OS,``).toLowerCase();var t=!1;if(ZS[e])e=ZS[e],t=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var n;return(n=uC.rgb.exec(e))?{r:n[1],g:n[2],b:n[3]}:(n=uC.rgba.exec(e))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=uC.hsl.exec(e))?{h:n[1],s:n[2],l:n[3]}:(n=uC.hsla.exec(e))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=uC.hsv.exec(e))?{h:n[1],s:n[2],v:n[3]}:(n=uC.hsva.exec(e))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=uC.hex8.exec(e))?{r:rC(n[1]),g:rC(n[2]),b:rC(n[3]),a:lC(n[4]),format:t?`name`:`hex8`}:(n=uC.hex6.exec(e))?{r:rC(n[1]),g:rC(n[2]),b:rC(n[3]),format:t?`name`:`hex`}:(n=uC.hex4.exec(e))?{r:rC(n[1]+``+n[1]),g:rC(n[2]+``+n[2]),b:rC(n[3]+``+n[3]),a:lC(n[4]+``+n[4]),format:t?`name`:`hex8`}:(n=uC.hex3.exec(e))?{r:rC(n[1]+``+n[1]),g:rC(n[2]+``+n[2]),b:rC(n[3]+``+n[3]),format:t?`name`:`hex`}:!1}function pC(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}function mC(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hC(e){if(Array.isArray(e))return e}function gC(e){if(Array.isArray(e))return mC(e)}function _C(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function vC(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function yC(e,t,n){return t=AC(t),zC(e,MC()?Reflect.construct(t,n||[],AC(e).constructor):t.apply(e,n))}function bC(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function xC(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function SC(e,t){return e.get(_C(e,t))}function CC(e,t,n){bC(e,t),t.set(e,n)}function wC(e,t,n){return e.set(_C(e,t),n),n}function TC(e,t,n){if(MC())return Reflect.construct.apply(null,arguments);var r=[null];return r.push.apply(r,t),new(e.bind.apply(e,r))}function EC(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,KC(r.key),r)}}function DC(e,t,n){return t&&EC(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function OC(e,t,n){return(t=KC(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kC(){return kC=typeof Reflect<`u`&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=HC(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},kC.apply(null,arguments)}function AC(e){return AC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},AC(e)}function jC(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&BC(e,t)}function MC(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(MC=function(){return!!e})()}function NC(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function PC(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function FC(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4627
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function IC(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4628
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function RC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?LC(Object(n),!0).forEach(function(t){OC(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LC(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zC(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return vC(e)}function BC(e,t){return BC=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},BC(e,t)}function VC(e,t){return hC(e)||PC(e,t)||JC(e,t)||FC()}function HC(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=AC(e))!==null;);return e}function UC(e,t,n,r){var i=kC(AC(e.prototype),t,n);return typeof i==`function`?function(e){return i.apply(n,e)}:i}function WC(e){return gC(e)||NC(e)||JC(e)||IC()}function GC(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function KC(e){var t=GC(e,`string`);return typeof t==`symbol`?t:t+``}function qC(e){"@babel/helpers - typeof";return qC=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},qC(e)}function JC(e,t){if(e){if(typeof e==`string`)return mC(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mC(e,t):void 0}}var YC=function(e){e instanceof Array?e.forEach(YC):(e.map&&e.map.dispose(),e.dispose())},XC=function(e){e.geometry&&e.geometry.dispose(),e.material&&YC(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(XC)},ZC=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),XC(t)}},QC=new WeakMap,$C=new WeakMap,ew=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=r.dataBindAttr,a=i===void 0?`__data`:i,o=r.objBindAttr,s=o===void 0?`__threeObj`:o;return xC(this,t),n=yC(this,t),OC(n,`scene`,void 0),CC(n,QC,void 0),CC(n,$C,void 0),n.scene=e,wC(QC,n,a),wC($C,n,s),n.onRemoveObj(function(){}),n}return jC(t,e),DC(t,[{key:`onCreateObj`,value:function(e){var n=this;return UC(t,`onCreateObj`,this)([function(t){var r=e(t);return t[SC($C,n)]=r,r[SC(QC,n)]=t,n.scene.add(r),r}]),this}},{key:`onRemoveObj`,value:function(e){var n=this;return UC(t,`onRemoveObj`,this)([function(r,i){var a=UC(t,`getData`,n)([r]);e(r,i),n.scene.remove(r),XC(r),delete a[SC($C,n)]}]),this}}])}(cv),tw=function(e){return isNaN(e)?parseInt(kS(e).toHex(),16):e},nw=function(e){return isNaN(e)?kS(e).getAlpha():1},rw=fv(TS);function iw(e,t,n){!t||typeof n!=`string`||e.filter(function(e){return!e[n]}).forEach(function(e){e[n]=rw(t(e))})}function aw(e,t){var n=e.nodes,r=e.links,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=i.nodeFilter,o=a===void 0?function(){return!0}:a,s=i.onLoopError,c=s===void 0?function(e){throw`Invalid DAG structure! Found cycle in node path: ${e.join(` -> `)}.`}:s,l={};n.forEach(function(e){return l[t(e)]={data:e,out:[],depth:-1,skip:!o(e)}}),r.forEach(function(e){var n=e.source,r=e.target,i=c(n),a=c(r);if(!l.hasOwnProperty(i))throw`Missing source node with id: ${i}`;if(!l.hasOwnProperty(a))throw`Missing target node with id: ${a}`;var o=l[i],s=l[a];o.out.push(s);function c(e){return qC(e)===`object`?t(e):e}});var u=[];return d(Object.values(l)),Object.assign.apply(Object,[{}].concat(WC(Object.entries(l).filter(function(e){return!VC(e,2)[1].skip}).map(function(e){var t=VC(e,2),n=t[0],r=t[1];return OC({},n,r.depth)}))));function d(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=function(){var i=e[a];if(n.indexOf(i)!==-1){var o=[].concat(WC(n.slice(n.indexOf(i))),[i]).map(function(e){return t(e.data)});return u.some(function(e){return e.length===o.length&&e.every(function(e,t){return e===o[t]})})||(u.push(o),c(o)),1}r>i.depth&&(i.depth=r,d(i.out,[].concat(WC(n),[i]),r+ +!i.skip))},a=0,o=e.length;a<o;a++)if(i())continue}}var ow=window.THREE?window.THREE:{Group:gc,Mesh:Zl,MeshLambertMaterial:wd,Color:Cc,BufferGeometry:wl,BufferAttribute:cl,Matrix4:Hs,Vector3:U,SphereGeometry:ad,CylinderGeometry:ku,TubeGeometry:sd,ConeGeometry:Au,Line:bu,LineBasicMaterial:fu,QuadraticBezierCurve3:nd,CubicBezierCurve3:Qu,Box3:Bc},sw={graph:Tg,forcelayout:Dne.default},cw=2,lw=new ow.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,uw=new ow.BufferGeometry().applyMatrix4?`applyMatrix4`:`applyMatrix`,dw=m_({props:{jsonUrl:{onChange:function(e,t){var n=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(e){return e.json()}).then(function(e){t.fetchingJson=!1,t.onFinishLoading(e),n.graphData(e)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var n=t.d3ForceLayout.force(`charge`);n&&n.strength(e>2?-60:-30),e<3&&r(t.graphData.nodes,`z`),e<2&&r(t.graphData.nodes,`y`);function r(e,t){e.forEach(function(e){delete e[t],delete e[`v${t}`]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine===`d3`&&(t.graphData.nodes||[]).forEach(function(e){e.fx=e.fy=e.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:`id`},nodeVal:{default:`val`},nodeResolution:{default:8},nodeColor:{default:`color`},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:`source`},linkTarget:{default:`target`},linkVisibility:{default:!0},linkColor:{default:`color`},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:`d3`},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,n){return n===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!==`ngraph`;return e.engineRunning&&n(),r(),i(),this;function n(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin?(e.engineRunning=!1,e.onEngineStop()):(e.layout[t?`tick`:`step`](),e.onEngineTick());var n=h_(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(r){var i=VC(r,2),a=i[0],o=i[1];if(o){var s=t?a:e.layout.getNodePosition(a[e.nodeId]),c=n(a);(!e.nodePositionUpdate||!e.nodePositionUpdate(c?o.children[0]:o,{x:s.x,y:s.y,z:s.z},a)||c)&&(o.position.x=s.x,o.position.y=s.y||0,o.position.z=s.z||0)}});var r=h_(e.linkWidth),i=h_(e.linkCurvature),a=h_(e.linkCurveRotation),o=h_(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(n){var i=VC(n,2),a=i[0],c=i[1];if(c){var l=t?a:e.layout.getLinkPosition(e.layout.graph.getLink(a.source,a.target).id),u=l[t?`source`:`from`],d=l[t?`target`:`to`];if(!(!u||!d||!u.hasOwnProperty(`x`)||!d.hasOwnProperty(`x`))){s(a);var f=o(a);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(f?c.children[1]:c,{start:{x:u.x,y:u.y,z:u.z},end:{x:d.x,y:d.y,z:d.z}},a)&&!f)){var p=30,m=a.__curve,h=c.children.length?c.children[0]:c;if(h.type===`Line`){if(m){var g=m.getPoints(p);h.geometry.getAttribute(`position`).array.length!==g.length*3&&h.geometry[lw](`position`,new ow.BufferAttribute(new Float32Array(g.length*3),3)),h.geometry.setFromPoints(g)}else{var _=h.geometry.getAttribute(`position`);(!_||!_.array||_.array.length!==6)&&h.geometry[lw](`position`,_=new ow.BufferAttribute(new Float32Array(6),3)),_.array[0]=u.x,_.array[1]=u.y||0,_.array[2]=u.z||0,_.array[3]=d.x,_.array[4]=d.y||0,_.array[5]=d.z||0,_.needsUpdate=!0}h.geometry.computeBoundingSphere()}else if(h.type===`Mesh`){if(m){h.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(h.position.set(0,0,0),h.rotation.set(0,0,0),h.scale.set(1,1,1));var v=Math.ceil(r(a)*10)/10/2,y=new ow.TubeGeometry(m,p,v,e.linkResolution,!1);h.geometry.dispose(),h.geometry=y}else{if(!h.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var b=Math.ceil(r(a)*10)/10/2,x=new ow.CylinderGeometry(b,b,1,e.linkResolution,1,!1);x[uw](new ow.Matrix4().makeTranslation(0,1/2,0)),x[uw](new ow.Matrix4().makeRotationX(Math.PI/2)),h.geometry.dispose(),h.geometry=x}var S=new ow.Vector3(u.x,u.y||0,u.z||0),C=new ow.Vector3(d.x,d.y||0,d.z||0),w=S.distanceTo(C);h.position.x=S.x,h.position.y=S.y,h.position.z=S.z,h.scale.z=w,h.parent.localToWorld(C),h.lookAt(C)}}}}}});function s(n){var r=t?n:e.layout.getLinkPosition(e.layout.graph.getLink(n.source,n.target).id),o=r[t?`source`:`from`],s=r[t?`target`:`to`];if(!(!o||!s||!o.hasOwnProperty(`x`)||!s.hasOwnProperty(`x`))){var c=i(n);if(!c)n.__curve=null;else{var l=new ow.Vector3(o.x,o.y||0,o.z||0),u=new ow.Vector3(s.x,s.y||0,s.z||0),d=l.distanceTo(u),f,p=a(n);if(d>0){var m=s.x-o.x,h=s.y-o.y||0,g=new ow.Vector3().subVectors(u,l),_=g.clone().multiplyScalar(c).cross(m!==0||h!==0?new ow.Vector3(0,0,1):new ow.Vector3(0,1,0)).applyAxisAngle(g.normalize(),p).add(new ow.Vector3().addVectors(l,u).divideScalar(2));f=new ow.QuadraticBezierCurve3(l,_,u)}else{var v=c*70,y=-p,b=y+Math.PI/2;f=new ow.CubicBezierCurve3(l,new ow.Vector3(v*Math.cos(b),v*Math.sin(b),0).add(l),new ow.Vector3(v*Math.cos(y),v*Math.sin(y),0).add(l),u)}n.__curve=f}}}}function r(){var n=h_(e.linkDirectionalArrowRelPos),r=h_(e.linkDirectionalArrowLength),i=h_(e.nodeVal);e.arrowDataMapper.entries().forEach(function(a){var o=VC(a,2),s=o[0],c=o[1];if(c){var l=t?s:e.layout.getLinkPosition(e.layout.graph.getLink(s.source,s.target).id),u=l[t?`source`:`from`],d=l[t?`target`:`to`];if(!(!u||!d||!u.hasOwnProperty(`x`)||!d.hasOwnProperty(`x`))){var f=Math.cbrt(Math.max(0,i(u)||1))*e.nodeRelSize,p=Math.cbrt(Math.max(0,i(d)||1))*e.nodeRelSize,m=r(s),h=n(s),g=s.__curve?function(e){return s.__curve.getPoint(e)}:function(e){var t=function(e,t,n,r){return t[e]+(n[e]-t[e])*r||0};return{x:t(`x`,u,d,e),y:t(`y`,u,d,e),z:t(`z`,u,d,e)}},_=s.__curve?s.__curve.getLength():Math.sqrt([`x`,`y`,`z`].map(function(e){return((d[e]||0)-(u[e]||0))**2}).reduce(function(e,t){return e+t},0)),v=f+m+(_-f-p-m)*h,y=g(v/_),b=g((v-m)/_);[`x`,`y`,`z`].forEach(function(e){return c.position[e]=b[e]});var x=TC(ow.Vector3,WC([`x`,`y`,`z`].map(function(e){return y[e]})));c.parent.localToWorld(x),c.lookAt(x)}}})}function i(){var n=h_(e.linkDirectionalParticleSpeed),r=h_(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(i){var a=e.particlesDataMapper.getObj(i),o=a&&a.children,s=i.__singleHopPhotonsObj&&i.__singleHopPhotonsObj.children;if(!((!s||!s.length)&&(!o||!o.length))){var c=t?i:e.layout.getLinkPosition(e.layout.graph.getLink(i.source,i.target).id),l=c[t?`source`:`from`],u=c[t?`target`:`to`];if(!(!l||!u||!l.hasOwnProperty(`x`)||!u.hasOwnProperty(`x`))){var d=n(i),f=Math.abs(r(i)),p=i.__curve?function(e){return i.__curve.getPoint(e)}:function(e){var t=function(e,t,n,r){return t[e]+(n[e]-t[e])*r||0};return{x:t(`x`,l,u,e),y:t(`y`,l,u,e),z:t(`z`,l,u,e)}};[].concat(WC(o||[]),WC(s||[])).forEach(function(e,t){var n=e.parent.__linkThreeObjType===`singleHopPhotons`;if(e.hasOwnProperty(`__progressRatio`)||(e.__progressRatio=n?+(d<0):(t+f)/o.length),e.__progressRatio+=d,e.__progressRatio>=1||e.__progressRatio<0){if(!n)e.__progressRatio%=1,e.__progressRatio<0&&e.__progressRatio++;else{e.parent.remove(e),ZC(e);return}}var r=e.__progressRatio,i=p(r);e.geometry.type!==`SphereGeometry`&&e.lookAt(i.x,i.y,i.z),[`x`,`y`,`z`].forEach(function(t){return e.position[t]=i[t]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new ow.Group;n.__linkThreeObjType=`singleHopPhotons`,t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var r=h_(e.linkDirectionalParticleThreeObject)(t);if(r&&e.linkDirectionalParticleThreeObject===r&&(r=r.clone()),!r){var i=h_(e.linkDirectionalParticleWidth),a=Math.ceil(i(t)*10)/10/2,o=e.linkDirectionalParticleResolution,s=new ow.SphereGeometry(a,o,o),c=h_(e.linkColor),l=h_(e.linkDirectionalParticleColor)(t)||c(t)||`#f0f0f0`,u=new ow.Color(tw(l)),d=e.linkOpacity*3,f=new ow.MeshLambertMaterial({color:u,transparent:!0,opacity:d});r=new ow.Mesh(s,f)}t.__singleHopPhotonsObj.add(r)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var n=function e(n){var r=[];if(n.geometry){n.geometry.computeBoundingBox();var i=new ow.Box3;i.copy(n.geometry.boundingBox).applyMatrix4(n.matrixWorld),r.push(i)}return r.concat.apply(r,WC((n.children||[]).filter(function(e){return!e.hasOwnProperty(`__graphObjType`)||e.__graphObjType===`node`&&t(e.__data)}).map(e)))}(e.graphScene);return n.length?Object.assign.apply(Object,WC([`x`,`y`,`z`].map(function(e){return OC({},e,[A_(n,function(t){return t.min[e]}),k_(n,function(t){return t.max[e]})])}))):null}},stateInit:function(){return{d3ForceLayout:pne().force(`link`,Qte()).force(`charge`,mne()).force(`center`,ete()).force(`dagRadial`,null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new ew(e,{objBindAttr:`__threeObj`}),t.linkDataMapper=new ew(e,{objBindAttr:`__lineObj`}),t.arrowDataMapper=new ew(e,{objBindAttr:`__arrowObj`}),t.particlesDataMapper=new ew(e,{objBindAttr:`__photonsObj`})},update:function(e,t){var n=function(e){return e.some(function(e){return t.hasOwnProperty(e)})};if(e.engineRunning=!1,typeof e.onUpdate==`function`&&e.onUpdate(),e.nodeAutoColorBy!==null&&n([`nodeAutoColorBy`,`graphData`,`nodeColor`])&&iw(e.graphData.nodes,h_(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n([`linkAutoColorBy`,`graphData`,`linkColor`])&&iw(e.graphData.links,h_(e.linkAutoColorBy),e.linkColor),e._flushObjects||n([`graphData`,`nodeThreeObject`,`nodeThreeObjectExtend`,`nodeVal`,`nodeColor`,`nodeVisibility`,`nodeRelSize`,`nodeResolution`,`nodeOpacity`])){var r=h_(e.nodeThreeObject),i=h_(e.nodeThreeObjectExtend),a=h_(e.nodeVal),o=h_(e.nodeColor),s=h_(e.nodeVisibility),c={},l={};(e._flushObjects||n([`nodeThreeObject`,`nodeThreeObjectExtend`]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(t){var n=r(t),a=i(t);n&&e.nodeThreeObject===n&&(n=n.clone());var o;return n&&!a?o=n:(o=new ow.Mesh,o.__graphDefaultObj=!0,n&&a&&o.add(n)),o.__graphObjType=`node`,o}).onUpdateObj(function(t,n){if(t.__graphDefaultObj){var r=a(n)||1,i=Math.cbrt(r)*e.nodeRelSize,s=e.nodeResolution;(!t.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||t.geometry.parameters.radius!==i||t.geometry.parameters.widthSegments!==s)&&(c.hasOwnProperty(r)||(c[r]=new ow.SphereGeometry(i,s,s)),t.geometry.dispose(),t.geometry=c[r]);var u=o(n),d=new ow.Color(tw(u||`#ffffaa`)),f=e.nodeOpacity*nw(u);(t.material.type!==`MeshLambertMaterial`||!t.material.color.equals(d)||t.material.opacity!==f)&&(l.hasOwnProperty(u)||(l[u]=new ow.MeshLambertMaterial({color:d,transparent:!0,opacity:f})),t.material.dispose(),t.material=l[u])}}).digest(e.graphData.nodes.filter(s))}if(e._flushObjects||n([`graphData`,`linkThreeObject`,`linkThreeObjectExtend`,`linkMaterial`,`linkColor`,`linkWidth`,`linkVisibility`,`linkResolution`,`linkOpacity`,`linkDirectionalArrowLength`,`linkDirectionalArrowColor`,`linkDirectionalArrowResolution`,`linkDirectionalParticles`,`linkDirectionalParticleWidth`,`linkDirectionalParticleColor`,`linkDirectionalParticleResolution`,`linkDirectionalParticleThreeObject`])){var u=h_(e.linkThreeObject),d=h_(e.linkThreeObjectExtend),f=h_(e.linkMaterial),p=h_(e.linkVisibility),m=h_(e.linkColor),h=h_(e.linkWidth),g={},_={},v={},y=e.graphData.links.filter(p);if((e._flushObjects||n([`linkThreeObject`,`linkThreeObjectExtend`,`linkWidth`]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(e){var t=e.__data&&e.__data.__singleHopPhotonsObj;t&&(t.parent.remove(t),ZC(t),delete e.__data.__singleHopPhotonsObj)}).onCreateObj(function(t){var n=u(t),r=d(t);n&&e.linkThreeObject===n&&(n=n.clone());var i;if(!n||r){if(h(t))i=new ow.Mesh;else{var a=new ow.BufferGeometry;a[lw](`position`,new ow.BufferAttribute(new Float32Array(6),3)),i=new ow.Line(a)}}var o;return n?r?(o=new ow.Group,o.__graphDefaultObj=!0,o.add(i),o.add(n)):o=n:(o=i,o.__graphDefaultObj=!0),o.renderOrder=10,o.__graphObjType=`link`,o}).onUpdateObj(function(t,n){if(t.__graphDefaultObj){var r=t.children.length?t.children[0]:t,i=Math.ceil(h(n)*10)/10,a=!!i;if(a){var o=i/2,s=e.linkResolution;if(!r.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||r.geometry.parameters.radiusTop!==o||r.geometry.parameters.radialSegments!==s){if(!g.hasOwnProperty(i)){var c=new ow.CylinderGeometry(o,o,1,s,1,!1);c[uw](new ow.Matrix4().makeTranslation(0,1/2,0)),c[uw](new ow.Matrix4().makeRotationX(Math.PI/2)),g[i]=c}r.geometry.dispose(),r.geometry=g[i]}}var l=f(n);if(l)r.material=l;else{var u=m(n),d=new ow.Color(tw(u||`#f0f0f0`)),p=e.linkOpacity*nw(u),y=a?`MeshLambertMaterial`:`LineBasicMaterial`;if(r.material.type!==y||!r.material.color.equals(d)||r.material.opacity!==p){var b=a?_:v;b.hasOwnProperty(u)||(b[u]=new ow[y]({color:d,transparent:p<1,opacity:p,depthWrite:p>=1})),r.material.dispose(),r.material=b[u]}}}}).digest(y),e.linkDirectionalArrowLength||t.hasOwnProperty(`linkDirectionalArrowLength`)){var b=h_(e.linkDirectionalArrowLength),x=h_(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var e=new ow.Mesh(void 0,new ow.MeshLambertMaterial({transparent:!0}));return e.__linkThreeObjType=`arrow`,e}).onUpdateObj(function(t,n){var r=b(n),i=e.linkDirectionalArrowResolution;if(!t.geometry.type.match(/^Cone(Buffer)?Geometry$/)||t.geometry.parameters.height!==r||t.geometry.parameters.radialSegments!==i){var a=new ow.ConeGeometry(r*.25,r,i);a.translate(0,r/2,0),a.rotateX(Math.PI/2),t.geometry.dispose(),t.geometry=a}var o=x(n)||m(n)||`#f0f0f0`;t.material.color=new ow.Color(tw(o)),t.material.opacity=e.linkOpacity*3*nw(o)}).digest(y.filter(b))}if(e.linkDirectionalParticles||t.hasOwnProperty(`linkDirectionalParticles`)){var S=h_(e.linkDirectionalParticles),C=h_(e.linkDirectionalParticleWidth),w=h_(e.linkDirectionalParticleColor),T=h_(e.linkDirectionalParticleThreeObject),E={},D={};e.particlesDataMapper.onCreateObj(function(){var e=new ow.Group;return e.__linkThreeObjType=`photons`,e.__photonDataMapper=new ew(e),e}).onUpdateObj(function(t,n){var r=!!t.children.length&&t.children[0],i=T(n),a,o;if(i)a=i.geometry,o=i.material;else{var s=Math.ceil(C(n)*10)/10/2,c=e.linkDirectionalParticleResolution;r&&r.geometry.parameters.radius===s&&r.geometry.parameters.widthSegments===c?a=r.geometry:(D.hasOwnProperty(s)||(D[s]=new ow.SphereGeometry(s,c,c)),a=D[s]);var l=w(n)||m(n)||`#f0f0f0`,u=new ow.Color(tw(l)),d=e.linkOpacity*3;r&&r.material.color.equals(u)&&r.material.opacity===d?o=r.material:(E.hasOwnProperty(l)||(E[l]=new ow.MeshLambertMaterial({color:u,transparent:!0,opacity:d})),o=E[l])}r&&(r.geometry!==a&&r.geometry.dispose(),r.material!==o&&r.material.dispose());var f=Math.round(Math.abs(S(n)));t.__photonDataMapper.id(function(e){return e.idx}).onCreateObj(function(){return new ow.Mesh(a,o)}).onUpdateObj(function(e){e.geometry=a,e.material=o}).digest(WC(Array(f)).map(function(e,t){return{idx:t}}))}).digest(y.filter(S))}}if(e._flushObjects=!1,n([`graphData`,`nodeId`,`linkSource`,`linkTarget`,`numDimensions`,`forceEngine`,`dagMode`,`dagNodeFilter`,`dagLevelDistance`])){e.engineRunning=!1,e.graphData.links.forEach(function(t){t.source=t[e.linkSource],t.target=t[e.linkTarget]});var O=e.forceEngine!==`ngraph`,k;if(O){(k=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var A=e.d3ForceLayout.force(`link`);A&&A.id(function(t){return t[e.nodeId]}).links(e.graphData.links);var j=e.dagMode&&aw(e.graphData,function(t){return t[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),ee=Math.max.apply(Math,WC(Object.values(j||[]))),M=e.dagLevelDistance||e.graphData.nodes.length/(ee||1)*cw*([`radialin`,`radialout`].indexOf(e.dagMode)===-1?1:.7);if([`lr`,`rl`,`td`,`bu`,`zin`,`zout`].includes(t.dagMode)){var te=[`lr`,`rl`].includes(t.dagMode)?`fx`:[`td`,`bu`].includes(t.dagMode)?`fy`:`fz`;e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(e){return delete e[te]})}if([`lr`,`rl`,`td`,`bu`,`zin`,`zout`].includes(e.dagMode)){var ne=[`rl`,`td`,`zout`].includes(e.dagMode),N=function(t){return(j[t[e.nodeId]]-ee/2)*M*(ne?-1:1)},P=[`lr`,`rl`].includes(e.dagMode)?`fx`:[`td`,`bu`].includes(e.dagMode)?`fy`:`fz`;e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(e){return e[P]=N(e)})}e.d3ForceLayout.force(`dagRadial`,[`radialin`,`radialout`].indexOf(e.dagMode)===-1?null:wg(function(t){var n=j[t[e.nodeId]]||-1;return(e.dagMode===`radialin`?ee-n:n)*M}).strength(function(t){return+!!e.dagNodeFilter(t)}))}else{var re=sw.graph();e.graphData.nodes.forEach(function(t){re.addNode(t[e.nodeId])}),e.graphData.links.forEach(function(e){re.addLink(e.source,e.target)}),k=sw.forcelayout(re,RC({dimensions:e.numDimensions},e.ngraphPhysics)),k.graph=re}for(var ie=0;ie<e.warmupTicks&&!(O&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);ie++)k[O?`tick`:`step`]();e.layout=k,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function fw(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=function(t){function r(){var t;xC(this,r);var i=[...arguments];return t=yC(this,r,[].concat(i)),t.__kapsuleInstance=TC(e,[].concat(WC(n?[t]:[]),i)),t}return jC(r,t),DC(r)}(t);return Object.keys(e()).forEach(function(e){return r.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}}),r}var pw=fw(dw,(window.THREE?window.THREE:{Group:gc}).Group,!0),mw=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.envMapRotation.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`),hw=new WeakMap,gw=new WeakMap,_w=new WeakMap,Ire=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=mw,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1&&(this.getRenderObjectData(e),!0)}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,object:r}=e;if(t={geometryId:n.id,worldMatrix:r.matrixWorld.clone()},r.center&&(t.center=r.center.clone()),r.morphTargetInfluences&&(t.morphTargetInfluences=r.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),e.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}let{environmentIntensity:i,environmentRotation:a}=e.scene;t.environmentIntensity=i,t.environmentRotation=a.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=_w.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},_w.set(e,t)),t}getMaterialData(e){let t=gw.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:0}:t[n]=r.clone():t[n]=r)}gw.set(e,t)}return t}equals(e,t,n){let{object:r,material:i,geometry:a}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(r.matrixWorld)!==!0)return o.worldMatrix.copy(r.matrixWorld),!1;let s=this.getMaterialData(e.material);if(s._renderId!==n){s._renderId=n;for(let e in s){let t=s[e],n=i[e];if(e!==`_renderId`&&e!==`_equal`){if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),s._equal=!1,!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,s._equal=!1,!1}else if(t!==n)return s[e]=n,s._equal=!1,!1}}if(s.transmission>0){let{width:t,height:n}=e.context;if(o.bufferWidth!==t||o.bufferHeight!==n)return o.bufferWidth=t,o.bufferHeight=n,s._equal=!1,!1}s._equal=!0}else if(s._equal===!1)return!1;if(o.geometryId!==a.id)return o.geometryId=a.id,!1;let c=this.getGeometryData(e.geometry);if(c._renderId!==n){c._renderId=n;let e=a.attributes,t=c.attributes,r=0,i=0;for(let t in e)r++;for(let n in t){i++;let r=t[n],a=e[n];if(a===void 0)return delete t[n],c._equal=!1,!1;let o=a.isInterleavedBufferAttribute?a.data.uuid:a.id,s=a.isInterleavedBufferAttribute?a.data.version:a.version;if(r.id!==o||r.version!==s)return r.id=o,r.version=s,c._equal=!1,!1}if(i!==r)return c.attributes=this.getAttributesData(e),c._equal=!1,!1;let o=a.index,s=c.indexId,l=c.indexVersion,u=o?o.id:null,d=o?o.version:null;if(s!==u||l!==d)return c.indexId=u,c.indexVersion=d,c._equal=!1,!1;if(c.drawRange.start!==a.drawRange.start||c.drawRange.count!==a.drawRange.count)return c.drawRange.start=a.drawRange.start,c.drawRange.count=a.drawRange.count,c._equal=!1,!1;c._equal=!0}else if(c._equal===!1)return!1;if(o.morphTargetInfluences){let e=!1;for(let t=0;t<o.morphTargetInfluences.length;t++)o.morphTargetInfluences[t]!==r.morphTargetInfluences[t]&&(o.morphTargetInfluences[t]=r.morphTargetInfluences[t],e=!0);if(e)return!1}if(o.lights){for(let e=0;e<t.length;e++)if(o.lights[e].map!==t[e].map)return!1}let l=e.scene;return l.environment!==null&&i.envMap===null&&(o.environmentIntensity!==l.environmentIntensity||o.environmentRotation.equals(l.environmentRotation)===!1)?(o.environmentIntensity=l.environmentIntensity,o.environmentRotation.copy(l.environmentRotation),!1):o.center&&o.center.equals(r.center)===!1?(o.center.copy(r.center),!1):(e.bundle!==null&&(o.version=e.bundle.version),!0)}getLightsData(e,t){t.length=0;for(let n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){let n=hw.get(e);return n===void 0&&(n={renderId:-1,lightsData:[]},hw.set(e,n)),n.renderId===t?n.lightsData:(n.renderId=t,this.getLightsData(e.getLights(),n.lightsData),n.lightsData)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.getLights(e.lightsNode,n);return this.equals(e,a,n)!==!0}},Lre=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function Rre(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
4629
|
+
`).map(e=>{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!Lre.some(t=>t.test(e.file)))}var vw=class{constructor(e=null){this.isStackTrace=!0,this.stack=Rre(e||Error().stack)}getLocation(){if(this.stack.length===0)return`[Unknown location]`;let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:``}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join(`
|
|
4630
|
+
`)}`}};function yw(e,t=0){let n=3735928559^t,r=1103547991^t;if(Array.isArray(e))for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var bw=e=>yw(e),xw=e=>yw(e),Sw=(...e)=>yw(e),zre=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),Cw=new WeakMap;function ww(e){return zre.get(e)}function Tw(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Ew(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new Cc(...t):n===`vec2`?new H(...t):n===`vec3`?new U(...t):n===`vec4`?new Ls(...t):n===`mat2`?new Kf(...t):n===`mat3`?new xs(...t):n===`mat4`?new Hs(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?Vre(t[0]):null}function Dw(e){let t=Cw.get(e);return t===void 0&&(t={},Cw.set(e,t)),t}function Bre(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function Vre(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Ow={VERTEX:`vertex`,FRAGMENT:`fragment`},kw={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},Aw={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},Hre=[`fragment`,`vertex`],jw=[`setup`,`analyze`,`generate`],Mw=[...Hre,`compute`],Nw=[`x`,`y`,`z`,`w`],Ure={analyze:`setup`,generate:`analyze`},Wre=0,Pw=class e extends Wo{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=kw.NONE,this.updateBeforeType=kw.NONE,this.updateAfterType=kw.NONE,this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=Wre++,this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new vw)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=_s.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,kw.FRAME)}onRenderUpdate(e){return this.onUpdate(e,kw.RENDER)}onObjectUpdate(e){return this.onUpdate(e,kw.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let e in r){if(e.startsWith(`_`)===!0)continue;let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}}}return t}getCacheKey(e=!1,t=null){if(e||=this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);let n=[];for(let{property:r,childNode:i}of this._getChildren(t))n.push(bw(r.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=Sw(xw(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return`void`}getNodeType(e,t=null){let n=e.getDataFromNode(this),r;return t===null?(r=n.type,r===void 0&&(r=this.generateNodeType(e),n.type=r)):(n.typeFromOutput=n.typeFromOutput||{},r=n.typeFromOutput[t],r===void 0&&(r=this.generateNodeType(e,t),n.typeFromOutput[t]=r)),r}generateNodeType(e,t=null){let n=e.getNodeProperties(this);return n.outputNode?n.outputNode.getNodeType(e,t):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t),r=null;if(n&&n!==this)r=n;else if(e.context.overrideNodes){let t=e.context.overrideNodes.get(this);if(t){let n=e.getDataFromNode(this);n.isOverwritten===!0?r=n.sharedNode:(n.isOverwritten=!0,r=t(e).overrideNode(this,null),n.sharedNode=r)}}return r||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){B(`Abstract function.`)}updateAfter(){B(`Abstract function.`)}update(){B(`Abstract function.`)}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){let n=this._beforeNodes;this._beforeNodes=null;for(let r of n)r.build(e,t);this._beforeNodes=n}let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=Ure[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){e.addNode(this),this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}e.addSequentialNode(this)}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){if(this.generate.length<2){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(B(`Node: Recursion detected.`,this),a=`/* Recursion detected. */`):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``;a===``&&t!==null&&t!==`void`&&t!==`OutputType`&&(V(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};Pw.captureStackTrace=!1;var Fw=class extends Pw{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},Iw=class extends Pw{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},Lw=class extends Pw{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},Gre=class extends Lw{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){V(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(V(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},Kre=Nw.join(``),qre=class extends Pw{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Nw.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===Kre.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},Jre=class extends Lw{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Nw[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Yre=class extends Lw{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Nw[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Rw=class extends Pw{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}generateNodeType(){return this.nodeType===null?Tw(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Tw(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=Bre(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Ew(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){B(`Abstract function.`)}},zw=/float|u?int/,Bw=class extends Rw{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return zw.test(n)&&zw.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Xre=class extends Pw{static get type(){return`MemberNode`}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!==`void`}generateNodeType(e){return this.hasMember(e)===!1?`float`:this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return`float`;let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){B(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+`.`+this.property}},Vw=null,Hw=new Map;function W(e,t){if(Hw.has(e)){B(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);Hw.set(e,t),e!==`assign`&&(Pw.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Pw.prototype[e+`Assign`]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}var Zre=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),Uw=e=>Zre(e).split(``).sort().join(``);Pw.prototype.assign=function(...e){if(this.isStackNode!==!0)return Vw===null?V(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new vw):Vw.assign(this,...e),this;{let t=Hw.get(`assign`);return this.addToStack(t(...e))}},Pw.prototype.toVarIntent=function(){return this},Pw.prototype.get=function(e){return new Xre(this,e)};var Ww={};function Gw(e,t,n){Ww[e]=Ww[t]=Ww[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new qre(this,e),this._cache[e]=t),t},set(t){this[e].assign(cT(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();Pw.prototype[`set`+r]=Pw.prototype[`set`+i]=Pw.prototype[`set`+a]=function(t){let n=Uw(e);return new Jre(this,n,cT(t))},Pw.prototype[`flip`+r]=Pw.prototype[`flip`+i]=Pw.prototype[`flip`+a]=function(){let t=Uw(e);return new Yre(this,t)}}var Kw=[`x`,`y`,`z`,`w`],qw=[`r`,`g`,`b`,`a`],Jw=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=Kw[e],n=qw[e],r=Jw[e];Gw(t,n,r);for(let i=0;i<4;i++){t=Kw[e]+Kw[i],n=qw[e]+qw[i],r=Jw[e]+Jw[i],Gw(t,n,r);for(let a=0;a<4;a++){t=Kw[e]+Kw[i]+Kw[a],n=qw[e]+qw[i]+qw[a],r=Jw[e]+Jw[i]+Jw[a],Gw(t,n,r);for(let o=0;o<4;o++)t=Kw[e]+Kw[i]+Kw[a]+Kw[o],n=qw[e]+qw[i]+qw[a]+qw[o],r=Jw[e]+Jw[i]+Jw[a]+Jw[o],Gw(t,n,r)}}}for(let e=0;e<32;e++)Ww[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Fw(this,new Bw(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(cT(t))}};Object.defineProperties(Pw.prototype,Ww);var Qre=function(e,t=null){let n=Tw(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?cT(iT(e,t)):n===`shader`?e.isFn?e:K(e):e},$re=function(e,t=null){for(let n in e)e[n]=cT(e[n],t);return e},eie=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=cT(e[r],t);return e},Yw=function(e,t=null,n=null,r=null){function i(e){return r===null?e=cT(e):(e=cT(Object.assign(e,r)),r.intent===!0&&(e=e.toVarIntent())),e}let a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(V(`TSL: "${n}" parameter length is less than minimum required.`,new vw),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(V(`TSL: "${n}" parameter length exceeds limit.`,new vw),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...dT(l(t)))):n===null?a=(...n)=>i(new e(t,...dT(l(n)))):(n=cT(n),a=(...r)=>i(new e(t,...dT(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},tie=function(e,...t){return new e(...dT(t))},nie=class extends Pw{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){if(n){let r=t.layout.inputs;if(Xw(n)){let t=n;for(let n=0;n<r.length;n++){let r=t[n];r&&r.isNode&&r.build(e)}}else{let t=n[0];for(let n of r){let r=t[n.name];r&&r.isNode&&r.build(e)}}}let r=e.buildFunctionNode(t);e.addInclude(r);let i=n?rie(n):null;c=r.call(i)}else{let r=new Proxy(e,{get:(e,t,n)=>{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?iie(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=cT(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function Xw(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}function rie(e){let t;return uT(e),t=Xw(e)?[...e]:e[0],t}function iie(e){let t=0;return uT(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield cT(t)};else{if(e.length>0){if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof Pw&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i))}else a=Reflect.get(n,r,i);a=cT(a)}return a}})}var aie=class extends Pw{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new nie(this,e)}setup(){return this.call()}},oie=[!1,!0],sie=[0,1,2,3],cie=[-1,-2],Zw=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Qw=new Map;for(let e of oie)Qw.set(e,new Bw(e));var $w=new Map;for(let e of sie)$w.set(e,new Bw(e,`uint`));var eT=new Map([...$w].map(e=>new Bw(e.value,`int`)));for(let e of cie)eT.set(e,new Bw(e,`int`));var tT=new Map([...eT].map(e=>new Bw(e.value)));for(let e of Zw)tT.set(e,new Bw(e));for(let e of Zw)tT.set(-e,new Bw(-e));var nT={bool:Qw,uint:$w,ints:eT,float:tT},rT=new Map([...Qw,...tT]),iT=(e,t)=>rT.has(e)?rT.get(e):e.isNode===!0?e:new Bw(e,t),aT=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return V(`TSL: Invalid parameter for the type "${e}".`,new vw),new Bw(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[Ew(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return lT(t.get(n[0]));if(n.length===1){let t=iT(n[0],e);return t.nodeType===e?lT(t):lT(new Iw(t,e))}return lT(new Gre(n.map(e=>iT(e)),e))}};function oT(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}var lie=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function sT(e,t){return new aie(e,t)}var cT=(e,t=null)=>Qre(e,t),lT=(e,t=null)=>cT(e,t).toVarIntent(),uT=(e,t=null)=>new $re(e,t),dT=(e,t=null)=>new eie(e,t),fT=(e,t=null,n=null,r=null)=>new Yw(e,t,n,r),G=(e,...t)=>new tie(e,...t),pT=(e,t=null,n=null,r={})=>new Yw(e,t,n,{...r,intent:!0}),uie=0,die=class extends Pw{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:V(`TSL: Invalid layout type.`,new vw),t=null)),this.shaderNode=new sT(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+uie++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return V(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function K(e,t=null){let n=new die(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var mT=e=>{Vw=e},hT=()=>Vw,gT=(...e)=>Vw.If(...e);function _T(e){return Vw&&Vw.addToStack(e),e}W(`toStack`,_T);var fie=new aT(`color`),q=new aT(`float`,nT.float),vT=new aT(`int`,nT.ints),yT=new aT(`uint`,nT.uint),bT=new aT(`bool`,nT.bool),xT=new aT(`vec2`),ST=new aT(`ivec2`),CT=new aT(`uvec2`),pie=new aT(`bvec2`),J=new aT(`vec3`),wT=new aT(`ivec3`),TT=new aT(`uvec3`),mie=new aT(`bvec3`),ET=new aT(`vec4`),DT=new aT(`ivec4`),OT=new aT(`uvec4`),hie=new aT(`bvec4`),kT=new aT(`mat2`),AT=new aT(`mat3`),jT=new aT(`mat4`);W(`toColor`,fie),W(`toFloat`,q),W(`toInt`,vT),W(`toUint`,yT),W(`toBool`,bT),W(`toVec2`,xT),W(`toIVec2`,ST),W(`toUVec2`,CT),W(`toBVec2`,pie),W(`toVec3`,J),W(`toIVec3`,wT),W(`toUVec3`,TT),W(`toBVec3`,mie),W(`toVec4`,ET),W(`toIVec4`,DT),W(`toUVec4`,OT),W(`toBVec4`,hie),W(`toMat2`,kT),W(`toMat3`,AT),W(`toMat4`,jT),W(`element`,fT(Fw).setParameterLength(2)),W(`convert`,(e,t)=>new Iw(cT(e),t)),W(`append`,e=>(B(`TSL: .append() has been renamed to .toStack().`,new vw),_T(e)));var MT=class extends Pw{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1,r=null){super(e),this.name=t,this.varying=n,this.placeholderNode=cT(r),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return t===`output`?e.getOutputType():t}customCacheKey(){return bw(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){let n=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${n}`,this)}return e.getPropertyName(t)}},NT=(e,t,n=null)=>new MT(e,t,!1,n),PT=(e,t,n=null)=>new MT(e,t,!0,n),FT=G(MT,`vec4`,`DiffuseColor`),IT=G(MT,`vec3`,`DiffuseContribution`),LT=G(MT,`vec3`,`EmissiveColor`),RT=G(MT,`float`,`Roughness`),zT=G(MT,`float`,`Metalness`),BT=G(MT,`float`,`Clearcoat`),VT=G(MT,`float`,`ClearcoatRoughness`),HT=G(MT,`vec3`,`Sheen`),UT=G(MT,`float`,`SheenRoughness`),WT=G(MT,`float`,`Iridescence`),GT=G(MT,`float`,`IridescenceIOR`),KT=G(MT,`float`,`IridescenceThickness`),qT=G(MT,`float`,`AlphaT`),JT=G(MT,`float`,`Anisotropy`),YT=G(MT,`vec3`,`AnisotropyT`),XT=G(MT,`vec3`,`AnisotropyB`),ZT=G(MT,`color`,`SpecularColor`),QT=G(MT,`color`,`SpecularColorBlended`),$T=G(MT,`float`,`SpecularF90`),eE=G(MT,`float`,`Shininess`),tE=G(MT,`output`,`Output`),nE=G(MT,`float`,`dashSize`),rE=G(MT,`float`,`gapSize`),iE=G(MT,`float`,`IOR`),aE=G(MT,`float`,`Transmission`),oE=G(MT,`float`,`Thickness`),sE=G(MT,`float`,`AttenuationDistance`),cE=G(MT,`color`,`AttenuationColor`),lE=G(MT,`float`,`Dispersion`),uE=G(MT,`float`,`AmbientOcclusion`,!1,1),dE=class extends Pw{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1,r=null){super(`string`),this.name=e,this.shared=t,this.order=n,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},gie=(e,t=1,n=null)=>new dE(e,!1,t,n),fE=(e,t=0,n=null)=>new dE(e,!0,t,n);kw.FRAME;var pE=fE(`render`,0,kw.RENDER),_ie=gie(`object`,1,kw.OBJECT),mE=class extends Rw{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=_ie}setName(e){return this.name=e,this}label(e){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new vw),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},hE=(e,t)=>{let n=lie(t||e);if(n===e&&(e=Ew(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new mE(e,n)},gE=class extends Lw{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},vie=(...e)=>{let t;if(e.length===1){let n=e[0];t=new gE(null,n.length,n)}else{let n=e[0],r=e[1];t=new gE(n,r)}return cT(t)};W(`toArray`,(e,t)=>vie(Array(t).fill(e))),W(`assign`,fT(class extends Lw{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return Nw.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${l}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=a)}else u=`${a} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=a));return l.initialized=!0,e.format(u,o,t)}}).setParameterLength(2));var yie=class extends Lw{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}generateNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)V(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(V(`TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(V(`TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}return`${n.build(e,`property`)}( ${t.join(`, `)} )`}};W(`call`,(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?dT(t):uT(t[0]),new yie(cT(e),t)));var bie={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},_E=class e extends Lw{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(bie[this.op],t)}generateNodeType(e,t=null){let n=this.op,r=this.aNode,i=this.bNode,a=r.getNodeType(e),o=i?i.getNodeType(e):null;if(a===`void`||o===`void`)return t||`void`;if(n===`%`)return a;if(n===`~`||n===`&`||n===`|`||n===`^`||n===`>>`||n===`<<`)return e.getIntegerType(a);if(n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`!`){let t=e.getTypeLength(a);return t>1?`bvec${t}`:`bool`}if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===ko;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`)return r&&e.isVector(o)?e.format(`not( ${c} )`,t):e.format(`( ${n} ${c} )`,o,t);if(n===`~`)return e.format(`( ${n} ${c} )`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},vE=pT(_E,`+`).setParameterLength(2,1/0).setName(`add`),yE=pT(_E,`-`).setParameterLength(2,1/0).setName(`sub`),bE=pT(_E,`*`).setParameterLength(2,1/0).setName(`mul`),xE=pT(_E,`/`).setParameterLength(2,1/0).setName(`div`),SE=pT(_E,`%`).setParameterLength(2).setName(`mod`),xie=pT(_E,`==`).setParameterLength(2).setName(`equal`),Sie=pT(_E,`!=`).setParameterLength(2).setName(`notEqual`),Cie=pT(_E,`<`).setParameterLength(2).setName(`lessThan`),wie=pT(_E,`>`).setParameterLength(2).setName(`greaterThan`),Tie=pT(_E,`<=`).setParameterLength(2).setName(`lessThanEqual`),Eie=pT(_E,`>=`).setParameterLength(2).setName(`greaterThanEqual`),Die=pT(_E,`&&`).setParameterLength(2,1/0).setName(`and`),Oie=pT(_E,`||`).setParameterLength(2,1/0).setName(`or`),kie=pT(_E,`!`).setParameterLength(1).setName(`not`),Aie=pT(_E,`^^`).setParameterLength(2).setName(`xor`),jie=pT(_E,`&`).setParameterLength(2).setName(`bitAnd`),Mie=pT(_E,`~`).setParameterLength(1).setName(`bitNot`),Nie=pT(_E,`|`).setParameterLength(2).setName(`bitOr`),Pie=pT(_E,`^`).setParameterLength(2).setName(`bitXor`),Fie=pT(_E,`<<`).setParameterLength(2).setName(`shiftLeft`),Iie=pT(_E,`>>`).setParameterLength(2).setName(`shiftRight`),Lie=K(([e])=>(e.addAssign(1),e)),Rie=K(([e])=>(e.subAssign(1),e)),zie=K(([e])=>{let t=vT(e).toConst();return e.addAssign(1),t}),Bie=K(([e])=>{let t=vT(e).toConst();return e.subAssign(1),t});W(`add`,vE),W(`sub`,yE),W(`mul`,bE),W(`div`,xE),W(`mod`,SE),W(`equal`,xie),W(`notEqual`,Sie),W(`lessThan`,Cie),W(`greaterThan`,wie),W(`lessThanEqual`,Tie),W(`greaterThanEqual`,Eie),W(`and`,Die),W(`or`,Oie),W(`not`,kie),W(`xor`,Aie),W(`bitAnd`,jie),W(`bitNot`,Mie),W(`bitOr`,Nie),W(`bitXor`,Pie),W(`shiftLeft`,Fie),W(`shiftRight`,Iie),W(`incrementBefore`,Lie),W(`decrementBefore`,Rie),W(`increment`,zie),W(`decrement`,Bie);var Y=class e extends Lw{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=3;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}generateNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=yE(1,n);else if(i===e.RECIPROCAL)a=xE(1,n);else if(i===e.DIFFERENCE)a=IE(yE(n,r));else if(i===e.TRANSFORM_DIRECTION){let e,i;t.isMatrix(n.getNodeType(t))?(e=n,i=r):(e=r,i=n),a=jE(bE(e,ET(J(i),0)).xyz)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(B(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Y.ALL=`all`,Y.ANY=`any`,Y.RADIANS=`radians`,Y.DEGREES=`degrees`,Y.EXP=`exp`,Y.EXP2=`exp2`,Y.LOG=`log`,Y.LOG2=`log2`,Y.SQRT=`sqrt`,Y.INVERSE_SQRT=`inversesqrt`,Y.FLOOR=`floor`,Y.CEIL=`ceil`,Y.NORMALIZE=`normalize`,Y.FRACT=`fract`,Y.SIN=`sin`,Y.SINH=`sinh`,Y.COS=`cos`,Y.COSH=`cosh`,Y.TAN=`tan`,Y.TANH=`tanh`,Y.ASIN=`asin`,Y.ASINH=`asinh`,Y.ACOS=`acos`,Y.ACOSH=`acosh`,Y.ATAN=`atan`,Y.ATANH=`atanh`,Y.ABS=`abs`,Y.SIGN=`sign`,Y.LENGTH=`length`,Y.NEGATE=`negate`,Y.ONE_MINUS=`oneMinus`,Y.DFDX=`dFdx`,Y.DFDY=`dFdy`,Y.ROUND=`round`,Y.RECIPROCAL=`reciprocal`,Y.TRUNC=`trunc`,Y.FWIDTH=`fwidth`,Y.TRANSPOSE=`transpose`,Y.DETERMINANT=`determinant`,Y.INVERSE=`inverse`,Y.EQUALS=`equals`,Y.MIN=`min`,Y.MAX=`max`,Y.STEP=`step`,Y.REFLECT=`reflect`,Y.DISTANCE=`distance`,Y.DIFFERENCE=`difference`,Y.DOT=`dot`,Y.CROSS=`cross`,Y.POW=`pow`,Y.TRANSFORM_DIRECTION=`transformDirection`,Y.MIX=`mix`,Y.CLAMP=`clamp`,Y.REFRACT=`refract`,Y.SMOOTHSTEP=`smoothstep`,Y.FACEFORWARD=`faceforward`;var CE=q(1e-6),Vie=q(Math.PI);Math.PI*2,Math.PI*2,Math.PI*.5;var Hie=pT(Y,Y.ALL).setParameterLength(1),Uie=pT(Y,Y.ANY).setParameterLength(1),Wie=pT(Y,Y.RADIANS).setParameterLength(1),Gie=pT(Y,Y.DEGREES).setParameterLength(1),wE=pT(Y,Y.EXP).setParameterLength(1),TE=pT(Y,Y.EXP2).setParameterLength(1),EE=pT(Y,Y.LOG).setParameterLength(1),DE=pT(Y,Y.LOG2).setParameterLength(1),OE=pT(Y,Y.SQRT).setParameterLength(1),Kie=pT(Y,Y.INVERSE_SQRT).setParameterLength(1),kE=pT(Y,Y.FLOOR).setParameterLength(1),AE=pT(Y,Y.CEIL).setParameterLength(1),jE=pT(Y,Y.NORMALIZE).setParameterLength(1),ME=pT(Y,Y.FRACT).setParameterLength(1),NE=pT(Y,Y.SIN).setParameterLength(1),qie=pT(Y,Y.SINH).setParameterLength(1),PE=pT(Y,Y.COS).setParameterLength(1),Jie=pT(Y,Y.COSH).setParameterLength(1),Yie=pT(Y,Y.TAN).setParameterLength(1),Xie=pT(Y,Y.TANH).setParameterLength(1),Zie=pT(Y,Y.ASIN).setParameterLength(1),Qie=pT(Y,Y.ASINH).setParameterLength(1),FE=pT(Y,Y.ACOS).setParameterLength(1),$ie=pT(Y,Y.ACOSH).setParameterLength(1),eae=pT(Y,Y.ATAN).setParameterLength(1,2),tae=pT(Y,Y.ATANH).setParameterLength(1),IE=pT(Y,Y.ABS).setParameterLength(1),LE=pT(Y,Y.SIGN).setParameterLength(1),RE=pT(Y,Y.LENGTH).setParameterLength(1),zE=pT(Y,Y.NEGATE).setParameterLength(1),nae=pT(Y,Y.ONE_MINUS).setParameterLength(1),BE=pT(Y,Y.DFDX).setParameterLength(1),VE=pT(Y,Y.DFDY).setParameterLength(1),rae=pT(Y,Y.ROUND).setParameterLength(1),iae=pT(Y,Y.RECIPROCAL).setParameterLength(1),aae=pT(Y,Y.TRUNC).setParameterLength(1),HE=pT(Y,Y.FWIDTH).setParameterLength(1),oae=pT(Y,Y.TRANSPOSE).setParameterLength(1),sae=pT(Y,Y.DETERMINANT).setParameterLength(1),cae=pT(Y,Y.INVERSE).setParameterLength(1),UE=pT(Y,Y.MIN).setParameterLength(2,1/0),WE=pT(Y,Y.MAX).setParameterLength(2,1/0),GE=pT(Y,Y.STEP).setParameterLength(2),lae=pT(Y,Y.REFLECT).setParameterLength(2),uae=pT(Y,Y.DISTANCE).setParameterLength(2),dae=pT(Y,Y.DIFFERENCE).setParameterLength(2),KE=pT(Y,Y.DOT).setParameterLength(2),qE=pT(Y,Y.CROSS).setParameterLength(2),JE=pT(Y,Y.POW).setParameterLength(2),YE=e=>bE(e,e),fae=e=>bE(e,e,e),XE=e=>bE(e,e,e,e),pae=pT(Y,Y.TRANSFORM_DIRECTION).setParameterLength(2),mae=(e,t)=>jE(bE(t,ET(J(e),0)).xyz),hae=(e,t)=>jE(ET(J(e),0).mul(t).xyz),gae=e=>bE(LE(e),JE(IE(e),1/3)),ZE=e=>KE(e,e),QE=pT(Y,Y.MIX).setParameterLength(3),$E=(e,t=0,n=1)=>new Y(Y.CLAMP,cT(e),cT(t),cT(n)),eD=e=>$E(e),tD=pT(Y,Y.REFRACT).setParameterLength(3),nD=pT(Y,Y.SMOOTHSTEP).setParameterLength(3),_ae=pT(Y,Y.FACEFORWARD).setParameterLength(3),vae=K(([e])=>ME(NE(SE(KE(e.xy,xT(12.9898,78.233)),Vie)).mul(43758.5453)));W(`all`,Hie),W(`any`,Uie),W(`radians`,Wie),W(`degrees`,Gie),W(`exp`,wE),W(`exp2`,TE),W(`log`,EE),W(`log2`,DE),W(`sqrt`,OE),W(`inverseSqrt`,Kie),W(`floor`,kE),W(`ceil`,AE),W(`normalize`,jE),W(`fract`,ME),W(`sin`,NE),W(`sinh`,qie),W(`cos`,PE),W(`cosh`,Jie),W(`tan`,Yie),W(`tanh`,Xie),W(`asin`,Zie),W(`asinh`,Qie),W(`acos`,FE),W(`acosh`,$ie),W(`atan`,eae),W(`atanh`,tae),W(`abs`,IE),W(`sign`,LE),W(`length`,RE),W(`lengthSq`,ZE),W(`negate`,zE),W(`oneMinus`,nae),W(`dFdx`,BE),W(`dFdy`,VE),W(`round`,rae),W(`reciprocal`,iae),W(`trunc`,aae),W(`fwidth`,HE),W(`min`,UE),W(`max`,WE),W(`step`,(e,t)=>GE(t,e)),W(`reflect`,lae),W(`distance`,uae),W(`dot`,KE),W(`cross`,qE),W(`pow`,JE),W(`pow2`,YE),W(`pow3`,fae),W(`pow4`,XE),W(`transformDirection`,pae),W(`transformNormalByViewMatrix`,mae),W(`transformNormalByInverseViewMatrix`,hae),W(`mix`,(e,t,n)=>QE(t,n,e)),W(`clamp`,$E),W(`refract`,tD),W(`smoothstep`,(e,t,n)=>nD(t,n,e)),W(`faceForward`,_ae),W(`difference`,dae),W(`saturate`,eD),W(`cbrt`,gae),W(`transpose`,oae),W(`determinant`,sae),W(`inverse`,cae),W(`rand`,vae);var rD=fT(class extends Pw{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}generateNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?NT(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(B(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
4631
4631
|
|
|
4632
4632
|
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
4633
4633
|
|
|
@@ -4637,23 +4637,23 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4637
4637
|
|
|
4638
4638
|
`)}else e.addFlowCode(`
|
|
4639
4639
|
|
|
4640
|
-
`);return e.format(l,n,t)}}).setParameterLength(2,3);W(`select`,nD);var rD=class extends Nw{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},iD=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new rD(n,t)},bae=e=>iD(e,{uniformFlow:!0}),aD=(e,t)=>iD(e,{nodeName:t});function xae(e,t,n=null){return iD(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function Sae(e,t=null){return iD(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function oD(e,t){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`),aD(e,t)}W(`context`,iD),W(`label`,oD),W(`uniformFlow`,bae),W(`setName`,aD),W(`builtinShadowContext`,(e,t,n)=>xae(t,n,e)),W(`builtinAOContext`,(e,t)=>Sae(t,e));var sD=class extends Nw{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration!==!0&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],n=this.getShared(t);if(this!==n)return n.build(...e);if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&V(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s){if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},cD=dT(sD);W(`toVar`,(e,t=null)=>cD(e,t).toStack()),W(`toConst`,(e,t=null)=>cD(e,t,!0).toStack()),W(`toVarIntent`,e=>cD(e).setIntent(!0).toStack());var Cae=class extends Nw{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},lD=(e,t,n=null)=>new Cae(sT(e),t,n),uD=dT(class extends Nw{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=lD(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=lD(this.node,`VERTEX`)}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage===`fragment`),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Dw.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Dw.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,Dw.VERTEX);if(e.shaderStage===Dw.VERTEX){let t=n.node.build(e,i);e.addLineFlowCode(`${a} = ${t}`,this)}else e.flowNodeFromShaderStage(Dw.VERTEX,n.node,i,a);n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2);W(`toVarying`,uD),W(`toVertexStage`,e=>uD(e));var wae=K(([e])=>ZE(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),Tae=K(([e])=>ZE(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),dD=`WorkingColorSpace`,fD=`OutputColorSpace`,pD=class extends Iw{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===dD?Es.workingColorSpace:t===fD?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return Es.enabled===!1||n===r||!n||!r?i:(Es.getTransfer(n)===`srgb`&&(i=TT(wae(i.rgb),i.a)),Es.getPrimaries(n)!==Es.getPrimaries(r)&&(i=TT(kT(Es._getMatrix(new xs,n,r)).mul(i.rgb),i.a)),Es.getTransfer(r)===`srgb`&&(i=TT(Tae(i.rgb),i.a)),i)}},mD=(e,t)=>new pD(sT(e),dD,t),hD=(e,t)=>new pD(sT(e),t,dD);W(`workingToColorSpace`,mD),W(`colorSpaceToWorking`,hD);var gD=class extends Pw{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},_D=class extends Nw{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=Ow.OBJECT}setGroup(e){return this.group=e,this}element(e){return new gD(this,sT(e))}setNodeType(e){let t=mE(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},vD=(e,t,n)=>new _D(e,t,n),yD=class extends _D{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(fE)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},bD=(e,t,n=null)=>new yD(e,t,n),Eae=class extends Iw{static get type(){return`ToneMappingNode`}constructor(e,t=Oae,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return xw(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(V(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=TT(i(t.rgb,this.exposureNode),t.a),r}},Dae=(e,t,n)=>new Eae(e,sT(t),sT(n)),Oae=bD(`toneMappingExposure`,`float`);W(`toneMapping`,(e,t,n)=>Dae(t,n,e));var xD=new WeakMap;function SD(e,t){let n=xD.get(e);return n===void 0&&(n=new Tl(e,t),xD.set(e,n)),n}var CD=class extends Lw{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=Do,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?SD(r.array,i):SD(r,i);let s=new Dl(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.context.nodeName;n!==void 0&&delete e.context.nodeName;let r=e.getBufferAttributeFromNode(this,t,n),i=e.getPropertyName(r),a=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=i,a=i;else{let r;n&&(r=n+`Varying`),a=uD(this,r).build(e,t)}return a}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function wD(e,t=null,n=0,r=0,i=Do,a=!1){return t===`mat3`||t===null&&e.itemSize===9?kT(new CD(e,`vec3`,9,0).setUsage(i).setInstanced(a),new CD(e,`vec3`,9,3).setUsage(i).setInstanced(a),new CD(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?AT(new CD(e,`vec4`,16,0).setUsage(i).setInstanced(a),new CD(e,`vec4`,16,4).setUsage(i).setInstanced(a),new CD(e,`vec4`,16,8).setUsage(i).setInstanced(a),new CD(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new CD(e,t,n,r).setUsage(i)}var TD=(e,t=null,n=0,r=0)=>wD(e,t,n,r),ED=(e,t=null,n=0,r=0)=>wD(e,t,n,r,Do,!0),DD=(e,t=null,n=0,r=0)=>wD(e,t,n,r,Oo,!0);W(`toAttribute`,e=>TD(e.value));var OD=class e extends Nw{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:uD(this).build(t,n),a}};OD.VERTEX=`vertex`,OD.INSTANCE=`instance`,OD.SUBGROUP=`subgroup`,OD.INVOCATION_LOCAL=`invocationLocal`,OD.INVOCATION_SUBGROUP=`invocationSubgroup`,OD.DRAW=`draw`;var kD=G(OD,OD.VERTEX),AD=G(OD,OD.INSTANCE);OD.SUBGROUP,OD.INVOCATION_SUBGROUP,OD.INVOCATION_LOCAL;var jD=G(OD,OD.DRAW),MD=class extends Nw{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name=``,this.updateBeforeType=Ow.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new _w),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=mE(this.count,`uint`).onObjectUpdate(()=>this.count));let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);if(t!==``&&e.addLineFlowCode(t,this),this.count!==null&&e.allowEarlyReturns===!0){let t=this.countNode.build(e,`uint`),n=AD.build(e,`uint`);e.flow.code=`${e.tab}if ( ${n} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},ND=(e,t=[64])=>{(t.length===0||t.length>3)&&V(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new _w);for(let e=0;e<t.length;e++){let n=t[e];(typeof n!=`number`||n<=0||!Number.isInteger(n))&&V(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new _w)}for(;t.length<3;)t.push(1);return new MD(sT(e),t)};W(`compute`,(e,t,n)=>{let r=ND(e,n);return typeof t==`number`?r.count=t:r.dispatchSize=t,r}),W(`computeKernel`,ND);var PD=class extends Nw{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},FD=e=>new PD(sT(e));function ID(e,t=!0){return B(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),FD(e).setParent(t)}W(`cache`,ID),W(`isolate`,FD),W(`bypass`,dT(class extends Nw{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2));var LD=K(([e,t,n,r=q(0),i=q(1),a=yT(!1)])=>{let o=e.sub(t).div(n.sub(t));return aT(a)&&(o=o.clamp()),o.mul(i.sub(r)).add(r)});function RD(e,t,n,r=q(0),i=q(1)){return LD(e,t,n,r,i,!0)}W(`remap`,LD),W(`remapClamp`,RD);var zD=class extends Nw{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}},BD=dT(zD).setParameterLength(1,2);W(`discard`,e=>(e?nD(e,BD(`discard`)):BD(`discard`)).toStack());var VD=K(([e])=>TT(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),HD=K(([e])=>e.a.equal(0).select(TT(0),TT(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),UD=class extends Iw{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=TT(t.rgb,t.a.clamp(0,1)),t=HD(t);let n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==Es.workingColorSpace&&(t=t.workingToColorSpace(r)),t=VD(t),t}},WD=(e,t=null,n=null)=>new UD(sT(e),t,n);W(`renderOutput`,WD);var GD=class extends Iw{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`#
|
|
4640
|
+
`);return e.format(l,n,t)}}).setParameterLength(2,3);W(`select`,rD);var iD=class extends Pw{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},aD=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new iD(n,t)},yae=e=>aD(e,{uniformFlow:!0}),oD=(e,t)=>aD(e,{nodeName:t});function bae(e,t,n=null){return aD(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function xae(e,t=null){return aD(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function sD(e,t){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`),oD(e,t)}W(`context`,aD),W(`label`,sD),W(`uniformFlow`,yae),W(`setName`,oD),W(`builtinShadowContext`,(e,t,n)=>bae(t,n,e)),W(`builtinAOContext`,(e,t)=>xae(t,e));var cD=class extends Pw{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration!==!0&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],n=this.getShared(t);if(this!==n)return n.build(...e);if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&V(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s){if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},lD=fT(cD);W(`toVar`,(e,t=null)=>lD(e,t).toStack()),W(`toConst`,(e,t=null)=>lD(e,t,!0).toStack()),W(`toVarIntent`,e=>lD(e).setIntent(!0).toStack());var Sae=class extends Pw{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},uD=(e,t,n=null)=>new Sae(cT(e),t,n),dD=fT(class extends Pw{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=uD(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=uD(this.node,`VERTEX`)}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage===`fragment`),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ow.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ow.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,Ow.VERTEX);if(e.shaderStage===Ow.VERTEX){let t=n.node.build(e,i);e.addLineFlowCode(`${a} = ${t}`,this)}else e.flowNodeFromShaderStage(Ow.VERTEX,n.node,i,a);n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2);W(`toVarying`,dD),W(`toVertexStage`,e=>dD(e));var Cae=K(([e])=>QE(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),wae=K(([e])=>QE(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),fD=`WorkingColorSpace`,pD=`OutputColorSpace`,mD=class extends Lw{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===fD?Es.workingColorSpace:t===pD?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return Es.enabled===!1||n===r||!n||!r?i:(Es.getTransfer(n)===`srgb`&&(i=ET(Cae(i.rgb),i.a)),Es.getPrimaries(n)!==Es.getPrimaries(r)&&(i=ET(AT(Es._getMatrix(new xs,n,r)).mul(i.rgb),i.a)),Es.getTransfer(r)===`srgb`&&(i=ET(wae(i.rgb),i.a)),i)}},hD=(e,t)=>new mD(cT(e),fD,t),gD=(e,t)=>new mD(cT(e),t,fD);W(`workingToColorSpace`,hD),W(`colorSpaceToWorking`,gD);var _D=class extends Fw{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},vD=class extends Pw{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=kw.OBJECT}setGroup(e){return this.group=e,this}element(e){return new _D(this,cT(e))}setNodeType(e){let t=hE(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},yD=(e,t,n)=>new vD(e,t,n),bD=class extends vD{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(pE)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},xD=(e,t,n=null)=>new bD(e,t,n),Tae=class extends Lw{static get type(){return`ToneMappingNode`}constructor(e,t=Dae,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return Sw(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(V(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=ET(i(t.rgb,this.exposureNode),t.a),r}},Eae=(e,t,n)=>new Tae(e,cT(t),cT(n)),Dae=xD(`toneMappingExposure`,`float`);W(`toneMapping`,(e,t,n)=>Eae(t,n,e));var SD=new WeakMap;function CD(e,t){let n=SD.get(e);return n===void 0&&(n=new Tl(e,t),SD.set(e,n)),n}var wD=class extends Rw{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=Do,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?CD(r.array,i):CD(r,i);let s=new Dl(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.context.nodeName;n!==void 0&&delete e.context.nodeName;let r=e.getBufferAttributeFromNode(this,t,n),i=e.getPropertyName(r),a=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=i,a=i;else{let r;n&&(r=n+`Varying`),a=dD(this,r).build(e,t)}return a}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function TD(e,t=null,n=0,r=0,i=Do,a=!1){return t===`mat3`||t===null&&e.itemSize===9?AT(new wD(e,`vec3`,9,0).setUsage(i).setInstanced(a),new wD(e,`vec3`,9,3).setUsage(i).setInstanced(a),new wD(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?jT(new wD(e,`vec4`,16,0).setUsage(i).setInstanced(a),new wD(e,`vec4`,16,4).setUsage(i).setInstanced(a),new wD(e,`vec4`,16,8).setUsage(i).setInstanced(a),new wD(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new wD(e,t,n,r).setUsage(i)}var ED=(e,t=null,n=0,r=0)=>TD(e,t,n,r),DD=(e,t=null,n=0,r=0)=>TD(e,t,n,r,Do,!0),OD=(e,t=null,n=0,r=0)=>TD(e,t,n,r,Oo,!0);W(`toAttribute`,e=>ED(e.value));var kD=class e extends Pw{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:dD(this).build(t,n),a}};kD.VERTEX=`vertex`,kD.INSTANCE=`instance`,kD.SUBGROUP=`subgroup`,kD.INVOCATION_LOCAL=`invocationLocal`,kD.INVOCATION_SUBGROUP=`invocationSubgroup`,kD.DRAW=`draw`;var AD=G(kD,kD.VERTEX),jD=G(kD,kD.INSTANCE);kD.SUBGROUP,kD.INVOCATION_SUBGROUP,kD.INVOCATION_LOCAL;var MD=G(kD,kD.DRAW),ND=class extends Pw{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name=``,this.updateBeforeType=kw.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new vw),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=hE(this.count,`uint`).onObjectUpdate(()=>this.count));let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);if(t!==``&&e.addLineFlowCode(t,this),this.count!==null&&e.allowEarlyReturns===!0){let t=this.countNode.build(e,`uint`),n=jD.build(e,`uint`);e.flow.code=`${e.tab}if ( ${n} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},PD=(e,t=[64])=>{(t.length===0||t.length>3)&&V(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new vw);for(let e=0;e<t.length;e++){let n=t[e];(typeof n!=`number`||n<=0||!Number.isInteger(n))&&V(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new vw)}for(;t.length<3;)t.push(1);return new ND(cT(e),t)};W(`compute`,(e,t,n)=>{let r=PD(e,n);return typeof t==`number`?r.count=t:r.dispatchSize=t,r}),W(`computeKernel`,PD);var FD=class extends Pw{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},ID=e=>new FD(cT(e));function LD(e,t=!0){return B(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),ID(e).setParent(t)}W(`cache`,LD),W(`isolate`,ID),W(`bypass`,fT(class extends Pw{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2));var RD=K(([e,t,n,r=q(0),i=q(1),a=bT(!1)])=>{let o=e.sub(t).div(n.sub(t));return oT(a)&&(o=o.clamp()),o.mul(i.sub(r)).add(r)});function zD(e,t,n,r=q(0),i=q(1)){return RD(e,t,n,r,i,!0)}W(`remap`,RD),W(`remapClamp`,zD);var BD=class extends Pw{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}},VD=fT(BD).setParameterLength(1,2);W(`discard`,e=>(e?rD(e,VD(`discard`)):VD(`discard`)).toStack());var HD=K(([e])=>ET(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),UD=K(([e])=>e.a.equal(0).select(ET(0),ET(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),WD=class extends Lw{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=ET(t.rgb,t.a.clamp(0,1)),t=UD(t);let n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==Es.workingColorSpace&&(t=t.workingToColorSpace(r)),t=HD(t),t}},GD=(e,t=null,n=null)=>new WD(cT(e),t,n);W(`renderOutput`,GD);var KD=class extends Lw{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`#
|
|
4641
4641
|
`,i+=e.flow.code.replace(/^\t/gm,``)+`
|
|
4642
4642
|
`,i+=`/* ... */ `+n+` /* ... */
|
|
4643
4643
|
`,i+=`// #`+r+`#
|
|
4644
|
-
`,Ro(i)}return n}};W(`debug`,(e,t=null)=>new GD(sT(e),t).toStack());var KD=class extends Wo{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},qD=class extends Nw{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=Ow.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==KD&&Bo(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function JD(e,t=``,n=null){return e=sT(e),e.before(new qD(e,t,n))}W(`toInspector`,JD);var YD=class extends Nw{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):uD(this).build(e,n)}return B(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},XD=(e,t=null)=>new YD(e,t),ZD=(e=0)=>XD(`uv`+(e>0?e:``),`vec2`),QD=dT(class extends Nw{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),kae=dT(class extends pE{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=Ow.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),Aae=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},$D=new Is,eO=class extends pE{static get type(){return`TextureNode`}constructor(e=$D,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Ow.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?`float`:`vec4`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return ZD(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=mE(this.value.matrix)),this._matrixUniform.mul(J(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=mE(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(_T(QD(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new Aae("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=K(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||=this.getDefaultUV(),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Ow.OBJECT:Ow.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null){if(e.renderer.hasCompatibility(Mo.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,Bo(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c,l,u){let d=this.value,f;return f=i?e.generateTextureBias(d,t,n,i,a,l):s?e.generateTextureGrad(d,t,n,s,a,l):c?o?e.generateTextureGatherCompare(d,t,n,o,a,l,u):e.generateTextureGather(d,t,n,c,a,l,u):o?e.generateTextureCompare(d,t,n,o,a,l):this.sampler===!1?e.generateTextureLoad(d,t,n,r,a,l):r?e.generateTextureLevel(d,t,n,r,a,l):e.generateTexture(d,t,n,a,l),f}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,gatherNode:m,offsetNode:h}=r,g=this.generateUV(e,t),_=c?c.build(e,`float`):null,v=l?l.build(e,`float`):null,y=f?f.build(e,`int`):null,b=u?u.build(e,`float`):null,x=d?d.build(e,`float`):null,S=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,C=m?m.build(e,`int`):null,w=h?this.generateOffset(e,h):null,T=this._flipYUniform?this._flipYUniform.build(e,`bool`):null;C&&(o=`vec4`);let E=y;E===null&&n.isArrayTexture&&this.isTexture3DNode!==!0&&(E=`0`);let D=e.getVarFromNode(this);s=e.getPropertyName(D);let O=this.generateSnippet(e,i,g,_,v,E,b,S,C,w,T);if(x!==null){let t=n.compareFunction;O=t===516||t===518?WE(BD(O,o),BD(x,`float`)).build(e,o):WE(BD(x,`float`),BD(O,o)).build(e,o)}e.addLineFlowCode(`${s} = ${O}`,this),a.snippet=O,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=hD(BD(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=sT(e),t.referenceNode=this.getBase(),sT(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=sT(e).mul(kae(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(B(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),sT(t)}level(e){let t=this.clone();return t.levelNode=sT(e),t.referenceNode=this.getBase(),sT(t)}size(e){return QD(this,e)}bias(e){let t=this.clone();return t.biasNode=sT(e),t.referenceNode=this.getBase(),sT(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=sT(e),t.referenceNode=this.getBase(),sT(t)}grad(e,t){let n=this.clone();return n.gradNode=[sT(e),sT(t)],n.referenceNode=this.getBase(),sT(n)}gather(e=0){let t=this.clone();return t.gatherNode=sT(e),t.referenceNode=this.getBase(),sT(t)}depth(e){let t=this.clone();return t.depthNode=sT(e),t.referenceNode=this.getBase(),sT(t)}offset(e){let t=this.clone();return t.offsetNode=sT(e),t.referenceNode=this.getBase(),sT(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},jae=dT(eO).setParameterLength(1,4).setName(`texture`),tO=(e=$D,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=sT(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=sT(t)),n!==null&&(i.levelNode=sT(n)),r!==null&&(i.biasNode=sT(r))):i=jae(e,t,n,r),i},nO=(...e)=>tO(...e).setSampler(!1),rO=class extends pE{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},iO=(e,t,n)=>new rO(e,t,n),Mae=class extends Pw{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(e),r=this.node.getPaddedType();return e.format(t,r,n)}},Nae=class extends rO{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?ww(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Ow.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,this.update(),super.setup(e)}element(e){return new Mae(this,sT(e))}},aO=(e,t)=>new Nae(e,t),oO=dT(class extends Nw{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),sO,cO,lO=class e extends Nw{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=Ow.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=Ow.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(cO),cO.multiplyScalar(t.getPixelRatio())):cO.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(sO):(sO.width=n.width,sO.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?mE(sO||=new H):t===e.VIEWPORT?mE(cO||=new Ls):t===e.DPR?mE(1):bT(pO.div(fO)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(fO).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};lO.COORDINATE=`coordinate`,lO.VIEWPORT=`viewport`,lO.SIZE=`size`,lO.UV=`uv`,lO.DPR=`dpr`;var uO=G(lO,lO.DPR),dO=G(lO,lO.UV),fO=G(lO,lO.SIZE),pO=G(lO,lO.COORDINATE),mO=G(lO,lO.VIEWPORT),Pae=mO.zw;mO.xy;var hO=null,gO=null,_O=null,vO=null,yO=null,bO=null,xO=null,SO=null,CO=null,wO=null,TO=mE(0,`uint`).setName(`u_cameraIndex`).setGroup(dE(`cameraIndex`)).toVarying(`v_cameraIndex`),EO=mE(`float`).setName(`cameraNear`).setGroup(fE).onRenderUpdate(({camera:e})=>e.near),DO=mE(`float`).setName(`cameraFar`).setGroup(fE).onRenderUpdate(({camera:e})=>e.far),OO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);gO===null?gO=aO(n).setGroup(fE).setName(`cameraProjectionMatrices`):gO.array=n,t=gO.element(e.isMultiViewCamera?oO(`gl_ViewID_OVR`):TO)}else hO===null&&(hO=mE(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(fE).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=hO;return t}).once()(),kO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);vO===null?vO=aO(n).setGroup(fE).setName(`cameraProjectionMatricesInverse`):vO.array=n,t=vO.element(e.isMultiViewCamera?oO(`gl_ViewID_OVR`):TO)}else _O===null&&(_O=mE(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(fE).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=_O;return t}).once()(),AO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);bO===null?bO=aO(n).setGroup(fE).setName(`cameraViewMatrices`):bO.array=n,t=bO.element(e.isMultiViewCamera?oO(`gl_ViewID_OVR`):TO)}else yO===null&&(yO=mE(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(fE).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=yO;return t}).once()(),jO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorld);SO===null?SO=aO(n).setGroup(fE).setName(`cameraWorldMatrices`):SO.array=n,t=SO.element(e.isMultiViewCamera?oO(`gl_ViewID_OVR`):TO)}else xO===null&&(xO=mE(e.matrixWorld).setName(`cameraWorldMatrix`).setGroup(fE).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=xO;return t}).once()(),MO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t=0,r=e.cameras.length;t<r;t++)n.push(new U);wO===null?wO=aO(n).setGroup(fE).setName(`cameraPositions`).onRenderUpdate(({camera:e},t)=>{let n=e.cameras,r=t.array;for(let e=0,t=n.length;e<t;e++)r[e].setFromMatrixPosition(n[e].matrixWorld)}):wO.array=n,t=wO.element(e.isMultiViewCamera?oO(`gl_ViewID_OVR`):TO)}else CO===null&&(CO=mE(new U).setName(`cameraPosition`).setGroup(fE).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=CO;return t}).once()(),NO=new gl,PO=class e extends Nw{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Ow.OBJECT,this.uniformNode=new pE(null)}generateNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new U,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new U,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new U,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new U,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),NO.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=NO.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};PO.WORLD_MATRIX=`worldMatrix`,PO.POSITION=`position`,PO.SCALE=`scale`,PO.VIEW_POSITION=`viewPosition`,PO.DIRECTION=`direction`,PO.RADIUS=`radius`;var FO=class extends PO{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};FO.DIRECTION;var IO=G(FO,FO.WORLD_MATRIX);FO.POSITION,FO.SCALE,FO.VIEW_POSITION,FO.RADIUS;var LO=mE(new xs).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),RO=K(e=>e.context.modelViewMatrix||zO).once()().toVar(`modelViewMatrix`),zO=AO.mul(IO),BO=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,mE(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),VO=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return mE(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),HO=K(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(Bo("TSL: `clipSpace` is only available in fragment stage."),TT())).once()(),UO=XD(`position`,`vec3`),WO=UO.toVarying(`positionLocal`),GO=UO.toVarying(`positionPrevious`),KO=K(e=>IO.mul(WO).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),qO=K(()=>WO.transformDirection(IO).toVarying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),`vec3`).once([`POSITION`])(),JO=K(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=kO.mul(HO);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),YO=K(e=>{let t;return t=e.camera.isOrthographicCamera?J(0,0,1):JO.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),XO=q(G(class extends Nw{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}})).mul(2).sub(1),ZO=K(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(XO)),e}),QO=XD(`normal`,`vec3`),$O=K(e=>e.geometry.hasAttribute(`normal`)===!1?(B(`TSL: Vertex attribute "normal" not found on geometry.`),J(0,1,0)):QO,`vec3`).once()().toVar(`normalLocal`),ek=JO.dFdx().cross(JO.dFdy()).normalize().toVar(`normalFlat`),tk=K(e=>{let t;return t=e.isFlatShading()?ek:sk($O).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),nk=K(e=>{let t=tk.transformNormalByInverseViewMatrix(AO);return e.isFlatShading()!==!0&&(t=t.toVarying(`v_normalWorldGeometry`)),t.normalize().toVar(`normalWorldGeometry`)},`vec3`).once()(),rk=K(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=tk,e.isFlatShading()!==!0&&(t=ZO(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),ik=rk.transformNormalByInverseViewMatrix(AO).toVar(`normalWorld`),ak=K(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?rk:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),ok=K(([e,t=IO])=>kT(t).inverse().transpose().mul(e).normalize());W(`transformNormal`,ok);var sk=K(([e],t)=>{let n=t.context.modelNormalViewMatrix;return n?e.transformNormalByViewMatrix(n):LO.mul(e).transformNormalByViewMatrix(AO)});K(()=>(B(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),rk)).once([`NORMAL`,`VERTEX`])(),K(()=>(B(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),ik)).once([`NORMAL`,`VERTEX`])(),K(()=>(B(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),ak)).once([`NORMAL`,`VERTEX`])();var ck=new Hs,lk=mE(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),uk=mE(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),dk=mE(new Hs).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=(t.environment!==null||t.environmentNode&&t.environmentNode.isNode)&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?ck.makeRotationFromEuler(n).transpose():ck.identity(),ck}),fk=YO.negate().reflect(rk),pk=YO.negate().refract(rk,lk),mk=fk.transformDirection(jO).toVar(`reflectVector`),hk=pk.transformDirection(jO).toVar(`refractVector`),gk=new wu,_k=dT(class extends eO{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?mk:e.mapping===302?hk:(V(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),J(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?J(t.x,t.y.negate(),t.z):t:(t=dk.mul(t),(e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=J(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),vk=(e=gk,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=sT(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=sT(t)),n!==null&&(i.levelNode=sT(n)),r!==null&&(i.biasNode=sT(r))):i=_k(e,t,n,r),i},yk=class extends Pw{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(e),r=this.getNodeType(e);return e.format(t,n,r)}},bk=class extends Nw{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Ow.OBJECT}element(e){return new yk(this,sT(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;this.count===null?Array.isArray(this.getValueFromReference())?(t=aO(null,e),t.updateType=Ow.OBJECT):t=e===`texture`?tO(null):e===`cubeTexture`?vk(null):mE(null,e):t=iO(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},xk=(e,t,n)=>new bk(e,t,n),Sk=(e,t,n,r)=>new bk(e,t,r,n),Ck=class extends bk{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},wk=(e,t,n=null)=>new Ck(e,t,n),Tk=ZD(),Ek=JO.dFdx(),Dk=JO.dFdy(),Ok=Tk.dFdx(),kk=Tk.dFdy(),Ak=rk,jk=Dk.cross(Ak),Mk=Ak.cross(Ek),Nk=jk.mul(Ok.x).add(Mk.mul(kk.x)),Pk=jk.mul(Ok.y).add(Mk.mul(kk.y)),Fk=Nk.dot(Nk).max(Pk.dot(Pk)),Ik=Fk.equal(0).select(0,Fk.inverseSqrt()),Fae=Nk.mul(Ik).toVar(`tangentViewFrame`),Iae=Pk.mul(Ik).toVar(`bitangentViewFrame`),Lk=XD(`tangent`,`vec4`),Rk=Lk.xyz.toVar(`tangentLocal`),zk=K(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?RO.mul(TT(Rk,0)).xyz.toVarying(`v_tangentView`).normalize():Fae,e.isFlatShading()!==!0&&(t=ZO(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),Lae=K(([e,t],n)=>{let r=e.mul(Lk.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),Bk=kT(zk,K(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?Lae(rk.cross(zk),`v_bitangentView`).normalize():Iae,e.isFlatShading()!==!0&&(t=ZO(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),rk).toVar(`TBNViewMatrix`),Rae=K(()=>{let e=YT.cross(YO);return e=e.cross(YT).normalize(),e=ZE(e,rk,qT.mul(LT.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),zae=e=>sT(e).mul(.5).add(.5),Vk=e=>J(e,DE($E(q(1).sub(GE(e,e))))),Hk=dT(class extends Iw{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=Vk(i.xy):r===`ga`?i=Vk(i.yw):r!==``&&V(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&V(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=ZO(t)),i=J(i.xy.mul(t),i.z)}let a=null;return t===1?a=sk(i):t===0?a=Bk.mul(i).normalize():(V(`NodeMaterial: Unsupported normal map type: ${t}`),a=rk),a}}).setParameterLength(1,2),Bae=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||ZD()),forceUVContext:!0}),r=q(n(e=>e));return bT(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Vae=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(XO),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),Hae=dT(class extends Iw{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return rk;let t=this.scaleNode===null?1:this.scaleNode;return Vae({surf_pos:JO,surf_norm:rk,dHdxy:Bae({textureNode:this.textureNode,bumpScale:t})})}}).setParameterLength(1,2),Uk=new Map,X=class e extends Nw{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Uk.get(e);return n===void 0&&(n=wk(e,t),Uk.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?J():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=Hk(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?Hae(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):rk;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?Hk(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):rk;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY){if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=OT(eA.x,eA.y,eA.y.negate(),eA.x).mul(e.rg.mul(2).sub(bT(1)).normalize().mul(e.b))}else i=eA}else if(r===e.IRIDESCENCE_THICKNESS){let e=xk(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=xk(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=n.lightMap?this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`)):J(0);else if(r===e.AO)i=n.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1):q(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};X.ALPHA_TEST=`alphaTest`,X.COLOR=`color`,X.OPACITY=`opacity`,X.SHININESS=`shininess`,X.SPECULAR=`specular`,X.SPECULAR_STRENGTH=`specularStrength`,X.SPECULAR_INTENSITY=`specularIntensity`,X.SPECULAR_COLOR=`specularColor`,X.REFLECTIVITY=`reflectivity`,X.ROUGHNESS=`roughness`,X.METALNESS=`metalness`,X.NORMAL=`normal`,X.CLEARCOAT=`clearcoat`,X.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,X.CLEARCOAT_NORMAL=`clearcoatNormal`,X.EMISSIVE=`emissive`,X.ROTATION=`rotation`,X.SHEEN=`sheen`,X.SHEEN_ROUGHNESS=`sheenRoughness`,X.ANISOTROPY=`anisotropy`,X.IRIDESCENCE=`iridescence`,X.IRIDESCENCE_IOR=`iridescenceIOR`,X.IRIDESCENCE_THICKNESS=`iridescenceThickness`,X.IOR=`ior`,X.TRANSMISSION=`transmission`,X.THICKNESS=`thickness`,X.ATTENUATION_DISTANCE=`attenuationDistance`,X.ATTENUATION_COLOR=`attenuationColor`,X.LINE_SCALE=`scale`,X.LINE_DASH_SIZE=`dashSize`,X.LINE_GAP_SIZE=`gapSize`,X.LINE_WIDTH=`linewidth`,X.LINE_DASH_OFFSET=`dashOffset`,X.POINT_SIZE=`size`,X.DISPERSION=`dispersion`,X.LIGHT_MAP=`light`,X.AO=`ao`;var Uae=G(X,X.ALPHA_TEST),Wae=G(X,X.COLOR),Gae=G(X,X.SHININESS),Kae=G(X,X.EMISSIVE),Wk=G(X,X.OPACITY),qae=G(X,X.SPECULAR),Gk=G(X,X.SPECULAR_INTENSITY),Jae=G(X,X.SPECULAR_COLOR),Kk=G(X,X.SPECULAR_STRENGTH),qk=G(X,X.REFLECTIVITY),Yae=G(X,X.ROUGHNESS),Xae=G(X,X.METALNESS),Zae=G(X,X.NORMAL),Qae=G(X,X.CLEARCOAT),$ae=G(X,X.CLEARCOAT_ROUGHNESS),eoe=G(X,X.CLEARCOAT_NORMAL),toe=G(X,X.ROTATION),noe=G(X,X.SHEEN),roe=G(X,X.SHEEN_ROUGHNESS),ioe=G(X,X.ANISOTROPY),aoe=G(X,X.IRIDESCENCE),ooe=G(X,X.IRIDESCENCE_IOR),soe=G(X,X.IRIDESCENCE_THICKNESS),coe=G(X,X.TRANSMISSION),loe=G(X,X.THICKNESS),uoe=G(X,X.IOR),doe=G(X,X.ATTENUATION_DISTANCE),foe=G(X,X.ATTENUATION_COLOR),Jk=G(X,X.LINE_SCALE),Yk=G(X,X.LINE_DASH_SIZE),Xk=G(X,X.LINE_GAP_SIZE),Zk=G(X,X.LINE_WIDTH),Qk=G(X,X.LINE_DASH_OFFSET),poe=G(X,X.POINT_SIZE),moe=G(X,X.DISPERSION),$k=G(X,X.LIGHT_MAP),hoe=G(X,X.AO),eA=mE(new H).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),goe=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),tA=class e extends Nw{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=Ow.OBJECT:t===e.MATERIAL?this.updateType=Ow.RENDER:t===e.FRAME?this.updateType=Ow.FRAME:t===e.BEFORE_OBJECT?this.updateBeforeType=Ow.OBJECT:t===e.BEFORE_MATERIAL?this.updateBeforeType=Ow.RENDER:t===e.BEFORE_FRAME&&(this.updateBeforeType=Ow.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};tA.OBJECT=`object`,tA.MATERIAL=`material`,tA.FRAME=`frame`,tA.BEFORE_OBJECT=`beforeObject`,tA.BEFORE_MATERIAL=`beforeMaterial`,tA.BEFORE_FRAME=`beforeFrame`;var nA=(e,t)=>new tA(e,t).toStack(),rA=e=>nA(tA.OBJECT,e),_oe=e=>nA(tA.FRAME,e),voe=dT(class extends Pw{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.isContextAssign();if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),yoe=class extends rO{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStructTypeNode?(r=`struct`,i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=Cw(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=kw.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return voe(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(kw.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=TD(this.value),this._varying=uD(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},iA=(e,t=null,n=0)=>new yoe(e,t,n),aA=new WeakMap,oA=new WeakMap,sA=new WeakMap;function cA(e,t){let n,r=Math.max(t.count,1);if(t.isStorageInstancedBufferAttribute===!0)n=iA(t,`mat4`,r).element(AD);else if(r*16*4<=e.getUniformBufferLimit())n=iO(t.array,`mat4`,r).element(AD);else{let e=aA.get(t);e||(e=new Bf(t.array,16,1),aA.set(t,e));let r=t.usage===35048?DD:ED;n=AT(r(e,`vec4`,16,0),r(e,`vec4`,16,4),r(e,`vec4`,16,8),r(e,`vec4`,16,12))}return n}function boe(e,t,n){let r=sA.get(e);if(r===void 0){let i=t.clone();r={previousInstanceMatrix:i,node:cA(n,i)},sA.set(e,r)}return r.node}var lA=NT(`vec3`,`vInstanceColor`),xoe=K(([e,t=null],n)=>{let r=e.isStorageInstancedBufferAttribute===!0,i=t&&t.isStorageInstancedBufferAttribute===!0,a=cA(n,e),o=null;r||Math.max(e.count,1)*16*4>n.getUniformBufferLimit()&&(o=aA.get(e));let s=null,c=null;if(t){if(i)s=iA(t,`vec3`,Math.max(t.count,1)).element(AD);else{let e=oA.get(t);e||(e=new tu(t.array,3),oA.set(t,e)),c=e,s=J((t.usage===35048?DD:ED)(e,`vec3`,3,0))}}(o!==null||c!==null)&&_oe(()=>{o!==null&&(o.clearUpdateRanges(),o.updateRanges.push(...e.updateRanges),e.version!==o.version&&(o.version=e.version)),t&&c!==null&&(c.clearUpdateRanges(),c.updateRanges.push(...t.updateRanges),t.version!==c.version&&(c.version=t.version))});let l=a.mul(WO).xyz;if(WO.assign(l),n.needsPreviousData()){let t=n.object;rA(({object:t})=>{sA.get(t).previousInstanceMatrix.array.set(e.array)});let r=boe(t,e,n);GO.assign(r.mul(GO).xyz)}if(n.hasGeometryAttribute(`normal`)){let e=ok($O,a);$O.assign(e)}s!==null&&lA.assign(s)},`void`),Soe=K(([e])=>{let{instanceMatrix:t,instanceColor:n}=e;xoe(t,n)},`void`),Coe=K(([e,t])=>{let n=_T(QD(nO(e),0).x).toConst(),r=_T(t);return nO(e,xT(r.mod(n).toConst(),r.div(n).toConst()))}),woe=K(([e,t])=>{let n=_T(QD(nO(e),0).x).toConst();return nO(e,xT(_T(t).mod(n).toConst(),_T(t).div(n).toConst())).x}),uA=NT(`vec4`,`vBatchColor`),Toe=K(([e],t)=>{let n=t.getDrawIndex()===null?AD:jD,r=woe(e._indirectTexture,_T(n)),i=e._matricesTexture,a=_T(QD(nO(i),0).x).toConst(),o=q(r).mul(4).toInt().toConst(),s=o.mod(a).toConst(),c=o.div(a).toConst(),l=AT(nO(i,xT(s,c)),nO(i,xT(s.add(1),c)),nO(i,xT(s.add(2),c)),nO(i,xT(s.add(3),c))),u=e._colorsTexture;if(u!==null){let e=Coe(u,r);uA.assign(e)}let d=kT(l);WO.assign(l.mul(WO));let f=$O.div(J(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(f).xyz;$O.assign(p),t.hasGeometryAttribute(`tangent`)&&Rk.mulAssign(d)},`void`),dA=new WeakMap,fA=new WeakMap;function pA(e,t,n,r,i,a){let o=e.element(i.x),s=e.element(i.y),c=e.element(i.z),l=e.element(i.w),u=n.mul(t),d=_E(o.mul(a.x).mul(u),s.mul(a.y).mul(u),c.mul(a.z).mul(u),l.mul(a.w).mul(u));return r.mul(d).xyz}function Eoe(e,t,n,r,i,a,o){let s=e.element(a.x),c=e.element(a.y),l=e.element(a.z),u=e.element(a.w),d=_E(o.x.mul(s),o.y.mul(c),o.z.mul(l),o.w.mul(u));return d=i.mul(d).mul(r),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}function Doe(e,t,n,r,i){let a=e.skeleton,o=fA.get(a);if(o===void 0){a.update();let e=new Float32Array(a.boneMatrices);o={previousBoneMatrices:e,node:iO(e,`mat4`,a.bones.length)},fA.set(a,o)}return pA(o.node,GO,t,n,r,i)}var Ooe=K(([e],t)=>{let n=XD(`skinIndex`,`uvec4`),r=XD(`skinWeight`,`vec4`),i=xk(`bindMatrix`,`mat4`),a=xk(`bindMatrixInverse`,`mat4`),o=Sk(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length);if(rA(({object:e,frameId:t})=>{let n=e.skeleton;if(dA.get(n)!==t){dA.set(n,t);let e=fA.get(n);e!==void 0&&e.previousBoneMatrices.set(n.boneMatrices),n.update()}}),t.needsPreviousData()){let t=Doe(e,i,a,n,r);GO.assign(t)}let s=pA(o,WO,i,a,n,r);if(WO.assign(s),t.hasGeometryAttribute(`normal`)){let{skinNormal:e,skinTangent:s}=Eoe(o,$O,Rk,i,a,n,r);$O.assign(e),t.hasGeometryAttribute(`tangent`)&&Rk.assign(s)}},`void`),koe=class extends Nw{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e);n[r]=BD(r,t.isNode!==!0&&t.type||`int`)}let r=e.addStack(),i=this.params[this.params.length-1](n);t.returnsNode=i.context({nodeLoop:i}),t.stackNode=r;let a=this.params[0];if(a.isNode!==!0&&typeof a.update==`function`){let e=K(this.params[0].update)(n);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(V(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?`
|
|
4644
|
+
`,Ro(i)}return n}};W(`debug`,(e,t=null)=>new KD(cT(e),t).toStack());var qD=class extends Wo{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},JD=class extends Pw{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=kw.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==qD&&Bo(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function YD(e,t=``,n=null){return e=cT(e),e.before(new JD(e,t,n))}W(`toInspector`,YD);var XD=class extends Pw{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):dD(this).build(e,n)}return B(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},ZD=(e,t=null)=>new XD(e,t),QD=(e=0)=>ZD(`uv`+(e>0?e:``),`vec2`),$D=fT(class extends Pw{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),Oae=fT(class extends mE{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=kw.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),kae=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},eO=new Is,tO=class extends mE{static get type(){return`TextureNode`}constructor(e=eO,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=kw.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?`float`:`vec4`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return QD(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=hE(this.value.matrix)),this._matrixUniform.mul(J(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=hE(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(vT($D(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new kae("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=K(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||=this.getDefaultUV(),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?kw.OBJECT:kw.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null){if(e.renderer.hasCompatibility(Mo.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,Bo(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c,l,u){let d=this.value,f;return f=i?e.generateTextureBias(d,t,n,i,a,l):s?e.generateTextureGrad(d,t,n,s,a,l):c?o?e.generateTextureGatherCompare(d,t,n,o,a,l,u):e.generateTextureGather(d,t,n,c,a,l,u):o?e.generateTextureCompare(d,t,n,o,a,l):this.sampler===!1?e.generateTextureLoad(d,t,n,r,a,l):r?e.generateTextureLevel(d,t,n,r,a,l):e.generateTexture(d,t,n,a,l),f}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,gatherNode:m,offsetNode:h}=r,g=this.generateUV(e,t),_=c?c.build(e,`float`):null,v=l?l.build(e,`float`):null,y=f?f.build(e,`int`):null,b=u?u.build(e,`float`):null,x=d?d.build(e,`float`):null,S=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,C=m?m.build(e,`int`):null,w=h?this.generateOffset(e,h):null,T=this._flipYUniform?this._flipYUniform.build(e,`bool`):null;C&&(o=`vec4`);let E=y;E===null&&n.isArrayTexture&&this.isTexture3DNode!==!0&&(E=`0`);let D=e.getVarFromNode(this);s=e.getPropertyName(D);let O=this.generateSnippet(e,i,g,_,v,E,b,S,C,w,T);if(x!==null){let t=n.compareFunction;O=t===516||t===518?GE(VD(O,o),VD(x,`float`)).build(e,o):GE(VD(x,`float`),VD(O,o)).build(e,o)}e.addLineFlowCode(`${s} = ${O}`,this),a.snippet=O,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=gD(VD(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=cT(e),t.referenceNode=this.getBase(),cT(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=cT(e).mul(Oae(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(B(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),cT(t)}level(e){let t=this.clone();return t.levelNode=cT(e),t.referenceNode=this.getBase(),cT(t)}size(e){return $D(this,e)}bias(e){let t=this.clone();return t.biasNode=cT(e),t.referenceNode=this.getBase(),cT(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=cT(e),t.referenceNode=this.getBase(),cT(t)}grad(e,t){let n=this.clone();return n.gradNode=[cT(e),cT(t)],n.referenceNode=this.getBase(),cT(n)}gather(e=0){let t=this.clone();return t.gatherNode=cT(e),t.referenceNode=this.getBase(),cT(t)}depth(e){let t=this.clone();return t.depthNode=cT(e),t.referenceNode=this.getBase(),cT(t)}offset(e){let t=this.clone();return t.offsetNode=cT(e),t.referenceNode=this.getBase(),cT(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},Aae=fT(tO).setParameterLength(1,4).setName(`texture`),nO=(e=eO,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=cT(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=cT(t)),n!==null&&(i.levelNode=cT(n)),r!==null&&(i.biasNode=cT(r))):i=Aae(e,t,n,r),i},rO=(...e)=>nO(...e).setSampler(!1),iO=class extends mE{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},aO=(e,t,n)=>new iO(e,t,n),jae=class extends Fw{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(e),r=this.node.getPaddedType();return e.format(t,r,n)}},Mae=class extends iO{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Tw(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=kw.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,this.update(),super.setup(e)}element(e){return new jae(this,cT(e))}},oO=(e,t)=>new Mae(e,t),sO=fT(class extends Pw{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),cO,lO,uO=class e extends Pw{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=kw.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=kw.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(lO),lO.multiplyScalar(t.getPixelRatio())):lO.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(cO):(cO.width=n.width,cO.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?hE(cO||=new H):t===e.VIEWPORT?hE(lO||=new Ls):t===e.DPR?hE(1):xT(mO.div(pO)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(pO).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};uO.COORDINATE=`coordinate`,uO.VIEWPORT=`viewport`,uO.SIZE=`size`,uO.UV=`uv`,uO.DPR=`dpr`;var dO=G(uO,uO.DPR),fO=G(uO,uO.UV),pO=G(uO,uO.SIZE),mO=G(uO,uO.COORDINATE),hO=G(uO,uO.VIEWPORT),Nae=hO.zw;hO.xy;var gO=null,_O=null,vO=null,yO=null,bO=null,xO=null,SO=null,CO=null,wO=null,TO=null,EO=hE(0,`uint`).setName(`u_cameraIndex`).setGroup(fE(`cameraIndex`)).toVarying(`v_cameraIndex`),DO=hE(`float`).setName(`cameraNear`).setGroup(pE).onRenderUpdate(({camera:e})=>e.near),OO=hE(`float`).setName(`cameraFar`).setGroup(pE).onRenderUpdate(({camera:e})=>e.far),kO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);_O===null?_O=oO(n).setGroup(pE).setName(`cameraProjectionMatrices`):_O.array=n,t=_O.element(e.isMultiViewCamera?sO(`gl_ViewID_OVR`):EO)}else gO===null&&(gO=hE(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(pE).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=gO;return t}).once()(),AO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);yO===null?yO=oO(n).setGroup(pE).setName(`cameraProjectionMatricesInverse`):yO.array=n,t=yO.element(e.isMultiViewCamera?sO(`gl_ViewID_OVR`):EO)}else vO===null&&(vO=hE(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(pE).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=vO;return t}).once()(),jO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);xO===null?xO=oO(n).setGroup(pE).setName(`cameraViewMatrices`):xO.array=n,t=xO.element(e.isMultiViewCamera?sO(`gl_ViewID_OVR`):EO)}else bO===null&&(bO=hE(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(pE).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=bO;return t}).once()(),MO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorld);CO===null?CO=oO(n).setGroup(pE).setName(`cameraWorldMatrices`):CO.array=n,t=CO.element(e.isMultiViewCamera?sO(`gl_ViewID_OVR`):EO)}else SO===null&&(SO=hE(e.matrixWorld).setName(`cameraWorldMatrix`).setGroup(pE).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=SO;return t}).once()(),NO=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t=0,r=e.cameras.length;t<r;t++)n.push(new U);TO===null?TO=oO(n).setGroup(pE).setName(`cameraPositions`).onRenderUpdate(({camera:e},t)=>{let n=e.cameras,r=t.array;for(let e=0,t=n.length;e<t;e++)r[e].setFromMatrixPosition(n[e].matrixWorld)}):TO.array=n,t=TO.element(e.isMultiViewCamera?sO(`gl_ViewID_OVR`):EO)}else wO===null&&(wO=hE(new U).setName(`cameraPosition`).setGroup(pE).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=wO;return t}).once()(),PO=new gl,FO=class e extends Pw{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=kw.OBJECT,this.uniformNode=new mE(null)}generateNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new U,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new U,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new U,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new U,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),PO.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=PO.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};FO.WORLD_MATRIX=`worldMatrix`,FO.POSITION=`position`,FO.SCALE=`scale`,FO.VIEW_POSITION=`viewPosition`,FO.DIRECTION=`direction`,FO.RADIUS=`radius`;var IO=class extends FO{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};IO.DIRECTION;var LO=G(IO,IO.WORLD_MATRIX);IO.POSITION,IO.SCALE,IO.VIEW_POSITION,IO.RADIUS;var RO=hE(new xs).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),zO=K(e=>e.context.modelViewMatrix||BO).once()().toVar(`modelViewMatrix`),BO=jO.mul(LO),VO=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,hE(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),HO=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return hE(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),UO=K(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(Bo("TSL: `clipSpace` is only available in fragment stage."),ET())).once()(),WO=ZD(`position`,`vec3`),GO=WO.toVarying(`positionLocal`),KO=WO.toVarying(`positionPrevious`),qO=K(e=>LO.mul(GO).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),JO=K(()=>GO.transformDirection(LO).toVarying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),`vec3`).once([`POSITION`])(),YO=K(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=AO.mul(UO);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),XO=K(e=>{let t;return t=e.camera.isOrthographicCamera?J(0,0,1):YO.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),ZO=q(G(class extends Pw{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}})).mul(2).sub(1),QO=K(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(ZO)),e}),$O=ZD(`normal`,`vec3`),ek=K(e=>e.geometry.hasAttribute(`normal`)===!1?(B(`TSL: Vertex attribute "normal" not found on geometry.`),J(0,1,0)):$O,`vec3`).once()().toVar(`normalLocal`),tk=YO.dFdx().cross(YO.dFdy()).normalize().toVar(`normalFlat`),nk=K(e=>{let t;return t=e.isFlatShading()?tk:ck(ek).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),rk=K(e=>{let t=nk.transformNormalByInverseViewMatrix(jO);return e.isFlatShading()!==!0&&(t=t.toVarying(`v_normalWorldGeometry`)),t.normalize().toVar(`normalWorldGeometry`)},`vec3`).once()(),ik=K(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=nk,e.isFlatShading()!==!0&&(t=QO(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),ak=ik.transformNormalByInverseViewMatrix(jO).toVar(`normalWorld`),ok=K(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?ik:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),sk=K(([e,t=LO])=>AT(t).inverse().transpose().mul(e).normalize());W(`transformNormal`,sk);var ck=K(([e],t)=>{let n=t.context.modelNormalViewMatrix;return n?e.transformNormalByViewMatrix(n):RO.mul(e).transformNormalByViewMatrix(jO)});K(()=>(B(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),ik)).once([`NORMAL`,`VERTEX`])(),K(()=>(B(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),ak)).once([`NORMAL`,`VERTEX`])(),K(()=>(B(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),ok)).once([`NORMAL`,`VERTEX`])();var lk=new Hs,uk=hE(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),dk=hE(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),fk=hE(new Hs).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=(t.environment!==null||t.environmentNode&&t.environmentNode.isNode)&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?lk.makeRotationFromEuler(n).transpose():lk.identity(),lk}),pk=XO.negate().reflect(ik),mk=XO.negate().refract(ik,uk),hk=pk.transformDirection(MO).toVar(`reflectVector`),gk=mk.transformDirection(MO).toVar(`refractVector`),_k=new wu,vk=fT(class extends tO{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?hk:e.mapping===302?gk:(V(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),J(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?J(t.x,t.y.negate(),t.z):t:(t=fk.mul(t),(e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=J(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),yk=(e=_k,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=cT(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=cT(t)),n!==null&&(i.levelNode=cT(n)),r!==null&&(i.biasNode=cT(r))):i=vk(e,t,n,r),i},bk=class extends Fw{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(e),r=this.getNodeType(e);return e.format(t,n,r)}},xk=class extends Pw{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=kw.OBJECT}element(e){return new bk(this,cT(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return B(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;this.count===null?Array.isArray(this.getValueFromReference())?(t=oO(null,e),t.updateType=kw.OBJECT):t=e===`texture`?nO(null):e===`cubeTexture`?yk(null):hE(null,e):t=aO(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},Sk=(e,t,n)=>new xk(e,t,n),Ck=(e,t,n,r)=>new xk(e,t,r,n),wk=class extends xk{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},Tk=(e,t,n=null)=>new wk(e,t,n),Ek=QD(),Dk=YO.dFdx(),Ok=YO.dFdy(),kk=Ek.dFdx(),Ak=Ek.dFdy(),jk=ik,Mk=Ok.cross(jk),Nk=jk.cross(Dk),Pk=Mk.mul(kk.x).add(Nk.mul(Ak.x)),Fk=Mk.mul(kk.y).add(Nk.mul(Ak.y)),Ik=Pk.dot(Pk).max(Fk.dot(Fk)),Lk=Ik.equal(0).select(0,Ik.inverseSqrt()),Pae=Pk.mul(Lk).toVar(`tangentViewFrame`),Fae=Fk.mul(Lk).toVar(`bitangentViewFrame`),Rk=ZD(`tangent`,`vec4`),zk=Rk.xyz.toVar(`tangentLocal`),Bk=K(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?zO.mul(ET(zk,0)).xyz.toVarying(`v_tangentView`).normalize():Pae,e.isFlatShading()!==!0&&(t=QO(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),Iae=K(([e,t],n)=>{let r=e.mul(Rk.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),Vk=AT(Bk,K(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?Iae(ik.cross(Bk),`v_bitangentView`).normalize():Fae,e.isFlatShading()!==!0&&(t=QO(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),ik).toVar(`TBNViewMatrix`),Lae=K(()=>{let e=XT.cross(XO);return e=e.cross(XT).normalize(),e=QE(e,ik,JT.mul(RT.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Rae=e=>cT(e).mul(.5).add(.5),Hk=e=>J(e,OE(eD(q(1).sub(KE(e,e))))),Uk=fT(class extends Lw{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=Hk(i.xy):r===`ga`?i=Hk(i.yw):r!==``&&V(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&V(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=QO(t)),i=J(i.xy.mul(t),i.z)}let a=null;return t===1?a=ck(i):t===0?a=Vk.mul(i).normalize():(V(`NodeMaterial: Unsupported normal map type: ${t}`),a=ik),a}}).setParameterLength(1,2),zae=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||QD()),forceUVContext:!0}),r=q(n(e=>e));return xT(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Bae=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(ZO),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),Vae=fT(class extends Lw{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return ik;let t=this.scaleNode===null?1:this.scaleNode;return Bae({surf_pos:YO,surf_norm:ik,dHdxy:zae({textureNode:this.textureNode,bumpScale:t})})}}).setParameterLength(1,2),Wk=new Map,X=class e extends Pw{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Wk.get(e);return n===void 0&&(n=Tk(e,t),Wk.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?J():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=Uk(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?Vae(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):ik;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?Uk(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):ik;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY){if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=kT(tA.x,tA.y,tA.y.negate(),tA.x).mul(e.rg.mul(2).sub(xT(1)).normalize().mul(e.b))}else i=tA}else if(r===e.IRIDESCENCE_THICKNESS){let e=Sk(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=Sk(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=n.lightMap?this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`)):J(0);else if(r===e.AO)i=n.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1):q(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};X.ALPHA_TEST=`alphaTest`,X.COLOR=`color`,X.OPACITY=`opacity`,X.SHININESS=`shininess`,X.SPECULAR=`specular`,X.SPECULAR_STRENGTH=`specularStrength`,X.SPECULAR_INTENSITY=`specularIntensity`,X.SPECULAR_COLOR=`specularColor`,X.REFLECTIVITY=`reflectivity`,X.ROUGHNESS=`roughness`,X.METALNESS=`metalness`,X.NORMAL=`normal`,X.CLEARCOAT=`clearcoat`,X.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,X.CLEARCOAT_NORMAL=`clearcoatNormal`,X.EMISSIVE=`emissive`,X.ROTATION=`rotation`,X.SHEEN=`sheen`,X.SHEEN_ROUGHNESS=`sheenRoughness`,X.ANISOTROPY=`anisotropy`,X.IRIDESCENCE=`iridescence`,X.IRIDESCENCE_IOR=`iridescenceIOR`,X.IRIDESCENCE_THICKNESS=`iridescenceThickness`,X.IOR=`ior`,X.TRANSMISSION=`transmission`,X.THICKNESS=`thickness`,X.ATTENUATION_DISTANCE=`attenuationDistance`,X.ATTENUATION_COLOR=`attenuationColor`,X.LINE_SCALE=`scale`,X.LINE_DASH_SIZE=`dashSize`,X.LINE_GAP_SIZE=`gapSize`,X.LINE_WIDTH=`linewidth`,X.LINE_DASH_OFFSET=`dashOffset`,X.POINT_SIZE=`size`,X.DISPERSION=`dispersion`,X.LIGHT_MAP=`light`,X.AO=`ao`;var Hae=G(X,X.ALPHA_TEST),Uae=G(X,X.COLOR),Wae=G(X,X.SHININESS),Gae=G(X,X.EMISSIVE),Gk=G(X,X.OPACITY),Kae=G(X,X.SPECULAR),Kk=G(X,X.SPECULAR_INTENSITY),qae=G(X,X.SPECULAR_COLOR),qk=G(X,X.SPECULAR_STRENGTH),Jk=G(X,X.REFLECTIVITY),Jae=G(X,X.ROUGHNESS),Yae=G(X,X.METALNESS),Xae=G(X,X.NORMAL),Zae=G(X,X.CLEARCOAT),Qae=G(X,X.CLEARCOAT_ROUGHNESS),$ae=G(X,X.CLEARCOAT_NORMAL),eoe=G(X,X.ROTATION),toe=G(X,X.SHEEN),noe=G(X,X.SHEEN_ROUGHNESS),roe=G(X,X.ANISOTROPY),ioe=G(X,X.IRIDESCENCE),aoe=G(X,X.IRIDESCENCE_IOR),ooe=G(X,X.IRIDESCENCE_THICKNESS),soe=G(X,X.TRANSMISSION),coe=G(X,X.THICKNESS),loe=G(X,X.IOR),uoe=G(X,X.ATTENUATION_DISTANCE),doe=G(X,X.ATTENUATION_COLOR),Yk=G(X,X.LINE_SCALE),Xk=G(X,X.LINE_DASH_SIZE),Zk=G(X,X.LINE_GAP_SIZE),Qk=G(X,X.LINE_WIDTH),$k=G(X,X.LINE_DASH_OFFSET),foe=G(X,X.POINT_SIZE),poe=G(X,X.DISPERSION),eA=G(X,X.LIGHT_MAP),moe=G(X,X.AO),tA=hE(new H).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),hoe=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),nA=class e extends Pw{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=kw.OBJECT:t===e.MATERIAL?this.updateType=kw.RENDER:t===e.FRAME?this.updateType=kw.FRAME:t===e.BEFORE_OBJECT?this.updateBeforeType=kw.OBJECT:t===e.BEFORE_MATERIAL?this.updateBeforeType=kw.RENDER:t===e.BEFORE_FRAME&&(this.updateBeforeType=kw.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};nA.OBJECT=`object`,nA.MATERIAL=`material`,nA.FRAME=`frame`,nA.BEFORE_OBJECT=`beforeObject`,nA.BEFORE_MATERIAL=`beforeMaterial`,nA.BEFORE_FRAME=`beforeFrame`;var rA=(e,t)=>new nA(e,t).toStack(),iA=e=>rA(nA.OBJECT,e),goe=e=>rA(nA.FRAME,e),_oe=fT(class extends Fw{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.isContextAssign();if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),voe=class extends iO{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStructTypeNode?(r=`struct`,i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=ww(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Aw.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return _oe(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Aw.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=ED(this.value),this._varying=dD(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},aA=(e,t=null,n=0)=>new voe(e,t,n),oA=new WeakMap,sA=new WeakMap,cA=new WeakMap;function lA(e,t){let n,r=Math.max(t.count,1);if(t.isStorageInstancedBufferAttribute===!0)n=aA(t,`mat4`,r).element(jD);else if(r*16*4<=e.getUniformBufferLimit())n=aO(t.array,`mat4`,r).element(jD);else{let e=oA.get(t);e||(e=new Bf(t.array,16,1),oA.set(t,e));let r=t.usage===35048?OD:DD;n=jT(r(e,`vec4`,16,0),r(e,`vec4`,16,4),r(e,`vec4`,16,8),r(e,`vec4`,16,12))}return n}function yoe(e,t,n){let r=cA.get(e);if(r===void 0){let i=t.clone();r={previousInstanceMatrix:i,node:lA(n,i)},cA.set(e,r)}return r.node}var uA=PT(`vec3`,`vInstanceColor`),boe=K(([e,t=null],n)=>{let r=e.isStorageInstancedBufferAttribute===!0,i=t&&t.isStorageInstancedBufferAttribute===!0,a=lA(n,e),o=null;r||Math.max(e.count,1)*16*4>n.getUniformBufferLimit()&&(o=oA.get(e));let s=null,c=null;if(t){if(i)s=aA(t,`vec3`,Math.max(t.count,1)).element(jD);else{let e=sA.get(t);e||(e=new tu(t.array,3),sA.set(t,e)),c=e,s=J((t.usage===35048?OD:DD)(e,`vec3`,3,0))}}(o!==null||c!==null)&&goe(()=>{o!==null&&(o.clearUpdateRanges(),o.updateRanges.push(...e.updateRanges),e.version!==o.version&&(o.version=e.version)),t&&c!==null&&(c.clearUpdateRanges(),c.updateRanges.push(...t.updateRanges),t.version!==c.version&&(c.version=t.version))});let l=a.mul(GO).xyz;if(GO.assign(l),n.needsPreviousData()){let t=n.object;iA(({object:t})=>{cA.get(t).previousInstanceMatrix.array.set(e.array)});let r=yoe(t,e,n);KO.assign(r.mul(KO).xyz)}if(n.hasGeometryAttribute(`normal`)){let e=sk(ek,a);ek.assign(e)}s!==null&&uA.assign(s)},`void`),xoe=K(([e])=>{let{instanceMatrix:t,instanceColor:n}=e;boe(t,n)},`void`),Soe=K(([e,t])=>{let n=vT($D(rO(e),0).x).toConst(),r=vT(t);return rO(e,ST(r.mod(n).toConst(),r.div(n).toConst()))}),Coe=K(([e,t])=>{let n=vT($D(rO(e),0).x).toConst();return rO(e,ST(vT(t).mod(n).toConst(),vT(t).div(n).toConst())).x}),dA=PT(`vec4`,`vBatchColor`),woe=K(([e],t)=>{let n=t.getDrawIndex()===null?jD:MD,r=Coe(e._indirectTexture,vT(n)),i=e._matricesTexture,a=vT($D(rO(i),0).x).toConst(),o=q(r).mul(4).toInt().toConst(),s=o.mod(a).toConst(),c=o.div(a).toConst(),l=jT(rO(i,ST(s,c)),rO(i,ST(s.add(1),c)),rO(i,ST(s.add(2),c)),rO(i,ST(s.add(3),c))),u=e._colorsTexture;if(u!==null){let e=Soe(u,r);dA.assign(e)}let d=AT(l);GO.assign(l.mul(GO));let f=ek.div(J(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(f).xyz;ek.assign(p),t.hasGeometryAttribute(`tangent`)&&zk.mulAssign(d)},`void`),fA=new WeakMap,pA=new WeakMap;function mA(e,t,n,r,i,a){let o=e.element(i.x),s=e.element(i.y),c=e.element(i.z),l=e.element(i.w),u=n.mul(t),d=vE(o.mul(a.x).mul(u),s.mul(a.y).mul(u),c.mul(a.z).mul(u),l.mul(a.w).mul(u));return r.mul(d).xyz}function Toe(e,t,n,r,i,a,o){let s=e.element(a.x),c=e.element(a.y),l=e.element(a.z),u=e.element(a.w),d=vE(o.x.mul(s),o.y.mul(c),o.z.mul(l),o.w.mul(u));return d=i.mul(d).mul(r),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}function Eoe(e,t,n,r,i){let a=e.skeleton,o=pA.get(a);if(o===void 0){a.update();let e=new Float32Array(a.boneMatrices);o={previousBoneMatrices:e,node:aO(e,`mat4`,a.bones.length)},pA.set(a,o)}return mA(o.node,KO,t,n,r,i)}var Doe=K(([e],t)=>{let n=ZD(`skinIndex`,`uvec4`),r=ZD(`skinWeight`,`vec4`),i=Sk(`bindMatrix`,`mat4`),a=Sk(`bindMatrixInverse`,`mat4`),o=Ck(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length);if(iA(({object:e,frameId:t})=>{let n=e.skeleton;if(fA.get(n)!==t){fA.set(n,t);let e=pA.get(n);e!==void 0&&e.previousBoneMatrices.set(n.boneMatrices),n.update()}}),t.needsPreviousData()){let t=Eoe(e,i,a,n,r);KO.assign(t)}let s=mA(o,GO,i,a,n,r);if(GO.assign(s),t.hasGeometryAttribute(`normal`)){let{skinNormal:e,skinTangent:s}=Toe(o,ek,zk,i,a,n,r);ek.assign(e),t.hasGeometryAttribute(`tangent`)&&zk.assign(s)}},`void`),Ooe=class extends Pw{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e);n[r]=VD(r,t.isNode!==!0&&t.type||`int`)}let r=e.addStack(),i=this.params[this.params.length-1](n);t.returnsNode=i.context({nodeLoop:i}),t.stackNode=r;let a=this.params[0];if(a.isNode!==!0&&typeof a.update==`function`){let e=K(this.params[0].update)(n);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(V(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?`
|
|
4645
4645
|
`:``)+e.tab+f+` {
|
|
4646
4646
|
|
|
4647
4647
|
`).addFlowTab()}let i=r.build(e,`void`);t.returnsNode.build(e,`void`),e.removeFlowTab().addFlowCode(`
|
|
4648
4648
|
`+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
|
|
4649
4649
|
|
|
4650
|
-
`).removeFlowTab();e.addFlowTab()}},mA=(...e)=>new koe(uT(e,`int`)).toStack(),Aoe=()=>BD(`break`).toStack(),hA=new WeakMap,gA=new Ls,_A=new WeakMap,vA=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=_T(kD).mul(n).add(a),s=o.div(r);return nO(e,xT(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function joe(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=hA.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new Bs(p,u,d,a);m.type=sa,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(gA.fromBufferAttribute(a,e),p[f+i+0]=gA.x,p[f+i+1]=gA.y,p[f+i+2]=gA.z,p[f+i+3]=0),n===!0&&(gA.fromBufferAttribute(o,e),p[f+i+4]=gA.x,p[f+i+5]=gA.y,p[f+i+6]=gA.z,p[f+i+7]=0),r===!0&&(gA.fromBufferAttribute(l,e),p[f+i+8]=gA.x,p[f+i+9]=gA.y,p[f+i+10]=gA.z,p[f+i+11]=l.itemSize===4?gA.w:1)}}o={count:a,texture:m,stride:l,size:new H(u,d)},hA.set(e,o);function g(){m.dispose(),hA.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var Moe=K(([e])=>{let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length;if(a===0)return;let o=_A.get(e);(o===void 0||o.count!==a)&&(o={base:mE(1),influences:e.morphTargetInfluences?aO(e.morphTargetInfluences,`float`):null,count:a},_A.set(e,o));let{base:s,influences:c}=o,{texture:l,stride:u,size:d}=joe(t);n===!0&&WO.mulAssign(s),r===!0&&$O.mulAssign(s);let f=_T(d.width);mA(a,({i:t})=>{let i=q(0).toVar();e.count>1&&e.morphTexture!==null&&e.morphTexture!==void 0?i.assign(nO(e.morphTexture,xT(_T(t).add(1),_T(AD))).r):i.assign(c.element(t).toVar()),hT(i.notEqual(0),()=>{n===!0&&WO.addAssign(vA({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:_T(0)})),r===!0&&$O.addAssign(vA({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:_T(1)}))})}),rA(({object:e})=>{let{base:t,influences:n}=o;t.value=e.geometry.morphTargetsRelative?1:1-e.morphTargetInfluences.reduce((e,t)=>e+t,0),n&&(n.array=e.morphTargetInfluences,n.update())})},`void`),yA=class extends Nw{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},Noe=class extends yA{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},Poe=dT(class extends rD{static get type(){return`LightingContextNode`}constructor(e,t=null,n=[],r=null,i=null){super(e),this.lightingModel=t,this.materialLightings=n,this.backdropNode=r,this.backdropAlphaNode=i,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:n}=this,r={directDiffuse:J().toVar(`directDiffuse`),directSpecular:J().toVar(`directSpecular`),indirectDiffuse:J().toVar(`indirectDiffuse`),indirectSpecular:J().toVar(`indirectSpecular`)};return{radiance:J().toVar(`radiance`),irradiance:J().toVar(`irradiance`),iblIrradiance:J().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:r,materialLightings:e,backdrop:t,backdropAlpha:n}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),Foe=class extends yA{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},bA=new H,xA=class extends eO{static get type(){return`ViewportTextureNode`}constructor(e=dO,t=null,n=null){let r=null;n===null?(r=new Cu,r.minFilter=ea,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=Ow.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;i===null?t.getDrawingBufferSize(bA):i.getDrawingBufferSize?i.getDrawingBufferSize(bA):bA.set(i.width,i.height);let a=this.getTextureForReference(i);(a.image.width!==bA.width||a.image.height!==bA.height)&&(a.image.width=bA.width,a.image.height=bA.height,a.needsUpdate=!0);let o=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=o}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},SA=dT(xA,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Ioe=SA(),Loe=(e=dO,t=null)=>Ioe.sample(e,t),CA=null,Roe=dT(class extends xA{static get type(){return`ViewportDepthTextureNode`}constructor(e=dO,t=null,n=null){n===null&&(CA===null&&(CA=new Tu),n=CA),super(e,t,n)}}).setParameterLength(0,3),wA=class e extends Nw{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=kA().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?EA(JO.z,EO,DO):TA(JO.z,EO,DO):n===e.LINEAR_DEPTH&&(i=r===null?TA(JO.z,EO,DO):t.isPerspectiveCamera?TA(DA(r,EO,DO),EO,DO):r),i}};wA.DEPTH_BASE=`depthBase`,wA.DEPTH=`depth`,wA.LINEAR_DEPTH=`linearDepth`;var TA=(e,t,n)=>e.add(t).div(t.sub(n)),zoe=K(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?n.sub(t).mul(e).sub(n):t.sub(n).mul(e).sub(t)),EA=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),Boe=(e,t,n)=>t.mul(e.add(n)).div(e.mul(t.sub(n))),DA=K(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),OA=(e,t,n)=>{t=t.max(1e-6).toVar();let r=EE(e.negate().div(t)),i=EE(n.div(t));return r.div(i)},kA=dT(wA,wA.DEPTH_BASE),AA=G(wA,wA.DEPTH);Roe(),AA.assign=e=>kA(e);var jA=class e extends Nw{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=aO(t).setGroup(fE);mA(a,({i:t})=>{let a=e.element(t);n.assign(JO.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(tD(r.negate(),r,n))})}let o=e.length;if(o>0){let t=aO(e).setGroup(fE),a=q(1).toVar(`intersectionClipOpacity`);mA(o,({i:e})=>{let i=t.element(e);n.assign(JO.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(tD(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}PT.a.mulAssign(i),PT.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=aO(t).setGroup(fE);mA(n,({i:t})=>{let n=e.element(t);JO.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=aO(e).setGroup(fE),n=yT(!0).toVar(`clipped`);mA(r,({i:e})=>{let r=t.element(e);n.assign(JO.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=aO(e).setGroup(fE),i=oO(t.getClipDistance());mA(n,({i:e})=>{let t=r.element(e),n=JO.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};jA.ALPHA_TO_COVERAGE=`alphaToCoverage`,jA.DEFAULT=`default`,jA.HARDWARE=`hardware`;var Voe=()=>new jA,Hoe=()=>new jA(jA.ALPHA_TO_COVERAGE),Uoe=()=>new jA(jA.HARDWARE),Woe=.05,MA=K(([e])=>jE(yE(1e4,ME(yE(17,e.x).add(yE(.1,e.y)))).mul(_E(.1,FE(ME(yE(13,e.y).add(e.x))))))),NA=K(([e])=>MA(bT(MA(e.xy),e.z))),Goe=K(([e])=>{let t=UE(LE(zE(e.xyz)),LE(BE(e.xyz))),n=q(1).div(q(Woe).mul(t)).toVar(`pixScale`),r=bT(wE(OE(EE(n))),wE(kE(EE(n)))),i=bT(NA(OE(r.x.mul(e.xyz))),NA(OE(r.y.mul(e.xyz)))),a=jE(EE(n)),o=_E(yE(a.oneMinus(),i.x),yE(a,i.y)),s=HE(a,a.oneMinus()),c=J(o.mul(o).div(yE(2,s).mul(vE(1,s))),o.sub(yE(.5,s)).div(vE(1,s)),vE(1,vE(1,o).mul(vE(1,o)).div(yE(2,s).mul(vE(1,s)))));return QE(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),Koe=class extends YD{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new Ls(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},qoe=(e=0)=>new Koe(e),PA=class extends kl{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(yw(t.slice(0,-4)),n.getCacheKey());return this.type+bw(e)}build(e){this.setup(e)}setupObserver(e){return new Lre(e)}setup(e){e.context.setupNormal=()=>lD(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=lD(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=TT(r,PT.a).max(0);a=this.setupOutput(e,i),eE.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&eE.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=t.convert(e.getOutputType())),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=Hoe():e.stack.addToStack(Voe())}return r}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(Uoe()),e.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?OA(JO.z,EO,DO):TA(JO.z,EO,DO))}r!==null&&AA.assign(r).toStack()}setupPositionView(){return RO.mul(WO).xyz}setupModelViewProjection(){return OO.mul(JO)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),goe}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&Moe(t),t.isSkinnedMesh===!0&&Ooe(t),this.displacementMap){let e=wk(`displacementMap`,`texture`),t=wk(`displacementScale`,`float`),n=wk(`displacementBias`,`float`);WO.addAssign($O.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&Toe(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&Soe(t),this.positionNode!==null&&WO.assign(lD(this.positionNode,`POSITION`,`vec3`)),WO}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&yT(this.maskNode).not().discard();let r=this.colorNode?TT(this.colorNode):Wae;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(qoe())),t.instanceColor&&(r=lA.mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=uA.mul(r)),PT.assign(r);let i=this.opacityNode?q(this.opacityNode):Wk;PT.a.assign(PT.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?Uae:q(this.alphaTestNode),this.alphaToCoverage===!0?(PT.a=tD(a,a.add(VE(PT.a)),PT.a),PT.a.lessThanEqual(0).discard()):PT.a.lessThanEqual(a).discard()),this.alphaHash===!0&&PT.a.lessThan(Goe(WO)).discard(),e.isOpaque()&&PT.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?J(0):PT.rgb}setupNormal(){return this.normalNode?J(this.normalNode):Zae}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?wk(`envMap`,`cubeTexture`):wk(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Foe($k)),t}setupMaterialLightings(e){let t=[];if(e.renderer.lighting.enabled===!1)return t;let n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);return r&&r.isLightingNode&&t.push(r),e.context.ambientOcclusion&&t.push(new Noe(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=hoe),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(lE.assign(t),e.context.ambientOcclusion=lE)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=this.lights===!0?this.setupMaterialLightings(e):[],s=a?this.lightsNode||e.lightsNode:null,c=this.setupOutgoingLight(e);return s&&(o.length>0||s.getScope().hasLights)?c=Poe(s,this.setupLightingModel(e)||null,o,n,r):n!==null&&(c=J(r===null?n:ZE(c,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(IT.assign(J(i||Kae)),c=c.add(IT)),c}setupFog(e,t){let n=e.fogNode;return n&&(eE.assign(t),t=TT(n.toVar())),t}setupPremultipliedAlpha(e,t){return VD(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=kl.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let n in t)if(t[n].set!==void 0&&e[n]!==void 0){let t=e[n];this[n]&&this[n].copy!==void 0?this[n].copy(t):this[n]=t}for(let t in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(t)&&this[t]!==void 0&&e[t]!==void 0){let n=e[t];this[t]&&this[t].copy!==void 0?this[t].copy(n):this[t]=n}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(e=>e.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},Joe=new fu,FA=class extends PA{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Joe),this.setValues(e)}},IA=new Od,LA=class extends PA{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(IA),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?q(this.offsetNode):Qk,t=this.dashScaleNode?q(this.dashScaleNode):Jk,n=this.dashSizeNode?q(this.dashSizeNode):Yk,r=this.gapSizeNode?q(this.gapSizeNode):Xk;tE.assign(n),nE.assign(r);let i=uD(XD(`lineDistance`).mul(t));(e?i.add(e):i).mod(tE.add(nE)).greaterThan(tE).discard()}},RA=NT(`vec3`,`worldStart`),zA=NT(`vec3`,`worldEnd`),BA=NT(`float`,`lineDistance`),VA=NT(`vec4`,`worldPos`),HA=K(({start:e,end:t})=>{let n=OO.element(2).element(2),r=OO.element(3).element(2);return n.greaterThan(0).select(r.negate().div(n.add(1)),r.mul(-.5).div(n)).sub(e.z).div(t.z.sub(e.z))},{start:`vec4`,end:`vec4`,return:`float`}),UA=K(({p1:e,p2:t,p3:n,p4:r})=>{let i=e.sub(n),a=r.sub(n),o=t.sub(e),s=i.dot(a),c=a.dot(o),l=i.dot(o),u=a.dot(a),d=o.dot(o).mul(u).sub(c.mul(c)),f=s.mul(c).sub(l.mul(u)).div(d).clamp();return bT(f,s.add(c.mul(f)).div(u).clamp())},{p1:`vec3`,p2:`vec3`,p3:`vec3`,p4:`vec3`,return:`vec2`});K(({material:e})=>{let t=e._useDash,n=e._useWorldUnits,r=XD(`instanceStart`),i=XD(`instanceEnd`),a=TT(RO.mul(TT(r,1))).toVar(`start`),o=TT(RO.mul(TT(i,1))).toVar(`end`),s,c;t&&(s=q(XD(`instanceDistanceStart`)).toVar(`distanceStart`),c=q(XD(`instanceDistanceEnd`)).toVar(`distanceEnd`)),n&&(RA.assign(a.xyz),zA.assign(o.xyz));let l=mO.z.div(mO.w);if(hT(OO.element(2).element(3).equal(-1),()=>{hT(a.z.lessThan(0).and(o.z.greaterThan(0)),()=>{let e=HA({start:a,end:o});o.assign(TT(ZE(a.xyz,o.xyz,e),o.w)),t&&c.assign(ZE(s,c,e))}).ElseIf(o.z.lessThan(0).and(a.z.greaterThanEqual(0)),()=>{let e=HA({start:o,end:a});a.assign(TT(ZE(o.xyz,a.xyz,e),a.w)),t&&s.assign(ZE(c,s,e))})}),t){let t=e.dashScaleNode?q(e.dashScaleNode):Jk,n=e.offsetNode?q(e.offsetNode):Qk,r=UO.y.lessThan(.5).select(t.mul(s),t.mul(c));r=r.add(n),BA.assign(r)}let u=OO.mul(a),d=OO.mul(o),f=u.xyz.div(u.w),p=d.xyz.div(d.w),m=p.xy.sub(f.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());let h=TT().toVar();if(n){let e=o.xyz.sub(a.xyz).normalize(),n=ZE(a.xyz,o.xyz,.5).normalize(),r=e.cross(n).normalize(),i=e.cross(r);VA.assign(UO.y.lessThan(.5).select(a,o));let s=Zk.mul(.5);VA.addAssign(TT(UO.x.lessThan(0).select(r.mul(s),r.mul(s).negate()),0)),t||(VA.addAssign(TT(UO.y.lessThan(.5).select(e.mul(s).negate(),e.mul(s)),0)),VA.addAssign(TT(i.mul(s),0)),hT(UO.y.greaterThan(1).or(UO.y.lessThan(0)),()=>{VA.subAssign(TT(i.mul(2).mul(s),0))})),h.assign(OO.mul(VA));let c=J().toVar();c.assign(UO.y.lessThan(.5).select(f,p)),h.z.assign(c.z.mul(h.w))}else{let e=bT(m.y,m.x.negate()).toVar(`offset`);m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(UO.x.lessThan(0).select(e.negate(),e)),hT(UO.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(UO.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(Zk)),e.assign(e.div(mO.w.div(uO))),h.assign(UO.y.lessThan(.5).select(u,d)),e.assign(e.mul(h.w)),h.assign(h.add(TT(e,0,0)))}return h})(),K(({material:e,renderer:t})=>{let n=e._useAlphaToCoverage,r=e._useDash,i=e._useWorldUnits,a=ZD();if(r){let t=e.dashSizeNode?q(e.dashSizeNode):Yk,n=e.gapSizeNode?q(e.gapSizeNode):Xk;tE.assign(t),nE.assign(n),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),BA.mod(tE.add(nE)).greaterThan(tE).discard()}let o=q(1).toVar(`alpha`);if(i){let e=VA.xyz.normalize().mul(1e5),i=zA.sub(RA),a=UA({p1:RA,p2:zA,p3:J(0,0,0),p4:e}),s=RA.add(i.mul(a.x)),c=e.mul(a.y),l=s.sub(c).length().div(Zk);if(!r){if(n&&t.currentSamples>0){let e=l.fwidth();o.assign(tD(e.negate().add(.5),e.add(.5),l).oneMinus())}else l.greaterThan(.5).discard()}}else if(n&&t.currentSamples>0){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),n=e.mul(e).add(t.mul(t)),r=q(n.fwidth()).toVar(`dlen`);hT(a.y.abs().greaterThan(1),()=>{o.assign(tD(r.oneMinus(),r.add(1),n).oneMinus())})}else hT(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return o})();var WA=new Cd,GA=class extends PA{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(WA),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?q(this.opacityNode):Wk;PT.assign(hD(TT(zae(rk),e),go))}},KA=K(([e=qO])=>bT(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),qA=K(([e=ZD()])=>{let t=e.x.sub(.5).mul(Math.PI*2),n=e.y.sub(.5).mul(Math.PI),r=n.cos();return J(r.mul(t.cos()),n.sin(),r.mul(t.sin()))}),JA=class extends Rs{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new wu(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,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;let i=new Ou(5,5,5),a=KA(qO),o=new PA;o.colorNode=tO(t,a,0),o.side=1,o.blending=0;let s=new Zl(i,o),c=new Tc;c.add(s),t.minFilter===1008&&(t.minFilter=Qi);let l=new wf(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.generateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},YA=new WeakMap,XA=class extends Iw{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=vk(null);let t=new wu;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Ow.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===303||n===304){if(YA.has(e)){let t=YA.get(e);$A(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(ZA(n)){let r=new JA(n.height);r.fromEquirectangularTexture(t,e),$A(r.texture,e.mapping),this._cubeTexture=r.texture,YA.set(e,r.texture),e.addEventListener(`dispose`,QA)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function ZA(e){return e!=null&&e.height>0}function QA(e){let t=e.target;t.removeEventListener(`dispose`,QA);let n=YA.get(t);n!==void 0&&(YA.delete(t),n.dispose())}function $A(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var ej=dT(XA).setParameterLength(1),tj=class extends yA{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=ej(this.envNode)}},nj=class extends yA{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=q(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},rj=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},ij=class extends rj{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(TT(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(TT(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(PT.rgb)}finish(e){let{material:t,context:n}=e,r=n.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case 0:r.rgb.assign(ZE(r.rgb,r.rgb.mul(i.rgb),Kk.mul(qk)));break;case 1:r.rgb.assign(ZE(r.rgb,i.rgb,Kk.mul(qk)));break;case 2:r.rgb.addAssign(i.rgb.mul(Kk.mul(qk)));break;default:B(`BasicLightingModel: Unsupported .combine value:`,t.combine)}}},aj=new zl,oj=class extends PA{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(aj),this.setValues(e)}setupNormal(){return ZO(tk)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tj(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new nj($k)),t}setupOutgoingLight(){return PT.rgb}setupLightingModel(){return new ij}},sj=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),cj=K(e=>e.diffuseColor.mul(1/Math.PI)),lj=()=>q(.25),uj=K(({dotNH:e})=>$T.mul(q(.5)).add(1).mul(q(1/Math.PI)).mul(e.pow($T))),dj=K(({lightDirection:e})=>{let t=e.add(YO).normalize(),n=rk.dot(t).clamp(),r=sj({f0:XT,f90:1,dotVH:YO.dot(t).clamp()}),i=lj(),a=uj({dotNH:n});return r.mul(i).mul(a)}),fj=class extends ij{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=rk.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(cj({diffuseColor:PT.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(dj({lightDirection:e})).mul(Kk))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(cj({diffuseColor:PT}))),r.indirectDiffuse.mulAssign(t)}},pj=new wd,mj=class extends PA{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(pj),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tj(t):null}setupLightingModel(){return new fj(!1)}},hj=new xd,gj=class extends PA{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(hj),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tj(t):null}setupLightingModel(){return new fj}setupVariants(){let e=(this.shininessNode?q(this.shininessNode):Gae).max(1e-4);$T.assign(e);let t=this.specularNode||qae;XT.assign(t)}},_j=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=tk.dFdx().abs().max(tk.dFdy().abs());return t.x.max(t.y).max(t.z)}),vj=K(e=>{let{roughness:t}=e,n=_j(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),yj=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return bE(.5,i.add(a).max(SE))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),bj=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(J(e.mul(n),t.mul(r),o).length()),l=o.mul(J(e.mul(i),t.mul(a),s).length());return bE(.5,c.add(l).max(SE))}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),xj=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Sj=q(1/Math.PI),Cj=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=J(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Sj.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),wj=K(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,normalView:a=rk,USE_IRIDESCENCE:o,USE_ANISOTROPY:s})=>{let c=r.pow2(),l=e.add(YO).normalize(),u=a.dot(e).clamp(),d=a.dot(YO).clamp(),f=a.dot(l).clamp(),p=sj({f0:t,f90:n,dotVH:YO.dot(l).clamp()}),m,h;if(aT(o)&&(p=UT.mix(p,i)),aT(s)){let t=JT.dot(e),n=JT.dot(YO),r=JT.dot(l),i=YT.dot(e),a=YT.dot(YO),o=YT.dot(l);m=bj({alphaT:KT,alphaB:c,dotTV:n,dotBV:a,dotTL:t,dotBL:i,dotNV:d,dotNL:u}),h=Cj({alphaT:KT,alphaB:c,dotNH:f,dotTH:r,dotBH:o})}else m=yj({alpha:c,dotNL:u,dotNV:d}),h=xj({alpha:c,dotNH:f});return p.mul(m).mul(h)}),Tj=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Ej=null,Dj=K(({roughness:e,dotNV:t})=>{Ej===null&&(Ej=new eu(Tj,16,16,xa,ca),Ej.name=`DFG_LUT`,Ej.minFilter=Qi,Ej.magFilter=Qi,Ej.wrapS=qi,Ej.wrapT=qi,Ej.generateMipmaps=!1,Ej.needsUpdate=!0);let n=bT(e,t);return tO(Ej,n).rg}),Oj=K(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let s=wj({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}),c=rk.dot(e).clamp(),l=Dj({roughness:r,dotNV:rk.dot(YO).clamp()}),u=Dj({roughness:r,dotNV:c}),d=t.mul(l.x).add(n.mul(l.y)),f=t.mul(u.x).add(n.mul(u.y)),p=l.x.add(l.y),m=u.x.add(u.y),h=q(1).sub(p),g=q(1).sub(m),_=t.add(t.oneMinus().mul(.047619)),v=d.mul(f).mul(_).div(q(1).sub(h.mul(g).mul(_).mul(_)).add(SE)),y=h.mul(g),b=v.mul(y);return s.add(b)}),kj=K(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=Dj({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),Aj=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(J(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),jj=K(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=q(1).div(n),i=t.pow2().oneMinus().max(.0078125);return q(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),Mj=K(({dotNV:e,dotNL:t})=>q(1).div(q(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),Nj=K(({lightDirection:e})=>{let t=e.add(YO).normalize(),n=rk.dot(e).clamp(),r=rk.dot(YO).clamp(),i=jj({roughness:HT,dotNH:rk.dot(t).clamp()}),a=Mj({dotNV:r,dotNL:n});return VT.mul(i).mul(a)}),Pj=K(({N:e,V:t,roughness:n})=>{let r=bT(n,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),Fj=K(({f:e})=>{let t=e.length();return UE(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),Ij=K(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,UE(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),Lj=K(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=J().toVar();return hT(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(kT(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=J(0).toVar();g.addAssign(Ij({v1:f,v2:p})),g.addAssign(Ij({v1:p,v2:m})),g.addAssign(Ij({v1:m,v2:h})),g.addAssign(Ij({v1:h,v2:f})),d.assign(J(Fj({f:g})))}),d}).setLayout({name:`LTC_Evaluate`,type:`vec3`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`P`,type:`vec3`},{name:`mInv`,type:`mat3`},{name:`p0`,type:`vec3`},{name:`p1`,type:`vec3`},{name:`p2`,type:`vec3`},{name:`p3`,type:`vec3`}]}),Rj=1/6,zj=e=>yE(Rj,yE(e,yE(e,e.negate().add(3)).sub(3)).add(1)),Bj=e=>yE(Rj,yE(e,yE(e,yE(3,e).sub(6))).add(4)),Vj=e=>yE(Rj,yE(e,yE(e,yE(-3,e).add(3)).add(3)).add(1)),Hj=e=>yE(Rj,qE(e,3)),Uj=e=>zj(e).add(Bj(e)),Wj=e=>Vj(e).add(Hj(e)),Gj=e=>_E(-1,Bj(e).div(zj(e).add(Bj(e)))),Kj=e=>_E(1,Hj(e).div(Vj(e).add(Hj(e)))),qj=(e,t,n)=>{let r=e.uvNode,i=yE(r,t.zw).add(.5),a=OE(i),o=jE(i),s=Uj(o.x),c=Wj(o.x),l=Gj(o.x),u=Kj(o.x),d=Gj(o.y),f=Kj(o.y),p=bT(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=bT(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=bT(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=bT(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=Uj(o.y).mul(_E(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=Wj(o.y).mul(_E(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Jj=K(([e,t])=>{let n=bT(e.size(_T(t))),r=bT(e.size(_T(t.add(1)))),i=bE(1,n),a=bE(1,r),o=qj(e,TT(i,n),OE(t)),s=qj(e,TT(a,r),kE(t));return jE(t).mix(o,s)}),Yj=K(([e,t,n,r,i])=>{let a=J(eD(t.negate(),AE(e),bE(1,r))),o=J(LE(i[0].xyz),LE(i[1].xyz),LE(i[2].xyz));return AE(a).mul(n.mul(o))}).setLayout({name:`getVolumeTransmissionRay`,type:`vec3`,inputs:[{name:`n`,type:`vec3`},{name:`v`,type:`vec3`},{name:`thickness`,type:`float`},{name:`ior`,type:`float`},{name:`modelMatrix`,type:`mat4`}]}),Xj=K(([e,t])=>e.mul(QE(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),Zj=SA(),Qj=Loe(),$j=K(([e,t,n],{material:r})=>Jj((r.side===1?Zj:Qj).sample(e),EE(fO.x).mul(Xj(t,n)))),eM=K(([e,t,n])=>(hT(n.notEqual(0),()=>CE(TE(t).negate().div(n).negate().mul(e))),J(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),tM=K(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=TT().toVar(),g=J().toVar();let i=u.sub(1).mul(m.mul(.025)),a=J(u.sub(i),u,u.add(i));mA({start:0,end:3},({i})=>{let u=a.element(i),m=Yj(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(TT(_,1))),y=bT(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(bT(y.x,y.y.oneMinus()));let b=$j(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(eM(LE(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Yj(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(TT(a,1))),_=bT(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(bT(_.x,_.y.oneMinus())),h=$j(_,n,u),g=r.mul(eM(LE(i),f,p))}let _=g.rgb.mul(h.rgb),v=J(kj({dotNV:e.dot(t).clamp(),specularColor:i,specularF90:a,roughness:n})),y=g.r.add(g.g,g.b).div(3);return TT(v.oneMinus().mul(_),h.a.oneMinus().mul(y).oneMinus())}),nM=kT(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),rM=e=>{let t=e.sqrt();return J(1).add(t).div(J(1).sub(t))},iM=(e,t)=>e.sub(t).div(e.add(t)).pow2(),aM=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=J(54856e-17,44201e-17,52481e-17),i=J(1681e3,1795300,2208400),a=J(43278e5,93046e5,66121e5),o=q(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());return s=J(s.x.add(o),s.y,s.z).div(1.0685e-7),nM.mul(s)},oM=K(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=ZE(e,t,tD(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()).oneMinus();hT(o.lessThan(0),()=>J(1));let s=o.sqrt(),c=sj({f0:iM(a,e),f90:1,dotVH:n}),l=c.oneMinus(),u=a.lessThan(e).select(Math.PI,0),d=q(Math.PI).sub(u),f=rM(i.clamp(0,.9999)),p=sj({f0:iM(f,a.toVec3()),f90:1,dotVH:s}),m=J(f.x.lessThan(a).select(Math.PI,0),f.y.lessThan(a).select(Math.PI,0),f.z.lessThan(a).select(Math.PI,0)),h=a.mul(r,s,2),g=J(d).add(m),_=c.mul(p).clamp(1e-5,.9999),v=_.sqrt(),y=l.pow2().mul(p).div(J(1).sub(_)),b=c.add(y).toVar(),x=y.sub(l).toVar();return mA({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{x.mulAssign(v);let t=aM(q(e).mul(h),q(e).mul(g)).mul(2);b.addAssign(x.mul(t))}),b.max(J(0))}).setLayout({name:`evalIridescence`,type:`vec3`,inputs:[{name:`outsideIOR`,type:`float`},{name:`eta2`,type:`float`},{name:`cosTheta1`,type:`float`},{name:`thinFilmThickness`,type:`float`},{name:`baseF0`,type:`vec3`}]}),sM=K(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.mul(n),a=n.add(.1).reciprocal(),o=q(-1.9362).add(n.mul(1.0678)).add(i.mul(.4573)).sub(a.mul(.8469)),s=q(-.6014).add(n.mul(.5538)).sub(i.mul(.467)).sub(a.mul(.1255));return o.mul(r).add(s).exp().saturate()}),cM=J(.04),lM=q(1),uM=class extends rj{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=J().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=J().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=J().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=J().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=J().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=rk.dot(YO).clamp(),t=oM({outsideIOR:q(1),eta2:WT,cosTheta1:e,thinFilmThickness:GT,baseF0:XT}),n=oM({outsideIOR:q(1),eta2:WT,cosTheta1:e,thinFilmThickness:GT,baseF0:PT.rgb});this.iridescenceFresnel=ZE(t,n,RT),this.iridescenceF0Dielectric=Aj({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=Aj({f:n,f90:1,dotVH:e}),this.iridescenceF0=ZE(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,RT)}if(this.transmission===!0){let t=KO,n=MO.sub(KO).normalize(),r=ik,i=e.context;i.backdrop=tM(r,n,LT,FT,ZT,QT,t,IO,AO,OO,rE,aE,sE,oE,this.dispersion?cE:null),i.backdropAlpha=iE,PT.a.mulAssign(ZE(1,i.backdrop.a,iE))}super.start(e)}computeMultiscattering(e,t,n,r,i=null){let a=Dj({roughness:LT,dotNV:rk.dot(YO).clamp()}),o=i?UT.mix(r,i):r,s=o.mul(a.x).add(n.mul(a.y)),c=a.x.add(a.y).oneMinus(),l=o.add(o.oneMinus().mul(.047619)),u=s.mul(l).div(c.mul(l).oneMinus());e.addAssign(s),t.addAssign(u.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=rk.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(r.mul(Nj({lightDirection:e})));let t=sM({normal:rk,viewDir:YO,roughness:HT}),n=sM({normal:rk,viewDir:e,roughness:HT}),i=VT.r.max(VT.g).max(VT.b).mul(t.max(n)).oneMinus();r.mulAssign(i)}if(this.clearcoat===!0){let n=ak.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(wj({lightDirection:e,f0:cM,f90:lM,roughness:BT,normalView:ak})))}n.directDiffuse.addAssign(r.mul(cj({diffuseColor:FT}))),n.directSpecular.addAssign(r.mul(Oj({lightDirection:e,f0:ZT,f90:1,roughness:LT,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=rk,f=YO,p=JO.toVar(),m=Pj({N:d,V:f,roughness:LT}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=kT(J(h.x,0,h.y),J(0,1,0),J(h.z,0,h.w)).toVar(),v=ZT.mul(g.x).add(QT.sub(ZT).mul(g.y)).toVar();if(i.directSpecular.addAssign(e.mul(v).mul(Lj({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(FT).mul(Lj({N:d,V:f,P:p,mInv:kT(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u}))),this.clearcoat===!0){let t=ak,n=Pj({N:t,V:f,roughness:BT}),r=a.sample(n),i=o.sample(n),d=kT(J(r.x,0,r.y),J(0,1,0),J(r.z,0,r.w)),m=cM.mul(i.x).add(lM.sub(cM).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(Lj({N:t,V:f,P:p,mInv:d,p0:s,p1:c,p2:l,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context,r=t.mul(cj({diffuseColor:FT})).toVar();if(this.sheen===!0){let e=sM({normal:rk,viewDir:YO,roughness:HT}),t=VT.r.max(VT.g).max(VT.b).mul(e).oneMinus();r.mulAssign(t)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(VT,sM({normal:rk,viewDir:YO,roughness:HT}))),this.clearcoat===!0){let e=kj({dotNV:ak.dot(YO).clamp(),specularColor:cM,specularF90:lM,roughness:BT});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let i=J().toVar(`singleScatteringDielectric`),a=J().toVar(`multiScatteringDielectric`),o=J().toVar(`singleScatteringMetallic`),s=J().toVar(`multiScatteringMetallic`);this.computeMultiscattering(i,a,QT,XT,this.iridescenceF0Dielectric),this.computeMultiscattering(o,s,QT,PT.rgb,this.iridescenceF0Metallic);let c=ZE(i,o,RT),l=ZE(a,s,RT),u=i.add(a),d=FT.mul(u.oneMinus()),f=n.mul(1/Math.PI),p=t.mul(c).add(l.mul(f)).toVar(),m=d.mul(f).toVar();if(this.sheen===!0){let e=sM({normal:rk,viewDir:YO,roughness:HT}),t=VT.r.max(VT.g).max(VT.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,r=rk.dot(YO).clamp().add(t),i=LT.mul(-16).oneMinus().negate().exp2(),a=t.sub(r.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=sj({dotVH:ak.dot(YO).clamp(),f0:cM,f90:lM}),n=t.mul(zT.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(zT));t.assign(n)}if(this.sheen===!0){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}},dM=q(1),fM=q(-2),pM=q(.8),mM=q(-1),hM=q(.4),gM=q(2),_M=q(.305),vM=q(3),yM=q(.21),bM=q(4),xM=q(4),SM=q(16),CM=K(([e])=>{let t=J(FE(e)).toVar(),n=q(-1).toVar();return hT(t.x.greaterThan(t.z),()=>{hT(t.x.greaterThan(t.y),()=>{n.assign(nD(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(nD(e.y.greaterThan(0),1,4))})}).Else(()=>{hT(t.z.greaterThan(t.y),()=>{n.assign(nD(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(nD(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),wM=K(([e,t])=>{let n=bT().toVar();return hT(t.equal(0),()=>{n.assign(bT(e.z,e.y).div(FE(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(bT(e.x.negate(),e.z.negate()).div(FE(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(bT(e.x.negate(),e.y).div(FE(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(bT(e.z.negate(),e.y).div(FE(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(bT(e.x.negate(),e.z).div(FE(e.y)))}).Else(()=>{n.assign(bT(e.x,e.y).div(FE(e.z)))}),yE(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),TM=K(([e])=>{let t=q(0).toVar();return hT(e.greaterThanEqual(pM),()=>{t.assign(dM.sub(e).mul(mM.sub(fM)).div(dM.sub(pM)).add(fM))}).ElseIf(e.greaterThanEqual(hM),()=>{t.assign(pM.sub(e).mul(gM.sub(mM)).div(pM.sub(hM)).add(mM))}).ElseIf(e.greaterThanEqual(_M),()=>{t.assign(hM.sub(e).mul(vM.sub(gM)).div(hM.sub(_M)).add(gM))}).ElseIf(e.greaterThanEqual(yM),()=>{t.assign(_M.sub(e).mul(bM.sub(vM)).div(_M.sub(yM)).add(vM))}).Else(()=>{t.assign(q(-2).mul(EE(yE(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),EM=K(([e,t])=>{let n=e.toVar();n.assign(yE(2,n).sub(1));let r=J(n,1).toVar();return hT(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),DM=K(([e,t,n,r,i,a])=>{let o=q(n),s=J(t),c=QE(TM(o),fM,a),l=jE(c),u=OE(c),d=J(OM(e,s,u,r,i,a)).toVar();return hT(l.notEqual(0),()=>{let t=J(OM(e,s,u.add(1),r,i,a)).toVar();d.assign(ZE(d,t,l))}),d}),OM=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=J(t),c=q(CM(s)).toVar(),l=q(UE(xM.sub(o),0)).toVar();o.assign(UE(o,xM));let u=q(wE(o)).toVar(),d=bT(wM(s,c).mul(u.sub(2)).add(1)).toVar();return hT(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(yE(3,SM))),d.y.addAssign(yE(4,wE(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(bT(),bT())}),kM=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=NE(r);return OM(e,n.mul(c).add(i.cross(n).mul(ME(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),AM=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=J(nD(t,n,KE(n,r))).toVar();hT(f.equal(J(0)),()=>{f.assign(J(r.z,0,r.x.negate()))}),f.assign(AE(f));let p=J().toVar();return p.addAssign(i.element(0).mul(kM({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),mA({start:_T(1),end:e},({i:e})=>{hT(e.greaterThanEqual(a),()=>{Aoe()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(kM({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(kM({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),TT(p,1)}),jM=K(([e])=>{let t=vT(e).toVar();return t.assign(t.shiftLeft(vT(16)).bitOr(t.shiftRight(vT(16)))),t.assign(t.bitAnd(vT(1431655765)).shiftLeft(vT(1)).bitOr(t.bitAnd(vT(2863311530)).shiftRight(vT(1)))),t.assign(t.bitAnd(vT(858993459)).shiftLeft(vT(2)).bitOr(t.bitAnd(vT(3435973836)).shiftRight(vT(2)))),t.assign(t.bitAnd(vT(252645135)).shiftLeft(vT(4)).bitOr(t.bitAnd(vT(4042322160)).shiftRight(vT(4)))),t.assign(t.bitAnd(vT(16711935)).shiftLeft(vT(8)).bitOr(t.bitAnd(vT(4278255360)).shiftRight(vT(8)))),q(t).mul(23283064365386963e-26)}),MM=K(([e,t])=>bT(q(e).div(q(t)),jM(e))),NM=K(([e,t,n])=>{let r=n.mul(n).toConst(),i=J(1,0,0).toConst(),a=KE(t,i).toConst(),o=DE(e.x).toConst(),s=yE(2,3.14159265359).mul(e.y).toConst(),c=o.mul(NE(s)).toConst(),l=o.mul(ME(s)).toVar(),u=yE(.5,t.z.add(1)).toConst();l.assign(u.oneMinus().mul(DE(c.mul(c).oneMinus())).add(u.mul(l)));let d=i.mul(c).add(a.mul(l)).add(t.mul(DE(UE(0,c.mul(c).add(l.mul(l)).oneMinus()))));return AE(J(r.mul(d.x),r.mul(d.y),UE(0,d.z)))}),PM=K(({roughness:e,mipInt:t,envMap:n,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=J(r).toVar(),l=J(0).toVar(),u=q(0).toVar();return hT(e.lessThan(.001),()=>{l.assign(OM(n,c,t,a,o,s))}).Else(()=>{let r=AE(KE(nD(FE(c.z).lessThan(.999),J(0,0,1),J(1,0,0)),c)).toVar(),d=KE(c,r).toVar();mA({start:vT(0),end:i},({i:f})=>{let p=NM(MM(f,i),J(0,0,1),e),m=AE(r.mul(p.x).add(d.mul(p.y)).add(c.mul(p.z))),h=AE(m.mul(GE(c,m).mul(2)).sub(c)),g=UE(GE(c,h),0);hT(g.greaterThan(0),()=>{let e=OM(n,h,t,a,o,s);l.addAssign(e.mul(g)),u.addAssign(g)})}),hT(u.greaterThan(0),()=>{l.assign(l.div(u))})}),TT(l,1)}),FM=4,IM=[.125,.215,.35,.446,.526,.582],LM=20,RM=512,zM=new hf(-1,1,1,-1,0,1),BM=new uf(90,1),VM=new Cc,HM=null,UM=0,WM=0,GM=new U,KM=new WeakMap,qM=[3,1,5,0,4,2],JM=EM(ZD(),XD(`faceIndex`)).normalize(),YM=J(JM.x,JM.y,JM.z),XM=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=GM,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.`);HM=this._renderer.getRenderTarget(),UM=this._renderer.getActiveCubeFace(),WM=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget(!0);return this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return Bo(`PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return Bo(`PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return Bo(`PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=nN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=rN(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(HM,UM,WM),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),HM=this._renderer.getRenderTarget(),UM=this._renderer.getActiveCubeFace(),WM=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget(!1);return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(e){return QM(3*Math.max(this._cubeSize,112),4*this._cubeSize,e)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=QM(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=ZM(t)),this._blurMaterial=eN(t,e.width,e.height),this._ggxMaterial=tN(t,e.width,e.height)}}async _compileMaterial(e){let t=new Zl(new wl,e);await this._renderer.compile(t,zM)}_sceneToCubeUV(e,t,n,r,i){let a=BM;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(VM),c.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new Zl(new Ou,new zl({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,f=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,f=!0):(d.color.copy(VM),f=!0),c.setRenderTarget(r),c.clear(),f&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;this._setViewport(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=nN(e)):this._equirectMaterial===null&&(this._equirectMaterial=rN(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,zM)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;t<r;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let s=KM.get(a),c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l)*(0+c*1.25),{_lodMax:d}=this,f=this._sizeLods[n],p=3*f*(n>d-FM?n-d+FM:0),m=4*(this._cubeSize-f);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,this._setViewport(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,zM),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,this._setViewport(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,zM)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&V(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=KM.get(c),d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/39,p=i/f,m=isFinite(i)?1+Math.floor(3*p):LM;m>LM&&B(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${LM}`);let h=[],g=0;for(let e=0;e<LM;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=h,u.latitudinal.value=+(a===`latitudinal`),o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r],y=3*v*(r>_-FM?r-_+FM:0),b=4*(this._cubeSize-v);this._setViewport(t,y,b,3*v,2*v),s.setRenderTarget(t),s.render(l,zM)}_setViewport(e,t,n,r,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-n,r,i),e.scissor.set(t,e.height-i-n,r,i)):(e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i))}};function ZM(e){let t=[],n=[],r=[],i=e,a=e-FM+1+IM.length;for(let o=0;o<a;o++){let a=2**i;t.push(a);let s=1/a;o>e-FM?s=IM[o-e+FM-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=qM[e];f.set(r,18*i),p.set(d,12*i);let a=[i,i,i,i,i,i];m.set(a,6*i)}let h=new wl;h.setAttribute(`position`,new cl(f,3)),h.setAttribute(`uv`,new cl(p,2)),h.setAttribute(`faceIndex`,new cl(m,1)),r.push(new Zl(h,null)),i>FM&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function QM(e,t,n){let r=new Rs(e,t,{magFilter:Qi,minFilter:Qi,generateMipmaps:!1,type:ca,format:ga,colorSpace:_o,depthBuffer:n});return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function $M(e){let t=new PA;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function eN(e,t,n){let r=aO(Array(LM).fill(0)),i=mE(new U(0,1,0)),a=mE(0),o=q(LM),s=mE(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:YM,dTheta:a,samples:mE(1),envMap:tO(),mipInt:mE(0),CUBEUV_TEXEL_WIDTH:q(1/t),CUBEUV_TEXEL_HEIGHT:q(1/n),CUBEUV_MAX_MIP:q(e)},l=$M(`blur`);return l.fragmentNode=AM({...c,latitudinal:s.equal(1)}),KM.set(l,c),l}function tN(e,t,n){let r={envMap:tO(),roughness:mE(0),mipInt:mE(0),CUBEUV_TEXEL_WIDTH:q(1/t),CUBEUV_TEXEL_HEIGHT:q(1/n),CUBEUV_MAX_MIP:q(e)},i=$M(`ggx`);return i.fragmentNode=PM({...r,N_immutable:YM,GGX_SAMPLES:vT(RM)}),KM.set(i,r),i}function nN(e){let t=$M(`cubemap`);return t.fragmentNode=vk(e,YM),t}function rN(e){let t=$M(`equirect`);return t.fragmentNode=tO(e,KA(YM),0),t}var iN=new WeakMap;function aN(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:n,maxMip:t}}function oN(e,t,n){let r=sN(t),i=r.get(e);if((i===void 0?-1:i.pmremVersion)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture){if(lN(t))i=n.fromCubemap(e,i);else return null}else if(uN(t))i=n.fromEquirectangular(e,i);else return null;if(i.pmremVersion=e.pmremVersion,r.has(e)===!1){let t=()=>{e.removeEventListener(`dispose`,t);let n=r.get(e);n!==void 0&&(n.dispose(),r.delete(e))};e.addEventListener(`dispose`,t)}r.set(e,i)}return i.texture}function sN(e){let t=iN.get(e);return t===void 0&&(t=new WeakMap,iN.set(e,t)),t}var cN=class extends Iw{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new Is;r.isRenderTargetTexture=!0,this._texture=tO(r),this._width=mE(0),this._height=mE(0),this._maxMip=mE(0),this.updateBeforeType=Ow.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=aN(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0||r.mapping===306?r:oN(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new XM(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?dk.mul(J(t.x,t.y.negate(),t.z)):dk.mul(t);let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),DM(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function lN(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function uN(e){return e!=null&&e.height>0}var dN=dT(cN).setParameterLength(1,3),fN=new WeakMap,pN=class extends yA{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let r=n.isTextureNode?n.value:t[n.property],i=this._getPMREMNodeCache(e.renderer),a=i.get(r);a===void 0&&(a=dN(r),i.set(r,a)),n=a}let r=t.useAnisotropy===!0||t.anisotropy>0?Rae:rk,i=n.context(mN(LT,r)).mul(uk),a=n.context(hN(ik)).mul(Math.PI).mul(uk),o=FD(i),s=FD(a);e.context.radiance.addAssign(o),e.context.iblIrradiance.addAssign(s);let c=e.context.lightingModel.clearcoatRadiance;if(c){let e=FD(n.context(mN(BT,ak)).mul(uk));c.addAssign(e)}}_getPMREMNodeCache(e){let t=fN.get(e);return t===void 0&&(t=new WeakMap,fN.set(e,t)),t}},mN=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=YO.negate().reflect(t),n=YE(e).mix(n,t).normalize(),n=n.transformDirection(jO)),n),getTextureLevel:()=>e}},hN=e=>({getUV:()=>e,getTextureLevel:()=>q(1)}),gN=new yd,_N=class extends PA{static get type(){return`MeshStandardNodeMaterial`}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(gN),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new pN(t):null}setupLightingModel(){return new uM}setupSpecular(){let e=ZE(J(.04),PT.rgb,RT);XT.assign(J(.04)),ZT.assign(e),QT.assign(1)}setupVariants(){let e=this.metalnessNode?q(this.metalnessNode):Xae;RT.assign(e);let t=this.roughnessNode?q(this.roughnessNode):Yae;t=vj({roughness:t}),LT.assign(t),this.setupSpecular(),FT.assign(PT.rgb.mul(e.oneMinus()))}},vN=new bd,yN=class extends _N{static get type(){return`MeshPhysicalNodeMaterial`}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(vN),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?q(this.iorNode):uoe;rE.assign(e),XT.assign(HE(JE(rE.sub(1).div(rE.add(1))).mul(Jae),J(1)).mul(Gk)),ZT.assign(ZE(XT,PT.rgb,RT)),QT.assign(ZE(Gk,1,RT))}setupLightingModel(){return new uM(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?q(this.clearcoatNode):Qae,t=this.clearcoatRoughnessNode?q(this.clearcoatRoughnessNode):$ae;zT.assign(e),BT.assign(vj({roughness:t}))}if(this.useSheen){let e=this.sheenNode?J(this.sheenNode):noe,t=this.sheenRoughnessNode?q(this.sheenRoughnessNode):roe;VT.assign(e),HT.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?q(this.iridescenceNode):aoe,t=this.iridescenceIORNode?q(this.iridescenceIORNode):ooe,n=this.iridescenceThicknessNode?q(this.iridescenceThicknessNode):soe;UT.assign(e),WT.assign(t),GT.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?bT(this.anisotropyNode):ioe).toVar();qT.assign(e.length()),hT(qT.equal(0),()=>{e.assign(bT(1,0))}).Else(()=>{e.divAssign(bT(qT)),qT.assign(qT.saturate())}),KT.assign(qT.pow2().mix(LT.pow2(),1)),JT.assign(Bk[0].mul(e.x).add(Bk[1].mul(e.y))),YT.assign(Bk[1].mul(e.x).sub(Bk[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?q(this.transmissionNode):coe,t=this.thicknessNode?q(this.thicknessNode):loe,n=this.attenuationDistanceNode?q(this.attenuationDistanceNode):doe,r=this.attenuationColorNode?J(this.attenuationColorNode):foe;if(iE.assign(e),aE.assign(t),oE.assign(n),sE.assign(r),this.useDispersion){let e=this.dispersionNode?q(this.dispersionNode):moe;cE.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?J(this.clearcoatNormalNode):eoe}setup(e){e.context.setupClearcoatNormal=()=>lD(this.setupClearcoatNormal(e),`NORMAL`,`vec3`),super.setup(e)}},bN=K(({normal:e,lightDirection:t,builder:n})=>{let r=bT(e.dot(t).mul(.5).add(.5),0);if(n.material.gradientMap)return J(wk(`gradientMap`,`texture`).context({getUV:()=>r}).r);{let e=r.fwidth().mul(.5);return ZE(J(.7),J(1),tD(q(.7).sub(e.x),q(.7).add(e.x),r.x))}}),xN=class extends rj{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=bN({normal:QO,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(cj({diffuseColor:PT.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(cj({diffuseColor:PT}))),r.indirectDiffuse.mulAssign(t)}},SN=new Sd,CN=class extends PA{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(SN),this.setValues(e)}setupLightingModel(){return new xN}},wN=K(()=>{let e=J(YO.z,0,YO.x.negate()).normalize(),t=YO.cross(e);return bT(e.dot(rk),t.dot(rk)).mul(.495).add(.5)}).once([`NORMAL`,`VERTEX`])().toVar(`matcapUV`),TN=new Dd,EN=class extends PA{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(TN),this.setValues(e)}setupVariants(e){let t=wN,n;n=e.material.matcap?wk(`matcap`,`texture`).context({getUV:()=>t}):J(ZE(.2,.8,t.y)),PT.rgb.mulAssign(n.rgb)}},DN=dT(class extends Iw{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return OT(e,r,r.negate(),e).mul(n)}{let e=t,r=AT(TT(1,0,0,0),TT(0,NE(e.x),ME(e.x).negate(),0),TT(0,ME(e.x),NE(e.x),0),TT(0,0,0,1)),i=AT(TT(NE(e.y),0,ME(e.y),0),TT(0,1,0,0),TT(ME(e.y).negate(),0,NE(e.y),0),TT(0,0,0,1)),a=AT(TT(NE(e.z),ME(e.z).negate(),0,0),TT(ME(e.z),NE(e.z),0,0),TT(0,0,1,0),TT(0,0,0,1));return r.mul(i).mul(a).mul(TT(n,1)).xyz}}}).setParameterLength(2),ON=new Al,kN=class extends PA{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(ON),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,{positionNode:r,rotationNode:i,scaleNode:a,sizeAttenuation:o}=this,s=RO.mul(J(r||0)),c=bT(IO[0].xyz.length(),IO[1].xyz.length());a!==null&&(c=c.mul(bT(a))),n.isPerspectiveCamera&&o===!1&&(c=c.mul(s.z.negate()));let l=UO.xy;if(t.center&&t.center.isVector2===!0){let e=vD(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=q(i||toe),d=DN(l,u);return TT(s.xy.add(d),s.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},AN=new Su,jN=new H,MN=class extends kN{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(AN),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return RO.mul(J(e||WO)).xyz}setupVertexSprite(e){let{material:t,camera:n}=e,{rotationNode:r,scaleNode:i,sizeNode:a,sizeAttenuation:o}=this,s=super.setupVertex(e);if(t.isNodeMaterial!==!0)return s;let c=a===null?poe:bT(a);c=c.mul(uO),n.isPerspectiveCamera&&o===!0&&(c=c.mul(NN.div(JO.z.negate()))),i&&i.isNode&&(c=c.mul(bT(i)));let l=UO.xy;if(r&&r.isNode){let e=q(r);l=DN(l,e)}return l=l.mul(c),l=l.div(Pae.div(2)),l=l.mul(s.w),s=s.add(TT(l,0,0)),s}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},NN=mE(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(jN);this.value=.5*t.y}),PN=class extends rj{constructor(){super(),this.shadowNode=q(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){PT.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(PT.rgb)}},FN=new cd,IN=class extends PA{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(FN),this.setValues(e)}setupLightingModel(){return new PN}};MT(`vec3`),MT(`vec3`),MT(`vec3`);var LN=class{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<`u`?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},RN=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},zN=0,BN=new WeakMap;function VN(e){let t=Object.keys(e),n=BN.get(e.constructor);if(n===void 0){n=[];let t=Object.getPrototypeOf(e);for(;t;){let e=Object.getOwnPropertyDescriptors(t);for(let t in e){let r=e[t];r&&typeof r.get==`function`&&n.push(t)}t=Object.getPrototypeOf(t)}BN.set(e.constructor,n)}for(let e=0;e<n.length;e++)t.push(n[e]);return t}var HN=class{constructor(e,t,n,r,i,a,o,s,c,l){this.id=zN++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=i,this.scene=a,this.camera=o,this.lightsNode=s,this.context=c,this.geometry=r.geometry,this.version=i.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=l,this.clippingContextCacheKey=l===null?``:l.cacheKey,this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this._sourceMaterial=n._currentSourceMaterial,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener(`dispose`,this.onMaterialDispose),this.geometry.addEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener(`dispose`,this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set,i={};for(let a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:(e=t.getAttribute(a.name),e!==void 0&&(e.isInterleavedBufferAttribute?i[a.name]=e.data.uuid:i[a.name]=e.id)),e===void 0)continue;n.push(e);let o=e.isInterleavedBufferAttribute?e.data:e;r.add(o)}return this.attributes=n,this.attributesId=i,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},o=this.getIndex(),s=o!==null,c=1;if(n.isInstancedBufferGeometry===!0?c=n.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let u=i.start*l,d=(i.start+i.count)*l;r!==null&&(u=Math.max(u,r.start*l),d=Math.min(d,(r.start+r.count)*l));let f=n.attributes.position,p=1/0;s?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=u,a)}getGeometryCacheKey(){let{geometry:e}=this,t=``;for(let n of Object.keys(e.attributes).sort()){let r=e.attributes[n];t+=n+`,`,r.data&&(t+=r.data.stride+`,`),r.offset&&(t+=r.offset+`,`),r.itemSize&&(t+=r.itemSize+`,`),r.normalized&&(t+=`n,`)}for(let n of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[n];t+=`morph-`+n+`,`;for(let e=0,n=r.length;e<n;e++){let n=r[e];t+=n.id+`,`}}return e.index&&(t+=`index,`),t}getMaterialCacheKey(){let{object:e,material:t,renderer:n}=this,r=t.customProgramCacheKey();for(let e of VN(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let i=t[e],a;if(i!==null){let t=typeof i;t===`number`?a=e===`side`?String(i):i===0?`0`:`1`:t===`object`?(a=`{`,i.isTexture&&(a+=i.mapping,n.backend.isWebGPUBackend===!0&&(a+=i.magFilter,a+=i.minFilter,a+=i.wrapS,a+=i.wrapT,a+=i.wrapR)),a+=`}`):a=String(i)}else a=String(i);r+=a+`,`}return r+=this.clippingContextCacheKey+`,`,e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+`,`),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+`,`,e._colorsTexture!==null&&(r+=e._colorsTexture.uuid+`,`)),(e.isInstancedMesh||e.count>1)&&(r+=e.uuid+`,`),r+=this.context.id+`,`,r+=e.receiveShadow+`,`,yw(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let n=this.geometry.getAttribute(t);if(n===void 0)return!0;let r=n.isInterleavedBufferAttribute?n.data.uuid:n.id;if(e[t]!==r)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=xw(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=xw(e,1)),e=xw(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.geometry.removeEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener(`dispose`,this.onMaterialDispose),this.onDispose()}},UN=[],WN=class{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,o,s){let c=this.getChainMap(s);UN[0]=e,UN[1]=t,UN[2]=a,UN[3]=i;let l=c.get(UN);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(UN,l)):(l.camera=r,l.updateClipping(o),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey===l.getCacheKey()?l.version=t.version:(l.dispose(),l=this.get(e,t,n,r,i,a,o,s)))),UN[0]=null,UN[1]=null,UN[2]=null,UN[3]=null,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new RN)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new HN(e,t,n,r,i,a,o,s,c,l);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},GN=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},KN={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},qN=16,JN=211,YN=212,XN=class extends GN{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===KN.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===KN.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===KN.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===KN.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version<t.version||t.usage===35048)&&(this.backend.updateAttribute(e),n.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function ZN(e){return e.index===null?e.attributes.position.version:e.index.version}function QN(e){return e.index===null?e.attributes.position.id:e.index.id}function $N(e){let t=[],n=e.index,r=e.attributes.position;if(n!==null){let e=n.array;for(let n=0,r=e.length;n<r;n+=3){let r=e[n+0],i=e[n+1],a=e[n+2];t.push(r,i,i,a,a,r)}}else{let e=r.array;for(let n=0,r=e.length/3-1;n<r;n+=3){let e=n+0,r=n+1,i=n+2;t.push(e,r,r,i,i,e)}}let i=new(r.count>=65535?ul:ll)(t,1);return i.version=ZN(e),i.__id=QN(e),i}var eP=class extends GN{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(let e of i)this.attributes.delete(e);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener(`dispose`,r),this._geometryDisposeListeners.delete(t)};t.addEventListener(`dispose`,r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){let t=e.getAttributes();for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,KN.STORAGE):this.updateAttribute(e,KN.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,KN.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,KN.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:n}=e,r=t.index;if(n.wireframe===!0){let e=this.wireframes,n=e.get(t);n===void 0?(n=$N(t),e.set(t,n)):(n.version!==ZN(t)||n.__id!==QN(t))&&(this.attributes.delete(n),n=$N(t),e.set(t,n)),r=n}return r}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener(`dispose`,t);this._geometryDisposeListeners.clear()}},tP=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*n:e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=t/2*n:e.isLine?this.render.lines+=n*(t-1):V(`WebGPUInfo: Unknown object type.`)}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(let e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let n=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:n,type:t}),this.memory[t]++,this.memory.total+=n,this.memory[t+`Size`]+=n}createAttribute(e){this._createAttribute(e,`attributes`)}createIndexAttribute(e){this._createAttribute(e,`indexAttributes`)}createStorageAttribute(e){this._createAttribute(e,`storageAttributes`)}createIndirectStorageAttribute(e){this._createAttribute(e,`indirectStorageAttributes`)}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+`Size`]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:`readbackBuffers`}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:`uniformBuffers`}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===1010||e.type===1009?t=1:e.type===1011||e.type===1012||e.type===1016?t=2:(e.type===1013||e.type===1014||e.type===1015)&&(t=4);let n=4;e.format===1021||e.format===1028||e.format===1029||e.format===1026||e.format===1027?n=1:e.format===1030||e.format===1031?n=2:(e.format===1022||e.format===1032)&&(n=3);let r=t*n;e.type===1017||e.type===1018?r=2:(e.type===1020||e.type===35902||e.type===35899)&&(r=4);let i=e.width||1,a=e.height||1,o=e.isCubeTexture?6:e.depth||1,s=i*a*o*r,c=e.mipmaps;if(c&&c.length>0){let e=0;for(let t=0;t<c.length;t++){let n=c[t];if(n.data)e+=n.data.byteLength;else{let s=n.width||Math.max(1,i>>t),c=n.height||Math.max(1,a>>t);e+=s*c*o*r}}s+=e}else e.generateMipmaps&&(s*=1.333);return Math.round(s)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},nP=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},rP=class extends nP{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},iP=class extends nP{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},aP=0,oP=class{constructor(e,t,n,r=null,i=null){this.id=aP++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},sP=class extends GN{constructor(e,t,n){super(),this.backend=e,this.nodes=t,this.info=n,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);o===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),o=new oP(a.computeShader,`compute`,e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),n.createProgram(o),this.info.createProgram(o));let s=this._getComputeCacheKey(e,o),c=this.caches.get(s);c===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),c=this._getComputePipeline(e,o,s,t)),c.usedTimes++,o.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){let{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let a=e.getNodeBuilderState(),o=e.material?e.material.name:``,s=this.programs.vertex.get(a.vertexShader);s===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),s=new oP(a.vertexShader,`vertex`,o),this.programs.vertex.set(a.vertexShader,s),n.createProgram(s),this.info.createProgram(s));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),c=new oP(a.fragmentShader,`fragment`,o),this.programs.fragment.set(a.fragmentShader,c),n.createProgram(c),this.info.createProgram(c));let l=this._getRenderCacheKey(e,s,c),u=this.caches.get(l);u===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),u=this._getRenderPipeline(e,s,c,l,t)):e.pipeline=u,u.usedTimes++,s.usedTimes++,c.usedTimes++,r.pipeline=u}return r.pipeline}isReady(e){let t=this.get(e).pipeline;if(t===void 0)return!1;let n=this.backend.get(t);return n.pipeline!==void 0&&n.pipeline!==null}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n||=this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new iP(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r||=this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new rP(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+`,`+t.id}_getRenderCacheKey(e,t,n){return t.id+`,`+n.id+`,`+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},cP=class extends GN{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),n=this.get(e);return n.initialized!==!0&&(this._createBindings(t),n.initialized=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,n=this.get(e);return(n.initialized!==!0||n.bindings!==t)&&(n.bindings!==void 0&&this._destroyBindings(n.bindings),this._createBindings(t),n.initialized=!0,n.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){let t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let n=this.get(t);if(n.bindGroup===void 0){for(let e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e);else if(e.isStorageBuffer){let t=e.attribute,n=t.isIndirectStorageBufferAttribute?KN.INDIRECT:KN.STORAGE;this.attributes.update(t,n)}this.backend.createBindings(t,e,0),n.bindGroup=t,n.usedTimes=1}else n.usedTimes++}}_destroyBindings(e){for(let t of e){let e=this.get(t);if(e.usedTimes--,e.usedTimes===0){for(let e of t.bindings)e.isUniformBuffer?(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release()):e.isSampler&&(e.isSampledTexture!==!0&&this.backend.destroySampler(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:n}=this,r=!1,i=!0,a=0,o=0;for(let t of e.bindings)if(this.nodes.updateGroup(t)!==!1){if(t.isStorageBuffer){let e=t.attribute,i=e.isIndirectStorageBufferAttribute?KN.INDIRECT:KN.STORAGE,a=n.get(t);this.attributes.update(e,i),a.attribute!==e&&(a.attribute=e,r=!0)}if(t.isUniformBuffer)t.update()&&n.updateBinding(t);else if(t.isSampledTexture){let s=t.update(),c=t.texture,l=this.textures.get(c);if(s&&(this.textures.updateTexture(c),t.generation!==l.generation&&(t.generation=l.generation,r=!0),l.bindGroups.add(e)),n.get(c).externalTexture!==void 0||l.isDefaultTexture?i=!1:(a=a*10+c.id,o+=c.version),c.isStorageTexture===!0&&c.mipmapsAutoUpdate===!0){let e=this.get(c);t.store===!0?e.needsMipmap=!0:this.textures.needsMipmaps(c)&&e.needsMipmap===!0&&(this.backend.generateMipmaps(c),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t);t.samplerKey!==e&&(t.samplerKey=e,r=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,i?a:0,o)}},lP=Object.freeze([]);function uP(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function dP(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function fP(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===2&&e.forceSinglePass===!1}var pP=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,o){let s=this.renderItems[this.renderItemsIndex];return s===void 0?(s={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.groupOrder=r,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}push(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(fP(n)&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}unshift(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(fP(n)&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,n){this.opaque.length>1&&this.opaque.sort(e||uP),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||dP),this.transparent.length>1&&this.transparent.sort(t||dP),n&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:lP);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let t=this.renderItems[e];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}this._lastOcclusionObject=null}},mP=[],hP=class{constructor(e){this.lighting=e,this.lists=new RN}get(e,t){let n=this.lists;mP[0]=e,mP[1]=t;let r=n.get(mP);return r===void 0&&(r=new pP(this.lighting,e,t),n.set(mP,r)),mP[0]=null,mP[1]=null,r}dispose(){this.lists=new RN}},gP=0,_P=class{constructor(){this.id=gP++,this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Ls,this.scissor=!1,this.scissorValue=new Ls,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}getCacheKey(){return vP(this)}};function vP(e){let{textures:t,activeCubeFace:n,activeMipmapLevel:r}=e,i=[n,r];for(let e of t)i.push(e.id);return bw(i)}var yP=class{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,n=0){let r;if(e===null)r=`default`;else{let t=e.texture.format,n=e.texture.type;r=`${e.textures.length}:${t}:${n}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let i=t===null?`default`:t.id,a=r+`-`+i+`-`+n,o=this._renderContexts[a];return o===void 0&&(o=new _P,o.mrt=t,this._renderContexts[a]=o),e!==null&&(o.sampleCount=e.samples===0?1:e.samples),o.clearDepthValue=this.renderer.getClearDepth(),o.clearStencilValue=this.renderer.getClearStencil(),o}dispose(){this._renderContexts={}}},bP=new U,xP=class extends GN{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n,this._htmlTextures=new Set}updateRenderTarget(e,t=0){let n=this.get(e),r=e.samples===0?1:e.samples,i=n.depthTextureMips||={},a=e.textures,o=this.getSize(a[0]),s=o.width>>t,c=o.height>>t,l=e.depthTexture||i[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1,f=l!==void 0&&l.image!==void 0&&l.image.depth>1,p=o.depth>1&&(e.useArrayDepthTexture||e.multiview||f);l===void 0&&u&&(l=new Tu,l.format=e.stencilBuffer?va:_a,l.type=e.stencilBuffer?da:oa,l.image.width=s,l.image.height=c,l.image.depth=o.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),(n.width!==o.width||o.height!==n.height)&&(d=!0,l&&(l.needsUpdate=!0,l.image.width=s,l.image.height=c,l.image.depth=p?o.depth:1)),n.width=o.width,n.height=o.height,n.textures=a,n.depthTexture=l||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(d=!0,l&&(l.needsUpdate=!0),n.sampleCount=r);let m={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let e=0;e<a.length;e++){let t=a[e];d&&(t.needsUpdate=!0),this.updateTexture(t,m)}l&&this.updateTexture(l,m)}n.initialized!==!0&&(n.initialized=!0,this.info.memory.renderTargets++,n.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener(`dispose`,n.onDispose))}updateTexture(e,t={}){let n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&i.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();e.type=t?t.texture.type:ta}if(e.isHTMLTexture&&e.image){let t=this.renderer.domElement;if(`requestPaint`in t){if(t.hasAttribute(`layoutsubtree`)||t.setAttribute(`layoutsubtree`,`true`),e.image.parentNode!==t&&t.appendChild(e.image),this._htmlTextures.size===0){let e=this._htmlTextures;t.onpaint=t=>{let n=t&&t.changedElements;for(let t of e)(!n||n.includes(t.image))&&(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:a,height:o,depth:s}=this.getSize(e);if(t.width=a,t.height=o,t.depth=s,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)i.createTexture(e,t),n.generation=e.version;else if(e.version>0){let r=e.image;if(r===void 0)B(`Renderer: Texture marked for update but image is undefined.`);else if(r.complete===!1)B(`Renderer: Texture marked for update but image is incomplete.`);else{if(e.images){let n=[];for(let t of e.images)n.push(t);t.images=n}else t.image=r;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t);let a=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!a&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&Es.enabled===!0&&Es.getTransfer(e.colorSpace)!==`srgb`&&B(`WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.`),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener(`dispose`,n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=bP){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),e.isHTMLTexture?(t.width=n.offsetWidth||1,t.height=n.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<`u`&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<`u`&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture===!0?1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener(`dispose`,t.onDispose);for(let e=0;e<n.length;e++)this._destroyTexture(n[e]);r&&this._destroyTexture(r),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}_destroyTexture(e){if(this.has(e)===!0){let t=this.get(e);e.removeEventListener(`dispose`,t.onDispose);let n=t.isDefaultTexture;if(this.backend.destroyTexture(e,n),t.bindGroups)for(let n of t.bindGroups){let t=this.backend.get(n);t.groups=void 0,t.versions=void 0;for(let t of n.bindings)t.isSampler&&t.texture===e&&(t.isSampledTexture!==!0&&this.backend.destroySampler(t),t.reset(),t.release())}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}},SP=class extends Cc{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},CP=class extends rD{static get type(){return`OverrideContextNode`}constructor(e,t=null){super(t,{overrideNodes:e}),this.isOverrideContextNode=!0}getFlowContextData(){let e=[];this.traverse(t=>{t.isOverrideContextNode===!0&&e.push(t.value.overrideNodes)});let t=new Map(e.flatMap(e=>Array.from(e.entries()))),n=super.getFlowContextData();return n.overrideNodes=t,n}};function wP(e,t=null,n=null){if(t&&t.isNode){let e=t;t=()=>e}return new CP(new Map([[e,t]]),n)}W(`overrideNode`,(e,t,n)=>wP(t,n,e));function TP(e,t=null){let n=new Map;for(let[t,r]of e){let e=r===null?null:typeof r==`function`?r:()=>r;n.set(t,e)}return new CP(n,t)}W(`overrideNodes`,(e,t)=>TP(t,e));var EP=class extends jT{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let n=this.getNodeType(e),r=e.getStructTypeNode(n),i;return r===null?(V(`TSL: Member "${t}" not found in struct "${n}".`,new _w),i=`float`):i=r.getMemberType(e,t),i}getHash(){return String(this.id)}generate(){return this.name}},DP=dT(class extends Nw{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):`void`}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}addToStack(e,t=-1){if(e.isNode!==!0)return V(`TSL: Invalid node added to stack.`,new _w),this;if(t===-1){if(this._currentNode){let e=this._nodeDataLibrary.get(this._currentNode);e===void 0&&(e={delta:0},this._nodeDataLibrary.set(this._currentNode,e)),e.delta++,t=this.nodes.indexOf(this._currentNode)+e.delta}else t=this.nodes.length}return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let n=new oT(t);return this._currentCond=nD(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){let n=nD(e,new oT(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new oT(e),this}Switch(e){return this._expressionNode=sT(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(sT(e[n])));else V(`TSL: Invalid parameter length. Case() requires at least two parameters.`,new _w);let n=e[e.length-1],r=new oT(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=nD(i,r);return this._currentCond===null?(this._currentCond=a,this.addToStack(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),n=0;for(let r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t[`node`+n++]=r);return t.outputNode||null}build(e,...t){let n=mT(),r=e.buildStage;pT(this),e.setActiveStack(this);for(let t=0;t<this.nodes.length;t++){let n=this.nodes[t],i=this._currentNode;if(this._currentNode=n,!(n.isVarNode&&n.isIntent(e)&&n.isAssign(e)!==!0)){if(r===`setup`)n.build(e);else if(r===`analyze`)n.build(e,this);else if(r===`generate`){let t=e.getDataFromNode(n,`any`).stages,r=t&&t[e.shaderStage];if(n.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;n.build(e,`void`)}this._currentNode=i}}let i;if(this.outputNode){let n=this.outputNode.build(e,...t);(e.buildStage!==`generate`||this.outputNode.getNodeType(e)!==`void`)&&(i=n)}else i=super.build(e,...t);return pT(n),e.removeActiveStack(this),i}}).setParameterLength(0,1),OP=class{constructor(e=1){this.blending=e,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,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.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}};new OP(0),new OP(6);var kP=class extends Iw{static get type(){return`BitcastNode`}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}generateNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),n=``;if(this.inputType!==null){let t=this.valueNode.getNodeType(e);n=e.getTypeLength(t)===1?this.inputType:e.changeComponentType(t,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}},AP=fT(kP).setParameterLength(2),jP=e=>new kP(e,`uint`,`float`),MP={},NP=class e extends Y{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(AP(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return vT;case`int`:return _T;case`uvec2`:return ST;case`uvec3`:return wT;case`uvec4`:return DT;case`ivec2`:return xT;case`ivec3`:return CT;case`ivec4`:return ET}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return K(([e])=>{let r=vT(0);this._resolveElementType(e,r,t);let i=jP(q(r.bitAnd(RE(r)))).shiftRight(23).sub(127);return n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return K(([e])=>{hT(e.equal(vT(0)),()=>vT(32));let r=vT(0),i=vT(0);return this._resolveElementType(e,r,t),hT(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),hT(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),hT(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),hT(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),hT(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return K(([e])=>{let r=vT(0);this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(vT(1)).bitAnd(vT(1431655765)))),r.assign(r.bitAnd(vT(858993459)).add(r.shiftRight(vT(2)).bitAnd(vT(858993459))));let i=r.add(r.shiftRight(vT(4))).bitAnd(vT(252645135)).mul(vT(16843009)).shiftRight(vT(24));return n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return K(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;i<n;i++){let n=a[i];t[n].assign(r(e[n]))}return t}}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}setup(t){let{method:n,aNode:r}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);let a=this.getInputType(t),o=t.getElementType(a),s=t.getTypeLength(a),c=`${n}_base_${o}`,l=`${n}_${a}`,u=MP[c];if(u===void 0){switch(n){case e.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(c,o);break;case e.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(c,o);break;case e.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(c,o)}MP[c]=u}let d=MP[l];return d===void 0&&(d=this._createMainLayout(l,a,s,u),MP[l]=d),K(()=>d(r))()}};NP.COUNT_TRAILING_ZEROS=`countTrailingZeros`,NP.COUNT_LEADING_ZEROS=`countLeadingZeros`,NP.COUNT_ONE_BITS=`countOneBits`,new au,new U,new U,new U,new Hs,new U(0,0,-1),new Ls,new U,new U,new Ls,new H;var PP=new Rs;dO.flipX(),PP.depthTexture=new Tu(1,1);var FP=new hf(-1,1,1,-1,0,1),IP=new class extends wl{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new fl([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new fl(t,2))}},LP=class extends Zl{constructor(e=null){super(IP,e),this.camera=FP,this.isQuadMesh=!0}async renderAsync(e){Bo(`QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await e.init(),e.render(this,FP)}render(e){e.render(this,FP)}},RP=K(([e])=>jE(q(52.9829189).mul(jE(GE(e,bT(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),zP=K(([e,t,n])=>{let r=q(2.399963229728653),i=DE(q(e).add(.5).div(q(t))),a=q(e).mul(r).add(n);return bT(NE(a),ME(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]}),BP=new Hs,VP=mE(0).setGroup(fE).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),HP=mE(1).setGroup(fE).onRenderUpdate(({scene:e})=>e.backgroundIntensity),UP=mE(new Hs).setGroup(fE).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300||e.backgroundNode&&e.backgroundNode.isNode?BP.makeRotationFromEuler(e.backgroundRotation).transpose():BP.identity(),BP});K(({texture:e,uv:t})=>{let n=1e-4,r=J().toVar();return hT(t.x.lessThan(n),()=>{r.assign(J(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(J(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(J(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{r.assign(J(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{r.assign(J(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{r.assign(J(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(J(-.01,0,0))).r.sub(e.sample(t.add(J(n,0,0))).r),a=e.sample(t.add(J(0,-.01,0))).r.sub(e.sample(t.add(J(0,n,0))).r),o=e.sample(t.add(J(0,0,-.01))).r.sub(e.sample(t.add(J(0,0,n))).r);r.assign(J(i,a,o))}),r.normalize()}),K(([e,t])=>e.mul(t).floor().div(t));var WP=new H,GP=class extends eO{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},KP=class extends GP{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},qP=class e extends Iw{static get type(){return`PassNode`}constructor(t,n,r,i={}){super(`vec4`),this.scope=t,this.scene=n,this.camera=r,this.options=i,this._width=1,this._height=1;let a=new Rs(this._width,this._height,{type:ca,...i});a.texture.name=`output`;let o=null;(this.scope===e.DEPTH||i.depthBuffer!==!1)&&(o=new Tu,o.isRenderTargetTexture=!0,o.name=`depth`,a.depthTexture=o),this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture},o!==null&&(this._textures.depth=o),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=mE(0),this._cameraFar=mE(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Ow.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return B(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return B(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e===`depth`)throw Error(`THREE.PassNode: Depth texture is not available for this pass.`);t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new KP(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new KP(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=DA(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=TA(i,n,r)}return t}async compileAsync(e){let t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),t.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=sa),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i=t.getOutputRenderTarget();i&&i.isXRRenderTarget===!0?(r=t.xr.getCamera(),t.xr.updateCamera(r),WP.set(i.width,i.height)):(r=this.camera,t.getDrawingBufferSize(WP)),this.setSize(WP.width,WP.height);let a=t.getRenderTarget(),o=t.getMRT(),s=t.autoClear,c=t.transparent,l=t.opaque,u=r.layers.mask,d=t.contextNode,f=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:iD({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);let p=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=p,n.overrideMaterial=f,t.setRenderTarget(a),t.setMRT(o),t.autoClear=s,t.transparent=c,t.opaque=l,t.contextNode=d,r.layers.mask=u}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._resolutionScale),r=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor===null?this.renderTarget.scissorTest=!1:(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Ls),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r))}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Ls),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r))}dispose(){this.renderTarget.dispose()}};qP.COLOR=`color`,qP.DEPTH=`depth`;var JP=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),YP=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),XP=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),ZP=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),QP=K(([e,t])=>{let n=kT(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=kT(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=ZP(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),$P=kT(J(1.6605,-.1246,-.0182),J(-.5876,1.1329,-.1006),J(-.0728,-.0083,1.1187)),eF=kT(J(.6274,.0691,.0164),J(.3293,.9195,.088),J(.0433,.0113,.8956)),tF=K(([e])=>{let t=J(e).toVar(),n=J(t.mul(t)).toVar(),r=J(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(yE(40.14,r.mul(t))).add(yE(31.96,r).sub(yE(6.868,n.mul(t))).add(yE(.4298,n).add(yE(.1191,t).sub(.00232))))}),nF=K(([e,t])=>{let n=J(e).toVar(),r=kT(J(.856627153315983,.137318972929847,.11189821299995),J(.0951212405381588,.761241990602591,.0767994186031903),J(.0482516061458583,.101439036467562,.811302368396859)),i=kT(J(1.1271005818144368,-.1413297634984383,-.14132976349843826),J(-.11060664309660323,1.157823702216272,-.11060664309660294),J(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign(eF.mul(n)),n.assign(r.mul(n)),n.assign(UE(n,1e-10)),n.assign(EE(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(QE(n,0,1)),n.assign(tF(n)),n.assign(i.mul(n)),n.assign(qE(UE(J(0),n),J(2.2))),n.assign($P.mul(n)),n.assign(QE(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),rF=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=HE(e.r,HE(e.g,e.b)),a=nD(i.lessThan(.08),i.sub(yE(6.25,i.mul(i))),.04);e.subAssign(a);let o=UE(e.r,UE(e.g,e.b));hT(o.lessThan(n),()=>e);let s=vE(1,n),c=vE(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=vE(1,bE(1,r.mul(o.sub(c)).add(1)));return ZE(e,J(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),iF=class extends Nw{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},aF=class extends iF{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+`
|
|
4651
|
-
`,t===`property`?o:e.format(`${o}()`,i,t)}};function oF(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||JO.z).negate()}var sF=K(([e,t],n)=>tD(e,t,oF(n))),cF=K(([e],t)=>{let n=oF(t);return e.mul(e,n,n).negate().exp().oneMinus()});K(([e,t],n)=>{let r=oF(n),i=t.sub(KO.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()});var lF=K(([e,t])=>TT(t.toFloat().mix(eE.rgb,e.toVec3()),eE.a));dT(class extends Nw{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});var uF=class extends Nw{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=BD(l,i).toConst()),t.constNode.build(e)}};uF.ATOMIC_LOAD=`atomicLoad`,uF.ATOMIC_STORE=`atomicStore`,uF.ATOMIC_ADD=`atomicAdd`,uF.ATOMIC_SUB=`atomicSub`,uF.ATOMIC_MAX=`atomicMax`,uF.ATOMIC_MIN=`atomicMin`,uF.ATOMIC_AND=`atomicAnd`,uF.ATOMIC_OR=`atomicOr`,uF.ATOMIC_XOR=`atomicXor`,dT(uF);var dF=class e extends Iw{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}generateNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};dF.SUBGROUP_ELECT=`subgroupElect`,dF.SUBGROUP_BALLOT=`subgroupBallot`,dF.SUBGROUP_ADD=`subgroupAdd`,dF.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,dF.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,dF.SUBGROUP_MUL=`subgroupMul`,dF.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,dF.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,dF.SUBGROUP_AND=`subgroupAnd`,dF.SUBGROUP_OR=`subgroupOr`,dF.SUBGROUP_XOR=`subgroupXor`,dF.SUBGROUP_MIN=`subgroupMin`,dF.SUBGROUP_MAX=`subgroupMax`,dF.SUBGROUP_ALL=`subgroupAll`,dF.SUBGROUP_ANY=`subgroupAny`,dF.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,dF.QUAD_SWAP_X=`quadSwapX`,dF.QUAD_SWAP_Y=`quadSwapY`,dF.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,dF.SUBGROUP_BROADCAST=`subgroupBroadcast`,dF.SUBGROUP_SHUFFLE=`subgroupShuffle`,dF.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,dF.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,dF.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,dF.QUAD_BROADCAST=`quadBroadcast`;var fF;function pF(e){fF||=new WeakMap;let t=fF.get(e);return t===void 0&&fF.set(e,t={}),t}function mF(e){let t=pF(e);return t.shadowMatrix||=mE(`mat4`).setGroup(fE).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix))}function Yoe(e,t=KO){let n=mF(e).mul(t);return n.xyz.div(n.w)}function hF(e){let t=pF(e);return t.position||=mE(new U).setGroup(fE).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function Xoe(e){let t=pF(e);return t.targetPosition||=mE(new U).setGroup(fE).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function gF(e){let t=pF(e);return t.viewPosition||=mE(new U).setGroup(fE).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new U,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}var _F=e=>AO.transformDirection(hF(e).sub(Xoe(e))),Zoe=MT(`vec3`,`totalDiffuse`),Qoe=MT(`vec3`,`totalSpecular`),$oe=MT(`vec3`,`outgoingLight`),ese=e=>e.sort((e,t)=>e.id-t.id),tse=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},vF=new WeakMap,yF=[],bF=class extends Nw{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=Zoe,this.totalSpecularNode=Qoe,this.outgoingLightNode=$oe,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(yF.push(n.id),yF.push(+!!n.castShadow),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;yF.push(e,t)}}let t=bw(yF);return yF.length=0,t}getHash(e){let t=e.getDataFromNode(this);if(t.lightNodesHash===void 0){let n=this.setupLightsNode(e);t.lightNodes=n;let r=[];for(let e of n)r.push(e.getHash());t.lightNodesHash=`lights-`+r.join(`,`)}return t.lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=e.getDataFromNode(this),n=[],r=t.lightNodes||null,i=e.context.materialLightings,a=ese([...i,...this._lights]),o=e.renderer.library;for(let e of a)if(e.isNode)n.push(e);else{let t=null;if(r!==null&&(t=tse(e.id,r)),t===null){let n=o.getLightNodeClass(e.constructor);if(n===null){B(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}vF.has(e)===!1&&vF.set(e,new n(e)),t=vF.get(e)}n.push(t)}return n}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){let t=e.getDataFromNode(this);return t.lightNodes===void 0&&(t.lightNodes=this.setupLightsNode(e)),t.lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n,a.nodes=e.addStack().nodes,i.start(e);let{backdrop:s,backdropAlpha:c}=r,{directDiffuse:l,directSpecular:u,indirectDiffuse:d,indirectSpecular:f}=r.reflectedLight,p=l.add(d);s!==null&&(p=J(c===null?s:c.mix(p,s))),t.assign(p),o.assign(u.add(f)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}},nse=class extends Nw{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=Ow.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){xF.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||KO)}},xF=MT(`vec3`,`shadowPositionWorld`);function rse(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Cc),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function ise(e,t){return t=rse(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function ase(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function ose(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function sse(e,t){return t=ose(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function cse(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function lse(e,t,n){return n=ise(e,n),n=sse(t,n),n}function use(e,t,n){ase(e,n),cse(t,n)}var SF=new WeakMap,dse=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=tO(e,t.xy).setName(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),fse=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=tO(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=xk(`mapSize`,`vec2`,n).setGroup(fE),o=xk(`radius`,`float`,n).setGroup(fE),s=bT(1).div(a),c=o.mul(s.x),l=RP(pO.xy).mul(6.28318530718);return _E(i(t.xy.add(zP(0,5,l).mul(c)),t.z),i(t.xy.add(zP(1,5,l).mul(c)),t.z),i(t.xy.add(zP(2,5,l).mul(c)),t.z),i(t.xy.add(zP(3,5,l).mul(c)),t.z),i(t.xy.add(zP(4,5,l).mul(c)),t.z)).mul(1/5)}),pse=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=xk(`mapSize`,`vec2`,n).setGroup(fE),a=bT(1).div(i),o=t.xy,s=jE(o.mul(i).add(.5)).toConst();o.subAssign(s.sub(.5).mul(a));let c=n=>{let i=tO(e,o).offset(n).gather();return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)},l=c(xT(-1,1)).toConst(),u=c(xT(1,1)).toConst(),d=c(xT(-1,-1)).toConst(),f=c(xT(1,-1)).toConst();return _E(ZE(l.x,u.y,s.x).add(l.y).add(u.x).mul(s.y),ZE(l.w,u.z,s.x).add(l.z).add(u.w),ZE(d.x,f.y,s.x).add(d.y).add(f.x),ZE(d.w,f.z,s.x).add(d.z).add(f.w).mul(s.y.oneMinus())).mul(1/9)}),mse=K(({depthTexture:e,shadowCoord:t,depthLayer:n},r)=>{let i=tO(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=i.x,o=UE(1e-7,i.y.mul(i.y)),s=r.renderer.reversedDepthBuffer?WE(a,t.z):WE(t.z,a),c=q(1).toVar();return hT(s.notEqual(1),()=>{let e=t.z.sub(a),n=o.div(o.add(e.mul(e)));n=QE(vE(n,.3).div(.65)),c.assign(UE(s,n))}),c}),hse=e=>{let t=SF.get(e);return t===void 0&&(t=new PA,t.colorNode=TT(0,0,0,1),t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.blending=0,t.fog=!1,SF.set(e,t)),t},gse=e=>{let t=SF.get(e);t!==void 0&&(t.dispose(),SF.delete(e))},CF=new RN,wF=[],_se=(e,t,n,r)=>{wF[0]=e,wF[1]=t;let i=CF.get(wF);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,u,d,f)=>{(i.castShadow===!0||i.receiveShadow&&n===3)&&(r&&(Ew(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,u,d,f),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,CF.set(wF,i)),wF[0]=null,wF[1]=null,i},vse=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));return mA({start:_T(0),end:_T(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(_E(pO.xy,bT(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e),bT(a,DE(o.sub(a.mul(a)).max(0)))}),yse=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));return mA({start:_T(0),end:_T(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(_E(pO.xy,bT(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(_E(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e),bT(a,DE(o.sub(a.mul(a)).max(0)))}),bse=[dse,fse,pse,mse],TF,EF=new LP,DF=class extends nse{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=n.biasNode||xk(`bias`,`float`,n).setGroup(fE),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{let e=a.w;a=a.xy.div(e);let t=xk(`near`,`float`,n.camera).setGroup(fE),r=xk(`far`,`float`,n.camera).setGroup(fE);o=OA(e.negate(),t,r)}return a=J(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(i):o.add(i)),a}getShadowFilterFn(e){return bse[e]}setupRenderTarget(e,t){let n=new Tu(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t,camera:n}=e,{light:r,shadow:i}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,e),s=t.shadowMap.type,c=t.hasCompatibility(Mo.TEXTURE_COMPARE);if((s===1||s===2)&&c?(a.minFilter=Qi,a.magFilter=Qi):(a.minFilter=Yi,a.magFilter=Yi),i.camera.coordinateSystem=n.coordinateSystem,i.camera.updateProjectionMatrix(),s===3&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depthBuffer:!1}));let t=tO(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=tO(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let r=xk(`blurSamples`,`float`,i).setGroup(fE),s=xk(`radius`,`float`,i).setGroup(fE),c=xk(`mapSize`,`vec2`,i).setGroup(fE),l=this.vsmMaterialVertical||=new PA;l.fragmentNode=vse({samples:r,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new PA,l.fragmentNode=yse({samples:r,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let l=xk(`intensity`,`float`,i).setGroup(fE),u=xk(`normalBias`,`float`,i).setGroup(fE),d=mF(r),f=ik.mul(u),p;p=!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?d.mul(xF.add(f)):mE(`mat4`).onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(d.value,e.matrixWorld)).mul(WO).add(d.mul(TT(f,0)));let m=this.setupShadowCoord(e,p),h=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(h===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let g=s===3&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,_=this.setupShadowFilter(e,{filterFn:h,shadowTexture:o.texture,depthTexture:g,shadowCoord:m,shadow:i,depthLayer:this.depthLayer}),v;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?v=vk(o.texture,m.xyz):(v=tO(o.texture,m),a.isArrayTexture&&(v=v.depth(this.depthLayer))));let y;y=v?ZE(1,_.rgb.mix(v,1),l.mul(v.a)).toVar():ZE(1,_,l).toVar(),this.shadowMap=o,this.shadow.map=o;let b=`${this.light.type} Shadow [ ${this.light.name||`ID: `+this.light.id} ]`;return v&&y.toInspector(`${b} / Color`,()=>this.shadowMap.texture.isCubeTexture?vk(this.shadowMap.texture,qA()):tO(this.shadowMap.texture)),y.toInspector(`${b} / Depth`,()=>{let e=xk(`near`,`float`,this.shadow.camera),t=xk(`far`,`float`,this.shadow.camera),n;n=this.shadowMap.texture.isCubeTexture?vk(this.shadowMap.depthTexture,qA()).r:tO(this.shadowMap.depthTexture).r;let r;return r=this.shadow.camera.isPerspectiveCamera?DA(n,e,t):zoe(n,e,t),r=TA(r,e,t),r.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);let o=a.name;a.name=`Shadow Map [ ${r.name||`ID: `+r.id} ]`,i.render(a,t.camera),a.name=o}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;TF=lse(i,a,TF),a.overrideMaterial=hse(n),i.setRenderObjectFunction(_se(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===3&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,use(i,a,TF)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),EF.material=this.vsmMaterialVertical,EF.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),EF.material=this.vsmMaterialHorizontal,EF.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,gse(this.light),this.shadowMap&&=(this.shadowMap.dispose(),null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},xse=(e,t)=>new DF(e,t),Sse=new Cc,OF=new Hs,kF=new U,AF=new U,Cse=[new U(1,0,0),new U(-1,0,0),new U(0,-1,0),new U(0,1,0),new U(0,0,1),new U(0,0,-1)],wse=[new U(0,-1,0),new U(0,-1,0),new U(0,0,-1),new U(0,0,1),new U(0,-1,0),new U(0,-1,0)],Tse=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],Ese=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Dse=K(({depthTexture:e,bd3D:t,dp:n})=>vk(e,t).compare(n)),Ose=K(({depthTexture:e,bd3D:t,dp:n,shadow:r})=>{let i=xk(`radius`,`float`,r).setGroup(fE),a=xk(`mapSize`,`vec2`,r).setGroup(fE),o=i.div(a.x),s=FE(t),c=AE(KE(t,s.x.greaterThan(s.z).select(J(0,1,0),J(1,0,0)))),l=KE(t,c),u=RP(pO.xy).mul(6.28318530718),d=zP(0,5,u),f=zP(1,5,u),p=zP(2,5,u),m=zP(3,5,u),h=zP(4,5,u);return vk(e,t.add(c.mul(d.x).add(l.mul(d.y)).mul(o))).compare(n).add(vk(e,t.add(c.mul(f.x).add(l.mul(f.y)).mul(o))).compare(n)).add(vk(e,t.add(c.mul(p.x).add(l.mul(p.y)).mul(o))).compare(n)).add(vk(e,t.add(c.mul(m.x).add(l.mul(m.y)).mul(o))).compare(n)).add(vk(e,t.add(c.mul(h.x).add(l.mul(h.y)).mul(o))).compare(n)).mul(1/5)}),kse=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r},i)=>{let a=n.xyz.toConst(),o=a.abs().toConst(),s=o.x.max(o.y).max(o.z),c=mE(`float`).setGroup(fE).onRenderUpdate(()=>r.camera.near),l=mE(`float`).setGroup(fE).onRenderUpdate(()=>r.camera.far),u=xk(`bias`,`float`,r).setGroup(fE),d=q(1).toVar();return hT(s.sub(l).lessThanEqual(0).and(s.sub(c).greaterThanEqual(0)),()=>{let n;i.renderer.reversedDepthBuffer?(n=Boe(s.negate(),c,l),n.subAssign(u)):i.renderer.logarithmicDepthBuffer?(n=OA(s.negate(),c,l),n.addAssign(u)):(n=EA(s.negate(),c,l),n.addAssign(u));let o=a.normalize();d.assign(e({depthTexture:t,bd3D:o,dp:n,shadow:r}))}),d}),Ase=class extends DF{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?Dse:Ose}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){return kse({filterFn:t,depthTexture:n,shadowCoord:r,shadow:i})}setupRenderTarget(e,t){let n=new Eu(e.mapSize.width);n.name=`PointShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name=`PointShadowMap`,r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.camera,s=t.matrix,c=i.coordinateSystem===Ao,l=c?Cse:Tse,u=c?wse:Ese;n.setSize(t.mapSize.width,t.mapSize.width);let d=i.autoClear,f=i.getClearColor(Sse),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(n,e),i.clear();let c=r.distance||o.far;c!==o.far&&(o.far=c,o.updateProjectionMatrix()),kF.setFromMatrixPosition(r.matrixWorld),o.position.copy(kF),AF.copy(o.position),AF.add(l[e]),o.up.copy(u[e]),o.lookAt(AF),o.updateMatrixWorld(),s.makeTranslation(-kF.x,-kF.y,-kF.z),OF.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(OF,o.coordinateSystem,o.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||`ID: `+r.id} ] - Face ${e+1}`,i.render(a,o),a.name=d}i.autoClear=d,i.setClearColor(f,p)}},jse=(e,t)=>new Ase(e,t),jF=class extends yA{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new Cc,this.colorNode=e&&e.colorNode||mE(this.color).setGroup(fE),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Ow.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener(`dispose`,this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener(`dispose`,this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return gF(this.light).sub(e.context.positionView||JO)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return xse(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let e=this.light.shadow.shadowNode,t;t=e===void 0?this.setupShadowNode():sT(e),this.shadowNode=t,this.shadowColorNode=n=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},MF=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),Mse=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=MF({lightDistance:t.length(),cutoffDistance:n,decayExponent:r});return{lightDirection:i,lightColor:e.mul(a)}},Nse=class extends jF{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=mE(0).setGroup(fE),this.decayExponentNode=mE(2).setGroup(fE)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return jse(this.light)}setupDirect(e){return Mse({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}};K(([e=ZD()],{renderer:t,material:n})=>{let r=XE(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=q(r.fwidth()).toVar();i=tD(e.oneMinus(),e.add(1),r).oneMinus()}else i=nD(r.greaterThan(1),0,1);return i});var Pse=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(1.023328).mul(r)),a=a.add(t.element(2).mul(1.023328).mul(i)),a=a.add(t.element(3).mul(1.023328).mul(n)),a=a.add(t.element(4).mul(.858086).mul(n).mul(r)),a=a.add(t.element(5).mul(.858086).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(.858086).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(yE(n,n).sub(yE(r,r)))),a}),NF=new SP,Fse=class extends GN{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(i===null)r._clearColor.getRGB(NF),NF.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(NF),NF.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;NF.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=TT(a).mul(HP).context({getUV:()=>UP.mul(nk),getTextureLevel:()=>VP}),t=OO.element(3).element(3).equal(1),r=bE(1,OO.element(1).element(1)).mul(3),s=t.select(WO.mul(r),WO),c=RO.mul(TT(s,0)),l=OO.mul(TT(c.xyz,1));l=l.setZ(l.w);let u=new PA;u.name=`Background.material`,u.side=1,u.depthTest=!1,u.depthWrite=!1,u.allowOverride=!1,u.fog=!1,u.lights=!1,u.vertexNode=l,u.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=o=new Zl(new ad(1,32,32),u),o.frustumCulled=!1,o.name=`Background.mesh`;function d(){i.removeEventListener(`dispose`,d),o.material.dispose(),o.geometry.dispose()}i.addEventListener(`dispose`,d)}let s=a.getCacheKey();n.backgroundCacheKey!==s&&(n.backgroundMeshNode.node=TT(a).mul(HP),n.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,n.backgroundCacheKey=s),t.unshift(o,o.geometry,o.material,0,0,null,null)}else V(`Renderer: Unsupported background configuration.`,i);let o=r.xr.getEnvironmentBlendMode();if(o===`additive`?NF.set(0,0,0,1):o===`alpha-blend`&&NF.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=NF.r,e.g=NF.g,e.b=NF.b,e.a=NF.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r.getClearDepth(),n.stencilClearValue=r.getClearStencil(),n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}},Ise=0,PF=class{constructor(e=``,t=[]){this.name=e,this.bindings=t,this.id=Ise++}},Lse=class{constructor(e,t,n,r,i,a,o,s,c,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=u,this.nodeAttributes=r,this.bindings=i,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=s,this.observer=c,this.hardwareClipping=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let n=new PF(t.name,[]);e.push(n);for(let e of t.bindings)n.bindings.push(e.clone())}else e.push(t);return e}},FF=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},Rse=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},IF=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},zse=class extends IF{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},Bse=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}},Vse=0,LF=class{constructor(e=null){this.id=Vse++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},Hse=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},RF=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},Use=class extends RF{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},Wse=class extends RF{constructor(e,t=new H){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},Gse=class extends RF{constructor(e,t=new U){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},Kse=class extends RF{constructor(e,t=new Ls){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},qse=class extends RF{constructor(e,t=new Cc){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},Jse=class extends RF{constructor(e,t=new Kf){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},Yse=class extends RF{constructor(e,t=new xs){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},Xse=class extends RF{constructor(e,t=new Hs){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},Zse=class extends Use{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},Qse=class extends Wse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},$se=class extends Gse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},ece=class extends Kse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},tce=class extends qse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},nce=class extends Jse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},rce=class extends Yse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},ice=class extends Xse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},ace=0,zF=new WeakMap,BF=new WeakMap,oce=new WeakMap,sce=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),VF=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`)),HF=e=>{if(e.writeUsageCount>0)return!0;if(e.subBuildsCache!==void 0){for(let t in e.subBuildsCache)if(HF(e.subBuildsCache[t]))return!0}return!1},UF=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:``,fragment:``,compute:``},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:``},this.chaining=[],this.stack=DP(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new LF,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:ace++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute(`normal`)===!1}isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===1&&e.alphaToCoverage===!1}createRenderTarget(e,t,n){return new Rs(e,t,n)}createCubeRenderTarget(e,t){return new JA(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t=`vec4`,n=this.renderer.getRenderTarget();if(n!==null){let r=n.textures[e].type,i=n.textures[e].format,a=`vec`;r===1013?a=`ivec`:r===1014&&(a=`uvec`),t=i===1028||i===1029?r===1013?`int`:r===1014?`uint`:`float`:i===1030||i===1031?`${a}2`:i===1022||i===1032?`${a}3`:`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){let n=t[0].groupNode,r=n.shared;if(r)for(let e=1;e<t.length;e++)n!==t[e].groupNode&&(r=!1);let i;if(r){let n=``;for(let e of t)if(e.isNodeUniformsGroup){e.uniforms.sort((e,t)=>e.nodeUniform.node.id-t.nodeUniform.node.id);for(let t of e.uniforms)n+=t.nodeUniform.node.id}else n+=e.nodeUniform.id;let r=this.renderer._currentRenderContext||this.renderer,a=zF.get(r);a===void 0&&(a=new Map,zF.set(r,a));let o=yw(n);i=a.get(o),i===void 0&&(i=new PF(e,t),a.set(o,i))}else i=new PF(e,t);return i}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of jw)for(let r in n[e]){let i=n[e][r],a=t[r]||(t[r]=[]);for(let e of i)a.includes(e)===!1&&a.push(e)}e=[];for(let n in t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let n=e[t];this.bindingsIndexes[n.name].group=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.has(e)===!1&&(this.nodes.add(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();(t!==Ow.NONE||n!==Ow.NONE)&&this.sequentialNodes.add(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==Ow.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==Ow.NONE&&this.updateBeforeNodes.push(e),n!==Ow.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===1006||e.magFilter===1007||e.magFilter===1005||e.magFilter===1008||e.minFilter===1006||e.minFilter===1007||e.minFilter===1005||e.minFilter===1008}getUniformBufferLimit(){return this.renderer.backend.capabilities.getUniformBufferLimit()}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error(`THREE.NodeBuilder: Invalid node chaining!`)}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new LF(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){B(`Abstract function.`)}getInstanceIndex(){B(`Abstract function.`)}getDrawIndex(){B(`Abstract function.`)}getFrontFacing(){B(`Abstract function.`)}getFragCoord(){B(`Abstract function.`)}isFlipY(){return!1}isContextAssign(){return this.context.assign===!0}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,this.isContextAssign()?t.writeUsageCount=t.writeUsageCount===void 0?1:t.writeUsageCount+1:t.readUsageCount=t.readUsageCount===void 0?1:t.readUsageCount+1,t.usageCount}hasWriteUsage(e){let t=e.getShared(this),n=(t.isGlobal(this)?this.globalCache:this.cache).getData(t);if(n!==void 0){for(let e in n)if(HF(n[e]))return!0}return!1}generateTexture(){B(`Abstract function.`)}generateTextureLod(){B(`Abstract function.`)}generateArrayDeclaration(e,t){return this.getType(e)+`[ `+t+` ]`}generateArray(e,t,n=null){let r=this.generateArrayDeclaration(e,t)+`( `;for(let i=0;i<t;i++){let a=n?n[i]:null;r+=a===null?this.generateConst(e):a.build(this,e),i<t-1&&(r+=`, `)}return r+=` )`,r}generateStruct(e,t,n=null){let r=[];for(let e of t){let{name:t,type:i}=e;n&&n[t]&&n[t].isNode?r.push(n[t].build(this,i)):r.push(this.generateConst(i))}return e+`( `+r.join(`, `)+` )`}generateConst(e,t=null){if(t===null&&(e===`float`||e===`int`||e===`uint`?t=0:e===`bool`?t=!1:e===`color`?t=new Cc:e===`vec2`||e===`uvec2`||e===`ivec2`?t=new H:e===`vec3`||e===`uvec3`||e===`ivec3`?t=new U:(e===`vec4`||e===`uvec4`||e===`ivec4`)&&(t=new Ls)),e===`float`)return VF(t);if(e===`int`)return`${Math.round(t)}`;if(e===`uint`)return t>=0?`${Math.round(t)}u`:`0u`;if(e===`bool`)return t?`true`:`false`;if(e===`color`)return`${this.getType(`vec3`)}( ${VF(t.r)}, ${VF(t.g)}, ${VF(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4&&e!==`mat2`)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e===`color`?`vec3`:e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new FF(e,t);return this.registerDeclaration(r),n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e===`void`||e===`property`||e===`sampler`||e===`samplerComparison`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;return e.isDepthTexture===!0?`float`:t===1013?`int`:t===1014?`uint`:`float`}getElementType(e){return e===`mat2`?`vec2`:e===`mat3`?`vec3`:e===`mat4`?`vec4`:this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e===`float`||e===`bool`||e===`int`||e===`uint`)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]===`b`?`bool`:t[1]===`i`?`int`:t[1]===`u`?`uint`:`float`}getVectorType(e){return e===`color`?`vec3`:e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`texture3D`?`vec4`:e}getTypeFromLength(e,t=`float`){if(e===1)return t;let n=Cw(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return sce.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof dl)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?t===`float`||t===`bool`||t===`int`||t===`uint`?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error(`THREE.NodeBuilder: Invalid active stack removal.`)}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=DP(this.stack);let e=mT();return this.stacks.push(e),pT(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,pT(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let i=r[t];if(this.subBuildLayers.length===0)return i;let a=r.any?r.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(i.subBuildsCache===void 0&&(i.subBuildsCache={}),i=i.subBuildsCache[o]||(i.subBuildsCache[o]={}),i.subBuilds=a),i}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t,n=null){let r=this.getDataFromNode(e,`vertex`),i=r.bufferAttribute;if(i===void 0){let a=this.uniforms.index++;n===null&&(n=`nodeAttribute`+a),i=new FF(n,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){let i=this.getDataFromNode(e,r,this.globalCache),a=i.structType;if(a===void 0){let o=this.structs.index++;n===null&&(n=`StructType`+o),a=new Hse(n,t),this.structs[r].push(a),this.types[r][n]=e,i.structType=a}return a}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,`OutputType`,`fragment`);return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new Rse(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),i.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,i=!1){let a=this.getDataFromNode(e,r),o=this.getSubBuildProperty(`variable`,a.subBuilds),s=a[o];if(s===void 0){let c=i?`_const`:`_var`,l=this.vars[r]||(this.vars[r]=[]),u=this.vars[c]||(this.vars[c]=0);t===null&&(t=(i?`nodeConst`:`nodeVar`)+u,this.vars[c]++),o!==`variable`&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);s=new IF(t,n,i,d),i||l.push(s),this.registerDeclaration(s),a[o]=s}return s}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,i=null){let a=this.getDataFromNode(e,`any`),o=this.getSubBuildProperty(`varying`,a.subBuilds),s=a[o];if(s===void 0){let e=this.varyings,c=e.length;t===null&&(t=`nodeVarying`+c),o!==`varying`&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new zse(t,n,r,i),e.push(s),this.registerDeclaration(s),a[o]=s}return s}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=e.name,i=r,a=this.getPropertyName(e),o=1;for(;n[a]!==void 0;)i=r+`_`+o++,e.name=i,a=this.getPropertyName(e);i!==r&&B(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${i}'.`),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new Bse(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===``?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`;
|
|
4652
|
-
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=` `,this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=this.renderer.backend,n=
|
|
4650
|
+
`).removeFlowTab();e.addFlowTab()}},hA=(...e)=>new Ooe(dT(e,`int`)).toStack(),koe=()=>VD(`break`).toStack(),gA=new WeakMap,_A=new Ls,vA=new WeakMap,yA=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=vT(AD).mul(n).add(a),s=o.div(r);return rO(e,ST(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function Aoe(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=gA.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new Bs(p,u,d,a);m.type=sa,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(_A.fromBufferAttribute(a,e),p[f+i+0]=_A.x,p[f+i+1]=_A.y,p[f+i+2]=_A.z,p[f+i+3]=0),n===!0&&(_A.fromBufferAttribute(o,e),p[f+i+4]=_A.x,p[f+i+5]=_A.y,p[f+i+6]=_A.z,p[f+i+7]=0),r===!0&&(_A.fromBufferAttribute(l,e),p[f+i+8]=_A.x,p[f+i+9]=_A.y,p[f+i+10]=_A.z,p[f+i+11]=l.itemSize===4?_A.w:1)}}o={count:a,texture:m,stride:l,size:new H(u,d)},gA.set(e,o);function g(){m.dispose(),gA.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var joe=K(([e])=>{let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length;if(a===0)return;let o=vA.get(e);(o===void 0||o.count!==a)&&(o={base:hE(1),influences:e.morphTargetInfluences?oO(e.morphTargetInfluences,`float`):null,count:a},vA.set(e,o));let{base:s,influences:c}=o,{texture:l,stride:u,size:d}=Aoe(t);n===!0&&GO.mulAssign(s),r===!0&&ek.mulAssign(s);let f=vT(d.width);hA(a,({i:t})=>{let i=q(0).toVar();e.count>1&&e.morphTexture!==null&&e.morphTexture!==void 0?i.assign(rO(e.morphTexture,ST(vT(t).add(1),vT(jD))).r):i.assign(c.element(t).toVar()),gT(i.notEqual(0),()=>{n===!0&&GO.addAssign(yA({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:vT(0)})),r===!0&&ek.addAssign(yA({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:vT(1)}))})}),iA(({object:e})=>{let{base:t,influences:n}=o;t.value=e.geometry.morphTargetsRelative?1:1-e.morphTargetInfluences.reduce((e,t)=>e+t,0),n&&(n.array=e.morphTargetInfluences,n.update())})},`void`),bA=class extends Pw{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},Moe=class extends bA{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},Noe=fT(class extends iD{static get type(){return`LightingContextNode`}constructor(e,t=null,n=[],r=null,i=null){super(e),this.lightingModel=t,this.materialLightings=n,this.backdropNode=r,this.backdropAlphaNode=i,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:n}=this,r={directDiffuse:J().toVar(`directDiffuse`),directSpecular:J().toVar(`directSpecular`),indirectDiffuse:J().toVar(`indirectDiffuse`),indirectSpecular:J().toVar(`indirectSpecular`)};return{radiance:J().toVar(`radiance`),irradiance:J().toVar(`irradiance`),iblIrradiance:J().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:r,materialLightings:e,backdrop:t,backdropAlpha:n}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),Poe=class extends bA{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},xA=new H,SA=class extends tO{static get type(){return`ViewportTextureNode`}constructor(e=fO,t=null,n=null){let r=null;n===null?(r=new Cu,r.minFilter=ea,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=kw.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;i===null?t.getDrawingBufferSize(xA):i.getDrawingBufferSize?i.getDrawingBufferSize(xA):xA.set(i.width,i.height);let a=this.getTextureForReference(i);(a.image.width!==xA.width||a.image.height!==xA.height)&&(a.image.width=xA.width,a.image.height=xA.height,a.needsUpdate=!0);let o=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=o}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},CA=fT(SA,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Foe=CA(),Ioe=(e=fO,t=null)=>Foe.sample(e,t),wA=null,Loe=fT(class extends SA{static get type(){return`ViewportDepthTextureNode`}constructor(e=fO,t=null,n=null){n===null&&(wA===null&&(wA=new Tu),n=wA),super(e,t,n)}}).setParameterLength(0,3),TA=class e extends Pw{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=AA().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?DA(YO.z,DO,OO):EA(YO.z,DO,OO):n===e.LINEAR_DEPTH&&(i=r===null?EA(YO.z,DO,OO):t.isPerspectiveCamera?EA(OA(r,DO,OO),DO,OO):r),i}};TA.DEPTH_BASE=`depthBase`,TA.DEPTH=`depth`,TA.LINEAR_DEPTH=`linearDepth`;var EA=(e,t,n)=>e.add(t).div(t.sub(n)),Roe=K(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?n.sub(t).mul(e).sub(n):t.sub(n).mul(e).sub(t)),DA=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),zoe=(e,t,n)=>t.mul(e.add(n)).div(e.mul(t.sub(n))),OA=K(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),kA=(e,t,n)=>{t=t.max(1e-6).toVar();let r=DE(e.negate().div(t)),i=DE(n.div(t));return r.div(i)},AA=fT(TA,TA.DEPTH_BASE),jA=G(TA,TA.DEPTH);Loe(),jA.assign=e=>AA(e);var MA=class e extends Pw{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=oO(t).setGroup(pE);hA(a,({i:t})=>{let a=e.element(t);n.assign(YO.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(nD(r.negate(),r,n))})}let o=e.length;if(o>0){let t=oO(e).setGroup(pE),a=q(1).toVar(`intersectionClipOpacity`);hA(o,({i:e})=>{let i=t.element(e);n.assign(YO.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(nD(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}FT.a.mulAssign(i),FT.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=oO(t).setGroup(pE);hA(n,({i:t})=>{let n=e.element(t);YO.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=oO(e).setGroup(pE),n=bT(!0).toVar(`clipped`);hA(r,({i:e})=>{let r=t.element(e);n.assign(YO.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=oO(e).setGroup(pE),i=sO(t.getClipDistance());hA(n,({i:e})=>{let t=r.element(e),n=YO.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};MA.ALPHA_TO_COVERAGE=`alphaToCoverage`,MA.DEFAULT=`default`,MA.HARDWARE=`hardware`;var Boe=()=>new MA,Voe=()=>new MA(MA.ALPHA_TO_COVERAGE),Hoe=()=>new MA(MA.HARDWARE),Uoe=.05,NA=K(([e])=>ME(bE(1e4,NE(bE(17,e.x).add(bE(.1,e.y)))).mul(vE(.1,IE(NE(bE(13,e.y).add(e.x))))))),PA=K(([e])=>NA(xT(NA(e.xy),e.z))),Woe=K(([e])=>{let t=WE(RE(BE(e.xyz)),RE(VE(e.xyz))),n=q(1).div(q(Uoe).mul(t)).toVar(`pixScale`),r=xT(TE(kE(DE(n))),TE(AE(DE(n)))),i=xT(PA(kE(r.x.mul(e.xyz))),PA(kE(r.y.mul(e.xyz)))),a=ME(DE(n)),o=vE(bE(a.oneMinus(),i.x),bE(a,i.y)),s=UE(a,a.oneMinus()),c=J(o.mul(o).div(bE(2,s).mul(yE(1,s))),o.sub(bE(.5,s)).div(yE(1,s)),yE(1,yE(1,o).mul(yE(1,o)).div(bE(2,s).mul(yE(1,s)))));return $E(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),Goe=class extends XD{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new Ls(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},Koe=(e=0)=>new Goe(e),FA=class extends kl{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(bw(t.slice(0,-4)),n.getCacheKey());return this.type+xw(e)}build(e){this.setup(e)}setupObserver(e){return new Ire(e)}setup(e){e.context.setupNormal=()=>uD(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=uD(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=ET(r,FT.a).max(0);a=this.setupOutput(e,i),tE.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&tE.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=t.convert(e.getOutputType())),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=Voe():e.stack.addToStack(Boe())}return r}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(Hoe()),e.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?kA(YO.z,DO,OO):EA(YO.z,DO,OO))}r!==null&&jA.assign(r).toStack()}setupPositionView(){return zO.mul(GO).xyz}setupModelViewProjection(){return kO.mul(YO)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),hoe}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&joe(t),t.isSkinnedMesh===!0&&Doe(t),this.displacementMap){let e=Tk(`displacementMap`,`texture`),t=Tk(`displacementScale`,`float`),n=Tk(`displacementBias`,`float`);GO.addAssign(ek.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&woe(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&xoe(t),this.positionNode!==null&&GO.assign(uD(this.positionNode,`POSITION`,`vec3`)),GO}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&bT(this.maskNode).not().discard();let r=this.colorNode?ET(this.colorNode):Uae;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(Koe())),t.instanceColor&&(r=uA.mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=dA.mul(r)),FT.assign(r);let i=this.opacityNode?q(this.opacityNode):Gk;FT.a.assign(FT.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?Hae:q(this.alphaTestNode),this.alphaToCoverage===!0?(FT.a=nD(a,a.add(HE(FT.a)),FT.a),FT.a.lessThanEqual(0).discard()):FT.a.lessThanEqual(a).discard()),this.alphaHash===!0&&FT.a.lessThan(Woe(GO)).discard(),e.isOpaque()&&FT.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?J(0):FT.rgb}setupNormal(){return this.normalNode?J(this.normalNode):Xae}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Tk(`envMap`,`cubeTexture`):Tk(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Poe(eA)),t}setupMaterialLightings(e){let t=[];if(e.renderer.lighting.enabled===!1)return t;let n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);return r&&r.isLightingNode&&t.push(r),e.context.ambientOcclusion&&t.push(new Moe(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=moe),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(uE.assign(t),e.context.ambientOcclusion=uE)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=this.lights===!0?this.setupMaterialLightings(e):[],s=a?this.lightsNode||e.lightsNode:null,c=this.setupOutgoingLight(e);return s&&(o.length>0||s.getScope().hasLights)?c=Noe(s,this.setupLightingModel(e)||null,o,n,r):n!==null&&(c=J(r===null?n:QE(c,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(LT.assign(J(i||Gae)),c=c.add(LT)),c}setupFog(e,t){let n=e.fogNode;return n&&(tE.assign(t),t=ET(n.toVar())),t}setupPremultipliedAlpha(e,t){return HD(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=kl.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let n in t)if(t[n].set!==void 0&&e[n]!==void 0){let t=e[n];this[n]&&this[n].copy!==void 0?this[n].copy(t):this[n]=t}for(let t in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(t)&&this[t]!==void 0&&e[t]!==void 0){let n=e[t];this[t]&&this[t].copy!==void 0?this[t].copy(n):this[t]=n}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(e=>e.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},qoe=new fu,IA=class extends FA{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(qoe),this.setValues(e)}},LA=new Od,RA=class extends FA{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(LA),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?q(this.offsetNode):$k,t=this.dashScaleNode?q(this.dashScaleNode):Yk,n=this.dashSizeNode?q(this.dashSizeNode):Xk,r=this.gapSizeNode?q(this.gapSizeNode):Zk;nE.assign(n),rE.assign(r);let i=dD(ZD(`lineDistance`).mul(t));(e?i.add(e):i).mod(nE.add(rE)).greaterThan(nE).discard()}},zA=PT(`vec3`,`worldStart`),BA=PT(`vec3`,`worldEnd`),VA=PT(`float`,`lineDistance`),HA=PT(`vec4`,`worldPos`),UA=K(({start:e,end:t})=>{let n=kO.element(2).element(2),r=kO.element(3).element(2);return n.greaterThan(0).select(r.negate().div(n.add(1)),r.mul(-.5).div(n)).sub(e.z).div(t.z.sub(e.z))},{start:`vec4`,end:`vec4`,return:`float`}),WA=K(({p1:e,p2:t,p3:n,p4:r})=>{let i=e.sub(n),a=r.sub(n),o=t.sub(e),s=i.dot(a),c=a.dot(o),l=i.dot(o),u=a.dot(a),d=o.dot(o).mul(u).sub(c.mul(c)),f=s.mul(c).sub(l.mul(u)).div(d).clamp();return xT(f,s.add(c.mul(f)).div(u).clamp())},{p1:`vec3`,p2:`vec3`,p3:`vec3`,p4:`vec3`,return:`vec2`});K(({material:e})=>{let t=e._useDash,n=e._useWorldUnits,r=ZD(`instanceStart`),i=ZD(`instanceEnd`),a=ET(zO.mul(ET(r,1))).toVar(`start`),o=ET(zO.mul(ET(i,1))).toVar(`end`),s,c;t&&(s=q(ZD(`instanceDistanceStart`)).toVar(`distanceStart`),c=q(ZD(`instanceDistanceEnd`)).toVar(`distanceEnd`)),n&&(zA.assign(a.xyz),BA.assign(o.xyz));let l=hO.z.div(hO.w);if(gT(kO.element(2).element(3).equal(-1),()=>{gT(a.z.lessThan(0).and(o.z.greaterThan(0)),()=>{let e=UA({start:a,end:o});o.assign(ET(QE(a.xyz,o.xyz,e),o.w)),t&&c.assign(QE(s,c,e))}).ElseIf(o.z.lessThan(0).and(a.z.greaterThanEqual(0)),()=>{let e=UA({start:o,end:a});a.assign(ET(QE(o.xyz,a.xyz,e),a.w)),t&&s.assign(QE(c,s,e))})}),t){let t=e.dashScaleNode?q(e.dashScaleNode):Yk,n=e.offsetNode?q(e.offsetNode):$k,r=WO.y.lessThan(.5).select(t.mul(s),t.mul(c));r=r.add(n),VA.assign(r)}let u=kO.mul(a),d=kO.mul(o),f=u.xyz.div(u.w),p=d.xyz.div(d.w),m=p.xy.sub(f.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());let h=ET().toVar();if(n){let e=o.xyz.sub(a.xyz).normalize(),n=QE(a.xyz,o.xyz,.5).normalize(),r=e.cross(n).normalize(),i=e.cross(r);HA.assign(WO.y.lessThan(.5).select(a,o));let s=Qk.mul(.5);HA.addAssign(ET(WO.x.lessThan(0).select(r.mul(s),r.mul(s).negate()),0)),t||(HA.addAssign(ET(WO.y.lessThan(.5).select(e.mul(s).negate(),e.mul(s)),0)),HA.addAssign(ET(i.mul(s),0)),gT(WO.y.greaterThan(1).or(WO.y.lessThan(0)),()=>{HA.subAssign(ET(i.mul(2).mul(s),0))})),h.assign(kO.mul(HA));let c=J().toVar();c.assign(WO.y.lessThan(.5).select(f,p)),h.z.assign(c.z.mul(h.w))}else{let e=xT(m.y,m.x.negate()).toVar(`offset`);m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(WO.x.lessThan(0).select(e.negate(),e)),gT(WO.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(WO.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(Qk)),e.assign(e.div(hO.w.div(dO))),h.assign(WO.y.lessThan(.5).select(u,d)),e.assign(e.mul(h.w)),h.assign(h.add(ET(e,0,0)))}return h})(),K(({material:e,renderer:t})=>{let n=e._useAlphaToCoverage,r=e._useDash,i=e._useWorldUnits,a=QD();if(r){let t=e.dashSizeNode?q(e.dashSizeNode):Xk,n=e.gapSizeNode?q(e.gapSizeNode):Zk;nE.assign(t),rE.assign(n),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),VA.mod(nE.add(rE)).greaterThan(nE).discard()}let o=q(1).toVar(`alpha`);if(i){let e=HA.xyz.normalize().mul(1e5),i=BA.sub(zA),a=WA({p1:zA,p2:BA,p3:J(0,0,0),p4:e}),s=zA.add(i.mul(a.x)),c=e.mul(a.y),l=s.sub(c).length().div(Qk);if(!r){if(n&&t.currentSamples>0){let e=l.fwidth();o.assign(nD(e.negate().add(.5),e.add(.5),l).oneMinus())}else l.greaterThan(.5).discard()}}else if(n&&t.currentSamples>0){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),n=e.mul(e).add(t.mul(t)),r=q(n.fwidth()).toVar(`dlen`);gT(a.y.abs().greaterThan(1),()=>{o.assign(nD(r.oneMinus(),r.add(1),n).oneMinus())})}else gT(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return o})();var GA=new Cd,KA=class extends FA{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(GA),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?q(this.opacityNode):Gk;FT.assign(gD(ET(Rae(ik),e),go))}},qA=K(([e=JO])=>xT(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),JA=K(([e=QD()])=>{let t=e.x.sub(.5).mul(Math.PI*2),n=e.y.sub(.5).mul(Math.PI),r=n.cos();return J(r.mul(t.cos()),n.sin(),r.mul(t.sin()))}),YA=class extends Rs{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new wu(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,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;let i=new Ou(5,5,5),a=qA(JO),o=new FA;o.colorNode=nO(t,a,0),o.side=1,o.blending=0;let s=new Zl(i,o),c=new Tc;c.add(s),t.minFilter===1008&&(t.minFilter=Qi);let l=new wf(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.generateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},XA=new WeakMap,ZA=class extends Lw{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=yk(null);let t=new wu;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=kw.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===303||n===304){if(XA.has(e)){let t=XA.get(e);ej(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(QA(n)){let r=new YA(n.height);r.fromEquirectangularTexture(t,e),ej(r.texture,e.mapping),this._cubeTexture=r.texture,XA.set(e,r.texture),e.addEventListener(`dispose`,$A)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function QA(e){return e!=null&&e.height>0}function $A(e){let t=e.target;t.removeEventListener(`dispose`,$A);let n=XA.get(t);n!==void 0&&(XA.delete(t),n.dispose())}function ej(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var tj=fT(ZA).setParameterLength(1),nj=class extends bA{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=tj(this.envNode)}},rj=class extends bA{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=q(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},ij=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},aj=class extends ij{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(ET(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(ET(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(FT.rgb)}finish(e){let{material:t,context:n}=e,r=n.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case 0:r.rgb.assign(QE(r.rgb,r.rgb.mul(i.rgb),qk.mul(Jk)));break;case 1:r.rgb.assign(QE(r.rgb,i.rgb,qk.mul(Jk)));break;case 2:r.rgb.addAssign(i.rgb.mul(qk.mul(Jk)));break;default:B(`BasicLightingModel: Unsupported .combine value:`,t.combine)}}},oj=new zl,sj=class extends FA{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(oj),this.setValues(e)}setupNormal(){return QO(nk)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new nj(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new rj(eA)),t}setupOutgoingLight(){return FT.rgb}setupLightingModel(){return new aj}},cj=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),lj=K(e=>e.diffuseColor.mul(1/Math.PI)),uj=()=>q(.25),dj=K(({dotNH:e})=>eE.mul(q(.5)).add(1).mul(q(1/Math.PI)).mul(e.pow(eE))),fj=K(({lightDirection:e})=>{let t=e.add(XO).normalize(),n=ik.dot(t).clamp(),r=cj({f0:ZT,f90:1,dotVH:XO.dot(t).clamp()}),i=uj(),a=dj({dotNH:n});return r.mul(i).mul(a)}),pj=class extends aj{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=ik.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(lj({diffuseColor:FT.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(fj({lightDirection:e})).mul(qk))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(lj({diffuseColor:FT}))),r.indirectDiffuse.mulAssign(t)}},mj=new wd,hj=class extends FA{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(mj),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new nj(t):null}setupLightingModel(){return new pj(!1)}},gj=new xd,_j=class extends FA{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(gj),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new nj(t):null}setupLightingModel(){return new pj}setupVariants(){let e=(this.shininessNode?q(this.shininessNode):Wae).max(1e-4);eE.assign(e);let t=this.specularNode||Kae;ZT.assign(t)}},vj=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=nk.dFdx().abs().max(nk.dFdy().abs());return t.x.max(t.y).max(t.z)}),yj=K(e=>{let{roughness:t}=e,n=vj(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),bj=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return xE(.5,i.add(a).max(CE))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),xj=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(J(e.mul(n),t.mul(r),o).length()),l=o.mul(J(e.mul(i),t.mul(a),s).length());return xE(.5,c.add(l).max(CE))}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),Sj=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Cj=q(1/Math.PI),wj=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=J(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Cj.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),Tj=K(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,normalView:a=ik,USE_IRIDESCENCE:o,USE_ANISOTROPY:s})=>{let c=r.pow2(),l=e.add(XO).normalize(),u=a.dot(e).clamp(),d=a.dot(XO).clamp(),f=a.dot(l).clamp(),p=cj({f0:t,f90:n,dotVH:XO.dot(l).clamp()}),m,h;if(oT(o)&&(p=WT.mix(p,i)),oT(s)){let t=YT.dot(e),n=YT.dot(XO),r=YT.dot(l),i=XT.dot(e),a=XT.dot(XO),o=XT.dot(l);m=xj({alphaT:qT,alphaB:c,dotTV:n,dotBV:a,dotTL:t,dotBL:i,dotNV:d,dotNL:u}),h=wj({alphaT:qT,alphaB:c,dotNH:f,dotTH:r,dotBH:o})}else m=bj({alpha:c,dotNL:u,dotNV:d}),h=Sj({alpha:c,dotNH:f});return p.mul(m).mul(h)}),Ej=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Dj=null,Oj=K(({roughness:e,dotNV:t})=>{Dj===null&&(Dj=new eu(Ej,16,16,xa,ca),Dj.name=`DFG_LUT`,Dj.minFilter=Qi,Dj.magFilter=Qi,Dj.wrapS=qi,Dj.wrapT=qi,Dj.generateMipmaps=!1,Dj.needsUpdate=!0);let n=xT(e,t);return nO(Dj,n).rg}),kj=K(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let s=Tj({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}),c=ik.dot(e).clamp(),l=Oj({roughness:r,dotNV:ik.dot(XO).clamp()}),u=Oj({roughness:r,dotNV:c}),d=t.mul(l.x).add(n.mul(l.y)),f=t.mul(u.x).add(n.mul(u.y)),p=l.x.add(l.y),m=u.x.add(u.y),h=q(1).sub(p),g=q(1).sub(m),_=t.add(t.oneMinus().mul(.047619)),v=d.mul(f).mul(_).div(q(1).sub(h.mul(g).mul(_).mul(_)).add(CE)),y=h.mul(g),b=v.mul(y);return s.add(b)}),Aj=K(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=Oj({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),jj=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(J(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),Mj=K(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=q(1).div(n),i=t.pow2().oneMinus().max(.0078125);return q(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),Nj=K(({dotNV:e,dotNL:t})=>q(1).div(q(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),Pj=K(({lightDirection:e})=>{let t=e.add(XO).normalize(),n=ik.dot(e).clamp(),r=ik.dot(XO).clamp(),i=Mj({roughness:UT,dotNH:ik.dot(t).clamp()}),a=Nj({dotNV:r,dotNL:n});return HT.mul(i).mul(a)}),Fj=K(({N:e,V:t,roughness:n})=>{let r=xT(n,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),Ij=K(({f:e})=>{let t=e.length();return WE(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),Lj=K(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,WE(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),Rj=K(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=J().toVar();return gT(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(AT(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=J(0).toVar();g.addAssign(Lj({v1:f,v2:p})),g.addAssign(Lj({v1:p,v2:m})),g.addAssign(Lj({v1:m,v2:h})),g.addAssign(Lj({v1:h,v2:f})),d.assign(J(Ij({f:g})))}),d}).setLayout({name:`LTC_Evaluate`,type:`vec3`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`P`,type:`vec3`},{name:`mInv`,type:`mat3`},{name:`p0`,type:`vec3`},{name:`p1`,type:`vec3`},{name:`p2`,type:`vec3`},{name:`p3`,type:`vec3`}]}),zj=1/6,Bj=e=>bE(zj,bE(e,bE(e,e.negate().add(3)).sub(3)).add(1)),Vj=e=>bE(zj,bE(e,bE(e,bE(3,e).sub(6))).add(4)),Hj=e=>bE(zj,bE(e,bE(e,bE(-3,e).add(3)).add(3)).add(1)),Uj=e=>bE(zj,JE(e,3)),Wj=e=>Bj(e).add(Vj(e)),Gj=e=>Hj(e).add(Uj(e)),Kj=e=>vE(-1,Vj(e).div(Bj(e).add(Vj(e)))),qj=e=>vE(1,Uj(e).div(Hj(e).add(Uj(e)))),Jj=(e,t,n)=>{let r=e.uvNode,i=bE(r,t.zw).add(.5),a=kE(i),o=ME(i),s=Wj(o.x),c=Gj(o.x),l=Kj(o.x),u=qj(o.x),d=Kj(o.y),f=qj(o.y),p=xT(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=xT(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=xT(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=xT(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=Wj(o.y).mul(vE(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=Gj(o.y).mul(vE(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Yj=K(([e,t])=>{let n=xT(e.size(vT(t))),r=xT(e.size(vT(t.add(1)))),i=xE(1,n),a=xE(1,r),o=Jj(e,ET(i,n),kE(t)),s=Jj(e,ET(a,r),AE(t));return ME(t).mix(o,s)}),Xj=K(([e,t,n,r,i])=>{let a=J(tD(t.negate(),jE(e),xE(1,r))),o=J(RE(i[0].xyz),RE(i[1].xyz),RE(i[2].xyz));return jE(a).mul(n.mul(o))}).setLayout({name:`getVolumeTransmissionRay`,type:`vec3`,inputs:[{name:`n`,type:`vec3`},{name:`v`,type:`vec3`},{name:`thickness`,type:`float`},{name:`ior`,type:`float`},{name:`modelMatrix`,type:`mat4`}]}),Zj=K(([e,t])=>e.mul($E(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),Qj=CA(),$j=Ioe(),eM=K(([e,t,n],{material:r})=>Yj((r.side===1?Qj:$j).sample(e),DE(pO.x).mul(Zj(t,n)))),tM=K(([e,t,n])=>(gT(n.notEqual(0),()=>wE(EE(t).negate().div(n).negate().mul(e))),J(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),nM=K(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=ET().toVar(),g=J().toVar();let i=u.sub(1).mul(m.mul(.025)),a=J(u.sub(i),u,u.add(i));hA({start:0,end:3},({i})=>{let u=a.element(i),m=Xj(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(ET(_,1))),y=xT(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(xT(y.x,y.y.oneMinus()));let b=eM(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(tM(RE(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Xj(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(ET(a,1))),_=xT(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(xT(_.x,_.y.oneMinus())),h=eM(_,n,u),g=r.mul(tM(RE(i),f,p))}let _=g.rgb.mul(h.rgb),v=J(Aj({dotNV:e.dot(t).clamp(),specularColor:i,specularF90:a,roughness:n})),y=g.r.add(g.g,g.b).div(3);return ET(v.oneMinus().mul(_),h.a.oneMinus().mul(y).oneMinus())}),rM=AT(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),iM=e=>{let t=e.sqrt();return J(1).add(t).div(J(1).sub(t))},aM=(e,t)=>e.sub(t).div(e.add(t)).pow2(),oM=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=J(54856e-17,44201e-17,52481e-17),i=J(1681e3,1795300,2208400),a=J(43278e5,93046e5,66121e5),o=q(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());return s=J(s.x.add(o),s.y,s.z).div(1.0685e-7),rM.mul(s)},sM=K(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=QE(e,t,nD(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()).oneMinus();gT(o.lessThan(0),()=>J(1));let s=o.sqrt(),c=cj({f0:aM(a,e),f90:1,dotVH:n}),l=c.oneMinus(),u=a.lessThan(e).select(Math.PI,0),d=q(Math.PI).sub(u),f=iM(i.clamp(0,.9999)),p=cj({f0:aM(f,a.toVec3()),f90:1,dotVH:s}),m=J(f.x.lessThan(a).select(Math.PI,0),f.y.lessThan(a).select(Math.PI,0),f.z.lessThan(a).select(Math.PI,0)),h=a.mul(r,s,2),g=J(d).add(m),_=c.mul(p).clamp(1e-5,.9999),v=_.sqrt(),y=l.pow2().mul(p).div(J(1).sub(_)),b=c.add(y).toVar(),x=y.sub(l).toVar();return hA({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{x.mulAssign(v);let t=oM(q(e).mul(h),q(e).mul(g)).mul(2);b.addAssign(x.mul(t))}),b.max(J(0))}).setLayout({name:`evalIridescence`,type:`vec3`,inputs:[{name:`outsideIOR`,type:`float`},{name:`eta2`,type:`float`},{name:`cosTheta1`,type:`float`},{name:`thinFilmThickness`,type:`float`},{name:`baseF0`,type:`vec3`}]}),cM=K(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.mul(n),a=n.add(.1).reciprocal(),o=q(-1.9362).add(n.mul(1.0678)).add(i.mul(.4573)).sub(a.mul(.8469)),s=q(-.6014).add(n.mul(.5538)).sub(i.mul(.467)).sub(a.mul(.1255));return o.mul(r).add(s).exp().saturate()}),lM=J(.04),uM=q(1),dM=class extends ij{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=J().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=J().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=J().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=J().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=J().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=ik.dot(XO).clamp(),t=sM({outsideIOR:q(1),eta2:GT,cosTheta1:e,thinFilmThickness:KT,baseF0:ZT}),n=sM({outsideIOR:q(1),eta2:GT,cosTheta1:e,thinFilmThickness:KT,baseF0:FT.rgb});this.iridescenceFresnel=QE(t,n,zT),this.iridescenceF0Dielectric=jj({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=jj({f:n,f90:1,dotVH:e}),this.iridescenceF0=QE(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,zT)}if(this.transmission===!0){let t=qO,n=NO.sub(qO).normalize(),r=ak,i=e.context;i.backdrop=nM(r,n,RT,IT,QT,$T,t,LO,jO,kO,iE,oE,cE,sE,this.dispersion?lE:null),i.backdropAlpha=aE,FT.a.mulAssign(QE(1,i.backdrop.a,aE))}super.start(e)}computeMultiscattering(e,t,n,r,i=null){let a=Oj({roughness:RT,dotNV:ik.dot(XO).clamp()}),o=i?WT.mix(r,i):r,s=o.mul(a.x).add(n.mul(a.y)),c=a.x.add(a.y).oneMinus(),l=o.add(o.oneMinus().mul(.047619)),u=s.mul(l).div(c.mul(l).oneMinus());e.addAssign(s),t.addAssign(u.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=ik.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(r.mul(Pj({lightDirection:e})));let t=cM({normal:ik,viewDir:XO,roughness:UT}),n=cM({normal:ik,viewDir:e,roughness:UT}),i=HT.r.max(HT.g).max(HT.b).mul(t.max(n)).oneMinus();r.mulAssign(i)}if(this.clearcoat===!0){let n=ok.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(Tj({lightDirection:e,f0:lM,f90:uM,roughness:VT,normalView:ok})))}n.directDiffuse.addAssign(r.mul(lj({diffuseColor:IT}))),n.directSpecular.addAssign(r.mul(kj({lightDirection:e,f0:QT,f90:1,roughness:RT,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=ik,f=XO,p=YO.toVar(),m=Fj({N:d,V:f,roughness:RT}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=AT(J(h.x,0,h.y),J(0,1,0),J(h.z,0,h.w)).toVar(),v=QT.mul(g.x).add($T.sub(QT).mul(g.y)).toVar();if(i.directSpecular.addAssign(e.mul(v).mul(Rj({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(IT).mul(Rj({N:d,V:f,P:p,mInv:AT(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u}))),this.clearcoat===!0){let t=ok,n=Fj({N:t,V:f,roughness:VT}),r=a.sample(n),i=o.sample(n),d=AT(J(r.x,0,r.y),J(0,1,0),J(r.z,0,r.w)),m=lM.mul(i.x).add(uM.sub(lM).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(Rj({N:t,V:f,P:p,mInv:d,p0:s,p1:c,p2:l,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context,r=t.mul(lj({diffuseColor:IT})).toVar();if(this.sheen===!0){let e=cM({normal:ik,viewDir:XO,roughness:UT}),t=HT.r.max(HT.g).max(HT.b).mul(e).oneMinus();r.mulAssign(t)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(HT,cM({normal:ik,viewDir:XO,roughness:UT}))),this.clearcoat===!0){let e=Aj({dotNV:ok.dot(XO).clamp(),specularColor:lM,specularF90:uM,roughness:VT});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let i=J().toVar(`singleScatteringDielectric`),a=J().toVar(`multiScatteringDielectric`),o=J().toVar(`singleScatteringMetallic`),s=J().toVar(`multiScatteringMetallic`);this.computeMultiscattering(i,a,$T,ZT,this.iridescenceF0Dielectric),this.computeMultiscattering(o,s,$T,FT.rgb,this.iridescenceF0Metallic);let c=QE(i,o,zT),l=QE(a,s,zT),u=i.add(a),d=IT.mul(u.oneMinus()),f=n.mul(1/Math.PI),p=t.mul(c).add(l.mul(f)).toVar(),m=d.mul(f).toVar();if(this.sheen===!0){let e=cM({normal:ik,viewDir:XO,roughness:UT}),t=HT.r.max(HT.g).max(HT.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,r=ik.dot(XO).clamp().add(t),i=RT.mul(-16).oneMinus().negate().exp2(),a=t.sub(r.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=cj({dotVH:ok.dot(XO).clamp(),f0:lM,f90:uM}),n=t.mul(BT.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(BT));t.assign(n)}if(this.sheen===!0){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}},fM=q(1),pM=q(-2),mM=q(.8),hM=q(-1),gM=q(.4),_M=q(2),vM=q(.305),yM=q(3),bM=q(.21),xM=q(4),SM=q(4),CM=q(16),wM=K(([e])=>{let t=J(IE(e)).toVar(),n=q(-1).toVar();return gT(t.x.greaterThan(t.z),()=>{gT(t.x.greaterThan(t.y),()=>{n.assign(rD(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(rD(e.y.greaterThan(0),1,4))})}).Else(()=>{gT(t.z.greaterThan(t.y),()=>{n.assign(rD(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(rD(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),TM=K(([e,t])=>{let n=xT().toVar();return gT(t.equal(0),()=>{n.assign(xT(e.z,e.y).div(IE(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(xT(e.x.negate(),e.z.negate()).div(IE(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(xT(e.x.negate(),e.y).div(IE(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(xT(e.z.negate(),e.y).div(IE(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(xT(e.x.negate(),e.z).div(IE(e.y)))}).Else(()=>{n.assign(xT(e.x,e.y).div(IE(e.z)))}),bE(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),EM=K(([e])=>{let t=q(0).toVar();return gT(e.greaterThanEqual(mM),()=>{t.assign(fM.sub(e).mul(hM.sub(pM)).div(fM.sub(mM)).add(pM))}).ElseIf(e.greaterThanEqual(gM),()=>{t.assign(mM.sub(e).mul(_M.sub(hM)).div(mM.sub(gM)).add(hM))}).ElseIf(e.greaterThanEqual(vM),()=>{t.assign(gM.sub(e).mul(yM.sub(_M)).div(gM.sub(vM)).add(_M))}).ElseIf(e.greaterThanEqual(bM),()=>{t.assign(vM.sub(e).mul(xM.sub(yM)).div(vM.sub(bM)).add(yM))}).Else(()=>{t.assign(q(-2).mul(DE(bE(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),DM=K(([e,t])=>{let n=e.toVar();n.assign(bE(2,n).sub(1));let r=J(n,1).toVar();return gT(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),OM=K(([e,t,n,r,i,a])=>{let o=q(n),s=J(t),c=$E(EM(o),pM,a),l=ME(c),u=kE(c),d=J(kM(e,s,u,r,i,a)).toVar();return gT(l.notEqual(0),()=>{let t=J(kM(e,s,u.add(1),r,i,a)).toVar();d.assign(QE(d,t,l))}),d}),kM=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=J(t),c=q(wM(s)).toVar(),l=q(WE(SM.sub(o),0)).toVar();o.assign(WE(o,SM));let u=q(TE(o)).toVar(),d=xT(TM(s,c).mul(u.sub(2)).add(1)).toVar();return gT(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(bE(3,CM))),d.y.addAssign(bE(4,TE(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(xT(),xT())}),AM=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=PE(r);return kM(e,n.mul(c).add(i.cross(n).mul(NE(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),jM=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=J(rD(t,n,qE(n,r))).toVar();gT(f.equal(J(0)),()=>{f.assign(J(r.z,0,r.x.negate()))}),f.assign(jE(f));let p=J().toVar();return p.addAssign(i.element(0).mul(AM({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),hA({start:vT(1),end:e},({i:e})=>{gT(e.greaterThanEqual(a),()=>{koe()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(AM({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(AM({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),ET(p,1)}),MM=K(([e])=>{let t=yT(e).toVar();return t.assign(t.shiftLeft(yT(16)).bitOr(t.shiftRight(yT(16)))),t.assign(t.bitAnd(yT(1431655765)).shiftLeft(yT(1)).bitOr(t.bitAnd(yT(2863311530)).shiftRight(yT(1)))),t.assign(t.bitAnd(yT(858993459)).shiftLeft(yT(2)).bitOr(t.bitAnd(yT(3435973836)).shiftRight(yT(2)))),t.assign(t.bitAnd(yT(252645135)).shiftLeft(yT(4)).bitOr(t.bitAnd(yT(4042322160)).shiftRight(yT(4)))),t.assign(t.bitAnd(yT(16711935)).shiftLeft(yT(8)).bitOr(t.bitAnd(yT(4278255360)).shiftRight(yT(8)))),q(t).mul(23283064365386963e-26)}),NM=K(([e,t])=>xT(q(e).div(q(t)),MM(e))),PM=K(([e,t,n])=>{let r=n.mul(n).toConst(),i=J(1,0,0).toConst(),a=qE(t,i).toConst(),o=OE(e.x).toConst(),s=bE(2,3.14159265359).mul(e.y).toConst(),c=o.mul(PE(s)).toConst(),l=o.mul(NE(s)).toVar(),u=bE(.5,t.z.add(1)).toConst();l.assign(u.oneMinus().mul(OE(c.mul(c).oneMinus())).add(u.mul(l)));let d=i.mul(c).add(a.mul(l)).add(t.mul(OE(WE(0,c.mul(c).add(l.mul(l)).oneMinus()))));return jE(J(r.mul(d.x),r.mul(d.y),WE(0,d.z)))}),FM=K(({roughness:e,mipInt:t,envMap:n,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=J(r).toVar(),l=J(0).toVar(),u=q(0).toVar();return gT(e.lessThan(.001),()=>{l.assign(kM(n,c,t,a,o,s))}).Else(()=>{let r=jE(qE(rD(IE(c.z).lessThan(.999),J(0,0,1),J(1,0,0)),c)).toVar(),d=qE(c,r).toVar();hA({start:yT(0),end:i},({i:f})=>{let p=PM(NM(f,i),J(0,0,1),e),m=jE(r.mul(p.x).add(d.mul(p.y)).add(c.mul(p.z))),h=jE(m.mul(KE(c,m).mul(2)).sub(c)),g=WE(KE(c,h),0);gT(g.greaterThan(0),()=>{let e=kM(n,h,t,a,o,s);l.addAssign(e.mul(g)),u.addAssign(g)})}),gT(u.greaterThan(0),()=>{l.assign(l.div(u))})}),ET(l,1)}),IM=4,LM=[.125,.215,.35,.446,.526,.582],RM=20,zM=512,BM=new hf(-1,1,1,-1,0,1),VM=new uf(90,1),HM=new Cc,UM=null,WM=0,GM=0,KM=new U,qM=new WeakMap,JM=[3,1,5,0,4,2],YM=DM(QD(),ZD(`faceIndex`)).normalize(),XM=J(YM.x,YM.y,YM.z),ZM=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=KM,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.`);UM=this._renderer.getRenderTarget(),WM=this._renderer.getActiveCubeFace(),GM=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget(!0);return this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return Bo(`PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return Bo(`PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return Bo(`PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=rN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=iN(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(UM,WM,GM),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),UM=this._renderer.getRenderTarget(),WM=this._renderer.getActiveCubeFace(),GM=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget(!1);return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(e){return $M(3*Math.max(this._cubeSize,112),4*this._cubeSize,e)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=$M(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=QM(t)),this._blurMaterial=tN(t,e.width,e.height),this._ggxMaterial=nN(t,e.width,e.height)}}async _compileMaterial(e){let t=new Zl(new wl,e);await this._renderer.compile(t,BM)}_sceneToCubeUV(e,t,n,r,i){let a=VM;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(HM),c.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new Zl(new Ou,new zl({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,f=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,f=!0):(d.color.copy(HM),f=!0),c.setRenderTarget(r),c.clear(),f&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;this._setViewport(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=rN(e)):this._equirectMaterial===null&&(this._equirectMaterial=iN(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,BM)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;t<r;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let s=qM.get(a),c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l)*(0+c*1.25),{_lodMax:d}=this,f=this._sizeLods[n],p=3*f*(n>d-IM?n-d+IM:0),m=4*(this._cubeSize-f);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,this._setViewport(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,BM),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,this._setViewport(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,BM)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&V(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=qM.get(c),d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/39,p=i/f,m=isFinite(i)?1+Math.floor(3*p):RM;m>RM&&B(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${RM}`);let h=[],g=0;for(let e=0;e<RM;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=h,u.latitudinal.value=+(a===`latitudinal`),o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r],y=3*v*(r>_-IM?r-_+IM:0),b=4*(this._cubeSize-v);this._setViewport(t,y,b,3*v,2*v),s.setRenderTarget(t),s.render(l,BM)}_setViewport(e,t,n,r,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-n,r,i),e.scissor.set(t,e.height-i-n,r,i)):(e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i))}};function QM(e){let t=[],n=[],r=[],i=e,a=e-IM+1+LM.length;for(let o=0;o<a;o++){let a=2**i;t.push(a);let s=1/a;o>e-IM?s=LM[o-e+IM-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=JM[e];f.set(r,18*i),p.set(d,12*i);let a=[i,i,i,i,i,i];m.set(a,6*i)}let h=new wl;h.setAttribute(`position`,new cl(f,3)),h.setAttribute(`uv`,new cl(p,2)),h.setAttribute(`faceIndex`,new cl(m,1)),r.push(new Zl(h,null)),i>IM&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function $M(e,t,n){let r=new Rs(e,t,{magFilter:Qi,minFilter:Qi,generateMipmaps:!1,type:ca,format:ga,colorSpace:_o,depthBuffer:n});return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function eN(e){let t=new FA;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function tN(e,t,n){let r=oO(Array(RM).fill(0)),i=hE(new U(0,1,0)),a=hE(0),o=q(RM),s=hE(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:XM,dTheta:a,samples:hE(1),envMap:nO(),mipInt:hE(0),CUBEUV_TEXEL_WIDTH:q(1/t),CUBEUV_TEXEL_HEIGHT:q(1/n),CUBEUV_MAX_MIP:q(e)},l=eN(`blur`);return l.fragmentNode=jM({...c,latitudinal:s.equal(1)}),qM.set(l,c),l}function nN(e,t,n){let r={envMap:nO(),roughness:hE(0),mipInt:hE(0),CUBEUV_TEXEL_WIDTH:q(1/t),CUBEUV_TEXEL_HEIGHT:q(1/n),CUBEUV_MAX_MIP:q(e)},i=eN(`ggx`);return i.fragmentNode=FM({...r,N_immutable:XM,GGX_SAMPLES:yT(zM)}),qM.set(i,r),i}function rN(e){let t=eN(`cubemap`);return t.fragmentNode=yk(e,XM),t}function iN(e){let t=eN(`equirect`);return t.fragmentNode=nO(e,qA(XM),0),t}var aN=new WeakMap;function oN(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:n,maxMip:t}}function sN(e,t,n){let r=cN(t),i=r.get(e);if((i===void 0?-1:i.pmremVersion)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture){if(uN(t))i=n.fromCubemap(e,i);else return null}else if(dN(t))i=n.fromEquirectangular(e,i);else return null;if(i.pmremVersion=e.pmremVersion,r.has(e)===!1){let t=()=>{e.removeEventListener(`dispose`,t);let n=r.get(e);n!==void 0&&(n.dispose(),r.delete(e))};e.addEventListener(`dispose`,t)}r.set(e,i)}return i.texture}function cN(e){let t=aN.get(e);return t===void 0&&(t=new WeakMap,aN.set(e,t)),t}var lN=class extends Lw{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new Is;r.isRenderTargetTexture=!0,this._texture=nO(r),this._width=hE(0),this._height=hE(0),this._maxMip=hE(0),this.updateBeforeType=kw.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=oN(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0||r.mapping===306?r:sN(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new ZM(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?fk.mul(J(t.x,t.y.negate(),t.z)):fk.mul(t);let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),OM(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function uN(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function dN(e){return e!=null&&e.height>0}var fN=fT(lN).setParameterLength(1,3),pN=new WeakMap,mN=class extends bA{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let r=n.isTextureNode?n.value:t[n.property],i=this._getPMREMNodeCache(e.renderer),a=i.get(r);a===void 0&&(a=fN(r),i.set(r,a)),n=a}let r=t.useAnisotropy===!0||t.anisotropy>0?Lae:ik,i=n.context(hN(RT,r)).mul(dk),a=n.context(gN(ak)).mul(Math.PI).mul(dk),o=ID(i),s=ID(a);e.context.radiance.addAssign(o),e.context.iblIrradiance.addAssign(s);let c=e.context.lightingModel.clearcoatRadiance;if(c){let e=ID(n.context(hN(VT,ok)).mul(dk));c.addAssign(e)}}_getPMREMNodeCache(e){let t=pN.get(e);return t===void 0&&(t=new WeakMap,pN.set(e,t)),t}},hN=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=XO.negate().reflect(t),n=XE(e).mix(n,t).normalize(),n=n.transformDirection(MO)),n),getTextureLevel:()=>e}},gN=e=>({getUV:()=>e,getTextureLevel:()=>q(1)}),_N=new yd,vN=class extends FA{static get type(){return`MeshStandardNodeMaterial`}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(_N),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new mN(t):null}setupLightingModel(){return new dM}setupSpecular(){let e=QE(J(.04),FT.rgb,zT);ZT.assign(J(.04)),QT.assign(e),$T.assign(1)}setupVariants(){let e=this.metalnessNode?q(this.metalnessNode):Yae;zT.assign(e);let t=this.roughnessNode?q(this.roughnessNode):Jae;t=yj({roughness:t}),RT.assign(t),this.setupSpecular(),IT.assign(FT.rgb.mul(e.oneMinus()))}},yN=new bd,bN=class extends vN{static get type(){return`MeshPhysicalNodeMaterial`}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(yN),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?q(this.iorNode):loe;iE.assign(e),ZT.assign(UE(YE(iE.sub(1).div(iE.add(1))).mul(qae),J(1)).mul(Kk)),QT.assign(QE(ZT,FT.rgb,zT)),$T.assign(QE(Kk,1,zT))}setupLightingModel(){return new dM(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?q(this.clearcoatNode):Zae,t=this.clearcoatRoughnessNode?q(this.clearcoatRoughnessNode):Qae;BT.assign(e),VT.assign(yj({roughness:t}))}if(this.useSheen){let e=this.sheenNode?J(this.sheenNode):toe,t=this.sheenRoughnessNode?q(this.sheenRoughnessNode):noe;HT.assign(e),UT.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?q(this.iridescenceNode):ioe,t=this.iridescenceIORNode?q(this.iridescenceIORNode):aoe,n=this.iridescenceThicknessNode?q(this.iridescenceThicknessNode):ooe;WT.assign(e),GT.assign(t),KT.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?xT(this.anisotropyNode):roe).toVar();JT.assign(e.length()),gT(JT.equal(0),()=>{e.assign(xT(1,0))}).Else(()=>{e.divAssign(xT(JT)),JT.assign(JT.saturate())}),qT.assign(JT.pow2().mix(RT.pow2(),1)),YT.assign(Vk[0].mul(e.x).add(Vk[1].mul(e.y))),XT.assign(Vk[1].mul(e.x).sub(Vk[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?q(this.transmissionNode):soe,t=this.thicknessNode?q(this.thicknessNode):coe,n=this.attenuationDistanceNode?q(this.attenuationDistanceNode):uoe,r=this.attenuationColorNode?J(this.attenuationColorNode):doe;if(aE.assign(e),oE.assign(t),sE.assign(n),cE.assign(r),this.useDispersion){let e=this.dispersionNode?q(this.dispersionNode):poe;lE.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?J(this.clearcoatNormalNode):$ae}setup(e){e.context.setupClearcoatNormal=()=>uD(this.setupClearcoatNormal(e),`NORMAL`,`vec3`),super.setup(e)}},xN=K(({normal:e,lightDirection:t,builder:n})=>{let r=xT(e.dot(t).mul(.5).add(.5),0);if(n.material.gradientMap)return J(Tk(`gradientMap`,`texture`).context({getUV:()=>r}).r);{let e=r.fwidth().mul(.5);return QE(J(.7),J(1),nD(q(.7).sub(e.x),q(.7).add(e.x),r.x))}}),SN=class extends ij{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=xN({normal:$O,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(lj({diffuseColor:FT.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(lj({diffuseColor:FT}))),r.indirectDiffuse.mulAssign(t)}},CN=new Sd,wN=class extends FA{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(CN),this.setValues(e)}setupLightingModel(){return new SN}},TN=K(()=>{let e=J(XO.z,0,XO.x.negate()).normalize(),t=XO.cross(e);return xT(e.dot(ik),t.dot(ik)).mul(.495).add(.5)}).once([`NORMAL`,`VERTEX`])().toVar(`matcapUV`),EN=new Dd,DN=class extends FA{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(EN),this.setValues(e)}setupVariants(e){let t=TN,n;n=e.material.matcap?Tk(`matcap`,`texture`).context({getUV:()=>t}):J(QE(.2,.8,t.y)),FT.rgb.mulAssign(n.rgb)}},ON=fT(class extends Lw{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return kT(e,r,r.negate(),e).mul(n)}{let e=t,r=jT(ET(1,0,0,0),ET(0,PE(e.x),NE(e.x).negate(),0),ET(0,NE(e.x),PE(e.x),0),ET(0,0,0,1)),i=jT(ET(PE(e.y),0,NE(e.y),0),ET(0,1,0,0),ET(NE(e.y).negate(),0,PE(e.y),0),ET(0,0,0,1)),a=jT(ET(PE(e.z),NE(e.z).negate(),0,0),ET(NE(e.z),PE(e.z),0,0),ET(0,0,1,0),ET(0,0,0,1));return r.mul(i).mul(a).mul(ET(n,1)).xyz}}}).setParameterLength(2),kN=new Al,AN=class extends FA{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(kN),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,{positionNode:r,rotationNode:i,scaleNode:a,sizeAttenuation:o}=this,s=zO.mul(J(r||0)),c=xT(LO[0].xyz.length(),LO[1].xyz.length());a!==null&&(c=c.mul(xT(a))),n.isPerspectiveCamera&&o===!1&&(c=c.mul(s.z.negate()));let l=WO.xy;if(t.center&&t.center.isVector2===!0){let e=yD(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=q(i||eoe),d=ON(l,u);return ET(s.xy.add(d),s.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},jN=new Su,MN=new H,NN=class extends AN{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(jN),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return zO.mul(J(e||GO)).xyz}setupVertexSprite(e){let{material:t,camera:n}=e,{rotationNode:r,scaleNode:i,sizeNode:a,sizeAttenuation:o}=this,s=super.setupVertex(e);if(t.isNodeMaterial!==!0)return s;let c=a===null?foe:xT(a);c=c.mul(dO),n.isPerspectiveCamera&&o===!0&&(c=c.mul(PN.div(YO.z.negate()))),i&&i.isNode&&(c=c.mul(xT(i)));let l=WO.xy;if(r&&r.isNode){let e=q(r);l=ON(l,e)}return l=l.mul(c),l=l.div(Nae.div(2)),l=l.mul(s.w),s=s.add(ET(l,0,0)),s}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},PN=hE(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(MN);this.value=.5*t.y}),FN=class extends ij{constructor(){super(),this.shadowNode=q(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){FT.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(FT.rgb)}},IN=new cd,LN=class extends FA{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(IN),this.setValues(e)}setupLightingModel(){return new FN}};NT(`vec3`),NT(`vec3`),NT(`vec3`);var RN=class{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<`u`?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},zN=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},BN=0,VN=new WeakMap;function HN(e){let t=Object.keys(e),n=VN.get(e.constructor);if(n===void 0){n=[];let t=Object.getPrototypeOf(e);for(;t;){let e=Object.getOwnPropertyDescriptors(t);for(let t in e){let r=e[t];r&&typeof r.get==`function`&&n.push(t)}t=Object.getPrototypeOf(t)}VN.set(e.constructor,n)}for(let e=0;e<n.length;e++)t.push(n[e]);return t}var UN=class{constructor(e,t,n,r,i,a,o,s,c,l){this.id=BN++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=i,this.scene=a,this.camera=o,this.lightsNode=s,this.context=c,this.geometry=r.geometry,this.version=i.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=l,this.clippingContextCacheKey=l===null?``:l.cacheKey,this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this._sourceMaterial=n._currentSourceMaterial,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener(`dispose`,this.onMaterialDispose),this.geometry.addEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener(`dispose`,this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set,i={};for(let a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:(e=t.getAttribute(a.name),e!==void 0&&(e.isInterleavedBufferAttribute?i[a.name]=e.data.uuid:i[a.name]=e.id)),e===void 0)continue;n.push(e);let o=e.isInterleavedBufferAttribute?e.data:e;r.add(o)}return this.attributes=n,this.attributesId=i,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},o=this.getIndex(),s=o!==null,c=1;if(n.isInstancedBufferGeometry===!0?c=n.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let u=i.start*l,d=(i.start+i.count)*l;r!==null&&(u=Math.max(u,r.start*l),d=Math.min(d,(r.start+r.count)*l));let f=n.attributes.position,p=1/0;s?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=u,a)}getGeometryCacheKey(){let{geometry:e}=this,t=``;for(let n of Object.keys(e.attributes).sort()){let r=e.attributes[n];t+=n+`,`,r.data&&(t+=r.data.stride+`,`),r.offset&&(t+=r.offset+`,`),r.itemSize&&(t+=r.itemSize+`,`),r.normalized&&(t+=`n,`)}for(let n of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[n];t+=`morph-`+n+`,`;for(let e=0,n=r.length;e<n;e++){let n=r[e];t+=n.id+`,`}}return e.index&&(t+=`index,`),t}getMaterialCacheKey(){let{object:e,material:t,renderer:n}=this,r=t.customProgramCacheKey();for(let e of HN(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let i=t[e],a;if(i!==null){let t=typeof i;t===`number`?a=e===`side`?String(i):i===0?`0`:`1`:t===`object`?(a=`{`,i.isTexture&&(a+=i.mapping,n.backend.isWebGPUBackend===!0&&(a+=i.magFilter,a+=i.minFilter,a+=i.wrapS,a+=i.wrapT,a+=i.wrapR)),a+=`}`):a=String(i)}else a=String(i);r+=a+`,`}return r+=this.clippingContextCacheKey+`,`,e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+`,`),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+`,`,e._colorsTexture!==null&&(r+=e._colorsTexture.uuid+`,`)),(e.isInstancedMesh||e.count>1)&&(r+=e.uuid+`,`),r+=this.context.id+`,`,r+=e.receiveShadow+`,`,bw(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let n=this.geometry.getAttribute(t);if(n===void 0)return!0;let r=n.isInterleavedBufferAttribute?n.data.uuid:n.id;if(e[t]!==r)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Sw(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Sw(e,1)),e=Sw(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.geometry.removeEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener(`dispose`,this.onMaterialDispose),this.onDispose()}},WN=[],GN=class{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,o,s){let c=this.getChainMap(s);WN[0]=e,WN[1]=t,WN[2]=a,WN[3]=i;let l=c.get(WN);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(WN,l)):(l.camera=r,l.updateClipping(o),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey===l.getCacheKey()?l.version=t.version:(l.dispose(),l=this.get(e,t,n,r,i,a,o,s)))),WN[0]=null,WN[1]=null,WN[2]=null,WN[3]=null,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new zN)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new UN(e,t,n,r,i,a,o,s,c,l);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},KN=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},qN={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},JN=16,YN=211,XN=212,ZN=class extends KN{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===qN.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===qN.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===qN.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===qN.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version<t.version||t.usage===35048)&&(this.backend.updateAttribute(e),n.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function QN(e){return e.index===null?e.attributes.position.version:e.index.version}function $N(e){return e.index===null?e.attributes.position.id:e.index.id}function eP(e){let t=[],n=e.index,r=e.attributes.position;if(n!==null){let e=n.array;for(let n=0,r=e.length;n<r;n+=3){let r=e[n+0],i=e[n+1],a=e[n+2];t.push(r,i,i,a,a,r)}}else{let e=r.array;for(let n=0,r=e.length/3-1;n<r;n+=3){let e=n+0,r=n+1,i=n+2;t.push(e,r,r,i,i,e)}}let i=new(r.count>=65535?ul:ll)(t,1);return i.version=QN(e),i.__id=$N(e),i}var tP=class extends KN{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(let e of i)this.attributes.delete(e);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener(`dispose`,r),this._geometryDisposeListeners.delete(t)};t.addEventListener(`dispose`,r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){let t=e.getAttributes();for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,qN.STORAGE):this.updateAttribute(e,qN.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,qN.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,qN.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:n}=e,r=t.index;if(n.wireframe===!0){let e=this.wireframes,n=e.get(t);n===void 0?(n=eP(t),e.set(t,n)):(n.version!==QN(t)||n.__id!==$N(t))&&(this.attributes.delete(n),n=eP(t),e.set(t,n)),r=n}return r}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener(`dispose`,t);this._geometryDisposeListeners.clear()}},nP=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*n:e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=t/2*n:e.isLine?this.render.lines+=n*(t-1):V(`WebGPUInfo: Unknown object type.`)}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(let e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let n=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:n,type:t}),this.memory[t]++,this.memory.total+=n,this.memory[t+`Size`]+=n}createAttribute(e){this._createAttribute(e,`attributes`)}createIndexAttribute(e){this._createAttribute(e,`indexAttributes`)}createStorageAttribute(e){this._createAttribute(e,`storageAttributes`)}createIndirectStorageAttribute(e){this._createAttribute(e,`indirectStorageAttributes`)}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+`Size`]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:`readbackBuffers`}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:`uniformBuffers`}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===1010||e.type===1009?t=1:e.type===1011||e.type===1012||e.type===1016?t=2:(e.type===1013||e.type===1014||e.type===1015)&&(t=4);let n=4;e.format===1021||e.format===1028||e.format===1029||e.format===1026||e.format===1027?n=1:e.format===1030||e.format===1031?n=2:(e.format===1022||e.format===1032)&&(n=3);let r=t*n;e.type===1017||e.type===1018?r=2:(e.type===1020||e.type===35902||e.type===35899)&&(r=4);let i=e.width||1,a=e.height||1,o=e.isCubeTexture?6:e.depth||1,s=i*a*o*r,c=e.mipmaps;if(c&&c.length>0){let e=0;for(let t=0;t<c.length;t++){let n=c[t];if(n.data)e+=n.data.byteLength;else{let s=n.width||Math.max(1,i>>t),c=n.height||Math.max(1,a>>t);e+=s*c*o*r}}s+=e}else e.generateMipmaps&&(s*=1.333);return Math.round(s)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},rP=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},iP=class extends rP{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},aP=class extends rP{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},oP=0,sP=class{constructor(e,t,n,r=null,i=null){this.id=oP++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},cP=class extends KN{constructor(e,t,n){super(),this.backend=e,this.nodes=t,this.info=n,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);o===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),o=new sP(a.computeShader,`compute`,e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),n.createProgram(o),this.info.createProgram(o));let s=this._getComputeCacheKey(e,o),c=this.caches.get(s);c===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),c=this._getComputePipeline(e,o,s,t)),c.usedTimes++,o.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){let{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let a=e.getNodeBuilderState(),o=e.material?e.material.name:``,s=this.programs.vertex.get(a.vertexShader);s===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),s=new sP(a.vertexShader,`vertex`,o),this.programs.vertex.set(a.vertexShader,s),n.createProgram(s),this.info.createProgram(s));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),c=new sP(a.fragmentShader,`fragment`,o),this.programs.fragment.set(a.fragmentShader,c),n.createProgram(c),this.info.createProgram(c));let l=this._getRenderCacheKey(e,s,c),u=this.caches.get(l);u===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),u=this._getRenderPipeline(e,s,c,l,t)):e.pipeline=u,u.usedTimes++,s.usedTimes++,c.usedTimes++,r.pipeline=u}return r.pipeline}isReady(e){let t=this.get(e).pipeline;if(t===void 0)return!1;let n=this.backend.get(t);return n.pipeline!==void 0&&n.pipeline!==null}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n||=this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new aP(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r||=this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new iP(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+`,`+t.id}_getRenderCacheKey(e,t,n){return t.id+`,`+n.id+`,`+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},lP=class extends KN{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),n=this.get(e);return n.initialized!==!0&&(this._createBindings(t),n.initialized=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,n=this.get(e);return(n.initialized!==!0||n.bindings!==t)&&(n.bindings!==void 0&&this._destroyBindings(n.bindings),this._createBindings(t),n.initialized=!0,n.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){let t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let n=this.get(t);if(n.bindGroup===void 0){for(let e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e);else if(e.isStorageBuffer){let t=e.attribute,n=t.isIndirectStorageBufferAttribute?qN.INDIRECT:qN.STORAGE;this.attributes.update(t,n)}this.backend.createBindings(t,e,0),n.bindGroup=t,n.usedTimes=1}else n.usedTimes++}}_destroyBindings(e){for(let t of e){let e=this.get(t);if(e.usedTimes--,e.usedTimes===0){for(let e of t.bindings)e.isUniformBuffer?(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release()):e.isSampler&&(e.isSampledTexture!==!0&&this.backend.destroySampler(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:n}=this,r=!1,i=!0,a=0,o=0;for(let t of e.bindings)if(this.nodes.updateGroup(t)!==!1){if(t.isStorageBuffer){let e=t.attribute,i=e.isIndirectStorageBufferAttribute?qN.INDIRECT:qN.STORAGE,a=n.get(t);this.attributes.update(e,i),a.attribute!==e&&(a.attribute=e,r=!0)}if(t.isUniformBuffer)t.update()&&n.updateBinding(t);else if(t.isSampledTexture){let s=t.update(),c=t.texture,l=this.textures.get(c);if(s&&(this.textures.updateTexture(c),t.generation!==l.generation&&(t.generation=l.generation,r=!0),l.bindGroups.add(e)),n.get(c).externalTexture!==void 0||l.isDefaultTexture?i=!1:(a=a*10+c.id,o+=c.version),c.isStorageTexture===!0&&c.mipmapsAutoUpdate===!0){let e=this.get(c);t.store===!0?e.needsMipmap=!0:this.textures.needsMipmaps(c)&&e.needsMipmap===!0&&(this.backend.generateMipmaps(c),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t);t.samplerKey!==e&&(t.samplerKey=e,r=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,i?a:0,o)}},uP=Object.freeze([]);function dP(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function fP(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function pP(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===2&&e.forceSinglePass===!1}var mP=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,o){let s=this.renderItems[this.renderItemsIndex];return s===void 0?(s={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.groupOrder=r,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}push(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(pP(n)&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}unshift(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(pP(n)&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,n){this.opaque.length>1&&this.opaque.sort(e||dP),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||fP),this.transparent.length>1&&this.transparent.sort(t||fP),n&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:uP);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let t=this.renderItems[e];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}this._lastOcclusionObject=null}},hP=[],gP=class{constructor(e){this.lighting=e,this.lists=new zN}get(e,t){let n=this.lists;hP[0]=e,hP[1]=t;let r=n.get(hP);return r===void 0&&(r=new mP(this.lighting,e,t),n.set(hP,r)),hP[0]=null,hP[1]=null,r}dispose(){this.lists=new zN}},_P=0,vP=class{constructor(){this.id=_P++,this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Ls,this.scissor=!1,this.scissorValue=new Ls,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}getCacheKey(){return yP(this)}};function yP(e){let{textures:t,activeCubeFace:n,activeMipmapLevel:r}=e,i=[n,r];for(let e of t)i.push(e.id);return xw(i)}var bP=class{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,n=0){let r;if(e===null)r=`default`;else{let t=e.texture.format,n=e.texture.type;r=`${e.textures.length}:${t}:${n}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let i=t===null?`default`:t.id,a=r+`-`+i+`-`+n,o=this._renderContexts[a];return o===void 0&&(o=new vP,o.mrt=t,this._renderContexts[a]=o),e!==null&&(o.sampleCount=e.samples===0?1:e.samples),o.clearDepthValue=this.renderer.getClearDepth(),o.clearStencilValue=this.renderer.getClearStencil(),o}dispose(){this._renderContexts={}}},xP=new U,SP=class extends KN{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n,this._htmlTextures=new Set}updateRenderTarget(e,t=0){let n=this.get(e),r=e.samples===0?1:e.samples,i=n.depthTextureMips||={},a=e.textures,o=this.getSize(a[0]),s=o.width>>t,c=o.height>>t,l=e.depthTexture||i[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1,f=l!==void 0&&l.image!==void 0&&l.image.depth>1,p=o.depth>1&&(e.useArrayDepthTexture||e.multiview||f);l===void 0&&u&&(l=new Tu,l.format=e.stencilBuffer?va:_a,l.type=e.stencilBuffer?da:oa,l.image.width=s,l.image.height=c,l.image.depth=o.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),(n.width!==o.width||o.height!==n.height)&&(d=!0,l&&(l.needsUpdate=!0,l.image.width=s,l.image.height=c,l.image.depth=p?o.depth:1)),n.width=o.width,n.height=o.height,n.textures=a,n.depthTexture=l||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(d=!0,l&&(l.needsUpdate=!0),n.sampleCount=r);let m={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let e=0;e<a.length;e++){let t=a[e];d&&(t.needsUpdate=!0),this.updateTexture(t,m)}l&&this.updateTexture(l,m)}n.initialized!==!0&&(n.initialized=!0,this.info.memory.renderTargets++,n.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener(`dispose`,n.onDispose))}updateTexture(e,t={}){let n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&i.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();e.type=t?t.texture.type:ta}if(e.isHTMLTexture&&e.image){let t=this.renderer.domElement;if(`requestPaint`in t){if(t.hasAttribute(`layoutsubtree`)||t.setAttribute(`layoutsubtree`,`true`),e.image.parentNode!==t&&t.appendChild(e.image),this._htmlTextures.size===0){let e=this._htmlTextures;t.onpaint=t=>{let n=t&&t.changedElements;for(let t of e)(!n||n.includes(t.image))&&(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:a,height:o,depth:s}=this.getSize(e);if(t.width=a,t.height=o,t.depth=s,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)i.createTexture(e,t),n.generation=e.version;else if(e.version>0){let r=e.image;if(r===void 0)B(`Renderer: Texture marked for update but image is undefined.`);else if(r.complete===!1)B(`Renderer: Texture marked for update but image is incomplete.`);else{if(e.images){let n=[];for(let t of e.images)n.push(t);t.images=n}else t.image=r;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t);let a=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!a&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&Es.enabled===!0&&Es.getTransfer(e.colorSpace)!==`srgb`&&B(`WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.`),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener(`dispose`,n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=xP){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),e.isHTMLTexture?(t.width=n.offsetWidth||1,t.height=n.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<`u`&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<`u`&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture===!0?1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener(`dispose`,t.onDispose);for(let e=0;e<n.length;e++)this._destroyTexture(n[e]);r&&this._destroyTexture(r),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}_destroyTexture(e){if(this.has(e)===!0){let t=this.get(e);e.removeEventListener(`dispose`,t.onDispose);let n=t.isDefaultTexture;if(this.backend.destroyTexture(e,n),t.bindGroups)for(let n of t.bindGroups){let t=this.backend.get(n);t.groups=void 0,t.versions=void 0;for(let t of n.bindings)t.isSampler&&t.texture===e&&(t.isSampledTexture!==!0&&this.backend.destroySampler(t),t.reset(),t.release())}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}},CP=class extends Cc{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},wP=class extends iD{static get type(){return`OverrideContextNode`}constructor(e,t=null){super(t,{overrideNodes:e}),this.isOverrideContextNode=!0}getFlowContextData(){let e=[];this.traverse(t=>{t.isOverrideContextNode===!0&&e.push(t.value.overrideNodes)});let t=new Map(e.flatMap(e=>Array.from(e.entries()))),n=super.getFlowContextData();return n.overrideNodes=t,n}};function TP(e,t=null,n=null){if(t&&t.isNode){let e=t;t=()=>e}return new wP(new Map([[e,t]]),n)}W(`overrideNode`,(e,t,n)=>TP(t,n,e));function EP(e,t=null){let n=new Map;for(let[t,r]of e){let e=r===null?null:typeof r==`function`?r:()=>r;n.set(t,e)}return new wP(n,t)}W(`overrideNodes`,(e,t)=>EP(t,e));var DP=class extends MT{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let n=this.getNodeType(e),r=e.getStructTypeNode(n),i;return r===null?(V(`TSL: Member "${t}" not found in struct "${n}".`,new vw),i=`float`):i=r.getMemberType(e,t),i}getHash(){return String(this.id)}generate(){return this.name}},OP=fT(class extends Pw{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):`void`}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}addToStack(e,t=-1){if(e.isNode!==!0)return V(`TSL: Invalid node added to stack.`,new vw),this;if(t===-1){if(this._currentNode){let e=this._nodeDataLibrary.get(this._currentNode);e===void 0&&(e={delta:0},this._nodeDataLibrary.set(this._currentNode,e)),e.delta++,t=this.nodes.indexOf(this._currentNode)+e.delta}else t=this.nodes.length}return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let n=new sT(t);return this._currentCond=rD(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){let n=rD(e,new sT(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new sT(e),this}Switch(e){return this._expressionNode=cT(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(cT(e[n])));else V(`TSL: Invalid parameter length. Case() requires at least two parameters.`,new vw);let n=e[e.length-1],r=new sT(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=rD(i,r);return this._currentCond===null?(this._currentCond=a,this.addToStack(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),n=0;for(let r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t[`node`+n++]=r);return t.outputNode||null}build(e,...t){let n=hT(),r=e.buildStage;mT(this),e.setActiveStack(this);for(let t=0;t<this.nodes.length;t++){let n=this.nodes[t],i=this._currentNode;if(this._currentNode=n,!(n.isVarNode&&n.isIntent(e)&&n.isAssign(e)!==!0)){if(r===`setup`)n.build(e);else if(r===`analyze`)n.build(e,this);else if(r===`generate`){let t=e.getDataFromNode(n,`any`).stages,r=t&&t[e.shaderStage];if(n.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;n.build(e,`void`)}this._currentNode=i}}let i;if(this.outputNode){let n=this.outputNode.build(e,...t);(e.buildStage!==`generate`||this.outputNode.getNodeType(e)!==`void`)&&(i=n)}else i=super.build(e,...t);return mT(n),e.removeActiveStack(this),i}}).setParameterLength(0,1),kP=class{constructor(e=1){this.blending=e,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,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.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}};new kP(0),new kP(6);var AP=class extends Lw{static get type(){return`BitcastNode`}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}generateNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),n=``;if(this.inputType!==null){let t=this.valueNode.getNodeType(e);n=e.getTypeLength(t)===1?this.inputType:e.changeComponentType(t,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}},jP=pT(AP).setParameterLength(2),MP=e=>new AP(e,`uint`,`float`),NP={},PP=class e extends Y{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(jP(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return yT;case`int`:return vT;case`uvec2`:return CT;case`uvec3`:return TT;case`uvec4`:return OT;case`ivec2`:return ST;case`ivec3`:return wT;case`ivec4`:return DT}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return K(([e])=>{let r=yT(0);this._resolveElementType(e,r,t);let i=MP(q(r.bitAnd(zE(r)))).shiftRight(23).sub(127);return n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return K(([e])=>{gT(e.equal(yT(0)),()=>yT(32));let r=yT(0),i=yT(0);return this._resolveElementType(e,r,t),gT(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),gT(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),gT(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),gT(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),gT(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return K(([e])=>{let r=yT(0);this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(yT(1)).bitAnd(yT(1431655765)))),r.assign(r.bitAnd(yT(858993459)).add(r.shiftRight(yT(2)).bitAnd(yT(858993459))));let i=r.add(r.shiftRight(yT(4))).bitAnd(yT(252645135)).mul(yT(16843009)).shiftRight(yT(24));return n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return K(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;i<n;i++){let n=a[i];t[n].assign(r(e[n]))}return t}}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}setup(t){let{method:n,aNode:r}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);let a=this.getInputType(t),o=t.getElementType(a),s=t.getTypeLength(a),c=`${n}_base_${o}`,l=`${n}_${a}`,u=NP[c];if(u===void 0){switch(n){case e.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(c,o);break;case e.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(c,o);break;case e.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(c,o)}NP[c]=u}let d=NP[l];return d===void 0&&(d=this._createMainLayout(l,a,s,u),NP[l]=d),K(()=>d(r))()}};PP.COUNT_TRAILING_ZEROS=`countTrailingZeros`,PP.COUNT_LEADING_ZEROS=`countLeadingZeros`,PP.COUNT_ONE_BITS=`countOneBits`,new au,new U,new U,new U,new Hs,new U(0,0,-1),new Ls,new U,new U,new Ls,new H;var FP=new Rs;fO.flipX(),FP.depthTexture=new Tu(1,1);var IP=new hf(-1,1,1,-1,0,1),LP=new class extends wl{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new fl([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new fl(t,2))}},RP=class extends Zl{constructor(e=null){super(LP,e),this.camera=IP,this.isQuadMesh=!0}async renderAsync(e){Bo(`QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await e.init(),e.render(this,IP)}render(e){e.render(this,IP)}},zP=K(([e])=>ME(q(52.9829189).mul(ME(KE(e,xT(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),BP=K(([e,t,n])=>{let r=q(2.399963229728653),i=OE(q(e).add(.5).div(q(t))),a=q(e).mul(r).add(n);return xT(PE(a),NE(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]}),VP=new Hs,HP=hE(0).setGroup(pE).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),UP=hE(1).setGroup(pE).onRenderUpdate(({scene:e})=>e.backgroundIntensity),WP=hE(new Hs).setGroup(pE).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300||e.backgroundNode&&e.backgroundNode.isNode?VP.makeRotationFromEuler(e.backgroundRotation).transpose():VP.identity(),VP});K(({texture:e,uv:t})=>{let n=1e-4,r=J().toVar();return gT(t.x.lessThan(n),()=>{r.assign(J(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(J(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(J(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{r.assign(J(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{r.assign(J(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{r.assign(J(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(J(-.01,0,0))).r.sub(e.sample(t.add(J(n,0,0))).r),a=e.sample(t.add(J(0,-.01,0))).r.sub(e.sample(t.add(J(0,n,0))).r),o=e.sample(t.add(J(0,0,-.01))).r.sub(e.sample(t.add(J(0,0,n))).r);r.assign(J(i,a,o))}),r.normalize()}),K(([e,t])=>e.mul(t).floor().div(t));var GP=new H,KP=class extends tO{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},qP=class extends KP{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},JP=class e extends Lw{static get type(){return`PassNode`}constructor(t,n,r,i={}){super(`vec4`),this.scope=t,this.scene=n,this.camera=r,this.options=i,this._width=1,this._height=1;let a=new Rs(this._width,this._height,{type:ca,...i});a.texture.name=`output`;let o=null;(this.scope===e.DEPTH||i.depthBuffer!==!1)&&(o=new Tu,o.isRenderTargetTexture=!0,o.name=`depth`,a.depthTexture=o),this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture},o!==null&&(this._textures.depth=o),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=hE(0),this._cameraFar=hE(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=kw.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return B(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return B(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e===`depth`)throw Error(`THREE.PassNode: Depth texture is not available for this pass.`);t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new qP(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new qP(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=OA(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=EA(i,n,r)}return t}async compileAsync(e){let t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),t.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=sa),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i=t.getOutputRenderTarget();i&&i.isXRRenderTarget===!0?(r=t.xr.getCamera(),t.xr.updateCamera(r),GP.set(i.width,i.height)):(r=this.camera,t.getDrawingBufferSize(GP)),this.setSize(GP.width,GP.height);let a=t.getRenderTarget(),o=t.getMRT(),s=t.autoClear,c=t.transparent,l=t.opaque,u=r.layers.mask,d=t.contextNode,f=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:aD({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);let p=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=p,n.overrideMaterial=f,t.setRenderTarget(a),t.setMRT(o),t.autoClear=s,t.transparent=c,t.opaque=l,t.contextNode=d,r.layers.mask=u}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._resolutionScale),r=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor===null?this.renderTarget.scissorTest=!1:(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Ls),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r))}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Ls),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r))}dispose(){this.renderTarget.dispose()}};JP.COLOR=`color`,JP.DEPTH=`depth`;var YP=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),XP=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),ZP=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),QP=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),$P=K(([e,t])=>{let n=AT(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=AT(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=QP(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),eF=AT(J(1.6605,-.1246,-.0182),J(-.5876,1.1329,-.1006),J(-.0728,-.0083,1.1187)),tF=AT(J(.6274,.0691,.0164),J(.3293,.9195,.088),J(.0433,.0113,.8956)),nF=K(([e])=>{let t=J(e).toVar(),n=J(t.mul(t)).toVar(),r=J(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(bE(40.14,r.mul(t))).add(bE(31.96,r).sub(bE(6.868,n.mul(t))).add(bE(.4298,n).add(bE(.1191,t).sub(.00232))))}),rF=K(([e,t])=>{let n=J(e).toVar(),r=AT(J(.856627153315983,.137318972929847,.11189821299995),J(.0951212405381588,.761241990602591,.0767994186031903),J(.0482516061458583,.101439036467562,.811302368396859)),i=AT(J(1.1271005818144368,-.1413297634984383,-.14132976349843826),J(-.11060664309660323,1.157823702216272,-.11060664309660294),J(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign(tF.mul(n)),n.assign(r.mul(n)),n.assign(WE(n,1e-10)),n.assign(DE(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign($E(n,0,1)),n.assign(nF(n)),n.assign(i.mul(n)),n.assign(JE(WE(J(0),n),J(2.2))),n.assign(eF.mul(n)),n.assign($E(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),iF=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=UE(e.r,UE(e.g,e.b)),a=rD(i.lessThan(.08),i.sub(bE(6.25,i.mul(i))),.04);e.subAssign(a);let o=WE(e.r,WE(e.g,e.b));gT(o.lessThan(n),()=>e);let s=yE(1,n),c=yE(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=yE(1,xE(1,r.mul(o.sub(c)).add(1)));return QE(e,J(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),aF=class extends Pw{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},oF=class extends aF{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+`
|
|
4651
|
+
`,t===`property`?o:e.format(`${o}()`,i,t)}};function sF(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||YO.z).negate()}var cF=K(([e,t],n)=>nD(e,t,sF(n))),lF=K(([e],t)=>{let n=sF(t);return e.mul(e,n,n).negate().exp().oneMinus()});K(([e,t],n)=>{let r=sF(n),i=t.sub(qO.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()});var uF=K(([e,t])=>ET(t.toFloat().mix(tE.rgb,e.toVec3()),tE.a));fT(class extends Pw{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});var dF=class extends Pw{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=VD(l,i).toConst()),t.constNode.build(e)}};dF.ATOMIC_LOAD=`atomicLoad`,dF.ATOMIC_STORE=`atomicStore`,dF.ATOMIC_ADD=`atomicAdd`,dF.ATOMIC_SUB=`atomicSub`,dF.ATOMIC_MAX=`atomicMax`,dF.ATOMIC_MIN=`atomicMin`,dF.ATOMIC_AND=`atomicAnd`,dF.ATOMIC_OR=`atomicOr`,dF.ATOMIC_XOR=`atomicXor`,fT(dF);var fF=class e extends Lw{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}generateNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};fF.SUBGROUP_ELECT=`subgroupElect`,fF.SUBGROUP_BALLOT=`subgroupBallot`,fF.SUBGROUP_ADD=`subgroupAdd`,fF.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,fF.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,fF.SUBGROUP_MUL=`subgroupMul`,fF.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,fF.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,fF.SUBGROUP_AND=`subgroupAnd`,fF.SUBGROUP_OR=`subgroupOr`,fF.SUBGROUP_XOR=`subgroupXor`,fF.SUBGROUP_MIN=`subgroupMin`,fF.SUBGROUP_MAX=`subgroupMax`,fF.SUBGROUP_ALL=`subgroupAll`,fF.SUBGROUP_ANY=`subgroupAny`,fF.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,fF.QUAD_SWAP_X=`quadSwapX`,fF.QUAD_SWAP_Y=`quadSwapY`,fF.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,fF.SUBGROUP_BROADCAST=`subgroupBroadcast`,fF.SUBGROUP_SHUFFLE=`subgroupShuffle`,fF.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,fF.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,fF.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,fF.QUAD_BROADCAST=`quadBroadcast`;var pF;function mF(e){pF||=new WeakMap;let t=pF.get(e);return t===void 0&&pF.set(e,t={}),t}function hF(e){let t=mF(e);return t.shadowMatrix||=hE(`mat4`).setGroup(pE).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix))}function Joe(e,t=qO){let n=hF(e).mul(t);return n.xyz.div(n.w)}function gF(e){let t=mF(e);return t.position||=hE(new U).setGroup(pE).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function Yoe(e){let t=mF(e);return t.targetPosition||=hE(new U).setGroup(pE).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function _F(e){let t=mF(e);return t.viewPosition||=hE(new U).setGroup(pE).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new U,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}var vF=e=>jO.transformDirection(gF(e).sub(Yoe(e))),Xoe=NT(`vec3`,`totalDiffuse`),Zoe=NT(`vec3`,`totalSpecular`),Qoe=NT(`vec3`,`outgoingLight`),$oe=e=>e.sort((e,t)=>e.id-t.id),ese=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},yF=new WeakMap,bF=[],xF=class extends Pw{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=Xoe,this.totalSpecularNode=Zoe,this.outgoingLightNode=Qoe,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(bF.push(n.id),bF.push(+!!n.castShadow),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;bF.push(e,t)}}let t=xw(bF);return bF.length=0,t}getHash(e){let t=e.getDataFromNode(this);if(t.lightNodesHash===void 0){let n=this.setupLightsNode(e);t.lightNodes=n;let r=[];for(let e of n)r.push(e.getHash());t.lightNodesHash=`lights-`+r.join(`,`)}return t.lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=e.getDataFromNode(this),n=[],r=t.lightNodes||null,i=e.context.materialLightings,a=$oe([...i,...this._lights]),o=e.renderer.library;for(let e of a)if(e.isNode)n.push(e);else{let t=null;if(r!==null&&(t=ese(e.id,r)),t===null){let n=o.getLightNodeClass(e.constructor);if(n===null){B(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}yF.has(e)===!1&&yF.set(e,new n(e)),t=yF.get(e)}n.push(t)}return n}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){let t=e.getDataFromNode(this);return t.lightNodes===void 0&&(t.lightNodes=this.setupLightsNode(e)),t.lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n,a.nodes=e.addStack().nodes,i.start(e);let{backdrop:s,backdropAlpha:c}=r,{directDiffuse:l,directSpecular:u,indirectDiffuse:d,indirectSpecular:f}=r.reflectedLight,p=l.add(d);s!==null&&(p=J(c===null?s:c.mix(p,s))),t.assign(p),o.assign(u.add(f)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}},tse=class extends Pw{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=kw.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){SF.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||qO)}},SF=NT(`vec3`,`shadowPositionWorld`);function nse(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Cc),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function rse(e,t){return t=nse(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function ise(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function ase(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function ose(e,t){return t=ase(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function sse(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function cse(e,t,n){return n=rse(e,n),n=ose(t,n),n}function lse(e,t,n){ise(e,n),sse(t,n)}var CF=new WeakMap,use=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=nO(e,t.xy).setName(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),dse=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=nO(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=Sk(`mapSize`,`vec2`,n).setGroup(pE),o=Sk(`radius`,`float`,n).setGroup(pE),s=xT(1).div(a),c=o.mul(s.x),l=zP(mO.xy).mul(6.28318530718);return vE(i(t.xy.add(BP(0,5,l).mul(c)),t.z),i(t.xy.add(BP(1,5,l).mul(c)),t.z),i(t.xy.add(BP(2,5,l).mul(c)),t.z),i(t.xy.add(BP(3,5,l).mul(c)),t.z),i(t.xy.add(BP(4,5,l).mul(c)),t.z)).mul(1/5)}),fse=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=Sk(`mapSize`,`vec2`,n).setGroup(pE),a=xT(1).div(i),o=t.xy,s=ME(o.mul(i).add(.5)).toConst();o.subAssign(s.sub(.5).mul(a));let c=n=>{let i=nO(e,o).offset(n).gather();return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)},l=c(ST(-1,1)).toConst(),u=c(ST(1,1)).toConst(),d=c(ST(-1,-1)).toConst(),f=c(ST(1,-1)).toConst();return vE(QE(l.x,u.y,s.x).add(l.y).add(u.x).mul(s.y),QE(l.w,u.z,s.x).add(l.z).add(u.w),QE(d.x,f.y,s.x).add(d.y).add(f.x),QE(d.w,f.z,s.x).add(d.z).add(f.w).mul(s.y.oneMinus())).mul(1/9)}),pse=K(({depthTexture:e,shadowCoord:t,depthLayer:n},r)=>{let i=nO(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=i.x,o=WE(1e-7,i.y.mul(i.y)),s=r.renderer.reversedDepthBuffer?GE(a,t.z):GE(t.z,a),c=q(1).toVar();return gT(s.notEqual(1),()=>{let e=t.z.sub(a),n=o.div(o.add(e.mul(e)));n=$E(yE(n,.3).div(.65)),c.assign(WE(s,n))}),c}),mse=e=>{let t=CF.get(e);return t===void 0&&(t=new FA,t.colorNode=ET(0,0,0,1),t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.blending=0,t.fog=!1,CF.set(e,t)),t},hse=e=>{let t=CF.get(e);t!==void 0&&(t.dispose(),CF.delete(e))},wF=new zN,TF=[],gse=(e,t,n,r)=>{TF[0]=e,TF[1]=t;let i=wF.get(TF);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,u,d,f)=>{(i.castShadow===!0||i.receiveShadow&&n===3)&&(r&&(Dw(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,u,d,f),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,wF.set(TF,i)),TF[0]=null,TF[1]=null,i},_se=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));return hA({start:vT(0),end:vT(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(vE(mO.xy,xT(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e),xT(a,OE(o.sub(a.mul(a)).max(0)))}),vse=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));return hA({start:vT(0),end:vT(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(vE(mO.xy,xT(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(vE(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e),xT(a,OE(o.sub(a.mul(a)).max(0)))}),yse=[use,dse,fse,pse],EF,DF=new RP,OF=class extends tse{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=n.biasNode||Sk(`bias`,`float`,n).setGroup(pE),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{let e=a.w;a=a.xy.div(e);let t=Sk(`near`,`float`,n.camera).setGroup(pE),r=Sk(`far`,`float`,n.camera).setGroup(pE);o=kA(e.negate(),t,r)}return a=J(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(i):o.add(i)),a}getShadowFilterFn(e){return yse[e]}setupRenderTarget(e,t){let n=new Tu(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t,camera:n}=e,{light:r,shadow:i}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,e),s=t.shadowMap.type,c=t.hasCompatibility(Mo.TEXTURE_COMPARE);if((s===1||s===2)&&c?(a.minFilter=Qi,a.magFilter=Qi):(a.minFilter=Yi,a.magFilter=Yi),i.camera.coordinateSystem=n.coordinateSystem,i.camera.updateProjectionMatrix(),s===3&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:xa,type:ca,depthBuffer:!1}));let t=nO(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=nO(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let r=Sk(`blurSamples`,`float`,i).setGroup(pE),s=Sk(`radius`,`float`,i).setGroup(pE),c=Sk(`mapSize`,`vec2`,i).setGroup(pE),l=this.vsmMaterialVertical||=new FA;l.fragmentNode=_se({samples:r,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new FA,l.fragmentNode=vse({samples:r,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let l=Sk(`intensity`,`float`,i).setGroup(pE),u=Sk(`normalBias`,`float`,i).setGroup(pE),d=hF(r),f=ak.mul(u),p;p=!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?d.mul(SF.add(f)):hE(`mat4`).onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(d.value,e.matrixWorld)).mul(GO).add(d.mul(ET(f,0)));let m=this.setupShadowCoord(e,p),h=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(h===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let g=s===3&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,_=this.setupShadowFilter(e,{filterFn:h,shadowTexture:o.texture,depthTexture:g,shadowCoord:m,shadow:i,depthLayer:this.depthLayer}),v;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?v=yk(o.texture,m.xyz):(v=nO(o.texture,m),a.isArrayTexture&&(v=v.depth(this.depthLayer))));let y;y=v?QE(1,_.rgb.mix(v,1),l.mul(v.a)).toVar():QE(1,_,l).toVar(),this.shadowMap=o,this.shadow.map=o;let b=`${this.light.type} Shadow [ ${this.light.name||`ID: `+this.light.id} ]`;return v&&y.toInspector(`${b} / Color`,()=>this.shadowMap.texture.isCubeTexture?yk(this.shadowMap.texture,JA()):nO(this.shadowMap.texture)),y.toInspector(`${b} / Depth`,()=>{let e=Sk(`near`,`float`,this.shadow.camera),t=Sk(`far`,`float`,this.shadow.camera),n;n=this.shadowMap.texture.isCubeTexture?yk(this.shadowMap.depthTexture,JA()).r:nO(this.shadowMap.depthTexture).r;let r;return r=this.shadow.camera.isPerspectiveCamera?OA(n,e,t):Roe(n,e,t),r=EA(r,e,t),r.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);let o=a.name;a.name=`Shadow Map [ ${r.name||`ID: `+r.id} ]`,i.render(a,t.camera),a.name=o}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;EF=cse(i,a,EF),a.overrideMaterial=mse(n),i.setRenderObjectFunction(gse(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===3&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,lse(i,a,EF)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),DF.material=this.vsmMaterialVertical,DF.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),DF.material=this.vsmMaterialHorizontal,DF.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,hse(this.light),this.shadowMap&&=(this.shadowMap.dispose(),null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},bse=(e,t)=>new OF(e,t),xse=new Cc,kF=new Hs,AF=new U,jF=new U,Sse=[new U(1,0,0),new U(-1,0,0),new U(0,-1,0),new U(0,1,0),new U(0,0,1),new U(0,0,-1)],Cse=[new U(0,-1,0),new U(0,-1,0),new U(0,0,-1),new U(0,0,1),new U(0,-1,0),new U(0,-1,0)],wse=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],Tse=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Ese=K(({depthTexture:e,bd3D:t,dp:n})=>yk(e,t).compare(n)),Dse=K(({depthTexture:e,bd3D:t,dp:n,shadow:r})=>{let i=Sk(`radius`,`float`,r).setGroup(pE),a=Sk(`mapSize`,`vec2`,r).setGroup(pE),o=i.div(a.x),s=IE(t),c=jE(qE(t,s.x.greaterThan(s.z).select(J(0,1,0),J(1,0,0)))),l=qE(t,c),u=zP(mO.xy).mul(6.28318530718),d=BP(0,5,u),f=BP(1,5,u),p=BP(2,5,u),m=BP(3,5,u),h=BP(4,5,u);return yk(e,t.add(c.mul(d.x).add(l.mul(d.y)).mul(o))).compare(n).add(yk(e,t.add(c.mul(f.x).add(l.mul(f.y)).mul(o))).compare(n)).add(yk(e,t.add(c.mul(p.x).add(l.mul(p.y)).mul(o))).compare(n)).add(yk(e,t.add(c.mul(m.x).add(l.mul(m.y)).mul(o))).compare(n)).add(yk(e,t.add(c.mul(h.x).add(l.mul(h.y)).mul(o))).compare(n)).mul(1/5)}),Ose=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r},i)=>{let a=n.xyz.toConst(),o=a.abs().toConst(),s=o.x.max(o.y).max(o.z),c=hE(`float`).setGroup(pE).onRenderUpdate(()=>r.camera.near),l=hE(`float`).setGroup(pE).onRenderUpdate(()=>r.camera.far),u=Sk(`bias`,`float`,r).setGroup(pE),d=q(1).toVar();return gT(s.sub(l).lessThanEqual(0).and(s.sub(c).greaterThanEqual(0)),()=>{let n;i.renderer.reversedDepthBuffer?(n=zoe(s.negate(),c,l),n.subAssign(u)):i.renderer.logarithmicDepthBuffer?(n=kA(s.negate(),c,l),n.addAssign(u)):(n=DA(s.negate(),c,l),n.addAssign(u));let o=a.normalize();d.assign(e({depthTexture:t,bd3D:o,dp:n,shadow:r}))}),d}),kse=class extends OF{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?Ese:Dse}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){return Ose({filterFn:t,depthTexture:n,shadowCoord:r,shadow:i})}setupRenderTarget(e,t){let n=new Eu(e.mapSize.width);n.name=`PointShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name=`PointShadowMap`,r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.camera,s=t.matrix,c=i.coordinateSystem===Ao,l=c?Sse:wse,u=c?Cse:Tse;n.setSize(t.mapSize.width,t.mapSize.width);let d=i.autoClear,f=i.getClearColor(xse),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(n,e),i.clear();let c=r.distance||o.far;c!==o.far&&(o.far=c,o.updateProjectionMatrix()),AF.setFromMatrixPosition(r.matrixWorld),o.position.copy(AF),jF.copy(o.position),jF.add(l[e]),o.up.copy(u[e]),o.lookAt(jF),o.updateMatrixWorld(),s.makeTranslation(-AF.x,-AF.y,-AF.z),kF.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(kF,o.coordinateSystem,o.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||`ID: `+r.id} ] - Face ${e+1}`,i.render(a,o),a.name=d}i.autoClear=d,i.setClearColor(f,p)}},Ase=(e,t)=>new kse(e,t),MF=class extends bA{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new Cc,this.colorNode=e&&e.colorNode||hE(this.color).setGroup(pE),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=kw.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener(`dispose`,this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener(`dispose`,this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return _F(this.light).sub(e.context.positionView||YO)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return bse(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let e=this.light.shadow.shadowNode,t;t=e===void 0?this.setupShadowNode():cT(e),this.shadowNode=t,this.shadowColorNode=n=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},NF=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),jse=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=NF({lightDistance:t.length(),cutoffDistance:n,decayExponent:r});return{lightDirection:i,lightColor:e.mul(a)}},Mse=class extends MF{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=hE(0).setGroup(pE),this.decayExponentNode=hE(2).setGroup(pE)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Ase(this.light)}setupDirect(e){return jse({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}};K(([e=QD()],{renderer:t,material:n})=>{let r=ZE(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=q(r.fwidth()).toVar();i=nD(e.oneMinus(),e.add(1),r).oneMinus()}else i=rD(r.greaterThan(1),0,1);return i});var Nse=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(1.023328).mul(r)),a=a.add(t.element(2).mul(1.023328).mul(i)),a=a.add(t.element(3).mul(1.023328).mul(n)),a=a.add(t.element(4).mul(.858086).mul(n).mul(r)),a=a.add(t.element(5).mul(.858086).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(.858086).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(bE(n,n).sub(bE(r,r)))),a}),PF=new CP,Pse=class extends KN{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(i===null)r._clearColor.getRGB(PF),PF.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(PF),PF.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;PF.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=ET(a).mul(UP).context({getUV:()=>WP.mul(rk),getTextureLevel:()=>HP}),t=kO.element(3).element(3).equal(1),r=xE(1,kO.element(1).element(1)).mul(3),s=t.select(GO.mul(r),GO),c=zO.mul(ET(s,0)),l=kO.mul(ET(c.xyz,1));l=l.setZ(l.w);let u=new FA;u.name=`Background.material`,u.side=1,u.depthTest=!1,u.depthWrite=!1,u.allowOverride=!1,u.fog=!1,u.lights=!1,u.vertexNode=l,u.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=o=new Zl(new ad(1,32,32),u),o.frustumCulled=!1,o.name=`Background.mesh`;function d(){i.removeEventListener(`dispose`,d),o.material.dispose(),o.geometry.dispose()}i.addEventListener(`dispose`,d)}let s=a.getCacheKey();n.backgroundCacheKey!==s&&(n.backgroundMeshNode.node=ET(a).mul(UP),n.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,n.backgroundCacheKey=s),t.unshift(o,o.geometry,o.material,0,0,null,null)}else V(`Renderer: Unsupported background configuration.`,i);let o=r.xr.getEnvironmentBlendMode();if(o===`additive`?PF.set(0,0,0,1):o===`alpha-blend`&&PF.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=PF.r,e.g=PF.g,e.b=PF.b,e.a=PF.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r.getClearDepth(),n.stencilClearValue=r.getClearStencil(),n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}},Fse=0,FF=class{constructor(e=``,t=[]){this.name=e,this.bindings=t,this.id=Fse++}},Ise=class{constructor(e,t,n,r,i,a,o,s,c,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=u,this.nodeAttributes=r,this.bindings=i,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=s,this.observer=c,this.hardwareClipping=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let n=new FF(t.name,[]);e.push(n);for(let e of t.bindings)n.bindings.push(e.clone())}else e.push(t);return e}},IF=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},Lse=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},LF=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},Rse=class extends LF{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},zse=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}},Bse=0,RF=class{constructor(e=null){this.id=Bse++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},Vse=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},zF=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},Hse=class extends zF{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},Use=class extends zF{constructor(e,t=new H){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},Wse=class extends zF{constructor(e,t=new U){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},Gse=class extends zF{constructor(e,t=new Ls){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},Kse=class extends zF{constructor(e,t=new Cc){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},qse=class extends zF{constructor(e,t=new Kf){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},Jse=class extends zF{constructor(e,t=new xs){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},Yse=class extends zF{constructor(e,t=new Hs){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},Xse=class extends Hse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},Zse=class extends Use{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},Qse=class extends Wse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},$se=class extends Gse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},ece=class extends Kse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},tce=class extends qse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},nce=class extends Jse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},rce=class extends Yse{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},ice=0,BF=new WeakMap,VF=new WeakMap,ace=new WeakMap,oce=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),HF=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`)),UF=e=>{if(e.writeUsageCount>0)return!0;if(e.subBuildsCache!==void 0){for(let t in e.subBuildsCache)if(UF(e.subBuildsCache[t]))return!0}return!1},WF=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:``,fragment:``,compute:``},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:``},this.chaining=[],this.stack=OP(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new RF,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:ice++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute(`normal`)===!1}isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===1&&e.alphaToCoverage===!1}createRenderTarget(e,t,n){return new Rs(e,t,n)}createCubeRenderTarget(e,t){return new YA(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t=`vec4`,n=this.renderer.getRenderTarget();if(n!==null){let r=n.textures[e].type,i=n.textures[e].format,a=`vec`;r===1013?a=`ivec`:r===1014&&(a=`uvec`),t=i===1028||i===1029?r===1013?`int`:r===1014?`uint`:`float`:i===1030||i===1031?`${a}2`:i===1022||i===1032?`${a}3`:`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){let n=t[0].groupNode,r=n.shared;if(r)for(let e=1;e<t.length;e++)n!==t[e].groupNode&&(r=!1);let i;if(r){let n=``;for(let e of t)if(e.isNodeUniformsGroup){e.uniforms.sort((e,t)=>e.nodeUniform.node.id-t.nodeUniform.node.id);for(let t of e.uniforms)n+=t.nodeUniform.node.id}else n+=e.nodeUniform.id;let r=this.renderer._currentRenderContext||this.renderer,a=BF.get(r);a===void 0&&(a=new Map,BF.set(r,a));let o=bw(n);i=a.get(o),i===void 0&&(i=new FF(e,t),a.set(o,i))}else i=new FF(e,t);return i}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of Mw)for(let r in n[e]){let i=n[e][r],a=t[r]||(t[r]=[]);for(let e of i)a.includes(e)===!1&&a.push(e)}e=[];for(let n in t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let n=e[t];this.bindingsIndexes[n.name].group=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.has(e)===!1&&(this.nodes.add(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();(t!==kw.NONE||n!==kw.NONE)&&this.sequentialNodes.add(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==kw.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==kw.NONE&&this.updateBeforeNodes.push(e),n!==kw.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===1006||e.magFilter===1007||e.magFilter===1005||e.magFilter===1008||e.minFilter===1006||e.minFilter===1007||e.minFilter===1005||e.minFilter===1008}getUniformBufferLimit(){return this.renderer.backend.capabilities.getUniformBufferLimit()}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error(`THREE.NodeBuilder: Invalid node chaining!`)}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new RF(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){B(`Abstract function.`)}getInstanceIndex(){B(`Abstract function.`)}getDrawIndex(){B(`Abstract function.`)}getFrontFacing(){B(`Abstract function.`)}getFragCoord(){B(`Abstract function.`)}isFlipY(){return!1}isContextAssign(){return this.context.assign===!0}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,this.isContextAssign()?t.writeUsageCount=t.writeUsageCount===void 0?1:t.writeUsageCount+1:t.readUsageCount=t.readUsageCount===void 0?1:t.readUsageCount+1,t.usageCount}hasWriteUsage(e){let t=e.getShared(this),n=(t.isGlobal(this)?this.globalCache:this.cache).getData(t);if(n!==void 0){for(let e in n)if(UF(n[e]))return!0}return!1}generateTexture(){B(`Abstract function.`)}generateTextureLod(){B(`Abstract function.`)}generateArrayDeclaration(e,t){return this.getType(e)+`[ `+t+` ]`}generateArray(e,t,n=null){let r=this.generateArrayDeclaration(e,t)+`( `;for(let i=0;i<t;i++){let a=n?n[i]:null;r+=a===null?this.generateConst(e):a.build(this,e),i<t-1&&(r+=`, `)}return r+=` )`,r}generateStruct(e,t,n=null){let r=[];for(let e of t){let{name:t,type:i}=e;n&&n[t]&&n[t].isNode?r.push(n[t].build(this,i)):r.push(this.generateConst(i))}return e+`( `+r.join(`, `)+` )`}generateConst(e,t=null){if(t===null&&(e===`float`||e===`int`||e===`uint`?t=0:e===`bool`?t=!1:e===`color`?t=new Cc:e===`vec2`||e===`uvec2`||e===`ivec2`?t=new H:e===`vec3`||e===`uvec3`||e===`ivec3`?t=new U:(e===`vec4`||e===`uvec4`||e===`ivec4`)&&(t=new Ls)),e===`float`)return HF(t);if(e===`int`)return`${Math.round(t)}`;if(e===`uint`)return t>=0?`${Math.round(t)}u`:`0u`;if(e===`bool`)return t?`true`:`false`;if(e===`color`)return`${this.getType(`vec3`)}( ${HF(t.r)}, ${HF(t.g)}, ${HF(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4&&e!==`mat2`)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e===`color`?`vec3`:e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new IF(e,t);return this.registerDeclaration(r),n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e===`void`||e===`property`||e===`sampler`||e===`samplerComparison`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;return e.isDepthTexture===!0?`float`:t===1013?`int`:t===1014?`uint`:`float`}getElementType(e){return e===`mat2`?`vec2`:e===`mat3`?`vec3`:e===`mat4`?`vec4`:this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e===`float`||e===`bool`||e===`int`||e===`uint`)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]===`b`?`bool`:t[1]===`i`?`int`:t[1]===`u`?`uint`:`float`}getVectorType(e){return e===`color`?`vec3`:e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`texture3D`?`vec4`:e}getTypeFromLength(e,t=`float`){if(e===1)return t;let n=ww(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return oce.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof dl)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?t===`float`||t===`bool`||t===`int`||t===`uint`?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error(`THREE.NodeBuilder: Invalid active stack removal.`)}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=OP(this.stack);let e=hT();return this.stacks.push(e),mT(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,mT(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let i=r[t];if(this.subBuildLayers.length===0)return i;let a=r.any?r.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(i.subBuildsCache===void 0&&(i.subBuildsCache={}),i=i.subBuildsCache[o]||(i.subBuildsCache[o]={}),i.subBuilds=a),i}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t,n=null){let r=this.getDataFromNode(e,`vertex`),i=r.bufferAttribute;if(i===void 0){let a=this.uniforms.index++;n===null&&(n=`nodeAttribute`+a),i=new IF(n,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){let i=this.getDataFromNode(e,r,this.globalCache),a=i.structType;if(a===void 0){let o=this.structs.index++;n===null&&(n=`StructType`+o),a=new Vse(n,t),this.structs[r].push(a),this.types[r][n]=e,i.structType=a}return a}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,`OutputType`,`fragment`);return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new Lse(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),i.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,i=!1){let a=this.getDataFromNode(e,r),o=this.getSubBuildProperty(`variable`,a.subBuilds),s=a[o];if(s===void 0){let c=i?`_const`:`_var`,l=this.vars[r]||(this.vars[r]=[]),u=this.vars[c]||(this.vars[c]=0);t===null&&(t=(i?`nodeConst`:`nodeVar`)+u,this.vars[c]++),o!==`variable`&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);s=new LF(t,n,i,d),i||l.push(s),this.registerDeclaration(s),a[o]=s}return s}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,i=null){let a=this.getDataFromNode(e,`any`),o=this.getSubBuildProperty(`varying`,a.subBuilds),s=a[o];if(s===void 0){let e=this.varyings,c=e.length;t===null&&(t=`nodeVarying`+c),o!==`varying`&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new Rse(t,n,r,i),e.push(s),this.registerDeclaration(s),a[o]=s}return s}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=e.name,i=r,a=this.getPropertyName(e),o=1;for(;n[a]!==void 0;)i=r+`_`+o++,e.name=i,a=this.getPropertyName(e);i!==r&&B(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${i}'.`),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new zse(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===``?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`;
|
|
4652
|
+
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=` `,this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=this.renderer.backend,n=VF.get(t);n===void 0&&(n=new WeakMap,VF.set(t,n));let r=n.get(e);if(r===void 0){r=new oF;let t=this.currentFunctionNode;this.currentFunctionNode=r,r.code=this.buildFunctionCode(e),this.currentFunctionNode=t,n.set(e,r)}return r}flowShaderNode(e){let t=e.layout,n={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)n[e.name]=new DP(e.type,e.name);e.layout=null;let r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowBuildStage(e,t,n=null){let r=this.getBuildStage();this.setBuildStage(t);let i=e.build(this,n);return this.setBuildStage(r),i}flowStagesNode(e,t=null){let n=this.flow,r=this.vars,i=this.declarations,a=this.cache,o=this.buildStage,s=this.stack,c={code:``};this.flow=c,this.vars={},this.declarations={},this.cache=new RF,this.stack=OP();for(let n of jw)this.setBuildStage(n),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=i,this.cache=a,this.stack=s,this.setBuildStage(o),c}getFunctionOperator(){return null}buildFunctionCode(){B(`Abstract function.`)}flowChildNode(e,t=null){let n=this.flow,r={code:``};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){let i=this.tab,a=this.cache,o=this.shaderStage,s=this.context;this.setShaderStage(e);let c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=` `,this.context=c;let l=null;if(this.buildStage===`generate`){let i=this.flowChildNode(t,n);r!==null&&(i.code+=`${this.tab+r} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=i,this.context=s,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){B(`Abstract function.`)}getVaryings(){B(`Abstract function.`)}getVar(e,t,n=null){return`${n===null?this.getType(e):this.generateArrayDeclaration(e,n)} ${t}`}getVars(e,t=!1){let n=[],r=this.vars[e];if(r!==void 0)for(let e of r)n.push(`${this.getVar(e.type,e.name,e.count)};`);return n.join(t?`
|
|
4653
4653
|
`:`
|
|
4654
4654
|
`)}getUniforms(){B(`Abstract function.`)}getCodes(e){let t=this.codes[e],n=``;if(t!==void 0)for(let e of t)n+=e.code+`
|
|
4655
|
-
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){B(`Abstract function.`)}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,`any`).subBuilds:e instanceof Set?[...e]:e,!t)return null;let n=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let r=t[e];if(n.includes(r))return r}return null}getSubBuildOutput(e){return this.getSubBuildProperty(`outputNode`,e)}getSubBuildProperty(e=``,t=null){let n;n=t===null?this.subBuildFn:this.getClosestSubBuild(t);let r;return r=n?e?n+`_`+e:n:e,r}prebuild(){let{object:e,renderer:t,material:n}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:V('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),n&&n.contextNode&&(n.contextNode.isContextNode===!0?this.context={...this.context,...n.contextNode.getFlowContextData()}:V('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),n!==null){let e=t.library.fromMaterial(n);e===null&&(V(`NodeBuilder: Material "${n.type}" is not compatible.`),e=new
|
|
4656
|
-
`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has(`velocity`)||Ew(this.object).useVelocity===!0}},WF=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Ow.FRAME){let t=this._getMaps(this.updateBeforeMap,n);if(t.frameId!==this.frameId){let n=t.frameId;t.frameId=this.frameId,e.updateBefore(this)===!1&&(t.frameId=n)}}else if(t===Ow.RENDER){let t=this._getMaps(this.updateBeforeMap,n);if(t.renderId!==this.renderId){let n=t.renderId;t.renderId=this.renderId,e.updateBefore(this)===!1&&(t.renderId=n)}}else t===Ow.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Ow.FRAME){let t=this._getMaps(this.updateAfterMap,n);t.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(t.frameId=this.frameId)}else if(t===Ow.RENDER){let t=this._getMaps(this.updateAfterMap,n);t.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(t.renderId=this.renderId)}else t===Ow.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===Ow.FRAME){let t=this._getMaps(this.updateMap,n);t.frameId!==this.frameId&&e.update(this)!==!1&&(t.frameId=this.frameId)}else if(t===Ow.RENDER){let t=this._getMaps(this.updateMap,n);t.renderId!==this.renderId&&e.update(this)!==!1&&(t.renderId=this.renderId)}else t===Ow.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},GF=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};GF.isNodeFunctionInput=!0;var cce=class extends jF{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},lce=class extends jF{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:_F(this.light),lightColor:e}}},uce=class extends jF{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=hF(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=mE(new Cc).setGroup(fE)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=ZE(n,t,ik.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(i)}},KF=class extends jF{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=mE(0).setGroup(fE),this.penumbraCosNode=mE(0).setGroup(fE),this.cutoffDistanceNode=mE(0).setGroup(fE),this.decayExponentNode=mE(0).setGroup(fE),this.colorNode=mE(this.color).setGroup(fE)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:n,penumbraCosNode:r}=this;return tD(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=Yoe(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=this.getLightVector(e),o=a.normalize(),s=o.dot(_F(i)),c=this.getSpotAttenuation(e,s),l=MF({lightDistance:a.length(),cutoffDistance:n,decayExponent:r}),u=t.mul(c).mul(l),d,f;return i.colorNode?(f=this.getLightCoord(e),d=i.colorNode(f)):i.map&&(f=this.getLightCoord(e),d=tO(i.map,f.xy).onRenderUpdate(()=>i.map)),d&&(u=f.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(d),u)),{lightColor:u,lightDirection:o}}},dce=class extends KF{static get type(){return`IESSpotLightNode`}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let n=this.light.iesMap,r=null;if(n&&n.isTexture===!0){let e=t.acos().mul(1/Math.PI);this._iesTextureNode=tO(n,bT(e,0),0),r=this._iesTextureNode.r}else r=super.getSpotAttenuation(e,t);return r}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}},fce=class extends jF{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new U);this.lightProbe=aO(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=Pse(ik,this.lightProbe);e.context.irradiance.addAssign(t)}},pce=K(([e,t])=>{let n=e.abs().sub(t);return LE(UE(n,0)).add(HE(UE(n.x,n.y),0))}),mce=class extends KF{static get type(){return`ProjectorLightNode`}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=q(0),n=this.penumbraCosNode,r=mF(this.light).mul(e.context.positionWorld||KO);return hT(r.w.greaterThan(0),()=>{let e=pce(r.xyz.div(r.w).xy.sub(bT(.5)),bT(.5)),i=bE(-1,vE(1,PE(n)).sub(1));t.assign($E(e.mul(-2).mul(i)))}),t}},qF=new Hs,JF=new Hs,YF=null,hce=class extends jF{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=mE(new U).setGroup(fE),this.halfWidth=mE(new U).setGroup(fE),this.updateType=Ow.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;JF.identity(),qF.copy(t.matrixWorld),qF.premultiply(n),JF.extractRotation(qF),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(JF),this.halfHeight.value.applyMatrix4(JF)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=tO(YF.LTC_FLOAT_1),n=tO(YF.LTC_FLOAT_2)):(t=tO(YF.LTC_HALF_1),n=tO(YF.LTC_HALF_2));let{colorNode:r,light:i}=this;return{lightColor:r,lightPosition:gF(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){YF=e}},XF=class{parseFunction(){B(`Abstract function.`)}},ZF=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){B(`Abstract function.`)}};ZF.isNodeFunction=!0;var gce=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,_ce=/[a-z_0-9]+/gi,vce=`#pragma main`,yce=e=>{e=e.trim();let t=e.indexOf(vce),n=t===-1?e:e.slice(t+12),r=n.match(gce);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=_ce.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c<a.length;){let e=a[c][0]===`const`;e===!0&&c++;let t=a[c][0];t===`in`||t===`out`||t===`inout`?c++:t=``;let n=a[c++][0],r=Number.parseInt(a[c][0]);Number.isNaN(r)===!1?c++:r=null;let i=a[c++][0];s.push(new GF(n,i,r,t,e))}let l=n.substring(r[0].length),u=r[3]===void 0?``:r[3];return{type:r[2],inputs:s,name:u,precision:r[1]===void 0?``:r[1],inputsCode:i,blockCode:l,headerCode:t===-1?``:e.slice(0,t)}}throw Error(`THREE.FunctionNode: Function is not a GLSL code.`)},bce=class extends ZF{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=yce(e);super(t,n,r,i),this.inputsCode=a,this.blockCode=o,this.headerCode=s}getCode(e=this.name){let t,n=this.blockCode;if(n!==``){let{type:r,inputsCode:i,headerCode:a,precision:o}=this,s=`${r} ${e} ( ${i.trim()} )`;o!==``&&(s=`${o} ${s}`),t=a+s+n}else t=``;return t}},xce=class extends XF{parseFunction(e){return new bce(e)}},QF=[],$F=[],eI=mE(0,`int`).setGroup(fE),Sce=class extends GN{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new WF,this.nodeBuilderCache=new Map,this.callHashCache=new RN,this.groupsData=new RN,this._buildQueue=[],this._buildInProgress=!1,this.cacheLib={}}updateGroup(e){let t=e.groupNode;if(t.updateType===Ow.OBJECT)return!0;QF[0]=t,QF[1]=e;let n=this.groupsData.get(QF);return n===void 0&&this.groupsData.set(QF,n={}),QF[0]=null,QF[1]=null,n.version!==t.version&&(n.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}_createNodeBuilder(e,t){let n=this.backend.createNodeBuilder(e.object,this.renderer);return n.scene=e.scene,n.material=t,n.camera=e.camera,n.context.material=t,n.lightsNode=e.lightsNode,n.environmentNode=this.getEnvironmentNode(e.scene),n.fogNode=this.getFogNode(e.scene),n.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&n.enableMultiview(),n}getForRender(e,t=!1){let n=this.get(e),r=n.nodeBuilderState;if(r===void 0){let{nodeBuilderCache:i}=this,a=this.getForRenderCacheKey(e);if(r=i.get(a),r===void 0){let o=async()=>{let n=this._createNodeBuilder(e,e.material);try{t?await n.buildAsync():n.build()}catch(r){n=this._createNodeBuilder(e,new PA),t?await n.buildAsync():n.build(),V(`TSL: `+r)}return n};if(t)return o().then(e=>(r=this._createNodeBuilderState(e),i.set(a,r),r.usedTimes++,n.nodeBuilderState=r,r));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(n){t=this._createNodeBuilder(e,new PA),t.build();let r=n.stackTrace;!r&&n.stack&&(r=new _w(n.stack)),V(`TSL: `+n,r)}r=this._createNodeBuilderState(t),i.set(a,r)}}r.usedTimes++,n.nodeBuilderState=r}return r}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;let n=this.getForRenderCacheKey(e),r=this.nodeBuilderCache.get(n);return r===void 0?(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null):(r.usedTimes++,t.nodeBuilderState=r,r)}_processBuildQueue(){this._buildInProgress||this._buildQueue.length===0||(this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()}))}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0||t.version!==e.version){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n,t.version=e.version}return n}_createNodeBuilderState(e){return new Lse(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){QF[0]=e,QF[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(QF)||{};if(r.callId!==n){if($F.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),$F.push(+!!this.renderer.lighting.enabled),this.renderer.lighting.enabled){$F.push(t.getCacheKey(!0)),$F.push(+!!this.renderer.shadowMap.enabled),$F.push(this.renderer.shadowMap.type);let n=this.getEnvironmentNode(e);n&&$F.push(n.getCacheKey())}let i=this.getFogNode(e);i&&$F.push(i.getCacheKey()),r.callId=n,r.cacheKey=bw($F),this.callHashCache.set(QF,r),$F.length=0}return QF[0]=null,QF[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),n=e.background;if(n){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;(t.background!==n||r)&&(t.backgroundNode=this.getCacheNode(`background`,n,()=>{if(n.isCubeTexture===!0||n.mapping===303||n.mapping===304||n.mapping===306){if(e.backgroundBlurriness>0||n.mapping===306)return dN(n);{let e;return e=n.isCubeTexture===!0?vk(n):tO(n),ej(e)}}if(n.isTexture===!0)return tO(n,dO.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&V(`WebGPUNodes: Unsupported background configuration.`,n)},r),t.background=n,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){let i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(a===void 0||r)&&(a=n(),i.set(t,a)),a}updateFog(e){let t=this.get(e),n=e.fog;n?t.fog!==n&&(t.fogNode=this.getCacheNode(`fog`,n,()=>{if(n.isFogExp2)return lF(xk(`color`,`color`,n).setGroup(fE),cF(xk(`density`,`float`,n).setGroup(fE)));if(n.isFog)return lF(xk(`color`,`color`,n).setGroup(fE),sF(xk(`near`,`float`,n).setGroup(fE),xk(`far`,`float`,n).setGroup(fE)));V(`Renderer: Unsupported fog configuration.`,n)}),t.fog=n):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),n=e.environment;n?t.environment!==n&&(t.environmentNode=this.getCacheNode(`environment`,n,()=>{if(n.isCubeTexture===!0)return vk(n);if(n.isTexture===!0)return tO(n);V(`Nodes: Unsupported environment configuration.`,n)}),t.environment=n):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=i,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+`,`+e.currentColorSpace+`,`+e.xr.isPresenting}getOutputNode(e){let t=this.renderer,n;return n=e.isArrayTexture?this.backend.isWebGLBackend?tO(e,dO).depth(oO(`gl_ViewID_OVR`)).renderOutput(t.toneMapping,t.currentColorSpace):tO(e,dO).depth(eI).renderOutput(t.toneMapping,t.currentColorSpace):tO(e,dO).renderOutput(t.toneMapping,t.currentColorSpace),n}setOutputLayerIndex(e){eI.value=e}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let e of n.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let e of n.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new WF,this.nodeBuilderCache=new Map,this.cacheLib={}}},tI=new au,nI=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewMatrix=new Hs,this.viewNormalMatrix=new xs,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,n){let r=e.length;for(let i=0;i<r;i++){tI.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[n+i],a=tI.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=tI.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix.copy(t.matrixWorldInverse),this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let n=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let r=t.clippingPlanes,i=r.length,a,o;if(this.clipIntersection?(a=this.intersectionPlanes,o=e.intersectionPlanes.length):(a=this.unionPlanes,o=e.unionPlanes.length),a.length!==o+i){a.length=o+i;for(let e=0;e<i;e++)a[o+e]=new Ls;n=!0}this.projectPlanes(r,a,o),n&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(t){if(this.shadowPass&&!t.clipShadows)return this;let n=this.clippingGroupContexts.get(t);return n===void 0&&(n=new e(this),this.clippingGroupContexts.set(t,n)),n.update(this,t),n}get unionClippingCount(){return this.unionPlanes.length}},Cce=class{constructor(e,t,n){this.bundleGroup=e,this.camera=t,this.renderContext=n}},rI=[],wce=class{constructor(){this.bundles=new RN}get(e,t,n){let r=this.bundles;rI[0]=e,rI[1]=t,rI[2]=n;let i=r.get(rI);return i===void 0&&(i=new Cce(e,t,n),r.set(rI,i)),rI[0]=null,rI[1]=null,rI[2]=null,i}dispose(){this.bundles=new RN}},iI=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(let n in e)t[n]=e[n]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){B(`Redefinition of node ${t}`);return}if(typeof e!=`function`)throw Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if(typeof t==`function`||typeof t==`object`)throw Error(`THREE.NodeLibrary: Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){B(`Redefinition of node ${t.name}`);return}if(typeof e!=`function`)throw Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if(typeof t!=`function`)throw Error(`THREE.NodeLibrary: Base class ${t.name} is not a class.`);n.set(t,e)}},Tce=new bF,aI=new WeakMap,Ece=class{constructor(){this.enabled=!0,this._cache=[]}createNode(e=[]){return new bF().setLights(e)}getNode(e){if(e.isScene!==!0&&e.isGroup!==!0)return Tce;let t=aI.get(e);return t===void 0&&(t=this.createNode(),aI.set(e,t)),t}beginRender(e){this._cache.push(this.getNode(e).getLights())}finishRender(e){this.getNode(e).setLights(this._cache.pop())}},oI=class extends Rs{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}},sI=new U,cI=new U,lI=new WeakMap,Dce=class extends Wo{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new uf,this._cameraL.viewport=new Ls,this._cameraL.matrixWorldAutoUpdate=!1,this._cameraR=new uf,this._cameraR.viewport=new Ls,this._cameraR.matrixWorldAutoUpdate=!1,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new Tf,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding<`u`,this._supportsWebGPUBinding=globalThis.XRGPUBinding!==void 0,this._createXRLayer=Nce.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSamples=null,this._currentSize=new H,this._onSessionEvent=Ace.bind(this),this._onSessionEnd=jce.bind(this),this._onInputSourcesChange=Mce.bind(this),this._onAnimationFrame=Pce.bind(this),this._referenceSpace=null,this._referenceSpaceType=`local-floor`,this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._webgpuBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&`createProjectionLayer`in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&B(`XRManager: Cannot change framebuffer scale while presenting.`)}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&B(`XRManager: Cannot change reference space type while presenting.`)}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBaseLayer(){return this._glProjLayer===null?this._glBaseLayer:this._glProjLayer}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}foveateBoundTexture(e){if(e.isPostProcessingRenderTarget!==!0||this.isPresenting!==!0||this._glProjLayer===null)return;let t=this._renderer.backend;if(t===void 0||t.isWebGLBackend!==!0||t.state===null)return;let n=this._renderer.getOutputRenderTarget();if(n===null||n.isXRRenderTarget!==!0)return;let r=this.getBinding();if(r===null||typeof r.foveateBoundTexture!=`function`)return;this._renderer._textures.updateRenderTarget(e);let{textureGPU:i,glTextureType:a}=t.get(e.texture);if(i!==void 0&&a!==void 0&&e._xrFoveationTextureGPU!==i){e._xrFoveationTextureGPU=i,t.state.bindTexture(a,i);try{r.foveateBoundTexture(a,this.getFoveation())}catch(e){Bo(`XRManager: Unable to foveate bound XR post-processing texture. ${e.name}: ${e.message}`)}finally{t.state.unbindTexture()}}}getWebGPUBinding(){return this._webgpuBinding===null&&this._supportsWebGPUBinding&&(this._webgpuBinding=new globalThis.XRGPUBinding(this._session,this._renderer.backend.device)),this._webgpuBinding}_isWebGPUSession(){return this._renderer.backend.isWebGPUBackend===!0&&this._session!==null&&this._session.enabledFeatures.includes(`webgpu`)}_validateWebGPUSession(){let e=this._renderer;if(e.backend.isWebGPUBackend===!0){if(this._session.enabledFeatures.includes(`webgpu`)===!1)throw Error(`THREE.XRManager: WebGPU XR sessions require the "webgpu" session feature. Use VRButtonGPU/XRButton with "webgpu" enabled or use a WebGL backend.`);e.samples>0&&(Bo(`THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session.`),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){let t=this.getWebGPUBinding(),n=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:`depth24plus`});this._glProjLayer=n,e.updateRenderState({layers:[n]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new Rs(n.textureWidth,n.textureHeight,{depth:2,minFilter:Qi,magFilter:Qi,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&Bo(`THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session.`),this._useMultiview=!1}_disposeWebGPUSession(){let e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;let n=e.backend,r=e._textures,i=n.get?n.get(t):null;i&&(i.descriptors=void 0);let a=e=>{e!=null&&(n.delete&&n.delete(e),r.delete&&r.delete(e))};for(let e=0;e<t.textures.length;e++)a(t.textures[e]);a(t.depthTexture),a(t),e._renderContexts&&e._renderContexts.dispose&&e._renderContexts.dispose(),t.dispose()}_getWebGPUViewData(e){let t=this.getWebGPUBinding(),n={colorTexture:null,viewDescriptors:[],viewports:[]};for(let r=0;r<e.length;r++){let i=t.getViewSubImage(this._glProjLayer,e[r]);n.colorTexture===null&&(n.colorTexture=i.colorTexture),n.viewports.push(i.viewport),i.getViewDescriptor&&n.viewDescriptors.push(i.getViewDescriptor())}return n}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,r,i,a,o,s={}){let c=new id(e,t),l=new oI(i,a,{format:ga,type:ta,depthTexture:new Tu(i,a,s.stencil?da:oa,void 0,void 0,void 0,void 0,void 0,void 0,s.stencil?va:_a),stencilBuffer:s.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});l._autoAllocateDepthBuffer=!0;let u=new zl({color:16777215,side:0});u.map=l.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new Zl(c,u);d.position.copy(n),d.quaternion.copy(r);let f={type:`quad`,width:e,height:t,translation:n,quaternion:r,pixelwidth:i,pixelheight:a,plane:d,material:u,rendercall:o,renderTarget:l};if(this._layers.push(f),this._session!==null){f.plane.material=new zl({color:16777215,side:0}),f.plane.material.blending=5,f.plane.material.blendEquation=100,f.plane.material.blendSrc=200,f.plane.material.blendDst=200,f.xrlayer=this._createXRLayer(f);let e=this._session.renderState.layers;e.unshift(f.xrlayer),this._session.updateRenderState({layers:e})}else l.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,n,r,i,a,o,s,c={}){let l=new ku(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),u=new oI(a,o,{format:ga,type:ta,depthTexture:new Tu(a,o,c.stencil?da:oa,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?va:_a),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;let d=new zl({color:16777215,side:1});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let f=new Zl(l,d);f.position.copy(r),f.quaternion.copy(i);let p={type:`cylinder`,radius:e,centralAngle:t,aspectratio:n,translation:r,quaternion:i,pixelwidth:a,pixelheight:o,plane:f,material:d,rendercall:s,renderTarget:u};if(this._layers.push(p),this._session!==null){p.plane.material=new zl({color:16777215,side:1}),p.plane.material.blending=5,p.plane.material.blendEquation=100,p.plane.material.blendSrc=200,p.plane.material.blendDst=200,p.xrlayer=this._createXRLayer(p);let e=this._session.renderState.layers;e.unshift(p.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return f}renderLayers(){let e=new U,t=new vs,n=this._renderer,r=this.isPresenting;this.isPresenting=!1;let i=new H;n.getSize(i);let a=n.getRenderTarget();for(let r of this._layers){r.renderTarget.isXRRenderTarget=this._session!==null,r.renderTarget._hasExternalTextures=r.renderTarget.isXRRenderTarget;let i=n.contextNode,a;if(r.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){r.xrlayer.transform=new XRRigidTransform(r.plane.getWorldPosition(e),r.plane.getWorldQuaternion(t));let o=this._glBinding.getSubImage(r.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(r.renderTarget,o.colorTexture,void 0),n._setXRLayerSize(r.renderTarget.width,r.renderTarget.height),a=lI.get(i),a===void 0&&(a=i.context({getOutput:e=>WD(e,n.toneMapping,n.outputColorSpace)}),lI.set(i,a))}else a=i;n.contextNode=a,n.setRenderTarget(r.renderTarget),r.rendercall(),n.contextNode=i}n.setRenderTarget(a),n._setXRLayerSize(i.x,i.y),this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();let n=this._gl;if(this._session=e,e!==null){if(e.addEventListener(`select`,this._onSessionEvent),e.addEventListener(`selectstart`,this._onSessionEvent),e.addEventListener(`selectend`,this._onSessionEvent),e.addEventListener(`squeeze`,this._onSessionEvent),e.addEventListener(`squeezestart`,this._onSessionEvent),e.addEventListener(`squeezeend`,this._onSessionEvent),e.addEventListener(`end`,this._onSessionEnd),e.addEventListener(`inputsourceschange`,this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let r=null,i=null,a=null,o=n.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(a=t.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,r=t.stencil?va:_a,i=t.stencil?da:oa);let s={colorFormat:n.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature(`OVR_multiview2`)&&(s.textureType=`texture-array`,this._useMultiview=!0),this._glBinding=this.getBinding();let c=this._glBinding.createProjectionLayer(s),l=[c];this._glProjLayer=c,t.setPixelRatio(1),t._setXRLayerSize(c.textureWidth,c.textureHeight);let u=this._useMultiview?2:1,d=new Tu(c.textureWidth,c.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,r,u);if(this._xrRenderTarget=new oI(c.textureWidth,c.textureHeight,{format:ga,type:ta,colorSpace:t.outputColorSpace,depthTexture:d,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes(`layers`),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new zl({color:16777215,side:+(e.type===`cylinder`)}),e.plane.material.blending=5,e.plane.material.blendEquation=100,e.plane.material.blendSrc=200,e.plane.material.blendDst=200,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());let r={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,n,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new oI(i.framebufferWidth,i.framebufferHeight,{format:ga,type:ta,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:i.ignoreDepthValues===!1,resolveStencilBuffer:i.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:`sessionstart`})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,r=e.far,i=this._cameraXR,a=this._cameraL,o=this._cameraR;i.near=o.near=a.near=n,i.far=o.far=a.far=r,i.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==i.near||this._currentDepthFar!==i.far)&&(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=e.layers.mask|6,a.layers.mask=i.layers.mask&-5,o.layers.mask=i.layers.mask&-3;let s=e.parent,c=i.cameras;uI(i,s);for(let e=0;e<c.length;e++)uI(c[e],s);c.length===2?Oce(i,a,o):i.projectionMatrix.copy(a.projectionMatrix),kce(e,i,s)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new vc,this._controllers[e]=t),t}};function Oce(e,t,n){sI.setFromMatrixPosition(t.matrixWorld),cI.setFromMatrixPosition(n.matrixWorld);let r=sI.distanceTo(cI),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function uI(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function kce(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=Jo*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function Ace(e){let t=this._controllerInputSources.indexOf(e.inputSource);if(t===-1)return;let n=this._controllers[t];if(n!==void 0){let t=this.getReferenceSpace();n.update(e.inputSource,e.frame,t),n.dispatchEvent({type:e.type,data:e.inputSource})}}function jce(){let e=this._session,t=this._renderer;e.removeEventListener(`select`,this._onSessionEvent),e.removeEventListener(`selectstart`,this._onSessionEvent),e.removeEventListener(`selectend`,this._onSessionEvent),e.removeEventListener(`squeeze`,this._onSessionEvent),e.removeEventListener(`squeezestart`,this._onSessionEvent),e.removeEventListener(`squeezeend`,this._onSessionEvent),e.removeEventListener(`end`,this._onSessionEnd),e.removeEventListener(`inputsourceschange`,this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){let t=this._controllerInputSources[e];t!==null&&(this._controllerInputSources[e]=null,this._controllers[e].disconnect(t))}if(this._currentDepthNear=null,this._currentDepthFar=null,this._currentSamples!==null&&(t._samples=this._currentSamples,this._currentSamples=null),t._resetXRState(),this._disposeWebGPUSession(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._webgpuBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(let e of this._layers)e.renderTarget=new oI(e.pixelwidth,e.pixelheight,{format:ga,type:ta,depthTexture:new Tu(e.pixelwidth,e.pixelheight,e.stencilBuffer?da:oa,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?va:_a),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:`sessionend`})}function Mce(e){let t=this._controllers,n=this._controllerInputSources;for(let r=0;r<e.removed.length;r++){let i=e.removed[r],a=n.indexOf(i);a>=0&&(n[a]=null,t[a].disconnect(i))}for(let r=0;r<e.added.length;r++){let i=e.added[r],a=n.indexOf(i);if(a===-1){for(let e=0;e<t.length;e++)if(e>=n.length){n.push(i),a=e;break}else if(n[e]===null){n[e]=i,a=e;break}if(a===-1)break}let o=t[a];o&&o.connect(i)}}function Nce(e){return e.type===`quad`?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function Pce(e,t){if(t===void 0)return;let n=this._cameraXR,r=this._renderer,i=r.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),s=t.getViewerPose(o);if(this._xrFrame=t,s!==null){let e=s.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;this._glBaseLayer!==null&&t===null&&i.setXRTarget(a.framebuffer);let o=!1;e.length!==n.cameras.length&&(n.cameras.length=0,o=!0);for(let r=0;r<e.length;r++){let s=e[r],c;if(t!==null)c=t.viewports[r];else if(this._supportsLayers===!0){let e=this._glBinding.getViewSubImage(this._glProjLayer,s);c=e.viewport,r===0&&i.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else c=a.getViewport(s);let l=this._cameras[r];l===void 0&&(l=new uf,l.layers.enable(r),l.viewport=new Ls,l.matrixWorldAutoUpdate=!1,this._cameras[r]=l),l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.projectionMatrix.fromArray(s.projectionMatrix),l.projectionMatrixInverse.copy(l.projectionMatrix).invert(),l.viewport.set(c.x,c.y,c.width,c.height),r===0&&(n.matrix.copy(l.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale)),o===!0&&n.cameras.push(l)}t!==null&&t.colorTexture!==null&&i.setXRRenderTargetTextures(this._xrRenderTarget,t.colorTexture,t.viewDescriptors),r.setOutputRenderTarget(this._xrRenderTarget);let c=r._getFrameBufferTarget();r.xr.foveateBoundTexture(c)}for(let e=0;e<this._controllers.length;e++){let n=this._controllerInputSources[e],r=this._controllers[e];n!==null&&r!==void 0&&r.update(n,t,o)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:`planesdetected`,data:t}),this._xrFrame=null}var Fce=class extends Wo{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Ls(0,0,this._width,this._height),this._scissor=new Ls(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new Cu,this.depthTexture=new Tu}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+`px`,this.domElement.style.height=t+`px`),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){let i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,i=0,a=1){let o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,n,r),o.minDepth=i,o.maxDepth=a}_dispatchResize(){this.dispatchEvent({type:`resize`})}dispose(){this.dispatchEvent({type:`dispose`})}},dI=new Tc,fI=new H,pI=new Ls,mI=new lu,hI=new du,gI=new Hs,_I=new Ls,Ice={0:1,1:0,2:2},Lce=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:n=!1,reversedDepthBuffer:r=!1,alpha:i=!0,depth:a=!0,stencil:o=!1,antialias:s=!1,samples:c=0,getFallback:l=null,outputBufferType:u=ca,multiview:d=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=n,this.reversedDepthBuffer=r,this.outputColorSpace=go,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=o,this.info=new tP,this.contextNode=iD(),this.library=new iI,this.lighting=new Ece,this._samples=c||s===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new Fce(e.getDomElement()),this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new KD,this._inspector.setRenderer(this),this._getFallback=l,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quadCache=new Map,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;let f=this.alpha===!0?0:1;this._clearColor=new SP(0,0,0,f),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this.onError=this._onError,this._outputBufferType=u,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this._currentSourceMaterial=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:1},this.xr=new Dce(this,d),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,n)=>{await this.compileAsync(n,t,e);let r=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,i=this._renderLists.get(e,t),a=this._renderContexts.get(r,this._mrt),o=e.overrideMaterial||n.material,{fragmentShader:s,vertexShader:c}=this._objects.get(n,o,e,t,i.lightsNode,a,a.clippingContext).getNodeBuilderState();return{fragmentShader:s,vertexShader:c}}}}async init(){return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new Sce(this,n),this._animation=new LN(this,this._nodes,this.info),this._attributes=new XN(n,this.info),this._background=new Fse(this,this._nodes),this._geometries=new eP(this._attributes,this.info),this._textures=new xP(this,n,this.info),this._pipelines=new sP(n,this._nodes,this.info),this._bindings=new cP(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new WN(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new hP(this.lighting),this._bundles=new wce,this._renderContexts=new yP(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,i=r.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._handleObjectFunction,c=this._compilationPromises;n===null&&(n=e);let l=e.isScene===!0?e:n.isScene===!0?n:dI,u=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(u,this._mrt),f=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||=new nI,d.clippingContext.updateGlobal(l,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),l.onBeforeRender(this,e,t,u);let m=t.isArrayCamera?hI:mI;t.isArrayCamera?m.setFromArrayCamera(t):(gI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(gI,t.coordinateSystem,t.reversedDepth));let h=this._renderLists.get(l,t);if(h.begin(),this._projectObject(e,t,0,h,d.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&h.pushLight(e)}),h.finish(),u!==null){this._textures.updateRenderTarget(u,f);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;n===e?this._background.update(l,h,d):this._background.update(n,h,d);let g=h.opaque,_=h.transparent,v=h.transparentDoublePass,y=h.lightsNode;this.opaque===!0&&g.length>0&&this._renderObjects(g,t,l,y),this.transparent===!0&&_.length>0&&this._renderTransparents(_,v,t,l,y),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=s,this._compilationPromises=c;for(let e of p){let t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._geometries.updateForRender(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);let n=[];this._pipelines.getForRender(t,n),n.length>0&&await Promise.all(n),this._nodes.updateAfter(t),await Vo()}}async renderAsync(e,t){Bo(`Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.render(e,t)}async waitForGPU(){V(`Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.`)}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=BO,t.modelNormalViewMatrix=VO):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===BO&&e.modelNormalViewMatrix===VO}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Bo(`Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".`),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),V(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),V(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,n){let{bundleGroup:r,camera:i,renderList:a}=e,o=this._currentRenderContext,s=this._bundles.get(r,i,o),c=this.backend.get(s);if(this._bundleNeedsUpdate(r,c)){this.backend.beginBundle(o),this._currentRenderBundle=s;let{transparentDoublePass:e,transparent:l,opaque:u}=a;this.opaque===!0&&u.length>0&&this._renderObjects(u,i,t,n),this.transparent===!0&&l.length>0&&this._renderTransparents(l,e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,s),c.version=r.version}else{let{renderObjects:e}=c;for(let t=0,n=e.length;t<n;t++){let n=e[t];this._nodes.needsRefresh(n)&&(this._nodes.updateBefore(n),this._geometries.updateForRender(n),this._nodes.updateForRender(n),this._bindings.updateForRender(n),this._nodes.updateAfter(n))}}this.backend.addBundle(o,s)}render(e,t){if(this._initialized===!1)throw Error(`THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.`);this._renderScene(e,t)}get initialized(){return this._initialized}_renderOutputLayers(e,t){if(t.texture.isArrayTexture!==!0||t.texture.image.depth<=1){this._renderScene(e,e.camera,!1);return}let n=this._activeCubeFace;try{for(let n=0;n<t.texture.image.depth;n++)this._nodes.setOutputLayerIndex(n),this._activeCubeFace=n,this._renderScene(e,e.camera,!1)}finally{this._nodes.setOutputLayerIndex(0),this._activeCubeFace=n}}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,n=e!==0,r=t!==Es.workingColorSpace;if(n===!1&&r===!1)return null;let{width:i,height:a}=this.getDrawingBufferSize(fI),{depth:o,stencil:s}=this,c=this._outputRenderTarget||this._canvasTarget,l=this._frameBufferTargets.get(c);if(l===void 0){l=new Rs(i,a,{depthBuffer:o,stencilBuffer:s,type:this._outputBufferType,format:ga,colorSpace:Es.workingColorSpace,generateMipmaps:!1,minFilter:Qi,magFilter:Qi,samples:this.samples}),l.isPostProcessingRenderTarget=!0;let e=()=>{c.removeEventListener(`dispose`,e),l.dispose(),this._frameBufferTargets.delete(c)};c.addEventListener(`dispose`,e),this._frameBufferTargets.set(c,l)}let u=this.getOutputRenderTarget();l.depthBuffer=o,l.stencilBuffer=s,u===null?l.setSize(i,a,1):l.setSize(u.width,u.height,u.depth);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:c._viewport,f=this._outputRenderTarget?this._outputRenderTarget.scissor:c._scissor,p=this._outputRenderTarget?1:c._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:c._scissorTest;return l.viewport.copy(d),l.scissor.copy(f),l.viewport.multiplyScalar(p),l.scissor.multiplyScalar(p),l.scissorTest=m,l.multiview=u!==null&&u.multiview,l.useArrayDepthTexture=u!==null&&u.useArrayDepthTexture,l.resolveDepthBuffer=u===null||u.resolveDepthBuffer,l._autoAllocateDepthBuffer=u!==null&&u._autoAllocateDepthBuffer,l}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;let r=n?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,c=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;let l=e.isScene===!0?e:dI,u=this._renderTarget||this._outputRenderTarget,d=this._activeCubeFace,f=this._activeMipmapLevel,p;if(r===null?p=u:(p=r,this.setRenderTarget(p)),p!==null&&p.depthBuffer===!0){let e=this._textures.get(p);e.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),e.depthInitialized=!0)}let m=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,p),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);let h=this._canvasTarget,g=h._viewport,_=h._scissor,v=h._pixelRatio;p!==null&&(g=p.viewport,_=p.scissor,v=1),this.getDrawingBufferSize(fI),pI.set(0,0,fI.width,fI.height);let y=g.minDepth===void 0?0:g.minDepth,b=g.maxDepth===void 0?1:g.maxDepth;m.viewportValue.copy(g).multiplyScalar(v).floor(),m.viewportValue.width>>=f,m.viewportValue.height>>=f,m.viewportValue.minDepth=y,m.viewportValue.maxDepth=b,m.viewport=m.viewportValue.equals(pI)===!1,m.scissorValue.copy(_).multiplyScalar(v).floor(),m.scissor=h._scissorTest&&m.scissorValue.equals(pI)===!1,m.scissorValue.width>>=f,m.scissorValue.height>>=f,m.clippingContext||=new nI,m.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);let x=t.isArrayCamera?hI:mI;t.isArrayCamera?x.setFromArrayCamera(t):(gI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(gI,t.coordinateSystem,t.reversedDepth));let S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,m.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),p!==null){this._textures.updateRenderTarget(p,f);let e=this._textures.get(p);m.textures=e.textures,m.depthTexture=e.depthTexture,m.width=e.width,m.height=e.height,m.renderTarget=p,m.depth=p.depthBuffer,m.stencil=p.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=fI.width,m.height=fI.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=f,m.height>>=f,m.activeCubeFace=d,m.activeMipmapLevel=f,m.occlusionQueryCount=S.occlusionQueryCount,m.scissorValue.max(_I.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(l,S,m),m.camera=t,this.backend.beginRender(m);let{bundles:C,lightsNode:w,transparentDoublePass:T,transparent:E,opaque:D}=S;return C.length>0&&this._renderBundles(C,l,w),this.opaque===!0&&D.length>0&&this._renderObjects(D,t,l,w),this.transparent===!0&&E.length>0&&this._renderTransparents(E,T,t,l,w),this.backend.finishRender(m),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,this._handleObjectFunction=c,this.lighting.finishRender(e),this._callDepth--,r!==null&&(this.setRenderTarget(u,d,f),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._nodes.getOutputCacheKey(),n=this._quadCache.get(e.texture),r;if(n===void 0){r=new LP(new PA),r.name=`Output Color Transform`,r.material.name=`outputColorTransform`,r.material.fragmentNode=this._nodes.getOutputNode(e.texture),n={quad:r,cacheKey:t},this._quadCache.set(e.texture,n);let i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener(`dispose`,i)};e.texture.addEventListener(`dispose`,i)}else r=n.quad,n.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,n.cacheKey=t);let i=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,n=0,r=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);let e=()=>{t.removeEventListener(`dispose`,e),this.info.destroyReadbackBuffer(t)};t.addEventListener(`dispose`,e)}if(n%4!=0||r>0&&r%4!=0)throw Error(`THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.`);return await this.backend.getArrayBufferAsync(e,t,n,r)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,r,i=0,a=1){this._canvasTarget.setViewport(e,t,n,r,i,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw Error(`THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.`);let r=this._renderTarget||this._getFrameBufferTarget(),i=null;if(r!==null){this._textures.updateRenderTarget(r);let e=this._textures.get(r);i=this._renderContexts.get(r,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer;let t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),r.depthBuffer===!0&&(e.depthInitialized=!0)}this.backend.clear(e,t,n,i),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){Bo(`Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.clear(e,t,n)}async clearColorAsync(){Bo(`Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.`),this.clear(!0,!1,!1)}async clearDepthAsync(){Bo(`Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!0,!1)}async clearStencilAsync(){Bo(`Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==0,t=this.currentColorSpace!==Es.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget===null?this.needsFrameBufferTarget&&(e=0):e=this._renderTarget.samples,e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Es.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return B(`Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.`),this.computeAsync(e,t);let n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let i=this.backend,a=this._pipelines,o=this._bindings,s=this._nodes,c=Array.isArray(e)?e:[e];if(c[0]===void 0||c[0].isComputeNode!==!0)throw Error(`THREE.Renderer: .compute() expects a ComputeNode.`);i.beginCompute(e);for(let n of c){if(a.has(n)===!1){let e=()=>{n.removeEventListener(`dispose`,e),a.delete(n),o.deleteForCompute(n),s.delete(n)};n.addEventListener(`dispose`,e);let t=n.onInitFunction;t!==null&&t.call(n,{renderer:this})}s.updateForCompute(n),o.updateForCompute(n);let r=o.getForCompute(n),c=a.getForCompute(n,r);i.compute(e,n,r,c,t)}i.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return Bo(`Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e=`render`){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Bo(`Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateRenderTarget(e);let t=this._textures.get(e),n=this._renderContexts.get(e);n.textures=t.textures,n.depthTexture=t.depthTexture,n.width=t.width,n.height=t.height,n.renderTarget=e,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,this.backend.initRenderTarget(n)}copyFramebufferToTexture(e,t=null){if(t!==null){if(t.isVector2)t=_I.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=_I.copy(t).floor();else{V(`Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}}else t=_I.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))):r=n.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,i,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,i,o)}_projectObject(e,t,n,r,i){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?hI:mI;if(!e.frustumCulled||a.intersectsSprite(e)){this.sortObjects===!0&&_I.setFromMatrixPosition(e.matrixWorld).applyMatrix4(gI);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,_I.z,null,i)}}else if(e.isLineLoop)V(`Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.`);else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?hI:mI;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),_I.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(gI)),Array.isArray(a)){let o=t.groups;for(let s=0,c=o.length;s<c;s++){let c=o[s],l=a[c.materialIndex];l&&l.visible&&r.push(e,t,l,n,_I.z,c,i)}}else a.visible&&r.push(e,t,a,n,_I.z,null,i)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){let a=r;r=this._renderLists.get(e,t);let o=this._bundles.get(e,t,this._currentRenderContext),s=this.backend.get(o);if(this._bundleNeedsUpdate(e,s)){r.begin(),s.renderObjects===void 0?s.renderObjects=[]:s.renderObjects.length=0;let a=e.children;for(let e=0,o=a.length;e<o;e++)this._projectObject(a[e],t,n,r,i);r.finish()}a.pushBundle({bundleGroup:e,camera:t,renderList:r});return}let a=e.children;for(let e=0,o=a.length;e<o;e++)this._projectObject(a[e],t,n,r,i)}_renderBundles(e,t,n){for(let r of e)this._renderBundle(r,t,n)}_renderTransparents(e,t,n,r,i){if(t.length>0){for(let{material:e}of t)e.side=1;this._renderObjects(t,n,r,i,`backSide`);for(let{material:e}of t)e.side=0;this._renderObjects(e,n,r,i);for(let{material:e}of t)e.side=2}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let a=0,o=e.length;a<o;a++){let{object:o,geometry:s,material:c,group:l,clippingContext:u}=e[a];this._currentRenderObjectFunction(o,n,t,s,c,l,r,u,i)}}_getShadowNodes(e){let t=e.version,n=this._cacheShadowNodes.get(e);if(n===void 0||n.version!==t){let r=e.map&&e.map.isTexture,i=e.colorNode&&e.colorNode.isNode,a=e.castShadowNode&&e.castShadowNode.isNode,o=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,s=null,c=null,l=null;if(r||i||a||o){let t,n;if(a?(t=e.castShadowNode.rgb,n=e.castShadowNode.a,this.shadowMap.transmitted!==!0&&Bo("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(t=J(0),n=q(1)),r&&(n=n.mul(xk(`map`,`texture`,e).a)),i&&(n=n.mul(e.colorNode.a)),c=TT(t,n),o){let t=e.maskShadowNode||e.maskNode;c=K(([e])=>(t.not().discard(),e))(c)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?s=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(s=e.positionNode),n={version:t,colorNode:c,depthNode:l,positionNode:s},this._cacheShadowNodes.set(e,n)}return n}_updateCamera(e){let t=this.xr;if(t.isPresenting===!1){let t=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(let t of e.cameras)t._reversedDepth=!0;t=!0}let n=this.coordinateSystem;if(e.coordinateSystem!==n){if(e.coordinateSystem=n,e.isArrayCamera)for(let t of e.cameras)t.coordinateSystem=n;t=!0}if(t===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let t of e.cameras)t.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,n,r,i,a,o,s=null,c=null){let l=!1,u,d,f,p,m,h,g,_=this._currentSourceMaterial;if(e.onBeforeRender(this,t,n,r,i,a),i.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=i;let e=t.overrideMaterial;if(l=!0,u=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,f=e.isNodeMaterial?e.positionNode:null,p=t.overrideMaterial.side,m=e.displacementMap,h=e.displacementScale,g=e.displacementBias,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.displacementMap=i.displacementMap,e.displacementScale=i.displacementScale,e.displacementBias=i.displacementBias,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:n,positionNode:r}=this._getShadowNodes(i);e.side=this.shadowMap.type===3?i.shadowSide===null?i.side:i.shadowSide:i.shadowSide===null?Ice[i.side]:i.shadowSide,t!==null&&(e.colorNode=t),n!==null&&(e.depthNode=n),r!==null&&(e.positionNode=r)}i=e}i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,this._handleObjectFunction(e,i,t,n,o,a,s,`backSide`),i.side=0,this._handleObjectFunction(e,i,t,n,o,a,s,c),i.side=2):this._handleObjectFunction(e,i,t,n,o,a,s,c),l&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=m,t.overrideMaterial.displacementScale=h,t.overrideMaterial.displacementBias=g),this._currentSourceMaterial=_,e.onAfterRender(this,t,n,r,i,a)}hasCompatibility(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup);let l=this._nodes.needsRefresh(c);l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._pipelines.isReady(c)&&(this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c))}_createObjectPipeline(e,t,n,r,i,a,o,s){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:n,camera:r,lightsNode:i,group:a,clippingContext:o,passId:s,renderContext:this._currentRenderContext});return}let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},vI=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function yI(e){return e+(qN-e%qN)%qN}var bI=class extends vI{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return yI(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}},xI=class extends bI{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},Rce=0,SI=class extends xI{constructor(e,t){super(`UniformBuffer_`+Rce++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return yI(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}},zce=class extends xI{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let n=this._updateRangeCache.get(t);n===void 0&&(n={start:0,count:0},this._updateRangeCache.set(t,n)),n.start=e.offset,n.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(n)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,r=this.uniforms.length;n<r;n++){let r=this.uniforms[n],i=r.boundary,a=r.itemSize*e,o=t%qN,s=o%i,c=o+s;t+=s,c!==0&&qN-c<a&&(t+=qN-c),r.offset=t/e,r.index=n,t+=a}return Math.ceil(t/qN)*qN}update(){let e=!1;for(let t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}release(){super.release(),this._values=null}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);V(`WebGPUUniformsGroup: Unsupported uniform type.`,e)}updateNumber(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i]!==r){let o=this._getBufferForType(a);o[i]=n[i]=r,t=!0,this.addUniformUpdateRange(e)}return t}updateVector2(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,o[i+2]=n[i+2]=r.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z||n[i+3]!==r.w){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,o[i+2]=n[i+2]=r.z,o[i+3]=n[i+3]=r.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset;if(n[i+0]!==r.r||n[i+1]!==r.g||n[i+2]!==r.b){let a=this.buffer;a[i+0]=n[i+0]=r.r,a[i+1]=n[i+1]=r.g,a[i+2]=n[i+2]=r.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;if(n[i+0]!==r[0]||n[i+1]!==r[1]||n[i+2]!==r[2]||n[i+4]!==r[3]||n[i+5]!==r[4]||n[i+6]!==r[5]||n[i+8]!==r[6]||n[i+9]!==r[7]||n[i+10]!==r[8]){let a=this.buffer;a[i+0]=n[i+0]=r[0],a[i+1]=n[i+1]=r[1],a[i+2]=n[i+2]=r[2],a[i+4]=n[i+4]=r[3],a[i+5]=n[i+5]=r[4],a[i+6]=n[i+6]=r[5],a[i+8]=n[i+8]=r[6],a[i+9]=n[i+9]=r[7],a[i+10]=n[i+10]=r[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;return Vce(n,r,i)===!1&&(this.buffer.set(r,i),Bce(n,r,i),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`?new Int32Array(this.buffer.buffer):e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`?new Uint32Array(this.buffer.buffer):this.buffer}};function Bce(e,t,n){for(let r=0,i=t.length;r<i;r++)e[n+r]=t[r]}function Vce(e,t,n){for(let r=0,i=t.length;r<i;r++)if(e[n+r]!==t[r])return!1;return!0}var Hce=0,CI=class extends zce{constructor(e,t){super(e),this.id=Hce++,this.groupNode=t,this.isNodeUniformsGroup=!0}},wI=class extends vI{constructor(e,t){super(e),this._texture=t,this.version=-1,this.generation=null,this.samplerKey=``,this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture=e,this.reset())}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}reset(){this.generation=null,this.version=-1}release(){this._texture=null}},Uce=0,Wce=class extends wI{constructor(e,t){super(e,t),this.id=Uce++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}},TI=class extends Wce{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},EI=class extends TI{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}},DI=class extends TI{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}},OI={bitcast_int_uint:new iF(`uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }`),bitcast_uint_int:new iF(`uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }`),textureGather:new iF(`
|
|
4655
|
+
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){B(`Abstract function.`)}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,`any`).subBuilds:e instanceof Set?[...e]:e,!t)return null;let n=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let r=t[e];if(n.includes(r))return r}return null}getSubBuildOutput(e){return this.getSubBuildProperty(`outputNode`,e)}getSubBuildProperty(e=``,t=null){let n;n=t===null?this.subBuildFn:this.getClosestSubBuild(t);let r;return r=n?e?n+`_`+e:n:e,r}prebuild(){let{object:e,renderer:t,material:n}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:V('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),n&&n.contextNode&&(n.contextNode.isContextNode===!0?this.context={...this.context,...n.contextNode.getFlowContextData()}:V('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),n!==null){let e=t.library.fromMaterial(n);e===null&&(V(`NodeBuilder: Material "${n.type}" is not compatible.`),e=new FA),e.build(this)}else this.addFlow(`compute`,e)}build(){this.prebuild();for(let e of jw){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of Mw){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(let e of jw){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of Mw){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this);await Vo()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=ace.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){let n=this.getSharedDataFromNode(e),r=n.cache;if(r===void 0){if(t===`float`||t===`int`||t===`uint`)r=new Xse(e);else if(t===`vec2`||t===`ivec2`||t===`uvec2`)r=new Zse(e);else if(t===`vec3`||t===`ivec3`||t===`uvec3`)r=new Qse(e);else if(t===`vec4`||t===`ivec4`||t===`uvec4`)r=new $se(e);else if(t===`color`)r=new ece(e);else if(t===`mat2`)r=new tce(e);else if(t===`mat3`)r=new nce(e);else if(t===`mat4`)r=new rce(e);else throw Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let r=this.getTypeLength(t),i=this.getTypeLength(n);return r===16&&i===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&i===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||i>4||i===0?e:r===i?`${this.getType(n)}( ${e} )`:r>i?(e=n===`bool`?`all( ${e} )`:`${e}.${`xyz`.slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),n)):i===4&&r>1?`${this.getType(n)}( ${this.format(e,t,`vec3`)}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,`vec2`)}, 0.0 )`:(r===1&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r185 - Node System
|
|
4656
|
+
`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has(`velocity`)||Dw(this.object).useVelocity===!0}},GF=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===kw.FRAME){let t=this._getMaps(this.updateBeforeMap,n);if(t.frameId!==this.frameId){let n=t.frameId;t.frameId=this.frameId,e.updateBefore(this)===!1&&(t.frameId=n)}}else if(t===kw.RENDER){let t=this._getMaps(this.updateBeforeMap,n);if(t.renderId!==this.renderId){let n=t.renderId;t.renderId=this.renderId,e.updateBefore(this)===!1&&(t.renderId=n)}}else t===kw.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===kw.FRAME){let t=this._getMaps(this.updateAfterMap,n);t.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(t.frameId=this.frameId)}else if(t===kw.RENDER){let t=this._getMaps(this.updateAfterMap,n);t.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(t.renderId=this.renderId)}else t===kw.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===kw.FRAME){let t=this._getMaps(this.updateMap,n);t.frameId!==this.frameId&&e.update(this)!==!1&&(t.frameId=this.frameId)}else if(t===kw.RENDER){let t=this._getMaps(this.updateMap,n);t.renderId!==this.renderId&&e.update(this)!==!1&&(t.renderId=this.renderId)}else t===kw.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},KF=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};KF.isNodeFunctionInput=!0;var sce=class extends MF{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},cce=class extends MF{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:vF(this.light),lightColor:e}}},lce=class extends MF{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=gF(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=hE(new Cc).setGroup(pE)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=QE(n,t,ak.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(i)}},qF=class extends MF{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=hE(0).setGroup(pE),this.penumbraCosNode=hE(0).setGroup(pE),this.cutoffDistanceNode=hE(0).setGroup(pE),this.decayExponentNode=hE(0).setGroup(pE),this.colorNode=hE(this.color).setGroup(pE)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:n,penumbraCosNode:r}=this;return nD(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=Joe(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=this.getLightVector(e),o=a.normalize(),s=o.dot(vF(i)),c=this.getSpotAttenuation(e,s),l=NF({lightDistance:a.length(),cutoffDistance:n,decayExponent:r}),u=t.mul(c).mul(l),d,f;return i.colorNode?(f=this.getLightCoord(e),d=i.colorNode(f)):i.map&&(f=this.getLightCoord(e),d=nO(i.map,f.xy).onRenderUpdate(()=>i.map)),d&&(u=f.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(d),u)),{lightColor:u,lightDirection:o}}},uce=class extends qF{static get type(){return`IESSpotLightNode`}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let n=this.light.iesMap,r=null;if(n&&n.isTexture===!0){let e=t.acos().mul(1/Math.PI);this._iesTextureNode=nO(n,xT(e,0),0),r=this._iesTextureNode.r}else r=super.getSpotAttenuation(e,t);return r}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}},dce=class extends MF{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new U);this.lightProbe=oO(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=Nse(ak,this.lightProbe);e.context.irradiance.addAssign(t)}},fce=K(([e,t])=>{let n=e.abs().sub(t);return RE(WE(n,0)).add(UE(WE(n.x,n.y),0))}),pce=class extends qF{static get type(){return`ProjectorLightNode`}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=q(0),n=this.penumbraCosNode,r=hF(this.light).mul(e.context.positionWorld||qO);return gT(r.w.greaterThan(0),()=>{let e=fce(r.xyz.div(r.w).xy.sub(xT(.5)),xT(.5)),i=xE(-1,yE(1,FE(n)).sub(1));t.assign(eD(e.mul(-2).mul(i)))}),t}},JF=new Hs,YF=new Hs,XF=null,mce=class extends MF{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=hE(new U).setGroup(pE),this.halfWidth=hE(new U).setGroup(pE),this.updateType=kw.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;YF.identity(),JF.copy(t.matrixWorld),JF.premultiply(n),YF.extractRotation(JF),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(YF),this.halfHeight.value.applyMatrix4(YF)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=nO(XF.LTC_FLOAT_1),n=nO(XF.LTC_FLOAT_2)):(t=nO(XF.LTC_HALF_1),n=nO(XF.LTC_HALF_2));let{colorNode:r,light:i}=this;return{lightColor:r,lightPosition:_F(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){XF=e}},ZF=class{parseFunction(){B(`Abstract function.`)}},QF=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){B(`Abstract function.`)}};QF.isNodeFunction=!0;var hce=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,gce=/[a-z_0-9]+/gi,_ce=`#pragma main`,vce=e=>{e=e.trim();let t=e.indexOf(_ce),n=t===-1?e:e.slice(t+12),r=n.match(hce);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=gce.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c<a.length;){let e=a[c][0]===`const`;e===!0&&c++;let t=a[c][0];t===`in`||t===`out`||t===`inout`?c++:t=``;let n=a[c++][0],r=Number.parseInt(a[c][0]);Number.isNaN(r)===!1?c++:r=null;let i=a[c++][0];s.push(new KF(n,i,r,t,e))}let l=n.substring(r[0].length),u=r[3]===void 0?``:r[3];return{type:r[2],inputs:s,name:u,precision:r[1]===void 0?``:r[1],inputsCode:i,blockCode:l,headerCode:t===-1?``:e.slice(0,t)}}throw Error(`THREE.FunctionNode: Function is not a GLSL code.`)},yce=class extends QF{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=vce(e);super(t,n,r,i),this.inputsCode=a,this.blockCode=o,this.headerCode=s}getCode(e=this.name){let t,n=this.blockCode;if(n!==``){let{type:r,inputsCode:i,headerCode:a,precision:o}=this,s=`${r} ${e} ( ${i.trim()} )`;o!==``&&(s=`${o} ${s}`),t=a+s+n}else t=``;return t}},bce=class extends ZF{parseFunction(e){return new yce(e)}},$F=[],eI=[],tI=hE(0,`int`).setGroup(pE),xce=class extends KN{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new GF,this.nodeBuilderCache=new Map,this.callHashCache=new zN,this.groupsData=new zN,this._buildQueue=[],this._buildInProgress=!1,this.cacheLib={}}updateGroup(e){let t=e.groupNode;if(t.updateType===kw.OBJECT)return!0;$F[0]=t,$F[1]=e;let n=this.groupsData.get($F);return n===void 0&&this.groupsData.set($F,n={}),$F[0]=null,$F[1]=null,n.version!==t.version&&(n.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}_createNodeBuilder(e,t){let n=this.backend.createNodeBuilder(e.object,this.renderer);return n.scene=e.scene,n.material=t,n.camera=e.camera,n.context.material=t,n.lightsNode=e.lightsNode,n.environmentNode=this.getEnvironmentNode(e.scene),n.fogNode=this.getFogNode(e.scene),n.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&n.enableMultiview(),n}getForRender(e,t=!1){let n=this.get(e),r=n.nodeBuilderState;if(r===void 0){let{nodeBuilderCache:i}=this,a=this.getForRenderCacheKey(e);if(r=i.get(a),r===void 0){let o=async()=>{let n=this._createNodeBuilder(e,e.material);try{t?await n.buildAsync():n.build()}catch(r){n=this._createNodeBuilder(e,new FA),t?await n.buildAsync():n.build(),V(`TSL: `+r)}return n};if(t)return o().then(e=>(r=this._createNodeBuilderState(e),i.set(a,r),r.usedTimes++,n.nodeBuilderState=r,r));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(n){t=this._createNodeBuilder(e,new FA),t.build();let r=n.stackTrace;!r&&n.stack&&(r=new vw(n.stack)),V(`TSL: `+n,r)}r=this._createNodeBuilderState(t),i.set(a,r)}}r.usedTimes++,n.nodeBuilderState=r}return r}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;let n=this.getForRenderCacheKey(e),r=this.nodeBuilderCache.get(n);return r===void 0?(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null):(r.usedTimes++,t.nodeBuilderState=r,r)}_processBuildQueue(){this._buildInProgress||this._buildQueue.length===0||(this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()}))}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0||t.version!==e.version){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n,t.version=e.version}return n}_createNodeBuilderState(e){return new Ise(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){$F[0]=e,$F[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get($F)||{};if(r.callId!==n){if(eI.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),eI.push(+!!this.renderer.lighting.enabled),this.renderer.lighting.enabled){eI.push(t.getCacheKey(!0)),eI.push(+!!this.renderer.shadowMap.enabled),eI.push(this.renderer.shadowMap.type);let n=this.getEnvironmentNode(e);n&&eI.push(n.getCacheKey())}let i=this.getFogNode(e);i&&eI.push(i.getCacheKey()),r.callId=n,r.cacheKey=xw(eI),this.callHashCache.set($F,r),eI.length=0}return $F[0]=null,$F[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),n=e.background;if(n){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;(t.background!==n||r)&&(t.backgroundNode=this.getCacheNode(`background`,n,()=>{if(n.isCubeTexture===!0||n.mapping===303||n.mapping===304||n.mapping===306){if(e.backgroundBlurriness>0||n.mapping===306)return fN(n);{let e;return e=n.isCubeTexture===!0?yk(n):nO(n),tj(e)}}if(n.isTexture===!0)return nO(n,fO.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&V(`WebGPUNodes: Unsupported background configuration.`,n)},r),t.background=n,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){let i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(a===void 0||r)&&(a=n(),i.set(t,a)),a}updateFog(e){let t=this.get(e),n=e.fog;n?t.fog!==n&&(t.fogNode=this.getCacheNode(`fog`,n,()=>{if(n.isFogExp2)return uF(Sk(`color`,`color`,n).setGroup(pE),lF(Sk(`density`,`float`,n).setGroup(pE)));if(n.isFog)return uF(Sk(`color`,`color`,n).setGroup(pE),cF(Sk(`near`,`float`,n).setGroup(pE),Sk(`far`,`float`,n).setGroup(pE)));V(`Renderer: Unsupported fog configuration.`,n)}),t.fog=n):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),n=e.environment;n?t.environment!==n&&(t.environmentNode=this.getCacheNode(`environment`,n,()=>{if(n.isCubeTexture===!0)return yk(n);if(n.isTexture===!0)return nO(n);V(`Nodes: Unsupported environment configuration.`,n)}),t.environment=n):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=i,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+`,`+e.currentColorSpace+`,`+e.xr.isPresenting}getOutputNode(e){let t=this.renderer,n;return n=e.isArrayTexture?this.backend.isWebGLBackend?nO(e,fO).depth(sO(`gl_ViewID_OVR`)).renderOutput(t.toneMapping,t.currentColorSpace):nO(e,fO).depth(tI).renderOutput(t.toneMapping,t.currentColorSpace):nO(e,fO).renderOutput(t.toneMapping,t.currentColorSpace),n}setOutputLayerIndex(e){tI.value=e}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let e of n.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let e of n.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new GF,this.nodeBuilderCache=new Map,this.cacheLib={}}},nI=new au,rI=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewMatrix=new Hs,this.viewNormalMatrix=new xs,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,n){let r=e.length;for(let i=0;i<r;i++){nI.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[n+i],a=nI.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=nI.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix.copy(t.matrixWorldInverse),this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let n=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let r=t.clippingPlanes,i=r.length,a,o;if(this.clipIntersection?(a=this.intersectionPlanes,o=e.intersectionPlanes.length):(a=this.unionPlanes,o=e.unionPlanes.length),a.length!==o+i){a.length=o+i;for(let e=0;e<i;e++)a[o+e]=new Ls;n=!0}this.projectPlanes(r,a,o),n&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(t){if(this.shadowPass&&!t.clipShadows)return this;let n=this.clippingGroupContexts.get(t);return n===void 0&&(n=new e(this),this.clippingGroupContexts.set(t,n)),n.update(this,t),n}get unionClippingCount(){return this.unionPlanes.length}},Sce=class{constructor(e,t,n){this.bundleGroup=e,this.camera=t,this.renderContext=n}},iI=[],Cce=class{constructor(){this.bundles=new zN}get(e,t,n){let r=this.bundles;iI[0]=e,iI[1]=t,iI[2]=n;let i=r.get(iI);return i===void 0&&(i=new Sce(e,t,n),r.set(iI,i)),iI[0]=null,iI[1]=null,iI[2]=null,i}dispose(){this.bundles=new zN}},aI=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(let n in e)t[n]=e[n]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){B(`Redefinition of node ${t}`);return}if(typeof e!=`function`)throw Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if(typeof t==`function`||typeof t==`object`)throw Error(`THREE.NodeLibrary: Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){B(`Redefinition of node ${t.name}`);return}if(typeof e!=`function`)throw Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if(typeof t!=`function`)throw Error(`THREE.NodeLibrary: Base class ${t.name} is not a class.`);n.set(t,e)}},wce=new xF,oI=new WeakMap,Tce=class{constructor(){this.enabled=!0,this._cache=[]}createNode(e=[]){return new xF().setLights(e)}getNode(e){if(e.isScene!==!0&&e.isGroup!==!0)return wce;let t=oI.get(e);return t===void 0&&(t=this.createNode(),oI.set(e,t)),t}beginRender(e){this._cache.push(this.getNode(e).getLights())}finishRender(e){this.getNode(e).setLights(this._cache.pop())}},sI=class extends Rs{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}},cI=new U,lI=new U,uI=new WeakMap,Ece=class extends Wo{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new uf,this._cameraL.viewport=new Ls,this._cameraL.matrixWorldAutoUpdate=!1,this._cameraR=new uf,this._cameraR.viewport=new Ls,this._cameraR.matrixWorldAutoUpdate=!1,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new Tf,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding<`u`,this._supportsWebGPUBinding=globalThis.XRGPUBinding!==void 0,this._createXRLayer=Mce.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSamples=null,this._currentSize=new H,this._onSessionEvent=kce.bind(this),this._onSessionEnd=Ace.bind(this),this._onInputSourcesChange=jce.bind(this),this._onAnimationFrame=Nce.bind(this),this._referenceSpace=null,this._referenceSpaceType=`local-floor`,this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._webgpuBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&`createProjectionLayer`in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&B(`XRManager: Cannot change framebuffer scale while presenting.`)}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&B(`XRManager: Cannot change reference space type while presenting.`)}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBaseLayer(){return this._glProjLayer===null?this._glBaseLayer:this._glProjLayer}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}foveateBoundTexture(e){if(e.isPostProcessingRenderTarget!==!0||this.isPresenting!==!0||this._glProjLayer===null)return;let t=this._renderer.backend;if(t===void 0||t.isWebGLBackend!==!0||t.state===null)return;let n=this._renderer.getOutputRenderTarget();if(n===null||n.isXRRenderTarget!==!0)return;let r=this.getBinding();if(r===null||typeof r.foveateBoundTexture!=`function`)return;this._renderer._textures.updateRenderTarget(e);let{textureGPU:i,glTextureType:a}=t.get(e.texture);if(i!==void 0&&a!==void 0&&e._xrFoveationTextureGPU!==i){e._xrFoveationTextureGPU=i,t.state.bindTexture(a,i);try{r.foveateBoundTexture(a,this.getFoveation())}catch(e){Bo(`XRManager: Unable to foveate bound XR post-processing texture. ${e.name}: ${e.message}`)}finally{t.state.unbindTexture()}}}getWebGPUBinding(){return this._webgpuBinding===null&&this._supportsWebGPUBinding&&(this._webgpuBinding=new globalThis.XRGPUBinding(this._session,this._renderer.backend.device)),this._webgpuBinding}_isWebGPUSession(){return this._renderer.backend.isWebGPUBackend===!0&&this._session!==null&&this._session.enabledFeatures.includes(`webgpu`)}_validateWebGPUSession(){let e=this._renderer;if(e.backend.isWebGPUBackend===!0){if(this._session.enabledFeatures.includes(`webgpu`)===!1)throw Error(`THREE.XRManager: WebGPU XR sessions require the "webgpu" session feature. Use VRButtonGPU/XRButton with "webgpu" enabled or use a WebGL backend.`);e.samples>0&&(Bo(`THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session.`),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){let t=this.getWebGPUBinding(),n=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:`depth24plus`});this._glProjLayer=n,e.updateRenderState({layers:[n]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new Rs(n.textureWidth,n.textureHeight,{depth:2,minFilter:Qi,magFilter:Qi,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&Bo(`THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session.`),this._useMultiview=!1}_disposeWebGPUSession(){let e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;let n=e.backend,r=e._textures,i=n.get?n.get(t):null;i&&(i.descriptors=void 0);let a=e=>{e!=null&&(n.delete&&n.delete(e),r.delete&&r.delete(e))};for(let e=0;e<t.textures.length;e++)a(t.textures[e]);a(t.depthTexture),a(t),e._renderContexts&&e._renderContexts.dispose&&e._renderContexts.dispose(),t.dispose()}_getWebGPUViewData(e){let t=this.getWebGPUBinding(),n={colorTexture:null,viewDescriptors:[],viewports:[]};for(let r=0;r<e.length;r++){let i=t.getViewSubImage(this._glProjLayer,e[r]);n.colorTexture===null&&(n.colorTexture=i.colorTexture),n.viewports.push(i.viewport),i.getViewDescriptor&&n.viewDescriptors.push(i.getViewDescriptor())}return n}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,r,i,a,o,s={}){let c=new id(e,t),l=new sI(i,a,{format:ga,type:ta,depthTexture:new Tu(i,a,s.stencil?da:oa,void 0,void 0,void 0,void 0,void 0,void 0,s.stencil?va:_a),stencilBuffer:s.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});l._autoAllocateDepthBuffer=!0;let u=new zl({color:16777215,side:0});u.map=l.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new Zl(c,u);d.position.copy(n),d.quaternion.copy(r);let f={type:`quad`,width:e,height:t,translation:n,quaternion:r,pixelwidth:i,pixelheight:a,plane:d,material:u,rendercall:o,renderTarget:l};if(this._layers.push(f),this._session!==null){f.plane.material=new zl({color:16777215,side:0}),f.plane.material.blending=5,f.plane.material.blendEquation=100,f.plane.material.blendSrc=200,f.plane.material.blendDst=200,f.xrlayer=this._createXRLayer(f);let e=this._session.renderState.layers;e.unshift(f.xrlayer),this._session.updateRenderState({layers:e})}else l.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,n,r,i,a,o,s,c={}){let l=new ku(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),u=new sI(a,o,{format:ga,type:ta,depthTexture:new Tu(a,o,c.stencil?da:oa,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?va:_a),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;let d=new zl({color:16777215,side:1});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let f=new Zl(l,d);f.position.copy(r),f.quaternion.copy(i);let p={type:`cylinder`,radius:e,centralAngle:t,aspectratio:n,translation:r,quaternion:i,pixelwidth:a,pixelheight:o,plane:f,material:d,rendercall:s,renderTarget:u};if(this._layers.push(p),this._session!==null){p.plane.material=new zl({color:16777215,side:1}),p.plane.material.blending=5,p.plane.material.blendEquation=100,p.plane.material.blendSrc=200,p.plane.material.blendDst=200,p.xrlayer=this._createXRLayer(p);let e=this._session.renderState.layers;e.unshift(p.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return f}renderLayers(){let e=new U,t=new vs,n=this._renderer,r=this.isPresenting;this.isPresenting=!1;let i=new H;n.getSize(i);let a=n.getRenderTarget();for(let r of this._layers){r.renderTarget.isXRRenderTarget=this._session!==null,r.renderTarget._hasExternalTextures=r.renderTarget.isXRRenderTarget;let i=n.contextNode,a;if(r.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){r.xrlayer.transform=new XRRigidTransform(r.plane.getWorldPosition(e),r.plane.getWorldQuaternion(t));let o=this._glBinding.getSubImage(r.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(r.renderTarget,o.colorTexture,void 0),n._setXRLayerSize(r.renderTarget.width,r.renderTarget.height),a=uI.get(i),a===void 0&&(a=i.context({getOutput:e=>GD(e,n.toneMapping,n.outputColorSpace)}),uI.set(i,a))}else a=i;n.contextNode=a,n.setRenderTarget(r.renderTarget),r.rendercall(),n.contextNode=i}n.setRenderTarget(a),n._setXRLayerSize(i.x,i.y),this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();let n=this._gl;if(this._session=e,e!==null){if(e.addEventListener(`select`,this._onSessionEvent),e.addEventListener(`selectstart`,this._onSessionEvent),e.addEventListener(`selectend`,this._onSessionEvent),e.addEventListener(`squeeze`,this._onSessionEvent),e.addEventListener(`squeezestart`,this._onSessionEvent),e.addEventListener(`squeezeend`,this._onSessionEvent),e.addEventListener(`end`,this._onSessionEnd),e.addEventListener(`inputsourceschange`,this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let r=null,i=null,a=null,o=n.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(a=t.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,r=t.stencil?va:_a,i=t.stencil?da:oa);let s={colorFormat:n.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature(`OVR_multiview2`)&&(s.textureType=`texture-array`,this._useMultiview=!0),this._glBinding=this.getBinding();let c=this._glBinding.createProjectionLayer(s),l=[c];this._glProjLayer=c,t.setPixelRatio(1),t._setXRLayerSize(c.textureWidth,c.textureHeight);let u=this._useMultiview?2:1,d=new Tu(c.textureWidth,c.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,r,u);if(this._xrRenderTarget=new sI(c.textureWidth,c.textureHeight,{format:ga,type:ta,colorSpace:t.outputColorSpace,depthTexture:d,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes(`layers`),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new zl({color:16777215,side:+(e.type===`cylinder`)}),e.plane.material.blending=5,e.plane.material.blendEquation=100,e.plane.material.blendSrc=200,e.plane.material.blendDst=200,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());let r={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,n,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new sI(i.framebufferWidth,i.framebufferHeight,{format:ga,type:ta,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:i.ignoreDepthValues===!1,resolveStencilBuffer:i.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:`sessionstart`})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,r=e.far,i=this._cameraXR,a=this._cameraL,o=this._cameraR;i.near=o.near=a.near=n,i.far=o.far=a.far=r,i.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==i.near||this._currentDepthFar!==i.far)&&(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=e.layers.mask|6,a.layers.mask=i.layers.mask&-5,o.layers.mask=i.layers.mask&-3;let s=e.parent,c=i.cameras;dI(i,s);for(let e=0;e<c.length;e++)dI(c[e],s);c.length===2?Dce(i,a,o):i.projectionMatrix.copy(a.projectionMatrix),Oce(e,i,s)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new vc,this._controllers[e]=t),t}};function Dce(e,t,n){cI.setFromMatrixPosition(t.matrixWorld),lI.setFromMatrixPosition(n.matrixWorld);let r=cI.distanceTo(lI),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function dI(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function Oce(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=Jo*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function kce(e){let t=this._controllerInputSources.indexOf(e.inputSource);if(t===-1)return;let n=this._controllers[t];if(n!==void 0){let t=this.getReferenceSpace();n.update(e.inputSource,e.frame,t),n.dispatchEvent({type:e.type,data:e.inputSource})}}function Ace(){let e=this._session,t=this._renderer;e.removeEventListener(`select`,this._onSessionEvent),e.removeEventListener(`selectstart`,this._onSessionEvent),e.removeEventListener(`selectend`,this._onSessionEvent),e.removeEventListener(`squeeze`,this._onSessionEvent),e.removeEventListener(`squeezestart`,this._onSessionEvent),e.removeEventListener(`squeezeend`,this._onSessionEvent),e.removeEventListener(`end`,this._onSessionEnd),e.removeEventListener(`inputsourceschange`,this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){let t=this._controllerInputSources[e];t!==null&&(this._controllerInputSources[e]=null,this._controllers[e].disconnect(t))}if(this._currentDepthNear=null,this._currentDepthFar=null,this._currentSamples!==null&&(t._samples=this._currentSamples,this._currentSamples=null),t._resetXRState(),this._disposeWebGPUSession(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._webgpuBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(let e of this._layers)e.renderTarget=new sI(e.pixelwidth,e.pixelheight,{format:ga,type:ta,depthTexture:new Tu(e.pixelwidth,e.pixelheight,e.stencilBuffer?da:oa,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?va:_a),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:`sessionend`})}function jce(e){let t=this._controllers,n=this._controllerInputSources;for(let r=0;r<e.removed.length;r++){let i=e.removed[r],a=n.indexOf(i);a>=0&&(n[a]=null,t[a].disconnect(i))}for(let r=0;r<e.added.length;r++){let i=e.added[r],a=n.indexOf(i);if(a===-1){for(let e=0;e<t.length;e++)if(e>=n.length){n.push(i),a=e;break}else if(n[e]===null){n[e]=i,a=e;break}if(a===-1)break}let o=t[a];o&&o.connect(i)}}function Mce(e){return e.type===`quad`?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function Nce(e,t){if(t===void 0)return;let n=this._cameraXR,r=this._renderer,i=r.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),s=t.getViewerPose(o);if(this._xrFrame=t,s!==null){let e=s.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;this._glBaseLayer!==null&&t===null&&i.setXRTarget(a.framebuffer);let o=!1;e.length!==n.cameras.length&&(n.cameras.length=0,o=!0);for(let r=0;r<e.length;r++){let s=e[r],c;if(t!==null)c=t.viewports[r];else if(this._supportsLayers===!0){let e=this._glBinding.getViewSubImage(this._glProjLayer,s);c=e.viewport,r===0&&i.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else c=a.getViewport(s);let l=this._cameras[r];l===void 0&&(l=new uf,l.layers.enable(r),l.viewport=new Ls,l.matrixWorldAutoUpdate=!1,this._cameras[r]=l),l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.projectionMatrix.fromArray(s.projectionMatrix),l.projectionMatrixInverse.copy(l.projectionMatrix).invert(),l.viewport.set(c.x,c.y,c.width,c.height),r===0&&(n.matrix.copy(l.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale)),o===!0&&n.cameras.push(l)}t!==null&&t.colorTexture!==null&&i.setXRRenderTargetTextures(this._xrRenderTarget,t.colorTexture,t.viewDescriptors),r.setOutputRenderTarget(this._xrRenderTarget);let c=r._getFrameBufferTarget();r.xr.foveateBoundTexture(c)}for(let e=0;e<this._controllers.length;e++){let n=this._controllerInputSources[e],r=this._controllers[e];n!==null&&r!==void 0&&r.update(n,t,o)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:`planesdetected`,data:t}),this._xrFrame=null}var Pce=class extends Wo{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Ls(0,0,this._width,this._height),this._scissor=new Ls(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new Cu,this.depthTexture=new Tu}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+`px`,this.domElement.style.height=t+`px`),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){let i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,i=0,a=1){let o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,n,r),o.minDepth=i,o.maxDepth=a}_dispatchResize(){this.dispatchEvent({type:`resize`})}dispose(){this.dispatchEvent({type:`dispose`})}},fI=new Tc,pI=new H,mI=new Ls,hI=new lu,gI=new du,_I=new Hs,vI=new Ls,Fce={0:1,1:0,2:2},Ice=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:n=!1,reversedDepthBuffer:r=!1,alpha:i=!0,depth:a=!0,stencil:o=!1,antialias:s=!1,samples:c=0,getFallback:l=null,outputBufferType:u=ca,multiview:d=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=n,this.reversedDepthBuffer=r,this.outputColorSpace=go,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=o,this.info=new nP,this.contextNode=aD(),this.library=new aI,this.lighting=new Tce,this._samples=c||s===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new Pce(e.getDomElement()),this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new qD,this._inspector.setRenderer(this),this._getFallback=l,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quadCache=new Map,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;let f=this.alpha===!0?0:1;this._clearColor=new CP(0,0,0,f),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this.onError=this._onError,this._outputBufferType=u,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this._currentSourceMaterial=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:1},this.xr=new Ece(this,d),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,n)=>{await this.compileAsync(n,t,e);let r=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,i=this._renderLists.get(e,t),a=this._renderContexts.get(r,this._mrt),o=e.overrideMaterial||n.material,{fragmentShader:s,vertexShader:c}=this._objects.get(n,o,e,t,i.lightsNode,a,a.clippingContext).getNodeBuilderState();return{fragmentShader:s,vertexShader:c}}}}async init(){return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new xce(this,n),this._animation=new RN(this,this._nodes,this.info),this._attributes=new ZN(n,this.info),this._background=new Pse(this,this._nodes),this._geometries=new tP(this._attributes,this.info),this._textures=new SP(this,n,this.info),this._pipelines=new cP(n,this._nodes,this.info),this._bindings=new lP(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new GN(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new gP(this.lighting),this._bundles=new Cce,this._renderContexts=new bP(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,i=r.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._handleObjectFunction,c=this._compilationPromises;n===null&&(n=e);let l=e.isScene===!0?e:n.isScene===!0?n:fI,u=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(u,this._mrt),f=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||=new rI,d.clippingContext.updateGlobal(l,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),l.onBeforeRender(this,e,t,u);let m=t.isArrayCamera?gI:hI;t.isArrayCamera?m.setFromArrayCamera(t):(_I.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(_I,t.coordinateSystem,t.reversedDepth));let h=this._renderLists.get(l,t);if(h.begin(),this._projectObject(e,t,0,h,d.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&h.pushLight(e)}),h.finish(),u!==null){this._textures.updateRenderTarget(u,f);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;n===e?this._background.update(l,h,d):this._background.update(n,h,d);let g=h.opaque,_=h.transparent,v=h.transparentDoublePass,y=h.lightsNode;this.opaque===!0&&g.length>0&&this._renderObjects(g,t,l,y),this.transparent===!0&&_.length>0&&this._renderTransparents(_,v,t,l,y),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=s,this._compilationPromises=c;for(let e of p){let t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._geometries.updateForRender(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);let n=[];this._pipelines.getForRender(t,n),n.length>0&&await Promise.all(n),this._nodes.updateAfter(t),await Vo()}}async renderAsync(e,t){Bo(`Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.render(e,t)}async waitForGPU(){V(`Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.`)}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=VO,t.modelNormalViewMatrix=HO):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===VO&&e.modelNormalViewMatrix===HO}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Bo(`Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".`),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),V(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),V(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,n){let{bundleGroup:r,camera:i,renderList:a}=e,o=this._currentRenderContext,s=this._bundles.get(r,i,o),c=this.backend.get(s);if(this._bundleNeedsUpdate(r,c)){this.backend.beginBundle(o),this._currentRenderBundle=s;let{transparentDoublePass:e,transparent:l,opaque:u}=a;this.opaque===!0&&u.length>0&&this._renderObjects(u,i,t,n),this.transparent===!0&&l.length>0&&this._renderTransparents(l,e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,s),c.version=r.version}else{let{renderObjects:e}=c;for(let t=0,n=e.length;t<n;t++){let n=e[t];this._nodes.needsRefresh(n)&&(this._nodes.updateBefore(n),this._geometries.updateForRender(n),this._nodes.updateForRender(n),this._bindings.updateForRender(n),this._nodes.updateAfter(n))}}this.backend.addBundle(o,s)}render(e,t){if(this._initialized===!1)throw Error(`THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.`);this._renderScene(e,t)}get initialized(){return this._initialized}_renderOutputLayers(e,t){if(t.texture.isArrayTexture!==!0||t.texture.image.depth<=1){this._renderScene(e,e.camera,!1);return}let n=this._activeCubeFace;try{for(let n=0;n<t.texture.image.depth;n++)this._nodes.setOutputLayerIndex(n),this._activeCubeFace=n,this._renderScene(e,e.camera,!1)}finally{this._nodes.setOutputLayerIndex(0),this._activeCubeFace=n}}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,n=e!==0,r=t!==Es.workingColorSpace;if(n===!1&&r===!1)return null;let{width:i,height:a}=this.getDrawingBufferSize(pI),{depth:o,stencil:s}=this,c=this._outputRenderTarget||this._canvasTarget,l=this._frameBufferTargets.get(c);if(l===void 0){l=new Rs(i,a,{depthBuffer:o,stencilBuffer:s,type:this._outputBufferType,format:ga,colorSpace:Es.workingColorSpace,generateMipmaps:!1,minFilter:Qi,magFilter:Qi,samples:this.samples}),l.isPostProcessingRenderTarget=!0;let e=()=>{c.removeEventListener(`dispose`,e),l.dispose(),this._frameBufferTargets.delete(c)};c.addEventListener(`dispose`,e),this._frameBufferTargets.set(c,l)}let u=this.getOutputRenderTarget();l.depthBuffer=o,l.stencilBuffer=s,u===null?l.setSize(i,a,1):l.setSize(u.width,u.height,u.depth);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:c._viewport,f=this._outputRenderTarget?this._outputRenderTarget.scissor:c._scissor,p=this._outputRenderTarget?1:c._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:c._scissorTest;return l.viewport.copy(d),l.scissor.copy(f),l.viewport.multiplyScalar(p),l.scissor.multiplyScalar(p),l.scissorTest=m,l.multiview=u!==null&&u.multiview,l.useArrayDepthTexture=u!==null&&u.useArrayDepthTexture,l.resolveDepthBuffer=u===null||u.resolveDepthBuffer,l._autoAllocateDepthBuffer=u!==null&&u._autoAllocateDepthBuffer,l}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;let r=n?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,c=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;let l=e.isScene===!0?e:fI,u=this._renderTarget||this._outputRenderTarget,d=this._activeCubeFace,f=this._activeMipmapLevel,p;if(r===null?p=u:(p=r,this.setRenderTarget(p)),p!==null&&p.depthBuffer===!0){let e=this._textures.get(p);e.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),e.depthInitialized=!0)}let m=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,p),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);let h=this._canvasTarget,g=h._viewport,_=h._scissor,v=h._pixelRatio;p!==null&&(g=p.viewport,_=p.scissor,v=1),this.getDrawingBufferSize(pI),mI.set(0,0,pI.width,pI.height);let y=g.minDepth===void 0?0:g.minDepth,b=g.maxDepth===void 0?1:g.maxDepth;m.viewportValue.copy(g).multiplyScalar(v).floor(),m.viewportValue.width>>=f,m.viewportValue.height>>=f,m.viewportValue.minDepth=y,m.viewportValue.maxDepth=b,m.viewport=m.viewportValue.equals(mI)===!1,m.scissorValue.copy(_).multiplyScalar(v).floor(),m.scissor=h._scissorTest&&m.scissorValue.equals(mI)===!1,m.scissorValue.width>>=f,m.scissorValue.height>>=f,m.clippingContext||=new rI,m.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);let x=t.isArrayCamera?gI:hI;t.isArrayCamera?x.setFromArrayCamera(t):(_I.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(_I,t.coordinateSystem,t.reversedDepth));let S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,m.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),p!==null){this._textures.updateRenderTarget(p,f);let e=this._textures.get(p);m.textures=e.textures,m.depthTexture=e.depthTexture,m.width=e.width,m.height=e.height,m.renderTarget=p,m.depth=p.depthBuffer,m.stencil=p.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=pI.width,m.height=pI.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=f,m.height>>=f,m.activeCubeFace=d,m.activeMipmapLevel=f,m.occlusionQueryCount=S.occlusionQueryCount,m.scissorValue.max(vI.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(l,S,m),m.camera=t,this.backend.beginRender(m);let{bundles:C,lightsNode:w,transparentDoublePass:T,transparent:E,opaque:D}=S;return C.length>0&&this._renderBundles(C,l,w),this.opaque===!0&&D.length>0&&this._renderObjects(D,t,l,w),this.transparent===!0&&E.length>0&&this._renderTransparents(E,T,t,l,w),this.backend.finishRender(m),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,this._handleObjectFunction=c,this.lighting.finishRender(e),this._callDepth--,r!==null&&(this.setRenderTarget(u,d,f),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._nodes.getOutputCacheKey(),n=this._quadCache.get(e.texture),r;if(n===void 0){r=new RP(new FA),r.name=`Output Color Transform`,r.material.name=`outputColorTransform`,r.material.fragmentNode=this._nodes.getOutputNode(e.texture),n={quad:r,cacheKey:t},this._quadCache.set(e.texture,n);let i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener(`dispose`,i)};e.texture.addEventListener(`dispose`,i)}else r=n.quad,n.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,n.cacheKey=t);let i=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,n=0,r=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);let e=()=>{t.removeEventListener(`dispose`,e),this.info.destroyReadbackBuffer(t)};t.addEventListener(`dispose`,e)}if(n%4!=0||r>0&&r%4!=0)throw Error(`THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.`);return await this.backend.getArrayBufferAsync(e,t,n,r)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,r,i=0,a=1){this._canvasTarget.setViewport(e,t,n,r,i,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw Error(`THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.`);let r=this._renderTarget||this._getFrameBufferTarget(),i=null;if(r!==null){this._textures.updateRenderTarget(r);let e=this._textures.get(r);i=this._renderContexts.get(r,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer;let t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),r.depthBuffer===!0&&(e.depthInitialized=!0)}this.backend.clear(e,t,n,i),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){Bo(`Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.clear(e,t,n)}async clearColorAsync(){Bo(`Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.`),this.clear(!0,!1,!1)}async clearDepthAsync(){Bo(`Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!0,!1)}async clearStencilAsync(){Bo(`Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==0,t=this.currentColorSpace!==Es.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget===null?this.needsFrameBufferTarget&&(e=0):e=this._renderTarget.samples,e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Es.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return B(`Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.`),this.computeAsync(e,t);let n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let i=this.backend,a=this._pipelines,o=this._bindings,s=this._nodes,c=Array.isArray(e)?e:[e];if(c[0]===void 0||c[0].isComputeNode!==!0)throw Error(`THREE.Renderer: .compute() expects a ComputeNode.`);i.beginCompute(e);for(let n of c){if(a.has(n)===!1){let e=()=>{n.removeEventListener(`dispose`,e),a.delete(n),o.deleteForCompute(n),s.delete(n)};n.addEventListener(`dispose`,e);let t=n.onInitFunction;t!==null&&t.call(n,{renderer:this})}s.updateForCompute(n),o.updateForCompute(n);let r=o.getForCompute(n),c=a.getForCompute(n,r);i.compute(e,n,r,c,t)}i.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return Bo(`Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e=`render`){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Bo(`Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateRenderTarget(e);let t=this._textures.get(e),n=this._renderContexts.get(e);n.textures=t.textures,n.depthTexture=t.depthTexture,n.width=t.width,n.height=t.height,n.renderTarget=e,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,this.backend.initRenderTarget(n)}copyFramebufferToTexture(e,t=null){if(t!==null){if(t.isVector2)t=vI.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=vI.copy(t).floor();else{V(`Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}}else t=vI.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))):r=n.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,i,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,i,o)}_projectObject(e,t,n,r,i){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?gI:hI;if(!e.frustumCulled||a.intersectsSprite(e)){this.sortObjects===!0&&vI.setFromMatrixPosition(e.matrixWorld).applyMatrix4(_I);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,vI.z,null,i)}}else if(e.isLineLoop)V(`Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.`);else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?gI:hI;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),vI.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(_I)),Array.isArray(a)){let o=t.groups;for(let s=0,c=o.length;s<c;s++){let c=o[s],l=a[c.materialIndex];l&&l.visible&&r.push(e,t,l,n,vI.z,c,i)}}else a.visible&&r.push(e,t,a,n,vI.z,null,i)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){let a=r;r=this._renderLists.get(e,t);let o=this._bundles.get(e,t,this._currentRenderContext),s=this.backend.get(o);if(this._bundleNeedsUpdate(e,s)){r.begin(),s.renderObjects===void 0?s.renderObjects=[]:s.renderObjects.length=0;let a=e.children;for(let e=0,o=a.length;e<o;e++)this._projectObject(a[e],t,n,r,i);r.finish()}a.pushBundle({bundleGroup:e,camera:t,renderList:r});return}let a=e.children;for(let e=0,o=a.length;e<o;e++)this._projectObject(a[e],t,n,r,i)}_renderBundles(e,t,n){for(let r of e)this._renderBundle(r,t,n)}_renderTransparents(e,t,n,r,i){if(t.length>0){for(let{material:e}of t)e.side=1;this._renderObjects(t,n,r,i,`backSide`);for(let{material:e}of t)e.side=0;this._renderObjects(e,n,r,i);for(let{material:e}of t)e.side=2}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let a=0,o=e.length;a<o;a++){let{object:o,geometry:s,material:c,group:l,clippingContext:u}=e[a];this._currentRenderObjectFunction(o,n,t,s,c,l,r,u,i)}}_getShadowNodes(e){let t=e.version,n=this._cacheShadowNodes.get(e);if(n===void 0||n.version!==t){let r=e.map&&e.map.isTexture,i=e.colorNode&&e.colorNode.isNode,a=e.castShadowNode&&e.castShadowNode.isNode,o=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,s=null,c=null,l=null;if(r||i||a||o){let t,n;if(a?(t=e.castShadowNode.rgb,n=e.castShadowNode.a,this.shadowMap.transmitted!==!0&&Bo("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(t=J(0),n=q(1)),r&&(n=n.mul(Sk(`map`,`texture`,e).a)),i&&(n=n.mul(e.colorNode.a)),c=ET(t,n),o){let t=e.maskShadowNode||e.maskNode;c=K(([e])=>(t.not().discard(),e))(c)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?s=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(s=e.positionNode),n={version:t,colorNode:c,depthNode:l,positionNode:s},this._cacheShadowNodes.set(e,n)}return n}_updateCamera(e){let t=this.xr;if(t.isPresenting===!1){let t=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(let t of e.cameras)t._reversedDepth=!0;t=!0}let n=this.coordinateSystem;if(e.coordinateSystem!==n){if(e.coordinateSystem=n,e.isArrayCamera)for(let t of e.cameras)t.coordinateSystem=n;t=!0}if(t===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let t of e.cameras)t.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,n,r,i,a,o,s=null,c=null){let l=!1,u,d,f,p,m,h,g,_=this._currentSourceMaterial;if(e.onBeforeRender(this,t,n,r,i,a),i.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=i;let e=t.overrideMaterial;if(l=!0,u=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,f=e.isNodeMaterial?e.positionNode:null,p=t.overrideMaterial.side,m=e.displacementMap,h=e.displacementScale,g=e.displacementBias,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.displacementMap=i.displacementMap,e.displacementScale=i.displacementScale,e.displacementBias=i.displacementBias,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:n,positionNode:r}=this._getShadowNodes(i);e.side=this.shadowMap.type===3?i.shadowSide===null?i.side:i.shadowSide:i.shadowSide===null?Fce[i.side]:i.shadowSide,t!==null&&(e.colorNode=t),n!==null&&(e.depthNode=n),r!==null&&(e.positionNode=r)}i=e}i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,this._handleObjectFunction(e,i,t,n,o,a,s,`backSide`),i.side=0,this._handleObjectFunction(e,i,t,n,o,a,s,c),i.side=2):this._handleObjectFunction(e,i,t,n,o,a,s,c),l&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=m,t.overrideMaterial.displacementScale=h,t.overrideMaterial.displacementBias=g),this._currentSourceMaterial=_,e.onAfterRender(this,t,n,r,i,a)}hasCompatibility(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup);let l=this._nodes.needsRefresh(c);l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._pipelines.isReady(c)&&(this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c))}_createObjectPipeline(e,t,n,r,i,a,o,s){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:n,camera:r,lightsNode:i,group:a,clippingContext:o,passId:s,renderContext:this._currentRenderContext});return}let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},yI=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function bI(e){return e+(JN-e%JN)%JN}var xI=class extends yI{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return bI(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}},SI=class extends xI{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},Lce=0,CI=class extends SI{constructor(e,t){super(`UniformBuffer_`+Lce++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return bI(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}},Rce=class extends SI{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let n=this._updateRangeCache.get(t);n===void 0&&(n={start:0,count:0},this._updateRangeCache.set(t,n)),n.start=e.offset,n.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(n)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,r=this.uniforms.length;n<r;n++){let r=this.uniforms[n],i=r.boundary,a=r.itemSize*e,o=t%JN,s=o%i,c=o+s;t+=s,c!==0&&JN-c<a&&(t+=JN-c),r.offset=t/e,r.index=n,t+=a}return Math.ceil(t/JN)*JN}update(){let e=!1;for(let t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}release(){super.release(),this._values=null}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);V(`WebGPUUniformsGroup: Unsupported uniform type.`,e)}updateNumber(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i]!==r){let o=this._getBufferForType(a);o[i]=n[i]=r,t=!0,this.addUniformUpdateRange(e)}return t}updateVector2(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,o[i+2]=n[i+2]=r.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z||n[i+3]!==r.w){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,o[i+2]=n[i+2]=r.z,o[i+3]=n[i+3]=r.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset;if(n[i+0]!==r.r||n[i+1]!==r.g||n[i+2]!==r.b){let a=this.buffer;a[i+0]=n[i+0]=r.r,a[i+1]=n[i+1]=r.g,a[i+2]=n[i+2]=r.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;if(n[i+0]!==r[0]||n[i+1]!==r[1]||n[i+2]!==r[2]||n[i+4]!==r[3]||n[i+5]!==r[4]||n[i+6]!==r[5]||n[i+8]!==r[6]||n[i+9]!==r[7]||n[i+10]!==r[8]){let a=this.buffer;a[i+0]=n[i+0]=r[0],a[i+1]=n[i+1]=r[1],a[i+2]=n[i+2]=r[2],a[i+4]=n[i+4]=r[3],a[i+5]=n[i+5]=r[4],a[i+6]=n[i+6]=r[5],a[i+8]=n[i+8]=r[6],a[i+9]=n[i+9]=r[7],a[i+10]=n[i+10]=r[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;return Bce(n,r,i)===!1&&(this.buffer.set(r,i),zce(n,r,i),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`?new Int32Array(this.buffer.buffer):e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`?new Uint32Array(this.buffer.buffer):this.buffer}};function zce(e,t,n){for(let r=0,i=t.length;r<i;r++)e[n+r]=t[r]}function Bce(e,t,n){for(let r=0,i=t.length;r<i;r++)if(e[n+r]!==t[r])return!1;return!0}var Vce=0,wI=class extends Rce{constructor(e,t){super(e),this.id=Vce++,this.groupNode=t,this.isNodeUniformsGroup=!0}},TI=class extends yI{constructor(e,t){super(e),this._texture=t,this.version=-1,this.generation=null,this.samplerKey=``,this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture=e,this.reset())}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}reset(){this.generation=null,this.version=-1}release(){this._texture=null}},Hce=0,Uce=class extends TI{constructor(e,t){super(e,t),this.id=Hce++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}},EI=class extends Uce{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},DI=class extends EI{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}},OI=class extends EI{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}},kI={bitcast_int_uint:new aF(`uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }`),bitcast_uint_int:new aF(`uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }`),textureGather:new aF(`
|
|
4657
4657
|
vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {
|
|
4658
4658
|
if ( flipY ) offset.y = - offset.y;
|
|
4659
4659
|
vec2 size = vec2( textureSize( map, 0 ) );
|
|
@@ -4667,7 +4667,7 @@ vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset,
|
|
|
4667
4667
|
);
|
|
4668
4668
|
return flipY ? ret.wzyx : ret;
|
|
4669
4669
|
}
|
|
4670
|
-
`),textureGatherArray:new
|
|
4670
|
+
`),textureGatherArray:new aF(`
|
|
4671
4671
|
vec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) {
|
|
4672
4672
|
if ( flipY ) offset.y = - offset.y;
|
|
4673
4673
|
vec2 size = vec2( textureSize( map, 0 ).xy );
|
|
@@ -4681,7 +4681,7 @@ vec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, iv
|
|
|
4681
4681
|
);
|
|
4682
4682
|
return flipY ? ret.wzyx : ret;
|
|
4683
4683
|
}
|
|
4684
|
-
`),textureGatherCompare:new
|
|
4684
|
+
`),textureGatherCompare:new aF(`
|
|
4685
4685
|
vec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) {
|
|
4686
4686
|
if ( flipY ) offset.y = - offset.y;
|
|
4687
4687
|
vec2 size = vec2( textureSize( map, 0 ) );
|
|
@@ -4695,7 +4695,7 @@ vec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, fl
|
|
|
4695
4695
|
);
|
|
4696
4696
|
return flipY ? ret.wzyx : ret;
|
|
4697
4697
|
}
|
|
4698
|
-
`),textureGatherCompareArray:new
|
|
4698
|
+
`),textureGatherCompareArray:new aF(`
|
|
4699
4699
|
vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) {
|
|
4700
4700
|
if ( flipY ) offset.y = - offset.y;
|
|
4701
4701
|
vec2 size = vec2( textureSize( map, 0 ).xy );
|
|
@@ -4709,7 +4709,7 @@ vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2
|
|
|
4709
4709
|
);
|
|
4710
4710
|
return flipY ? ret.wzyx : ret;
|
|
4711
4711
|
}
|
|
4712
|
-
`)},
|
|
4712
|
+
`)},Wce={textureDimensions:`textureSize`,equals:`equal`,bitcast_float_int:`floatBitsToInt`,bitcast_int_float:`intBitsToFloat`,bitcast_uint_float:`uintBitsToFloat`,bitcast_float_uint:`floatBitsToUint`,bitcast_uint_int:`tsl_bitcast_uint_to_int`,bitcast_int_uint:`tsl_bitcast_int_to_uint`,floatpack_snorm_2x16:`packSnorm2x16`,floatpack_unorm_2x16:`packUnorm2x16`,floatpack_float16_2x16:`packHalf2x16`,floatunpack_snorm_2x16:`unpackSnorm2x16`,floatunpack_unorm_2x16:`unpackUnorm2x16`,floatunpack_float16_2x16:`unpackHalf2x16`},AI={low:`lowp`,medium:`mediump`,high:`highp`},jI={swizzleAssign:!0,storageBuffer:!1},MI={perspective:`smooth`,linear:`noperspective`},NI={centroid:`centroid`},PI=`
|
|
4713
4713
|
precision highp float;
|
|
4714
4714
|
precision highp int;
|
|
4715
4715
|
precision highp sampler2D;
|
|
@@ -4730,14 +4730,14 @@ precision highp isampler2DArray;
|
|
|
4730
4730
|
precision highp sampler2DShadow;
|
|
4731
4731
|
precision highp sampler2DArrayShadow;
|
|
4732
4732
|
precision highp samplerCubeShadow;
|
|
4733
|
-
`,
|
|
4733
|
+
`,Gce=class extends WF{constructor(e,t){super(e,t,new bce),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==``}_include(e){let t=kI[e];return t.build(this),this.addInclude(t),t}getMethod(e){return kI[e]!==void 0&&this._include(e),Wce[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return``}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(this.getType(e.type)+` `+e.name);return`${this.getType(t.type)} ${t.name}( ${r.join(`, `)} ) {
|
|
4734
4734
|
|
|
4735
4735
|
${n.vars}
|
|
4736
4736
|
|
|
4737
4737
|
${n.code}
|
|
4738
4738
|
return ${n.result};
|
|
4739
4739
|
|
|
4740
|
-
}`}setupPBO(e){let t=e.value;if(t.pbo===void 0){let e=t.array,n=t.count*t.itemSize,{itemSize:r}=t,i=t.array.constructor.name.toLowerCase().includes(`int`),a=i?ba:ya;r===2?a=i?Sa:xa:r===3?a=i?Ca:ha:r===4&&(a=i?wa:ga);let o={Float32Array:sa,Uint8Array:ta,Uint16Array:ia,Uint32Array:oa,Int8Array:na,Int16Array:ra,Int32Array:aa,Uint8ClampedArray:ta},s=2**Math.ceil(Math.log2(Math.sqrt(n/r))),c=Math.ceil(n/r/s);s*c*r<n&&c++;let l=s*c*r,u=new e.constructor(l);u.set(e,0),t.array=u;let d=new eu(t.array,s,c,a,o[t.array.constructor.name]||1015);d.needsUpdate=!0,d.isPBOTexture=!0;let f=new
|
|
4740
|
+
}`}setupPBO(e){let t=e.value;if(t.pbo===void 0){let e=t.array,n=t.count*t.itemSize,{itemSize:r}=t,i=t.array.constructor.name.toLowerCase().includes(`int`),a=i?ba:ya;r===2?a=i?Sa:xa:r===3?a=i?Ca:ha:r===4&&(a=i?wa:ga);let o={Float32Array:sa,Uint8Array:ta,Uint16Array:ia,Uint32Array:oa,Int8Array:na,Int16Array:ra,Int32Array:aa,Uint8ClampedArray:ta},s=2**Math.ceil(Math.log2(Math.sqrt(n/r))),c=Math.ceil(n/r/s);s*c*r<n&&c++;let l=s*c*r,u=new e.constructor(l);u.set(e,0),t.array=u;let d=new eu(t.array,s,c,a,o[t.array.constructor.name]||1015);d.needsUpdate=!0,d.isPBOTexture=!0;let f=new tO(d,null,null);f.setPrecision(`high`),t.pboNode=f,t.pbo=f.value,this.getUniformFromNode(t.pboNode,`texture`,this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?e.name:super.getPropertyName(e,t)}generatePBO(e){let{node:t,indexNode:n}=e,r=t.value;if(this.renderer.backend.has(r)){let e=this.renderer.backend.get(r);e.pbo=r.pbo}let i=this.getUniformFromNode(r.pboNode,`texture`,this.shaderStage,this.context.nodeName),a=this.getPropertyName(i);this.increaseUsage(n);let o=n.build(this,`uint`),s=this.getDataFromNode(e),c=s.propertyName;if(c===void 0){let n=this.getVarFromNode(e);c=this.getPropertyName(n);let i=this.getDataFromNode(t),l=i.propertySizeName;l===void 0&&(l=c+`Size`,this.getVarFromNode(t,l,`uint`),this.addLineFlowCode(`${l} = uint( textureSize( ${a}, 0 ).x )`,e),i.propertySizeName=l);let{itemSize:u}=r,d=`.`+Nw.join(``).slice(0,u),f=`ivec2(${o} % ${l}, ${o} / ${l})`,p=this.generateTextureLoad(null,a,f,`0`,null,null),m=`vec4`;r.pbo.type===1014?m=`uvec4`:r.pbo.type===1013&&(m=`ivec4`),this.addLineFlowCode(`${c} = ${m}(${p})${d}`,e),s.propertyName=c}return c}generateTextureLoad(e,t,n,r,i,a){r===null&&(r=`0`);let o;return o=i?a?`texelFetchOffset( ${t}, ivec3( ${n}, ${i} ), int( ${r} ), ${a} )`:`texelFetch( ${t}, ivec3( ${n}, ${i} ), int( ${r} ) )`:a?`texelFetchOffset( ${t}, ${n}, int( ${r} ), ${a} )`:`texelFetch( ${t}, ${n}, int( ${r} ) )`,e!==null&&e.isDepthTexture&&(o+=`.x`),o}generateTexture(e,t,n,r,i){return r&&(n=`vec3( ${n}, ${r} )`),e.isDepthTexture?i?`textureOffset( ${t}, ${n}, ${i} ).x`:`texture( ${t}, ${n} ).x`:i?`textureOffset( ${t}, ${n}, ${i} )`:`texture( ${t}, ${n} )`}generateTextureLevel(e,t,n,r,i,a){return i&&(n=`vec3( ${n}, ${i} )`),a?`textureLodOffset( ${t}, ${n}, ${r}, ${a} )`:`textureLod( ${t}, ${n}, ${r} )`}generateTextureBias(e,t,n,r,i,a){return i&&(n=`vec3( ${n}, ${i} )`),a?`textureOffset( ${t}, ${n}, ${a}, ${r} )`:`texture( ${t}, ${n}, ${r} )`}generateTextureGrad(e,t,n,r,i,a){return i&&(n=`vec3( ${n}, ${i} )`),a?`textureGradOffset( ${t}, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureGrad( ${t}, ${n}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return e.isCubeTexture?`texture( ${t}, vec4( ${n}, ${r} ) )`:i?a?`textureOffset( ${t}, vec4( ${n}, ${i}, ${r} ), ${a} )`:`texture( ${t}, vec4( ${n}, ${i}, ${r} ) )`:a?`textureOffset( ${t}, vec3( ${n}, ${r} ), ${a} )`:`texture( ${t}, vec3( ${n}, ${r} ) )`;V(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,n,r,i,a,o){return e.isDepthTexture&&(r=`0`),a===null&&(a=`ivec2( 0 )`),o===null&&(o=`false`),i?(this._include(`textureGatherArray`),`tsl_textureGather_array( ${r}, ${t}, vec3( ${n}, ${i} ), ${a}, ${o} )`):(this._include(`textureGather`),`tsl_textureGather( ${r}, ${t}, ${n}, ${a}, ${o} )`)}generateTextureGatherCompare(e,t,n,r,i,a,o){return a===null&&(a=`ivec2( 0 )`),o===null&&(o=`false`),i?(this._include(`textureGatherCompareArray`),`tsl_textureGatherCompare_array( ${t}, vec3( ${n}, ${i} ), ${a}, ${r}, ${o} )`):(this._include(`textureGatherCompare`),`tsl_textureGatherCompare( ${t}, ${n}, ${a}, ${r}, ${o} )`)}getUniforms(e){let t=this.uniforms[e],n=[],r={};for(let e of t){let t=null,i=!1;if(e.type===`texture`||e.type===`texture3D`){let n=e.node,r=n.value,i=``;(r.isDataTexture===!0||r.isData3DTexture===!0)&&(r.type===1014?i=`u`:r.type===1013&&(i=`i`)),t=e.type===`texture3D`&&r.isArrayTexture===!1?`${i}sampler3D ${e.name};`:r.compareFunction&&n.compareNode!==null?r.isArrayTexture===!0?`sampler2DArrayShadow ${e.name};`:`sampler2DShadow ${e.name};`:r.isArrayTexture===!0||r.isDataArrayTexture===!0||r.isCompressedArrayTexture===!0?`${i}sampler2DArray ${e.name};`:`${i}sampler2D ${e.name};`}else if(e.type===`cubeTexture`)t=`samplerCube ${e.name};`;else if(e.type===`cubeDepthTexture`)t=e.node.value.compareFunction?`samplerCubeShadow ${e.name};`:`samplerCube ${e.name};`;else if(e.type===`buffer`){let n=e.node,r=this.getType(n.bufferType),i=n.bufferCount,a=i>0?i:``;t=`${n.name} {\n\t${r} ${e.name}[${a}];\n};\n`}else{let t=e.groupNode.name;if(r[t]===void 0){let e=this.uniformGroups[t];if(e!==void 0){let n=[];for(let t of e.uniforms){let e=t.getType(),r=this.getVectorType(e),i=t.nodeUniform.node.precision,a=`${r} ${t.name};`;i!==null&&(a=AI[i]+` `+a),n.push(` `+a)}r[t]=n}}i=!0}if(!i){let r=e.node.precision;r!==null&&(t=AI[r]+` `+t),t=`uniform `+t,n.push(t)}}let i=``;for(let e in r){let t=r[e];i+=this._getGLSLUniformStruct(e,t.join(`
|
|
4741
4741
|
`))+`
|
|
4742
4742
|
`}return i+=n.join(`
|
|
4743
4743
|
`),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==1013){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);let r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t=``;if(e===`vertex`||e===`compute`){let e=this.getAttributesArray(),n=0;for(let r of e)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};\n`}return t}getStructMembers(e){let t=[];for(let n of e.members)t.push(`\t${n.type} ${n.name};`);return t.join(`
|
|
@@ -4749,8 +4749,8 @@ ${n.code}
|
|
|
4749
4749
|
`)+`
|
|
4750
4750
|
|
|
4751
4751
|
`+t.join(`
|
|
4752
|
-
`)}getVaryings(e){let t=``,n=this.varyings;if(e===`vertex`||e===`compute`)for(let r of n){e===`compute`&&(r.needsInterpolation=!0);let n=this.getType(r.type);if(r.needsInterpolation){if(r.interpolationType){let e=
|
|
4753
|
-
`)}getClipDistance(){return`gl_ClipDistance`}isAvailable(e){let t=
|
|
4752
|
+
`)}getVaryings(e){let t=``,n=this.varyings;if(e===`vertex`||e===`compute`)for(let r of n){e===`compute`&&(r.needsInterpolation=!0);let n=this.getType(r.type);if(r.needsInterpolation){if(r.interpolationType){let e=MI[r.interpolationType]||r.interpolationType,i=NI[r.interpolationSampling]||``;t+=`${e} ${i} out ${n} ${r.name};\n`}else{let e=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${e}out ${n} ${r.name};\n`}}else t+=`${n} ${r.name};\n`}else if(e===`fragment`){for(let e of n)if(e.needsInterpolation){let n=this.getType(e.type);if(e.interpolationType){let r=MI[e.interpolationType]||e.interpolationType,i=NI[e.interpolationSampling]||``;t+=`${r} ${i} in ${n} ${e.name};\n`}else{let r=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${r}in ${n} ${e.name};\n`}}}for(let n of this.builtins[e])t+=`${n};\n`;return t}getVertexIndex(){return`uint( gl_VertexID )`}getInstanceIndex(){return`uint( gl_InstanceID )`}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){V(`GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node`)}getInvocationSubgroupIndex(){V(`GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node`)}getSubgroupIndex(){V(`GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node`)}getDrawIndex(){return this.renderer.backend.extensions.has(`WEBGL_multi_draw`)?`uint( gl_DrawID )`:`nodeUniformDrawId`}getFrontFacing(){return`gl_FrontFacing`}getFragCoord(){return`gl_FragCoord.xy`}getFragDepth(){return`gl_FragDepth`}enableExtension(e,t,n=this.shaderStage){let r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e===`vertex`){let t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has(`WEBGL_multi_draw`)&&this.enableExtension(`GL_ANGLE_multi_draw`,`require`,e)}let n=this.extensions[e];if(n!==void 0)for(let{name:e,behavior:r}of n.values())t.push(`#extension ${e} : ${r}`);return t.join(`
|
|
4753
|
+
`)}getClipDistance(){return`gl_ClipDistance`}isAvailable(e){let t=jI[e];if(t===void 0){let n;switch(t=!1,e){case`float32Filterable`:n=`OES_texture_float_linear`;break;case`clipDistance`:n=`WEBGL_clip_cull_distance`}if(n!==void 0){let e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}jI[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension(`GL_ANGLE_clip_cull_distance`,`require`),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension(`GL_OVR_multiview2`,`require`,`fragment`),this.enableExtension(`GL_OVR_multiview2`,`require`,`vertex`),this.builtins.vertex.push(`layout(num_views = 2) in`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t=``;for(let n=0;n<e.length;n++){let r=e[n],i=this.getPropertyName(r.attributeNode);i&&(t+=`${r.varyingName} = ${i};\n\t`)}return t}_getGLSLUniformStruct(e,t){return`
|
|
4754
4754
|
layout( std140 ) uniform ${e} {
|
|
4755
4755
|
${t}
|
|
4756
4756
|
};`}_getGLSLVertexCode(e){return`#version 300 es
|
|
@@ -4761,7 +4761,7 @@ ${this.getSignature()}
|
|
|
4761
4761
|
${e.extensions}
|
|
4762
4762
|
|
|
4763
4763
|
// precision
|
|
4764
|
-
${
|
|
4764
|
+
${PI}
|
|
4765
4765
|
|
|
4766
4766
|
// structs
|
|
4767
4767
|
${e.structs}
|
|
@@ -4800,7 +4800,7 @@ ${this.getSignature()}
|
|
|
4800
4800
|
${e.extensions}
|
|
4801
4801
|
|
|
4802
4802
|
// precision
|
|
4803
|
-
${
|
|
4803
|
+
${PI}
|
|
4804
4804
|
|
|
4805
4805
|
// structs
|
|
4806
4806
|
${e.structs}
|
|
@@ -4829,7 +4829,7 @@ void main() {
|
|
|
4829
4829
|
`),n+=`\t// flow -> ${a}\n\t`),n+=`${r.code}\n\t`,e===i&&t!==`compute`&&(n+=`// result
|
|
4830
4830
|
`,t===`vertex`?(n+=`gl_Position = `,n+=`${this.format(r.result,i.getNodeType(this),`vec4`)};`):t===`fragment`&&(e.outputNode.isOutputStructNode||(n+=`fragColor = `,n+=`${this.format(r.result,i.getNodeType(this),this.getOutputType())};`)))}let a=e[t];if(a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t,!0),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n,t===`vertex`){let e=this.renderer.backend.extensions;this.object.isBatchedMesh&&e.has(`WEBGL_multi_draw`)===!1&&(a.uniforms+=`
|
|
4831
4831
|
uniform uint nodeUniformDrawId;
|
|
4832
|
-
`)}}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache),o=a.uniformGPU;if(o===void 0){let r=e.groupNode,s=r.name,c=this.getBindGroupArray(s,n);if(t===`texture`)o=new TI(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`||t===`cubeDepthTexture`)o=new EI(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new DI(i.name,i.node,r),c.push(o);else if(t===`buffer`){i.name=`buffer${e.id}`;let t=this.getSharedDataFromNode(e),n=t.buffer;n===void 0&&(e.name=`NodeBuffer_${e.id}`,n=new SI(e,r),n.name=e.name,t.buffer=n),c.push(n),o=n}else{let e=this.uniformGroups[s];e===void 0?(e=new CI(s,r),this.uniformGroups[s]=e,c.push(e)):c.indexOf(e)===-1&&c.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}},PI=null,FI=null,II=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[jo.RENDER]:null,[jo.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),n=this.renderer.info.frame,r;r=e.isComputeNode===!0?`c:`+this.renderer.info.compute.frameCalls:`r:`+this.renderer.info.render.frameCalls,t.timestampUID=r+`:`+e.id+`:f`+n}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith(`c:`)?jo.COMPUTE:jo.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e=`render`){if(!this.trackTimestamp){Bo(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t)return;let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return PI||=new H,this.renderer.getDrawingBufferSize(PI)}setScissorTest(){}getClearColor(){let e=this.renderer;return FI||=new SP,e.getClearColor(FI),FI.getRGB(FI),FI}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?Io():this.parameters.canvas,`setAttribute`in e&&e.setAttribute(`data-engine`,`three.js r185 webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},qce=0,Jce=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},Yce=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:r}=n,i=e.array,a=e.usage||r.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,s=n.get(o),c=s.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,i,a),s.bufferGPU=c,s.bufferType=t,s.version=o.version);let l;if(i instanceof Float32Array)l=r.FLOAT;else if(typeof Float16Array<`u`&&i instanceof Float16Array)l=r.HALF_FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)l=r.UNSIGNED_BYTE;else throw Error(`THREE.WebGLBackend: Unsupported buffer data format: `+i);let u={bufferGPU:c,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===1013,id:qce++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new Jce(u,e)}n.set(e,u)}updateAttribute(e){let t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(o,a.bufferGPU),s.length===0)n.bufferSubData(o,0,r);else{for(let e=0,t=s.length;e<t;e++){let t=s[e];n.bufferSubData(o,t.start*r.BYTES_PER_ELEMENT,r,t.start,t.count)}i.clearUpdateRanges()}n.bindBuffer(o,null),a.version=i.version}destroyAttribute(e){let t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let r=t.get(e);n.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e,t=null,n=0,r=-1){let i=this.backend,{gl:a}=i,o=e.isInterleavedBufferAttribute?e.data:e,s=i.get(o),{bufferGPU:c}=s,l=r===-1?s.byteLength-n:r,u;if(t===null)u=new Uint8Array(new ArrayBuffer(l));else if(t.isReadbackBuffer){if(t._mapped===!0)throw Error(`THREE.WebGPURenderer: ReadbackBuffer must be released before being used again.`);let e=()=>{t.buffer=null,t._mapped=!1,t.removeEventListener(`release`,e),t.removeEventListener(`dispose`,e)};t.addEventListener(`release`,e),t.addEventListener(`dispose`,e),u=new Uint8Array(new ArrayBuffer(l)),t.buffer=u.buffer}else u=new Uint8Array(t);return a.bindBuffer(a.COPY_READ_BUFFER,c),a.getBufferSubData(a.COPY_READ_BUFFER,n,u),a.bindBuffer(a.COPY_READ_BUFFER,null),a.bindBuffer(a.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:u.buffer}_createBuffer(e,t,n,r){let i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,n,r),e.bindBuffer(t,null),i}},LI,RI,Xce=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;LI={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT},RI={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new Ls().fromArray(t),this.currentViewport=new Ls().fromArray(n),this._tempVec4=new Ls}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===0?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===1?t.cullFace(t.BACK):e===2?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,n){let r=this.gl,i=this.backend.drawBuffersIndexedExt;if(!i){Bo(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`);return}for(let a=0;a<e.length;a++){let o=e[a],s=null;if(t!==null){let e=t.getBlendMode(o.name);e.blending===6?s=n:e.blending!==0&&(s=e)}else s=n;s===null?i.blendFuncSeparateiOES(a,r.ONE,r.ZERO,r.ONE,r.ZERO):this._setMRTBlendingIndex(a,s)}}_setMRTBlendingIndex(e,t){let{gl:n}=this,r=this.backend.drawBuffersIndexedExt,i=t.blending,a=t.blendSrc,o=t.blendDst,s=t.blendEquation,c=t.premultipliedAlpha;if(i===5){let n=t.blendSrcAlpha===null?a:t.blendSrcAlpha,i=t.blendDstAlpha===null?o:t.blendDstAlpha,c=t.blendEquationAlpha===null?s:t.blendEquationAlpha;r.blendEquationSeparateiOES(e,LI[s],LI[c]),r.blendFuncSeparateiOES(e,RI[a],RI[o],RI[n],RI[i])}else if(r.blendEquationSeparateiOES(e,n.FUNC_ADD,n.FUNC_ADD),c)switch(i){case 1:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,n.ONE,n.ONE,n.ONE,n.ONE);break;case 3:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case 4:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}else switch(i){case 1:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case 3:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case 4:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}}setBlending(e,t,n,r,i,a,o,s){let{gl:c}=this;if(e===0){this.currentBlendingEnabled===!0&&(this.disable(c.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(c.BLEND),this.currentBlendingEnabled=!0),e!==5){if(e!==this.currentBlending||s!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==100||this.currentBlendEquationAlpha!==100)&&(c.blendEquation(c.FUNC_ADD),this.currentBlendEquation=100,this.currentBlendEquationAlpha=100),s)switch(e){case 1:c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case 2:c.blendFunc(c.ONE,c.ONE);break;case 3:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case 4:c.blendFuncSeparate(c.DST_COLOR,c.ONE_MINUS_SRC_ALPHA,c.ZERO,c.ONE);break;default:V(`WebGLState: Invalid blending: `,e)}else switch(e){case 1:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case 2:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE,c.ONE,c.ONE);break;case 3:V(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:V(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:V(`WebGLState: Invalid blending: `,e)}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=s}return}i||=t,a||=n,o||=r,(t!==this.currentBlendEquation||i!==this.currentBlendEquationAlpha)&&(c.blendEquationSeparate(LI[t],LI[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(RI[n],RI[r],RI[a],RI[o]),this.currentBlendSrc=n,this.currentBlendDst=r,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=o),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setReversedDepth(e){if(this.currentDepthReversed!==e){let t=this.backend.extensions.get(`EXT_clip_control`);e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=Uo[e]),this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentScissor.equals(i)===!1){let{gl:e}=this;e.scissor(i.x,i.y,i.z,i.w),this.currentScissor.copy(i)}}viewport(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentViewport.equals(i)===!1){let{gl:e}=this;e.viewport(i.x,i.y,i.z,i.w),this.currentViewport.copy(i)}}setScissorTest(e){let t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){let{gl:r}=this;e.side===2?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let i=e.side===1;t&&(i=!i),this.setFlipSided(i),e.blending===1&&e.transparent===!1?this.setBlending(0):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let a=e.stencilWrite;if(this.setStencilTest(a),a&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){let e=12288;for(let t=0;t<8;t++)t<n?this.enable(e+t):this.disable(e+t)}}setPolygonOffset(e,t,n){let{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(r.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e&&(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){let n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:n,currentBoundFramebuffers:r}=this;return r[e]!==t&&(n.bindFramebuffer(e,t),r[e]=t,e===n.DRAW_FRAMEBUFFER&&(r[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(r[n.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){let{gl:n}=this,r=[],i=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));let a=e.textures;if(r.length!==a.length||r[0]!==n.COLOR_ATTACHMENT0){for(let e=0,t=a.length;e<t;e++)r[e]=n.COLOR_ATTACHMENT0+e;r.length=a.length,i=!0}}else r[0]!==n.BACK&&(r[0]=n.BACK,i=!0);i&&n.drawBuffers(r)}activeTexture(e){let{gl:t,currentTextureSlot:n,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){let{gl:r,currentTextureSlot:i,currentBoundTextures:a,maxTextures:o}=this;n===void 0&&(n=i===null?r.TEXTURE0+o-1:i);let s=a[n];s===void 0&&(s={type:void 0,texture:void 0},a[n]=s),(s.type!==e||s.texture!==t)&&(i!==n&&(r.activeTexture(n),this.currentTextureSlot=n),r.bindTexture(e,t),s.type=e,s.texture=t)}bindBufferBase(e,t,n){let{gl:r}=this,i=`${e}-${t}`;return this.currentBoundBufferBases[i]!==n&&(r.bindBufferBase(e,t,n),this.currentBoundBufferBases[i]=n,!0)}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,r=n[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}getParameter(e){let{gl:t,parameters:n}=this;return n[e]===void 0?t.getParameter(e):n[e]}pixelStorei(e,t){let{gl:n,parameters:r}=this;r[e]!==t&&(n.pixelStorei(e,t),r[e]=t)}},Zce=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=``){let{gl:n,extensions:r}=this,i,a=Es.getTransfer(t);if(e===1009)return n.UNSIGNED_BYTE;if(e===1017)return n.UNSIGNED_SHORT_4_4_4_4;if(e===1018)return n.UNSIGNED_SHORT_5_5_5_1;if(e===35902)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===35899)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===1010)return n.BYTE;if(e===1011)return n.SHORT;if(e===1012)return n.UNSIGNED_SHORT;if(e===1013)return n.INT;if(e===1014)return n.UNSIGNED_INT;if(e===1015)return n.FLOAT;if(e===1016)return n.HALF_FLOAT;if(e===1021)return n.ALPHA;if(e===1022)return n.RGB;if(e===1023)return n.RGBA;if(e===1026)return n.DEPTH_COMPONENT;if(e===1027)return n.DEPTH_STENCIL;if(e===1028)return n.RED;if(e===1029)return n.RED_INTEGER;if(e===1030)return n.RG;if(e===1031)return n.RG_INTEGER;if(e===1033)return n.RGBA_INTEGER;if(e===33776||e===33777||e===33778||e===33779){if(a===`srgb`){if(i=r.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(e===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=r.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(e===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(e===35840||e===35841||e===35842||e===35843){if(i=r.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(e===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(e===36196||e===37492||e===37496||e===37488||e===37489||e===37490||e===37491){if(i=r.get(`WEBGL_compressed_texture_etc`),i!==null){if(e===36196||e===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(e===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(e===37488)return i.COMPRESSED_R11_EAC;if(e===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(e===37490)return i.COMPRESSED_RG11_EAC;if(e===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null}if(e===37808||e===37809||e===37810||e===37811||e===37812||e===37813||e===37814||e===37815||e===37816||e===37817||e===37818||e===37819||e===37820||e===37821){if(i=r.get(`WEBGL_compressed_texture_astc`),i!==null){if(e===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(e===36492||e===36494||e===36495){if(i=r.get(`EXT_texture_compression_bptc`),i!==null){if(e===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(e===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(e===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(e===36283||e===36284||e===36285||e===36286){if(i=r.get(`EXT_texture_compression_rgtc`),i!==null){if(e===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(e===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return e===1020?n.UNSIGNED_INT_24_8:n[e]===void 0?null:n[e]}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,r)=>{function i(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(i);return}e.deleteSync(t),n()}i()})}},zI=!1,BI,VI,HI,Qce=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,zI===!1&&(this._init(),zI=!0)}_init(){let e=this.gl;BI={[Ki]:e.REPEAT,[qi]:e.CLAMP_TO_EDGE,[Ji]:e.MIRRORED_REPEAT},VI={[Yi]:e.NEAREST,[Xi]:e.NEAREST_MIPMAP_NEAREST,[Zi]:e.NEAREST_MIPMAP_LINEAR,[Qi]:e.LINEAR,[$i]:e.LINEAR_MIPMAP_NEAREST,[ea]:e.LINEAR_MIPMAP_LINEAR},HI={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return n=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i,a=!1){let{gl:o,extensions:s}=this;if(e!==null){if(o[e]!==void 0)return o[e];B(`WebGLBackend: Attempt to use non-existing WebGL internal format '`+e+`'`)}let c=null;r&&(c=s.get(`EXT_texture_norm16`),c||B(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=t;if(t===o.RED&&(n===o.FLOAT&&(l=o.R32F),n===o.HALF_FLOAT&&(l=o.R16F),n===o.UNSIGNED_BYTE&&(l=o.R8),n===o.BYTE&&(l=o.R8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),n===o.SHORT&&c&&(l=c.R16_SNORM_EXT)),t===o.RED_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.R8UI),n===o.UNSIGNED_SHORT&&(l=o.R16UI),n===o.UNSIGNED_INT&&(l=o.R32UI),n===o.BYTE&&(l=o.R8I),n===o.SHORT&&(l=o.R16I),n===o.INT&&(l=o.R32I)),t===o.RG&&(n===o.FLOAT&&(l=o.RG32F),n===o.HALF_FLOAT&&(l=o.RG16F),n===o.UNSIGNED_BYTE&&(l=o.RG8),n===o.BYTE&&(l=o.RG8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),n===o.SHORT&&c&&(l=c.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RG8UI),n===o.UNSIGNED_SHORT&&(l=o.RG16UI),n===o.UNSIGNED_INT&&(l=o.RG32UI),n===o.BYTE&&(l=o.RG8I),n===o.SHORT&&(l=o.RG16I),n===o.INT&&(l=o.RG32I)),t===o.RGB){let e=a?vo:Es.getTransfer(i);n===o.FLOAT&&(l=o.RGB32F),n===o.HALF_FLOAT&&(l=o.RGB16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8:o.RGB8),n===o.BYTE&&(l=o.RGB8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),n===o.SHORT&&c&&(l=c.RGB16_SNORM_EXT),n===o.UNSIGNED_SHORT_5_6_5&&(l=o.RGB565),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGB4),n===o.UNSIGNED_INT_5_9_9_9_REV&&(l=o.RGB9_E5),n===o.UNSIGNED_INT_10F_11F_11F_REV&&(l=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGB8UI),n===o.UNSIGNED_SHORT&&(l=o.RGB16UI),n===o.UNSIGNED_INT&&(l=o.RGB32UI),n===o.BYTE&&(l=o.RGB8I),n===o.SHORT&&(l=o.RGB16I),n===o.INT&&(l=o.RGB32I)),t===o.RGBA){let e=a?vo:Es.getTransfer(i);n===o.FLOAT&&(l=o.RGBA32F),n===o.HALF_FLOAT&&(l=o.RGBA16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8_ALPHA8:o.RGBA8),n===o.BYTE&&(l=o.RGBA8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),n===o.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGBA4),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGBA8UI),n===o.UNSIGNED_SHORT&&(l=o.RGBA16UI),n===o.UNSIGNED_INT&&(l=o.RGBA32UI),n===o.BYTE&&(l=o.RGBA8I),n===o.SHORT&&(l=o.RGBA16I),n===o.INT&&(l=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(n===o.UNSIGNED_SHORT&&(l=o.DEPTH_COMPONENT16),n===o.UNSIGNED_INT&&(l=o.DEPTH_COMPONENT24),n===o.FLOAT&&(l=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&n===o.UNSIGNED_INT_24_8&&(l=o.DEPTH24_STENCIL8),(l===o.R16F||l===o.R32F||l===o.RG16F||l===o.RG32F||l===o.RGBA16F||l===o.RGBA32F)&&s.get(`EXT_color_buffer_float`),l}setTextureParameters(e,t){let{gl:n,extensions:r,backend:i}=this,{state:a}=this.backend,o=Es.getPrimaries(Es.workingColorSpace),s=t.colorSpace===``?null:Es.getPrimaries(t.colorSpace),c=t.colorSpace===``||o===s?n.NONE:n.BROWSER_DEFAULT_WEBGL;a.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),n.texParameteri(e,n.TEXTURE_WRAP_S,BI[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,BI[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,BI[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,VI[t.magFilter]);let l=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===1006&&l?ea:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,VI[u]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,HI[t.compareFunction])),r.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&r.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1){let a=r.get(`EXT_texture_filter_anisotropic`);n.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e),a=r[i];a===void 0&&(a=t.createTexture(),n.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=a),n.set(e,{textureGPU:a,glTextureType:i})}createTexture(e,t){let{gl:n,backend:r}=this,i,a,o,s,c;if(e.isExternalTexture===!0)i=e.sourceTexture,a=this.getGLTextureType(e);else{let{levels:l,width:u,height:d,depth:f}=t;o=r.utils.convert(e.format,e.colorSpace),s=r.utils.convert(e.type),c=this.getInternalFormat(e.internalFormat,o,s,e.normalized,e.colorSpace,e.isVideoTexture),i=n.createTexture(),a=this.getGLTextureType(e),r.state.bindTexture(a,i),this.setTextureParameters(a,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,l,c,u,d,f):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,l,c,u,d,f):e.isVideoTexture||n.texStorage2D(a,l,c,u,d)}r.set(e,{textureGPU:i,glTextureType:a,glFormat:o,glType:s,glInternalFormat:c})}copyBufferToTexture(e,t){let{gl:n,backend:r}=this,{state:i}=r,{textureGPU:a,glTextureType:o,glFormat:s,glType:c}=r.get(t),{width:l,height:u}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(o,a),i.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,l,u,s,c,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:r,height:i}=t,{textureGPU:a,glTextureType:o,glFormat:s,glType:c,glInternalFormat:l}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0)){if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){let r=e.mipmaps,i=t.image;for(let t=0;t<r.length;t++){let a=r[t];e.isCompressedArrayTexture?e.format===n.RGBA?n.texSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,c,a.data):s===null?B(`WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()`):n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,a.data):s===null?B(`WebGLBackend: Unsupported compressed texture format`):n.compressedTexSubImage2D(n.TEXTURE_2D,t,0,0,a.width,a.height,s,a.data)}}else if(e.isCubeTexture){let a=t.images,o=e.mipmaps;for(let e=0;e<6;e++){let t=UI(a[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,r,i,s,c,t);for(let t=0;t<o.length;t++){let r=o[t],i=UI(r.images[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,t+1,0,0,i.width,i.height,s,c,i)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let r=t.image;if(e.layerUpdates.size>0){let t=Jf(r.width,r.height,e.format,e.type);for(let i of e.layerUpdates){let e=r.data.subarray(i*t/r.data.BYTES_PER_ELEMENT,(i+1)*t/r.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,i,r.width,r.height,1,s,c,e)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,r.width,r.height,r.depth,s,c,r.data)}else if(e.isData3DTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(o,0,l,s,c,t.image);else if(e.isHTMLTexture)typeof n.texElementImage2D==`function`&&(n.texElementImage2D.length===3?n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,t.image):n.texElementImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t.image));else{let a=e.mipmaps;if(a.length>0)for(let e=0,t=a.length;e<t;e++){let t=a[e],r=UI(t);n.texSubImage2D(o,e,0,0,t.width,t.height,s,c,r)}else{let e=UI(t.image);n.texSubImage2D(o,0,0,0,r,i,s,c,e)}}}}generateMipmaps(e){let{gl:t,backend:n}=this,{textureGPU:r,glTextureType:i}=n.get(e);n.state.bindTexture(i,r),t.generateMipmap(i)}deallocateRenderBuffers(e){let{gl:t,backend:n}=this;if(e){let r=n.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(let e in r.framebuffers)t.deleteFramebuffer(r.framebuffers[e]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let e=0;e<r.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(r.msaaRenderbuffers[e]);delete r.msaaRenderbuffers}}}destroyTexture(e,t=!1){let{gl:n,backend:r}=this,{textureGPU:i,renderTarget:a}=r.get(e);this.deallocateRenderBuffers(a),t===!1&&e.isExternalTexture!==!0&&n.deleteTexture(i),r.delete(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let{gl:o,backend:s}=this,{state:c}=this.backend,{textureGPU:l,glTextureType:u,glType:d,glFormat:f}=s.get(t);c.bindTexture(u,l);let p,m,h,g,_,v,y,b,x,S=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)p=n.max.x-n.min.x,m=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,g=n.min.x,_=n.min.y,v=n.isBox3?n.min.z:0;else{let t=2**-i;p=Math.floor(S.width*t),m=Math.floor(S.height*t),h=e.isDataArrayTexture||e.isArrayTexture?S.depth:e.isData3DTexture?Math.floor(S.depth*t):1,g=0,_=0,v=0}r===null?(y=0,b=0,x=0):(y=r.x,b=r.y,x=r.z),c.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t.flipY),c.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),c.pixelStorei(o.UNPACK_ALIGNMENT,t.unpackAlignment);let C=c.getParameter(o.UNPACK_ROW_LENGTH),w=c.getParameter(o.UNPACK_IMAGE_HEIGHT),T=c.getParameter(o.UNPACK_SKIP_PIXELS),E=c.getParameter(o.UNPACK_SKIP_ROWS),D=c.getParameter(o.UNPACK_SKIP_IMAGES);c.pixelStorei(o.UNPACK_ROW_LENGTH,S.width),c.pixelStorei(o.UNPACK_IMAGE_HEIGHT,S.height),c.pixelStorei(o.UNPACK_SKIP_PIXELS,g),c.pixelStorei(o.UNPACK_SKIP_ROWS,_),c.pixelStorei(o.UNPACK_SKIP_IMAGES,v);let O=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,k=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let n=s.get(e),r=s.get(t),u=s.get(n.renderTarget),d=s.get(r.renderTarget),f=u.framebuffers[n.cacheKey],S=d.framebuffers[r.cacheKey],C=c.currentBoundFramebuffers[o.READ_FRAMEBUFFER]??null,w=c.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER]??null;c.bindFramebuffer(o.READ_FRAMEBUFFER,f),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,S);for(let e=0;e<h;e++)O&&(o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,n.textureGPU,i,v+e),o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,l,a,x+e)),o.blitFramebuffer(g,_,p,m,y,b,p,m,o.DEPTH_BUFFER_BIT,o.NEAREST);c.bindFramebuffer(o.READ_FRAMEBUFFER,C),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,w)}else if(i!==0||e.isRenderTargetTexture||s.has(e)){let t=s.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=o.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=o.createFramebuffer());let n=c.currentBoundFramebuffers[o.READ_FRAMEBUFFER]??null,r=c.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER]??null;c.bindFramebuffer(o.READ_FRAMEBUFFER,this._srcFramebuffer),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let e=0;e<h;e++)O?o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,t.textureGPU,i,v+e):o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,t.textureGPU,i),k?o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,l,a,x+e):o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,l,a),i===0?k?o.copyTexSubImage3D(u,a,y,b,x+e,g,_,p,m):o.copyTexSubImage2D(u,a,y,b,g,_,p,m):o.blitFramebuffer(g,_,p,m,y,b,p,m,o.COLOR_BUFFER_BIT,o.NEAREST);c.bindFramebuffer(o.READ_FRAMEBUFFER,n),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,r)}else k?e.isDataTexture||e.isData3DTexture?o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S.data):t.isCompressedArrayTexture?o.compressedTexSubImage3D(u,a,y,b,x,p,m,h,f,S.data):o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S):e.isDataTexture?o.texSubImage2D(o.TEXTURE_2D,a,y,b,p,m,f,d,S.data):e.isCompressedTexture?o.compressedTexSubImage2D(o.TEXTURE_2D,a,y,b,S.width,S.height,f,S.data):o.texSubImage2D(o.TEXTURE_2D,a,y,b,p,m,f,d,S);c.pixelStorei(o.UNPACK_ROW_LENGTH,C),c.pixelStorei(o.UNPACK_IMAGE_HEIGHT,w),c.pixelStorei(o.UNPACK_SKIP_PIXELS,T),c.pixelStorei(o.UNPACK_SKIP_ROWS,E),c.pixelStorei(o.UNPACK_SKIP_IMAGES,D),a===0&&t.generateMipmaps&&o.generateMipmap(u),c.unbindTexture()}copyFramebufferToTexture(e,t,n){let{gl:r}=this,{state:i}=this.backend,{textureGPU:a}=this.backend.get(e),{x:o,y:s,z:c,w:l}=n,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let n=o!==0||s!==0,u,f;if(e.isDepthTexture===!0?(u=r.DEPTH_BUFFER_BIT,f=r.DEPTH_ATTACHMENT,t.stencil&&(u|=r.STENCIL_BUFFER_BIT)):(u=r.COLOR_BUFFER_BIT,f=r.COLOR_ATTACHMENT0),n){let e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],f=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,f);let p=d-s-l;r.blitFramebuffer(o,p,o+c,p+l,o,p,o+c,p+l,u,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,p,c,l),i.unbindTexture()}else{let e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,f,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,c,l,0,0,c,l,u,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,d-l-s,c,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){let{gl:i}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:s,stencilBuffer:c,width:l,height:u}=a;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!c){let t=i.DEPTH_COMPONENT24;r===!0?this.extensions.get(`WEBGL_multisampled_render_to_texture`).renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,t,l,u):n>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,t,l,u)):i.renderbufferStorage(i.RENDERBUFFER,t,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&c&&(n>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.DEPTH24_STENCIL8,l,u):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,i,a){let{backend:o,gl:s}=this,{textureGPU:c,glFormat:l,glType:u}=this.backend.get(e),d=s.createFramebuffer();o.state.bindFramebuffer(s.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?s.TEXTURE_CUBE_MAP_POSITIVE_X+a:s.TEXTURE_2D;s.framebufferTexture2D(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,f,c,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,l),h=r*i*m,g=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.bufferData(s.PIXEL_PACK_BUFFER,h,s.STREAM_READ),s.readPixels(t,n,r,i,l,u,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let _=new p(h/p.BYTES_PER_ELEMENT);return s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,_),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.deleteFramebuffer(d),_}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function UI(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?e:e.data}var $ce=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},ele=class{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}},WI={WEBGL_multi_draw:`WEBGL_multi_draw`,WEBGL_compressed_texture_astc:`texture-compression-astc`,WEBGL_compressed_texture_etc:`texture-compression-etc2`,WEBGL_compressed_texture_etc1:`texture-compression-etc1`,WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBGL_compressed_texture_s3tc:`texture-compression-s3tc`,EXT_texture_compression_bptc:`texture-compression-bc`,EXT_disjoint_timer_query_webgl2:`timestamp-query`,OVR_multiview2:`OVR_multiview2`},tle=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:r,object:i,type:a,info:o,index:s}=this;s===0?n.drawArrays(r,e,t):n.drawElements(r,t,a,e),o.update(i,t,1)}renderInstances(e,t,n){let{gl:r,mode:i,type:a,index:o,object:s,info:c}=this;n!==0&&(o===0?r.drawArraysInstanced(i,e,t,n):r.drawElementsInstanced(i,t,a,e,n),c.update(s,t,n))}renderMultiDraw(e,t,n){let{extensions:r,mode:i,object:a,info:o}=this;if(n===0)return;let s=r.get(`WEBGL_multi_draw`);if(s===null)for(let r=0;r<n;r++)this.render(e[r],t[r]);else{this.index===0?s.multiDrawArraysWEBGL(i,e,0,t,0,n):s.multiDrawElementsWEBGL(i,t,0,this.type,e,0,n);let r=0;for(let e=0;e<n;e++)r+=t[e];o.update(a,r,1)}}},GI=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&(B(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestampQuery(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},nle=class extends GI{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension(`EXT_disjoint_timer_query_webgl2`)||e.getExtension(`EXT_disjoint_timer_query`),!this.ext){B(`EXT_disjoint_timer_query not supported; timestamps will be disabled.`),this.trackTimestamp=!1;return}this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return Bo(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,`inactive`),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)===`inactive`&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,`started`))}catch(e){V(`Error in beginQuery:`,e),this.activeQuery=null,this.queryStates.set(t,`inactive`)}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,`ended`),this.activeQuery=null}catch(e){V(`Error in endQuery:`,e),this.queryStates.set(t,`inactive`),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[t,n]of this.queryOffsets)if(this.queryStates.get(n)===`ended`){let r=this.queries[n];e.set(t,this.resolveQuery(r))}if(e.size===0)return this.lastValue;let t={},n=[];for(let[r,i]of e){let e=r.match(/^(.*):f(\d+)$/),a=parseInt(e[2]);n.includes(a)===!1&&n.push(a),t[a]===void 0&&(t[a]=0);let o=await i;this.timestamps.set(r,o),t[a]+=o}let r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return V(`Error resolving queries:`,e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1,i=()=>{n&&=(clearTimeout(n),null)},a=e=>{r||(r=!0,i(),t(e))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(o,1);return}let r=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(r)/1e6)}catch(e){V(`Error checking query:`,e),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},KI=class extends II{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext(`webgl2`,n):t.context;function i(t){t.preventDefault();let n={api:`WebGL`,message:t.statusMessage||`Unknown reason`,reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=i,e.domElement.addEventListener(`webglcontextlost`,i,!1),this.gl=r,this.extensions=new $ce(this),this.capabilities=new ele(this),this.attributeUtils=new Yce(this),this.textureUtils=new Qce(this),this.bufferRenderer=new tle(this),this.state=new Xce(this),this.utils=new Zce(this),this.extensions.get(`EXT_color_buffer_float`),this.extensions.get(`WEBGL_clip_cull_distance`),this.extensions.get(`OES_texture_float_linear`),this.extensions.get(`EXT_color_buffer_half_float`),this.extensions.get(`WEBGL_multisampled_render_to_texture`),this.extensions.get(`WEBGL_render_shared_exponent`),this.extensions.get(`WEBGL_multi_draw`),this.extensions.get(`OVR_multiview2`),this.extensions.get(`EXT_clip_control`),this.disjoint=this.extensions.get(`EXT_disjoint_timer_query_webgl2`),this.parallel=this.extensions.get(`KHR_parallel_shader_compile`),this.drawBuffersIndexedExt=this.extensions.get(`OES_draw_buffers_indexed`),t.reversedDepthBuffer&&(this.extensions.has(`EXT_clip_control`)?e.reversedDepthBuffer=!0:(B(`WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return ko}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){let t=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&B(`WebGLBackend: Render-to-texture extension was disabled because an external texture was provided`),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new nle(this.gl,e,2048));let n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){!this.disjoint||!this.trackTimestamp||this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.viewport(0,0,e,n)}if(e.scissor)this.updateScissor(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.scissor(0,0,e,n)}this.initTimestampQuery(jo.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=Array(r),n.occlusionQueryObjects=Array(r),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,r=this.get(e),i=r.previousContext;n.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let o=e.textures;if(o!==null)for(let e=0;e<o.length;e++){let t=o[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=i,this._resolveRenderTarget(e),i!==null){if(this._setFramebuffer(i),i.viewport)this.updateViewport(i);else{let{width:e,height:t}=this.getDrawingBufferSize();n.viewport(0,0,e,t)}if(i.scissor)this.updateScissor(i);else{let{width:e,height:t}=this.getDrawingBufferSize();n.scissor(0,0,e,t)}}this.prepareTimestampBuffer(jo.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let a=()=>{let o=0;for(let t=0;t<n.length;t++){let a=n[t];a!==null&&i.getQueryParameter(a,i.QUERY_RESULT_AVAILABLE)&&(i.getQueryParameter(a,i.QUERY_RESULT)===0&&e.add(r[t]),n[t]=null,i.deleteQuery(a),o++)}o<n.length?requestAnimationFrame(a):t.occluded=e};a()}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.viewportValue;t.viewport(n,e.height-a-r,i,a)}updateScissor(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.scissorValue;t.scissor(n,e.height-a-r,i,a)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,r=null,i=!0,a=!0){let{gl:o,renderer:s}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let c=0;if(e&&(c|=o.COLOR_BUFFER_BIT),t&&(c|=o.DEPTH_BUFFER_BIT),n&&(c|=o.STENCIL_BUFFER_BIT),c!==0){let l;l=r.clearColorValue?r.clearColorValue:this.getClearColor();let u=s.getClearDepth(),d=s.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)o.clearColor(l.r,l.g,l.b,l.a),o.clear(c);else{if(i&&this._setFramebuffer(r),e)for(let e=0;e<r.textures.length;e++)e===0?o.clearBufferfv(o.COLOR,e,[l.r,l.g,l.b,l.a]):o.clearBufferfv(o.COLOR,e,[0,0,0,1]);t&&n?o.clearBufferfi(o.DEPTH_STENCIL,0,u,d):t?o.clearBufferfv(o.DEPTH,0,[u]):n&&o.clearBufferiv(o.STENCIL,0,[d]),i&&a&&this._resolveRenderTarget(r),i&&this._currentContext!==null&&this._currentContext!==r&&this._setFramebuffer(this._currentContext)}}}beginCompute(e){let{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(jo.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,r,i=null){let{state:a,gl:o}=this;this.discard===!1&&(a.enable(o.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:s,transformBuffers:c,attributes:l}=this.get(r),u=this._getVaoKey(l),d=this.vaoCache[u];d===void 0?this.vaoCache[u]=this._createVao(l):a.setVertexState(d),a.useProgram(s),this._bindUniforms(n);let f=this._getTransformFeedback(c);o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,f),o.beginTransformFeedback(o.POINTS),i=i===null?t.count:i,Array.isArray(i)?(Bo(`WebGLBackend.compute(): The count parameter must be a single number, not an array.`),i=i[0]):i&&typeof i==`object`&&i.isIndirectStorageBufferAttribute&&(Bo(`WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute`),i=t.count),l[0].isStorageInstancedBufferAttribute?o.drawArraysInstanced(o.POINTS,0,1,i):o.drawArrays(o.POINTS,0,i),o.endTransformFeedback(),o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,null);for(let e=0;e<c.length;e++){let t=c[e];t.pbo&&this.has(t.pbo)&&this.textureUtils.copyBufferToTexture(t.transformBuffer,t.pbo),t.switchBuffers()}}finishCompute(e){let{state:t,gl:n}=this;this.discard=!1,t.disable(n.RASTERIZER_DISCARD),this.prepareTimestampBuffer(jo.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}_draw(e,t,n,r,i,a){if(e.isBatchedMesh){if(this.hasFeature(`WEBGL_multi_draw`)===!1){let{gl:n}=this,r=n.getUniformLocation(a,`nodeUniformDrawId`),i=e._multiDrawStarts,o=e._multiDrawCounts,s=e._multiDrawCount;for(let e=0;e<s;e++)n.uniform1ui(r,e),t.render(i[e],o[e])}else t.renderMultiDraw(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount)}else i>1?t.renderInstances(n,r,i):t.render(n,r)}draw(e){let{object:t,pipeline:n,material:r,context:i,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(n),{gl:s,state:c}=this,l=this.get(i),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinantAffine()<0;c.setMaterial(r,d,a),i.mrt!==null&&i.textures!==null&&c.setMRTBlending(i.textures,i.mrt,r),c.useProgram(o);let f=e.getAttributes(),p=this.get(f),m=p.vaoGPU;if(m===void 0){let e=this._getVaoKey(f);m=this.vaoCache[e],m===void 0&&(m=this._createVao(f),this.vaoCache[e]=m,p.vaoGPU=m)}let h=e.getIndex(),g=h===null?null:this.get(h).bufferGPU;c.setVertexState(m,g);let _=l.lastOcclusionObject;if(_!==t&&_!==void 0){if(_!==null&&_.occlusionTest===!0&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),t.occlusionTest===!0){let e=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}let v=this.bufferRenderer;t.isPoints?v.mode=s.POINTS:t.isLineSegments?v.mode=s.LINES:t.isLine?v.mode=s.LINE_STRIP:t.isLineLoop?v.mode=s.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),v.mode=s.LINES):v.mode=s.TRIANGLES;let{vertexCount:y,instanceCount:b}=u,{firstVertex:x}=u;if(v.object=t,h!==null){x*=h.array.BYTES_PER_ELEMENT;let e=this.get(h);v.index=h.count,v.type=e.type}else v.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let n=this.get(e.camera),r=e.camera.cameras,i=e.getBindingGroup(`cameraIndex`).bindings[0];if(n.indexesGPU===void 0||n.indexesGPU.length!==r.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let n=0,i=r.length;n<i;n++){let r=s.createBuffer();e[0]=n,s.bindBuffer(s.UNIFORM_BUFFER,r),s.bufferData(s.UNIFORM_BUFFER,e,s.STATIC_DRAW),t.push(r)}n.indexesGPU=t}let a=0;bindingsSearch:for(let t of e.getBindings())for(let e of t.bindings){if(e===i)break bindingsSearch;(e.isUniformsGroup||e.isUniformBuffer)&&a++}let l=this.renderer.getPixelRatio(),u=this._currentContext.renderTarget,d=this._isRenderCameraDepthArray(this._currentContext),f=this._currentContext.activeCubeFace;if(d){let e=this.get(u.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=u;for(let e=0,n=r.length;e<n;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1,!1);this.renderer._activeCubeFace=f,this._currentContext.activeCubeFace=f}}for(let i=0,u=r.length;i<u;i++){let u=r[i];if(t.layers.test(u.layers)){d&&(this.renderer._activeCubeFace=i,this._currentContext.activeCubeFace=i,this._setFramebuffer(this._currentContext));let r=u.viewport;if(r!==void 0){let t=r.x*l,n=r.y*l,i=r.width*l,a=r.height*l;c.viewport(Math.floor(t),Math.floor(e.context.height-a-n),Math.floor(i),Math.floor(a))}c.bindBufferBase(s.UNIFORM_BUFFER,a,n.indexesGPU[i]),this._draw(t,v,x,y,b,o)}this._currentContext.activeCubeFace=f,this.renderer._activeCubeFace=f}}else this._draw(t,v,x,y,b,o)}needsRenderUpdate(){return!1}getRenderCacheKey(){return``}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}updateSampler(){return``}createNodeBuilder(e,t){return new Kce(e,t)}createProgram(e){let t=this.gl,{stage:n,code:r}=e,i=n===`fragment`?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(i,r),t.compileShader(i),this.set(e,{shaderGPU:i})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let n=this.gl,r=e.pipeline,{fragmentProgram:i,vertexProgram:a}=r,o=n.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU;if(n.attachShader(o,s),n.attachShader(o,c),n.linkProgram(o),this.set(r,{programGPU:o,fragmentShader:s,vertexShader:c}),t!==null&&this.parallel){let i=new Promise(t=>{let i=this.parallel,a=()=>{n.getProgramParameter(o,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(a)};a()});t.push(i);return}this._completeCompile(e,r)}_handleSource(e,t){let n=e.split(`
|
|
4832
|
+
`)}}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache),o=a.uniformGPU;if(o===void 0){let r=e.groupNode,s=r.name,c=this.getBindGroupArray(s,n);if(t===`texture`)o=new EI(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`||t===`cubeDepthTexture`)o=new DI(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new OI(i.name,i.node,r),c.push(o);else if(t===`buffer`){i.name=`buffer${e.id}`;let t=this.getSharedDataFromNode(e),n=t.buffer;n===void 0&&(e.name=`NodeBuffer_${e.id}`,n=new CI(e,r),n.name=e.name,t.buffer=n),c.push(n),o=n}else{let e=this.uniformGroups[s];e===void 0?(e=new wI(s,r),this.uniformGroups[s]=e,c.push(e)):c.indexOf(e)===-1&&c.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}},FI=null,II=null,LI=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[jo.RENDER]:null,[jo.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),n=this.renderer.info.frame,r;r=e.isComputeNode===!0?`c:`+this.renderer.info.compute.frameCalls:`r:`+this.renderer.info.render.frameCalls,t.timestampUID=r+`:`+e.id+`:f`+n}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith(`c:`)?jo.COMPUTE:jo.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e=`render`){if(!this.trackTimestamp){Bo(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t)return;let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return FI||=new H,this.renderer.getDrawingBufferSize(FI)}setScissorTest(){}getClearColor(){let e=this.renderer;return II||=new CP,e.getClearColor(II),II.getRGB(II),II}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?Io():this.parameters.canvas,`setAttribute`in e&&e.setAttribute(`data-engine`,`three.js r185 webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},Kce=0,qce=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},Jce=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:r}=n,i=e.array,a=e.usage||r.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,s=n.get(o),c=s.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,i,a),s.bufferGPU=c,s.bufferType=t,s.version=o.version);let l;if(i instanceof Float32Array)l=r.FLOAT;else if(typeof Float16Array<`u`&&i instanceof Float16Array)l=r.HALF_FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)l=r.UNSIGNED_BYTE;else throw Error(`THREE.WebGLBackend: Unsupported buffer data format: `+i);let u={bufferGPU:c,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===1013,id:Kce++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new qce(u,e)}n.set(e,u)}updateAttribute(e){let t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(o,a.bufferGPU),s.length===0)n.bufferSubData(o,0,r);else{for(let e=0,t=s.length;e<t;e++){let t=s[e];n.bufferSubData(o,t.start*r.BYTES_PER_ELEMENT,r,t.start,t.count)}i.clearUpdateRanges()}n.bindBuffer(o,null),a.version=i.version}destroyAttribute(e){let t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let r=t.get(e);n.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e,t=null,n=0,r=-1){let i=this.backend,{gl:a}=i,o=e.isInterleavedBufferAttribute?e.data:e,s=i.get(o),{bufferGPU:c}=s,l=r===-1?s.byteLength-n:r,u;if(t===null)u=new Uint8Array(new ArrayBuffer(l));else if(t.isReadbackBuffer){if(t._mapped===!0)throw Error(`THREE.WebGPURenderer: ReadbackBuffer must be released before being used again.`);let e=()=>{t.buffer=null,t._mapped=!1,t.removeEventListener(`release`,e),t.removeEventListener(`dispose`,e)};t.addEventListener(`release`,e),t.addEventListener(`dispose`,e),u=new Uint8Array(new ArrayBuffer(l)),t.buffer=u.buffer}else u=new Uint8Array(t);return a.bindBuffer(a.COPY_READ_BUFFER,c),a.getBufferSubData(a.COPY_READ_BUFFER,n,u),a.bindBuffer(a.COPY_READ_BUFFER,null),a.bindBuffer(a.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:u.buffer}_createBuffer(e,t,n,r){let i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,n,r),e.bindBuffer(t,null),i}},RI,zI,Yce=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;RI={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT},zI={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new Ls().fromArray(t),this.currentViewport=new Ls().fromArray(n),this._tempVec4=new Ls}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===0?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===1?t.cullFace(t.BACK):e===2?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,n){let r=this.gl,i=this.backend.drawBuffersIndexedExt;if(!i){Bo(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`);return}for(let a=0;a<e.length;a++){let o=e[a],s=null;if(t!==null){let e=t.getBlendMode(o.name);e.blending===6?s=n:e.blending!==0&&(s=e)}else s=n;s===null?i.blendFuncSeparateiOES(a,r.ONE,r.ZERO,r.ONE,r.ZERO):this._setMRTBlendingIndex(a,s)}}_setMRTBlendingIndex(e,t){let{gl:n}=this,r=this.backend.drawBuffersIndexedExt,i=t.blending,a=t.blendSrc,o=t.blendDst,s=t.blendEquation,c=t.premultipliedAlpha;if(i===5){let n=t.blendSrcAlpha===null?a:t.blendSrcAlpha,i=t.blendDstAlpha===null?o:t.blendDstAlpha,c=t.blendEquationAlpha===null?s:t.blendEquationAlpha;r.blendEquationSeparateiOES(e,RI[s],RI[c]),r.blendFuncSeparateiOES(e,zI[a],zI[o],zI[n],zI[i])}else if(r.blendEquationSeparateiOES(e,n.FUNC_ADD,n.FUNC_ADD),c)switch(i){case 1:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,n.ONE,n.ONE,n.ONE,n.ONE);break;case 3:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case 4:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}else switch(i){case 1:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case 3:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case 4:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}}setBlending(e,t,n,r,i,a,o,s){let{gl:c}=this;if(e===0){this.currentBlendingEnabled===!0&&(this.disable(c.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(c.BLEND),this.currentBlendingEnabled=!0),e!==5){if(e!==this.currentBlending||s!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==100||this.currentBlendEquationAlpha!==100)&&(c.blendEquation(c.FUNC_ADD),this.currentBlendEquation=100,this.currentBlendEquationAlpha=100),s)switch(e){case 1:c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case 2:c.blendFunc(c.ONE,c.ONE);break;case 3:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case 4:c.blendFuncSeparate(c.DST_COLOR,c.ONE_MINUS_SRC_ALPHA,c.ZERO,c.ONE);break;default:V(`WebGLState: Invalid blending: `,e)}else switch(e){case 1:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case 2:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE,c.ONE,c.ONE);break;case 3:V(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:V(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:V(`WebGLState: Invalid blending: `,e)}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=s}return}i||=t,a||=n,o||=r,(t!==this.currentBlendEquation||i!==this.currentBlendEquationAlpha)&&(c.blendEquationSeparate(RI[t],RI[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(zI[n],zI[r],zI[a],zI[o]),this.currentBlendSrc=n,this.currentBlendDst=r,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=o),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setReversedDepth(e){if(this.currentDepthReversed!==e){let t=this.backend.extensions.get(`EXT_clip_control`);e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=Uo[e]),this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentScissor.equals(i)===!1){let{gl:e}=this;e.scissor(i.x,i.y,i.z,i.w),this.currentScissor.copy(i)}}viewport(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentViewport.equals(i)===!1){let{gl:e}=this;e.viewport(i.x,i.y,i.z,i.w),this.currentViewport.copy(i)}}setScissorTest(e){let t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){let{gl:r}=this;e.side===2?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let i=e.side===1;t&&(i=!i),this.setFlipSided(i),e.blending===1&&e.transparent===!1?this.setBlending(0):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let a=e.stencilWrite;if(this.setStencilTest(a),a&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){let e=12288;for(let t=0;t<8;t++)t<n?this.enable(e+t):this.disable(e+t)}}setPolygonOffset(e,t,n){let{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(r.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e&&(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){let n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:n,currentBoundFramebuffers:r}=this;return r[e]!==t&&(n.bindFramebuffer(e,t),r[e]=t,e===n.DRAW_FRAMEBUFFER&&(r[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(r[n.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){let{gl:n}=this,r=[],i=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));let a=e.textures;if(r.length!==a.length||r[0]!==n.COLOR_ATTACHMENT0){for(let e=0,t=a.length;e<t;e++)r[e]=n.COLOR_ATTACHMENT0+e;r.length=a.length,i=!0}}else r[0]!==n.BACK&&(r[0]=n.BACK,i=!0);i&&n.drawBuffers(r)}activeTexture(e){let{gl:t,currentTextureSlot:n,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){let{gl:r,currentTextureSlot:i,currentBoundTextures:a,maxTextures:o}=this;n===void 0&&(n=i===null?r.TEXTURE0+o-1:i);let s=a[n];s===void 0&&(s={type:void 0,texture:void 0},a[n]=s),(s.type!==e||s.texture!==t)&&(i!==n&&(r.activeTexture(n),this.currentTextureSlot=n),r.bindTexture(e,t),s.type=e,s.texture=t)}bindBufferBase(e,t,n){let{gl:r}=this,i=`${e}-${t}`;return this.currentBoundBufferBases[i]!==n&&(r.bindBufferBase(e,t,n),this.currentBoundBufferBases[i]=n,!0)}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,r=n[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}getParameter(e){let{gl:t,parameters:n}=this;return n[e]===void 0?t.getParameter(e):n[e]}pixelStorei(e,t){let{gl:n,parameters:r}=this;r[e]!==t&&(n.pixelStorei(e,t),r[e]=t)}},Xce=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=``){let{gl:n,extensions:r}=this,i,a=Es.getTransfer(t);if(e===1009)return n.UNSIGNED_BYTE;if(e===1017)return n.UNSIGNED_SHORT_4_4_4_4;if(e===1018)return n.UNSIGNED_SHORT_5_5_5_1;if(e===35902)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===35899)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===1010)return n.BYTE;if(e===1011)return n.SHORT;if(e===1012)return n.UNSIGNED_SHORT;if(e===1013)return n.INT;if(e===1014)return n.UNSIGNED_INT;if(e===1015)return n.FLOAT;if(e===1016)return n.HALF_FLOAT;if(e===1021)return n.ALPHA;if(e===1022)return n.RGB;if(e===1023)return n.RGBA;if(e===1026)return n.DEPTH_COMPONENT;if(e===1027)return n.DEPTH_STENCIL;if(e===1028)return n.RED;if(e===1029)return n.RED_INTEGER;if(e===1030)return n.RG;if(e===1031)return n.RG_INTEGER;if(e===1033)return n.RGBA_INTEGER;if(e===33776||e===33777||e===33778||e===33779){if(a===`srgb`){if(i=r.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(e===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=r.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(e===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(e===35840||e===35841||e===35842||e===35843){if(i=r.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(e===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(e===36196||e===37492||e===37496||e===37488||e===37489||e===37490||e===37491){if(i=r.get(`WEBGL_compressed_texture_etc`),i!==null){if(e===36196||e===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(e===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(e===37488)return i.COMPRESSED_R11_EAC;if(e===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(e===37490)return i.COMPRESSED_RG11_EAC;if(e===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null}if(e===37808||e===37809||e===37810||e===37811||e===37812||e===37813||e===37814||e===37815||e===37816||e===37817||e===37818||e===37819||e===37820||e===37821){if(i=r.get(`WEBGL_compressed_texture_astc`),i!==null){if(e===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(e===36492||e===36494||e===36495){if(i=r.get(`EXT_texture_compression_bptc`),i!==null){if(e===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(e===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(e===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(e===36283||e===36284||e===36285||e===36286){if(i=r.get(`EXT_texture_compression_rgtc`),i!==null){if(e===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(e===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return e===1020?n.UNSIGNED_INT_24_8:n[e]===void 0?null:n[e]}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,r)=>{function i(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(i);return}e.deleteSync(t),n()}i()})}},BI=!1,VI,HI,UI,Zce=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,BI===!1&&(this._init(),BI=!0)}_init(){let e=this.gl;VI={[Ki]:e.REPEAT,[qi]:e.CLAMP_TO_EDGE,[Ji]:e.MIRRORED_REPEAT},HI={[Yi]:e.NEAREST,[Xi]:e.NEAREST_MIPMAP_NEAREST,[Zi]:e.NEAREST_MIPMAP_LINEAR,[Qi]:e.LINEAR,[$i]:e.LINEAR_MIPMAP_NEAREST,[ea]:e.LINEAR_MIPMAP_LINEAR},UI={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return n=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i,a=!1){let{gl:o,extensions:s}=this;if(e!==null){if(o[e]!==void 0)return o[e];B(`WebGLBackend: Attempt to use non-existing WebGL internal format '`+e+`'`)}let c=null;r&&(c=s.get(`EXT_texture_norm16`),c||B(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=t;if(t===o.RED&&(n===o.FLOAT&&(l=o.R32F),n===o.HALF_FLOAT&&(l=o.R16F),n===o.UNSIGNED_BYTE&&(l=o.R8),n===o.BYTE&&(l=o.R8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),n===o.SHORT&&c&&(l=c.R16_SNORM_EXT)),t===o.RED_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.R8UI),n===o.UNSIGNED_SHORT&&(l=o.R16UI),n===o.UNSIGNED_INT&&(l=o.R32UI),n===o.BYTE&&(l=o.R8I),n===o.SHORT&&(l=o.R16I),n===o.INT&&(l=o.R32I)),t===o.RG&&(n===o.FLOAT&&(l=o.RG32F),n===o.HALF_FLOAT&&(l=o.RG16F),n===o.UNSIGNED_BYTE&&(l=o.RG8),n===o.BYTE&&(l=o.RG8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),n===o.SHORT&&c&&(l=c.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RG8UI),n===o.UNSIGNED_SHORT&&(l=o.RG16UI),n===o.UNSIGNED_INT&&(l=o.RG32UI),n===o.BYTE&&(l=o.RG8I),n===o.SHORT&&(l=o.RG16I),n===o.INT&&(l=o.RG32I)),t===o.RGB){let e=a?vo:Es.getTransfer(i);n===o.FLOAT&&(l=o.RGB32F),n===o.HALF_FLOAT&&(l=o.RGB16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8:o.RGB8),n===o.BYTE&&(l=o.RGB8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),n===o.SHORT&&c&&(l=c.RGB16_SNORM_EXT),n===o.UNSIGNED_SHORT_5_6_5&&(l=o.RGB565),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGB4),n===o.UNSIGNED_INT_5_9_9_9_REV&&(l=o.RGB9_E5),n===o.UNSIGNED_INT_10F_11F_11F_REV&&(l=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGB8UI),n===o.UNSIGNED_SHORT&&(l=o.RGB16UI),n===o.UNSIGNED_INT&&(l=o.RGB32UI),n===o.BYTE&&(l=o.RGB8I),n===o.SHORT&&(l=o.RGB16I),n===o.INT&&(l=o.RGB32I)),t===o.RGBA){let e=a?vo:Es.getTransfer(i);n===o.FLOAT&&(l=o.RGBA32F),n===o.HALF_FLOAT&&(l=o.RGBA16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8_ALPHA8:o.RGBA8),n===o.BYTE&&(l=o.RGBA8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),n===o.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGBA4),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGBA8UI),n===o.UNSIGNED_SHORT&&(l=o.RGBA16UI),n===o.UNSIGNED_INT&&(l=o.RGBA32UI),n===o.BYTE&&(l=o.RGBA8I),n===o.SHORT&&(l=o.RGBA16I),n===o.INT&&(l=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(n===o.UNSIGNED_SHORT&&(l=o.DEPTH_COMPONENT16),n===o.UNSIGNED_INT&&(l=o.DEPTH_COMPONENT24),n===o.FLOAT&&(l=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&n===o.UNSIGNED_INT_24_8&&(l=o.DEPTH24_STENCIL8),(l===o.R16F||l===o.R32F||l===o.RG16F||l===o.RG32F||l===o.RGBA16F||l===o.RGBA32F)&&s.get(`EXT_color_buffer_float`),l}setTextureParameters(e,t){let{gl:n,extensions:r,backend:i}=this,{state:a}=this.backend,o=Es.getPrimaries(Es.workingColorSpace),s=t.colorSpace===``?null:Es.getPrimaries(t.colorSpace),c=t.colorSpace===``||o===s?n.NONE:n.BROWSER_DEFAULT_WEBGL;a.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),n.texParameteri(e,n.TEXTURE_WRAP_S,VI[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,VI[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,VI[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,HI[t.magFilter]);let l=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===1006&&l?ea:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,HI[u]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,UI[t.compareFunction])),r.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&r.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1){let a=r.get(`EXT_texture_filter_anisotropic`);n.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e),a=r[i];a===void 0&&(a=t.createTexture(),n.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=a),n.set(e,{textureGPU:a,glTextureType:i})}createTexture(e,t){let{gl:n,backend:r}=this,i,a,o,s,c;if(e.isExternalTexture===!0)i=e.sourceTexture,a=this.getGLTextureType(e);else{let{levels:l,width:u,height:d,depth:f}=t;o=r.utils.convert(e.format,e.colorSpace),s=r.utils.convert(e.type),c=this.getInternalFormat(e.internalFormat,o,s,e.normalized,e.colorSpace,e.isVideoTexture),i=n.createTexture(),a=this.getGLTextureType(e),r.state.bindTexture(a,i),this.setTextureParameters(a,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,l,c,u,d,f):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,l,c,u,d,f):e.isVideoTexture||n.texStorage2D(a,l,c,u,d)}r.set(e,{textureGPU:i,glTextureType:a,glFormat:o,glType:s,glInternalFormat:c})}copyBufferToTexture(e,t){let{gl:n,backend:r}=this,{state:i}=r,{textureGPU:a,glTextureType:o,glFormat:s,glType:c}=r.get(t),{width:l,height:u}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(o,a),i.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,l,u,s,c,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:r,height:i}=t,{textureGPU:a,glTextureType:o,glFormat:s,glType:c,glInternalFormat:l}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0)){if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){let r=e.mipmaps,i=t.image;for(let t=0;t<r.length;t++){let a=r[t];e.isCompressedArrayTexture?e.format===n.RGBA?n.texSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,c,a.data):s===null?B(`WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()`):n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,a.data):s===null?B(`WebGLBackend: Unsupported compressed texture format`):n.compressedTexSubImage2D(n.TEXTURE_2D,t,0,0,a.width,a.height,s,a.data)}}else if(e.isCubeTexture){let a=t.images,o=e.mipmaps;for(let e=0;e<6;e++){let t=WI(a[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,r,i,s,c,t);for(let t=0;t<o.length;t++){let r=o[t],i=WI(r.images[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,t+1,0,0,i.width,i.height,s,c,i)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let r=t.image;if(e.layerUpdates.size>0){let t=Jf(r.width,r.height,e.format,e.type);for(let i of e.layerUpdates){let e=r.data.subarray(i*t/r.data.BYTES_PER_ELEMENT,(i+1)*t/r.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,i,r.width,r.height,1,s,c,e)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,r.width,r.height,r.depth,s,c,r.data)}else if(e.isData3DTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(o,0,l,s,c,t.image);else if(e.isHTMLTexture)typeof n.texElementImage2D==`function`&&(n.texElementImage2D.length===3?n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,t.image):n.texElementImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t.image));else{let a=e.mipmaps;if(a.length>0)for(let e=0,t=a.length;e<t;e++){let t=a[e],r=WI(t);n.texSubImage2D(o,e,0,0,t.width,t.height,s,c,r)}else{let e=WI(t.image);n.texSubImage2D(o,0,0,0,r,i,s,c,e)}}}}generateMipmaps(e){let{gl:t,backend:n}=this,{textureGPU:r,glTextureType:i}=n.get(e);n.state.bindTexture(i,r),t.generateMipmap(i)}deallocateRenderBuffers(e){let{gl:t,backend:n}=this;if(e){let r=n.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(let e in r.framebuffers)t.deleteFramebuffer(r.framebuffers[e]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let e=0;e<r.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(r.msaaRenderbuffers[e]);delete r.msaaRenderbuffers}}}destroyTexture(e,t=!1){let{gl:n,backend:r}=this,{textureGPU:i,renderTarget:a}=r.get(e);this.deallocateRenderBuffers(a),t===!1&&e.isExternalTexture!==!0&&n.deleteTexture(i),r.delete(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let{gl:o,backend:s}=this,{state:c}=this.backend,{textureGPU:l,glTextureType:u,glType:d,glFormat:f}=s.get(t);c.bindTexture(u,l);let p,m,h,g,_,v,y,b,x,S=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)p=n.max.x-n.min.x,m=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,g=n.min.x,_=n.min.y,v=n.isBox3?n.min.z:0;else{let t=2**-i;p=Math.floor(S.width*t),m=Math.floor(S.height*t),h=e.isDataArrayTexture||e.isArrayTexture?S.depth:e.isData3DTexture?Math.floor(S.depth*t):1,g=0,_=0,v=0}r===null?(y=0,b=0,x=0):(y=r.x,b=r.y,x=r.z),c.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t.flipY),c.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),c.pixelStorei(o.UNPACK_ALIGNMENT,t.unpackAlignment);let C=c.getParameter(o.UNPACK_ROW_LENGTH),w=c.getParameter(o.UNPACK_IMAGE_HEIGHT),T=c.getParameter(o.UNPACK_SKIP_PIXELS),E=c.getParameter(o.UNPACK_SKIP_ROWS),D=c.getParameter(o.UNPACK_SKIP_IMAGES);c.pixelStorei(o.UNPACK_ROW_LENGTH,S.width),c.pixelStorei(o.UNPACK_IMAGE_HEIGHT,S.height),c.pixelStorei(o.UNPACK_SKIP_PIXELS,g),c.pixelStorei(o.UNPACK_SKIP_ROWS,_),c.pixelStorei(o.UNPACK_SKIP_IMAGES,v);let O=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,k=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let n=s.get(e),r=s.get(t),u=s.get(n.renderTarget),d=s.get(r.renderTarget),f=u.framebuffers[n.cacheKey],S=d.framebuffers[r.cacheKey],C=c.currentBoundFramebuffers[o.READ_FRAMEBUFFER]??null,w=c.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER]??null;c.bindFramebuffer(o.READ_FRAMEBUFFER,f),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,S);for(let e=0;e<h;e++)O&&(o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,n.textureGPU,i,v+e),o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,l,a,x+e)),o.blitFramebuffer(g,_,p,m,y,b,p,m,o.DEPTH_BUFFER_BIT,o.NEAREST);c.bindFramebuffer(o.READ_FRAMEBUFFER,C),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,w)}else if(i!==0||e.isRenderTargetTexture||s.has(e)){let t=s.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=o.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=o.createFramebuffer());let n=c.currentBoundFramebuffers[o.READ_FRAMEBUFFER]??null,r=c.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER]??null;c.bindFramebuffer(o.READ_FRAMEBUFFER,this._srcFramebuffer),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let e=0;e<h;e++)O?o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,t.textureGPU,i,v+e):o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,t.textureGPU,i),k?o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,l,a,x+e):o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,l,a),i===0?k?o.copyTexSubImage3D(u,a,y,b,x+e,g,_,p,m):o.copyTexSubImage2D(u,a,y,b,g,_,p,m):o.blitFramebuffer(g,_,p,m,y,b,p,m,o.COLOR_BUFFER_BIT,o.NEAREST);c.bindFramebuffer(o.READ_FRAMEBUFFER,n),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,r)}else k?e.isDataTexture||e.isData3DTexture?o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S.data):t.isCompressedArrayTexture?o.compressedTexSubImage3D(u,a,y,b,x,p,m,h,f,S.data):o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S):e.isDataTexture?o.texSubImage2D(o.TEXTURE_2D,a,y,b,p,m,f,d,S.data):e.isCompressedTexture?o.compressedTexSubImage2D(o.TEXTURE_2D,a,y,b,S.width,S.height,f,S.data):o.texSubImage2D(o.TEXTURE_2D,a,y,b,p,m,f,d,S);c.pixelStorei(o.UNPACK_ROW_LENGTH,C),c.pixelStorei(o.UNPACK_IMAGE_HEIGHT,w),c.pixelStorei(o.UNPACK_SKIP_PIXELS,T),c.pixelStorei(o.UNPACK_SKIP_ROWS,E),c.pixelStorei(o.UNPACK_SKIP_IMAGES,D),a===0&&t.generateMipmaps&&o.generateMipmap(u),c.unbindTexture()}copyFramebufferToTexture(e,t,n){let{gl:r}=this,{state:i}=this.backend,{textureGPU:a}=this.backend.get(e),{x:o,y:s,z:c,w:l}=n,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let n=o!==0||s!==0,u,f;if(e.isDepthTexture===!0?(u=r.DEPTH_BUFFER_BIT,f=r.DEPTH_ATTACHMENT,t.stencil&&(u|=r.STENCIL_BUFFER_BIT)):(u=r.COLOR_BUFFER_BIT,f=r.COLOR_ATTACHMENT0),n){let e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],f=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,f);let p=d-s-l;r.blitFramebuffer(o,p,o+c,p+l,o,p,o+c,p+l,u,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,p,c,l),i.unbindTexture()}else{let e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,f,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,c,l,0,0,c,l,u,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,d-l-s,c,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){let{gl:i}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:s,stencilBuffer:c,width:l,height:u}=a;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!c){let t=i.DEPTH_COMPONENT24;r===!0?this.extensions.get(`WEBGL_multisampled_render_to_texture`).renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,t,l,u):n>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,t,l,u)):i.renderbufferStorage(i.RENDERBUFFER,t,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&c&&(n>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.DEPTH24_STENCIL8,l,u):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,i,a){let{backend:o,gl:s}=this,{textureGPU:c,glFormat:l,glType:u}=this.backend.get(e),d=s.createFramebuffer();o.state.bindFramebuffer(s.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?s.TEXTURE_CUBE_MAP_POSITIVE_X+a:s.TEXTURE_2D;s.framebufferTexture2D(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,f,c,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,l),h=r*i*m,g=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.bufferData(s.PIXEL_PACK_BUFFER,h,s.STREAM_READ),s.readPixels(t,n,r,i,l,u,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let _=new p(h/p.BYTES_PER_ELEMENT);return s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,_),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.deleteFramebuffer(d),_}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function WI(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?e:e.data}var Qce=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},$ce=class{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}},GI={WEBGL_multi_draw:`WEBGL_multi_draw`,WEBGL_compressed_texture_astc:`texture-compression-astc`,WEBGL_compressed_texture_etc:`texture-compression-etc2`,WEBGL_compressed_texture_etc1:`texture-compression-etc1`,WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBGL_compressed_texture_s3tc:`texture-compression-s3tc`,EXT_texture_compression_bptc:`texture-compression-bc`,EXT_disjoint_timer_query_webgl2:`timestamp-query`,OVR_multiview2:`OVR_multiview2`},ele=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:r,object:i,type:a,info:o,index:s}=this;s===0?n.drawArrays(r,e,t):n.drawElements(r,t,a,e),o.update(i,t,1)}renderInstances(e,t,n){let{gl:r,mode:i,type:a,index:o,object:s,info:c}=this;n!==0&&(o===0?r.drawArraysInstanced(i,e,t,n):r.drawElementsInstanced(i,t,a,e,n),c.update(s,t,n))}renderMultiDraw(e,t,n){let{extensions:r,mode:i,object:a,info:o}=this;if(n===0)return;let s=r.get(`WEBGL_multi_draw`);if(s===null)for(let r=0;r<n;r++)this.render(e[r],t[r]);else{this.index===0?s.multiDrawArraysWEBGL(i,e,0,t,0,n):s.multiDrawElementsWEBGL(i,t,0,this.type,e,0,n);let r=0;for(let e=0;e<n;e++)r+=t[e];o.update(a,r,1)}}},KI=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&(B(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestampQuery(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},tle=class extends KI{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension(`EXT_disjoint_timer_query_webgl2`)||e.getExtension(`EXT_disjoint_timer_query`),!this.ext){B(`EXT_disjoint_timer_query not supported; timestamps will be disabled.`),this.trackTimestamp=!1;return}this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return Bo(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,`inactive`),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)===`inactive`&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,`started`))}catch(e){V(`Error in beginQuery:`,e),this.activeQuery=null,this.queryStates.set(t,`inactive`)}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,`ended`),this.activeQuery=null}catch(e){V(`Error in endQuery:`,e),this.queryStates.set(t,`inactive`),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[t,n]of this.queryOffsets)if(this.queryStates.get(n)===`ended`){let r=this.queries[n];e.set(t,this.resolveQuery(r))}if(e.size===0)return this.lastValue;let t={},n=[];for(let[r,i]of e){let e=r.match(/^(.*):f(\d+)$/),a=parseInt(e[2]);n.includes(a)===!1&&n.push(a),t[a]===void 0&&(t[a]=0);let o=await i;this.timestamps.set(r,o),t[a]+=o}let r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return V(`Error resolving queries:`,e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1,i=()=>{n&&=(clearTimeout(n),null)},a=e=>{r||(r=!0,i(),t(e))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(o,1);return}let r=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(r)/1e6)}catch(e){V(`Error checking query:`,e),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},qI=class extends LI{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext(`webgl2`,n):t.context;function i(t){t.preventDefault();let n={api:`WebGL`,message:t.statusMessage||`Unknown reason`,reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=i,e.domElement.addEventListener(`webglcontextlost`,i,!1),this.gl=r,this.extensions=new Qce(this),this.capabilities=new $ce(this),this.attributeUtils=new Jce(this),this.textureUtils=new Zce(this),this.bufferRenderer=new ele(this),this.state=new Yce(this),this.utils=new Xce(this),this.extensions.get(`EXT_color_buffer_float`),this.extensions.get(`WEBGL_clip_cull_distance`),this.extensions.get(`OES_texture_float_linear`),this.extensions.get(`EXT_color_buffer_half_float`),this.extensions.get(`WEBGL_multisampled_render_to_texture`),this.extensions.get(`WEBGL_render_shared_exponent`),this.extensions.get(`WEBGL_multi_draw`),this.extensions.get(`OVR_multiview2`),this.extensions.get(`EXT_clip_control`),this.disjoint=this.extensions.get(`EXT_disjoint_timer_query_webgl2`),this.parallel=this.extensions.get(`KHR_parallel_shader_compile`),this.drawBuffersIndexedExt=this.extensions.get(`OES_draw_buffers_indexed`),t.reversedDepthBuffer&&(this.extensions.has(`EXT_clip_control`)?e.reversedDepthBuffer=!0:(B(`WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return ko}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){let t=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&B(`WebGLBackend: Render-to-texture extension was disabled because an external texture was provided`),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new tle(this.gl,e,2048));let n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){!this.disjoint||!this.trackTimestamp||this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.viewport(0,0,e,n)}if(e.scissor)this.updateScissor(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.scissor(0,0,e,n)}this.initTimestampQuery(jo.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=Array(r),n.occlusionQueryObjects=Array(r),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,r=this.get(e),i=r.previousContext;n.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let o=e.textures;if(o!==null)for(let e=0;e<o.length;e++){let t=o[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=i,this._resolveRenderTarget(e),i!==null){if(this._setFramebuffer(i),i.viewport)this.updateViewport(i);else{let{width:e,height:t}=this.getDrawingBufferSize();n.viewport(0,0,e,t)}if(i.scissor)this.updateScissor(i);else{let{width:e,height:t}=this.getDrawingBufferSize();n.scissor(0,0,e,t)}}this.prepareTimestampBuffer(jo.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let a=()=>{let o=0;for(let t=0;t<n.length;t++){let a=n[t];a!==null&&i.getQueryParameter(a,i.QUERY_RESULT_AVAILABLE)&&(i.getQueryParameter(a,i.QUERY_RESULT)===0&&e.add(r[t]),n[t]=null,i.deleteQuery(a),o++)}o<n.length?requestAnimationFrame(a):t.occluded=e};a()}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.viewportValue;t.viewport(n,e.height-a-r,i,a)}updateScissor(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.scissorValue;t.scissor(n,e.height-a-r,i,a)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,r=null,i=!0,a=!0){let{gl:o,renderer:s}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let c=0;if(e&&(c|=o.COLOR_BUFFER_BIT),t&&(c|=o.DEPTH_BUFFER_BIT),n&&(c|=o.STENCIL_BUFFER_BIT),c!==0){let l;l=r.clearColorValue?r.clearColorValue:this.getClearColor();let u=s.getClearDepth(),d=s.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)o.clearColor(l.r,l.g,l.b,l.a),o.clear(c);else{if(i&&this._setFramebuffer(r),e)for(let e=0;e<r.textures.length;e++)e===0?o.clearBufferfv(o.COLOR,e,[l.r,l.g,l.b,l.a]):o.clearBufferfv(o.COLOR,e,[0,0,0,1]);t&&n?o.clearBufferfi(o.DEPTH_STENCIL,0,u,d):t?o.clearBufferfv(o.DEPTH,0,[u]):n&&o.clearBufferiv(o.STENCIL,0,[d]),i&&a&&this._resolveRenderTarget(r),i&&this._currentContext!==null&&this._currentContext!==r&&this._setFramebuffer(this._currentContext)}}}beginCompute(e){let{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(jo.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,r,i=null){let{state:a,gl:o}=this;this.discard===!1&&(a.enable(o.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:s,transformBuffers:c,attributes:l}=this.get(r),u=this._getVaoKey(l),d=this.vaoCache[u];d===void 0?this.vaoCache[u]=this._createVao(l):a.setVertexState(d),a.useProgram(s),this._bindUniforms(n);let f=this._getTransformFeedback(c);o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,f),o.beginTransformFeedback(o.POINTS),i=i===null?t.count:i,Array.isArray(i)?(Bo(`WebGLBackend.compute(): The count parameter must be a single number, not an array.`),i=i[0]):i&&typeof i==`object`&&i.isIndirectStorageBufferAttribute&&(Bo(`WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute`),i=t.count),l[0].isStorageInstancedBufferAttribute?o.drawArraysInstanced(o.POINTS,0,1,i):o.drawArrays(o.POINTS,0,i),o.endTransformFeedback(),o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,null);for(let e=0;e<c.length;e++){let t=c[e];t.pbo&&this.has(t.pbo)&&this.textureUtils.copyBufferToTexture(t.transformBuffer,t.pbo),t.switchBuffers()}}finishCompute(e){let{state:t,gl:n}=this;this.discard=!1,t.disable(n.RASTERIZER_DISCARD),this.prepareTimestampBuffer(jo.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}_draw(e,t,n,r,i,a){if(e.isBatchedMesh){if(this.hasFeature(`WEBGL_multi_draw`)===!1){let{gl:n}=this,r=n.getUniformLocation(a,`nodeUniformDrawId`),i=e._multiDrawStarts,o=e._multiDrawCounts,s=e._multiDrawCount;for(let e=0;e<s;e++)n.uniform1ui(r,e),t.render(i[e],o[e])}else t.renderMultiDraw(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount)}else i>1?t.renderInstances(n,r,i):t.render(n,r)}draw(e){let{object:t,pipeline:n,material:r,context:i,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(n),{gl:s,state:c}=this,l=this.get(i),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinantAffine()<0;c.setMaterial(r,d,a),i.mrt!==null&&i.textures!==null&&c.setMRTBlending(i.textures,i.mrt,r),c.useProgram(o);let f=e.getAttributes(),p=this.get(f),m=p.vaoGPU;if(m===void 0){let e=this._getVaoKey(f);m=this.vaoCache[e],m===void 0&&(m=this._createVao(f),this.vaoCache[e]=m,p.vaoGPU=m)}let h=e.getIndex(),g=h===null?null:this.get(h).bufferGPU;c.setVertexState(m,g);let _=l.lastOcclusionObject;if(_!==t&&_!==void 0){if(_!==null&&_.occlusionTest===!0&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),t.occlusionTest===!0){let e=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}let v=this.bufferRenderer;t.isPoints?v.mode=s.POINTS:t.isLineSegments?v.mode=s.LINES:t.isLine?v.mode=s.LINE_STRIP:t.isLineLoop?v.mode=s.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),v.mode=s.LINES):v.mode=s.TRIANGLES;let{vertexCount:y,instanceCount:b}=u,{firstVertex:x}=u;if(v.object=t,h!==null){x*=h.array.BYTES_PER_ELEMENT;let e=this.get(h);v.index=h.count,v.type=e.type}else v.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let n=this.get(e.camera),r=e.camera.cameras,i=e.getBindingGroup(`cameraIndex`).bindings[0];if(n.indexesGPU===void 0||n.indexesGPU.length!==r.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let n=0,i=r.length;n<i;n++){let r=s.createBuffer();e[0]=n,s.bindBuffer(s.UNIFORM_BUFFER,r),s.bufferData(s.UNIFORM_BUFFER,e,s.STATIC_DRAW),t.push(r)}n.indexesGPU=t}let a=0;bindingsSearch:for(let t of e.getBindings())for(let e of t.bindings){if(e===i)break bindingsSearch;(e.isUniformsGroup||e.isUniformBuffer)&&a++}let l=this.renderer.getPixelRatio(),u=this._currentContext.renderTarget,d=this._isRenderCameraDepthArray(this._currentContext),f=this._currentContext.activeCubeFace;if(d){let e=this.get(u.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=u;for(let e=0,n=r.length;e<n;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1,!1);this.renderer._activeCubeFace=f,this._currentContext.activeCubeFace=f}}for(let i=0,u=r.length;i<u;i++){let u=r[i];if(t.layers.test(u.layers)){d&&(this.renderer._activeCubeFace=i,this._currentContext.activeCubeFace=i,this._setFramebuffer(this._currentContext));let r=u.viewport;if(r!==void 0){let t=r.x*l,n=r.y*l,i=r.width*l,a=r.height*l;c.viewport(Math.floor(t),Math.floor(e.context.height-a-n),Math.floor(i),Math.floor(a))}c.bindBufferBase(s.UNIFORM_BUFFER,a,n.indexesGPU[i]),this._draw(t,v,x,y,b,o)}this._currentContext.activeCubeFace=f,this.renderer._activeCubeFace=f}}else this._draw(t,v,x,y,b,o)}needsRenderUpdate(){return!1}getRenderCacheKey(){return``}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}updateSampler(){return``}createNodeBuilder(e,t){return new Gce(e,t)}createProgram(e){let t=this.gl,{stage:n,code:r}=e,i=n===`fragment`?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(i,r),t.compileShader(i),this.set(e,{shaderGPU:i})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let n=this.gl,r=e.pipeline,{fragmentProgram:i,vertexProgram:a}=r,o=n.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU;if(n.attachShader(o,s),n.attachShader(o,c),n.linkProgram(o),this.set(r,{programGPU:o,fragmentShader:s,vertexShader:c}),t!==null&&this.parallel){let i=new Promise(t=>{let i=this.parallel,a=()=>{n.getProgramParameter(o,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(a)};a()});t.push(i);return}this._completeCompile(e,r)}_handleSource(e,t){let n=e.split(`
|
|
4833
4833
|
`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){let i=e+1;r.push(`${i===t?`>`:` `} ${i}: ${n[e]}`)}return r.join(`
|
|
4834
4834
|
`)}_getShaderErrors(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+`
|
|
4835
4835
|
|
|
@@ -4841,7 +4841,7 @@ Program Info Log: `+i+`
|
|
|
4841
4841
|
`+a+`
|
|
4842
4842
|
`+o)}}else i!==``&&B(`WebGLProgram: Program Info Log:`,i)}}_completeCompile(e,t){let{state:n,gl:r}=this,{programGPU:i,fragmentShader:a,vertexShader:o}=this.get(t);r.getProgramParameter(i,r.LINK_STATUS)===!1&&this._logProgramError(i,a,o),n.useProgram(i);let s=e.getBindings();this._setupBindings(s,i),this.set(t,{programGPU:i,pipeline:i})}createComputePipeline(e,t){let{state:n,gl:r}=this,i={stage:`fragment`,code:`#version 300 es
|
|
4843
4843
|
precision highp float;
|
|
4844
|
-
void main() {}`};this.createProgram(i);let{computeProgram:a}=e,o=r.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU,l=a.transforms,u=[],d=[];for(let e=0;e<l.length;e++){let t=l[e];u.push(t.varyingName),d.push(t.attributeNode)}r.attachShader(o,s),r.attachShader(o,c),r.transformFeedbackVaryings(o,u,r.SEPARATE_ATTRIBS),r.linkProgram(o),r.getProgramParameter(o,r.LINK_STATUS)===!1&&this._logProgramError(o,s,c),n.useProgram(o),this._setupBindings(t,o);let f=a.attributes,p=[],m=[];for(let e=0;e<f.length;e++){let t=f[e].node.attribute;p.push(t),this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER)}for(let e=0;e<d.length;e++){let t=d[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER);let n=this.get(t);m.push(n)}this.set(e,{programGPU:o,transformBuffers:m,attributes:p})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let e=0,n=0;for(let r of t){this.set(r,{textures:n,uniformBuffers:e});for(let t of r.bindings)t.isUniformBuffer&&e++,t.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this;for(let n of e.bindings){let e=this.get(n);if(n.isUniformsGroup||n.isUniformBuffer){let r=n.buffer,i=e.bufferGPU;t.bindBuffer(t.UNIFORM_BUFFER,i);let a=n.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,i),a.length===0)t.bufferData(t.UNIFORM_BUFFER,r,t.DYNAMIC_DRAW);else{let e=Po(r),n=e?1:r.BYTES_PER_ELEMENT;for(let i=0,o=a.length;i<o;i++){let o=a[i],s=o.start*n,c=o.count*n,l=s*(e?r.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,l,r,s,c)}}this.set(n,e)}else if(n.isSampledTexture){let{textureGPU:t,glTextureType:r}=this.get(n.texture);e.textureGPU=t,e.glTextureType=r,this.set(n,e)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let n=this.get(e).bufferGPU,r=e.buffer,i=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,n),i.length===0)t.bufferData(t.UNIFORM_BUFFER,r,t.DYNAMIC_DRAW);else{let e=Po(r),n=e?1:r.BYTES_PER_ELEMENT,a=i[0].start;for(let o=0,s=i.length;o<s;o++){let s=i[o],c=i[o+1],l=s.start+s.count;if(c!==void 0&&c.start===l)continue;let u=a*n,d=(l-a)*n,f=u*(e?r.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,f,r,u,d),c!==void 0&&(a=c.start)}}}}createUniformBuffer(e){let t=this.get(e);if(t.bufferGPU===void 0){let n=this.gl,r=e.buffer;t.bufferGPU=n.createBuffer(),n.bindBuffer(n.UNIFORM_BUFFER,t.bufferGPU),n.bufferData(n.UNIFORM_BUFFER,r.byteLength,n.DYNAMIC_DRAW)}}destroyUniformBuffer(e){let t=this.get(e);this.gl.deleteBuffer(t.bufferGPU),this.delete(e)}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(WI).filter(t=>WI[t]===e),n=this.extensions;for(let e=0;e<t.length;e++)if(n.has(t[e]))return!0;return!1}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this.textureUtils.copyTextureToTexture(e,t,n,r,i,a)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}hasCompatibility(e){return e===Mo.TEXTURE_COMPARE||super.hasCompatibility(e)}initRenderTarget(e){let{gl:t,state:n}=this;this._setFramebuffer(e),n.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){let{gl:t,state:n}=this,r=null;if(e.textures!==null){let i=e.renderTarget,a=this.get(i),{samples:o,depthBuffer:s,stencilBuffer:c}=i,l=i.isCubeRenderTarget===!0,u=i.isRenderTarget3D===!0,d=i.depth>1,f=i.isXRRenderTarget===!0,p=f===!0&&i._hasExternalTextures===!0,m=a.msaaFrameBuffer,h=a.depthRenderbuffer,g=this.extensions.get(`WEBGL_multisampled_render_to_texture`),_=this.extensions.get(`OVR_multiview2`),v=this._useMultisampledExtension(i),y=vP(e),b;if(l?(a.cubeFramebuffers||={},b=a.cubeFramebuffers[y]):f&&p===!1?b=this._xrFramebuffer:(a.framebuffers||={},b=a.framebuffers[y]),b===void 0){b=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,b);let r=e.textures,s=[];if(l){a.cubeFramebuffers[y]=b;let{textureGPU:e}=this.get(r[0]),n=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,i)}else{a.framebuffers[y]=b;for(let n=0;n<r.length;n++){let a=r[n],s=this.get(a);s.renderTarget=e.renderTarget,s.cacheKey=y;let c=t.COLOR_ATTACHMENT0+n;if(i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,c,s.textureGPU,0,o,0,2);else if(u||d){let e=this.renderer._activeCubeFace,n=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,c,s.textureGPU,n,e)}else if(v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,0,o);else{let e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,e)}}}let f=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){let n=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(n,e,0,v),a.xrDepthRenderbuffer=n,s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,f,t.RENDERBUFFER,n)}else if(e.depthTexture!==null){s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let n=this.get(e.depthTexture);if(n.renderTarget=e.renderTarget,n.cacheKey=y,i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,f,n.textureGPU,0,o,0,2);else if(p&&v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0,o);else if(e.depthTexture.isArrayTexture){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,f,n.textureGPU,0,e)}else if(e.depthTexture.isCubeTexture){let e=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0)}a.depthInvalidationArray=s}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.renderer._activeCubeFace,i=this.get(e.depthTexture),a=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,a,i.textureGPU,0,r)}if((f||v||i.multiview)&&i._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.get(e.textures[0]);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,r.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0);let s=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){let e=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,e)}else{let n=this.get(e.depthTexture);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,s,n.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0)}}}if(o>0&&v===!1&&!i.multiview){if(m===void 0){let r=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let i=[],l=e.textures;for(let n=0;n<l.length;n++){i[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,i[n]),r.push(t.COLOR_ATTACHMENT0+n);let a=e.textures[n],s=this.get(a);t.renderbufferStorageMultisample(t.RENDERBUFFER,o,s.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,i[n])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=m,a.msaaRenderbuffers=i,s&&h===void 0){h=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(h,e,o),a.depthRenderbuffer=h;let n=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r.push(n)}a.invalidationArray=r}r=a.msaaFrameBuffer}else r=b;n.drawBuffers(e,b)}n.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t=``;for(let n=0;n<e.length;n++){let r=this.get(e[n]);t+=`:`+r.id}return t}_createVao(e){let{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let n=0;n<e.length;n++){let r=e[n],i=this.get(r);t.bindBuffer(t.ARRAY_BUFFER,i.bufferGPU),t.enableVertexAttribArray(n);let a,o;r.isInterleavedBufferAttribute===!0?(a=r.data.stride*i.bytesPerElement,o=r.offset*i.bytesPerElement):(a=0,o=0),i.isInteger?t.vertexAttribIPointer(n,r.itemSize,i.type,a,o):t.vertexAttribPointer(n,r.itemSize,i.type,r.normalized,a,o),r.isInstancedBufferAttribute&&!r.isInterleavedBufferAttribute?t.vertexAttribDivisor(n,r.meshPerAttribute):r.isInterleavedBufferAttribute&&r.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(n,r.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let t=``;for(let n=0;n<e.length;n++)t+=`:`+e[n].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;let{gl:r}=this;n=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n);for(let t=0;t<e.length;t++){let n=e[t];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,t,n.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){let n=this.gl,r=0,i=0;for(let a of e)for(let e of a.bindings)if(e.isUniformsGroup||e.isUniformBuffer){let i=r++,a=n.getUniformBlockIndex(t,e.name);n.uniformBlockBinding(t,a,i)}else if(e.isSampledTexture){let r=i++,a=n.getUniformLocation(t,e.name);n.uniform1i(a,r)}}_bindUniforms(e){let{gl:t,state:n}=this,r=0,i=0;for(let a of e)for(let e of a.bindings){let a=this.get(e);if(e.isUniformsGroup||e.isUniformBuffer){let e=r++;n.bindBufferBase(t.UNIFORM_BUFFER,e,a.bufferGPU)}else if(e.isSampledTexture){let e=i++;n.bindTexture(a.glTextureType,a.textureGPU,t.TEXTURE0+e)}}}_resolveRenderTarget(e){let{gl:t,state:n}=this,r=e.renderTarget;if(e.textures!==null&&r){let i=this.get(r);if(r.samples>0&&this._useMultisampledExtension(r)===!1){let a=i.framebuffers[e.getCacheKey()],o=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));let s=i.msaaFrameBuffer,c=i.msaaRenderbuffers,l=e.textures,u=l.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,s),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),u)for(let e=0;e<l.length;e++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);for(let n=0;n<l.length;n++){if(u){let{textureGPU:e}=this.get(l[n]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c[n]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}if(e.scissor){let{x:n,y:r,width:i,height:a}=e.scissorValue,s=e.height-a-r;t.blitFramebuffer(n,s,n+i,s+a,n,s,n+i,s+a,o,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o,t.NEAREST)}if(u)for(let e=0;e<l.length;e++){let{textureGPU:n}=this.get(l[e]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c[e]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,n,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,i.invalidationArray)}else if(r.resolveDepthBuffer===!1&&i.framebuffers){let r=i.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,r),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,i.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0||e.samples>0&&this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get(`WEBGL_lose_context`);e&&e.loseContext(),this.renderer.domElement.removeEventListener(`webglcontextlost`,this._onContextLost)}},qI={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`},JI=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},YI={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},XI={Store:`store`},ZI={Load:`load`,Clear:`clear`},QI={CCW:`ccw`,CW:`cw`},$I={None:`none`,Back:`back`},eL={Uint16:`uint16`,Uint32:`uint32`},Z={R8Unorm:`r8unorm`,R8Snorm:`r8snorm`,R8Uint:`r8uint`,R8Sint:`r8sint`,R16Uint:`r16uint`,R16Sint:`r16sint`,R16Float:`r16float`,RG8Unorm:`rg8unorm`,RG8Snorm:`rg8snorm`,RG8Uint:`rg8uint`,RG8Sint:`rg8sint`,R16Unorm:`r16unorm`,R16Snorm:`r16snorm`,R32Uint:`r32uint`,R32Sint:`r32sint`,R32Float:`r32float`,RG16Uint:`rg16uint`,RG16Sint:`rg16sint`,RG16Float:`rg16float`,RGBA8Unorm:`rgba8unorm`,RGBA8UnormSRGB:`rgba8unorm-srgb`,RGBA8Snorm:`rgba8snorm`,RGBA8Uint:`rgba8uint`,RGBA8Sint:`rgba8sint`,BGRA8Unorm:`bgra8unorm`,BGRA8UnormSRGB:`bgra8unorm-srgb`,RG16Unorm:`rg16unorm`,RG16Snorm:`rg16snorm`,RGB9E5UFloat:`rgb9e5ufloat`,RGB10A2Unorm:`rgb10a2unorm`,RG11B10UFloat:`rg11b10ufloat`,RG32Uint:`rg32uint`,RG32Sint:`rg32sint`,RG32Float:`rg32float`,RGBA16Uint:`rgba16uint`,RGBA16Sint:`rgba16sint`,RGBA16Float:`rgba16float`,RGBA16Unorm:`rgba16unorm`,RGBA16Snorm:`rgba16snorm`,RGBA32Uint:`rgba32uint`,RGBA32Sint:`rgba32sint`,RGBA32Float:`rgba32float`,Depth16Unorm:`depth16unorm`,Depth24Plus:`depth24plus`,Depth24PlusStencil8:`depth24plus-stencil8`,Depth32Float:`depth32float`,Depth32FloatStencil8:`depth32float-stencil8`,BC1RGBAUnorm:`bc1-rgba-unorm`,BC1RGBAUnormSRGB:`bc1-rgba-unorm-srgb`,BC2RGBAUnorm:`bc2-rgba-unorm`,BC2RGBAUnormSRGB:`bc2-rgba-unorm-srgb`,BC3RGBAUnorm:`bc3-rgba-unorm`,BC3RGBAUnormSRGB:`bc3-rgba-unorm-srgb`,BC4RUnorm:`bc4-r-unorm`,BC4RSnorm:`bc4-r-snorm`,BC5RGUnorm:`bc5-rg-unorm`,BC5RGSnorm:`bc5-rg-snorm`,BC6HRGBUFloat:`bc6h-rgb-ufloat`,BC6HRGBFloat:`bc6h-rgb-float`,BC7RGBAUnorm:`bc7-rgba-unorm`,BC7RGBAUnormSRGB:`bc7-rgba-unorm-srgb`,ETC2RGB8Unorm:`etc2-rgb8unorm`,ETC2RGB8UnormSRGB:`etc2-rgb8unorm-srgb`,ETC2RGB8A1Unorm:`etc2-rgb8a1unorm`,ETC2RGB8A1UnormSRGB:`etc2-rgb8a1unorm-srgb`,ETC2RGBA8Unorm:`etc2-rgba8unorm`,ETC2RGBA8UnormSRGB:`etc2-rgba8unorm-srgb`,EACR11Unorm:`eac-r11unorm`,EACR11Snorm:`eac-r11snorm`,EACRG11Unorm:`eac-rg11unorm`,EACRG11Snorm:`eac-rg11snorm`,ASTC4x4Unorm:`astc-4x4-unorm`,ASTC4x4UnormSRGB:`astc-4x4-unorm-srgb`,ASTC5x4Unorm:`astc-5x4-unorm`,ASTC5x4UnormSRGB:`astc-5x4-unorm-srgb`,ASTC5x5Unorm:`astc-5x5-unorm`,ASTC5x5UnormSRGB:`astc-5x5-unorm-srgb`,ASTC6x5Unorm:`astc-6x5-unorm`,ASTC6x5UnormSRGB:`astc-6x5-unorm-srgb`,ASTC6x6Unorm:`astc-6x6-unorm`,ASTC6x6UnormSRGB:`astc-6x6-unorm-srgb`,ASTC8x5Unorm:`astc-8x5-unorm`,ASTC8x5UnormSRGB:`astc-8x5-unorm-srgb`,ASTC8x6Unorm:`astc-8x6-unorm`,ASTC8x6UnormSRGB:`astc-8x6-unorm-srgb`,ASTC8x8Unorm:`astc-8x8-unorm`,ASTC8x8UnormSRGB:`astc-8x8-unorm-srgb`,ASTC10x5Unorm:`astc-10x5-unorm`,ASTC10x5UnormSRGB:`astc-10x5-unorm-srgb`,ASTC10x6Unorm:`astc-10x6-unorm`,ASTC10x6UnormSRGB:`astc-10x6-unorm-srgb`,ASTC10x8Unorm:`astc-10x8-unorm`,ASTC10x8UnormSRGB:`astc-10x8-unorm-srgb`,ASTC10x10Unorm:`astc-10x10-unorm`,ASTC10x10UnormSRGB:`astc-10x10-unorm-srgb`,ASTC12x10Unorm:`astc-12x10-unorm`,ASTC12x10UnormSRGB:`astc-12x10-unorm-srgb`,ASTC12x12Unorm:`astc-12x12-unorm`,ASTC12x12UnormSRGB:`astc-12x12-unorm-srgb`},tL={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},nL={Linear:`linear`,Nearest:`nearest`},rL={Zero:`zero`,One:`one`,Src:`src`,OneMinusSrc:`one-minus-src`,SrcAlpha:`src-alpha`,OneMinusSrcAlpha:`one-minus-src-alpha`,Dst:`dst`,OneMinusDst:`one-minus-dst`,DstAlpha:`dst-alpha`,OneMinusDstAlpha:`one-minus-dst-alpha`,SrcAlphaSaturated:`src-alpha-saturated`,Constant:`constant`,OneMinusConstant:`one-minus-constant`},iL={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},aL={None:0,All:15},oL={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},sL={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},cL={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},lL={NonFiltering:`non-filtering`,Comparison:`comparison`},uL={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},dL={TwoD:`2d`,ThreeD:`3d`},fL={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},rle={All:`all`},pL={Vertex:`vertex`,Instance:`instance`},mL={CoreFeaturesAndLimits:`core-features-and-limits`,DepthClipControl:`depth-clip-control`,Depth32FloatStencil8:`depth32float-stencil8`,TextureCompressionBC:`texture-compression-bc`,TextureCompressionBCSliced3D:`texture-compression-bc-sliced-3d`,TextureCompressionETC2:`texture-compression-etc2`,TextureCompressionASTC:`texture-compression-astc`,TextureCompressionASTCSliced3D:`texture-compression-astc-sliced-3d`,TimestampQuery:`timestamp-query`,IndirectFirstInstance:`indirect-first-instance`,ShaderF16:`shader-f16`,RG11B10UFloat:`rg11b10ufloat-renderable`,BGRA8UNormStorage:`bgra8unorm-storage`,Float32Filterable:`float32-filterable`,Float32Blendable:`float32-blendable`,ClipDistances:`clip-distances`,DualSourceBlending:`dual-source-blending`,Subgroups:`subgroups`,TextureFormatsTier1:`texture-formats-tier1`,TextureFormatsTier2:`texture-formats-tier2`},hL={"texture-compression-s3tc":`texture-compression-bc`,"texture-compression-etc1":`texture-compression-etc2`},ile=class extends wI{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},ale=class extends bI{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},ole=0,sle=class extends ale{constructor(e,t){super(`StorageBuffer_`+ole++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:kw.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},gL=[null],cle=class{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=e.depthTexture===null?e.stencil?this.backend.renderer.reversedDepthBuffer===!0?Z.Depth32FloatStencil8:Z.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?Z.Depth32Float:Z.Depth24Plus:this.getTextureFormatGPU(e.depthTexture)),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorFormats(e){return e.textures===null?[this.getPreferredCanvasFormat()]:e.textures.map(e=>this.getTextureFormatGPU(e))}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return qI.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return qI.LineList;if(e.isLine)return qI.LineStrip;if(e.isMesh)return qI.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.currentSamples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===1009)return Z.BGRA8Unorm;if(e===1016)return Z.RGBA16Float;throw Error(`THREE.WebGPUUtils: Unsupported output buffer type.`)}};function _L(e,t){gL[0]=t,e.queue.submit(gL),gL[0]=null}var vL=class{constructor(){this.label=``,this.layout=null,this.entries=[]}reset(){this.label=``,this.layout=null,this.entries.length=0}},yL=class{constructor(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}},bL=class{constructor(){this.label=``}reset(){this.label=``}},xL=class{constructor(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}},SL=class{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}},CL=class{constructor(){this.label=``,this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label=``,this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}},wL=class{constructor(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new lle,this.fragment=null}reset(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}},lle=class{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}},TL=class{constructor(){this.label=``,this.code=``,this.compilationHints=[]}reset(){this.label=``,this.code=``,this.compilationHints.length=0}},EL=class{constructor(){this.label=``,this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label=``,this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}},DL=class{constructor(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}reset(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}},OL=new vL,kL=new yL,AL=new bL,jL=new xL,ML=new CL,NL=new wL,PL=new SL,FL=new TL,IL=new EL,LL=new DL,ule=class extends GN{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:nL.Linear}),this.flipYSampler=e.createSampler({minFilter:nL.Nearest}),kL.size=4,kL.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(kL),kL.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),kL.size=4,kL.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(kL),kL.reset(),this.transferPipelines={},FL.label=`mipmap`,FL.code=`
|
|
4844
|
+
void main() {}`};this.createProgram(i);let{computeProgram:a}=e,o=r.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU,l=a.transforms,u=[],d=[];for(let e=0;e<l.length;e++){let t=l[e];u.push(t.varyingName),d.push(t.attributeNode)}r.attachShader(o,s),r.attachShader(o,c),r.transformFeedbackVaryings(o,u,r.SEPARATE_ATTRIBS),r.linkProgram(o),r.getProgramParameter(o,r.LINK_STATUS)===!1&&this._logProgramError(o,s,c),n.useProgram(o),this._setupBindings(t,o);let f=a.attributes,p=[],m=[];for(let e=0;e<f.length;e++){let t=f[e].node.attribute;p.push(t),this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER)}for(let e=0;e<d.length;e++){let t=d[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER);let n=this.get(t);m.push(n)}this.set(e,{programGPU:o,transformBuffers:m,attributes:p})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let e=0,n=0;for(let r of t){this.set(r,{textures:n,uniformBuffers:e});for(let t of r.bindings)t.isUniformBuffer&&e++,t.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this;for(let n of e.bindings){let e=this.get(n);if(n.isUniformsGroup||n.isUniformBuffer){let r=n.buffer,i=e.bufferGPU;t.bindBuffer(t.UNIFORM_BUFFER,i);let a=n.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,i),a.length===0)t.bufferData(t.UNIFORM_BUFFER,r,t.DYNAMIC_DRAW);else{let e=Po(r),n=e?1:r.BYTES_PER_ELEMENT;for(let i=0,o=a.length;i<o;i++){let o=a[i],s=o.start*n,c=o.count*n,l=s*(e?r.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,l,r,s,c)}}this.set(n,e)}else if(n.isSampledTexture){let{textureGPU:t,glTextureType:r}=this.get(n.texture);e.textureGPU=t,e.glTextureType=r,this.set(n,e)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let n=this.get(e).bufferGPU,r=e.buffer,i=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,n),i.length===0)t.bufferData(t.UNIFORM_BUFFER,r,t.DYNAMIC_DRAW);else{let e=Po(r),n=e?1:r.BYTES_PER_ELEMENT,a=i[0].start;for(let o=0,s=i.length;o<s;o++){let s=i[o],c=i[o+1],l=s.start+s.count;if(c!==void 0&&c.start===l)continue;let u=a*n,d=(l-a)*n,f=u*(e?r.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,f,r,u,d),c!==void 0&&(a=c.start)}}}}createUniformBuffer(e){let t=this.get(e);if(t.bufferGPU===void 0){let n=this.gl,r=e.buffer;t.bufferGPU=n.createBuffer(),n.bindBuffer(n.UNIFORM_BUFFER,t.bufferGPU),n.bufferData(n.UNIFORM_BUFFER,r.byteLength,n.DYNAMIC_DRAW)}}destroyUniformBuffer(e){let t=this.get(e);this.gl.deleteBuffer(t.bufferGPU),this.delete(e)}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(GI).filter(t=>GI[t]===e),n=this.extensions;for(let e=0;e<t.length;e++)if(n.has(t[e]))return!0;return!1}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this.textureUtils.copyTextureToTexture(e,t,n,r,i,a)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}hasCompatibility(e){return e===Mo.TEXTURE_COMPARE||super.hasCompatibility(e)}initRenderTarget(e){let{gl:t,state:n}=this;this._setFramebuffer(e),n.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){let{gl:t,state:n}=this,r=null;if(e.textures!==null){let i=e.renderTarget,a=this.get(i),{samples:o,depthBuffer:s,stencilBuffer:c}=i,l=i.isCubeRenderTarget===!0,u=i.isRenderTarget3D===!0,d=i.depth>1,f=i.isXRRenderTarget===!0,p=f===!0&&i._hasExternalTextures===!0,m=a.msaaFrameBuffer,h=a.depthRenderbuffer,g=this.extensions.get(`WEBGL_multisampled_render_to_texture`),_=this.extensions.get(`OVR_multiview2`),v=this._useMultisampledExtension(i),y=yP(e),b;if(l?(a.cubeFramebuffers||={},b=a.cubeFramebuffers[y]):f&&p===!1?b=this._xrFramebuffer:(a.framebuffers||={},b=a.framebuffers[y]),b===void 0){b=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,b);let r=e.textures,s=[];if(l){a.cubeFramebuffers[y]=b;let{textureGPU:e}=this.get(r[0]),n=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,i)}else{a.framebuffers[y]=b;for(let n=0;n<r.length;n++){let a=r[n],s=this.get(a);s.renderTarget=e.renderTarget,s.cacheKey=y;let c=t.COLOR_ATTACHMENT0+n;if(i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,c,s.textureGPU,0,o,0,2);else if(u||d){let e=this.renderer._activeCubeFace,n=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,c,s.textureGPU,n,e)}else if(v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,0,o);else{let e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,e)}}}let f=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){let n=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(n,e,0,v),a.xrDepthRenderbuffer=n,s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,f,t.RENDERBUFFER,n)}else if(e.depthTexture!==null){s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let n=this.get(e.depthTexture);if(n.renderTarget=e.renderTarget,n.cacheKey=y,i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,f,n.textureGPU,0,o,0,2);else if(p&&v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0,o);else if(e.depthTexture.isArrayTexture){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,f,n.textureGPU,0,e)}else if(e.depthTexture.isCubeTexture){let e=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0)}a.depthInvalidationArray=s}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.renderer._activeCubeFace,i=this.get(e.depthTexture),a=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,a,i.textureGPU,0,r)}if((f||v||i.multiview)&&i._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.get(e.textures[0]);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,r.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0);let s=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){let e=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,e)}else{let n=this.get(e.depthTexture);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,s,n.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0)}}}if(o>0&&v===!1&&!i.multiview){if(m===void 0){let r=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let i=[],l=e.textures;for(let n=0;n<l.length;n++){i[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,i[n]),r.push(t.COLOR_ATTACHMENT0+n);let a=e.textures[n],s=this.get(a);t.renderbufferStorageMultisample(t.RENDERBUFFER,o,s.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,i[n])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=m,a.msaaRenderbuffers=i,s&&h===void 0){h=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(h,e,o),a.depthRenderbuffer=h;let n=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r.push(n)}a.invalidationArray=r}r=a.msaaFrameBuffer}else r=b;n.drawBuffers(e,b)}n.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t=``;for(let n=0;n<e.length;n++){let r=this.get(e[n]);t+=`:`+r.id}return t}_createVao(e){let{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let n=0;n<e.length;n++){let r=e[n],i=this.get(r);t.bindBuffer(t.ARRAY_BUFFER,i.bufferGPU),t.enableVertexAttribArray(n);let a,o;r.isInterleavedBufferAttribute===!0?(a=r.data.stride*i.bytesPerElement,o=r.offset*i.bytesPerElement):(a=0,o=0),i.isInteger?t.vertexAttribIPointer(n,r.itemSize,i.type,a,o):t.vertexAttribPointer(n,r.itemSize,i.type,r.normalized,a,o),r.isInstancedBufferAttribute&&!r.isInterleavedBufferAttribute?t.vertexAttribDivisor(n,r.meshPerAttribute):r.isInterleavedBufferAttribute&&r.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(n,r.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let t=``;for(let n=0;n<e.length;n++)t+=`:`+e[n].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;let{gl:r}=this;n=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n);for(let t=0;t<e.length;t++){let n=e[t];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,t,n.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){let n=this.gl,r=0,i=0;for(let a of e)for(let e of a.bindings)if(e.isUniformsGroup||e.isUniformBuffer){let i=r++,a=n.getUniformBlockIndex(t,e.name);n.uniformBlockBinding(t,a,i)}else if(e.isSampledTexture){let r=i++,a=n.getUniformLocation(t,e.name);n.uniform1i(a,r)}}_bindUniforms(e){let{gl:t,state:n}=this,r=0,i=0;for(let a of e)for(let e of a.bindings){let a=this.get(e);if(e.isUniformsGroup||e.isUniformBuffer){let e=r++;n.bindBufferBase(t.UNIFORM_BUFFER,e,a.bufferGPU)}else if(e.isSampledTexture){let e=i++;n.bindTexture(a.glTextureType,a.textureGPU,t.TEXTURE0+e)}}}_resolveRenderTarget(e){let{gl:t,state:n}=this,r=e.renderTarget;if(e.textures!==null&&r){let i=this.get(r);if(r.samples>0&&this._useMultisampledExtension(r)===!1){let a=i.framebuffers[e.getCacheKey()],o=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));let s=i.msaaFrameBuffer,c=i.msaaRenderbuffers,l=e.textures,u=l.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,s),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),u)for(let e=0;e<l.length;e++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);for(let n=0;n<l.length;n++){if(u){let{textureGPU:e}=this.get(l[n]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c[n]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}if(e.scissor){let{x:n,y:r,width:i,height:a}=e.scissorValue,s=e.height-a-r;t.blitFramebuffer(n,s,n+i,s+a,n,s,n+i,s+a,o,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o,t.NEAREST)}if(u)for(let e=0;e<l.length;e++){let{textureGPU:n}=this.get(l[e]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c[e]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,n,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,i.invalidationArray)}else if(r.resolveDepthBuffer===!1&&i.framebuffers){let r=i.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,r),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,i.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0||e.samples>0&&this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get(`WEBGL_lose_context`);e&&e.loseContext(),this.renderer.domElement.removeEventListener(`webglcontextlost`,this._onContextLost)}},JI={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`},YI=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},XI={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},ZI={Store:`store`},QI={Load:`load`,Clear:`clear`},$I={CCW:`ccw`,CW:`cw`},eL={None:`none`,Back:`back`},tL={Uint16:`uint16`,Uint32:`uint32`},Z={R8Unorm:`r8unorm`,R8Snorm:`r8snorm`,R8Uint:`r8uint`,R8Sint:`r8sint`,R16Uint:`r16uint`,R16Sint:`r16sint`,R16Float:`r16float`,RG8Unorm:`rg8unorm`,RG8Snorm:`rg8snorm`,RG8Uint:`rg8uint`,RG8Sint:`rg8sint`,R16Unorm:`r16unorm`,R16Snorm:`r16snorm`,R32Uint:`r32uint`,R32Sint:`r32sint`,R32Float:`r32float`,RG16Uint:`rg16uint`,RG16Sint:`rg16sint`,RG16Float:`rg16float`,RGBA8Unorm:`rgba8unorm`,RGBA8UnormSRGB:`rgba8unorm-srgb`,RGBA8Snorm:`rgba8snorm`,RGBA8Uint:`rgba8uint`,RGBA8Sint:`rgba8sint`,BGRA8Unorm:`bgra8unorm`,BGRA8UnormSRGB:`bgra8unorm-srgb`,RG16Unorm:`rg16unorm`,RG16Snorm:`rg16snorm`,RGB9E5UFloat:`rgb9e5ufloat`,RGB10A2Unorm:`rgb10a2unorm`,RG11B10UFloat:`rg11b10ufloat`,RG32Uint:`rg32uint`,RG32Sint:`rg32sint`,RG32Float:`rg32float`,RGBA16Uint:`rgba16uint`,RGBA16Sint:`rgba16sint`,RGBA16Float:`rgba16float`,RGBA16Unorm:`rgba16unorm`,RGBA16Snorm:`rgba16snorm`,RGBA32Uint:`rgba32uint`,RGBA32Sint:`rgba32sint`,RGBA32Float:`rgba32float`,Depth16Unorm:`depth16unorm`,Depth24Plus:`depth24plus`,Depth24PlusStencil8:`depth24plus-stencil8`,Depth32Float:`depth32float`,Depth32FloatStencil8:`depth32float-stencil8`,BC1RGBAUnorm:`bc1-rgba-unorm`,BC1RGBAUnormSRGB:`bc1-rgba-unorm-srgb`,BC2RGBAUnorm:`bc2-rgba-unorm`,BC2RGBAUnormSRGB:`bc2-rgba-unorm-srgb`,BC3RGBAUnorm:`bc3-rgba-unorm`,BC3RGBAUnormSRGB:`bc3-rgba-unorm-srgb`,BC4RUnorm:`bc4-r-unorm`,BC4RSnorm:`bc4-r-snorm`,BC5RGUnorm:`bc5-rg-unorm`,BC5RGSnorm:`bc5-rg-snorm`,BC6HRGBUFloat:`bc6h-rgb-ufloat`,BC6HRGBFloat:`bc6h-rgb-float`,BC7RGBAUnorm:`bc7-rgba-unorm`,BC7RGBAUnormSRGB:`bc7-rgba-unorm-srgb`,ETC2RGB8Unorm:`etc2-rgb8unorm`,ETC2RGB8UnormSRGB:`etc2-rgb8unorm-srgb`,ETC2RGB8A1Unorm:`etc2-rgb8a1unorm`,ETC2RGB8A1UnormSRGB:`etc2-rgb8a1unorm-srgb`,ETC2RGBA8Unorm:`etc2-rgba8unorm`,ETC2RGBA8UnormSRGB:`etc2-rgba8unorm-srgb`,EACR11Unorm:`eac-r11unorm`,EACR11Snorm:`eac-r11snorm`,EACRG11Unorm:`eac-rg11unorm`,EACRG11Snorm:`eac-rg11snorm`,ASTC4x4Unorm:`astc-4x4-unorm`,ASTC4x4UnormSRGB:`astc-4x4-unorm-srgb`,ASTC5x4Unorm:`astc-5x4-unorm`,ASTC5x4UnormSRGB:`astc-5x4-unorm-srgb`,ASTC5x5Unorm:`astc-5x5-unorm`,ASTC5x5UnormSRGB:`astc-5x5-unorm-srgb`,ASTC6x5Unorm:`astc-6x5-unorm`,ASTC6x5UnormSRGB:`astc-6x5-unorm-srgb`,ASTC6x6Unorm:`astc-6x6-unorm`,ASTC6x6UnormSRGB:`astc-6x6-unorm-srgb`,ASTC8x5Unorm:`astc-8x5-unorm`,ASTC8x5UnormSRGB:`astc-8x5-unorm-srgb`,ASTC8x6Unorm:`astc-8x6-unorm`,ASTC8x6UnormSRGB:`astc-8x6-unorm-srgb`,ASTC8x8Unorm:`astc-8x8-unorm`,ASTC8x8UnormSRGB:`astc-8x8-unorm-srgb`,ASTC10x5Unorm:`astc-10x5-unorm`,ASTC10x5UnormSRGB:`astc-10x5-unorm-srgb`,ASTC10x6Unorm:`astc-10x6-unorm`,ASTC10x6UnormSRGB:`astc-10x6-unorm-srgb`,ASTC10x8Unorm:`astc-10x8-unorm`,ASTC10x8UnormSRGB:`astc-10x8-unorm-srgb`,ASTC10x10Unorm:`astc-10x10-unorm`,ASTC10x10UnormSRGB:`astc-10x10-unorm-srgb`,ASTC12x10Unorm:`astc-12x10-unorm`,ASTC12x10UnormSRGB:`astc-12x10-unorm-srgb`,ASTC12x12Unorm:`astc-12x12-unorm`,ASTC12x12UnormSRGB:`astc-12x12-unorm-srgb`},nL={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},rL={Linear:`linear`,Nearest:`nearest`},iL={Zero:`zero`,One:`one`,Src:`src`,OneMinusSrc:`one-minus-src`,SrcAlpha:`src-alpha`,OneMinusSrcAlpha:`one-minus-src-alpha`,Dst:`dst`,OneMinusDst:`one-minus-dst`,DstAlpha:`dst-alpha`,OneMinusDstAlpha:`one-minus-dst-alpha`,SrcAlphaSaturated:`src-alpha-saturated`,Constant:`constant`,OneMinusConstant:`one-minus-constant`},aL={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},oL={None:0,All:15},sL={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},cL={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},lL={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},uL={NonFiltering:`non-filtering`,Comparison:`comparison`},dL={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},fL={TwoD:`2d`,ThreeD:`3d`},pL={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},nle={All:`all`},mL={Vertex:`vertex`,Instance:`instance`},hL={CoreFeaturesAndLimits:`core-features-and-limits`,DepthClipControl:`depth-clip-control`,Depth32FloatStencil8:`depth32float-stencil8`,TextureCompressionBC:`texture-compression-bc`,TextureCompressionBCSliced3D:`texture-compression-bc-sliced-3d`,TextureCompressionETC2:`texture-compression-etc2`,TextureCompressionASTC:`texture-compression-astc`,TextureCompressionASTCSliced3D:`texture-compression-astc-sliced-3d`,TimestampQuery:`timestamp-query`,IndirectFirstInstance:`indirect-first-instance`,ShaderF16:`shader-f16`,RG11B10UFloat:`rg11b10ufloat-renderable`,BGRA8UNormStorage:`bgra8unorm-storage`,Float32Filterable:`float32-filterable`,Float32Blendable:`float32-blendable`,ClipDistances:`clip-distances`,DualSourceBlending:`dual-source-blending`,Subgroups:`subgroups`,TextureFormatsTier1:`texture-formats-tier1`,TextureFormatsTier2:`texture-formats-tier2`},gL={"texture-compression-s3tc":`texture-compression-bc`,"texture-compression-etc1":`texture-compression-etc2`},rle=class extends TI{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},ile=class extends xI{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},ale=0,ole=class extends ile{constructor(e,t){super(`StorageBuffer_`+ale++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Aw.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},_L=[null],sle=class{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=e.depthTexture===null?e.stencil?this.backend.renderer.reversedDepthBuffer===!0?Z.Depth32FloatStencil8:Z.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?Z.Depth32Float:Z.Depth24Plus:this.getTextureFormatGPU(e.depthTexture)),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorFormats(e){return e.textures===null?[this.getPreferredCanvasFormat()]:e.textures.map(e=>this.getTextureFormatGPU(e))}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return JI.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return JI.LineList;if(e.isLine)return JI.LineStrip;if(e.isMesh)return JI.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.currentSamples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===1009)return Z.BGRA8Unorm;if(e===1016)return Z.RGBA16Float;throw Error(`THREE.WebGPUUtils: Unsupported output buffer type.`)}};function vL(e,t){_L[0]=t,e.queue.submit(_L),_L[0]=null}var yL=class{constructor(){this.label=``,this.layout=null,this.entries=[]}reset(){this.label=``,this.layout=null,this.entries.length=0}},bL=class{constructor(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}},xL=class{constructor(){this.label=``}reset(){this.label=``}},SL=class{constructor(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}},CL=class{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}},wL=class{constructor(){this.label=``,this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label=``,this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}},TL=class{constructor(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new cle,this.fragment=null}reset(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}},cle=class{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}},EL=class{constructor(){this.label=``,this.code=``,this.compilationHints=[]}reset(){this.label=``,this.code=``,this.compilationHints.length=0}},DL=class{constructor(){this.label=``,this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label=``,this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}},OL=class{constructor(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}reset(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}},kL=new yL,AL=new bL,jL=new xL,ML=new SL,NL=new wL,PL=new TL,FL=new CL,IL=new EL,LL=new DL,RL=new OL,lle=class extends KN{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:rL.Linear}),this.flipYSampler=e.createSampler({minFilter:rL.Nearest}),AL.size=4,AL.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(AL),AL.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),AL.size=4,AL.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(AL),AL.reset(),this.transferPipelines={},IL.label=`mipmap`,IL.code=`
|
|
4845
4845
|
struct VarysStruct {
|
|
4846
4846
|
@builtin( position ) Position: vec4f,
|
|
4847
4847
|
@location( 0 ) vTex : vec2f,
|
|
@@ -4915,7 +4915,7 @@ fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
|
|
|
4915
4915
|
return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );
|
|
4916
4916
|
|
|
4917
4917
|
}
|
|
4918
|
-
`,this.mipmapShaderModule=e.createShaderModule(FL),FL.reset()}getTransferPipeline(e,t){t||=`2d-array`;let n=`${e}-${t}`,r=this.transferPipelines[n];return r===void 0&&(NL.label=`mipmap-${e}-${t}`,NL.vertex={module:this.mipmapShaderModule},NL.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace(`-`,`_`)}`,targets:[{format:e}]},NL.layout=`auto`,r=this.device.createRenderPipeline(NL),NL.reset(),this.transferPipelines[n]=r),r}flipY(e,t,n=0){let r=t.format,{width:i,height:a}=t.size;IL.size.width=i,IL.size.height=a,IL.format=r,IL.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let o=this.device.createTexture(IL);IL.reset();let s=this.getTransferPipeline(r,e.textureBindingViewDimension),c=this.getTransferPipeline(r,o.textureBindingViewDimension),l=this.device.createCommandEncoder(AL),u=(e,t,n,r,i,a)=>{let o=e.getBindGroupLayout(0);LL.dimension=t.textureBindingViewDimension||`2d-array`,LL.mipLevelCount=1;let s=t.createView(LL);LL.reset(),OL.layout=o,OL.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:s},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}});let c=this.device.createBindGroup(OL);OL.reset(),LL.dimension=`2d`,LL.mipLevelCount=1,LL.baseArrayLayer=i,LL.arrayLayerCount=1;let u=r.createView(LL);LL.reset(),PL.view=u,PL.loadOp=ZI.Clear,PL.storeOp=XI.Store,ML.colorAttachments.push(PL);let d=l.beginRenderPass(ML);ML.reset(),PL.reset(),d.setPipeline(e),d.setBindGroup(0,c),d.draw(3,1,0,n),d.end()};u(s,e,n,o,0,!1),u(c,o,0,e,n,!0),_L(this.device,l.finish()),o.destroy()}generateMipmaps(e,t=null){let n=this.get(e),r=n.layers||this._mipmapCreateBundles(e),i=t;i===null&&(AL.label=`mipmapEncoder`,i=this.device.createCommandEncoder(AL),AL.reset()),this._mipmapRunBundles(i,r),t===null&&_L(this.device,i.finish()),n.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||`2d-array`,n=this.getTransferPipeline(e.format,t),r=n.getBindGroupLayout(0),i=[];for(let a=1;a<e.mipLevelCount;a++)for(let o=0;o<e.depthOrArrayLayers;o++){LL.dimension=t,LL.baseMipLevel=a-1,LL.mipLevelCount=1;let s=e.createView(LL);LL.reset(),OL.layout=r,OL.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:s},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});let c=this.device.createBindGroup(OL);OL.reset(),LL.dimension=`2d`,LL.baseMipLevel=a,LL.mipLevelCount=1,LL.baseArrayLayer=o,LL.arrayLayerCount=1;let l=e.createView(LL);LL.reset();let u=new SL;u.view=l,u.loadOp=ZI.Clear,u.storeOp=XI.Store;let d=new CL;d.colorAttachments.push(u),jL.colorFormats=[e.format];let f=this.device.createRenderBundleEncoder(jL);jL.reset(),f.setPipeline(n),f.setBindGroup(0,c),f.draw(3,1,0,o),i.push({renderBundles:[f.finish()],passDescriptor:d})}return i}_mipmapRunBundles(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=e.beginRenderPass(n.passDescriptor);i.executeBundles(n.renderBundles),i.end()}}},dle=class{constructor(){this.label=``,this.addressModeU=`clamp-to-edge`,this.addressModeV=`clamp-to-edge`,this.addressModeW=`clamp-to-edge`,this.magFilter=`nearest`,this.minFilter=`nearest`,this.mipmapFilter=`nearest`,this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}reset(){this.label=``,this.addressModeU=`clamp-to-edge`,this.addressModeV=`clamp-to-edge`,this.addressModeW=`clamp-to-edge`,this.magFilter=`nearest`,this.minFilter=`nearest`,this.mipmapFilter=`nearest`,this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}},RL=class{constructor(){this.texture=null,this.mipLevel=0,this.origin={x:0,y:0,z:0},this.aspect=`all`}reset(){this.texture=null,this.mipLevel=0,this.origin.x=0,this.origin.y=0,this.origin.z=0,this.aspect=`all`}},fle=class{constructor(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},ple=class{constructor(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},mle=class{constructor(){this.source=null,this.origin={x:0,y:0},this.flipY=!1}reset(){this.source=null,this.origin.x=0,this.origin.y=0,this.flipY=!1}},hle=class extends RL{constructor(){super(),this.colorSpace=`srgb`,this.premultipliedAlpha=!1}reset(){super.reset(),this.colorSpace=`srgb`,this.premultipliedAlpha=!1}},zL=class{constructor(){this.width=0,this.height=1,this.depthOrArrayLayers=1}reset(){this.width=0,this.height=1,this.depthOrArrayLayers=1}},BL=new yL,gle=new bL,VL=new dle,HL=new RL,UL=new fle,WL=new ple,GL=new mle,KL=new hle,qL=new EL,JL=new zL,_le={512:`never`,513:`less`,514:`equal`,515:`less-equal`,516:`greater`,518:`greater-equal`,519:`always`,517:`not-equal`},vle=[0,1,3,2,4,5];function YL(e,t,n,r,i,a,o,s,c,l){HL.texture=t,HL.mipLevel=n,HL.origin.z=r,WL.offset=r*a,WL.bytesPerRow=o,WL.rowsPerImage=s,JL.width=c,JL.height=l,e.queue.writeTexture(HL,i.data,WL,JL),HL.reset(),WL.reset(),JL.reset()}var yle=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,n=e.texture,r=e.textureNode,i=n.minFilter+`-`+n.magFilter+`-`+n.wrapS+`-`+n.wrapT+`-`+(n.wrapR||`0`)+`-`+n.anisotropy+`-`+ +(n.isDepthTexture===!0)+`-`+(n.compareFunction!==null&&r.compareNode!==null?n.compareFunction:0),a=this._samplerCache.get(i);if(a===void 0){VL.addressModeU=this._convertAddressMode(n.wrapS),VL.addressModeV=this._convertAddressMode(n.wrapT),VL.addressModeW=this._convertAddressMode(n.wrapR),VL.magFilter=this._convertFilterMode(n.magFilter),VL.minFilter=this._convertFilterMode(n.minFilter),VL.mipmapFilter=this._convertMipmapFilterMode(n.minFilter),n.isDepthTexture&&(n.compareFunction===null||r.compareNode===null)&&(VL.magFilter=nL.Nearest,VL.minFilter=nL.Nearest,VL.mipmapFilter=nL.Nearest),VL.magFilter===nL.Linear&&VL.minFilter===nL.Linear&&VL.mipmapFilter===nL.Linear&&(VL.maxAnisotropy=n.anisotropy),n.isDepthTexture&&n.compareFunction!==null&&r.compareNode!==null&&t.hasCompatibility(Mo.TEXTURE_COMPARE)&&(VL.compare=_le[n.compareFunction]);let e=t.device.createSampler(VL);VL.reset(),a={sampler:e,usedTimes:0},this._samplerCache.set(i,a)}let o=t.get(e);return o.sampler!==a.sampler&&(this._releaseSampler(o),o.samplerKey=i,o.sampler=a.sampler,a.usedTimes++),i}destroySampler(e){this._releaseSampler(this.backend.get(e))}_releaseSampler(e){if(e.sampler!==void 0){let t=this._samplerCache.get(e.samplerKey);t.usedTimes--,t.usedTimes===0&&this._samplerCache.delete(e.samplerKey),e.sampler=void 0,e.samplerKey=void 0}}createDefaultTexture(e){let t,n=XL(e,this.backend.device);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(n):this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){let n=this.backend,r=n.get(e);if(r.initialized){if(r.externalTexture===!0)return;throw Error(`THREE.WebGPUTextureUtils: Texture already initialized.`)}if(e.isExternalTexture){r.texture=e.sourceTexture,r.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);let{width:i,height:a,depth:o,levels:s}=t;e.isFramebufferTexture&&(t.format=t.renderTarget?this.backend.utils.getCurrentColorFormat(t.renderTarget):this.backend.utils.getPreferredCanvasFormat());let c=this._getDimension(e),l=e.internalFormat||t.format||XL(e,n.device);r.format=l;let{samples:u,primarySamples:d,isMSAA:f}=n.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(p|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&l!==Z.RGB9E5UFloat&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m=new EL;if(m.label=e.name,m.size.width=i,m.size.height=a,m.size.depthOrArrayLayers=o,m.mipLevelCount=s,m.sampleCount=d,m.dimension=c,m.format=l,m.usage=p,l===void 0){B(`WebGPURenderer: Texture format not supported.`),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=fL.Cube);try{r.texture=n.device.createTexture(m)}catch{B(`WebGPURenderer: Failed to create texture with descriptor:`,m),this.createDefaultTexture(e);return}if(f){let e=Object.assign({},m);e.label+=`-msaa`,e.sampleCount=u,e.mipLevelCount=1,r.msaaTexture=n.device.createTexture(e)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e,t=!1){let n=this.backend,r=n.get(e);r.texture!==void 0&&t===!1&&e.isExternalTexture!==!0&&r.texture.destroy(),r.msaaTexture!==void 0&&r.msaaTexture.destroy(),n.delete(e)}generateMipmaps(e,t=null){let n=this.backend.get(e);this._generateMipmaps(n.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:n,height:r}=e.getDrawingBufferSize(),i=e.renderer.currentSamples,a=t.colorTexture,o=e.get(a);if(a.width===n&&a.height===r&&a.samples===i)return o.texture;let s=o.texture;return s&&s.destroy(),qL.label=`colorBuffer`,qL.size.width=n,qL.size.height=r,qL.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),qL.format=e.utils.getPreferredCanvasFormat(),qL.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,s=e.device.createTexture(qL),qL.reset(),a.source.width=n,a.source.height=r,a.samples=i,o.texture=s,s}getDepthBuffer(e=!0,t=!1){let n=this.backend,r=n.renderer.getCanvasTarget(),{width:i,height:a}=n.getDrawingBufferSize(),o=n.renderer.currentSamples,s=r.depthTexture;if(s.width===i&&s.height===a&&s.samples===o&&s.depth===e&&s.stencil===t)return n.get(s).texture;let c=n.get(s).texture,l,u;if(t?(l=va,u=n.renderer.reversedDepthBuffer===!0?sa:da):e&&(l=_a,u=n.renderer.reversedDepthBuffer===!0?sa:oa),c!==void 0){if(s.image.width===i&&s.image.height===a&&s.format===l&&s.type===u&&s.samples===o)return c;this.destroyTexture(s)}return s.name=`depthBuffer`,s.format=l,s.type=u,s.image.width=i,s.image.height=a,s.samples=o,this.createTexture(s,{width:i,height:a}),n.get(s).texture}updateTexture(e,t){let n=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:i}=n;if(!(e.isRenderTargetTexture||i===void 0)){if(e.isDataTexture){if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyBufferToTexture(a,n.texture,i,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,n.texture,i,0,e.flipY)}else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture){if(e.layerUpdates&&e.layerUpdates.size>0){for(let r of e.layerUpdates)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r);e.clearLayerUpdates()}else for(let r=0;r<t.image.depth;r++)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r)}else if(e.isCompressedTexture||e.isCompressedArrayTexture)e.isCompressedArrayTexture&&e.layerUpdates.size>0?(this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,i);else if(e.isHTMLTexture){let t=this.backend.device,r=this.backend.renderer.domElement,a=e.image;if(typeof t.queue.copyElementImageToTexture!=`function`)return;if(!n.hasPaintCallback){n.hasPaintCallback=!0,r.requestPaint();return}let o=i.size.width,s=i.size.height;t.queue.copyElementImageToTexture.length===2?t.queue.copyElementImageToTexture({source:a},{destination:{texture:n.texture},width:o,height:s}):t.queue.copyElementImageToTexture(a,o,s,{texture:n.texture}),e.flipY&&this._flipY(n.texture,i)}else if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyImageToTexture(a,n.texture,i,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,n.texture,i,0,e.flipY,e.premultiplyAlpha);n.version=e.version}}async copyTextureToBuffer(e,t,n,r,i,a){let o=this.backend.device,s=this.backend.get(e),c=s.texture,l=s.textureDescriptorGPU.format,u=this._getBytesPerTexel(l),d=r*u;d=Math.ceil(d/256)*256,BL.size=(i-1)*d+r*u,BL.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let f=o.createBuffer(BL);BL.reset();let p=o.createCommandEncoder(gle);HL.texture=c,HL.origin.x=t,HL.origin.y=n,HL.origin.z=a,UL.buffer=f,UL.bytesPerRow=d,JL.width=r,JL.height=i,p.copyTextureToBuffer(HL,UL,JL),HL.reset(),UL.reset(),JL.reset();let m=this._getTypedArrayType(l);_L(o,p.finish()),await f.mapAsync(GPUMapMode.READ);let h=f.getMappedRange().slice();return f.destroy(),new m(h)}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let n=new Is;n.minFilter=Yi,n.magFilter=Yi,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){let n=new wu;n.minFilter=Yi,n.magFilter=Yi,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){let r=e.images,i=e.mipmaps;for(let a=0;a<6;a++){let o=r[a],s=e.flipY===!0?vle[a]:a;o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,e.flipY):this._copyImageToTexture(o,t,n,s,e.flipY,e.premultiplyAlpha);for(let r=0;r<i.length;r++){let o=i[r].images[a];o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,e.flipY,0,r+1):this._copyImageToTexture(o,t,n,s,e.flipY,e.premultiplyAlpha,r+1)}}}_copyImageToTexture(e,t,n,r,i,a,o=0){let s=this.backend.device,c=o>0?e.width:n.size.width,l=o>0?e.height:n.size.height;GL.source=e,GL.flipY=i,KL.texture=t,KL.mipLevel=o,KL.origin.z=r,KL.premultipliedAlpha=a,JL.width=c,JL.height=l;try{s.queue.copyExternalImageToTexture(GL,KL,JL)}catch{}finally{GL.reset(),KL.reset(),JL.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new ule(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,i,a=0,o=0){let s=this.backend.device,c=e.data,l=this._getBytesPerTexel(n.format),u=e.width*l;HL.texture=t,HL.mipLevel=o,HL.origin.z=r,WL.offset=e.width*e.height*l*a,WL.bytesPerRow=u,JL.width=e.width,JL.height=e.height,s.queue.writeTexture(HL,c,WL,JL),HL.reset(),WL.reset(),JL.reset(),i===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n,r=null){let i=this.backend.device,a=this._getBlockData(n.format),o=n.size.depthOrArrayLayers>1,s=r&&r.size>0?r:null;for(let r=0;r<e.length;r++){let c=e[r],l=c.width,u=c.height,d=o?n.size.depthOrArrayLayers:1,f=Math.ceil(l/a.width)*a.byteLength,p=Math.ceil(u/a.height),m=f*p,h=Math.ceil(l/a.width)*a.width,g=p*a.height;if(s!==null)for(let e of s)YL(i,t,r,e,c,m,f,p,h,g);else for(let e=0;e<d;e++)YL(i,t,r,e,c,m,f,p,h,g)}}_getBlockData(e){if(e===Z.BC1RGBAUnorm||e===Z.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===Z.BC2RGBAUnorm||e===Z.BC2RGBAUnormSRGB||e===Z.BC3RGBAUnorm||e===Z.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.BC4RUnorm||e===Z.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===Z.BC5RGUnorm||e===Z.BC5RGSnorm||e===Z.BC6HRGBUFloat||e===Z.BC6HRGBFloat||e===Z.BC7RGBAUnorm||e===Z.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.ETC2RGB8Unorm||e===Z.ETC2RGB8UnormSRGB||e===Z.ETC2RGB8A1Unorm||e===Z.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===Z.ETC2RGBA8Unorm||e===Z.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.EACR11Unorm||e===Z.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===Z.EACRG11Unorm||e===Z.EACRG11Snorm||e===Z.ASTC4x4Unorm||e===Z.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.ASTC5x4Unorm||e===Z.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===Z.ASTC5x5Unorm||e===Z.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===Z.ASTC6x5Unorm||e===Z.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===Z.ASTC6x6Unorm||e===Z.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===Z.ASTC8x5Unorm||e===Z.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===Z.ASTC8x6Unorm||e===Z.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===Z.ASTC8x8Unorm||e===Z.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===Z.ASTC10x5Unorm||e===Z.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===Z.ASTC10x6Unorm||e===Z.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===Z.ASTC10x8Unorm||e===Z.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===Z.ASTC10x10Unorm||e===Z.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===Z.ASTC12x10Unorm||e===Z.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===Z.ASTC12x12Unorm||e===Z.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=tL.ClampToEdge;return e===1e3?t=tL.Repeat:e===1002&&(t=tL.MirrorRepeat),t}_convertFilterMode(e){let t=nL.Linear;return(e===1003||e===1004||e===1005)&&(t=nL.Nearest),t}_convertMipmapFilterMode(e){return e===1005||e===1008?nL.Linear:nL.Nearest}_getBytesPerTexel(e){if(e===Z.R8Unorm||e===Z.R8Snorm||e===Z.R8Uint||e===Z.R8Sint)return 1;if(e===Z.R16Uint||e===Z.R16Sint||e===Z.R16Float||e===Z.RG8Unorm||e===Z.RG8Snorm||e===Z.RG8Uint||e===Z.RG8Sint||e===Z.R16Unorm||e===Z.R16Snorm)return 2;if(e===Z.R32Uint||e===Z.R32Sint||e===Z.R32Float||e===Z.RG16Uint||e===Z.RG16Sint||e===Z.RG16Float||e===Z.RGBA8Unorm||e===Z.RGBA8UnormSRGB||e===Z.RGBA8Snorm||e===Z.RGBA8Uint||e===Z.RGBA8Sint||e===Z.BGRA8Unorm||e===Z.BGRA8UnormSRGB||e===Z.RG16Unorm||e===Z.RG16Snorm||e===Z.RGB9E5UFloat||e===Z.RGB10A2Unorm||e===Z.RG11B10UFloat||e===Z.Depth32Float||e===Z.Depth24Plus||e===Z.Depth24PlusStencil8||e===Z.Depth32FloatStencil8)return 4;if(e===Z.RG32Uint||e===Z.RG32Sint||e===Z.RG32Float||e===Z.RGBA16Uint||e===Z.RGBA16Sint||e===Z.RGBA16Float||e===Z.RGBA16Unorm||e===Z.RGBA16Snorm)return 8;if(e===Z.RGBA32Uint||e===Z.RGBA32Sint||e===Z.RGBA32Float)return 16}_getTypedArrayType(e){if(e===Z.R8Uint)return Uint8Array;if(e===Z.R8Sint)return Int8Array;if(e===Z.R8Unorm)return Uint8Array;if(e===Z.R8Snorm)return Int8Array;if(e===Z.RG8Uint)return Uint8Array;if(e===Z.RG8Sint)return Int8Array;if(e===Z.RG8Unorm)return Uint8Array;if(e===Z.RG8Snorm)return Int8Array;if(e===Z.RGBA8Uint)return Uint8Array;if(e===Z.RGBA8Sint)return Int8Array;if(e===Z.RGBA8Unorm||e===Z.RGBA8UnormSRGB)return Uint8Array;if(e===Z.RGBA8Snorm)return Int8Array;if(e===Z.R16Uint)return Uint16Array;if(e===Z.R16Sint)return Int16Array;if(e===Z.RG16Uint)return Uint16Array;if(e===Z.RG16Sint)return Int16Array;if(e===Z.RGBA16Uint)return Uint16Array;if(e===Z.RGBA16Sint)return Int16Array;if(e===Z.R16Float||e===Z.RG16Float||e===Z.RGBA16Float||e===Z.R16Unorm)return Uint16Array;if(e===Z.R16Snorm)return Int16Array;if(e===Z.RG16Unorm)return Uint16Array;if(e===Z.RG16Snorm)return Int16Array;if(e===Z.RGBA16Unorm)return Uint16Array;if(e===Z.RGBA16Snorm)return Int16Array;if(e===Z.R32Uint)return Uint32Array;if(e===Z.R32Sint)return Int32Array;if(e===Z.R32Float)return Float32Array;if(e===Z.RG32Uint)return Uint32Array;if(e===Z.RG32Sint)return Int32Array;if(e===Z.RG32Float)return Float32Array;if(e===Z.RGBA32Uint)return Uint32Array;if(e===Z.RGBA32Sint)return Int32Array;if(e===Z.RGBA32Float)return Float32Array;if(e===Z.BGRA8Unorm||e===Z.BGRA8UnormSRGB)return Uint8Array;if(e===Z.RGB10A2Unorm||e===Z.RGB9E5UFloat||e===Z.RG11B10UFloat)return Uint32Array;if(e===Z.Depth32Float)return Float32Array;if(e===Z.Depth24Plus||e===Z.Depth24PlusStencil8)return Uint32Array;if(e===Z.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return t=e.is3DTexture||e.isData3DTexture?dL.ThreeD:dL.TwoD,t}};function XL(e,t){let n=e.format,r=e.type,i=e.normalized,a=e.colorSpace,o=Es.getTransfer(a),s,c=!1;if(i&&(c=t.features.has(mL.TextureFormatsTier1),c===!1&&B(`WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.`)),e.isCompressedTexture===!0||e.isCompressedArrayTexture===!0)switch(n){case Ta:case Ea:s=o===`srgb`?Z.BC1RGBAUnormSRGB:Z.BC1RGBAUnorm;break;case Da:s=o===`srgb`?Z.BC2RGBAUnormSRGB:Z.BC2RGBAUnorm;break;case Oa:s=o===`srgb`?Z.BC3RGBAUnormSRGB:Z.BC3RGBAUnorm;break;case ro:s=Z.BC4RUnorm;break;case io:s=Z.BC4RSnorm;break;case ao:s=Z.BC5RGUnorm;break;case oo:s=Z.BC5RGSnorm;break;case eo:s=o===`srgb`?Z.BC7RGBAUnormSRGB:Z.BC7RGBAUnorm;break;case to:s=Z.BC6HRGBFloat;break;case no:s=Z.BC6HRGBUFloat;break;case Pa:case Na:s=o===`srgb`?Z.ETC2RGB8UnormSRGB:Z.ETC2RGB8Unorm;break;case Fa:s=o===`srgb`?Z.ETC2RGBA8UnormSRGB:Z.ETC2RGBA8Unorm;break;case Ia:s=Z.EACR11Unorm;break;case La:s=Z.EACR11Snorm;break;case Ra:s=Z.EACRG11Unorm;break;case za:s=Z.EACRG11Snorm;break;case Ba:s=o===`srgb`?Z.ASTC4x4UnormSRGB:Z.ASTC4x4Unorm;break;case Va:s=o===`srgb`?Z.ASTC5x4UnormSRGB:Z.ASTC5x4Unorm;break;case Ha:s=o===`srgb`?Z.ASTC5x5UnormSRGB:Z.ASTC5x5Unorm;break;case Ua:s=o===`srgb`?Z.ASTC6x5UnormSRGB:Z.ASTC6x5Unorm;break;case Wa:s=o===`srgb`?Z.ASTC6x6UnormSRGB:Z.ASTC6x6Unorm;break;case Ga:s=o===`srgb`?Z.ASTC8x5UnormSRGB:Z.ASTC8x5Unorm;break;case Ka:s=o===`srgb`?Z.ASTC8x6UnormSRGB:Z.ASTC8x6Unorm;break;case qa:s=o===`srgb`?Z.ASTC8x8UnormSRGB:Z.ASTC8x8Unorm;break;case Ja:s=o===`srgb`?Z.ASTC10x5UnormSRGB:Z.ASTC10x5Unorm;break;case Ya:s=o===`srgb`?Z.ASTC10x6UnormSRGB:Z.ASTC10x6Unorm;break;case Xa:s=o===`srgb`?Z.ASTC10x8UnormSRGB:Z.ASTC10x8Unorm;break;case Za:s=o===`srgb`?Z.ASTC10x10UnormSRGB:Z.ASTC10x10Unorm;break;case Qa:s=o===`srgb`?Z.ASTC12x10UnormSRGB:Z.ASTC12x10Unorm;break;case $a:s=o===`srgb`?Z.ASTC12x12UnormSRGB:Z.ASTC12x12Unorm;break;case ga:s=o===`srgb`?Z.RGBA8UnormSRGB:Z.RGBA8Unorm;break;default:V(`WebGPURenderer: Unsupported texture format.`,n)}else switch(n){case ga:switch(r){case na:s=Z.RGBA8Snorm;break;case ra:s=c?Z.RGBA16Snorm:Z.RGBA16Sint;break;case ia:s=c?Z.RGBA16Unorm:Z.RGBA16Uint;break;case oa:s=Z.RGBA32Uint;break;case aa:s=Z.RGBA32Sint;break;case ta:s=o===`srgb`?Z.RGBA8UnormSRGB:Z.RGBA8Unorm;break;case ca:s=Z.RGBA16Float;break;case sa:s=Z.RGBA32Float;break;default:V(`WebGPURenderer: Unsupported texture type with RGBAFormat.`,r)}break;case ha:switch(r){case fa:s=Z.RGB9E5UFloat;break;case pa:s=Z.RG11B10UFloat;break;default:V(`WebGPURenderer: Unsupported texture type with RGBFormat.`,r)}break;case ya:switch(r){case na:s=Z.R8Snorm;break;case ra:s=c?Z.R16Snorm:Z.R16Sint;break;case ia:s=c?Z.R16Unorm:Z.R16Uint;break;case oa:s=Z.R32Uint;break;case aa:s=Z.R32Sint;break;case ta:s=Z.R8Unorm;break;case ca:s=Z.R16Float;break;case sa:s=Z.R32Float;break;default:V(`WebGPURenderer: Unsupported texture type with RedFormat.`,r)}break;case xa:switch(r){case na:s=Z.RG8Snorm;break;case ra:s=c?Z.RG16Snorm:Z.RG16Sint;break;case ia:s=c?Z.RG16Unorm:Z.RG16Uint;break;case oa:s=Z.RG32Uint;break;case aa:s=Z.RG32Sint;break;case ta:s=Z.RG8Unorm;break;case ca:s=Z.RG16Float;break;case sa:s=Z.RG32Float;break;default:V(`WebGPURenderer: Unsupported texture type with RGFormat.`,r)}break;case _a:switch(r){case ia:s=Z.Depth16Unorm;break;case oa:s=Z.Depth24Plus;break;case sa:s=Z.Depth32Float;break;default:V(`WebGPURenderer: Unsupported texture type with DepthFormat.`,r)}break;case va:switch(r){case da:s=Z.Depth24PlusStencil8;break;case sa:t&&t.features.has(mL.Depth32FloatStencil8)===!1&&V(`WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.`),s=Z.Depth32FloatStencil8;break;default:V(`WebGPURenderer: Unsupported texture type with DepthStencilFormat.`,r)}break;case ba:switch(r){case aa:s=Z.R32Sint;break;case oa:s=Z.R32Uint;break;default:V(`WebGPURenderer: Unsupported texture type with RedIntegerFormat.`,r)}break;case Sa:switch(r){case aa:s=Z.RG32Sint;break;case oa:s=Z.RG32Uint;break;default:V(`WebGPURenderer: Unsupported texture type with RGIntegerFormat.`,r)}break;case wa:switch(r){case aa:s=Z.RGBA32Sint;break;case oa:s=Z.RGBA32Uint;break;default:V(`WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.`,r)}break;default:V(`WebGPURenderer: Unsupported texture format.`,n)}return s}var ble=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,xle=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,ZL={f32:`float`,i32:`int`,u32:`uint`,bool:`bool`,"vec2<f32>":`vec2`,"vec2<i32>":`ivec2`,"vec2<u32>":`uvec2`,"vec2<bool>":`bvec2`,vec2f:`vec2`,vec2i:`ivec2`,vec2u:`uvec2`,vec2b:`bvec2`,"vec3<f32>":`vec3`,"vec3<i32>":`ivec3`,"vec3<u32>":`uvec3`,"vec3<bool>":`bvec3`,vec3f:`vec3`,vec3i:`ivec3`,vec3u:`uvec3`,vec3b:`bvec3`,"vec4<f32>":`vec4`,"vec4<i32>":`ivec4`,"vec4<u32>":`uvec4`,"vec4<bool>":`bvec4`,vec4f:`vec4`,vec4i:`ivec4`,vec4u:`uvec4`,vec4b:`bvec4`,"mat2x2<f32>":`mat2`,mat2x2f:`mat2`,"mat3x3<f32>":`mat3`,mat3x3f:`mat3`,"mat4x4<f32>":`mat4`,mat4x4f:`mat4`,sampler:`sampler`,texture_1d:`texture`,texture_2d:`texture`,texture_2d_array:`texture`,texture_multisampled_2d:`cubeTexture`,texture_depth_2d:`depthTexture`,texture_depth_2d_array:`depthTexture`,texture_depth_multisampled_2d:`depthTexture`,texture_depth_cube:`depthTexture`,texture_depth_cube_array:`depthTexture`,texture_3d:`texture3D`,texture_cube:`cubeTexture`,texture_cube_array:`cubeTexture`,texture_storage_1d:`storageTexture`,texture_storage_2d:`storageTexture`,texture_storage_2d_array:`storageTexture`,texture_storage_3d:`storageTexture`},Sle=e=>{e=e.trim();let t=e.match(ble);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=xle.exec(n))!==null;)r.push({name:i[1],type:i[2]});let a=[];for(let e=0;e<r.length;e++){let{name:t,type:n}=r[e],i=n;i.startsWith(`ptr`)?i=`pointer`:(i.startsWith(`texture`)&&(i=n.split(`<`)[0]),i=ZL[i]),a.push(new GF(i,t))}let o=e.substring(t[0].length),s=t[3]||`void`,c=t[1]===void 0?``:t[1];return{type:ZL[s]||s,inputs:a,name:c,inputsCode:n,blockCode:o,outputType:s}}throw Error(`THREE.WGSLNodeFunction: Function is not a WGSL code.`)},Cle=class extends ZF{constructor(e){let{type:t,inputs:n,name:r,inputsCode:i,blockCode:a,outputType:o}=Sle(e);super(t,n,r),this.inputsCode=i,this.blockCode=a,this.outputType=o}getCode(e=this.name){let t=this.outputType===`void`?``:`-> `+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},wle=class extends XF{parseFunction(e){return new Cle(e)}},Tle={[kw.READ_ONLY]:`read`,[kw.WRITE_ONLY]:`write`,[kw.READ_WRITE]:`read_write`},QL={[Ki]:`repeat`,[qi]:`clamp`,[Ji]:`mirror`},$L={vertex:JI.VERTEX,fragment:JI.FRAGMENT,compute:JI.COMPUTE},eR={instance:!0,swizzleAssign:!1,storageBuffer:!0},Ele={"^^":`tsl_xor`},Dle={float:`f32`,int:`i32`,uint:`u32`,bool:`bool`,color:`vec3<f32>`,vec2:`vec2<f32>`,ivec2:`vec2<i32>`,uvec2:`vec2<u32>`,bvec2:`vec2<bool>`,vec3:`vec3<f32>`,ivec3:`vec3<i32>`,uvec3:`vec3<u32>`,bvec3:`vec3<bool>`,vec4:`vec4<f32>`,ivec4:`vec4<i32>`,uvec4:`vec4<u32>`,bvec4:`vec4<bool>`,mat2:`mat2x2<f32>`,mat3:`mat3x3<f32>`,mat4:`mat4x4<f32>`},tR={},nR={tsl_xor:new iF(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new iF(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new iF(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new iF(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new iF(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new iF(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new iF(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new iF(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new iF(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new iF(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new iF(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new iF(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),inverse_mat2:new iF(`
|
|
4918
|
+
`,this.mipmapShaderModule=e.createShaderModule(IL),IL.reset()}getTransferPipeline(e,t){t||=`2d-array`;let n=`${e}-${t}`,r=this.transferPipelines[n];return r===void 0&&(PL.label=`mipmap-${e}-${t}`,PL.vertex={module:this.mipmapShaderModule},PL.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace(`-`,`_`)}`,targets:[{format:e}]},PL.layout=`auto`,r=this.device.createRenderPipeline(PL),PL.reset(),this.transferPipelines[n]=r),r}flipY(e,t,n=0){let r=t.format,{width:i,height:a}=t.size;LL.size.width=i,LL.size.height=a,LL.format=r,LL.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let o=this.device.createTexture(LL);LL.reset();let s=this.getTransferPipeline(r,e.textureBindingViewDimension),c=this.getTransferPipeline(r,o.textureBindingViewDimension),l=this.device.createCommandEncoder(jL),u=(e,t,n,r,i,a)=>{let o=e.getBindGroupLayout(0);RL.dimension=t.textureBindingViewDimension||`2d-array`,RL.mipLevelCount=1;let s=t.createView(RL);RL.reset(),kL.layout=o,kL.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:s},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}});let c=this.device.createBindGroup(kL);kL.reset(),RL.dimension=`2d`,RL.mipLevelCount=1,RL.baseArrayLayer=i,RL.arrayLayerCount=1;let u=r.createView(RL);RL.reset(),FL.view=u,FL.loadOp=QI.Clear,FL.storeOp=ZI.Store,NL.colorAttachments.push(FL);let d=l.beginRenderPass(NL);NL.reset(),FL.reset(),d.setPipeline(e),d.setBindGroup(0,c),d.draw(3,1,0,n),d.end()};u(s,e,n,o,0,!1),u(c,o,0,e,n,!0),vL(this.device,l.finish()),o.destroy()}generateMipmaps(e,t=null){let n=this.get(e),r=n.layers||this._mipmapCreateBundles(e),i=t;i===null&&(jL.label=`mipmapEncoder`,i=this.device.createCommandEncoder(jL),jL.reset()),this._mipmapRunBundles(i,r),t===null&&vL(this.device,i.finish()),n.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||`2d-array`,n=this.getTransferPipeline(e.format,t),r=n.getBindGroupLayout(0),i=[];for(let a=1;a<e.mipLevelCount;a++)for(let o=0;o<e.depthOrArrayLayers;o++){RL.dimension=t,RL.baseMipLevel=a-1,RL.mipLevelCount=1;let s=e.createView(RL);RL.reset(),kL.layout=r,kL.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:s},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});let c=this.device.createBindGroup(kL);kL.reset(),RL.dimension=`2d`,RL.baseMipLevel=a,RL.mipLevelCount=1,RL.baseArrayLayer=o,RL.arrayLayerCount=1;let l=e.createView(RL);RL.reset();let u=new CL;u.view=l,u.loadOp=QI.Clear,u.storeOp=ZI.Store;let d=new wL;d.colorAttachments.push(u),ML.colorFormats=[e.format];let f=this.device.createRenderBundleEncoder(ML);ML.reset(),f.setPipeline(n),f.setBindGroup(0,c),f.draw(3,1,0,o),i.push({renderBundles:[f.finish()],passDescriptor:d})}return i}_mipmapRunBundles(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=e.beginRenderPass(n.passDescriptor);i.executeBundles(n.renderBundles),i.end()}}},ule=class{constructor(){this.label=``,this.addressModeU=`clamp-to-edge`,this.addressModeV=`clamp-to-edge`,this.addressModeW=`clamp-to-edge`,this.magFilter=`nearest`,this.minFilter=`nearest`,this.mipmapFilter=`nearest`,this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}reset(){this.label=``,this.addressModeU=`clamp-to-edge`,this.addressModeV=`clamp-to-edge`,this.addressModeW=`clamp-to-edge`,this.magFilter=`nearest`,this.minFilter=`nearest`,this.mipmapFilter=`nearest`,this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}},zL=class{constructor(){this.texture=null,this.mipLevel=0,this.origin={x:0,y:0,z:0},this.aspect=`all`}reset(){this.texture=null,this.mipLevel=0,this.origin.x=0,this.origin.y=0,this.origin.z=0,this.aspect=`all`}},dle=class{constructor(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},fle=class{constructor(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},ple=class{constructor(){this.source=null,this.origin={x:0,y:0},this.flipY=!1}reset(){this.source=null,this.origin.x=0,this.origin.y=0,this.flipY=!1}},mle=class extends zL{constructor(){super(),this.colorSpace=`srgb`,this.premultipliedAlpha=!1}reset(){super.reset(),this.colorSpace=`srgb`,this.premultipliedAlpha=!1}},BL=class{constructor(){this.width=0,this.height=1,this.depthOrArrayLayers=1}reset(){this.width=0,this.height=1,this.depthOrArrayLayers=1}},VL=new bL,hle=new xL,HL=new ule,UL=new zL,WL=new dle,GL=new fle,KL=new ple,qL=new mle,JL=new DL,YL=new BL,gle={512:`never`,513:`less`,514:`equal`,515:`less-equal`,516:`greater`,518:`greater-equal`,519:`always`,517:`not-equal`},_le=[0,1,3,2,4,5];function XL(e,t,n,r,i,a,o,s,c,l){UL.texture=t,UL.mipLevel=n,UL.origin.z=r,GL.offset=r*a,GL.bytesPerRow=o,GL.rowsPerImage=s,YL.width=c,YL.height=l,e.queue.writeTexture(UL,i.data,GL,YL),UL.reset(),GL.reset(),YL.reset()}var vle=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,n=e.texture,r=e.textureNode,i=n.minFilter+`-`+n.magFilter+`-`+n.wrapS+`-`+n.wrapT+`-`+(n.wrapR||`0`)+`-`+n.anisotropy+`-`+ +(n.isDepthTexture===!0)+`-`+(n.compareFunction!==null&&r.compareNode!==null?n.compareFunction:0),a=this._samplerCache.get(i);if(a===void 0){HL.addressModeU=this._convertAddressMode(n.wrapS),HL.addressModeV=this._convertAddressMode(n.wrapT),HL.addressModeW=this._convertAddressMode(n.wrapR),HL.magFilter=this._convertFilterMode(n.magFilter),HL.minFilter=this._convertFilterMode(n.minFilter),HL.mipmapFilter=this._convertMipmapFilterMode(n.minFilter),n.isDepthTexture&&(n.compareFunction===null||r.compareNode===null)&&(HL.magFilter=rL.Nearest,HL.minFilter=rL.Nearest,HL.mipmapFilter=rL.Nearest),HL.magFilter===rL.Linear&&HL.minFilter===rL.Linear&&HL.mipmapFilter===rL.Linear&&(HL.maxAnisotropy=n.anisotropy),n.isDepthTexture&&n.compareFunction!==null&&r.compareNode!==null&&t.hasCompatibility(Mo.TEXTURE_COMPARE)&&(HL.compare=gle[n.compareFunction]);let e=t.device.createSampler(HL);HL.reset(),a={sampler:e,usedTimes:0},this._samplerCache.set(i,a)}let o=t.get(e);return o.sampler!==a.sampler&&(this._releaseSampler(o),o.samplerKey=i,o.sampler=a.sampler,a.usedTimes++),i}destroySampler(e){this._releaseSampler(this.backend.get(e))}_releaseSampler(e){if(e.sampler!==void 0){let t=this._samplerCache.get(e.samplerKey);t.usedTimes--,t.usedTimes===0&&this._samplerCache.delete(e.samplerKey),e.sampler=void 0,e.samplerKey=void 0}}createDefaultTexture(e){let t,n=ZL(e,this.backend.device);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(n):this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){let n=this.backend,r=n.get(e);if(r.initialized){if(r.externalTexture===!0)return;throw Error(`THREE.WebGPUTextureUtils: Texture already initialized.`)}if(e.isExternalTexture){r.texture=e.sourceTexture,r.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);let{width:i,height:a,depth:o,levels:s}=t;e.isFramebufferTexture&&(t.format=t.renderTarget?this.backend.utils.getCurrentColorFormat(t.renderTarget):this.backend.utils.getPreferredCanvasFormat());let c=this._getDimension(e),l=e.internalFormat||t.format||ZL(e,n.device);r.format=l;let{samples:u,primarySamples:d,isMSAA:f}=n.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(p|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&l!==Z.RGB9E5UFloat&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m=new DL;if(m.label=e.name,m.size.width=i,m.size.height=a,m.size.depthOrArrayLayers=o,m.mipLevelCount=s,m.sampleCount=d,m.dimension=c,m.format=l,m.usage=p,l===void 0){B(`WebGPURenderer: Texture format not supported.`),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=pL.Cube);try{r.texture=n.device.createTexture(m)}catch{B(`WebGPURenderer: Failed to create texture with descriptor:`,m),this.createDefaultTexture(e);return}if(f){let e=Object.assign({},m);e.label+=`-msaa`,e.sampleCount=u,e.mipLevelCount=1,r.msaaTexture=n.device.createTexture(e)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e,t=!1){let n=this.backend,r=n.get(e);r.texture!==void 0&&t===!1&&e.isExternalTexture!==!0&&r.texture.destroy(),r.msaaTexture!==void 0&&r.msaaTexture.destroy(),n.delete(e)}generateMipmaps(e,t=null){let n=this.backend.get(e);this._generateMipmaps(n.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:n,height:r}=e.getDrawingBufferSize(),i=e.renderer.currentSamples,a=t.colorTexture,o=e.get(a);if(a.width===n&&a.height===r&&a.samples===i)return o.texture;let s=o.texture;return s&&s.destroy(),JL.label=`colorBuffer`,JL.size.width=n,JL.size.height=r,JL.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),JL.format=e.utils.getPreferredCanvasFormat(),JL.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,s=e.device.createTexture(JL),JL.reset(),a.source.width=n,a.source.height=r,a.samples=i,o.texture=s,s}getDepthBuffer(e=!0,t=!1){let n=this.backend,r=n.renderer.getCanvasTarget(),{width:i,height:a}=n.getDrawingBufferSize(),o=n.renderer.currentSamples,s=r.depthTexture;if(s.width===i&&s.height===a&&s.samples===o&&s.depth===e&&s.stencil===t)return n.get(s).texture;let c=n.get(s).texture,l,u;if(t?(l=va,u=n.renderer.reversedDepthBuffer===!0?sa:da):e&&(l=_a,u=n.renderer.reversedDepthBuffer===!0?sa:oa),c!==void 0){if(s.image.width===i&&s.image.height===a&&s.format===l&&s.type===u&&s.samples===o)return c;this.destroyTexture(s)}return s.name=`depthBuffer`,s.format=l,s.type=u,s.image.width=i,s.image.height=a,s.samples=o,this.createTexture(s,{width:i,height:a}),n.get(s).texture}updateTexture(e,t){let n=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:i}=n;if(!(e.isRenderTargetTexture||i===void 0)){if(e.isDataTexture){if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyBufferToTexture(a,n.texture,i,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,n.texture,i,0,e.flipY)}else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture){if(e.layerUpdates&&e.layerUpdates.size>0){for(let r of e.layerUpdates)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r);e.clearLayerUpdates()}else for(let r=0;r<t.image.depth;r++)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r)}else if(e.isCompressedTexture||e.isCompressedArrayTexture)e.isCompressedArrayTexture&&e.layerUpdates.size>0?(this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,i);else if(e.isHTMLTexture){let t=this.backend.device,r=this.backend.renderer.domElement,a=e.image;if(typeof t.queue.copyElementImageToTexture!=`function`)return;if(!n.hasPaintCallback){n.hasPaintCallback=!0,r.requestPaint();return}let o=i.size.width,s=i.size.height;t.queue.copyElementImageToTexture.length===2?t.queue.copyElementImageToTexture({source:a},{destination:{texture:n.texture},width:o,height:s}):t.queue.copyElementImageToTexture(a,o,s,{texture:n.texture}),e.flipY&&this._flipY(n.texture,i)}else if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyImageToTexture(a,n.texture,i,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,n.texture,i,0,e.flipY,e.premultiplyAlpha);n.version=e.version}}async copyTextureToBuffer(e,t,n,r,i,a){let o=this.backend.device,s=this.backend.get(e),c=s.texture,l=s.textureDescriptorGPU.format,u=this._getBytesPerTexel(l),d=r*u;d=Math.ceil(d/256)*256,VL.size=(i-1)*d+r*u,VL.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let f=o.createBuffer(VL);VL.reset();let p=o.createCommandEncoder(hle);UL.texture=c,UL.origin.x=t,UL.origin.y=n,UL.origin.z=a,WL.buffer=f,WL.bytesPerRow=d,YL.width=r,YL.height=i,p.copyTextureToBuffer(UL,WL,YL),UL.reset(),WL.reset(),YL.reset();let m=this._getTypedArrayType(l);vL(o,p.finish()),await f.mapAsync(GPUMapMode.READ);let h=f.getMappedRange().slice();return f.destroy(),new m(h)}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let n=new Is;n.minFilter=Yi,n.magFilter=Yi,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){let n=new wu;n.minFilter=Yi,n.magFilter=Yi,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){let r=e.images,i=e.mipmaps;for(let a=0;a<6;a++){let o=r[a],s=e.flipY===!0?_le[a]:a;o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,e.flipY):this._copyImageToTexture(o,t,n,s,e.flipY,e.premultiplyAlpha);for(let r=0;r<i.length;r++){let o=i[r].images[a];o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,e.flipY,0,r+1):this._copyImageToTexture(o,t,n,s,e.flipY,e.premultiplyAlpha,r+1)}}}_copyImageToTexture(e,t,n,r,i,a,o=0){let s=this.backend.device,c=o>0?e.width:n.size.width,l=o>0?e.height:n.size.height;KL.source=e,KL.flipY=i,qL.texture=t,qL.mipLevel=o,qL.origin.z=r,qL.premultipliedAlpha=a,YL.width=c,YL.height=l;try{s.queue.copyExternalImageToTexture(KL,qL,YL)}catch{}finally{KL.reset(),qL.reset(),YL.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new lle(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,i,a=0,o=0){let s=this.backend.device,c=e.data,l=this._getBytesPerTexel(n.format),u=e.width*l;UL.texture=t,UL.mipLevel=o,UL.origin.z=r,GL.offset=e.width*e.height*l*a,GL.bytesPerRow=u,YL.width=e.width,YL.height=e.height,s.queue.writeTexture(UL,c,GL,YL),UL.reset(),GL.reset(),YL.reset(),i===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n,r=null){let i=this.backend.device,a=this._getBlockData(n.format),o=n.size.depthOrArrayLayers>1,s=r&&r.size>0?r:null;for(let r=0;r<e.length;r++){let c=e[r],l=c.width,u=c.height,d=o?n.size.depthOrArrayLayers:1,f=Math.ceil(l/a.width)*a.byteLength,p=Math.ceil(u/a.height),m=f*p,h=Math.ceil(l/a.width)*a.width,g=p*a.height;if(s!==null)for(let e of s)XL(i,t,r,e,c,m,f,p,h,g);else for(let e=0;e<d;e++)XL(i,t,r,e,c,m,f,p,h,g)}}_getBlockData(e){if(e===Z.BC1RGBAUnorm||e===Z.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===Z.BC2RGBAUnorm||e===Z.BC2RGBAUnormSRGB||e===Z.BC3RGBAUnorm||e===Z.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.BC4RUnorm||e===Z.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===Z.BC5RGUnorm||e===Z.BC5RGSnorm||e===Z.BC6HRGBUFloat||e===Z.BC6HRGBFloat||e===Z.BC7RGBAUnorm||e===Z.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.ETC2RGB8Unorm||e===Z.ETC2RGB8UnormSRGB||e===Z.ETC2RGB8A1Unorm||e===Z.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===Z.ETC2RGBA8Unorm||e===Z.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.EACR11Unorm||e===Z.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===Z.EACRG11Unorm||e===Z.EACRG11Snorm||e===Z.ASTC4x4Unorm||e===Z.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===Z.ASTC5x4Unorm||e===Z.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===Z.ASTC5x5Unorm||e===Z.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===Z.ASTC6x5Unorm||e===Z.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===Z.ASTC6x6Unorm||e===Z.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===Z.ASTC8x5Unorm||e===Z.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===Z.ASTC8x6Unorm||e===Z.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===Z.ASTC8x8Unorm||e===Z.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===Z.ASTC10x5Unorm||e===Z.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===Z.ASTC10x6Unorm||e===Z.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===Z.ASTC10x8Unorm||e===Z.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===Z.ASTC10x10Unorm||e===Z.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===Z.ASTC12x10Unorm||e===Z.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===Z.ASTC12x12Unorm||e===Z.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=nL.ClampToEdge;return e===1e3?t=nL.Repeat:e===1002&&(t=nL.MirrorRepeat),t}_convertFilterMode(e){let t=rL.Linear;return(e===1003||e===1004||e===1005)&&(t=rL.Nearest),t}_convertMipmapFilterMode(e){return e===1005||e===1008?rL.Linear:rL.Nearest}_getBytesPerTexel(e){if(e===Z.R8Unorm||e===Z.R8Snorm||e===Z.R8Uint||e===Z.R8Sint)return 1;if(e===Z.R16Uint||e===Z.R16Sint||e===Z.R16Float||e===Z.RG8Unorm||e===Z.RG8Snorm||e===Z.RG8Uint||e===Z.RG8Sint||e===Z.R16Unorm||e===Z.R16Snorm)return 2;if(e===Z.R32Uint||e===Z.R32Sint||e===Z.R32Float||e===Z.RG16Uint||e===Z.RG16Sint||e===Z.RG16Float||e===Z.RGBA8Unorm||e===Z.RGBA8UnormSRGB||e===Z.RGBA8Snorm||e===Z.RGBA8Uint||e===Z.RGBA8Sint||e===Z.BGRA8Unorm||e===Z.BGRA8UnormSRGB||e===Z.RG16Unorm||e===Z.RG16Snorm||e===Z.RGB9E5UFloat||e===Z.RGB10A2Unorm||e===Z.RG11B10UFloat||e===Z.Depth32Float||e===Z.Depth24Plus||e===Z.Depth24PlusStencil8||e===Z.Depth32FloatStencil8)return 4;if(e===Z.RG32Uint||e===Z.RG32Sint||e===Z.RG32Float||e===Z.RGBA16Uint||e===Z.RGBA16Sint||e===Z.RGBA16Float||e===Z.RGBA16Unorm||e===Z.RGBA16Snorm)return 8;if(e===Z.RGBA32Uint||e===Z.RGBA32Sint||e===Z.RGBA32Float)return 16}_getTypedArrayType(e){if(e===Z.R8Uint)return Uint8Array;if(e===Z.R8Sint)return Int8Array;if(e===Z.R8Unorm)return Uint8Array;if(e===Z.R8Snorm)return Int8Array;if(e===Z.RG8Uint)return Uint8Array;if(e===Z.RG8Sint)return Int8Array;if(e===Z.RG8Unorm)return Uint8Array;if(e===Z.RG8Snorm)return Int8Array;if(e===Z.RGBA8Uint)return Uint8Array;if(e===Z.RGBA8Sint)return Int8Array;if(e===Z.RGBA8Unorm||e===Z.RGBA8UnormSRGB)return Uint8Array;if(e===Z.RGBA8Snorm)return Int8Array;if(e===Z.R16Uint)return Uint16Array;if(e===Z.R16Sint)return Int16Array;if(e===Z.RG16Uint)return Uint16Array;if(e===Z.RG16Sint)return Int16Array;if(e===Z.RGBA16Uint)return Uint16Array;if(e===Z.RGBA16Sint)return Int16Array;if(e===Z.R16Float||e===Z.RG16Float||e===Z.RGBA16Float||e===Z.R16Unorm)return Uint16Array;if(e===Z.R16Snorm)return Int16Array;if(e===Z.RG16Unorm)return Uint16Array;if(e===Z.RG16Snorm)return Int16Array;if(e===Z.RGBA16Unorm)return Uint16Array;if(e===Z.RGBA16Snorm)return Int16Array;if(e===Z.R32Uint)return Uint32Array;if(e===Z.R32Sint)return Int32Array;if(e===Z.R32Float)return Float32Array;if(e===Z.RG32Uint)return Uint32Array;if(e===Z.RG32Sint)return Int32Array;if(e===Z.RG32Float)return Float32Array;if(e===Z.RGBA32Uint)return Uint32Array;if(e===Z.RGBA32Sint)return Int32Array;if(e===Z.RGBA32Float)return Float32Array;if(e===Z.BGRA8Unorm||e===Z.BGRA8UnormSRGB)return Uint8Array;if(e===Z.RGB10A2Unorm||e===Z.RGB9E5UFloat||e===Z.RG11B10UFloat)return Uint32Array;if(e===Z.Depth32Float)return Float32Array;if(e===Z.Depth24Plus||e===Z.Depth24PlusStencil8)return Uint32Array;if(e===Z.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return t=e.is3DTexture||e.isData3DTexture?fL.ThreeD:fL.TwoD,t}};function ZL(e,t){let n=e.format,r=e.type,i=e.normalized,a=e.colorSpace,o=Es.getTransfer(a),s,c=!1;if(i&&(c=t.features.has(hL.TextureFormatsTier1),c===!1&&B(`WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.`)),e.isCompressedTexture===!0||e.isCompressedArrayTexture===!0)switch(n){case Ta:case Ea:s=o===`srgb`?Z.BC1RGBAUnormSRGB:Z.BC1RGBAUnorm;break;case Da:s=o===`srgb`?Z.BC2RGBAUnormSRGB:Z.BC2RGBAUnorm;break;case Oa:s=o===`srgb`?Z.BC3RGBAUnormSRGB:Z.BC3RGBAUnorm;break;case ro:s=Z.BC4RUnorm;break;case io:s=Z.BC4RSnorm;break;case ao:s=Z.BC5RGUnorm;break;case oo:s=Z.BC5RGSnorm;break;case eo:s=o===`srgb`?Z.BC7RGBAUnormSRGB:Z.BC7RGBAUnorm;break;case to:s=Z.BC6HRGBFloat;break;case no:s=Z.BC6HRGBUFloat;break;case Pa:case Na:s=o===`srgb`?Z.ETC2RGB8UnormSRGB:Z.ETC2RGB8Unorm;break;case Fa:s=o===`srgb`?Z.ETC2RGBA8UnormSRGB:Z.ETC2RGBA8Unorm;break;case Ia:s=Z.EACR11Unorm;break;case La:s=Z.EACR11Snorm;break;case Ra:s=Z.EACRG11Unorm;break;case za:s=Z.EACRG11Snorm;break;case Ba:s=o===`srgb`?Z.ASTC4x4UnormSRGB:Z.ASTC4x4Unorm;break;case Va:s=o===`srgb`?Z.ASTC5x4UnormSRGB:Z.ASTC5x4Unorm;break;case Ha:s=o===`srgb`?Z.ASTC5x5UnormSRGB:Z.ASTC5x5Unorm;break;case Ua:s=o===`srgb`?Z.ASTC6x5UnormSRGB:Z.ASTC6x5Unorm;break;case Wa:s=o===`srgb`?Z.ASTC6x6UnormSRGB:Z.ASTC6x6Unorm;break;case Ga:s=o===`srgb`?Z.ASTC8x5UnormSRGB:Z.ASTC8x5Unorm;break;case Ka:s=o===`srgb`?Z.ASTC8x6UnormSRGB:Z.ASTC8x6Unorm;break;case qa:s=o===`srgb`?Z.ASTC8x8UnormSRGB:Z.ASTC8x8Unorm;break;case Ja:s=o===`srgb`?Z.ASTC10x5UnormSRGB:Z.ASTC10x5Unorm;break;case Ya:s=o===`srgb`?Z.ASTC10x6UnormSRGB:Z.ASTC10x6Unorm;break;case Xa:s=o===`srgb`?Z.ASTC10x8UnormSRGB:Z.ASTC10x8Unorm;break;case Za:s=o===`srgb`?Z.ASTC10x10UnormSRGB:Z.ASTC10x10Unorm;break;case Qa:s=o===`srgb`?Z.ASTC12x10UnormSRGB:Z.ASTC12x10Unorm;break;case $a:s=o===`srgb`?Z.ASTC12x12UnormSRGB:Z.ASTC12x12Unorm;break;case ga:s=o===`srgb`?Z.RGBA8UnormSRGB:Z.RGBA8Unorm;break;default:V(`WebGPURenderer: Unsupported texture format.`,n)}else switch(n){case ga:switch(r){case na:s=Z.RGBA8Snorm;break;case ra:s=c?Z.RGBA16Snorm:Z.RGBA16Sint;break;case ia:s=c?Z.RGBA16Unorm:Z.RGBA16Uint;break;case oa:s=Z.RGBA32Uint;break;case aa:s=Z.RGBA32Sint;break;case ta:s=o===`srgb`?Z.RGBA8UnormSRGB:Z.RGBA8Unorm;break;case ca:s=Z.RGBA16Float;break;case sa:s=Z.RGBA32Float;break;default:V(`WebGPURenderer: Unsupported texture type with RGBAFormat.`,r)}break;case ha:switch(r){case fa:s=Z.RGB9E5UFloat;break;case pa:s=Z.RG11B10UFloat;break;default:V(`WebGPURenderer: Unsupported texture type with RGBFormat.`,r)}break;case ya:switch(r){case na:s=Z.R8Snorm;break;case ra:s=c?Z.R16Snorm:Z.R16Sint;break;case ia:s=c?Z.R16Unorm:Z.R16Uint;break;case oa:s=Z.R32Uint;break;case aa:s=Z.R32Sint;break;case ta:s=Z.R8Unorm;break;case ca:s=Z.R16Float;break;case sa:s=Z.R32Float;break;default:V(`WebGPURenderer: Unsupported texture type with RedFormat.`,r)}break;case xa:switch(r){case na:s=Z.RG8Snorm;break;case ra:s=c?Z.RG16Snorm:Z.RG16Sint;break;case ia:s=c?Z.RG16Unorm:Z.RG16Uint;break;case oa:s=Z.RG32Uint;break;case aa:s=Z.RG32Sint;break;case ta:s=Z.RG8Unorm;break;case ca:s=Z.RG16Float;break;case sa:s=Z.RG32Float;break;default:V(`WebGPURenderer: Unsupported texture type with RGFormat.`,r)}break;case _a:switch(r){case ia:s=Z.Depth16Unorm;break;case oa:s=Z.Depth24Plus;break;case sa:s=Z.Depth32Float;break;default:V(`WebGPURenderer: Unsupported texture type with DepthFormat.`,r)}break;case va:switch(r){case da:s=Z.Depth24PlusStencil8;break;case sa:t&&t.features.has(hL.Depth32FloatStencil8)===!1&&V(`WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.`),s=Z.Depth32FloatStencil8;break;default:V(`WebGPURenderer: Unsupported texture type with DepthStencilFormat.`,r)}break;case ba:switch(r){case aa:s=Z.R32Sint;break;case oa:s=Z.R32Uint;break;default:V(`WebGPURenderer: Unsupported texture type with RedIntegerFormat.`,r)}break;case Sa:switch(r){case aa:s=Z.RG32Sint;break;case oa:s=Z.RG32Uint;break;default:V(`WebGPURenderer: Unsupported texture type with RGIntegerFormat.`,r)}break;case wa:switch(r){case aa:s=Z.RGBA32Sint;break;case oa:s=Z.RGBA32Uint;break;default:V(`WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.`,r)}break;default:V(`WebGPURenderer: Unsupported texture format.`,n)}return s}var yle=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,ble=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,QL={f32:`float`,i32:`int`,u32:`uint`,bool:`bool`,"vec2<f32>":`vec2`,"vec2<i32>":`ivec2`,"vec2<u32>":`uvec2`,"vec2<bool>":`bvec2`,vec2f:`vec2`,vec2i:`ivec2`,vec2u:`uvec2`,vec2b:`bvec2`,"vec3<f32>":`vec3`,"vec3<i32>":`ivec3`,"vec3<u32>":`uvec3`,"vec3<bool>":`bvec3`,vec3f:`vec3`,vec3i:`ivec3`,vec3u:`uvec3`,vec3b:`bvec3`,"vec4<f32>":`vec4`,"vec4<i32>":`ivec4`,"vec4<u32>":`uvec4`,"vec4<bool>":`bvec4`,vec4f:`vec4`,vec4i:`ivec4`,vec4u:`uvec4`,vec4b:`bvec4`,"mat2x2<f32>":`mat2`,mat2x2f:`mat2`,"mat3x3<f32>":`mat3`,mat3x3f:`mat3`,"mat4x4<f32>":`mat4`,mat4x4f:`mat4`,sampler:`sampler`,texture_1d:`texture`,texture_2d:`texture`,texture_2d_array:`texture`,texture_multisampled_2d:`cubeTexture`,texture_depth_2d:`depthTexture`,texture_depth_2d_array:`depthTexture`,texture_depth_multisampled_2d:`depthTexture`,texture_depth_cube:`depthTexture`,texture_depth_cube_array:`depthTexture`,texture_3d:`texture3D`,texture_cube:`cubeTexture`,texture_cube_array:`cubeTexture`,texture_storage_1d:`storageTexture`,texture_storage_2d:`storageTexture`,texture_storage_2d_array:`storageTexture`,texture_storage_3d:`storageTexture`},xle=e=>{e=e.trim();let t=e.match(yle);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=ble.exec(n))!==null;)r.push({name:i[1],type:i[2]});let a=[];for(let e=0;e<r.length;e++){let{name:t,type:n}=r[e],i=n;i.startsWith(`ptr`)?i=`pointer`:(i.startsWith(`texture`)&&(i=n.split(`<`)[0]),i=QL[i]),a.push(new KF(i,t))}let o=e.substring(t[0].length),s=t[3]||`void`,c=t[1]===void 0?``:t[1];return{type:QL[s]||s,inputs:a,name:c,inputsCode:n,blockCode:o,outputType:s}}throw Error(`THREE.WGSLNodeFunction: Function is not a WGSL code.`)},Sle=class extends QF{constructor(e){let{type:t,inputs:n,name:r,inputsCode:i,blockCode:a,outputType:o}=xle(e);super(t,n,r),this.inputsCode=i,this.blockCode=a,this.outputType=o}getCode(e=this.name){let t=this.outputType===`void`?``:`-> `+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},Cle=class extends ZF{parseFunction(e){return new Sle(e)}},wle={[Aw.READ_ONLY]:`read`,[Aw.WRITE_ONLY]:`write`,[Aw.READ_WRITE]:`read_write`},$L={[Ki]:`repeat`,[qi]:`clamp`,[Ji]:`mirror`},eR={vertex:YI.VERTEX,fragment:YI.FRAGMENT,compute:YI.COMPUTE},tR={instance:!0,swizzleAssign:!1,storageBuffer:!0},Tle={"^^":`tsl_xor`},Ele={float:`f32`,int:`i32`,uint:`u32`,bool:`bool`,color:`vec3<f32>`,vec2:`vec2<f32>`,ivec2:`vec2<i32>`,uvec2:`vec2<u32>`,bvec2:`vec2<bool>`,vec3:`vec3<f32>`,ivec3:`vec3<i32>`,uvec3:`vec3<u32>`,bvec3:`vec3<bool>`,vec4:`vec4<f32>`,ivec4:`vec4<i32>`,uvec4:`vec4<u32>`,bvec4:`vec4<bool>`,mat2:`mat2x2<f32>`,mat3:`mat3x3<f32>`,mat4:`mat4x4<f32>`},nR={},rR={tsl_xor:new aF(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new aF(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new aF(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new aF(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new aF(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new aF(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new aF(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new aF(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new aF(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new aF(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new aF(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new aF(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),inverse_mat2:new aF(`
|
|
4919
4919
|
fn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> {
|
|
4920
4920
|
|
|
4921
4921
|
let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ];
|
|
@@ -4926,7 +4926,7 @@ fn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> {
|
|
|
4926
4926
|
) * ( 1.0 / det );
|
|
4927
4927
|
|
|
4928
4928
|
}
|
|
4929
|
-
`),inverse_mat3:new
|
|
4929
|
+
`),inverse_mat3:new aF(`
|
|
4930
4930
|
fn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> {
|
|
4931
4931
|
|
|
4932
4932
|
let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ];
|
|
@@ -4946,7 +4946,7 @@ fn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> {
|
|
|
4946
4946
|
) * ( 1.0 / det );
|
|
4947
4947
|
|
|
4948
4948
|
}
|
|
4949
|
-
`),inverse_mat4:new
|
|
4949
|
+
`),inverse_mat4:new aF(`
|
|
4950
4950
|
fn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> {
|
|
4951
4951
|
|
|
4952
4952
|
let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ];
|
|
@@ -4989,7 +4989,7 @@ fn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> {
|
|
|
4989
4989
|
) * ( 1.0 / det );
|
|
4990
4990
|
|
|
4991
4991
|
}
|
|
4992
|
-
`),biquadraticTexture:new
|
|
4992
|
+
`),biquadraticTexture:new aF(`
|
|
4993
4993
|
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
4994
4994
|
|
|
4995
4995
|
let res = vec2f( iRes );
|
|
@@ -5011,7 +5011,7 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
|
|
|
5011
5011
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
5012
5012
|
|
|
5013
5013
|
}
|
|
5014
|
-
`),biquadraticTextureArray:new
|
|
5014
|
+
`),biquadraticTextureArray:new aF(`
|
|
5015
5015
|
fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
|
|
5016
5016
|
|
|
5017
5017
|
let res = vec2f( iRes );
|
|
@@ -5033,14 +5033,14 @@ fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRe
|
|
|
5033
5033
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
5034
5034
|
|
|
5035
5035
|
}
|
|
5036
|
-
`)},
|
|
5037
|
-
`);var
|
|
5036
|
+
`)},Dle={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inverse_mat2:`tsl_inverse_mat2`,inverse_mat3:`tsl_inverse_mat3`,inverse_mat4:`tsl_inverse_mat4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`,floatpack_snorm_2x16:`pack2x16snorm`,floatpack_unorm_2x16:`pack2x16unorm`,floatpack_float16_2x16:`pack2x16float`,floatunpack_snorm_2x16:`unpack2x16snorm`,floatunpack_unorm_2x16:`unpack2x16unorm`,floatunpack_float16_2x16:`unpack2x16float`},iR=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(iR+=`diagnostic( off, derivative_uniformity );
|
|
5037
|
+
`);var Ole=class extends WF{constructor(e,t){super(e,t,new Cle),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,n,r,i,a=this.shaderStage){return a===`fragment`?r?i?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:i?`textureSample( ${t}, ${t}_sampler, ${n}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,`0`,r)}generateTextureSampleLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateWrapFunction(e){let t=`tsl_coord_${$L[e.wrapS]}S_${$L[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?`3d`:`2d`}`,n=nR[t];if(n===void 0){let r=[],i=e.is3DTexture||e.isData3DTexture?`vec3f`:`vec2f`,a=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`,o=(e,t)=>{e===1e3?(r.push(rR.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===1001?(r.push(rR.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===1002?(r.push(rR.mirrorWrapping_float),a+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(a+=`\t\tcoord.${t}`,B(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};o(e.wrapS,`x`),a+=`,
|
|
5038
5038
|
`,o(e.wrapT,`y`),(e.is3DTexture||e.isData3DTexture)&&(a+=`,
|
|
5039
5039
|
`,o(e.wrapR,`z`)),a+=`
|
|
5040
5040
|
);
|
|
5041
5041
|
|
|
5042
5042
|
}
|
|
5043
|
-
`,
|
|
5043
|
+
`,nR[t]=n=new aF(a,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){let r=this.getDataFromNode(e,this.shaderStage,this.cache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let i=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,o,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(e),c=s>1;o=e.is3DTexture||e.isData3DTexture?`vec3<u32>`:`vec2<u32>`,a=c||e.isStorageTexture?t:`${t}${n?`, u32( ${n} )`:``}`,i=new cD(new BD(`textureDimensions( ${a} )`,o)),r.dimensionsSnippet[n]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new cD(new BD(`textureNumLayers(${t})`,`u32`))),e.isTextureCube&&(r.cubeFaceCount=new cD(new BD(`6u`,`u32`)))}return i.build(this)}generateFilteredTexture(e,t,n,r,i=`0u`,a){let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,i);return r&&(n=`${n} + vec2<f32>(${r}) / ${s}`),a?(this._include(`biquadraticTextureArray`),`tsl_biquadraticTexture_array( ${t}, ${o}( ${n} ), ${s}, u32( ${a} ), u32( ${i} ) )`):(this._include(`biquadraticTexture`),`tsl_biquadraticTexture( ${t}, ${o}( ${n} ), ${s}, u32( ${i} ) )`)}generateTextureLod(e,t,n,r,i,a=`0u`){if(e.isCubeTexture===!0){i&&(n=`${n} + vec3<f32>(${i})`);let r=e.isDepthTexture?`u32`:`f32`;return`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}( ${a} ) )`}let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,a),c=e.is3DTexture||e.isData3DTexture?`vec3`:`vec2`,l=c===`vec3`?`vec3<u32>( 1, 1, 1 )`:`vec2<u32>( 1, 1 )`;i&&(n=`${n} + ${c}<f32>(${i}) / ${c}<f32>( ${s} )`);let u=`${c}<f32>( 0 )`,d=`${c}<f32>( ${s} - ${l} )`;return n=`${c}<u32>( clamp( floor( ${o}( ${n} ) * ${c}<f32>( ${s} ) ), ${u}, ${d} ) )`,this.generateTextureLoad(e,t,n,a,r,null)}generateStorageTextureLoad(e,t,n,r,i,a){a&&(n=`${n} + ${a}`);let o;return o=i?`textureLoad( ${t}, ${n}, ${i} )`:`textureLoad( ${t}, ${n} )`,o}generateTextureLoad(e,t,n,r,i,a){r===null&&(r=`0u`),a&&(n=`${n} + ${a}`);let o;return i?o=`textureLoad( ${t}, ${n}, ${i}, u32( ${r} ) )`:(o=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=`.x`)),o}generateTextureStore(e,t,n,r,i){let a;return a=r?`textureStore( ${t}, ${n}, ${r}, ${i} )`:`textureStore( ${t}, ${n}, ${i} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(Mo.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!==`float`||!this.isAvailable(`float32Filterable`)&&e.type===1015||this.isSampleCompare(e)===!1&&e.minFilter===1003&&e.magFilter===1003||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,i,a=this.shaderStage){let o=null;return o=this.isUnfilterable(e)?this.generateTextureLod(e,t,n,r,i,`0`,a):this._generateTextureSample(e,t,n,r,i,a),o}generateTextureGrad(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]} )`:a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;V(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${o} shader.`)}generateTextureCompare(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;V(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,n,r,i,a){let o=e.isDepthTexture===!0?``:`${r}, `;return i?a?`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${i}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${i} )`:a?`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${n})`}generateTextureGatherCompare(e,t,n,r,i,a){return i?a?`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r})`:a?`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${r})`}generateTextureLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateTextureBias(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;V(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${o} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t===`vertex`)return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let t=e.name,n=e.type;return n===`texture`||n===`cubeTexture`||n===`cubeDepthTexture`||n===`storageTexture`||n===`texture3D`?t:n===`buffer`||n===`storageBuffer`||n===`indirectStorageBuffer`?this.isCustomStruct(e)?t:t+`.value`:e.groupNode.name+`.`+t}return super.getPropertyName(e)}getOutputStructName(){return`output`}getFunctionOperator(e){let t=Tle[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t===`compute`?e.access:e.isAtomic===!0?(B(`WebGPURenderer: Atomic operations are only supported in compute shaders.`),Aw.READ_WRITE):Aw.READ_ONLY}getStorageAccess(e,t){return wle[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let o,s=e.groupNode,c=s.name,l=this.getBindGroupArray(c,n);if(t===`texture`||t===`cubeTexture`||t===`cubeDepthTexture`||t===`storageTexture`||t===`texture3D`){let r=null,a=this.getNodeAccess(e,n);if(t===`texture`||t===`storageTexture`?r=e.value.is3DTexture===!0?new OI(i.name,i.node,s,a):new EI(i.name,i.node,s,a):t===`cubeTexture`||t===`cubeDepthTexture`?r=new DI(i.name,i.node,s,a):t===`texture3D`&&(r=new OI(i.name,i.node,s,a)),r.store=e.isStorageTextureNode===!0,r.mipLevel=r.store?e.mipLevel:0,r.setVisibility(eR[n]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&r.store===!1||e.gatherNode!==null){let e=new rle(`${i.name}_sampler`,i.node,s);e.setVisibility(eR[n]),l.push(e,r),o=[e,r]}else l.push(r),o=[r]}else if(t===`buffer`||t===`storageBuffer`||t===`indirectStorageBuffer`){let a=this.getSharedDataFromNode(e),c=a.buffer;c===void 0&&(c=new(t===`buffer`?CI:ole)(e,s),a.buffer=c),c.setVisibility(c.getVisibility()|eR[n]),l.push(c),o=c,i.name=r||`NodeBuffer_`+i.id}else{let e=this.uniformGroups[c];e===void 0&&(e=new wI(c,s),e.setVisibility(YI.VERTEX|YI.FRAGMENT|YI.COMPUTE),this.uniformGroups[c]=e),l.indexOf(e)===-1&&l.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}getBuiltin(e,t,n,r=this.shaderStage){let i=this.builtins[r]||(this.builtins[r]=new Map);return i.has(e)===!1&&i.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`vertex_index`,`vertexIndex`,`u32`,`attribute`):`vertexIndex`}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(e.name+` : `+this.getType(e.type));let i=`fn ${t.name}( ${r.join(`, `)} ) -> ${this.getType(t.type)} {
|
|
5044
5044
|
${n.vars}
|
|
5045
5045
|
${n.code}
|
|
5046
5046
|
`;return n.result&&(i+=`\treturn ${n.result};\n`),i+=`
|
|
@@ -5058,7 +5058,7 @@ ${n.code}
|
|
|
5058
5058
|
`}return t}getVar(e,t,n=null,r=``){let i=`var${r} ${t} : `;return i+=n===null?this.getType(e):this.generateArrayDeclaration(e,n),i}getVars(e,t=!1){let n=``;t&&(n=`<private>`);let r=[],i=this.vars[e];if(i!==void 0)for(let e of i)r.push(`${this.getVar(e.type,e.name,e.count,n)};`);return t?r.join(`
|
|
5059
5059
|
`):`\n\t${r.join(`
|
|
5060
5060
|
`)}\n`}getVaryings(e){let t=[];if(e===`vertex`&&this.getBuiltin(`position`,`builtinClipSpace`,`vec4<f32>`,`vertex`),e===`vertex`||e===`fragment`){let n=this.varyings,r=this.vars[e],i=0;for(let a=0;a<n.length;a++){let o=n[a];if(o.needsInterpolation){let e=`@location( ${i++} )`;if(o.interpolationType){let t=o.interpolationSampling===null?` )`:`, ${o.interpolationSampling} )`;e+=` @interpolate( ${o.interpolationType}${t}`}else/^(int|uint|ivec|uvec)/.test(o.type)&&(e+=` @interpolate(flat, either)`);t.push(`${e} ${o.name} : ${this.getType(o.type)}`)}else e===`vertex`&&r.includes(o)===!1&&r.push(o)}}let n=this.getBuiltins(e);n&&t.push(n);let r=t.join(`,
|
|
5061
|
-
`);return e===`vertex`?this._getWGSLStruct(`VaryingsStruct`,` `+r):r}isCustomStruct(e){let t=e.value,n=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,i=n.value&&n.value.array&&typeof n.value.itemSize==`number`&&n.value.array.length>n.value.itemSize;return r&&!i}getUniforms(e){let t=this.renderer.backend,n=this.uniforms[e],r=[],i=[],a=[],o={};for(let a of n){let n=a.groupNode.name,s=this.bindingsIndexes[n];if(a.type===`texture`||a.type===`cubeTexture`||a.type===`cubeDepthTexture`||a.type===`storageTexture`||a.type===`texture3D`){let n=a.node,i=n.value;(i.isCubeTexture===!0||this.isUnfilterable(i)===!1&&n.isStorageTextureNode!==!0||n.gatherNode!==null)&&(this.isSampleCompare(i)&&n.compareNode!==null?r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler_comparison;`):r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler;`));let o,c=``,{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(c=`_multisampled`),i.isCubeTexture===!0&&i.isDepthTexture===!0)o=`texture_depth_cube`;else if(i.isCubeTexture===!0)o=`texture_cube<f32>`;else if(i.isDepthTexture===!0)o=t.compatibilityMode&&i.compareFunction===null?`texture${c}_2d<f32>`:`texture_depth${c}_2d${i.isArrayTexture===!0?`_array`:``}`;else if(a.node.isStorageTextureNode===!0){let n=
|
|
5061
|
+
`);return e===`vertex`?this._getWGSLStruct(`VaryingsStruct`,` `+r):r}isCustomStruct(e){let t=e.value,n=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,i=n.value&&n.value.array&&typeof n.value.itemSize==`number`&&n.value.array.length>n.value.itemSize;return r&&!i}getUniforms(e){let t=this.renderer.backend,n=this.uniforms[e],r=[],i=[],a=[],o={};for(let a of n){let n=a.groupNode.name,s=this.bindingsIndexes[n];if(a.type===`texture`||a.type===`cubeTexture`||a.type===`cubeDepthTexture`||a.type===`storageTexture`||a.type===`texture3D`){let n=a.node,i=n.value;(i.isCubeTexture===!0||this.isUnfilterable(i)===!1&&n.isStorageTextureNode!==!0||n.gatherNode!==null)&&(this.isSampleCompare(i)&&n.compareNode!==null?r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler_comparison;`):r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler;`));let o,c=``,{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(c=`_multisampled`),i.isCubeTexture===!0&&i.isDepthTexture===!0)o=`texture_depth_cube`;else if(i.isCubeTexture===!0)o=`texture_cube<f32>`;else if(i.isDepthTexture===!0)o=t.compatibilityMode&&i.compareFunction===null?`texture${c}_2d<f32>`:`texture_depth${c}_2d${i.isArrayTexture===!0?`_array`:``}`;else if(a.node.isStorageTextureNode===!0){let n=ZL(i,t.device),r=this.getStorageAccess(a.node,e),s=a.node.value.is3DTexture,c=a.node.value.isArrayTexture;o=`texture_storage_${s?`3d`:`2d${c?`_array`:``}`}<${n}, ${r}>`}else if(i.isArrayTexture===!0||i.isDataArrayTexture===!0||i.isCompressedArrayTexture===!0)o=`texture_2d_array<f32>`;else if(i.is3DTexture===!0||i.isData3DTexture===!0)o=`texture_3d<f32>`;else{let e=this.getComponentTypeFromTexture(i).charAt(0);o=`texture${c}_2d<${e}32>`}r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name} : ${o};`)}else if(a.type===`buffer`||a.type===`storageBuffer`||a.type===`indirectStorageBuffer`){let t=a.node,n=this.getType(t.getNodeType(this)),r=t.bufferCount,o=r>0&&a.type===`buffer`?`, `+r:``,c=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:`uniform`;if(this.isCustomStruct(a))i.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var<${c}> ${a.name} : ${n};`);else{let e=`\tvalue : array< ${t.isAtomic?`atomic<${n}>`:`${n}`}${o} >`;i.push(this._getWGSLStructBinding(a.name,e,c,s.binding++,s.group))}}else{let e=a.groupNode.name;if(o[e]===void 0){let t=this.uniformGroups[e];if(t!==void 0){let n=[];for(let e of t.uniforms){let t=e.getType(),r=this.getType(this.getVectorType(t));n.push(`\t${e.name} : ${r}`)}let r=this.uniformGroupsBindings[e];r===void 0&&(r={index:s.binding++,id:s.group},this.uniformGroupsBindings[e]=r),o[e]={index:r.index,id:r.id,snippets:n}}}}}for(let e in o){let t=o[e];a.push(this._getWGSLStructBinding(e,t.snippets.join(`,
|
|
5062
5062
|
`),`uniform`,t.index,t.id))}return[...r,...i,...a].join(`
|
|
5063
5063
|
`)}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let n=this.allowGlobalVariables,r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t,n),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let i=`// code
|
|
5064
5064
|
|
|
@@ -5067,7 +5067,7 @@ ${n.code}
|
|
|
5067
5067
|
|
|
5068
5068
|
`,t===`vertex`)i+=`varyings.builtinClipSpace = ${n.result};`;else if(t===`fragment`){if(c)r.returnType=s.getNodeType(this),r.structs+=`var<private> output : `+r.returnType+`;`,i+=`return ${n.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`,t=this.getBuiltins(`output`);t&&(e+=`,
|
|
5069
5069
|
`+t),r.returnType=`OutputStruct`,r.structs+=this._getWGSLStruct(`OutputStruct`,e),r.structs+=`
|
|
5070
|
-
var<private> output : OutputStruct;`,i+=`output.color = ${this.format(n.result,o.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}}}r.flow=i}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+`_`+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return
|
|
5070
|
+
var<private> output : OutputStruct;`,i+=`output.color = ${this.format(n.result,o.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}}}r.flow=i}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+`_`+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return Ele[e]||e}isAvailable(e){let t=tR[e];return t===void 0&&(e===`float32Filterable`?t=this.renderer.hasFeature(`float32-filterable`):e===`clipDistance`&&(t=this.renderer.hasFeature(`clip-distances`)),tR[e]=t),t}_getWGSLMethod(e){return rR[e]!==void 0&&this._include(e),Dle[e]}_include(e){let t=rR[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
|
|
5071
5071
|
// directives
|
|
5072
5072
|
${e.directives}
|
|
5073
5073
|
|
|
@@ -5098,7 +5098,7 @@ fn main( ${e.attributes} ) -> VaryingsStruct {
|
|
|
5098
5098
|
}
|
|
5099
5099
|
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
|
|
5100
5100
|
// global
|
|
5101
|
-
${
|
|
5101
|
+
${iR}
|
|
5102
5102
|
|
|
5103
5103
|
// structs
|
|
5104
5104
|
${e.structs}
|
|
@@ -5161,8 +5161,8 @@ struct ${e} {
|
|
|
5161
5161
|
${t}
|
|
5162
5162
|
};`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`;return`${this._getWGSLStruct(a,t)}
|
|
5163
5163
|
@binding( ${r} ) @group( ${i} )
|
|
5164
|
-
var<${n}> ${e} : ${a};`}},iR=new yL,aR=new bL,oR=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&oR.set(Float16Array,[`float16`]);var Ale=new Map([[dl,[`float16`]]]),jle=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]),Mle=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}n.array=s;let c;if((n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3)c=4;else if(n.itemSize>1&&n.itemSize*s.BYTES_PER_ELEMENT%4!=0){let e=n.itemSize*s.BYTES_PER_ELEMENT;c=Math.floor((e+3)/4)*4/s.BYTES_PER_ELEMENT}if(c!==void 0){let e=n.itemSize,t=new s.constructor(n.count*c);for(let r=0;r<n.count;r++)t.set(s.subarray(r*e,r*e+e),r*c);(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&(n.itemSize=c,n.array=t),s=t,i._itemSize=e,i._paddedItemSize=c}let l=s.byteLength,u=l+(4-l%4)%4;iR.label=n.name,iR.size=u,iR.usage=t,iR.mappedAtCreation=!0,a=o.createBuffer(iR),iR.reset(),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array,s=i._itemSize,c=i._paddedItemSize;if(c!==void 0){o=new o.constructor(t.count*c);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*s,e*s+s),e*c);(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(t.array=o)}let l=t.updateRanges;if(l.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=Po(o),n=e?1:o.BYTES_PER_ELEMENT;for(let t=0,i=l.length;t<i;t++){let i=l[t],u,d;if(c!==void 0){let e=Math.floor(i.start/s),t=Math.ceil((i.start+i.count)/s)-e;u=e*c*n,d=t*c*n}else u=i.start*n,d=i.count*n;let f=u*(e?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,f,o,u,d)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?pL.Instance:pL.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?pL.Instance:pL.Vertex,r.itemSize>1&&e%4!=0&&(e=Math.floor((e+3)/4)*4)),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,n=0,r=-1){let i=this.backend,a=i.device,o=i.get(this._getBufferAttribute(e)).buffer,s=r===-1?o.size-n:r,c;if(t!==null&&t.isReadbackBuffer){let e=i.get(t);if(t._mapped===!0)throw Error(`THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.`);if(t._mapped=!0,e.readBufferGPU===void 0){iR.label=`${t.name}_readback`,iR.size=t.maxByteLength,iR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(iR),iR.reset();let n=()=>{t.buffer=null,t._mapped=!1,c.unmap()},r=()=>{t.buffer=null,t._mapped=!1,c.destroy(),i.delete(t),t.removeEventListener(`release`,n),t.removeEventListener(`dispose`,r)};t.addEventListener(`release`,n),t.addEventListener(`dispose`,r),e.readBufferGPU=c}else c=e.readBufferGPU}else iR.label=`${e.name}_readback`,iR.size=s,iR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(iR),iR.reset();aR.label=`readback_encoder_${e.name}`;let l=a.createCommandEncoder(aR);if(aR.reset(),l.copyBufferToBuffer(o,n,c,0,s),_L(a,l.finish()),await c.mapAsync(GPUMapMode.READ,0,s),t===null){let e=c.getMappedRange(0,s).slice();return c.destroy(),e}if(t.isReadbackBuffer)return t.buffer=c.getMappedRange(0,s),t;{let e=c.getMappedRange(0,s);return new Uint8Array(t).set(new Uint8Array(e)),c.destroy(),t}}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=jle.get(r);else{let e=(Ale.get(i)||oR.get(r))[+!!n];if(e){let n=r.BYTES_PER_ELEMENT*t,i=Math.floor((n+3)/4)*4/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${e}x${i}`}}return a||V(`WebGPUAttributeUtils: Vertex format not supported yet.`),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},sR=new vL,cR=new yL,lR=new DL,Nle=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},Ple=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let i=this._createLayoutEntries(e),a=yw(JSON.stringify(i)),o=this._bindGroupLayoutCache.get(a);return o===void 0&&(o=new Nle(n.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,r.layout=o,r.layoutKey=a,o.layoutGPU}createBindings(e,t,n,r=0){let{backend:i}=this,a=i.get(e),o=this.createBindingsLayout(e),s;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(s=a.groups[n])),s===void 0&&(s=this.createBindGroup(e,o),n>0&&(a.groups[n]=s,a.versions[n]=r)),a.group=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer,a=e.updateRanges;if(a.length===0)n.queue.writeBuffer(i,0,r,0);else{let e=Po(r),t=e?1:r.BYTES_PER_ELEMENT,o=a[0].start;for(let s=0,c=a.length;s<c;s++){let c=a[s],l=a[s+1],u=c.start+c.count;if(l!==void 0&&l.start===u)continue;let d=o*t,f=(u-o)*t,p=d*(e?r.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(i,p,r,d,f),l!==void 0&&(o=l.start)}}}createBindGroupIndex(e,t){let n=this.backend.device,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0];cR.label=`bindingCameraIndex_`+i,cR.size=16,cR.usage=r;let a=n.createBuffer(cR);cR.reset(),n.queue.writeBuffer(a,0,e,0),sR.label=`bindGroupCameraIndex_`+i,sR.layout=t,sR.entries.push({binding:0,resource:{buffer:a}});let o=n.createBindGroup(sR);return sR.reset(),o}createBindGroup(e,t){let n=this.backend,r=n.device,i=0;sR.label=`bindGroup_`+e.name,sR.layout=t;for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);sR.entries.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t.attribute).buffer;sR.entries.push({binding:i,resource:{buffer:e}})}else if(t.isSampledTexture){let e=n.get(t.texture),a;if(e.externalTexture!==void 0)a=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=t.store?t.mipLevel:0,i=`view-${e.texture.width}-${e.texture.height}`;if(e.texture.depthOrArrayLayers>1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${n}-${r}`,a=e[i],a===void 0){let o=rle.All,s;s=t.isSampledCubeTexture?fL.Cube:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?fL.TwoDArray:t.isSampledTexture3D?fL.ThreeD:fL.TwoD,lR.aspect=o,lR.dimension=s,lR.mipLevelCount=n,lR.baseMipLevel=r,a=e[i]=e.texture.createView(lR),lR.reset()}}sR.entries.push({binding:i,resource:a})}else if(t.isSampler){let e=n.get(t);sR.entries.push({binding:i,resource:e.sampler})}i++}let a=r.createBindGroup(sR);return sR.reset(),a}_createLayoutEntries(e){let t=[],n=0;for(let r of e.bindings){let e=this.backend,i={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let e={};r.isStorageBuffer&&(e.type=r.visibility&JI.COMPUTE&&(r.access===kw.READ_WRITE||r.access===kw.WRITE_ONLY)?sL.Storage:sL.ReadOnlyStorage),i.buffer=e}else if(r.isSampledTexture&&r.store){let e={};e.format=this.backend.get(r.texture).texture.format;let t=r.access;e.access=t===kw.READ_WRITE?cL.ReadWrite:t===kw.WRITE_ONLY?cL.WriteOnly:cL.ReadOnly,r.texture.isArrayTexture?e.viewDimension=fL.TwoDArray:r.texture.is3DTexture&&(e.viewDimension=fL.ThreeD),i.storageTexture=e}else if(r.isSampledTexture){let t={},{primarySamples:n}=e.utils.getTextureSampleData(r.texture);if(n>1&&(t.multisampled=!0,r.texture.isDepthTexture||(t.sampleType=uL.UnfilterableFloat)),r.texture.isDepthTexture)t.sampleType=e.compatibilityMode&&r.texture.compareFunction===null?uL.UnfilterableFloat:uL.Depth;else{let e=r.texture.type;e===1013?t.sampleType=uL.SInt:e===1014?t.sampleType=uL.UInt:e===1015&&(t.sampleType=this.backend.hasFeature(`float32-filterable`)?uL.Float:uL.UnfilterableFloat)}r.isSampledCubeTexture?t.viewDimension=fL.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?t.viewDimension=fL.TwoDArray:r.isSampledTexture3D&&(t.viewDimension=fL.ThreeD),i.texture=t}else if(r.isSampler){let t={};r.texture.isDepthTexture&&(t.type=r.texture.compareFunction!==null&&r.textureNode.compareNode!==null&&e.hasCompatibility(Mo.TEXTURE_COMPARE)?lL.Comparison:lL.NonFiltering),i.sampler=t}else V(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(i),n++}return t}deleteBindGroupData(e){let{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},Fle=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},Ile=class{constructor(){this.label=``,this.layout=null,this.compute=null}reset(){this.label=``,this.layout=null,this.compute=null}},Lle=class{constructor(){this.label=``,this.bindGroupLayouts=null}reset(){this.label=``,this.bindGroupLayouts=null}},uR=new Ile,dR=new Lle,fR=new xL,pR=new wL,Rle=class{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let{layoutGPU:e}=c.get(t).layout;f.push(e)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==0&&(r.blending!==1||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures,n=e.context.mrt;for(let e=0;e<t.length;e++){let r=t[e],i=u.getTextureFormatGPU(r),a;if(n!==null){if(this.backend.compatibilityMode!==!0){let e=n.getBlendMode(r.name);e.blending===6?a=m:e.blending!==0&&(a=this._getBlending(e))}else Bo(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`),a=m}else a=m;_.push({format:i,blend:a,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),C=this._getSampleCount(e.context);dR.bindGroupLayouts=f;let w=l.createPipelineLayout(dR);dR.reset(),pR.label=`renderPipeline_${r.name||r.type}_${r.id}`,pR.vertex=Object.assign({},v,{buffers:p}),pR.fragment=Object.assign({},y,{targets:_}),pR.primitive=b,pR.multisample.count=C,pR.multisample.alphaToCoverageEnabled=r.alphaToCoverage&&C>1,pR.layout=w;let T={},E=e.context.depth,D=e.context.stencil;(E===!0||D===!0)&&(E===!0&&(T.format=S,T.depthWriteEnabled=r.depthWrite,T.depthCompare=x),D===!0&&(T.stencilFront=h,T.stencilBack=h,T.stencilReadMask=r.stencilFuncMask,T.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&b.topology===qI.TriangleList&&(T.depthBias=r.polygonOffsetUnits,T.depthBiasSlopeScale=r.polygonOffsetFactor,T.depthBiasClamp=0),pR.depthStencil=T),l.pushErrorScope(`validation`);let O=[{program:o,module:v.module},{program:s,module:y.module}],k=pR.label;if(t===null)d.pipeline=l.createRenderPipeline(pR),pR.reset(),l.popErrorScope().then(e=>{e!==null&&(d.error=!0,V(`WebGPURenderer: Render pipeline creation failed (${k}): ${e.message}`),this._reportShaderDiagnostics(O,k))});else{let e=new Promise(async e=>{try{let e=null,t=null;try{t=l.createRenderPipelineAsync(pR)}catch(t){e=t}if(pR.reset(),t!==null)try{d.pipeline=await t}catch(t){e=t}let n=await l.popErrorScope();if(n!==null||e!==null){d.error=!0;let t=n&&n.message||e&&e.message||`unknown`;V(`WebGPURenderer: Async render pipeline creation failed (${k}): ${t}`),await this._reportShaderDiagnostics(O,k)}}finally{e()}});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let{utils:n,device:r}=this.backend,i=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormats(e),o=this._getSampleCount(e);fR.label=t,fR.colorFormats=a,fR.depthStencilFormat=i,fR.sampleCount=o;let s=r.createRenderBundleEncoder(fR);return fR.reset(),s}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let{layoutGPU:t}=n.get(e).layout;o.push(t)}let s=e.computeProgram,c=`computePipeline_${s.stage}${s.name?`_${s.name}`:``}`;r.pushErrorScope(`validation`),dR.bindGroupLayouts=o;let l=r.createPipelineLayout(dR);dR.reset(),uR.label=c,uR.compute=i,uR.layout=l,a.pipeline=r.createComputePipeline(uR),uR.reset(),r.popErrorScope().then(e=>{e!==null&&(a.error=!0,V(`WebGPURenderer: Compute pipeline creation failed (${c}): ${e.message}`),this._reportShaderDiagnostics([{program:s,module:i.module}],c))})}async _reportShaderDiagnostics(e,t){for(let{program:n,module:r}of e){let e=await r.getCompilationInfo();if(e.messages.length===0)continue;let i=n.code.split(`
|
|
5165
|
-
`);for(let r of e.messages){let e=r.lineNum>0?` at line ${r.lineNum}${r.linePos>0?`:${r.linePos}`:``}`:``,a=`WebGPURenderer [${t} / ${n.stage} ${r.type}]${e}: ${r.message}`,o=``;r.lineNum>0&&r.lineNum<=i.length&&(o=`\n ${i[r.lineNum-1]}`,r.linePos>0&&(o+=`\n ${` `.repeat(r.linePos-1)}^`)),(r.type===`error`?V:B)(a+o)}}}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===5){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:iL.Add},n={srcFactor:i,dstFactor:a,operation:iL.Add}};if(i)switch(r){case 1:a(rL.One,rL.OneMinusSrcAlpha,rL.One,rL.OneMinusSrcAlpha);break;case 2:a(rL.One,rL.One,rL.One,rL.One);break;case 3:a(rL.Zero,rL.OneMinusSrc,rL.Zero,rL.One);break;case 4:a(rL.Dst,rL.OneMinusSrcAlpha,rL.Zero,rL.One)}else switch(r){case 1:a(rL.SrcAlpha,rL.OneMinusSrcAlpha,rL.One,rL.OneMinusSrcAlpha);break;case 2:a(rL.SrcAlpha,rL.One,rL.One,rL.One);break;case 3:V(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break;case 4:V(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`)}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};V(`WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case 200:t=rL.Zero;break;case 201:t=rL.One;break;case 202:t=rL.Src;break;case 203:t=rL.OneMinusSrc;break;case 204:t=rL.SrcAlpha;break;case 205:t=rL.OneMinusSrcAlpha;break;case 208:t=rL.Dst;break;case 209:t=rL.OneMinusDst;break;case 206:t=rL.DstAlpha;break;case 207:t=rL.OneMinusDstAlpha;break;case 210:t=rL.SrcAlphaSaturated;break;case JN:t=rL.Constant;break;case YN:t=rL.OneMinusConstant;break;default:V(`WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case 512:t=YI.Never;break;case 519:t=YI.Always;break;case 513:t=YI.Less;break;case 515:t=YI.LessEqual;break;case 514:t=YI.Equal;break;case 518:t=YI.GreaterEqual;break;case 516:t=YI.Greater;break;case 517:t=YI.NotEqual;break;default:V(`WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bo:t=oL.Keep;break;case 0:t=oL.Zero;break;case xo:t=oL.Replace;break;case Eo:t=oL.Invert;break;case So:t=oL.IncrementClamp;break;case Co:t=oL.DecrementClamp;break;case wo:t=oL.IncrementWrap;break;case To:t=oL.DecrementWrap;break;default:V(`WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case 100:t=iL.Add;break;case 101:t=iL.Subtract;break;case 102:t=iL.ReverseSubtract;break;case 103:t=iL.Min;break;case 104:t=iL.Max;break;default:V(`WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={};r.topology=this.backend.utils.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?eL.Uint16:eL.Uint32);let i=n.side===1;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(i=!i),r.frontFace=i===!0?QI.CW:QI.CCW,r.cullMode=n.side===2?$I.None:$I.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?aL.All:aL.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=YI.Always;else{let n=this.backend.parameters.reversedDepthBuffer?Uo[e.depthFunc]:e.depthFunc;switch(n){case 0:t=YI.Never;break;case 1:t=YI.Always;break;case 2:t=YI.Less;break;case 3:t=YI.LessEqual;break;case 4:t=YI.Equal;break;case 5:t=YI.GreaterEqual;break;case 6:t=YI.Greater;break;case 7:t=YI.NotEqual;break;default:V(`WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},mR=class{constructor(){this.label=``,this.type=void 0,this.count=0}reset(){this.label=``,this.type=void 0,this.count=0}},hR=new yL,zle=new bL,gR=new mR,Ble=class extends GI{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,gR.label=`queryset_global_timestamp_${t}`,gR.type=`timestamp`,gR.count=this.maxQueries,this.querySet=this.device.createQuerySet(gR),gR.reset();let r=this.maxQueries*8;hR.label=`buffer_timestamp_resolve_${t}`,hR.size=r,hR.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(hR),hR.reset(),hR.label=`buffer_timestamp_result_${t}`,hR.size=r,hR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(hR),hR.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Bo(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(zle);r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(_L(this.device,i),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o={},s=[];for(let[t,n]of e){let e=t.match(/^(.*):f(\d+)$/),r=parseInt(e[2]);s.includes(r)===!1&&s.push(r),o[r]===void 0&&(o[r]=0);let i=a[n],c=a[n+1],l=Number(c-i)/1e6;this.timestamps.set(t,l),o[r]+=l}let c=o[s[s.length-1]];return this.resultBuffer.unmap(),this.lastValue=c,this.frames=s,c}catch(e){return V(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){V(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){V(`Error unmapping buffer:`,e)}this.querySet&&=(this.querySet.destroy(),null),this.resolveBuffer&&=(this.resolveBuffer.destroy(),null),this.resultBuffer&&=(this.resultBuffer.destroy(),null),this.queryOffsets.clear(),this.pendingResolve=null}}},Vle=class{constructor(){this.label=``,this.timestampWrites=void 0}reset(){this.label=``,this.timestampWrites=void 0}},_R=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},Hle=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},vR={r:0,g:0,b:0,a:1},yR=new yL,bR=new bL,xR=new Vle,SR=new mR,CR=new TL,wR=new Hle,TR=new RL,ER=new RL,DR=new DL,OR=new zL,Ule=class extends II{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0||e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new cle(this),this.attributeUtils=new Mle(this),this.bindingUtils=new Ple(this),this.capabilities=new Fle(this),this.pipelineUtils=new Rle(this),this.textureUtils=new yle(this),this.occludedResolveCache=new Map;let t=typeof navigator>`u`||/Android/.test(navigator.userAgent)===!1;this._compatibility={[Mo.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let r={powerPreference:t.powerPreference,featureLevel:`compatibility`,xrCompatible:e.xr.enabled},i=typeof navigator<`u`?await navigator.gpu.requestAdapter(r):null;if(i===null)throw Error(`THREE.WebGPUBackend: Unable to create WebGPU adapter.`);let a=Object.values(mL),o=[];for(let e of a)i.features.has(e)&&o.push(e);let s={requiredFeatures:o,requiredLimits:t.requiredLimits};n=await i.requestDevice(s)}else n=t.device;this.compatibilityMode=!n.features.has(`core-features-and-limits`),this.compatibilityMode&&(e._samples=0),n.lost.then(t=>{if(t.reason===`destroyed`)return;let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}),n.onuncapturederror=t=>{let n=t.error,r=n&&n.constructor?n.constructor.name:`GPUError`,i=n&&n.message||`Unknown uncaptured GPU error`;e.onError({api:`WebGPU`,type:r,message:i,originalEvent:t})},this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(mL.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,n=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:n,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),n=t.context;if(n===void 0){let r=this.parameters;n=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext(`webgpu`),`setAttribute`in e.domElement&&e.domElement.setAttribute(`data-engine`,`three.js r185 webgpu`);let i=r.alpha?`premultiplied`:`opaque`,a=r.outputType===1016?`extended`:`standard`;n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:a}}),t.context=n}return n}get coordinateSystem(){return Ao}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples,i=n.descriptor;if(i===void 0||n.samples!==r){if(i=new CL,i.colorAttachments.push(new SL),e.depth===!0||e.stencil===!0){let t=new _R;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}let t=i.colorAttachments[0];r>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,n.descriptor=i,n.samples=r}let a=i.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){let t=e.textures;if(t===null)return!1;for(let e=0;e<t.length;e++)if(this.get(t[e]).externalTexture===!0)return!0;return!1}_createExternalTextureViews(e,t){let n=[],r=e.camera;if(t.xrViewDescriptors&&r!==null&&r.isArrayCamera===!0)for(let e=0;e<t.xrViewDescriptors.length;e++)n.push({view:t.texture.createView(t.xrViewDescriptors[e]),resolveTarget:void 0,depthSlice:void 0});else n.push({view:t.texture.createView({dimension:fL.TwoD,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return n}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=this._hasExternalTexture(e),a=r.descriptors;(a===void 0||r.width!==n.width||r.height!==n.height||r.samples!==n.samples||i)&&(a={},r.descriptors=a);let o=e.getCacheKey(),s=a[o];if(s===void 0||i){let t=e.textures,i=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let a=this.get(t[r]);if(a.externalTexture===!0){i.push(...this._createExternalTextureViews(e,a));continue}if(DR.label=`colorAttachment_${r}`,DR.baseMipLevel=e.activeMipmapLevel,DR.mipLevelCount=1,DR.baseArrayLayer=e.activeCubeFace,DR.arrayLayerCount=1,DR.dimension=fL.TwoD,n.isRenderTarget3D)c=e.activeCubeFace,DR.baseArrayLayer=0,DR.dimension=fL.ThreeD;else if(n.isRenderTarget&&t[r].image.depth>1){if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){DR.baseArrayLayer=e,DR.arrayLayerCount=1,DR.dimension=fL.TwoD;let t=a.texture.createView(DR);i.push({view:t,resolveTarget:void 0,depthSlice:void 0})}}else DR.dimension=fL.TwoDArray}if(l!==!0){let e=a.texture.createView(DR),t,n;a.msaaTexture===void 0?(t=e,n=void 0):(t=a.msaaTexture.createView(),n=e),i.push({view:t,resolveTarget:n,depthSlice:c})}DR.reset()}let u=[];for(let e=0;e<i.length;e++){let t=i[e],n=new SL;n.view=t.view,n.depthSlice=t.depthSlice,n.resolveTarget=t.resolveTarget,u.push(n)}if(s={textureViews:i,colorAttachments:u,descriptor:new CL},e.depth){let t=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(DR.dimension=fL.TwoD,DR.arrayLayerCount=1,DR.baseArrayLayer=e.activeCubeFace);let n=new _R;n.view=t.texture.createView(DR),s.depthStencilAttachment=n,DR.reset()}a[o]=s,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}let c=s.descriptor;c.reset();for(let e=0;e<s.colorAttachments.length;e++){let n=s.colorAttachments[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),n.loadOp=t.loadOp||ZI.Load,n.storeOp=t.storeOp||XI.Store,n.clearValue=r,c.colorAttachments.push(n)}return s.depthStencilAttachment&&(c.depthStencilAttachment=s.depthStencilAttachment),c}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,SR.label=`occlusionQuerySet_${e.id}`,SR.type=`occlusion`,SR.count=r,i=n.createQuerySet(SR),SR.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:ZI.Load}),this.initTimestampQuery(jo.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(n===0?r.clearValue=e.clearColorValue:(vR.r=0,vR.g=0,vR.b=0,vR.a=1,r.clearValue=vR),r.loadOp=ZI.Clear):r.loadOp=ZI.Load,r.storeOp=XI.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=ZI.Clear):t.loadOp=ZI.Load,t.storeOp=XI.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=ZI.Clear):o.depthLoadOp=ZI.Load,o.depthStoreOp=XI.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=ZI.Clear):o.stencilLoadOp=ZI.Load,o.stencilStoreOp=XI.Store),bR.label=`renderContext_`+e.id;let s=n.createCommandEncoder(bR);if(bR.reset(),this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createArrayCameraLayerDescriptors(e,t,a,n):this._updateArrayCameraLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r);t.bundleEncoders.push(n),t.bundleSets.push({attributes:{},bindingGroups:[],pipeline:null,index:null})}t.currentPass=null}else t.currentPass=s.beginRenderPass(a),e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e);t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createArrayCameraLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r=n.colorAttachments[0],s=new SL;s.view=n.colorAttachments[o].view,s.depthSlice=r.depthSlice,s.resolveTarget=r.resolveTarget,s.loadOp=r.loadOp,s.storeOp=r.storeOp,s.clearValue=r.clearValue;let c=new CL;if(c.label=n.label,c.occlusionQuerySet=n.occlusionQuerySet,c.timestampWrites=n.timestampWrites,c.colorAttachments.push(s),n.depthStencilAttachment){let t=o;a.viewCache[t]||(DR.dimension=fL.TwoD,DR.baseArrayLayer=o,DR.arrayLayerCount=1,a.viewCache[t]=a.texture.createView(DR),DR.reset());let n=new _R;n.view=a.viewCache[t],n.depthLoadOp=i.depthLoadOp||ZI.Clear,n.depthStoreOp=i.depthStoreOp||XI.Store,n.depthClearValue=i.depthClearValue||1,e.stencil&&(n.stencilLoadOp=i.stencilLoadOp,n.stencilStoreOp=i.stencilStoreOp,n.stencilClearValue=i.stencilClearValue),c.depthStencilAttachment=n}else{let e=new _R;e.view=i.view,e.depthLoadOp=i.depthLoadOp,e.depthStoreOp=i.depthStoreOp,e.depthClearValue=i.depthClearValue,e.depthReadOnly=i.depthReadOnly,e.stencilLoadOp=i.stencilLoadOp,e.stencilStoreOp=i.stencilStoreOp,e.stencilClearValue=i.stencilClearValue,e.stencilReadOnly=i.stencilReadOnly,c.depthStencilAttachment=e}t.layerDescriptors.push(c)}}_updateArrayCameraLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=ZI.Clear):t.depthLoadOp=ZI.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=ZI.Clear):t.stencilLoadOp=ZI.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(yR.size=r,yR.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer(yR),yR.reset(),this.occludedResolveCache.set(r,i)),yR.size=r,yR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(yR);yR.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(_L(this.device,t.encoder.finish()),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}updateScissor(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a}=e.scissorValue;t.setScissorRect(n,r,i,a)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l;if(e){let e=this.getClearColor();vR.r=e.r,vR.g=e.g,vR.b=e.b,vR.a=e.a}if(r===null){c=a.depth,l=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=vR,e.loadOp=ZI.Clear,e.storeOp=XI.Store}(c||l)&&(s=t.depthStencilAttachment)}else{c=r.depth,l=r.stencil;let i={loadOp:e?ZI.Clear:ZI.Load,clearValue:e?vR:void 0};c&&(i.depthLoadOp=t?ZI.Clear:ZI.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=XI.Store),l&&(i.stencilLoadOp=n?ZI.Clear:ZI.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=XI.Store);let u=this._getRenderPassDescriptor(r,i);o=u.colorAttachments,s=u.depthStencilAttachment}c&&s&&(t?(s.depthLoadOp=ZI.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=XI.Store):(s.depthLoadOp=ZI.Load,s.depthStoreOp=XI.Store)),l&&s&&(n?(s.stencilLoadOp=ZI.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=XI.Store):(s.stencilLoadOp=ZI.Load,s.stencilStoreOp=XI.Store)),bR.label=`clear`;let u=i.createCommandEncoder(bR);bR.reset(),u.beginRenderPass({colorAttachments:o,depthStencilAttachment:s}).end(),_L(i,u.finish())}beginCompute(e){let t=this.get(e),n=`computeGroup_`+e.id;xR.label=n,bR.label=n,this.initTimestampQuery(jo.COMPUTE,this.getTimestampUID(e),xR),t.cmdEncoderGPU=this.device.createCommandEncoder(bR),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(xR),t.currentPipeline=null,bR.reset(),xR.reset()}compute(e,t,n,r,i=null){let a=this.get(t),o=this.get(e),{passEncoderGPU:s}=o,c=this.get(r).pipeline;o.currentPipeline!==c&&(s.setPipeline(c),o.currentPipeline=c);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);s.setBindGroup(e,r.group)}if(i===null&&(i=t.dispatchSize||t.count),i&&i.isIndirectStorageBufferAttribute){let e=this.get(i).buffer;s.dispatchWorkgroupsIndirect(e,0);return}if(typeof i==`number`){let e=i;if(a.dispatchSize===void 0||a.count!==e){a.dispatchSize=[0,1,1],a.count=e;let n=t.workgroupSize,r=n[0];for(let e=1;e<n.length;e++)r*=n[e];let o=Math.ceil(e/r),s=this.device.limits.maxComputeWorkgroupsPerDimension;i=[o,1,1],o>s&&(i[0]=Math.min(o,s),i[1]=Math.ceil(o/s)),a.dispatchSize=i}i=a.dispatchSize}s.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),_L(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,n,r,i,a,o,s,c){let{object:l,material:u,context:d}=e,f=e.getIndex(),p=f!==null;c.pipeline!==r&&(s.setPipeline(r),c.pipeline=r);let m=c.bindingGroups;for(let e=0,t=i.length;e<t;e++){let t=i[e];if(m[e]!==t.id){let n=this.get(t);s.setBindGroup(e,n.group),m[e]=t.id}}if(p===!0&&c.index!==f){let e=this.get(f).buffer,t=f.array instanceof Uint16Array?eL.Uint16:eL.Uint32;s.setIndexBuffer(e,t),c.index=f}for(let e=0,t=a.length;e<t;e++){let t=a[e];if(c.attributes[e]!==t){let n=this.get(t).buffer;s.setVertexBuffer(e,n),c.attributes[e]=t}}if(d.stencil===!0&&u.stencilWrite===!0&&n.currentStencilRef!==u.stencilRef&&(s.setStencilReference(u.stencilRef),n.currentStencilRef=u.stencilRef),l.isBatchedMesh===!0){let e=l._multiDrawStarts,n=l._multiDrawCounts,r=l._multiDrawCount,i=p===!0?f.array.BYTES_PER_ELEMENT:1;u.wireframe&&(i=l.geometry.attributes.position.count>65535?4:2);for(let a=0;a<r;a++)p===!0?s.drawIndexed(n[a],1,e[a]/i,0,a):s.draw(n[a],1,e[a],a),t.update(l,n[a],1)}else if(p===!0){let{vertexCount:n,instanceCount:r,firstVertex:i}=o,a=e.getIndirect();if(a!==null){let t=this.get(a).buffer,n=e.getIndirectOffset(),r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e++)s.drawIndexedIndirect(t,r[e])}else s.drawIndexed(n,r,i,0,0);t.update(l,n,r)}else{let{vertexCount:n,instanceCount:r,firstVertex:i}=o,a=e.getIndirect();if(a!==null){let t=this.get(a).buffer,n=e.getIndirectOffset(),r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e++)s.drawIndirect(t,r[e])}else s.draw(n,r,i,0);t.update(l,n,r)}}draw(e,t){let{object:n,context:r,pipeline:i}=e,a=this.get(r),o=this.get(i),s=o.pipeline;if(o.error===!0)return;let c=e.getDrawParameters();if(c===null)return;let l=e.getBindings(),u=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let i=this.get(e.camera),o=e.camera.cameras,d=e.getBindingGroup(`cameraIndex`);if(i.indexesGPU===void 0||i.indexesGPU.length!==o.length){let e=this.get(d),t=[],n=new Uint32Array([0,0,0,0]);for(let r=0,i=o.length;r<i;r++){n[0]=r;let{layoutGPU:i}=e.layout,a=this.bindingUtils.createBindGroupIndex(n,i);t.push(a)}i.indexesGPU=t}let f=this.renderer.getPixelRatio();for(let p=0,m=o.length;p<m;p++){let m=o[p];if(n.layers.test(m.layers)){let n=m.viewport,o=a.currentPass,h=a.currentSets,g=a.bundleEncoders!==void 0;if(g){let e=a.bundleEncoders[p],t=a.bundleSets[p];o=e,h=t}if(n&&!g&&o.setViewport(Math.floor(n.x*f),Math.floor(n.y*f),Math.floor(n.width*f),Math.floor(n.height*f),r.viewportValue.minDepth,r.viewportValue.maxDepth),d&&i.indexesGPU){let e=l.indexOf(d);o.setBindGroup(e,i.indexesGPU[p]),h.bindingGroups[e]=d.id}this._draw(e,t,a,s,l,u,c,o,h)}}}else if(a.currentPass){if(a.occlusionQuerySet!==void 0){let e=a.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(a.currentPass.endOcclusionQuery(),a.occlusionQueryIndex++),n.occlusionTest===!0&&(a.currentPass.beginOcclusionQuery(a.occlusionQueryIndex),a.occlusionQueryObjects[a.occlusionQueryIndex]=n),a.lastOcclusionObject=n)}this._draw(e,t,a,s,l,u,c,a.currentPass,a.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=n.isMesh&&n.matrixWorld.determinantAffine()<0,d=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.frontFaceCW!==u||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.frontFaceCW=u,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context,a=t.isMesh&&t.matrixWorld.determinantAffine()<0;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,a,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new Ble(this.device,e,2048));let r=this.timestampQueryPool[e],i=r.allocateQueriesForContext(t);wR.querySet=r.querySet,wR.beginningOfPassWriteIndex=i,wR.endOfPassWriteIndex=i+1,n.timestampWrites=wR}createNodeBuilder(e,t){return new kle(e,t)}createProgram(e){let t=this.get(e);CR.label=e.stage+(e.name===``?``:`_${e.name}`),CR.code=e.code,t.module={module:this.device.createShaderModule(CR),entryPoint:`main`},CR.reset()}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass.finish();this.get(t).bundleGPU=r,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createUniformBuffer(e){let t=this.get(e);if(t.buffer===void 0){let n=e.byteLength,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=[];e.visibility&JI.VERTEX&&i.push(`vertex`),e.visibility&JI.FRAGMENT&&i.push(`fragment`),e.visibility&JI.COMPUTE&&i.push(`compute`);let a=`(${i.join(`,`)})`;yR.label=`bindingBuffer${e.id}_${e.name}_${a}`,yR.size=n,yR.usage=r;let o=this.device.createBuffer(yR);yR.reset(),t.buffer=o}}destroyUniformBuffer(e){this.get(e).buffer.destroy(),this.delete(e)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(e){return hL[e]!==void 0&&(e=hL[e]),this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0),bR.label=`copyTextureToTexture_`+e.id+`_`+t.id;let h=this.device.createCommandEncoder(bR);bR.reset();let g=this.get(e).texture,_=this.get(t).texture;TR.texture=g,TR.mipLevel=i,TR.origin.x=l,TR.origin.y=u,TR.origin.z=d,ER.texture=_,ER.mipLevel=a,ER.origin.x=o,ER.origin.y=s,ER.origin.z=c,OR.width=f,OR.height=p,OR.depthOrArrayLayers=m,h.copyTextureToTexture(TR,ER,OR),TR.reset(),ER.reset(),OR.reset(),_L(this.device,h.finish()),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){V(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):(bR.label=`copyFramebufferToTexture_`+e.id,o=this.device.createCommandEncoder(bR),bR.reset()),TR.texture=i,TR.origin.x=n.x,TR.origin.y=n.y,ER.texture=a,OR.width=n.z,OR.height=n.w,o.copyTextureToTexture(TR,ER,OR),TR.reset(),ER.reset(),OR.reset(),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,o),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=ZI.Load;t.depth&&(e.depthStencilAttachment.depthLoadOp=ZI.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=ZI.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else _L(this.device,o.finish())}hasCompatibility(e){return this._compatibility[e]===void 0?super.hasCompatibility(e):this._compatibility[e]}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},Wle=class extends ff{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},Gle=class extends ff{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},Kle=class extends iI{constructor(){super(),this.addMaterial(gj,`MeshPhongMaterial`),this.addMaterial(_N,`MeshStandardMaterial`),this.addMaterial(yN,`MeshPhysicalMaterial`),this.addMaterial(CN,`MeshToonMaterial`),this.addMaterial(oj,`MeshBasicMaterial`),this.addMaterial(mj,`MeshLambertMaterial`),this.addMaterial(GA,`MeshNormalMaterial`),this.addMaterial(EN,`MeshMatcapMaterial`),this.addMaterial(FA,`LineBasicMaterial`),this.addMaterial(LA,`LineDashedMaterial`),this.addMaterial(MN,`PointsMaterial`),this.addMaterial(kN,`SpriteMaterial`),this.addMaterial(IN,`ShadowMaterial`),this.addLight(Nse,mf),this.addLight(lce,_f),this.addLight(hce,yf),this.addLight(KF,ff),this.addLight(cce,vf),this.addLight(uce,Zd),this.addLight(fce,xf),this.addLight(dce,Wle),this.addLight(mce,Gle),this.addToneMapping(JP,1),this.addToneMapping(YP,2),this.addToneMapping(XP,3),this.addToneMapping(QP,4),this.addToneMapping(nF,6),this.addToneMapping(rF,7)}},qle=class extends Lce{constructor(e={}){let t;e.forceWebGL?t=KI:(t=Ule,e.getFallback=()=>(B(`WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new KI(e)));let n=new t(e);super(n,e),this.library=new Kle,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},kR={type:`change`},AR={type:`start`},jR={type:`end`},MR=1e-6,NR={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},PR=new H,FR=new H,Jle=new U,IR=new U,LR=new U,RR=new vs,zR=new U,BR=new U,VR=new U,HR=new U,Yle=class extends qf{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=[`KeyA`,`KeyS`,`KeyD`],this.mouseButtons={LEFT:Wi.ROTATE,MIDDLE:Wi.DOLLY,RIGHT:Wi.PAN},this.target=new U,this.state=NR.NONE,this.keyState=NR.NONE,this._lastPosition=new U,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new U,this._movePrev=new H,this._moveCurr=new H,this._lastAxis=new U,this._zoomStart=new H,this._zoomEnd=new H,this._panStart=new H,this._panEnd=new H,this._pointers=[],this._pointerPositions={},this._onPointerMove=Zle.bind(this),this._onPointerDown=Xle.bind(this),this._onPointerUp=Qle.bind(this),this._onPointerCancel=$le.bind(this),this._onContextMenu=oue.bind(this),this._onMouseWheel=aue.bind(this),this._onKeyDown=tue.bind(this),this._onKeyUp=eue.bind(this),this._onTouchStart=sue.bind(this),this._onTouchMove=cue.bind(this),this._onTouchEnd=lue.bind(this),this._onMouseDown=nue.bind(this),this._onMouseMove=rue.bind(this),this._onMouseUp=iue.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener(`keydown`,this._onKeyDown),window.addEventListener(`keyup`,this._onKeyUp),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerCancel),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=`none`}disconnect(){window.removeEventListener(`keydown`,this._onKeyDown),window.removeEventListener(`keyup`,this._onKeyUp),this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerCancel),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=``}dispose(){this.disconnect()}handleResize(){let e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>MR&&(this.dispatchEvent(kR),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>MR||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(kR),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn(`THREE.TrackballControls: Unsupported camera type.`)}reset(){this.state=NR.NONE,this.keyState=NR.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(kR),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(FR.copy(this._panEnd).sub(this._panStart),FR.lengthSq()){if(this.object.isOrthographicCamera){let 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;FR.x*=e,FR.y*=t}FR.multiplyScalar(this._eye.length()*this.panSpeed),IR.copy(this._eye).cross(this.object.up).setLength(FR.x),IR.add(Jle.copy(this.object.up).setLength(FR.y)),this.object.position.add(IR),this.target.add(IR),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(FR.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){HR.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=HR.length();e?(this._eye.copy(this.object.position).sub(this.target),zR.copy(this._eye).normalize(),BR.copy(this.object.up).normalize(),VR.crossVectors(BR,zR).normalize(),BR.setLength(this._moveCurr.y-this._movePrev.y),VR.setLength(this._moveCurr.x-this._movePrev.x),HR.copy(BR.add(VR)),LR.crossVectors(HR,this._eye).normalize(),e*=this.rotateSpeed,RR.setFromAxisAngle(LR,e),this._eye.applyQuaternion(RR),this.object.up.applyQuaternion(RR),this._lastAxis.copy(LR),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),RR.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(RR),this.object.up.applyQuaternion(RR)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===NR.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=_s.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=_s.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 PR.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),PR}_getMouseOnCircle(e,t){return PR.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),PR}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId==e.pointerId){this._pointers.splice(t,1);return}}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new H,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[t.pointerId]}_checkDistances(){(!this.noZoom||!this.noPan)&&(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}};function Xle(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e))}function Zle(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function Qle(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchEnd(e):this._onMouseUp(),this._removePointer(e),this._pointers.length===0&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp)))}function $le(e){this._removePointer(e)}function eue(){this.enabled!==!1&&(this.keyState=NR.NONE,window.addEventListener(`keydown`,this._onKeyDown))}function tue(e){this.enabled!==!1&&(window.removeEventListener(`keydown`,this._onKeyDown),this.keyState===NR.NONE&&(e.code===this.keys[NR.ROTATE]&&!this.noRotate?this.keyState=NR.ROTATE:e.code===this.keys[NR.ZOOM]&&!this.noZoom?this.keyState=NR.ZOOM:e.code===this.keys[NR.PAN]&&!this.noPan&&(this.keyState=NR.PAN)))}function nue(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Wi.DOLLY:this.state=NR.ZOOM;break;case Wi.ROTATE:this.state=NR.ROTATE;break;case Wi.PAN:this.state=NR.PAN;break;default:this.state=NR.NONE}let n=this.keyState===NR.NONE?this.state:this.keyState;n===NR.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY)),this._movePrev.copy(this._moveCurr)):n===NR.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(e.pageX,e.pageY)),this._zoomEnd.copy(this._zoomStart)):n===NR.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(e.pageX,e.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(AR)}function rue(e){let t=this.keyState===NR.NONE?this.state:this.keyState;t===NR.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY))):t===NR.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(e.pageX,e.pageY)):t===NR.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(e.pageX,e.pageY))}function iue(){this.state=NR.NONE,this.dispatchEvent(jR)}function aue(e){if(this.enabled!==!1&&this.noZoom!==!0){switch(e.preventDefault(),e.deltaMode){case 2:this._zoomStart.y-=e.deltaY*.025;break;case 1:this._zoomStart.y-=e.deltaY*.01;break;default:this._zoomStart.y-=e.deltaY*25e-5}this.dispatchEvent(AR),this.dispatchEvent(jR)}}function oue(e){this.enabled!==!1&&e.preventDefault()}function sue(e){switch(this._trackPointer(e),this._pointers.length){case 1:this.state=NR.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=NR.TOUCH_ZOOM_PAN;let e=this._pointers[0].pageX-this._pointers[1].pageX,t=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+t*t);let n=(this._pointers[0].pageX+this._pointers[1].pageX)/2,r=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(n,r)),this._panEnd.copy(this._panStart)}this.dispatchEvent(AR)}function cue(e){switch(this._trackPointer(e),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY));break;default:let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y;this._touchZoomDistanceEnd=Math.sqrt(n*n+r*r);let i=(e.pageX+t.x)/2,a=(e.pageY+t.y)/2;this._panEnd.copy(this._getMouseOnScreen(i,a))}}function lue(e){switch(this._pointers.length){case 0:this.state=NR.NONE;break;case 1:this.state=NR.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=NR.TOUCH_ZOOM_PAN;for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId!==e.pointerId){let e=this._pointerPositions[this._pointers[t].pointerId];this._moveCurr.copy(this._getMouseOnCircle(e.x,e.y)),this._movePrev.copy(this._moveCurr);break}}this.dispatchEvent(jR)}var UR={type:`change`},WR={type:`start`},GR={type:`end`},KR=new Rl,qR=new au,uue=Math.cos(70*_s.DEG2RAD),JR=new U,YR=2*Math.PI,XR={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ZR=1e-6,due=class extends qf{constructor(e,t=null){super(e,t),this.state=XR.NONE,this.target=new U,this.cursor=new U,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:Wi.ROTATE,MIDDLE:Wi.DOLLY,RIGHT:Wi.PAN},this.touches={ONE:Gi.ROTATE,TWO:Gi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new vs,this._lastTargetPosition=new U,this._quat=new vs().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Gf,this._sphericalDelta=new Gf,this._scale=1,this._panOffset=new U,this._rotateStart=new H,this._rotateEnd=new H,this._rotateDelta=new H,this._panStart=new H,this._panEnd=new H,this._panDelta=new H,this._dollyStart=new H,this._dollyEnd=new H,this._dollyDelta=new H,this._dollyDirection=new U,this._mouse=new H,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=pue.bind(this),this._onPointerDown=fue.bind(this),this._onPointerUp=mue.bind(this),this._onContextMenu=xue.bind(this),this._onMouseWheel=_ue.bind(this),this._onKeyDown=vue.bind(this),this._onTouchStart=yue.bind(this),this._onTouchMove=bue.bind(this),this._onMouseDown=hue.bind(this),this._onMouseMove=gue.bind(this),this._interceptControlDown=Sue.bind(this),this._interceptControlUp=Cue.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),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.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.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=``}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(UR),this.update(),this.state=XR.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;JR.copy(t).sub(this.target),JR.applyQuaternion(this._quat),this._spherical.setFromVector3(JR),this.autoRotate&&this.state===XR.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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=YR:n>Math.PI&&(n-=YR),r<-Math.PI?r+=YR:r>Math.PI&&(r-=YR),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(JR.setFromSpherical(this._spherical),JR.applyQuaternion(this._quatInverse),t.copy(this.target).add(JR),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 e=null;if(this.object.isPerspectiveCamera){let t=JR.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new U(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new U(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=JR.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(KR.origin.copy(this.object.position),KR.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(KR.direction))<uue?this.object.lookAt(this.target):(qR.setFromNormalAndCoplanarPoint(this.object.up,this.target),KR.intersectPlane(qR,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>ZR||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ZR||this._lastTargetPosition.distanceToSquared(this.target)>ZR?(this.dispatchEvent(UR),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?YR/60/60*this.autoRotateSpeed:YR/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){JR.setFromMatrixColumn(t,0),JR.multiplyScalar(-e),this._panOffset.add(JR)}_panUp(e,t){this.screenSpacePanning===!0?JR.setFromMatrixColumn(t,1):(JR.setFromMatrixColumn(t,0),JR.crossVectors(this.object.up,JR)),JR.multiplyScalar(e),this._panOffset.add(JR)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;JR.copy(r).sub(this.target);let i=JR.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.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;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*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);let t=this.domElement;this._rotateLeft(YR*this._rotateDelta.x/t.clientHeight),this._rotateUp(YR*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(YR*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(-YR*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(YR*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(-YR*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(YR*this._rotateDelta.x/t.clientHeight),this._rotateUp(YR*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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new H,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function fue(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function pue(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function mue(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(GR),this.state=XR.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y})}}function hue(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Wi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=XR.DOLLY;break;case Wi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=XR.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=XR.ROTATE}break;case Wi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=XR.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=XR.PAN}break;default:this.state=XR.NONE}this.state!==XR.NONE&&this.dispatchEvent(WR)}function gue(e){switch(this.state){case XR.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case XR.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case XR.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e)}}function _ue(e){this.enabled!==!1&&this.enableZoom!==!1&&this.state===XR.NONE&&(e.preventDefault(),this.dispatchEvent(WR),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(GR))}function vue(e){this.enabled!==!1&&this._handleKeyDown(e)}function yue(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Gi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=XR.TOUCH_ROTATE;break;case Gi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=XR.TOUCH_PAN;break;default:this.state=XR.NONE}break;case 2:switch(this.touches.TWO){case Gi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=XR.TOUCH_DOLLY_PAN;break;case Gi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=XR.TOUCH_DOLLY_ROTATE;break;default:this.state=XR.NONE}break;default:this.state=XR.NONE}this.state!==XR.NONE&&this.dispatchEvent(WR)}function bue(e){switch(this._trackPointer(e),this.state){case XR.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case XR.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case XR.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case XR.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=XR.NONE}}function xue(e){this.enabled!==!1&&e.preventDefault()}function Sue(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function Cue(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var wue={type:`change`},QR=1e-6,$R=new vs,Tue=class extends qf{constructor(e,t=null){super(e,t),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this._moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this._moveVector=new U(0,0,0),this._rotationVector=new U(0,0,0),this._lastQuaternion=new vs,this._lastPosition=new U,this._status=0,this._onKeyDown=Eue.bind(this),this._onKeyUp=Due.bind(this),this._onPointerMove=kue.bind(this),this._onPointerDown=Oue.bind(this),this._onPointerUp=Aue.bind(this),this._onPointerCancel=jue.bind(this),this._onContextMenu=Mue.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),window.addEventListener(`keydown`,this._onKeyDown),window.addEventListener(`keyup`,this._onKeyUp),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.addEventListener(`pointercancel`,this._onPointerCancel),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=`none`}disconnect(){window.removeEventListener(`keydown`,this._onKeyDown),window.removeEventListener(`keyup`,this._onKeyUp),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerCancel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=``}dispose(){this.disconnect()}update(e){if(this.enabled===!1)return;let t=this.object,n=e*this.movementSpeed,r=e*this.rollSpeed;t.translateX(this._moveVector.x*n),t.translateY(this._moveVector.y*n),t.translateZ(this._moveVector.z*n),$R.set(this._rotationVector.x*r,this._rotationVector.y*r,this._rotationVector.z*r,1).normalize(),t.quaternion.multiply($R),(this._lastPosition.distanceToSquared(t.position)>QR||8*(1-this._lastQuaternion.dot(t.quaternion))>QR)&&(this.dispatchEvent(wue),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){let e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement==document?{size:[window.innerWidth,window.innerHeight],offset:[0,0]}:{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}}};function Eue(e){if(!(e.altKey||this.enabled===!1)){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=.1;break;case`KeyW`:this._moveState.forward=1;break;case`KeyS`:this._moveState.back=1;break;case`KeyA`:this._moveState.left=1;break;case`KeyD`:this._moveState.right=1;break;case`KeyR`:this._moveState.up=1;break;case`KeyF`:this._moveState.down=1;break;case`ArrowUp`:this._moveState.pitchUp=1;break;case`ArrowDown`:this._moveState.pitchDown=1;break;case`ArrowLeft`:this._moveState.yawLeft=1;break;case`ArrowRight`:this._moveState.yawRight=1;break;case`KeyQ`:this._moveState.rollLeft=1;break;case`KeyE`:this._moveState.rollRight=1}this._updateMovementVector(),this._updateRotationVector()}}function Due(e){if(this.enabled!==!1){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=1;break;case`KeyW`:this._moveState.forward=0;break;case`KeyS`:this._moveState.back=0;break;case`KeyA`:this._moveState.left=0;break;case`KeyD`:this._moveState.right=0;break;case`KeyR`:this._moveState.up=0;break;case`KeyF`:this._moveState.down=0;break;case`ArrowUp`:this._moveState.pitchUp=0;break;case`ArrowDown`:this._moveState.pitchDown=0;break;case`ArrowLeft`:this._moveState.yawLeft=0;break;case`ArrowRight`:this._moveState.yawRight=0;break;case`KeyQ`:this._moveState.rollLeft=0;break;case`KeyE`:this._moveState.rollRight=0}this._updateMovementVector(),this._updateRotationVector()}}function Oue(e){if(this.enabled!==!1){if(this.dragToLook)this._status++;else{switch(e.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1}this._updateMovementVector()}}}function kue(e){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){let t=this._getContainerDimensions(),n=t.size[0]/2,r=t.size[1]/2;this._moveState.yawLeft=-(e.pageX-t.offset[0]-n)/n,this._moveState.pitchDown=(e.pageY-t.offset[1]-r)/r,this._updateRotationVector()}}function Aue(e){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(e.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0}this._updateMovementVector()}this._updateRotationVector()}}function jue(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Mue(e){this.enabled!==!1&&e.preventDefault()}var Nue={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
5164
|
+
var<${n}> ${e} : ${a};`}},aR=new bL,oR=new xL,sR=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&sR.set(Float16Array,[`float16`]);var kle=new Map([[dl,[`float16`]]]),Ale=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]),jle=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}n.array=s;let c;if((n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3)c=4;else if(n.itemSize>1&&n.itemSize*s.BYTES_PER_ELEMENT%4!=0){let e=n.itemSize*s.BYTES_PER_ELEMENT;c=Math.floor((e+3)/4)*4/s.BYTES_PER_ELEMENT}if(c!==void 0){let e=n.itemSize,t=new s.constructor(n.count*c);for(let r=0;r<n.count;r++)t.set(s.subarray(r*e,r*e+e),r*c);(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&(n.itemSize=c,n.array=t),s=t,i._itemSize=e,i._paddedItemSize=c}let l=s.byteLength,u=l+(4-l%4)%4;aR.label=n.name,aR.size=u,aR.usage=t,aR.mappedAtCreation=!0,a=o.createBuffer(aR),aR.reset(),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array,s=i._itemSize,c=i._paddedItemSize;if(c!==void 0){o=new o.constructor(t.count*c);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*s,e*s+s),e*c);(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(t.array=o)}let l=t.updateRanges;if(l.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=Po(o),n=e?1:o.BYTES_PER_ELEMENT;for(let t=0,i=l.length;t<i;t++){let i=l[t],u,d;if(c!==void 0){let e=Math.floor(i.start/s),t=Math.ceil((i.start+i.count)/s)-e;u=e*c*n,d=t*c*n}else u=i.start*n,d=i.count*n;let f=u*(e?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,f,o,u,d)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?mL.Instance:mL.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?mL.Instance:mL.Vertex,r.itemSize>1&&e%4!=0&&(e=Math.floor((e+3)/4)*4)),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,n=0,r=-1){let i=this.backend,a=i.device,o=i.get(this._getBufferAttribute(e)).buffer,s=r===-1?o.size-n:r,c;if(t!==null&&t.isReadbackBuffer){let e=i.get(t);if(t._mapped===!0)throw Error(`THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.`);if(t._mapped=!0,e.readBufferGPU===void 0){aR.label=`${t.name}_readback`,aR.size=t.maxByteLength,aR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(aR),aR.reset();let n=()=>{t.buffer=null,t._mapped=!1,c.unmap()},r=()=>{t.buffer=null,t._mapped=!1,c.destroy(),i.delete(t),t.removeEventListener(`release`,n),t.removeEventListener(`dispose`,r)};t.addEventListener(`release`,n),t.addEventListener(`dispose`,r),e.readBufferGPU=c}else c=e.readBufferGPU}else aR.label=`${e.name}_readback`,aR.size=s,aR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(aR),aR.reset();oR.label=`readback_encoder_${e.name}`;let l=a.createCommandEncoder(oR);if(oR.reset(),l.copyBufferToBuffer(o,n,c,0,s),vL(a,l.finish()),await c.mapAsync(GPUMapMode.READ,0,s),t===null){let e=c.getMappedRange(0,s).slice();return c.destroy(),e}if(t.isReadbackBuffer)return t.buffer=c.getMappedRange(0,s),t;{let e=c.getMappedRange(0,s);return new Uint8Array(t).set(new Uint8Array(e)),c.destroy(),t}}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=Ale.get(r);else{let e=(kle.get(i)||sR.get(r))[+!!n];if(e){let n=r.BYTES_PER_ELEMENT*t,i=Math.floor((n+3)/4)*4/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${e}x${i}`}}return a||V(`WebGPUAttributeUtils: Vertex format not supported yet.`),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},cR=new yL,lR=new bL,uR=new OL,Mle=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},Nle=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let i=this._createLayoutEntries(e),a=bw(JSON.stringify(i)),o=this._bindGroupLayoutCache.get(a);return o===void 0&&(o=new Mle(n.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,r.layout=o,r.layoutKey=a,o.layoutGPU}createBindings(e,t,n,r=0){let{backend:i}=this,a=i.get(e),o=this.createBindingsLayout(e),s;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(s=a.groups[n])),s===void 0&&(s=this.createBindGroup(e,o),n>0&&(a.groups[n]=s,a.versions[n]=r)),a.group=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer,a=e.updateRanges;if(a.length===0)n.queue.writeBuffer(i,0,r,0);else{let e=Po(r),t=e?1:r.BYTES_PER_ELEMENT,o=a[0].start;for(let s=0,c=a.length;s<c;s++){let c=a[s],l=a[s+1],u=c.start+c.count;if(l!==void 0&&l.start===u)continue;let d=o*t,f=(u-o)*t,p=d*(e?r.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(i,p,r,d,f),l!==void 0&&(o=l.start)}}}createBindGroupIndex(e,t){let n=this.backend.device,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0];lR.label=`bindingCameraIndex_`+i,lR.size=16,lR.usage=r;let a=n.createBuffer(lR);lR.reset(),n.queue.writeBuffer(a,0,e,0),cR.label=`bindGroupCameraIndex_`+i,cR.layout=t,cR.entries.push({binding:0,resource:{buffer:a}});let o=n.createBindGroup(cR);return cR.reset(),o}createBindGroup(e,t){let n=this.backend,r=n.device,i=0;cR.label=`bindGroup_`+e.name,cR.layout=t;for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);cR.entries.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t.attribute).buffer;cR.entries.push({binding:i,resource:{buffer:e}})}else if(t.isSampledTexture){let e=n.get(t.texture),a;if(e.externalTexture!==void 0)a=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=t.store?t.mipLevel:0,i=`view-${e.texture.width}-${e.texture.height}`;if(e.texture.depthOrArrayLayers>1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${n}-${r}`,a=e[i],a===void 0){let o=nle.All,s;s=t.isSampledCubeTexture?pL.Cube:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?pL.TwoDArray:t.isSampledTexture3D?pL.ThreeD:pL.TwoD,uR.aspect=o,uR.dimension=s,uR.mipLevelCount=n,uR.baseMipLevel=r,a=e[i]=e.texture.createView(uR),uR.reset()}}cR.entries.push({binding:i,resource:a})}else if(t.isSampler){let e=n.get(t);cR.entries.push({binding:i,resource:e.sampler})}i++}let a=r.createBindGroup(cR);return cR.reset(),a}_createLayoutEntries(e){let t=[],n=0;for(let r of e.bindings){let e=this.backend,i={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let e={};r.isStorageBuffer&&(e.type=r.visibility&YI.COMPUTE&&(r.access===Aw.READ_WRITE||r.access===Aw.WRITE_ONLY)?cL.Storage:cL.ReadOnlyStorage),i.buffer=e}else if(r.isSampledTexture&&r.store){let e={};e.format=this.backend.get(r.texture).texture.format;let t=r.access;e.access=t===Aw.READ_WRITE?lL.ReadWrite:t===Aw.WRITE_ONLY?lL.WriteOnly:lL.ReadOnly,r.texture.isArrayTexture?e.viewDimension=pL.TwoDArray:r.texture.is3DTexture&&(e.viewDimension=pL.ThreeD),i.storageTexture=e}else if(r.isSampledTexture){let t={},{primarySamples:n}=e.utils.getTextureSampleData(r.texture);if(n>1&&(t.multisampled=!0,r.texture.isDepthTexture||(t.sampleType=dL.UnfilterableFloat)),r.texture.isDepthTexture)t.sampleType=e.compatibilityMode&&r.texture.compareFunction===null?dL.UnfilterableFloat:dL.Depth;else{let e=r.texture.type;e===1013?t.sampleType=dL.SInt:e===1014?t.sampleType=dL.UInt:e===1015&&(t.sampleType=this.backend.hasFeature(`float32-filterable`)?dL.Float:dL.UnfilterableFloat)}r.isSampledCubeTexture?t.viewDimension=pL.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?t.viewDimension=pL.TwoDArray:r.isSampledTexture3D&&(t.viewDimension=pL.ThreeD),i.texture=t}else if(r.isSampler){let t={};r.texture.isDepthTexture&&(t.type=r.texture.compareFunction!==null&&r.textureNode.compareNode!==null&&e.hasCompatibility(Mo.TEXTURE_COMPARE)?uL.Comparison:uL.NonFiltering),i.sampler=t}else V(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(i),n++}return t}deleteBindGroupData(e){let{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},Ple=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},Fle=class{constructor(){this.label=``,this.layout=null,this.compute=null}reset(){this.label=``,this.layout=null,this.compute=null}},Ile=class{constructor(){this.label=``,this.bindGroupLayouts=null}reset(){this.label=``,this.bindGroupLayouts=null}},dR=new Fle,fR=new Ile,pR=new SL,mR=new TL,Lle=class{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let{layoutGPU:e}=c.get(t).layout;f.push(e)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==0&&(r.blending!==1||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures,n=e.context.mrt;for(let e=0;e<t.length;e++){let r=t[e],i=u.getTextureFormatGPU(r),a;if(n!==null){if(this.backend.compatibilityMode!==!0){let e=n.getBlendMode(r.name);e.blending===6?a=m:e.blending!==0&&(a=this._getBlending(e))}else Bo(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`),a=m}else a=m;_.push({format:i,blend:a,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),C=this._getSampleCount(e.context);fR.bindGroupLayouts=f;let w=l.createPipelineLayout(fR);fR.reset(),mR.label=`renderPipeline_${r.name||r.type}_${r.id}`,mR.vertex=Object.assign({},v,{buffers:p}),mR.fragment=Object.assign({},y,{targets:_}),mR.primitive=b,mR.multisample.count=C,mR.multisample.alphaToCoverageEnabled=r.alphaToCoverage&&C>1,mR.layout=w;let T={},E=e.context.depth,D=e.context.stencil;(E===!0||D===!0)&&(E===!0&&(T.format=S,T.depthWriteEnabled=r.depthWrite,T.depthCompare=x),D===!0&&(T.stencilFront=h,T.stencilBack=h,T.stencilReadMask=r.stencilFuncMask,T.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&b.topology===JI.TriangleList&&(T.depthBias=r.polygonOffsetUnits,T.depthBiasSlopeScale=r.polygonOffsetFactor,T.depthBiasClamp=0),mR.depthStencil=T),l.pushErrorScope(`validation`);let O=[{program:o,module:v.module},{program:s,module:y.module}],k=mR.label;if(t===null)d.pipeline=l.createRenderPipeline(mR),mR.reset(),l.popErrorScope().then(e=>{e!==null&&(d.error=!0,V(`WebGPURenderer: Render pipeline creation failed (${k}): ${e.message}`),this._reportShaderDiagnostics(O,k))});else{let e=new Promise(async e=>{try{let e=null,t=null;try{t=l.createRenderPipelineAsync(mR)}catch(t){e=t}if(mR.reset(),t!==null)try{d.pipeline=await t}catch(t){e=t}let n=await l.popErrorScope();if(n!==null||e!==null){d.error=!0;let t=n&&n.message||e&&e.message||`unknown`;V(`WebGPURenderer: Async render pipeline creation failed (${k}): ${t}`),await this._reportShaderDiagnostics(O,k)}}finally{e()}});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let{utils:n,device:r}=this.backend,i=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormats(e),o=this._getSampleCount(e);pR.label=t,pR.colorFormats=a,pR.depthStencilFormat=i,pR.sampleCount=o;let s=r.createRenderBundleEncoder(pR);return pR.reset(),s}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let{layoutGPU:t}=n.get(e).layout;o.push(t)}let s=e.computeProgram,c=`computePipeline_${s.stage}${s.name?`_${s.name}`:``}`;r.pushErrorScope(`validation`),fR.bindGroupLayouts=o;let l=r.createPipelineLayout(fR);fR.reset(),dR.label=c,dR.compute=i,dR.layout=l,a.pipeline=r.createComputePipeline(dR),dR.reset(),r.popErrorScope().then(e=>{e!==null&&(a.error=!0,V(`WebGPURenderer: Compute pipeline creation failed (${c}): ${e.message}`),this._reportShaderDiagnostics([{program:s,module:i.module}],c))})}async _reportShaderDiagnostics(e,t){for(let{program:n,module:r}of e){let e=await r.getCompilationInfo();if(e.messages.length===0)continue;let i=n.code.split(`
|
|
5165
|
+
`);for(let r of e.messages){let e=r.lineNum>0?` at line ${r.lineNum}${r.linePos>0?`:${r.linePos}`:``}`:``,a=`WebGPURenderer [${t} / ${n.stage} ${r.type}]${e}: ${r.message}`,o=``;r.lineNum>0&&r.lineNum<=i.length&&(o=`\n ${i[r.lineNum-1]}`,r.linePos>0&&(o+=`\n ${` `.repeat(r.linePos-1)}^`)),(r.type===`error`?V:B)(a+o)}}}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===5){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:aL.Add},n={srcFactor:i,dstFactor:a,operation:aL.Add}};if(i)switch(r){case 1:a(iL.One,iL.OneMinusSrcAlpha,iL.One,iL.OneMinusSrcAlpha);break;case 2:a(iL.One,iL.One,iL.One,iL.One);break;case 3:a(iL.Zero,iL.OneMinusSrc,iL.Zero,iL.One);break;case 4:a(iL.Dst,iL.OneMinusSrcAlpha,iL.Zero,iL.One)}else switch(r){case 1:a(iL.SrcAlpha,iL.OneMinusSrcAlpha,iL.One,iL.OneMinusSrcAlpha);break;case 2:a(iL.SrcAlpha,iL.One,iL.One,iL.One);break;case 3:V(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break;case 4:V(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`)}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};V(`WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case 200:t=iL.Zero;break;case 201:t=iL.One;break;case 202:t=iL.Src;break;case 203:t=iL.OneMinusSrc;break;case 204:t=iL.SrcAlpha;break;case 205:t=iL.OneMinusSrcAlpha;break;case 208:t=iL.Dst;break;case 209:t=iL.OneMinusDst;break;case 206:t=iL.DstAlpha;break;case 207:t=iL.OneMinusDstAlpha;break;case 210:t=iL.SrcAlphaSaturated;break;case YN:t=iL.Constant;break;case XN:t=iL.OneMinusConstant;break;default:V(`WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case 512:t=XI.Never;break;case 519:t=XI.Always;break;case 513:t=XI.Less;break;case 515:t=XI.LessEqual;break;case 514:t=XI.Equal;break;case 518:t=XI.GreaterEqual;break;case 516:t=XI.Greater;break;case 517:t=XI.NotEqual;break;default:V(`WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bo:t=sL.Keep;break;case 0:t=sL.Zero;break;case xo:t=sL.Replace;break;case Eo:t=sL.Invert;break;case So:t=sL.IncrementClamp;break;case Co:t=sL.DecrementClamp;break;case wo:t=sL.IncrementWrap;break;case To:t=sL.DecrementWrap;break;default:V(`WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case 100:t=aL.Add;break;case 101:t=aL.Subtract;break;case 102:t=aL.ReverseSubtract;break;case 103:t=aL.Min;break;case 104:t=aL.Max;break;default:V(`WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={};r.topology=this.backend.utils.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?tL.Uint16:tL.Uint32);let i=n.side===1;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(i=!i),r.frontFace=i===!0?$I.CW:$I.CCW,r.cullMode=n.side===2?eL.None:eL.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?oL.All:oL.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=XI.Always;else{let n=this.backend.parameters.reversedDepthBuffer?Uo[e.depthFunc]:e.depthFunc;switch(n){case 0:t=XI.Never;break;case 1:t=XI.Always;break;case 2:t=XI.Less;break;case 3:t=XI.LessEqual;break;case 4:t=XI.Equal;break;case 5:t=XI.GreaterEqual;break;case 6:t=XI.Greater;break;case 7:t=XI.NotEqual;break;default:V(`WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},hR=class{constructor(){this.label=``,this.type=void 0,this.count=0}reset(){this.label=``,this.type=void 0,this.count=0}},gR=new bL,Rle=new xL,_R=new hR,zle=class extends KI{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,_R.label=`queryset_global_timestamp_${t}`,_R.type=`timestamp`,_R.count=this.maxQueries,this.querySet=this.device.createQuerySet(_R),_R.reset();let r=this.maxQueries*8;gR.label=`buffer_timestamp_resolve_${t}`,gR.size=r,gR.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(gR),gR.reset(),gR.label=`buffer_timestamp_result_${t}`,gR.size=r,gR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(gR),gR.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Bo(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(Rle);r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(vL(this.device,i),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o={},s=[];for(let[t,n]of e){let e=t.match(/^(.*):f(\d+)$/),r=parseInt(e[2]);s.includes(r)===!1&&s.push(r),o[r]===void 0&&(o[r]=0);let i=a[n],c=a[n+1],l=Number(c-i)/1e6;this.timestamps.set(t,l),o[r]+=l}let c=o[s[s.length-1]];return this.resultBuffer.unmap(),this.lastValue=c,this.frames=s,c}catch(e){return V(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){V(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){V(`Error unmapping buffer:`,e)}this.querySet&&=(this.querySet.destroy(),null),this.resolveBuffer&&=(this.resolveBuffer.destroy(),null),this.resultBuffer&&=(this.resultBuffer.destroy(),null),this.queryOffsets.clear(),this.pendingResolve=null}}},Ble=class{constructor(){this.label=``,this.timestampWrites=void 0}reset(){this.label=``,this.timestampWrites=void 0}},vR=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},Vle=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},yR={r:0,g:0,b:0,a:1},bR=new bL,xR=new xL,SR=new Ble,CR=new hR,wR=new EL,TR=new Vle,ER=new zL,DR=new zL,OR=new OL,kR=new BL,Hle=class extends LI{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0||e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new sle(this),this.attributeUtils=new jle(this),this.bindingUtils=new Nle(this),this.capabilities=new Ple(this),this.pipelineUtils=new Lle(this),this.textureUtils=new vle(this),this.occludedResolveCache=new Map;let t=typeof navigator>`u`||/Android/.test(navigator.userAgent)===!1;this._compatibility={[Mo.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let r={powerPreference:t.powerPreference,featureLevel:`compatibility`,xrCompatible:e.xr.enabled},i=typeof navigator<`u`?await navigator.gpu.requestAdapter(r):null;if(i===null)throw Error(`THREE.WebGPUBackend: Unable to create WebGPU adapter.`);let a=Object.values(hL),o=[];for(let e of a)i.features.has(e)&&o.push(e);let s={requiredFeatures:o,requiredLimits:t.requiredLimits};n=await i.requestDevice(s)}else n=t.device;this.compatibilityMode=!n.features.has(`core-features-and-limits`),this.compatibilityMode&&(e._samples=0),n.lost.then(t=>{if(t.reason===`destroyed`)return;let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}),n.onuncapturederror=t=>{let n=t.error,r=n&&n.constructor?n.constructor.name:`GPUError`,i=n&&n.message||`Unknown uncaptured GPU error`;e.onError({api:`WebGPU`,type:r,message:i,originalEvent:t})},this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(hL.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,n=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:n,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),n=t.context;if(n===void 0){let r=this.parameters;n=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext(`webgpu`),`setAttribute`in e.domElement&&e.domElement.setAttribute(`data-engine`,`three.js r185 webgpu`);let i=r.alpha?`premultiplied`:`opaque`,a=r.outputType===1016?`extended`:`standard`;n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:a}}),t.context=n}return n}get coordinateSystem(){return Ao}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples,i=n.descriptor;if(i===void 0||n.samples!==r){if(i=new wL,i.colorAttachments.push(new CL),e.depth===!0||e.stencil===!0){let t=new vR;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}let t=i.colorAttachments[0];r>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,n.descriptor=i,n.samples=r}let a=i.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){let t=e.textures;if(t===null)return!1;for(let e=0;e<t.length;e++)if(this.get(t[e]).externalTexture===!0)return!0;return!1}_createExternalTextureViews(e,t){let n=[],r=e.camera;if(t.xrViewDescriptors&&r!==null&&r.isArrayCamera===!0)for(let e=0;e<t.xrViewDescriptors.length;e++)n.push({view:t.texture.createView(t.xrViewDescriptors[e]),resolveTarget:void 0,depthSlice:void 0});else n.push({view:t.texture.createView({dimension:pL.TwoD,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return n}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=this._hasExternalTexture(e),a=r.descriptors;(a===void 0||r.width!==n.width||r.height!==n.height||r.samples!==n.samples||i)&&(a={},r.descriptors=a);let o=e.getCacheKey(),s=a[o];if(s===void 0||i){let t=e.textures,i=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let a=this.get(t[r]);if(a.externalTexture===!0){i.push(...this._createExternalTextureViews(e,a));continue}if(OR.label=`colorAttachment_${r}`,OR.baseMipLevel=e.activeMipmapLevel,OR.mipLevelCount=1,OR.baseArrayLayer=e.activeCubeFace,OR.arrayLayerCount=1,OR.dimension=pL.TwoD,n.isRenderTarget3D)c=e.activeCubeFace,OR.baseArrayLayer=0,OR.dimension=pL.ThreeD;else if(n.isRenderTarget&&t[r].image.depth>1){if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){OR.baseArrayLayer=e,OR.arrayLayerCount=1,OR.dimension=pL.TwoD;let t=a.texture.createView(OR);i.push({view:t,resolveTarget:void 0,depthSlice:void 0})}}else OR.dimension=pL.TwoDArray}if(l!==!0){let e=a.texture.createView(OR),t,n;a.msaaTexture===void 0?(t=e,n=void 0):(t=a.msaaTexture.createView(),n=e),i.push({view:t,resolveTarget:n,depthSlice:c})}OR.reset()}let u=[];for(let e=0;e<i.length;e++){let t=i[e],n=new CL;n.view=t.view,n.depthSlice=t.depthSlice,n.resolveTarget=t.resolveTarget,u.push(n)}if(s={textureViews:i,colorAttachments:u,descriptor:new wL},e.depth){let t=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(OR.dimension=pL.TwoD,OR.arrayLayerCount=1,OR.baseArrayLayer=e.activeCubeFace);let n=new vR;n.view=t.texture.createView(OR),s.depthStencilAttachment=n,OR.reset()}a[o]=s,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}let c=s.descriptor;c.reset();for(let e=0;e<s.colorAttachments.length;e++){let n=s.colorAttachments[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),n.loadOp=t.loadOp||QI.Load,n.storeOp=t.storeOp||ZI.Store,n.clearValue=r,c.colorAttachments.push(n)}return s.depthStencilAttachment&&(c.depthStencilAttachment=s.depthStencilAttachment),c}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,CR.label=`occlusionQuerySet_${e.id}`,CR.type=`occlusion`,CR.count=r,i=n.createQuerySet(CR),CR.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:QI.Load}),this.initTimestampQuery(jo.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(n===0?r.clearValue=e.clearColorValue:(yR.r=0,yR.g=0,yR.b=0,yR.a=1,r.clearValue=yR),r.loadOp=QI.Clear):r.loadOp=QI.Load,r.storeOp=ZI.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=QI.Clear):t.loadOp=QI.Load,t.storeOp=ZI.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=QI.Clear):o.depthLoadOp=QI.Load,o.depthStoreOp=ZI.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=QI.Clear):o.stencilLoadOp=QI.Load,o.stencilStoreOp=ZI.Store),xR.label=`renderContext_`+e.id;let s=n.createCommandEncoder(xR);if(xR.reset(),this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createArrayCameraLayerDescriptors(e,t,a,n):this._updateArrayCameraLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r);t.bundleEncoders.push(n),t.bundleSets.push({attributes:{},bindingGroups:[],pipeline:null,index:null})}t.currentPass=null}else t.currentPass=s.beginRenderPass(a),e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e);t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createArrayCameraLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r=n.colorAttachments[0],s=new CL;s.view=n.colorAttachments[o].view,s.depthSlice=r.depthSlice,s.resolveTarget=r.resolveTarget,s.loadOp=r.loadOp,s.storeOp=r.storeOp,s.clearValue=r.clearValue;let c=new wL;if(c.label=n.label,c.occlusionQuerySet=n.occlusionQuerySet,c.timestampWrites=n.timestampWrites,c.colorAttachments.push(s),n.depthStencilAttachment){let t=o;a.viewCache[t]||(OR.dimension=pL.TwoD,OR.baseArrayLayer=o,OR.arrayLayerCount=1,a.viewCache[t]=a.texture.createView(OR),OR.reset());let n=new vR;n.view=a.viewCache[t],n.depthLoadOp=i.depthLoadOp||QI.Clear,n.depthStoreOp=i.depthStoreOp||ZI.Store,n.depthClearValue=i.depthClearValue||1,e.stencil&&(n.stencilLoadOp=i.stencilLoadOp,n.stencilStoreOp=i.stencilStoreOp,n.stencilClearValue=i.stencilClearValue),c.depthStencilAttachment=n}else{let e=new vR;e.view=i.view,e.depthLoadOp=i.depthLoadOp,e.depthStoreOp=i.depthStoreOp,e.depthClearValue=i.depthClearValue,e.depthReadOnly=i.depthReadOnly,e.stencilLoadOp=i.stencilLoadOp,e.stencilStoreOp=i.stencilStoreOp,e.stencilClearValue=i.stencilClearValue,e.stencilReadOnly=i.stencilReadOnly,c.depthStencilAttachment=e}t.layerDescriptors.push(c)}}_updateArrayCameraLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=QI.Clear):t.depthLoadOp=QI.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=QI.Clear):t.stencilLoadOp=QI.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(bR.size=r,bR.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer(bR),bR.reset(),this.occludedResolveCache.set(r,i)),bR.size=r,bR.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(bR);bR.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(vL(this.device,t.encoder.finish()),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}updateScissor(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a}=e.scissorValue;t.setScissorRect(n,r,i,a)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l;if(e){let e=this.getClearColor();yR.r=e.r,yR.g=e.g,yR.b=e.b,yR.a=e.a}if(r===null){c=a.depth,l=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=yR,e.loadOp=QI.Clear,e.storeOp=ZI.Store}(c||l)&&(s=t.depthStencilAttachment)}else{c=r.depth,l=r.stencil;let i={loadOp:e?QI.Clear:QI.Load,clearValue:e?yR:void 0};c&&(i.depthLoadOp=t?QI.Clear:QI.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=ZI.Store),l&&(i.stencilLoadOp=n?QI.Clear:QI.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=ZI.Store);let u=this._getRenderPassDescriptor(r,i);o=u.colorAttachments,s=u.depthStencilAttachment}c&&s&&(t?(s.depthLoadOp=QI.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=ZI.Store):(s.depthLoadOp=QI.Load,s.depthStoreOp=ZI.Store)),l&&s&&(n?(s.stencilLoadOp=QI.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=ZI.Store):(s.stencilLoadOp=QI.Load,s.stencilStoreOp=ZI.Store)),xR.label=`clear`;let u=i.createCommandEncoder(xR);xR.reset(),u.beginRenderPass({colorAttachments:o,depthStencilAttachment:s}).end(),vL(i,u.finish())}beginCompute(e){let t=this.get(e),n=`computeGroup_`+e.id;SR.label=n,xR.label=n,this.initTimestampQuery(jo.COMPUTE,this.getTimestampUID(e),SR),t.cmdEncoderGPU=this.device.createCommandEncoder(xR),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(SR),t.currentPipeline=null,xR.reset(),SR.reset()}compute(e,t,n,r,i=null){let a=this.get(t),o=this.get(e),{passEncoderGPU:s}=o,c=this.get(r).pipeline;o.currentPipeline!==c&&(s.setPipeline(c),o.currentPipeline=c);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);s.setBindGroup(e,r.group)}if(i===null&&(i=t.dispatchSize||t.count),i&&i.isIndirectStorageBufferAttribute){let e=this.get(i).buffer;s.dispatchWorkgroupsIndirect(e,0);return}if(typeof i==`number`){let e=i;if(a.dispatchSize===void 0||a.count!==e){a.dispatchSize=[0,1,1],a.count=e;let n=t.workgroupSize,r=n[0];for(let e=1;e<n.length;e++)r*=n[e];let o=Math.ceil(e/r),s=this.device.limits.maxComputeWorkgroupsPerDimension;i=[o,1,1],o>s&&(i[0]=Math.min(o,s),i[1]=Math.ceil(o/s)),a.dispatchSize=i}i=a.dispatchSize}s.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),vL(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,n,r,i,a,o,s,c){let{object:l,material:u,context:d}=e,f=e.getIndex(),p=f!==null;c.pipeline!==r&&(s.setPipeline(r),c.pipeline=r);let m=c.bindingGroups;for(let e=0,t=i.length;e<t;e++){let t=i[e];if(m[e]!==t.id){let n=this.get(t);s.setBindGroup(e,n.group),m[e]=t.id}}if(p===!0&&c.index!==f){let e=this.get(f).buffer,t=f.array instanceof Uint16Array?tL.Uint16:tL.Uint32;s.setIndexBuffer(e,t),c.index=f}for(let e=0,t=a.length;e<t;e++){let t=a[e];if(c.attributes[e]!==t){let n=this.get(t).buffer;s.setVertexBuffer(e,n),c.attributes[e]=t}}if(d.stencil===!0&&u.stencilWrite===!0&&n.currentStencilRef!==u.stencilRef&&(s.setStencilReference(u.stencilRef),n.currentStencilRef=u.stencilRef),l.isBatchedMesh===!0){let e=l._multiDrawStarts,n=l._multiDrawCounts,r=l._multiDrawCount,i=p===!0?f.array.BYTES_PER_ELEMENT:1;u.wireframe&&(i=l.geometry.attributes.position.count>65535?4:2);for(let a=0;a<r;a++)p===!0?s.drawIndexed(n[a],1,e[a]/i,0,a):s.draw(n[a],1,e[a],a),t.update(l,n[a],1)}else if(p===!0){let{vertexCount:n,instanceCount:r,firstVertex:i}=o,a=e.getIndirect();if(a!==null){let t=this.get(a).buffer,n=e.getIndirectOffset(),r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e++)s.drawIndexedIndirect(t,r[e])}else s.drawIndexed(n,r,i,0,0);t.update(l,n,r)}else{let{vertexCount:n,instanceCount:r,firstVertex:i}=o,a=e.getIndirect();if(a!==null){let t=this.get(a).buffer,n=e.getIndirectOffset(),r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e++)s.drawIndirect(t,r[e])}else s.draw(n,r,i,0);t.update(l,n,r)}}draw(e,t){let{object:n,context:r,pipeline:i}=e,a=this.get(r),o=this.get(i),s=o.pipeline;if(o.error===!0)return;let c=e.getDrawParameters();if(c===null)return;let l=e.getBindings(),u=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let i=this.get(e.camera),o=e.camera.cameras,d=e.getBindingGroup(`cameraIndex`);if(i.indexesGPU===void 0||i.indexesGPU.length!==o.length){let e=this.get(d),t=[],n=new Uint32Array([0,0,0,0]);for(let r=0,i=o.length;r<i;r++){n[0]=r;let{layoutGPU:i}=e.layout,a=this.bindingUtils.createBindGroupIndex(n,i);t.push(a)}i.indexesGPU=t}let f=this.renderer.getPixelRatio();for(let p=0,m=o.length;p<m;p++){let m=o[p];if(n.layers.test(m.layers)){let n=m.viewport,o=a.currentPass,h=a.currentSets,g=a.bundleEncoders!==void 0;if(g){let e=a.bundleEncoders[p],t=a.bundleSets[p];o=e,h=t}if(n&&!g&&o.setViewport(Math.floor(n.x*f),Math.floor(n.y*f),Math.floor(n.width*f),Math.floor(n.height*f),r.viewportValue.minDepth,r.viewportValue.maxDepth),d&&i.indexesGPU){let e=l.indexOf(d);o.setBindGroup(e,i.indexesGPU[p]),h.bindingGroups[e]=d.id}this._draw(e,t,a,s,l,u,c,o,h)}}}else if(a.currentPass){if(a.occlusionQuerySet!==void 0){let e=a.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(a.currentPass.endOcclusionQuery(),a.occlusionQueryIndex++),n.occlusionTest===!0&&(a.currentPass.beginOcclusionQuery(a.occlusionQueryIndex),a.occlusionQueryObjects[a.occlusionQueryIndex]=n),a.lastOcclusionObject=n)}this._draw(e,t,a,s,l,u,c,a.currentPass,a.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=n.isMesh&&n.matrixWorld.determinantAffine()<0,d=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.frontFaceCW!==u||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.frontFaceCW=u,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context,a=t.isMesh&&t.matrixWorld.determinantAffine()<0;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,a,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new zle(this.device,e,2048));let r=this.timestampQueryPool[e],i=r.allocateQueriesForContext(t);TR.querySet=r.querySet,TR.beginningOfPassWriteIndex=i,TR.endOfPassWriteIndex=i+1,n.timestampWrites=TR}createNodeBuilder(e,t){return new Ole(e,t)}createProgram(e){let t=this.get(e);wR.label=e.stage+(e.name===``?``:`_${e.name}`),wR.code=e.code,t.module={module:this.device.createShaderModule(wR),entryPoint:`main`},wR.reset()}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass.finish();this.get(t).bundleGPU=r,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createUniformBuffer(e){let t=this.get(e);if(t.buffer===void 0){let n=e.byteLength,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=[];e.visibility&YI.VERTEX&&i.push(`vertex`),e.visibility&YI.FRAGMENT&&i.push(`fragment`),e.visibility&YI.COMPUTE&&i.push(`compute`);let a=`(${i.join(`,`)})`;bR.label=`bindingBuffer${e.id}_${e.name}_${a}`,bR.size=n,bR.usage=r;let o=this.device.createBuffer(bR);bR.reset(),t.buffer=o}}destroyUniformBuffer(e){this.get(e).buffer.destroy(),this.delete(e)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(e){return gL[e]!==void 0&&(e=gL[e]),this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0),xR.label=`copyTextureToTexture_`+e.id+`_`+t.id;let h=this.device.createCommandEncoder(xR);xR.reset();let g=this.get(e).texture,_=this.get(t).texture;ER.texture=g,ER.mipLevel=i,ER.origin.x=l,ER.origin.y=u,ER.origin.z=d,DR.texture=_,DR.mipLevel=a,DR.origin.x=o,DR.origin.y=s,DR.origin.z=c,kR.width=f,kR.height=p,kR.depthOrArrayLayers=m,h.copyTextureToTexture(ER,DR,kR),ER.reset(),DR.reset(),kR.reset(),vL(this.device,h.finish()),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){V(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):(xR.label=`copyFramebufferToTexture_`+e.id,o=this.device.createCommandEncoder(xR),xR.reset()),ER.texture=i,ER.origin.x=n.x,ER.origin.y=n.y,DR.texture=a,kR.width=n.z,kR.height=n.w,o.copyTextureToTexture(ER,DR,kR),ER.reset(),DR.reset(),kR.reset(),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,o),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=QI.Load;t.depth&&(e.depthStencilAttachment.depthLoadOp=QI.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=QI.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else vL(this.device,o.finish())}hasCompatibility(e){return this._compatibility[e]===void 0?super.hasCompatibility(e):this._compatibility[e]}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},Ule=class extends ff{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},Wle=class extends ff{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},Gle=class extends aI{constructor(){super(),this.addMaterial(_j,`MeshPhongMaterial`),this.addMaterial(vN,`MeshStandardMaterial`),this.addMaterial(bN,`MeshPhysicalMaterial`),this.addMaterial(wN,`MeshToonMaterial`),this.addMaterial(sj,`MeshBasicMaterial`),this.addMaterial(hj,`MeshLambertMaterial`),this.addMaterial(KA,`MeshNormalMaterial`),this.addMaterial(DN,`MeshMatcapMaterial`),this.addMaterial(IA,`LineBasicMaterial`),this.addMaterial(RA,`LineDashedMaterial`),this.addMaterial(NN,`PointsMaterial`),this.addMaterial(AN,`SpriteMaterial`),this.addMaterial(LN,`ShadowMaterial`),this.addLight(Mse,mf),this.addLight(cce,_f),this.addLight(mce,yf),this.addLight(qF,ff),this.addLight(sce,vf),this.addLight(lce,Zd),this.addLight(dce,xf),this.addLight(uce,Ule),this.addLight(pce,Wle),this.addToneMapping(YP,1),this.addToneMapping(XP,2),this.addToneMapping(ZP,3),this.addToneMapping($P,4),this.addToneMapping(rF,6),this.addToneMapping(iF,7)}},Kle=class extends Ice{constructor(e={}){let t;e.forceWebGL?t=qI:(t=Hle,e.getFallback=()=>(B(`WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new qI(e)));let n=new t(e);super(n,e),this.library=new Gle,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},AR={type:`change`},jR={type:`start`},MR={type:`end`},NR=1e-6,PR={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},FR=new H,IR=new H,qle=new U,LR=new U,RR=new U,zR=new vs,BR=new U,VR=new U,HR=new U,UR=new U,Jle=class extends qf{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=[`KeyA`,`KeyS`,`KeyD`],this.mouseButtons={LEFT:Wi.ROTATE,MIDDLE:Wi.DOLLY,RIGHT:Wi.PAN},this.target=new U,this.state=PR.NONE,this.keyState=PR.NONE,this._lastPosition=new U,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new U,this._movePrev=new H,this._moveCurr=new H,this._lastAxis=new U,this._zoomStart=new H,this._zoomEnd=new H,this._panStart=new H,this._panEnd=new H,this._pointers=[],this._pointerPositions={},this._onPointerMove=Xle.bind(this),this._onPointerDown=Yle.bind(this),this._onPointerUp=Zle.bind(this),this._onPointerCancel=Qle.bind(this),this._onContextMenu=aue.bind(this),this._onMouseWheel=iue.bind(this),this._onKeyDown=eue.bind(this),this._onKeyUp=$le.bind(this),this._onTouchStart=oue.bind(this),this._onTouchMove=sue.bind(this),this._onTouchEnd=cue.bind(this),this._onMouseDown=tue.bind(this),this._onMouseMove=nue.bind(this),this._onMouseUp=rue.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener(`keydown`,this._onKeyDown),window.addEventListener(`keyup`,this._onKeyUp),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerCancel),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=`none`}disconnect(){window.removeEventListener(`keydown`,this._onKeyDown),window.removeEventListener(`keyup`,this._onKeyUp),this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerCancel),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=``}dispose(){this.disconnect()}handleResize(){let e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>NR&&(this.dispatchEvent(AR),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>NR||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(AR),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn(`THREE.TrackballControls: Unsupported camera type.`)}reset(){this.state=PR.NONE,this.keyState=PR.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(AR),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(IR.copy(this._panEnd).sub(this._panStart),IR.lengthSq()){if(this.object.isOrthographicCamera){let 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;IR.x*=e,IR.y*=t}IR.multiplyScalar(this._eye.length()*this.panSpeed),LR.copy(this._eye).cross(this.object.up).setLength(IR.x),LR.add(qle.copy(this.object.up).setLength(IR.y)),this.object.position.add(LR),this.target.add(LR),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(IR.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){UR.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=UR.length();e?(this._eye.copy(this.object.position).sub(this.target),BR.copy(this._eye).normalize(),VR.copy(this.object.up).normalize(),HR.crossVectors(VR,BR).normalize(),VR.setLength(this._moveCurr.y-this._movePrev.y),HR.setLength(this._moveCurr.x-this._movePrev.x),UR.copy(VR.add(HR)),RR.crossVectors(UR,this._eye).normalize(),e*=this.rotateSpeed,zR.setFromAxisAngle(RR,e),this._eye.applyQuaternion(zR),this.object.up.applyQuaternion(zR),this._lastAxis.copy(RR),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),zR.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(zR),this.object.up.applyQuaternion(zR)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===PR.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=_s.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=_s.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 FR.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),FR}_getMouseOnCircle(e,t){return FR.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),FR}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId==e.pointerId){this._pointers.splice(t,1);return}}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new H,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[t.pointerId]}_checkDistances(){(!this.noZoom||!this.noPan)&&(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}};function Yle(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e))}function Xle(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function Zle(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchEnd(e):this._onMouseUp(),this._removePointer(e),this._pointers.length===0&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp)))}function Qle(e){this._removePointer(e)}function $le(){this.enabled!==!1&&(this.keyState=PR.NONE,window.addEventListener(`keydown`,this._onKeyDown))}function eue(e){this.enabled!==!1&&(window.removeEventListener(`keydown`,this._onKeyDown),this.keyState===PR.NONE&&(e.code===this.keys[PR.ROTATE]&&!this.noRotate?this.keyState=PR.ROTATE:e.code===this.keys[PR.ZOOM]&&!this.noZoom?this.keyState=PR.ZOOM:e.code===this.keys[PR.PAN]&&!this.noPan&&(this.keyState=PR.PAN)))}function tue(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Wi.DOLLY:this.state=PR.ZOOM;break;case Wi.ROTATE:this.state=PR.ROTATE;break;case Wi.PAN:this.state=PR.PAN;break;default:this.state=PR.NONE}let n=this.keyState===PR.NONE?this.state:this.keyState;n===PR.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY)),this._movePrev.copy(this._moveCurr)):n===PR.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(e.pageX,e.pageY)),this._zoomEnd.copy(this._zoomStart)):n===PR.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(e.pageX,e.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(jR)}function nue(e){let t=this.keyState===PR.NONE?this.state:this.keyState;t===PR.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY))):t===PR.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(e.pageX,e.pageY)):t===PR.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(e.pageX,e.pageY))}function rue(){this.state=PR.NONE,this.dispatchEvent(MR)}function iue(e){if(this.enabled!==!1&&this.noZoom!==!0){switch(e.preventDefault(),e.deltaMode){case 2:this._zoomStart.y-=e.deltaY*.025;break;case 1:this._zoomStart.y-=e.deltaY*.01;break;default:this._zoomStart.y-=e.deltaY*25e-5}this.dispatchEvent(jR),this.dispatchEvent(MR)}}function aue(e){this.enabled!==!1&&e.preventDefault()}function oue(e){switch(this._trackPointer(e),this._pointers.length){case 1:this.state=PR.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=PR.TOUCH_ZOOM_PAN;let e=this._pointers[0].pageX-this._pointers[1].pageX,t=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+t*t);let n=(this._pointers[0].pageX+this._pointers[1].pageX)/2,r=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(n,r)),this._panEnd.copy(this._panStart)}this.dispatchEvent(jR)}function sue(e){switch(this._trackPointer(e),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY));break;default:let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y;this._touchZoomDistanceEnd=Math.sqrt(n*n+r*r);let i=(e.pageX+t.x)/2,a=(e.pageY+t.y)/2;this._panEnd.copy(this._getMouseOnScreen(i,a))}}function cue(e){switch(this._pointers.length){case 0:this.state=PR.NONE;break;case 1:this.state=PR.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(e.pageX,e.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=PR.TOUCH_ZOOM_PAN;for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId!==e.pointerId){let e=this._pointerPositions[this._pointers[t].pointerId];this._moveCurr.copy(this._getMouseOnCircle(e.x,e.y)),this._movePrev.copy(this._moveCurr);break}}this.dispatchEvent(MR)}var WR={type:`change`},GR={type:`start`},KR={type:`end`},qR=new Rl,JR=new au,lue=Math.cos(70*_s.DEG2RAD),YR=new U,XR=2*Math.PI,ZR={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},QR=1e-6,uue=class extends qf{constructor(e,t=null){super(e,t),this.state=ZR.NONE,this.target=new U,this.cursor=new U,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:Wi.ROTATE,MIDDLE:Wi.DOLLY,RIGHT:Wi.PAN},this.touches={ONE:Gi.ROTATE,TWO:Gi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new vs,this._lastTargetPosition=new U,this._quat=new vs().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Gf,this._sphericalDelta=new Gf,this._scale=1,this._panOffset=new U,this._rotateStart=new H,this._rotateEnd=new H,this._rotateDelta=new H,this._panStart=new H,this._panEnd=new H,this._panDelta=new H,this._dollyStart=new H,this._dollyEnd=new H,this._dollyDelta=new H,this._dollyDirection=new U,this._mouse=new H,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=fue.bind(this),this._onPointerDown=due.bind(this),this._onPointerUp=pue.bind(this),this._onContextMenu=bue.bind(this),this._onMouseWheel=gue.bind(this),this._onKeyDown=_ue.bind(this),this._onTouchStart=vue.bind(this),this._onTouchMove=yue.bind(this),this._onMouseDown=mue.bind(this),this._onMouseMove=hue.bind(this),this._interceptControlDown=xue.bind(this),this._interceptControlUp=Sue.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),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.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.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=``}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(WR),this.update(),this.state=ZR.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;YR.copy(t).sub(this.target),YR.applyQuaternion(this._quat),this._spherical.setFromVector3(YR),this.autoRotate&&this.state===ZR.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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=XR:n>Math.PI&&(n-=XR),r<-Math.PI?r+=XR:r>Math.PI&&(r-=XR),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(YR.setFromSpherical(this._spherical),YR.applyQuaternion(this._quatInverse),t.copy(this.target).add(YR),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 e=null;if(this.object.isPerspectiveCamera){let t=YR.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new U(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new U(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=YR.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(qR.origin.copy(this.object.position),qR.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(qR.direction))<lue?this.object.lookAt(this.target):(JR.setFromNormalAndCoplanarPoint(this.object.up,this.target),qR.intersectPlane(JR,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>QR||8*(1-this._lastQuaternion.dot(this.object.quaternion))>QR||this._lastTargetPosition.distanceToSquared(this.target)>QR?(this.dispatchEvent(WR),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?XR/60/60*this.autoRotateSpeed:XR/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){YR.setFromMatrixColumn(t,0),YR.multiplyScalar(-e),this._panOffset.add(YR)}_panUp(e,t){this.screenSpacePanning===!0?YR.setFromMatrixColumn(t,1):(YR.setFromMatrixColumn(t,0),YR.crossVectors(this.object.up,YR)),YR.multiplyScalar(e),this._panOffset.add(YR)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;YR.copy(r).sub(this.target);let i=YR.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.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;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*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);let t=this.domElement;this._rotateLeft(XR*this._rotateDelta.x/t.clientHeight),this._rotateUp(XR*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(XR*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(-XR*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(XR*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(-XR*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(XR*this._rotateDelta.x/t.clientHeight),this._rotateUp(XR*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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new H,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function due(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function fue(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function pue(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(KR),this.state=ZR.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y})}}function mue(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Wi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=ZR.DOLLY;break;case Wi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ZR.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ZR.ROTATE}break;case Wi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ZR.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ZR.PAN}break;default:this.state=ZR.NONE}this.state!==ZR.NONE&&this.dispatchEvent(GR)}function hue(e){switch(this.state){case ZR.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case ZR.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case ZR.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e)}}function gue(e){this.enabled!==!1&&this.enableZoom!==!1&&this.state===ZR.NONE&&(e.preventDefault(),this.dispatchEvent(GR),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(KR))}function _ue(e){this.enabled!==!1&&this._handleKeyDown(e)}function vue(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Gi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=ZR.TOUCH_ROTATE;break;case Gi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=ZR.TOUCH_PAN;break;default:this.state=ZR.NONE}break;case 2:switch(this.touches.TWO){case Gi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=ZR.TOUCH_DOLLY_PAN;break;case Gi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=ZR.TOUCH_DOLLY_ROTATE;break;default:this.state=ZR.NONE}break;default:this.state=ZR.NONE}this.state!==ZR.NONE&&this.dispatchEvent(GR)}function yue(e){switch(this._trackPointer(e),this.state){case ZR.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case ZR.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case ZR.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case ZR.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=ZR.NONE}}function bue(e){this.enabled!==!1&&e.preventDefault()}function xue(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function Sue(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var Cue={type:`change`},$R=1e-6,ez=new vs,wue=class extends qf{constructor(e,t=null){super(e,t),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this._moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this._moveVector=new U(0,0,0),this._rotationVector=new U(0,0,0),this._lastQuaternion=new vs,this._lastPosition=new U,this._status=0,this._onKeyDown=Tue.bind(this),this._onKeyUp=Eue.bind(this),this._onPointerMove=Oue.bind(this),this._onPointerDown=Due.bind(this),this._onPointerUp=kue.bind(this),this._onPointerCancel=Aue.bind(this),this._onContextMenu=jue.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),window.addEventListener(`keydown`,this._onKeyDown),window.addEventListener(`keyup`,this._onKeyUp),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.addEventListener(`pointercancel`,this._onPointerCancel),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=`none`}disconnect(){window.removeEventListener(`keydown`,this._onKeyDown),window.removeEventListener(`keyup`,this._onKeyUp),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerCancel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=``}dispose(){this.disconnect()}update(e){if(this.enabled===!1)return;let t=this.object,n=e*this.movementSpeed,r=e*this.rollSpeed;t.translateX(this._moveVector.x*n),t.translateY(this._moveVector.y*n),t.translateZ(this._moveVector.z*n),ez.set(this._rotationVector.x*r,this._rotationVector.y*r,this._rotationVector.z*r,1).normalize(),t.quaternion.multiply(ez),(this._lastPosition.distanceToSquared(t.position)>$R||8*(1-this._lastQuaternion.dot(t.quaternion))>$R)&&(this.dispatchEvent(Cue),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){let e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement==document?{size:[window.innerWidth,window.innerHeight],offset:[0,0]}:{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}}};function Tue(e){if(!(e.altKey||this.enabled===!1)){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=.1;break;case`KeyW`:this._moveState.forward=1;break;case`KeyS`:this._moveState.back=1;break;case`KeyA`:this._moveState.left=1;break;case`KeyD`:this._moveState.right=1;break;case`KeyR`:this._moveState.up=1;break;case`KeyF`:this._moveState.down=1;break;case`ArrowUp`:this._moveState.pitchUp=1;break;case`ArrowDown`:this._moveState.pitchDown=1;break;case`ArrowLeft`:this._moveState.yawLeft=1;break;case`ArrowRight`:this._moveState.yawRight=1;break;case`KeyQ`:this._moveState.rollLeft=1;break;case`KeyE`:this._moveState.rollRight=1}this._updateMovementVector(),this._updateRotationVector()}}function Eue(e){if(this.enabled!==!1){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=1;break;case`KeyW`:this._moveState.forward=0;break;case`KeyS`:this._moveState.back=0;break;case`KeyA`:this._moveState.left=0;break;case`KeyD`:this._moveState.right=0;break;case`KeyR`:this._moveState.up=0;break;case`KeyF`:this._moveState.down=0;break;case`ArrowUp`:this._moveState.pitchUp=0;break;case`ArrowDown`:this._moveState.pitchDown=0;break;case`ArrowLeft`:this._moveState.yawLeft=0;break;case`ArrowRight`:this._moveState.yawRight=0;break;case`KeyQ`:this._moveState.rollLeft=0;break;case`KeyE`:this._moveState.rollRight=0}this._updateMovementVector(),this._updateRotationVector()}}function Due(e){if(this.enabled!==!1){if(this.dragToLook)this._status++;else{switch(e.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1}this._updateMovementVector()}}}function Oue(e){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){let t=this._getContainerDimensions(),n=t.size[0]/2,r=t.size[1]/2;this._moveState.yawLeft=-(e.pageX-t.offset[0]-n)/n,this._moveState.pitchDown=(e.pageY-t.offset[1]-r)/r,this._updateRotationVector()}}function kue(e){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(e.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0}this._updateMovementVector()}this._updateRotationVector()}}function Aue(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function jue(e){this.enabled!==!1&&e.preventDefault()}var Mue={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
5166
5166
|
|
|
5167
5167
|
varying vec2 vUv;
|
|
5168
5168
|
|
|
@@ -5185,7 +5185,7 @@ var<${n}> ${e} : ${a};`}},iR=new yL,aR=new bL,oR=new Map([[Int8Array,[`sint8`,`s
|
|
|
5185
5185
|
gl_FragColor = opacity * texel;
|
|
5186
5186
|
|
|
5187
5187
|
|
|
5188
|
-
}`},ez=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},Pue=new hf(-1,1,1,-1,0,1),Fue=new class extends wl{constructor(){super(),this.setAttribute(`position`,new fl([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new fl([0,2,0,0,2,0],2))}},tz=class{constructor(e){this._mesh=new Zl(Fue,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Pue)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},nz=class extends ez{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof _d?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=md.clone(e.uniforms),this.material=new _d({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new tz(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},rz=class extends ez{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},iz=class extends ez{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},az=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new H);this._width=n.width,this._height=n.height,t=new zs(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ca}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new nz(Nue),this.copyPass.material.blending=0,this.timer=new Ef}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}rz!==void 0&&(r instanceof rz?n=!0:r instanceof iz&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new H);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},oz=class extends ez{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new Cc}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}};function sz(){return sz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sz.apply(null,arguments)}function cz(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function lz(e,t){return lz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},lz(e,t)}function uz(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,lz(e,t)}function dz(e){return dz=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},dz(e)}function fz(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}function pz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(pz=function(){return!!e})()}function mz(e,t,n){if(pz())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&lz(i,n.prototype),i}function hz(e){var t=typeof Map==`function`?new Map:void 0;return hz=function(e){if(e===null||!fz(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return mz(e,arguments,dz(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),lz(n,e)},hz(e)}var gz=function(e){uz(t,e);function t(t){return cz(e.call(this,`An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#`+t+` for more information.`)||this)}return t}(hz(Error));function _z(e){return Math.round(e*255)}function vz(e,t,n){return _z(e)+`,`+_z(t)+`,`+_z(n)}function yz(e,t,n,r){if(r===void 0&&(r=vz),t===0)return r(n,n,n);var i=(e%360+360)%360/60,a=(1-Math.abs(2*n-1))*t,o=a*(1-Math.abs(i%2-1)),s=0,c=0,l=0;i>=0&&i<1?(s=a,c=o):i>=1&&i<2?(s=o,c=a):i>=2&&i<3?(c=a,l=o):i>=3&&i<4?(c=o,l=a):i>=4&&i<5?(s=o,l=a):i>=5&&i<6&&(s=a,l=o);var u=n-a/2,d=s+u,f=c+u,p=l+u;return r(d,f,p)}var bz={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`639`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`};function xz(e){if(typeof e!=`string`)return e;var t=e.toLowerCase();return bz[t]?`#`+bz[t]:e}var Sz=/^#[a-fA-F0-9]{6}$/,Cz=/^#[a-fA-F0-9]{8}$/,wz=/^#[a-fA-F0-9]{3}$/,Tz=/^#[a-fA-F0-9]{4}$/,Ez=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Dz=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Oz=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,kz=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Az(e){if(typeof e!=`string`)throw new gz(3);var t=xz(e);if(t.match(Sz))return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16)};if(t.match(Cz)){var n=parseFloat((parseInt(``+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16),alpha:n}}if(t.match(wz))return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16)};if(t.match(Tz)){var r=parseFloat((parseInt(``+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16),alpha:r}}var i=Ez.exec(t);if(i)return{red:parseInt(``+i[1],10),green:parseInt(``+i[2],10),blue:parseInt(``+i[3],10)};var a=Dz.exec(t.substring(0,50));if(a)return{red:parseInt(``+a[1],10),green:parseInt(``+a[2],10),blue:parseInt(``+a[3],10),alpha:parseFloat(``+a[4])>1?parseFloat(``+a[4])/100:parseFloat(``+a[4])};var o=Oz.exec(t);if(o){var s=`rgb(`+yz(parseInt(``+o[1],10),parseInt(``+o[2],10)/100,parseInt(``+o[3],10)/100)+`)`,c=Ez.exec(s);if(!c)throw new gz(4,t,s);return{red:parseInt(``+c[1],10),green:parseInt(``+c[2],10),blue:parseInt(``+c[3],10)}}var l=kz.exec(t.substring(0,50));if(l){var u=`rgb(`+yz(parseInt(``+l[1],10),parseInt(``+l[2],10)/100,parseInt(``+l[3],10)/100)+`)`,d=Ez.exec(u);if(!d)throw new gz(4,t,u);return{red:parseInt(``+d[1],10),green:parseInt(``+d[2],10),blue:parseInt(``+d[3],10),alpha:parseFloat(``+l[4])>1?parseFloat(``+l[4])/100:parseFloat(``+l[4])}}throw new gz(5)}function jz(e){var t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return e.alpha===void 0?{hue:0,saturation:0,lightness:o}:{hue:0,saturation:0,lightness:o,alpha:e.alpha};var s,c=i-a,l=o>.5?c/(2-i-a):c/(i+a);switch(i){case t:s=(n-r)/c+(n<r?6:0);break;case n:s=(r-t)/c+2;break;default:s=(t-n)/c+4}return s*=60,e.alpha===void 0?{hue:s,saturation:l,lightness:o}:{hue:s,saturation:l,lightness:o,alpha:e.alpha}}function Mz(e){return jz(Az(e))}var Nz=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?`#`+e[1]+e[3]+e[5]:e};function Pz(e){var t=e.toString(16);return t.length===1?`0`+t:t}function Fz(e){return Pz(Math.round(e*255))}function Iz(e,t,n){return Nz(`#`+Fz(e)+Fz(t)+Fz(n))}function Lz(e,t,n){return yz(e,t,n,Iz)}function Rz(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Lz(e,t,n);if(typeof e==`object`&&t===void 0&&n===void 0)return Lz(e.hue,e.saturation,e.lightness);throw new gz(1)}function zz(e,t,n,r){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return r>=1?Lz(e,t,n):`rgba(`+yz(e,t,n)+`,`+r+`)`;if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?Lz(e.hue,e.saturation,e.lightness):`rgba(`+yz(e.hue,e.saturation,e.lightness)+`,`+e.alpha+`)`;throw new gz(2)}function Bz(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Nz(`#`+Pz(e)+Pz(t)+Pz(n));if(typeof e==`object`&&t===void 0&&n===void 0)return Nz(`#`+Pz(e.red)+Pz(e.green)+Pz(e.blue));throw new gz(6)}function Vz(e,t,n,r){if(typeof e==`string`&&typeof t==`number`){var i=Az(e);return`rgba(`+i.red+`,`+i.green+`,`+i.blue+`,`+t+`)`}if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return r>=1?Bz(e,t,n):`rgba(`+e+`,`+t+`,`+n+`,`+r+`)`;if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?Bz(e.red,e.green,e.blue):`rgba(`+e.red+`,`+e.green+`,`+e.blue+`,`+e.alpha+`)`;throw new gz(7)}var Hz=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},Uz=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&typeof e.alpha==`number`},Wz=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},Gz=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&typeof e.alpha==`number`};function Kz(e){if(typeof e!=`object`)throw new gz(8);if(Uz(e))return Vz(e);if(Hz(e))return Bz(e);if(Gz(e))return zz(e);if(Wz(e))return Rz(e);throw new gz(8)}function qz(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):qz(e,t,r)}}function Jz(e){return qz(e,e.length,[])}function Yz(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{hue:n.hue+parseFloat(e)}))}Jz(Yz);function Xz(e,t,n){return Math.max(e,Math.min(t,n))}function Zz(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{lightness:Xz(0,1,n.lightness-parseFloat(e))}))}Jz(Zz);function Qz(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{saturation:Xz(0,1,n.saturation-parseFloat(e))}))}Jz(Qz);function $z(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{lightness:Xz(0,1,n.lightness+parseFloat(e))}))}Jz($z);function eB(e,t,n){if(t===`transparent`)return n;if(n===`transparent`)return t;if(e===0)return n;var r=Az(t),i=sz({},r,{alpha:typeof r.alpha==`number`?r.alpha:1}),a=Az(n),o=sz({},a,{alpha:typeof a.alpha==`number`?a.alpha:1}),s=i.alpha-o.alpha,c=parseFloat(e)*2-1,l=((c*s===-1?c:c+s)/(1+c*s)+1)/2,u=1-l;return Vz({red:Math.floor(i.red*l+o.red*u),green:Math.floor(i.green*l+o.green*u),blue:Math.floor(i.blue*l+o.blue*u),alpha:i.alpha*parseFloat(e)+o.alpha*(1-parseFloat(e))})}var tB=Jz(eB);function nB(e,t){if(t===`transparent`)return t;var n=Az(t),r=typeof n.alpha==`number`?n.alpha:1;return Vz(sz({},n,{alpha:Xz(0,1,(r*100+parseFloat(e)*100)/100)}))}var rB=Jz(nB);function iB(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{saturation:Xz(0,1,n.saturation+parseFloat(e))}))}Jz(iB);function aB(e,t){return t===`transparent`?t:Kz(sz({},Mz(t),{hue:parseFloat(e)}))}Jz(aB);function oB(e,t){return t===`transparent`?t:Kz(sz({},Mz(t),{lightness:parseFloat(e)}))}Jz(oB);function sB(e,t){return t===`transparent`?t:Kz(sz({},Mz(t),{saturation:parseFloat(e)}))}Jz(sB);function cB(e,t){return t===`transparent`?t:tB(parseFloat(e),`rgb(0, 0, 0)`,t)}Jz(cB);function lB(e,t){return t===`transparent`?t:tB(parseFloat(e),`rgb(255, 255, 255)`,t)}Jz(lB);function uB(e,t){if(t===`transparent`)return t;var n=Az(t),r=typeof n.alpha==`number`?n.alpha:1;return Vz(sz({},n,{alpha:Xz(0,1,(r*100-parseFloat(e)*100).toFixed(2)/100)}))}Jz(uB);var dB=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return e},Out:function(e){return e},InOut:function(e){return e}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return .5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return e===0?0:1024**(e-1)},Out:function(e){return e===1?1:1-2**(-10*e)},InOut:function(e){return e===0?0:e===1?1:(e*=2)<1?.5*1024**(e-1):.5*(-(2**(-10*(e-1)))+2)}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return e===0?0:e===1?1:-(2**(10*(e-1)))*Math.sin((e-1.1)*5*Math.PI)},Out:function(e){return e===0?0:e===1?1:2**(-10*e)*Math.sin((e-.1)*5*Math.PI)+1},InOut:function(e){return e===0?0:e===1?1:(e*=2,e<1?-.5*2**(10*(e-1))*Math.sin((e-1.1)*5*Math.PI):.5*2**(-10*(e-1))*Math.sin((e-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(e){var t=1.70158;return e===1?1:e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return e===0?0:--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}}),Bounce:Object.freeze({In:function(e){return 1-dB.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?dB.Bounce.In(e*2)*.5:dB.Bounce.Out(e*2-1)*.5+.5}}),generatePow:function(e){return e===void 0&&(e=4),e=e<2**-52?2**-52:e,e=e>1e4?1e4:e,{In:function(t){return t**+e},Out:function(t){return 1-(1-t)**e},InOut:function(t){return t<.5?(t*2)**e/2:(1-(2-t*2)**e)/2+.5}}}}),fB=function(){return performance.now()},pB=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){e===void 0&&(e=fB()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var i=this._tweens[n[r]],a=!t;i&&i.update(e,a)===!1&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),mB={Linear:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=mB.Utils.Linear;return t<0?a(e[0],e[1],r):t>1?a(e[n],e[n-1],n-r):a(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,a=mB.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*a(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=mB.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),a(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):a(e[i?i-1:0],e[i],e[n<i+1?n:i+1],e[n<i+2?n:i+2],r-i)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=mB.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(function(){var e=[1];return function(t){var n=1;if(e[t])return e[t];for(var r=t;r>1;r--)n*=r;return e[t]=n,n}})(),CatmullRom:function(e,t,n,r,i){var a=(n-e)*.5,o=(r-t)*.5,s=i*i,c=i*s;return(2*t-2*n+a+o)*c+(-3*t+3*n-2*a-o)*s+a*i+t}}},hB=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),gB=new pB,_B=function(){function e(e,t){t===void 0&&(t=gB),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=dB.Linear.None,this._interpolationFunction=mB.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=hB.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw Error(`Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.`);return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(e===void 0&&(e=fB()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,n,r,i){for(var a in n){var o=e[a],s=Array.isArray(o),c=s?`array`:typeof o,l=!s&&Array.isArray(n[a]);if(c!==`undefined`&&c!==`function`){if(l){var u=n[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var m=this._handleRelativeValue(o,u[f]);if(isNaN(m)){l=!1,console.warn(`Found invalid interpolation list. Skipping.`);break}d.push(m)}l&&(n[a]=d)}if((c===`object`||s)&&o&&!l){t[a]=s?[]:{};var h=o;for(var g in h)t[a][g]=h[g];r[a]=s?[]:{};var u=n[a];if(!this._isDynamic){var _={};for(var g in u)_[g]=u[g];n[a]=u=_}this._setupProperties(h,t[a],u,r[a],i)}else(t[a]===void 0||i)&&(t[a]=o),s||(t[a]*=1),r[a]=l?n[a].slice().reverse():t[a]||0}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return e===void 0&&(e=fB()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},e.prototype.resume=function(e){return e===void 0&&(e=fB()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return e===void 0&&(e=gB),this._group=e,this},e.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},e.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},e.prototype.easing=function(e){return e===void 0&&(e=dB.Linear.None),this._easingFunction=e,this},e.prototype.interpolation=function(e){return e===void 0&&(e=mB.Linear),this._interpolationFunction=e,this},e.prototype.chain=function(){var e=[...arguments];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){var n=this;if(e===void 0&&(e=fB()),t===void 0&&(t=!0),this._isPaused)return!0;var r,i=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>i)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,o=this._duration+(this._repeatDelayTime??this._delayTime),s=this._duration+this._repeat*o,c=function(){if(n._duration===0||a>s)return 1;var e=a-Math.trunc(a/o)*o,t=Math.min(e/n._duration,1);return t===0&&a===n._duration?1:t}(),l=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||a>=this._duration){if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(r in isFinite(this._repeat)&&(this._repeat-=u),this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]==`string`&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,f=this._chainedTweens.length;d<f;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,r){for(var i in n)if(t[i]!==void 0){var a=t[i]||0,o=n[i];!Array.isArray(e[i])&&Array.isArray(o)?e[i]=this._interpolationFunction(o,r):typeof o==`object`&&o?this._updateProperties(e[i],a,o,r):(o=this._handleRelativeValue(a,o),typeof o==`number`&&(e[i]=a+(o-a)*r))}},e.prototype._handleRelativeValue=function(e,t){return typeof t==`string`?t.charAt(0)===`+`||t.charAt(0)===`-`?e+parseFloat(t):parseFloat(t):t},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n==`string`?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},e}();hB.nextId;var vB=gB;vB.getAll.bind(vB),vB.removeAll.bind(vB),vB.add.bind(vB),vB.remove.bind(vB),vB.update.bind(vB);var yB={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function bB(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),yB.hasOwnProperty(t)?{space:yB[t],local:e}:e}function xB(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function SB(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function CB(e){var t=bB(e);return(t.local?SB:xB)(t)}function wB(){}function TB(e){return e==null?wB:function(){return this.querySelector(e)}}function EB(e){typeof e!=`function`&&(e=TB(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new mH(r,this._parents)}function DB(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function OB(){return[]}function kB(e){return e==null?OB:function(){return this.querySelectorAll(e)}}function AB(e){return function(){return DB(e.apply(this,arguments))}}function jB(e){e=typeof e==`function`?AB(e):kB(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new mH(r,i)}function MB(e){return function(){return this.matches(e)}}function NB(e){return function(t){return t.matches(e)}}var PB=Array.prototype.find;function FB(e){return function(){return PB.call(this.children,e)}}function IB(){return this.firstElementChild}function LB(e){return this.select(e==null?IB:FB(typeof e==`function`?e:NB(e)))}var RB=Array.prototype.filter;function zB(){return Array.from(this.children)}function BB(e){return function(){return RB.call(this.children,e)}}function VB(e){return this.selectAll(e==null?zB:BB(typeof e==`function`?e:NB(e)))}function HB(e){typeof e!=`function`&&(e=MB(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new mH(r,this._parents)}function UB(e){return Array(e.length)}function WB(){return new mH(this._enter||this._groups.map(UB),this._parents)}function GB(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}GB.prototype={constructor:GB,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function KB(e){return function(){return e}}function qB(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new GB(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function JB(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new GB(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function YB(e){return e.__data__}function XB(e,t){if(!arguments.length)return Array.from(this,YB);var n=t?JB:qB,r=this._parents,i=this._groups;typeof e!=`function`&&(e=KB(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=ZB(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new mH(o,r),o._enter=s,o._exit=c,o}function ZB(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function QB(){return new mH(this._exit||this._groups.map(UB),this._parents)}function $B(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function eV(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new mH(s,this._parents)}function tV(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function nV(e){e||=rV;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new mH(i,this._parents).order()}function rV(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function iV(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function aV(){return Array.from(this)}function oV(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function sV(){let e=0;for(let t of this)++e;return e}function cV(){return!this.node()}function lV(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function uV(e){return function(){this.removeAttribute(e)}}function dV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fV(e,t){return function(){this.setAttribute(e,t)}}function pV(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function mV(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function hV(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function gV(e,t){var n=bB(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?dV:uV:typeof t==`function`?n.local?hV:mV:n.local?pV:fV)(n,t))}function _V(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function vV(e){return function(){this.style.removeProperty(e)}}function yV(e,t,n){return function(){this.style.setProperty(e,t,n)}}function bV(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function xV(e,t,n){return arguments.length>1?this.each((t==null?vV:typeof t==`function`?bV:yV)(e,t,n??``)):SV(this.node(),e)}function SV(e,t){return e.style.getPropertyValue(t)||_V(e).getComputedStyle(e,null).getPropertyValue(t)}function CV(e){return function(){delete this[e]}}function wV(e,t){return function(){this[e]=t}}function TV(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function EV(e,t){return arguments.length>1?this.each((t==null?CV:typeof t==`function`?TV:wV)(e,t)):this.node()[e]}function DV(e){return e.trim().split(/^|\s+/)}function OV(e){return e.classList||new kV(e)}function kV(e){this._node=e,this._names=DV(e.getAttribute(`class`)||``)}kV.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function AV(e,t){for(var n=OV(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function jV(e,t){for(var n=OV(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function MV(e){return function(){AV(this,e)}}function NV(e){return function(){jV(this,e)}}function PV(e,t){return function(){(t.apply(this,arguments)?AV:jV)(this,e)}}function FV(e,t){var n=DV(e+``);if(arguments.length<2){for(var r=OV(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?PV:t?MV:NV)(n,t))}function IV(){this.textContent=``}function LV(e){return function(){this.textContent=e}}function RV(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function zV(e){return arguments.length?this.each(e==null?IV:(typeof e==`function`?RV:LV)(e)):this.node().textContent}function BV(){this.innerHTML=``}function VV(e){return function(){this.innerHTML=e}}function HV(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function UV(e){return arguments.length?this.each(e==null?BV:(typeof e==`function`?HV:VV)(e)):this.node().innerHTML}function WV(){this.nextSibling&&this.parentNode.appendChild(this)}function GV(){return this.each(WV)}function KV(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qV(){return this.each(KV)}function JV(e){var t=typeof e==`function`?e:CB(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function YV(){return null}function XV(e,t){var n=typeof e==`function`?e:CB(e),r=t==null?YV:typeof t==`function`?t:TB(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ZV(){var e=this.parentNode;e&&e.removeChild(this)}function QV(){return this.each(ZV)}function $V(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eH(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tH(e){return this.select(e?eH:$V)}function nH(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function rH(e){return function(t){e.call(this,t,this.__data__)}}function iH(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function aH(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function oH(e,t,n){return function(){var r=this.__on,i,a=rH(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function sH(e,t,n){var r=iH(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?oH:aH,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function cH(e,t,n){var r=_V(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function lH(e,t){return function(){return cH(this,e,t)}}function uH(e,t){return function(){return cH(this,e,t.apply(this,arguments))}}function dH(e,t){return this.each((typeof t==`function`?uH:lH)(e,t))}function*fH(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var pH=[null];function mH(e,t){this._groups=e,this._parents=t}function hH(){return new mH([[document.documentElement]],pH)}function gH(){return this}mH.prototype=hH.prototype={constructor:mH,select:EB,selectAll:jB,selectChild:LB,selectChildren:VB,filter:HB,data:XB,enter:WB,exit:QB,join:$B,merge:eV,selection:gH,order:tV,sort:nV,call:iV,nodes:aV,node:oV,size:sV,empty:cV,each:lV,attr:gV,style:xV,property:EV,classed:FV,text:zV,html:UV,raise:GV,lower:qV,append:JV,insert:XV,remove:QV,clone:tH,datum:nH,on:sH,dispatch:dH,[Symbol.iterator]:fH};function _H(e){return typeof e==`string`?new mH([[document.querySelector(e)]],[document.documentElement]):new mH([[e]],pH)}function vH(e){let t;for(;t=e.sourceEvent;)e=t;return e}function yH(e,t){if(e=vH(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var bH,xH,SH,CH,wH,TH,EH,DH,OH,kH,AH,jH,MH,NH,PH,FH={},IH=[],LH=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,RH=Array.isArray;function zH(e,t){for(var n in t)e[n]=t[n];return e}function BH(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function VH(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?bH.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return HH(e,o,r,i,null)}function HH(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++SH,__i:-1,__u:0};return i==null&&xH.vnode!=null&&xH.vnode(a),a}function UH(e){return e.children}function WH(e,t){this.props=e,this.context=t}function GH(e,t){if(t==null)return e.__?GH(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?GH(e):null}function KH(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=zH({},t);a.__v=t.__v+1,xH.vnode&&xH.vnode(a),rU(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??GH(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,aU(r,a,i),t.__e=t.__=null,a.__e!=n&&qH(a)}}function qH(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),qH(e)}function JH(e){(!e.__d&&(e.__d=!0)&&wH.push(e)&&!YH.__r++||TH!=xH.debounceRendering)&&((TH=xH.debounceRendering)||EH)(YH)}function YH(){try{for(var e,t=1;wH.length;)wH.length>t&&wH.sort(DH),e=wH.shift(),t=wH.length,KH(e)}finally{wH.length=YH.__r=0}}function XH(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||IH,v=t.length;for(c=ZH(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||FH,p.__i=d,g=rU(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&cU(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=QH(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function ZH(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=HH(null,o,null,null,null):RH(o)?o=e.__k[a]=HH(UH,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=HH(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=$H(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=GH(s)),lU(s,s));return r}function QH(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=QH(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=GH(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function $H(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function eU(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||LH.test(t)?n:n+`px`}function tU(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||eU(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||eU(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(jH,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[AH]=r[AH]:(n[AH]=MH,e.addEventListener(t,a?PH:NH,a)):e.removeEventListener(t,a?PH:NH,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function nU(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[kH]==null)t[kH]=MH++;else if(t[kH]<n[AH])return;return n(xH.event?xH.event(t):t)}}}function rU(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=xH.__b)&&u(t);n:if(typeof E==`function`){d=o.length;try{if(v=t.props,y=E.prototype&&E.prototype.render,b=(u=E.contextType)&&r[u.__c],x=u?b?b.props.value:u.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new E(v,x):(t.__c=f=new WH(v,x),f.constructor=E,f.render=uU),b&&b.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&E.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=zH({},f.__s)),zH(f.__s,E.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&E.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&E.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),IH.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f),s=GH(n);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__e=!1,S=xH.__r,C=0,y)f.state=f.__s,f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),IH.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++C<25);f.state=f.__s,f.getChildContext!=null&&(r=zH(zH({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),w=u!=null&&u.type===UH&&u.key==null?oU(u.props.children):u,s=XH(e,RH(w)?w:[w],t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(T=a.length;T--;)BH(a[T])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||iU(t),xH.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=sU(n.__e,t,n,r,i,a,o,c,l);return(u=xH.diffed)&&u(t),128&t.__u?void 0:s}function iU(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(iU))}function aU(e,t,n){for(var r=0;r<n.length;r++)cU(n[r],n[++r],n[++r]);xH.__c&&xH.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){xH.__e(e,t.__v)}})}function oU(e){return typeof e!=`object`||!e||e.__b>0?e:RH(e)?e.map(oU):e.constructor===void 0?zH({},e):null}function sU(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||FH,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(xH.__m&&xH.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&bH.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||tU(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||tU(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),XH(t.type==`template`?e.content:e,RH(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&GH(n,0),s,c),a!=null)for(l=a.length;l--;)BH(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&tU(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&tU(e,l,h,g[l],i))}return e}function cU(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){xH.__e(e,n)}}function lU(e,t,n){var r,i;if(xH.unmount&&xH.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||cU(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){xH.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&lU(r[i],t,n||typeof e.type!=`function`);n||BH(e.__e),e.__c=e.__=e.__e=void 0}function uU(e,t,n){return this.constructor(e,n)}function dU(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),xH.__&&xH.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],rU(t,e=(!r&&n||t).__k=VH(UH,null,[e]),i||FH,FH,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?bH.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),aU(a,e,o),e.props.children=null}function fU(e,t,n){var r,i,a,o,s=zH({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?bH.call(arguments,2):n),HH(e.type,s,r||e.key,i||e.ref,null)}bH=IH.slice,xH={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},SH=0,CH=function(e){return e!=null&&e.constructor===void 0},WH.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=zH({},this.state);typeof e==`function`&&(e=e(zH({},n),this.props)),e&&zH(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),JH(this))},WH.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),JH(this))},WH.prototype.render=UH,wH=[],EH=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,DH=function(e,t){return e.__v.__b-t.__v.__b},YH.__r=0,OH=Math.random().toString(8),kH=`__d`+OH,AH=`__a`+OH,jH=/(PointerCapture)$|Capture$/i,MH=0,NH=nU(!1),PH=nU(!0);function pU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mU(e){if(Array.isArray(e))return e}function hU(e,t,n){return(t=SU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gU(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function _U(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5188
|
+
}`},tz=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},Nue=new hf(-1,1,1,-1,0,1),Pue=new class extends wl{constructor(){super(),this.setAttribute(`position`,new fl([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new fl([0,2,0,0,2,0],2))}},Fue=class{constructor(e){this._mesh=new Zl(Pue,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Nue)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},nz=class extends tz{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof _d?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=md.clone(e.uniforms),this.material=new _d({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new Fue(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},rz=class extends tz{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},iz=class extends tz{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},az=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new H);this._width=n.width,this._height=n.height,t=new zs(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ca}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new nz(Mue),this.copyPass.material.blending=0,this.timer=new Ef}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}rz!==void 0&&(r instanceof rz?n=!0:r instanceof iz&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new H);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},oz=class extends tz{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new Cc}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}};function sz(){return sz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sz.apply(null,arguments)}function cz(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function lz(e,t){return lz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},lz(e,t)}function uz(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,lz(e,t)}function dz(e){return dz=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},dz(e)}function fz(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}function pz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(pz=function(){return!!e})()}function mz(e,t,n){if(pz())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&lz(i,n.prototype),i}function hz(e){var t=typeof Map==`function`?new Map:void 0;return hz=function(e){if(e===null||!fz(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return mz(e,arguments,dz(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),lz(n,e)},hz(e)}var gz=function(e){uz(t,e);function t(t){return cz(e.call(this,`An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#`+t+` for more information.`)||this)}return t}(hz(Error));function _z(e){return Math.round(e*255)}function vz(e,t,n){return _z(e)+`,`+_z(t)+`,`+_z(n)}function yz(e,t,n,r){if(r===void 0&&(r=vz),t===0)return r(n,n,n);var i=(e%360+360)%360/60,a=(1-Math.abs(2*n-1))*t,o=a*(1-Math.abs(i%2-1)),s=0,c=0,l=0;i>=0&&i<1?(s=a,c=o):i>=1&&i<2?(s=o,c=a):i>=2&&i<3?(c=a,l=o):i>=3&&i<4?(c=o,l=a):i>=4&&i<5?(s=o,l=a):i>=5&&i<6&&(s=a,l=o);var u=n-a/2,d=s+u,f=c+u,p=l+u;return r(d,f,p)}var bz={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`639`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`};function xz(e){if(typeof e!=`string`)return e;var t=e.toLowerCase();return bz[t]?`#`+bz[t]:e}var Sz=/^#[a-fA-F0-9]{6}$/,Cz=/^#[a-fA-F0-9]{8}$/,wz=/^#[a-fA-F0-9]{3}$/,Tz=/^#[a-fA-F0-9]{4}$/,Ez=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Dz=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Oz=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,kz=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Az(e){if(typeof e!=`string`)throw new gz(3);var t=xz(e);if(t.match(Sz))return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16)};if(t.match(Cz)){var n=parseFloat((parseInt(``+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16),alpha:n}}if(t.match(wz))return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16)};if(t.match(Tz)){var r=parseFloat((parseInt(``+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16),alpha:r}}var i=Ez.exec(t);if(i)return{red:parseInt(``+i[1],10),green:parseInt(``+i[2],10),blue:parseInt(``+i[3],10)};var a=Dz.exec(t.substring(0,50));if(a)return{red:parseInt(``+a[1],10),green:parseInt(``+a[2],10),blue:parseInt(``+a[3],10),alpha:parseFloat(``+a[4])>1?parseFloat(``+a[4])/100:parseFloat(``+a[4])};var o=Oz.exec(t);if(o){var s=`rgb(`+yz(parseInt(``+o[1],10),parseInt(``+o[2],10)/100,parseInt(``+o[3],10)/100)+`)`,c=Ez.exec(s);if(!c)throw new gz(4,t,s);return{red:parseInt(``+c[1],10),green:parseInt(``+c[2],10),blue:parseInt(``+c[3],10)}}var l=kz.exec(t.substring(0,50));if(l){var u=`rgb(`+yz(parseInt(``+l[1],10),parseInt(``+l[2],10)/100,parseInt(``+l[3],10)/100)+`)`,d=Ez.exec(u);if(!d)throw new gz(4,t,u);return{red:parseInt(``+d[1],10),green:parseInt(``+d[2],10),blue:parseInt(``+d[3],10),alpha:parseFloat(``+l[4])>1?parseFloat(``+l[4])/100:parseFloat(``+l[4])}}throw new gz(5)}function jz(e){var t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return e.alpha===void 0?{hue:0,saturation:0,lightness:o}:{hue:0,saturation:0,lightness:o,alpha:e.alpha};var s,c=i-a,l=o>.5?c/(2-i-a):c/(i+a);switch(i){case t:s=(n-r)/c+(n<r?6:0);break;case n:s=(r-t)/c+2;break;default:s=(t-n)/c+4}return s*=60,e.alpha===void 0?{hue:s,saturation:l,lightness:o}:{hue:s,saturation:l,lightness:o,alpha:e.alpha}}function Mz(e){return jz(Az(e))}var Nz=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?`#`+e[1]+e[3]+e[5]:e};function Pz(e){var t=e.toString(16);return t.length===1?`0`+t:t}function Fz(e){return Pz(Math.round(e*255))}function Iz(e,t,n){return Nz(`#`+Fz(e)+Fz(t)+Fz(n))}function Lz(e,t,n){return yz(e,t,n,Iz)}function Rz(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Lz(e,t,n);if(typeof e==`object`&&t===void 0&&n===void 0)return Lz(e.hue,e.saturation,e.lightness);throw new gz(1)}function zz(e,t,n,r){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return r>=1?Lz(e,t,n):`rgba(`+yz(e,t,n)+`,`+r+`)`;if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?Lz(e.hue,e.saturation,e.lightness):`rgba(`+yz(e.hue,e.saturation,e.lightness)+`,`+e.alpha+`)`;throw new gz(2)}function Bz(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Nz(`#`+Pz(e)+Pz(t)+Pz(n));if(typeof e==`object`&&t===void 0&&n===void 0)return Nz(`#`+Pz(e.red)+Pz(e.green)+Pz(e.blue));throw new gz(6)}function Vz(e,t,n,r){if(typeof e==`string`&&typeof t==`number`){var i=Az(e);return`rgba(`+i.red+`,`+i.green+`,`+i.blue+`,`+t+`)`}if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return r>=1?Bz(e,t,n):`rgba(`+e+`,`+t+`,`+n+`,`+r+`)`;if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?Bz(e.red,e.green,e.blue):`rgba(`+e.red+`,`+e.green+`,`+e.blue+`,`+e.alpha+`)`;throw new gz(7)}var Hz=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},Uz=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&typeof e.alpha==`number`},Wz=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},Gz=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&typeof e.alpha==`number`};function Kz(e){if(typeof e!=`object`)throw new gz(8);if(Uz(e))return Vz(e);if(Hz(e))return Bz(e);if(Gz(e))return zz(e);if(Wz(e))return Rz(e);throw new gz(8)}function qz(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):qz(e,t,r)}}function Jz(e){return qz(e,e.length,[])}function Yz(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{hue:n.hue+parseFloat(e)}))}Jz(Yz);function Xz(e,t,n){return Math.max(e,Math.min(t,n))}function Zz(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{lightness:Xz(0,1,n.lightness-parseFloat(e))}))}Jz(Zz);function Qz(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{saturation:Xz(0,1,n.saturation-parseFloat(e))}))}Jz(Qz);function $z(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{lightness:Xz(0,1,n.lightness+parseFloat(e))}))}Jz($z);function eB(e,t,n){if(t===`transparent`)return n;if(n===`transparent`)return t;if(e===0)return n;var r=Az(t),i=sz({},r,{alpha:typeof r.alpha==`number`?r.alpha:1}),a=Az(n),o=sz({},a,{alpha:typeof a.alpha==`number`?a.alpha:1}),s=i.alpha-o.alpha,c=parseFloat(e)*2-1,l=((c*s===-1?c:c+s)/(1+c*s)+1)/2,u=1-l;return Vz({red:Math.floor(i.red*l+o.red*u),green:Math.floor(i.green*l+o.green*u),blue:Math.floor(i.blue*l+o.blue*u),alpha:i.alpha*parseFloat(e)+o.alpha*(1-parseFloat(e))})}var tB=Jz(eB);function nB(e,t){if(t===`transparent`)return t;var n=Az(t),r=typeof n.alpha==`number`?n.alpha:1;return Vz(sz({},n,{alpha:Xz(0,1,(r*100+parseFloat(e)*100)/100)}))}var rB=Jz(nB);function iB(e,t){if(t===`transparent`)return t;var n=Mz(t);return Kz(sz({},n,{saturation:Xz(0,1,n.saturation+parseFloat(e))}))}Jz(iB);function aB(e,t){return t===`transparent`?t:Kz(sz({},Mz(t),{hue:parseFloat(e)}))}Jz(aB);function oB(e,t){return t===`transparent`?t:Kz(sz({},Mz(t),{lightness:parseFloat(e)}))}Jz(oB);function sB(e,t){return t===`transparent`?t:Kz(sz({},Mz(t),{saturation:parseFloat(e)}))}Jz(sB);function cB(e,t){return t===`transparent`?t:tB(parseFloat(e),`rgb(0, 0, 0)`,t)}Jz(cB);function lB(e,t){return t===`transparent`?t:tB(parseFloat(e),`rgb(255, 255, 255)`,t)}Jz(lB);function uB(e,t){if(t===`transparent`)return t;var n=Az(t),r=typeof n.alpha==`number`?n.alpha:1;return Vz(sz({},n,{alpha:Xz(0,1,(r*100-parseFloat(e)*100).toFixed(2)/100)}))}Jz(uB);var dB=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return e},Out:function(e){return e},InOut:function(e){return e}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return .5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return e===0?0:1024**(e-1)},Out:function(e){return e===1?1:1-2**(-10*e)},InOut:function(e){return e===0?0:e===1?1:(e*=2)<1?.5*1024**(e-1):.5*(-(2**(-10*(e-1)))+2)}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return e===0?0:e===1?1:-(2**(10*(e-1)))*Math.sin((e-1.1)*5*Math.PI)},Out:function(e){return e===0?0:e===1?1:2**(-10*e)*Math.sin((e-.1)*5*Math.PI)+1},InOut:function(e){return e===0?0:e===1?1:(e*=2,e<1?-.5*2**(10*(e-1))*Math.sin((e-1.1)*5*Math.PI):.5*2**(-10*(e-1))*Math.sin((e-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(e){var t=1.70158;return e===1?1:e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return e===0?0:--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}}),Bounce:Object.freeze({In:function(e){return 1-dB.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?dB.Bounce.In(e*2)*.5:dB.Bounce.Out(e*2-1)*.5+.5}}),generatePow:function(e){return e===void 0&&(e=4),e=e<2**-52?2**-52:e,e=e>1e4?1e4:e,{In:function(t){return t**+e},Out:function(t){return 1-(1-t)**e},InOut:function(t){return t<.5?(t*2)**e/2:(1-(2-t*2)**e)/2+.5}}}}),fB=function(){return performance.now()},pB=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){e===void 0&&(e=fB()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var i=this._tweens[n[r]],a=!t;i&&i.update(e,a)===!1&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),mB={Linear:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=mB.Utils.Linear;return t<0?a(e[0],e[1],r):t>1?a(e[n],e[n-1],n-r):a(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,a=mB.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*a(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=mB.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),a(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):a(e[i?i-1:0],e[i],e[n<i+1?n:i+1],e[n<i+2?n:i+2],r-i)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=mB.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(function(){var e=[1];return function(t){var n=1;if(e[t])return e[t];for(var r=t;r>1;r--)n*=r;return e[t]=n,n}})(),CatmullRom:function(e,t,n,r,i){var a=(n-e)*.5,o=(r-t)*.5,s=i*i,c=i*s;return(2*t-2*n+a+o)*c+(-3*t+3*n-2*a-o)*s+a*i+t}}},hB=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),gB=new pB,_B=function(){function e(e,t){t===void 0&&(t=gB),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=dB.Linear.None,this._interpolationFunction=mB.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=hB.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw Error(`Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.`);return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(e===void 0&&(e=fB()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,n,r,i){for(var a in n){var o=e[a],s=Array.isArray(o),c=s?`array`:typeof o,l=!s&&Array.isArray(n[a]);if(c!==`undefined`&&c!==`function`){if(l){var u=n[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var m=this._handleRelativeValue(o,u[f]);if(isNaN(m)){l=!1,console.warn(`Found invalid interpolation list. Skipping.`);break}d.push(m)}l&&(n[a]=d)}if((c===`object`||s)&&o&&!l){t[a]=s?[]:{};var h=o;for(var g in h)t[a][g]=h[g];r[a]=s?[]:{};var u=n[a];if(!this._isDynamic){var _={};for(var g in u)_[g]=u[g];n[a]=u=_}this._setupProperties(h,t[a],u,r[a],i)}else(t[a]===void 0||i)&&(t[a]=o),s||(t[a]*=1),r[a]=l?n[a].slice().reverse():t[a]||0}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return e===void 0&&(e=fB()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},e.prototype.resume=function(e){return e===void 0&&(e=fB()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return e===void 0&&(e=gB),this._group=e,this},e.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},e.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},e.prototype.easing=function(e){return e===void 0&&(e=dB.Linear.None),this._easingFunction=e,this},e.prototype.interpolation=function(e){return e===void 0&&(e=mB.Linear),this._interpolationFunction=e,this},e.prototype.chain=function(){var e=[...arguments];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){var n=this;if(e===void 0&&(e=fB()),t===void 0&&(t=!0),this._isPaused)return!0;var r,i=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>i)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,o=this._duration+(this._repeatDelayTime??this._delayTime),s=this._duration+this._repeat*o,c=function(){if(n._duration===0||a>s)return 1;var e=a-Math.trunc(a/o)*o,t=Math.min(e/n._duration,1);return t===0&&a===n._duration?1:t}(),l=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||a>=this._duration){if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(r in isFinite(this._repeat)&&(this._repeat-=u),this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]==`string`&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,f=this._chainedTweens.length;d<f;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,r){for(var i in n)if(t[i]!==void 0){var a=t[i]||0,o=n[i];!Array.isArray(e[i])&&Array.isArray(o)?e[i]=this._interpolationFunction(o,r):typeof o==`object`&&o?this._updateProperties(e[i],a,o,r):(o=this._handleRelativeValue(a,o),typeof o==`number`&&(e[i]=a+(o-a)*r))}},e.prototype._handleRelativeValue=function(e,t){return typeof t==`string`?t.charAt(0)===`+`||t.charAt(0)===`-`?e+parseFloat(t):parseFloat(t):t},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n==`string`?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},e}();hB.nextId;var vB=gB;vB.getAll.bind(vB),vB.removeAll.bind(vB),vB.add.bind(vB),vB.remove.bind(vB),vB.update.bind(vB);var yB={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function bB(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),yB.hasOwnProperty(t)?{space:yB[t],local:e}:e}function xB(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function SB(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function CB(e){var t=bB(e);return(t.local?SB:xB)(t)}function wB(){}function TB(e){return e==null?wB:function(){return this.querySelector(e)}}function EB(e){typeof e!=`function`&&(e=TB(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new mH(r,this._parents)}function DB(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function OB(){return[]}function kB(e){return e==null?OB:function(){return this.querySelectorAll(e)}}function AB(e){return function(){return DB(e.apply(this,arguments))}}function jB(e){e=typeof e==`function`?AB(e):kB(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new mH(r,i)}function MB(e){return function(){return this.matches(e)}}function NB(e){return function(t){return t.matches(e)}}var PB=Array.prototype.find;function FB(e){return function(){return PB.call(this.children,e)}}function IB(){return this.firstElementChild}function LB(e){return this.select(e==null?IB:FB(typeof e==`function`?e:NB(e)))}var RB=Array.prototype.filter;function zB(){return Array.from(this.children)}function BB(e){return function(){return RB.call(this.children,e)}}function VB(e){return this.selectAll(e==null?zB:BB(typeof e==`function`?e:NB(e)))}function HB(e){typeof e!=`function`&&(e=MB(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new mH(r,this._parents)}function UB(e){return Array(e.length)}function WB(){return new mH(this._enter||this._groups.map(UB),this._parents)}function GB(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}GB.prototype={constructor:GB,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function KB(e){return function(){return e}}function qB(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new GB(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function JB(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new GB(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function YB(e){return e.__data__}function XB(e,t){if(!arguments.length)return Array.from(this,YB);var n=t?JB:qB,r=this._parents,i=this._groups;typeof e!=`function`&&(e=KB(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=ZB(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new mH(o,r),o._enter=s,o._exit=c,o}function ZB(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function QB(){return new mH(this._exit||this._groups.map(UB),this._parents)}function $B(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function eV(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new mH(s,this._parents)}function tV(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function nV(e){e||=rV;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new mH(i,this._parents).order()}function rV(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function iV(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function aV(){return Array.from(this)}function oV(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function sV(){let e=0;for(let t of this)++e;return e}function cV(){return!this.node()}function lV(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function uV(e){return function(){this.removeAttribute(e)}}function dV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fV(e,t){return function(){this.setAttribute(e,t)}}function pV(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function mV(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function hV(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function gV(e,t){var n=bB(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?dV:uV:typeof t==`function`?n.local?hV:mV:n.local?pV:fV)(n,t))}function _V(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function vV(e){return function(){this.style.removeProperty(e)}}function yV(e,t,n){return function(){this.style.setProperty(e,t,n)}}function bV(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function xV(e,t,n){return arguments.length>1?this.each((t==null?vV:typeof t==`function`?bV:yV)(e,t,n??``)):SV(this.node(),e)}function SV(e,t){return e.style.getPropertyValue(t)||_V(e).getComputedStyle(e,null).getPropertyValue(t)}function CV(e){return function(){delete this[e]}}function wV(e,t){return function(){this[e]=t}}function TV(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function EV(e,t){return arguments.length>1?this.each((t==null?CV:typeof t==`function`?TV:wV)(e,t)):this.node()[e]}function DV(e){return e.trim().split(/^|\s+/)}function OV(e){return e.classList||new kV(e)}function kV(e){this._node=e,this._names=DV(e.getAttribute(`class`)||``)}kV.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function AV(e,t){for(var n=OV(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function jV(e,t){for(var n=OV(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function MV(e){return function(){AV(this,e)}}function NV(e){return function(){jV(this,e)}}function PV(e,t){return function(){(t.apply(this,arguments)?AV:jV)(this,e)}}function FV(e,t){var n=DV(e+``);if(arguments.length<2){for(var r=OV(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?PV:t?MV:NV)(n,t))}function IV(){this.textContent=``}function LV(e){return function(){this.textContent=e}}function RV(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function zV(e){return arguments.length?this.each(e==null?IV:(typeof e==`function`?RV:LV)(e)):this.node().textContent}function BV(){this.innerHTML=``}function VV(e){return function(){this.innerHTML=e}}function HV(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function UV(e){return arguments.length?this.each(e==null?BV:(typeof e==`function`?HV:VV)(e)):this.node().innerHTML}function WV(){this.nextSibling&&this.parentNode.appendChild(this)}function GV(){return this.each(WV)}function KV(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qV(){return this.each(KV)}function JV(e){var t=typeof e==`function`?e:CB(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function YV(){return null}function XV(e,t){var n=typeof e==`function`?e:CB(e),r=t==null?YV:typeof t==`function`?t:TB(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ZV(){var e=this.parentNode;e&&e.removeChild(this)}function QV(){return this.each(ZV)}function $V(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eH(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tH(e){return this.select(e?eH:$V)}function nH(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function rH(e){return function(t){e.call(this,t,this.__data__)}}function iH(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function aH(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function oH(e,t,n){return function(){var r=this.__on,i,a=rH(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function sH(e,t,n){var r=iH(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?oH:aH,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function cH(e,t,n){var r=_V(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function lH(e,t){return function(){return cH(this,e,t)}}function uH(e,t){return function(){return cH(this,e,t.apply(this,arguments))}}function dH(e,t){return this.each((typeof t==`function`?uH:lH)(e,t))}function*fH(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var pH=[null];function mH(e,t){this._groups=e,this._parents=t}function hH(){return new mH([[document.documentElement]],pH)}function gH(){return this}mH.prototype=hH.prototype={constructor:mH,select:EB,selectAll:jB,selectChild:LB,selectChildren:VB,filter:HB,data:XB,enter:WB,exit:QB,join:$B,merge:eV,selection:gH,order:tV,sort:nV,call:iV,nodes:aV,node:oV,size:sV,empty:cV,each:lV,attr:gV,style:xV,property:EV,classed:FV,text:zV,html:UV,raise:GV,lower:qV,append:JV,insert:XV,remove:QV,clone:tH,datum:nH,on:sH,dispatch:dH,[Symbol.iterator]:fH};function _H(e){return typeof e==`string`?new mH([[document.querySelector(e)]],[document.documentElement]):new mH([[e]],pH)}function vH(e){let t;for(;t=e.sourceEvent;)e=t;return e}function yH(e,t){if(e=vH(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var bH,xH,SH,CH,wH,TH,EH,DH,OH,kH,AH,jH,MH,NH,PH,FH={},IH=[],LH=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,RH=Array.isArray;function zH(e,t){for(var n in t)e[n]=t[n];return e}function BH(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function VH(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?bH.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return HH(e,o,r,i,null)}function HH(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++SH,__i:-1,__u:0};return i==null&&xH.vnode!=null&&xH.vnode(a),a}function UH(e){return e.children}function WH(e,t){this.props=e,this.context=t}function GH(e,t){if(t==null)return e.__?GH(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?GH(e):null}function KH(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=zH({},t);a.__v=t.__v+1,xH.vnode&&xH.vnode(a),rU(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??GH(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,aU(r,a,i),t.__e=t.__=null,a.__e!=n&&qH(a)}}function qH(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),qH(e)}function JH(e){(!e.__d&&(e.__d=!0)&&wH.push(e)&&!YH.__r++||TH!=xH.debounceRendering)&&((TH=xH.debounceRendering)||EH)(YH)}function YH(){try{for(var e,t=1;wH.length;)wH.length>t&&wH.sort(DH),e=wH.shift(),t=wH.length,KH(e)}finally{wH.length=YH.__r=0}}function XH(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||IH,v=t.length;for(c=ZH(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||FH,p.__i=d,g=rU(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&cU(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=QH(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function ZH(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=HH(null,o,null,null,null):RH(o)?o=e.__k[a]=HH(UH,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=HH(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=$H(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=GH(s)),lU(s,s));return r}function QH(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=QH(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=GH(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function $H(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function eU(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||LH.test(t)?n:n+`px`}function tU(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||eU(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||eU(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(jH,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[AH]=r[AH]:(n[AH]=MH,e.addEventListener(t,a?PH:NH,a)):e.removeEventListener(t,a?PH:NH,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function nU(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[kH]==null)t[kH]=MH++;else if(t[kH]<n[AH])return;return n(xH.event?xH.event(t):t)}}}function rU(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=xH.__b)&&u(t);n:if(typeof E==`function`){d=o.length;try{if(v=t.props,y=E.prototype&&E.prototype.render,b=(u=E.contextType)&&r[u.__c],x=u?b?b.props.value:u.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new E(v,x):(t.__c=f=new WH(v,x),f.constructor=E,f.render=uU),b&&b.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&E.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=zH({},f.__s)),zH(f.__s,E.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&E.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&E.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),IH.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f),s=GH(n);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__e=!1,S=xH.__r,C=0,y)f.state=f.__s,f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),IH.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++C<25);f.state=f.__s,f.getChildContext!=null&&(r=zH(zH({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),w=u!=null&&u.type===UH&&u.key==null?oU(u.props.children):u,s=XH(e,RH(w)?w:[w],t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(T=a.length;T--;)BH(a[T])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||iU(t),xH.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=sU(n.__e,t,n,r,i,a,o,c,l);return(u=xH.diffed)&&u(t),128&t.__u?void 0:s}function iU(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(iU))}function aU(e,t,n){for(var r=0;r<n.length;r++)cU(n[r],n[++r],n[++r]);xH.__c&&xH.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){xH.__e(e,t.__v)}})}function oU(e){return typeof e!=`object`||!e||e.__b>0?e:RH(e)?e.map(oU):e.constructor===void 0?zH({},e):null}function sU(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||FH,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(xH.__m&&xH.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&bH.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||tU(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||tU(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),XH(t.type==`template`?e.content:e,RH(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&GH(n,0),s,c),a!=null)for(l=a.length;l--;)BH(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&tU(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&tU(e,l,h,g[l],i))}return e}function cU(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){xH.__e(e,n)}}function lU(e,t,n){var r,i;if(xH.unmount&&xH.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||cU(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){xH.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&lU(r[i],t,n||typeof e.type!=`function`);n||BH(e.__e),e.__c=e.__=e.__e=void 0}function uU(e,t,n){return this.constructor(e,n)}function dU(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),xH.__&&xH.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],rU(t,e=(!r&&n||t).__k=VH(UH,null,[e]),i||FH,FH,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?bH.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),aU(a,e,o),e.props.children=null}function fU(e,t,n){var r,i,a,o,s=zH({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?bH.call(arguments,2):n),HH(e.type,s,r||e.key,i||e.ref,null)}bH=IH.slice,xH={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},SH=0,CH=function(e){return e!=null&&e.constructor===void 0},WH.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=zH({},this.state);typeof e==`function`&&(e=e(zH({},n),this.props)),e&&zH(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),JH(this))},WH.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),JH(this))},WH.prototype.render=UH,wH=[],EH=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,DH=function(e,t){return e.__v.__b-t.__v.__b},YH.__r=0,OH=Math.random().toString(8),kH=`__d`+OH,AH=`__a`+OH,jH=/(PointerCapture)$|Capture$/i,MH=0,NH=nU(!1),PH=nU(!0);function pU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mU(e){if(Array.isArray(e))return e}function hU(e,t,n){return(t=SU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gU(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function _U(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5189
5189
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?vU(Object(n),!0).forEach(function(t){hU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function bU(e,t){return mU(e)||gU(e,t)||wU(e,t)||_U()}function xU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function SU(e){var t=xU(e,`string`);return typeof t==`symbol`?t:t+``}function CU(e){"@babel/helpers - typeof";return CU=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},CU(e)}function wU(e,t){if(e){if(typeof e==`string`)return pU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pU(e,t):void 0}}var TU=function(e){if(CU(e)!==`object`)return e;var t=fU(e);if(t.props){var n;t.props=yU({},t.props),t!=null&&(n=t.props)!=null&&n.children&&(t.props.children=Array.isArray(t.props.children)?t.props.children.map(TU):TU(t.props.children))}return t},EU=function(e){return CH(fU(e))},DU=function(e,t){delete t.__k,dU(TU(e),t)};function OU(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}OU(`.float-tooltip-kap {
|
|
5190
5190
|
position: absolute;
|
|
5191
5191
|
width: max-content; /* prevent shrinking near right edge */
|
|
@@ -5214,7 +5214,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5214
5214
|
outline: none;
|
|
5215
5215
|
}`);function jU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function MU(e){if(Array.isArray(e))return e}function NU(e){if(Array.isArray(e))return jU(e)}function PU(e,t,n){return(t=HU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function FU(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function IU(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function LU(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5216
5216
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RU(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
5217
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zU(e,t){return MU(e)||IU(e,t)||UU(e,t)||LU()}function BU(e){return NU(e)||FU(e)||UU(e)||RU()}function VU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function HU(e){var t=VU(e,`string`);return typeof t==`symbol`?t:t+``}function UU(e,t){if(e){if(typeof e==`string`)return jU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jU(e,t):void 0}}var WU=function(e){e instanceof Array?e.forEach(WU):(e.map&&e.map.dispose(),e.dispose())},GU=function(e){e.geometry&&e.geometry.dispose(),e.material&&WU(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(GU)},KU=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),GU(t)}},qU=window.THREE?window.THREE:{WebGLRenderer:gh,Scene:Tc,PerspectiveCamera:uf,Raycaster:Hf,SRGBColorSpace:go,TextureLoader:Yd,Vector2:H,Vector3:U,Box3:Bc,Color:Cc,Mesh:Zl,SphereGeometry:ad,MeshBasicMaterial:zl,BackSide:1,Timer:Ef},JU=m_({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:`#000011`},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.timer.update().getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(t){return t.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(t,n){return e.hoverOrderComparator(t.object,n.object)});var i=r.find(function(t){return e.hoverFilter(t.object)})||null;n=i?i.object:null,e.intersection=i||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&h_(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos;return{x:t.x,y:t.y}},cameraPosition:function(e,t,n,r){var i=e.camera;if(t&&e.initialised){var a,o,s=t,c=n||{x:0,y:0,z:0};if((a=e.povPosTween)==null||a.end(),(o=e.povTgtTween)==null||o.end(),!r)d(s),f(c);else{var l=Object.assign({},i.position),u=p();e.tweenGroup.add(e.povPosTween=new _B(l).to(s,r).easing(dB.Quadratic.Out).onUpdate(d).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new _B(u).to(c,r/3).easing(dB.Quadratic.Out).onUpdate(f).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},i.position,{lookAt:p()});function d(e){var t=e.x,n=e.y,r=e.z;t!==void 0&&(i.position.x=t),n!==void 0&&(i.position.y=n),r!==void 0&&(i.position.z=r)}function f(t){var n=new qU.Vector3(t.x,t.y,t.z);e.controls.enabled&&e.controls.target?e.controls.target=n:i.lookAt(n)}function p(){return Object.assign(new qU.Vector3(0,0,-1e3).applyQuaternion(i.quaternion).add(i.position))}},zoomToFit:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=[...arguments].slice(3);return this.fitToBbox(this.getBbox.apply(this,r),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,i=e.camera;if(t){var a=new qU.Vector3(0,0,0),o=Math.max.apply(Math,BU(Object.entries(t).map(function(e){var t=zU(e,2),n=t[0],r=t[1];return Math.max.apply(Math,BU(r.map(function(e){return Math.abs(a[n]-e)})))})))*2,s=(1-r*2/e.height)*i.fov,c=o/Math.atan(s*Math.PI/180),l=c/i.aspect,u=Math.max(c,l);if(u>0){var d=a.clone().sub(i.position).normalize().multiplyScalar(-u);this.cameraPosition(d,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new qU.Box3(new qU.Vector3(0,0,0),new qU.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(e){return n.expandByObject(e)}),Object.assign.apply(Object,BU([`x`,`y`,`z`].map(function(e){return PU({},e,[n.min[e],n.max[e]])})))):null},getScreenCoords:function(e,t,n,r){var i=new qU.Vector3(t,n,r);return i.project(this.camera()),{x:(i.x+1)*e.width/2,y:-(i.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=new qU.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new qU.Raycaster;return a.setFromCamera(i,e.camera),Object.assign({},a.ray.at(r,new qU.Vector3))},intersectingObjects:function(e,t,n){var r=new qU.Vector2(t/e.width*2-1,-(n/e.height)*2+1),i=new qU.Raycaster;return i.params.Line.threshold=e.lineHoverPrecision,i.params.Points.threshold=e.pointsHoverPrecision,i.setFromCamera(r,e.camera),i.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,n,r;KU(e.scene),(t=e.controls)==null||t.dispose(),(n=e.renderer)==null||n.dispose(),(r=e.postProcessingComposer)==null||r.dispose()}},stateInit:function(){return{scene:new qU.Scene,camera:new qU.PerspectiveCamera,timer:new qU.Timer,tweenGroup:new pB,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,i=r===void 0?`trackball`:r,a=n.useWebGPU,o=a!==void 0&&a,s=n.rendererConfig,c=s===void 0?{}:s,l=n.extraRenderers,u=l===void 0?[]:l,d=n.waitForLoadComplete,f=d===void 0||d;e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.className=`scene-container`,t.container.style.position=`relative`,t.container.appendChild(t.navInfo=document.createElement(`div`)),t.navInfo.className=`scene-nav-info`,t.navInfo.textContent={orbit:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,trackball:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,fly:`WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw`}[i]||``,t.navInfo.style.display=t.showNavInfo?null:`none`,t.tooltip=new kU(t.container),t.pointerPos=new qU.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,[`pointermove`,`pointerdown`].forEach(function(e){return t.container.addEventListener(e,function(n){if(e===`pointerdown`&&(t.isPointerPressed=!0),!t.isPointerDragging&&n.type===`pointermove`&&(n.pressure>0||t.isPointerPressed)&&(n.pointerType===`mouse`||n.movementX===void 0||[n.movementX,n.movementY].some(function(e){return Math.abs(e)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var r=i(t.container);t.pointerPos.x=n.pageX-r.left,t.pointerPos.y=n.pageY-r.top}function i(e){var t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,r=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+r,left:t.left+n}}},{passive:!0})}),t.container.addEventListener(`pointerup`,function(e){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){e.button===0&&t.onClick(t.hoverObj||null,e,t.intersection),e.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,e,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener(`contextmenu`,function(e){t.onRightClick&&e.preventDefault()}),t.renderer=new(o?qle:qU.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},c)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=u,t.extraRenderers.forEach(function(e){e.domElement.style.position=`absolute`,e.domElement.style.top=`0px`,e.domElement.style.pointerEvents=`none`,t.container.appendChild(e.domElement)}),t.postProcessingComposer=new az(t.renderer),t.postProcessingComposer.addPass(new oz(t.scene,t.camera)),t.controls=new{trackball:Yle,orbit:due,fly:Tue}[i](t.camera,t.renderer.domElement),i===`fly`&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(i===`trackball`||i===`orbit`)&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener(`start`,function(){t.controlsEngaged=!0}),t.controls.addEventListener(`change`,function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener(`end`,function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(BU(t.extraRenderers)).forEach(function(e){return e.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new qU.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!f,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty(`width`)||t.hasOwnProperty(`height`))){var n,r=e.width,i=e.height;e.container.style.width=`${r}px`,e.container.style.height=`${i}px`,[e.renderer,e.postProcessingComposer].concat(BU(e.extraRenderers)).forEach(function(e){return e.setSize(r,i)}),e.camera.aspect=r/i;var a=e.viewOffset.slice(0,2);a.some(function(e){return e})&&(n=e.camera).setViewOffset.apply(n,[r,i].concat(BU(a),[r,i])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty(`viewOffset`)){var o,s=e.width,c=e.height,l=e.viewOffset.slice(0,2);l.some(function(e){return e})?(o=e.camera).setViewOffset.apply(o,[s,c].concat(BU(l),[s,c])):e.camera.clearViewOffset()}if(t.hasOwnProperty(`skyRadius`)&&e.skyRadius&&(e.controls.hasOwnProperty(`maxDistance`)&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new qU.SphereGeometry(e.skyRadius)),t.hasOwnProperty(`backgroundColor`)){var u=Az(e.backgroundColor).alpha;u===void 0&&(u=1),e.renderer.setClearColor(new qU.Color(rB(1,e.backgroundColor)),u)}t.hasOwnProperty(`backgroundImageUrl`)&&(e.backgroundImageUrl?new qU.TextureLoader().load(e.backgroundImageUrl,function(t){t.colorSpace=qU.SRGBColorSpace,e.skysphere.material=new qU.MeshBasicMaterial({map:t,side:qU.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&d()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&d())),t.hasOwnProperty(`showNavInfo`)&&(e.navInfo.style.display=e.showNavInfo?null:`none`),t.hasOwnProperty(`lights`)&&((t.lights||[]).forEach(function(t){return e.scene.remove(t)}),e.lights.forEach(function(t){return e.scene.add(t)})),t.hasOwnProperty(`objects`)&&((t.objects||[]).forEach(function(t){return e.scene.remove(t)}),e.objects.forEach(function(t){return e.scene.add(t)}));function d(){e.loadComplete=e.scene.visible=!0}}});function YU(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}YU(`.graph-info-msg {
|
|
5217
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zU(e,t){return MU(e)||IU(e,t)||UU(e,t)||LU()}function BU(e){return NU(e)||FU(e)||UU(e)||RU()}function VU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function HU(e){var t=VU(e,`string`);return typeof t==`symbol`?t:t+``}function UU(e,t){if(e){if(typeof e==`string`)return jU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jU(e,t):void 0}}var WU=function(e){e instanceof Array?e.forEach(WU):(e.map&&e.map.dispose(),e.dispose())},GU=function(e){e.geometry&&e.geometry.dispose(),e.material&&WU(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(GU)},KU=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),GU(t)}},qU=window.THREE?window.THREE:{WebGLRenderer:gh,Scene:Tc,PerspectiveCamera:uf,Raycaster:Hf,SRGBColorSpace:go,TextureLoader:Yd,Vector2:H,Vector3:U,Box3:Bc,Color:Cc,Mesh:Zl,SphereGeometry:ad,MeshBasicMaterial:zl,BackSide:1,Timer:Ef},JU=m_({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:`#000011`},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.timer.update().getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(t){return t.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(t,n){return e.hoverOrderComparator(t.object,n.object)});var i=r.find(function(t){return e.hoverFilter(t.object)})||null;n=i?i.object:null,e.intersection=i||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&h_(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos;return{x:t.x,y:t.y}},cameraPosition:function(e,t,n,r){var i=e.camera;if(t&&e.initialised){var a,o,s=t,c=n||{x:0,y:0,z:0};if((a=e.povPosTween)==null||a.end(),(o=e.povTgtTween)==null||o.end(),!r)d(s),f(c);else{var l=Object.assign({},i.position),u=p();e.tweenGroup.add(e.povPosTween=new _B(l).to(s,r).easing(dB.Quadratic.Out).onUpdate(d).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new _B(u).to(c,r/3).easing(dB.Quadratic.Out).onUpdate(f).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},i.position,{lookAt:p()});function d(e){var t=e.x,n=e.y,r=e.z;t!==void 0&&(i.position.x=t),n!==void 0&&(i.position.y=n),r!==void 0&&(i.position.z=r)}function f(t){var n=new qU.Vector3(t.x,t.y,t.z);e.controls.enabled&&e.controls.target?e.controls.target=n:i.lookAt(n)}function p(){return Object.assign(new qU.Vector3(0,0,-1e3).applyQuaternion(i.quaternion).add(i.position))}},zoomToFit:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=[...arguments].slice(3);return this.fitToBbox(this.getBbox.apply(this,r),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,i=e.camera;if(t){var a=new qU.Vector3(0,0,0),o=Math.max.apply(Math,BU(Object.entries(t).map(function(e){var t=zU(e,2),n=t[0],r=t[1];return Math.max.apply(Math,BU(r.map(function(e){return Math.abs(a[n]-e)})))})))*2,s=(1-r*2/e.height)*i.fov,c=o/Math.atan(s*Math.PI/180),l=c/i.aspect,u=Math.max(c,l);if(u>0){var d=a.clone().sub(i.position).normalize().multiplyScalar(-u);this.cameraPosition(d,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new qU.Box3(new qU.Vector3(0,0,0),new qU.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(e){return n.expandByObject(e)}),Object.assign.apply(Object,BU([`x`,`y`,`z`].map(function(e){return PU({},e,[n.min[e],n.max[e]])})))):null},getScreenCoords:function(e,t,n,r){var i=new qU.Vector3(t,n,r);return i.project(this.camera()),{x:(i.x+1)*e.width/2,y:-(i.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=new qU.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new qU.Raycaster;return a.setFromCamera(i,e.camera),Object.assign({},a.ray.at(r,new qU.Vector3))},intersectingObjects:function(e,t,n){var r=new qU.Vector2(t/e.width*2-1,-(n/e.height)*2+1),i=new qU.Raycaster;return i.params.Line.threshold=e.lineHoverPrecision,i.params.Points.threshold=e.pointsHoverPrecision,i.setFromCamera(r,e.camera),i.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,n,r;KU(e.scene),(t=e.controls)==null||t.dispose(),(n=e.renderer)==null||n.dispose(),(r=e.postProcessingComposer)==null||r.dispose()}},stateInit:function(){return{scene:new qU.Scene,camera:new qU.PerspectiveCamera,timer:new qU.Timer,tweenGroup:new pB,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,i=r===void 0?`trackball`:r,a=n.useWebGPU,o=a!==void 0&&a,s=n.rendererConfig,c=s===void 0?{}:s,l=n.extraRenderers,u=l===void 0?[]:l,d=n.waitForLoadComplete,f=d===void 0||d;e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.className=`scene-container`,t.container.style.position=`relative`,t.container.appendChild(t.navInfo=document.createElement(`div`)),t.navInfo.className=`scene-nav-info`,t.navInfo.textContent={orbit:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,trackball:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,fly:`WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw`}[i]||``,t.navInfo.style.display=t.showNavInfo?null:`none`,t.tooltip=new kU(t.container),t.pointerPos=new qU.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,[`pointermove`,`pointerdown`].forEach(function(e){return t.container.addEventListener(e,function(n){if(e===`pointerdown`&&(t.isPointerPressed=!0),!t.isPointerDragging&&n.type===`pointermove`&&(n.pressure>0||t.isPointerPressed)&&(n.pointerType===`mouse`||n.movementX===void 0||[n.movementX,n.movementY].some(function(e){return Math.abs(e)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var r=i(t.container);t.pointerPos.x=n.pageX-r.left,t.pointerPos.y=n.pageY-r.top}function i(e){var t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,r=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+r,left:t.left+n}}},{passive:!0})}),t.container.addEventListener(`pointerup`,function(e){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){e.button===0&&t.onClick(t.hoverObj||null,e,t.intersection),e.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,e,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener(`contextmenu`,function(e){t.onRightClick&&e.preventDefault()}),t.renderer=new(o?Kle:qU.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},c)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=u,t.extraRenderers.forEach(function(e){e.domElement.style.position=`absolute`,e.domElement.style.top=`0px`,e.domElement.style.pointerEvents=`none`,t.container.appendChild(e.domElement)}),t.postProcessingComposer=new az(t.renderer),t.postProcessingComposer.addPass(new oz(t.scene,t.camera)),t.controls=new{trackball:Jle,orbit:uue,fly:wue}[i](t.camera,t.renderer.domElement),i===`fly`&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(i===`trackball`||i===`orbit`)&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener(`start`,function(){t.controlsEngaged=!0}),t.controls.addEventListener(`change`,function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener(`end`,function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(BU(t.extraRenderers)).forEach(function(e){return e.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new qU.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!f,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty(`width`)||t.hasOwnProperty(`height`))){var n,r=e.width,i=e.height;e.container.style.width=`${r}px`,e.container.style.height=`${i}px`,[e.renderer,e.postProcessingComposer].concat(BU(e.extraRenderers)).forEach(function(e){return e.setSize(r,i)}),e.camera.aspect=r/i;var a=e.viewOffset.slice(0,2);a.some(function(e){return e})&&(n=e.camera).setViewOffset.apply(n,[r,i].concat(BU(a),[r,i])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty(`viewOffset`)){var o,s=e.width,c=e.height,l=e.viewOffset.slice(0,2);l.some(function(e){return e})?(o=e.camera).setViewOffset.apply(o,[s,c].concat(BU(l),[s,c])):e.camera.clearViewOffset()}if(t.hasOwnProperty(`skyRadius`)&&e.skyRadius&&(e.controls.hasOwnProperty(`maxDistance`)&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new qU.SphereGeometry(e.skyRadius)),t.hasOwnProperty(`backgroundColor`)){var u=Az(e.backgroundColor).alpha;u===void 0&&(u=1),e.renderer.setClearColor(new qU.Color(rB(1,e.backgroundColor)),u)}t.hasOwnProperty(`backgroundImageUrl`)&&(e.backgroundImageUrl?new qU.TextureLoader().load(e.backgroundImageUrl,function(t){t.colorSpace=qU.SRGBColorSpace,e.skysphere.material=new qU.MeshBasicMaterial({map:t,side:qU.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&d()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&d())),t.hasOwnProperty(`showNavInfo`)&&(e.navInfo.style.display=e.showNavInfo?null:`none`),t.hasOwnProperty(`lights`)&&((t.lights||[]).forEach(function(t){return e.scene.remove(t)}),e.lights.forEach(function(t){return e.scene.add(t)})),t.hasOwnProperty(`objects`)&&((t.objects||[]).forEach(function(t){return e.scene.remove(t)}),e.objects.forEach(function(t){return e.scene.add(t)}));function d(){e.loadComplete=e.scene.visible=!0}}});function YU(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}YU(`.graph-info-msg {
|
|
5218
5218
|
top: 50%;
|
|
5219
5219
|
width: 100%;
|
|
5220
5220
|
text-align: center;
|
|
@@ -5241,10 +5241,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5241
5241
|
cursor: -moz-grabbing;
|
|
5242
5242
|
cursor: -webkit-grabbing;
|
|
5243
5243
|
}`);function XU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ZU(e){if(Array.isArray(e))return XU(e)}function QU(e,t,n){return(t=aW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $U(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function eW(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
5244
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?tW(Object(n),!0).forEach(function(t){QU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rW(e){return ZU(e)||$U(e)||oW(e)||eW()}function iW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function aW(e){var t=iW(e,`string`);return typeof t==`symbol`?t:t+``}function oW(e,t){if(e){if(typeof e==`string`)return XU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?XU(e,t):void 0}}function sW(e,t){var n=new t;return n._destructor&&n._destructor(),{linkProp:function(t){return{default:n[t](),onChange:function(n,r){r[e][t](n)},triggerUpdate:!1}},linkMethod:function(t){return function(n){var r=n[e],i=[...arguments].slice(1),a=r[t].apply(r,i);return a===r?this:a}}}}var cW=window.THREE?window.THREE:{AmbientLight:vf,DirectionalLight:_f,REVISION:`185`},lW=170,uW=sW(`forceGraph`,fw),dW=Object.assign.apply(Object,rW(`jsonUrl.graphData.numDimensions.dagMode.dagLevelDistance.dagNodeFilter.onDagError.nodeRelSize.nodeId.nodeVal.nodeResolution.nodeColor.nodeAutoColorBy.nodeOpacity.nodeVisibility.nodeThreeObject.nodeThreeObjectExtend.nodePositionUpdate.linkSource.linkTarget.linkVisibility.linkColor.linkAutoColorBy.linkOpacity.linkWidth.linkResolution.linkCurvature.linkCurveRotation.linkMaterial.linkThreeObject.linkThreeObjectExtend.linkPositionUpdate.linkDirectionalArrowLength.linkDirectionalArrowColor.linkDirectionalArrowRelPos.linkDirectionalArrowResolution.linkDirectionalParticles.linkDirectionalParticleSpeed.linkDirectionalParticleOffset.linkDirectionalParticleWidth.linkDirectionalParticleColor.linkDirectionalParticleResolution.linkDirectionalParticleThreeObject.forceEngine.d3AlphaDecay.d3VelocityDecay.d3AlphaMin.ngraphPhysics.warmupTicks.cooldownTicks.cooldownTime.onEngineTick.onEngineStop`.split(`.`).map(function(e){return QU({},e,uW.linkProp(e))}))),fW=Object.assign.apply(Object,rW([`refresh`,`getGraphBbox`,`d3Force`,`d3ReheatSimulation`,`emitParticle`].map(function(e){return QU({},e,uW.linkMethod(e))}))),pW=sW(`renderObjs`,JU),mW=Object.assign.apply(Object,rW([`width`,`height`,`backgroundColor`,`showNavInfo`,`enablePointerInteraction`].map(function(e){return QU({},e,pW.linkProp(e))}))),hW=Object.assign.apply(Object,rW([`lights`,`cameraPosition`,`postProcessingComposer`].map(function(e){return QU({},e,pW.linkMethod(e))})).concat([{graph2ScreenCoords:pW.linkMethod(`getScreenCoords`),screen2GraphCoords:pW.linkMethod(`getSceneCoords`)}])),gW=m_({props:nW(nW({nodeLabel:{default:`name`,triggerUpdate:!1},linkLabel:{default:`name`,triggerUpdate:!1},linkHoverPrecision:{default:1,onChange:function(e,t){return t.renderObjs.lineHoverPrecision(e)},triggerUpdate:!1},enableNavigationControls:{default:!0,onChange:function(e,t){var n=t.renderObjs.controls();n&&(n.enabled=e,e&&n.domElement&&n.domElement.dispatchEvent(new PointerEvent(`pointerup`)))},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1}},dW),mW),methods:nW(nW({zoomToFit:function(e,t,n){var r,i=[...arguments].slice(3);return e.renderObjs.fitToBbox((r=e.forceGraph).getGraphBbox.apply(r,i),t,n),this},pauseAnimation:function(e){return e.animationFrameRequestId!==null&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId===null&&this._animationCycle(),this},_animationCycle:function(e){e.enablePointerInteraction&&(this.renderer().domElement.style.cursor=null),e.forceGraph.tickFrame(),e.renderObjs.tick(),e.animationFrameRequestId=requestAnimationFrame(this._animationCycle)},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},_destructor:function(e){var t,n;this.pauseAnimation(),this.graphData({nodes:[],links:[]}),(t=(n=e.forceGraph)._destructor)==null||t.call(n),e.renderObjs._destructor()}},fW),hW),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,r=e.extraRenderers,i=new fw;return{forceGraph:i,renderObjs:JU({controlType:t,rendererConfig:n,extraRenderers:r}).objects([i]).lights([new cW.AmbientLight(13421772,Math.PI),new cW.DirectionalLight(16777215,.6*Math.PI)])}},init:function(e,t){e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.style.position=`relative`;var n=document.createElement(`div`);t.container.appendChild(n),t.renderObjs(n);var r=t.renderObjs.camera(),i=t.renderObjs.renderer(),a=t.renderObjs.controls();a.enabled=!!t.enableNavigationControls,t.lastSetCameraZ=r.position.z;var o;t.container.appendChild(o=document.createElement(`div`)),o.className=`graph-info-msg`,o.textContent=``,t.forceGraph.onLoading(function(){o.textContent=`Loading...`}).onFinishLoading(function(){o.textContent=``}).onUpdate(function(){t.graphData=t.forceGraph.graphData(),r.position.x===0&&r.position.y===0&&r.position.z===t.lastSetCameraZ&&t.graphData.nodes.length&&(r.lookAt(t.forceGraph.position),t.lastSetCameraZ=r.position.z=Math.cbrt(t.graphData.nodes.length)*lW)}).onFinishUpdate(function(){if(t._dragControls){var e=t.graphData.nodes.find(function(e){return e.__initialFixedPos&&!e.__disposeControlsAfterDrag});e?e.__disposeControlsAfterDrag=!0:t._dragControls.dispose(),t._dragControls=void 0}if(t.enableNodeDrag&&t.enablePointerInteraction&&t.forceEngine===`d3`){var n=t._dragControls=new jh(t.graphData.nodes.map(function(e){return e.__threeObj}).filter(function(e){return e}),r,i.domElement);n.addEventListener(`dragstart`,function(e){var t=_W(e.object);if(t){a.enabled=!1,e.object.__initialPos=e.object.position.clone(),e.object.__prevPos=e.object.position.clone();var n=t.__data;!n.__initialFixedPos&&(n.__initialFixedPos={fx:n.fx,fy:n.fy,fz:n.fz}),!n.__initialPos&&(n.__initialPos={x:n.x,y:n.y,z:n.z}),[`x`,`y`,`z`].forEach(function(e){return n[`f${e}`]=n[e]}),i.domElement.classList.add(`grabbable`)}}),n.addEventListener(`drag`,function(e){var n=_W(e.object);if(n){if(!e.object.hasOwnProperty(`__graphObjType`)){var r=e.object.__initialPos,i=e.object.__prevPos,a=e.object.position;n.position.add(a.clone().sub(i)),i.copy(a),a.copy(r)}var o=n.__data,s=n.position,c={x:s.x-o.x,y:s.y-o.y,z:s.z-o.z};[`x`,`y`,`z`].forEach(function(e){return o[`f${e}`]=o[e]=s[e]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),o.__dragged=!0,t.onNodeDrag(o,c)}}),n.addEventListener(`dragend`,function(e){var r=_W(e.object);if(r){delete e.object.__initialPos,delete e.object.__prevPos;var o=r.__data;o.__disposeControlsAfterDrag&&(n.dispose(),delete o.__disposeControlsAfterDrag);var s=o.__initialFixedPos,c=o.__initialPos,l={x:c.x-o.x,y:c.y-o.y,z:c.z-o.z};if(s&&([`x`,`y`,`z`].forEach(function(e){var t=`f${e}`;s[t]===void 0&&delete o[t]}),delete o.__initialFixedPos,delete o.__initialPos,o.__dragged&&(delete o.__dragged,t.onNodeDragEnd(o,l))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var u;a.enabled=!0,a._status&&((u=a._onPointerCancel)==null||u.call(a)),a.domElement&&a.domElement.ownerDocument&&a.domElement.ownerDocument.dispatchEvent(new PointerEvent(`pointerup`,{pointerType:`touch`}))}i.domElement.classList.remove(`grabbable`)}})}}),cW.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(e,t){var n=_W(e);if(!n)return 1;var r=_W(t);if(!r)return-1;var i=function(e){return e.__graphObjType===`node`};return i(r)-i(n)}).tooltipContent(function(e){var n=_W(e);return n&&h_(t[`${n.__graphObjType}Label`])(n.__data)||``}).hoverDuringDrag(!1).onHover(function(e){var n=_W(e);if(n!==t.hoverObj){var r=t.hoverObj?t.hoverObj.__graphObjType:null,a=t.hoverObj?t.hoverObj.__data:null,o=n?n.__graphObjType:null,s=n?n.__data:null;if(r&&r!==o){var c=t[`on${r===`node`?`Node`:`Link`}Hover`];c&&c(null,a)}if(o){var l=t[`on${o===`node`?`Node`:`Link`}Hover`];l&&l(s,r===o?a:null)}i.domElement.classList[(n&&t[`on${o===`node`?`Node`:`Link`}Click`]||!n&&t.onBackgroundClick)&&h_(t.showPointerCursor)(s)?`add`:`remove`](`clickable`),t.hoverObj=n}}).clickAfterDrag(!1).onClick(function(e,n){var r=_W(e);if(r){var i=t[`on${r.__graphObjType===`node`?`Node`:`Link`}Click`];i&&i(r.__data,n)}else t.onBackgroundClick&&t.onBackgroundClick(n)}).onRightClick(function(e,n){var r=_W(e);if(r){var i=t[`on${r.__graphObjType===`node`?`Node`:`Link`}RightClick`];i&&i(r.__data,n)}else t.onBackgroundRightClick&&t.onBackgroundRightClick(n)}),this._animationCycle()}});function _W(e){for(var t=e;t&&!t.hasOwnProperty(`__graphObjType`);)t=t.parent;return t}var vW=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),yW=o(((e,t)=>{var n=vW();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Q=l(o(((e,t)=>{t.exports=yW()()}))(),1),bW={width:Q.default.number,height:Q.default.number,graphData:Q.default.shape({nodes:Q.default.arrayOf(Q.default.object).isRequired,links:Q.default.arrayOf(Q.default.object).isRequired}),backgroundColor:Q.default.string,nodeRelSize:Q.default.number,nodeId:Q.default.string,nodeLabel:Q.default.oneOfType([Q.default.string,Q.default.func]),nodeVal:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),nodeVisibility:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),nodeColor:Q.default.oneOfType([Q.default.string,Q.default.func]),nodeAutoColorBy:Q.default.oneOfType([Q.default.string,Q.default.func]),onNodeHover:Q.default.func,onNodeClick:Q.default.func,linkSource:Q.default.string,linkTarget:Q.default.string,linkLabel:Q.default.oneOfType([Q.default.string,Q.default.func]),linkVisibility:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),linkColor:Q.default.oneOfType([Q.default.string,Q.default.func]),linkAutoColorBy:Q.default.oneOfType([Q.default.string,Q.default.func]),linkWidth:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkCurvature:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalArrowLength:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalArrowColor:Q.default.oneOfType([Q.default.string,Q.default.func]),linkDirectionalArrowRelPos:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticles:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleSpeed:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleOffset:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleWidth:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleColor:Q.default.oneOfType([Q.default.string,Q.default.func]),onLinkHover:Q.default.func,onLinkClick:Q.default.func,dagMode:Q.default.oneOf([`td`,`bu`,`lr`,`rl`,`zin`,`zout`,`radialin`,`radialout`]),dagLevelDistance:Q.default.number,dagNodeFilter:Q.default.func,onDagError:Q.default.func,d3AlphaMin:Q.default.number,d3AlphaDecay:Q.default.number,d3VelocityDecay:Q.default.number,warmupTicks:Q.default.number,cooldownTicks:Q.default.number,cooldownTime:Q.default.number,onEngineTick:Q.default.func,onEngineStop:Q.default.func,getGraphBbox:Q.default.func},xW={zoomToFit:Q.default.func,onNodeRightClick:Q.default.func,onNodeDrag:Q.default.func,onNodeDragEnd:Q.default.func,onLinkRightClick:Q.default.func,linkHoverPrecision:Q.default.number,onBackgroundClick:Q.default.func,onBackgroundRightClick:Q.default.func,showPointerCursor:Q.default.oneOfType([Q.default.bool,Q.default.func]),enablePointerInteraction:Q.default.bool,enableNodeDrag:Q.default.bool},SW={showNavInfo:Q.default.bool,nodeOpacity:Q.default.number,nodeResolution:Q.default.number,nodeThreeObject:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),nodeThreeObjectExtend:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),nodePositionUpdate:Q.default.func,linkOpacity:Q.default.number,linkResolution:Q.default.number,linkCurveRotation:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkMaterial:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),linkThreeObject:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),linkThreeObjectExtend:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),linkPositionUpdate:Q.default.func,linkDirectionalArrowResolution:Q.default.number,linkDirectionalParticleResolution:Q.default.number,linkDirectionalParticleThreeObject:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),forceEngine:Q.default.oneOf([`d3`,`ngraph`]),ngraphPhysics:Q.default.object,numDimensions:Q.default.oneOf([1,2,3])};Object.assign({},bW,xW,{linkLineDash:Q.default.oneOfType([Q.default.arrayOf(Q.default.number),Q.default.string,Q.default.func]),nodeCanvasObjectMode:Q.default.oneOfType([Q.default.string,Q.default.func]),nodeCanvasObject:Q.default.func,nodePointerAreaPaint:Q.default.func,linkCanvasObjectMode:Q.default.oneOfType([Q.default.string,Q.default.func]),linkCanvasObject:Q.default.func,linkPointerAreaPaint:Q.default.func,linkDirectionalParticleCanvasObject:Q.default.func,autoPauseRedraw:Q.default.bool,minZoom:Q.default.number,maxZoom:Q.default.number,enableZoomInteraction:Q.default.oneOfType([Q.default.bool,Q.default.func]),enablePanInteraction:Q.default.oneOfType([Q.default.bool,Q.default.func]),onZoom:Q.default.func,onZoomEnd:Q.default.func,onRenderFramePre:Q.default.func,onRenderFramePost:Q.default.func});var CW=Object.assign({},bW,xW,SW,{enableNavigationControls:Q.default.bool,controlType:Q.default.oneOf([`trackball`,`orbit`,`fly`]),rendererConfig:Q.default.object,extraRenderers:Q.default.arrayOf(Q.default.shape({render:Q.default.func.isRequired}))});Object.assign({},bW,SW,{nodeDesc:Q.default.oneOfType([Q.default.string,Q.default.func]),linkDesc:Q.default.oneOfType([Q.default.string,Q.default.func])}),Object.assign({},bW,SW,{markerAttrs:Q.default.object,yOffset:Q.default.number,glScale:Q.default.number});var wW=Hi(gW,{methodNames:[`emitParticle`,`d3Force`,`d3ReheatSimulation`,`stopAnimation`,`pauseAnimation`,`resumeAnimation`,`cameraPosition`,`zoomToFit`,`getGraphBbox`,`screen2GraphCoords`,`graph2ScreenCoords`,`postProcessingComposer`,`lights`,`scene`,`camera`,`renderer`,`controls`,`refresh`],initPropNames:[`controlType`,`rendererConfig`,`extraRenderers`]});wW.displayName=`ForceGraph3D`,wW.propTypes=CW;var TW=new ad(1,16,16),EW=new od(1,.1,8,32),DW=new Map;function OW(e,t=!1){let n=`${e}-${t}`;return DW.has(n)||(t?DW.set(n,new zl({color:16777215,transparent:!0,opacity:.8})):DW.set(n,new wd({color:e,transparent:!0,opacity:.9}))),DW.get(n)}function kW({threads:e,memoryNodes:t,researchItems:n,onOpenThread:r,onGroundMemoryNode:i,selectedGroundingNodes:a,interactive:o=!0}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),[l,u]=(0,v.useState)({width:0,height:0}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)({research:!0,observations:!0,rules:!0,threads:!1});(0,v.useEffect)(()=>{if(!c.current)return;let e=new ResizeObserver(e=>{if(e[0]){let{width:t,height:n}=e[0].contentRect;u({width:t,height:n})}});return e.observe(c.current),()=>e.disconnect()},[]);let h=(0,v.useMemo)(()=>{let r=[],i=[],a=new Map,o=new Map,s=new Map,c=new Map;p.threads&&e.forEach(e=>{let t={id:`thread-${e.id}`,type:`thread`,title:e.title||`Untitled Thread`,subtitle:`${e.turns} ${e.turns===1?`turn`:`turns`}`,originalData:e};r.push(t),a.set(t.id,t)}),t.forEach(e=>{let t=(e.category||`general`).toLowerCase();if([`invariants`,`preferences`,`patterns`,`anti-patterns`].includes(t)){if(!p.rules)return}else if(!p.observations)return;let n={id:`memory-${e.slug}`,type:`memory`,title:e.title||e.slug,subtitle:`Memory Node • ${e.category||`general`}`,category:t,originalData:e};r.push(n),a.set(n.id,n);let i=e.slug?.toLowerCase(),l=e.title?.toLowerCase();i&&o.set(i,n),l&&s.set(l,n),c.has(t)||c.set(t,[]),c.get(t).push(n)}),p.research&&n.forEach(e=>{let t={id:`research-${e.id}`,type:`research`,title:e.topic,subtitle:`Research Topic • ${e.priority} priority`,originalData:e};r.push(t),a.set(t.id,t)}),r.forEach(e=>{if(e.type===`research`){let t=e.originalData;if(t.node_slug){let n=`memory-${t.node_slug}`;a.has(n)&&i.push({source:e.id,target:n,type:`research`,colorHex:`#fbbf24`})}}if(e.type===`memory`){let t=e.originalData;[`related`,`contradicts`,`supersedes`].forEach(n=>{let r=t[n];if(Array.isArray(r)){let t=n===`contradicts`?`#ef4444`:n===`supersedes`?`#f59e0b`:`#60a5fa`;r.forEach(r=>{let o=`memory-${r}`;a.has(o)&&i.push({source:e.id,target:o,type:n,colorHex:t})})}});let n=c.get(e.category)||[],r=0;for(let t=0;t<n.length&&r<2;t++){let a=n[t];a.id!==e.id&&a.id>e.id&&(i.push({source:e.id,target:a.id,type:`implicit`,colorHex:`#475569`}),r++)}let l=t.body||t.content||``;(l.match(/\[\[(.*?)\]\]/g)||[]).forEach(t=>{let n=t.slice(2,-2).split(`|`).pop()?.trim().toLowerCase();if(n){let t=o.get(n)||s.get(n);t&&t.id!==e.id&&i.push({source:e.id,target:t.id,type:`openwiki`,colorHex:`#a78bfa`})}}),Array.from(l.matchAll(/\[([^\]]+)\]\(([^)]+)\)/g)).forEach(t=>{let n=t[2]?.trim().toLowerCase();if(n&&!n.startsWith(`http`)){let t=o.get(n);t&&t.id!==e.id&&i.push({source:e.id,target:t.id,type:`openwiki`,colorHex:`#a78bfa`})}})}});let l={};return i.forEach(e=>{l[e.source]=(l[e.source]||0)+1,l[e.target]=(l[e.target]||0)+1}),r.forEach(e=>{if(e.val=Math.max(2,Math.min(10,Math.sqrt(l[e.id]||0)+1.5)),e.neighbors=new Set,e.type===`memory`){let t={invariants:`#38bdf8`,preferences:`#818cf8`,patterns:`#34d399`,"anti-patterns":`#f87171`,facts:`#60a5fa`,concepts:`#a78bfa`,decisions:`#fbbf24`,lore:`#c084fc`,corrections:`#fb923c`};e.color=t[e.category]||`#60a5fa`,[`invariants`,`preferences`,`patterns`,`anti-patterns`].includes(e.category)&&(t[e.category]||(e.color=`#818cf8`))}else e.type===`thread`?e.color=`#22d3ee`:e.type===`research`&&(e.color=`#fbbf24`)}),i.forEach(e=>{let t=a.get(e.source),n=a.get(e.target);t&&n&&(t.neighbors.add(n.id),n.neighbors.add(t.id))}),{nodes:r,links:i}},[e,t,n,p]);(0,v.useEffect)(()=>{s.current&&l.width>0&&setTimeout(()=>{s.current.zoomToFit(600,50)},800)},[h,l]),(0,v.useEffect)(()=>{h.nodes.forEach(e=>{if(e.__threeObj&&e.__threeObj.userData.isCustomNode){let t=!d||e===d||d.neighbors&&d.neighbors.has(e.id),n=e.__threeObj.children[0];n&&(t?n.material=OW(e.color):(n.userData.dimMaterial||(n.userData.dimMaterial=new zl({color:e.color,transparent:!0,opacity:.05})),n.material=n.userData.dimMaterial))}})},[d,h]),(0,v.useEffect)(()=>{s.current&&(s.current.d3Force(`charge`).strength(-150),s.current.d3Force(`link`).distance(e=>e.type===`implicit`?40:80),s.current.d3Force(`collide`,window.d3?.forceCollide?.(e=>e.val*2+3)))},[h]);let g=(0,v.useCallback)(e=>{if(!o)return;let t=Math.hypot(e.x,e.y,e.z),n=1+90/(t<.1?.1:t);s.current?.cameraPosition({x:e.x*n,y:e.y*n,z:e.z*n},e,1500),e.type===`memory`?i(e.originalData.slug):e.type===`thread`&&r(e.originalData.id)},[o,i,r]),_=(0,v.useCallback)(e=>{let t=new gc;t.userData.isCustomNode=!0;let n=new Zl(TW,OW(e.color)),r=e.val*1.8;if(n.scale.set(r,r,r),t.add(n),a.includes(e.originalData?.slug)){let e=new Zl(EW,OW(`#ffffff`,!0)),n=r+1.2;e.scale.set(n,n,n),e.rotation.x=Math.PI/2,t.add(e)}return t},[a]),y=(0,v.useCallback)(e=>{let t=typeof e.source==`object`?e.source.id:e.source,n=typeof e.target==`object`?e.target.id:e.target,r=!d||t===d?.id||n===d?.id,i=e.colorHex||`#475569`,a=parseInt(i.slice(1,3),16)||71,o=parseInt(i.slice(3,5),16)||85,s=parseInt(i.slice(5,7),16)||105,c=e.type===`implicit`?.2:.6;return`rgba(${a}, ${o}, ${s}, ${r?c:.02})`},[d]);return(0,z.jsxs)(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`,background:`radial-gradient(circle at center, #0a0f1d 0%, #03050a 100%)`},children:[l.width>0&&(0,z.jsx)(wW,{ref:s,width:l.width,height:l.height,graphData:h,nodeThreeObject:_,nodeLabel:e=>`<div style="background: rgba(10, 15, 30, 0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.5); font-family: var(--font-sans, system-ui); max-width: 250px;">
|
|
5244
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?tW(Object(n),!0).forEach(function(t){QU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rW(e){return ZU(e)||$U(e)||oW(e)||eW()}function iW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function aW(e){var t=iW(e,`string`);return typeof t==`symbol`?t:t+``}function oW(e,t){if(e){if(typeof e==`string`)return XU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?XU(e,t):void 0}}function sW(e,t){var n=new t;return n._destructor&&n._destructor(),{linkProp:function(t){return{default:n[t](),onChange:function(n,r){r[e][t](n)},triggerUpdate:!1}},linkMethod:function(t){return function(n){var r=n[e],i=[...arguments].slice(1),a=r[t].apply(r,i);return a===r?this:a}}}}var cW=window.THREE?window.THREE:{AmbientLight:vf,DirectionalLight:_f,REVISION:`185`},lW=170,uW=sW(`forceGraph`,pw),dW=Object.assign.apply(Object,rW(`jsonUrl.graphData.numDimensions.dagMode.dagLevelDistance.dagNodeFilter.onDagError.nodeRelSize.nodeId.nodeVal.nodeResolution.nodeColor.nodeAutoColorBy.nodeOpacity.nodeVisibility.nodeThreeObject.nodeThreeObjectExtend.nodePositionUpdate.linkSource.linkTarget.linkVisibility.linkColor.linkAutoColorBy.linkOpacity.linkWidth.linkResolution.linkCurvature.linkCurveRotation.linkMaterial.linkThreeObject.linkThreeObjectExtend.linkPositionUpdate.linkDirectionalArrowLength.linkDirectionalArrowColor.linkDirectionalArrowRelPos.linkDirectionalArrowResolution.linkDirectionalParticles.linkDirectionalParticleSpeed.linkDirectionalParticleOffset.linkDirectionalParticleWidth.linkDirectionalParticleColor.linkDirectionalParticleResolution.linkDirectionalParticleThreeObject.forceEngine.d3AlphaDecay.d3VelocityDecay.d3AlphaMin.ngraphPhysics.warmupTicks.cooldownTicks.cooldownTime.onEngineTick.onEngineStop`.split(`.`).map(function(e){return QU({},e,uW.linkProp(e))}))),fW=Object.assign.apply(Object,rW([`refresh`,`getGraphBbox`,`d3Force`,`d3ReheatSimulation`,`emitParticle`].map(function(e){return QU({},e,uW.linkMethod(e))}))),pW=sW(`renderObjs`,JU),mW=Object.assign.apply(Object,rW([`width`,`height`,`backgroundColor`,`showNavInfo`,`enablePointerInteraction`].map(function(e){return QU({},e,pW.linkProp(e))}))),hW=Object.assign.apply(Object,rW([`lights`,`cameraPosition`,`postProcessingComposer`].map(function(e){return QU({},e,pW.linkMethod(e))})).concat([{graph2ScreenCoords:pW.linkMethod(`getScreenCoords`),screen2GraphCoords:pW.linkMethod(`getSceneCoords`)}])),gW=m_({props:nW(nW({nodeLabel:{default:`name`,triggerUpdate:!1},linkLabel:{default:`name`,triggerUpdate:!1},linkHoverPrecision:{default:1,onChange:function(e,t){return t.renderObjs.lineHoverPrecision(e)},triggerUpdate:!1},enableNavigationControls:{default:!0,onChange:function(e,t){var n=t.renderObjs.controls();n&&(n.enabled=e,e&&n.domElement&&n.domElement.dispatchEvent(new PointerEvent(`pointerup`)))},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1}},dW),mW),methods:nW(nW({zoomToFit:function(e,t,n){var r,i=[...arguments].slice(3);return e.renderObjs.fitToBbox((r=e.forceGraph).getGraphBbox.apply(r,i),t,n),this},pauseAnimation:function(e){return e.animationFrameRequestId!==null&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId===null&&this._animationCycle(),this},_animationCycle:function(e){e.enablePointerInteraction&&(this.renderer().domElement.style.cursor=null),e.forceGraph.tickFrame(),e.renderObjs.tick(),e.animationFrameRequestId=requestAnimationFrame(this._animationCycle)},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},_destructor:function(e){var t,n;this.pauseAnimation(),this.graphData({nodes:[],links:[]}),(t=(n=e.forceGraph)._destructor)==null||t.call(n),e.renderObjs._destructor()}},fW),hW),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,r=e.extraRenderers,i=new pw;return{forceGraph:i,renderObjs:JU({controlType:t,rendererConfig:n,extraRenderers:r}).objects([i]).lights([new cW.AmbientLight(13421772,Math.PI),new cW.DirectionalLight(16777215,.6*Math.PI)])}},init:function(e,t){e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.style.position=`relative`;var n=document.createElement(`div`);t.container.appendChild(n),t.renderObjs(n);var r=t.renderObjs.camera(),i=t.renderObjs.renderer(),a=t.renderObjs.controls();a.enabled=!!t.enableNavigationControls,t.lastSetCameraZ=r.position.z;var o;t.container.appendChild(o=document.createElement(`div`)),o.className=`graph-info-msg`,o.textContent=``,t.forceGraph.onLoading(function(){o.textContent=`Loading...`}).onFinishLoading(function(){o.textContent=``}).onUpdate(function(){t.graphData=t.forceGraph.graphData(),r.position.x===0&&r.position.y===0&&r.position.z===t.lastSetCameraZ&&t.graphData.nodes.length&&(r.lookAt(t.forceGraph.position),t.lastSetCameraZ=r.position.z=Math.cbrt(t.graphData.nodes.length)*lW)}).onFinishUpdate(function(){if(t._dragControls){var e=t.graphData.nodes.find(function(e){return e.__initialFixedPos&&!e.__disposeControlsAfterDrag});e?e.__disposeControlsAfterDrag=!0:t._dragControls.dispose(),t._dragControls=void 0}if(t.enableNodeDrag&&t.enablePointerInteraction&&t.forceEngine===`d3`){var n=t._dragControls=new jh(t.graphData.nodes.map(function(e){return e.__threeObj}).filter(function(e){return e}),r,i.domElement);n.addEventListener(`dragstart`,function(e){var t=_W(e.object);if(t){a.enabled=!1,e.object.__initialPos=e.object.position.clone(),e.object.__prevPos=e.object.position.clone();var n=t.__data;!n.__initialFixedPos&&(n.__initialFixedPos={fx:n.fx,fy:n.fy,fz:n.fz}),!n.__initialPos&&(n.__initialPos={x:n.x,y:n.y,z:n.z}),[`x`,`y`,`z`].forEach(function(e){return n[`f${e}`]=n[e]}),i.domElement.classList.add(`grabbable`)}}),n.addEventListener(`drag`,function(e){var n=_W(e.object);if(n){if(!e.object.hasOwnProperty(`__graphObjType`)){var r=e.object.__initialPos,i=e.object.__prevPos,a=e.object.position;n.position.add(a.clone().sub(i)),i.copy(a),a.copy(r)}var o=n.__data,s=n.position,c={x:s.x-o.x,y:s.y-o.y,z:s.z-o.z};[`x`,`y`,`z`].forEach(function(e){return o[`f${e}`]=o[e]=s[e]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),o.__dragged=!0,t.onNodeDrag(o,c)}}),n.addEventListener(`dragend`,function(e){var r=_W(e.object);if(r){delete e.object.__initialPos,delete e.object.__prevPos;var o=r.__data;o.__disposeControlsAfterDrag&&(n.dispose(),delete o.__disposeControlsAfterDrag);var s=o.__initialFixedPos,c=o.__initialPos,l={x:c.x-o.x,y:c.y-o.y,z:c.z-o.z};if(s&&([`x`,`y`,`z`].forEach(function(e){var t=`f${e}`;s[t]===void 0&&delete o[t]}),delete o.__initialFixedPos,delete o.__initialPos,o.__dragged&&(delete o.__dragged,t.onNodeDragEnd(o,l))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var u;a.enabled=!0,a._status&&((u=a._onPointerCancel)==null||u.call(a)),a.domElement&&a.domElement.ownerDocument&&a.domElement.ownerDocument.dispatchEvent(new PointerEvent(`pointerup`,{pointerType:`touch`}))}i.domElement.classList.remove(`grabbable`)}})}}),cW.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(e,t){var n=_W(e);if(!n)return 1;var r=_W(t);if(!r)return-1;var i=function(e){return e.__graphObjType===`node`};return i(r)-i(n)}).tooltipContent(function(e){var n=_W(e);return n&&h_(t[`${n.__graphObjType}Label`])(n.__data)||``}).hoverDuringDrag(!1).onHover(function(e){var n=_W(e);if(n!==t.hoverObj){var r=t.hoverObj?t.hoverObj.__graphObjType:null,a=t.hoverObj?t.hoverObj.__data:null,o=n?n.__graphObjType:null,s=n?n.__data:null;if(r&&r!==o){var c=t[`on${r===`node`?`Node`:`Link`}Hover`];c&&c(null,a)}if(o){var l=t[`on${o===`node`?`Node`:`Link`}Hover`];l&&l(s,r===o?a:null)}i.domElement.classList[(n&&t[`on${o===`node`?`Node`:`Link`}Click`]||!n&&t.onBackgroundClick)&&h_(t.showPointerCursor)(s)?`add`:`remove`](`clickable`),t.hoverObj=n}}).clickAfterDrag(!1).onClick(function(e,n){var r=_W(e);if(r){var i=t[`on${r.__graphObjType===`node`?`Node`:`Link`}Click`];i&&i(r.__data,n)}else t.onBackgroundClick&&t.onBackgroundClick(n)}).onRightClick(function(e,n){var r=_W(e);if(r){var i=t[`on${r.__graphObjType===`node`?`Node`:`Link`}RightClick`];i&&i(r.__data,n)}else t.onBackgroundRightClick&&t.onBackgroundRightClick(n)}),this._animationCycle()}});function _W(e){for(var t=e;t&&!t.hasOwnProperty(`__graphObjType`);)t=t.parent;return t}var vW=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),yW=o(((e,t)=>{var n=vW();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Q=l(o(((e,t)=>{t.exports=yW()()}))(),1),bW={width:Q.default.number,height:Q.default.number,graphData:Q.default.shape({nodes:Q.default.arrayOf(Q.default.object).isRequired,links:Q.default.arrayOf(Q.default.object).isRequired}),backgroundColor:Q.default.string,nodeRelSize:Q.default.number,nodeId:Q.default.string,nodeLabel:Q.default.oneOfType([Q.default.string,Q.default.func]),nodeVal:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),nodeVisibility:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),nodeColor:Q.default.oneOfType([Q.default.string,Q.default.func]),nodeAutoColorBy:Q.default.oneOfType([Q.default.string,Q.default.func]),onNodeHover:Q.default.func,onNodeClick:Q.default.func,linkSource:Q.default.string,linkTarget:Q.default.string,linkLabel:Q.default.oneOfType([Q.default.string,Q.default.func]),linkVisibility:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),linkColor:Q.default.oneOfType([Q.default.string,Q.default.func]),linkAutoColorBy:Q.default.oneOfType([Q.default.string,Q.default.func]),linkWidth:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkCurvature:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalArrowLength:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalArrowColor:Q.default.oneOfType([Q.default.string,Q.default.func]),linkDirectionalArrowRelPos:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticles:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleSpeed:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleOffset:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleWidth:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkDirectionalParticleColor:Q.default.oneOfType([Q.default.string,Q.default.func]),onLinkHover:Q.default.func,onLinkClick:Q.default.func,dagMode:Q.default.oneOf([`td`,`bu`,`lr`,`rl`,`zin`,`zout`,`radialin`,`radialout`]),dagLevelDistance:Q.default.number,dagNodeFilter:Q.default.func,onDagError:Q.default.func,d3AlphaMin:Q.default.number,d3AlphaDecay:Q.default.number,d3VelocityDecay:Q.default.number,warmupTicks:Q.default.number,cooldownTicks:Q.default.number,cooldownTime:Q.default.number,onEngineTick:Q.default.func,onEngineStop:Q.default.func,getGraphBbox:Q.default.func},xW={zoomToFit:Q.default.func,onNodeRightClick:Q.default.func,onNodeDrag:Q.default.func,onNodeDragEnd:Q.default.func,onLinkRightClick:Q.default.func,linkHoverPrecision:Q.default.number,onBackgroundClick:Q.default.func,onBackgroundRightClick:Q.default.func,showPointerCursor:Q.default.oneOfType([Q.default.bool,Q.default.func]),enablePointerInteraction:Q.default.bool,enableNodeDrag:Q.default.bool},SW={showNavInfo:Q.default.bool,nodeOpacity:Q.default.number,nodeResolution:Q.default.number,nodeThreeObject:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),nodeThreeObjectExtend:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),nodePositionUpdate:Q.default.func,linkOpacity:Q.default.number,linkResolution:Q.default.number,linkCurveRotation:Q.default.oneOfType([Q.default.number,Q.default.string,Q.default.func]),linkMaterial:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),linkThreeObject:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),linkThreeObjectExtend:Q.default.oneOfType([Q.default.bool,Q.default.string,Q.default.func]),linkPositionUpdate:Q.default.func,linkDirectionalArrowResolution:Q.default.number,linkDirectionalParticleResolution:Q.default.number,linkDirectionalParticleThreeObject:Q.default.oneOfType([Q.default.object,Q.default.string,Q.default.func]),forceEngine:Q.default.oneOf([`d3`,`ngraph`]),ngraphPhysics:Q.default.object,numDimensions:Q.default.oneOf([1,2,3])};Object.assign({},bW,xW,{linkLineDash:Q.default.oneOfType([Q.default.arrayOf(Q.default.number),Q.default.string,Q.default.func]),nodeCanvasObjectMode:Q.default.oneOfType([Q.default.string,Q.default.func]),nodeCanvasObject:Q.default.func,nodePointerAreaPaint:Q.default.func,linkCanvasObjectMode:Q.default.oneOfType([Q.default.string,Q.default.func]),linkCanvasObject:Q.default.func,linkPointerAreaPaint:Q.default.func,linkDirectionalParticleCanvasObject:Q.default.func,autoPauseRedraw:Q.default.bool,minZoom:Q.default.number,maxZoom:Q.default.number,enableZoomInteraction:Q.default.oneOfType([Q.default.bool,Q.default.func]),enablePanInteraction:Q.default.oneOfType([Q.default.bool,Q.default.func]),onZoom:Q.default.func,onZoomEnd:Q.default.func,onRenderFramePre:Q.default.func,onRenderFramePost:Q.default.func});var CW=Object.assign({},bW,xW,SW,{enableNavigationControls:Q.default.bool,controlType:Q.default.oneOf([`trackball`,`orbit`,`fly`]),rendererConfig:Q.default.object,extraRenderers:Q.default.arrayOf(Q.default.shape({render:Q.default.func.isRequired}))});Object.assign({},bW,SW,{nodeDesc:Q.default.oneOfType([Q.default.string,Q.default.func]),linkDesc:Q.default.oneOfType([Q.default.string,Q.default.func])}),Object.assign({},bW,SW,{markerAttrs:Q.default.object,yOffset:Q.default.number,glScale:Q.default.number});var wW=Hi(gW,{methodNames:[`emitParticle`,`d3Force`,`d3ReheatSimulation`,`stopAnimation`,`pauseAnimation`,`resumeAnimation`,`cameraPosition`,`zoomToFit`,`getGraphBbox`,`screen2GraphCoords`,`graph2ScreenCoords`,`postProcessingComposer`,`lights`,`scene`,`camera`,`renderer`,`controls`,`refresh`],initPropNames:[`controlType`,`rendererConfig`,`extraRenderers`]});wW.displayName=`ForceGraph3D`,wW.propTypes=CW;var TW=new ad(1,16,16),EW=new od(1,.1,8,32),DW=new Map;function OW(e,t=!1){let n=`${e}-${t}`;return DW.has(n)||(t?DW.set(n,new zl({color:16777215,transparent:!0,opacity:.8})):DW.set(n,new wd({color:e,transparent:!0,opacity:.9}))),DW.get(n)}function kW({threads:e,memoryNodes:t,researchItems:n,onOpenThread:r,onGroundMemoryNode:i,selectedGroundingNodes:a,interactive:o=!0}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),[l,u]=(0,v.useState)({width:0,height:0}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)({research:!0,observations:!0,rules:!0,threads:!1});(0,v.useEffect)(()=>{if(!c.current)return;let e=new ResizeObserver(e=>{if(e[0]){let{width:t,height:n}=e[0].contentRect;u({width:t,height:n})}});return e.observe(c.current),()=>e.disconnect()},[]);let h=(0,v.useMemo)(()=>{let r=[],i=[],a=new Map,o=new Map,s=new Map,c=new Map;p.threads&&e.forEach(e=>{let t={id:`thread-${e.id}`,type:`thread`,title:e.title||`Untitled Thread`,subtitle:`${e.turns} ${e.turns===1?`turn`:`turns`}`,originalData:e};r.push(t),a.set(t.id,t)}),t.forEach(e=>{let t=(e.category||`general`).toLowerCase();if([`invariants`,`preferences`,`patterns`,`anti-patterns`].includes(t)){if(!p.rules)return}else if(!p.observations)return;let n={id:`memory-${e.slug}`,type:`memory`,title:e.title||e.slug,subtitle:`Memory Node • ${e.category||`general`}`,category:t,originalData:e};r.push(n),a.set(n.id,n);let i=e.slug?.toLowerCase(),l=e.title?.toLowerCase();i&&o.set(i,n),l&&s.set(l,n),c.has(t)||c.set(t,[]),c.get(t).push(n)}),p.research&&n.forEach(e=>{let t={id:`research-${e.id}`,type:`research`,title:e.topic,subtitle:`Research Topic • ${e.priority} priority`,originalData:e};r.push(t),a.set(t.id,t)}),r.forEach(e=>{if(e.type===`research`){let t=e.originalData;if(t.node_slug){let n=`memory-${t.node_slug}`;a.has(n)&&i.push({source:e.id,target:n,type:`research`,colorHex:`#fbbf24`})}}if(e.type===`memory`){let t=e.originalData;[`related`,`contradicts`,`supersedes`].forEach(n=>{let r=t[n];if(Array.isArray(r)){let t=n===`contradicts`?`#ef4444`:n===`supersedes`?`#f59e0b`:`#60a5fa`;r.forEach(r=>{let o=`memory-${r}`;a.has(o)&&i.push({source:e.id,target:o,type:n,colorHex:t})})}});let n=c.get(e.category)||[],r=0;for(let t=0;t<n.length&&r<2;t++){let a=n[t];a.id!==e.id&&a.id>e.id&&(i.push({source:e.id,target:a.id,type:`implicit`,colorHex:`#475569`}),r++)}let l=t.body||t.content||``;(l.match(/\[\[(.*?)\]\]/g)||[]).forEach(t=>{let n=t.slice(2,-2).split(`|`).pop()?.trim().toLowerCase();if(n){let t=o.get(n)||s.get(n);t&&t.id!==e.id&&i.push({source:e.id,target:t.id,type:`openwiki`,colorHex:`#a78bfa`})}}),Array.from(l.matchAll(/\[([^\]]+)\]\(([^)]+)\)/g)).forEach(t=>{let n=t[2]?.trim().toLowerCase();if(n&&!n.startsWith(`http`)){let t=o.get(n);t&&t.id!==e.id&&i.push({source:e.id,target:t.id,type:`openwiki`,colorHex:`#a78bfa`})}})}});let l={};return i.forEach(e=>{l[e.source]=(l[e.source]||0)+1,l[e.target]=(l[e.target]||0)+1}),r.forEach(e=>{if(e.val=Math.max(2,Math.min(10,Math.sqrt(l[e.id]||0)+1.5)),e.neighbors=new Set,e.type===`memory`){let t={invariants:`#38bdf8`,preferences:`#818cf8`,patterns:`#34d399`,"anti-patterns":`#f87171`,facts:`#60a5fa`,concepts:`#a78bfa`,decisions:`#fbbf24`,lore:`#c084fc`,corrections:`#fb923c`};e.color=t[e.category]||`#60a5fa`,[`invariants`,`preferences`,`patterns`,`anti-patterns`].includes(e.category)&&(t[e.category]||(e.color=`#818cf8`))}else e.type===`thread`?e.color=`#22d3ee`:e.type===`research`&&(e.color=`#fbbf24`)}),i.forEach(e=>{let t=a.get(e.source),n=a.get(e.target);t&&n&&(t.neighbors.add(n.id),n.neighbors.add(t.id))}),{nodes:r,links:i}},[e,t,n,p]);(0,v.useEffect)(()=>{s.current&&l.width>0&&setTimeout(()=>{s.current.zoomToFit(600,50)},800)},[h,l]),(0,v.useEffect)(()=>{h.nodes.forEach(e=>{if(e.__threeObj&&e.__threeObj.userData.isCustomNode){let t=!d||e===d||d.neighbors&&d.neighbors.has(e.id),n=e.__threeObj.children[0];n&&(t?n.material=OW(e.color):(n.userData.dimMaterial||(n.userData.dimMaterial=new zl({color:e.color,transparent:!0,opacity:.05})),n.material=n.userData.dimMaterial))}})},[d,h]),(0,v.useEffect)(()=>{s.current&&(s.current.d3Force(`charge`).strength(-150),s.current.d3Force(`link`).distance(e=>e.type===`implicit`?40:80),s.current.d3Force(`collide`,window.d3?.forceCollide?.(e=>e.val*2+3)))},[h]);let g=(0,v.useCallback)(e=>{if(!o)return;let t=Math.hypot(e.x,e.y,e.z),n=1+90/(t<.1?.1:t);s.current?.cameraPosition({x:e.x*n,y:e.y*n,z:e.z*n},e,1500),e.type===`memory`?i(e.originalData.slug):e.type===`thread`&&r(e.originalData.id)},[o,i,r]),_=(0,v.useCallback)(e=>{let t=new gc;t.userData.isCustomNode=!0;let n=new Zl(TW,OW(e.color)),r=e.val*1.8;if(n.scale.set(r,r,r),t.add(n),a.includes(e.originalData?.slug)){let e=new Zl(EW,OW(`#ffffff`,!0)),n=r+1.2;e.scale.set(n,n,n),e.rotation.x=Math.PI/2,t.add(e)}return t},[a]),y=(0,v.useCallback)(e=>{let t=typeof e.source==`object`?e.source.id:e.source,n=typeof e.target==`object`?e.target.id:e.target,r=!d||t===d?.id||n===d?.id,i=e.colorHex||`#475569`,a=parseInt(i.slice(1,3),16)||71,o=parseInt(i.slice(3,5),16)||85,s=parseInt(i.slice(5,7),16)||105,c=e.type===`implicit`?.2:.6;return`rgba(${a}, ${o}, ${s}, ${r?c:.02})`},[d]);return(0,z.jsxs)(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`,background:`radial-gradient(circle at center, #0a0f1d 0%, #03050a 100%)`},children:[l.width>0&&(0,z.jsx)(wW,{ref:s,width:l.width,height:l.height,graphData:h,nodeThreeObject:_,nodeLabel:e=>`<div style="background: rgba(10, 15, 30, 0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.5); font-family: var(--font-sans, system-ui); max-width: 250px;">
|
|
5245
5245
|
<strong style="color: #fff; font-size: 14px; display: block; margin-bottom: 2px;">${e.title}</strong>
|
|
5246
5246
|
<span style="color: #94a3b8; font-size: 12px; display: block;">${e.subtitle}</span>
|
|
5247
|
-
</div>`,enableNodeDrag:o,enableNavigationControls:o,onNodeClick:g,onNodeHover:e=>{f(e||null),c.current&&(c.current.style.cursor=e?`pointer`:`default`)},linkColor:y,linkWidth:e=>e.type===`implicit`?.5:1.5,linkDirectionalParticles:e=>e.type===`implicit`?0:2,linkDirectionalParticleWidth:1.5,linkDirectionalParticleSpeed:.005,backgroundColor:`rgba(0,0,0,0)`,d3VelocityDecay:.3}),(0,z.jsxs)(`div`,{style:{position:`absolute`,top:20,left:20,zIndex:30,pointerEvents:`none`},children:[(0,z.jsx)(`h3`,{style:{margin:0,fontSize:20,color:`#f8fafc`,fontWeight:600,letterSpacing:`-0.02em`,textShadow:`0 2px 10px rgba(0,0,0,0.5)`},children:`Constellation`}),(0,z.jsx)(`p`,{style:{margin:`2px 0 0`,fontSize:12,color:`rgba(148,163,184,0.9)`,textShadow:`0 1px 4px rgba(0,0,0,0.5)`},children:`Interactive Knowledge Network`})]}),o&&(0,z.jsxs)(`div`,{style:{position:`absolute`,top:80,left:20,display:`flex`,flexDirection:`column`,gap:12,background:`rgba(15, 20, 35, 0.4)`,backdropFilter:`blur(24px)`,WebkitBackdropFilter:`blur(24px)`,padding:`16px 20px`,borderRadius:16,border:`1px solid rgba(255, 255, 255, 0.08)`,boxShadow:`0 12px 40px rgba(0,0,0,0.3)`,width:240,zIndex:60,pointerEvents:`auto`,transition:`all 0.3s ease`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:700,color:`#cbd5e1`,textTransform:`uppercase`,letterSpacing:1.2},children:`Filters`}),(0,z.jsxs)(`span`,{style:{fontSize:10,background:`rgba(255,255,255,0.06)`,padding:`2px 6px`,borderRadius:6,color:`#94a3b8`},children:[h.nodes.length,` items`]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.research,onChange:()=>m(e=>({...e,research:!e.research})),style:{accentColor:`#fbbf24`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#fbbf24`,boxShadow:`0 0 8px rgba(251,191,36,0.6)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Research`})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.observations,onChange:()=>m(e=>({...e,observations:!e.observations})),style:{accentColor:`#60a5fa`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#60a5fa`,boxShadow:`0 0 8px rgba(96,165,250,0.6)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Memory`})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.rules,onChange:()=>m(e=>({...e,rules:!e.rules})),style:{accentColor:`#38bdf8`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`linear-gradient(135deg,#38bdf8,#f87171)`,boxShadow:`0 0 8px rgba(56,189,248,0.5)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Rules`})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.threads,onChange:()=>m(e=>({...e,threads:!e.threads})),style:{accentColor:`#22d3ee`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#22d3ee`,boxShadow:`0 0 8px rgba(34,211,238,0.6)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Sessions`})]})]})]})]})}function AW({onTranscript:e,isRecording:t=!1}){let[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!0);return(0,v.useEffect)(()=>{if(typeof window<`u`){let t=window,n=t.SpeechRecognition||t.webkitSpeechRecognition;n?(i.current=new n,i.current.continuous=!1,i.current.interimResults=!1,i.current.onresult=t=>{let n=t.results[0][0].transcript;e(n),r(!1)},i.current.onerror=()=>{r(!1)},i.current.onend=()=>{r(!1)}):setTimeout(()=>o(!1),0)}},[e]),a?(0,z.jsx)(`button`,{onClick:()=>{a&&(n?(i.current?.stop(),r(!1)):(i.current?.start(),r(!0)))},className:`btn btn-ghost ${n?`active`:``}`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,background:n?`var(--error-muted)`:`rgba(148, 163, 184, 0.06)`,border:n?`1px solid var(--error)`:`1px solid var(--border)`,color:n?`var(--error)`:`var(--text-tertiary)`,transition:`all var(--transition-fast)`},title:n?`Stop recording`:`Start voice input`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`})]})}):(0,z.jsx)(`button`,{disabled:!0,className:`btn btn-ghost`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,background:`rgba(148, 163, 184, 0.03)`,border:`1px solid var(--border)`,color:`var(--text-tertiary)`,opacity:.5,cursor:`not-allowed`},title:`Voice input not supported`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`})]})})}var jW=0;function MW(){return Date.now()}function NW(e){let t=MW()-e;if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function PW({activeBrainId:e,onBrainChange:t}){let n=dt(),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(null),f=(0,v.useRef)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(()=>localStorage.getItem(`tr-ext-banner-dismissed`)===`true`),[A,j]=(0,v.useState)(()=>localStorage.getItem(`tr-update-banner-dismissed-version`)),[ee,M]=(0,v.useState)([]),[te,ne]=(0,v.useState)(void 0),[N,P]=(0,v.useState)([]),[re,ie]=(0,v.useState)([]),[ae,oe]=(0,v.useState)([]),[se,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(``),de=(0,v.useRef)(null),[fe,pe]=(0,v.useState)([]),[me,he]=(0,v.useState)(()=>{let e=localStorage.getItem(`selectedModel`);return e&&e!==`gemini`?e:`antigravity`}),[ge,_e]=(0,v.useState)(()=>localStorage.getItem(`selectedSubModel`)||``),[ve,ye]=(0,v.useState)([]),[be,xe]=(0,v.useState)(!1),Se=(0,v.useRef)(null),F=(0,v.useCallback)(()=>{l.current?.scrollIntoView({behavior:`smooth`})},[]);(0,v.useEffect)(F,[r,F]);let Ce=(0,v.useCallback)(()=>{Qn().then(e=>{M(e)}).catch(console.error),Gr().then(e=>oe(e.items||[])).catch(console.error)},[]);(0,v.useEffect)(()=>{Qn().then(e=>{M(e),e.length>0&&(ne(e[0].id),e[0].brainId&&t&&t(e[0].brainId))}).catch(console.error),Gr().then(e=>oe(e.items||[])).catch(console.error),Yr().then(e=>{let t=e.cli_agents&&e.cli_agents.length>0?e.cli_agents:[`antigravity`,`grok`,`claude`,`codex`];pe(t);let n=localStorage.getItem(`selectedModel`);if(n&&t.includes(n))he(n);else{let e=t.includes(`antigravity`)?`antigravity`:t.includes(`grok`)?`grok`:t[0];he(e),localStorage.setItem(`selectedModel`,e)}}).catch(()=>{let e=[`antigravity`,`grok`,`claude`,`codex`];pe(e);let t=localStorage.getItem(`selectedModel`);t&&e.includes(t)?he(t):(he(`antigravity`),localStorage.setItem(`selectedModel`,`antigravity`))}),ci().then(e=>{if(ye(e),e&&e.length>0){let t=localStorage.getItem(`selectedSubModel`),n=e.some(e=>e.id===t);t&&n?_e(t):(_e(e[0].id),localStorage.setItem(`selectedSubModel`,e[0].id))}}).catch(console.error)},[]),(0,v.useEffect)(()=>{let e=!0,t=()=>{oi().then(t=>{e&&y(t)}).catch(console.error)};t();let n=setInterval(t,36e5);return()=>{e=!1,clearInterval(n)}},[]),(0,v.useEffect)(()=>{let t=!0,n=()=>{nr(e).then(e=>{t&&(ie(e),P(t=>t.filter(t=>e.some(e=>e.slug===t))))}).catch(console.error)};n();let r=new EventSource(`http://localhost:9111/stream`);return r.onmessage=e=>{if(t)try{let t=JSON.parse(e.data);(t.sender===`conflict-detector`||t.sender===`memory-ingestion`||t.message?.includes(`Surface compilation`)||t.message?.includes(`Brain embeddings rebuilt`)||t.message?.includes(`Graph indices rebuilt`)||t.message?.includes(`deleted`))&&n()}catch{}},()=>{t=!1,r.close()}},[e]),(0,v.useEffect)(()=>{function e(e){de.current&&!de.current.contains(e.target)&&ce(!1),Se.current&&!Se.current.contains(e.target)&&xe(!1)}return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[de,Se]),(0,v.useEffect)(()=>{Zn(te).then(e=>{e?(i(e),jW=Math.max(jW,e.length+1)):i([])}).catch(e=>{console.error(e),i([])})},[te]),(0,v.useEffect)(()=>{!p||h!==null||er().then(e=>g(e.enabled)).catch(()=>g(!1))},[p,h]),(0,v.useEffect)(()=>{O||mi().then(D).catch(()=>{})},[O]);let we=e=>{if(!(`speechSynthesis`in window))return;window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);t.rate=1.05,t.pitch=.95,window.speechSynthesis.speak(t)},Te=async e=>{if(!(!p||!e.trim())){if(h===!1){we(e);return}try{let t=await tr(e);if(!t){g(!1),we(e);return}let n=URL.createObjectURL(t);f.current&&(f.current.pause(),URL.revokeObjectURL(f.current.src));let r=new Audio(n);f.current=r,r.onended=()=>URL.revokeObjectURL(n),r.play().catch(()=>we(e))}catch{we(e)}}},Ee=()=>{let e=`thread-${MW()}`;ne(e),i([]),o(``),P([]),u.current&&(u.current.style.height=`44px`)},De=async(e,t)=>{if(e.stopPropagation(),confirm(`Are you sure you want to delete this conversation thread?`))try{if(await $n(t),te===t){let e=ee.filter(e=>e.id!==t);e.length>0?ne(e[0].id):(ne(void 0),i([]))}Ce()}catch(e){console.error(`Failed to delete thread:`,e)}},I=async()=>{let t=a.trim();if(!t||s)return;let n=te||`thread-${MW()}`;te||ne(n);let l={id:String(++jW),role:`user`,content:t,timestamp:MW()};i(e=>[...e,l]),o(``),c(!0),d.current=new AbortController,u.current&&(u.current.style.height=`44px`);try{if(b){i(e=>[...e,{id:String(++jW),role:`assistant`,content:`🕵️ **Deep Research Agents dispatched.** Gathering facts across parallel web streams...`,timestamp:MW()}]);let{slug:e}=await ii(`proactive-research`,t,t),n=!1;for(;!n;){await new Promise(e=>setTimeout(e,2e3));let t=(await ri()).find(t=>t.slug===e);t&&(t.status===`completed`||t.status===`failed`)&&(n=!0,i(e=>e.filter(e=>e.content!==`🕵️ **Deep Research Agents dispatched.** Gathering facts across parallel web streams...`)),i(e=>[...e,{id:String(++jW),role:`assistant`,content:t.body||``,timestamp:MW()}]),Te(t.body||``))}c(!1);return}let a=[`gemini`,`antigravity`].includes(me)&&ge?`${me}:${ge}`:me,o=await Xn([...r,l].map(e=>({role:e.role,content:e.content})),d.current.signal,n,N,a,e),s={id:String(++jW),role:`assistant`,content:o,timestamp:MW(),versions:[o],currentVersionIndex:0};i(e=>[...e,s]),Te(o),Ce()}catch(e){if(e.name===`AbortError`)i(e=>[...e,{id:String(++jW),role:`assistant`,content:`⛔ Generation stopped by user.`,timestamp:MW(),versions:[`⛔ Generation stopped by user.`],currentVersionIndex:0}]);else{let t={id:String(++jW),role:`assistant`,content:`⚠️ Error: ${e.message}`,timestamp:MW(),versions:[`⚠️ Error: ${e.message}`],currentVersionIndex:0};i(e=>[...e,t])}}finally{c(!1),d.current=null}},Oe=async t=>{if(s)return;let n=r.slice(0,t).map(e=>({role:e.role,content:e.content}));c(!0),d.current=new AbortController;try{let r=[`gemini`,`antigravity`].includes(me)&&ge?`${me}:${ge}`:me,a=await Xn(n,d.current.signal,te,void 0,r,e);i(e=>{let n=[...e],r=n[t],i=r.versions||[r.content];return i.push(a),r.versions=i,r.currentVersionIndex=i.length-1,r.content=a,n}),Te(a),Ce()}catch(e){e.name!==`AbortError`&&console.error(e)}finally{c(!1),d.current=null}},ke=e=>{navigator.clipboard.writeText(e).catch(console.error)},Ae=(e,t)=>{i(n=>{let r=[...n],i=r[e];if(!i.versions)return n;let a=Math.max(0,Math.min(i.versions.length-1,(i.currentVersionIndex||0)+t));return i.currentVersionIndex=a,i.content=i.versions[a],r})},je=()=>{d.current&&(d.current.abort(),d.current=null,c(!1))},Me=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),I())},Ne=e=>{let t=e.target.value;o(t);let n=e.target;n.style.height=`44px`,n.style.height=Math.min(n.scrollHeight,160)+`px`;let r=t.match(/https?:\/\/[^\s]+/);C(r?r[0]:null)},Pe=async e=>{if(S)try{await ai({url:S,action:e}),T(`✅ URL sent to ${e}`),C(null),setTimeout(()=>T(null),3e3)}catch(e){console.error(`Share API error:`,e),T(`⚠️ Failed to process URL`),setTimeout(()=>T(null),3e3)}},Fe=re.filter(e=>e.title.toLowerCase().includes(le.toLowerCase())||e.slug.toLowerCase().includes(le.toLowerCase())||e.category&&e.category.toLowerCase().includes(le.toLowerCase()));return(0,z.jsxs)(`div`,{className:`chat-layout`,children:[(0,z.jsxs)(`aside`,{className:`chat-threads-sidebar`,children:[(0,z.jsx)(`div`,{className:`sidebar-header`,children:(0,z.jsxs)(`button`,{className:`new-chat-btn`,onClick:Ee,children:[(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginRight:6},children:[(0,z.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,z.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),`New Chat`]})}),(0,z.jsx)(`div`,{className:`thread-list`,children:ee.map(e=>(0,z.jsxs)(`div`,{className:`thread-item ${te===e.id?`active`:``}`,onClick:()=>{ne(e.id),e.brainId&&t&&t(e.brainId)},children:[(0,z.jsxs)(`div`,{className:`thread-info`,children:[(0,z.jsx)(`div`,{className:`thread-title`,title:e.title,children:e.title}),(0,z.jsxs)(`div`,{className:`thread-meta`,children:[(0,z.jsxs)(`span`,{children:[e.turns,` `,e.turns===1?`turn`:`turns`]}),(0,z.jsx)(`span`,{children:`•`}),(0,z.jsx)(`span`,{children:NW(e.lastUpdated)})]})]}),(0,z.jsx)(`button`,{className:`thread-delete-btn`,onClick:t=>De(t,e.id),title:`Delete chat thread`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,z.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,z.jsx)(`line`,{x1:`10`,y1:`11`,x2:`10`,y2:`17`}),(0,z.jsx)(`line`,{x1:`14`,y1:`11`,x2:`14`,y2:`17`})]})})]},e.id))})]}),(0,z.jsxs)(`div`,{className:`chat-container`,style:{position:`relative`,overflow:`hidden`},children:[(0,z.jsx)(`div`,{"aria-hidden":!0,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,zIndex:0,pointerEvents:`none`,opacity:r.length>0?.22:.55,transition:`opacity 0.3s ease`},children:(0,z.jsx)(kW,{threads:ee,memoryNodes:re,researchItems:ae,onOpenThread:()=>{},onGroundMemoryNode:()=>{},selectedGroundingNodes:N,interactive:!1})}),(0,z.jsxs)(`header`,{className:`chat-header animate-fade-in`,style:{position:`relative`,zIndex:40,overflow:`visible`},children:[(0,z.jsxs)(`div`,{className:`chat-header-title`,children:[(0,z.jsx)(`h2`,{children:`Chat Session`}),te&&(0,z.jsx)(`span`,{className:`badge badge-accent`,style:{textTransform:`none`,letterSpacing:`normal`,fontSize:`11px`,padding:`2px 8px`},children:te})]}),(0,z.jsxs)(`div`,{className:`chat-header-model-selector`,ref:Se,style:{position:`relative`,zIndex:50},children:[(0,z.jsx)(`span`,{className:`selector-label`,children:`Model / provider:`}),(0,z.jsxs)(`div`,{className:`model-selector-dropdown-wrapper`,style:{position:`relative`,zIndex:50},children:[(0,z.jsxs)(`button`,{type:`button`,className:`model-selector-dropdown-btn ${be?`active`:``}`,onClick:e=>{e.stopPropagation(),xe(e=>!e)},title:`Select CLI agent / provider`,children:[(0,z.jsx)(`span`,{style:{textTransform:`capitalize`},children:me||`Select Model`}),(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,z.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),be&&(0,z.jsx)(`div`,{className:`model-selector-menu glass`,style:{zIndex:200,pointerEvents:`auto`},role:`listbox`,children:fe.map(e=>(0,z.jsxs)(`div`,{role:`option`,"aria-selected":me===e,className:`model-selector-item ${me===e?`selected`:``}`,onClick:t=>{t.stopPropagation(),he(e),localStorage.setItem(`selectedModel`,e),_e(``),localStorage.removeItem(`selectedSubModel`),xe(!1)},children:[(0,z.jsxs)(`div`,{className:`model-selector-item-info`,children:[(0,z.jsx)(`span`,{className:`model-selector-item-name`,style:{textTransform:`capitalize`},children:e}),(0,z.jsxs)(`span`,{className:`model-selector-item-desc`,children:[e===`antigravity`&&`Google Antigravity`,e===`grok`&&`xAI Grok Build CLI`,e===`gemini`&&`Google Gemini CLI`,e===`claude`&&`Anthropic Claude CLI`,e===`codex`&&`Codex Coding Agent`]})]}),(0,z.jsx)(`span`,{className:`model-selector-item-badge`,children:`CLI`})]},e))})]}),[`gemini`,`antigravity`].includes(me)&&ve.length>0&&(0,z.jsxs)(`div`,{className:`chat-header-submodel-selector`,style:{display:`flex`,alignItems:`center`,gap:8,marginLeft:16},children:[(0,z.jsx)(`span`,{className:`selector-label`,style:{fontSize:`12px`,color:`var(--text-tertiary)`,fontWeight:500},children:`Base:`}),(0,z.jsx)(`select`,{value:ge,onChange:e=>{_e(e.target.value),localStorage.setItem(`selectedSubModel`,e.target.value)},className:`submodel-select`,style:{background:`rgba(255, 255, 255, 0.04)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,color:`var(--text-secondary)`,padding:`6px 12px`,fontSize:`13px`,fontWeight:500,outline:`none`,cursor:`pointer`,transition:`all var(--transition-fast)`},children:ve.map(e=>(0,z.jsx)(`option`,{value:e.id,style:{background:`#12121a`,color:`var(--text-secondary)`},children:e.displayName},e.id))})]})]})]}),_?.updateAvailable&&A!==_.latestVersion&&(0,z.jsxs)(`div`,{className:`animate-fade-in`,style:{margin:`0 16px 12px`,padding:`12px 16px`,background:`linear-gradient(135deg, rgba(63, 185, 80, 0.12), rgba(34, 197, 94, 0.12))`,border:`1px solid rgba(63, 185, 80, 0.3)`,borderRadius:10,display:`flex`,alignItems:`center`,gap:12,position:`relative`,zIndex:40},children:[(0,z.jsx)(`span`,{style:{fontSize:22,flexShrink:0},children:`🚀`}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text-primary)`,marginBottom:2},children:`System Update Available`}),(0,z.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-secondary)`},children:[`Version `,_.latestVersion,` is available. Upgrade to load the latest features.`]})]}),(0,z.jsx)(`button`,{onClick:()=>n(`/health`),style:{flexShrink:0,padding:`6px 14px`,background:`#3fb950`,color:`#fff`,border:`none`,borderRadius:6,fontWeight:600,fontSize:12,cursor:`pointer`,whiteSpace:`nowrap`},children:`Go to Update`}),(0,z.jsx)(`button`,{onClick:()=>{_?.latestVersion&&(localStorage.setItem(`tr-update-banner-dismissed-version`,_.latestVersion),j(_.latestVersion))},title:`Dismiss banner`,"aria-label":`Dismiss update banner`,style:{background:`transparent`,border:`none`,color:`var(--text-muted)`,fontSize:16,cursor:`pointer`,padding:`4px 6px`,lineHeight:1},children:`✕`})]}),E?.available&&!E.connected&&!O&&(0,z.jsxs)(`div`,{style:{margin:`0 16px 0`,padding:`12px 16px`,background:`linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(99, 179, 237, 0.12))`,border:`1px solid rgba(108, 92, 231, 0.3)`,borderRadius:10,display:`flex`,alignItems:`center`,gap:12,animation:`fadeIn 0.3s ease`,position:`relative`,zIndex:40},children:[(0,z.jsx)(`span`,{style:{fontSize:22,flexShrink:0},children:`🧩`}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text-primary)`,marginBottom:2},children:`Chrome Extension Available`}),(0,z.jsx)(`div`,{style:{fontSize:11,color:`var(--text-secondary)`},children:`Browse with your brain — contextual memory, quick capture, and research from any page`})]}),(0,z.jsx)(`a`,{href:`/api/extension/download`,download:!0,style:{flexShrink:0,padding:`6px 14px`,background:`linear-gradient(135deg, #3b82f6, #93c5fd)`,color:`#fff`,borderRadius:6,fontWeight:500,fontSize:12,textDecoration:`none`,whiteSpace:`nowrap`},children:`⬇ Download`}),(0,z.jsx)(`button`,{onClick:()=>{k(!0),localStorage.setItem(`tr-ext-banner-dismissed`,`true`)},style:{flexShrink:0,background:`none`,border:`none`,color:`var(--text-tertiary)`,cursor:`pointer`,fontSize:16,padding:`0 2px`,lineHeight:1},title:`Dismiss`,children:`✕`})]}),(0,z.jsx)(`div`,{className:`chat-messages`,style:{position:`relative`,zIndex:1,pointerEvents:`auto`},children:(0,z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,flexDirection:`column`,gap:`16px`,width:`100%`,maxWidth:800,margin:`0 auto`,pointerEvents:`auto`},children:[r.map((e,t)=>(0,z.jsxs)(`div`,{className:`message message-${e.role}`,style:{backdropFilter:`blur(8px)`,WebkitBackdropFilter:`blur(8px)`,background:e.role===`user`?`rgba(108, 92, 231, 0.75)`:`rgba(18, 18, 26, 0.75)`,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,z.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`break-word`},children:e.content}),e.role===`assistant`&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:12,marginTop:12,fontSize:13,color:`var(--text-tertiary)`,alignItems:`center`,userSelect:`none`},children:[e.versions&&e.versions.length>1&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`,marginRight:4},children:[(0,z.jsx)(`button`,{onClick:()=>Ae(t,-1),disabled:(e.currentVersionIndex||0)===0,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:2,opacity:(e.currentVersionIndex||0)===0?.3:1},children:`◄`}),(0,z.jsxs)(`span`,{children:[(e.currentVersionIndex||0)+1,` / `,e.versions.length]}),(0,z.jsx)(`button`,{onClick:()=>Ae(t,1),disabled:(e.currentVersionIndex||0)===e.versions.length-1,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:2,opacity:(e.currentVersionIndex||0)===e.versions.length-1?.3:1},children:`►`})]}),(0,z.jsx)(`button`,{onClick:()=>ke(e.content),title:`Copy to clipboard`,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4},children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,z.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),(0,z.jsx)(`button`,{onClick:()=>Te(e.content),title:`Read Aloud`,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4},children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),(0,z.jsx)(`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07`})]})}),(0,z.jsx)(`button`,{onClick:()=>Oe(t),disabled:s,title:`Regenerate Response`,style:{background:`none`,border:`none`,color:`inherit`,cursor:s?`default`:`pointer`,display:`flex`,alignItems:`center`,gap:4,opacity:s?.3:1},children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polyline`,{points:`1 4 1 10 7 10`}),(0,z.jsx)(`polyline`,{points:`23 20 23 14 17 14`}),(0,z.jsx)(`path`,{d:`M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15`})]})})]})]},e.id)),s&&(0,z.jsx)(`div`,{className:`message message-assistant`,style:{backdropFilter:`blur(8px)`,WebkitBackdropFilter:`blur(8px)`,background:`rgba(18, 18, 26, 0.75)`,border:`1px solid rgba(255, 255, 255, 0.08)`},children:(0,z.jsx)(`span`,{className:`skeleton`,style:{display:`inline-block`,width:180,height:16}})}),(0,z.jsx)(`div`,{ref:l})]})}),(0,z.jsxs)(`div`,{className:`chat-input-bar`,style:{position:`relative`,zIndex:30,pointerEvents:`auto`},children:[N.length>0&&(0,z.jsx)(`div`,{className:`grounding-pills`,children:N.map(e=>{let t=re.find(t=>t.slug===e);return(0,z.jsxs)(`div`,{className:`grounding-pill animate-fade-in`,children:[(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,z.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),(0,z.jsx)(`span`,{className:`grounding-pill-title`,children:t?.title||e}),(0,z.jsx)(`button`,{className:`grounding-pill-remove`,onClick:()=>P(t=>t.filter(t=>t!==e)),title:`Remove grounding context`,children:`×`})]},e)})}),(0,z.jsxs)(`div`,{className:`chat-input-wrapper`,children:[(0,z.jsx)(`button`,{className:`btn btn-ghost ${b?`active`:``}`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,color:b?`var(--accent)`:`var(--text-tertiary)`,borderColor:b?`var(--accent)`:`var(--border)`},onClick:()=>x(!b),title:b?`Deep Research On`:`Deep Research Off`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`path`,{d:`M12 2v20`}),(0,z.jsx)(`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`})]})}),(0,z.jsxs)(`div`,{style:{position:`relative`,display:`flex`},ref:de,children:[(0,z.jsxs)(`button`,{className:`btn btn-ghost ${N.length>0?`active`:``}`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,color:N.length>0?`var(--accent)`:`var(--text-tertiary)`,borderColor:N.length>0?`var(--accent)`:`var(--border)`},onClick:()=>ce(!se),title:`Ground with brain nodes`,children:[(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,z.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),N.length>0&&(0,z.jsx)(`span`,{className:`grounding-count-badge`,children:N.length})]}),se&&(0,z.jsxs)(`div`,{className:`node-selector-popover glass`,children:[(0,z.jsxs)(`div`,{className:`node-selector-header`,children:[(0,z.jsx)(`h4`,{children:`Ground with Brain Nodes`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`Search nodes...`,value:le,onChange:e=>ue(e.target.value),className:`node-search-input`,autoFocus:!0})]}),(0,z.jsx)(`div`,{className:`node-selector-list`,children:Fe.length===0?(0,z.jsx)(`div`,{className:`node-selector-empty`,children:`No nodes found`}):Fe.map(e=>{let t=N.includes(e.slug);return(0,z.jsxs)(`div`,{className:`node-selector-item ${t?`selected`:``}`,onClick:()=>{P(t?t=>t.filter(t=>t!==e.slug):t=>[...t,e.slug])},children:[(0,z.jsx)(`span`,{className:`node-selector-item-checkbox`,children:t?`✓`:``}),(0,z.jsxs)(`div`,{className:`node-selector-item-info`,children:[(0,z.jsx)(`span`,{className:`node-selector-item-title`,children:e.title}),(0,z.jsxs)(`span`,{className:`node-selector-item-meta`,children:[e.category,` • `,e.status||`active`]})]})]},e.slug)})})]})]}),(0,z.jsx)(AW,{onTranscript:e=>{o(t=>t+(t.endsWith(` `)||t===``?``:` `)+e),setTimeout(()=>{if(u.current){u.current.focus();let e=new Event(`input`,{bubbles:!0});u.current.dispatchEvent(e)}},10)}}),(0,z.jsxs)(`div`,{style:{position:`relative`,flex:1,display:`flex`,alignItems:`center`},children:[(0,z.jsx)(`textarea`,{ref:u,id:`chat-input`,value:a,onChange:Ne,onKeyDown:Me,placeholder:`Message your brain…`,rows:1,disabled:s,style:{paddingRight:44}}),(0,z.jsx)(`button`,{className:`btn btn-ghost ${p?`active`:``}`,style:{position:`absolute`,right:4,bottom:4,width:36,height:36,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,color:p?`#ef4444`:`var(--text-tertiary)`,border:`none`,background:`transparent`},onClick:()=>{m(!p),p&&`speechSynthesis`in window&&window.speechSynthesis.cancel()},title:p?`Voice Mode On`:`Voice Mode Off`,children:p?(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}),(0,z.jsx)(`line`,{x1:`8`,x2:`16`,y1:`22`,y2:`22`})]}):(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`line`,{x1:`1`,x2:`23`,y1:`1`,y2:`23`}),(0,z.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V5a3 3 0 0 0-5.94-.88`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-1.39 4.2M5 10v2a7 7 0 0 0 1.93 4.88`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}),(0,z.jsx)(`line`,{x1:`8`,x2:`16`,y1:`22`,y2:`22`})]})})]}),s?(0,z.jsx)(`button`,{className:`chat-send-btn`,onClick:je,id:`chat-stop`,style:{background:`var(--error)`,color:`#fff`},title:`Stop Generation`,children:(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,style:{width:20,height:20},children:(0,z.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`,ry:`2`})})}):(0,z.jsx)(`button`,{className:`chat-send-btn`,onClick:I,disabled:!a.trim(),id:`chat-send`,title:`Send Message`,children:(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,z.jsx)(`path`,{d:`M3.478 2.405a.75.75 0 00-.926.94l2.432 7.905H13.5a.75.75 0 010 1.5H4.984l-2.432 7.905a.75.75 0 00.926.94 60.519 60.519 0 0018.445-8.986.75.75 0 000-1.218A60.517 60.517 0 003.478 2.405z`})})})]}),S&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,padding:`8px 12px`,background:`var(--bg-secondary, #1e1e2e)`,borderRadius:`8px`,alignItems:`center`,fontSize:`0.85rem`,marginTop:4},children:[(0,z.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`🔗 URL detected`}),(0,z.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>Pe(`research`),children:`🔬 Research`}),(0,z.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>Pe(`remember`),children:`📌 Remember`})]}),w&&(0,z.jsx)(`div`,{style:{padding:`6px 12px`,background:`rgba(46, 204, 113, 0.1)`,border:`1px solid rgba(46, 204, 113, 0.3)`,borderRadius:`8px`,fontSize:`0.8rem`,color:`var(--success)`,marginTop:4,textAlign:`center`},children:w})]})]})]})}var FW=[`all`,`invariants`,`preferences`,`anti-patterns`,`patterns`,`decisions`,`concepts`,`facts`,`lore`];function IW(e){if(!e)return``;let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);return t=t.replace(/^### (.*$)/gim,`<h3>$1</h3>`),t=t.replace(/^## (.*$)/gim,`<h2>$1</h2>`),t=t.replace(/^# (.*$)/gim,`<h1>$1</h1>`),t=t.replace(/\*\*(.*?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/\*(.*?)\*/g,`<em>$1</em>`),t=t.replace(/```([\s\S]*?)```/g,`<pre style="background:rgba(0,0,0,0.3);padding:12px;border-radius:6px;border:1px solid rgba(255,255,255,0.06);font-family:monospace;overflow-x:auto;"><code>$1</code></pre>`),t=t.replace(/`(.*?)`/g,`<code style="background:rgba(255,255,255,0.06);padding:2px 6px;border-radius:4px;font-family:monospace;">$1</code>`),t=t.replace(/^> (.*$)/gim,`<blockquote style="border-left:4px solid var(--purple-primary);padding-left:14px;color:var(--text-secondary);margin:16px 0;font-style:italic;">$1</blockquote>`),t=t.replace(/^- (.*$)/gim,`<li style="margin-left:20px;list-style-type:disc;">$1</li>`),t=t.replace(/\n/g,`<br />`),(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:t},className:`markdown-preview-block`})}function LW({activeBrainId:e}){let[t,n]=jn(),r=t.get(`slug`),[i,a]=(0,v.useState)(`vault`),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(`all`),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(0),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)([]),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),[j,ee]=(0,v.useState)(!1),[M,te]=(0,v.useState)(``),[ne,N]=(0,v.useState)(``),[P,re]=(0,v.useState)(`invariants`),[ie,ae]=(0,v.useState)(``),[oe,se]=(0,v.useState)(`active`),[ce,le]=(0,v.useState)(`low`),[ue,de]=(0,v.useState)(`should`),[fe,pe]=(0,v.useState)(1),[me,he]=(0,v.useState)(3),[ge,_e]=(0,v.useState)(``),[ve,ye]=(0,v.useState)(``),[be,xe]=(0,v.useState)(``),[Se,F]=(0,v.useState)(``),Ce=(0,v.useCallback)(async()=>{h(!0),_(``);try{if(f.trim()){let e=await rr(f,u===`all`?void 0:u);s(e)}else{let t=await nr(e,u===`all`?void 0:u);s(t)}}catch(e){_(e.message),s([])}finally{h(!1)}},[u,f,e]);(0,v.useEffect)(()=>{c&&(te(c.slug||``),N(c.title||``),re(c.category||`invariants`),ae(c.content||c.body||``),se(c.status||`active`),le(c.priority||`low`),de(c.modality||`should`),pe(c.confidence??1),he(c.importance??3),_e((c.tags||[]).join(`, `)),ye((c.related||[]).join(`, `)),xe((c.contradicts||[]).join(`, `)),F((c.supersedes||[]).join(`, `)))},[c]);let we=async()=>{if(c){h(!0),_(``);try{let t=ge.split(`,`).map(e=>e.trim()).filter(Boolean),n=ve.split(`,`).map(e=>e.trim()).filter(Boolean),r=be.split(`,`).map(e=>e.trim()).filter(Boolean),i=Se.split(`,`).map(e=>e.trim()).filter(Boolean),a=await ar(c.slug,{title:ne,category:P,content:ie,status:oe,priority:ce,modality:ue,confidence:fe,importance:me,tags:t,related:n,contradicts:r,supersedes:i},e);l(a),A(!1),Ce()}catch(e){_(e.message)}finally{h(!1)}}},Te=async()=>{if(!M.trim()||!ne.trim()||!ie.trim()){_(`Slug, Title, and Content are required fields.`);return}h(!0),_(``);try{let t=ge.split(`,`).map(e=>e.trim()).filter(Boolean),r=ve.split(`,`).map(e=>e.trim()).filter(Boolean),i=be.split(`,`).map(e=>e.trim()).filter(Boolean),a=Se.split(`,`).map(e=>e.trim()).filter(Boolean),o=await or({slug:M,title:ne,category:P,content:ie,status:oe,priority:ce,modality:ue,confidence:fe,importance:me,tags:t,related:r,contradicts:i,supersedes:a},e);ee(!1),l(o),n({slug:o.slug}),Ce()}catch(e){_(e.message)}finally{h(!1)}},Ee=async t=>{if(window.confirm(`Are you sure you want to delete memory node "${t}"?`)){h(!0),_(``);try{await sr(t,e),l(null),n({}),Ce()}catch(e){_(e.message)}finally{h(!1)}}},De=(0,v.useCallback)(async()=>{try{let e=await cr();E(e.conflicts||[])}catch(e){console.warn(`Conflicts API error (enhanced features might be disabled):`,e)}},[]);(0,v.useEffect)(()=>{let e=setTimeout(Ce,300);return()=>clearTimeout(e)},[Ce]);let I=(0,v.useCallback)(async()=>{w(!0);try{let e=await hi(100);b(e.sessions),S(e.total)}catch(e){_(e.message)}finally{w(!1)}},[]);(0,v.useEffect)(()=>{i===`conflicts`?De():i===`sessions`&&I()},[i,De,I]);let Oe=async e=>{if(window.confirm(`Delete session "${e}"?`))try{await gi(e),I()}catch(e){_(e.message)}};(0,v.useEffect)(()=>{r?(async()=>{let t=o.find(e=>e.slug===r);if(t&&(t.content||t.body)){l(t),_(``);return}h(!0),_(``);try{let n=await ir(r,e);n?l(n):t?l(t):(_(`Memory node not found: ${r}`),l(null))}catch(e){t?(l(t),_(``)):(_(`Failed to load memory node '${r}': ${e.message}`),l(null))}finally{h(!1)}})():l(null)},[r,e,o]),(0,v.useEffect)(()=>{let e=new EventSource(`http://localhost:9111/stream`);return e.onmessage=e=>{try{let t=JSON.parse(e.data);(t.subsystem===`conflict-detector`||t.subsystem===`rebuild`||t.subsystem===`session-watcher`)&&(Ce(),De())}catch{}},e.onerror=()=>{e.close()},()=>{e.close()}},[Ce,De]);let ke=e=>{l(e),_(``),n({slug:e.slug})},Ae=async(e,t,n)=>{O(e),_(``);try{await lr(e,t,n),await De(),await Ce()}catch(e){_(e.message)}finally{O(null)}},je=(e,t,n)=>(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Slug (kebab-case, matches filename)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. prefer-atomic-writes`,value:M,onChange:e=>te(e.target.value),disabled:!n,style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Title (One-line description)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. Always write files atomically (write-then-rename)`,value:ne,onChange:e=>N(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Category`}),(0,z.jsxs)(`select`,{value:P,onChange:e=>re(e.target.value),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:`invariants`,children:`invariants`}),(0,z.jsx)(`option`,{value:`patterns`,children:`patterns`}),(0,z.jsx)(`option`,{value:`anti-patterns`,children:`anti-patterns`}),(0,z.jsx)(`option`,{value:`preferences`,children:`preferences`}),(0,z.jsx)(`option`,{value:`decisions`,children:`decisions`}),(0,z.jsx)(`option`,{value:`concepts`,children:`concepts`}),(0,z.jsx)(`option`,{value:`facts`,children:`facts`}),(0,z.jsx)(`option`,{value:`lore`,children:`lore`})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Modality`}),(0,z.jsxs)(`select`,{value:ue,onChange:e=>de(e.target.value),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:`must`,children:`must`}),(0,z.jsx)(`option`,{value:`must_not`,children:`must_not`}),(0,z.jsx)(`option`,{value:`should`,children:`should`}),(0,z.jsx)(`option`,{value:`should_not`,children:`should_not`})]})]})]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Status`}),(0,z.jsxs)(`select`,{value:oe,onChange:e=>se(e.target.value),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:`active`,children:`active`}),(0,z.jsx)(`option`,{value:`draft`,children:`draft`}),(0,z.jsx)(`option`,{value:`deprecated`,children:`deprecated`}),(0,z.jsx)(`option`,{value:`superseded`,children:`superseded`})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Importance (1-5 Stars)`}),(0,z.jsxs)(`select`,{value:me,onChange:e=>he(Number(e.target.value)),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:1,children:`★ 1/5`}),(0,z.jsx)(`option`,{value:2,children:`★★ 2/5`}),(0,z.jsx)(`option`,{value:3,children:`★★★ 3/5`}),(0,z.jsx)(`option`,{value:4,children:`★★★★ 4/5`}),(0,z.jsx)(`option`,{value:5,children:`★★★★★ 5/5`})]})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:[`Confidence: `,(0,z.jsxs)(`strong`,{children:[Math.round(fe*100),`%`]})]}),(0,z.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:fe,onChange:e=>pe(Number(e.target.value)),style:{width:`100%`,height:6,background:`rgba(255,255,255,0.1)`,borderRadius:3,outline:`none`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Tags (comma separated)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. filesystem, reliability, writes`,value:ge,onChange:e=>_e(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]})]})]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Related Nodes (comma separated slugs)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. use-atomic-writes, git-wiping`,value:ve,onChange:e=>ye(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Contradicts Nodes (comma separated slugs)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. write-anywhere-sync`,value:be,onChange:e=>xe(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Supersedes Nodes (comma separated slugs)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. prefer-atomic-writes-v1`,value:Se,onChange:e=>F(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,z.jsx)(`label`,{style:{fontSize:12,color:`var(--text-secondary)`},children:`Memory Content`}),(0,z.jsx)(`textarea`,{value:ie,onChange:e=>ae(e.target.value),placeholder:`Write markdown here...`,style:{minHeight:300,padding:16,color:`#fff`,background:`#090d16`,border:`1px solid var(--border)`,borderRadius:8,outline:`none`,fontSize:14,lineHeight:1.6,resize:`vertical`,width:`100%`,boxSizing:`border-box`}})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:12},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost`,type:`button`,onClick:t,style:{fontSize:13},children:`Cancel`}),(0,z.jsx)(`button`,{className:`btn btn-purple`,type:`button`,onClick:e,style:{fontSize:13},children:n?`🚀 Create Memory Node`:`💾 Save Changes`})]})]}),Me=o.reduce((e,t)=>(e[t.category]=(e[t.category]||0)+1,e),{});return(0,z.jsxs)(`div`,{className:`page`,children:[(0,z.jsxs)(`div`,{className:`page-header`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-end`,marginBottom:20},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{children:`Memory Vault`}),(0,z.jsx)(`p`,{children:`Browse, audit, and resolve contradictions in your SSSS knowledge graph`})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,background:`rgba(255,255,255,0.03)`,padding:4,borderRadius:8,border:`1px solid var(--border)`},children:[(0,z.jsx)(`button`,{className:`btn btn-sm ${i===`vault`?`btn-purple`:`btn-ghost`}`,onClick:()=>{a(`vault`),l(null),n({})},style:{borderRadius:6,fontSize:12,padding:`6px 12px`},children:`🧠 Active Nodes`}),(0,z.jsxs)(`button`,{className:`btn btn-sm ${i===`conflicts`?`btn-cyan`:`btn-ghost`}`,onClick:()=>{a(`conflicts`),l(null),n({})},style:{borderRadius:6,fontSize:12,padding:`6px 12px`,display:`flex`,alignItems:`center`,gap:6},children:[`⚠️ Quarantined Conflicts`,T.length>0&&(0,z.jsx)(`span`,{style:{background:`#ef4444`,color:`#fff`,fontSize:9,padding:`1px 5px`,borderRadius:10,fontWeight:700},children:T.length})]}),(0,z.jsxs)(`button`,{className:`btn btn-sm ${i===`sessions`?`btn-purple`:`btn-ghost`}`,onClick:()=>{a(`sessions`),l(null),n({})},style:{borderRadius:6,fontSize:12,padding:`6px 12px`},children:[`📝 Sessions`,x>0&&(0,z.jsx)(`span`,{style:{background:`rgba(139,92,246,0.3)`,color:`#a78bfa`,fontSize:9,padding:`1px 5px`,borderRadius:10,fontWeight:700,marginLeft:4},children:x})]})]})]}),g&&(0,z.jsxs)(`div`,{className:`badge badge-error`,style:{alignSelf:`flex-start`,marginBottom:15},children:[`⚠️ `,g]}),i===`vault`?(0,z.jsxs)(`div`,{className:`memory-layout`,children:[(0,z.jsxs)(`div`,{className:`memory-sidebar`,children:[(0,z.jsx)(`h3`,{style:{margin:`0 0 12px 0`},children:`Categories`}),FW.map(e=>(0,z.jsxs)(`button`,{className:`category-btn ${u===e?`active`:``}`,onClick:()=>{d(e),n({}),ee(!1),A(!1)},children:[(0,z.jsx)(`span`,{children:e===`all`?`📋 All Nodes`:e}),e===`all`?(0,z.jsx)(`span`,{className:`category-count`,children:o.length}):Me[e]?(0,z.jsx)(`span`,{className:`category-count`,children:Me[e]}):null]},e)),(0,z.jsx)(`button`,{className:`btn btn-purple`,style:{width:`100%`,marginTop:20,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:8,fontSize:13},onClick:()=>{l(null),n({}),ee(!0),A(!1),te(``),N(``),re(`invariants`),ae(``),se(`active`),le(`low`),de(`should`),pe(1),he(3),_e(``),ye(``),xe(``),F(``)},children:`➕ Create New Node`})]}),(0,z.jsxs)(`div`,{className:`memory-main`,children:[(0,z.jsxs)(`div`,{className:`memory-search`,children:[(0,z.jsx)(`input`,{id:`memory-search`,type:`text`,placeholder:`Search memory nodes…`,value:f,onChange:e=>p(e.target.value)}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:Ce,children:`Refresh`})]}),m?(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2,3].map(e=>(0,z.jsx)(`div`,{className:`skeleton`,style:{height:60}},e))}):j?(0,z.jsxs)(`div`,{className:`memory-detail`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:20},children:[(0,z.jsx)(`h2`,{style:{margin:0,color:`#fff`},children:`Create New SSSS Memory Node`}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>ee(!1),style:{fontSize:12},children:`← Back to List`})]}),je(Te,()=>ee(!1),!0)]}):c&&k?(0,z.jsxs)(`div`,{className:`memory-detail`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:20},children:[(0,z.jsx)(`h2`,{style:{margin:0,color:`#fff`},children:`Edit Memory Node`}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>A(!1),style:{fontSize:12},children:`← Cancel Edit`})]}),je(we,()=>A(!1),!1)]}):c?(0,z.jsxs)(`div`,{className:`memory-detail`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:c.modality===`must`?`2px solid #10b981`:c.modality===`must_not`?`2px solid #ef4444`:c.modality===`should`?`1px solid #8b5cf6`:c.modality===`should_not`?`1px solid #f97316`:`1px solid var(--border)`,boxShadow:c.modality===`must`?`0 0 16px rgba(16, 185, 129, 0.1)`:c.modality===`must_not`?`0 0 16px rgba(239, 68, 68, 0.1)`:void 0,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:16},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>n({}),style:{fontSize:12},children:`← Back to List`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>{te(c.slug||``),N(c.title||``),re(c.category||`invariants`),ae(c.content||c.body||``),se(c.status||`active`),le(c.priority||`low`),de(c.modality||`should`),pe(c.confidence??1),he(c.importance??3),_e((c.tags||[]).join(`, `)),ye((c.related||[]).join(`, `)),xe((c.contradicts||[]).join(`, `)),F((c.supersedes||[]).join(`, `)),A(!0)},style:{fontSize:12,border:`1px solid var(--border)`},children:`✏️ Edit Node`}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>Ee(c.slug),style:{fontSize:12,borderColor:`rgba(239,68,68,0.2)`,color:`#fca5a5`},children:`🗑️ Delete`})]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:12},children:[(0,z.jsx)(`h2`,{style:{margin:0,color:`#fff`},children:c.title}),c.modality&&(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:700,textTransform:`uppercase`,padding:`4px 10px`,borderRadius:6,background:c.modality===`must`?`rgba(16, 185, 129, 0.15)`:c.modality===`must_not`?`rgba(239, 68, 68, 0.15)`:`rgba(255, 255, 255, 0.05)`,color:c.modality===`must`?`#10b981`:c.modality===`must_not`?`#ef4444`:`var(--text-secondary)`,border:c.modality===`must`?`1px solid rgba(16, 185, 129, 0.3)`:c.modality===`must_not`?`1px solid rgba(239, 68, 68, 0.3)`:`1px solid rgba(255, 255, 255, 0.1)`},children:c.modality})]}),(0,z.jsxs)(`dl`,{className:`frontmatter`,style:{display:`grid`,gridTemplateColumns:`120px 1fr`,gap:`10px 20px`,marginBottom:24,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.06)`},children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Slug`}),(0,z.jsx)(`dd`,{style:{margin:0},children:(0,z.jsx)(`code`,{children:c.slug})}),(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Category`}),(0,z.jsx)(`dd`,{style:{margin:0,textTransform:`capitalize`},children:c.category}),c.status&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Status`}),(0,z.jsx)(`dd`,{style:{margin:0},children:(0,z.jsx)(`span`,{className:`badge badge-success`,style:{background:c.status===`active`?`rgba(34, 197, 94, 0.15)`:`rgba(255,255,255,0.05)`,color:c.status===`active`?`#22c55e`:`var(--text-secondary)`},children:c.status})})]}),c.confidence!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Confidence`}),(0,z.jsxs)(`dd`,{style:{margin:0,display:`flex`,alignItems:`center`,gap:12},children:[(0,z.jsxs)(`strong`,{style:{fontSize:13},children:[Math.round(c.confidence*100),`%`]}),(0,z.jsx)(`div`,{style:{flex:1,maxWidth:150,height:6,background:`rgba(255,255,255,0.06)`,borderRadius:3,overflow:`hidden`,display:`inline-block`},children:(0,z.jsx)(`div`,{style:{width:`${Math.round(c.confidence*100)}%`,height:`100%`,background:`linear-gradient(90deg, #8b5cf6, #06b6d4)`,borderRadius:3}})})]})]}),c.importance!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Importance`}),(0,z.jsx)(`dd`,{style:{margin:0,color:`#fbbf24`,display:`flex`,gap:2},children:Array.from({length:5}).map((e,t)=>(0,z.jsx)(`span`,{children:t<(c.importance||0)?`★`:`☆`},t))})]}),c.tags?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Tags`}),(0,z.jsx)(`dd`,{style:{margin:0,display:`flex`,gap:6,flexWrap:`wrap`},children:c.tags.map(e=>(0,z.jsx)(`span`,{style:{background:`rgba(255,255,255,0.05)`,color:`var(--text-secondary)`,fontSize:10,padding:`2px 8px`,borderRadius:4,border:`1px solid rgba(255,255,255,0.03)`},children:e},e))})]}):null,c.related?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Related`}),(0,z.jsx)(`dd`,{style:{margin:0},children:(0,z.jsx)(`code`,{children:c.related.join(`, `)})})]}):null,c.contradicts?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Contradicts`}),(0,z.jsx)(`dd`,{style:{margin:0,color:`#fca5a5`},children:(0,z.jsx)(`code`,{children:c.contradicts.join(`, `)})})]}):null,c.supersedes?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Supersedes`}),(0,z.jsx)(`dd`,{style:{margin:0,color:`#93c5fd`},children:(0,z.jsx)(`code`,{children:c.supersedes.join(`, `)})})]}):null]}),(0,z.jsxs)(`div`,{style:{marginTop:20},children:[(0,z.jsx)(`h3`,{style:{fontSize:12,textTransform:`uppercase`,color:`var(--text-tertiary)`,letterSpacing:.5,marginBottom:12},children:`Memory Content (SSSS Body)`}),(0,z.jsx)(`div`,{style:{background:`rgba(0,0,0,0.15)`,border:`1px solid rgba(255,255,255,0.04)`,borderRadius:8,padding:20},children:IW(c.body||c.content||``)})]})]}):(0,z.jsxs)(`div`,{className:`memory-list`,style:{display:`grid`,gridTemplateColumns:`1fr`,gap:12},children:[o.length===0&&!m&&(0,z.jsx)(`div`,{style:{textAlign:`center`,padding:40,color:`var(--text-tertiary)`},children:f?`No matching nodes found.`:u===`all`?`No memory nodes loaded. Is the backend running?`:`No memory nodes found in category "${u}".`}),o.map(e=>{let t=e.modality===`must`?`2px solid #10b981`:e.modality===`must_not`?`2px solid #ef4444`:e.modality===`should`?`1px solid #8b5cf6`:e.modality===`should_not`?`1px solid #f97316`:`1px solid rgba(255, 255, 255, 0.08)`,n=e.modality===`must`?`0 0 12px rgba(16, 185, 129, 0.15)`:e.modality===`must_not`?`0 0 12px rgba(239, 68, 68, 0.15)`:void 0;return(0,z.jsxs)(`div`,{className:`memory-node-card`,onClick:()=>ke(e),style:{border:t,boxShadow:n,transition:`transform 0.2s ease, box-shadow 0.2s ease`,position:`relative`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:6},children:[(0,z.jsx)(`h4`,{style:{margin:0,color:`#fff`,fontSize:15},children:e.title}),e.modality&&(0,z.jsx)(`span`,{style:{fontSize:9,fontWeight:700,textTransform:`uppercase`,padding:`2px 6px`,borderRadius:4,background:e.modality===`must`?`rgba(16, 185, 129, 0.15)`:e.modality===`must_not`?`rgba(239, 68, 68, 0.15)`:`rgba(255, 255, 255, 0.05)`,color:e.modality===`must`?`#10b981`:e.modality===`must_not`?`#ef4444`:`var(--text-secondary)`},children:e.modality})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:16,fontSize:11,color:`var(--text-tertiary)`,marginTop:8},children:[(0,z.jsxs)(`span`,{children:[`📂 `,e.category]}),e.importance!==void 0&&(0,z.jsxs)(`span`,{style:{color:`#fbbf24`},children:[`★ `,e.importance,`/5`]}),e.confidence!==void 0&&(0,z.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:4},children:[`🧠 `,Math.round(e.confidence*100),`%`]})]})]},e.slug)})]})]})]}):(0,z.jsxs)(`div`,{style:{width:`100%`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:16},children:[(0,z.jsx)(`h3`,{children:`Quarantined Contradiction Records`}),(0,z.jsxs)(`span`,{style:{fontSize:12,color:`var(--text-tertiary)`,display:`flex`,alignItems:`center`,gap:5},children:[(0,z.jsx)(`span`,{className:`pulse`,style:{background:`#06b6d4`}}),` SSE Real-time Agent Monitor Connected`]})]}),T.length===0?(0,z.jsxs)(`div`,{style:{textAlign:`center`,padding:60,background:`rgba(255,255,255,0.02)`,borderRadius:12,border:`1px dashed var(--border)`,color:`var(--text-tertiary)`},children:[(0,z.jsx)(`span`,{style:{fontSize:32,display:`block`,marginBottom:12},children:`🛡️`}),(0,z.jsx)(`h4`,{style:{color:`#fff`,marginBottom:6},children:`All Clear!`}),"No memory conflicts enqueued or quarantined in `.agent/memory-inbox/conflicts/`."]}):(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:T.map(e=>{let t=e.status===`pending`;return(0,z.jsxs)(`div`,{style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:t?`1px solid rgba(239, 68, 68, 0.25)`:`1px solid rgba(34, 197, 94, 0.2)`,borderRadius:12,padding:24,boxShadow:`0 8px 32px rgba(0,0,0,0.15)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:16,borderBottom:`1px solid rgba(255,255,255,0.06)`,paddingBottom:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h4`,{style:{margin:0,fontSize:16,color:`#fff`,display:`flex`,alignItems:`center`,gap:8},children:[`Conflict: `,(0,z.jsx)(`code`,{children:e.conflict_id}),(0,z.jsx)(`span`,{style:{fontSize:11,padding:`2px 8px`,borderRadius:10,background:t?`rgba(239,68,68,0.15)`:`rgba(34,197,94,0.15)`,color:t?`#ef4444`:`#22c55e`,textTransform:`uppercase`},children:e.status})]}),(0,z.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[`Detected at: `,new Date(e.detected_at).toLocaleString()]})]}),(0,z.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,z.jsxs)(`span`,{style:{fontSize:12,color:`#ef4444`,fontWeight:700,display:`block`},children:[`Clash Similarity: `,Math.round(e.similarity*100),`%`]}),(0,z.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`Modality polarity flip`})]})]}),(0,z.jsxs)(`p`,{style:{fontSize:13,background:`rgba(239,68,68,0.03)`,padding:`10px 14px`,borderRadius:6,borderLeft:`3px solid #ef4444`,color:`#fca5a5`,marginBottom:20},children:[(0,z.jsx)(`strong`,{children:`Reason:`}),` `,e.reason]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16,marginBottom:24},children:[(0,z.jsxs)(`div`,{style:{background:`rgba(255,255,255,0.02)`,padding:16,borderRadius:8,border:`1px solid rgba(255,255,255,0.05)`},children:[(0,z.jsx)(`h5`,{style:{margin:`0 0 10px 0`,color:`#a78bfa`,textTransform:`uppercase`,fontSize:11,letterSpacing:.5},children:`✓ Existing Node In Vault`}),(0,z.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`#fff`,marginBottom:8},children:(0,z.jsx)(`code`,{children:e.existing_slug})}),(0,z.jsxs)(`dl`,{style:{display:`grid`,gridTemplateColumns:`80px 1fr`,gap:4,margin:`0 0 12px 0`,fontSize:11,color:`var(--text-secondary)`},children:[(0,z.jsx)(`dt`,{children:`Modality:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._existing_node?.modality||`must`})}),(0,z.jsx)(`dt`,{children:`Polarity:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._existing_node?.sentiment_polarity||`directive_must`})}),(0,z.jsx)(`dt`,{children:`Confidence:`}),(0,z.jsx)(`dd`,{children:e._existing_node?.confidence===void 0?`N/A`:`${Math.round(e._existing_node.confidence*100)}%`})]}),(0,z.jsx)(`div`,{style:{fontSize:12,fontStyle:`italic`,background:`rgba(0,0,0,0.2)`,padding:10,borderRadius:6,color:`var(--text-tertiary)`,minHeight:60,whiteSpace:`pre-wrap`},children:e._existing_node?.excerpt||e._existing_node?.body||`No preview content.`})]}),(0,z.jsxs)(`div`,{style:{background:`rgba(255,255,255,0.02)`,padding:16,borderRadius:8,border:`1px solid rgba(255,255,255,0.05)`},children:[(0,z.jsx)(`h5`,{style:{margin:`0 0 10px 0`,color:`#06b6d4`,textTransform:`uppercase`,fontSize:11,letterSpacing:.5},children:`⚠ New Ingestion Candidate`}),(0,z.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`#fff`,marginBottom:8},children:(0,z.jsx)(`code`,{children:e.new_slug})}),(0,z.jsxs)(`dl`,{style:{display:`grid`,gridTemplateColumns:`80px 1fr`,gap:4,margin:`0 0 12px 0`,fontSize:11,color:`var(--text-secondary)`},children:[(0,z.jsx)(`dt`,{children:`Modality:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._new_node?.modality||`must_not`})}),(0,z.jsx)(`dt`,{children:`Polarity:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._new_node?.sentiment_polarity||`directive_must_not`})}),(0,z.jsx)(`dt`,{children:`Confidence:`}),(0,z.jsx)(`dd`,{children:e._new_node?.confidence===void 0?`N/A`:`${Math.round(e._new_node.confidence*100)}%`})]}),(0,z.jsx)(`div`,{style:{fontSize:12,fontStyle:`italic`,background:`rgba(0,0,0,0.2)`,padding:10,borderRadius:6,color:`var(--text-tertiary)`,minHeight:60,whiteSpace:`pre-wrap`},children:e._new_node?.excerpt||e._new_node?.body||`No preview content.`})]})]}),t?(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:D!==null,onClick:()=>Ae(e.conflict_id,`keep`,e.existing_slug),style:{borderColor:`rgba(255,255,255,0.1)`,fontSize:12},children:D===e.conflict_id?`Processing...`:`Keep Existing Node (${e.existing_slug})`}),(0,z.jsx)(`button`,{className:`btn btn-purple btn-sm`,disabled:D!==null,onClick:()=>Ae(e.conflict_id,`supersede`,e.new_slug),style:{fontSize:12},children:D===e.conflict_id?`Processing...`:`Supersede with New (${e.new_slug})`})]}):(0,z.jsxs)(`div`,{style:{fontSize:12,color:`#22c55e`,background:`rgba(34,197,94,0.06)`,padding:`10px 14px`,borderRadius:6,border:`1px solid rgba(34,197,94,0.15)`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,z.jsxs)(`span`,{children:[`✓ Resolved successfully. Choice: `,(0,z.jsx)(`strong`,{children:e.resolution})]}),(0,z.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[`Resolved at: `,e.resolved_at?new Date(e.resolved_at).toLocaleString():``]})]})]},e.conflict_id)})})]}),i===`sessions`&&(0,z.jsxs)(`div`,{className:`health-log`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:16},children:[(0,z.jsxs)(`h2`,{style:{margin:0,color:`#fff`,fontSize:16},children:[`📝 IDE Sessions (`,x,`)`]}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:I,style:{fontSize:12},children:`🔄 Refresh`})]}),C?(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2,3].map(e=>(0,z.jsx)(`div`,{className:`skeleton`,style:{height:56}},e))}):y.length===0?(0,z.jsxs)(`div`,{style:{textAlign:`center`,padding:40,color:`var(--text-tertiary)`},children:[(0,z.jsx)(`span`,{style:{fontSize:32,display:`block`,marginBottom:8},children:`📝`}),`No sessions ingested yet. Sessions appear here when the relay ships IDE conversation data.`]}):(0,z.jsxs)(`table`,{style:{width:`100%`,textAlign:`left`,borderCollapse:`collapse`},children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Title`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Date`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Source`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Messages`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600,width:60}})]})}),(0,z.jsx)(`tbody`,{children:y.map(e=>{let t={antigravity:`#8b5cf6`,"claude-code":`#f59e0b`,codex:`#10b981`,vscode:`#3b82f6`,cursor:`#06b6d4`,"gemini-cli":`#ec4899`}[e.source||``]||`var(--text-secondary)`;return(0,z.jsxs)(`tr`,{style:{borderBottom:`1px solid rgba(255,255,255,0.04)`},children:[(0,z.jsx)(`td`,{style:{padding:`10px 12px`,color:`#fff`,fontSize:13,maxWidth:400,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.title||e.id}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`,fontSize:12,whiteSpace:`nowrap`},children:e.date?new Date(e.date).toLocaleString():`-`}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`},children:e.source&&(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:600,textTransform:`uppercase`,padding:`2px 8px`,borderRadius:4,background:`${t}20`,color:t,border:`1px solid ${t}40`},children:e.source})}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`,fontSize:12},children:e.count}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`},children:(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>Oe(e.id),style:{fontSize:10,padding:`2px 6px`,color:`#fca5a5`,borderColor:`rgba(239,68,68,0.2)`},children:`🗑️`})})]},e.id)})})]})]})]})}var RW=Object.defineProperty,zW=Object.getOwnPropertySymbols,BW=Object.prototype.hasOwnProperty,VW=Object.prototype.propertyIsEnumerable,HW=(e,t,n)=>t in e?RW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,UW=(e,t)=>{for(var n in t||={})BW.call(t,n)&&HW(e,n,t[n]);if(zW)for(var n of zW(t))VW.call(t,n)&&HW(e,n,t[n]);return e},WW=(e,t)=>{var n={};for(var r in e)BW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&zW)for(var r of zW(e))t.indexOf(r)<0&&VW.call(e,r)&&(n[r]=e[r]);return n},GW;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(!(a>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(!(t>>>18));for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(GW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(GW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(GW||={});var KW=GW,qW={L:KW.QrCode.Ecc.LOW,M:KW.QrCode.Ecc.MEDIUM,Q:KW.QrCode.Ecc.QUARTILE,H:KW.QrCode.Ecc.HIGH},JW=128,YW=`L`,XW=`#FFFFFF`,ZW=`#000000`,QW=!1,$W=1,eG=4,tG=0,nG=.1;function rG(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function iG(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function aG(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*nG),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function oG(e,t){return t==null?e?eG:tG:Math.max(Math.floor(t),0)}function sG({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=v.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...KW.QrSegment.makeSegments(t)),e),[]);return KW.QrCode.encodeSegments(r,qW[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=v.useMemo(()=>{let e=c.getModules(),t=oG(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:aG(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var cG=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),lG=v.forwardRef(function(e,t){let n=e,{value:r,size:i=JW,level:a=YW,bgColor:o=XW,fgColor:s=ZW,includeMargin:c=QW,minVersion:l=$W,boostLevel:u,marginSize:d,imageSettings:f}=n,p=WW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=WW(p,[`style`]),g=f?.src,_=v.useRef(null),y=v.useRef(null),b=v.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=v.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=sG({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});v.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=iG(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,cG?t.fill(new Path2D(rG(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),v.useEffect(()=>{S(!1)},[g]);let D=UW({height:i,width:i},m),O=null;return g!=null&&(O=v.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),v.createElement(v.Fragment,null,v.createElement(`canvas`,UW({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});lG.displayName=`QRCodeCanvas`;var uG=v.forwardRef(function(e,t){let n=e,{value:r,size:i=JW,level:a=YW,bgColor:o=XW,fgColor:s=ZW,includeMargin:c=QW,minVersion:l=$W,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=WW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:y}=sG({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=iG(g,y.excavation)),x=v.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=rG(b,h);return v.createElement(`svg`,UW({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&v.createElement(`title`,null,d),v.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),v.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});uG.displayName=`QRCodeSVG`;function dG(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),u=async()=>{s(!0),a(null);try{let e=await R(`${Ln()}/api/pairing`);if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Pairing API error: ${e.status}`)}let n=await e.json();t(n);let i=n.preferred_url||n.endpoints?.find(e=>e.recommended)?.url||n.endpoints?.[0]?.url||``;r(i)}catch(e){console.error(e),a(e instanceof Error?e.message:`Failed to load pairing endpoints`);let n=`${window.location.protocol}//${window.location.host}`;r(n),t({port:Number(window.location.port||3e3),protocol:window.location.protocol.replace(`:`,``)||`http`,preferred_url:n,endpoints:[{kind:`browser`,label:`This browser URL (may not work on phone)`,ip:window.location.hostname,url:n,recommended:!0,reachable_hint:`Fallback when pairing API is unavailable.`}],warnings:[`Could not load live network endpoints from the brain.`],listen_hosts:[]})}finally{s(!1)}};(0,v.useEffect)(()=>{setTimeout(()=>{u()},0)},[]);let d=e?.endpoints?.find(e=>e.url===n)||null,f=d?.kind===`loopback`||n.includes(`127.0.0.1`)||n.includes(`localhost`);return(0,z.jsxs)(`div`,{className:`mobile-pairing`,"data-testid":`mobile-pairing`,style:{padding:`20px`,background:`var(--bg-secondary)`,borderRadius:`12px`,border:`1px solid var(--border)`},children:[(0,z.jsx)(`h3`,{style:{margin:`0 0 8px`},children:`Mobile Device Pairing`}),(0,z.jsxs)(`p`,{style:{color:`var(--text-tertiary)`,fontSize:`13px`,marginBottom:`16px`},children:[`Scan with your phone to open this Total Recall dashboard. Prefer `,(0,z.jsx)(`strong`,{children:`LAN`}),` on the same Wi‑Fi, or `,(0,z.jsx)(`strong`,{children:`Tailscale/mesh`}),` if the phone is on your tailnet.`]}),o&&(0,z.jsx)(`div`,{"data-testid":`pairing-loading`,style:{color:`var(--text-tertiary)`,fontSize:13},children:`Detecting reachable addresses…`}),i&&(0,z.jsxs)(`div`,{role:`alert`,"data-testid":`pairing-error`,style:{marginBottom:12,padding:10,borderRadius:8,border:`1px solid #ef4444`,color:`#ef4444`,fontSize:12},children:[i,` `,(0,z.jsx)(`button`,{type:`button`,onClick:()=>u(),style:{marginLeft:8,cursor:`pointer`},children:`Retry`})]}),!o&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:20,flexWrap:`wrap`,alignItems:`flex-start`},children:[(0,z.jsx)(`div`,{style:{background:`#fff`,padding:`16px`,borderRadius:`8px`,display:`inline-block`},"data-testid":`pairing-qr`,children:n?(0,z.jsx)(uG,{value:n,size:150,level:`M`,includeMargin:!0}):(0,z.jsx)(`div`,{style:{width:150,height:150}})}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:200},children:[e&&e.endpoints.length>0&&(0,z.jsxs)(`div`,{className:`field-col`,style:{marginBottom:12},children:[(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`pairing-endpoint`,children:`Pairing address`}),(0,z.jsx)(`select`,{id:`pairing-endpoint`,className:`settings-select`,"data-testid":`pairing-endpoint-select`,value:n,onChange:e=>r(e.target.value),style:{width:`100%`,marginTop:4},children:e.endpoints.map(e=>(0,z.jsxs)(`option`,{value:e.url,children:[e.label,e.recommended?` ★`:``,` — `,e.url]},e.url))})]}),(0,z.jsx)(`p`,{"data-testid":`pairing-url`,style:{margin:`0 0 8px`,fontSize:12,fontFamily:`var(--font-mono)`,wordBreak:`break-all`,color:`var(--text-primary)`},children:n||`—`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,marginBottom:12},children:[(0,z.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:async()=>{if(n)try{await navigator.clipboard.writeText(n),l(!0),setTimeout(()=>l(!1),2e3)}catch{a(`Clipboard copy failed — select the URL text manually.`)}},"data-testid":`pairing-copy`,children:c?`Copied`:`Copy URL`}),(0,z.jsx)(`button`,{type:`button`,className:`btn-ghost btn-sm`,onClick:()=>u(),children:`Refresh`})]}),d&&(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--text-secondary)`,margin:`0 0 10px`,lineHeight:1.5,background:`rgba(255,255,255,0.03)`,padding:`8px 12px`,borderRadius:6},children:[(0,z.jsx)(`strong`,{children:`Connection Route:`}),` `,d.reachable_hint]}),f&&(0,z.jsxs)(`div`,{"data-testid":`pairing-loopback-warning`,style:{fontSize:12,color:`#f59e0b`,margin:`0 0 8px`,background:`rgba(245, 158, 11, 0.1)`,padding:`8px 12px`,borderRadius:6,border:`1px solid rgba(245, 158, 11, 0.2)`},children:[`⚠️ `,(0,z.jsx)(`strong`,{children:`Loopback Only:`}),` `,(0,z.jsx)(`code`,{children:`127.0.0.1`}),` only works on this computer. To open on your phone, select your Mesh IP (`,(0,z.jsx)(`code`,{children:`100.64.x.x`}),`) or enable `,(0,z.jsx)(`strong`,{children:`Allow Public Bind`}),` below to use local Wi-Fi.`]})]})]}),e?.warnings&&e.warnings.length>0&&(0,z.jsxs)(`div`,{"data-testid":`pairing-warnings`,style:{margin:`16px 0 0`,padding:`10px 14px`,fontSize:12,color:`#fbbf24`,background:`rgba(251, 191, 36, 0.08)`,borderRadius:8,border:`1px solid rgba(251, 191, 36, 0.2)`},children:[(0,z.jsx)(`div`,{style:{fontWeight:600,marginBottom:4},children:`Network Notice:`}),(0,z.jsx)(`ul`,{style:{margin:0,paddingLeft:18},children:e.warnings.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}),(0,z.jsxs)(`div`,{style:{marginTop:16,padding:`12px 14px`,background:`rgba(59, 130, 246, 0.06)`,borderRadius:8,border:`1px solid rgba(59, 130, 246, 0.15)`,fontSize:12,color:`var(--text-secondary)`,lineHeight:1.5},children:[(0,z.jsx)(`div`,{style:{color:`var(--text-primary)`,fontWeight:600,marginBottom:4},children:`📱 How to connect your phone:`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:`Option A (WireGuard / Mesh — Recommended):`}),` Install the standard `,(0,z.jsx)(`em`,{children:`Tailscale`}),` app on your phone (iOS App Store / Google Play). Log into your tailnet/headscale server. Scan the `,(0,z.jsx)(`code`,{children:`100.64.x.x`}),` QR code above.`]}),(0,z.jsxs)(`div`,{style:{marginTop:4},children:[(0,z.jsx)(`strong`,{children:`Option B (Local Home Wi-Fi):`}),` Check `,(0,z.jsx)(`strong`,{children:`Allow Public Bind`}),` in `,(0,z.jsx)(`em`,{children:`Network & Binding`}),` below, restart the server, and scan your local Wi-Fi LAN QR code (e.g. `,(0,z.jsx)(`code`,{children:`192.168.x.x`}),`).`]})]})]})}async function fG(){let e=await Vn(`/api/mesh/leader`);if(!e.leader)throw Error(`No online mesh leader is available`);return e.leader}async function pG(){return(await Vn(`/api/mesh/nodes`)).nodes}async function mG(){return Vn(`/api/mesh/access/proposals`)}async function hG(){return Hn(`/api/mesh/access/import`,{})}async function gG(e){return Hn(`/api/mesh/access`,e)}async function _G(){let e=await Hn(`/api/mesh/election/refresh`,{});if(!e.leader)throw Error(`No online mesh leader is available`);return e.leader}async function vG(){return(await Vn(`/api/mesh/election/history`)).events||[]}async function yG(e){return Hn(`/api/mesh/election/log`,e)}async function bG(){return Vn(`/api/mesh/latency`)}async function xG(){return Vn(`/api/mesh/interfaces`)}async function SG(e){let t=new URLSearchParams;e?.probe===!1&&t.set(`probe`,`0`),e?.limit&&t.set(`limit`,String(e.limit));let n=t.toString();return Vn(`/api/mesh/lan${n?`?${n}`:``}`)}async function CG(){return Vn(`/api/mesh/io`)}async function wG(){return Vn(`/api/mesh/enrollment`)}async function TG(e){return Hn(`/api/mesh/enroll`,e||{})}async function EG(e){return Hn(`/api/mesh/lan/register`,{probe:e?.probe!==!1,limit:e?.limit??32})}async function DG(e){return Hn(`/api/mesh/preauthkey`,{reusable:e?.reusable===!0,ephemeral:e?.ephemeral===!0,ttlMinutes:e?.ttlMinutes})}function OG(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null);(0,v.useEffect)(()=>{pG().then(t).catch(e=>d(e?.message??`could not load nodes`))},[]),(0,v.useEffect)(()=>{if(!n)return;let e=()=>{let e=new Date(n.expiration).getTime()-Date.now();h(Math.max(0,Math.floor(e/1e3)))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[n]);let g=async()=>{l(!0),d(null),p(!1);try{r(await DG({reusable:i,ephemeral:o}))}catch(e){d(e instanceof Error?e.message:`could not mint an enrollment key`)}finally{l(!1)}},_=m!==null&&m<=0,y=n?.login_server??null,b=e.filter(e=>!e.self&&e.access_resolved?.complete!==!0);return(0,z.jsxs)(`section`,{"data-testid":`tailnet-enroll`,style:{marginTop:24},children:[(0,z.jsx)(`h3`,{style:{marginBottom:4},children:`Add a device to the tailnet`}),(0,z.jsx)(`p`,{style:{fontSize:12,opacity:.75,marginTop:0},children:`Mints a short-lived enrollment key for a phone, tablet, or another machine.`}),u&&(0,z.jsx)(`div`,{role:`alert`,"data-testid":`tailnet-enroll-error`,style:{margin:`10px 0`,padding:10,borderRadius:8,border:`1px solid #ef4444`,color:`#ef4444`,fontSize:12},children:u}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:16,alignItems:`center`,flexWrap:`wrap`,margin:`12px 0`},children:[(0,z.jsxs)(`label`,{style:{fontSize:12,display:`flex`,gap:6,alignItems:`center`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`enroll-reusable`}),`Reusable (enroll more than one device)`]}),(0,z.jsxs)(`label`,{style:{fontSize:12,display:`flex`,gap:6,alignItems:`center`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),"data-testid":`enroll-ephemeral`}),`Ephemeral (drops off the list when offline)`]}),(0,z.jsx)(`button`,{type:`button`,onClick:g,disabled:c,"data-testid":`enroll-mint`,style:{cursor:c?`wait`:`pointer`},children:c?`Minting…`:n?`Mint another key`:`Get enrollment key`})]}),n&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:20,flexWrap:`wrap`,alignItems:`flex-start`},children:[(0,z.jsx)(`div`,{style:{background:`#fff`,padding:16,borderRadius:8},"data-testid":`enroll-qr`,children:_?(0,z.jsx)(`div`,{style:{width:150,height:150,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#ef4444`,fontSize:12,textAlign:`center`},children:`Key expired — mint another`}):(0,z.jsx)(uG,{value:n.key,size:150,level:`M`,includeMargin:!0})}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:260},children:[(0,z.jsxs)(`div`,{style:{fontSize:12,marginBottom:6},children:[(0,z.jsx)(`strong`,{children:`Control server`}),(0,z.jsx)(`div`,{children:(0,z.jsx)(`code`,{"data-testid":`enroll-login-server`,children:y??`not configured`})})]}),(0,z.jsxs)(`div`,{style:{fontSize:12,marginBottom:6},children:[(0,z.jsx)(`strong`,{children:`Enrollment key`}),` `,(0,z.jsx)(`span`,{"data-testid":`enroll-ttl`,style:{opacity:.7},children:_?`(expired)`:`(expires in ${m}s, ${n.reusable?`reusable`:`single-use`})`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:4},children:[(0,z.jsx)(`code`,{style:{wordBreak:`break-all`,flex:1,opacity:_?.4:1},children:n.key}),(0,z.jsx)(`button`,{type:`button`,disabled:_,onClick:()=>{navigator.clipboard?.writeText(n.key),p(!0)},"data-testid":`enroll-copy`,children:f?`Copied`:`Copy`})]})]}),(0,z.jsxs)(`details`,{style:{fontSize:12,marginTop:10},children:[(0,z.jsx)(`summary`,{style:{cursor:`pointer`},children:`On a phone (iOS / Android)`}),(0,z.jsxs)(`ol`,{style:{paddingLeft:18,lineHeight:1.6},children:[(0,z.jsx)(`li`,{children:`Install Tailscale (iOS needs 1.38.1 or newer).`}),(0,z.jsxs)(`li`,{children:[`Account icon → `,(0,z.jsx)(`strong`,{children:`Log in`}),` → options menu → `,(0,z.jsx)(`strong`,{children:`Use custom coordination server`}),`.`]}),(0,z.jsxs)(`li`,{children:[`Enter `,(0,z.jsx)(`code`,{children:y??`your control server URL`}),`.`]}),(0,z.jsx)(`li`,{children:`Scan the QR or paste the key above when asked to authenticate.`})]}),(0,z.jsxs)(`p`,{style:{opacity:.75},children:[`If that menu does not respond (reported on some 2026 iOS builds), set the same URL under iOS Settings → Tailscale → `,(0,z.jsx)(`em`,{children:`Alternate coordination server URL`}),`.`]})]}),(0,z.jsxs)(`details`,{style:{fontSize:12,marginTop:6},children:[(0,z.jsx)(`summary`,{style:{cursor:`pointer`},children:`On a computer`}),(0,z.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:`tailscale up --login-server ${y??`<control-server>`} --authkey ${_?`<expired — mint another>`:n.key}`}),(0,z.jsxs)(`p`,{style:{opacity:.75},children:[`Always pass `,(0,z.jsx)(`code`,{children:`--login-server`}),` alongside any `,(0,z.jsx)(`code`,{children:`--reset`}),`, or the client silently repoints at the public Tailscale control plane.`]})]})]})]}),(0,z.jsxs)(`div`,{style:{marginTop:20},children:[(0,z.jsxs)(`h4`,{style:{marginBottom:6},children:[`Nodes (`,e.length,`)`]}),(0,z.jsx)(`ul`,{"data-testid":`enroll-node-list`,style:{listStyle:`none`,padding:0,fontSize:12,margin:0},children:e.map(e=>(0,z.jsxs)(`li`,{style:{padding:`4px 0`,display:`flex`,gap:8},children:[(0,z.jsx)(`span`,{title:e.online?`online`:`offline`,children:e.online?`🟢`:`⚪️`}),(0,z.jsx)(`strong`,{children:e.hostname}),(0,z.jsx)(`code`,{style:{opacity:.75},children:e.ip??`—`}),e.self&&(0,z.jsx)(`span`,{style:{opacity:.6},children:`(this host)`})]},`${e.hostname}-${e.ip??`noip`}`))}),b.length>0&&(0,z.jsxs)(`p`,{"data-testid":`enroll-access-warning`,style:{fontSize:12,color:`#f59e0b`,marginBottom:0},children:[b.length,` node(s) have no recorded login account — connecting to one fails as though it were unreachable. Run `,(0,z.jsx)(`code`,{children:`total-recall mesh access import`}),`.`]})]})]})}function kG(e){let t={...e};return t.security||={},t.security.dashboard||(t.security.dashboard={}),t.security.api||(t.security.api={}),t.security.network||(t.security.network={}),t.security.bind||(t.security.bind={}),t.security.rate_limits||(t.security.rate_limits={}),t.security.sandbox||(t.security.sandbox={}),t.security.privacy||(t.security.privacy={}),t.budget||={budget:{}},t.budget.budget||(t.budget.budget={}),t.brain||={},t.secrets||={},t}function AG({activeBrainId:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(`idle`),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),O=async()=>{D(!0),C(null);try{let e=await ni();if(C(e.message),e.scheduled){setTimeout(function e(t=0){Yr().then(e=>{f(e),C(`Server restarted — reconnected.`),D(!1)}).catch(()=>{if(t>=20){C(`Server restarted but has not answered yet — reload in a moment.`),D(!1);return}setTimeout(()=>e(t+1),1500)})},2e3);return}}catch(e){C(`Restart error: `+e.message)}D(!1)},k=async()=>{T(!0),C(null);try{let e=await ti();C(e.message||`Daemon restarted successfully.`);let t=await Yr().catch(()=>null);t&&f(t)}catch(e){C(`Restart error: `+e.message)}finally{T(!1)}},[A,j]=(0,v.useState)(!1),ee=async()=>{o(!0),i(null);try{let e=await yi();n(kG(e))}catch(e){console.error(e),i(e instanceof Error?e.message:`Failed to load settings`),n(null)}finally{o(!1)}};(0,v.useEffect)(()=>{Yr().then(f).catch(console.error),oi().then(e=>y({updateAvailable:!!e.updateAvailable,latestVersion:e.latestVersion,currentVersion:e.currentVersion})).catch(console.error),setTimeout(()=>{ee()},0)},[e]);let M=[{id:`antigravity`,name:`Antigravity (Gemini SDK)`,desc:`Primary core developer agent`},{id:`gemini`,name:`Gemini CLI`,desc:`Direct Gemini assistant binary`},{id:`claude`,name:`Claude Code`,desc:`Anthropic developer CLI wrapper`},{id:`codex`,name:`Codex CLI`,desc:`OpenAI agent binary integration`},{id:`grok`,name:`Grok CLI`,desc:`xAI developer binary integration`}],te=Array.isArray(d?.cli_agents)?d.cli_agents:Array.isArray(d?.agents)?d.agents:[],ne=async e=>{e.preventDefault(),m(!0),g(null);try{let e=await ei();g(e.output),Yr().then(f).catch(console.error)}catch(e){g(`Error: `+e.message)}finally{m(!1)}},N=async()=>{x(!0),C(null);try{let e=await si();if(e.success){let t=e.summary,n=[t?.updated==null?null:`${t.updated} updated`,t?.up_to_date==null?null:`${t.up_to_date} current`,t?.latest?`latest ${t.latest}`:null].filter(Boolean),r=e.restart?.scheduled?` Server is restarting into the new code.`:e.restart?.required?` Server still runs the old code — ${e.restart.reason}`:``;C(n.length?`Update complete — ${n.join(` · `)}.${r}`:(e.message||`Update complete.`)+r)}else{let t=(e.summary?.results||[]).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.error||`failed`}`).slice(0,3).join(`; `);C(`Update failed: ${e.message}${t?` (${t})`:``}`)}let t=await oi().catch(()=>null);t&&y({updateAvailable:!!t.updateAvailable,latestVersion:t.latestVersion,currentVersion:t.currentVersion})}catch(e){C(`Update error: `+e.message)}finally{x(!1)}},P=async()=>{if(t){c(`saving`);try{let e={...t};if(e.secrets){let t={};for(let[n,r]of Object.entries(e.secrets))typeof r==`string`&&r&&!r.includes(`•`)&&r!==`[redacted]`&&(t[n]=r);e.secrets=t}await bi(e),c(`saved`),setTimeout(()=>c(`idle`),2500)}catch(e){console.error(e),c(`error`),setTimeout(()=>c(`idle`),3e3)}}},re=async()=>{j(!0),u(`[Running] Rebuilding instruction surfaces…`);try{let e=await $r();u(`[Finished] Rebuilding instruction surfaces\n\n${e.message||(e.success?`Compile complete.`:`Compile finished with warnings.`)}`)}catch(e){u(`[Failed] Rebuild\n\n${e instanceof Error?e.message:String(e)}`)}finally{j(!1)}},ie=async()=>{try{let e=await R(`${Ln()}/api/extension/download`);if(!e.ok)throw Error(`Download failed: ${e.status}`);let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`total-recall-extension.zip`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}catch(e){u(`[Failed] Extension download\n\n${e instanceof Error?e.message:String(e)}`)}},ae=(e,t,r)=>{n(n=>n&&{...n,security:{...n.security,[e]:{...n.security[e]||{},[t]:r}}})},oe=(e,t)=>{n(n=>n&&{...n,budget:{...n.budget,budget:{...n.budget.budget||{},[e]:t}}})},se=(e,t)=>{n(n=>n?{...n,brain:{...n.brain,[e]:t}}:null)},ce=e=>Array.isArray(e)?e.filter(Boolean).join(`, `):``,le=e=>e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return a&&!t?(0,z.jsx)(`div`,{style:{padding:40,color:`var(--text-secondary)`},"data-testid":`settings-loading`,children:(0,z.jsx)(`div`,{className:`glass-card`,style:{display:`inline-block`,padding:`12px 24px`},children:`Loading Settings...`})}):r&&!t?(0,z.jsx)(`div`,{style:{padding:40},"data-testid":`settings-error`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`glass-card`,style:{display:`inline-block`,padding:`16px 24px`,border:`1px solid #ef4444`,color:`#ef4444`},children:[`Failed to load settings: `,r,(0,z.jsx)(`button`,{type:`button`,className:`btn-primary`,style:{marginLeft:16},onClick:()=>ee(),children:`Retry`})]})}):t?(0,z.jsxs)(`div`,{className:`settings-page-wrapper`,"data-testid":`settings-page`,children:[(0,z.jsx)(`style`,{children:`
|
|
5247
|
+
</div>`,enableNodeDrag:o,enableNavigationControls:o,onNodeClick:g,onNodeHover:e=>{f(e||null),c.current&&(c.current.style.cursor=e?`pointer`:`default`)},linkColor:y,linkWidth:e=>e.type===`implicit`?.5:1.5,linkDirectionalParticles:e=>e.type===`implicit`?0:2,linkDirectionalParticleWidth:1.5,linkDirectionalParticleSpeed:.005,backgroundColor:`rgba(0,0,0,0)`,d3VelocityDecay:.3}),(0,z.jsxs)(`div`,{style:{position:`absolute`,top:20,left:20,zIndex:30,pointerEvents:`none`},children:[(0,z.jsx)(`h3`,{style:{margin:0,fontSize:20,color:`#f8fafc`,fontWeight:600,letterSpacing:`-0.02em`,textShadow:`0 2px 10px rgba(0,0,0,0.5)`},children:`Constellation`}),(0,z.jsx)(`p`,{style:{margin:`2px 0 0`,fontSize:12,color:`rgba(148,163,184,0.9)`,textShadow:`0 1px 4px rgba(0,0,0,0.5)`},children:`Interactive Knowledge Network`})]}),o&&(0,z.jsxs)(`div`,{style:{position:`absolute`,top:80,left:20,display:`flex`,flexDirection:`column`,gap:12,background:`rgba(15, 20, 35, 0.4)`,backdropFilter:`blur(24px)`,WebkitBackdropFilter:`blur(24px)`,padding:`16px 20px`,borderRadius:16,border:`1px solid rgba(255, 255, 255, 0.08)`,boxShadow:`0 12px 40px rgba(0,0,0,0.3)`,width:240,zIndex:60,pointerEvents:`auto`,transition:`all 0.3s ease`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:700,color:`#cbd5e1`,textTransform:`uppercase`,letterSpacing:1.2},children:`Filters`}),(0,z.jsxs)(`span`,{style:{fontSize:10,background:`rgba(255,255,255,0.06)`,padding:`2px 6px`,borderRadius:6,color:`#94a3b8`},children:[h.nodes.length,` items`]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.research,onChange:()=>m(e=>({...e,research:!e.research})),style:{accentColor:`#fbbf24`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#fbbf24`,boxShadow:`0 0 8px rgba(251,191,36,0.6)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Research`})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.observations,onChange:()=>m(e=>({...e,observations:!e.observations})),style:{accentColor:`#60a5fa`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#60a5fa`,boxShadow:`0 0 8px rgba(96,165,250,0.6)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Memory`})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.rules,onChange:()=>m(e=>({...e,rules:!e.rules})),style:{accentColor:`#38bdf8`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`linear-gradient(135deg,#38bdf8,#f87171)`,boxShadow:`0 0 8px rgba(56,189,248,0.5)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Rules`})]}),(0,z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:12,color:`#e2e8f0`,cursor:`pointer`,userSelect:`none`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.threads,onChange:()=>m(e=>({...e,threads:!e.threads})),style:{accentColor:`#22d3ee`,cursor:`pointer`}}),(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#22d3ee`,boxShadow:`0 0 8px rgba(34,211,238,0.6)`}}),(0,z.jsx)(`span`,{style:{flex:1},children:`Sessions`})]})]})]})]})}function AW({onTranscript:e,isRecording:t=!1}){let[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!0);return(0,v.useEffect)(()=>{if(typeof window<`u`){let t=window,n=t.SpeechRecognition||t.webkitSpeechRecognition;n?(i.current=new n,i.current.continuous=!1,i.current.interimResults=!1,i.current.onresult=t=>{let n=t.results[0][0].transcript;e(n),r(!1)},i.current.onerror=()=>{r(!1)},i.current.onend=()=>{r(!1)}):setTimeout(()=>o(!1),0)}},[e]),a?(0,z.jsx)(`button`,{onClick:()=>{a&&(n?(i.current?.stop(),r(!1)):(i.current?.start(),r(!0)))},className:`btn btn-ghost ${n?`active`:``}`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,background:n?`var(--error-muted)`:`rgba(148, 163, 184, 0.06)`,border:n?`1px solid var(--error)`:`1px solid var(--border)`,color:n?`var(--error)`:`var(--text-tertiary)`,transition:`all var(--transition-fast)`},title:n?`Stop recording`:`Start voice input`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`})]})}):(0,z.jsx)(`button`,{disabled:!0,className:`btn btn-ghost`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,background:`rgba(148, 163, 184, 0.03)`,border:`1px solid var(--border)`,color:`var(--text-tertiary)`,opacity:.5,cursor:`not-allowed`},title:`Voice input not supported`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`})]})})}var jW=0;function MW(){return Date.now()}function NW(e){let t=MW()-e;if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function PW({activeBrainId:e,onBrainChange:t}){let n=dt(),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(null),f=(0,v.useRef)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(()=>localStorage.getItem(`tr-ext-banner-dismissed`)===`true`),[A,j]=(0,v.useState)(()=>localStorage.getItem(`tr-update-banner-dismissed-version`)),[ee,M]=(0,v.useState)([]),[te,ne]=(0,v.useState)(void 0),[N,P]=(0,v.useState)([]),[re,ie]=(0,v.useState)([]),[ae,oe]=(0,v.useState)([]),[se,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(``),de=(0,v.useRef)(null),[fe,pe]=(0,v.useState)([]),[me,he]=(0,v.useState)(()=>{let e=localStorage.getItem(`selectedModel`);return e&&e!==`gemini`?e:`antigravity`}),[ge,_e]=(0,v.useState)(()=>localStorage.getItem(`selectedSubModel`)||``),[ve,ye]=(0,v.useState)([]),[be,xe]=(0,v.useState)(!1),Se=(0,v.useRef)(null),F=(0,v.useCallback)(()=>{l.current?.scrollIntoView({behavior:`smooth`})},[]);(0,v.useEffect)(F,[r,F]);let Ce=(0,v.useCallback)(()=>{Qn().then(e=>{M(e)}).catch(console.error),Gr().then(e=>oe(e.items||[])).catch(console.error)},[]);(0,v.useEffect)(()=>{Qn().then(e=>{M(e),e.length>0&&(ne(e[0].id),e[0].brainId&&t&&t(e[0].brainId))}).catch(console.error),Gr().then(e=>oe(e.items||[])).catch(console.error),Yr().then(e=>{let t=e.cli_agents&&e.cli_agents.length>0?e.cli_agents:[`antigravity`,`grok`,`claude`,`codex`];pe(t);let n=localStorage.getItem(`selectedModel`);if(n&&t.includes(n))he(n);else{let e=t.includes(`antigravity`)?`antigravity`:t.includes(`grok`)?`grok`:t[0];he(e),localStorage.setItem(`selectedModel`,e)}}).catch(()=>{let e=[`antigravity`,`grok`,`claude`,`codex`];pe(e);let t=localStorage.getItem(`selectedModel`);t&&e.includes(t)?he(t):(he(`antigravity`),localStorage.setItem(`selectedModel`,`antigravity`))}),ci().then(e=>{if(ye(e),e&&e.length>0){let t=localStorage.getItem(`selectedSubModel`),n=e.some(e=>e.id===t);t&&n?_e(t):(_e(e[0].id),localStorage.setItem(`selectedSubModel`,e[0].id))}}).catch(console.error)},[]),(0,v.useEffect)(()=>{let e=!0,t=()=>{oi().then(t=>{e&&y(t)}).catch(console.error)};t();let n=setInterval(t,36e5);return()=>{e=!1,clearInterval(n)}},[]),(0,v.useEffect)(()=>{let t=!0,n=()=>{nr(e).then(e=>{t&&(ie(e),P(t=>t.filter(t=>e.some(e=>e.slug===t))))}).catch(console.error)};n();let r=new EventSource(`http://localhost:9111/stream`);return r.onmessage=e=>{if(t)try{let t=JSON.parse(e.data);(t.sender===`conflict-detector`||t.sender===`memory-ingestion`||t.message?.includes(`Surface compilation`)||t.message?.includes(`Brain embeddings rebuilt`)||t.message?.includes(`Graph indices rebuilt`)||t.message?.includes(`deleted`))&&n()}catch{}},()=>{t=!1,r.close()}},[e]),(0,v.useEffect)(()=>{function e(e){de.current&&!de.current.contains(e.target)&&ce(!1),Se.current&&!Se.current.contains(e.target)&&xe(!1)}return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[de,Se]),(0,v.useEffect)(()=>{Zn(te).then(e=>{e?(i(e),jW=Math.max(jW,e.length+1)):i([])}).catch(e=>{console.error(e),i([])})},[te]),(0,v.useEffect)(()=>{!p||h!==null||er().then(e=>g(e.enabled)).catch(()=>g(!1))},[p,h]),(0,v.useEffect)(()=>{O||mi().then(D).catch(()=>{})},[O]);let we=e=>{if(!(`speechSynthesis`in window))return;window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);t.rate=1.05,t.pitch=.95,window.speechSynthesis.speak(t)},Te=async e=>{if(!(!p||!e.trim())){if(h===!1){we(e);return}try{let t=await tr(e);if(!t){g(!1),we(e);return}let n=URL.createObjectURL(t);f.current&&(f.current.pause(),URL.revokeObjectURL(f.current.src));let r=new Audio(n);f.current=r,r.onended=()=>URL.revokeObjectURL(n),r.play().catch(()=>we(e))}catch{we(e)}}},Ee=()=>{let e=`thread-${MW()}`;ne(e),i([]),o(``),P([]),u.current&&(u.current.style.height=`44px`)},De=async(e,t)=>{if(e.stopPropagation(),confirm(`Are you sure you want to delete this conversation thread?`))try{if(await $n(t),te===t){let e=ee.filter(e=>e.id!==t);e.length>0?ne(e[0].id):(ne(void 0),i([]))}Ce()}catch(e){console.error(`Failed to delete thread:`,e)}},I=async()=>{let t=a.trim();if(!t||s)return;let n=te||`thread-${MW()}`;te||ne(n);let l={id:String(++jW),role:`user`,content:t,timestamp:MW()};i(e=>[...e,l]),o(``),c(!0),d.current=new AbortController,u.current&&(u.current.style.height=`44px`);try{if(b){i(e=>[...e,{id:String(++jW),role:`assistant`,content:`🕵️ **Deep Research Agents dispatched.** Gathering facts across parallel web streams...`,timestamp:MW()}]);let{slug:e}=await ii(`proactive-research`,t,t),n=!1;for(;!n;){await new Promise(e=>setTimeout(e,2e3));let t=(await ri()).find(t=>t.slug===e);t&&(t.status===`completed`||t.status===`failed`)&&(n=!0,i(e=>e.filter(e=>e.content!==`🕵️ **Deep Research Agents dispatched.** Gathering facts across parallel web streams...`)),i(e=>[...e,{id:String(++jW),role:`assistant`,content:t.body||``,timestamp:MW()}]),Te(t.body||``))}c(!1);return}let a=[`gemini`,`antigravity`].includes(me)&&ge?`${me}:${ge}`:me,o=await Xn([...r,l].map(e=>({role:e.role,content:e.content})),d.current.signal,n,N,a,e),s={id:String(++jW),role:`assistant`,content:o,timestamp:MW(),versions:[o],currentVersionIndex:0};i(e=>[...e,s]),Te(o),Ce()}catch(e){if(e.name===`AbortError`)i(e=>[...e,{id:String(++jW),role:`assistant`,content:`⛔ Generation stopped by user.`,timestamp:MW(),versions:[`⛔ Generation stopped by user.`],currentVersionIndex:0}]);else{let t={id:String(++jW),role:`assistant`,content:`⚠️ Error: ${e.message}`,timestamp:MW(),versions:[`⚠️ Error: ${e.message}`],currentVersionIndex:0};i(e=>[...e,t])}}finally{c(!1),d.current=null}},Oe=async t=>{if(s)return;let n=r.slice(0,t).map(e=>({role:e.role,content:e.content}));c(!0),d.current=new AbortController;try{let r=[`gemini`,`antigravity`].includes(me)&&ge?`${me}:${ge}`:me,a=await Xn(n,d.current.signal,te,void 0,r,e);i(e=>{let n=[...e],r=n[t],i=r.versions||[r.content];return i.push(a),r.versions=i,r.currentVersionIndex=i.length-1,r.content=a,n}),Te(a),Ce()}catch(e){e.name!==`AbortError`&&console.error(e)}finally{c(!1),d.current=null}},ke=e=>{navigator.clipboard.writeText(e).catch(console.error)},Ae=(e,t)=>{i(n=>{let r=[...n],i=r[e];if(!i.versions)return n;let a=Math.max(0,Math.min(i.versions.length-1,(i.currentVersionIndex||0)+t));return i.currentVersionIndex=a,i.content=i.versions[a],r})},je=()=>{d.current&&(d.current.abort(),d.current=null,c(!1))},Me=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),I())},Ne=e=>{let t=e.target.value;o(t);let n=e.target;n.style.height=`44px`,n.style.height=Math.min(n.scrollHeight,160)+`px`;let r=t.match(/https?:\/\/[^\s]+/);C(r?r[0]:null)},Pe=async e=>{if(S)try{await ai({url:S,action:e}),T(`✅ URL sent to ${e}`),C(null),setTimeout(()=>T(null),3e3)}catch(e){console.error(`Share API error:`,e),T(`⚠️ Failed to process URL`),setTimeout(()=>T(null),3e3)}},Fe=re.filter(e=>e.title.toLowerCase().includes(le.toLowerCase())||e.slug.toLowerCase().includes(le.toLowerCase())||e.category&&e.category.toLowerCase().includes(le.toLowerCase()));return(0,z.jsxs)(`div`,{className:`chat-layout`,children:[(0,z.jsxs)(`aside`,{className:`chat-threads-sidebar`,children:[(0,z.jsx)(`div`,{className:`sidebar-header`,children:(0,z.jsxs)(`button`,{className:`new-chat-btn`,onClick:Ee,children:[(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginRight:6},children:[(0,z.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,z.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),`New Chat`]})}),(0,z.jsx)(`div`,{className:`thread-list`,children:ee.map(e=>(0,z.jsxs)(`div`,{className:`thread-item ${te===e.id?`active`:``}`,onClick:()=>{ne(e.id),e.brainId&&t&&t(e.brainId)},children:[(0,z.jsxs)(`div`,{className:`thread-info`,children:[(0,z.jsx)(`div`,{className:`thread-title`,title:e.title,children:e.title}),(0,z.jsxs)(`div`,{className:`thread-meta`,children:[(0,z.jsxs)(`span`,{children:[e.turns,` `,e.turns===1?`turn`:`turns`]}),(0,z.jsx)(`span`,{children:`•`}),(0,z.jsx)(`span`,{children:NW(e.lastUpdated)})]})]}),(0,z.jsx)(`button`,{className:`thread-delete-btn`,onClick:t=>De(t,e.id),title:`Delete chat thread`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,z.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,z.jsx)(`line`,{x1:`10`,y1:`11`,x2:`10`,y2:`17`}),(0,z.jsx)(`line`,{x1:`14`,y1:`11`,x2:`14`,y2:`17`})]})})]},e.id))})]}),(0,z.jsxs)(`div`,{className:`chat-container`,style:{position:`relative`,overflow:`hidden`},children:[(0,z.jsx)(`div`,{"aria-hidden":!0,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,zIndex:0,pointerEvents:`none`,opacity:r.length>0?.22:.55,transition:`opacity 0.3s ease`},children:(0,z.jsx)(kW,{threads:ee,memoryNodes:re,researchItems:ae,onOpenThread:()=>{},onGroundMemoryNode:()=>{},selectedGroundingNodes:N,interactive:!1})}),(0,z.jsxs)(`header`,{className:`chat-header animate-fade-in`,style:{position:`relative`,zIndex:40,overflow:`visible`},children:[(0,z.jsxs)(`div`,{className:`chat-header-title`,children:[(0,z.jsx)(`h2`,{children:`Chat Session`}),te&&(0,z.jsx)(`span`,{className:`badge badge-accent`,style:{textTransform:`none`,letterSpacing:`normal`,fontSize:`11px`,padding:`2px 8px`},children:te})]}),(0,z.jsxs)(`div`,{className:`chat-header-model-selector`,ref:Se,style:{position:`relative`,zIndex:50},children:[(0,z.jsx)(`span`,{className:`selector-label`,children:`Model / provider:`}),(0,z.jsxs)(`div`,{className:`model-selector-dropdown-wrapper`,style:{position:`relative`,zIndex:50},children:[(0,z.jsxs)(`button`,{type:`button`,className:`model-selector-dropdown-btn ${be?`active`:``}`,onClick:e=>{e.stopPropagation(),xe(e=>!e)},title:`Select CLI agent / provider`,children:[(0,z.jsx)(`span`,{style:{textTransform:`capitalize`},children:me||`Select Model`}),(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,z.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),be&&(0,z.jsx)(`div`,{className:`model-selector-menu glass`,style:{zIndex:200,pointerEvents:`auto`},role:`listbox`,children:fe.map(e=>(0,z.jsxs)(`div`,{role:`option`,"aria-selected":me===e,className:`model-selector-item ${me===e?`selected`:``}`,onClick:t=>{t.stopPropagation(),he(e),localStorage.setItem(`selectedModel`,e),_e(``),localStorage.removeItem(`selectedSubModel`),xe(!1)},children:[(0,z.jsxs)(`div`,{className:`model-selector-item-info`,children:[(0,z.jsx)(`span`,{className:`model-selector-item-name`,style:{textTransform:`capitalize`},children:e}),(0,z.jsxs)(`span`,{className:`model-selector-item-desc`,children:[e===`antigravity`&&`Google Antigravity`,e===`grok`&&`xAI Grok Build CLI`,e===`gemini`&&`Google Gemini CLI`,e===`claude`&&`Anthropic Claude CLI`,e===`codex`&&`Codex Coding Agent`]})]}),(0,z.jsx)(`span`,{className:`model-selector-item-badge`,children:`CLI`})]},e))})]}),[`gemini`,`antigravity`].includes(me)&&ve.length>0&&(0,z.jsxs)(`div`,{className:`chat-header-submodel-selector`,style:{display:`flex`,alignItems:`center`,gap:8,marginLeft:16},children:[(0,z.jsx)(`span`,{className:`selector-label`,style:{fontSize:`12px`,color:`var(--text-tertiary)`,fontWeight:500},children:`Base:`}),(0,z.jsx)(`select`,{value:ge,onChange:e=>{_e(e.target.value),localStorage.setItem(`selectedSubModel`,e.target.value)},className:`submodel-select`,style:{background:`rgba(255, 255, 255, 0.04)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,color:`var(--text-secondary)`,padding:`6px 12px`,fontSize:`13px`,fontWeight:500,outline:`none`,cursor:`pointer`,transition:`all var(--transition-fast)`},children:ve.map(e=>(0,z.jsx)(`option`,{value:e.id,style:{background:`#12121a`,color:`var(--text-secondary)`},children:e.displayName},e.id))})]})]})]}),_?.updateAvailable&&A!==_.latestVersion&&(0,z.jsxs)(`div`,{className:`animate-fade-in`,style:{margin:`0 16px 12px`,padding:`12px 16px`,background:`linear-gradient(135deg, rgba(63, 185, 80, 0.12), rgba(34, 197, 94, 0.12))`,border:`1px solid rgba(63, 185, 80, 0.3)`,borderRadius:10,display:`flex`,alignItems:`center`,gap:12,position:`relative`,zIndex:40},children:[(0,z.jsx)(`span`,{style:{fontSize:22,flexShrink:0},children:`🚀`}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text-primary)`,marginBottom:2},children:`System Update Available`}),(0,z.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-secondary)`},children:[`Version `,_.latestVersion,` is available. Upgrade to load the latest features.`]})]}),(0,z.jsx)(`button`,{onClick:()=>n(`/health`),style:{flexShrink:0,padding:`6px 14px`,background:`#3fb950`,color:`#fff`,border:`none`,borderRadius:6,fontWeight:600,fontSize:12,cursor:`pointer`,whiteSpace:`nowrap`},children:`Go to Update`}),(0,z.jsx)(`button`,{onClick:()=>{_?.latestVersion&&(localStorage.setItem(`tr-update-banner-dismissed-version`,_.latestVersion),j(_.latestVersion))},title:`Dismiss banner`,"aria-label":`Dismiss update banner`,style:{background:`transparent`,border:`none`,color:`var(--text-muted)`,fontSize:16,cursor:`pointer`,padding:`4px 6px`,lineHeight:1},children:`✕`})]}),E?.available&&!E.connected&&!O&&(0,z.jsxs)(`div`,{style:{margin:`0 16px 0`,padding:`12px 16px`,background:`linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(99, 179, 237, 0.12))`,border:`1px solid rgba(108, 92, 231, 0.3)`,borderRadius:10,display:`flex`,alignItems:`center`,gap:12,animation:`fadeIn 0.3s ease`,position:`relative`,zIndex:40},children:[(0,z.jsx)(`span`,{style:{fontSize:22,flexShrink:0},children:`🧩`}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text-primary)`,marginBottom:2},children:`Chrome Extension Available`}),(0,z.jsx)(`div`,{style:{fontSize:11,color:`var(--text-secondary)`},children:`Browse with your brain — contextual memory, quick capture, and research from any page`})]}),(0,z.jsx)(`a`,{href:`/api/extension/download`,download:!0,style:{flexShrink:0,padding:`6px 14px`,background:`linear-gradient(135deg, #3b82f6, #93c5fd)`,color:`#fff`,borderRadius:6,fontWeight:500,fontSize:12,textDecoration:`none`,whiteSpace:`nowrap`},children:`⬇ Download`}),(0,z.jsx)(`button`,{onClick:()=>{k(!0),localStorage.setItem(`tr-ext-banner-dismissed`,`true`)},style:{flexShrink:0,background:`none`,border:`none`,color:`var(--text-tertiary)`,cursor:`pointer`,fontSize:16,padding:`0 2px`,lineHeight:1},title:`Dismiss`,children:`✕`})]}),(0,z.jsx)(`div`,{className:`chat-messages`,style:{position:`relative`,zIndex:1,pointerEvents:`auto`},children:(0,z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,flexDirection:`column`,gap:`16px`,width:`100%`,maxWidth:800,margin:`0 auto`,pointerEvents:`auto`},children:[r.map((e,t)=>(0,z.jsxs)(`div`,{className:`message message-${e.role}`,style:{backdropFilter:`blur(8px)`,WebkitBackdropFilter:`blur(8px)`,background:e.role===`user`?`rgba(108, 92, 231, 0.75)`:`rgba(18, 18, 26, 0.75)`,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,z.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`break-word`},children:e.content}),e.role===`assistant`&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:12,marginTop:12,fontSize:13,color:`var(--text-tertiary)`,alignItems:`center`,userSelect:`none`},children:[e.versions&&e.versions.length>1&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`,marginRight:4},children:[(0,z.jsx)(`button`,{onClick:()=>Ae(t,-1),disabled:(e.currentVersionIndex||0)===0,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:2,opacity:(e.currentVersionIndex||0)===0?.3:1},children:`◄`}),(0,z.jsxs)(`span`,{children:[(e.currentVersionIndex||0)+1,` / `,e.versions.length]}),(0,z.jsx)(`button`,{onClick:()=>Ae(t,1),disabled:(e.currentVersionIndex||0)===e.versions.length-1,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:2,opacity:(e.currentVersionIndex||0)===e.versions.length-1?.3:1},children:`►`})]}),(0,z.jsx)(`button`,{onClick:()=>ke(e.content),title:`Copy to clipboard`,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4},children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,z.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),(0,z.jsx)(`button`,{onClick:()=>Te(e.content),title:`Read Aloud`,style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4},children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),(0,z.jsx)(`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07`})]})}),(0,z.jsx)(`button`,{onClick:()=>Oe(t),disabled:s,title:`Regenerate Response`,style:{background:`none`,border:`none`,color:`inherit`,cursor:s?`default`:`pointer`,display:`flex`,alignItems:`center`,gap:4,opacity:s?.3:1},children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`polyline`,{points:`1 4 1 10 7 10`}),(0,z.jsx)(`polyline`,{points:`23 20 23 14 17 14`}),(0,z.jsx)(`path`,{d:`M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15`})]})})]})]},e.id)),s&&(0,z.jsx)(`div`,{className:`message message-assistant`,style:{backdropFilter:`blur(8px)`,WebkitBackdropFilter:`blur(8px)`,background:`rgba(18, 18, 26, 0.75)`,border:`1px solid rgba(255, 255, 255, 0.08)`},children:(0,z.jsx)(`span`,{className:`skeleton`,style:{display:`inline-block`,width:180,height:16}})}),(0,z.jsx)(`div`,{ref:l})]})}),(0,z.jsxs)(`div`,{className:`chat-input-bar`,style:{position:`relative`,zIndex:30,pointerEvents:`auto`},children:[N.length>0&&(0,z.jsx)(`div`,{className:`grounding-pills`,children:N.map(e=>{let t=re.find(t=>t.slug===e);return(0,z.jsxs)(`div`,{className:`grounding-pill animate-fade-in`,children:[(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,z.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),(0,z.jsx)(`span`,{className:`grounding-pill-title`,children:t?.title||e}),(0,z.jsx)(`button`,{className:`grounding-pill-remove`,onClick:()=>P(t=>t.filter(t=>t!==e)),title:`Remove grounding context`,children:`×`})]},e)})}),(0,z.jsxs)(`div`,{className:`chat-input-wrapper`,children:[(0,z.jsx)(`button`,{className:`btn btn-ghost ${b?`active`:``}`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,color:b?`var(--accent)`:`var(--text-tertiary)`,borderColor:b?`var(--accent)`:`var(--border)`},onClick:()=>x(!b),title:b?`Deep Research On`:`Deep Research Off`,children:(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`path`,{d:`M12 2v20`}),(0,z.jsx)(`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`})]})}),(0,z.jsxs)(`div`,{style:{position:`relative`,display:`flex`},ref:de,children:[(0,z.jsxs)(`button`,{className:`btn btn-ghost ${N.length>0?`active`:``}`,style:{width:44,height:44,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,color:N.length>0?`var(--accent)`:`var(--text-tertiary)`,borderColor:N.length>0?`var(--accent)`:`var(--border)`},onClick:()=>ce(!se),title:`Ground with brain nodes`,children:[(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,z.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),N.length>0&&(0,z.jsx)(`span`,{className:`grounding-count-badge`,children:N.length})]}),se&&(0,z.jsxs)(`div`,{className:`node-selector-popover glass`,children:[(0,z.jsxs)(`div`,{className:`node-selector-header`,children:[(0,z.jsx)(`h4`,{children:`Ground with Brain Nodes`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`Search nodes...`,value:le,onChange:e=>ue(e.target.value),className:`node-search-input`,autoFocus:!0})]}),(0,z.jsx)(`div`,{className:`node-selector-list`,children:Fe.length===0?(0,z.jsx)(`div`,{className:`node-selector-empty`,children:`No nodes found`}):Fe.map(e=>{let t=N.includes(e.slug);return(0,z.jsxs)(`div`,{className:`node-selector-item ${t?`selected`:``}`,onClick:()=>{P(t?t=>t.filter(t=>t!==e.slug):t=>[...t,e.slug])},children:[(0,z.jsx)(`span`,{className:`node-selector-item-checkbox`,children:t?`✓`:``}),(0,z.jsxs)(`div`,{className:`node-selector-item-info`,children:[(0,z.jsx)(`span`,{className:`node-selector-item-title`,children:e.title}),(0,z.jsxs)(`span`,{className:`node-selector-item-meta`,children:[e.category,` • `,e.status||`active`]})]})]},e.slug)})})]})]}),(0,z.jsx)(AW,{onTranscript:e=>{o(t=>t+(t.endsWith(` `)||t===``?``:` `)+e),setTimeout(()=>{if(u.current){u.current.focus();let e=new Event(`input`,{bubbles:!0});u.current.dispatchEvent(e)}},10)}}),(0,z.jsxs)(`div`,{style:{position:`relative`,flex:1,display:`flex`,alignItems:`center`},children:[(0,z.jsx)(`textarea`,{ref:u,id:`chat-input`,value:a,onChange:Ne,onKeyDown:Me,placeholder:`Message your brain…`,rows:1,disabled:s,style:{paddingRight:44}}),(0,z.jsx)(`button`,{className:`btn btn-ghost ${p?`active`:``}`,style:{position:`absolute`,right:4,bottom:4,width:36,height:36,padding:0,display:`flex`,justifyContent:`center`,alignItems:`center`,color:p?`#ef4444`:`var(--text-tertiary)`,border:`none`,background:`transparent`},onClick:()=>{m(!p),p&&`speechSynthesis`in window&&window.speechSynthesis.cancel()},title:p?`Voice Mode On`:`Voice Mode Off`,children:p?(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}),(0,z.jsx)(`line`,{x1:`8`,x2:`16`,y1:`22`,y2:`22`})]}):(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{width:18,height:18},children:[(0,z.jsx)(`line`,{x1:`1`,x2:`23`,y1:`1`,y2:`23`}),(0,z.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V5a3 3 0 0 0-5.94-.88`}),(0,z.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-1.39 4.2M5 10v2a7 7 0 0 0 1.93 4.88`}),(0,z.jsx)(`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}),(0,z.jsx)(`line`,{x1:`8`,x2:`16`,y1:`22`,y2:`22`})]})})]}),s?(0,z.jsx)(`button`,{className:`chat-send-btn`,onClick:je,id:`chat-stop`,style:{background:`var(--error)`,color:`#fff`},title:`Stop Generation`,children:(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,style:{width:20,height:20},children:(0,z.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`,ry:`2`})})}):(0,z.jsx)(`button`,{className:`chat-send-btn`,onClick:I,disabled:!a.trim(),id:`chat-send`,title:`Send Message`,children:(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,z.jsx)(`path`,{d:`M3.478 2.405a.75.75 0 00-.926.94l2.432 7.905H13.5a.75.75 0 010 1.5H4.984l-2.432 7.905a.75.75 0 00.926.94 60.519 60.519 0 0018.445-8.986.75.75 0 000-1.218A60.517 60.517 0 003.478 2.405z`})})})]}),S&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,padding:`8px 12px`,background:`var(--bg-secondary, #1e1e2e)`,borderRadius:`8px`,alignItems:`center`,fontSize:`0.85rem`,marginTop:4},children:[(0,z.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`🔗 URL detected`}),(0,z.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>Pe(`research`),children:`🔬 Research`}),(0,z.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>Pe(`remember`),children:`📌 Remember`})]}),w&&(0,z.jsx)(`div`,{style:{padding:`6px 12px`,background:`rgba(46, 204, 113, 0.1)`,border:`1px solid rgba(46, 204, 113, 0.3)`,borderRadius:`8px`,fontSize:`0.8rem`,color:`var(--success)`,marginTop:4,textAlign:`center`},children:w})]})]})]})}var FW=[`all`,`invariants`,`preferences`,`anti-patterns`,`patterns`,`decisions`,`concepts`,`facts`,`lore`];function IW(e){if(!e)return``;let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);return t=t.replace(/^### (.*$)/gim,`<h3>$1</h3>`),t=t.replace(/^## (.*$)/gim,`<h2>$1</h2>`),t=t.replace(/^# (.*$)/gim,`<h1>$1</h1>`),t=t.replace(/\*\*(.*?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/\*(.*?)\*/g,`<em>$1</em>`),t=t.replace(/```([\s\S]*?)```/g,`<pre style="background:rgba(0,0,0,0.3);padding:12px;border-radius:6px;border:1px solid rgba(255,255,255,0.06);font-family:monospace;overflow-x:auto;"><code>$1</code></pre>`),t=t.replace(/`(.*?)`/g,`<code style="background:rgba(255,255,255,0.06);padding:2px 6px;border-radius:4px;font-family:monospace;">$1</code>`),t=t.replace(/^> (.*$)/gim,`<blockquote style="border-left:4px solid var(--purple-primary);padding-left:14px;color:var(--text-secondary);margin:16px 0;font-style:italic;">$1</blockquote>`),t=t.replace(/^- (.*$)/gim,`<li style="margin-left:20px;list-style-type:disc;">$1</li>`),t=t.replace(/\n/g,`<br />`),(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:t},className:`markdown-preview-block`})}function LW({activeBrainId:e}){let[t,n]=jn(),r=t.get(`slug`),[i,a]=(0,v.useState)(`vault`),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(`all`),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(0),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)([]),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),[j,ee]=(0,v.useState)(!1),[M,te]=(0,v.useState)(``),[ne,N]=(0,v.useState)(``),[P,re]=(0,v.useState)(`invariants`),[ie,ae]=(0,v.useState)(``),[oe,se]=(0,v.useState)(`active`),[ce,le]=(0,v.useState)(`low`),[ue,de]=(0,v.useState)(`should`),[fe,pe]=(0,v.useState)(1),[me,he]=(0,v.useState)(3),[ge,_e]=(0,v.useState)(``),[ve,ye]=(0,v.useState)(``),[be,xe]=(0,v.useState)(``),[Se,F]=(0,v.useState)(``),Ce=(0,v.useCallback)(async()=>{h(!0),_(``);try{if(f.trim()){let e=await rr(f,u===`all`?void 0:u);s(e)}else{let t=await nr(e,u===`all`?void 0:u);s(t)}}catch(e){_(e.message),s([])}finally{h(!1)}},[u,f,e]);(0,v.useEffect)(()=>{c&&(te(c.slug||``),N(c.title||``),re(c.category||`invariants`),ae(c.content||c.body||``),se(c.status||`active`),le(c.priority||`low`),de(c.modality||`should`),pe(c.confidence??1),he(c.importance??3),_e((c.tags||[]).join(`, `)),ye((c.related||[]).join(`, `)),xe((c.contradicts||[]).join(`, `)),F((c.supersedes||[]).join(`, `)))},[c]);let we=async()=>{if(c){h(!0),_(``);try{let t=ge.split(`,`).map(e=>e.trim()).filter(Boolean),n=ve.split(`,`).map(e=>e.trim()).filter(Boolean),r=be.split(`,`).map(e=>e.trim()).filter(Boolean),i=Se.split(`,`).map(e=>e.trim()).filter(Boolean),a=await ar(c.slug,{title:ne,category:P,content:ie,status:oe,priority:ce,modality:ue,confidence:fe,importance:me,tags:t,related:n,contradicts:r,supersedes:i},e);l(a),A(!1),Ce()}catch(e){_(e.message)}finally{h(!1)}}},Te=async()=>{if(!M.trim()||!ne.trim()||!ie.trim()){_(`Slug, Title, and Content are required fields.`);return}h(!0),_(``);try{let t=ge.split(`,`).map(e=>e.trim()).filter(Boolean),r=ve.split(`,`).map(e=>e.trim()).filter(Boolean),i=be.split(`,`).map(e=>e.trim()).filter(Boolean),a=Se.split(`,`).map(e=>e.trim()).filter(Boolean),o=await or({slug:M,title:ne,category:P,content:ie,status:oe,priority:ce,modality:ue,confidence:fe,importance:me,tags:t,related:r,contradicts:i,supersedes:a},e);ee(!1),l(o),n({slug:o.slug}),Ce()}catch(e){_(e.message)}finally{h(!1)}},Ee=async t=>{if(window.confirm(`Are you sure you want to delete memory node "${t}"?`)){h(!0),_(``);try{await sr(t,e),l(null),n({}),Ce()}catch(e){_(e.message)}finally{h(!1)}}},De=(0,v.useCallback)(async()=>{try{let e=await cr();E(e.conflicts||[])}catch(e){console.warn(`Conflicts API error (enhanced features might be disabled):`,e)}},[]);(0,v.useEffect)(()=>{let e=setTimeout(Ce,300);return()=>clearTimeout(e)},[Ce]);let I=(0,v.useCallback)(async()=>{w(!0);try{let e=await hi(100);b(e.sessions),S(e.total)}catch(e){_(e.message)}finally{w(!1)}},[]);(0,v.useEffect)(()=>{i===`conflicts`?De():i===`sessions`&&I()},[i,De,I]);let Oe=async e=>{if(window.confirm(`Delete session "${e}"?`))try{await gi(e),I()}catch(e){_(e.message)}};(0,v.useEffect)(()=>{r?(async()=>{let t=o.find(e=>e.slug===r);if(t&&(t.content||t.body)){l(t),_(``);return}h(!0),_(``);try{let n=await ir(r,e);n?l(n):t?l(t):(_(`Memory node not found: ${r}`),l(null))}catch(e){t?(l(t),_(``)):(_(`Failed to load memory node '${r}': ${e.message}`),l(null))}finally{h(!1)}})():l(null)},[r,e,o]),(0,v.useEffect)(()=>{let e=new EventSource(`http://localhost:9111/stream`);return e.onmessage=e=>{try{let t=JSON.parse(e.data);(t.subsystem===`conflict-detector`||t.subsystem===`rebuild`||t.subsystem===`session-watcher`)&&(Ce(),De())}catch{}},e.onerror=()=>{e.close()},()=>{e.close()}},[Ce,De]);let ke=e=>{l(e),_(``),n({slug:e.slug})},Ae=async(e,t,n)=>{O(e),_(``);try{await lr(e,t,n),await De(),await Ce()}catch(e){_(e.message)}finally{O(null)}},je=(e,t,n)=>(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Slug (kebab-case, matches filename)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. prefer-atomic-writes`,value:M,onChange:e=>te(e.target.value),disabled:!n,style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Title (One-line description)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. Always write files atomically (write-then-rename)`,value:ne,onChange:e=>N(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Category`}),(0,z.jsxs)(`select`,{value:P,onChange:e=>re(e.target.value),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:`invariants`,children:`invariants`}),(0,z.jsx)(`option`,{value:`patterns`,children:`patterns`}),(0,z.jsx)(`option`,{value:`anti-patterns`,children:`anti-patterns`}),(0,z.jsx)(`option`,{value:`preferences`,children:`preferences`}),(0,z.jsx)(`option`,{value:`decisions`,children:`decisions`}),(0,z.jsx)(`option`,{value:`concepts`,children:`concepts`}),(0,z.jsx)(`option`,{value:`facts`,children:`facts`}),(0,z.jsx)(`option`,{value:`lore`,children:`lore`})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Modality`}),(0,z.jsxs)(`select`,{value:ue,onChange:e=>de(e.target.value),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:`must`,children:`must`}),(0,z.jsx)(`option`,{value:`must_not`,children:`must_not`}),(0,z.jsx)(`option`,{value:`should`,children:`should`}),(0,z.jsx)(`option`,{value:`should_not`,children:`should_not`})]})]})]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Status`}),(0,z.jsxs)(`select`,{value:oe,onChange:e=>se(e.target.value),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:`active`,children:`active`}),(0,z.jsx)(`option`,{value:`draft`,children:`draft`}),(0,z.jsx)(`option`,{value:`deprecated`,children:`deprecated`}),(0,z.jsx)(`option`,{value:`superseded`,children:`superseded`})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Importance (1-5 Stars)`}),(0,z.jsxs)(`select`,{value:me,onChange:e=>he(Number(e.target.value)),style:{width:`100%`,background:`rgba(15,23,42,0.9)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`},children:[(0,z.jsx)(`option`,{value:1,children:`★ 1/5`}),(0,z.jsx)(`option`,{value:2,children:`★★ 2/5`}),(0,z.jsx)(`option`,{value:3,children:`★★★ 3/5`}),(0,z.jsx)(`option`,{value:4,children:`★★★★ 4/5`}),(0,z.jsx)(`option`,{value:5,children:`★★★★★ 5/5`})]})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:[`Confidence: `,(0,z.jsxs)(`strong`,{children:[Math.round(fe*100),`%`]})]}),(0,z.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:fe,onChange:e=>pe(Number(e.target.value)),style:{width:`100%`,height:6,background:`rgba(255,255,255,0.1)`,borderRadius:3,outline:`none`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Tags (comma separated)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. filesystem, reliability, writes`,value:ge,onChange:e=>_e(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]})]})]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Related Nodes (comma separated slugs)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. use-atomic-writes, git-wiping`,value:ve,onChange:e=>ye(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Contradicts Nodes (comma separated slugs)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. write-anywhere-sync`,value:be,onChange:e=>xe(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{style:{display:`block`,fontSize:12,color:`var(--text-secondary)`,marginBottom:4},children:`Supersedes Nodes (comma separated slugs)`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`e.g. prefer-atomic-writes-v1`,value:Se,onChange:e=>F(e.target.value),style:{width:`100%`,background:`rgba(255,255,255,0.03)`,border:`1px solid var(--border)`,borderRadius:6,padding:`8px 12px`,color:`#fff`}})]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,z.jsx)(`label`,{style:{fontSize:12,color:`var(--text-secondary)`},children:`Memory Content`}),(0,z.jsx)(`textarea`,{value:ie,onChange:e=>ae(e.target.value),placeholder:`Write markdown here...`,style:{minHeight:300,padding:16,color:`#fff`,background:`#090d16`,border:`1px solid var(--border)`,borderRadius:8,outline:`none`,fontSize:14,lineHeight:1.6,resize:`vertical`,width:`100%`,boxSizing:`border-box`}})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:12},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost`,type:`button`,onClick:t,style:{fontSize:13},children:`Cancel`}),(0,z.jsx)(`button`,{className:`btn btn-purple`,type:`button`,onClick:e,style:{fontSize:13},children:n?`🚀 Create Memory Node`:`💾 Save Changes`})]})]}),Me=o.reduce((e,t)=>(e[t.category]=(e[t.category]||0)+1,e),{});return(0,z.jsxs)(`div`,{className:`page`,children:[(0,z.jsxs)(`div`,{className:`page-header`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-end`,marginBottom:20},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{children:`Memory Vault`}),(0,z.jsx)(`p`,{children:`Browse, audit, and resolve contradictions in your SSSS knowledge graph`})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,background:`rgba(255,255,255,0.03)`,padding:4,borderRadius:8,border:`1px solid var(--border)`},children:[(0,z.jsx)(`button`,{className:`btn btn-sm ${i===`vault`?`btn-purple`:`btn-ghost`}`,onClick:()=>{a(`vault`),l(null),n({})},style:{borderRadius:6,fontSize:12,padding:`6px 12px`},children:`🧠 Active Nodes`}),(0,z.jsxs)(`button`,{className:`btn btn-sm ${i===`conflicts`?`btn-cyan`:`btn-ghost`}`,onClick:()=>{a(`conflicts`),l(null),n({})},style:{borderRadius:6,fontSize:12,padding:`6px 12px`,display:`flex`,alignItems:`center`,gap:6},children:[`⚠️ Quarantined Conflicts`,T.length>0&&(0,z.jsx)(`span`,{style:{background:`#ef4444`,color:`#fff`,fontSize:9,padding:`1px 5px`,borderRadius:10,fontWeight:700},children:T.length})]}),(0,z.jsxs)(`button`,{className:`btn btn-sm ${i===`sessions`?`btn-purple`:`btn-ghost`}`,onClick:()=>{a(`sessions`),l(null),n({})},style:{borderRadius:6,fontSize:12,padding:`6px 12px`},children:[`📝 Sessions`,x>0&&(0,z.jsx)(`span`,{style:{background:`rgba(139,92,246,0.3)`,color:`#a78bfa`,fontSize:9,padding:`1px 5px`,borderRadius:10,fontWeight:700,marginLeft:4},children:x})]})]})]}),g&&(0,z.jsxs)(`div`,{className:`badge badge-error`,style:{alignSelf:`flex-start`,marginBottom:15},children:[`⚠️ `,g]}),i===`vault`?(0,z.jsxs)(`div`,{className:`memory-layout`,children:[(0,z.jsxs)(`div`,{className:`memory-sidebar`,children:[(0,z.jsx)(`h3`,{style:{margin:`0 0 12px 0`},children:`Categories`}),FW.map(e=>(0,z.jsxs)(`button`,{className:`category-btn ${u===e?`active`:``}`,onClick:()=>{d(e),n({}),ee(!1),A(!1)},children:[(0,z.jsx)(`span`,{children:e===`all`?`📋 All Nodes`:e}),e===`all`?(0,z.jsx)(`span`,{className:`category-count`,children:o.length}):Me[e]?(0,z.jsx)(`span`,{className:`category-count`,children:Me[e]}):null]},e)),(0,z.jsx)(`button`,{className:`btn btn-purple`,style:{width:`100%`,marginTop:20,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:8,fontSize:13},onClick:()=>{l(null),n({}),ee(!0),A(!1),te(``),N(``),re(`invariants`),ae(``),se(`active`),le(`low`),de(`should`),pe(1),he(3),_e(``),ye(``),xe(``),F(``)},children:`➕ Create New Node`})]}),(0,z.jsxs)(`div`,{className:`memory-main`,children:[(0,z.jsxs)(`div`,{className:`memory-search`,children:[(0,z.jsx)(`input`,{id:`memory-search`,type:`text`,placeholder:`Search memory nodes…`,value:f,onChange:e=>p(e.target.value)}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:Ce,children:`Refresh`})]}),m?(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2,3].map(e=>(0,z.jsx)(`div`,{className:`skeleton`,style:{height:60}},e))}):j?(0,z.jsxs)(`div`,{className:`memory-detail`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:20},children:[(0,z.jsx)(`h2`,{style:{margin:0,color:`#fff`},children:`Create New SSSS Memory Node`}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>ee(!1),style:{fontSize:12},children:`← Back to List`})]}),je(Te,()=>ee(!1),!0)]}):c&&k?(0,z.jsxs)(`div`,{className:`memory-detail`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:20},children:[(0,z.jsx)(`h2`,{style:{margin:0,color:`#fff`},children:`Edit Memory Node`}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>A(!1),style:{fontSize:12},children:`← Cancel Edit`})]}),je(we,()=>A(!1),!1)]}):c?(0,z.jsxs)(`div`,{className:`memory-detail`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:c.modality===`must`?`2px solid #10b981`:c.modality===`must_not`?`2px solid #ef4444`:c.modality===`should`?`1px solid #8b5cf6`:c.modality===`should_not`?`1px solid #f97316`:`1px solid var(--border)`,boxShadow:c.modality===`must`?`0 0 16px rgba(16, 185, 129, 0.1)`:c.modality===`must_not`?`0 0 16px rgba(239, 68, 68, 0.1)`:void 0,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:16},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>n({}),style:{fontSize:12},children:`← Back to List`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>{te(c.slug||``),N(c.title||``),re(c.category||`invariants`),ae(c.content||c.body||``),se(c.status||`active`),le(c.priority||`low`),de(c.modality||`should`),pe(c.confidence??1),he(c.importance??3),_e((c.tags||[]).join(`, `)),ye((c.related||[]).join(`, `)),xe((c.contradicts||[]).join(`, `)),F((c.supersedes||[]).join(`, `)),A(!0)},style:{fontSize:12,border:`1px solid var(--border)`},children:`✏️ Edit Node`}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>Ee(c.slug),style:{fontSize:12,borderColor:`rgba(239,68,68,0.2)`,color:`#fca5a5`},children:`🗑️ Delete`})]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:12},children:[(0,z.jsx)(`h2`,{style:{margin:0,color:`#fff`},children:c.title}),c.modality&&(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:700,textTransform:`uppercase`,padding:`4px 10px`,borderRadius:6,background:c.modality===`must`?`rgba(16, 185, 129, 0.15)`:c.modality===`must_not`?`rgba(239, 68, 68, 0.15)`:`rgba(255, 255, 255, 0.05)`,color:c.modality===`must`?`#10b981`:c.modality===`must_not`?`#ef4444`:`var(--text-secondary)`,border:c.modality===`must`?`1px solid rgba(16, 185, 129, 0.3)`:c.modality===`must_not`?`1px solid rgba(239, 68, 68, 0.3)`:`1px solid rgba(255, 255, 255, 0.1)`},children:c.modality})]}),(0,z.jsxs)(`dl`,{className:`frontmatter`,style:{display:`grid`,gridTemplateColumns:`120px 1fr`,gap:`10px 20px`,marginBottom:24,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.06)`},children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Slug`}),(0,z.jsx)(`dd`,{style:{margin:0},children:(0,z.jsx)(`code`,{children:c.slug})}),(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Category`}),(0,z.jsx)(`dd`,{style:{margin:0,textTransform:`capitalize`},children:c.category}),c.status&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Status`}),(0,z.jsx)(`dd`,{style:{margin:0},children:(0,z.jsx)(`span`,{className:`badge badge-success`,style:{background:c.status===`active`?`rgba(34, 197, 94, 0.15)`:`rgba(255,255,255,0.05)`,color:c.status===`active`?`#22c55e`:`var(--text-secondary)`},children:c.status})})]}),c.confidence!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Confidence`}),(0,z.jsxs)(`dd`,{style:{margin:0,display:`flex`,alignItems:`center`,gap:12},children:[(0,z.jsxs)(`strong`,{style:{fontSize:13},children:[Math.round(c.confidence*100),`%`]}),(0,z.jsx)(`div`,{style:{flex:1,maxWidth:150,height:6,background:`rgba(255,255,255,0.06)`,borderRadius:3,overflow:`hidden`,display:`inline-block`},children:(0,z.jsx)(`div`,{style:{width:`${Math.round(c.confidence*100)}%`,height:`100%`,background:`linear-gradient(90deg, #8b5cf6, #06b6d4)`,borderRadius:3}})})]})]}),c.importance!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Importance`}),(0,z.jsx)(`dd`,{style:{margin:0,color:`#fbbf24`,display:`flex`,gap:2},children:Array.from({length:5}).map((e,t)=>(0,z.jsx)(`span`,{children:t<(c.importance||0)?`★`:`☆`},t))})]}),c.tags?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Tags`}),(0,z.jsx)(`dd`,{style:{margin:0,display:`flex`,gap:6,flexWrap:`wrap`},children:c.tags.map(e=>(0,z.jsx)(`span`,{style:{background:`rgba(255,255,255,0.05)`,color:`var(--text-secondary)`,fontSize:10,padding:`2px 8px`,borderRadius:4,border:`1px solid rgba(255,255,255,0.03)`},children:e},e))})]}):null,c.related?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Related`}),(0,z.jsx)(`dd`,{style:{margin:0},children:(0,z.jsx)(`code`,{children:c.related.join(`, `)})})]}):null,c.contradicts?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Contradicts`}),(0,z.jsx)(`dd`,{style:{margin:0,color:`#fca5a5`},children:(0,z.jsx)(`code`,{children:c.contradicts.join(`, `)})})]}):null,c.supersedes?.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{style:{color:`var(--text-tertiary)`,fontWeight:500},children:`Supersedes`}),(0,z.jsx)(`dd`,{style:{margin:0,color:`#93c5fd`},children:(0,z.jsx)(`code`,{children:c.supersedes.join(`, `)})})]}):null]}),(0,z.jsxs)(`div`,{style:{marginTop:20},children:[(0,z.jsx)(`h3`,{style:{fontSize:12,textTransform:`uppercase`,color:`var(--text-tertiary)`,letterSpacing:.5,marginBottom:12},children:`Memory Content (SSSS Body)`}),(0,z.jsx)(`div`,{style:{background:`rgba(0,0,0,0.15)`,border:`1px solid rgba(255,255,255,0.04)`,borderRadius:8,padding:20},children:IW(c.body||c.content||``)})]})]}):(0,z.jsxs)(`div`,{className:`memory-list`,style:{display:`grid`,gridTemplateColumns:`1fr`,gap:12},children:[o.length===0&&!m&&(0,z.jsx)(`div`,{style:{textAlign:`center`,padding:40,color:`var(--text-tertiary)`},children:f?`No matching nodes found.`:u===`all`?`No memory nodes loaded. Is the backend running?`:`No memory nodes found in category "${u}".`}),o.map(e=>{let t=e.modality===`must`?`2px solid #10b981`:e.modality===`must_not`?`2px solid #ef4444`:e.modality===`should`?`1px solid #8b5cf6`:e.modality===`should_not`?`1px solid #f97316`:`1px solid rgba(255, 255, 255, 0.08)`,n=e.modality===`must`?`0 0 12px rgba(16, 185, 129, 0.15)`:e.modality===`must_not`?`0 0 12px rgba(239, 68, 68, 0.15)`:void 0;return(0,z.jsxs)(`div`,{className:`memory-node-card`,onClick:()=>ke(e),style:{border:t,boxShadow:n,transition:`transform 0.2s ease, box-shadow 0.2s ease`,position:`relative`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:6},children:[(0,z.jsx)(`h4`,{style:{margin:0,color:`#fff`,fontSize:15},children:e.title}),e.modality&&(0,z.jsx)(`span`,{style:{fontSize:9,fontWeight:700,textTransform:`uppercase`,padding:`2px 6px`,borderRadius:4,background:e.modality===`must`?`rgba(16, 185, 129, 0.15)`:e.modality===`must_not`?`rgba(239, 68, 68, 0.15)`:`rgba(255, 255, 255, 0.05)`,color:e.modality===`must`?`#10b981`:e.modality===`must_not`?`#ef4444`:`var(--text-secondary)`},children:e.modality})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:16,fontSize:11,color:`var(--text-tertiary)`,marginTop:8},children:[(0,z.jsxs)(`span`,{children:[`📂 `,e.category]}),e.importance!==void 0&&(0,z.jsxs)(`span`,{style:{color:`#fbbf24`},children:[`★ `,e.importance,`/5`]}),e.confidence!==void 0&&(0,z.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:4},children:[`🧠 `,Math.round(e.confidence*100),`%`]})]})]},e.slug)})]})]})]}):(0,z.jsxs)(`div`,{style:{width:`100%`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:16},children:[(0,z.jsx)(`h3`,{children:`Quarantined Contradiction Records`}),(0,z.jsxs)(`span`,{style:{fontSize:12,color:`var(--text-tertiary)`,display:`flex`,alignItems:`center`,gap:5},children:[(0,z.jsx)(`span`,{className:`pulse`,style:{background:`#06b6d4`}}),` SSE Real-time Agent Monitor Connected`]})]}),T.length===0?(0,z.jsxs)(`div`,{style:{textAlign:`center`,padding:60,background:`rgba(255,255,255,0.02)`,borderRadius:12,border:`1px dashed var(--border)`,color:`var(--text-tertiary)`},children:[(0,z.jsx)(`span`,{style:{fontSize:32,display:`block`,marginBottom:12},children:`🛡️`}),(0,z.jsx)(`h4`,{style:{color:`#fff`,marginBottom:6},children:`All Clear!`}),"No memory conflicts enqueued or quarantined in `.agent/memory-inbox/conflicts/`."]}):(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:T.map(e=>{let t=e.status===`pending`;return(0,z.jsxs)(`div`,{style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:t?`1px solid rgba(239, 68, 68, 0.25)`:`1px solid rgba(34, 197, 94, 0.2)`,borderRadius:12,padding:24,boxShadow:`0 8px 32px rgba(0,0,0,0.15)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:16,borderBottom:`1px solid rgba(255,255,255,0.06)`,paddingBottom:12},children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h4`,{style:{margin:0,fontSize:16,color:`#fff`,display:`flex`,alignItems:`center`,gap:8},children:[`Conflict: `,(0,z.jsx)(`code`,{children:e.conflict_id}),(0,z.jsx)(`span`,{style:{fontSize:11,padding:`2px 8px`,borderRadius:10,background:t?`rgba(239,68,68,0.15)`:`rgba(34,197,94,0.15)`,color:t?`#ef4444`:`#22c55e`,textTransform:`uppercase`},children:e.status})]}),(0,z.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[`Detected at: `,new Date(e.detected_at).toLocaleString()]})]}),(0,z.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,z.jsxs)(`span`,{style:{fontSize:12,color:`#ef4444`,fontWeight:700,display:`block`},children:[`Clash Similarity: `,Math.round(e.similarity*100),`%`]}),(0,z.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`Modality polarity flip`})]})]}),(0,z.jsxs)(`p`,{style:{fontSize:13,background:`rgba(239,68,68,0.03)`,padding:`10px 14px`,borderRadius:6,borderLeft:`3px solid #ef4444`,color:`#fca5a5`,marginBottom:20},children:[(0,z.jsx)(`strong`,{children:`Reason:`}),` `,e.reason]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16,marginBottom:24},children:[(0,z.jsxs)(`div`,{style:{background:`rgba(255,255,255,0.02)`,padding:16,borderRadius:8,border:`1px solid rgba(255,255,255,0.05)`},children:[(0,z.jsx)(`h5`,{style:{margin:`0 0 10px 0`,color:`#a78bfa`,textTransform:`uppercase`,fontSize:11,letterSpacing:.5},children:`✓ Existing Node In Vault`}),(0,z.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`#fff`,marginBottom:8},children:(0,z.jsx)(`code`,{children:e.existing_slug})}),(0,z.jsxs)(`dl`,{style:{display:`grid`,gridTemplateColumns:`80px 1fr`,gap:4,margin:`0 0 12px 0`,fontSize:11,color:`var(--text-secondary)`},children:[(0,z.jsx)(`dt`,{children:`Modality:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._existing_node?.modality||`must`})}),(0,z.jsx)(`dt`,{children:`Polarity:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._existing_node?.sentiment_polarity||`directive_must`})}),(0,z.jsx)(`dt`,{children:`Confidence:`}),(0,z.jsx)(`dd`,{children:e._existing_node?.confidence===void 0?`N/A`:`${Math.round(e._existing_node.confidence*100)}%`})]}),(0,z.jsx)(`div`,{style:{fontSize:12,fontStyle:`italic`,background:`rgba(0,0,0,0.2)`,padding:10,borderRadius:6,color:`var(--text-tertiary)`,minHeight:60,whiteSpace:`pre-wrap`},children:e._existing_node?.excerpt||e._existing_node?.body||`No preview content.`})]}),(0,z.jsxs)(`div`,{style:{background:`rgba(255,255,255,0.02)`,padding:16,borderRadius:8,border:`1px solid rgba(255,255,255,0.05)`},children:[(0,z.jsx)(`h5`,{style:{margin:`0 0 10px 0`,color:`#06b6d4`,textTransform:`uppercase`,fontSize:11,letterSpacing:.5},children:`⚠ New Ingestion Candidate`}),(0,z.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`#fff`,marginBottom:8},children:(0,z.jsx)(`code`,{children:e.new_slug})}),(0,z.jsxs)(`dl`,{style:{display:`grid`,gridTemplateColumns:`80px 1fr`,gap:4,margin:`0 0 12px 0`,fontSize:11,color:`var(--text-secondary)`},children:[(0,z.jsx)(`dt`,{children:`Modality:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._new_node?.modality||`must_not`})}),(0,z.jsx)(`dt`,{children:`Polarity:`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e._new_node?.sentiment_polarity||`directive_must_not`})}),(0,z.jsx)(`dt`,{children:`Confidence:`}),(0,z.jsx)(`dd`,{children:e._new_node?.confidence===void 0?`N/A`:`${Math.round(e._new_node.confidence*100)}%`})]}),(0,z.jsx)(`div`,{style:{fontSize:12,fontStyle:`italic`,background:`rgba(0,0,0,0.2)`,padding:10,borderRadius:6,color:`var(--text-tertiary)`,minHeight:60,whiteSpace:`pre-wrap`},children:e._new_node?.excerpt||e._new_node?.body||`No preview content.`})]})]}),t?(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12},children:[(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:D!==null,onClick:()=>Ae(e.conflict_id,`keep`,e.existing_slug),style:{borderColor:`rgba(255,255,255,0.1)`,fontSize:12},children:D===e.conflict_id?`Processing...`:`Keep Existing Node (${e.existing_slug})`}),(0,z.jsx)(`button`,{className:`btn btn-purple btn-sm`,disabled:D!==null,onClick:()=>Ae(e.conflict_id,`supersede`,e.new_slug),style:{fontSize:12},children:D===e.conflict_id?`Processing...`:`Supersede with New (${e.new_slug})`})]}):(0,z.jsxs)(`div`,{style:{fontSize:12,color:`#22c55e`,background:`rgba(34,197,94,0.06)`,padding:`10px 14px`,borderRadius:6,border:`1px solid rgba(34,197,94,0.15)`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,z.jsxs)(`span`,{children:[`✓ Resolved successfully. Choice: `,(0,z.jsx)(`strong`,{children:e.resolution})]}),(0,z.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[`Resolved at: `,e.resolved_at?new Date(e.resolved_at).toLocaleString():``]})]})]},e.conflict_id)})})]}),i===`sessions`&&(0,z.jsxs)(`div`,{className:`health-log`,style:{background:`rgba(15,23,42,0.45)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderRadius:12,padding:24},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:16},children:[(0,z.jsxs)(`h2`,{style:{margin:0,color:`#fff`,fontSize:16},children:[`📝 IDE Sessions (`,x,`)`]}),(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:I,style:{fontSize:12},children:`🔄 Refresh`})]}),C?(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2,3].map(e=>(0,z.jsx)(`div`,{className:`skeleton`,style:{height:56}},e))}):y.length===0?(0,z.jsxs)(`div`,{style:{textAlign:`center`,padding:40,color:`var(--text-tertiary)`},children:[(0,z.jsx)(`span`,{style:{fontSize:32,display:`block`,marginBottom:8},children:`📝`}),`No sessions ingested yet. Sessions appear here when the relay ships IDE conversation data.`]}):(0,z.jsxs)(`table`,{style:{width:`100%`,textAlign:`left`,borderCollapse:`collapse`},children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Title`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Date`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Source`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600},children:`Messages`}),(0,z.jsx)(`th`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--border)`,color:`var(--text-tertiary)`,fontSize:12,fontWeight:600,width:60}})]})}),(0,z.jsx)(`tbody`,{children:y.map(e=>{let t={antigravity:`#8b5cf6`,"claude-code":`#f59e0b`,codex:`#10b981`,vscode:`#3b82f6`,cursor:`#06b6d4`,"gemini-cli":`#ec4899`}[e.source||``]||`var(--text-secondary)`;return(0,z.jsxs)(`tr`,{style:{borderBottom:`1px solid rgba(255,255,255,0.04)`},children:[(0,z.jsx)(`td`,{style:{padding:`10px 12px`,color:`#fff`,fontSize:13,maxWidth:400,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.title||e.id}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`,fontSize:12,whiteSpace:`nowrap`},children:e.date?new Date(e.date).toLocaleString():`-`}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`},children:e.source&&(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:600,textTransform:`uppercase`,padding:`2px 8px`,borderRadius:4,background:`${t}20`,color:t,border:`1px solid ${t}40`},children:e.source})}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`,fontSize:12},children:e.count}),(0,z.jsx)(`td`,{style:{padding:`10px 12px`},children:(0,z.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>Oe(e.id),style:{fontSize:10,padding:`2px 6px`,color:`#fca5a5`,borderColor:`rgba(239,68,68,0.2)`},children:`🗑️`})})]},e.id)})})]})]})]})}var RW=Object.defineProperty,zW=Object.getOwnPropertySymbols,BW=Object.prototype.hasOwnProperty,VW=Object.prototype.propertyIsEnumerable,HW=(e,t,n)=>t in e?RW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,UW=(e,t)=>{for(var n in t||={})BW.call(t,n)&&HW(e,n,t[n]);if(zW)for(var n of zW(t))VW.call(t,n)&&HW(e,n,t[n]);return e},WW=(e,t)=>{var n={};for(var r in e)BW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&zW)for(var r of zW(e))t.indexOf(r)<0&&VW.call(e,r)&&(n[r]=e[r]);return n},GW;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(!(a>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(!(t>>>18));for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(GW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(GW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(GW||={});var KW=GW,qW={L:KW.QrCode.Ecc.LOW,M:KW.QrCode.Ecc.MEDIUM,Q:KW.QrCode.Ecc.QUARTILE,H:KW.QrCode.Ecc.HIGH},JW=128,YW=`L`,XW=`#FFFFFF`,ZW=`#000000`,QW=!1,$W=1,eG=4,tG=0,nG=.1;function rG(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function iG(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function aG(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*nG),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function oG(e,t){return t==null?e?eG:tG:Math.max(Math.floor(t),0)}function sG({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=v.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...KW.QrSegment.makeSegments(t)),e),[]);return KW.QrCode.encodeSegments(r,qW[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=v.useMemo(()=>{let e=c.getModules(),t=oG(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:aG(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var cG=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),lG=v.forwardRef(function(e,t){let n=e,{value:r,size:i=JW,level:a=YW,bgColor:o=XW,fgColor:s=ZW,includeMargin:c=QW,minVersion:l=$W,boostLevel:u,marginSize:d,imageSettings:f}=n,p=WW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=WW(p,[`style`]),g=f?.src,_=v.useRef(null),y=v.useRef(null),b=v.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=v.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=sG({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});v.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=iG(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,cG?t.fill(new Path2D(rG(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),v.useEffect(()=>{S(!1)},[g]);let D=UW({height:i,width:i},m),O=null;return g!=null&&(O=v.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),v.createElement(v.Fragment,null,v.createElement(`canvas`,UW({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});lG.displayName=`QRCodeCanvas`;var uG=v.forwardRef(function(e,t){let n=e,{value:r,size:i=JW,level:a=YW,bgColor:o=XW,fgColor:s=ZW,includeMargin:c=QW,minVersion:l=$W,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=WW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:y}=sG({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=iG(g,y.excavation)),x=v.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=rG(b,h);return v.createElement(`svg`,UW({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&v.createElement(`title`,null,d),v.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),v.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});uG.displayName=`QRCodeSVG`;function dG(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),u=async()=>{s(!0),a(null);try{let e=await R(`${Ln()}/api/pairing`);if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Pairing API error: ${e.status}`)}let n=await e.json();t(n);let i=n.preferred_url||n.endpoints?.find(e=>e.recommended)?.url||n.endpoints?.[0]?.url||``;r(i)}catch(e){console.error(e),a(e instanceof Error?e.message:`Failed to load pairing endpoints`);let n=`${window.location.protocol}//${window.location.host}`;r(n),t({port:Number(window.location.port||3e3),protocol:window.location.protocol.replace(`:`,``)||`http`,preferred_url:n,endpoints:[{kind:`browser`,label:`This browser URL (may not work on phone)`,ip:window.location.hostname,url:n,recommended:!0,reachable_hint:`Fallback when pairing API is unavailable.`}],warnings:[`Could not load live network endpoints from the brain.`],listen_hosts:[]})}finally{s(!1)}};(0,v.useEffect)(()=>{setTimeout(()=>{u()},0)},[]);let d=e?.endpoints?.find(e=>e.url===n)||null,f=d?.kind===`loopback`||n.includes(`127.0.0.1`)||n.includes(`localhost`);return(0,z.jsxs)(`div`,{className:`mobile-pairing`,"data-testid":`mobile-pairing`,style:{padding:`20px`,background:`var(--bg-secondary)`,borderRadius:`12px`,border:`1px solid var(--border)`},children:[(0,z.jsx)(`h3`,{style:{margin:`0 0 8px`},children:`Mobile Device Pairing`}),(0,z.jsxs)(`p`,{style:{color:`var(--text-tertiary)`,fontSize:`13px`,marginBottom:`16px`},children:[`Scan with your phone to open this Total Recall dashboard. Prefer `,(0,z.jsx)(`strong`,{children:`LAN`}),` on the same Wi‑Fi, or `,(0,z.jsx)(`strong`,{children:`Tailscale/mesh`}),` if the phone is on your tailnet.`]}),o&&(0,z.jsx)(`div`,{"data-testid":`pairing-loading`,style:{color:`var(--text-tertiary)`,fontSize:13},children:`Detecting reachable addresses…`}),i&&(0,z.jsxs)(`div`,{role:`alert`,"data-testid":`pairing-error`,style:{marginBottom:12,padding:10,borderRadius:8,border:`1px solid #ef4444`,color:`#ef4444`,fontSize:12},children:[i,` `,(0,z.jsx)(`button`,{type:`button`,onClick:()=>u(),style:{marginLeft:8,cursor:`pointer`},children:`Retry`})]}),!o&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:20,flexWrap:`wrap`,alignItems:`flex-start`},children:[(0,z.jsx)(`div`,{style:{background:`#fff`,padding:`16px`,borderRadius:`8px`,display:`inline-block`},"data-testid":`pairing-qr`,children:n?(0,z.jsx)(uG,{value:n,size:150,level:`M`,includeMargin:!0}):(0,z.jsx)(`div`,{style:{width:150,height:150}})}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:200},children:[e&&e.endpoints.length>0&&(0,z.jsxs)(`div`,{className:`field-col`,style:{marginBottom:12},children:[(0,z.jsx)(`label`,{className:`field-label`,htmlFor:`pairing-endpoint`,children:`Pairing address`}),(0,z.jsx)(`select`,{id:`pairing-endpoint`,className:`settings-select`,"data-testid":`pairing-endpoint-select`,value:n,onChange:e=>r(e.target.value),style:{width:`100%`,marginTop:4},children:e.endpoints.map(e=>(0,z.jsxs)(`option`,{value:e.url,children:[e.label,e.recommended?` ★`:``,` — `,e.url]},e.url))})]}),(0,z.jsx)(`p`,{"data-testid":`pairing-url`,style:{margin:`0 0 8px`,fontSize:12,fontFamily:`var(--font-mono)`,wordBreak:`break-all`,color:`var(--text-primary)`},children:n||`—`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,marginBottom:12},children:[(0,z.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:async()=>{if(n)try{await navigator.clipboard.writeText(n),l(!0),setTimeout(()=>l(!1),2e3)}catch{a(`Clipboard copy failed — select the URL text manually.`)}},"data-testid":`pairing-copy`,children:c?`Copied`:`Copy URL`}),(0,z.jsx)(`button`,{type:`button`,className:`btn-ghost btn-sm`,onClick:()=>u(),children:`Refresh`})]}),d&&(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--text-secondary)`,margin:`0 0 10px`,lineHeight:1.5,background:`rgba(255,255,255,0.03)`,padding:`8px 12px`,borderRadius:6},children:[(0,z.jsx)(`strong`,{children:`Connection Route:`}),` `,d.reachable_hint]}),f&&(0,z.jsxs)(`div`,{"data-testid":`pairing-loopback-warning`,style:{fontSize:12,color:`#f59e0b`,margin:`0 0 8px`,background:`rgba(245, 158, 11, 0.1)`,padding:`8px 12px`,borderRadius:6,border:`1px solid rgba(245, 158, 11, 0.2)`},children:[`⚠️ `,(0,z.jsx)(`strong`,{children:`Loopback Only:`}),` `,(0,z.jsx)(`code`,{children:`127.0.0.1`}),` only works on this computer. To open on your phone, select your Mesh IP (`,(0,z.jsx)(`code`,{children:`100.64.x.x`}),`) or enable `,(0,z.jsx)(`strong`,{children:`Allow Public Bind`}),` below to use local Wi-Fi.`]})]})]}),e?.warnings&&e.warnings.length>0&&(0,z.jsxs)(`div`,{"data-testid":`pairing-warnings`,style:{margin:`16px 0 0`,padding:`10px 14px`,fontSize:12,color:`#fbbf24`,background:`rgba(251, 191, 36, 0.08)`,borderRadius:8,border:`1px solid rgba(251, 191, 36, 0.2)`},children:[(0,z.jsx)(`div`,{style:{fontWeight:600,marginBottom:4},children:`Network Notice:`}),(0,z.jsx)(`ul`,{style:{margin:0,paddingLeft:18},children:e.warnings.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}),(0,z.jsxs)(`div`,{style:{marginTop:16,padding:`12px 14px`,background:`rgba(59, 130, 246, 0.06)`,borderRadius:8,border:`1px solid rgba(59, 130, 246, 0.15)`,fontSize:12,color:`var(--text-secondary)`,lineHeight:1.5},children:[(0,z.jsx)(`div`,{style:{color:`var(--text-primary)`,fontWeight:600,marginBottom:4},children:`📱 How to connect your phone:`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:`Option A (WireGuard / Mesh — Recommended):`}),` Install the standard `,(0,z.jsx)(`em`,{children:`Tailscale`}),` app on your phone (iOS App Store / Google Play). Log into your tailnet/headscale server. Scan the `,(0,z.jsx)(`code`,{children:`100.64.x.x`}),` QR code above.`]}),(0,z.jsxs)(`div`,{style:{marginTop:4},children:[(0,z.jsx)(`strong`,{children:`Option B (Local Home Wi-Fi):`}),` Check `,(0,z.jsx)(`strong`,{children:`Allow Public Bind`}),` in `,(0,z.jsx)(`em`,{children:`Network & Binding`}),` below, restart the server, and scan your local Wi-Fi LAN QR code (e.g. `,(0,z.jsx)(`code`,{children:`192.168.x.x`}),`).`]})]})]})}async function fG(){let e=await Vn(`/api/mesh/leader`);if(!e.leader)throw Error(`No online mesh leader is available`);return e.leader}async function pG(){return(await Vn(`/api/mesh/nodes`)).nodes}async function mG(){return Vn(`/api/mesh/access/proposals`)}async function hG(){return Hn(`/api/mesh/access/import`,{})}async function gG(e){return Hn(`/api/mesh/access`,e)}async function _G(){let e=await Hn(`/api/mesh/election/refresh`,{});if(!e.leader)throw Error(`No online mesh leader is available`);return e.leader}async function vG(){return(await Vn(`/api/mesh/election/history`)).events||[]}async function yG(e){return Hn(`/api/mesh/election/log`,e)}async function bG(){return Vn(`/api/mesh/latency`)}async function xG(){return Vn(`/api/mesh/interfaces`)}async function SG(e){let t=new URLSearchParams;e?.probe===!1&&t.set(`probe`,`0`),e?.limit&&t.set(`limit`,String(e.limit));let n=t.toString();return Vn(`/api/mesh/lan${n?`?${n}`:``}`)}async function CG(){return Vn(`/api/mesh/io`)}async function wG(){return Vn(`/api/mesh/enrollment`)}async function TG(e){return Hn(`/api/mesh/enroll`,e||{})}async function EG(e){return Hn(`/api/mesh/lan/register`,{probe:e?.probe!==!1,limit:e?.limit??32})}async function DG(e){return Hn(`/api/mesh/preauthkey`,{reusable:e?.reusable===!0,ephemeral:e?.ephemeral===!0,ttlMinutes:e?.ttlMinutes})}function OG(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null);(0,v.useEffect)(()=>{pG().then(t).catch(e=>d(e?.message??`could not load nodes`)),wG().then(e=>b(e.login_server)).catch(()=>b(null))},[]),(0,v.useEffect)(()=>{if(!n)return;let e=()=>{let e=new Date(n.expiration).getTime()-Date.now();_(Math.max(0,Math.floor(e/1e3)))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[n]);let x=async()=>{l(!0),d(null),p(!1);try{r(await DG({reusable:i,ephemeral:o}))}catch(e){d(e instanceof Error?e.message:`could not mint an enrollment key`)}finally{l(!1)}},S=g!==null&&g<=0,C=y??n?.login_server??null,w=e.filter(e=>!e.self&&e.access_resolved?.complete!==!0);return(0,z.jsxs)(`section`,{"data-testid":`tailnet-enroll`,style:{marginTop:24},children:[(0,z.jsx)(`h3`,{style:{marginBottom:4},children:`Add a device to the tailnet`}),(0,z.jsx)(`p`,{style:{fontSize:12,opacity:.75,marginTop:0},children:`Point the device at this control server, then authenticate it with a short-lived key.`}),(0,z.jsxs)(`div`,{"data-testid":`enroll-instructions`,style:{margin:`12px 0`,padding:14,borderRadius:8,border:`1px solid var(--border)`,background:`var(--bg-secondary)`},children:[(0,z.jsxs)(`div`,{style:{fontSize:12,marginBottom:10},children:[(0,z.jsx)(`strong`,{children:`Control server`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:4},children:[(0,z.jsx)(`code`,{"data-testid":`enroll-login-server`,style:{wordBreak:`break-all`,flex:1},children:C??`not configured — set the Headscale URL in Secrets first`}),C&&(0,z.jsx)(`button`,{type:`button`,"data-testid":`enroll-copy-server`,onClick:()=>{navigator.clipboard?.writeText(C),h(!0)},children:m?`Copied`:`Copy`})]})]}),(0,z.jsxs)(`details`,{open:!0,style:{fontSize:12},children:[(0,z.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600},children:`On a phone (iOS)`}),(0,z.jsxs)(`ol`,{style:{paddingLeft:18,lineHeight:1.7,marginBottom:6},children:[(0,z.jsxs)(`li`,{children:[`Install `,(0,z.jsx)(`strong`,{children:`Tailscale`}),` from the App Store — `,(0,z.jsx)(`strong`,{children:`1.38.1 or newer`}),`, the first release that supports an alternate control server.`]}),(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`strong`,{children:`Sign out of Tailscale first.`}),` The alternate-server setting is only read while the app is logged out.`]}),(0,z.jsxs)(`li`,{children:[`Open `,(0,z.jsx)(`strong`,{children:`iOS Settings`}),`, scroll past Game Center and TV Provider to`,` `,(0,z.jsx)(`strong`,{children:`Tailscale`}),`, and put the control server above into`,` `,(0,z.jsx)(`strong`,{children:`Alternate Coordination Server URL`}),`.`]}),(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`strong`,{children:`If this device was ever signed into Tailscale's own service, turn on “Reset Keychain”.`}),` `,`Skipping this is the usual reason the app keeps going back to the public login.`]}),(0,z.jsx)(`li`,{children:`Force-quit Tailscale from the app switcher, then reopen it — the setting is read at launch.`}),(0,z.jsxs)(`li`,{children:[`Tap the plain `,(0,z.jsx)(`strong`,{children:`Sign in`}),` option (not SSO). It should open this control server's page.`]}),(0,z.jsx)(`li`,{children:`Authenticate with the key below.`})]}),(0,z.jsxs)(`p`,{style:{opacity:.75,margin:0},children:[`The in-app route — account icon → `,(0,z.jsx)(`strong`,{children:`Log in…`}),` → options menu →`,` `,(0,z.jsx)(`strong`,{children:`Use custom coordination server`}),` — reaches the same place when it works, but that menu has been reported unresponsive on some builds. The Settings route above is the reliable one.`]})]}),(0,z.jsxs)(`details`,{style:{fontSize:12,marginTop:8},children:[(0,z.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600},children:`On Android`}),(0,z.jsxs)(`ol`,{style:{paddingLeft:18,lineHeight:1.7,margin:`4px 0 0`},children:[(0,z.jsx)(`li`,{children:`Install Tailscale from Google Play and make sure it is signed out.`}),(0,z.jsxs)(`li`,{children:[`Open the app, tap the account icon, then `,(0,z.jsx)(`strong`,{children:`Log in…`}),`.`]}),(0,z.jsxs)(`li`,{children:[`Open the top-right options menu → `,(0,z.jsx)(`strong`,{children:`Use custom coordination server`}),`.`]}),(0,z.jsx)(`li`,{children:`Enter the control server above, then authenticate with the key below.`})]})]})]}),u&&(0,z.jsx)(`div`,{role:`alert`,"data-testid":`tailnet-enroll-error`,style:{margin:`10px 0`,padding:10,borderRadius:8,border:`1px solid #ef4444`,color:`#ef4444`,fontSize:12},children:u}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:16,alignItems:`center`,flexWrap:`wrap`,margin:`12px 0`},children:[(0,z.jsxs)(`label`,{style:{fontSize:12,display:`flex`,gap:6,alignItems:`center`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`enroll-reusable`}),`Reusable (enroll more than one device)`]}),(0,z.jsxs)(`label`,{style:{fontSize:12,display:`flex`,gap:6,alignItems:`center`},children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),"data-testid":`enroll-ephemeral`}),`Ephemeral (drops off the list when offline)`]}),(0,z.jsx)(`button`,{type:`button`,onClick:x,disabled:c,"data-testid":`enroll-mint`,style:{cursor:c?`wait`:`pointer`},children:c?`Minting…`:n?`Mint another key`:`Get enrollment key`})]}),n&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:20,flexWrap:`wrap`,alignItems:`flex-start`},children:[(0,z.jsx)(`div`,{style:{background:`#fff`,padding:16,borderRadius:8},"data-testid":`enroll-qr`,children:S?(0,z.jsx)(`div`,{style:{width:150,height:150,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#ef4444`,fontSize:12,textAlign:`center`},children:`Key expired — mint another`}):(0,z.jsx)(uG,{value:n.key,size:150,level:`M`,includeMargin:!0})}),(0,z.jsxs)(`div`,{style:{flex:1,minWidth:260},children:[(0,z.jsxs)(`div`,{style:{fontSize:12,marginBottom:6},children:[(0,z.jsx)(`strong`,{children:`Enrollment key`}),` `,(0,z.jsx)(`span`,{"data-testid":`enroll-ttl`,style:{opacity:.7},children:S?`(expired)`:`(expires in ${g}s, ${n.reusable?`reusable`:`single-use`})`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:4},children:[(0,z.jsx)(`code`,{style:{wordBreak:`break-all`,flex:1,opacity:S?.4:1},children:n.key}),(0,z.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>{navigator.clipboard?.writeText(n.key),p(!0)},"data-testid":`enroll-copy`,children:f?`Copied`:`Copy`})]})]}),(0,z.jsxs)(`details`,{style:{fontSize:12,marginTop:6},children:[(0,z.jsx)(`summary`,{style:{cursor:`pointer`},children:`On a computer`}),(0,z.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:`tailscale up --login-server ${C??`<control-server>`} --authkey ${S?`<expired — mint another>`:n.key}`}),(0,z.jsxs)(`p`,{style:{opacity:.75},children:[`Always pass `,(0,z.jsx)(`code`,{children:`--login-server`}),` alongside any `,(0,z.jsx)(`code`,{children:`--reset`}),`, or the client silently repoints at the public Tailscale control plane.`]})]})]})]}),(0,z.jsxs)(`div`,{style:{marginTop:20},children:[(0,z.jsxs)(`h4`,{style:{marginBottom:6},children:[`Nodes (`,e.length,`)`]}),(0,z.jsx)(`ul`,{"data-testid":`enroll-node-list`,style:{listStyle:`none`,padding:0,fontSize:12,margin:0},children:e.map(e=>(0,z.jsxs)(`li`,{style:{padding:`4px 0`,display:`flex`,gap:8},children:[(0,z.jsx)(`span`,{title:e.online?`online`:`offline`,children:e.online?`🟢`:`⚪️`}),(0,z.jsx)(`strong`,{children:e.hostname}),(0,z.jsx)(`code`,{style:{opacity:.75},children:e.ip??`—`}),e.self&&(0,z.jsx)(`span`,{style:{opacity:.6},children:`(this host)`})]},`${e.hostname}-${e.ip??`noip`}`))}),w.length>0&&(0,z.jsxs)(`p`,{"data-testid":`enroll-access-warning`,style:{fontSize:12,color:`#f59e0b`,marginBottom:0},children:[w.length,` node(s) have no recorded login account — connecting to one fails as though it were unreachable. Run `,(0,z.jsx)(`code`,{children:`total-recall mesh access import`}),`.`]})]})]})}function kG(e){let t={...e};return t.security||={},t.security.dashboard||(t.security.dashboard={}),t.security.api||(t.security.api={}),t.security.network||(t.security.network={}),t.security.bind||(t.security.bind={}),t.security.rate_limits||(t.security.rate_limits={}),t.security.sandbox||(t.security.sandbox={}),t.security.privacy||(t.security.privacy={}),t.budget||={budget:{}},t.budget.budget||(t.budget.budget={}),t.brain||={},t.secrets||={},t}function AG({activeBrainId:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(`idle`),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),O=async()=>{D(!0),C(null);try{let e=await ni();if(C(e.message),e.scheduled){setTimeout(function e(t=0){Yr().then(e=>{f(e),C(`Server restarted — reconnected.`),D(!1)}).catch(()=>{if(t>=20){C(`Server restarted but has not answered yet — reload in a moment.`),D(!1);return}setTimeout(()=>e(t+1),1500)})},2e3);return}}catch(e){C(`Restart error: `+e.message)}D(!1)},k=async()=>{T(!0),C(null);try{let e=await ti();C(e.message||`Daemon restarted successfully.`);let t=await Yr().catch(()=>null);t&&f(t)}catch(e){C(`Restart error: `+e.message)}finally{T(!1)}},[A,j]=(0,v.useState)(!1),ee=async()=>{o(!0),i(null);try{let e=await yi();n(kG(e))}catch(e){console.error(e),i(e instanceof Error?e.message:`Failed to load settings`),n(null)}finally{o(!1)}};(0,v.useEffect)(()=>{Yr().then(f).catch(console.error),oi().then(e=>y({updateAvailable:!!e.updateAvailable,latestVersion:e.latestVersion,currentVersion:e.currentVersion})).catch(console.error),setTimeout(()=>{ee()},0)},[e]);let M=[{id:`antigravity`,name:`Antigravity (Gemini SDK)`,desc:`Primary core developer agent`},{id:`gemini`,name:`Gemini CLI`,desc:`Direct Gemini assistant binary`},{id:`claude`,name:`Claude Code`,desc:`Anthropic developer CLI wrapper`},{id:`codex`,name:`Codex CLI`,desc:`OpenAI agent binary integration`},{id:`grok`,name:`Grok CLI`,desc:`xAI developer binary integration`}],te=Array.isArray(d?.cli_agents)?d.cli_agents:Array.isArray(d?.agents)?d.agents:[],ne=async e=>{e.preventDefault(),m(!0),g(null);try{let e=await ei();g(e.output),Yr().then(f).catch(console.error)}catch(e){g(`Error: `+e.message)}finally{m(!1)}},N=async()=>{x(!0),C(null);try{let e=await si();if(e.success){let t=e.summary,n=[t?.updated==null?null:`${t.updated} updated`,t?.up_to_date==null?null:`${t.up_to_date} current`,t?.latest?`latest ${t.latest}`:null].filter(Boolean),r=e.restart?.scheduled?` Server is restarting into the new code.`:e.restart?.required?` Server still runs the old code — ${e.restart.reason}`:``;C(n.length?`Update complete — ${n.join(` · `)}.${r}`:(e.message||`Update complete.`)+r)}else{let t=(e.summary?.results||[]).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.error||`failed`}`).slice(0,3).join(`; `);C(`Update failed: ${e.message}${t?` (${t})`:``}`)}let t=await oi().catch(()=>null);t&&y({updateAvailable:!!t.updateAvailable,latestVersion:t.latestVersion,currentVersion:t.currentVersion})}catch(e){C(`Update error: `+e.message)}finally{x(!1)}},P=async()=>{if(t){c(`saving`);try{let e={...t};if(e.secrets){let t={};for(let[n,r]of Object.entries(e.secrets))typeof r==`string`&&r&&!r.includes(`•`)&&r!==`[redacted]`&&(t[n]=r);e.secrets=t}await bi(e),c(`saved`),setTimeout(()=>c(`idle`),2500)}catch(e){console.error(e),c(`error`),setTimeout(()=>c(`idle`),3e3)}}},re=async()=>{j(!0),u(`[Running] Rebuilding instruction surfaces…`);try{let e=await $r();u(`[Finished] Rebuilding instruction surfaces\n\n${e.message||(e.success?`Compile complete.`:`Compile finished with warnings.`)}`)}catch(e){u(`[Failed] Rebuild\n\n${e instanceof Error?e.message:String(e)}`)}finally{j(!1)}},ie=async()=>{try{let e=await R(`${Ln()}/api/extension/download`);if(!e.ok)throw Error(`Download failed: ${e.status}`);let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`total-recall-extension.zip`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}catch(e){u(`[Failed] Extension download\n\n${e instanceof Error?e.message:String(e)}`)}},ae=(e,t,r)=>{n(n=>n&&{...n,security:{...n.security,[e]:{...n.security[e]||{},[t]:r}}})},oe=(e,t)=>{n(n=>n&&{...n,budget:{...n.budget,budget:{...n.budget.budget||{},[e]:t}}})},se=(e,t)=>{n(n=>n?{...n,brain:{...n.brain,[e]:t}}:null)},ce=e=>Array.isArray(e)?e.filter(Boolean).join(`, `):``,le=e=>e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return a&&!t?(0,z.jsx)(`div`,{style:{padding:40,color:`var(--text-secondary)`},"data-testid":`settings-loading`,children:(0,z.jsx)(`div`,{className:`glass-card`,style:{display:`inline-block`,padding:`12px 24px`},children:`Loading Settings...`})}):r&&!t?(0,z.jsx)(`div`,{style:{padding:40},"data-testid":`settings-error`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`glass-card`,style:{display:`inline-block`,padding:`16px 24px`,border:`1px solid #ef4444`,color:`#ef4444`},children:[`Failed to load settings: `,r,(0,z.jsx)(`button`,{type:`button`,className:`btn-primary`,style:{marginLeft:16},onClick:()=>ee(),children:`Retry`})]})}):t?(0,z.jsxs)(`div`,{className:`settings-page-wrapper`,"data-testid":`settings-page`,children:[(0,z.jsx)(`style`,{children:`
|
|
5248
5248
|
.settings-page-wrapper {
|
|
5249
5249
|
padding: 32px 40px 100px;
|
|
5250
5250
|
max-width: 1200px;
|
|
@@ -5505,7 +5505,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5505
5505
|
A`,`,`,`,0,`,`,`,`,`,`,`,`
|
|
5506
5506
|
A`,`,`,`,0,0,`,`,`,`,`,`Z`]),D.x,D.y,a,a,+(u<0),E.x,E.y,r,r,+(k>180),+(u>0),S.x,S.y,a,a,+(u<0),C.x,C.y)}else b+=BK(Yme||=n2([`L`,`,`,`Z`]),t,n);return b},Qme={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},$me=e=>{var t=oY(e,Qme),n=t.cx,r=t.cy,i=t.innerRadius,a=t.outerRadius,o=t.cornerRadius,s=t.forceCornerRadius,c=t.cornerIsExternal,l=t.startAngle,u=t.endAngle,d=t.className;if(a<i||l===u)return null;var f=uK(`recharts-sector`,d),p=a-i,m=JK(o,p,0,!0),h=m>0&&Math.abs(l-u)<360?Zme({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(m,p/2),forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u}):i2({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:l,endAngle:u});return v.createElement(`path`,t2({},vK(t),{className:f,d:h}))};function ehe(e,t,n){if(e===`horizontal`)return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e===`vertical`)return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(ZJ(t)){if(e===`centric`){var r=t.cx,i=t.cy,a=t.innerRadius,o=t.outerRadius,s=t.angle,c=$0(r,i,a,s),l=$0(r,i,o,s);return[{x:c.x,y:c.y},{x:l.x,y:l.y}]}return e2(t)}}function the(e){return aZ(e)?NaN:Number(e)}function a2(e){return e?(e=the(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}function o2(e,t,n){n&&typeof n!=`number`&&nZ(e,t,n)&&(t=n=void 0),e=a2(e),t===void 0?(t=e,e=0):t=a2(t),n=n===void 0?e<t?1:-1:a2(n);let r=Math.max(Math.ceil((t-e)/(n||1)),0),i=Array(r);for(let t=0;t<r;t++)i[t]=e,e+=n;return i}var s2=e=>e.chartData,c2=$([s2],e=>{var t=e.chartData==null?0:e.chartData.length-1;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),l2=(e,t,n,r)=>r?c2(e):s2(e),nhe=(e,t,n)=>n?c2(e):s2(e),rhe=$([l2],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t==null?[]:t.slice(n,r+1)});$([c2],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t==null?[]:t.slice(n,r+1)});var ihe=$([s2],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t==null?[]:t.slice(n,r+1)});function u2(e,t){return che(e)||she(e,t)||ohe(e,t)||ahe()}function ahe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5507
5507
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ohe(e,t){if(e){if(typeof e==`string`)return d2(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d2(e,t):void 0}}function d2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function she(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function che(e){if(Array.isArray(e))return e}function f2(e){if(Array.isArray(e)&&e.length===2){var t=u2(e,2),n=t[0],r=t[1];if(Z$(n)&&Z$(r))return!0}return!1}function p2(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function m2(e,t){if(t&&typeof e!=`function`&&Array.isArray(e)&&e.length===2){var n=u2(e,2),r=n[0],i=n[1],a,o;if(Z$(r))a=r;else if(typeof r==`function`)return;if(Z$(i))o=i;else if(typeof i==`function`)return;var s=[a,o];if(f2(s))return s}}function lhe(e,t,n){if(!(!n&&t==null)){if(typeof e==`function`&&t!=null)try{var r=e(t,n);if(f2(r))return p2(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var i=u2(e,2),a=i[0],o=i[1],s,c;if(a===`auto`)t!=null&&(s=Math.min(...t));else if(WK(a))s=a;else if(typeof a==`function`)try{t!=null&&(s=a(t?.[0]))}catch{}else if(typeof a==`string`&&o1.test(a)){var l=o1.exec(a);if(l==null||l[1]==null||t==null)s=void 0;else{var u=+l[1];s=t[0]-u}}else s=t?.[0];if(o===`auto`)t!=null&&(c=Math.max(...t));else if(WK(o))c=o;else if(typeof o==`function`)try{t!=null&&(c=o(t?.[1]))}catch{}else if(typeof o==`string`&&s1.test(o)){var d=s1.exec(o);if(d==null||d[1]==null||t==null)c=void 0;else{var f=+d[1];c=t[1]+f}}else c=t?.[1];var p=[s,c];if(f2(p))return t==null?p:p2(p,t,n)}}}var h2=l(o(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),A(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),A(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,A=r.constructor,j=r.s==i.s?1:-1,ee=r.d,M=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=M.length,T=ee.length,g=new A(j),_=g.d=[],u=0;M[u]==(ee[u]||0);)++u;if(M[u]>(ee[u]||0)&&--l,x=o==null?o=A.precision:s?o+(S(r)-S(i))+1:o,x<0)return new A(0);if(x=x/p+2|0,u=0,O==1)for(d=0,M=M[0],x++;(u<T||d)&&x--;u++)C=d*f+(ee[u]||0),_[u]=C/M|0,d=C%M|0;else{for(d=f/(M[0]+1)|0,d>1&&(M=e(M,d),ee=e(ee,d),O=M.length,T=ee.length),w=O,v=ee.slice(0,O),y=v.length;y<O;)v[y++]=0;k=M.slice(),k.unshift(0),E=M[0],M[1]>=f/2&&++E;do d=0,c=t(M,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(M,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O<h?k:M,h))):(d==0&&(c=d=1),m=M.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(M,v,O,y),c<1&&(d++,n(v,O<y?k:M,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=ee[w]||0:(v=[ee[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,D(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?D(t,g):t):new h(0)}function k(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function A(e,t){if(e.length>t)return e.length=t,!0}function j(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=j,i.config=i.set=ee,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function ee(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0){if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i)}if((i=e[r=`LN10`])!==void 0){if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i)}return this}r=j(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))());function g2(e){return e===0?1:Math.floor(new h2.default(e).abs().log(10).toNumber())+1}function _2(e,t,n){for(var r=new h2.default(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}function v2(e,t){return phe(e)||fhe(e,t)||dhe(e,t)||uhe()}function uhe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5508
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dhe(e,t){if(e){if(typeof e==`string`)return y2(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y2(e,t):void 0}}function y2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function fhe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function phe(e){if(Array.isArray(e))return e}var b2=e=>{var t=v2(e,2),n=t[0],r=t[1],i=n,a=r;return n>r&&(i=r,a=n),[i,a]},x2=(e,t,n)=>{if(e.lte(0))return new h2.default(0);var r=g2(e.toNumber()),i=new h2.default(10).pow(r),a=e.div(i),o=r===1?.1:.05,s=new h2.default(Math.ceil(a.div(o).toNumber())).add(n).mul(o).mul(i);return t?new h2.default(s.toNumber()):new h2.default(Math.ceil(s.toNumber()))},S2=(e,t,n)=>{if(e.lte(0))return new h2.default(0);var r=[1,2,2.5,5],i=e.toNumber(),a=Math.floor(new h2.default(i).abs().log(10).toNumber()),o=new h2.default(10).pow(a),s=e.div(o).toNumber(),c=r.findIndex(e=>e>=s-1e-10);if(c===-1&&(o=o.mul(10),c=0),c+=n,c>=r.length){var l=Math.floor(c/r.length);c%=r.length,o=o.mul(new h2.default(10).pow(l))}var u=r[c]??1,d=new h2.default(u).mul(o);return t?d:new h2.default(Math.ceil(d.toNumber()))},mhe=(e,t,n)=>{var r=new h2.default(1),i=new h2.default(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new h2.default(10).pow(g2(e)-1),i=new h2.default(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new h2.default(Math.floor(e)))}else e===0?i=new h2.default(Math.floor((t-1)/2)):n||(i=new h2.default(Math.floor(e)));for(var o=Math.floor((t-1)/2),s=[],c=0;c<t;c++)s.push(i.add(new h2.default(c-o).mul(r)).toNumber());return s},C2=function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:x2;if(!Number.isFinite((t-e)/(n-1)))return{step:new h2.default(0),tickMin:new h2.default(0),tickMax:new h2.default(0)};var o=a(new h2.default(t).sub(e).div(n-1),r,i),s;e<=0&&t>=0?s=new h2.default(0):(s=new h2.default(e).add(t).div(2),s=s.sub(new h2.default(s).mod(o)));var c=Math.ceil(s.sub(e).div(o).toNumber()),l=Math.ceil(new h2.default(t).sub(s).div(o).toNumber()),u=c+l+1;return u>n?C2(e,t,n,r,i+1,a):(u<n&&(l=t>0?l+(n-u):l,c=t>0?c:c+(n-u)),{step:o,tickMin:s.sub(new h2.default(c).mul(o)),tickMax:s.add(new h2.default(l).mul(o))})},w2=function(e){var t=v2(e,2),n=t[0],r=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,s=Math.max(i,2),c=v2(b2([n,r]),2),l=c[0],u=c[1];if(l===-1/0||u===1/0){var d=u===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),u];return n>r?d.reverse():d}if(l===u)return mhe(l,i,a);var f=C2(l,u,s,a,0,o===`snap125`?S2:x2),p=f.step,m=f.tickMin,h=f.tickMax,g=_2(m,h.add(new h2.default(.1).mul(p)),p);return n>r?g.reverse():g},T2=function(e,t){var n=v2(e,2),r=n[0],i=n[1],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,s=v2(b2([r,i]),2),c=s[0],l=s[1];if(c===-1/0||l===1/0)return[r,i];if(c===l)return[c];var u=o===`snap125`?S2:x2,d=Math.max(t,2),f=u(new h2.default(l).sub(c).div(d-1),a,0),p=[..._2(new h2.default(c),new h2.default(l),f),l];if(a===!1){p=p.map(e=>Math.round(e));var m=p.length-1;m>0&&p[m]===p[m-1]&&(p=p.slice(0,m))}return r>i?p.reverse():p},hhe=e=>e.rootProps.barCategoryGap,E2=e=>e.rootProps.stackOffset,D2=e=>e.rootProps.reverseStackOrder,O2=e=>e.options.chartName,k2=e=>e.rootProps.syncId,A2=e=>e.rootProps.syncMethod,j2=e=>e.options.eventEmitter,ghe=e=>e.rootProps.baseValue,M2={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},N2={allowDecimals:!1,allowDuplicatedCategory:!0,allowDataOverflow:!1,angle:0,angleAxisId:0,axisLine:!0,axisLineType:`polygon`,cx:0,cy:0,hide:!1,includeHidden:!1,label:!1,niceTicks:`auto`,orientation:`outer`,reversed:!1,scale:`auto`,tick:!0,tickLine:!0,tickSize:8,type:`auto`,zIndex:M2.axis},P2={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,angle:0,axisLine:!0,includeHidden:!1,hide:!1,niceTicks:`auto`,label:!1,orientation:`right`,radiusAxisId:0,reversed:!1,scale:`auto`,stroke:`#ccc`,tick:!0,tickCount:5,tickLine:!0,type:`auto`,zIndex:M2.axis},F2=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function I2(e,t,n){if(n!==`auto`)return n;if(e!=null)return n1(e,t)?`category`:`number`}function L2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R2(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?L2(Object(n),!0).forEach(function(t){_he(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L2(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _he(e,t,n){return(t=vhe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vhe(e){var t=yhe(e,`string`);return typeof t==`symbol`?t:t+``}function yhe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var z2={allowDataOverflow:N2.allowDataOverflow,allowDecimals:N2.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:N2.angleAxisId,includeHidden:!1,name:void 0,reversed:N2.reversed,scale:N2.scale,tick:N2.tick,tickCount:void 0,ticks:void 0,type:N2.type,unit:void 0,niceTicks:`auto`},B2={allowDataOverflow:P2.allowDataOverflow,allowDecimals:P2.allowDecimals,allowDuplicatedCategory:P2.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:P2.radiusAxisId,includeHidden:P2.includeHidden,name:void 0,reversed:P2.reversed,scale:P2.scale,tick:P2.tick,tickCount:P2.tickCount,ticks:void 0,type:P2.type,unit:void 0,niceTicks:`auto`},V2=$([(e,t)=>{if(t!=null)return e.polarAxis.angleAxis[t]},V1],(e,t)=>{if(e!=null)return e;var n=I2(t,`angleAxis`,z2.type)??`category`;return R2(R2({},z2),{},{type:n})}),H2=$([(e,t)=>e.polarAxis.radiusAxis[t],V1],(e,t)=>{if(e!=null)return e;var n=I2(t,`radiusAxis`,B2.type)??`category`;return R2(R2({},B2),{},{type:n})}),U2=e=>e.polarOptions,W2=$([d1,f1,v1],Lme),G2=$([U2,W2],(e,t)=>{if(e!=null)return JK(e.innerRadius,t,0)}),K2=$([U2,W2],(e,t)=>{if(e!=null)return JK(e.outerRadius,t,t*.8)}),q2=$([U2],e=>e==null?[0,0]:[e.startAngle,e.endAngle]);$([V2,q2],F2);var J2=$([W2,G2,K2],(e,t,n)=>{if(e!=null&&t!=null&&n!=null)return[t,n]});$([H2,J2],F2);var Y2=$([R1,U2,G2,K2,d1,f1],(e,t,n,r,i,a)=>{if(!(e!==`centric`&&e!==`radial`||t==null||n==null||r==null)){var o=t.cx,s=t.cy,c=t.startAngle,l=t.endAngle;return{cx:JK(o,i,i/2),cy:JK(s,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:l,clockWise:!1}}}),X2=(e,t)=>t,Z2=(e,t,n)=>n;function Q2(e){return e?.id}function $2(e,t,n){var r=t.chartData,i=r===void 0?[]:r,a=n.allowDuplicatedCategory,o=n.dataKey,s=new Map;return e.forEach(e=>{var t=e.data??i;if(t!=null&&t.length!==0){var n=Q2(e);t.forEach((t,r)=>{var i=o==null||a?r:String(t1(t,o,null)),c=t1(t,e.dataKey,0),l=s.has(i)?s.get(i):{};Object.assign(l,{[n]:c}),s.set(i,l)})}}),Array.from(s.values())}function e4(e){return`stackId`in e&&e.stackId!=null&&e.dataKey!=null}var t4=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function n4(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function bhe(e,t){if(e.length===t.length){for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return!1}var r4=e=>{var t=R1(e);return t===`horizontal`?`xAxis`:t===`vertical`?`yAxis`:t===`centric`?`angleAxis`:`radiusAxis`},i4=e=>e.tooltip.settings.axisId;function a4(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(e){var t=i[0],n=i[1];return t<=n?e>=t&&e<=n:e>=n&&e<=t},bandwidth:n?()=>n.call(e):void 0,ticks:t?n=>t.call(e,n):void 0,map:(t,n)=>{var r=e(t);if(r!=null){if(e.bandwidth&&n!=null&&n.position){var i=e.bandwidth();switch(n.position){case`middle`:r+=i/2;break;case`end`:r+=i}}return r}}}}}var xhe=(e,t)=>{if(t!=null)switch(e){case`linear`:if(!f2(t)){for(var n,r,i=0;i<t.length;i++){var a=t[i];Z$(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t;default:return t}},o4=s({scaleBand:()=>pv,scaleDiverging:()=>vS,scaleDivergingLog:()=>yS,scaleDivergingPow:()=>xS,scaleDivergingSqrt:()=>SS,scaleDivergingSymlog:()=>bS,scaleIdentity:()=>Oy,scaleImplicit:()=>dv,scaleLinear:()=>Dy,scaleLog:()=>Py,scaleOrdinal:()=>fv,scalePoint:()=>hv,scalePow:()=>Vy,scaleQuantile:()=>Wy,scaleQuantize:()=>Gy,scaleRadial:()=>Uy,scaleSequential:()=>dS,scaleSequentialLog:()=>fS,scaleSequentialPow:()=>mS,scaleSequentialQuantile:()=>gS,scaleSequentialSqrt:()=>hS,scaleSequentialSymlog:()=>pS,scaleSqrt:()=>jre,scaleSymlog:()=>Ry,scaleThreshold:()=>Ky,scaleTime:()=>sS,scaleUtc:()=>cS,tickFormat:()=>Ty});function She(e){var t=o4;if(e in t&&typeof t[e]==`function`)return t[e]();var n=`scale${$K(e)}`;if(n in t&&typeof t[n]==`function`)return t[n]()}function s4(e,t,n){if(typeof e==`function`)return e.copy().domain(t).range(n);if(e!=null){var r=She(e);if(r!=null)return r.domain(t).range(n),r}}function c4(e,t,n,r){if(n!=null&&r!=null)return typeof e.scale==`function`?s4(e.scale,n,r):s4(t,n,r)}function Che(e){return`scale${$K(e)}`}function whe(e){return Che(e)in o4}var l4=(e,t,n)=>{if(e!=null){var r=e.scale,i=e.type;if(r===`auto`)return i===`category`&&n&&(n.indexOf(`LineChart`)>=0||n.indexOf(`AreaChart`)>=0||n.indexOf(`ComposedChart`)>=0&&!t)?`point`:i===`category`?`band`:`linear`;if(typeof r==`string`)return whe(r)?r:`point`}};function The(e,t){for(var n=0,r=e.length,i=e[0]<e[e.length-1];n<r;){var a=Math.floor((n+r)/2);(i?e[a]<t:e[a]>t)?n=a+1:r=a}return n}function u4(e,t){if(e){var n=t??e.domain(),r=n.map(t=>e(t)??0),i=e.range();if(!(n.length===0||i.length<2))return e=>{var t=The(r,e);if(t<=0)return n[0];if(t>=n.length)return n[n.length-1];var i=r[t-1]??0,a=r[t]??0;return Math.abs(e-i)<=Math.abs(e-a)?n[t-1]:n[t]}}}function Ehe(e){if(e!=null)return`invert`in e&&typeof e.invert==`function`?e.invert.bind(e):u4(e,void 0)}function d4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function f4(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d4(Object(n),!0).forEach(function(t){Dhe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d4(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Dhe(e,t,n){return(t=Ohe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ohe(e){var t=khe(e,`string`);return typeof t==`symbol`?t:t+``}function khe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p4(e,t){return Nhe(e)||Mhe(e,t)||jhe(e,t)||Ahe()}function Ahe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5508
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dhe(e,t){if(e){if(typeof e==`string`)return y2(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y2(e,t):void 0}}function y2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function fhe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function phe(e){if(Array.isArray(e))return e}var b2=e=>{var t=v2(e,2),n=t[0],r=t[1],i=n,a=r;return n>r&&(i=r,a=n),[i,a]},x2=(e,t,n)=>{if(e.lte(0))return new h2.default(0);var r=g2(e.toNumber()),i=new h2.default(10).pow(r),a=e.div(i),o=r===1?.1:.05,s=new h2.default(Math.ceil(a.div(o).toNumber())).add(n).mul(o).mul(i);return t?new h2.default(s.toNumber()):new h2.default(Math.ceil(s.toNumber()))},S2=(e,t,n)=>{if(e.lte(0))return new h2.default(0);var r=[1,2,2.5,5],i=e.toNumber(),a=Math.floor(new h2.default(i).abs().log(10).toNumber()),o=new h2.default(10).pow(a),s=e.div(o).toNumber(),c=r.findIndex(e=>e>=s-1e-10);if(c===-1&&(o=o.mul(10),c=0),c+=n,c>=r.length){var l=Math.floor(c/r.length);c%=r.length,o=o.mul(new h2.default(10).pow(l))}var u=r[c]??1,d=new h2.default(u).mul(o);return t?d:new h2.default(Math.ceil(d.toNumber()))},mhe=(e,t,n)=>{var r=new h2.default(1),i=new h2.default(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new h2.default(10).pow(g2(e)-1),i=new h2.default(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new h2.default(Math.floor(e)))}else e===0?i=new h2.default(Math.floor((t-1)/2)):n||(i=new h2.default(Math.floor(e)));for(var o=Math.floor((t-1)/2),s=[],c=0;c<t;c++)s.push(i.add(new h2.default(c-o).mul(r)).toNumber());return s},C2=function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:x2;if(!Number.isFinite((t-e)/(n-1)))return{step:new h2.default(0),tickMin:new h2.default(0),tickMax:new h2.default(0)};var o=a(new h2.default(t).sub(e).div(n-1),r,i),s;e<=0&&t>=0?s=new h2.default(0):(s=new h2.default(e).add(t).div(2),s=s.sub(new h2.default(s).mod(o)));var c=Math.ceil(s.sub(e).div(o).toNumber()),l=Math.ceil(new h2.default(t).sub(s).div(o).toNumber()),u=c+l+1;return u>n?C2(e,t,n,r,i+1,a):(u<n&&(l=t>0?l+(n-u):l,c=t>0?c:c+(n-u)),{step:o,tickMin:s.sub(new h2.default(c).mul(o)),tickMax:s.add(new h2.default(l).mul(o))})},w2=function(e){var t=v2(e,2),n=t[0],r=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,s=Math.max(i,2),c=v2(b2([n,r]),2),l=c[0],u=c[1];if(l===-1/0||u===1/0){var d=u===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),u];return n>r?d.reverse():d}if(l===u)return mhe(l,i,a);var f=C2(l,u,s,a,0,o===`snap125`?S2:x2),p=f.step,m=f.tickMin,h=f.tickMax,g=_2(m,h.add(new h2.default(.1).mul(p)),p);return n>r?g.reverse():g},T2=function(e,t){var n=v2(e,2),r=n[0],i=n[1],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,s=v2(b2([r,i]),2),c=s[0],l=s[1];if(c===-1/0||l===1/0)return[r,i];if(c===l)return[c];var u=o===`snap125`?S2:x2,d=Math.max(t,2),f=u(new h2.default(l).sub(c).div(d-1),a,0),p=[..._2(new h2.default(c),new h2.default(l),f),l];if(a===!1){p=p.map(e=>Math.round(e));var m=p.length-1;m>0&&p[m]===p[m-1]&&(p=p.slice(0,m))}return r>i?p.reverse():p},hhe=e=>e.rootProps.barCategoryGap,E2=e=>e.rootProps.stackOffset,D2=e=>e.rootProps.reverseStackOrder,O2=e=>e.options.chartName,k2=e=>e.rootProps.syncId,A2=e=>e.rootProps.syncMethod,j2=e=>e.options.eventEmitter,ghe=e=>e.rootProps.baseValue,M2={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},N2={allowDecimals:!1,allowDuplicatedCategory:!0,allowDataOverflow:!1,angle:0,angleAxisId:0,axisLine:!0,axisLineType:`polygon`,cx:0,cy:0,hide:!1,includeHidden:!1,label:!1,niceTicks:`auto`,orientation:`outer`,reversed:!1,scale:`auto`,tick:!0,tickLine:!0,tickSize:8,type:`auto`,zIndex:M2.axis},P2={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,angle:0,axisLine:!0,includeHidden:!1,hide:!1,niceTicks:`auto`,label:!1,orientation:`right`,radiusAxisId:0,reversed:!1,scale:`auto`,stroke:`#ccc`,tick:!0,tickCount:5,tickLine:!0,type:`auto`,zIndex:M2.axis},F2=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function I2(e,t,n){if(n!==`auto`)return n;if(e!=null)return n1(e,t)?`category`:`number`}function L2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R2(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?L2(Object(n),!0).forEach(function(t){_he(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L2(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _he(e,t,n){return(t=vhe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vhe(e){var t=yhe(e,`string`);return typeof t==`symbol`?t:t+``}function yhe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var z2={allowDataOverflow:N2.allowDataOverflow,allowDecimals:N2.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:N2.angleAxisId,includeHidden:!1,name:void 0,reversed:N2.reversed,scale:N2.scale,tick:N2.tick,tickCount:void 0,ticks:void 0,type:N2.type,unit:void 0,niceTicks:`auto`},B2={allowDataOverflow:P2.allowDataOverflow,allowDecimals:P2.allowDecimals,allowDuplicatedCategory:P2.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:P2.radiusAxisId,includeHidden:P2.includeHidden,name:void 0,reversed:P2.reversed,scale:P2.scale,tick:P2.tick,tickCount:P2.tickCount,ticks:void 0,type:P2.type,unit:void 0,niceTicks:`auto`},V2=$([(e,t)=>{if(t!=null)return e.polarAxis.angleAxis[t]},V1],(e,t)=>{if(e!=null)return e;var n=I2(t,`angleAxis`,z2.type)??`category`;return R2(R2({},z2),{},{type:n})}),H2=$([(e,t)=>e.polarAxis.radiusAxis[t],V1],(e,t)=>{if(e!=null)return e;var n=I2(t,`radiusAxis`,B2.type)??`category`;return R2(R2({},B2),{},{type:n})}),U2=e=>e.polarOptions,W2=$([d1,f1,v1],Lme),G2=$([U2,W2],(e,t)=>{if(e!=null)return JK(e.innerRadius,t,0)}),K2=$([U2,W2],(e,t)=>{if(e!=null)return JK(e.outerRadius,t,t*.8)}),q2=$([U2],e=>e==null?[0,0]:[e.startAngle,e.endAngle]);$([V2,q2],F2);var J2=$([W2,G2,K2],(e,t,n)=>{if(e!=null&&t!=null&&n!=null)return[t,n]});$([H2,J2],F2);var Y2=$([R1,U2,G2,K2,d1,f1],(e,t,n,r,i,a)=>{if(!(e!==`centric`&&e!==`radial`||t==null||n==null||r==null)){var o=t.cx,s=t.cy,c=t.startAngle,l=t.endAngle;return{cx:JK(o,i,i/2),cy:JK(s,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:l,clockWise:!1}}}),X2=(e,t)=>t,Z2=(e,t,n)=>n;function Q2(e){return e?.id}function $2(e,t,n){var r=t.chartData,i=r===void 0?[]:r,a=n.allowDuplicatedCategory,o=n.dataKey,s=new Map;return e.forEach(e=>{var t=e.data??i;if(t!=null&&t.length!==0){var n=Q2(e);t.forEach((t,r)=>{var i=o==null||a?r:String(t1(t,o,null)),c=t1(t,e.dataKey,0),l=s.has(i)?s.get(i):{};Object.assign(l,{[n]:c}),s.set(i,l)})}}),Array.from(s.values())}function e4(e){return`stackId`in e&&e.stackId!=null&&e.dataKey!=null}var t4=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function n4(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function bhe(e,t){if(e.length===t.length){for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return!1}var r4=e=>{var t=R1(e);return t===`horizontal`?`xAxis`:t===`vertical`?`yAxis`:t===`centric`?`angleAxis`:`radiusAxis`},i4=e=>e.tooltip.settings.axisId;function a4(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(e){var t=i[0],n=i[1];return t<=n?e>=t&&e<=n:e>=n&&e<=t},bandwidth:n?()=>n.call(e):void 0,ticks:t?n=>t.call(e,n):void 0,map:(t,n)=>{var r=e(t);if(r!=null){if(e.bandwidth&&n!=null&&n.position){var i=e.bandwidth();switch(n.position){case`middle`:r+=i/2;break;case`end`:r+=i}}return r}}}}}var xhe=(e,t)=>{if(t!=null)switch(e){case`linear`:if(!f2(t)){for(var n,r,i=0;i<t.length;i++){var a=t[i];Z$(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t;default:return t}},o4=s({scaleBand:()=>pv,scaleDiverging:()=>yS,scaleDivergingLog:()=>bS,scaleDivergingPow:()=>SS,scaleDivergingSqrt:()=>CS,scaleDivergingSymlog:()=>xS,scaleIdentity:()=>ky,scaleImplicit:()=>dv,scaleLinear:()=>Oy,scaleLog:()=>Fy,scaleOrdinal:()=>fv,scalePoint:()=>hv,scalePow:()=>Hy,scaleQuantile:()=>Gy,scaleQuantize:()=>Ky,scaleRadial:()=>Wy,scaleSequential:()=>fS,scaleSequentialLog:()=>pS,scaleSequentialPow:()=>hS,scaleSequentialQuantile:()=>_S,scaleSequentialSqrt:()=>gS,scaleSequentialSymlog:()=>mS,scaleSqrt:()=>Are,scaleSymlog:()=>zy,scaleThreshold:()=>qy,scaleTime:()=>cS,scaleUtc:()=>lS,tickFormat:()=>Ey});function She(e){var t=o4;if(e in t&&typeof t[e]==`function`)return t[e]();var n=`scale${$K(e)}`;if(n in t&&typeof t[n]==`function`)return t[n]()}function s4(e,t,n){if(typeof e==`function`)return e.copy().domain(t).range(n);if(e!=null){var r=She(e);if(r!=null)return r.domain(t).range(n),r}}function c4(e,t,n,r){if(n!=null&&r!=null)return typeof e.scale==`function`?s4(e.scale,n,r):s4(t,n,r)}function Che(e){return`scale${$K(e)}`}function whe(e){return Che(e)in o4}var l4=(e,t,n)=>{if(e!=null){var r=e.scale,i=e.type;if(r===`auto`)return i===`category`&&n&&(n.indexOf(`LineChart`)>=0||n.indexOf(`AreaChart`)>=0||n.indexOf(`ComposedChart`)>=0&&!t)?`point`:i===`category`?`band`:`linear`;if(typeof r==`string`)return whe(r)?r:`point`}};function The(e,t){for(var n=0,r=e.length,i=e[0]<e[e.length-1];n<r;){var a=Math.floor((n+r)/2);(i?e[a]<t:e[a]>t)?n=a+1:r=a}return n}function u4(e,t){if(e){var n=t??e.domain(),r=n.map(t=>e(t)??0),i=e.range();if(!(n.length===0||i.length<2))return e=>{var t=The(r,e);if(t<=0)return n[0];if(t>=n.length)return n[n.length-1];var i=r[t-1]??0,a=r[t]??0;return Math.abs(e-i)<=Math.abs(e-a)?n[t-1]:n[t]}}}function Ehe(e){if(e!=null)return`invert`in e&&typeof e.invert==`function`?e.invert.bind(e):u4(e,void 0)}function d4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function f4(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d4(Object(n),!0).forEach(function(t){Dhe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d4(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Dhe(e,t,n){return(t=Ohe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ohe(e){var t=khe(e,`string`);return typeof t==`symbol`?t:t+``}function khe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p4(e,t){return Nhe(e)||Mhe(e,t)||jhe(e,t)||Ahe()}function Ahe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5509
5509
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jhe(e,t){if(e){if(typeof e==`string`)return m4(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m4(e,t):void 0}}function m4(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Mhe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Nhe(e){if(Array.isArray(e))return e}var h4=[0,`auto`],g4={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`bottom`,padding:{left:0,right:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`category`,unit:void 0,niceTicks:`auto`},_4=(e,t)=>e.cartesianAxis.xAxis[t],v4=(e,t)=>_4(e,t)??g4,y4={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:h4,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`left`,padding:{top:0,bottom:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`number`,unit:void 0,niceTicks:`auto`,width:60},b4=(e,t)=>e.cartesianAxis.yAxis[t],x4=(e,t)=>b4(e,t)??y4,Phe={domain:[0,`auto`],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:``,range:[64,64],scale:`auto`,type:`number`,unit:``},S4=(e,t)=>e.cartesianAxis.zAxis[t]??Phe,C4=(e,t,n)=>{switch(t){case`xAxis`:return v4(e,n);case`yAxis`:return x4(e,n);case`zAxis`:return S4(e,n);case`angleAxis`:return V2(e,n);case`radiusAxis`:return H2(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},Fhe=(e,t,n)=>{switch(t){case`xAxis`:return v4(e,n);case`yAxis`:return x4(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},w4=(e,t,n)=>{switch(t){case`xAxis`:return v4(e,n);case`yAxis`:return x4(e,n);case`angleAxis`:return V2(e,n);case`radiusAxis`:return H2(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},T4=e=>e.graphicalItems.cartesianItems.some(e=>e.type===`bar`)||e.graphicalItems.polarItems.some(e=>e.type===`radialBar`);function E4(e,t){return n=>{switch(e){case`xAxis`:return`xAxisId`in n&&n.xAxisId===t;case`yAxis`:return`yAxisId`in n&&n.yAxisId===t;case`zAxis`:return`zAxisId`in n&&n.zAxisId===t;case`angleAxis`:return`angleAxisId`in n&&n.angleAxisId===t;case`radiusAxis`:return`radiusAxisId`in n&&n.radiusAxisId===t;default:return!1}}}var D4=e=>e.graphicalItems.cartesianItems,Ihe=$([X2,Z2],E4),O4=(e,t,n)=>e.filter(n).filter(e=>t?.includeHidden===!0||!e.hide),k4=$([D4,C4,Ihe],O4,{memoizeOptions:{resultEqualityCheck:n4}}),A4=$([k4],e=>e.filter(e=>e.type===`area`||e.type===`bar`).filter(e4)),j4=e=>e.filter(e=>!(`stackId`in e)||e.stackId===void 0),Lhe=$([k4],j4),M4=e=>e.map(e=>e.data).filter(Boolean).flat(1),Rhe=$([k4],e=>e.some(e=>!e.data)),N4=$([k4],M4,{memoizeOptions:{resultEqualityCheck:n4}}),P4=(e,t)=>{var n=t.chartData,r=n===void 0?[]:n,i=t.dataStartIndex,a=t.dataEndIndex;return e.length>0?e:r.slice(i,a+1)},F4=$([N4,l2],P4),zhe=(e,t,n)=>t?.dataKey==null?n.length>0?n.map(e=>e.dataKey).flatMap(t=>e.map(e=>({value:t1(e,t)}))):e.map(e=>({value:e})):e.map(e=>({value:t1(e,t.dataKey)})),I4=(e,t,n,r,i,a)=>{var o=r.chartData,s=o===void 0?[]:o,c=r.dataStartIndex,l=r.dataEndIndex,u=zhe(e,t,n);return i&&t?.dataKey!=null&&a.length>0?[...s.slice(c,l+1).map(e=>({value:t1(e,t.dataKey)})).filter(e=>e.value!=null),...u]:u},L4=$([F4,C4,k4,l2,Rhe,N4],I4);function R4(e){if(GK(e)||e instanceof Date){var t=Number(e);if(Z$(t))return t}}function z4(e){if(Array.isArray(e)){var t=[R4(e[0]),R4(e[1])];return f2(t)?t:void 0}var n=R4(e);if(n!=null)return[n,n]}function B4(e){return e.map(R4).filter(eq)}function Bhe(e,t){var n=R4(e),r=R4(t);return n==null&&r==null?0:n==null?-1:r==null?1:n-r}var Vhe=$([L4],e=>e?.map(e=>e.value).sort(Bhe));function V4(e,t){switch(e){case`xAxis`:return t.direction===`x`;case`yAxis`:return t.direction===`y`;default:return!1}}function Hhe(e,t,n){if(!n||!n.length)return[];var r;if(typeof t==`number`&&!HK(t))r=t;else if(Array.isArray(t)){var i=B4(t);i.length>0&&(r=Math.max(...i))}return r==null?[]:B4(n.flatMap(t=>{var n=t1(e,t.dataKey),i,a;if(Array.isArray(n)){var o=p4(n,2);i=o[0],a=o[1]}else i=a=n;if(!(!Z$(i)||!Z$(a)))return[r-i,r+a]}))}var H4=e=>w4(e,r4(e),i4(e)),U4=$([H4],e=>e?.dataKey),Uhe=$([A4,l2,H4],$2),W4=(e,t,n,r)=>{var i=t.reduce((e,t)=>{if(t.stackId==null)return e;var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},{});return Object.fromEntries(Object.entries(i).map(t=>{var i=p4(t,2),a=i[0],o=i[1],s=r?[...o].reverse():o;return[a,{stackedData:_de(e,s.map(Q2),n),graphicalItems:s}]}))},G4=$([Uhe,A4,E2,D2],W4),K4=(e,t,n,r)=>{var i=t.dataStartIndex,a=t.dataEndIndex;if(r==null&&n!==`zAxis`)return xde(e,i,a)},Whe=$([C4],e=>e.allowDataOverflow),q4=e=>{if(e==null||!(`domain`in e))return h4;if(e.domain!=null)return e.domain;if(`ticks`in e&&e.ticks!=null){if(e.type===`number`){var t=B4(e.ticks);return[Math.min(...t),Math.max(...t)]}if(e.type===`category`)return e.ticks.map(String)}return e?.domain??h4},J4=$([C4],q4),Y4=$([J4,Whe],m2),Ghe=$([G4,s2,X2,Y4],K4,{memoizeOptions:{resultEqualityCheck:t4}}),X4=e=>e.errorBars,Khe=(e,t,n)=>e.flatMap(e=>t[e.id]).filter(Boolean).filter(e=>V4(n,e)),Z4=function(){var e=[...arguments].filter(Boolean);if(e.length!==0){var t=e.flat();return[Math.min(...t),Math.max(...t)]}},Q4=function(e,t,n,r,i){var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:[],o,s;if(n.length>0&&n.forEach(e=>{var n=e.data==null?a:[...e.data],c=r[e.id]?.filter(e=>V4(i,e));n.forEach(n=>{var r=t1(n,t.dataKey??e.dataKey),i=Hhe(n,r,c);if(i.length>=2){var a=Math.min(...i),l=Math.max(...i);(o==null||a<o)&&(o=a),(s==null||l>s)&&(s=l)}var u=z4(r);u!=null&&(o=o==null?u[0]:Math.min(o,u[0]),s=s==null?u[1]:Math.max(s,u[1]))})}),t?.dataKey!=null&&n.length===0&&e.forEach(e=>{var n=z4(t1(e,t.dataKey));n!=null&&(o=o==null?n[0]:Math.min(o,n[0]),s=s==null?n[1]:Math.max(s,n[1]))}),Z$(o)&&Z$(s))return[o,s]},qhe=$([F4,C4,Lhe,X4,X2,rhe],Q4,{memoizeOptions:{resultEqualityCheck:t4}});function Jhe(e){var t=e.value;if(GK(t)||t instanceof Date)return t}var Yhe=(e,t,n)=>{var r=e.map(Jhe).filter(e=>e!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&YK(r))?o2(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},$4=e=>e.referenceElements.dots,e3=(e,t,n)=>e.filter(e=>e.ifOverflow===`extendDomain`).filter(e=>t===`xAxis`?e.xAxisId===n:e.yAxisId===n),Xhe=$([$4,X2,Z2],e3),t3=e=>e.referenceElements.areas,Zhe=$([t3,X2,Z2],e3),n3=e=>e.referenceElements.lines,Qhe=$([n3,X2,Z2],e3),r3=(e,t)=>{if(e!=null){var n=B4(e.map(e=>t===`xAxis`?e.x:e.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},$he=$(Xhe,X2,r3),i3=(e,t)=>{if(e!=null){var n=B4(e.flatMap(e=>[t===`xAxis`?e.x1:e.y1,t===`xAxis`?e.x2:e.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},ege=$([Zhe,X2],i3);function tge(e){if(e.x!=null)return B4([e.x]);var t=e.segment?.map(e=>e.x);return t==null||t.length===0?[]:B4(t)}function nge(e){if(e.y!=null)return B4([e.y]);var t=e.segment?.map(e=>e.y);return t==null||t.length===0?[]:B4(t)}var a3=(e,t)=>{if(e!=null){var n=e.flatMap(e=>t===`xAxis`?tge(e):nge(e));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},rge=$($he,$([Qhe,X2],a3),ege,(e,t,n)=>Z4(e,n,t)),o3=(e,t,n,r,i,a,o,s,c)=>{if(n!=null)return n;var l=o===`vertical`&&s===`xAxis`||o===`horizontal`&&s===`yAxis`?Z4(r,a,i):Z4(a,i),u=lhe(t,l,e.allowDataOverflow);return u==null&&e.allowDataOverflow&&l==null&&c!=null?c:u},ige=$([C4,J4,Y4,Ghe,qhe,rge,R1,X2,$([C4],e=>{if(!(e==null||e.type!==`number`||!(`ticks`in e)||e.ticks==null)){var t=B4(e.ticks);if(t.length!==0)return[Math.min(...t),Math.max(...t)]}},{memoizeOptions:{resultEqualityCheck:t4}})],o3,{memoizeOptions:{resultEqualityCheck:t4}}),age=[0,1],s3=(e,t,n,r,i,a,o)=>{if(e!=null&&n!=null&&n.length!==0||o!==void 0){var s=e.dataKey,c=e.type,l=n1(t,a);return l&&s==null?o2(0,n?.length??0):c===`category`?Yhe(r,e,l):i===`expand`&&!l?age:o}},c3=$([C4,R1,F4,L4,E2,X2,ige],s3),l3=$([C4,T4,O2],l4),u3=(e,t,n)=>{var r=t.niceTicks;if(r!==`none`){var i=q4(t),a=Array.isArray(i)&&(i[0]===`auto`||i[1]===`auto`);if((r===`snap125`||r===`adaptive`)&&t!=null&&t.tickCount&&f2(e)){if(a)return w2(e,t.tickCount,t.allowDecimals,r);if(t.type===`number`)return T2(e,t.tickCount,t.allowDecimals,r)}if(r===`auto`&&n===`linear`&&t!=null&&t.tickCount){if(a&&f2(e))return w2(e,t.tickCount,t.allowDecimals,`adaptive`);if(t.type===`number`&&f2(e))return T2(e,t.tickCount,t.allowDecimals,`adaptive`)}}},d3=$([c3,w4,l3],u3),f3=(e,t,n,r)=>{if(r!==`angleAxis`&&e?.type===`number`&&f2(t)&&Array.isArray(n)&&n.length>0){var i=t[0],a=n[0]??0,o=t[1],s=n[n.length-1]??0;return[Math.min(i,a),Math.max(o,s)]}return t},oge=$([C4,c3,d3,X2],f3),p3=$($(L4,C4,(e,t)=>{if(!(!t||t.type!==`number`)){var n=1/0,r=Array.from(B4(e.map(e=>e.value))).sort((e,t)=>e-t),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var s=0;s<r.length-1;s++){var c=r[s],l=r[s+1];if(c!=null&&l!=null){var u=l-c;n=Math.min(n,u)}}return n/o}}),R1,hhe,v1,(e,t,n,r,i)=>i,(e,t,n,r,i)=>{if(!Z$(e))return 0;var a=t===`vertical`?r.height:r.width;if(i===`gap`)return e*a/2;if(i===`no-gap`){var o=JK(n,e*a),s=e*a/2;return s-o-(s-o)/a*o}return 0}),sge=(e,t,n)=>{var r=v4(e,t);return r==null||typeof r.padding!=`string`?0:p3(e,`xAxis`,t,n,r.padding)},cge=(e,t,n)=>{var r=x4(e,t);return r==null||typeof r.padding!=`string`?0:p3(e,`yAxis`,t,n,r.padding)},lge=$(v4,sge,(e,t)=>{if(e==null)return{left:0,right:0};var n=e.padding;return typeof n==`string`?{left:t,right:t}:{left:(n.left??0)+t,right:(n.right??0)+t}}),uge=$(x4,cge,(e,t)=>{if(e==null)return{top:0,bottom:0};var n=e.padding;return typeof n==`string`?{top:t,bottom:t}:{top:(n.top??0)+t,bottom:(n.bottom??0)+t}}),m3=$([v1,lge,C1,S1,(e,t,n)=>n],(e,t,n,r,i)=>{var a=r.padding;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),h3=$([v1,R1,uge,C1,S1,(e,t,n)=>n],(e,t,n,r,i,a)=>{var o=i.padding;return a?[r.height-o.bottom,o.top]:t===`horizontal`?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),g3=(e,t,n,r)=>{switch(t){case`xAxis`:return m3(e,n,r);case`yAxis`:return h3(e,n,r);case`zAxis`:return S4(e,n)?.range;case`angleAxis`:return q2(e);case`radiusAxis`:return J2(e,n);default:return}},_3=$([C4,g3],F2),v3=$([C4,l3,$([l3,oge],xhe),_3],c4),y3=(e,t,n,r)=>{if(n!=null&&n.dataKey!=null){var i=n.type,a=n.scale;if(n1(e,r)&&(i===`number`||a!==`auto`))return t.map(e=>e.value)}},b3=$([R1,L4,w4,X2],y3),x3=$([v3],a4);$([v3],Ehe),$([v3,Vhe],u4),$([k4,X4,X2],Khe);function S3(e,t){return e.id<t.id?-1:+(e.id>t.id)}var C3=(e,t)=>t,w3=(e,t,n)=>n,dge=$(m1,C3,w3,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(S3)),fge=$(h1,C3,w3,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(S3)),T3=(e,t)=>{var n=typeof t.height==`number`?t.height:30;return{width:e.width,height:n}},pge=(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height}),mge=$(v1,v4,T3),hge=(e,t,n)=>{switch(t){case`top`:return e.top;case`bottom`:return n-e.bottom;default:return 0}},gge=(e,t,n)=>{switch(t){case`left`:return e.left;case`right`:return n-e.right;default:return 0}},_ge=$(f1,v1,dge,C3,w3,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=T3(t,n);o??=hge(t,r,e);var c=r===`top`&&!i||r===`bottom`&&i;a[n.id]=o-Number(c)*s.height,o+=(c?-1:1)*s.height}),a}),vge=$(d1,v1,fge,C3,w3,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=pge(t,n);o??=gge(t,r,e);var c=r===`left`&&!i||r===`right`&&i;a[n.id]=o-Number(c)*s.width,o+=(c?-1:1)*s.width}),a}),yge=$([v1,v4,(e,t)=>{var n=v4(e,t);if(n!=null)return _ge(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),bge=$([v1,x4,(e,t)=>{var n=x4(e,t);if(n!=null)return vge(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),xge=$(v1,x4,(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height})),E3=(e,t,n,r)=>{if(n!=null){var i=n.allowDuplicatedCategory,a=n.type,o=n.dataKey,s=n1(e,r),c=t.map(e=>e.value),l=c.filter(e=>e!=null);if(o&&s&&a===`category`&&i&&YK(l))return c}},D3=$([R1,L4,C4,X2],E3),O3=$([R1,Fhe,l3,x3,D3,b3,g3,d3,X2],(e,t,n,r,i,a,o,s,c)=>{if(t!=null){var l=n1(e,c);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:l,niceTicks:s,range:o,realScaleType:n,scale:r}}}),k3=$([R1,w4,l3,x3,d3,g3,D3,b3,X2],(e,t,n,r,i,a,o,s,c)=>{if(t!=null&&r!=null){var l=n1(e,c),u=t.type,d=t.ticks,f=t.tickCount,p=n===`scaleBand`&&typeof r.bandwidth==`function`?r.bandwidth()/2:2,m=u===`category`&&r.bandwidth?r.bandwidth()/p:0;m=c===`angleAxis`&&a!=null&&a.length>=2?VK(a[0]-a[1])*2*m:m;var h=d||i;return h?h.map((e,t)=>{var n=o?o.indexOf(e):e,i=r.map(n);return Z$(i)?{index:t,coordinate:i+m,value:e,offset:m}:null}).filter(eq):l&&s?s.map((e,t)=>{var n=r.map(e);return Z$(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(eq):r.ticks?r.ticks(f).map((e,t)=>{var n=r.map(e);return Z$(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(eq):r.domain().map((e,t)=>{var n=r.map(e);return Z$(n)?{coordinate:n+m,value:o?o[e]:e,index:t,offset:m}:null}).filter(eq)}}),A3=$([R1,w4,x3,g3,D3,b3,X2],(e,t,n,r,i,a,o)=>{if(t!=null&&n!=null&&r!=null&&r[0]!==r[1]){var s=n1(e,o),c=t.tickCount,l=0;return l=o===`angleAxis`&&r?.length>=2?VK(r[0]-r[1])*2*l:l,s&&a?a.map((e,t)=>{var r=n.map(e);return Z$(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(eq):n.ticks?n.ticks(c).map((e,t)=>{var r=n.map(e);return Z$(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(eq):n.domain().map((e,t)=>{var r=n.map(e);return Z$(r)?{coordinate:r+l,value:i?i[e]:e,index:t,offset:l}:null}).filter(eq)}}),j3=$(C4,x3,(e,t)=>{if(e!=null&&t!=null)return f4(f4({},e),{},{scale:t})});$((e,t,n)=>S4(e,n),$([$([C4,l3,c3,_3],c4)],a4),(e,t)=>{if(e!=null&&t!=null)return f4(f4({},e),{},{scale:t})});var Sge=$([R1,m1,h1],(e,t,n)=>{switch(e){case`horizontal`:return t.some(e=>e.reversed)?`right-to-left`:`left-to-right`;case`vertical`:return n.some(e=>e.reversed)?`bottom-to-top`:`top-to-bottom`;case`centric`:case`radial`:return`left-to-right`;default:return}});$([(e,t,n)=>e.renderedTicks[t]?.[n]],e=>{if(!(!e||e.length===0))return t=>{var n=1/0,r=e[0];for(var i of e){var a=Math.abs(i.coordinate-t);a<n&&(n=a,r=i)}return r?.value}});var M3=e=>e.options.defaultTooltipEventType,N3=e=>e.options.validateTooltipEventTypes;function P3(e,t,n){if(e==null)return t;var r=e?`axis`:`item`;return n==null?t:n.includes(r)?r:t}function F3(e,t){return P3(t,M3(e),N3(e))}function Cge(e){return VX(t=>F3(t,e))}var I3=(e,t)=>{var n,r=Number(t);if(!(HK(r)||t==null))return r>=0?e==null||(n=e[r])==null?void 0:n.value:void 0},wge=e=>e.tooltip.settings,L3={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},R3=x$({name:`tooltip`,initialState:{itemInteraction:{click:L3,hover:L3},axisInteraction:{click:L3,hover:L3},keyboardInteraction:L3,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:`hover`,axisId:0,active:!1,defaultIndex:void 0}},reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(i$(t.payload))},prepare:g$()},replaceTooltipEntrySettings:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next,a=t$(e).tooltipItemPayloads.indexOf(i$(r));a>-1&&(e.tooltipItemPayloads[a]=i$(i))},prepare:g$()},removeTooltipEntrySettings:{reducer(e,t){var n=t$(e).tooltipItemPayloads.indexOf(i$(t.payload));n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:g$()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),z3=R3.actions,Tge=z3.addTooltipEntrySettings,Ege=z3.replaceTooltipEntrySettings,Dge=z3.removeTooltipEntrySettings,Oge=z3.setTooltipSettingsState,kge=z3.setActiveMouseOverItemIndex;z3.mouseLeaveItem;var B3=z3.mouseLeaveChart;z3.setActiveClickItemIndex;var V3=z3.setMouseOverAxisIndex,Age=z3.setMouseClickAxisIndex,H3=z3.setSyncInteraction,U3=z3.setKeyboardInteraction,jge=R3.reducer;function W3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G3(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?W3(Object(n),!0).forEach(function(t){Mge(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W3(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mge(e,t,n){return(t=Nge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Nge(e){var t=Pge(e,`string`);return typeof t==`symbol`?t:t+``}function Pge(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Fge(e,t,n){return t===`axis`?n===`click`?e.axisInteraction.click:e.axisInteraction.hover:n===`click`?e.itemInteraction.click:e.itemInteraction.hover}function Ige(e){return e.index!=null}var K3=(e,t,n,r)=>{if(t==null)return L3;var i=Fge(e,t,n);if(i==null)return L3;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(Ige(i)){if(a)return G3(G3({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return G3(G3({},L3),{},{coordinate:i.coordinate})};function Lge(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function Rge(e,t){var n=Lge(e),r=t[0],i=t[1];return n!==void 0&&n>=Math.min(r,i)&&n<=Math.max(r,i)}function zge(e,t,n){if(n==null||t==null)return!0;var r=t1(e,t);return r==null||!f2(n)||Rge(r,n)}var q3=(e,t,n,r)=>{var i=e?.index;if(i==null)return null;var a=Number(i);if(!Z$(a))return i;var o=0,s=1/0;t.length>0&&(s=t.length-1);var c=Math.max(o,Math.min(a,s)),l=t[c];return l==null||zge(l,n,r)?String(c):null},J3=(e,t,n,r,i,a,o)=>{if(a!=null){var s=o[0]?.getPosition(a);if(s!=null)return s;var c=i?.[Number(a)];if(c)switch(n){case`horizontal`:return{x:c.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:c.coordinate}}}},Y3=(e,t,n,r)=>{if(t===`axis`)return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i=n===`hover`?e.itemInteraction.hover.graphicalItemId:e.itemInteraction.click.graphicalItemId;if(e.syncInteraction.active&&i==null)return e.tooltipItemPayloads;if(i==null&&(r!=null||e.keyboardInteraction.active)){var a=e.tooltipItemPayloads[0];return a==null?[]:[a]}return e.tooltipItemPayloads.filter(e=>e.settings?.graphicalItemId===i)},X3=e=>e.options.tooltipPayloadSearcher,Z3=e=>e.tooltip;function Q3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $3(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Q3(Object(n),!0).forEach(function(t){Bge(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q3(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Bge(e,t,n){return(t=Vge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vge(e){var t=Hge(e,`string`);return typeof t==`symbol`?t:t+``}function Hge(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Uge(e){if(typeof e==`string`||typeof e==`number`)return e}function Wge(e){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e}function Gge(e){if(typeof e==`string`||typeof e==`number`)return e;if(typeof e==`function`)return t=>e(t)}function e6(e){if(typeof e==`string`)return e}function Kge(e){if(!(typeof e!=`object`||!e))return{name:`name`in e?Uge(e.name):void 0,unit:`unit`in e?Wge(e.unit):void 0,dataKey:`dataKey`in e?Gge(e.dataKey):void 0,payload:`payload`in e?e.payload:void 0,color:`color`in e?e6(e.color):void 0,fill:`fill`in e?e6(e.fill):void 0}}function qge(e,t){return e??t}var t6=(e,t,n,r,i,a,o)=>{if(t!=null&&a!=null){var s=n.chartData,c=n.computedData,l=n.dataStartIndex,u=n.dataEndIndex;return e.reduce((e,n)=>{var d=n.dataDefinedOnItem,f=n.settings,p=qge(d,s),m=Array.isArray(p)?X$(p,l,u):p,h=f?.dataKey??r,g=f?.nameKey,_;return r&&Array.isArray(m)&&!Array.isArray(m[0])&&o===`axis`?(_=ZK(m,r,i),_??=a(m,t,c,g)):_=a(m,t,c,g),Array.isArray(_)?_.forEach(t=>{var n=Kge(t),r=n?.name,i=n?.dataKey,a=n?.payload,o=$3($3({},f),{},{name:r,unit:n?.unit,color:n?.color??f?.color,fill:n?.fill??f?.fill});e.push(l1({tooltipEntrySettings:o,dataKey:i,payload:a,value:t1(a,i),name:r==null?void 0:String(r)}))}):e.push(l1({tooltipEntrySettings:f,dataKey:h,payload:_,value:t1(_,h),name:t1(_,g)??f?.name})),e},[])}},n6=$([H4,T4,O2],l4),r6=$([$([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),H4,$([r4,i4],E4)],O4,{memoizeOptions:{resultEqualityCheck:n4}}),Jge=$([r6],e=>e.filter(e4)),i6=$([r6],M4,{memoizeOptions:{resultEqualityCheck:n4}}),Yge=$([r6],e=>e.some(e=>!e.data)),a6=$([i6,s2],P4),Xge=$([Jge,s2,H4],$2),o6=$([a6,H4,r6,s2,Yge,i6],I4),s6=$([H4],q4),c6=$([s6,$([H4],e=>e.allowDataOverflow)],m2),Zge=$([$([Xge,$([r6],e=>e.filter(e4)),E2,D2],W4),s2,r4,c6],K4),Qge=$([a6,H4,$([r6],j4),X4,r4,ihe],Q4,{memoizeOptions:{resultEqualityCheck:t4}}),$ge=$([$([$4,r4,i4],e3),r4],r3),e_e=$([$([t3,r4,i4],e3),r4],i3),l6=$([H4,R1,a6,o6,E2,r4,$([H4,s6,c6,Zge,Qge,$([$ge,$([$([n3,r4,i4],e3),r4],a3),e_e],Z4),R1,r4],o3)],s3),t_e=$([H4,l6,$([l6,H4,n6],u3),r4],f3),u6=e=>g3(e,r4(e),i4(e),!1),d6=$([H4,u6],F2),f6=$([$([H4,n6,t_e,d6],c4)],a4),p6=$([R1,H4,n6,f6,u6,$([R1,o6,H4,r4],E3),$([R1,o6,H4,r4],y3),r4],(e,t,n,r,i,a,o,s)=>{if(t){var c=t.type,l=n1(e,s);if(r){var u=n===`scaleBand`&&r.bandwidth?r.bandwidth()/2:2,d=c===`category`&&r.bandwidth?r.bandwidth()/u:0;return d=s===`angleAxis`&&i!=null&&i?.length>=2?VK(i[0]-i[1])*2*d:d,l&&o?o.map((e,t)=>{var n=r.map(e);return Z$(n)?{coordinate:n+d,value:e,index:t,offset:d}:null}).filter(eq):r.domain().map((e,t)=>{var n=r.map(e);return Z$(n)?{coordinate:n+d,value:a?a[e]:e,index:t,offset:d}:null}).filter(eq)}}}),m6=$([M3,N3,wge],(e,t,n)=>P3(n.shared,e,t)),h6=e=>e.tooltip.settings.trigger,g6=e=>e.tooltip.settings.defaultIndex,_6=$([Z3,m6,h6,g6],K3),v6=$([_6,a6,U4,l6],q3),y6=$([p6,v6],I3),n_e=$([_6],e=>{if(e)return e.dataKey}),r_e=$([_6],e=>{if(e)return e.graphicalItemId}),b6=$([Z3,m6,h6,g6],Y3),i_e=$([_6,$([d1,f1,R1,v1,p6,g6,b6],J3)],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),a_e=$([_6],e=>e?.active??!1),o_e=$([$([b6,v6,s2,U4,y6,X3,m6],t6)],e=>{if(e!=null){var t=e.map(e=>e.payload).filter(e=>e!=null);return Array.from(new Set(t))}});function x6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function S6(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x6(Object(n),!0).forEach(function(t){s_e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function s_e(e,t,n){return(t=c_e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c_e(e){var t=l_e(e,`string`);return typeof t==`symbol`?t:t+``}function l_e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var u_e=()=>VX(H4),d_e=()=>{var e=u_e(),t=VX(p6),n=VX(f6);return c1(!e||!n?void 0:S6(S6({},e),{},{scale:n}),t)};function C6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w6(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?C6(Object(n),!0).forEach(function(t){f_e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C6(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f_e(e,t,n){return(t=p_e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p_e(e){var t=m_e(e,`string`);return typeof t==`symbol`?t:t+``}function m_e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var h_e=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`horizontal`)return{x:i.coordinate,y:r.relativeY};if(e===`vertical`)return{x:r.relativeX,y:i.coordinate}}return{x:0,y:0}},g_e=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`centric`){var a=i.coordinate,o=r.radius;return w6(w6(w6({},r),$0(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var s=i.coordinate,c=r.angle;return w6(w6(w6({},r),$0(r.cx,r.cy,s,c)),{},{angle:c,radius:s})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function __e(e,t){var n=e.relativeX,r=e.relativeY;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var T6=(e,t,n,r,i)=>{var a=t?.length??0;if(a<=1||e==null)return 0;if(r===`angleAxis`&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var o=i[1]-i[0],s=(t,n,r)=>[e,e+o,e-o].some(e=>(r?e>=t:e>t)&&e<=n),c=0;c<a;c++){var l=c>0?n[c-1]?.coordinate:n[a-1]?.coordinate,u=n[c]?.coordinate,d=c>=a-1?n[0]?.coordinate:n[c+1]?.coordinate,f=void 0;if(l!=null&&u!=null&&d!=null){if(VK(u-l)!==VK(d-u)){var p=[];if(VK(d-u)===VK(i[1]-i[0])){f=d;var m=u+i[1]-i[0];p[0]=Math.min(m,(m+l)/2),p[1]=Math.max(m,(m+l)/2)}else{f=l;var h=d+i[1]-i[0];p[0]=Math.min(u,(h+u)/2),p[1]=Math.max(u,(h+u)/2)}var g=[Math.min(u,(f+u)/2),Math.max(u,(f+u)/2)];if(s(g[0],g[1],!1)||s(p[0],p[1],!0))return n[c]?.index}else{var _=Math.min(l,d),v=Math.max(l,d);if(s((_+u)/2,(v+u)/2,!1))return n[c]?.index}}}else if(t)for(var y=0;y<a;y++){var b=t[y];if(b!=null){var x=t[y+1],S=t[y-1];if(y===0&&x!=null&&e<=(b.coordinate+x.coordinate)/2||y===a-1&&S!=null&&e>(b.coordinate+S.coordinate)/2||y>0&&y<a-1&&S!=null&&x!=null&&e>(b.coordinate+S.coordinate)/2&&e<=(b.coordinate+x.coordinate)/2)return b.index}}return-1},E6=()=>VX(O2),D6=(e,t)=>t,O6=(e,t,n)=>n,k6=(e,t,n,r)=>r,v_e=$(p6,e=>uZ(e,e=>e.coordinate)),A6=$([Z3,D6,O6,k6],K3),j6=$([A6,a6,U4,l6],q3),y_e=(e,t,n)=>{if(t!=null){var r=Z3(e);return t===`axis`?n===`hover`?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n===`hover`?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},M6=$([Z3,D6,O6,k6],Y3),N6=$([d1,f1,R1,v1,p6,k6,M6],J3),b_e=$([A6,N6],(e,t)=>e.coordinate??t),P6=$([p6,j6],I3),x_e=$([M6,j6,s2,U4,P6,X3,D6],t6),S_e=$([A6,j6],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),C_e=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&__e(e,o)){var s=T6(Sde(e,t),a,i,n,r),c=h_e(t,i,s,e);return{activeIndex:String(s),activeCoordinate:c}}},w_e=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var s=Hme(e,n);if(s){var c=T6(Cde(s,t),o,a,r,i),l=g_e(t,a,c,s);return{activeIndex:String(c),activeCoordinate:l}}}},T_e=(e,t,n,r,i,a,o,s)=>{if(!(!e||!t||!r||!i||!a))return t===`horizontal`||t===`vertical`?C_e(e,t,r,i,a,o,s):w_e(e,t,n,r,i,a,o)},E_e=$(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),D_e=$(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(e=>parseInt(e,10)).concat(Object.values(M2));return Array.from(new Set(t)).sort((e,t)=>e-t)},{memoizeOptions:{resultEqualityCheck:bhe}});function F6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function I6(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?F6(Object(n),!0).forEach(function(t){O_e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F6(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function O_e(e,t,n){return(t=k_e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k_e(e){var t=A_e(e,`string`);return typeof t==`symbol`?t:t+``}function A_e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var j_e={zIndexMap:Object.values(M2).reduce((e,t)=>I6(I6({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),{})},M_e=new Set(Object.values(M2));function N_e(e){return M_e.has(e)}var L6=x$({name:`zIndex`,initialState:j_e,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:g$()},unregisterZIndexPortal:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]&&(--e.zIndexMap[n].consumers,e.zIndexMap[n].consumers<=0&&!N_e(n)&&delete e.zIndexMap[n])},prepare:g$()},registerZIndexPortalElement:{reducer:(e,t)=>{var n=t.payload,r=n.zIndex,i=n.element,a=n.isPanorama;e.zIndexMap[r]?a?e.zIndexMap[r].panoramaElement=i$(i):e.zIndexMap[r].element=i$(i):e.zIndexMap[r]={consumers:0,element:a?void 0:i$(i),panoramaElement:a?i$(i):void 0}},prepare:g$()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:g$()}}}),R6=L6.actions,P_e=R6.registerZIndexPortal,z6=R6.unregisterZIndexPortal,F_e=R6.registerZIndexPortalElement,I_e=R6.unregisterZIndexPortalElement,L_e=L6.reducer;function B6(e){var t=e.zIndex,n=e.children,r=ofe()&&t!==void 0&&t!==0,i=x1(),a=(0,v.useRef)(void 0),o=(0,v.useRef)(new Set),s=LX(),c=VX(e=>E_e(e,t,i));if((0,v.useLayoutEffect)(()=>{if(!r){var e=o.current;e.forEach(e=>{s(z6({zIndex:e}))}),e.clear(),a.current=void 0;return}if(o.current.has(t)||(s(P_e({zIndex:t})),o.current.add(t)),c){a.current=c;var n=o.current;n.forEach(e=>{e!==t&&(s(z6({zIndex:e})),n.delete(e))})}},[s,t,r,c]),(0,v.useLayoutEffect)(()=>{var e=o.current;return()=>{e.forEach(e=>{s(z6({zIndex:e}))}),e.clear()}},[s]),!r)return n;var l=c??a.current;return l?(0,X1.createPortal)(n,l):null}function V6(){return V6=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V6.apply(null,arguments)}function H6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function U6(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?H6(Object(n),!0).forEach(function(t){R_e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H6(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function R_e(e,t,n){return(t=z_e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function z_e(e){var t=B_e(e,`string`);return typeof t==`symbol`?t:t+``}function B_e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function V_e(e){var t=e.cursor,n=e.cursorComp,r=e.cursorProps;return(0,v.isValidElement)(t)?(0,v.cloneElement)(t,r):(0,v.createElement)(n,r)}function H_e(e){var t=e.coordinate,n=e.payload,r=e.index,i=e.offset,a=e.tooltipAxisBandSize,o=e.layout,s=e.cursor,c=e.tooltipEventType,l=e.chartName,u=t,d=n,f=r;if(!s||!u||l!==`ScatterChart`&&c!==`axis`)return null;var p,m,h;if(l===`ScatterChart`)p=u,m=Vpe,h=M2.cursorLine;else if(l===`BarChart`)p=Hpe(o,u,i,a),m=Mme,h=M2.cursorRectangle;else if(o===`radial`&&ZJ(u)){var g=e2(u),_=g.cx,y=g.cy,b=g.radius;p={cx:_,cy:y,startAngle:g.startAngle,endAngle:g.endAngle,innerRadius:b,outerRadius:b},m=$me,h=M2.cursorLine}else p={points:ehe(o,u,i)},m=T0,h=M2.cursorLine;var x=typeof s==`object`&&`className`in s?s.className:void 0,S=U6(U6(U6(U6({stroke:`#ccc`,pointerEvents:`none`},i),p),_K(s)),{},{payload:d,payloadIndex:f,className:uK(`recharts-tooltip-cursor`,x)});return v.createElement(B6,{zIndex:e.zIndex??h},v.createElement(V_e,{cursor:s,cursorComp:m,cursorProps:S}))}function U_e(e){var t=d_e(),n=F1(),r=z1(),i=E6();return t==null||n==null||r==null||i==null?null:v.createElement(H_e,V6({},e,{offset:n,layout:r,tooltipAxisBandSize:t,chartName:i}))}var W6=(0,v.createContext)(null),W_e=()=>(0,v.useContext)(W6),G_e=l(o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1).default,G6=new G_e,K6=`recharts.syncEvent.tooltip`,q6=`recharts.syncEvent.brush`,K_e=(e,t)=>{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!HK(n))return e[n]}},J6=x$({name:`options`,initialState:{chartName:``,tooltipPayloadSearcher:()=>void 0,eventEmitter:void 0,defaultTooltipEventType:`axis`},reducers:{createEventEmitter:e=>{e.eventEmitter??=Symbol(`rechartsEventEmitter`)}}}),q_e=J6.reducer,J_e=J6.actions.createEventEmitter;function Y_e(e){return e.tooltip.syncInteraction}var Y6=x$({name:`chartData`,initialState:{chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},reducers:{setChartData(e,t){if(e.chartData=i$(t.payload),t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var n=t.payload,r=n.startIndex,i=n.endIndex;r!=null&&(e.dataStartIndex=r),i!=null&&(e.dataEndIndex=i)}}}),X6=Y6.actions,Z6=X6.setChartData,X_e=X6.setDataStartEndIndexes;X6.setComputedData;var Z_e=Y6.reducer,Q_e=[`x`,`y`];function Q6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $6(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Q6(Object(n),!0).forEach(function(t){$_e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q6(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $_e(e,t,n){return(t=eve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eve(e){var t=tve(e,`string`);return typeof t==`symbol`?t:t+``}function tve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function nve(e,t){if(e==null)return{};var n,r,i=rve(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function rve(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ive(){var e=VX(k2),t=VX(j2),n=LX(),r=VX(A2),i=VX(p6),a=z1(),o=P1(),s=VX(e=>e.rootProps.className);(0,v.useEffect)(()=>{if(e==null)return tq;var s=(s,c,l)=>{if(t!==l&&e===s){if(c.payload.active===!1){n(H3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(r===`index`){var u;if(o&&c!=null&&(u=c.payload)!=null&&u.coordinate&&c.payload.sourceViewBox){var d=c.payload.coordinate,f=d.x,p=d.y,m=nve(d,Q_e),h=c.payload.sourceViewBox,g=h.x,_=h.y,v=h.width,y=h.height,b=$6($6({},m),{},{x:o.x+(v?(f-g)/v:0)*o.width,y:o.y+(y?(p-_)/y:0)*o.height});n($6($6({},c),{},{payload:$6($6({},c.payload),{},{coordinate:b})}))}else n(c);return}if(i!=null){var x;typeof r==`function`?x=i[r(i,{activeTooltipIndex:c.payload.index==null?void 0:Number(c.payload.index),isTooltipActive:c.payload.active,activeIndex:c.payload.index==null?void 0:Number(c.payload.index),activeLabel:c.payload.label,activeDataKey:c.payload.dataKey,activeCoordinate:c.payload.coordinate})]:r===`value`&&(x=i.find(e=>String(e.value)===c.payload.label));var S=c.payload.coordinate;if(S==null||o==null){n(H3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(x==null){n(H3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:void 0}));return}var C=S.x,w=S.y,T=Math.min(C,o.x+o.width),E=Math.min(w,o.y+o.height),D={x:a===`horizontal`?x.coordinate:T,y:a===`horizontal`?E:x.coordinate};n(H3({active:c.payload.active,coordinate:D,dataKey:c.payload.dataKey,index:String(x.index),label:c.payload.label,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:c.payload.graphicalItemId}))}}};return G6.on(K6,s),()=>{G6.off(K6,s)}},[s,n,t,e,r,i,a,o])}function ave(){var e=VX(k2),t=VX(j2),n=LX();(0,v.useEffect)(()=>{if(e==null)return tq;var r=(r,i,a)=>{t!==a&&e===r&&n(X_e(i))};return G6.on(q6,r),()=>{G6.off(q6,r)}},[n,t,e])}function ove(){var e=LX();(0,v.useEffect)(()=>{e(J_e())},[e]),ive(),ave()}function sve(e,t,n,r,i,a){var o=VX(n=>y_e(n,e,t)),s=VX(r_e),c=VX(j2),l=VX(k2),u=VX(A2),d=VX(Y_e)?.sourceViewBox!=null,f=P1();(0,v.useEffect)(()=>{if(!d&&l!=null&&c!=null){var e=H3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r==`number`?String(r):r,sourceViewBox:f,graphicalItemId:s});G6.emit(K6,l,e,c)}},[d,n,o,s,i,r,c,l,u,a,f])}function e8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function t8(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?e8(Object(n),!0).forEach(function(t){cve(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):e8(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cve(e,t,n){return(t=lve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lve(e){var t=uve(e,`string`);return typeof t==`symbol`?t:t+``}function uve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function dve(e,t){return hve(e)||mve(e,t)||pve(e,t)||fve()}function fve(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5510
5510
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pve(e,t){if(e){if(typeof e==`string`)return n8(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?n8(e,t):void 0}}function n8(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mve(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function hve(e){if(Array.isArray(e))return e}function gve(e){return e.dataKey}function _ve(e,t){return v.isValidElement(e)?v.cloneElement(e,t):typeof e==`function`?v.createElement(e,t):v.createElement(spe,t)}var r8=[],vve={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:`ease`,axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:`auto`,itemSorter:`name`,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:` : `,trigger:`hover`,useTranslate3d:!1,wrapperStyle:{}};function yve(e){var t=oY(e,vve),n=t.active,r=t.allowEscapeViewBox,i=t.animationDuration,a=t.animationEasing,o=t.content,s=t.filterNull,c=t.isAnimationActive,l=t.offset,u=t.payloadUniqBy,d=t.position,f=t.reverseDirection,p=t.useTranslate3d,m=t.wrapperStyle,h=t.cursor,g=t.shared,_=t.trigger,y=t.defaultIndex,b=t.portal,x=t.axisId,S=LX(),C=typeof y==`number`?String(y):y;(0,v.useEffect)(()=>{S(Oge({shared:g,trigger:_,axisId:x,active:n,defaultIndex:C}))},[S,g,_,x,n,C]);var w=P1(),T=h0(),E=Cge(g),D=VX(e=>S_e(e,E,_,C))??{},O=D.activeIndex,k=D.isActive,A=VX(e=>x_e(e,E,_,C)),j=VX(e=>P6(e,E,_,C)),ee=VX(e=>b_e(e,E,_,C)),M=A,te=W_e(),ne=n??k??!1,N=dve(wZ([M,ne]),2),P=N[0],re=N[1],ie=E===`axis`?j:void 0;sve(E,_,ee,ie,O,ne);var ae=b??te;if(ae==null||w==null||E==null)return null;var oe=M??r8;ne||(oe=r8),s&&oe.length&&(oe=kX(oe.filter(e=>e.value!=null&&(e.hide!==!0||t.includeHidden)),u,gve));var se=oe.length>0,ce=t8(t8({},t),{},{payload:oe,label:ie,active:ne,activeIndex:O,coordinate:ee,accessibilityLayer:T}),le=v.createElement(Dpe,{allowEscapeViewBox:r,animationDuration:i,animationEasing:a,isAnimationActive:c,active:ne,coordinate:ee,hasPayload:se,offset:l,position:d,reverseDirection:f,useTranslate3d:p,viewBox:w,wrapperStyle:m,lastBoundingBox:P,innerRef:re,hasPortalFromProps:!!b},_ve(o,ce));return v.createElement(v.Fragment,null,(0,X1.createPortal)(le,ae),ne&&v.createElement(U_e,{cursor:h,tooltipEventType:E,coordinate:ee,payload:oe,index:O}))}function bve(e,t,n){return(t=xve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xve(e){var t=Sve(e,`string`);return typeof t==`symbol`?t:t+``}function Sve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Cve=class{constructor(e){bve(this,`cache`,new Map),this.maxSize=e}get(e){var t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;n!=null&&this.cache.delete(n)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};function i8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wve(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i8(Object(n),!0).forEach(function(t){Tve(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i8(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tve(e,t,n){return(t=Eve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Eve(e){var t=Dve(e,`string`);return typeof t==`symbol`?t:t+``}function Dve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var a8=wve({},{cacheSize:2e3,enableCache:!0}),o8=new Cve(a8.cacheSize),Ove={position:`absolute`,top:`-20000px`,left:0,padding:0,margin:0,border:`none`,whiteSpace:`pre`},s8=`recharts_measurement_span`;function kve(e,t){return`${e}|${t.fontSize||``}|${t.fontFamily||``}|${t.fontWeight||``}|${t.fontStyle||``}|${t.letterSpacing||``}|${t.textTransform||``}`}var c8=(e,t)=>{try{var n=document.getElementById(s8);n||(n=document.createElement(`span`),n.setAttribute(`id`,s8),n.setAttribute(`aria-hidden`,`true`),document.body.appendChild(n)),Object.assign(n.style,Ove,t),n.textContent=`${e}`;var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},l8=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||l0.isSsr)return{width:0,height:0};if(!a8.enableCache)return c8(e,t);var n=kve(e,t),r=o8.get(n);if(r)return r;var i=c8(e,t);return o8.set(n,i),i},u8;function d8(e,t){return Nve(e)||Mve(e,t)||jve(e,t)||Ave()}function Ave(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5511
5511
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jve(e,t){if(e){if(typeof e==`string`)return f8(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f8(e,t):void 0}}function f8(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Mve(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Nve(e){if(Array.isArray(e))return e}function Pve(e,t,n){return(t=Fve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Fve(e){var t=Ive(e,`string`);return typeof t==`symbol`?t:t+``}function Ive(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var p8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,m8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Lve=/^(px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q)$/,Rve=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,zve={cm:96/2.54,mm:96/25.4,pt:96/72,pc:16,in:96,Q:96/101.6,px:1},Bve=[`cm`,`mm`,`pt`,`pc`,`in`,`Q`,`px`];function Vve(e){return Bve.includes(e)}var h8=`NaN`;function Hve(e,t){return e*zve[t]}var g8=class e{static parse(t){var n=d8(Rve.exec(t)??[],3),r=n[1],i=n[2];return r==null?e.NaN:new e(parseFloat(r),i??``)}constructor(e,t){this.num=e,this.unit=t,this.num=e,this.unit=t,HK(e)&&(this.unit=``),t!==``&&!Lve.test(t)&&(this.num=NaN,this.unit=``),Vve(t)&&(this.num=Hve(e,t),this.unit=`px`)}add(t){return this.unit===t.unit?new e(this.num+t.num,this.unit):new e(NaN,``)}subtract(t){return this.unit===t.unit?new e(this.num-t.num,this.unit):new e(NaN,``)}multiply(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num/t.num,this.unit||t.unit)}toString(){return`${this.num}${this.unit}`}isNaN(){return HK(this.num)}};u8=g8,Pve(g8,`NaN`,new u8(NaN,``));function _8(e){if(e==null||e.includes(h8))return h8;for(var t=e;t.includes(`*`)||t.includes(`/`);){var n=d8(p8.exec(t)??[],4),r=n[1],i=n[2],a=n[3],o=g8.parse(r??``),s=g8.parse(a??``),c=i===`*`?o.multiply(s):o.divide(s);if(c.isNaN())return h8;t=t.replace(p8,c.toString())}for(;t.includes(`+`)||/.-\d+(?:\.\d+)?/.test(t);){var l=d8(m8.exec(t)??[],4),u=l[1],d=l[2],f=l[3],p=g8.parse(u??``),m=g8.parse(f??``),h=d===`+`?p.add(m):p.subtract(m);if(h.isNaN())return h8;t=t.replace(m8,h.toString())}return t}var v8=/\(([^()]*)\)/;function Uve(e){for(var t=e,n;(n=v8.exec(t))!=null;){var r=d8(n,2)[1];t=t.replace(v8,_8(r))}return t}function Wve(e){var t=e.replace(/\s+/g,``);return t=Uve(t),t=_8(t),t}function Gve(e){try{return Wve(e)}catch{return h8}}function y8(e){var t=Gve(e.slice(5,-1));return t===h8?``:t}var Kve=[`x`,`y`,`lineHeight`,`capHeight`,`fill`,`scaleToFit`,`textAnchor`,`verticalAnchor`],qve=[`dx`,`dy`,`angle`,`className`,`breakAll`];function b8(){return b8=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},b8.apply(null,arguments)}function x8(e,t){if(e==null)return{};var n,r,i=Jve(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Jve(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function S8(e,t){return Qve(e)||Zve(e,t)||Xve(e,t)||Yve()}function Yve(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|