Files
glitch_automata_lab/backend/public/admin/assets/index-COp4VUl7.js
T

4117 lines
835 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&s(f)}).observe(document,{childList:!0,subtree:!0});function n(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=n(l);fetch(l.href,c)}})();function Gx(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var $d={exports:{}},hl={};var sv;function nb(){if(sv)return hl;sv=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(s,l,c){var f=null;if(c!==void 0&&(f=""+c),l.key!==void 0&&(f=""+l.key),"key"in l){c={};for(var p in l)p!=="key"&&(c[p]=l[p])}else c=l;return l=c.ref,{$$typeof:a,type:s,key:f,ref:l!==void 0?l:null,props:c}}return hl.Fragment=e,hl.jsx=n,hl.jsxs=n,hl}var rv;function ib(){return rv||(rv=1,$d.exports=nb()),$d.exports}var g=ib(),Qd={exports:{}},Mt={};var ov;function ab(){if(ov)return Mt;ov=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),v=Symbol.iterator;function M(z){return z===null||typeof z!="object"?null:(z=v&&z[v]||z["@@iterator"],typeof z=="function"?z:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,y={};function x(z,te,Ee){this.props=z,this.context=te,this.refs=y,this.updater=Ee||E}x.prototype.isReactComponent={},x.prototype.setState=function(z,te){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,te,"setState")},x.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function P(){}P.prototype=x.prototype;function L(z,te,Ee){this.props=z,this.context=te,this.refs=y,this.updater=Ee||E}var R=L.prototype=new P;R.constructor=L,w(R,x.prototype),R.isPureReactComponent=!0;var I=Array.isArray;function O(){}var U={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function N(z,te,Ee){var Oe=Ee.ref;return{$$typeof:a,type:z,key:te,ref:Oe!==void 0?Oe:null,props:Ee}}function k(z,te){return N(z.type,te,z.props)}function V(z){return typeof z=="object"&&z!==null&&z.$$typeof===a}function Q(z){var te={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(Ee){return te[Ee]})}var fe=/\/+/g;function pe(z,te){return typeof z=="object"&&z!==null&&z.key!=null?Q(""+z.key):te.toString(36)}function J(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(O,O):(z.status="pending",z.then(function(te){z.status==="pending"&&(z.status="fulfilled",z.value=te)},function(te){z.status==="pending"&&(z.status="rejected",z.reason=te)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function G(z,te,Ee,Oe,He){var le=typeof z;(le==="undefined"||le==="boolean")&&(z=null);var Me=!1;if(z===null)Me=!0;else switch(le){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(z.$$typeof){case a:case e:Me=!0;break;case _:return Me=z._init,G(Me(z._payload),te,Ee,Oe,He)}}if(Me)return He=He(z),Me=Oe===""?"."+pe(z,0):Oe,I(He)?(Ee="",Me!=null&&(Ee=Me.replace(fe,"$&/")+"/"),G(He,te,Ee,"",function(rt){return rt})):He!=null&&(V(He)&&(He=k(He,Ee+(He.key==null||z&&z.key===He.key?"":(""+He.key).replace(fe,"$&/")+"/")+Me)),te.push(He)),1;Me=0;var Ae=Oe===""?".":Oe+":";if(I(z))for(var je=0;je<z.length;je++)Oe=z[je],le=Ae+pe(Oe,je),Me+=G(Oe,te,Ee,le,He);else if(je=M(z),typeof je=="function")for(z=je.call(z),je=0;!(Oe=z.next()).done;)Oe=Oe.value,le=Ae+pe(Oe,je++),Me+=G(Oe,te,Ee,le,He);else if(le==="object"){if(typeof z.then=="function")return G(J(z),te,Ee,Oe,He);throw te=String(z),Error("Objects are not valid as a React child (found: "+(te==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":te)+"). If you meant to render a collection of children, use an array instead.")}return Me}function j(z,te,Ee){if(z==null)return z;var Oe=[],He=0;return G(z,Oe,"","",function(le){return te.call(Ee,le,He++)}),Oe}function se(z){if(z._status===-1){var te=z._result;te=te(),te.then(function(Ee){(z._status===0||z._status===-1)&&(z._status=1,z._result=Ee)},function(Ee){(z._status===0||z._status===-1)&&(z._status=2,z._result=Ee)}),z._status===-1&&(z._status=0,z._result=te)}if(z._status===1)return z._result.default;throw z._result}var Se=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var te=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(te))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},xe={map:j,forEach:function(z,te,Ee){j(z,function(){te.apply(this,arguments)},Ee)},count:function(z){var te=0;return j(z,function(){te++}),te},toArray:function(z){return j(z,function(te){return te})||[]},only:function(z){if(!V(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return Mt.Activity=S,Mt.Children=xe,Mt.Component=x,Mt.Fragment=n,Mt.Profiler=l,Mt.PureComponent=L,Mt.StrictMode=s,Mt.Suspense=m,Mt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,Mt.__COMPILER_RUNTIME={__proto__:null,c:function(z){return U.H.useMemoCache(z)}},Mt.cache=function(z){return function(){return z.apply(null,arguments)}},Mt.cacheSignal=function(){return null},Mt.cloneElement=function(z,te,Ee){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var Oe=w({},z.props),He=z.key;if(te!=null)for(le in te.key!==void 0&&(He=""+te.key),te)!A.call(te,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&te.ref===void 0||(Oe[le]=te[le]);var le=arguments.length-2;if(le===1)Oe.children=Ee;else if(1<le){for(var Me=Array(le),Ae=0;Ae<le;Ae++)Me[Ae]=arguments[Ae+2];Oe.children=Me}return N(z.type,He,Oe)},Mt.createContext=function(z){return z={$$typeof:f,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:c,_context:z},z},Mt.createElement=function(z,te,Ee){var Oe,He={},le=null;if(te!=null)for(Oe in te.key!==void 0&&(le=""+te.key),te)A.call(te,Oe)&&Oe!=="key"&&Oe!=="__self"&&Oe!=="__source"&&(He[Oe]=te[Oe]);var Me=arguments.length-2;if(Me===1)He.children=Ee;else if(1<Me){for(var Ae=Array(Me),je=0;je<Me;je++)Ae[je]=arguments[je+2];He.children=Ae}if(z&&z.defaultProps)for(Oe in Me=z.defaultProps,Me)He[Oe]===void 0&&(He[Oe]=Me[Oe]);return N(z,le,He)},Mt.createRef=function(){return{current:null}},Mt.forwardRef=function(z){return{$$typeof:p,render:z}},Mt.isValidElement=V,Mt.lazy=function(z){return{$$typeof:_,_payload:{_status:-1,_result:z},_init:se}},Mt.memo=function(z,te){return{$$typeof:h,type:z,compare:te===void 0?null:te}},Mt.startTransition=function(z){var te=U.T,Ee={};U.T=Ee;try{var Oe=z(),He=U.S;He!==null&&He(Ee,Oe),typeof Oe=="object"&&Oe!==null&&typeof Oe.then=="function"&&Oe.then(O,Se)}catch(le){Se(le)}finally{te!==null&&Ee.types!==null&&(te.types=Ee.types),U.T=te}},Mt.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},Mt.use=function(z){return U.H.use(z)},Mt.useActionState=function(z,te,Ee){return U.H.useActionState(z,te,Ee)},Mt.useCallback=function(z,te){return U.H.useCallback(z,te)},Mt.useContext=function(z){return U.H.useContext(z)},Mt.useDebugValue=function(){},Mt.useDeferredValue=function(z,te){return U.H.useDeferredValue(z,te)},Mt.useEffect=function(z,te){return U.H.useEffect(z,te)},Mt.useEffectEvent=function(z){return U.H.useEffectEvent(z)},Mt.useId=function(){return U.H.useId()},Mt.useImperativeHandle=function(z,te,Ee){return U.H.useImperativeHandle(z,te,Ee)},Mt.useInsertionEffect=function(z,te){return U.H.useInsertionEffect(z,te)},Mt.useLayoutEffect=function(z,te){return U.H.useLayoutEffect(z,te)},Mt.useMemo=function(z,te){return U.H.useMemo(z,te)},Mt.useOptimistic=function(z,te){return U.H.useOptimistic(z,te)},Mt.useReducer=function(z,te,Ee){return U.H.useReducer(z,te,Ee)},Mt.useRef=function(z){return U.H.useRef(z)},Mt.useState=function(z){return U.H.useState(z)},Mt.useSyncExternalStore=function(z,te,Ee){return U.H.useSyncExternalStore(z,te,Ee)},Mt.useTransition=function(){return U.H.useTransition()},Mt.version="19.2.7",Mt}var lv;function Wp(){return lv||(lv=1,Qd.exports=ab()),Qd.exports}var sb=Wp();const ee=Gx(sb);var Jd={exports:{}},pl={},eh={exports:{}},th={};var cv;function rb(){return cv||(cv=1,(function(a){function e(G,j){var se=G.length;G.push(j);e:for(;0<se;){var Se=se-1>>>1,xe=G[Se];if(0<l(xe,j))G[Se]=j,G[se]=xe,se=Se;else break e}}function n(G){return G.length===0?null:G[0]}function s(G){if(G.length===0)return null;var j=G[0],se=G.pop();if(se!==j){G[0]=se;e:for(var Se=0,xe=G.length,z=xe>>>1;Se<z;){var te=2*(Se+1)-1,Ee=G[te],Oe=te+1,He=G[Oe];if(0>l(Ee,se))Oe<xe&&0>l(He,Ee)?(G[Se]=He,G[Oe]=se,Se=Oe):(G[Se]=Ee,G[te]=se,Se=te);else if(Oe<xe&&0>l(He,se))G[Se]=He,G[Oe]=se,Se=Oe;else break e}}return j}function l(G,j){var se=G.sortIndex-j.sortIndex;return se!==0?se:G.id-j.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;a.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();a.unstable_now=function(){return f.now()-p}}var m=[],h=[],_=1,S=null,v=3,M=!1,E=!1,w=!1,y=!1,x=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function R(G){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=G)s(h),j.sortIndex=j.expirationTime,e(m,j);else break;j=n(h)}}function I(G){if(w=!1,R(G),!E)if(n(m)!==null)E=!0,O||(O=!0,Q());else{var j=n(h);j!==null&&J(I,j.startTime-G)}}var O=!1,U=-1,A=5,N=-1;function k(){return y?!0:!(a.unstable_now()-N<A)}function V(){if(y=!1,O){var G=a.unstable_now();N=G;var j=!0;try{e:{E=!1,w&&(w=!1,P(U),U=-1),M=!0;var se=v;try{t:{for(R(G),S=n(m);S!==null&&!(S.expirationTime>G&&k());){var Se=S.callback;if(typeof Se=="function"){S.callback=null,v=S.priorityLevel;var xe=Se(S.expirationTime<=G);if(G=a.unstable_now(),typeof xe=="function"){S.callback=xe,R(G),j=!0;break t}S===n(m)&&s(m),R(G)}else s(m);S=n(m)}if(S!==null)j=!0;else{var z=n(h);z!==null&&J(I,z.startTime-G),j=!1}}break e}finally{S=null,v=se,M=!1}j=void 0}}finally{j?Q():O=!1}}}var Q;if(typeof L=="function")Q=function(){L(V)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,pe=fe.port2;fe.port1.onmessage=V,Q=function(){pe.postMessage(null)}}else Q=function(){x(V,0)};function J(G,j){U=x(function(){G(a.unstable_now())},j)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(G){G.callback=null},a.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<G?Math.floor(1e3/G):5},a.unstable_getCurrentPriorityLevel=function(){return v},a.unstable_next=function(G){switch(v){case 1:case 2:case 3:var j=3;break;default:j=v}var se=v;v=j;try{return G()}finally{v=se}},a.unstable_requestPaint=function(){y=!0},a.unstable_runWithPriority=function(G,j){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var se=v;v=G;try{return j()}finally{v=se}},a.unstable_scheduleCallback=function(G,j,se){var Se=a.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?Se+se:Se):se=Se,G){case 1:var xe=-1;break;case 2:xe=250;break;case 5:xe=1073741823;break;case 4:xe=1e4;break;default:xe=5e3}return xe=se+xe,G={id:_++,callback:j,priorityLevel:G,startTime:se,expirationTime:xe,sortIndex:-1},se>Se?(G.sortIndex=se,e(h,G),n(m)===null&&G===n(h)&&(w?(P(U),U=-1):w=!0,J(I,se-Se))):(G.sortIndex=xe,e(m,G),E||M||(E=!0,O||(O=!0,Q()))),G},a.unstable_shouldYield=k,a.unstable_wrapCallback=function(G){var j=v;return function(){var se=v;v=j;try{return G.apply(this,arguments)}finally{v=se}}}})(th)),th}var uv;function ob(){return uv||(uv=1,eh.exports=rb()),eh.exports}var nh={exports:{}},Xn={};var fv;function lb(){if(fv)return Xn;fv=1;var a=Wp();function e(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)h+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(m,h,_){var S=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:S==null?null:""+S,children:m,containerInfo:h,implementation:_}}var f=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Xn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,Xn.createPortal=function(m,h){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return c(m,h,null,_)},Xn.flushSync=function(m){var h=f.T,_=s.p;try{if(f.T=null,s.p=2,m)return m()}finally{f.T=h,s.p=_,s.d.f()}},Xn.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,s.d.C(m,h))},Xn.prefetchDNS=function(m){typeof m=="string"&&s.d.D(m)},Xn.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var _=h.as,S=p(_,h.crossOrigin),v=typeof h.integrity=="string"?h.integrity:void 0,M=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;_==="style"?s.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:S,integrity:v,fetchPriority:M}):_==="script"&&s.d.X(m,{crossOrigin:S,integrity:v,fetchPriority:M,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Xn.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var _=p(h.as,h.crossOrigin);s.d.M(m,{crossOrigin:_,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&s.d.M(m)},Xn.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var _=h.as,S=p(_,h.crossOrigin);s.d.L(m,_,{crossOrigin:S,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Xn.preloadModule=function(m,h){if(typeof m=="string")if(h){var _=p(h.as,h.crossOrigin);s.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:_,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else s.d.m(m)},Xn.requestFormReset=function(m){s.d.r(m)},Xn.unstable_batchedUpdates=function(m,h){return m(h)},Xn.useFormState=function(m,h,_){return f.H.useFormState(m,h,_)},Xn.useFormStatus=function(){return f.H.useHostTransitionStatus()},Xn.version="19.2.7",Xn}var dv;function cb(){if(dv)return nh.exports;dv=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),nh.exports=lb(),nh.exports}var hv;function ub(){if(hv)return pl;hv=1;var a=ob(),e=Wp(),n=cb();function s(t){var i="https://react.dev/errors/"+t;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)i+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+t+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function c(t){var i=t,r=t;if(t.alternate)for(;i.return;)i=i.return;else{t=i;do i=t,(i.flags&4098)!==0&&(r=i.return),t=i.return;while(t)}return i.tag===3?r:null}function f(t){if(t.tag===13){var i=t.memoizedState;if(i===null&&(t=t.alternate,t!==null&&(i=t.memoizedState)),i!==null)return i.dehydrated}return null}function p(t){if(t.tag===31){var i=t.memoizedState;if(i===null&&(t=t.alternate,t!==null&&(i=t.memoizedState)),i!==null)return i.dehydrated}return null}function m(t){if(c(t)!==t)throw Error(s(188))}function h(t){var i=t.alternate;if(!i){if(i=c(t),i===null)throw Error(s(188));return i!==t?null:t}for(var r=t,o=i;;){var u=r.return;if(u===null)break;var d=u.alternate;if(d===null){if(o=u.return,o!==null){r=o;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===r)return m(u),t;if(d===o)return m(u),i;d=d.sibling}throw Error(s(188))}if(r.return!==o.return)r=u,o=d;else{for(var b=!1,D=u.child;D;){if(D===r){b=!0,r=u,o=d;break}if(D===o){b=!0,o=u,r=d;break}D=D.sibling}if(!b){for(D=d.child;D;){if(D===r){b=!0,r=d,o=u;break}if(D===o){b=!0,o=d,r=u;break}D=D.sibling}if(!b)throw Error(s(189))}}if(r.alternate!==o)throw Error(s(190))}if(r.tag!==3)throw Error(s(188));return r.stateNode.current===r?t:i}function _(t){var i=t.tag;if(i===5||i===26||i===27||i===6)return t;for(t=t.child;t!==null;){if(i=_(t),i!==null)return i;t=t.sibling}return null}var S=Object.assign,v=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),L=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),k=Symbol.for("react.memo_cache_sentinel"),V=Symbol.iterator;function Q(t){return t===null||typeof t!="object"?null:(t=V&&t[V]||t["@@iterator"],typeof t=="function"?t:null)}var fe=Symbol.for("react.client.reference");function pe(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===fe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case w:return"Fragment";case x:return"Profiler";case y:return"StrictMode";case I:return"Suspense";case O:return"SuspenseList";case N:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case E:return"Portal";case L:return t.displayName||"Context";case P:return(t._context.displayName||"Context")+".Consumer";case R:var i=t.render;return t=t.displayName,t||(t=i.displayName||i.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case U:return i=t.displayName||null,i!==null?i:pe(t.type)||"Memo";case A:i=t._payload,t=t._init;try{return pe(t(i))}catch{}}return null}var J=Array.isArray,G=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},Se=[],xe=-1;function z(t){return{current:t}}function te(t){0>xe||(t.current=Se[xe],Se[xe]=null,xe--)}function Ee(t,i){xe++,Se[xe]=t.current,t.current=i}var Oe=z(null),He=z(null),le=z(null),Me=z(null);function Ae(t,i){switch(Ee(le,i),Ee(He,t),Ee(Oe,null),i.nodeType){case 9:case 11:t=(t=i.documentElement)&&(t=t.namespaceURI)?w_(t):0;break;default:if(t=i.tagName,i=i.namespaceURI)i=w_(i),t=R_(i,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}te(Oe),Ee(Oe,t)}function je(){te(Oe),te(He),te(le)}function rt(t){t.memoizedState!==null&&Ee(Me,t);var i=Oe.current,r=R_(i,t.type);i!==r&&(Ee(He,t),Ee(Oe,r))}function $e(t){He.current===t&&(te(Oe),te(He)),Me.current===t&&(te(Me),cl._currentValue=se)}var Pt,gt;function dt(t){if(Pt===void 0)try{throw Error()}catch(r){var i=r.stack.trim().match(/\n( *(at )?)/);Pt=i&&i[1]||"",gt=-1<r.stack.indexOf(`
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
`+Pt+t+gt}var yt=!1;function ht(t,i){if(!t||yt)return"";yt=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(i){var we=function(){throw Error()};if(Object.defineProperty(we.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(we,[])}catch(me){var de=me}Reflect.construct(t,[],we)}else{try{we.call()}catch(me){de=me}t.call(we.prototype)}}else{try{throw Error()}catch(me){de=me}(we=t())&&typeof we.catch=="function"&&we.catch(function(){})}}catch(me){if(me&&de&&typeof me.stack=="string")return[me.stack,de.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=o.DetermineComponentFrameRoot(),b=d[0],D=d[1];if(b&&D){var X=b.split(`
`),ue=D.split(`
`);for(u=o=0;o<X.length&&!X[o].includes("DetermineComponentFrameRoot");)o++;for(;u<ue.length&&!ue[u].includes("DetermineComponentFrameRoot");)u++;if(o===X.length||u===ue.length)for(o=X.length-1,u=ue.length-1;1<=o&&0<=u&&X[o]!==ue[u];)u--;for(;1<=o&&0<=u;o--,u--)if(X[o]!==ue[u]){if(o!==1||u!==1)do if(o--,u--,0>u||X[o]!==ue[u]){var be=`
`+X[o].replace(" at new "," at ");return t.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",t.displayName)),be}while(1<=o&&0<=u);break}}}finally{yt=!1,Error.prepareStackTrace=r}return(r=t?t.displayName||t.name:"")?dt(r):""}function It(t,i){switch(t.tag){case 26:case 27:case 5:return dt(t.type);case 16:return dt("Lazy");case 13:return t.child!==i&&i!==null?dt("Suspense Fallback"):dt("Suspense");case 19:return dt("SuspenseList");case 0:case 15:return ht(t.type,!1);case 11:return ht(t.type.render,!1);case 1:return ht(t.type,!0);case 31:return dt("Activity");default:return""}}function zt(t){try{var i="",r=null;do i+=It(t,r),r=t,t=t.return;while(t);return i}catch(o){return`
Error generating stack: `+o.message+`
`+o.stack}}var qt=Object.prototype.hasOwnProperty,rn=a.unstable_scheduleCallback,ct=a.unstable_cancelCallback,K=a.unstable_shouldYield,F=a.unstable_requestPaint,Ue=a.unstable_now,_t=a.unstable_getCurrentPriorityLevel,B=a.unstable_ImmediatePriority,C=a.unstable_UserBlockingPriority,ie=a.unstable_NormalPriority,oe=a.unstable_LowPriority,he=a.unstable_IdlePriority,Ne=a.log,Re=a.unstable_setDisableYieldValue,_e=null,ve=null;function Ie(t){if(typeof Ne=="function"&&Re(t),ve&&typeof ve.setStrictMode=="function")try{ve.setStrictMode(_e,t)}catch{}}var Xe=Math.clz32?Math.clz32:st,Ve=Math.log,ge=Math.LN2;function st(t){return t>>>=0,t===0?32:31-(Ve(t)/ge|0)|0}var Je=256,tt=262144,Z=4194304;function Le(t){var i=t&42;if(i!==0)return i;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function ye(t,i,r){var o=t.pendingLanes;if(o===0)return 0;var u=0,d=t.suspendedLanes,b=t.pingedLanes;t=t.warmLanes;var D=o&134217727;return D!==0?(o=D&~d,o!==0?u=Le(o):(b&=D,b!==0?u=Le(b):r||(r=D&~t,r!==0&&(u=Le(r))))):(D=o&~d,D!==0?u=Le(D):b!==0?u=Le(b):r||(r=o&~t,r!==0&&(u=Le(r)))),u===0?0:i!==0&&i!==u&&(i&d)===0&&(d=u&-u,r=i&-i,d>=r||d===32&&(r&4194048)!==0)?i:u}function Fe(t,i){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&i)===0}function Ge(t,i){switch(t){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ce(){var t=Z;return Z<<=1,(Z&62914560)===0&&(Z=4194304),t}function Qe(t){for(var i=[],r=0;31>r;r++)i.push(t);return i}function Ye(t,i){t.pendingLanes|=i,i!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Yt(t,i,r,o,u,d){var b=t.pendingLanes;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=r,t.entangledLanes&=r,t.errorRecoveryDisabledLanes&=r,t.shellSuspendCounter=0;var D=t.entanglements,X=t.expirationTimes,ue=t.hiddenUpdates;for(r=b&~r;0<r;){var be=31-Xe(r),we=1<<be;D[be]=0,X[be]=-1;var de=ue[be];if(de!==null)for(ue[be]=null,be=0;be<de.length;be++){var me=de[be];me!==null&&(me.lane&=-536870913)}r&=~we}o!==0&&Rt(t,o,0),d!==0&&u===0&&t.tag!==0&&(t.suspendedLanes|=d&~(b&~i))}function Rt(t,i,r){t.pendingLanes|=i,t.suspendedLanes&=~i;var o=31-Xe(i);t.entangledLanes|=i,t.entanglements[o]=t.entanglements[o]|1073741824|r&261930}function dn(t,i){var r=t.entangledLanes|=i;for(t=t.entanglements;r;){var o=31-Xe(r),u=1<<o;u&i|t[o]&i&&(t[o]|=i),r&=~u}}function Bn(t,i){var r=i&-i;return r=(r&42)!==0?1:De(r),(r&(t.suspendedLanes|i))!==0?0:r}function De(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Ze(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function vt(){var t=j.p;return t!==0?t:(t=window.event,t===void 0?32:Q_(t.type))}function Dt(t,i){var r=j.p;try{return j.p=t,i()}finally{j.p=r}}var Ct=Math.random().toString(36).slice(2),St="__reactFiber$"+Ct,_n="__reactProps$"+Ct,kn="__reactContainer$"+Ct,pa="__reactEvents$"+Ct,hr="__reactListeners$"+Ct,pr="__reactHandles$"+Ct,ma="__reactResources$"+Ct,Qi="__reactMarker$"+Ct;function Ji(t){delete t[St],delete t[_n],delete t[pa],delete t[hr],delete t[pr]}function li(t){var i=t[St];if(i)return i;for(var r=t.parentNode;r;){if(i=r[kn]||r[St]){if(r=i.alternate,i.child!==null||r!==null&&r.child!==null)for(t=I_(t);t!==null;){if(r=t[St])return r;t=I_(t)}return i}t=r,r=t.parentNode}return null}function Ii(t){if(t=t[St]||t[kn]){var i=t.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return t}return null}function ga(t){var i=t.tag;if(i===5||i===26||i===27||i===6)return t.stateNode;throw Error(s(33))}function Bi(t){var i=t[ma];return i||(i=t[ma]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function vn(t){t[Qi]=!0}var ne=new Set,T={};function H(t,i){Y(t,i),Y(t+"Capture",i)}function Y(t,i){for(T[t]=i,t=0;t<i.length;t++)ne.add(i[t])}var W=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),q={},Be={};function ze(t){return qt.call(Be,t)?!0:qt.call(q,t)?!1:W.test(t)?Be[t]=!0:(q[t]=!0,!1)}function Pe(t,i,r){if(ze(i))if(r===null)t.removeAttribute(i);else{switch(typeof r){case"undefined":case"function":case"symbol":t.removeAttribute(i);return;case"boolean":var o=i.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){t.removeAttribute(i);return}}t.setAttribute(i,""+r)}}function We(t,i,r){if(r===null)t.removeAttribute(i);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(i);return}t.setAttribute(i,""+r)}}function ke(t,i,r,o){if(o===null)t.removeAttribute(r);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttributeNS(i,r,""+o)}}function nt(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ut(t){var i=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function it(t,i,r){var o=Object.getOwnPropertyDescriptor(t.constructor.prototype,i);if(!t.hasOwnProperty(i)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,d=o.set;return Object.defineProperty(t,i,{configurable:!0,get:function(){return u.call(this)},set:function(b){r=""+b,d.call(this,b)}}),Object.defineProperty(t,i,{enumerable:o.enumerable}),{getValue:function(){return r},setValue:function(b){r=""+b},stopTracking:function(){t._valueTracker=null,delete t[i]}}}}function Et(t){if(!t._valueTracker){var i=ut(t)?"checked":"value";t._valueTracker=it(t,i,""+t[i])}}function hn(t){if(!t)return!1;var i=t._valueTracker;if(!i)return!0;var r=i.getValue(),o="";return t&&(o=ut(t)?t.checked?"true":"false":t.value),t=o,t!==r?(i.setValue(t),!0):!1}function on(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Zt=/[\n"\\]/g;function Kt(t){return t.replace(Zt,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Ke(t,i,r,o,u,d,b,D){t.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?t.type=b:t.removeAttribute("type"),i!=null?b==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+nt(i)):t.value!==""+nt(i)&&(t.value=""+nt(i)):b!=="submit"&&b!=="reset"||t.removeAttribute("value"),i!=null?Nt(t,b,nt(i)):r!=null?Nt(t,b,nt(r)):o!=null&&t.removeAttribute("value"),u==null&&d!=null&&(t.defaultChecked=!!d),u!=null&&(t.checked=u&&typeof u!="function"&&typeof u!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?t.name=""+nt(D):t.removeAttribute("name")}function jn(t,i,r,o,u,d,b,D){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(t.type=d),i!=null||r!=null){if(!(d!=="submit"&&d!=="reset"||i!=null)){Et(t);return}r=r!=null?""+nt(r):"",i=i!=null?""+nt(i):r,D||i===t.value||(t.value=i),t.defaultValue=i}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,t.checked=D?t.checked:!!o,t.defaultChecked=!!o,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(t.name=b),Et(t)}function Nt(t,i,r){i==="number"&&on(t.ownerDocument)===t||t.defaultValue===""+r||(t.defaultValue=""+r)}function wn(t,i,r,o){if(t=t.options,i){i={};for(var u=0;u<r.length;u++)i["$"+r[u]]=!0;for(r=0;r<t.length;r++)u=i.hasOwnProperty("$"+t[r].value),t[r].selected!==u&&(t[r].selected=u),u&&o&&(t[r].defaultSelected=!0)}else{for(r=""+nt(r),i=null,u=0;u<t.length;u++){if(t[u].value===r){t[u].selected=!0,o&&(t[u].defaultSelected=!0);return}i!==null||t[u].disabled||(i=t[u])}i!==null&&(i.selected=!0)}}function ci(t,i,r){if(i!=null&&(i=""+nt(i),i!==t.value&&(t.value=i),r==null)){t.defaultValue!==i&&(t.defaultValue=i);return}t.defaultValue=r!=null?""+nt(r):""}function Fi(t,i,r,o){if(i==null){if(o!=null){if(r!=null)throw Error(s(92));if(J(o)){if(1<o.length)throw Error(s(93));o=o[0]}r=o}r==null&&(r=""),i=r}r=nt(i),t.defaultValue=r,o=t.textContent,o===r&&o!==""&&o!==null&&(t.value=o),Et(t)}function ui(t,i){if(i){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=i;return}}t.textContent=i}var $t=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function pn(t,i,r){var o=i.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?o?t.setProperty(i,""):i==="float"?t.cssFloat="":t[i]="":o?t.setProperty(i,r):typeof r!="number"||r===0||$t.has(i)?i==="float"?t.cssFloat=r:t[i]=(""+r).trim():t[i]=r+"px"}function zi(t,i,r){if(i!=null&&typeof i!="object")throw Error(s(62));if(t=t.style,r!=null){for(var o in r)!r.hasOwnProperty(o)||i!=null&&i.hasOwnProperty(o)||(o.indexOf("--")===0?t.setProperty(o,""):o==="float"?t.cssFloat="":t[o]="");for(var u in i)o=i[u],i.hasOwnProperty(u)&&r[u]!==o&&pn(t,u,o)}else for(var d in i)i.hasOwnProperty(d)&&pn(t,d,i[d])}function Wt(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ea=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Ya=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ls(t){return Ya.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function _a(){}var qu=null;function Yu(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var mr=null,gr=null;function Cm(t){var i=Ii(t);if(i&&(t=i.stateNode)){var r=t[_n]||null;e:switch(t=i.stateNode,i.type){case"input":if(Ke(t,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),i=r.name,r.type==="radio"&&i!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+Kt(""+i)+'"][type="radio"]'),i=0;i<r.length;i++){var o=r[i];if(o!==t&&o.form===t.form){var u=o[_n]||null;if(!u)throw Error(s(90));Ke(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(i=0;i<r.length;i++)o=r[i],o.form===t.form&&hn(o)}break e;case"textarea":ci(t,r.value,r.defaultValue);break e;case"select":i=r.value,i!=null&&wn(t,!!r.multiple,i,!1)}}}var Zu=!1;function wm(t,i,r){if(Zu)return t(i,r);Zu=!0;try{var o=t(i);return o}finally{if(Zu=!1,(mr!==null||gr!==null)&&(Ec(),mr&&(i=mr,t=gr,gr=mr=null,Cm(i),t)))for(i=0;i<t.length;i++)Cm(t[i])}}function Ao(t,i){var r=t.stateNode;if(r===null)return null;var o=r[_n]||null;if(o===null)return null;r=o[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(t=t.type,o=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!o;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(s(231,i,typeof r));return r}var va=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ku=!1;if(va)try{var Co={};Object.defineProperty(Co,"passive",{get:function(){Ku=!0}}),window.addEventListener("test",Co,Co),window.removeEventListener("test",Co,Co)}catch{Ku=!1}var Za=null,$u=null,Fl=null;function Rm(){if(Fl)return Fl;var t,i=$u,r=i.length,o,u="value"in Za?Za.value:Za.textContent,d=u.length;for(t=0;t<r&&i[t]===u[t];t++);var b=r-t;for(o=1;o<=b&&i[r-o]===u[d-o];o++);return Fl=u.slice(t,1<o?1-o:void 0)}function zl(t){var i=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&i===13&&(t=13)):t=i,t===10&&(t=13),32<=t||t===13?t:0}function Hl(){return!0}function Dm(){return!1}function Qn(t){function i(r,o,u,d,b){this._reactName=r,this._targetInst=u,this.type=o,this.nativeEvent=d,this.target=b,this.currentTarget=null;for(var D in t)t.hasOwnProperty(D)&&(r=t[D],this[D]=r?r(d):d[D]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?Hl:Dm,this.isPropagationStopped=Dm,this}return S(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=Hl)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Hl)},persist:function(){},isPersistent:Hl}),i}var Os={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gl=Qn(Os),wo=S({},Os,{view:0,detail:0}),eS=Qn(wo),Qu,Ju,Ro,Vl=S({},wo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:tf,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ro&&(Ro&&t.type==="mousemove"?(Qu=t.screenX-Ro.screenX,Ju=t.screenY-Ro.screenY):Ju=Qu=0,Ro=t),Qu)},movementY:function(t){return"movementY"in t?t.movementY:Ju}}),Nm=Qn(Vl),tS=S({},Vl,{dataTransfer:0}),nS=Qn(tS),iS=S({},wo,{relatedTarget:0}),ef=Qn(iS),aS=S({},Os,{animationName:0,elapsedTime:0,pseudoElement:0}),sS=Qn(aS),rS=S({},Os,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),oS=Qn(rS),lS=S({},Os,{data:0}),Um=Qn(lS),cS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uS={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dS(t){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(t):(t=fS[t])?!!i[t]:!1}function tf(){return dS}var hS=S({},wo,{key:function(t){if(t.key){var i=cS[t.key]||t.key;if(i!=="Unidentified")return i}return t.type==="keypress"?(t=zl(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?uS[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:tf,charCode:function(t){return t.type==="keypress"?zl(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?zl(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),pS=Qn(hS),mS=S({},Vl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Lm=Qn(mS),gS=S({},wo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:tf}),_S=Qn(gS),vS=S({},Os,{propertyName:0,elapsedTime:0,pseudoElement:0}),xS=Qn(vS),yS=S({},Vl,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),SS=Qn(yS),MS=S({},Os,{newState:0,oldState:0}),bS=Qn(MS),ES=[9,13,27,32],nf=va&&"CompositionEvent"in window,Do=null;va&&"documentMode"in document&&(Do=document.documentMode);var TS=va&&"TextEvent"in window&&!Do,Om=va&&(!nf||Do&&8<Do&&11>=Do),Pm=" ",Im=!1;function Bm(t,i){switch(t){case"keyup":return ES.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fm(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var _r=!1;function AS(t,i){switch(t){case"compositionend":return Fm(i);case"keypress":return i.which!==32?null:(Im=!0,Pm);case"textInput":return t=i.data,t===Pm&&Im?null:t;default:return null}}function CS(t,i){if(_r)return t==="compositionend"||!nf&&Bm(t,i)?(t=Rm(),Fl=$u=Za=null,_r=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Om&&i.locale!=="ko"?null:i.data;default:return null}}var wS={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function zm(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i==="input"?!!wS[t.type]:i==="textarea"}function Hm(t,i,r,o){mr?gr?gr.push(o):gr=[o]:mr=o,i=Nc(i,"onChange"),0<i.length&&(r=new Gl("onChange","change",null,r,o),t.push({event:r,listeners:i}))}var No=null,Uo=null;function RS(t){M_(t,0)}function kl(t){var i=ga(t);if(hn(i))return t}function Gm(t,i){if(t==="change")return i}var Vm=!1;if(va){var af;if(va){var sf="oninput"in document;if(!sf){var km=document.createElement("div");km.setAttribute("oninput","return;"),sf=typeof km.oninput=="function"}af=sf}else af=!1;Vm=af&&(!document.documentMode||9<document.documentMode)}function jm(){No&&(No.detachEvent("onpropertychange",Xm),Uo=No=null)}function Xm(t){if(t.propertyName==="value"&&kl(Uo)){var i=[];Hm(i,Uo,t,Yu(t)),wm(RS,i)}}function DS(t,i,r){t==="focusin"?(jm(),No=i,Uo=r,No.attachEvent("onpropertychange",Xm)):t==="focusout"&&jm()}function NS(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return kl(Uo)}function US(t,i){if(t==="click")return kl(i)}function LS(t,i){if(t==="input"||t==="change")return kl(i)}function OS(t,i){return t===i&&(t!==0||1/t===1/i)||t!==t&&i!==i}var fi=typeof Object.is=="function"?Object.is:OS;function Lo(t,i){if(fi(t,i))return!0;if(typeof t!="object"||t===null||typeof i!="object"||i===null)return!1;var r=Object.keys(t),o=Object.keys(i);if(r.length!==o.length)return!1;for(o=0;o<r.length;o++){var u=r[o];if(!qt.call(i,u)||!fi(t[u],i[u]))return!1}return!0}function Wm(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function qm(t,i){var r=Wm(t);t=0;for(var o;r;){if(r.nodeType===3){if(o=t+r.textContent.length,t<=i&&o>=i)return{node:r,offset:i-t};t=o}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Wm(r)}}function Ym(t,i){return t&&i?t===i?!0:t&&t.nodeType===3?!1:i&&i.nodeType===3?Ym(t,i.parentNode):"contains"in t?t.contains(i):t.compareDocumentPosition?!!(t.compareDocumentPosition(i)&16):!1:!1}function Zm(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var i=on(t.document);i instanceof t.HTMLIFrameElement;){try{var r=typeof i.contentWindow.location.href=="string"}catch{r=!1}if(r)t=i.contentWindow;else break;i=on(t.document)}return i}function rf(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i&&(i==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||i==="textarea"||t.contentEditable==="true")}var PS=va&&"documentMode"in document&&11>=document.documentMode,vr=null,of=null,Oo=null,lf=!1;function Km(t,i,r){var o=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;lf||vr==null||vr!==on(o)||(o=vr,"selectionStart"in o&&rf(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Oo&&Lo(Oo,o)||(Oo=o,o=Nc(of,"onSelect"),0<o.length&&(i=new Gl("onSelect","select",null,i,r),t.push({event:i,listeners:o}),i.target=vr)))}function Ps(t,i){var r={};return r[t.toLowerCase()]=i.toLowerCase(),r["Webkit"+t]="webkit"+i,r["Moz"+t]="moz"+i,r}var xr={animationend:Ps("Animation","AnimationEnd"),animationiteration:Ps("Animation","AnimationIteration"),animationstart:Ps("Animation","AnimationStart"),transitionrun:Ps("Transition","TransitionRun"),transitionstart:Ps("Transition","TransitionStart"),transitioncancel:Ps("Transition","TransitionCancel"),transitionend:Ps("Transition","TransitionEnd")},cf={},$m={};va&&($m=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);function Is(t){if(cf[t])return cf[t];if(!xr[t])return t;var i=xr[t],r;for(r in i)if(i.hasOwnProperty(r)&&r in $m)return cf[t]=i[r];return t}var Qm=Is("animationend"),Jm=Is("animationiteration"),eg=Is("animationstart"),IS=Is("transitionrun"),BS=Is("transitionstart"),FS=Is("transitioncancel"),tg=Is("transitionend"),ng=new Map,uf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");uf.push("scrollEnd");function Hi(t,i){ng.set(t,i),H(i,[t])}var jl=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Mi=[],yr=0,ff=0;function Xl(){for(var t=yr,i=ff=yr=0;i<t;){var r=Mi[i];Mi[i++]=null;var o=Mi[i];Mi[i++]=null;var u=Mi[i];Mi[i++]=null;var d=Mi[i];if(Mi[i++]=null,o!==null&&u!==null){var b=o.pending;b===null?u.next=u:(u.next=b.next,b.next=u),o.pending=u}d!==0&&ig(r,u,d)}}function Wl(t,i,r,o){Mi[yr++]=t,Mi[yr++]=i,Mi[yr++]=r,Mi[yr++]=o,ff|=o,t.lanes|=o,t=t.alternate,t!==null&&(t.lanes|=o)}function df(t,i,r,o){return Wl(t,i,r,o),ql(t)}function Bs(t,i){return Wl(t,null,null,i),ql(t)}function ig(t,i,r){t.lanes|=r;var o=t.alternate;o!==null&&(o.lanes|=r);for(var u=!1,d=t.return;d!==null;)d.childLanes|=r,o=d.alternate,o!==null&&(o.childLanes|=r),d.tag===22&&(t=d.stateNode,t===null||t._visibility&1||(u=!0)),t=d,d=d.return;return t.tag===3?(d=t.stateNode,u&&i!==null&&(u=31-Xe(r),t=d.hiddenUpdates,o=t[u],o===null?t[u]=[i]:o.push(i),i.lane=r|536870912),d):null}function ql(t){if(50<nl)throw nl=0,Sd=null,Error(s(185));for(var i=t.return;i!==null;)t=i,i=t.return;return t.tag===3?t.stateNode:null}var Sr={};function zS(t,i,r,o){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function di(t,i,r,o){return new zS(t,i,r,o)}function hf(t){return t=t.prototype,!(!t||!t.isReactComponent)}function xa(t,i){var r=t.alternate;return r===null?(r=di(t.tag,i,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=i,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&65011712,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,i=t.dependencies,r.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r.refCleanup=t.refCleanup,r}function ag(t,i){t.flags&=65011714;var r=t.alternate;return r===null?(t.childLanes=0,t.lanes=i,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=r.childLanes,t.lanes=r.lanes,t.child=r.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=r.memoizedProps,t.memoizedState=r.memoizedState,t.updateQueue=r.updateQueue,t.type=r.type,i=r.dependencies,t.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),t}function Yl(t,i,r,o,u,d){var b=0;if(o=t,typeof t=="function")hf(t)&&(b=1);else if(typeof t=="string")b=jM(t,r,Oe.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case N:return t=di(31,r,i,u),t.elementType=N,t.lanes=d,t;case w:return Fs(r.children,u,d,i);case y:b=8,u|=24;break;case x:return t=di(12,r,i,u|2),t.elementType=x,t.lanes=d,t;case I:return t=di(13,r,i,u),t.elementType=I,t.lanes=d,t;case O:return t=di(19,r,i,u),t.elementType=O,t.lanes=d,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case L:b=10;break e;case P:b=9;break e;case R:b=11;break e;case U:b=14;break e;case A:b=16,o=null;break e}b=29,r=Error(s(130,t===null?"null":typeof t,"")),o=null}return i=di(b,r,i,u),i.elementType=t,i.type=o,i.lanes=d,i}function Fs(t,i,r,o){return t=di(7,t,o,i),t.lanes=r,t}function pf(t,i,r){return t=di(6,t,null,i),t.lanes=r,t}function sg(t){var i=di(18,null,null,0);return i.stateNode=t,i}function mf(t,i,r){return i=di(4,t.children!==null?t.children:[],t.key,i),i.lanes=r,i.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},i}var rg=new WeakMap;function bi(t,i){if(typeof t=="object"&&t!==null){var r=rg.get(t);return r!==void 0?r:(i={value:t,source:i,stack:zt(i)},rg.set(t,i),i)}return{value:t,source:i,stack:zt(i)}}var Mr=[],br=0,Zl=null,Po=0,Ei=[],Ti=0,Ka=null,ta=1,na="";function ya(t,i){Mr[br++]=Po,Mr[br++]=Zl,Zl=t,Po=i}function og(t,i,r){Ei[Ti++]=ta,Ei[Ti++]=na,Ei[Ti++]=Ka,Ka=t;var o=ta;t=na;var u=32-Xe(o)-1;o&=~(1<<u),r+=1;var d=32-Xe(i)+u;if(30<d){var b=u-u%5;d=(o&(1<<b)-1).toString(32),o>>=b,u-=b,ta=1<<32-Xe(i)+u|r<<u|o,na=d+t}else ta=1<<d|r<<u|o,na=t}function gf(t){t.return!==null&&(ya(t,1),og(t,1,0))}function _f(t){for(;t===Zl;)Zl=Mr[--br],Mr[br]=null,Po=Mr[--br],Mr[br]=null;for(;t===Ka;)Ka=Ei[--Ti],Ei[Ti]=null,na=Ei[--Ti],Ei[Ti]=null,ta=Ei[--Ti],Ei[Ti]=null}function lg(t,i){Ei[Ti++]=ta,Ei[Ti++]=na,Ei[Ti++]=Ka,ta=i.id,na=i.overflow,Ka=t}var Fn=null,un=null,Ht=!1,$a=null,Ai=!1,vf=Error(s(519));function Qa(t){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Io(bi(i,t)),vf}function cg(t){var i=t.stateNode,r=t.type,o=t.memoizedProps;switch(i[St]=t,i[_n]=o,r){case"dialog":Lt("cancel",i),Lt("close",i);break;case"iframe":case"object":case"embed":Lt("load",i);break;case"video":case"audio":for(r=0;r<al.length;r++)Lt(al[r],i);break;case"source":Lt("error",i);break;case"img":case"image":case"link":Lt("error",i),Lt("load",i);break;case"details":Lt("toggle",i);break;case"input":Lt("invalid",i),jn(i,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":Lt("invalid",i);break;case"textarea":Lt("invalid",i),Fi(i,o.value,o.defaultValue,o.children)}r=o.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||i.textContent===""+r||o.suppressHydrationWarning===!0||A_(i.textContent,r)?(o.popover!=null&&(Lt("beforetoggle",i),Lt("toggle",i)),o.onScroll!=null&&Lt("scroll",i),o.onScrollEnd!=null&&Lt("scrollend",i),o.onClick!=null&&(i.onclick=_a),i=!0):i=!1,i||Qa(t,!0)}function ug(t){for(Fn=t.return;Fn;)switch(Fn.tag){case 5:case 31:case 13:Ai=!1;return;case 27:case 3:Ai=!0;return;default:Fn=Fn.return}}function Er(t){if(t!==Fn)return!1;if(!Ht)return ug(t),Ht=!0,!1;var i=t.tag,r;if((r=i!==3&&i!==27)&&((r=i===5)&&(r=t.type,r=!(r!=="form"&&r!=="button")||Id(t.type,t.memoizedProps)),r=!r),r&&un&&Qa(t),ug(t),i===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));un=P_(t)}else if(i===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));un=P_(t)}else i===27?(i=un,ds(t.type)?(t=Gd,Gd=null,un=t):un=i):un=Fn?wi(t.stateNode.nextSibling):null;return!0}function zs(){un=Fn=null,Ht=!1}function xf(){var t=$a;return t!==null&&(ni===null?ni=t:ni.push.apply(ni,t),$a=null),t}function Io(t){$a===null?$a=[t]:$a.push(t)}var yf=z(null),Hs=null,Sa=null;function Ja(t,i,r){Ee(yf,i._currentValue),i._currentValue=r}function Ma(t){t._currentValue=yf.current,te(yf)}function Sf(t,i,r){for(;t!==null;){var o=t.alternate;if((t.childLanes&i)!==i?(t.childLanes|=i,o!==null&&(o.childLanes|=i)):o!==null&&(o.childLanes&i)!==i&&(o.childLanes|=i),t===r)break;t=t.return}}function Mf(t,i,r,o){var u=t.child;for(u!==null&&(u.return=t);u!==null;){var d=u.dependencies;if(d!==null){var b=u.child;d=d.firstContext;e:for(;d!==null;){var D=d;d=u;for(var X=0;X<i.length;X++)if(D.context===i[X]){d.lanes|=r,D=d.alternate,D!==null&&(D.lanes|=r),Sf(d.return,r,t),o||(b=null);break e}d=D.next}}else if(u.tag===18){if(b=u.return,b===null)throw Error(s(341));b.lanes|=r,d=b.alternate,d!==null&&(d.lanes|=r),Sf(b,r,t),b=null}else b=u.child;if(b!==null)b.return=u;else for(b=u;b!==null;){if(b===t){b=null;break}if(u=b.sibling,u!==null){u.return=b.return,b=u;break}b=b.return}u=b}}function Tr(t,i,r,o){t=null;for(var u=i,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var b=u.alternate;if(b===null)throw Error(s(387));if(b=b.memoizedProps,b!==null){var D=u.type;fi(u.pendingProps.value,b.value)||(t!==null?t.push(D):t=[D])}}else if(u===Me.current){if(b=u.alternate,b===null)throw Error(s(387));b.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(t!==null?t.push(cl):t=[cl])}u=u.return}t!==null&&Mf(i,t,r,o),i.flags|=262144}function Kl(t){for(t=t.firstContext;t!==null;){if(!fi(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function Gs(t){Hs=t,Sa=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function zn(t){return fg(Hs,t)}function $l(t,i){return Hs===null&&Gs(t),fg(t,i)}function fg(t,i){var r=i._currentValue;if(i={context:i,memoizedValue:r,next:null},Sa===null){if(t===null)throw Error(s(308));Sa=i,t.dependencies={lanes:0,firstContext:i},t.flags|=524288}else Sa=Sa.next=i;return r}var HS=typeof AbortController<"u"?AbortController:function(){var t=[],i=this.signal={aborted:!1,addEventListener:function(r,o){t.push(o)}};this.abort=function(){i.aborted=!0,t.forEach(function(r){return r()})}},GS=a.unstable_scheduleCallback,VS=a.unstable_NormalPriority,bn={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bf(){return{controller:new HS,data:new Map,refCount:0}}function Bo(t){t.refCount--,t.refCount===0&&GS(VS,function(){t.controller.abort()})}var Fo=null,Ef=0,Ar=0,Cr=null;function kS(t,i){if(Fo===null){var r=Fo=[];Ef=0,Ar=Cd(),Cr={status:"pending",value:void 0,then:function(o){r.push(o)}}}return Ef++,i.then(dg,dg),i}function dg(){if(--Ef===0&&Fo!==null){Cr!==null&&(Cr.status="fulfilled");var t=Fo;Fo=null,Ar=0,Cr=null;for(var i=0;i<t.length;i++)(0,t[i])()}}function jS(t,i){var r=[],o={status:"pending",value:null,reason:null,then:function(u){r.push(u)}};return t.then(function(){o.status="fulfilled",o.value=i;for(var u=0;u<r.length;u++)(0,r[u])(i)},function(u){for(o.status="rejected",o.reason=u,u=0;u<r.length;u++)(0,r[u])(void 0)}),o}var hg=G.S;G.S=function(t,i){K0=Ue(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&kS(t,i),hg!==null&&hg(t,i)};var Vs=z(null);function Tf(){var t=Vs.current;return t!==null?t:ln.pooledCache}function Ql(t,i){i===null?Ee(Vs,Vs.current):Ee(Vs,i.pool)}function pg(){var t=Tf();return t===null?null:{parent:bn._currentValue,pool:t}}var wr=Error(s(460)),Af=Error(s(474)),Jl=Error(s(542)),ec={then:function(){}};function mg(t){return t=t.status,t==="fulfilled"||t==="rejected"}function gg(t,i,r){switch(r=t[r],r===void 0?t.push(i):r!==i&&(i.then(_a,_a),i=r),i.status){case"fulfilled":return i.value;case"rejected":throw t=i.reason,vg(t),t;default:if(typeof i.status=="string")i.then(_a,_a);else{if(t=ln,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=i,t.status="pending",t.then(function(o){if(i.status==="pending"){var u=i;u.status="fulfilled",u.value=o}},function(o){if(i.status==="pending"){var u=i;u.status="rejected",u.reason=o}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw t=i.reason,vg(t),t}throw js=i,wr}}function ks(t){try{var i=t._init;return i(t._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(js=r,wr):r}}var js=null;function _g(){if(js===null)throw Error(s(459));var t=js;return js=null,t}function vg(t){if(t===wr||t===Jl)throw Error(s(483))}var Rr=null,zo=0;function tc(t){var i=zo;return zo+=1,Rr===null&&(Rr=[]),gg(Rr,t,i)}function Ho(t,i){i=i.props.ref,t.ref=i!==void 0?i:null}function nc(t,i){throw i.$$typeof===v?Error(s(525)):(t=Object.prototype.toString.call(i),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":t)))}function xg(t){function i(ae,$){if(t){var ce=ae.deletions;ce===null?(ae.deletions=[$],ae.flags|=16):ce.push($)}}function r(ae,$){if(!t)return null;for(;$!==null;)i(ae,$),$=$.sibling;return null}function o(ae){for(var $=new Map;ae!==null;)ae.key!==null?$.set(ae.key,ae):$.set(ae.index,ae),ae=ae.sibling;return $}function u(ae,$){return ae=xa(ae,$),ae.index=0,ae.sibling=null,ae}function d(ae,$,ce){return ae.index=ce,t?(ce=ae.alternate,ce!==null?(ce=ce.index,ce<$?(ae.flags|=67108866,$):ce):(ae.flags|=67108866,$)):(ae.flags|=1048576,$)}function b(ae){return t&&ae.alternate===null&&(ae.flags|=67108866),ae}function D(ae,$,ce,Te){return $===null||$.tag!==6?($=pf(ce,ae.mode,Te),$.return=ae,$):($=u($,ce),$.return=ae,$)}function X(ae,$,ce,Te){var lt=ce.type;return lt===w?be(ae,$,ce.props.children,Te,ce.key):$!==null&&($.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===A&&ks(lt)===$.type)?($=u($,ce.props),Ho($,ce),$.return=ae,$):($=Yl(ce.type,ce.key,ce.props,null,ae.mode,Te),Ho($,ce),$.return=ae,$)}function ue(ae,$,ce,Te){return $===null||$.tag!==4||$.stateNode.containerInfo!==ce.containerInfo||$.stateNode.implementation!==ce.implementation?($=mf(ce,ae.mode,Te),$.return=ae,$):($=u($,ce.children||[]),$.return=ae,$)}function be(ae,$,ce,Te,lt){return $===null||$.tag!==7?($=Fs(ce,ae.mode,Te,lt),$.return=ae,$):($=u($,ce),$.return=ae,$)}function we(ae,$,ce){if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return $=pf(""+$,ae.mode,ce),$.return=ae,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case M:return ce=Yl($.type,$.key,$.props,null,ae.mode,ce),Ho(ce,$),ce.return=ae,ce;case E:return $=mf($,ae.mode,ce),$.return=ae,$;case A:return $=ks($),we(ae,$,ce)}if(J($)||Q($))return $=Fs($,ae.mode,ce,null),$.return=ae,$;if(typeof $.then=="function")return we(ae,tc($),ce);if($.$$typeof===L)return we(ae,$l(ae,$),ce);nc(ae,$)}return null}function de(ae,$,ce,Te){var lt=$!==null?$.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return lt!==null?null:D(ae,$,""+ce,Te);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case M:return ce.key===lt?X(ae,$,ce,Te):null;case E:return ce.key===lt?ue(ae,$,ce,Te):null;case A:return ce=ks(ce),de(ae,$,ce,Te)}if(J(ce)||Q(ce))return lt!==null?null:be(ae,$,ce,Te,null);if(typeof ce.then=="function")return de(ae,$,tc(ce),Te);if(ce.$$typeof===L)return de(ae,$,$l(ae,ce),Te);nc(ae,ce)}return null}function me(ae,$,ce,Te,lt){if(typeof Te=="string"&&Te!==""||typeof Te=="number"||typeof Te=="bigint")return ae=ae.get(ce)||null,D($,ae,""+Te,lt);if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case M:return ae=ae.get(Te.key===null?ce:Te.key)||null,X($,ae,Te,lt);case E:return ae=ae.get(Te.key===null?ce:Te.key)||null,ue($,ae,Te,lt);case A:return Te=ks(Te),me(ae,$,ce,Te,lt)}if(J(Te)||Q(Te))return ae=ae.get(ce)||null,be($,ae,Te,lt,null);if(typeof Te.then=="function")return me(ae,$,ce,tc(Te),lt);if(Te.$$typeof===L)return me(ae,$,ce,$l($,Te),lt);nc($,Te)}return null}function et(ae,$,ce,Te){for(var lt=null,kt=null,at=$,At=$=0,Ft=null;at!==null&&At<ce.length;At++){at.index>At?(Ft=at,at=null):Ft=at.sibling;var jt=de(ae,at,ce[At],Te);if(jt===null){at===null&&(at=Ft);break}t&&at&&jt.alternate===null&&i(ae,at),$=d(jt,$,At),kt===null?lt=jt:kt.sibling=jt,kt=jt,at=Ft}if(At===ce.length)return r(ae,at),Ht&&ya(ae,At),lt;if(at===null){for(;At<ce.length;At++)at=we(ae,ce[At],Te),at!==null&&($=d(at,$,At),kt===null?lt=at:kt.sibling=at,kt=at);return Ht&&ya(ae,At),lt}for(at=o(at);At<ce.length;At++)Ft=me(at,ae,At,ce[At],Te),Ft!==null&&(t&&Ft.alternate!==null&&at.delete(Ft.key===null?At:Ft.key),$=d(Ft,$,At),kt===null?lt=Ft:kt.sibling=Ft,kt=Ft);return t&&at.forEach(function(_s){return i(ae,_s)}),Ht&&ya(ae,At),lt}function pt(ae,$,ce,Te){if(ce==null)throw Error(s(151));for(var lt=null,kt=null,at=$,At=$=0,Ft=null,jt=ce.next();at!==null&&!jt.done;At++,jt=ce.next()){at.index>At?(Ft=at,at=null):Ft=at.sibling;var _s=de(ae,at,jt.value,Te);if(_s===null){at===null&&(at=Ft);break}t&&at&&_s.alternate===null&&i(ae,at),$=d(_s,$,At),kt===null?lt=_s:kt.sibling=_s,kt=_s,at=Ft}if(jt.done)return r(ae,at),Ht&&ya(ae,At),lt;if(at===null){for(;!jt.done;At++,jt=ce.next())jt=we(ae,jt.value,Te),jt!==null&&($=d(jt,$,At),kt===null?lt=jt:kt.sibling=jt,kt=jt);return Ht&&ya(ae,At),lt}for(at=o(at);!jt.done;At++,jt=ce.next())jt=me(at,ae,At,jt.value,Te),jt!==null&&(t&&jt.alternate!==null&&at.delete(jt.key===null?At:jt.key),$=d(jt,$,At),kt===null?lt=jt:kt.sibling=jt,kt=jt);return t&&at.forEach(function(tb){return i(ae,tb)}),Ht&&ya(ae,At),lt}function an(ae,$,ce,Te){if(typeof ce=="object"&&ce!==null&&ce.type===w&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case M:e:{for(var lt=ce.key;$!==null;){if($.key===lt){if(lt=ce.type,lt===w){if($.tag===7){r(ae,$.sibling),Te=u($,ce.props.children),Te.return=ae,ae=Te;break e}}else if($.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===A&&ks(lt)===$.type){r(ae,$.sibling),Te=u($,ce.props),Ho(Te,ce),Te.return=ae,ae=Te;break e}r(ae,$);break}else i(ae,$);$=$.sibling}ce.type===w?(Te=Fs(ce.props.children,ae.mode,Te,ce.key),Te.return=ae,ae=Te):(Te=Yl(ce.type,ce.key,ce.props,null,ae.mode,Te),Ho(Te,ce),Te.return=ae,ae=Te)}return b(ae);case E:e:{for(lt=ce.key;$!==null;){if($.key===lt)if($.tag===4&&$.stateNode.containerInfo===ce.containerInfo&&$.stateNode.implementation===ce.implementation){r(ae,$.sibling),Te=u($,ce.children||[]),Te.return=ae,ae=Te;break e}else{r(ae,$);break}else i(ae,$);$=$.sibling}Te=mf(ce,ae.mode,Te),Te.return=ae,ae=Te}return b(ae);case A:return ce=ks(ce),an(ae,$,ce,Te)}if(J(ce))return et(ae,$,ce,Te);if(Q(ce)){if(lt=Q(ce),typeof lt!="function")throw Error(s(150));return ce=lt.call(ce),pt(ae,$,ce,Te)}if(typeof ce.then=="function")return an(ae,$,tc(ce),Te);if(ce.$$typeof===L)return an(ae,$,$l(ae,ce),Te);nc(ae,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,$!==null&&$.tag===6?(r(ae,$.sibling),Te=u($,ce),Te.return=ae,ae=Te):(r(ae,$),Te=pf(ce,ae.mode,Te),Te.return=ae,ae=Te),b(ae)):r(ae,$)}return function(ae,$,ce,Te){try{zo=0;var lt=an(ae,$,ce,Te);return Rr=null,lt}catch(at){if(at===wr||at===Jl)throw at;var kt=di(29,at,null,ae.mode);return kt.lanes=Te,kt.return=ae,kt}}}var Xs=xg(!0),yg=xg(!1),es=!1;function Cf(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wf(t,i){t=t.updateQueue,i.updateQueue===t&&(i.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function ts(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function ns(t,i,r){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(Xt&2)!==0){var u=o.pending;return u===null?i.next=i:(i.next=u.next,u.next=i),o.pending=i,i=ql(t),ig(t,null,r),i}return Wl(t,o,i,r),ql(t)}function Go(t,i,r){if(i=i.updateQueue,i!==null&&(i=i.shared,(r&4194048)!==0)){var o=i.lanes;o&=t.pendingLanes,r|=o,i.lanes=r,dn(t,r)}}function Rf(t,i){var r=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,r===o)){var u=null,d=null;if(r=r.firstBaseUpdate,r!==null){do{var b={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};d===null?u=d=b:d=d.next=b,r=r.next}while(r!==null);d===null?u=d=i:d=d.next=i}else u=d=i;r={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:o.shared,callbacks:o.callbacks},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=i:t.next=i,r.lastBaseUpdate=i}var Df=!1;function Vo(){if(Df){var t=Cr;if(t!==null)throw t}}function ko(t,i,r,o){Df=!1;var u=t.updateQueue;es=!1;var d=u.firstBaseUpdate,b=u.lastBaseUpdate,D=u.shared.pending;if(D!==null){u.shared.pending=null;var X=D,ue=X.next;X.next=null,b===null?d=ue:b.next=ue,b=X;var be=t.alternate;be!==null&&(be=be.updateQueue,D=be.lastBaseUpdate,D!==b&&(D===null?be.firstBaseUpdate=ue:D.next=ue,be.lastBaseUpdate=X))}if(d!==null){var we=u.baseState;b=0,be=ue=X=null,D=d;do{var de=D.lane&-536870913,me=de!==D.lane;if(me?(Bt&de)===de:(o&de)===de){de!==0&&de===Ar&&(Df=!0),be!==null&&(be=be.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var et=t,pt=D;de=i;var an=r;switch(pt.tag){case 1:if(et=pt.payload,typeof et=="function"){we=et.call(an,we,de);break e}we=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=pt.payload,de=typeof et=="function"?et.call(an,we,de):et,de==null)break e;we=S({},we,de);break e;case 2:es=!0}}de=D.callback,de!==null&&(t.flags|=64,me&&(t.flags|=8192),me=u.callbacks,me===null?u.callbacks=[de]:me.push(de))}else me={lane:de,tag:D.tag,payload:D.payload,callback:D.callback,next:null},be===null?(ue=be=me,X=we):be=be.next=me,b|=de;if(D=D.next,D===null){if(D=u.shared.pending,D===null)break;me=D,D=me.next,me.next=null,u.lastBaseUpdate=me,u.shared.pending=null}}while(!0);be===null&&(X=we),u.baseState=X,u.firstBaseUpdate=ue,u.lastBaseUpdate=be,d===null&&(u.shared.lanes=0),os|=b,t.lanes=b,t.memoizedState=we}}function Sg(t,i){if(typeof t!="function")throw Error(s(191,t));t.call(i)}function Mg(t,i){var r=t.callbacks;if(r!==null)for(t.callbacks=null,t=0;t<r.length;t++)Sg(r[t],i)}var Dr=z(null),ic=z(0);function bg(t,i){t=Na,Ee(ic,t),Ee(Dr,i),Na=t|i.baseLanes}function Nf(){Ee(ic,Na),Ee(Dr,Dr.current)}function Uf(){Na=ic.current,te(Dr),te(ic)}var hi=z(null),Ci=null;function is(t){var i=t.alternate;Ee(Sn,Sn.current&1),Ee(hi,t),Ci===null&&(i===null||Dr.current!==null||i.memoizedState!==null)&&(Ci=t)}function Lf(t){Ee(Sn,Sn.current),Ee(hi,t),Ci===null&&(Ci=t)}function Eg(t){t.tag===22?(Ee(Sn,Sn.current),Ee(hi,t),Ci===null&&(Ci=t)):as()}function as(){Ee(Sn,Sn.current),Ee(hi,hi.current)}function pi(t){te(hi),Ci===t&&(Ci=null),te(Sn)}var Sn=z(0);function ac(t){for(var i=t;i!==null;){if(i.tag===13){var r=i.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||zd(r)||Hd(r)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var ba=0,Tt=null,tn=null,En=null,sc=!1,Nr=!1,Ws=!1,rc=0,jo=0,Ur=null,XS=0;function xn(){throw Error(s(321))}function Of(t,i){if(i===null)return!1;for(var r=0;r<i.length&&r<t.length;r++)if(!fi(t[r],i[r]))return!1;return!0}function Pf(t,i,r,o,u,d){return ba=d,Tt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,G.H=t===null||t.memoizedState===null?o0:Kf,Ws=!1,d=r(o,u),Ws=!1,Nr&&(d=Ag(i,r,o,u)),Tg(t),d}function Tg(t){G.H=qo;var i=tn!==null&&tn.next!==null;if(ba=0,En=tn=Tt=null,sc=!1,jo=0,Ur=null,i)throw Error(s(300));t===null||Tn||(t=t.dependencies,t!==null&&Kl(t)&&(Tn=!0))}function Ag(t,i,r,o){Tt=t;var u=0;do{if(Nr&&(Ur=null),jo=0,Nr=!1,25<=u)throw Error(s(301));if(u+=1,En=tn=null,t.updateQueue!=null){var d=t.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}G.H=l0,d=i(r,o)}while(Nr);return d}function WS(){var t=G.H,i=t.useState()[0];return i=typeof i.then=="function"?Xo(i):i,t=t.useState()[0],(tn!==null?tn.memoizedState:null)!==t&&(Tt.flags|=1024),i}function If(){var t=rc!==0;return rc=0,t}function Bf(t,i,r){i.updateQueue=t.updateQueue,i.flags&=-2053,t.lanes&=~r}function Ff(t){if(sc){for(t=t.memoizedState;t!==null;){var i=t.queue;i!==null&&(i.pending=null),t=t.next}sc=!1}ba=0,En=tn=Tt=null,Nr=!1,jo=rc=0,Ur=null}function Zn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return En===null?Tt.memoizedState=En=t:En=En.next=t,En}function Mn(){if(tn===null){var t=Tt.alternate;t=t!==null?t.memoizedState:null}else t=tn.next;var i=En===null?Tt.memoizedState:En.next;if(i!==null)En=i,tn=t;else{if(t===null)throw Tt.alternate===null?Error(s(467)):Error(s(310));tn=t,t={memoizedState:tn.memoizedState,baseState:tn.baseState,baseQueue:tn.baseQueue,queue:tn.queue,next:null},En===null?Tt.memoizedState=En=t:En=En.next=t}return En}function oc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xo(t){var i=jo;return jo+=1,Ur===null&&(Ur=[]),t=gg(Ur,t,i),i=Tt,(En===null?i.memoizedState:En.next)===null&&(i=i.alternate,G.H=i===null||i.memoizedState===null?o0:Kf),t}function lc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Xo(t);if(t.$$typeof===L)return zn(t)}throw Error(s(438,String(t)))}function zf(t){var i=null,r=Tt.updateQueue;if(r!==null&&(i=r.memoCache),i==null){var o=Tt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(i={data:o.data.map(function(u){return u.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),r===null&&(r=oc(),Tt.updateQueue=r),r.memoCache=i,r=i.data[i.index],r===void 0)for(r=i.data[i.index]=Array(t),o=0;o<t;o++)r[o]=k;return i.index++,r}function Ea(t,i){return typeof i=="function"?i(t):i}function cc(t){var i=Mn();return Hf(i,tn,t)}function Hf(t,i,r){var o=t.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=r;var u=t.baseQueue,d=o.pending;if(d!==null){if(u!==null){var b=u.next;u.next=d.next,d.next=b}i.baseQueue=u=d,o.pending=null}if(d=t.baseState,u===null)t.memoizedState=d;else{i=u.next;var D=b=null,X=null,ue=i,be=!1;do{var we=ue.lane&-536870913;if(we!==ue.lane?(Bt&we)===we:(ba&we)===we){var de=ue.revertLane;if(de===0)X!==null&&(X=X.next={lane:0,revertLane:0,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),we===Ar&&(be=!0);else if((ba&de)===de){ue=ue.next,de===Ar&&(be=!0);continue}else we={lane:0,revertLane:ue.revertLane,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},X===null?(D=X=we,b=d):X=X.next=we,Tt.lanes|=de,os|=de;we=ue.action,Ws&&r(d,we),d=ue.hasEagerState?ue.eagerState:r(d,we)}else de={lane:we,revertLane:ue.revertLane,gesture:ue.gesture,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},X===null?(D=X=de,b=d):X=X.next=de,Tt.lanes|=we,os|=we;ue=ue.next}while(ue!==null&&ue!==i);if(X===null?b=d:X.next=D,!fi(d,t.memoizedState)&&(Tn=!0,be&&(r=Cr,r!==null)))throw r;t.memoizedState=d,t.baseState=b,t.baseQueue=X,o.lastRenderedState=d}return u===null&&(o.lanes=0),[t.memoizedState,o.dispatch]}function Gf(t){var i=Mn(),r=i.queue;if(r===null)throw Error(s(311));r.lastRenderedReducer=t;var o=r.dispatch,u=r.pending,d=i.memoizedState;if(u!==null){r.pending=null;var b=u=u.next;do d=t(d,b.action),b=b.next;while(b!==u);fi(d,i.memoizedState)||(Tn=!0),i.memoizedState=d,i.baseQueue===null&&(i.baseState=d),r.lastRenderedState=d}return[d,o]}function Cg(t,i,r){var o=Tt,u=Mn(),d=Ht;if(d){if(r===void 0)throw Error(s(407));r=r()}else r=i();var b=!fi((tn||u).memoizedState,r);if(b&&(u.memoizedState=r,Tn=!0),u=u.queue,jf(Dg.bind(null,o,u,t),[t]),u.getSnapshot!==i||b||En!==null&&En.memoizedState.tag&1){if(o.flags|=2048,Lr(9,{destroy:void 0},Rg.bind(null,o,u,r,i),null),ln===null)throw Error(s(349));d||(ba&127)!==0||wg(o,i,r)}return r}function wg(t,i,r){t.flags|=16384,t={getSnapshot:i,value:r},i=Tt.updateQueue,i===null?(i=oc(),Tt.updateQueue=i,i.stores=[t]):(r=i.stores,r===null?i.stores=[t]:r.push(t))}function Rg(t,i,r,o){i.value=r,i.getSnapshot=o,Ng(i)&&Ug(t)}function Dg(t,i,r){return r(function(){Ng(i)&&Ug(t)})}function Ng(t){var i=t.getSnapshot;t=t.value;try{var r=i();return!fi(t,r)}catch{return!0}}function Ug(t){var i=Bs(t,2);i!==null&&ii(i,t,2)}function Vf(t){var i=Zn();if(typeof t=="function"){var r=t;if(t=r(),Ws){Ie(!0);try{r()}finally{Ie(!1)}}}return i.memoizedState=i.baseState=t,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ea,lastRenderedState:t},i}function Lg(t,i,r,o){return t.baseState=r,Hf(t,tn,typeof o=="function"?o:Ea)}function qS(t,i,r,o,u){if(dc(t))throw Error(s(485));if(t=i.action,t!==null){var d={payload:u,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){d.listeners.push(b)}};G.T!==null?r(!0):d.isTransition=!1,o(d),r=i.pending,r===null?(d.next=i.pending=d,Og(i,d)):(d.next=r.next,i.pending=r.next=d)}}function Og(t,i){var r=i.action,o=i.payload,u=t.state;if(i.isTransition){var d=G.T,b={};G.T=b;try{var D=r(u,o),X=G.S;X!==null&&X(b,D),Pg(t,i,D)}catch(ue){kf(t,i,ue)}finally{d!==null&&b.types!==null&&(d.types=b.types),G.T=d}}else try{d=r(u,o),Pg(t,i,d)}catch(ue){kf(t,i,ue)}}function Pg(t,i,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(o){Ig(t,i,o)},function(o){return kf(t,i,o)}):Ig(t,i,r)}function Ig(t,i,r){i.status="fulfilled",i.value=r,Bg(i),t.state=r,i=t.pending,i!==null&&(r=i.next,r===i?t.pending=null:(r=r.next,i.next=r,Og(t,r)))}function kf(t,i,r){var o=t.pending;if(t.pending=null,o!==null){o=o.next;do i.status="rejected",i.reason=r,Bg(i),i=i.next;while(i!==o)}t.action=null}function Bg(t){t=t.listeners;for(var i=0;i<t.length;i++)(0,t[i])()}function Fg(t,i){return i}function zg(t,i){if(Ht){var r=ln.formState;if(r!==null){e:{var o=Tt;if(Ht){if(un){t:{for(var u=un,d=Ai;u.nodeType!==8;){if(!d){u=null;break t}if(u=wi(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){un=wi(u.nextSibling),o=u.data==="F!";break e}}Qa(o)}o=!1}o&&(i=r[0])}}return r=Zn(),r.memoizedState=r.baseState=i,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fg,lastRenderedState:i},r.queue=o,r=a0.bind(null,Tt,o),o.dispatch=r,o=Vf(!1),d=Zf.bind(null,Tt,!1,o.queue),o=Zn(),u={state:i,dispatch:null,action:t,pending:null},o.queue=u,r=qS.bind(null,Tt,u,d,r),u.dispatch=r,o.memoizedState=t,[i,r,!1]}function Hg(t){var i=Mn();return Gg(i,tn,t)}function Gg(t,i,r){if(i=Hf(t,i,Fg)[0],t=cc(Ea)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var o=Xo(i)}catch(b){throw b===wr?Jl:b}else o=i;i=Mn();var u=i.queue,d=u.dispatch;return r!==i.memoizedState&&(Tt.flags|=2048,Lr(9,{destroy:void 0},YS.bind(null,u,r),null)),[o,d,t]}function YS(t,i){t.action=i}function Vg(t){var i=Mn(),r=tn;if(r!==null)return Gg(i,r,t);Mn(),i=i.memoizedState,r=Mn();var o=r.queue.dispatch;return r.memoizedState=t,[i,o,!1]}function Lr(t,i,r,o){return t={tag:t,create:r,deps:o,inst:i,next:null},i=Tt.updateQueue,i===null&&(i=oc(),Tt.updateQueue=i),r=i.lastEffect,r===null?i.lastEffect=t.next=t:(o=r.next,r.next=t,t.next=o,i.lastEffect=t),t}function kg(){return Mn().memoizedState}function uc(t,i,r,o){var u=Zn();Tt.flags|=t,u.memoizedState=Lr(1|i,{destroy:void 0},r,o===void 0?null:o)}function fc(t,i,r,o){var u=Mn();o=o===void 0?null:o;var d=u.memoizedState.inst;tn!==null&&o!==null&&Of(o,tn.memoizedState.deps)?u.memoizedState=Lr(i,d,r,o):(Tt.flags|=t,u.memoizedState=Lr(1|i,d,r,o))}function jg(t,i){uc(8390656,8,t,i)}function jf(t,i){fc(2048,8,t,i)}function ZS(t){Tt.flags|=4;var i=Tt.updateQueue;if(i===null)i=oc(),Tt.updateQueue=i,i.events=[t];else{var r=i.events;r===null?i.events=[t]:r.push(t)}}function Xg(t){var i=Mn().memoizedState;return ZS({ref:i,nextImpl:t}),function(){if((Xt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function Wg(t,i){return fc(4,2,t,i)}function qg(t,i){return fc(4,4,t,i)}function Yg(t,i){if(typeof i=="function"){t=t();var r=i(t);return function(){typeof r=="function"?r():i(null)}}if(i!=null)return t=t(),i.current=t,function(){i.current=null}}function Zg(t,i,r){r=r!=null?r.concat([t]):null,fc(4,4,Yg.bind(null,i,t),r)}function Xf(){}function Kg(t,i){var r=Mn();i=i===void 0?null:i;var o=r.memoizedState;return i!==null&&Of(i,o[1])?o[0]:(r.memoizedState=[t,i],t)}function $g(t,i){var r=Mn();i=i===void 0?null:i;var o=r.memoizedState;if(i!==null&&Of(i,o[1]))return o[0];if(o=t(),Ws){Ie(!0);try{t()}finally{Ie(!1)}}return r.memoizedState=[o,i],o}function Wf(t,i,r){return r===void 0||(ba&1073741824)!==0&&(Bt&261930)===0?t.memoizedState=i:(t.memoizedState=r,t=Q0(),Tt.lanes|=t,os|=t,r)}function Qg(t,i,r,o){return fi(r,i)?r:Dr.current!==null?(t=Wf(t,r,o),fi(t,i)||(Tn=!0),t):(ba&42)===0||(ba&1073741824)!==0&&(Bt&261930)===0?(Tn=!0,t.memoizedState=r):(t=Q0(),Tt.lanes|=t,os|=t,i)}function Jg(t,i,r,o,u){var d=j.p;j.p=d!==0&&8>d?d:8;var b=G.T,D={};G.T=D,Zf(t,!1,i,r);try{var X=u(),ue=G.S;if(ue!==null&&ue(D,X),X!==null&&typeof X=="object"&&typeof X.then=="function"){var be=jS(X,o);Wo(t,i,be,_i(t))}else Wo(t,i,o,_i(t))}catch(we){Wo(t,i,{then:function(){},status:"rejected",reason:we},_i())}finally{j.p=d,b!==null&&D.types!==null&&(b.types=D.types),G.T=b}}function KS(){}function qf(t,i,r,o){if(t.tag!==5)throw Error(s(476));var u=e0(t).queue;Jg(t,u,i,se,r===null?KS:function(){return t0(t),r(o)})}function e0(t){var i=t.memoizedState;if(i!==null)return i;i={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ea,lastRenderedState:se},next:null};var r={};return i.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ea,lastRenderedState:r},next:null},t.memoizedState=i,t=t.alternate,t!==null&&(t.memoizedState=i),i}function t0(t){var i=e0(t);i.next===null&&(i=t.alternate.memoizedState),Wo(t,i.next.queue,{},_i())}function Yf(){return zn(cl)}function n0(){return Mn().memoizedState}function i0(){return Mn().memoizedState}function $S(t){for(var i=t.return;i!==null;){switch(i.tag){case 24:case 3:var r=_i();t=ts(r);var o=ns(i,t,r);o!==null&&(ii(o,i,r),Go(o,i,r)),i={cache:bf()},t.payload=i;return}i=i.return}}function QS(t,i,r){var o=_i();r={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},dc(t)?s0(i,r):(r=df(t,i,r,o),r!==null&&(ii(r,t,o),r0(r,i,o)))}function a0(t,i,r){var o=_i();Wo(t,i,r,o)}function Wo(t,i,r,o){var u={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(dc(t))s0(i,u);else{var d=t.alternate;if(t.lanes===0&&(d===null||d.lanes===0)&&(d=i.lastRenderedReducer,d!==null))try{var b=i.lastRenderedState,D=d(b,r);if(u.hasEagerState=!0,u.eagerState=D,fi(D,b))return Wl(t,i,u,0),ln===null&&Xl(),!1}catch{}if(r=df(t,i,u,o),r!==null)return ii(r,t,o),r0(r,i,o),!0}return!1}function Zf(t,i,r,o){if(o={lane:2,revertLane:Cd(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},dc(t)){if(i)throw Error(s(479))}else i=df(t,r,o,2),i!==null&&ii(i,t,2)}function dc(t){var i=t.alternate;return t===Tt||i!==null&&i===Tt}function s0(t,i){Nr=sc=!0;var r=t.pending;r===null?i.next=i:(i.next=r.next,r.next=i),t.pending=i}function r0(t,i,r){if((r&4194048)!==0){var o=i.lanes;o&=t.pendingLanes,r|=o,i.lanes=r,dn(t,r)}}var qo={readContext:zn,use:lc,useCallback:xn,useContext:xn,useEffect:xn,useImperativeHandle:xn,useLayoutEffect:xn,useInsertionEffect:xn,useMemo:xn,useReducer:xn,useRef:xn,useState:xn,useDebugValue:xn,useDeferredValue:xn,useTransition:xn,useSyncExternalStore:xn,useId:xn,useHostTransitionStatus:xn,useFormState:xn,useActionState:xn,useOptimistic:xn,useMemoCache:xn,useCacheRefresh:xn};qo.useEffectEvent=xn;var o0={readContext:zn,use:lc,useCallback:function(t,i){return Zn().memoizedState=[t,i===void 0?null:i],t},useContext:zn,useEffect:jg,useImperativeHandle:function(t,i,r){r=r!=null?r.concat([t]):null,uc(4194308,4,Yg.bind(null,i,t),r)},useLayoutEffect:function(t,i){return uc(4194308,4,t,i)},useInsertionEffect:function(t,i){uc(4,2,t,i)},useMemo:function(t,i){var r=Zn();i=i===void 0?null:i;var o=t();if(Ws){Ie(!0);try{t()}finally{Ie(!1)}}return r.memoizedState=[o,i],o},useReducer:function(t,i,r){var o=Zn();if(r!==void 0){var u=r(i);if(Ws){Ie(!0);try{r(i)}finally{Ie(!1)}}}else u=i;return o.memoizedState=o.baseState=u,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:u},o.queue=t,t=t.dispatch=QS.bind(null,Tt,t),[o.memoizedState,t]},useRef:function(t){var i=Zn();return t={current:t},i.memoizedState=t},useState:function(t){t=Vf(t);var i=t.queue,r=a0.bind(null,Tt,i);return i.dispatch=r,[t.memoizedState,r]},useDebugValue:Xf,useDeferredValue:function(t,i){var r=Zn();return Wf(r,t,i)},useTransition:function(){var t=Vf(!1);return t=Jg.bind(null,Tt,t.queue,!0,!1),Zn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,i,r){var o=Tt,u=Zn();if(Ht){if(r===void 0)throw Error(s(407));r=r()}else{if(r=i(),ln===null)throw Error(s(349));(Bt&127)!==0||wg(o,i,r)}u.memoizedState=r;var d={value:r,getSnapshot:i};return u.queue=d,jg(Dg.bind(null,o,d,t),[t]),o.flags|=2048,Lr(9,{destroy:void 0},Rg.bind(null,o,d,r,i),null),r},useId:function(){var t=Zn(),i=ln.identifierPrefix;if(Ht){var r=na,o=ta;r=(o&~(1<<32-Xe(o)-1)).toString(32)+r,i="_"+i+"R_"+r,r=rc++,0<r&&(i+="H"+r.toString(32)),i+="_"}else r=XS++,i="_"+i+"r_"+r.toString(32)+"_";return t.memoizedState=i},useHostTransitionStatus:Yf,useFormState:zg,useActionState:zg,useOptimistic:function(t){var i=Zn();i.memoizedState=i.baseState=t;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=r,i=Zf.bind(null,Tt,!0,r),r.dispatch=i,[t,i]},useMemoCache:zf,useCacheRefresh:function(){return Zn().memoizedState=$S.bind(null,Tt)},useEffectEvent:function(t){var i=Zn(),r={impl:t};return i.memoizedState=r,function(){if((Xt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}},Kf={readContext:zn,use:lc,useCallback:Kg,useContext:zn,useEffect:jf,useImperativeHandle:Zg,useInsertionEffect:Wg,useLayoutEffect:qg,useMemo:$g,useReducer:cc,useRef:kg,useState:function(){return cc(Ea)},useDebugValue:Xf,useDeferredValue:function(t,i){var r=Mn();return Qg(r,tn.memoizedState,t,i)},useTransition:function(){var t=cc(Ea)[0],i=Mn().memoizedState;return[typeof t=="boolean"?t:Xo(t),i]},useSyncExternalStore:Cg,useId:n0,useHostTransitionStatus:Yf,useFormState:Hg,useActionState:Hg,useOptimistic:function(t,i){var r=Mn();return Lg(r,tn,t,i)},useMemoCache:zf,useCacheRefresh:i0};Kf.useEffectEvent=Xg;var l0={readContext:zn,use:lc,useCallback:Kg,useContext:zn,useEffect:jf,useImperativeHandle:Zg,useInsertionEffect:Wg,useLayoutEffect:qg,useMemo:$g,useReducer:Gf,useRef:kg,useState:function(){return Gf(Ea)},useDebugValue:Xf,useDeferredValue:function(t,i){var r=Mn();return tn===null?Wf(r,t,i):Qg(r,tn.memoizedState,t,i)},useTransition:function(){var t=Gf(Ea)[0],i=Mn().memoizedState;return[typeof t=="boolean"?t:Xo(t),i]},useSyncExternalStore:Cg,useId:n0,useHostTransitionStatus:Yf,useFormState:Vg,useActionState:Vg,useOptimistic:function(t,i){var r=Mn();return tn!==null?Lg(r,tn,t,i):(r.baseState=t,[t,r.queue.dispatch])},useMemoCache:zf,useCacheRefresh:i0};l0.useEffectEvent=Xg;function $f(t,i,r,o){i=t.memoizedState,r=r(o,i),r=r==null?i:S({},i,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var Qf={enqueueSetState:function(t,i,r){t=t._reactInternals;var o=_i(),u=ts(o);u.payload=i,r!=null&&(u.callback=r),i=ns(t,u,o),i!==null&&(ii(i,t,o),Go(i,t,o))},enqueueReplaceState:function(t,i,r){t=t._reactInternals;var o=_i(),u=ts(o);u.tag=1,u.payload=i,r!=null&&(u.callback=r),i=ns(t,u,o),i!==null&&(ii(i,t,o),Go(i,t,o))},enqueueForceUpdate:function(t,i){t=t._reactInternals;var r=_i(),o=ts(r);o.tag=2,i!=null&&(o.callback=i),i=ns(t,o,r),i!==null&&(ii(i,t,r),Go(i,t,r))}};function c0(t,i,r,o,u,d,b){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,d,b):i.prototype&&i.prototype.isPureReactComponent?!Lo(r,o)||!Lo(u,d):!0}function u0(t,i,r,o){t=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(r,o),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(r,o),i.state!==t&&Qf.enqueueReplaceState(i,i.state,null)}function qs(t,i){var r=i;if("ref"in i){r={};for(var o in i)o!=="ref"&&(r[o]=i[o])}if(t=t.defaultProps){r===i&&(r=S({},r));for(var u in t)r[u]===void 0&&(r[u]=t[u])}return r}function f0(t){jl(t)}function d0(t){console.error(t)}function h0(t){jl(t)}function hc(t,i){try{var r=t.onUncaughtError;r(i.value,{componentStack:i.stack})}catch(o){setTimeout(function(){throw o})}}function p0(t,i,r){try{var o=t.onCaughtError;o(r.value,{componentStack:r.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Jf(t,i,r){return r=ts(r),r.tag=3,r.payload={element:null},r.callback=function(){hc(t,i)},r}function m0(t){return t=ts(t),t.tag=3,t}function g0(t,i,r,o){var u=r.type.getDerivedStateFromError;if(typeof u=="function"){var d=o.value;t.payload=function(){return u(d)},t.callback=function(){p0(i,r,o)}}var b=r.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(t.callback=function(){p0(i,r,o),typeof u!="function"&&(ls===null?ls=new Set([this]):ls.add(this));var D=o.stack;this.componentDidCatch(o.value,{componentStack:D!==null?D:""})})}function JS(t,i,r,o,u){if(r.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(i=r.alternate,i!==null&&Tr(i,r,u,!0),r=hi.current,r!==null){switch(r.tag){case 31:case 13:return Ci===null?Tc():r.alternate===null&&yn===0&&(yn=3),r.flags&=-257,r.flags|=65536,r.lanes=u,o===ec?r.flags|=16384:(i=r.updateQueue,i===null?r.updateQueue=new Set([o]):i.add(o),Ed(t,o,u)),!1;case 22:return r.flags|=65536,o===ec?r.flags|=16384:(i=r.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([o])},r.updateQueue=i):(r=i.retryQueue,r===null?i.retryQueue=new Set([o]):r.add(o)),Ed(t,o,u)),!1}throw Error(s(435,r.tag))}return Ed(t,o,u),Tc(),!1}if(Ht)return i=hi.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=u,o!==vf&&(t=Error(s(422),{cause:o}),Io(bi(t,r)))):(o!==vf&&(i=Error(s(423),{cause:o}),Io(bi(i,r))),t=t.current.alternate,t.flags|=65536,u&=-u,t.lanes|=u,o=bi(o,r),u=Jf(t.stateNode,o,u),Rf(t,u),yn!==4&&(yn=2)),!1;var d=Error(s(520),{cause:o});if(d=bi(d,r),tl===null?tl=[d]:tl.push(d),yn!==4&&(yn=2),i===null)return!0;o=bi(o,r),r=i;do{switch(r.tag){case 3:return r.flags|=65536,t=u&-u,r.lanes|=t,t=Jf(r.stateNode,o,t),Rf(r,t),!1;case 1:if(i=r.type,d=r.stateNode,(r.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(ls===null||!ls.has(d))))return r.flags|=65536,u&=-u,r.lanes|=u,u=m0(u),g0(u,t,r,o),Rf(r,u),!1}r=r.return}while(r!==null);return!1}var ed=Error(s(461)),Tn=!1;function Hn(t,i,r,o){i.child=t===null?yg(i,null,r,o):Xs(i,t.child,r,o)}function _0(t,i,r,o,u){r=r.render;var d=i.ref;if("ref"in o){var b={};for(var D in o)D!=="ref"&&(b[D]=o[D])}else b=o;return Gs(i),o=Pf(t,i,r,b,d,u),D=If(),t!==null&&!Tn?(Bf(t,i,u),Ta(t,i,u)):(Ht&&D&&gf(i),i.flags|=1,Hn(t,i,o,u),i.child)}function v0(t,i,r,o,u){if(t===null){var d=r.type;return typeof d=="function"&&!hf(d)&&d.defaultProps===void 0&&r.compare===null?(i.tag=15,i.type=d,x0(t,i,d,o,u)):(t=Yl(r.type,null,o,i,i.mode,u),t.ref=i.ref,t.return=i,i.child=t)}if(d=t.child,!ld(t,u)){var b=d.memoizedProps;if(r=r.compare,r=r!==null?r:Lo,r(b,o)&&t.ref===i.ref)return Ta(t,i,u)}return i.flags|=1,t=xa(d,o),t.ref=i.ref,t.return=i,i.child=t}function x0(t,i,r,o,u){if(t!==null){var d=t.memoizedProps;if(Lo(d,o)&&t.ref===i.ref)if(Tn=!1,i.pendingProps=o=d,ld(t,u))(t.flags&131072)!==0&&(Tn=!0);else return i.lanes=t.lanes,Ta(t,i,u)}return td(t,i,r,o,u)}function y0(t,i,r,o){var u=o.children,d=t!==null?t.memoizedState:null;if(t===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((i.flags&128)!==0){if(d=d!==null?d.baseLanes|r:r,t!==null){for(o=i.child=t.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~d}else o=0,i.child=null;return S0(t,i,d,r,o)}if((r&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},t!==null&&Ql(i,d!==null?d.cachePool:null),d!==null?bg(i,d):Nf(),Eg(i);else return o=i.lanes=536870912,S0(t,i,d!==null?d.baseLanes|r:r,r,o)}else d!==null?(Ql(i,d.cachePool),bg(i,d),as(),i.memoizedState=null):(t!==null&&Ql(i,null),Nf(),as());return Hn(t,i,u,r),i.child}function Yo(t,i){return t!==null&&t.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function S0(t,i,r,o,u){var d=Tf();return d=d===null?null:{parent:bn._currentValue,pool:d},i.memoizedState={baseLanes:r,cachePool:d},t!==null&&Ql(i,null),Nf(),Eg(i),t!==null&&Tr(t,i,o,!0),i.childLanes=u,null}function pc(t,i){return i=gc({mode:i.mode,children:i.children},t.mode),i.ref=t.ref,t.child=i,i.return=t,i}function M0(t,i,r){return Xs(i,t.child,null,r),t=pc(i,i.pendingProps),t.flags|=2,pi(i),i.memoizedState=null,t}function eM(t,i,r){var o=i.pendingProps,u=(i.flags&128)!==0;if(i.flags&=-129,t===null){if(Ht){if(o.mode==="hidden")return t=pc(i,o),i.lanes=536870912,Yo(null,t);if(Lf(i),(t=un)?(t=O_(t,Ai),t=t!==null&&t.data==="&"?t:null,t!==null&&(i.memoizedState={dehydrated:t,treeContext:Ka!==null?{id:ta,overflow:na}:null,retryLane:536870912,hydrationErrors:null},r=sg(t),r.return=i,i.child=r,Fn=i,un=null)):t=null,t===null)throw Qa(i);return i.lanes=536870912,null}return pc(i,o)}var d=t.memoizedState;if(d!==null){var b=d.dehydrated;if(Lf(i),u)if(i.flags&256)i.flags&=-257,i=M0(t,i,r);else if(i.memoizedState!==null)i.child=t.child,i.flags|=128,i=null;else throw Error(s(558));else if(Tn||Tr(t,i,r,!1),u=(r&t.childLanes)!==0,Tn||u){if(o=ln,o!==null&&(b=Bn(o,r),b!==0&&b!==d.retryLane))throw d.retryLane=b,Bs(t,b),ii(o,t,b),ed;Tc(),i=M0(t,i,r)}else t=d.treeContext,un=wi(b.nextSibling),Fn=i,Ht=!0,$a=null,Ai=!1,t!==null&&lg(i,t),i=pc(i,o),i.flags|=4096;return i}return t=xa(t.child,{mode:o.mode,children:o.children}),t.ref=i.ref,i.child=t,t.return=i,t}function mc(t,i){var r=i.ref;if(r===null)t!==null&&t.ref!==null&&(i.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(s(284));(t===null||t.ref!==r)&&(i.flags|=4194816)}}function td(t,i,r,o,u){return Gs(i),r=Pf(t,i,r,o,void 0,u),o=If(),t!==null&&!Tn?(Bf(t,i,u),Ta(t,i,u)):(Ht&&o&&gf(i),i.flags|=1,Hn(t,i,r,u),i.child)}function b0(t,i,r,o,u,d){return Gs(i),i.updateQueue=null,r=Ag(i,o,r,u),Tg(t),o=If(),t!==null&&!Tn?(Bf(t,i,d),Ta(t,i,d)):(Ht&&o&&gf(i),i.flags|=1,Hn(t,i,r,d),i.child)}function E0(t,i,r,o,u){if(Gs(i),i.stateNode===null){var d=Sr,b=r.contextType;typeof b=="object"&&b!==null&&(d=zn(b)),d=new r(o,d),i.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Qf,i.stateNode=d,d._reactInternals=i,d=i.stateNode,d.props=o,d.state=i.memoizedState,d.refs={},Cf(i),b=r.contextType,d.context=typeof b=="object"&&b!==null?zn(b):Sr,d.state=i.memoizedState,b=r.getDerivedStateFromProps,typeof b=="function"&&($f(i,r,b,o),d.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(b=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),b!==d.state&&Qf.enqueueReplaceState(d,d.state,null),ko(i,o,d,u),Vo(),d.state=i.memoizedState),typeof d.componentDidMount=="function"&&(i.flags|=4194308),o=!0}else if(t===null){d=i.stateNode;var D=i.memoizedProps,X=qs(r,D);d.props=X;var ue=d.context,be=r.contextType;b=Sr,typeof be=="object"&&be!==null&&(b=zn(be));var we=r.getDerivedStateFromProps;be=typeof we=="function"||typeof d.getSnapshotBeforeUpdate=="function",D=i.pendingProps!==D,be||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(D||ue!==b)&&u0(i,d,o,b),es=!1;var de=i.memoizedState;d.state=de,ko(i,o,d,u),Vo(),ue=i.memoizedState,D||de!==ue||es?(typeof we=="function"&&($f(i,r,we,o),ue=i.memoizedState),(X=es||c0(i,r,X,o,de,ue,b))?(be||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(i.flags|=4194308)):(typeof d.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=o,i.memoizedState=ue),d.props=o,d.state=ue,d.context=b,o=X):(typeof d.componentDidMount=="function"&&(i.flags|=4194308),o=!1)}else{d=i.stateNode,wf(t,i),b=i.memoizedProps,be=qs(r,b),d.props=be,we=i.pendingProps,de=d.context,ue=r.contextType,X=Sr,typeof ue=="object"&&ue!==null&&(X=zn(ue)),D=r.getDerivedStateFromProps,(ue=typeof D=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(b!==we||de!==X)&&u0(i,d,o,X),es=!1,de=i.memoizedState,d.state=de,ko(i,o,d,u),Vo();var me=i.memoizedState;b!==we||de!==me||es||t!==null&&t.dependencies!==null&&Kl(t.dependencies)?(typeof D=="function"&&($f(i,r,D,o),me=i.memoizedState),(be=es||c0(i,r,be,o,de,me,X)||t!==null&&t.dependencies!==null&&Kl(t.dependencies))?(ue||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(o,me,X),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(o,me,X)),typeof d.componentDidUpdate=="function"&&(i.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof d.componentDidUpdate!="function"||b===t.memoizedProps&&de===t.memoizedState||(i.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||b===t.memoizedProps&&de===t.memoizedState||(i.flags|=1024),i.memoizedProps=o,i.memoizedState=me),d.props=o,d.state=me,d.context=X,o=be):(typeof d.componentDidUpdate!="function"||b===t.memoizedProps&&de===t.memoizedState||(i.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||b===t.memoizedProps&&de===t.memoizedState||(i.flags|=1024),o=!1)}return d=o,mc(t,i),o=(i.flags&128)!==0,d||o?(d=i.stateNode,r=o&&typeof r.getDerivedStateFromError!="function"?null:d.render(),i.flags|=1,t!==null&&o?(i.child=Xs(i,t.child,null,u),i.child=Xs(i,null,r,u)):Hn(t,i,r,u),i.memoizedState=d.state,t=i.child):t=Ta(t,i,u),t}function T0(t,i,r,o){return zs(),i.flags|=256,Hn(t,i,r,o),i.child}var nd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function id(t){return{baseLanes:t,cachePool:pg()}}function ad(t,i,r){return t=t!==null?t.childLanes&~r:0,i&&(t|=gi),t}function A0(t,i,r){var o=i.pendingProps,u=!1,d=(i.flags&128)!==0,b;if((b=d)||(b=t!==null&&t.memoizedState===null?!1:(Sn.current&2)!==0),b&&(u=!0,i.flags&=-129),b=(i.flags&32)!==0,i.flags&=-33,t===null){if(Ht){if(u?is(i):as(),(t=un)?(t=O_(t,Ai),t=t!==null&&t.data!=="&"?t:null,t!==null&&(i.memoizedState={dehydrated:t,treeContext:Ka!==null?{id:ta,overflow:na}:null,retryLane:536870912,hydrationErrors:null},r=sg(t),r.return=i,i.child=r,Fn=i,un=null)):t=null,t===null)throw Qa(i);return Hd(t)?i.lanes=32:i.lanes=536870912,null}var D=o.children;return o=o.fallback,u?(as(),u=i.mode,D=gc({mode:"hidden",children:D},u),o=Fs(o,u,r,null),D.return=i,o.return=i,D.sibling=o,i.child=D,o=i.child,o.memoizedState=id(r),o.childLanes=ad(t,b,r),i.memoizedState=nd,Yo(null,o)):(is(i),sd(i,D))}var X=t.memoizedState;if(X!==null&&(D=X.dehydrated,D!==null)){if(d)i.flags&256?(is(i),i.flags&=-257,i=rd(t,i,r)):i.memoizedState!==null?(as(),i.child=t.child,i.flags|=128,i=null):(as(),D=o.fallback,u=i.mode,o=gc({mode:"visible",children:o.children},u),D=Fs(D,u,r,null),D.flags|=2,o.return=i,D.return=i,o.sibling=D,i.child=o,Xs(i,t.child,null,r),o=i.child,o.memoizedState=id(r),o.childLanes=ad(t,b,r),i.memoizedState=nd,i=Yo(null,o));else if(is(i),Hd(D)){if(b=D.nextSibling&&D.nextSibling.dataset,b)var ue=b.dgst;b=ue,o=Error(s(419)),o.stack="",o.digest=b,Io({value:o,source:null,stack:null}),i=rd(t,i,r)}else if(Tn||Tr(t,i,r,!1),b=(r&t.childLanes)!==0,Tn||b){if(b=ln,b!==null&&(o=Bn(b,r),o!==0&&o!==X.retryLane))throw X.retryLane=o,Bs(t,o),ii(b,t,o),ed;zd(D)||Tc(),i=rd(t,i,r)}else zd(D)?(i.flags|=192,i.child=t.child,i=null):(t=X.treeContext,un=wi(D.nextSibling),Fn=i,Ht=!0,$a=null,Ai=!1,t!==null&&lg(i,t),i=sd(i,o.children),i.flags|=4096);return i}return u?(as(),D=o.fallback,u=i.mode,X=t.child,ue=X.sibling,o=xa(X,{mode:"hidden",children:o.children}),o.subtreeFlags=X.subtreeFlags&65011712,ue!==null?D=xa(ue,D):(D=Fs(D,u,r,null),D.flags|=2),D.return=i,o.return=i,o.sibling=D,i.child=o,Yo(null,o),o=i.child,D=t.child.memoizedState,D===null?D=id(r):(u=D.cachePool,u!==null?(X=bn._currentValue,u=u.parent!==X?{parent:X,pool:X}:u):u=pg(),D={baseLanes:D.baseLanes|r,cachePool:u}),o.memoizedState=D,o.childLanes=ad(t,b,r),i.memoizedState=nd,Yo(t.child,o)):(is(i),r=t.child,t=r.sibling,r=xa(r,{mode:"visible",children:o.children}),r.return=i,r.sibling=null,t!==null&&(b=i.deletions,b===null?(i.deletions=[t],i.flags|=16):b.push(t)),i.child=r,i.memoizedState=null,r)}function sd(t,i){return i=gc({mode:"visible",children:i},t.mode),i.return=t,t.child=i}function gc(t,i){return t=di(22,t,null,i),t.lanes=0,t}function rd(t,i,r){return Xs(i,t.child,null,r),t=sd(i,i.pendingProps.children),t.flags|=2,i.memoizedState=null,t}function C0(t,i,r){t.lanes|=i;var o=t.alternate;o!==null&&(o.lanes|=i),Sf(t.return,i,r)}function od(t,i,r,o,u,d){var b=t.memoizedState;b===null?t.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:o,tail:r,tailMode:u,treeForkCount:d}:(b.isBackwards=i,b.rendering=null,b.renderingStartTime=0,b.last=o,b.tail=r,b.tailMode=u,b.treeForkCount=d)}function w0(t,i,r){var o=i.pendingProps,u=o.revealOrder,d=o.tail;o=o.children;var b=Sn.current,D=(b&2)!==0;if(D?(b=b&1|2,i.flags|=128):b&=1,Ee(Sn,b),Hn(t,i,o,r),o=Ht?Po:0,!D&&t!==null&&(t.flags&128)!==0)e:for(t=i.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&C0(t,r,i);else if(t.tag===19)C0(t,r,i);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===i)break e;for(;t.sibling===null;){if(t.return===null||t.return===i)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(u){case"forwards":for(r=i.child,u=null;r!==null;)t=r.alternate,t!==null&&ac(t)===null&&(u=r),r=r.sibling;r=u,r===null?(u=i.child,i.child=null):(u=r.sibling,r.sibling=null),od(i,!1,u,r,d,o);break;case"backwards":case"unstable_legacy-backwards":for(r=null,u=i.child,i.child=null;u!==null;){if(t=u.alternate,t!==null&&ac(t)===null){i.child=u;break}t=u.sibling,u.sibling=r,r=u,u=t}od(i,!0,r,null,d,o);break;case"together":od(i,!1,null,null,void 0,o);break;default:i.memoizedState=null}return i.child}function Ta(t,i,r){if(t!==null&&(i.dependencies=t.dependencies),os|=i.lanes,(r&i.childLanes)===0)if(t!==null){if(Tr(t,i,r,!1),(r&i.childLanes)===0)return null}else return null;if(t!==null&&i.child!==t.child)throw Error(s(153));if(i.child!==null){for(t=i.child,r=xa(t,t.pendingProps),i.child=r,r.return=i;t.sibling!==null;)t=t.sibling,r=r.sibling=xa(t,t.pendingProps),r.return=i;r.sibling=null}return i.child}function ld(t,i){return(t.lanes&i)!==0?!0:(t=t.dependencies,!!(t!==null&&Kl(t)))}function tM(t,i,r){switch(i.tag){case 3:Ae(i,i.stateNode.containerInfo),Ja(i,bn,t.memoizedState.cache),zs();break;case 27:case 5:rt(i);break;case 4:Ae(i,i.stateNode.containerInfo);break;case 10:Ja(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,Lf(i),null;break;case 13:var o=i.memoizedState;if(o!==null)return o.dehydrated!==null?(is(i),i.flags|=128,null):(r&i.child.childLanes)!==0?A0(t,i,r):(is(i),t=Ta(t,i,r),t!==null?t.sibling:null);is(i);break;case 19:var u=(t.flags&128)!==0;if(o=(r&i.childLanes)!==0,o||(Tr(t,i,r,!1),o=(r&i.childLanes)!==0),u){if(o)return w0(t,i,r);i.flags|=128}if(u=i.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),Ee(Sn,Sn.current),o)break;return null;case 22:return i.lanes=0,y0(t,i,r,i.pendingProps);case 24:Ja(i,bn,t.memoizedState.cache)}return Ta(t,i,r)}function R0(t,i,r){if(t!==null)if(t.memoizedProps!==i.pendingProps)Tn=!0;else{if(!ld(t,r)&&(i.flags&128)===0)return Tn=!1,tM(t,i,r);Tn=(t.flags&131072)!==0}else Tn=!1,Ht&&(i.flags&1048576)!==0&&og(i,Po,i.index);switch(i.lanes=0,i.tag){case 16:e:{var o=i.pendingProps;if(t=ks(i.elementType),i.type=t,typeof t=="function")hf(t)?(o=qs(t,o),i.tag=1,i=E0(null,i,t,o,r)):(i.tag=0,i=td(null,i,t,o,r));else{if(t!=null){var u=t.$$typeof;if(u===R){i.tag=11,i=_0(null,i,t,o,r);break e}else if(u===U){i.tag=14,i=v0(null,i,t,o,r);break e}}throw i=pe(t)||t,Error(s(306,i,""))}}return i;case 0:return td(t,i,i.type,i.pendingProps,r);case 1:return o=i.type,u=qs(o,i.pendingProps),E0(t,i,o,u,r);case 3:e:{if(Ae(i,i.stateNode.containerInfo),t===null)throw Error(s(387));o=i.pendingProps;var d=i.memoizedState;u=d.element,wf(t,i),ko(i,o,null,r);var b=i.memoizedState;if(o=b.cache,Ja(i,bn,o),o!==d.cache&&Mf(i,[bn],r,!0),Vo(),o=b.element,d.isDehydrated)if(d={element:o,isDehydrated:!1,cache:b.cache},i.updateQueue.baseState=d,i.memoizedState=d,i.flags&256){i=T0(t,i,o,r);break e}else if(o!==u){u=bi(Error(s(424)),i),Io(u),i=T0(t,i,o,r);break e}else for(t=i.stateNode.containerInfo,t.nodeType===9?t=t.body:t=t.nodeName==="HTML"?t.ownerDocument.body:t,un=wi(t.firstChild),Fn=i,Ht=!0,$a=null,Ai=!0,r=yg(i,null,o,r),i.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(zs(),o===u){i=Ta(t,i,r);break e}Hn(t,i,o,r)}i=i.child}return i;case 26:return mc(t,i),t===null?(r=H_(i.type,null,i.pendingProps,null))?i.memoizedState=r:Ht||(r=i.type,t=i.pendingProps,o=Uc(le.current).createElement(r),o[St]=i,o[_n]=t,Gn(o,r,t),vn(o),i.stateNode=o):i.memoizedState=H_(i.type,t.memoizedProps,i.pendingProps,t.memoizedState),null;case 27:return rt(i),t===null&&Ht&&(o=i.stateNode=B_(i.type,i.pendingProps,le.current),Fn=i,Ai=!0,u=un,ds(i.type)?(Gd=u,un=wi(o.firstChild)):un=u),Hn(t,i,i.pendingProps.children,r),mc(t,i),t===null&&(i.flags|=4194304),i.child;case 5:return t===null&&Ht&&((u=o=un)&&(o=NM(o,i.type,i.pendingProps,Ai),o!==null?(i.stateNode=o,Fn=i,un=wi(o.firstChild),Ai=!1,u=!0):u=!1),u||Qa(i)),rt(i),u=i.type,d=i.pendingProps,b=t!==null?t.memoizedProps:null,o=d.children,Id(u,d)?o=null:b!==null&&Id(u,b)&&(i.flags|=32),i.memoizedState!==null&&(u=Pf(t,i,WS,null,null,r),cl._currentValue=u),mc(t,i),Hn(t,i,o,r),i.child;case 6:return t===null&&Ht&&((t=r=un)&&(r=UM(r,i.pendingProps,Ai),r!==null?(i.stateNode=r,Fn=i,un=null,t=!0):t=!1),t||Qa(i)),null;case 13:return A0(t,i,r);case 4:return Ae(i,i.stateNode.containerInfo),o=i.pendingProps,t===null?i.child=Xs(i,null,o,r):Hn(t,i,o,r),i.child;case 11:return _0(t,i,i.type,i.pendingProps,r);case 7:return Hn(t,i,i.pendingProps,r),i.child;case 8:return Hn(t,i,i.pendingProps.children,r),i.child;case 12:return Hn(t,i,i.pendingProps.children,r),i.child;case 10:return o=i.pendingProps,Ja(i,i.type,o.value),Hn(t,i,o.children,r),i.child;case 9:return u=i.type._context,o=i.pendingProps.children,Gs(i),u=zn(u),o=o(u),i.flags|=1,Hn(t,i,o,r),i.child;case 14:return v0(t,i,i.type,i.pendingProps,r);case 15:return x0(t,i,i.type,i.pendingProps,r);case 19:return w0(t,i,r);case 31:return eM(t,i,r);case 22:return y0(t,i,r,i.pendingProps);case 24:return Gs(i),o=zn(bn),t===null?(u=Tf(),u===null&&(u=ln,d=bf(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=r),u=d),i.memoizedState={parent:o,cache:u},Cf(i),Ja(i,bn,u)):((t.lanes&r)!==0&&(wf(t,i),ko(i,null,null,r),Vo()),u=t.memoizedState,d=i.memoizedState,u.parent!==o?(u={parent:o,cache:o},i.memoizedState=u,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=u),Ja(i,bn,o)):(o=d.cache,Ja(i,bn,o),o!==u.cache&&Mf(i,[bn],r,!0))),Hn(t,i,i.pendingProps.children,r),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function Aa(t){t.flags|=4}function cd(t,i,r,o,u){if((i=(t.mode&32)!==0)&&(i=!1),i){if(t.flags|=16777216,(u&335544128)===u)if(t.stateNode.complete)t.flags|=8192;else if(n_())t.flags|=8192;else throw js=ec,Af}else t.flags&=-16777217}function D0(t,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!X_(i))if(n_())t.flags|=8192;else throw js=ec,Af}function _c(t,i){i!==null&&(t.flags|=4),t.flags&16384&&(i=t.tag!==22?Ce():536870912,t.lanes|=i,Br|=i)}function Zo(t,i){if(!Ht)switch(t.tailMode){case"hidden":i=t.tail;for(var r=null;i!==null;)i.alternate!==null&&(r=i),i=i.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var o=null;r!==null;)r.alternate!==null&&(o=r),r=r.sibling;o===null?i||t.tail===null?t.tail=null:t.tail.sibling=null:o.sibling=null}}function fn(t){var i=t.alternate!==null&&t.alternate.child===t.child,r=0,o=0;if(i)for(var u=t.child;u!==null;)r|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=t,u=u.sibling;else for(u=t.child;u!==null;)r|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=t,u=u.sibling;return t.subtreeFlags|=o,t.childLanes=r,i}function nM(t,i,r){var o=i.pendingProps;switch(_f(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fn(i),null;case 1:return fn(i),null;case 3:return r=i.stateNode,o=null,t!==null&&(o=t.memoizedState.cache),i.memoizedState.cache!==o&&(i.flags|=2048),Ma(bn),je(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Er(i)?Aa(i):t===null||t.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,xf())),fn(i),null;case 26:var u=i.type,d=i.memoizedState;return t===null?(Aa(i),d!==null?(fn(i),D0(i,d)):(fn(i),cd(i,u,null,o,r))):d?d!==t.memoizedState?(Aa(i),fn(i),D0(i,d)):(fn(i),i.flags&=-16777217):(t=t.memoizedProps,t!==o&&Aa(i),fn(i),cd(i,u,t,o,r)),null;case 27:if($e(i),r=le.current,u=i.type,t!==null&&i.stateNode!=null)t.memoizedProps!==o&&Aa(i);else{if(!o){if(i.stateNode===null)throw Error(s(166));return fn(i),null}t=Oe.current,Er(i)?cg(i):(t=B_(u,o,r),i.stateNode=t,Aa(i))}return fn(i),null;case 5:if($e(i),u=i.type,t!==null&&i.stateNode!=null)t.memoizedProps!==o&&Aa(i);else{if(!o){if(i.stateNode===null)throw Error(s(166));return fn(i),null}if(d=Oe.current,Er(i))cg(i);else{var b=Uc(le.current);switch(d){case 1:d=b.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=b.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=b.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=b.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=b.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof o.is=="string"?b.createElement("select",{is:o.is}):b.createElement("select"),o.multiple?d.multiple=!0:o.size&&(d.size=o.size);break;default:d=typeof o.is=="string"?b.createElement(u,{is:o.is}):b.createElement(u)}}d[St]=i,d[_n]=o;e:for(b=i.child;b!==null;){if(b.tag===5||b.tag===6)d.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===i)break e;for(;b.sibling===null;){if(b.return===null||b.return===i)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}i.stateNode=d;e:switch(Gn(d,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Aa(i)}}return fn(i),cd(i,i.type,t===null?null:t.memoizedProps,i.pendingProps,r),null;case 6:if(t&&i.stateNode!=null)t.memoizedProps!==o&&Aa(i);else{if(typeof o!="string"&&i.stateNode===null)throw Error(s(166));if(t=le.current,Er(i)){if(t=i.stateNode,r=i.memoizedProps,o=null,u=Fn,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}t[St]=i,t=!!(t.nodeValue===r||o!==null&&o.suppressHydrationWarning===!0||A_(t.nodeValue,r)),t||Qa(i,!0)}else t=Uc(t).createTextNode(o),t[St]=i,i.stateNode=t}return fn(i),null;case 31:if(r=i.memoizedState,t===null||t.memoizedState!==null){if(o=Er(i),r!==null){if(t===null){if(!o)throw Error(s(318));if(t=i.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[St]=i}else zs(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;fn(i),t=!1}else r=xf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),t=!0;if(!t)return i.flags&256?(pi(i),i):(pi(i),null);if((i.flags&128)!==0)throw Error(s(558))}return fn(i),null;case 13:if(o=i.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(u=Er(i),o!==null&&o.dehydrated!==null){if(t===null){if(!u)throw Error(s(318));if(u=i.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[St]=i}else zs(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;fn(i),u=!1}else u=xf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=u),u=!0;if(!u)return i.flags&256?(pi(i),i):(pi(i),null)}return pi(i),(i.flags&128)!==0?(i.lanes=r,i):(r=o!==null,t=t!==null&&t.memoizedState!==null,r&&(o=i.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),d=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),d!==u&&(o.flags|=2048)),r!==t&&r&&(i.child.flags|=8192),_c(i,i.updateQueue),fn(i),null);case 4:return je(),t===null&&Nd(i.stateNode.containerInfo),fn(i),null;case 10:return Ma(i.type),fn(i),null;case 19:if(te(Sn),o=i.memoizedState,o===null)return fn(i),null;if(u=(i.flags&128)!==0,d=o.rendering,d===null)if(u)Zo(o,!1);else{if(yn!==0||t!==null&&(t.flags&128)!==0)for(t=i.child;t!==null;){if(d=ac(t),d!==null){for(i.flags|=128,Zo(o,!1),t=d.updateQueue,i.updateQueue=t,_c(i,t),i.subtreeFlags=0,t=r,r=i.child;r!==null;)ag(r,t),r=r.sibling;return Ee(Sn,Sn.current&1|2),Ht&&ya(i,o.treeForkCount),i.child}t=t.sibling}o.tail!==null&&Ue()>Mc&&(i.flags|=128,u=!0,Zo(o,!1),i.lanes=4194304)}else{if(!u)if(t=ac(d),t!==null){if(i.flags|=128,u=!0,t=t.updateQueue,i.updateQueue=t,_c(i,t),Zo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!d.alternate&&!Ht)return fn(i),null}else 2*Ue()-o.renderingStartTime>Mc&&r!==536870912&&(i.flags|=128,u=!0,Zo(o,!1),i.lanes=4194304);o.isBackwards?(d.sibling=i.child,i.child=d):(t=o.last,t!==null?t.sibling=d:i.child=d,o.last=d)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Ue(),t.sibling=null,r=Sn.current,Ee(Sn,u?r&1|2:r&1),Ht&&ya(i,o.treeForkCount),t):(fn(i),null);case 22:case 23:return pi(i),Uf(),o=i.memoizedState!==null,t!==null?t.memoizedState!==null!==o&&(i.flags|=8192):o&&(i.flags|=8192),o?(r&536870912)!==0&&(i.flags&128)===0&&(fn(i),i.subtreeFlags&6&&(i.flags|=8192)):fn(i),r=i.updateQueue,r!==null&&_c(i,r.retryQueue),r=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==r&&(i.flags|=2048),t!==null&&te(Vs),null;case 24:return r=null,t!==null&&(r=t.memoizedState.cache),i.memoizedState.cache!==r&&(i.flags|=2048),Ma(bn),fn(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function iM(t,i){switch(_f(i),i.tag){case 1:return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 3:return Ma(bn),je(),t=i.flags,(t&65536)!==0&&(t&128)===0?(i.flags=t&-65537|128,i):null;case 26:case 27:case 5:return $e(i),null;case 31:if(i.memoizedState!==null){if(pi(i),i.alternate===null)throw Error(s(340));zs()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 13:if(pi(i),t=i.memoizedState,t!==null&&t.dehydrated!==null){if(i.alternate===null)throw Error(s(340));zs()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 19:return te(Sn),null;case 4:return je(),null;case 10:return Ma(i.type),null;case 22:case 23:return pi(i),Uf(),t!==null&&te(Vs),t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 24:return Ma(bn),null;case 25:return null;default:return null}}function N0(t,i){switch(_f(i),i.tag){case 3:Ma(bn),je();break;case 26:case 27:case 5:$e(i);break;case 4:je();break;case 31:i.memoizedState!==null&&pi(i);break;case 13:pi(i);break;case 19:te(Sn);break;case 10:Ma(i.type);break;case 22:case 23:pi(i),Uf(),t!==null&&te(Vs);break;case 24:Ma(bn)}}function Ko(t,i){try{var r=i.updateQueue,o=r!==null?r.lastEffect:null;if(o!==null){var u=o.next;r=u;do{if((r.tag&t)===t){o=void 0;var d=r.create,b=r.inst;o=d(),b.destroy=o}r=r.next}while(r!==u)}}catch(D){Jt(i,i.return,D)}}function ss(t,i,r){try{var o=i.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var d=u.next;o=d;do{if((o.tag&t)===t){var b=o.inst,D=b.destroy;if(D!==void 0){b.destroy=void 0,u=i;var X=r,ue=D;try{ue()}catch(be){Jt(u,X,be)}}}o=o.next}while(o!==d)}}catch(be){Jt(i,i.return,be)}}function U0(t){var i=t.updateQueue;if(i!==null){var r=t.stateNode;try{Mg(i,r)}catch(o){Jt(t,t.return,o)}}}function L0(t,i,r){r.props=qs(t.type,t.memoizedProps),r.state=t.memoizedState;try{r.componentWillUnmount()}catch(o){Jt(t,i,o)}}function $o(t,i){try{var r=t.ref;if(r!==null){switch(t.tag){case 26:case 27:case 5:var o=t.stateNode;break;case 30:o=t.stateNode;break;default:o=t.stateNode}typeof r=="function"?t.refCleanup=r(o):r.current=o}}catch(u){Jt(t,i,u)}}function ia(t,i){var r=t.ref,o=t.refCleanup;if(r!==null)if(typeof o=="function")try{o()}catch(u){Jt(t,i,u)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(u){Jt(t,i,u)}else r.current=null}function O0(t){var i=t.type,r=t.memoizedProps,o=t.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":r.autoFocus&&o.focus();break e;case"img":r.src?o.src=r.src:r.srcSet&&(o.srcset=r.srcSet)}}catch(u){Jt(t,t.return,u)}}function ud(t,i,r){try{var o=t.stateNode;TM(o,t.type,r,i),o[_n]=i}catch(u){Jt(t,t.return,u)}}function P0(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&ds(t.type)||t.tag===4}function fd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||P0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&ds(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function dd(t,i,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,i?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(t,i):(i=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,i.appendChild(t),r=r._reactRootContainer,r!=null||i.onclick!==null||(i.onclick=_a));else if(o!==4&&(o===27&&ds(t.type)&&(r=t.stateNode,i=null),t=t.child,t!==null))for(dd(t,i,r),t=t.sibling;t!==null;)dd(t,i,r),t=t.sibling}function vc(t,i,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,i?r.insertBefore(t,i):r.appendChild(t);else if(o!==4&&(o===27&&ds(t.type)&&(r=t.stateNode),t=t.child,t!==null))for(vc(t,i,r),t=t.sibling;t!==null;)vc(t,i,r),t=t.sibling}function I0(t){var i=t.stateNode,r=t.memoizedProps;try{for(var o=t.type,u=i.attributes;u.length;)i.removeAttributeNode(u[0]);Gn(i,o,r),i[St]=t,i[_n]=r}catch(d){Jt(t,t.return,d)}}var Ca=!1,An=!1,hd=!1,B0=typeof WeakSet=="function"?WeakSet:Set,On=null;function aM(t,i){if(t=t.containerInfo,Od=zc,t=Zm(t),rf(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var o=r.getSelection&&r.getSelection();if(o&&o.rangeCount!==0){r=o.anchorNode;var u=o.anchorOffset,d=o.focusNode;o=o.focusOffset;try{r.nodeType,d.nodeType}catch{r=null;break e}var b=0,D=-1,X=-1,ue=0,be=0,we=t,de=null;t:for(;;){for(var me;we!==r||u!==0&&we.nodeType!==3||(D=b+u),we!==d||o!==0&&we.nodeType!==3||(X=b+o),we.nodeType===3&&(b+=we.nodeValue.length),(me=we.firstChild)!==null;)de=we,we=me;for(;;){if(we===t)break t;if(de===r&&++ue===u&&(D=b),de===d&&++be===o&&(X=b),(me=we.nextSibling)!==null)break;we=de,de=we.parentNode}we=me}r=D===-1||X===-1?null:{start:D,end:X}}else r=null}r=r||{start:0,end:0}}else r=null;for(Pd={focusedElem:t,selectionRange:r},zc=!1,On=i;On!==null;)if(i=On,t=i.child,(i.subtreeFlags&1028)!==0&&t!==null)t.return=i,On=t;else for(;On!==null;){switch(i=On,d=i.alternate,t=i.flags,i.tag){case 0:if((t&4)!==0&&(t=i.updateQueue,t=t!==null?t.events:null,t!==null))for(r=0;r<t.length;r++)u=t[r],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&d!==null){t=void 0,r=i,u=d.memoizedProps,d=d.memoizedState,o=r.stateNode;try{var et=qs(r.type,u);t=o.getSnapshotBeforeUpdate(et,d),o.__reactInternalSnapshotBeforeUpdate=t}catch(pt){Jt(r,r.return,pt)}}break;case 3:if((t&1024)!==0){if(t=i.stateNode.containerInfo,r=t.nodeType,r===9)Fd(t);else if(r===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Fd(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(s(163))}if(t=i.sibling,t!==null){t.return=i.return,On=t;break}On=i.return}}function F0(t,i,r){var o=r.flags;switch(r.tag){case 0:case 11:case 15:Ra(t,r),o&4&&Ko(5,r);break;case 1:if(Ra(t,r),o&4)if(t=r.stateNode,i===null)try{t.componentDidMount()}catch(b){Jt(r,r.return,b)}else{var u=qs(r.type,i.memoizedProps);i=i.memoizedState;try{t.componentDidUpdate(u,i,t.__reactInternalSnapshotBeforeUpdate)}catch(b){Jt(r,r.return,b)}}o&64&&U0(r),o&512&&$o(r,r.return);break;case 3:if(Ra(t,r),o&64&&(t=r.updateQueue,t!==null)){if(i=null,r.child!==null)switch(r.child.tag){case 27:case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}try{Mg(t,i)}catch(b){Jt(r,r.return,b)}}break;case 27:i===null&&o&4&&I0(r);case 26:case 5:Ra(t,r),i===null&&o&4&&O0(r),o&512&&$o(r,r.return);break;case 12:Ra(t,r);break;case 31:Ra(t,r),o&4&&G0(t,r);break;case 13:Ra(t,r),o&4&&V0(t,r),o&64&&(t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(r=hM.bind(null,r),LM(t,r))));break;case 22:if(o=r.memoizedState!==null||Ca,!o){i=i!==null&&i.memoizedState!==null||An,u=Ca;var d=An;Ca=o,(An=i)&&!d?Da(t,r,(r.subtreeFlags&8772)!==0):Ra(t,r),Ca=u,An=d}break;case 30:break;default:Ra(t,r)}}function z0(t){var i=t.alternate;i!==null&&(t.alternate=null,z0(i)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(i=t.stateNode,i!==null&&Ji(i)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var mn=null,Jn=!1;function wa(t,i,r){for(r=r.child;r!==null;)H0(t,i,r),r=r.sibling}function H0(t,i,r){if(ve&&typeof ve.onCommitFiberUnmount=="function")try{ve.onCommitFiberUnmount(_e,r)}catch{}switch(r.tag){case 26:An||ia(r,i),wa(t,i,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:An||ia(r,i);var o=mn,u=Jn;ds(r.type)&&(mn=r.stateNode,Jn=!1),wa(t,i,r),rl(r.stateNode),mn=o,Jn=u;break;case 5:An||ia(r,i);case 6:if(o=mn,u=Jn,mn=null,wa(t,i,r),mn=o,Jn=u,mn!==null)if(Jn)try{(mn.nodeType===9?mn.body:mn.nodeName==="HTML"?mn.ownerDocument.body:mn).removeChild(r.stateNode)}catch(d){Jt(r,i,d)}else try{mn.removeChild(r.stateNode)}catch(d){Jt(r,i,d)}break;case 18:mn!==null&&(Jn?(t=mn,U_(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,r.stateNode),Xr(t)):U_(mn,r.stateNode));break;case 4:o=mn,u=Jn,mn=r.stateNode.containerInfo,Jn=!0,wa(t,i,r),mn=o,Jn=u;break;case 0:case 11:case 14:case 15:ss(2,r,i),An||ss(4,r,i),wa(t,i,r);break;case 1:An||(ia(r,i),o=r.stateNode,typeof o.componentWillUnmount=="function"&&L0(r,i,o)),wa(t,i,r);break;case 21:wa(t,i,r);break;case 22:An=(o=An)||r.memoizedState!==null,wa(t,i,r),An=o;break;default:wa(t,i,r)}}function G0(t,i){if(i.memoizedState===null&&(t=i.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Xr(t)}catch(r){Jt(i,i.return,r)}}}function V0(t,i){if(i.memoizedState===null&&(t=i.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Xr(t)}catch(r){Jt(i,i.return,r)}}function sM(t){switch(t.tag){case 31:case 13:case 19:var i=t.stateNode;return i===null&&(i=t.stateNode=new B0),i;case 22:return t=t.stateNode,i=t._retryCache,i===null&&(i=t._retryCache=new B0),i;default:throw Error(s(435,t.tag))}}function xc(t,i){var r=sM(t);i.forEach(function(o){if(!r.has(o)){r.add(o);var u=pM.bind(null,t,o);o.then(u,u)}})}function ei(t,i){var r=i.deletions;if(r!==null)for(var o=0;o<r.length;o++){var u=r[o],d=t,b=i,D=b;e:for(;D!==null;){switch(D.tag){case 27:if(ds(D.type)){mn=D.stateNode,Jn=!1;break e}break;case 5:mn=D.stateNode,Jn=!1;break e;case 3:case 4:mn=D.stateNode.containerInfo,Jn=!0;break e}D=D.return}if(mn===null)throw Error(s(160));H0(d,b,u),mn=null,Jn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)k0(i,t),i=i.sibling}var Gi=null;function k0(t,i){var r=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:ei(i,t),ti(t),o&4&&(ss(3,t,t.return),Ko(3,t),ss(5,t,t.return));break;case 1:ei(i,t),ti(t),o&512&&(An||r===null||ia(r,r.return)),o&64&&Ca&&(t=t.updateQueue,t!==null&&(o=t.callbacks,o!==null&&(r=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=r===null?o:r.concat(o))));break;case 26:var u=Gi;if(ei(i,t),ti(t),o&512&&(An||r===null||ia(r,r.return)),o&4){var d=r!==null?r.memoizedState:null;if(o=t.memoizedState,r===null)if(o===null)if(t.stateNode===null){e:{o=t.type,r=t.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Qi]||d[St]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(o),u.head.insertBefore(d,u.querySelector("head > title"))),Gn(d,o,r),d[St]=t,vn(d),o=d;break e;case"link":var b=k_("link","href",u).get(o+(r.href||""));if(b){for(var D=0;D<b.length;D++)if(d=b[D],d.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&d.getAttribute("rel")===(r.rel==null?null:r.rel)&&d.getAttribute("title")===(r.title==null?null:r.title)&&d.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){b.splice(D,1);break t}}d=u.createElement(o),Gn(d,o,r),u.head.appendChild(d);break;case"meta":if(b=k_("meta","content",u).get(o+(r.content||""))){for(D=0;D<b.length;D++)if(d=b[D],d.getAttribute("content")===(r.content==null?null:""+r.content)&&d.getAttribute("name")===(r.name==null?null:r.name)&&d.getAttribute("property")===(r.property==null?null:r.property)&&d.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&d.getAttribute("charset")===(r.charSet==null?null:r.charSet)){b.splice(D,1);break t}}d=u.createElement(o),Gn(d,o,r),u.head.appendChild(d);break;default:throw Error(s(468,o))}d[St]=t,vn(d),o=d}t.stateNode=o}else j_(u,t.type,t.stateNode);else t.stateNode=V_(u,o,t.memoizedProps);else d!==o?(d===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):d.count--,o===null?j_(u,t.type,t.stateNode):V_(u,o,t.memoizedProps)):o===null&&t.stateNode!==null&&ud(t,t.memoizedProps,r.memoizedProps)}break;case 27:ei(i,t),ti(t),o&512&&(An||r===null||ia(r,r.return)),r!==null&&o&4&&ud(t,t.memoizedProps,r.memoizedProps);break;case 5:if(ei(i,t),ti(t),o&512&&(An||r===null||ia(r,r.return)),t.flags&32){u=t.stateNode;try{ui(u,"")}catch(et){Jt(t,t.return,et)}}o&4&&t.stateNode!=null&&(u=t.memoizedProps,ud(t,u,r!==null?r.memoizedProps:u)),o&1024&&(hd=!0);break;case 6:if(ei(i,t),ti(t),o&4){if(t.stateNode===null)throw Error(s(162));o=t.memoizedProps,r=t.stateNode;try{r.nodeValue=o}catch(et){Jt(t,t.return,et)}}break;case 3:if(Pc=null,u=Gi,Gi=Lc(i.containerInfo),ei(i,t),Gi=u,ti(t),o&4&&r!==null&&r.memoizedState.isDehydrated)try{Xr(i.containerInfo)}catch(et){Jt(t,t.return,et)}hd&&(hd=!1,j0(t));break;case 4:o=Gi,Gi=Lc(t.stateNode.containerInfo),ei(i,t),ti(t),Gi=o;break;case 12:ei(i,t),ti(t);break;case 31:ei(i,t),ti(t),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,xc(t,o)));break;case 13:ei(i,t),ti(t),t.child.flags&8192&&t.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Sc=Ue()),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,xc(t,o)));break;case 22:u=t.memoizedState!==null;var X=r!==null&&r.memoizedState!==null,ue=Ca,be=An;if(Ca=ue||u,An=be||X,ei(i,t),An=be,Ca=ue,ti(t),o&8192)e:for(i=t.stateNode,i._visibility=u?i._visibility&-2:i._visibility|1,u&&(r===null||X||Ca||An||Ys(t)),r=null,i=t;;){if(i.tag===5||i.tag===26){if(r===null){X=r=i;try{if(d=X.stateNode,u)b=d.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{D=X.stateNode;var we=X.memoizedProps.style,de=we!=null&&we.hasOwnProperty("display")?we.display:null;D.style.display=de==null||typeof de=="boolean"?"":(""+de).trim()}}catch(et){Jt(X,X.return,et)}}}else if(i.tag===6){if(r===null){X=i;try{X.stateNode.nodeValue=u?"":X.memoizedProps}catch(et){Jt(X,X.return,et)}}}else if(i.tag===18){if(r===null){X=i;try{var me=X.stateNode;u?L_(me,!0):L_(X.stateNode,!1)}catch(et){Jt(X,X.return,et)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===t)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;i.sibling===null;){if(i.return===null||i.return===t)break e;r===i&&(r=null),i=i.return}r===i&&(r=null),i.sibling.return=i.return,i=i.sibling}o&4&&(o=t.updateQueue,o!==null&&(r=o.retryQueue,r!==null&&(o.retryQueue=null,xc(t,r))));break;case 19:ei(i,t),ti(t),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,xc(t,o)));break;case 30:break;case 21:break;default:ei(i,t),ti(t)}}function ti(t){var i=t.flags;if(i&2){try{for(var r,o=t.return;o!==null;){if(P0(o)){r=o;break}o=o.return}if(r==null)throw Error(s(160));switch(r.tag){case 27:var u=r.stateNode,d=fd(t);vc(t,d,u);break;case 5:var b=r.stateNode;r.flags&32&&(ui(b,""),r.flags&=-33);var D=fd(t);vc(t,D,b);break;case 3:case 4:var X=r.stateNode.containerInfo,ue=fd(t);dd(t,ue,X);break;default:throw Error(s(161))}}catch(be){Jt(t,t.return,be)}t.flags&=-3}i&4096&&(t.flags&=-4097)}function j0(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var i=t;j0(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),t=t.sibling}}function Ra(t,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)F0(t,i.alternate,i),i=i.sibling}function Ys(t){for(t=t.child;t!==null;){var i=t;switch(i.tag){case 0:case 11:case 14:case 15:ss(4,i,i.return),Ys(i);break;case 1:ia(i,i.return);var r=i.stateNode;typeof r.componentWillUnmount=="function"&&L0(i,i.return,r),Ys(i);break;case 27:rl(i.stateNode);case 26:case 5:ia(i,i.return),Ys(i);break;case 22:i.memoizedState===null&&Ys(i);break;case 30:Ys(i);break;default:Ys(i)}t=t.sibling}}function Da(t,i,r){for(r=r&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var o=i.alternate,u=t,d=i,b=d.flags;switch(d.tag){case 0:case 11:case 15:Da(u,d,r),Ko(4,d);break;case 1:if(Da(u,d,r),o=d,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(ue){Jt(o,o.return,ue)}if(o=d,u=o.updateQueue,u!==null){var D=o.stateNode;try{var X=u.shared.hiddenCallbacks;if(X!==null)for(u.shared.hiddenCallbacks=null,u=0;u<X.length;u++)Sg(X[u],D)}catch(ue){Jt(o,o.return,ue)}}r&&b&64&&U0(d),$o(d,d.return);break;case 27:I0(d);case 26:case 5:Da(u,d,r),r&&o===null&&b&4&&O0(d),$o(d,d.return);break;case 12:Da(u,d,r);break;case 31:Da(u,d,r),r&&b&4&&G0(u,d);break;case 13:Da(u,d,r),r&&b&4&&V0(u,d);break;case 22:d.memoizedState===null&&Da(u,d,r),$o(d,d.return);break;case 30:break;default:Da(u,d,r)}i=i.sibling}}function pd(t,i){var r=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),t=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(t=i.memoizedState.cachePool.pool),t!==r&&(t!=null&&t.refCount++,r!=null&&Bo(r))}function md(t,i){t=null,i.alternate!==null&&(t=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==t&&(i.refCount++,t!=null&&Bo(t))}function Vi(t,i,r,o){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)X0(t,i,r,o),i=i.sibling}function X0(t,i,r,o){var u=i.flags;switch(i.tag){case 0:case 11:case 15:Vi(t,i,r,o),u&2048&&Ko(9,i);break;case 1:Vi(t,i,r,o);break;case 3:Vi(t,i,r,o),u&2048&&(t=null,i.alternate!==null&&(t=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==t&&(i.refCount++,t!=null&&Bo(t)));break;case 12:if(u&2048){Vi(t,i,r,o),t=i.stateNode;try{var d=i.memoizedProps,b=d.id,D=d.onPostCommit;typeof D=="function"&&D(b,i.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(X){Jt(i,i.return,X)}}else Vi(t,i,r,o);break;case 31:Vi(t,i,r,o);break;case 13:Vi(t,i,r,o);break;case 23:break;case 22:d=i.stateNode,b=i.alternate,i.memoizedState!==null?d._visibility&2?Vi(t,i,r,o):Qo(t,i):d._visibility&2?Vi(t,i,r,o):(d._visibility|=2,Or(t,i,r,o,(i.subtreeFlags&10256)!==0||!1)),u&2048&&pd(b,i);break;case 24:Vi(t,i,r,o),u&2048&&md(i.alternate,i);break;default:Vi(t,i,r,o)}}function Or(t,i,r,o,u){for(u=u&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var d=t,b=i,D=r,X=o,ue=b.flags;switch(b.tag){case 0:case 11:case 15:Or(d,b,D,X,u),Ko(8,b);break;case 23:break;case 22:var be=b.stateNode;b.memoizedState!==null?be._visibility&2?Or(d,b,D,X,u):Qo(d,b):(be._visibility|=2,Or(d,b,D,X,u)),u&&ue&2048&&pd(b.alternate,b);break;case 24:Or(d,b,D,X,u),u&&ue&2048&&md(b.alternate,b);break;default:Or(d,b,D,X,u)}i=i.sibling}}function Qo(t,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var r=t,o=i,u=o.flags;switch(o.tag){case 22:Qo(r,o),u&2048&&pd(o.alternate,o);break;case 24:Qo(r,o),u&2048&&md(o.alternate,o);break;default:Qo(r,o)}i=i.sibling}}var Jo=8192;function Pr(t,i,r){if(t.subtreeFlags&Jo)for(t=t.child;t!==null;)W0(t,i,r),t=t.sibling}function W0(t,i,r){switch(t.tag){case 26:Pr(t,i,r),t.flags&Jo&&t.memoizedState!==null&&XM(r,Gi,t.memoizedState,t.memoizedProps);break;case 5:Pr(t,i,r);break;case 3:case 4:var o=Gi;Gi=Lc(t.stateNode.containerInfo),Pr(t,i,r),Gi=o;break;case 22:t.memoizedState===null&&(o=t.alternate,o!==null&&o.memoizedState!==null?(o=Jo,Jo=16777216,Pr(t,i,r),Jo=o):Pr(t,i,r));break;default:Pr(t,i,r)}}function q0(t){var i=t.alternate;if(i!==null&&(t=i.child,t!==null)){i.child=null;do i=t.sibling,t.sibling=null,t=i;while(t!==null)}}function el(t){var i=t.deletions;if((t.flags&16)!==0){if(i!==null)for(var r=0;r<i.length;r++){var o=i[r];On=o,Z0(o,t)}q0(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Y0(t),t=t.sibling}function Y0(t){switch(t.tag){case 0:case 11:case 15:el(t),t.flags&2048&&ss(9,t,t.return);break;case 3:el(t);break;case 12:el(t);break;case 22:var i=t.stateNode;t.memoizedState!==null&&i._visibility&2&&(t.return===null||t.return.tag!==13)?(i._visibility&=-3,yc(t)):el(t);break;default:el(t)}}function yc(t){var i=t.deletions;if((t.flags&16)!==0){if(i!==null)for(var r=0;r<i.length;r++){var o=i[r];On=o,Z0(o,t)}q0(t)}for(t=t.child;t!==null;){switch(i=t,i.tag){case 0:case 11:case 15:ss(8,i,i.return),yc(i);break;case 22:r=i.stateNode,r._visibility&2&&(r._visibility&=-3,yc(i));break;default:yc(i)}t=t.sibling}}function Z0(t,i){for(;On!==null;){var r=On;switch(r.tag){case 0:case 11:case 15:ss(8,r,i);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var o=r.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Bo(r.memoizedState.cache)}if(o=r.child,o!==null)o.return=r,On=o;else e:for(r=t;On!==null;){o=On;var u=o.sibling,d=o.return;if(z0(o),o===r){On=null;break e}if(u!==null){u.return=d,On=u;break e}On=d}}}var rM={getCacheForType:function(t){var i=zn(bn),r=i.data.get(t);return r===void 0&&(r=t(),i.data.set(t,r)),r},cacheSignal:function(){return zn(bn).controller.signal}},oM=typeof WeakMap=="function"?WeakMap:Map,Xt=0,ln=null,Ut=null,Bt=0,Qt=0,mi=null,rs=!1,Ir=!1,gd=!1,Na=0,yn=0,os=0,Zs=0,_d=0,gi=0,Br=0,tl=null,ni=null,vd=!1,Sc=0,K0=0,Mc=1/0,bc=null,ls=null,Rn=0,cs=null,Fr=null,Ua=0,xd=0,yd=null,$0=null,nl=0,Sd=null;function _i(){return(Xt&2)!==0&&Bt!==0?Bt&-Bt:G.T!==null?Cd():vt()}function Q0(){if(gi===0)if((Bt&536870912)===0||Ht){var t=tt;tt<<=1,(tt&3932160)===0&&(tt=262144),gi=t}else gi=536870912;return t=hi.current,t!==null&&(t.flags|=32),gi}function ii(t,i,r){(t===ln&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)&&(zr(t,0),us(t,Bt,gi,!1)),Ye(t,r),((Xt&2)===0||t!==ln)&&(t===ln&&((Xt&2)===0&&(Zs|=r),yn===4&&us(t,Bt,gi,!1)),aa(t))}function J0(t,i,r){if((Xt&6)!==0)throw Error(s(327));var o=!r&&(i&127)===0&&(i&t.expiredLanes)===0||Fe(t,i),u=o?uM(t,i):bd(t,i,!0),d=o;do{if(u===0){Ir&&!o&&us(t,i,0,!1);break}else{if(r=t.current.alternate,d&&!lM(r)){u=bd(t,i,!1),d=!1;continue}if(u===2){if(d=i,t.errorRecoveryDisabledLanes&d)var b=0;else b=t.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){i=b;e:{var D=t;u=tl;var X=D.current.memoizedState.isDehydrated;if(X&&(zr(D,b).flags|=256),b=bd(D,b,!1),b!==2){if(gd&&!X){D.errorRecoveryDisabledLanes|=d,Zs|=d,u=4;break e}d=ni,ni=u,d!==null&&(ni===null?ni=d:ni.push.apply(ni,d))}u=b}if(d=!1,u!==2)continue}}if(u===1){zr(t,0),us(t,i,0,!0);break}e:{switch(o=t,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:us(o,i,gi,!rs);break e;case 2:ni=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(u=Sc+300-Ue(),10<u)){if(us(o,i,gi,!rs),ye(o,0,!0)!==0)break e;Ua=i,o.timeoutHandle=D_(e_.bind(null,o,r,ni,bc,vd,i,gi,Zs,Br,rs,d,"Throttled",-0,0),u);break e}e_(o,r,ni,bc,vd,i,gi,Zs,Br,rs,d,null,-0,0)}}break}while(!0);aa(t)}function e_(t,i,r,o,u,d,b,D,X,ue,be,we,de,me){if(t.timeoutHandle=-1,we=i.subtreeFlags,we&8192||(we&16785408)===16785408){we={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:_a},W0(i,d,we);var et=(d&62914560)===d?Sc-Ue():(d&4194048)===d?K0-Ue():0;if(et=WM(we,et),et!==null){Ua=d,t.cancelPendingCommit=et(l_.bind(null,t,i,d,r,o,u,b,D,X,be,we,null,de,me)),us(t,d,b,!ue);return}}l_(t,i,d,r,o,u,b,D,X)}function lM(t){for(var i=t;;){var r=i.tag;if((r===0||r===11||r===15)&&i.flags&16384&&(r=i.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var o=0;o<r.length;o++){var u=r[o],d=u.getSnapshot;u=u.value;try{if(!fi(d(),u))return!1}catch{return!1}}if(r=i.child,i.subtreeFlags&16384&&r!==null)r.return=i,i=r;else{if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function us(t,i,r,o){i&=~_d,i&=~Zs,t.suspendedLanes|=i,t.pingedLanes&=~i,o&&(t.warmLanes|=i),o=t.expirationTimes;for(var u=i;0<u;){var d=31-Xe(u),b=1<<d;o[d]=-1,u&=~b}r!==0&&Rt(t,r,i)}function Ec(){return(Xt&6)===0?(il(0),!1):!0}function Md(){if(Ut!==null){if(Qt===0)var t=Ut.return;else t=Ut,Sa=Hs=null,Ff(t),Rr=null,zo=0,t=Ut;for(;t!==null;)N0(t.alternate,t),t=t.return;Ut=null}}function zr(t,i){var r=t.timeoutHandle;r!==-1&&(t.timeoutHandle=-1,wM(r)),r=t.cancelPendingCommit,r!==null&&(t.cancelPendingCommit=null,r()),Ua=0,Md(),ln=t,Ut=r=xa(t.current,null),Bt=i,Qt=0,mi=null,rs=!1,Ir=Fe(t,i),gd=!1,Br=gi=_d=Zs=os=yn=0,ni=tl=null,vd=!1,(i&8)!==0&&(i|=i&32);var o=t.entangledLanes;if(o!==0)for(t=t.entanglements,o&=i;0<o;){var u=31-Xe(o),d=1<<u;i|=t[u],o&=~d}return Na=i,Xl(),r}function t_(t,i){Tt=null,G.H=qo,i===wr||i===Jl?(i=_g(),Qt=3):i===Af?(i=_g(),Qt=4):Qt=i===ed?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,mi=i,Ut===null&&(yn=1,hc(t,bi(i,t.current)))}function n_(){var t=hi.current;return t===null?!0:(Bt&4194048)===Bt?Ci===null:(Bt&62914560)===Bt||(Bt&536870912)!==0?t===Ci:!1}function i_(){var t=G.H;return G.H=qo,t===null?qo:t}function a_(){var t=G.A;return G.A=rM,t}function Tc(){yn=4,rs||(Bt&4194048)!==Bt&&hi.current!==null||(Ir=!0),(os&134217727)===0&&(Zs&134217727)===0||ln===null||us(ln,Bt,gi,!1)}function bd(t,i,r){var o=Xt;Xt|=2;var u=i_(),d=a_();(ln!==t||Bt!==i)&&(bc=null,zr(t,i)),i=!1;var b=yn;e:do try{if(Qt!==0&&Ut!==null){var D=Ut,X=mi;switch(Qt){case 8:Md(),b=6;break e;case 3:case 2:case 9:case 6:hi.current===null&&(i=!0);var ue=Qt;if(Qt=0,mi=null,Hr(t,D,X,ue),r&&Ir){b=0;break e}break;default:ue=Qt,Qt=0,mi=null,Hr(t,D,X,ue)}}cM(),b=yn;break}catch(be){t_(t,be)}while(!0);return i&&t.shellSuspendCounter++,Sa=Hs=null,Xt=o,G.H=u,G.A=d,Ut===null&&(ln=null,Bt=0,Xl()),b}function cM(){for(;Ut!==null;)s_(Ut)}function uM(t,i){var r=Xt;Xt|=2;var o=i_(),u=a_();ln!==t||Bt!==i?(bc=null,Mc=Ue()+500,zr(t,i)):Ir=Fe(t,i);e:do try{if(Qt!==0&&Ut!==null){i=Ut;var d=mi;t:switch(Qt){case 1:Qt=0,mi=null,Hr(t,i,d,1);break;case 2:case 9:if(mg(d)){Qt=0,mi=null,r_(i);break}i=function(){Qt!==2&&Qt!==9||ln!==t||(Qt=7),aa(t)},d.then(i,i);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:mg(d)?(Qt=0,mi=null,r_(i)):(Qt=0,mi=null,Hr(t,i,d,7));break;case 5:var b=null;switch(Ut.tag){case 26:b=Ut.memoizedState;case 5:case 27:var D=Ut;if(b?X_(b):D.stateNode.complete){Qt=0,mi=null;var X=D.sibling;if(X!==null)Ut=X;else{var ue=D.return;ue!==null?(Ut=ue,Ac(ue)):Ut=null}break t}}Qt=0,mi=null,Hr(t,i,d,5);break;case 6:Qt=0,mi=null,Hr(t,i,d,6);break;case 8:Md(),yn=6;break e;default:throw Error(s(462))}}fM();break}catch(be){t_(t,be)}while(!0);return Sa=Hs=null,G.H=o,G.A=u,Xt=r,Ut!==null?0:(ln=null,Bt=0,Xl(),yn)}function fM(){for(;Ut!==null&&!K();)s_(Ut)}function s_(t){var i=R0(t.alternate,t,Na);t.memoizedProps=t.pendingProps,i===null?Ac(t):Ut=i}function r_(t){var i=t,r=i.alternate;switch(i.tag){case 15:case 0:i=b0(r,i,i.pendingProps,i.type,void 0,Bt);break;case 11:i=b0(r,i,i.pendingProps,i.type.render,i.ref,Bt);break;case 5:Ff(i);default:N0(r,i),i=Ut=ag(i,Na),i=R0(r,i,Na)}t.memoizedProps=t.pendingProps,i===null?Ac(t):Ut=i}function Hr(t,i,r,o){Sa=Hs=null,Ff(i),Rr=null,zo=0;var u=i.return;try{if(JS(t,u,i,r,Bt)){yn=1,hc(t,bi(r,t.current)),Ut=null;return}}catch(d){if(u!==null)throw Ut=u,d;yn=1,hc(t,bi(r,t.current)),Ut=null;return}i.flags&32768?(Ht||o===1?t=!0:Ir||(Bt&536870912)!==0?t=!1:(rs=t=!0,(o===2||o===9||o===3||o===6)&&(o=hi.current,o!==null&&o.tag===13&&(o.flags|=16384))),o_(i,t)):Ac(i)}function Ac(t){var i=t;do{if((i.flags&32768)!==0){o_(i,rs);return}t=i.return;var r=nM(i.alternate,i,Na);if(r!==null){Ut=r;return}if(i=i.sibling,i!==null){Ut=i;return}Ut=i=t}while(i!==null);yn===0&&(yn=5)}function o_(t,i){do{var r=iM(t.alternate,t);if(r!==null){r.flags&=32767,Ut=r;return}if(r=t.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!i&&(t=t.sibling,t!==null)){Ut=t;return}Ut=t=r}while(t!==null);yn=6,Ut=null}function l_(t,i,r,o,u,d,b,D,X){t.cancelPendingCommit=null;do Cc();while(Rn!==0);if((Xt&6)!==0)throw Error(s(327));if(i!==null){if(i===t.current)throw Error(s(177));if(d=i.lanes|i.childLanes,d|=ff,Yt(t,r,d,b,D,X),t===ln&&(Ut=ln=null,Bt=0),Fr=i,cs=t,Ua=r,xd=d,yd=u,$0=o,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,mM(ie,function(){return h_(),null})):(t.callbackNode=null,t.callbackPriority=0),o=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||o){o=G.T,G.T=null,u=j.p,j.p=2,b=Xt,Xt|=4;try{aM(t,i,r)}finally{Xt=b,j.p=u,G.T=o}}Rn=1,c_(),u_(),f_()}}function c_(){if(Rn===1){Rn=0;var t=cs,i=Fr,r=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||r){r=G.T,G.T=null;var o=j.p;j.p=2;var u=Xt;Xt|=4;try{k0(i,t);var d=Pd,b=Zm(t.containerInfo),D=d.focusedElem,X=d.selectionRange;if(b!==D&&D&&D.ownerDocument&&Ym(D.ownerDocument.documentElement,D)){if(X!==null&&rf(D)){var ue=X.start,be=X.end;if(be===void 0&&(be=ue),"selectionStart"in D)D.selectionStart=ue,D.selectionEnd=Math.min(be,D.value.length);else{var we=D.ownerDocument||document,de=we&&we.defaultView||window;if(de.getSelection){var me=de.getSelection(),et=D.textContent.length,pt=Math.min(X.start,et),an=X.end===void 0?pt:Math.min(X.end,et);!me.extend&&pt>an&&(b=an,an=pt,pt=b);var ae=qm(D,pt),$=qm(D,an);if(ae&&$&&(me.rangeCount!==1||me.anchorNode!==ae.node||me.anchorOffset!==ae.offset||me.focusNode!==$.node||me.focusOffset!==$.offset)){var ce=we.createRange();ce.setStart(ae.node,ae.offset),me.removeAllRanges(),pt>an?(me.addRange(ce),me.extend($.node,$.offset)):(ce.setEnd($.node,$.offset),me.addRange(ce))}}}}for(we=[],me=D;me=me.parentNode;)me.nodeType===1&&we.push({element:me,left:me.scrollLeft,top:me.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<we.length;D++){var Te=we[D];Te.element.scrollLeft=Te.left,Te.element.scrollTop=Te.top}}zc=!!Od,Pd=Od=null}finally{Xt=u,j.p=o,G.T=r}}t.current=i,Rn=2}}function u_(){if(Rn===2){Rn=0;var t=cs,i=Fr,r=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||r){r=G.T,G.T=null;var o=j.p;j.p=2;var u=Xt;Xt|=4;try{F0(t,i.alternate,i)}finally{Xt=u,j.p=o,G.T=r}}Rn=3}}function f_(){if(Rn===4||Rn===3){Rn=0,F();var t=cs,i=Fr,r=Ua,o=$0;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?Rn=5:(Rn=0,Fr=cs=null,d_(t,t.pendingLanes));var u=t.pendingLanes;if(u===0&&(ls=null),Ze(r),i=i.stateNode,ve&&typeof ve.onCommitFiberRoot=="function")try{ve.onCommitFiberRoot(_e,i,void 0,(i.current.flags&128)===128)}catch{}if(o!==null){i=G.T,u=j.p,j.p=2,G.T=null;try{for(var d=t.onRecoverableError,b=0;b<o.length;b++){var D=o[b];d(D.value,{componentStack:D.stack})}}finally{G.T=i,j.p=u}}(Ua&3)!==0&&Cc(),aa(t),u=t.pendingLanes,(r&261930)!==0&&(u&42)!==0?t===Sd?nl++:(nl=0,Sd=t):nl=0,il(0)}}function d_(t,i){(t.pooledCacheLanes&=i)===0&&(i=t.pooledCache,i!=null&&(t.pooledCache=null,Bo(i)))}function Cc(){return c_(),u_(),f_(),h_()}function h_(){if(Rn!==5)return!1;var t=cs,i=xd;xd=0;var r=Ze(Ua),o=G.T,u=j.p;try{j.p=32>r?32:r,G.T=null,r=yd,yd=null;var d=cs,b=Ua;if(Rn=0,Fr=cs=null,Ua=0,(Xt&6)!==0)throw Error(s(331));var D=Xt;if(Xt|=4,Y0(d.current),X0(d,d.current,b,r),Xt=D,il(0,!1),ve&&typeof ve.onPostCommitFiberRoot=="function")try{ve.onPostCommitFiberRoot(_e,d)}catch{}return!0}finally{j.p=u,G.T=o,d_(t,i)}}function p_(t,i,r){i=bi(r,i),i=Jf(t.stateNode,i,2),t=ns(t,i,2),t!==null&&(Ye(t,2),aa(t))}function Jt(t,i,r){if(t.tag===3)p_(t,t,r);else for(;i!==null;){if(i.tag===3){p_(i,t,r);break}else if(i.tag===1){var o=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(ls===null||!ls.has(o))){t=bi(r,t),r=m0(2),o=ns(i,r,2),o!==null&&(g0(r,o,i,t),Ye(o,2),aa(o));break}}i=i.return}}function Ed(t,i,r){var o=t.pingCache;if(o===null){o=t.pingCache=new oM;var u=new Set;o.set(i,u)}else u=o.get(i),u===void 0&&(u=new Set,o.set(i,u));u.has(r)||(gd=!0,u.add(r),t=dM.bind(null,t,i,r),i.then(t,t))}function dM(t,i,r){var o=t.pingCache;o!==null&&o.delete(i),t.pingedLanes|=t.suspendedLanes&r,t.warmLanes&=~r,ln===t&&(Bt&r)===r&&(yn===4||yn===3&&(Bt&62914560)===Bt&&300>Ue()-Sc?(Xt&2)===0&&zr(t,0):_d|=r,Br===Bt&&(Br=0)),aa(t)}function m_(t,i){i===0&&(i=Ce()),t=Bs(t,i),t!==null&&(Ye(t,i),aa(t))}function hM(t){var i=t.memoizedState,r=0;i!==null&&(r=i.retryLane),m_(t,r)}function pM(t,i){var r=0;switch(t.tag){case 31:case 13:var o=t.stateNode,u=t.memoizedState;u!==null&&(r=u.retryLane);break;case 19:o=t.stateNode;break;case 22:o=t.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(i),m_(t,r)}function mM(t,i){return rn(t,i)}var wc=null,Gr=null,Td=!1,Rc=!1,Ad=!1,fs=0;function aa(t){t!==Gr&&t.next===null&&(Gr===null?wc=Gr=t:Gr=Gr.next=t),Rc=!0,Td||(Td=!0,_M())}function il(t,i){if(!Ad&&Rc){Ad=!0;do for(var r=!1,o=wc;o!==null;){if(t!==0){var u=o.pendingLanes;if(u===0)var d=0;else{var b=o.suspendedLanes,D=o.pingedLanes;d=(1<<31-Xe(42|t)+1)-1,d&=u&~(b&~D),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(r=!0,x_(o,d))}else d=Bt,d=ye(o,o===ln?d:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(d&3)===0||Fe(o,d)||(r=!0,x_(o,d));o=o.next}while(r);Ad=!1}}function gM(){g_()}function g_(){Rc=Td=!1;var t=0;fs!==0&&CM()&&(t=fs);for(var i=Ue(),r=null,o=wc;o!==null;){var u=o.next,d=__(o,i);d===0?(o.next=null,r===null?wc=u:r.next=u,u===null&&(Gr=r)):(r=o,(t!==0||(d&3)!==0)&&(Rc=!0)),o=u}Rn!==0&&Rn!==5||il(t),fs!==0&&(fs=0)}function __(t,i){for(var r=t.suspendedLanes,o=t.pingedLanes,u=t.expirationTimes,d=t.pendingLanes&-62914561;0<d;){var b=31-Xe(d),D=1<<b,X=u[b];X===-1?((D&r)===0||(D&o)!==0)&&(u[b]=Ge(D,i)):X<=i&&(t.expiredLanes|=D),d&=~D}if(i=ln,r=Bt,r=ye(t,t===i?r:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),o=t.callbackNode,r===0||t===i&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)return o!==null&&o!==null&&ct(o),t.callbackNode=null,t.callbackPriority=0;if((r&3)===0||Fe(t,r)){if(i=r&-r,i===t.callbackPriority)return i;switch(o!==null&&ct(o),Ze(r)){case 2:case 8:r=C;break;case 32:r=ie;break;case 268435456:r=he;break;default:r=ie}return o=v_.bind(null,t),r=rn(r,o),t.callbackPriority=i,t.callbackNode=r,i}return o!==null&&o!==null&&ct(o),t.callbackPriority=2,t.callbackNode=null,2}function v_(t,i){if(Rn!==0&&Rn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var r=t.callbackNode;if(Cc()&&t.callbackNode!==r)return null;var o=Bt;return o=ye(t,t===ln?o:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),o===0?null:(J0(t,o,i),__(t,Ue()),t.callbackNode!=null&&t.callbackNode===r?v_.bind(null,t):null)}function x_(t,i){if(Cc())return null;J0(t,i,!0)}function _M(){RM(function(){(Xt&6)!==0?rn(B,gM):g_()})}function Cd(){if(fs===0){var t=Ar;t===0&&(t=Je,Je<<=1,(Je&261888)===0&&(Je=256)),fs=t}return fs}function y_(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Ls(""+t)}function S_(t,i){var r=i.ownerDocument.createElement("input");return r.name=i.name,r.value=i.value,t.id&&r.setAttribute("form",t.id),i.parentNode.insertBefore(r,i),t=new FormData(t),r.parentNode.removeChild(r),t}function vM(t,i,r,o,u){if(i==="submit"&&r&&r.stateNode===u){var d=y_((u[_n]||null).action),b=o.submitter;b&&(i=(i=b[_n]||null)?y_(i.formAction):b.getAttribute("formAction"),i!==null&&(d=i,b=null));var D=new Gl("action","action",null,o,u);t.push({event:D,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(fs!==0){var X=b?S_(u,b):new FormData(u);qf(r,{pending:!0,data:X,method:u.method,action:d},null,X)}}else typeof d=="function"&&(D.preventDefault(),X=b?S_(u,b):new FormData(u),qf(r,{pending:!0,data:X,method:u.method,action:d},d,X))},currentTarget:u}]})}}for(var wd=0;wd<uf.length;wd++){var Rd=uf[wd],xM=Rd.toLowerCase(),yM=Rd[0].toUpperCase()+Rd.slice(1);Hi(xM,"on"+yM)}Hi(Qm,"onAnimationEnd"),Hi(Jm,"onAnimationIteration"),Hi(eg,"onAnimationStart"),Hi("dblclick","onDoubleClick"),Hi("focusin","onFocus"),Hi("focusout","onBlur"),Hi(IS,"onTransitionRun"),Hi(BS,"onTransitionStart"),Hi(FS,"onTransitionCancel"),Hi(tg,"onTransitionEnd"),Y("onMouseEnter",["mouseout","mouseover"]),Y("onMouseLeave",["mouseout","mouseover"]),Y("onPointerEnter",["pointerout","pointerover"]),Y("onPointerLeave",["pointerout","pointerover"]),H("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),H("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),H("onBeforeInput",["compositionend","keypress","textInput","paste"]),H("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),H("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),H("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var al="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),SM=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(al));function M_(t,i){i=(i&4)!==0;for(var r=0;r<t.length;r++){var o=t[r],u=o.event;o=o.listeners;e:{var d=void 0;if(i)for(var b=o.length-1;0<=b;b--){var D=o[b],X=D.instance,ue=D.currentTarget;if(D=D.listener,X!==d&&u.isPropagationStopped())break e;d=D,u.currentTarget=ue;try{d(u)}catch(be){jl(be)}u.currentTarget=null,d=X}else for(b=0;b<o.length;b++){if(D=o[b],X=D.instance,ue=D.currentTarget,D=D.listener,X!==d&&u.isPropagationStopped())break e;d=D,u.currentTarget=ue;try{d(u)}catch(be){jl(be)}u.currentTarget=null,d=X}}}}function Lt(t,i){var r=i[pa];r===void 0&&(r=i[pa]=new Set);var o=t+"__bubble";r.has(o)||(b_(i,t,2,!1),r.add(o))}function Dd(t,i,r){var o=0;i&&(o|=4),b_(r,t,o,i)}var Dc="_reactListening"+Math.random().toString(36).slice(2);function Nd(t){if(!t[Dc]){t[Dc]=!0,ne.forEach(function(r){r!=="selectionchange"&&(SM.has(r)||Dd(r,!1,t),Dd(r,!0,t))});var i=t.nodeType===9?t:t.ownerDocument;i===null||i[Dc]||(i[Dc]=!0,Dd("selectionchange",!1,i))}}function b_(t,i,r,o){switch(Q_(i)){case 2:var u=ZM;break;case 8:u=KM;break;default:u=Wd}r=u.bind(null,i,r,t),u=void 0,!Ku||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(u=!0),o?u!==void 0?t.addEventListener(i,r,{capture:!0,passive:u}):t.addEventListener(i,r,!0):u!==void 0?t.addEventListener(i,r,{passive:u}):t.addEventListener(i,r,!1)}function Ud(t,i,r,o,u){var d=o;if((i&1)===0&&(i&2)===0&&o!==null)e:for(;;){if(o===null)return;var b=o.tag;if(b===3||b===4){var D=o.stateNode.containerInfo;if(D===u)break;if(b===4)for(b=o.return;b!==null;){var X=b.tag;if((X===3||X===4)&&b.stateNode.containerInfo===u)return;b=b.return}for(;D!==null;){if(b=li(D),b===null)return;if(X=b.tag,X===5||X===6||X===26||X===27){o=d=b;continue e}D=D.parentNode}}o=o.return}wm(function(){var ue=d,be=Yu(r),we=[];e:{var de=ng.get(t);if(de!==void 0){var me=Gl,et=t;switch(t){case"keypress":if(zl(r)===0)break e;case"keydown":case"keyup":me=pS;break;case"focusin":et="focus",me=ef;break;case"focusout":et="blur",me=ef;break;case"beforeblur":case"afterblur":me=ef;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":me=Nm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=nS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=_S;break;case Qm:case Jm:case eg:me=sS;break;case tg:me=xS;break;case"scroll":case"scrollend":me=eS;break;case"wheel":me=SS;break;case"copy":case"cut":case"paste":me=oS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=Lm;break;case"toggle":case"beforetoggle":me=bS}var pt=(i&4)!==0,an=!pt&&(t==="scroll"||t==="scrollend"),ae=pt?de!==null?de+"Capture":null:de;pt=[];for(var $=ue,ce;$!==null;){var Te=$;if(ce=Te.stateNode,Te=Te.tag,Te!==5&&Te!==26&&Te!==27||ce===null||ae===null||(Te=Ao($,ae),Te!=null&&pt.push(sl($,Te,ce))),an)break;$=$.return}0<pt.length&&(de=new me(de,et,null,r,be),we.push({event:de,listeners:pt}))}}if((i&7)===0){e:{if(de=t==="mouseover"||t==="pointerover",me=t==="mouseout"||t==="pointerout",de&&r!==qu&&(et=r.relatedTarget||r.fromElement)&&(li(et)||et[kn]))break e;if((me||de)&&(de=be.window===be?be:(de=be.ownerDocument)?de.defaultView||de.parentWindow:window,me?(et=r.relatedTarget||r.toElement,me=ue,et=et?li(et):null,et!==null&&(an=c(et),pt=et.tag,et!==an||pt!==5&&pt!==27&&pt!==6)&&(et=null)):(me=null,et=ue),me!==et)){if(pt=Nm,Te="onMouseLeave",ae="onMouseEnter",$="mouse",(t==="pointerout"||t==="pointerover")&&(pt=Lm,Te="onPointerLeave",ae="onPointerEnter",$="pointer"),an=me==null?de:ga(me),ce=et==null?de:ga(et),de=new pt(Te,$+"leave",me,r,be),de.target=an,de.relatedTarget=ce,Te=null,li(be)===ue&&(pt=new pt(ae,$+"enter",et,r,be),pt.target=ce,pt.relatedTarget=an,Te=pt),an=Te,me&&et)t:{for(pt=MM,ae=me,$=et,ce=0,Te=ae;Te;Te=pt(Te))ce++;Te=0;for(var lt=$;lt;lt=pt(lt))Te++;for(;0<ce-Te;)ae=pt(ae),ce--;for(;0<Te-ce;)$=pt($),Te--;for(;ce--;){if(ae===$||$!==null&&ae===$.alternate){pt=ae;break t}ae=pt(ae),$=pt($)}pt=null}else pt=null;me!==null&&E_(we,de,me,pt,!1),et!==null&&an!==null&&E_(we,an,et,pt,!0)}}e:{if(de=ue?ga(ue):window,me=de.nodeName&&de.nodeName.toLowerCase(),me==="select"||me==="input"&&de.type==="file")var kt=Gm;else if(zm(de))if(Vm)kt=LS;else{kt=NS;var at=DS}else me=de.nodeName,!me||me.toLowerCase()!=="input"||de.type!=="checkbox"&&de.type!=="radio"?ue&&Wt(ue.elementType)&&(kt=Gm):kt=US;if(kt&&(kt=kt(t,ue))){Hm(we,kt,r,be);break e}at&&at(t,de,ue),t==="focusout"&&ue&&de.type==="number"&&ue.memoizedProps.value!=null&&Nt(de,"number",de.value)}switch(at=ue?ga(ue):window,t){case"focusin":(zm(at)||at.contentEditable==="true")&&(vr=at,of=ue,Oo=null);break;case"focusout":Oo=of=vr=null;break;case"mousedown":lf=!0;break;case"contextmenu":case"mouseup":case"dragend":lf=!1,Km(we,r,be);break;case"selectionchange":if(PS)break;case"keydown":case"keyup":Km(we,r,be)}var At;if(nf)e:{switch(t){case"compositionstart":var Ft="onCompositionStart";break e;case"compositionend":Ft="onCompositionEnd";break e;case"compositionupdate":Ft="onCompositionUpdate";break e}Ft=void 0}else _r?Bm(t,r)&&(Ft="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(Ft="onCompositionStart");Ft&&(Om&&r.locale!=="ko"&&(_r||Ft!=="onCompositionStart"?Ft==="onCompositionEnd"&&_r&&(At=Rm()):(Za=be,$u="value"in Za?Za.value:Za.textContent,_r=!0)),at=Nc(ue,Ft),0<at.length&&(Ft=new Um(Ft,t,null,r,be),we.push({event:Ft,listeners:at}),At?Ft.data=At:(At=Fm(r),At!==null&&(Ft.data=At)))),(At=TS?AS(t,r):CS(t,r))&&(Ft=Nc(ue,"onBeforeInput"),0<Ft.length&&(at=new Um("onBeforeInput","beforeinput",null,r,be),we.push({event:at,listeners:Ft}),at.data=At)),vM(we,t,ue,r,be)}M_(we,i)})}function sl(t,i,r){return{instance:t,listener:i,currentTarget:r}}function Nc(t,i){for(var r=i+"Capture",o=[];t!==null;){var u=t,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=Ao(t,r),u!=null&&o.unshift(sl(t,u,d)),u=Ao(t,i),u!=null&&o.push(sl(t,u,d))),t.tag===3)return o;t=t.return}return[]}function MM(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function E_(t,i,r,o,u){for(var d=i._reactName,b=[];r!==null&&r!==o;){var D=r,X=D.alternate,ue=D.stateNode;if(D=D.tag,X!==null&&X===o)break;D!==5&&D!==26&&D!==27||ue===null||(X=ue,u?(ue=Ao(r,d),ue!=null&&b.unshift(sl(r,ue,X))):u||(ue=Ao(r,d),ue!=null&&b.push(sl(r,ue,X)))),r=r.return}b.length!==0&&t.push({event:i,listeners:b})}var bM=/\r\n?/g,EM=/\u0000|\uFFFD/g;function T_(t){return(typeof t=="string"?t:""+t).replace(bM,`
`).replace(EM,"")}function A_(t,i){return i=T_(i),T_(t)===i}function nn(t,i,r,o,u,d){switch(r){case"children":typeof o=="string"?i==="body"||i==="textarea"&&o===""||ui(t,o):(typeof o=="number"||typeof o=="bigint")&&i!=="body"&&ui(t,""+o);break;case"className":We(t,"class",o);break;case"tabIndex":We(t,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":We(t,r,o);break;case"style":zi(t,o,d);break;case"data":if(i!=="object"){We(t,"data",o);break}case"src":case"href":if(o===""&&(i!=="a"||r!=="href")){t.removeAttribute(r);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){t.removeAttribute(r);break}o=Ls(""+o),t.setAttribute(r,o);break;case"action":case"formAction":if(typeof o=="function"){t.setAttribute(r,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(r==="formAction"?(i!=="input"&&nn(t,i,"name",u.name,u,null),nn(t,i,"formEncType",u.formEncType,u,null),nn(t,i,"formMethod",u.formMethod,u,null),nn(t,i,"formTarget",u.formTarget,u,null)):(nn(t,i,"encType",u.encType,u,null),nn(t,i,"method",u.method,u,null),nn(t,i,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){t.removeAttribute(r);break}o=Ls(""+o),t.setAttribute(r,o);break;case"onClick":o!=null&&(t.onclick=_a);break;case"onScroll":o!=null&&Lt("scroll",t);break;case"onScrollEnd":o!=null&&Lt("scrollend",t);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(r=o.__html,r!=null){if(u.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"multiple":t.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":t.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){t.removeAttribute("xlink:href");break}r=Ls(""+o),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?t.setAttribute(r,""+o):t.removeAttribute(r);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?t.setAttribute(r,""):t.removeAttribute(r);break;case"capture":case"download":o===!0?t.setAttribute(r,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?t.setAttribute(r,o):t.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?t.setAttribute(r,o):t.removeAttribute(r);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?t.removeAttribute(r):t.setAttribute(r,o);break;case"popover":Lt("beforetoggle",t),Lt("toggle",t),Pe(t,"popover",o);break;case"xlinkActuate":ke(t,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ke(t,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ke(t,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ke(t,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ke(t,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ke(t,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ke(t,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ke(t,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ke(t,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Pe(t,"is",o);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=ea.get(r)||r,Pe(t,r,o))}}function Ld(t,i,r,o,u,d){switch(r){case"style":zi(t,o,d);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(r=o.__html,r!=null){if(u.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"children":typeof o=="string"?ui(t,o):(typeof o=="number"||typeof o=="bigint")&&ui(t,""+o);break;case"onScroll":o!=null&&Lt("scroll",t);break;case"onScrollEnd":o!=null&&Lt("scrollend",t);break;case"onClick":o!=null&&(t.onclick=_a);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!T.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(u=r.endsWith("Capture"),i=r.slice(2,u?r.length-7:void 0),d=t[_n]||null,d=d!=null?d[r]:null,typeof d=="function"&&t.removeEventListener(i,d,u),typeof o=="function")){typeof d!="function"&&d!==null&&(r in t?t[r]=null:t.hasAttribute(r)&&t.removeAttribute(r)),t.addEventListener(i,o,u);break e}r in t?t[r]=o:o===!0?t.setAttribute(r,""):Pe(t,r,o)}}}function Gn(t,i,r){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Lt("error",t),Lt("load",t);var o=!1,u=!1,d;for(d in r)if(r.hasOwnProperty(d)){var b=r[d];if(b!=null)switch(d){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:nn(t,i,d,b,r,null)}}u&&nn(t,i,"srcSet",r.srcSet,r,null),o&&nn(t,i,"src",r.src,r,null);return;case"input":Lt("invalid",t);var D=d=b=u=null,X=null,ue=null;for(o in r)if(r.hasOwnProperty(o)){var be=r[o];if(be!=null)switch(o){case"name":u=be;break;case"type":b=be;break;case"checked":X=be;break;case"defaultChecked":ue=be;break;case"value":d=be;break;case"defaultValue":D=be;break;case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(s(137,i));break;default:nn(t,i,o,be,r,null)}}jn(t,d,D,X,ue,b,u,!1);return;case"select":Lt("invalid",t),o=b=d=null;for(u in r)if(r.hasOwnProperty(u)&&(D=r[u],D!=null))switch(u){case"value":d=D;break;case"defaultValue":b=D;break;case"multiple":o=D;default:nn(t,i,u,D,r,null)}i=d,r=b,t.multiple=!!o,i!=null?wn(t,!!o,i,!1):r!=null&&wn(t,!!o,r,!0);return;case"textarea":Lt("invalid",t),d=u=o=null;for(b in r)if(r.hasOwnProperty(b)&&(D=r[b],D!=null))switch(b){case"value":o=D;break;case"defaultValue":u=D;break;case"children":d=D;break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(s(91));break;default:nn(t,i,b,D,r,null)}Fi(t,o,u,d);return;case"option":for(X in r)r.hasOwnProperty(X)&&(o=r[X],o!=null)&&(X==="selected"?t.selected=o&&typeof o!="function"&&typeof o!="symbol":nn(t,i,X,o,r,null));return;case"dialog":Lt("beforetoggle",t),Lt("toggle",t),Lt("cancel",t),Lt("close",t);break;case"iframe":case"object":Lt("load",t);break;case"video":case"audio":for(o=0;o<al.length;o++)Lt(al[o],t);break;case"image":Lt("error",t),Lt("load",t);break;case"details":Lt("toggle",t);break;case"embed":case"source":case"link":Lt("error",t),Lt("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ue in r)if(r.hasOwnProperty(ue)&&(o=r[ue],o!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:nn(t,i,ue,o,r,null)}return;default:if(Wt(i)){for(be in r)r.hasOwnProperty(be)&&(o=r[be],o!==void 0&&Ld(t,i,be,o,r,void 0));return}}for(D in r)r.hasOwnProperty(D)&&(o=r[D],o!=null&&nn(t,i,D,o,r,null))}function TM(t,i,r,o){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,b=null,D=null,X=null,ue=null,be=null;for(me in r){var we=r[me];if(r.hasOwnProperty(me)&&we!=null)switch(me){case"checked":break;case"value":break;case"defaultValue":X=we;default:o.hasOwnProperty(me)||nn(t,i,me,null,o,we)}}for(var de in o){var me=o[de];if(we=r[de],o.hasOwnProperty(de)&&(me!=null||we!=null))switch(de){case"type":d=me;break;case"name":u=me;break;case"checked":ue=me;break;case"defaultChecked":be=me;break;case"value":b=me;break;case"defaultValue":D=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(s(137,i));break;default:me!==we&&nn(t,i,de,me,o,we)}}Ke(t,b,D,X,ue,be,d,u);return;case"select":me=b=D=de=null;for(d in r)if(X=r[d],r.hasOwnProperty(d)&&X!=null)switch(d){case"value":break;case"multiple":me=X;default:o.hasOwnProperty(d)||nn(t,i,d,null,o,X)}for(u in o)if(d=o[u],X=r[u],o.hasOwnProperty(u)&&(d!=null||X!=null))switch(u){case"value":de=d;break;case"defaultValue":D=d;break;case"multiple":b=d;default:d!==X&&nn(t,i,u,d,o,X)}i=D,r=b,o=me,de!=null?wn(t,!!r,de,!1):!!o!=!!r&&(i!=null?wn(t,!!r,i,!0):wn(t,!!r,r?[]:"",!1));return;case"textarea":me=de=null;for(D in r)if(u=r[D],r.hasOwnProperty(D)&&u!=null&&!o.hasOwnProperty(D))switch(D){case"value":break;case"children":break;default:nn(t,i,D,null,o,u)}for(b in o)if(u=o[b],d=r[b],o.hasOwnProperty(b)&&(u!=null||d!=null))switch(b){case"value":de=u;break;case"defaultValue":me=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&nn(t,i,b,u,o,d)}ci(t,de,me);return;case"option":for(var et in r)de=r[et],r.hasOwnProperty(et)&&de!=null&&!o.hasOwnProperty(et)&&(et==="selected"?t.selected=!1:nn(t,i,et,null,o,de));for(X in o)de=o[X],me=r[X],o.hasOwnProperty(X)&&de!==me&&(de!=null||me!=null)&&(X==="selected"?t.selected=de&&typeof de!="function"&&typeof de!="symbol":nn(t,i,X,de,o,me));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var pt in r)de=r[pt],r.hasOwnProperty(pt)&&de!=null&&!o.hasOwnProperty(pt)&&nn(t,i,pt,null,o,de);for(ue in o)if(de=o[ue],me=r[ue],o.hasOwnProperty(ue)&&de!==me&&(de!=null||me!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(s(137,i));break;default:nn(t,i,ue,de,o,me)}return;default:if(Wt(i)){for(var an in r)de=r[an],r.hasOwnProperty(an)&&de!==void 0&&!o.hasOwnProperty(an)&&Ld(t,i,an,void 0,o,de);for(be in o)de=o[be],me=r[be],!o.hasOwnProperty(be)||de===me||de===void 0&&me===void 0||Ld(t,i,be,de,o,me);return}}for(var ae in r)de=r[ae],r.hasOwnProperty(ae)&&de!=null&&!o.hasOwnProperty(ae)&&nn(t,i,ae,null,o,de);for(we in o)de=o[we],me=r[we],!o.hasOwnProperty(we)||de===me||de==null&&me==null||nn(t,i,we,de,o,me)}function C_(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function AM(){if(typeof performance.getEntriesByType=="function"){for(var t=0,i=0,r=performance.getEntriesByType("resource"),o=0;o<r.length;o++){var u=r[o],d=u.transferSize,b=u.initiatorType,D=u.duration;if(d&&D&&C_(b)){for(b=0,D=u.responseEnd,o+=1;o<r.length;o++){var X=r[o],ue=X.startTime;if(ue>D)break;var be=X.transferSize,we=X.initiatorType;be&&C_(we)&&(X=X.responseEnd,b+=be*(X<D?1:(D-ue)/(X-ue)))}if(--o,i+=8*(d+b)/(u.duration/1e3),t++,10<t)break}}if(0<t)return i/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Od=null,Pd=null;function Uc(t){return t.nodeType===9?t:t.ownerDocument}function w_(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function R_(t,i){if(t===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&i==="foreignObject"?0:t}function Id(t,i){return t==="textarea"||t==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Bd=null;function CM(){var t=window.event;return t&&t.type==="popstate"?t===Bd?!1:(Bd=t,!0):(Bd=null,!1)}var D_=typeof setTimeout=="function"?setTimeout:void 0,wM=typeof clearTimeout=="function"?clearTimeout:void 0,N_=typeof Promise=="function"?Promise:void 0,RM=typeof queueMicrotask=="function"?queueMicrotask:typeof N_<"u"?function(t){return N_.resolve(null).then(t).catch(DM)}:D_;function DM(t){setTimeout(function(){throw t})}function ds(t){return t==="head"}function U_(t,i){var r=i,o=0;do{var u=r.nextSibling;if(t.removeChild(r),u&&u.nodeType===8)if(r=u.data,r==="/$"||r==="/&"){if(o===0){t.removeChild(u),Xr(i);return}o--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")o++;else if(r==="html")rl(t.ownerDocument.documentElement);else if(r==="head"){r=t.ownerDocument.head,rl(r);for(var d=r.firstChild;d;){var b=d.nextSibling,D=d.nodeName;d[Qi]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&d.rel.toLowerCase()==="stylesheet"||r.removeChild(d),d=b}}else r==="body"&&rl(t.ownerDocument.body);r=u}while(r);Xr(i)}function L_(t,i){var r=t;t=0;do{var o=r.nextSibling;if(r.nodeType===1?i?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(i?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),o&&o.nodeType===8)if(r=o.data,r==="/$"){if(t===0)break;t--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||t++;r=o}while(r)}function Fd(t){var i=t.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var r=i;switch(i=i.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":Fd(r),Ji(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}t.removeChild(r)}}function NM(t,i,r,o){for(;t.nodeType===1;){var u=r;if(t.nodeName.toLowerCase()!==i.toLowerCase()){if(!o&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(o){if(!t[Qi])switch(i){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(d=t.getAttribute("rel"),d==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(d!==u.rel||t.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||t.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||t.getAttribute("title")!==(u.title==null?null:u.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(d=t.getAttribute("src"),(d!==(u.src==null?null:u.src)||t.getAttribute("type")!==(u.type==null?null:u.type)||t.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(i==="input"&&t.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&t.getAttribute("name")===d)return t}else return t;if(t=wi(t.nextSibling),t===null)break}return null}function UM(t,i,r){if(i==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=wi(t.nextSibling),t===null))return null;return t}function O_(t,i){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!i||(t=wi(t.nextSibling),t===null))return null;return t}function zd(t){return t.data==="$?"||t.data==="$~"}function Hd(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function LM(t,i){var r=t.ownerDocument;if(t.data==="$~")t._reactRetry=i;else if(t.data!=="$?"||r.readyState!=="loading")i();else{var o=function(){i(),r.removeEventListener("DOMContentLoaded",o)};r.addEventListener("DOMContentLoaded",o),t._reactRetry=o}}function wi(t){for(;t!=null;t=t.nextSibling){var i=t.nodeType;if(i===1||i===3)break;if(i===8){if(i=t.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return t}var Gd=null;function P_(t){t=t.nextSibling;for(var i=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"||r==="/&"){if(i===0)return wi(t.nextSibling);i--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||i++}t=t.nextSibling}return null}function I_(t){t=t.previousSibling;for(var i=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(i===0)return t;i--}else r!=="/$"&&r!=="/&"||i++}t=t.previousSibling}return null}function B_(t,i,r){switch(i=Uc(r),t){case"html":if(t=i.documentElement,!t)throw Error(s(452));return t;case"head":if(t=i.head,!t)throw Error(s(453));return t;case"body":if(t=i.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function rl(t){for(var i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Ji(t)}var Ri=new Map,F_=new Set;function Lc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var La=j.d;j.d={f:OM,r:PM,D:IM,C:BM,L:FM,m:zM,X:GM,S:HM,M:VM};function OM(){var t=La.f(),i=Ec();return t||i}function PM(t){var i=Ii(t);i!==null&&i.tag===5&&i.type==="form"?t0(i):La.r(t)}var Vr=typeof document>"u"?null:document;function z_(t,i,r){var o=Vr;if(o&&typeof i=="string"&&i){var u=Kt(i);u='link[rel="'+t+'"][href="'+u+'"]',typeof r=="string"&&(u+='[crossorigin="'+r+'"]'),F_.has(u)||(F_.add(u),t={rel:t,crossOrigin:r,href:i},o.querySelector(u)===null&&(i=o.createElement("link"),Gn(i,"link",t),vn(i),o.head.appendChild(i)))}}function IM(t){La.D(t),z_("dns-prefetch",t,null)}function BM(t,i){La.C(t,i),z_("preconnect",t,i)}function FM(t,i,r){La.L(t,i,r);var o=Vr;if(o&&t&&i){var u='link[rel="preload"][as="'+Kt(i)+'"]';i==="image"&&r&&r.imageSrcSet?(u+='[imagesrcset="'+Kt(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(u+='[imagesizes="'+Kt(r.imageSizes)+'"]')):u+='[href="'+Kt(t)+'"]';var d=u;switch(i){case"style":d=kr(t);break;case"script":d=jr(t)}Ri.has(d)||(t=S({rel:"preload",href:i==="image"&&r&&r.imageSrcSet?void 0:t,as:i},r),Ri.set(d,t),o.querySelector(u)!==null||i==="style"&&o.querySelector(ol(d))||i==="script"&&o.querySelector(ll(d))||(i=o.createElement("link"),Gn(i,"link",t),vn(i),o.head.appendChild(i)))}}function zM(t,i){La.m(t,i);var r=Vr;if(r&&t){var o=i&&typeof i.as=="string"?i.as:"script",u='link[rel="modulepreload"][as="'+Kt(o)+'"][href="'+Kt(t)+'"]',d=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=jr(t)}if(!Ri.has(d)&&(t=S({rel:"modulepreload",href:t},i),Ri.set(d,t),r.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(ll(d)))return}o=r.createElement("link"),Gn(o,"link",t),vn(o),r.head.appendChild(o)}}}function HM(t,i,r){La.S(t,i,r);var o=Vr;if(o&&t){var u=Bi(o).hoistableStyles,d=kr(t);i=i||"default";var b=u.get(d);if(!b){var D={loading:0,preload:null};if(b=o.querySelector(ol(d)))D.loading=5;else{t=S({rel:"stylesheet",href:t,"data-precedence":i},r),(r=Ri.get(d))&&Vd(t,r);var X=b=o.createElement("link");vn(X),Gn(X,"link",t),X._p=new Promise(function(ue,be){X.onload=ue,X.onerror=be}),X.addEventListener("load",function(){D.loading|=1}),X.addEventListener("error",function(){D.loading|=2}),D.loading|=4,Oc(b,i,o)}b={type:"stylesheet",instance:b,count:1,state:D},u.set(d,b)}}}function GM(t,i){La.X(t,i);var r=Vr;if(r&&t){var o=Bi(r).hoistableScripts,u=jr(t),d=o.get(u);d||(d=r.querySelector(ll(u)),d||(t=S({src:t,async:!0},i),(i=Ri.get(u))&&kd(t,i),d=r.createElement("script"),vn(d),Gn(d,"link",t),r.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function VM(t,i){La.M(t,i);var r=Vr;if(r&&t){var o=Bi(r).hoistableScripts,u=jr(t),d=o.get(u);d||(d=r.querySelector(ll(u)),d||(t=S({src:t,async:!0,type:"module"},i),(i=Ri.get(u))&&kd(t,i),d=r.createElement("script"),vn(d),Gn(d,"link",t),r.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function H_(t,i,r,o){var u=(u=le.current)?Lc(u):null;if(!u)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(i=kr(r.href),r=Bi(u).hoistableStyles,o=r.get(i),o||(o={type:"style",instance:null,count:0,state:null},r.set(i,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){t=kr(r.href);var d=Bi(u).hoistableStyles,b=d.get(t);if(b||(u=u.ownerDocument||u,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(t,b),(d=u.querySelector(ol(t)))&&!d._p&&(b.instance=d,b.state.loading=5),Ri.has(t)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},Ri.set(t,r),d||kM(u,t,r,b.state))),i&&o===null)throw Error(s(528,""));return b}if(i&&o!==null)throw Error(s(529,""));return null;case"script":return i=r.async,r=r.src,typeof r=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=jr(r),r=Bi(u).hoistableScripts,o=r.get(i),o||(o={type:"script",instance:null,count:0,state:null},r.set(i,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function kr(t){return'href="'+Kt(t)+'"'}function ol(t){return'link[rel="stylesheet"]['+t+"]"}function G_(t){return S({},t,{"data-precedence":t.precedence,precedence:null})}function kM(t,i,r,o){t.querySelector('link[rel="preload"][as="style"]['+i+"]")?o.loading=1:(i=t.createElement("link"),o.preload=i,i.addEventListener("load",function(){return o.loading|=1}),i.addEventListener("error",function(){return o.loading|=2}),Gn(i,"link",r),vn(i),t.head.appendChild(i))}function jr(t){return'[src="'+Kt(t)+'"]'}function ll(t){return"script[async]"+t}function V_(t,i,r){if(i.count++,i.instance===null)switch(i.type){case"style":var o=t.querySelector('style[data-href~="'+Kt(r.href)+'"]');if(o)return i.instance=o,vn(o),o;var u=S({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return o=(t.ownerDocument||t).createElement("style"),vn(o),Gn(o,"style",u),Oc(o,r.precedence,t),i.instance=o;case"stylesheet":u=kr(r.href);var d=t.querySelector(ol(u));if(d)return i.state.loading|=4,i.instance=d,vn(d),d;o=G_(r),(u=Ri.get(u))&&Vd(o,u),d=(t.ownerDocument||t).createElement("link"),vn(d);var b=d;return b._p=new Promise(function(D,X){b.onload=D,b.onerror=X}),Gn(d,"link",o),i.state.loading|=4,Oc(d,r.precedence,t),i.instance=d;case"script":return d=jr(r.src),(u=t.querySelector(ll(d)))?(i.instance=u,vn(u),u):(o=r,(u=Ri.get(d))&&(o=S({},r),kd(o,u)),t=t.ownerDocument||t,u=t.createElement("script"),vn(u),Gn(u,"link",o),t.head.appendChild(u),i.instance=u);case"void":return null;default:throw Error(s(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(o=i.instance,i.state.loading|=4,Oc(o,r.precedence,t));return i.instance}function Oc(t,i,r){for(var o=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,d=u,b=0;b<o.length;b++){var D=o[b];if(D.dataset.precedence===i)d=D;else if(d!==u)break}d?d.parentNode.insertBefore(t,d.nextSibling):(i=r.nodeType===9?r.head:r,i.insertBefore(t,i.firstChild))}function Vd(t,i){t.crossOrigin==null&&(t.crossOrigin=i.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=i.referrerPolicy),t.title==null&&(t.title=i.title)}function kd(t,i){t.crossOrigin==null&&(t.crossOrigin=i.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=i.referrerPolicy),t.integrity==null&&(t.integrity=i.integrity)}var Pc=null;function k_(t,i,r){if(Pc===null){var o=new Map,u=Pc=new Map;u.set(r,o)}else u=Pc,o=u.get(r),o||(o=new Map,u.set(r,o));if(o.has(t))return o;for(o.set(t,null),r=r.getElementsByTagName(t),u=0;u<r.length;u++){var d=r[u];if(!(d[Qi]||d[St]||t==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var b=d.getAttribute(i)||"";b=t+b;var D=o.get(b);D?D.push(d):o.set(b,[d])}}return o}function j_(t,i,r){t=t.ownerDocument||t,t.head.insertBefore(r,i==="title"?t.querySelector("head > title"):null)}function jM(t,i,r){if(r===1||i.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(t=i.disabled,typeof i.precedence=="string"&&t==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function X_(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function XM(t,i,r,o){if(r.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var u=kr(o.href),d=i.querySelector(ol(u));if(d){i=d._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(t.count++,t=Ic.bind(t),i.then(t,t)),r.state.loading|=4,r.instance=d,vn(d);return}d=i.ownerDocument||i,o=G_(o),(u=Ri.get(u))&&Vd(o,u),d=d.createElement("link"),vn(d);var b=d;b._p=new Promise(function(D,X){b.onload=D,b.onerror=X}),Gn(d,"link",o),r.instance=d}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(r,i),(i=r.state.preload)&&(r.state.loading&3)===0&&(t.count++,r=Ic.bind(t),i.addEventListener("load",r),i.addEventListener("error",r))}}var jd=0;function WM(t,i){return t.stylesheets&&t.count===0&&Fc(t,t.stylesheets),0<t.count||0<t.imgCount?function(r){var o=setTimeout(function(){if(t.stylesheets&&Fc(t,t.stylesheets),t.unsuspend){var d=t.unsuspend;t.unsuspend=null,d()}},6e4+i);0<t.imgBytes&&jd===0&&(jd=62500*AM());var u=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Fc(t,t.stylesheets),t.unsuspend)){var d=t.unsuspend;t.unsuspend=null,d()}},(t.imgBytes>jd?50:800)+i);return t.unsuspend=r,function(){t.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Ic(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Bc=null;function Fc(t,i){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Bc=new Map,i.forEach(qM,t),Bc=null,Ic.call(t))}function qM(t,i){if(!(i.state.loading&4)){var r=Bc.get(t);if(r)var o=r.get(null);else{r=new Map,Bc.set(t,r);for(var u=t.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var b=u[d];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(r.set(b.dataset.precedence,b),o=b)}o&&r.set(null,o)}u=i.instance,b=u.getAttribute("data-precedence"),d=r.get(b)||o,d===o&&r.set(null,u),r.set(b,u),this.count++,o=Ic.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),d?d.parentNode.insertBefore(u,d.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(u,t.firstChild)),i.state.loading|=4}}var cl={$$typeof:L,Provider:null,Consumer:null,_currentValue:se,_currentValue2:se,_threadCount:0};function YM(t,i,r,o,u,d,b,D,X){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Qe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qe(0),this.hiddenUpdates=Qe(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=X,this.incompleteTransitions=new Map}function W_(t,i,r,o,u,d,b,D,X,ue,be,we){return t=new YM(t,i,r,b,X,ue,be,we,D),i=1,d===!0&&(i|=24),d=di(3,null,null,i),t.current=d,d.stateNode=t,i=bf(),i.refCount++,t.pooledCache=i,i.refCount++,d.memoizedState={element:o,isDehydrated:r,cache:i},Cf(d),t}function q_(t){return t?(t=Sr,t):Sr}function Y_(t,i,r,o,u,d){u=q_(u),o.context===null?o.context=u:o.pendingContext=u,o=ts(i),o.payload={element:r},d=d===void 0?null:d,d!==null&&(o.callback=d),r=ns(t,o,i),r!==null&&(ii(r,t,i),Go(r,t,i))}function Z_(t,i){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<i?r:i}}function Xd(t,i){Z_(t,i),(t=t.alternate)&&Z_(t,i)}function K_(t){if(t.tag===13||t.tag===31){var i=Bs(t,67108864);i!==null&&ii(i,t,67108864),Xd(t,67108864)}}function $_(t){if(t.tag===13||t.tag===31){var i=_i();i=De(i);var r=Bs(t,i);r!==null&&ii(r,t,i),Xd(t,i)}}var zc=!0;function ZM(t,i,r,o){var u=G.T;G.T=null;var d=j.p;try{j.p=2,Wd(t,i,r,o)}finally{j.p=d,G.T=u}}function KM(t,i,r,o){var u=G.T;G.T=null;var d=j.p;try{j.p=8,Wd(t,i,r,o)}finally{j.p=d,G.T=u}}function Wd(t,i,r,o){if(zc){var u=qd(o);if(u===null)Ud(t,i,o,Hc,r),J_(t,o);else if(QM(u,t,i,r,o))o.stopPropagation();else if(J_(t,o),i&4&&-1<$M.indexOf(t)){for(;u!==null;){var d=Ii(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var b=Le(d.pendingLanes);if(b!==0){var D=d;for(D.pendingLanes|=2,D.entangledLanes|=2;b;){var X=1<<31-Xe(b);D.entanglements[1]|=X,b&=~X}aa(d),(Xt&6)===0&&(Mc=Ue()+500,il(0))}}break;case 31:case 13:D=Bs(d,2),D!==null&&ii(D,d,2),Ec(),Xd(d,2)}if(d=qd(o),d===null&&Ud(t,i,o,Hc,r),d===u)break;u=d}u!==null&&o.stopPropagation()}else Ud(t,i,o,null,r)}}function qd(t){return t=Yu(t),Yd(t)}var Hc=null;function Yd(t){if(Hc=null,t=li(t),t!==null){var i=c(t);if(i===null)t=null;else{var r=i.tag;if(r===13){if(t=f(i),t!==null)return t;t=null}else if(r===31){if(t=p(i),t!==null)return t;t=null}else if(r===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;t=null}else i!==t&&(t=null)}}return Hc=t,null}function Q_(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(_t()){case B:return 2;case C:return 8;case ie:case oe:return 32;case he:return 268435456;default:return 32}default:return 32}}var Zd=!1,hs=null,ps=null,ms=null,ul=new Map,fl=new Map,gs=[],$M="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function J_(t,i){switch(t){case"focusin":case"focusout":hs=null;break;case"dragenter":case"dragleave":ps=null;break;case"mouseover":case"mouseout":ms=null;break;case"pointerover":case"pointerout":ul.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":fl.delete(i.pointerId)}}function dl(t,i,r,o,u,d){return t===null||t.nativeEvent!==d?(t={blockedOn:i,domEventName:r,eventSystemFlags:o,nativeEvent:d,targetContainers:[u]},i!==null&&(i=Ii(i),i!==null&&K_(i)),t):(t.eventSystemFlags|=o,i=t.targetContainers,u!==null&&i.indexOf(u)===-1&&i.push(u),t)}function QM(t,i,r,o,u){switch(i){case"focusin":return hs=dl(hs,t,i,r,o,u),!0;case"dragenter":return ps=dl(ps,t,i,r,o,u),!0;case"mouseover":return ms=dl(ms,t,i,r,o,u),!0;case"pointerover":var d=u.pointerId;return ul.set(d,dl(ul.get(d)||null,t,i,r,o,u)),!0;case"gotpointercapture":return d=u.pointerId,fl.set(d,dl(fl.get(d)||null,t,i,r,o,u)),!0}return!1}function ev(t){var i=li(t.target);if(i!==null){var r=c(i);if(r!==null){if(i=r.tag,i===13){if(i=f(r),i!==null){t.blockedOn=i,Dt(t.priority,function(){$_(r)});return}}else if(i===31){if(i=p(r),i!==null){t.blockedOn=i,Dt(t.priority,function(){$_(r)});return}}else if(i===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Gc(t){if(t.blockedOn!==null)return!1;for(var i=t.targetContainers;0<i.length;){var r=qd(t.nativeEvent);if(r===null){r=t.nativeEvent;var o=new r.constructor(r.type,r);qu=o,r.target.dispatchEvent(o),qu=null}else return i=Ii(r),i!==null&&K_(i),t.blockedOn=r,!1;i.shift()}return!0}function tv(t,i,r){Gc(t)&&r.delete(i)}function JM(){Zd=!1,hs!==null&&Gc(hs)&&(hs=null),ps!==null&&Gc(ps)&&(ps=null),ms!==null&&Gc(ms)&&(ms=null),ul.forEach(tv),fl.forEach(tv)}function Vc(t,i){t.blockedOn===i&&(t.blockedOn=null,Zd||(Zd=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,JM)))}var kc=null;function nv(t){kc!==t&&(kc=t,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){kc===t&&(kc=null);for(var i=0;i<t.length;i+=3){var r=t[i],o=t[i+1],u=t[i+2];if(typeof o!="function"){if(Yd(o||r)===null)continue;break}var d=Ii(r);d!==null&&(t.splice(i,3),i-=3,qf(d,{pending:!0,data:u,method:r.method,action:o},o,u))}}))}function Xr(t){function i(X){return Vc(X,t)}hs!==null&&Vc(hs,t),ps!==null&&Vc(ps,t),ms!==null&&Vc(ms,t),ul.forEach(i),fl.forEach(i);for(var r=0;r<gs.length;r++){var o=gs[r];o.blockedOn===t&&(o.blockedOn=null)}for(;0<gs.length&&(r=gs[0],r.blockedOn===null);)ev(r),r.blockedOn===null&&gs.shift();if(r=(t.ownerDocument||t).$$reactFormReplay,r!=null)for(o=0;o<r.length;o+=3){var u=r[o],d=r[o+1],b=u[_n]||null;if(typeof d=="function")b||nv(r);else if(b){var D=null;if(d&&d.hasAttribute("formAction")){if(u=d,b=d[_n]||null)D=b.formAction;else if(Yd(u)!==null)continue}else D=b.action;typeof D=="function"?r[o+1]=D:(r.splice(o,3),o-=3),nv(r)}}}function iv(){function t(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(b){return u=b})},focusReset:"manual",scroll:"manual"})}function i(){u!==null&&(u(),u=null),o||setTimeout(r,20)}function r(){if(!o&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(r,100),function(){o=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),u!==null&&(u(),u=null)}}}function Kd(t){this._internalRoot=t}jc.prototype.render=Kd.prototype.render=function(t){var i=this._internalRoot;if(i===null)throw Error(s(409));var r=i.current,o=_i();Y_(r,o,t,i,null,null)},jc.prototype.unmount=Kd.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var i=t.containerInfo;Y_(t.current,2,null,t,null,null),Ec(),i[kn]=null}};function jc(t){this._internalRoot=t}jc.prototype.unstable_scheduleHydration=function(t){if(t){var i=vt();t={blockedOn:null,target:t,priority:i};for(var r=0;r<gs.length&&i!==0&&i<gs[r].priority;r++);gs.splice(r,0,t),r===0&&ev(t)}};var av=e.version;if(av!=="19.2.7")throw Error(s(527,av,"19.2.7"));j.findDOMNode=function(t){var i=t._reactInternals;if(i===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=h(i),t=t!==null?_(t):null,t=t===null?null:t.stateNode,t};var eb={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xc.isDisabled&&Xc.supportsFiber)try{_e=Xc.inject(eb),ve=Xc}catch{}}return pl.createRoot=function(t,i){if(!l(t))throw Error(s(299));var r=!1,o="",u=f0,d=d0,b=h0;return i!=null&&(i.unstable_strictMode===!0&&(r=!0),i.identifierPrefix!==void 0&&(o=i.identifierPrefix),i.onUncaughtError!==void 0&&(u=i.onUncaughtError),i.onCaughtError!==void 0&&(d=i.onCaughtError),i.onRecoverableError!==void 0&&(b=i.onRecoverableError)),i=W_(t,1,!1,null,null,r,o,null,u,d,b,iv),t[kn]=i.current,Nd(t),new Kd(i)},pl.hydrateRoot=function(t,i,r){if(!l(t))throw Error(s(299));var o=!1,u="",d=f0,b=d0,D=h0,X=null;return r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(d=r.onUncaughtError),r.onCaughtError!==void 0&&(b=r.onCaughtError),r.onRecoverableError!==void 0&&(D=r.onRecoverableError),r.formState!==void 0&&(X=r.formState)),i=W_(t,1,!0,i,r??null,o,u,X,d,b,D,iv),i.context=q_(null),r=i.current,o=_i(),o=De(o),u=ts(o),u.callback=null,ns(r,u,o),r=o,i.current.lanes=r,Ye(i,r),aa(i),t[kn]=i.current,Nd(t),new jc(i)},pl.version="19.2.7",pl}var pv;function fb(){if(pv)return Jd.exports;pv=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),Jd.exports=ub(),Jd.exports}var db=fb();const hb=Gx(db),pb="wrap",mb=24;function Vx(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function gb(a,e){return a===void 0||e===void 0?!1:Array.isArray(a)||Array.isArray(e)?!Array.isArray(a)||!Array.isArray(e)?!1:JSON.stringify([...a].sort())===JSON.stringify([...e].sort()):a===e}function za(a,e){return e?(a.supported_classes??a.supportedClasses??[]).some(s=>s.dimensions===e.dimensions&&gb(s.states,e.states)&&_b(s,e)):!1}function _b(a,e){return!a.neighborhoodId||!e.neighborhoodId?!0:a.neighborhoodId===e.neighborhoodId}function sr(a){const e=a?.caClass;if(!Vx(e))return;const n=typeof e.dimensions=="number"?e.dimensions:void 0,s=e.states;if(!(!n||typeof s!="number"&&!Array.isArray(s)))return{neighborhoodId:typeof e.neighborhoodId=="string"?e.neighborhoodId:void 0,dimensions:n,states:s}}function kx(a,e,n=mb){const s=Vx(a)?a:{},l=Array.isArray(s.size)?s.size:[],c=typeof l[0]=="number"?l[0]:n,f=e>=2&&typeof l[1]=="number"?l[1]:1,p=e>=3&&typeof l[2]=="number"?l[2]:1;return[c,f,p]}function Hu(a){let e=2166136261;for(let n=0;n<a.length;n+=1)e^=a.charCodeAt(n),e=Math.imul(e,16777619);return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function vb(a){return a==="wrap"||a==="mirror"||a==="fixed"}function qp(a){return Il(a?.simulation?.grid)}function Il(a){return vb(a?.boundary)?a.boundary:a?.wrap===!1?"fixed":pb}function jx(a,e){return(a%e+e)%e}function xb(a,e){if(e<=1)return 0;const n=(e-1)*2,s=jx(a,n);return s<=e-1?s:n-s}function Va(a,e,n){return e<=0?null:n==="wrap"?jx(a,e):n==="mirror"?xb(a,e):a>=0&&a<e?a:null}function Xx(a){return a.map(e=>[...e])}function mv(a,e="cells"){const n=a[0]?.length??0;for(const s of a){if(s.length!==n)throw new Error(`${e} must be rectangular`);for(const l of s)if(typeof l!="boolean")throw new Error(`${e} must contain boolean cell states`)}}function yb(a,e,n="engine output"){if(mv(a,"input cells"),mv(e,n),e.length!==a.length||(e[0]?.length??0)!==(a[0]?.length??0))throw new Error(`${n} must preserve the input grid dimensions`)}function Sb(a){const e=/(?:rule[-_\s]*)?(\d{1,3})/i.exec(a??"");return e?Math.max(0,Math.min(255,Number(e[1]))):110}function Mb(a,e){const n=Sb(e.simulation?.ruleId),s=Xx(a),l=a[0]?.length??0;if(a.length===0||l===0)return s;const c=Il(e.simulation?.grid),f=Math.max(0,a.findIndex(m=>m.some(Boolean))),p=a[f]??[];for(let m=0;m<l;m+=1){const h=Va(m-1,l,c),_=Va(m+1,l,c),S=h===null?0:p[h]?1:0,v=p[m]?1:0,M=_===null?0:p[_]?1:0,E=S<<2|v<<1|M;s[f][m]=(n>>E&1)===1}return s}class Ru{position;forward;constructor(e,n){this.position=e,this.forward=n}}function Mu(a){return a===1||a===2||a===3||a===4||a===5||a===6}function bb(a,e){return[a[0]+e[0],a[1]+e[1],a[2]+e[2]]}function Eb(a,e){return[a[0]-e[0],a[1]-e[1],a[2]-e[2]]}function Wx(a,e){const n=Va(a[0],e.size[0],e.boundary),s=Va(a[1],e.size[1],e.boundary),l=Va(a[2],e.size[2],e.boundary);return n===null||s===null||l===null?null:[n,s,l]}function jh(a,e,n){return Wx(bb(a,e),n)}function ih(a,e,n){return Wx(Eb(a,e),n)}function qx(a){return(a+2)%6+1}function uo(a){return a===1?[1,0,0]:a===2?[0,1,0]:a===3?[0,0,1]:a===4?[-1,0,0]:a===5?[0,-1,0]:a===6?[0,0,-1]:null}function Wi(a){return`${a[0]}_${a[1]}_${a[2]}`}function Tb(a,e,n){const s=[];for(const l of a.values()){let c=0,f=0;if(l.forward!==null){for(let p=1;p<=6;p=p+1){const m=uo(p);if(!m)continue;const h=jh(l.position,m,n);if(!h)continue;const _=a.get(Wi(h));!_||_.forward===null||(_.forward===qx(p)&&(f+=1),p===l.forward&&(c+=1))}c<=1&&f===0&&s.push(l)}}return s}function Yx(a=100){return Hu(String(a))}function Ab(a,e,n,s=Yx()){const l=Tb(a,e,n);if(l.length===0)throw new Error("Cannot evolve, no heads");const c=l[Math.floor(s()*l.length)]??l[0];return Cb(a,c,e,n)}function Cb(a,e,n,s,l){let c=0,f=0,p=e,m=e,h=!0;const _=new Set;for(;h;){const x=Wi(p.position);if(_.has(x)){h=!1,m=p;break}if(_.add(x),p.forward===null)break;const P=uo(p.forward);if(!P)break;const L=jh(p.position,P,s);if(!L)break;const R=a.get(Wi(L));R&&Mu(R.forward)?(p=R,h=!0):(h=!1,m=p)}if(m.forward===null)return{changes:c,emits:f,comment:`T:${n} | Tail has no symbol to move.`};const S=uo(m.forward);if(!S)return{changes:c,emits:f,comment:`T:${n} | Tail symbol has no direction.`};const v=ih(e.position,S,s);if(!v)return{changes:c,emits:f,comment:`T:${n} | Tail would move outside fixed boundary.`};const M=Wi(v);a.has(M)||a.set(M,new Ru(v,null));const E=a.get(M);if(!E)throw new Error(`Unable to create naga place cell at ${M}`);if(e.forward===qx(m.forward)){let x=`T:${n} | Emission! ${E.position.join(",")} implied contradiction.`,P=!0;p=a.get(Wi(e.position))??e;const L=new Set;for(;P;){const A=Wi(p.position);if(L.has(A)||(L.add(A),p.forward===null))break;const N=uo(p.forward);if(!N)break;const k=jh(p.position,N,s);if(!k)break;const V=a.get(Wi(k));if(V&&Mu(V.forward)){p=V;const Q=ih(p.position,S,s);if(!Q){P=!1;break}const fe=a.get(Wi(Q));P=!!(fe&&Mu(fe.forward))}else P=!1}const R=ih(p.position,S,s);if(!R)return{changes:c,emits:f,comment:`T:${n} | Kink would move outside fixed boundary.`};const I=Wi(R);a.has(I)||a.set(I,new Ru(R,null));const O=a.get(I);if(!O)throw new Error(`Unable to create naga kink place cell at ${I}`);const U=O.forward;return O.forward=m.forward,m.forward=U,f+=1,c+=1,x+=` Kink at ${R.join(",")}, swapped ${O.forward} for ${U}.`,{changes:c,emits:f,comment:x}}const w=`T:${n} | Take tail symbol ${m.forward} from ${m.position.join(",")}, put into ${E.position.join(",")} in exchange for ${E.forward}`,y=E.forward;return E.forward=m.forward,m.forward=y,c+=1,{changes:c,emits:f,comment:w}}function wb(a,e){const n=a.simulation?.grid?.size,s=Array.isArray(n)&&typeof n[0]=="number"?n[0]:e[0]?.length??24,l=Array.isArray(n)&&typeof n[1]=="number"?n[1]:e.length||24,c=Array.isArray(n)&&typeof n[2]=="number"?n[2]:24;return[Math.max(1,s),Math.max(1,l),Math.max(1,c)]}function Rb(a){const e=a[3]??1;return Mu(e)?e:1}function Db(a){const e=new Map;for(const n of a??[]){const[s,l,c=0]=n;if(!Number.isInteger(s)||!Number.isInteger(l)||!Number.isInteger(c))continue;const f=[s,l,c];e.set(Wi(f),new Ru(f,Rb(n)))}return e}function Nb(a){const e=new Map;for(let n=0;n<a.length;n+=1)for(let s=0;s<(a[n]?.length??0);s+=1){if(!a[n][s])continue;const l=[s,n,0];e.set(Wi(l),new Ru(l,1))}return e}function Ub(a,e){const n=[];for(const s of a.values()){const[l,c,f]=s.position;s.forward!==null&&(l<0||c<0||f<0||l>=e[0]||c>=e[1]||f>=e[2]||n.push([l,c,f,s.forward]))}return n}function Lb(a,e){const n=e.map(s=>s.map(()=>!1));for(const s of a){const[l,c]=s;!Number.isInteger(l)||!Number.isInteger(c)||c<0||l<0||c>=n.length||l>=(n[c]?.length??0)||(n[c][l]=!0)}return n}function Ob(a){return a.simulation??={},a.simulation.initialCondition??={},a.simulation}function Pb(a,e){const n=Ob(e),s=wb(e,a),l=n.initialCondition?.cells,c=Array.isArray(l)&&l.length>0?Db(l):Nb(a),f=typeof n.nagaTick=="number"?n.nagaTick:0,p=typeof n.seed=="string"?n.seed:"naga",m={boundary:Il(n.grid),size:s};try{Ab(c,f,m,Yx(`${p}:${f}`))}catch(_){if(!(_ instanceof Error)||_.message!=="Cannot evolve, no heads")throw _}const h=Ub(c,s);return n.initialCondition={...n.initialCondition,type:"cells",cells:h},n.nagaTick=f+1,Lb(h,a)}function Yp(a){return Xx(a)}function Zx(a){return a.map(e=>e.map(()=>!1))}function Ib(a){const e=/^B([0-8]*)\/S([0-8]*)$/i.exec(a);return e?{birth:new Set(e[1].split("").map(Number)),survival:new Set(e[2].split("").map(Number))}:{birth:new Set([3]),survival:new Set([2,3])}}function Kx(a,e){const n=Ib(e.simulation?.ruleId??"B3/S23"),s=Zx(a),l=a.length,c=a[0]?.length??0,f=Il(e.simulation?.grid);for(let p=0;p<l;p+=1)for(let m=0;m<c;m+=1){let h=0;for(let _=-1;_<=1;_+=1)for(let S=-1;S<=1;S+=1){if(S===0&&_===0)continue;const v=m+S,M=p+_,E=Va(v,c,f),w=Va(M,l,f);E===null||w===null||a[w][E]&&(h+=1)}s[p][m]=a[p][m]?n.survival.has(h):n.birth.has(h)}return s}function Bb(a,e){return typeof a=="number"&&Number.isFinite(a)?Math.max(0,Math.min(1,a)):e}function Fb(a,e,n){return Hu(`${a}:${e}:${n}`)()}function zb(a,e){const n=Zx(a),s=a.length,l=a[0]?.length??0,c=Il(e.simulation?.grid),f=Bb(e.simulation?.spreadProbability,1),p=typeof e.simulation?.seed=="string"?e.simulation.seed:"wildfire";for(let m=0;m<s;m+=1)for(let h=0;h<l;h+=1){if(a[m][h]){n[m][h]=!1;continue}let _=0;const S=[[0,-1],[1,0],[0,1],[-1,0]];for(const[v,M]of S){const E=Va(h+v,l,c),w=Va(m+M,s,c);E===null||w===null||a[w][E]&&(_+=1)}n[m][h]=_>0&&Fb(p,h,m)<f}return n}const wl=new Map;function fr(a,e={}){if(!a.id.trim())throw new Error("CA engine runtime id is required");if(wl.has(a.id)&&!e.replace)throw new Error(`CA engine runtime already registered: ${a.id}`);wl.set(a.id,a)}function Dl(a,e){const n=e.simulation?.engineId??"game-of-life-2d",s=wl.get(n)??wl.get("outer-totalistic-2d")??wl.get("noop"),l=structuredClone(e),c=s?s.step(a,l):Yp(a);return yb(a,c,`CA engine output (${s?.id??"fallback"})`),{cells:c,settings:l}}fr({id:"game-of-life-2d",label:"Game of Life 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"B3/S23",rendererId:"2d-canvas"},step:Kx},{replace:!0});fr({id:"outer-totalistic-2d",label:"Outer-totalistic 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"B3/S23",rendererId:"2d-canvas"},step:Kx},{replace:!0});fr({id:"elementary-1d",label:"Elementary 1D",supportedClasses:[{dimensions:1,states:2}],defaultParams:{ruleId:"Rule 110",rendererId:"elementary-1d"},step:Mb},{replace:!0});fr({id:"wildfire-2d",label:"Wildfire 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"wildfire-binary",rendererId:"wildfire-2d",spreadProbability:1},step:zb},{replace:!0});fr({id:"naga-3d",label:"Naga 3D",supportedClasses:[{dimensions:3,states:7}],defaultParams:{ruleId:"naga-3d",rendererId:"voxel-3d",seed:"naga",edgeWrap:!0},step:Pb},{replace:!0});fr({id:"generic-voxel-ca",label:"Generic voxel CA",step:Yp},{replace:!0});fr({id:"noop",label:"No evolution",step:Yp},{replace:!0});const Xh=new Map;function Hb(a){return Math.max(0,Math.min(1,typeof a=="number"?a:.28))}function gv(a,e,n,s){return Math.max(n,Math.min(s,typeof a=="number"&&Number.isFinite(a)?Math.round(a):e))}function Gb(a,e){return Math.max(0,Math.min(1,typeof a=="number"&&Number.isFinite(a)?a:e))}function Vb({settings:a,caClass:e,params:n}){const s=Hb(n.density),l=typeof n.seed=="string"?n.seed:"studio-seed",c=Hu(l),[f,p,m]=kx(a.simulation?.grid,e.dimensions),h=[];for(let _=0;_<m;_+=1)for(let S=0;S<p;S+=1)for(let v=0;v<f;v+=1)c()<s&&h.push([v,S,_]);return{type:"cells",cells:h,generator:{kind:"random-soup",density:s,seed:l}}}function kb(a){return Math.floor(a()*6)+1}function jb(a,e,n){if(n()<e)return a;const s=[1,2,3,4,5,6].filter(l=>l!==a);return s[Math.floor(n()*s.length)]??a}function ah(a,e,n){return`${a}_${e}_${n}`}function _v(a,e,n,s,l,c){return a>=0&&e>=0&&n>=0&&a<s&&e<l&&n<c}function Xb({settings:a,caClass:e,params:n}){const[s,l,c]=kx(a.simulation?.grid,e.dimensions),f=gv(n.count,3,1,Math.max(1,s*l*c)),p=gv(n.length,5,1,Math.max(1,s*l*c)),m=Gb(n.sameTypeProbability,.8),h=typeof n.seed=="string"?n.seed:"naga-markov",_=Hu(h),S=new Set,v=[],M=f*300;let E=0,w=0;for(;E<f&&w<M;){w+=1;let y=Math.floor(_()*s),x=Math.floor(_()*l),P=Math.floor(_()*c),L=kb(_);const R=[],I=new Set;let O=!0;for(let A=0;A<p;A+=1){const N=ah(y,x,P);if(!_v(y,x,P,s,l,c)||S.has(N)||I.has(N)){O=!1;break}R.push([y,x,P,L]),I.add(N);const k=uo(L);if(!k){O=!1;break}const V=jb(L,m,_);y+=k[0],x+=k[1],P+=k[2],L=V}const U=R[R.length-1];if(U){const[A,N,k,V]=U,Q=uo(V);if(!Q)O=!1;else{const fe=A+Q[0],pe=N+Q[1],J=k+Q[2],G=ah(fe,pe,J);(!_v(fe,pe,J,s,l,c)||S.has(G)||I.has(G))&&(O=!1)}}if(O){for(const A of R){const[N,k,V]=A;S.add(ah(N,k,V)),v.push(A)}E+=1}}return{type:"cells",cells:v,generator:{kind:"naga-markov",count:f,length:p,sameTypeProbability:m,seed:h,created:E}}}function $x(a,e={}){if(!a.id.trim())throw new Error("Initial condition runtime id is required");if(Xh.has(a.id)&&!e.replace)throw new Error(`Initial condition runtime already registered: ${a.id}`);Xh.set(a.id,a)}function Wb(a){return Xh.get(a)??null}function qb(a,e){const n=Wb(a);if(!n)throw new Error(`Initial condition runtime unavailable: ${a}`);const s=n.generate(e);if(s.type!=="cells"||!Array.isArray(s.cells))throw new Error(`Initial condition runtime returned an invalid result: ${a}`);return s}$x({id:"random-soup",label:"Random soup",generate:Vb},{replace:!0});$x({id:"naga-markov",label:"Naga Markov chains",generate:Xb},{replace:!0});const Zp="185",fo={ROTATE:0,DOLLY:1,PAN:2},oo={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Yb=0,vv=1,Zb=2,bu=1,Qx=2,Tl=3,Cs=0,ri=1,Ha=2,ka=0,ho=1,Wh=2,xv=3,yv=4,Kb=5,er=100,$b=101,Qb=102,Jb=103,eE=104,tE=200,nE=201,iE=202,aE=203,qh=204,Yh=205,sE=206,rE=207,oE=208,lE=209,cE=210,uE=211,fE=212,dE=213,hE=214,Zh=0,Kh=1,$h=2,vo=3,Qh=4,Jh=5,ep=6,tp=7,Jx=0,pE=1,mE=2,ca=0,ey=1,ty=2,ny=3,Kp=4,iy=5,ay=6,sy=7,ry=300,or=301,xo=302,sh=303,rh=304,Gu=306,np=1e3,Ga=1001,ip=1002,Vn=1003,gE=1004,Wc=1005,Yn=1006,oh=1007,nr=1008,Si=1009,oy=1010,ly=1011,Nl=1012,$p=1013,da=1014,qi=1015,Wa=1016,Qp=1017,Jp=1018,Ul=1020,cy=35902,uy=35899,fy=1021,dy=1022,Yi=1023,qa=1026,ir=1027,em=1028,tm=1029,lr=1030,nm=1031,im=1033,Eu=33776,Tu=33777,Au=33778,Cu=33779,ap=35840,sp=35841,rp=35842,op=35843,lp=36196,cp=37492,up=37496,fp=37488,dp=37489,Du=37490,hp=37491,pp=37808,mp=37809,gp=37810,_p=37811,vp=37812,xp=37813,yp=37814,Sp=37815,Mp=37816,bp=37817,Ep=37818,Tp=37819,Ap=37820,Cp=37821,wp=36492,Rp=36494,Dp=36495,Np=36283,Up=36284,Nu=36285,Lp=36286,_E=3200,Op=0,vE=1,Ts="",yi="srgb",Uu="srgb-linear",Lu="linear",en="srgb",Wr=7680,Sv=519,xE=512,yE=513,SE=514,am=515,ME=516,bE=517,sm=518,EE=519,Mv=35044,hy=35048,bv="300 es",la=2e3,Ll=2001;function TE(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}function Ou(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function AE(){const a=Ou("canvas");return a.style.display="block",a}const Ev={};function Tv(...a){const e="THREE."+a.shift();console.log(e,...a)}function py(a){const e=a[0];if(typeof e=="string"&&e.startsWith("TSL:")){const n=a[1];n&&n.isStackTrace?a[0]+=" "+n.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function mt(...a){a=py(a);const e="THREE."+a.shift();{const n=a[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...a)}}function Vt(...a){a=py(a);const e="THREE."+a.shift();{const n=a[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...a)}}function po(...a){const e=a.join(" ");e in Ev||(Ev[e]=!0,mt(...a))}function CE(a,e,n){return new Promise(function(s,l){function c(){switch(a.clientWaitSync(e,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:l();break;case a.TIMEOUT_EXPIRED:setTimeout(c,n);break;default:s()}}setTimeout(c,n)})}const wE={[Zh]:Kh,[$h]:ep,[Qh]:tp,[vo]:Jh,[Kh]:Zh,[ep]:$h,[tp]:Qh,[Jh]:vo};class Ns{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(n)===-1&&s[e].push(n)}hasEventListener(e,n){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(n)!==-1}removeEventListener(e,n){const s=this._listeners;if(s===void 0)return;const l=s[e];if(l!==void 0){const c=l.indexOf(n);c!==-1&&l.splice(c,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const s=n[e.type];if(s!==void 0){e.target=this;const l=s.slice(0);for(let c=0,f=l.length;c<f;c++)l[c].call(this,e);e.target=null}}}const Wn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Rl=Math.PI/180,Pp=180/Math.PI;function Bl(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Wn[a&255]+Wn[a>>8&255]+Wn[a>>16&255]+Wn[a>>24&255]+"-"+Wn[e&255]+Wn[e>>8&255]+"-"+Wn[e>>16&15|64]+Wn[e>>24&255]+"-"+Wn[n&63|128]+Wn[n>>8&255]+"-"+Wn[n>>16&255]+Wn[n>>24&255]+Wn[s&255]+Wn[s>>8&255]+Wn[s>>16&255]+Wn[s>>24&255]).toLowerCase()}function Ot(a,e,n){return Math.max(e,Math.min(n,a))}function RE(a,e){return(a%e+e)%e}function lh(a,e,n){return(1-n)*a+n*e}function ml(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ai(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const DE={DEG2RAD:Rl},Mm=class Mm{constructor(e=0,n=0){this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,s=this.y,l=e.elements;return this.x=l[0]*n+l[3]*s+l[6],this.y=l[1]*n+l[4]*s+l[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Ot(this.x,e.x,n.x),this.y=Ot(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Ot(this.x,e,n),this.y=Ot(this.y,e,n),this}clampLength(e,n){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Ot(s,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const s=this.dot(e)/n;return Math.acos(Ot(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,s=this.y-e.y;return n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,s){return this.x=e.x+(n.x-e.x)*s,this.y=e.y+(n.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const s=Math.cos(n),l=Math.sin(n),c=this.x-e.x,f=this.y-e.y;return this.x=c*s-f*l+e.x,this.y=c*l+f*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Mm.prototype.isVector2=!0;let xt=Mm;class ws{constructor(e=0,n=0,s=0,l=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=s,this._w=l}static slerpFlat(e,n,s,l,c,f,p){let m=s[l+0],h=s[l+1],_=s[l+2],S=s[l+3],v=c[f+0],M=c[f+1],E=c[f+2],w=c[f+3];if(S!==w||m!==v||h!==M||_!==E){let y=m*v+h*M+_*E+S*w;y<0&&(v=-v,M=-M,E=-E,w=-w,y=-y);let x=1-p;if(y<.9995){const P=Math.acos(y),L=Math.sin(P);x=Math.sin(x*P)/L,p=Math.sin(p*P)/L,m=m*x+v*p,h=h*x+M*p,_=_*x+E*p,S=S*x+w*p}else{m=m*x+v*p,h=h*x+M*p,_=_*x+E*p,S=S*x+w*p;const P=1/Math.sqrt(m*m+h*h+_*_+S*S);m*=P,h*=P,_*=P,S*=P}}e[n]=m,e[n+1]=h,e[n+2]=_,e[n+3]=S}static multiplyQuaternionsFlat(e,n,s,l,c,f){const p=s[l],m=s[l+1],h=s[l+2],_=s[l+3],S=c[f],v=c[f+1],M=c[f+2],E=c[f+3];return e[n]=p*E+_*S+m*M-h*v,e[n+1]=m*E+_*v+h*S-p*M,e[n+2]=h*E+_*M+p*v-m*S,e[n+3]=_*E-p*S-m*v-h*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,s,l){return this._x=e,this._y=n,this._z=s,this._w=l,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const s=e._x,l=e._y,c=e._z,f=e._order,p=Math.cos,m=Math.sin,h=p(s/2),_=p(l/2),S=p(c/2),v=m(s/2),M=m(l/2),E=m(c/2);switch(f){case"XYZ":this._x=v*_*S+h*M*E,this._y=h*M*S-v*_*E,this._z=h*_*E+v*M*S,this._w=h*_*S-v*M*E;break;case"YXZ":this._x=v*_*S+h*M*E,this._y=h*M*S-v*_*E,this._z=h*_*E-v*M*S,this._w=h*_*S+v*M*E;break;case"ZXY":this._x=v*_*S-h*M*E,this._y=h*M*S+v*_*E,this._z=h*_*E+v*M*S,this._w=h*_*S-v*M*E;break;case"ZYX":this._x=v*_*S-h*M*E,this._y=h*M*S+v*_*E,this._z=h*_*E-v*M*S,this._w=h*_*S+v*M*E;break;case"YZX":this._x=v*_*S+h*M*E,this._y=h*M*S+v*_*E,this._z=h*_*E-v*M*S,this._w=h*_*S-v*M*E;break;case"XZY":this._x=v*_*S-h*M*E,this._y=h*M*S-v*_*E,this._z=h*_*E+v*M*S,this._w=h*_*S+v*M*E;break;default:mt("Quaternion: .setFromEuler() encountered an unknown order: "+f)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const s=n/2,l=Math.sin(s);return this._x=e.x*l,this._y=e.y*l,this._z=e.z*l,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,s=n[0],l=n[4],c=n[8],f=n[1],p=n[5],m=n[9],h=n[2],_=n[6],S=n[10],v=s+p+S;if(v>0){const M=.5/Math.sqrt(v+1);this._w=.25/M,this._x=(_-m)*M,this._y=(c-h)*M,this._z=(f-l)*M}else if(s>p&&s>S){const M=2*Math.sqrt(1+s-p-S);this._w=(_-m)/M,this._x=.25*M,this._y=(l+f)/M,this._z=(c+h)/M}else if(p>S){const M=2*Math.sqrt(1+p-s-S);this._w=(c-h)/M,this._x=(l+f)/M,this._y=.25*M,this._z=(m+_)/M}else{const M=2*Math.sqrt(1+S-s-p);this._w=(f-l)/M,this._x=(c+h)/M,this._y=(m+_)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let s=e.dot(n)+1;return s<1e-8?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ot(this.dot(e),-1,1)))}rotateTowards(e,n){const s=this.angleTo(e);if(s===0)return this;const l=Math.min(1,n/s);return this.slerp(e,l),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const s=e._x,l=e._y,c=e._z,f=e._w,p=n._x,m=n._y,h=n._z,_=n._w;return this._x=s*_+f*p+l*h-c*m,this._y=l*_+f*m+c*p-s*h,this._z=c*_+f*h+s*m-l*p,this._w=f*_-s*p-l*m-c*h,this._onChangeCallback(),this}slerp(e,n){let s=e._x,l=e._y,c=e._z,f=e._w,p=this.dot(e);p<0&&(s=-s,l=-l,c=-c,f=-f,p=-p);let m=1-n;if(p<.9995){const h=Math.acos(p),_=Math.sin(h);m=Math.sin(m*h)/_,n=Math.sin(n*h)/_,this._x=this._x*m+s*n,this._y=this._y*m+l*n,this._z=this._z*m+c*n,this._w=this._w*m+f*n,this._onChangeCallback()}else this._x=this._x*m+s*n,this._y=this._y*m+l*n,this._z=this._z*m+c*n,this._w=this._w*m+f*n,this.normalize();return this}slerpQuaternions(e,n,s){return this.copy(e).slerp(n,s)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),s=Math.random(),l=Math.sqrt(1-s),c=Math.sqrt(s);return this.set(l*Math.sin(e),l*Math.cos(e),c*Math.sin(n),c*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const bm=class bm{constructor(e=0,n=0,s=0){this.x=e,this.y=n,this.z=s}set(e,n,s){return s===void 0&&(s=this.z),this.x=e,this.y=n,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(Av.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Av.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,s=this.y,l=this.z,c=e.elements;return this.x=c[0]*n+c[3]*s+c[6]*l,this.y=c[1]*n+c[4]*s+c[7]*l,this.z=c[2]*n+c[5]*s+c[8]*l,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,s=this.y,l=this.z,c=e.elements,f=1/(c[3]*n+c[7]*s+c[11]*l+c[15]);return this.x=(c[0]*n+c[4]*s+c[8]*l+c[12])*f,this.y=(c[1]*n+c[5]*s+c[9]*l+c[13])*f,this.z=(c[2]*n+c[6]*s+c[10]*l+c[14])*f,this}applyQuaternion(e){const n=this.x,s=this.y,l=this.z,c=e.x,f=e.y,p=e.z,m=e.w,h=2*(f*l-p*s),_=2*(p*n-c*l),S=2*(c*s-f*n);return this.x=n+m*h+f*S-p*_,this.y=s+m*_+p*h-c*S,this.z=l+m*S+c*_-f*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,s=this.y,l=this.z,c=e.elements;return this.x=c[0]*n+c[4]*s+c[8]*l,this.y=c[1]*n+c[5]*s+c[9]*l,this.z=c[2]*n+c[6]*s+c[10]*l,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Ot(this.x,e.x,n.x),this.y=Ot(this.y,e.y,n.y),this.z=Ot(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Ot(this.x,e,n),this.y=Ot(this.y,e,n),this.z=Ot(this.z,e,n),this}clampLength(e,n){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Ot(s,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,s){return this.x=e.x+(n.x-e.x)*s,this.y=e.y+(n.y-e.y)*s,this.z=e.z+(n.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const s=e.x,l=e.y,c=e.z,f=n.x,p=n.y,m=n.z;return this.x=l*m-c*p,this.y=c*f-s*m,this.z=s*p-l*f,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const s=e.dot(this)/n;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return ch.copy(this).projectOnVector(e),this.sub(ch)}reflect(e){return this.sub(ch.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const s=this.dot(e)/n;return Math.acos(Ot(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,s=this.y-e.y,l=this.z-e.z;return n*n+s*s+l*l}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,s){const l=Math.sin(n)*e;return this.x=l*Math.sin(s),this.y=Math.cos(n)*e,this.z=l*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,s){return this.x=e*Math.sin(n),this.y=s,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=s,this.z=l,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,s=Math.sqrt(1-n*n);return this.x=s*Math.cos(e),this.y=n,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};bm.prototype.isVector3=!0;let re=bm;const ch=new re,Av=new ws,Em=class Em{constructor(e,n,s,l,c,f,p,m,h){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,s,l,c,f,p,m,h)}set(e,n,s,l,c,f,p,m,h){const _=this.elements;return _[0]=e,_[1]=l,_[2]=p,_[3]=n,_[4]=c,_[5]=m,_[6]=s,_[7]=f,_[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,s=e.elements;return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],this}extractBasis(e,n,s){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const s=e.elements,l=n.elements,c=this.elements,f=s[0],p=s[3],m=s[6],h=s[1],_=s[4],S=s[7],v=s[2],M=s[5],E=s[8],w=l[0],y=l[3],x=l[6],P=l[1],L=l[4],R=l[7],I=l[2],O=l[5],U=l[8];return c[0]=f*w+p*P+m*I,c[3]=f*y+p*L+m*O,c[6]=f*x+p*R+m*U,c[1]=h*w+_*P+S*I,c[4]=h*y+_*L+S*O,c[7]=h*x+_*R+S*U,c[2]=v*w+M*P+E*I,c[5]=v*y+M*L+E*O,c[8]=v*x+M*R+E*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],s=e[1],l=e[2],c=e[3],f=e[4],p=e[5],m=e[6],h=e[7],_=e[8];return n*f*_-n*p*h-s*c*_+s*p*m+l*c*h-l*f*m}invert(){const e=this.elements,n=e[0],s=e[1],l=e[2],c=e[3],f=e[4],p=e[5],m=e[6],h=e[7],_=e[8],S=_*f-p*h,v=p*m-_*c,M=h*c-f*m,E=n*S+s*v+l*M;if(E===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/E;return e[0]=S*w,e[1]=(l*h-_*s)*w,e[2]=(p*s-l*f)*w,e[3]=v*w,e[4]=(_*n-l*m)*w,e[5]=(l*c-p*n)*w,e[6]=M*w,e[7]=(s*m-h*n)*w,e[8]=(f*n-s*c)*w,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,s,l,c,f,p){const m=Math.cos(c),h=Math.sin(c);return this.set(s*m,s*h,-s*(m*f+h*p)+f+e,-l*h,l*m,-l*(-h*f+m*p)+p+n,0,0,1),this}scale(e,n){return po("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(uh.makeScale(e,n)),this}rotate(e){return po("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(uh.makeRotation(-e)),this}translate(e,n){return po("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(uh.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),s=Math.sin(e);return this.set(n,-s,0,s,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,s=e.elements;for(let l=0;l<9;l++)if(n[l]!==s[l])return!1;return!0}fromArray(e,n=0){for(let s=0;s<9;s++)this.elements[s]=e[s+n];return this}toArray(e=[],n=0){const s=this.elements;return e[n]=s[0],e[n+1]=s[1],e[n+2]=s[2],e[n+3]=s[3],e[n+4]=s[4],e[n+5]=s[5],e[n+6]=s[6],e[n+7]=s[7],e[n+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Em.prototype.isMatrix3=!0;let bt=Em;const uh=new bt,Cv=new bt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wv=new bt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function NE(){const a={enabled:!0,workingColorSpace:Uu,spaces:{},convert:function(l,c,f){return this.enabled===!1||c===f||!c||!f||(this.spaces[c].transfer===en&&(l.r=ja(l.r),l.g=ja(l.g),l.b=ja(l.b)),this.spaces[c].primaries!==this.spaces[f].primaries&&(l.applyMatrix3(this.spaces[c].toXYZ),l.applyMatrix3(this.spaces[f].fromXYZ)),this.spaces[f].transfer===en&&(l.r=mo(l.r),l.g=mo(l.g),l.b=mo(l.b))),l},workingToColorSpace:function(l,c){return this.convert(l,this.workingColorSpace,c)},colorSpaceToWorking:function(l,c){return this.convert(l,c,this.workingColorSpace)},getPrimaries:function(l){return this.spaces[l].primaries},getTransfer:function(l){return l===Ts?Lu:this.spaces[l].transfer},getToneMappingMode:function(l){return this.spaces[l].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(l,c=this.workingColorSpace){return l.fromArray(this.spaces[c].luminanceCoefficients)},define:function(l){Object.assign(this.spaces,l)},_getMatrix:function(l,c,f){return l.copy(this.spaces[c].toXYZ).multiply(this.spaces[f].fromXYZ)},_getDrawingBufferColorSpace:function(l){return this.spaces[l].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(l=this.workingColorSpace){return this.spaces[l].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(l,c){return po("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(l,c)},toWorkingColorSpace:function(l,c){return po("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(l,c)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],s=[.3127,.329];return a.define({[Uu]:{primaries:e,whitePoint:s,transfer:Lu,toXYZ:Cv,fromXYZ:wv,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:yi},outputColorSpaceConfig:{drawingBufferColorSpace:yi}},[yi]:{primaries:e,whitePoint:s,transfer:en,toXYZ:Cv,fromXYZ:wv,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:yi}}}),a}const Gt=NE();function ja(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function mo(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let qr;class UE{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{qr===void 0&&(qr=Ou("canvas")),qr.width=e.width,qr.height=e.height;const l=qr.getContext("2d");e instanceof ImageData?l.putImageData(e,0,0):l.drawImage(e,0,0,e.width,e.height),s=qr}return s.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=Ou("canvas");n.width=e.width,n.height=e.height;const s=n.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const l=s.getImageData(0,0,e.width,e.height),c=l.data;for(let f=0;f<c.length;f++)c[f]=ja(c[f]/255)*255;return s.putImageData(l,0,0),n}else if(e.data){const n=e.data.slice(0);for(let s=0;s<n.length;s++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[s]=Math.floor(ja(n[s]/255)*255):n[s]=ja(n[s]);return{data:n,width:e.width,height:e.height}}else return mt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let LE=0;class rm{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:LE++}),this.uuid=Bl(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):typeof VideoFrame<"u"&&n instanceof VideoFrame?e.set(n.displayWidth,n.displayHeight,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const s={uuid:this.uuid,url:""},l=this.data;if(l!==null){let c;if(Array.isArray(l)){c=[];for(let f=0,p=l.length;f<p;f++)l[f].isDataTexture?c.push(fh(l[f].image)):c.push(fh(l[f]))}else c=fh(l);s.url=c}return n||(e.images[this.uuid]=s),s}}function fh(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?UE.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(mt("Texture: Unable to serialize Texture."),{})}let OE=0;const dh=new re;class $n extends Ns{constructor(e=$n.DEFAULT_IMAGE,n=$n.DEFAULT_MAPPING,s=Ga,l=Ga,c=Yn,f=nr,p=Yi,m=Si,h=$n.DEFAULT_ANISOTROPY,_=Ts){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:OE++}),this.uuid=Bl(),this.name="",this.source=new rm(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=s,this.wrapT=l,this.magFilter=c,this.minFilter=f,this.anisotropy=h,this.format=p,this.internalFormat=null,this.type=m,this.offset=new xt(0,0),this.repeat=new xt(1,1),this.center=new xt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new bt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=_,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(dh).x}get height(){return this.source.getSize(dh).y}get depth(){return this.source.getSize(dh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const s=e[n];if(s===void 0){mt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const l=this[n];if(l===void 0){mt(`Texture.setValues(): property '${n}' does not exist.`);continue}l&&s&&l.isVector2&&s.isVector2||l&&s&&l.isVector3&&s.isVector3||l&&s&&l.isMatrix3&&s.isMatrix3?l.copy(s):this[n]=s}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),n||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ry)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case np:e.x=e.x-Math.floor(e.x);break;case Ga:e.x=e.x<0?0:1;break;case ip:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case np:e.y=e.y-Math.floor(e.y);break;case Ga:e.y=e.y<0?0:1;break;case ip:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}$n.DEFAULT_IMAGE=null;$n.DEFAULT_MAPPING=ry;$n.DEFAULT_ANISOTROPY=1;const Tm=class Tm{constructor(e=0,n=0,s=0,l=1){this.x=e,this.y=n,this.z=s,this.w=l}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,s,l){return this.x=e,this.y=n,this.z=s,this.w=l,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,s=this.y,l=this.z,c=this.w,f=e.elements;return this.x=f[0]*n+f[4]*s+f[8]*l+f[12]*c,this.y=f[1]*n+f[5]*s+f[9]*l+f[13]*c,this.z=f[2]*n+f[6]*s+f[10]*l+f[14]*c,this.w=f[3]*n+f[7]*s+f[11]*l+f[15]*c,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,s,l,c;const m=e.elements,h=m[0],_=m[4],S=m[8],v=m[1],M=m[5],E=m[9],w=m[2],y=m[6],x=m[10];if(Math.abs(_-v)<.01&&Math.abs(S-w)<.01&&Math.abs(E-y)<.01){if(Math.abs(_+v)<.1&&Math.abs(S+w)<.1&&Math.abs(E+y)<.1&&Math.abs(h+M+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const L=(h+1)/2,R=(M+1)/2,I=(x+1)/2,O=(_+v)/4,U=(S+w)/4,A=(E+y)/4;return L>R&&L>I?L<.01?(s=0,l=.707106781,c=.707106781):(s=Math.sqrt(L),l=O/s,c=U/s):R>I?R<.01?(s=.707106781,l=0,c=.707106781):(l=Math.sqrt(R),s=O/l,c=A/l):I<.01?(s=.707106781,l=.707106781,c=0):(c=Math.sqrt(I),s=U/c,l=A/c),this.set(s,l,c,n),this}let P=Math.sqrt((y-E)*(y-E)+(S-w)*(S-w)+(v-_)*(v-_));return Math.abs(P)<.001&&(P=1),this.x=(y-E)/P,this.y=(S-w)/P,this.z=(v-_)/P,this.w=Math.acos((h+M+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Ot(this.x,e.x,n.x),this.y=Ot(this.y,e.y,n.y),this.z=Ot(this.z,e.z,n.z),this.w=Ot(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Ot(this.x,e,n),this.y=Ot(this.y,e,n),this.z=Ot(this.z,e,n),this.w=Ot(this.w,e,n),this}clampLength(e,n){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Ot(s,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,s){return this.x=e.x+(n.x-e.x)*s,this.y=e.y+(n.y-e.y)*s,this.z=e.z+(n.z-e.z)*s,this.w=e.w+(n.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Tm.prototype.isVector4=!0;let gn=Tm;class PE extends Ns{constructor(e=1,n=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Yn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},s),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=s.depth,this.scissor=new gn(0,0,e,n),this.scissorTest=!1,this.viewport=new gn(0,0,e,n),this.textures=[];const l={width:e,height:n,depth:s.depth},c=new $n(l),f=s.count;for(let p=0;p<f;p++)this.textures[p]=c.clone(),this.textures[p].isRenderTargetTexture=!0,this.textures[p].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview,this.useArrayDepthTexture=s.useArrayDepthTexture}_setTextureOptions(e={}){const n={minFilter:Yn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,s=1){if(this.width!==e||this.height!==n||this.depth!==s){this.width=e,this.height=n,this.depth=s;for(let l=0,c=this.textures.length;l<c;l++)this.textures[l].image.width=e,this.textures[l].image.height=n,this.textures[l].image.depth=s,this.textures[l].isData3DTexture!==!0&&(this.textures[l].isArrayTexture=this.textures[l].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,s=e.textures.length;n<s;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const l=Object.assign({},e.textures[n].image);this.textures[n].source=new rm(l)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ua extends PE{constructor(e=1,n=1,s={}){super(e,n,s),this.isWebGLRenderTarget=!0}}class my extends $n{constructor(e=null,n=1,s=1,l=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:s,depth:l},this.magFilter=Vn,this.minFilter=Vn,this.wrapR=Ga,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class IE extends $n{constructor(e=null,n=1,s=1,l=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:s,depth:l},this.magFilter=Vn,this.minFilter=Vn,this.wrapR=Ga,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const zu=class zu{constructor(e,n,s,l,c,f,p,m,h,_,S,v,M,E,w,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,s,l,c,f,p,m,h,_,S,v,M,E,w,y)}set(e,n,s,l,c,f,p,m,h,_,S,v,M,E,w,y){const x=this.elements;return x[0]=e,x[4]=n,x[8]=s,x[12]=l,x[1]=c,x[5]=f,x[9]=p,x[13]=m,x[2]=h,x[6]=_,x[10]=S,x[14]=v,x[3]=M,x[7]=E,x[11]=w,x[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new zu().fromArray(this.elements)}copy(e){const n=this.elements,s=e.elements;return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],this}copyPosition(e){const n=this.elements,s=e.elements;return n[12]=s[12],n[13]=s[13],n[14]=s[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,s){return this.determinantAffine()===0?(e.set(1,0,0),n.set(0,1,0),s.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(e,n,s){return this.set(e.x,n.x,s.x,0,e.y,n.y,s.y,0,e.z,n.z,s.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const n=this.elements,s=e.elements,l=1/Yr.setFromMatrixColumn(e,0).length(),c=1/Yr.setFromMatrixColumn(e,1).length(),f=1/Yr.setFromMatrixColumn(e,2).length();return n[0]=s[0]*l,n[1]=s[1]*l,n[2]=s[2]*l,n[3]=0,n[4]=s[4]*c,n[5]=s[5]*c,n[6]=s[6]*c,n[7]=0,n[8]=s[8]*f,n[9]=s[9]*f,n[10]=s[10]*f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,s=e.x,l=e.y,c=e.z,f=Math.cos(s),p=Math.sin(s),m=Math.cos(l),h=Math.sin(l),_=Math.cos(c),S=Math.sin(c);if(e.order==="XYZ"){const v=f*_,M=f*S,E=p*_,w=p*S;n[0]=m*_,n[4]=-m*S,n[8]=h,n[1]=M+E*h,n[5]=v-w*h,n[9]=-p*m,n[2]=w-v*h,n[6]=E+M*h,n[10]=f*m}else if(e.order==="YXZ"){const v=m*_,M=m*S,E=h*_,w=h*S;n[0]=v+w*p,n[4]=E*p-M,n[8]=f*h,n[1]=f*S,n[5]=f*_,n[9]=-p,n[2]=M*p-E,n[6]=w+v*p,n[10]=f*m}else if(e.order==="ZXY"){const v=m*_,M=m*S,E=h*_,w=h*S;n[0]=v-w*p,n[4]=-f*S,n[8]=E+M*p,n[1]=M+E*p,n[5]=f*_,n[9]=w-v*p,n[2]=-f*h,n[6]=p,n[10]=f*m}else if(e.order==="ZYX"){const v=f*_,M=f*S,E=p*_,w=p*S;n[0]=m*_,n[4]=E*h-M,n[8]=v*h+w,n[1]=m*S,n[5]=w*h+v,n[9]=M*h-E,n[2]=-h,n[6]=p*m,n[10]=f*m}else if(e.order==="YZX"){const v=f*m,M=f*h,E=p*m,w=p*h;n[0]=m*_,n[4]=w-v*S,n[8]=E*S+M,n[1]=S,n[5]=f*_,n[9]=-p*_,n[2]=-h*_,n[6]=M*S+E,n[10]=v-w*S}else if(e.order==="XZY"){const v=f*m,M=f*h,E=p*m,w=p*h;n[0]=m*_,n[4]=-S,n[8]=h*_,n[1]=v*S+w,n[5]=f*_,n[9]=M*S-E,n[2]=E*S-M,n[6]=p*_,n[10]=w*S+v}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(BE,e,FE)}lookAt(e,n,s){const l=this.elements;return vi.subVectors(e,n),vi.lengthSq()===0&&(vi.z=1),vi.normalize(),vs.crossVectors(s,vi),vs.lengthSq()===0&&(Math.abs(s.z)===1?vi.x+=1e-4:vi.z+=1e-4,vi.normalize(),vs.crossVectors(s,vi)),vs.normalize(),qc.crossVectors(vi,vs),l[0]=vs.x,l[4]=qc.x,l[8]=vi.x,l[1]=vs.y,l[5]=qc.y,l[9]=vi.y,l[2]=vs.z,l[6]=qc.z,l[10]=vi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const s=e.elements,l=n.elements,c=this.elements,f=s[0],p=s[4],m=s[8],h=s[12],_=s[1],S=s[5],v=s[9],M=s[13],E=s[2],w=s[6],y=s[10],x=s[14],P=s[3],L=s[7],R=s[11],I=s[15],O=l[0],U=l[4],A=l[8],N=l[12],k=l[1],V=l[5],Q=l[9],fe=l[13],pe=l[2],J=l[6],G=l[10],j=l[14],se=l[3],Se=l[7],xe=l[11],z=l[15];return c[0]=f*O+p*k+m*pe+h*se,c[4]=f*U+p*V+m*J+h*Se,c[8]=f*A+p*Q+m*G+h*xe,c[12]=f*N+p*fe+m*j+h*z,c[1]=_*O+S*k+v*pe+M*se,c[5]=_*U+S*V+v*J+M*Se,c[9]=_*A+S*Q+v*G+M*xe,c[13]=_*N+S*fe+v*j+M*z,c[2]=E*O+w*k+y*pe+x*se,c[6]=E*U+w*V+y*J+x*Se,c[10]=E*A+w*Q+y*G+x*xe,c[14]=E*N+w*fe+y*j+x*z,c[3]=P*O+L*k+R*pe+I*se,c[7]=P*U+L*V+R*J+I*Se,c[11]=P*A+L*Q+R*G+I*xe,c[15]=P*N+L*fe+R*j+I*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],s=e[4],l=e[8],c=e[12],f=e[1],p=e[5],m=e[9],h=e[13],_=e[2],S=e[6],v=e[10],M=e[14],E=e[3],w=e[7],y=e[11],x=e[15],P=m*M-h*v,L=p*M-h*S,R=p*v-m*S,I=f*M-h*_,O=f*v-m*_,U=f*S-p*_;return n*(w*P-y*L+x*R)-s*(E*P-y*I+x*O)+l*(E*L-w*I+x*U)-c*(E*R-w*O+y*U)}determinantAffine(){const e=this.elements,n=e[0],s=e[4],l=e[8],c=e[1],f=e[5],p=e[9],m=e[2],h=e[6],_=e[10];return n*(f*_-p*h)-s*(c*_-p*m)+l*(c*h-f*m)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,s){const l=this.elements;return e.isVector3?(l[12]=e.x,l[13]=e.y,l[14]=e.z):(l[12]=e,l[13]=n,l[14]=s),this}invert(){const e=this.elements,n=e[0],s=e[1],l=e[2],c=e[3],f=e[4],p=e[5],m=e[6],h=e[7],_=e[8],S=e[9],v=e[10],M=e[11],E=e[12],w=e[13],y=e[14],x=e[15],P=n*p-s*f,L=n*m-l*f,R=n*h-c*f,I=s*m-l*p,O=s*h-c*p,U=l*h-c*m,A=_*w-S*E,N=_*y-v*E,k=_*x-M*E,V=S*y-v*w,Q=S*x-M*w,fe=v*x-M*y,pe=P*fe-L*Q+R*V+I*k-O*N+U*A;if(pe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const J=1/pe;return e[0]=(p*fe-m*Q+h*V)*J,e[1]=(l*Q-s*fe-c*V)*J,e[2]=(w*U-y*O+x*I)*J,e[3]=(v*O-S*U-M*I)*J,e[4]=(m*k-f*fe-h*N)*J,e[5]=(n*fe-l*k+c*N)*J,e[6]=(y*R-E*U-x*L)*J,e[7]=(_*U-v*R+M*L)*J,e[8]=(f*Q-p*k+h*A)*J,e[9]=(s*k-n*Q-c*A)*J,e[10]=(E*O-w*R+x*P)*J,e[11]=(S*R-_*O-M*P)*J,e[12]=(p*N-f*V-m*A)*J,e[13]=(n*V-s*N+l*A)*J,e[14]=(w*L-E*I-y*P)*J,e[15]=(_*I-S*L+v*P)*J,this}scale(e){const n=this.elements,s=e.x,l=e.y,c=e.z;return n[0]*=s,n[4]*=l,n[8]*=c,n[1]*=s,n[5]*=l,n[9]*=c,n[2]*=s,n[6]*=l,n[10]*=c,n[3]*=s,n[7]*=l,n[11]*=c,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],l=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,s,l))}makeTranslation(e,n,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,s,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,n,-s,0,0,s,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),s=Math.sin(e);return this.set(n,0,s,0,0,1,0,0,-s,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),s=Math.sin(e);return this.set(n,-s,0,0,s,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const s=Math.cos(n),l=Math.sin(n),c=1-s,f=e.x,p=e.y,m=e.z,h=c*f,_=c*p;return this.set(h*f+s,h*p-l*m,h*m+l*p,0,h*p+l*m,_*p+s,_*m-l*f,0,h*m-l*p,_*m+l*f,c*m*m+s,0,0,0,0,1),this}makeScale(e,n,s){return this.set(e,0,0,0,0,n,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,n,s,l,c,f){return this.set(1,s,c,0,e,1,f,0,n,l,1,0,0,0,0,1),this}compose(e,n,s){const l=this.elements,c=n._x,f=n._y,p=n._z,m=n._w,h=c+c,_=f+f,S=p+p,v=c*h,M=c*_,E=c*S,w=f*_,y=f*S,x=p*S,P=m*h,L=m*_,R=m*S,I=s.x,O=s.y,U=s.z;return l[0]=(1-(w+x))*I,l[1]=(M+R)*I,l[2]=(E-L)*I,l[3]=0,l[4]=(M-R)*O,l[5]=(1-(v+x))*O,l[6]=(y+P)*O,l[7]=0,l[8]=(E+L)*U,l[9]=(y-P)*U,l[10]=(1-(v+w))*U,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this}decompose(e,n,s){const l=this.elements;e.x=l[12],e.y=l[13],e.z=l[14];const c=this.determinantAffine();if(c===0)return s.set(1,1,1),n.identity(),this;let f=Yr.set(l[0],l[1],l[2]).length();const p=Yr.set(l[4],l[5],l[6]).length(),m=Yr.set(l[8],l[9],l[10]).length();c<0&&(f=-f),ki.copy(this);const h=1/f,_=1/p,S=1/m;return ki.elements[0]*=h,ki.elements[1]*=h,ki.elements[2]*=h,ki.elements[4]*=_,ki.elements[5]*=_,ki.elements[6]*=_,ki.elements[8]*=S,ki.elements[9]*=S,ki.elements[10]*=S,n.setFromRotationMatrix(ki),s.x=f,s.y=p,s.z=m,this}makePerspective(e,n,s,l,c,f,p=la,m=!1){const h=this.elements,_=2*c/(n-e),S=2*c/(s-l),v=(n+e)/(n-e),M=(s+l)/(s-l);let E,w;if(m)E=c/(f-c),w=f*c/(f-c);else if(p===la)E=-(f+c)/(f-c),w=-2*f*c/(f-c);else if(p===Ll)E=-f/(f-c),w=-f*c/(f-c);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+p);return h[0]=_,h[4]=0,h[8]=v,h[12]=0,h[1]=0,h[5]=S,h[9]=M,h[13]=0,h[2]=0,h[6]=0,h[10]=E,h[14]=w,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,n,s,l,c,f,p=la,m=!1){const h=this.elements,_=2/(n-e),S=2/(s-l),v=-(n+e)/(n-e),M=-(s+l)/(s-l);let E,w;if(m)E=1/(f-c),w=f/(f-c);else if(p===la)E=-2/(f-c),w=-(f+c)/(f-c);else if(p===Ll)E=-1/(f-c),w=-c/(f-c);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+p);return h[0]=_,h[4]=0,h[8]=0,h[12]=v,h[1]=0,h[5]=S,h[9]=0,h[13]=M,h[2]=0,h[6]=0,h[10]=E,h[14]=w,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const n=this.elements,s=e.elements;for(let l=0;l<16;l++)if(n[l]!==s[l])return!1;return!0}fromArray(e,n=0){for(let s=0;s<16;s++)this.elements[s]=e[s+n];return this}toArray(e=[],n=0){const s=this.elements;return e[n]=s[0],e[n+1]=s[1],e[n+2]=s[2],e[n+3]=s[3],e[n+4]=s[4],e[n+5]=s[5],e[n+6]=s[6],e[n+7]=s[7],e[n+8]=s[8],e[n+9]=s[9],e[n+10]=s[10],e[n+11]=s[11],e[n+12]=s[12],e[n+13]=s[13],e[n+14]=s[14],e[n+15]=s[15],e}};zu.prototype.isMatrix4=!0;let cn=zu;const Yr=new re,ki=new cn,BE=new re(0,0,0),FE=new re(1,1,1),vs=new re,qc=new re,vi=new re,Rv=new cn,Dv=new ws;class Rs{constructor(e=0,n=0,s=0,l=Rs.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=s,this._order=l}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,s,l=this._order){return this._x=e,this._y=n,this._z=s,this._order=l,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,s=!0){const l=e.elements,c=l[0],f=l[4],p=l[8],m=l[1],h=l[5],_=l[9],S=l[2],v=l[6],M=l[10];switch(n){case"XYZ":this._y=Math.asin(Ot(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(-_,M),this._z=Math.atan2(-f,c)):(this._x=Math.atan2(v,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Ot(_,-1,1)),Math.abs(_)<.9999999?(this._y=Math.atan2(p,M),this._z=Math.atan2(m,h)):(this._y=Math.atan2(-S,c),this._z=0);break;case"ZXY":this._x=Math.asin(Ot(v,-1,1)),Math.abs(v)<.9999999?(this._y=Math.atan2(-S,M),this._z=Math.atan2(-f,h)):(this._y=0,this._z=Math.atan2(m,c));break;case"ZYX":this._y=Math.asin(-Ot(S,-1,1)),Math.abs(S)<.9999999?(this._x=Math.atan2(v,M),this._z=Math.atan2(m,c)):(this._x=0,this._z=Math.atan2(-f,h));break;case"YZX":this._z=Math.asin(Ot(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(-_,h),this._y=Math.atan2(-S,c)):(this._x=0,this._y=Math.atan2(p,M));break;case"XZY":this._z=Math.asin(-Ot(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(v,h),this._y=Math.atan2(p,c)):(this._x=Math.atan2(-_,M),this._y=0);break;default:mt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,s){return Rv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Rv,n,s)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return Dv.setFromEuler(this),this.setFromQuaternion(Dv,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Rs.DEFAULT_ORDER="XYZ";class gy{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let zE=0;const Nv=new re,Zr=new ws,Oa=new cn,Yc=new re,gl=new re,HE=new re,GE=new ws,Uv=new re(1,0,0),Lv=new re(0,1,0),Ov=new re(0,0,1),Pv={type:"added"},VE={type:"removed"},Kr={type:"childadded",child:null},hh={type:"childremoved",child:null};class Nn extends Ns{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:zE++}),this.uuid=Bl(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Nn.DEFAULT_UP.clone();const e=new re,n=new Rs,s=new ws,l=new re(1,1,1);function c(){s.setFromEuler(n,!1)}function f(){n.setFromQuaternion(s,void 0,!1)}n._onChange(c),s._onChange(f),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:l},modelViewMatrix:{value:new cn},normalMatrix:{value:new bt}}),this.matrix=new cn,this.matrixWorld=new cn,this.matrixAutoUpdate=Nn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Nn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gy,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Zr.setFromAxisAngle(e,n),this.quaternion.multiply(Zr),this}rotateOnWorldAxis(e,n){return Zr.setFromAxisAngle(e,n),this.quaternion.premultiply(Zr),this}rotateX(e){return this.rotateOnAxis(Uv,e)}rotateY(e){return this.rotateOnAxis(Lv,e)}rotateZ(e){return this.rotateOnAxis(Ov,e)}translateOnAxis(e,n){return Nv.copy(e).applyQuaternion(this.quaternion),this.position.add(Nv.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Uv,e)}translateY(e){return this.translateOnAxis(Lv,e)}translateZ(e){return this.translateOnAxis(Ov,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Oa.copy(this.matrixWorld).invert())}lookAt(e,n,s){e.isVector3?Yc.copy(e):Yc.set(e,n,s);const l=this.parent;this.updateWorldMatrix(!0,!1),gl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Oa.lookAt(gl,Yc,this.up):Oa.lookAt(Yc,gl,this.up),this.quaternion.setFromRotationMatrix(Oa),l&&(Oa.extractRotation(l.matrixWorld),Zr.setFromRotationMatrix(Oa),this.quaternion.premultiply(Zr.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Vt("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Pv),Kr.child=e,this.dispatchEvent(Kr),Kr.child=null):Vt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(VE),hh.child=e,this.dispatchEvent(hh),hh.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Oa.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Oa.multiply(e.parent.matrixWorld)),e.applyMatrix4(Oa),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pv),Kr.child=e,this.dispatchEvent(Kr),Kr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let s=0,l=this.children.length;s<l;s++){const f=this.children[s].getObjectByProperty(e,n);if(f!==void 0)return f}}getObjectsByProperty(e,n,s=[]){this[e]===n&&s.push(this);const l=this.children;for(let c=0,f=l.length;c<f;c++)l[c].getObjectsByProperty(e,n,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gl,e,HE),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gl,GE,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let s=0,l=n.length;s<l;s++)n[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let s=0,l=n.length;s<l;s++)n[s].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const n=e.x,s=e.y,l=e.z,c=this.matrix.elements;c[12]+=n-c[0]*n-c[4]*s-c[8]*l,c[13]+=s-c[1]*n-c[5]*s-c[9]*l,c[14]+=l-c[2]*n-c[6]*s-c[10]*l}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let s=0,l=n.length;s<l;s++)n[s].updateMatrixWorld(e)}updateWorldMatrix(e,n,s=!1){const l=this.parent;if(e===!0&&l!==null&&l.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||s)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,s=!0),n===!0){const c=this.children;for(let f=0,p=c.length;f<p;f++)c[f].updateWorldMatrix(!1,!0,s)}}toJSON(e){const n=e===void 0||typeof e=="string",s={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const l={};l.uuid=this.uuid,l.type=this.type,this.name!==""&&(l.name=this.name),this.castShadow===!0&&(l.castShadow=!0),this.receiveShadow===!0&&(l.receiveShadow=!0),this.visible===!1&&(l.visible=!1),this.frustumCulled===!1&&(l.frustumCulled=!1),this.renderOrder!==0&&(l.renderOrder=this.renderOrder),this.static!==!1&&(l.static=this.static),Object.keys(this.userData).length>0&&(l.userData=this.userData),l.layers=this.layers.mask,l.matrix=this.matrix.toArray(),l.up=this.up.toArray(),this.pivot!==null&&(l.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(l.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(l.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(l.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(l.type="InstancedMesh",l.count=this.count,l.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(l.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(l.type="BatchedMesh",l.perObjectFrustumCulled=this.perObjectFrustumCulled,l.sortObjects=this.sortObjects,l.drawRanges=this._drawRanges,l.reservedRanges=this._reservedRanges,l.geometryInfo=this._geometryInfo.map(p=>({...p,boundingBox:p.boundingBox?p.boundingBox.toJSON():void 0,boundingSphere:p.boundingSphere?p.boundingSphere.toJSON():void 0})),l.instanceInfo=this._instanceInfo.map(p=>({...p})),l.availableInstanceIds=this._availableInstanceIds.slice(),l.availableGeometryIds=this._availableGeometryIds.slice(),l.nextIndexStart=this._nextIndexStart,l.nextVertexStart=this._nextVertexStart,l.geometryCount=this._geometryCount,l.maxInstanceCount=this._maxInstanceCount,l.maxVertexCount=this._maxVertexCount,l.maxIndexCount=this._maxIndexCount,l.geometryInitialized=this._geometryInitialized,l.matricesTexture=this._matricesTexture.toJSON(e),l.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(l.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(l.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(l.boundingBox=this.boundingBox.toJSON()));function c(p,m){return p[m.uuid]===void 0&&(p[m.uuid]=m.toJSON(e)),m.uuid}if(this.isScene)this.background&&(this.background.isColor?l.background=this.background.toJSON():this.background.isTexture&&(l.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(l.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){l.geometry=c(e.geometries,this.geometry);const p=this.geometry.parameters;if(p!==void 0&&p.shapes!==void 0){const m=p.shapes;if(Array.isArray(m))for(let h=0,_=m.length;h<_;h++){const S=m[h];c(e.shapes,S)}else c(e.shapes,m)}}if(this.isSkinnedMesh&&(l.bindMode=this.bindMode,l.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(c(e.skeletons,this.skeleton),l.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const p=[];for(let m=0,h=this.material.length;m<h;m++)p.push(c(e.materials,this.material[m]));l.material=p}else l.material=c(e.materials,this.material);if(this.children.length>0){l.children=[];for(let p=0;p<this.children.length;p++)l.children.push(this.children[p].toJSON(e).object)}if(this.animations.length>0){l.animations=[];for(let p=0;p<this.animations.length;p++){const m=this.animations[p];l.animations.push(c(e.animations,m))}}if(n){const p=f(e.geometries),m=f(e.materials),h=f(e.textures),_=f(e.images),S=f(e.shapes),v=f(e.skeletons),M=f(e.animations),E=f(e.nodes);p.length>0&&(s.geometries=p),m.length>0&&(s.materials=m),h.length>0&&(s.textures=h),_.length>0&&(s.images=_),S.length>0&&(s.shapes=S),v.length>0&&(s.skeletons=v),M.length>0&&(s.animations=M),E.length>0&&(s.nodes=E)}return s.object=l,s;function f(p){const m=[];for(const h in p){const _=p[h];delete _.metadata,m.push(_)}return m}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let s=0;s<e.children.length;s++){const l=e.children[s];this.add(l.clone())}return this}}Nn.DEFAULT_UP=new re(0,1,0);Nn.DEFAULT_MATRIX_AUTO_UPDATE=!0;Nn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Zc extends Nn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const kE={type:"move"};class ph{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Zc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Zc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new re,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new re),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Zc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new re,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new re,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const s of e.hand.values())this._getHandJoint(n,s)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,s){let l=null,c=null,f=null;const p=this._targetRay,m=this._grip,h=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(h&&e.hand){f=!0;for(const w of e.hand.values()){const y=n.getJointPose(w,s),x=this._getHandJoint(h,w);y!==null&&(x.matrix.fromArray(y.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=y.radius),x.visible=y!==null}const _=h.joints["index-finger-tip"],S=h.joints["thumb-tip"],v=_.position.distanceTo(S.position),M=.02,E=.005;h.inputState.pinching&&v>M+E?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&v<=M-E&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else m!==null&&e.gripSpace&&(c=n.getPose(e.gripSpace,s),c!==null&&(m.matrix.fromArray(c.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,c.linearVelocity?(m.hasLinearVelocity=!0,m.linearVelocity.copy(c.linearVelocity)):m.hasLinearVelocity=!1,c.angularVelocity?(m.hasAngularVelocity=!0,m.angularVelocity.copy(c.angularVelocity)):m.hasAngularVelocity=!1,m.eventsEnabled&&m.dispatchEvent({type:"gripUpdated",data:e,target:this})));p!==null&&(l=n.getPose(e.targetRaySpace,s),l===null&&c!==null&&(l=c),l!==null&&(p.matrix.fromArray(l.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,l.linearVelocity?(p.hasLinearVelocity=!0,p.linearVelocity.copy(l.linearVelocity)):p.hasLinearVelocity=!1,l.angularVelocity?(p.hasAngularVelocity=!0,p.angularVelocity.copy(l.angularVelocity)):p.hasAngularVelocity=!1,this.dispatchEvent(kE)))}return p!==null&&(p.visible=l!==null),m!==null&&(m.visible=c!==null),h!==null&&(h.visible=f!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const s=new Zc;s.matrixAutoUpdate=!1,s.visible=!1,e.joints[n.jointName]=s,e.add(s)}return e.joints[n.jointName]}}const _y={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},xs={h:0,s:0,l:0},Kc={h:0,s:0,l:0};function mh(a,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?a+(e-a)*6*n:n<1/2?e:n<2/3?a+(e-a)*6*(2/3-n):a}class ot{constructor(e,n,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,s)}set(e,n,s){if(n===void 0&&s===void 0){const l=e;l&&l.isColor?this.copy(l):typeof l=="number"?this.setHex(l):typeof l=="string"&&this.setStyle(l)}else this.setRGB(e,n,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=yi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Gt.colorSpaceToWorking(this,n),this}setRGB(e,n,s,l=Gt.workingColorSpace){return this.r=e,this.g=n,this.b=s,Gt.colorSpaceToWorking(this,l),this}setHSL(e,n,s,l=Gt.workingColorSpace){if(e=RE(e,1),n=Ot(n,0,1),s=Ot(s,0,1),n===0)this.r=this.g=this.b=s;else{const c=s<=.5?s*(1+n):s+n-s*n,f=2*s-c;this.r=mh(f,c,e+1/3),this.g=mh(f,c,e),this.b=mh(f,c,e-1/3)}return Gt.colorSpaceToWorking(this,l),this}setStyle(e,n=yi){function s(c){c!==void 0&&parseFloat(c)<1&&mt("Color: Alpha component of "+e+" will be ignored.")}let l;if(l=/^(\w+)\(([^\)]*)\)/.exec(e)){let c;const f=l[1],p=l[2];switch(f){case"rgb":case"rgba":if(c=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(p))return s(c[4]),this.setRGB(Math.min(255,parseInt(c[1],10))/255,Math.min(255,parseInt(c[2],10))/255,Math.min(255,parseInt(c[3],10))/255,n);if(c=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(p))return s(c[4]),this.setRGB(Math.min(100,parseInt(c[1],10))/100,Math.min(100,parseInt(c[2],10))/100,Math.min(100,parseInt(c[3],10))/100,n);break;case"hsl":case"hsla":if(c=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(p))return s(c[4]),this.setHSL(parseFloat(c[1])/360,parseFloat(c[2])/100,parseFloat(c[3])/100,n);break;default:mt("Color: Unknown color model "+e)}}else if(l=/^\#([A-Fa-f\d]+)$/.exec(e)){const c=l[1],f=c.length;if(f===3)return this.setRGB(parseInt(c.charAt(0),16)/15,parseInt(c.charAt(1),16)/15,parseInt(c.charAt(2),16)/15,n);if(f===6)return this.setHex(parseInt(c,16),n);mt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=yi){const s=_y[e.toLowerCase()];return s!==void 0?this.setHex(s,n):mt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ja(e.r),this.g=ja(e.g),this.b=ja(e.b),this}copyLinearToSRGB(e){return this.r=mo(e.r),this.g=mo(e.g),this.b=mo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yi){return Gt.workingToColorSpace(qn.copy(this),e),Math.round(Ot(qn.r*255,0,255))*65536+Math.round(Ot(qn.g*255,0,255))*256+Math.round(Ot(qn.b*255,0,255))}getHexString(e=yi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Gt.workingColorSpace){Gt.workingToColorSpace(qn.copy(this),n);const s=qn.r,l=qn.g,c=qn.b,f=Math.max(s,l,c),p=Math.min(s,l,c);let m,h;const _=(p+f)/2;if(p===f)m=0,h=0;else{const S=f-p;switch(h=_<=.5?S/(f+p):S/(2-f-p),f){case s:m=(l-c)/S+(l<c?6:0);break;case l:m=(c-s)/S+2;break;case c:m=(s-l)/S+4;break}m/=6}return e.h=m,e.s=h,e.l=_,e}getRGB(e,n=Gt.workingColorSpace){return Gt.workingToColorSpace(qn.copy(this),n),e.r=qn.r,e.g=qn.g,e.b=qn.b,e}getStyle(e=yi){Gt.workingToColorSpace(qn.copy(this),e);const n=qn.r,s=qn.g,l=qn.b;return e!==yi?`color(${e} ${n.toFixed(3)} ${s.toFixed(3)} ${l.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(s*255)},${Math.round(l*255)})`}offsetHSL(e,n,s){return this.getHSL(xs),this.setHSL(xs.h+e,xs.s+n,xs.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,s){return this.r=e.r+(n.r-e.r)*s,this.g=e.g+(n.g-e.g)*s,this.b=e.b+(n.b-e.b)*s,this}lerpHSL(e,n){this.getHSL(xs),e.getHSL(Kc);const s=lh(xs.h,Kc.h,n),l=lh(xs.s,Kc.s,n),c=lh(xs.l,Kc.l,n);return this.setHSL(s,l,c),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,s=this.g,l=this.b,c=e.elements;return this.r=c[0]*n+c[3]*s+c[6]*l,this.g=c[1]*n+c[4]*s+c[7]*l,this.b=c[2]*n+c[5]*s+c[8]*l,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qn=new ot;ot.NAMES=_y;class jE extends Nn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Rs,this.environmentIntensity=1,this.environmentRotation=new Rs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}const ji=new re,Pa=new re,gh=new re,Ia=new re,$r=new re,Qr=new re,Iv=new re,_h=new re,vh=new re,xh=new re,yh=new gn,Sh=new gn,Mh=new gn;class Oi{constructor(e=new re,n=new re,s=new re){this.a=e,this.b=n,this.c=s}static getNormal(e,n,s,l){l.subVectors(s,n),ji.subVectors(e,n),l.cross(ji);const c=l.lengthSq();return c>0?l.multiplyScalar(1/Math.sqrt(c)):l.set(0,0,0)}static getBarycoord(e,n,s,l,c){ji.subVectors(l,n),Pa.subVectors(s,n),gh.subVectors(e,n);const f=ji.dot(ji),p=ji.dot(Pa),m=ji.dot(gh),h=Pa.dot(Pa),_=Pa.dot(gh),S=f*h-p*p;if(S===0)return c.set(0,0,0),null;const v=1/S,M=(h*m-p*_)*v,E=(f*_-p*m)*v;return c.set(1-M-E,E,M)}static containsPoint(e,n,s,l){return this.getBarycoord(e,n,s,l,Ia)===null?!1:Ia.x>=0&&Ia.y>=0&&Ia.x+Ia.y<=1}static getInterpolation(e,n,s,l,c,f,p,m){return this.getBarycoord(e,n,s,l,Ia)===null?(m.x=0,m.y=0,"z"in m&&(m.z=0),"w"in m&&(m.w=0),null):(m.setScalar(0),m.addScaledVector(c,Ia.x),m.addScaledVector(f,Ia.y),m.addScaledVector(p,Ia.z),m)}static getInterpolatedAttribute(e,n,s,l,c,f){return yh.setScalar(0),Sh.setScalar(0),Mh.setScalar(0),yh.fromBufferAttribute(e,n),Sh.fromBufferAttribute(e,s),Mh.fromBufferAttribute(e,l),f.setScalar(0),f.addScaledVector(yh,c.x),f.addScaledVector(Sh,c.y),f.addScaledVector(Mh,c.z),f}static isFrontFacing(e,n,s,l){return ji.subVectors(s,n),Pa.subVectors(e,n),ji.cross(Pa).dot(l)<0}set(e,n,s){return this.a.copy(e),this.b.copy(n),this.c.copy(s),this}setFromPointsAndIndices(e,n,s,l){return this.a.copy(e[n]),this.b.copy(e[s]),this.c.copy(e[l]),this}setFromAttributeAndIndices(e,n,s,l){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,l),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ji.subVectors(this.c,this.b),Pa.subVectors(this.a,this.b),ji.cross(Pa).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Oi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Oi.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,s,l,c){return Oi.getInterpolation(e,this.a,this.b,this.c,n,s,l,c)}containsPoint(e){return Oi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Oi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const s=this.a,l=this.b,c=this.c;let f,p;$r.subVectors(l,s),Qr.subVectors(c,s),_h.subVectors(e,s);const m=$r.dot(_h),h=Qr.dot(_h);if(m<=0&&h<=0)return n.copy(s);vh.subVectors(e,l);const _=$r.dot(vh),S=Qr.dot(vh);if(_>=0&&S<=_)return n.copy(l);const v=m*S-_*h;if(v<=0&&m>=0&&_<=0)return f=m/(m-_),n.copy(s).addScaledVector($r,f);xh.subVectors(e,c);const M=$r.dot(xh),E=Qr.dot(xh);if(E>=0&&M<=E)return n.copy(c);const w=M*h-m*E;if(w<=0&&h>=0&&E<=0)return p=h/(h-E),n.copy(s).addScaledVector(Qr,p);const y=_*E-M*S;if(y<=0&&S-_>=0&&M-E>=0)return Iv.subVectors(c,l),p=(S-_)/(S-_+(M-E)),n.copy(l).addScaledVector(Iv,p);const x=1/(y+w+v);return f=w*x,p=v*x,n.copy(s).addScaledVector($r,f).addScaledVector(Qr,p)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class dr{constructor(e=new re(1/0,1/0,1/0),n=new re(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,s=e.length;n<s;n+=3)this.expandByPoint(Xi.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,s=e.count;n<s;n++)this.expandByPoint(Xi.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,s=e.length;n<s;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const s=Xi.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const s=e.geometry;if(s!==void 0){const c=s.getAttribute("position");if(n===!0&&c!==void 0&&e.isInstancedMesh!==!0)for(let f=0,p=c.count;f<p;f++)e.isMesh===!0?e.getVertexPosition(f,Xi):Xi.fromBufferAttribute(c,f),Xi.applyMatrix4(e.matrixWorld),this.expandByPoint(Xi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),$c.copy(e.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),$c.copy(s.boundingBox)),$c.applyMatrix4(e.matrixWorld),this.union($c)}const l=e.children;for(let c=0,f=l.length;c<f;c++)this.expandByObject(l[c],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Xi),Xi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,s;return e.normal.x>0?(n=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),n<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_l),Qc.subVectors(this.max,_l),Jr.subVectors(e.a,_l),eo.subVectors(e.b,_l),to.subVectors(e.c,_l),ys.subVectors(eo,Jr),Ss.subVectors(to,eo),Ks.subVectors(Jr,to);let n=[0,-ys.z,ys.y,0,-Ss.z,Ss.y,0,-Ks.z,Ks.y,ys.z,0,-ys.x,Ss.z,0,-Ss.x,Ks.z,0,-Ks.x,-ys.y,ys.x,0,-Ss.y,Ss.x,0,-Ks.y,Ks.x,0];return!bh(n,Jr,eo,to,Qc)||(n=[1,0,0,0,1,0,0,0,1],!bh(n,Jr,eo,to,Qc))?!1:(Jc.crossVectors(ys,Ss),n=[Jc.x,Jc.y,Jc.z],bh(n,Jr,eo,to,Qc))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ba[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ba[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ba[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ba[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ba[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ba[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ba[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ba[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ba),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Ba=[new re,new re,new re,new re,new re,new re,new re,new re],Xi=new re,$c=new dr,Jr=new re,eo=new re,to=new re,ys=new re,Ss=new re,Ks=new re,_l=new re,Qc=new re,Jc=new re,$s=new re;function bh(a,e,n,s,l){for(let c=0,f=a.length-3;c<=f;c+=3){$s.fromArray(a,c);const p=l.x*Math.abs($s.x)+l.y*Math.abs($s.y)+l.z*Math.abs($s.z),m=e.dot($s),h=n.dot($s),_=s.dot($s);if(Math.max(-Math.max(m,h,_),Math.min(m,h,_))>p)return!1}return!0}const Cn=new re,eu=new xt;let XE=0;class Zi extends Ns{constructor(e,n,s=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:XE++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=s,this.usage=Mv,this.updateRanges=[],this.gpuType=qi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,s){e*=this.itemSize,s*=n.itemSize;for(let l=0,c=this.itemSize;l<c;l++)this.array[e+l]=n.array[s+l];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,s=this.count;n<s;n++)eu.fromBufferAttribute(this,n),eu.applyMatrix3(e),this.setXY(n,eu.x,eu.y);else if(this.itemSize===3)for(let n=0,s=this.count;n<s;n++)Cn.fromBufferAttribute(this,n),Cn.applyMatrix3(e),this.setXYZ(n,Cn.x,Cn.y,Cn.z);return this}applyMatrix4(e){for(let n=0,s=this.count;n<s;n++)Cn.fromBufferAttribute(this,n),Cn.applyMatrix4(e),this.setXYZ(n,Cn.x,Cn.y,Cn.z);return this}applyNormalMatrix(e){for(let n=0,s=this.count;n<s;n++)Cn.fromBufferAttribute(this,n),Cn.applyNormalMatrix(e),this.setXYZ(n,Cn.x,Cn.y,Cn.z);return this}transformDirection(e){for(let n=0,s=this.count;n<s;n++)Cn.fromBufferAttribute(this,n),Cn.transformDirection(e),this.setXYZ(n,Cn.x,Cn.y,Cn.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let s=this.array[e*this.itemSize+n];return this.normalized&&(s=ml(s,this.array)),s}setComponent(e,n,s){return this.normalized&&(s=ai(s,this.array)),this.array[e*this.itemSize+n]=s,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ml(n,this.array)),n}setX(e,n){return this.normalized&&(n=ai(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ml(n,this.array)),n}setY(e,n){return this.normalized&&(n=ai(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=ml(n,this.array)),n}setZ(e,n){return this.normalized&&(n=ai(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=ml(n,this.array)),n}setW(e,n){return this.normalized&&(n=ai(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,s){return e*=this.itemSize,this.normalized&&(n=ai(n,this.array),s=ai(s,this.array)),this.array[e+0]=n,this.array[e+1]=s,this}setXYZ(e,n,s,l){return e*=this.itemSize,this.normalized&&(n=ai(n,this.array),s=ai(s,this.array),l=ai(l,this.array)),this.array[e+0]=n,this.array[e+1]=s,this.array[e+2]=l,this}setXYZW(e,n,s,l,c){return e*=this.itemSize,this.normalized&&(n=ai(n,this.array),s=ai(s,this.array),l=ai(l,this.array),c=ai(c,this.array)),this.array[e+0]=n,this.array[e+1]=s,this.array[e+2]=l,this.array[e+3]=c,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Mv&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class vy extends Zi{constructor(e,n,s){super(new Uint16Array(e),n,s)}}class xy extends Zi{constructor(e,n,s){super(new Uint32Array(e),n,s)}}class oi extends Zi{constructor(e,n,s){super(new Float32Array(e),n,s)}}const WE=new dr,vl=new re,Eh=new re;class bo{constructor(e=new re,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const s=this.center;n!==void 0?s.copy(n):WE.setFromPoints(e).getCenter(s);let l=0;for(let c=0,f=e.length;c<f;c++)l=Math.max(l,s.distanceToSquared(e[c]));return this.radius=Math.sqrt(l),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const s=this.center.distanceToSquared(e);return n.copy(e),s>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vl.subVectors(e,this.center);const n=vl.lengthSq();if(n>this.radius*this.radius){const s=Math.sqrt(n),l=(s-this.radius)*.5;this.center.addScaledVector(vl,l/s),this.radius+=l}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Eh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vl.copy(e.center).add(Eh)),this.expandByPoint(vl.copy(e.center).sub(Eh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let qE=0;const Di=new cn,Th=new Nn,no=new re,xi=new dr,xl=new dr,Pn=new re;class Pi extends Ns{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qE++}),this.uuid=Bl(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(TE(e)?xy:vy)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,s=0){this.groups.push({start:e,count:n,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const c=new bt().getNormalMatrix(e);s.applyNormalMatrix(c),s.needsUpdate=!0}const l=this.attributes.tangent;return l!==void 0&&(l.transformDirection(e),l.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Di.makeRotationFromQuaternion(e),this.applyMatrix4(Di),this}rotateX(e){return Di.makeRotationX(e),this.applyMatrix4(Di),this}rotateY(e){return Di.makeRotationY(e),this.applyMatrix4(Di),this}rotateZ(e){return Di.makeRotationZ(e),this.applyMatrix4(Di),this}translate(e,n,s){return Di.makeTranslation(e,n,s),this.applyMatrix4(Di),this}scale(e,n,s){return Di.makeScale(e,n,s),this.applyMatrix4(Di),this}lookAt(e){return Th.lookAt(e),Th.updateMatrix(),this.applyMatrix4(Th.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(no).negate(),this.translate(no.x,no.y,no.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const s=[];for(let l=0,c=e.length;l<c;l++){const f=e[l];s.push(f.x,f.y,f.z||0)}this.setAttribute("position",new oi(s,3))}else{const s=Math.min(e.length,n.count);for(let l=0;l<s;l++){const c=e[l];n.setXYZ(l,c.x,c.y,c.z||0)}e.length>n.count&&mt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new dr);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new re(-1/0,-1/0,-1/0),new re(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let s=0,l=n.length;s<l;s++){const c=n[s];xi.setFromBufferAttribute(c),this.morphTargetsRelative?(Pn.addVectors(this.boundingBox.min,xi.min),this.boundingBox.expandByPoint(Pn),Pn.addVectors(this.boundingBox.max,xi.max),this.boundingBox.expandByPoint(Pn)):(this.boundingBox.expandByPoint(xi.min),this.boundingBox.expandByPoint(xi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new bo);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new re,1/0);return}if(e){const s=this.boundingSphere.center;if(xi.setFromBufferAttribute(e),n)for(let c=0,f=n.length;c<f;c++){const p=n[c];xl.setFromBufferAttribute(p),this.morphTargetsRelative?(Pn.addVectors(xi.min,xl.min),xi.expandByPoint(Pn),Pn.addVectors(xi.max,xl.max),xi.expandByPoint(Pn)):(xi.expandByPoint(xl.min),xi.expandByPoint(xl.max))}xi.getCenter(s);let l=0;for(let c=0,f=e.count;c<f;c++)Pn.fromBufferAttribute(e,c),l=Math.max(l,s.distanceToSquared(Pn));if(n)for(let c=0,f=n.length;c<f;c++){const p=n[c],m=this.morphTargetsRelative;for(let h=0,_=p.count;h<_;h++)Pn.fromBufferAttribute(p,h),m&&(no.fromBufferAttribute(e,h),Pn.add(no)),l=Math.max(l,s.distanceToSquared(Pn))}this.boundingSphere.radius=Math.sqrt(l),isNaN(this.boundingSphere.radius)&&Vt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Vt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=n.position,l=n.normal,c=n.uv;let f=this.getAttribute("tangent");(f===void 0||f.count!==s.count)&&(f=new Zi(new Float32Array(4*s.count),4),this.setAttribute("tangent",f));const p=[],m=[];for(let A=0;A<s.count;A++)p[A]=new re,m[A]=new re;const h=new re,_=new re,S=new re,v=new xt,M=new xt,E=new xt,w=new re,y=new re;function x(A,N,k){h.fromBufferAttribute(s,A),_.fromBufferAttribute(s,N),S.fromBufferAttribute(s,k),v.fromBufferAttribute(c,A),M.fromBufferAttribute(c,N),E.fromBufferAttribute(c,k),_.sub(h),S.sub(h),M.sub(v),E.sub(v);const V=1/(M.x*E.y-E.x*M.y);isFinite(V)&&(w.copy(_).multiplyScalar(E.y).addScaledVector(S,-M.y).multiplyScalar(V),y.copy(S).multiplyScalar(M.x).addScaledVector(_,-E.x).multiplyScalar(V),p[A].add(w),p[N].add(w),p[k].add(w),m[A].add(y),m[N].add(y),m[k].add(y))}let P=this.groups;P.length===0&&(P=[{start:0,count:e.count}]);for(let A=0,N=P.length;A<N;++A){const k=P[A],V=k.start,Q=k.count;for(let fe=V,pe=V+Q;fe<pe;fe+=3)x(e.getX(fe+0),e.getX(fe+1),e.getX(fe+2))}const L=new re,R=new re,I=new re,O=new re;function U(A){I.fromBufferAttribute(l,A),O.copy(I);const N=p[A];L.copy(N),L.sub(I.multiplyScalar(I.dot(N))).normalize(),R.crossVectors(O,N);const V=R.dot(m[A])<0?-1:1;f.setXYZW(A,L.x,L.y,L.z,V)}for(let A=0,N=P.length;A<N;++A){const k=P[A],V=k.start,Q=k.count;for(let fe=V,pe=V+Q;fe<pe;fe+=3)U(e.getX(fe+0)),U(e.getX(fe+1)),U(e.getX(fe+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let s=this.getAttribute("normal");if(s===void 0||s.count!==n.count)s=new Zi(new Float32Array(n.count*3),3),this.setAttribute("normal",s);else for(let v=0,M=s.count;v<M;v++)s.setXYZ(v,0,0,0);const l=new re,c=new re,f=new re,p=new re,m=new re,h=new re,_=new re,S=new re;if(e)for(let v=0,M=e.count;v<M;v+=3){const E=e.getX(v+0),w=e.getX(v+1),y=e.getX(v+2);l.fromBufferAttribute(n,E),c.fromBufferAttribute(n,w),f.fromBufferAttribute(n,y),_.subVectors(f,c),S.subVectors(l,c),_.cross(S),p.fromBufferAttribute(s,E),m.fromBufferAttribute(s,w),h.fromBufferAttribute(s,y),p.add(_),m.add(_),h.add(_),s.setXYZ(E,p.x,p.y,p.z),s.setXYZ(w,m.x,m.y,m.z),s.setXYZ(y,h.x,h.y,h.z)}else for(let v=0,M=n.count;v<M;v+=3)l.fromBufferAttribute(n,v+0),c.fromBufferAttribute(n,v+1),f.fromBufferAttribute(n,v+2),_.subVectors(f,c),S.subVectors(l,c),_.cross(S),s.setXYZ(v+0,_.x,_.y,_.z),s.setXYZ(v+1,_.x,_.y,_.z),s.setXYZ(v+2,_.x,_.y,_.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,s=e.count;n<s;n++)Pn.fromBufferAttribute(e,n),Pn.normalize(),e.setXYZ(n,Pn.x,Pn.y,Pn.z)}toNonIndexed(){function e(p,m){const h=p.array,_=p.itemSize,S=p.normalized,v=new h.constructor(m.length*_);let M=0,E=0;for(let w=0,y=m.length;w<y;w++){p.isInterleavedBufferAttribute?M=m[w]*p.data.stride+p.offset:M=m[w]*_;for(let x=0;x<_;x++)v[E++]=h[M++]}return new Zi(v,_,S)}if(this.index===null)return mt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Pi,s=this.index.array,l=this.attributes;for(const p in l){const m=l[p],h=e(m,s);n.setAttribute(p,h)}const c=this.morphAttributes;for(const p in c){const m=[],h=c[p];for(let _=0,S=h.length;_<S;_++){const v=h[_],M=e(v,s);m.push(M)}n.morphAttributes[p]=m}n.morphTargetsRelative=this.morphTargetsRelative;const f=this.groups;for(let p=0,m=f.length;p<m;p++){const h=f[p];n.addGroup(h.start,h.count,h.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const m=this.parameters;for(const h in m)m[h]!==void 0&&(e[h]=m[h]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const s=this.attributes;for(const m in s){const h=s[m];e.data.attributes[m]=h.toJSON(e.data)}const l={};let c=!1;for(const m in this.morphAttributes){const h=this.morphAttributes[m],_=[];for(let S=0,v=h.length;S<v;S++){const M=h[S];_.push(M.toJSON(e.data))}_.length>0&&(l[m]=_,c=!0)}c&&(e.data.morphAttributes=l,e.data.morphTargetsRelative=this.morphTargetsRelative);const f=this.groups;f.length>0&&(e.data.groups=JSON.parse(JSON.stringify(f)));const p=this.boundingSphere;return p!==null&&(e.data.boundingSphere=p.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const s=e.index;s!==null&&this.setIndex(s.clone());const l=e.attributes;for(const h in l){const _=l[h];this.setAttribute(h,_.clone(n))}const c=e.morphAttributes;for(const h in c){const _=[],S=c[h];for(let v=0,M=S.length;v<M;v++)_.push(S[v].clone(n));this.morphAttributes[h]=_}this.morphTargetsRelative=e.morphTargetsRelative;const f=e.groups;for(let h=0,_=f.length;h<_;h++){const S=f[h];this.addGroup(S.start,S.count,S.materialIndex)}const p=e.boundingBox;p!==null&&(this.boundingBox=p.clone());const m=e.boundingSphere;return m!==null&&(this.boundingSphere=m.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}let YE=0;class Eo extends Ns{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:YE++}),this.uuid=Bl(),this.name="",this.type="Material",this.blending=ho,this.side=Cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=qh,this.blendDst=Yh,this.blendEquation=er,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ot(0,0,0),this.blendAlpha=0,this.depthFunc=vo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Sv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wr,this.stencilZFail=Wr,this.stencilZPass=Wr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const s=e[n];if(s===void 0){mt(`Material: parameter '${n}' has value of undefined.`);continue}const l=this[n];if(l===void 0){mt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}l&&l.isColor?l.set(s):l&&l.isVector2&&s&&s.isVector2||l&&l.isEuler&&s&&s.isEuler||l&&l.isVector3&&s&&s.isVector3?l.copy(s):this[n]=s}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==ho&&(s.blending=this.blending),this.side!==Cs&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==qh&&(s.blendSrc=this.blendSrc),this.blendDst!==Yh&&(s.blendDst=this.blendDst),this.blendEquation!==er&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==vo&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Sv&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wr&&(s.stencilFail=this.stencilFail),this.stencilZFail!==Wr&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==Wr&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.allowOverride===!1&&(s.allowOverride=!1),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function l(c){const f=[];for(const p in c){const m=c[p];delete m.metadata,f.push(m)}return f}if(n){const c=l(e.textures),f=l(e.images);c.length>0&&(s.textures=c),f.length>0&&(s.images=f)}return s}fromJSON(e,n){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new ot().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=n[e.map]||null),e.matcap!==void 0&&(this.matcap=n[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=n[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=n[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=n[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),this.normalScale=new xt().fromArray(s)}return e.displacementMap!==void 0&&(this.displacementMap=n[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=n[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=n[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=n[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=n[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=n[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=n[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=n[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=n[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=n[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=n[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=n[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=n[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=n[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new xt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=n[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=n[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=n[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=n[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=n[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=n[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=n[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let s=null;if(n!==null){const l=n.length;s=new Array(l);for(let c=0;c!==l;++c)s[c]=n[c].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const Fa=new re,Ah=new re,tu=new re,Ms=new re,Ch=new re,nu=new re,wh=new re;class om{constructor(e=new re,n=new re(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Fa)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const s=n.dot(this.direction);return s<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Fa.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Fa.copy(this.origin).addScaledVector(this.direction,n),Fa.distanceToSquared(e))}distanceSqToSegment(e,n,s,l){Ah.copy(e).add(n).multiplyScalar(.5),tu.copy(n).sub(e).normalize(),Ms.copy(this.origin).sub(Ah);const c=e.distanceTo(n)*.5,f=-this.direction.dot(tu),p=Ms.dot(this.direction),m=-Ms.dot(tu),h=Ms.lengthSq(),_=Math.abs(1-f*f);let S,v,M,E;if(_>0)if(S=f*m-p,v=f*p-m,E=c*_,S>=0)if(v>=-E)if(v<=E){const w=1/_;S*=w,v*=w,M=S*(S+f*v+2*p)+v*(f*S+v+2*m)+h}else v=c,S=Math.max(0,-(f*v+p)),M=-S*S+v*(v+2*m)+h;else v=-c,S=Math.max(0,-(f*v+p)),M=-S*S+v*(v+2*m)+h;else v<=-E?(S=Math.max(0,-(-f*c+p)),v=S>0?-c:Math.min(Math.max(-c,-m),c),M=-S*S+v*(v+2*m)+h):v<=E?(S=0,v=Math.min(Math.max(-c,-m),c),M=v*(v+2*m)+h):(S=Math.max(0,-(f*c+p)),v=S>0?c:Math.min(Math.max(-c,-m),c),M=-S*S+v*(v+2*m)+h);else v=f>0?-c:c,S=Math.max(0,-(f*v+p)),M=-S*S+v*(v+2*m)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,S),l&&l.copy(Ah).addScaledVector(tu,v),M}intersectSphere(e,n){Fa.subVectors(e.center,this.origin);const s=Fa.dot(this.direction),l=Fa.dot(Fa)-s*s,c=e.radius*e.radius;if(l>c)return null;const f=Math.sqrt(c-l),p=s-f,m=s+f;return m<0?null:p<0?this.at(m,n):this.at(p,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/n;return s>=0?s:null}intersectPlane(e,n){const s=this.distanceToPlane(e);return s===null?null:this.at(s,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let s,l,c,f,p,m;const h=1/this.direction.x,_=1/this.direction.y,S=1/this.direction.z,v=this.origin;return h>=0?(s=(e.min.x-v.x)*h,l=(e.max.x-v.x)*h):(s=(e.max.x-v.x)*h,l=(e.min.x-v.x)*h),_>=0?(c=(e.min.y-v.y)*_,f=(e.max.y-v.y)*_):(c=(e.max.y-v.y)*_,f=(e.min.y-v.y)*_),s>f||c>l||((c>s||isNaN(s))&&(s=c),(f<l||isNaN(l))&&(l=f),S>=0?(p=(e.min.z-v.z)*S,m=(e.max.z-v.z)*S):(p=(e.max.z-v.z)*S,m=(e.min.z-v.z)*S),s>m||p>l)||((p>s||s!==s)&&(s=p),(m<l||l!==l)&&(l=m),l<0)?null:this.at(s>=0?s:l,n)}intersectsBox(e){return this.intersectBox(e,Fa)!==null}intersectTriangle(e,n,s,l,c){Ch.subVectors(n,e),nu.subVectors(s,e),wh.crossVectors(Ch,nu);let f=this.direction.dot(wh),p;if(f>0){if(l)return null;p=1}else if(f<0)p=-1,f=-f;else return null;Ms.subVectors(this.origin,e);const m=p*this.direction.dot(nu.crossVectors(Ms,nu));if(m<0)return null;const h=p*this.direction.dot(Ch.cross(Ms));if(h<0||m+h>f)return null;const _=-p*Ms.dot(wh);return _<0?null:this.at(_/f,c)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class lm extends Eo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ot(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rs,this.combine=Jx,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Bv=new cn,Qs=new om,iu=new bo,Fv=new re,au=new re,su=new re,ru=new re,Rh=new re,ou=new re,zv=new re,lu=new re;class $i extends Nn{constructor(e=new Pi,n=new lm){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,s=Object.keys(n);if(s.length>0){const l=n[s[0]];if(l!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let c=0,f=l.length;c<f;c++){const p=l[c].name||String(c);this.morphTargetInfluences.push(0),this.morphTargetDictionary[p]=c}}}}getVertexPosition(e,n){const s=this.geometry,l=s.attributes.position,c=s.morphAttributes.position,f=s.morphTargetsRelative;n.fromBufferAttribute(l,e);const p=this.morphTargetInfluences;if(c&&p){ou.set(0,0,0);for(let m=0,h=c.length;m<h;m++){const _=p[m],S=c[m];_!==0&&(Rh.fromBufferAttribute(S,e),f?ou.addScaledVector(Rh,_):ou.addScaledVector(Rh.sub(n),_))}n.add(ou)}return n}raycast(e,n){const s=this.geometry,l=this.material,c=this.matrixWorld;l!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),iu.copy(s.boundingSphere),iu.applyMatrix4(c),Qs.copy(e.ray).recast(e.near),!(iu.containsPoint(Qs.origin)===!1&&(Qs.intersectSphere(iu,Fv)===null||Qs.origin.distanceToSquared(Fv)>(e.far-e.near)**2))&&(Bv.copy(c).invert(),Qs.copy(e.ray).applyMatrix4(Bv),!(s.boundingBox!==null&&Qs.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(e,n,Qs)))}_computeIntersections(e,n,s){let l;const c=this.geometry,f=this.material,p=c.index,m=c.attributes.position,h=c.attributes.uv,_=c.attributes.uv1,S=c.attributes.normal,v=c.groups,M=c.drawRange;if(p!==null)if(Array.isArray(f))for(let E=0,w=v.length;E<w;E++){const y=v[E],x=f[y.materialIndex],P=Math.max(y.start,M.start),L=Math.min(p.count,Math.min(y.start+y.count,M.start+M.count));for(let R=P,I=L;R<I;R+=3){const O=p.getX(R),U=p.getX(R+1),A=p.getX(R+2);l=cu(this,x,e,s,h,_,S,O,U,A),l&&(l.faceIndex=Math.floor(R/3),l.face.materialIndex=y.materialIndex,n.push(l))}}else{const E=Math.max(0,M.start),w=Math.min(p.count,M.start+M.count);for(let y=E,x=w;y<x;y+=3){const P=p.getX(y),L=p.getX(y+1),R=p.getX(y+2);l=cu(this,f,e,s,h,_,S,P,L,R),l&&(l.faceIndex=Math.floor(y/3),n.push(l))}}else if(m!==void 0)if(Array.isArray(f))for(let E=0,w=v.length;E<w;E++){const y=v[E],x=f[y.materialIndex],P=Math.max(y.start,M.start),L=Math.min(m.count,Math.min(y.start+y.count,M.start+M.count));for(let R=P,I=L;R<I;R+=3){const O=R,U=R+1,A=R+2;l=cu(this,x,e,s,h,_,S,O,U,A),l&&(l.faceIndex=Math.floor(R/3),l.face.materialIndex=y.materialIndex,n.push(l))}}else{const E=Math.max(0,M.start),w=Math.min(m.count,M.start+M.count);for(let y=E,x=w;y<x;y+=3){const P=y,L=y+1,R=y+2;l=cu(this,f,e,s,h,_,S,P,L,R),l&&(l.faceIndex=Math.floor(y/3),n.push(l))}}}}function ZE(a,e,n,s,l,c,f,p){let m;if(e.side===ri?m=s.intersectTriangle(f,c,l,!0,p):m=s.intersectTriangle(l,c,f,e.side===Cs,p),m===null)return null;lu.copy(p),lu.applyMatrix4(a.matrixWorld);const h=n.ray.origin.distanceTo(lu);return h<n.near||h>n.far?null:{distance:h,point:lu.clone(),object:a}}function cu(a,e,n,s,l,c,f,p,m,h){a.getVertexPosition(p,au),a.getVertexPosition(m,su),a.getVertexPosition(h,ru);const _=ZE(a,e,n,s,au,su,ru,zv);if(_){const S=new re;Oi.getBarycoord(zv,au,su,ru,S),l&&(_.uv=Oi.getInterpolatedAttribute(l,p,m,h,S,new xt)),c&&(_.uv1=Oi.getInterpolatedAttribute(c,p,m,h,S,new xt)),f&&(_.normal=Oi.getInterpolatedAttribute(f,p,m,h,S,new re),_.normal.dot(s.direction)>0&&_.normal.multiplyScalar(-1));const v={a:p,b:m,c:h,normal:new re,materialIndex:0};Oi.getNormal(au,su,ru,v.normal),_.face=v,_.barycoord=S}return _}class yy extends $n{constructor(e=null,n=1,s=1,l,c,f,p,m,h=Vn,_=Vn,S,v){super(null,f,p,m,h,_,l,c,S,v),this.isDataTexture=!0,this.image={data:e,width:n,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Hv extends Zi{constructor(e,n,s,l=1){super(e,n,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=l}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const io=new cn,Gv=new cn,uu=[],Vv=new dr,KE=new cn,yl=new $i,Sl=new bo;class Sy extends $i{constructor(e,n,s){super(e,n),this.isInstancedMesh=!0,this.instanceMatrix=new Hv(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let l=0;l<s;l++)this.setMatrixAt(l,KE)}computeBoundingBox(){const e=this.geometry,n=this.count;this.boundingBox===null&&(this.boundingBox=new dr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<n;s++)this.getMatrixAt(s,io),Vv.copy(e.boundingBox).applyMatrix4(io),this.boundingBox.union(Vv)}computeBoundingSphere(){const e=this.geometry,n=this.count;this.boundingSphere===null&&(this.boundingSphere=new bo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<n;s++)this.getMatrixAt(s,io),Sl.copy(e.boundingSphere).applyMatrix4(io),this.boundingSphere.union(Sl)}copy(e,n){return super.copy(e,n),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,n){return this.instanceColor===null?n.setRGB(1,1,1):n.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,n){return n.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,n){const s=n.morphTargetInfluences,l=this.morphTexture.source.data.data,c=s.length+1,f=e*c+1;for(let p=0;p<s.length;p++)s[p]=l[f+p]}raycast(e,n){const s=this.matrixWorld,l=this.count;if(yl.geometry=this.geometry,yl.material=this.material,yl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Sl.copy(this.boundingSphere),Sl.applyMatrix4(s),e.ray.intersectsSphere(Sl)!==!1))for(let c=0;c<l;c++){this.getMatrixAt(c,io),Gv.multiplyMatrices(s,io),yl.matrixWorld=Gv,yl.raycast(e,uu);for(let f=0,p=uu.length;f<p;f++){const m=uu[f];m.instanceId=c,m.object=this,n.push(m)}uu.length=0}}setColorAt(e,n){return this.instanceColor===null&&(this.instanceColor=new Hv(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),n.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,n){return n.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,n){const s=n.morphTargetInfluences,l=s.length+1;this.morphTexture===null&&(this.morphTexture=new yy(new Float32Array(l*this.count),l,this.count,em,qi));const c=this.morphTexture.source.data.data;let f=0;for(let h=0;h<s.length;h++)f+=s[h];const p=this.geometry.morphTargetsRelative?1:1-f,m=l*e;return c[m]=p,c.set(s,m+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Dh=new re,$E=new re,QE=new bt;class Es{constructor(e=new re(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,s,l){return this.normal.set(e,n,s),this.constant=l,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,s){const l=Dh.subVectors(s,n).cross($E.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(l,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n,s=!0){const l=e.delta(Dh),c=this.normal.dot(l);if(c===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const f=-(e.start.dot(this.normal)+this.constant)/c;return s===!0&&(f<0||f>1)?null:n.copy(e.start).addScaledVector(l,f)}intersectsLine(e){const n=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return n<0&&s>0||s<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const s=n||QE.getNormalMatrix(e),l=this.coplanarPoint(Dh).applyMatrix4(e),c=this.normal.applyMatrix3(s).normalize();return this.constant=-l.dot(c),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Js=new bo,JE=new xt(.5,.5),fu=new re;class cm{constructor(e=new Es,n=new Es,s=new Es,l=new Es,c=new Es,f=new Es){this.planes=[e,n,s,l,c,f]}set(e,n,s,l,c,f){const p=this.planes;return p[0].copy(e),p[1].copy(n),p[2].copy(s),p[3].copy(l),p[4].copy(c),p[5].copy(f),this}copy(e){const n=this.planes;for(let s=0;s<6;s++)n[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,n=la,s=!1){const l=this.planes,c=e.elements,f=c[0],p=c[1],m=c[2],h=c[3],_=c[4],S=c[5],v=c[6],M=c[7],E=c[8],w=c[9],y=c[10],x=c[11],P=c[12],L=c[13],R=c[14],I=c[15];if(l[0].setComponents(h-f,M-_,x-E,I-P).normalize(),l[1].setComponents(h+f,M+_,x+E,I+P).normalize(),l[2].setComponents(h+p,M+S,x+w,I+L).normalize(),l[3].setComponents(h-p,M-S,x-w,I-L).normalize(),s)l[4].setComponents(m,v,y,R).normalize(),l[5].setComponents(h-m,M-v,x-y,I-R).normalize();else if(l[4].setComponents(h-m,M-v,x-y,I-R).normalize(),n===la)l[5].setComponents(h+m,M+v,x+y,I+R).normalize();else if(n===Ll)l[5].setComponents(m,v,y,R).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Js.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Js.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Js)}intersectsSprite(e){Js.center.set(0,0,0);const n=JE.distanceTo(e.center);return Js.radius=.7071067811865476+n,Js.applyMatrix4(e.matrixWorld),this.intersectsSphere(Js)}intersectsSphere(e){const n=this.planes,s=e.center,l=-e.radius;for(let c=0;c<6;c++)if(n[c].distanceToPoint(s)<l)return!1;return!0}intersectsBox(e){const n=this.planes;for(let s=0;s<6;s++){const l=n[s];if(fu.x=l.normal.x>0?e.max.x:e.min.x,fu.y=l.normal.y>0?e.max.y:e.min.y,fu.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(fu)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let s=0;s<6;s++)if(n[s].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class um extends Eo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ot(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Pu=new re,Iu=new re,kv=new cn,Ml=new om,du=new bo,Nh=new re,jv=new re;class eT extends Nn{constructor(e=new Pi,n=new um){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,s=[0];for(let l=1,c=n.count;l<c;l++)Pu.fromBufferAttribute(n,l-1),Iu.fromBufferAttribute(n,l),s[l]=s[l-1],s[l]+=Pu.distanceTo(Iu);e.setAttribute("lineDistance",new oi(s,1))}else mt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const s=this.geometry,l=this.matrixWorld,c=e.params.Line.threshold,f=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),du.copy(s.boundingSphere),du.applyMatrix4(l),du.radius+=c,e.ray.intersectsSphere(du)===!1)return;kv.copy(l).invert(),Ml.copy(e.ray).applyMatrix4(kv);const p=c/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.isLineSegments?2:1,_=s.index,v=s.attributes.position;if(_!==null){const M=Math.max(0,f.start),E=Math.min(_.count,f.start+f.count);for(let w=M,y=E-1;w<y;w+=h){const x=_.getX(w),P=_.getX(w+1),L=hu(this,e,Ml,m,x,P,w);L&&n.push(L)}if(this.isLineLoop){const w=_.getX(E-1),y=_.getX(M),x=hu(this,e,Ml,m,w,y,E-1);x&&n.push(x)}}else{const M=Math.max(0,f.start),E=Math.min(v.count,f.start+f.count);for(let w=M,y=E-1;w<y;w+=h){const x=hu(this,e,Ml,m,w,w+1,w);x&&n.push(x)}if(this.isLineLoop){const w=hu(this,e,Ml,m,E-1,M,E-1);w&&n.push(w)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,s=Object.keys(n);if(s.length>0){const l=n[s[0]];if(l!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let c=0,f=l.length;c<f;c++){const p=l[c].name||String(c);this.morphTargetInfluences.push(0),this.morphTargetDictionary[p]=c}}}}}function hu(a,e,n,s,l,c,f){const p=a.geometry.attributes.position;if(Pu.fromBufferAttribute(p,l),Iu.fromBufferAttribute(p,c),n.distanceSqToSegment(Pu,Iu,Nh,jv)>s)return;Nh.applyMatrix4(a.matrixWorld);const h=e.ray.origin.distanceTo(Nh);if(!(h<e.near||h>e.far))return{distance:h,point:jv.clone().applyMatrix4(a.matrixWorld),index:f,face:null,faceIndex:null,barycoord:null,object:a}}const Xv=new re,Wv=new re;class My extends eT{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,s=[];for(let l=0,c=n.count;l<c;l+=2)Xv.fromBufferAttribute(n,l),Wv.fromBufferAttribute(n,l+1),s[l]=l===0?0:s[l-1],s[l+1]=s[l]+Xv.distanceTo(Wv);e.setAttribute("lineDistance",new oi(s,1))}else mt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class by extends $n{constructor(e=[],n=or,s,l,c,f,p,m,h,_){super(e,n,s,l,c,f,p,m,h,_),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class yo extends $n{constructor(e,n,s=da,l,c,f,p=Vn,m=Vn,h,_=qa,S=1){if(_!==qa&&_!==ir)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const v={width:e,height:n,depth:S};super(v,l,c,f,p,m,_,s,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new rm(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class tT extends yo{constructor(e,n=da,s=or,l,c,f=Vn,p=Vn,m,h=qa){const _={width:e,height:e,depth:1},S=[_,_,_,_,_,_];super(e,e,n,s,l,c,f,p,m,h),this.image=S,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Ey extends $n{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Us extends Pi{constructor(e=1,n=1,s=1,l=1,c=1,f=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:s,widthSegments:l,heightSegments:c,depthSegments:f};const p=this;l=Math.floor(l),c=Math.floor(c),f=Math.floor(f);const m=[],h=[],_=[],S=[];let v=0,M=0;E("z","y","x",-1,-1,s,n,e,f,c,0),E("z","y","x",1,-1,s,n,-e,f,c,1),E("x","z","y",1,1,e,s,n,l,f,2),E("x","z","y",1,-1,e,s,-n,l,f,3),E("x","y","z",1,-1,e,n,s,l,c,4),E("x","y","z",-1,-1,e,n,-s,l,c,5),this.setIndex(m),this.setAttribute("position",new oi(h,3)),this.setAttribute("normal",new oi(_,3)),this.setAttribute("uv",new oi(S,2));function E(w,y,x,P,L,R,I,O,U,A,N){const k=R/U,V=I/A,Q=R/2,fe=I/2,pe=O/2,J=U+1,G=A+1;let j=0,se=0;const Se=new re;for(let xe=0;xe<G;xe++){const z=xe*V-fe;for(let te=0;te<J;te++){const Ee=te*k-Q;Se[w]=Ee*P,Se[y]=z*L,Se[x]=pe,h.push(Se.x,Se.y,Se.z),Se[w]=0,Se[y]=0,Se[x]=O>0?1:-1,_.push(Se.x,Se.y,Se.z),S.push(te/U),S.push(1-xe/A),j+=1}}for(let xe=0;xe<A;xe++)for(let z=0;z<U;z++){const te=v+z+J*xe,Ee=v+z+J*(xe+1),Oe=v+(z+1)+J*(xe+1),He=v+(z+1)+J*xe;m.push(te,Ee,He),m.push(Ee,Oe,He),se+=6}p.addGroup(M,se,N),M+=se,v+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Us(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}const pu=new re,mu=new re,Uh=new re,gu=new Oi;class nT extends Pi{constructor(e=null,n=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:n},e!==null){const l=Math.pow(10,4),c=Math.cos(Rl*n),f=e.getIndex(),p=e.getAttribute("position"),m=f?f.count:p.count,h=[0,0,0],_=["a","b","c"],S=new Array(3),v={},M=[];for(let E=0;E<m;E+=3){f?(h[0]=f.getX(E),h[1]=f.getX(E+1),h[2]=f.getX(E+2)):(h[0]=E,h[1]=E+1,h[2]=E+2);const{a:w,b:y,c:x}=gu;if(w.fromBufferAttribute(p,h[0]),y.fromBufferAttribute(p,h[1]),x.fromBufferAttribute(p,h[2]),gu.getNormal(Uh),S[0]=`${Math.round(w.x*l)},${Math.round(w.y*l)},${Math.round(w.z*l)}`,S[1]=`${Math.round(y.x*l)},${Math.round(y.y*l)},${Math.round(y.z*l)}`,S[2]=`${Math.round(x.x*l)},${Math.round(x.y*l)},${Math.round(x.z*l)}`,!(S[0]===S[1]||S[1]===S[2]||S[2]===S[0]))for(let P=0;P<3;P++){const L=(P+1)%3,R=S[P],I=S[L],O=gu[_[P]],U=gu[_[L]],A=`${R}_${I}`,N=`${I}_${R}`;N in v&&v[N]?(Uh.dot(v[N].normal)<=c&&(M.push(O.x,O.y,O.z),M.push(U.x,U.y,U.z)),v[N]=null):A in v||(v[A]={index0:h[P],index1:h[L],normal:Uh.clone()})}}for(const E in v)if(v[E]){const{index0:w,index1:y}=v[E];pu.fromBufferAttribute(p,w),mu.fromBufferAttribute(p,y),M.push(pu.x,pu.y,pu.z),M.push(mu.x,mu.y,mu.z)}this.setAttribute("position",new oi(M,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Vu extends Pi{constructor(e=1,n=1,s=1,l=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:s,heightSegments:l};const c=e/2,f=n/2,p=Math.floor(s),m=Math.floor(l),h=p+1,_=m+1,S=e/p,v=n/m,M=[],E=[],w=[],y=[];for(let x=0;x<_;x++){const P=x*v-f;for(let L=0;L<h;L++){const R=L*S-c;E.push(R,-P,0),w.push(0,0,1),y.push(L/p),y.push(1-x/m)}}for(let x=0;x<m;x++)for(let P=0;P<p;P++){const L=P+h*x,R=P+h*(x+1),I=P+1+h*(x+1),O=P+1+h*x;M.push(L,R,O),M.push(R,I,O)}this.setIndex(M),this.setAttribute("position",new oi(E,3)),this.setAttribute("normal",new oi(w,3)),this.setAttribute("uv",new oi(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vu(e.width,e.height,e.widthSegments,e.heightSegments)}}function So(a){const e={};for(const n in a){e[n]={};for(const s in a[n]){const l=a[n][s];if(qv(l))l.isRenderTargetTexture?(mt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][s]=null):e[n][s]=l.clone();else if(Array.isArray(l))if(qv(l[0])){const c=[];for(let f=0,p=l.length;f<p;f++)c[f]=l[f].clone();e[n][s]=c}else e[n][s]=l.slice();else e[n][s]=l}}return e}function Kn(a){const e={};for(let n=0;n<a.length;n++){const s=So(a[n]);for(const l in s)e[l]=s[l]}return e}function qv(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function iT(a){const e=[];for(let n=0;n<a.length;n++)e.push(a[n].clone());return e}function Ty(a){const e=a.getRenderTarget();return e===null?a.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Gt.workingColorSpace}const aT={clone:So,merge:Kn};var sT=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,rT=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class ha extends Eo{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=sT,this.fragmentShader=rT,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=So(e.uniforms),this.uniformsGroups=iT(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const l in this.uniforms){const f=this.uniforms[l].value;f&&f.isTexture?n.uniforms[l]={type:"t",value:f.toJSON(e).uuid}:f&&f.isColor?n.uniforms[l]={type:"c",value:f.getHex()}:f&&f.isVector2?n.uniforms[l]={type:"v2",value:f.toArray()}:f&&f.isVector3?n.uniforms[l]={type:"v3",value:f.toArray()}:f&&f.isVector4?n.uniforms[l]={type:"v4",value:f.toArray()}:f&&f.isMatrix3?n.uniforms[l]={type:"m3",value:f.toArray()}:f&&f.isMatrix4?n.uniforms[l]={type:"m4",value:f.toArray()}:n.uniforms[l]={value:f}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const s={};for(const l in this.extensions)this.extensions[l]===!0&&(s[l]=!0);return Object.keys(s).length>0&&(n.extensions=s),n}fromJSON(e,n){if(super.fromJSON(e,n),e.uniforms!==void 0)for(const s in e.uniforms){const l=e.uniforms[s];switch(this.uniforms[s]={},l.type){case"t":this.uniforms[s].value=n[l.value]||null;break;case"c":this.uniforms[s].value=new ot().setHex(l.value);break;case"v2":this.uniforms[s].value=new xt().fromArray(l.value);break;case"v3":this.uniforms[s].value=new re().fromArray(l.value);break;case"v4":this.uniforms[s].value=new gn().fromArray(l.value);break;case"m3":this.uniforms[s].value=new bt().fromArray(l.value);break;case"m4":this.uniforms[s].value=new cn().fromArray(l.value);break;default:this.uniforms[s].value=l.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)this.extensions[s]=e.extensions[s];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class oT extends ha{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class lT extends Eo{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ot(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ot(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Op,this.normalScale=new xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rs,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class cT extends Eo{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_E,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class uT extends Eo{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class fm extends Nn{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new ot(e),this.intensity=n}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,n}}class fT extends fm{constructor(e,n,s){super(e,s),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Nn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ot(n)}copy(e,n){return super.copy(e,n),this.groundColor.copy(e.groundColor),this}toJSON(e){const n=super.toJSON(e);return n.object.groundColor=this.groundColor.getHex(),n}}const Lh=new cn,Yv=new re,Zv=new re;class dT{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xt(512,512),this.mapType=Si,this.map=null,this.mapPass=null,this.matrix=new cn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cm,this._frameExtents=new xt(1,1),this._viewportCount=1,this._viewports=[new gn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,s=this.matrix;Yv.setFromMatrixPosition(e.matrixWorld),n.position.copy(Yv),Zv.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(Zv),n.updateMatrixWorld(),Lh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Lh,n.coordinateSystem,n.reversedDepth),n.coordinateSystem===Ll||n.reversedDepth?s.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(Lh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const _u=new re,vu=new ws,sa=new re;class Ay extends Nn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new cn,this.projectionMatrix=new cn,this.projectionMatrixInverse=new cn,this.coordinateSystem=la,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(_u,vu,sa),sa.x===1&&sa.y===1&&sa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(_u,vu,sa.set(1,1,1)).invert()}updateWorldMatrix(e,n,s=!1){super.updateWorldMatrix(e,n,s),this.matrixWorld.decompose(_u,vu,sa),sa.x===1&&sa.y===1&&sa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(_u,vu,sa.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const bs=new re,Kv=new xt,$v=new xt;class Li extends Ay{constructor(e=50,n=1,s=.1,l=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=l,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=Pp*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Rl*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Pp*2*Math.atan(Math.tan(Rl*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,s){bs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(bs.x,bs.y).multiplyScalar(-e/bs.z),bs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(bs.x,bs.y).multiplyScalar(-e/bs.z)}getViewSize(e,n){return this.getViewBounds(e,Kv,$v),n.subVectors($v,Kv)}setViewOffset(e,n,s,l,c,f){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=s,this.view.offsetY=l,this.view.width=c,this.view.height=f,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Rl*.5*this.fov)/this.zoom,s=2*n,l=this.aspect*s,c=-.5*l;const f=this.view;if(this.view!==null&&this.view.enabled){const m=f.fullWidth,h=f.fullHeight;c+=f.offsetX*l/m,n-=f.offsetY*s/h,l*=f.width/m,s*=f.height/h}const p=this.filmOffset;p!==0&&(c+=e*p/this.getFilmWidth()),this.projectionMatrix.makePerspective(c,c+l,n,n-s,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}class dm extends Ay{constructor(e=-1,n=1,s=1,l=-1,c=.1,f=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=s,this.bottom=l,this.near=c,this.far=f,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,s,l,c,f){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=s,this.view.offsetY=l,this.view.width=c,this.view.height=f,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,l=(this.top+this.bottom)/2;let c=s-e,f=s+e,p=l+n,m=l-n;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,_=(this.top-this.bottom)/this.view.fullHeight/this.zoom;c+=h*this.view.offsetX,f=c+h*this.view.width,p-=_*this.view.offsetY,m=p-_*this.view.height}this.projectionMatrix.makeOrthographic(c,f,p,m,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}class hT extends dT{constructor(){super(new dm(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Qv extends fm{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Nn.DEFAULT_UP),this.updateMatrix(),this.target=new Nn,this.shadow=new hT}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const n=super.toJSON(e);return n.object.shadow=this.shadow.toJSON(),n.object.target=this.target.uuid,n}}class pT extends fm{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}const ao=-90,so=1;class mT extends Nn{constructor(e,n,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const l=new Li(ao,so,e,n);l.layers=this.layers,this.add(l);const c=new Li(ao,so,e,n);c.layers=this.layers,this.add(c);const f=new Li(ao,so,e,n);f.layers=this.layers,this.add(f);const p=new Li(ao,so,e,n);p.layers=this.layers,this.add(p);const m=new Li(ao,so,e,n);m.layers=this.layers,this.add(m);const h=new Li(ao,so,e,n);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[s,l,c,f,p,m]=n;for(const h of n)this.remove(h);if(e===la)s.up.set(0,1,0),s.lookAt(1,0,0),l.up.set(0,1,0),l.lookAt(-1,0,0),c.up.set(0,0,-1),c.lookAt(0,1,0),f.up.set(0,0,1),f.lookAt(0,-1,0),p.up.set(0,1,0),p.lookAt(0,0,1),m.up.set(0,1,0),m.lookAt(0,0,-1);else if(e===Ll)s.up.set(0,-1,0),s.lookAt(-1,0,0),l.up.set(0,-1,0),l.lookAt(1,0,0),c.up.set(0,0,1),c.lookAt(0,1,0),f.up.set(0,0,-1),f.lookAt(0,-1,0),p.up.set(0,-1,0),p.lookAt(0,0,1),m.up.set(0,-1,0),m.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of n)this.add(h),h.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:l}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[c,f,p,m,h,_]=this.children,S=e.getRenderTarget(),v=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),E=e.xr.enabled;e.xr.enabled=!1;const w=s.texture.generateMipmaps;s.texture.generateMipmaps=!1;let y=!1;e.isWebGLRenderer===!0?y=e.state.buffers.depth.getReversed():y=e.reversedDepthBuffer,e.setRenderTarget(s,0,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,c),e.setRenderTarget(s,1,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,f),e.setRenderTarget(s,2,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,p),e.setRenderTarget(s,3,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,m),e.setRenderTarget(s,4,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,h),s.texture.generateMipmaps=w,e.setRenderTarget(s,5,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,_),e.setRenderTarget(S,v,M),e.xr.enabled=E,s.texture.needsPMREMUpdate=!0}}class gT extends Li{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Jv{constructor(e=1,n=0,s=0){this.radius=e,this.phi=n,this.theta=s}set(e,n,s){return this.radius=e,this.phi=n,this.theta=s,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ot(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,s){return this.radius=Math.sqrt(e*e+n*n+s*s),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,s),this.phi=Math.acos(Ot(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Am=class Am{constructor(e,n,s,l){this.elements=[1,0,0,1],e!==void 0&&this.set(e,n,s,l)}identity(){return this.set(1,0,0,1),this}fromArray(e,n=0){for(let s=0;s<4;s++)this.elements[s]=e[s+n];return this}set(e,n,s,l){const c=this.elements;return c[0]=e,c[2]=n,c[1]=s,c[3]=l,this}};Am.prototype.isMatrix2=!0;let ex=Am;class _T extends My{constructor(e=10,n=10,s=4473924,l=8947848){s=new ot(s),l=new ot(l);const c=n/2,f=e/n,p=e/2,m=[],h=[];for(let v=0,M=0,E=-p;v<=n;v++,E+=f){m.push(-p,0,E,p,0,E),m.push(E,0,-p,E,0,p);const w=v===c?s:l;w.toArray(h,M),M+=3,w.toArray(h,M),M+=3,w.toArray(h,M),M+=3,w.toArray(h,M),M+=3}const _=new Pi;_.setAttribute("position",new oi(m,3)),_.setAttribute("color",new oi(h,3));const S=new um({vertexColors:!0,toneMapped:!1});super(_,S),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class vT extends Ns{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){mt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function tx(a,e,n,s){const l=xT(s);switch(n){case fy:return a*e;case em:return a*e/l.components*l.byteLength;case tm:return a*e/l.components*l.byteLength;case lr:return a*e*2/l.components*l.byteLength;case nm:return a*e*2/l.components*l.byteLength;case dy:return a*e*3/l.components*l.byteLength;case Yi:return a*e*4/l.components*l.byteLength;case im:return a*e*4/l.components*l.byteLength;case Eu:case Tu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case Au:case Cu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case sp:case op:return Math.max(a,16)*Math.max(e,8)/4;case ap:case rp:return Math.max(a,8)*Math.max(e,8)/2;case lp:case cp:case fp:case dp:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case up:case Du:case hp:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case pp:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case mp:return Math.floor((a+4)/5)*Math.floor((e+3)/4)*16;case gp:return Math.floor((a+4)/5)*Math.floor((e+4)/5)*16;case _p:return Math.floor((a+5)/6)*Math.floor((e+4)/5)*16;case vp:return Math.floor((a+5)/6)*Math.floor((e+5)/6)*16;case xp:return Math.floor((a+7)/8)*Math.floor((e+4)/5)*16;case yp:return Math.floor((a+7)/8)*Math.floor((e+5)/6)*16;case Sp:return Math.floor((a+7)/8)*Math.floor((e+7)/8)*16;case Mp:return Math.floor((a+9)/10)*Math.floor((e+4)/5)*16;case bp:return Math.floor((a+9)/10)*Math.floor((e+5)/6)*16;case Ep:return Math.floor((a+9)/10)*Math.floor((e+7)/8)*16;case Tp:return Math.floor((a+9)/10)*Math.floor((e+9)/10)*16;case Ap:return Math.floor((a+11)/12)*Math.floor((e+9)/10)*16;case Cp:return Math.floor((a+11)/12)*Math.floor((e+11)/12)*16;case wp:case Rp:case Dp:return Math.ceil(a/4)*Math.ceil(e/4)*16;case Np:case Up:return Math.ceil(a/4)*Math.ceil(e/4)*8;case Nu:case Lp:return Math.ceil(a/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function xT(a){switch(a){case Si:case oy:return{byteLength:1,components:1};case Nl:case ly:case Wa:return{byteLength:2,components:1};case Qp:case Jp:return{byteLength:2,components:4};case da:case $p:case qi:return{byteLength:4,components:1};case cy:case uy:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${a}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Zp}}));typeof window<"u"&&(window.__THREE__?mt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Zp);function Cy(){let a=null,e=!1,n=null,s=null;function l(c,f){n(c,f),s=a.requestAnimationFrame(l)}return{start:function(){e!==!0&&n!==null&&a!==null&&(s=a.requestAnimationFrame(l),e=!0)},stop:function(){a!==null&&a.cancelAnimationFrame(s),e=!1},setAnimationLoop:function(c){n=c},setContext:function(c){a=c}}}function yT(a){const e=new WeakMap;function n(p,m){const h=p.array,_=p.usage,S=h.byteLength,v=a.createBuffer();a.bindBuffer(m,v),a.bufferData(m,h,_),p.onUploadCallback();let M;if(h instanceof Float32Array)M=a.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)M=a.HALF_FLOAT;else if(h instanceof Uint16Array)p.isFloat16BufferAttribute?M=a.HALF_FLOAT:M=a.UNSIGNED_SHORT;else if(h instanceof Int16Array)M=a.SHORT;else if(h instanceof Uint32Array)M=a.UNSIGNED_INT;else if(h instanceof Int32Array)M=a.INT;else if(h instanceof Int8Array)M=a.BYTE;else if(h instanceof Uint8Array)M=a.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)M=a.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:v,type:M,bytesPerElement:h.BYTES_PER_ELEMENT,version:p.version,size:S}}function s(p,m,h){const _=m.array,S=m.updateRanges;if(a.bindBuffer(h,p),S.length===0)a.bufferSubData(h,0,_);else{S.sort((M,E)=>M.start-E.start);let v=0;for(let M=1;M<S.length;M++){const E=S[v],w=S[M];w.start<=E.start+E.count+1?E.count=Math.max(E.count,w.start+w.count-E.start):(++v,S[v]=w)}S.length=v+1;for(let M=0,E=S.length;M<E;M++){const w=S[M];a.bufferSubData(h,w.start*_.BYTES_PER_ELEMENT,_,w.start,w.count)}m.clearUpdateRanges()}m.onUploadCallback()}function l(p){return p.isInterleavedBufferAttribute&&(p=p.data),e.get(p)}function c(p){p.isInterleavedBufferAttribute&&(p=p.data);const m=e.get(p);m&&(a.deleteBuffer(m.buffer),e.delete(p))}function f(p,m){if(p.isInterleavedBufferAttribute&&(p=p.data),p.isGLBufferAttribute){const _=e.get(p);(!_||_.version<p.version)&&e.set(p,{buffer:p.buffer,type:p.type,bytesPerElement:p.elementSize,version:p.version});return}const h=e.get(p);if(h===void 0)e.set(p,n(p,m));else if(h.version<p.version){if(h.size!==p.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(h.buffer,p,m),h.version=p.version}}return{get:l,remove:c,update:f}}var ST=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,MT=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
}
float hash3D( vec3 value ) {
return hash2D( vec2( hash2D( value.xy ), value.z ) );
}
float getAlphaHashThreshold( vec3 position ) {
float maxDeriv = max(
length( dFdx( position.xyz ) ),
length( dFdy( position.xyz ) )
);
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
vec2 pixScales = vec2(
exp2( floor( log2( pixScale ) ) ),
exp2( ceil( log2( pixScale ) ) )
);
vec2 alpha = vec2(
hash3D( floor( pixScales.x * position.xyz ) ),
hash3D( floor( pixScales.y * position.xyz ) )
);
float lerpFactor = fract( log2( pixScale ) );
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
float a = min( lerpFactor, 1.0 - lerpFactor );
vec3 cases = vec3(
x * x / ( 2.0 * a * ( 1.0 - a ) ),
( x - 0.5 * a ) / ( 1.0 - a ),
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
);
float threshold = ( x < ( 1.0 - a ) )
? ( ( x < a ) ? cases.x : cases.y )
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
#endif`,bT=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,ET=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,TT=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
#endif`,AT=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,CT=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
clearcoatSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_SHEEN )
sheenSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif`,wT=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,RT=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
#endif
uniform highp sampler2D batchingTexture;
uniform highp usampler2D batchingIdTexture;
mat4 getBatchingMatrix( const in float i ) {
int size = textureSize( batchingTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
float getIndirectIndex( const in int i ) {
int size = textureSize( batchingIdTexture, 0 ).x;
int x = i % size;
int y = i / size;
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
}
#endif
#ifdef USE_BATCHING_COLOR
uniform sampler2D batchingColorTexture;
vec4 getBatchingColor( const in float i ) {
int size = textureSize( batchingColorTexture, 0 ).x;
int j = int( i );
int x = j % size;
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
#endif`,DT=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,NT=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,UT=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,LT=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
} // validated`,OT=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
vec3 sqrtF0 = sqrt( fresnel0 );
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
float phase = 2.0 * PI * OPD * 1.0e-9;
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
xyz /= 1.0685e-7;
vec3 rgb = XYZ_TO_REC709 * xyz;
return rgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
vec3 I;
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
float cosTheta2Sq = 1.0 - sinTheta2Sq;
if ( cosTheta2Sq < 0.0 ) {
return vec3( 1.0 );
}
float cosTheta2 = sqrt( cosTheta2Sq );
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
float T121 = 1.0 - R12;
float phi12 = 0.0;
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
float phi21 = PI - phi12;
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
vec3 phi23 = vec3( 0.0 );
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
vec3 phi = vec3( phi21 ) + phi23;
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
vec3 r123 = sqrt( R123 );
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
vec3 C0 = R12 + Rs;
I = C0;
vec3 Cm = Rs - T121;
for ( int m = 1; m <= 2; ++ m ) {
Cm *= r123;
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
I += Cm * Sm;
}
return max( I, vec3( 0.0 ) );
}
#endif`,PT=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vBumpMapUv );
vec2 dSTdy = dFdy( vBumpMapUv );
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm;
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif`,IT=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
float clipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
if ( clipOpacity == 0.0 ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
float unionClipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
}
#pragma unroll_loop_end
clipOpacity *= 1.0 - unionClipOpacity;
#endif
diffuseColor.a *= clipOpacity;
if ( diffuseColor.a == 0.0 ) discard;
#else
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif
#endif`,BT=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,FT=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,zT=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,HT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#endif`,GT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#endif`,VT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
#endif`,kT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
vColor *= color;
#elif defined( USE_COLOR )
vColor.rgb *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.rgb *= instanceColor.rgb;
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
#endif`,jT=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
#define inverseTransformDirection transformDirectionByInverseViewMatrix
vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {
return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );
}
vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {
return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,XT=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;
#ifdef texture2DGradEXT
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
#else
return texture2D( envMap, uv ).rgb;
#endif
}
#define cubeUV_r0 1.0
#define cubeUV_m0 - 2.0
#define cubeUV_r1 0.8
#define cubeUV_m1 - 1.0
#define cubeUV_r4 0.4
#define cubeUV_m4 2.0
#define cubeUV_r5 0.305
#define cubeUV_m5 3.0
#define cubeUV_r6 0.21
#define cubeUV_m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= cubeUV_r1 ) {
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
} else if ( roughness >= cubeUV_r4 ) {
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
} else if ( roughness >= cubeUV_r5 ) {
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
} else if ( roughness >= cubeUV_r6 ) {
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); }
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif`,WT=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#endif`,qT=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,YT=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,ZT=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,KT=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,$T="gl_FragColor = linearToOutputTexel( gl_FragColor );",QT=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,JT=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
#endif`,eA=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,tA=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif`,nA=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif`,iA=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,aA=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,sA=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,rA=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,oA=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,lA=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
}`,cA=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,uA=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,fA=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,dA=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif
#include <lightprobes_pars_fragment>`,hA=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,pA=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,mA=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,gA=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,_A=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,vA=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = vec3( 0.04 );
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,xA=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
vec3 specularColor;
vec3 specularColorBlended;
float roughness;
float metalness;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
vec3 iridescenceFresnelDielectric;
vec3 iridescenceFresnelMetallic;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColorBlended;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float rInv = 1.0 / ( roughness + 0.1 );
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
float DG = exp( a * dotNV + b );
return saturate( DG );
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
float Ess_V = dfgV.x + dfgV.y;
float Ess_L = dfgL.x + dfgL.y;
float Ems_V = 1.0 - Ess_V;
float Ems_L = 1.0 - Ess_L;
vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
float compensationFactor = Ems_V * Ems_L;
vec3 multiScatter = Fms * compensationFactor;
return singleScatter + multiScatter;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
#ifdef USE_CLEARCOAT
vec3 Ncc = geometryClearcoatNormal;
vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
mat3 mInvClearcoat = mat3(
vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
vec3( 0, 1, 0 ),
vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
);
vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
#endif
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
irradiance *= sheenEnergyComp;
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
diffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectDiffuse += diffuse;
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
#endif
vec3 singleScatteringDielectric = vec3( 0.0 );
vec3 multiScatteringDielectric = vec3( 0.0 );
vec3 singleScatteringMetallic = vec3( 0.0 );
vec3 multiScatteringMetallic = vec3( 0.0 );
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#endif
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
vec3 indirectSpecular = radiance * singleScattering;
indirectSpecular += multiScattering * cosineWeightedIrradiance;
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
indirectSpecular *= sheenEnergyComp;
indirectDiffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectSpecular += indirectSpecular;
reflectedLight.indirectDiffuse += indirectDiffuse;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,yA=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometryPosition, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#ifdef USE_LIGHT_PROBES_GRID
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,SA=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,MA=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,bA=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
uniform vec3 probesResolution;
vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
vec3 res = probesResolution;
vec3 gridRange = probesMax - probesMin;
vec3 resMinusOne = res - 1.0;
vec3 probeSpacing = gridRange / resMinusOne;
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );
uvw = uvw * resMinusOne / res + 0.5 / res;
float nz = res.z;
float paddedSlices = nz + 2.0;
float atlasDepth = 7.0 * paddedSlices;
float uvZBase = uvw.z * nz + 1.0;
vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );
vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
vec3 c0 = s0.xyz;
vec3 c1 = vec3( s0.w, s1.xy );
vec3 c2 = vec3( s1.zw, s2.x );
vec3 c3 = s2.yzw;
vec3 c4 = s3.xyz;
vec3 c5 = vec3( s3.w, s4.xy );
vec3 c6 = vec3( s4.zw, s5.x );
vec3 c7 = s5.yzw;
vec3 c8 = s6.xyz;
float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;
vec3 result = c0 * 0.886227;
result += c1 * 2.0 * 0.511664 * y;
result += c2 * 2.0 * 0.511664 * z;
result += c3 * 2.0 * 0.511664 * x;
result += c4 * 2.0 * 0.429043 * x * y;
result += c5 * 2.0 * 0.429043 * y * z;
result += c6 * ( 0.743125 * z * z - 0.247708 );
result += c7 * 2.0 * 0.429043 * x * z;
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
#endif`,EA=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,TA=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,AA=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,CA=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,wA=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,RA=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,DA=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,NA=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,UA=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,LA=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,OA=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
#endif`,PA=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
#elif defined( USE_COLOR )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
#endif`,IA=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
#endif`,BA=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
#endif
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#endif`,FA=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
#endif`,zA=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#ifdef DOUBLE_SIDED
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#ifdef DOUBLE_SIDED
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,HA=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#if defined( USE_PACKED_NORMALMAP )
mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );
#endif
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,GA=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,VA=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,kA=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#ifdef FLIP_SIDED
vBitangent = - vBitangent;
#endif
#endif
#endif`,jA=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
#endif`,XA=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,WA=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,qA=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif`,YA=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,ZA=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,KA=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return depth * ( far - near ) - far;
#else
return depth * ( near - far ) - near;
#endif
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return ( near * far ) / ( ( near - far ) * depth - near );
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
}`,$A=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,QA=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,JA=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,e1=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,t1=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,n1=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,i1=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#else
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#endif
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#else
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#elif defined( SHADOWMAP_TYPE_BASIC )
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#endif
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float interleavedGradientNoise( vec2 position ) {
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
}
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
const float goldenAngle = 2.399963229728653;
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
float theta = float( sampleIndex ) * goldenAngle + phi;
return vec2( cos( theta ), sin( theta ) ) * r;
}
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float radius = shadowRadius * texelSize.x;
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
shadow = (
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_VSM )
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
float mean = distribution.x;
float variance = distribution.y * distribution.y;
#ifdef USE_REVERSED_DEPTH_BUFFER
float hard_shadow = step( mean, shadowCoord.z );
#else
float hard_shadow = step( shadowCoord.z, mean );
#endif
if ( hard_shadow == 1.0 ) {
shadow = 1.0;
} else {
variance = max( variance, 0.0000001 );
float d = shadowCoord.z - mean;
float p_max = variance / ( variance + d * d );
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
shadow = max( hard_shadow, p_max );
}
}
return mix( 1.0, shadow, shadowIntensity );
}
#else
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadow = step( depth, shadowCoord.z );
#else
shadow = step( shadowCoord.z, depth );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 bd3D = normalize( lightToPosition );
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp -= shadowBias;
#else
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
#endif
float texelSize = shadowRadius / shadowMapSize.x;
vec3 absDir = abs( bd3D );
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
tangent = normalize( cross( bd3D, tangent ) );
vec3 bitangent = cross( bd3D, tangent );
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
vec2 sample0 = vogelDiskSample( 0, 5, phi );
vec2 sample1 = vogelDiskSample( 1, 5, phi );
vec2 sample2 = vogelDiskSample( 2, 5, phi );
vec2 sample3 = vogelDiskSample( 3, 5, phi );
vec2 sample4 = vogelDiskSample( 4, 5, phi );
shadow = (
texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_BASIC )
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
float depth = textureCube( shadowMap, bd3D ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
depth = 1.0 - depth;
#endif
shadow = step( dp, depth );
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#endif
#endif`,a1=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#endif`,s1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
vec3 shadowWorldNormal = vec3( 0.0 );
#endif
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,r1=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,o1=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,l1=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
mat4 getBoneMatrix( const in float i ) {
int size = textureSize( boneTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
#endif`,c1=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,u1=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif`,f1=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,d1=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,h1=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,p1=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
vec3( 1.6605, - 0.1246, - 0.0182 ),
vec3( - 0.5876, 1.1329, - 0.1006 ),
vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
vec3( 0.6274, 0.0691, 0.0164 ),
vec3( 0.3293, 0.9195, 0.0880 ),
vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return + 15.5 * x4 * x2
- 40.14 * x4 * x
+ 31.96 * x4
- 6.868 * x2 * x
+ 0.4298 * x2
+ 0.1191 * x
- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
const mat3 AgXInsetMatrix = mat3(
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
);
const mat3 AgXOutsetMatrix = mat3(
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
);
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
color *= toneMappingExposure;
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color = AgXInsetMatrix * color;
color = max( color, 1e-10 ); color = log2( color );
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
color = clamp( color, 0.0, 1.0 );
color = agxDefaultContrastApprox( color );
color = AgXOutsetMatrix * color;
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
color = clamp( color, 0.0, 1.0 );
return color;
}
vec3 NeutralToneMapping( vec3 color ) {
const float StartCompression = 0.8 - 0.04;
const float Desaturation = 0.15;
color *= toneMappingExposure;
float x = min( color.r, min( color.g, color.b ) );
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
float peak = max( color.r, max( color.g, color.b ) );
if ( peak < StartCompression ) return color;
float d = 1. - StartCompression;
float newPeak = 1. - d * d / ( peak + d - StartCompression );
color *= newPeak / peak;
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,g1=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
float w0( float a ) {
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
}
float w1( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
}
float w2( float a ){
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
}
float w3( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * a );
}
float g0( float a ) {
return w0( a ) + w1( a );
}
float g1( float a ) {
return w2( a ) + w3( a );
}
float h0( float a ) {
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
}
float h1( float a ) {
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
}
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
uv = uv * texelSize.zw + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
float g0x = g0( fuv.x );
float g1x = g1( fuv.x );
float h0x = h0( fuv.x );
float h1x = h1( fuv.x );
float h0y = h0( fuv.y );
float h1y = h1( fuv.y );
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
}
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
vec2 fLodSizeInv = 1.0 / fLodSize;
vec2 cLodSizeInv = 1.0 / cLodSize;
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
return mix( fSample, cSample, fract( lod ) );
}
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
}
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( isinf( attenuationDistance ) ) {
return vec3( 1.0 );
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec4 transmittedLight;
vec3 transmittance;
#ifdef USE_DISPERSION
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
for ( int i = 0; i < 3; i ++ ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
transmittedLight[ i ] = transmissionSample[ i ];
transmittedLight.a += transmissionSample.a;
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
}
transmittedLight.a /= 3.0;
#else
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
#endif
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
#endif`,_1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,v1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
uniform mat3 mapTransform;
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
uniform mat3 alphaMapTransform;
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
uniform mat3 lightMapTransform;
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
uniform mat3 aoMapTransform;
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
uniform mat3 bumpMapTransform;
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
uniform mat3 normalMapTransform;
varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
uniform mat3 displacementMapTransform;
varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
uniform mat3 emissiveMapTransform;
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
uniform mat3 metalnessMapTransform;
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
uniform mat3 roughnessMapTransform;
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
uniform mat3 anisotropyMapTransform;
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
uniform mat3 clearcoatMapTransform;
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform mat3 clearcoatNormalMapTransform;
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform mat3 clearcoatRoughnessMapTransform;
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
uniform mat3 sheenColorMapTransform;
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform mat3 sheenRoughnessMapTransform;
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
uniform mat3 iridescenceMapTransform;
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform mat3 iridescenceThicknessMapTransform;
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
uniform mat3 specularMapTransform;
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
uniform mat3 specularColorMapTransform;
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform mat3 specularIntensityMapTransform;
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,x1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,y1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
#endif
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif`;const S1=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,M1=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,b1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,E1=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,T1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,A1=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,C1=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,w1=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <logdepthbuf_fragment>
#ifdef USE_REVERSED_DEPTH_BUFFER
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
#else
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
#endif
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,R1=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,D1=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
}`,N1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,U1=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,L1=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,O1=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,P1=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,I1=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,B1=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,F1=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,z1=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,H1=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,G1=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
}`,V1=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,k1=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,j1=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,X1=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,W1=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef USE_SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULAR_COLORMAP
uniform sampler2D specularColorMap;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEEN_COLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
#ifdef USE_ANISOTROPY
uniform vec2 anisotropyVector;
#ifdef USE_ANISOTROPYMAP
uniform sampler2D anisotropyMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,q1=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,Y1=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,Z1=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
varying vec2 vUv;
uniform mat3 uvTransform;
#endif
void main() {
#ifdef USE_POINTS_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,K1=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,$1=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,Q1=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,J1=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix[ 3 ];
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,eC=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,wt={alphahash_fragment:ST,alphahash_pars_fragment:MT,alphamap_fragment:bT,alphamap_pars_fragment:ET,alphatest_fragment:TT,alphatest_pars_fragment:AT,aomap_fragment:CT,aomap_pars_fragment:wT,batching_pars_vertex:RT,batching_vertex:DT,begin_vertex:NT,beginnormal_vertex:UT,bsdfs:LT,iridescence_fragment:OT,bumpmap_pars_fragment:PT,clipping_planes_fragment:IT,clipping_planes_pars_fragment:BT,clipping_planes_pars_vertex:FT,clipping_planes_vertex:zT,color_fragment:HT,color_pars_fragment:GT,color_pars_vertex:VT,color_vertex:kT,common:jT,cube_uv_reflection_fragment:XT,defaultnormal_vertex:WT,displacementmap_pars_vertex:qT,displacementmap_vertex:YT,emissivemap_fragment:ZT,emissivemap_pars_fragment:KT,colorspace_fragment:$T,colorspace_pars_fragment:QT,envmap_fragment:JT,envmap_common_pars_fragment:eA,envmap_pars_fragment:tA,envmap_pars_vertex:nA,envmap_physical_pars_fragment:hA,envmap_vertex:iA,fog_vertex:aA,fog_pars_vertex:sA,fog_fragment:rA,fog_pars_fragment:oA,gradientmap_pars_fragment:lA,lightmap_pars_fragment:cA,lights_lambert_fragment:uA,lights_lambert_pars_fragment:fA,lights_pars_begin:dA,lights_toon_fragment:pA,lights_toon_pars_fragment:mA,lights_phong_fragment:gA,lights_phong_pars_fragment:_A,lights_physical_fragment:vA,lights_physical_pars_fragment:xA,lights_fragment_begin:yA,lights_fragment_maps:SA,lights_fragment_end:MA,lightprobes_pars_fragment:bA,logdepthbuf_fragment:EA,logdepthbuf_pars_fragment:TA,logdepthbuf_pars_vertex:AA,logdepthbuf_vertex:CA,map_fragment:wA,map_pars_fragment:RA,map_particle_fragment:DA,map_particle_pars_fragment:NA,metalnessmap_fragment:UA,metalnessmap_pars_fragment:LA,morphinstance_vertex:OA,morphcolor_vertex:PA,morphnormal_vertex:IA,morphtarget_pars_vertex:BA,morphtarget_vertex:FA,normal_fragment_begin:zA,normal_fragment_maps:HA,normal_pars_fragment:GA,normal_pars_vertex:VA,normal_vertex:kA,normalmap_pars_fragment:jA,clearcoat_normal_fragment_begin:XA,clearcoat_normal_fragment_maps:WA,clearcoat_pars_fragment:qA,iridescence_pars_fragment:YA,opaque_fragment:ZA,packing:KA,premultiplied_alpha_fragment:$A,project_vertex:QA,dithering_fragment:JA,dithering_pars_fragment:e1,roughnessmap_fragment:t1,roughnessmap_pars_fragment:n1,shadowmap_pars_fragment:i1,shadowmap_pars_vertex:a1,shadowmap_vertex:s1,shadowmask_pars_fragment:r1,skinbase_vertex:o1,skinning_pars_vertex:l1,skinning_vertex:c1,skinnormal_vertex:u1,specularmap_fragment:f1,specularmap_pars_fragment:d1,tonemapping_fragment:h1,tonemapping_pars_fragment:p1,transmission_fragment:m1,transmission_pars_fragment:g1,uv_pars_fragment:_1,uv_pars_vertex:v1,uv_vertex:x1,worldpos_vertex:y1,background_vert:S1,background_frag:M1,backgroundCube_vert:b1,backgroundCube_frag:E1,cube_vert:T1,cube_frag:A1,depth_vert:C1,depth_frag:w1,distance_vert:R1,distance_frag:D1,equirect_vert:N1,equirect_frag:U1,linedashed_vert:L1,linedashed_frag:O1,meshbasic_vert:P1,meshbasic_frag:I1,meshlambert_vert:B1,meshlambert_frag:F1,meshmatcap_vert:z1,meshmatcap_frag:H1,meshnormal_vert:G1,meshnormal_frag:V1,meshphong_vert:k1,meshphong_frag:j1,meshphysical_vert:X1,meshphysical_frag:W1,meshtoon_vert:q1,meshtoon_frag:Y1,points_vert:Z1,points_frag:K1,shadow_vert:$1,shadow_frag:Q1,sprite_vert:J1,sprite_frag:eC},qe={common:{diffuse:{value:new ot(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new bt},alphaMap:{value:null},alphaMapTransform:{value:new bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new bt}},envmap:{envMap:{value:null},envMapRotation:{value:new bt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new bt},normalScale:{value:new xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ot(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new re},probesMax:{value:new re},probesResolution:{value:new re}},points:{diffuse:{value:new ot(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new bt},alphaTest:{value:0},uvTransform:{value:new bt}},sprite:{diffuse:{value:new ot(16777215)},opacity:{value:1},center:{value:new xt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new bt},alphaMap:{value:null},alphaMapTransform:{value:new bt},alphaTest:{value:0}}},oa={basic:{uniforms:Kn([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.fog]),vertexShader:wt.meshbasic_vert,fragmentShader:wt.meshbasic_frag},lambert:{uniforms:Kn([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new ot(0)},envMapIntensity:{value:1}}]),vertexShader:wt.meshlambert_vert,fragmentShader:wt.meshlambert_frag},phong:{uniforms:Kn([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new ot(0)},specular:{value:new ot(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:wt.meshphong_vert,fragmentShader:wt.meshphong_frag},standard:{uniforms:Kn([qe.common,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.roughnessmap,qe.metalnessmap,qe.fog,qe.lights,{emissive:{value:new ot(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wt.meshphysical_vert,fragmentShader:wt.meshphysical_frag},toon:{uniforms:Kn([qe.common,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.gradientmap,qe.fog,qe.lights,{emissive:{value:new ot(0)}}]),vertexShader:wt.meshtoon_vert,fragmentShader:wt.meshtoon_frag},matcap:{uniforms:Kn([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,{matcap:{value:null}}]),vertexShader:wt.meshmatcap_vert,fragmentShader:wt.meshmatcap_frag},points:{uniforms:Kn([qe.points,qe.fog]),vertexShader:wt.points_vert,fragmentShader:wt.points_frag},dashed:{uniforms:Kn([qe.common,qe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wt.linedashed_vert,fragmentShader:wt.linedashed_frag},depth:{uniforms:Kn([qe.common,qe.displacementmap]),vertexShader:wt.depth_vert,fragmentShader:wt.depth_frag},normal:{uniforms:Kn([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,{opacity:{value:1}}]),vertexShader:wt.meshnormal_vert,fragmentShader:wt.meshnormal_frag},sprite:{uniforms:Kn([qe.sprite,qe.fog]),vertexShader:wt.sprite_vert,fragmentShader:wt.sprite_frag},background:{uniforms:{uvTransform:{value:new bt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wt.background_vert,fragmentShader:wt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new bt}},vertexShader:wt.backgroundCube_vert,fragmentShader:wt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wt.cube_vert,fragmentShader:wt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wt.equirect_vert,fragmentShader:wt.equirect_frag},distance:{uniforms:Kn([qe.common,qe.displacementmap,{referencePosition:{value:new re},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wt.distance_vert,fragmentShader:wt.distance_frag},shadow:{uniforms:Kn([qe.lights,qe.fog,{color:{value:new ot(0)},opacity:{value:1}}]),vertexShader:wt.shadow_vert,fragmentShader:wt.shadow_frag}};oa.physical={uniforms:Kn([oa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new bt},clearcoatNormalScale:{value:new xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new bt},sheen:{value:0},sheenColor:{value:new ot(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new bt},transmissionSamplerSize:{value:new xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new bt},attenuationDistance:{value:0},attenuationColor:{value:new ot(0)},specularColor:{value:new ot(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new bt},anisotropyVector:{value:new xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new bt}}]),vertexShader:wt.meshphysical_vert,fragmentShader:wt.meshphysical_frag};const xu={r:0,b:0,g:0},tC=new cn,wy=new bt;wy.set(-1,0,0,0,1,0,0,0,1);function nC(a,e,n,s,l,c){const f=new ot(0);let p=l===!0?0:1,m,h,_=null,S=0,v=null;function M(P){let L=P.isScene===!0?P.background:null;if(L&&L.isTexture){const R=P.backgroundBlurriness>0;L=e.get(L,R)}return L}function E(P){let L=!1;const R=M(P);R===null?y(f,p):R&&R.isColor&&(y(R,1),L=!0);const I=a.xr.getEnvironmentBlendMode();I==="additive"?n.buffers.color.setClear(0,0,0,1,c):I==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,c),(a.autoClear||L)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function w(P,L){const R=M(L);R&&(R.isCubeTexture||R.mapping===Gu)?(h===void 0&&(h=new $i(new Us(1,1,1),new ha({name:"BackgroundCubeMaterial",uniforms:So(oa.backgroundCube.uniforms),vertexShader:oa.backgroundCube.vertexShader,fragmentShader:oa.backgroundCube.fragmentShader,side:ri,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(I,O,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=R,h.material.uniforms.backgroundBlurriness.value=L.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(tC.makeRotationFromEuler(L.backgroundRotation)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&h.material.uniforms.backgroundRotation.value.premultiply(wy),h.material.toneMapped=Gt.getTransfer(R.colorSpace)!==en,(_!==R||S!==R.version||v!==a.toneMapping)&&(h.material.needsUpdate=!0,_=R,S=R.version,v=a.toneMapping),h.layers.enableAll(),P.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(m===void 0&&(m=new $i(new Vu(2,2),new ha({name:"BackgroundMaterial",uniforms:So(oa.background.uniforms),vertexShader:oa.background.vertexShader,fragmentShader:oa.background.fragmentShader,side:Cs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),m.geometry.deleteAttribute("normal"),Object.defineProperty(m.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(m)),m.material.uniforms.t2D.value=R,m.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,m.material.toneMapped=Gt.getTransfer(R.colorSpace)!==en,R.matrixAutoUpdate===!0&&R.updateMatrix(),m.material.uniforms.uvTransform.value.copy(R.matrix),(_!==R||S!==R.version||v!==a.toneMapping)&&(m.material.needsUpdate=!0,_=R,S=R.version,v=a.toneMapping),m.layers.enableAll(),P.unshift(m,m.geometry,m.material,0,0,null))}function y(P,L){P.getRGB(xu,Ty(a)),n.buffers.color.setClear(xu.r,xu.g,xu.b,L,c)}function x(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),m!==void 0&&(m.geometry.dispose(),m.material.dispose(),m=void 0)}return{getClearColor:function(){return f},setClearColor:function(P,L=1){f.set(P),p=L,y(f,p)},getClearAlpha:function(){return p},setClearAlpha:function(P){p=P,y(f,p)},render:E,addToRenderList:w,dispose:x}}function iC(a,e){const n=a.getParameter(a.MAX_VERTEX_ATTRIBS),s={},l=v(null);let c=l,f=!1;function p(V,Q,fe,pe,J){let G=!1;const j=S(V,pe,fe,Q);c!==j&&(c=j,h(c.object)),G=M(V,pe,fe,J),G&&E(V,pe,fe,J),J!==null&&e.update(J,a.ELEMENT_ARRAY_BUFFER),(G||f)&&(f=!1,R(V,Q,fe,pe),J!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.get(J).buffer))}function m(){return a.createVertexArray()}function h(V){return a.bindVertexArray(V)}function _(V){return a.deleteVertexArray(V)}function S(V,Q,fe,pe){const J=pe.wireframe===!0;let G=s[Q.id];G===void 0&&(G={},s[Q.id]=G);const j=V.isInstancedMesh===!0?V.id:0;let se=G[j];se===void 0&&(se={},G[j]=se);let Se=se[fe.id];Se===void 0&&(Se={},se[fe.id]=Se);let xe=Se[J];return xe===void 0&&(xe=v(m()),Se[J]=xe),xe}function v(V){const Q=[],fe=[],pe=[];for(let J=0;J<n;J++)Q[J]=0,fe[J]=0,pe[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:Q,enabledAttributes:fe,attributeDivisors:pe,object:V,attributes:{},index:null}}function M(V,Q,fe,pe){const J=c.attributes,G=Q.attributes;let j=0;const se=fe.getAttributes();for(const Se in se)if(se[Se].location>=0){const z=J[Se];let te=G[Se];if(te===void 0&&(Se==="instanceMatrix"&&V.instanceMatrix&&(te=V.instanceMatrix),Se==="instanceColor"&&V.instanceColor&&(te=V.instanceColor)),z===void 0||z.attribute!==te||te&&z.data!==te.data)return!0;j++}return c.attributesNum!==j||c.index!==pe}function E(V,Q,fe,pe){const J={},G=Q.attributes;let j=0;const se=fe.getAttributes();for(const Se in se)if(se[Se].location>=0){let z=G[Se];z===void 0&&(Se==="instanceMatrix"&&V.instanceMatrix&&(z=V.instanceMatrix),Se==="instanceColor"&&V.instanceColor&&(z=V.instanceColor));const te={};te.attribute=z,z&&z.data&&(te.data=z.data),J[Se]=te,j++}c.attributes=J,c.attributesNum=j,c.index=pe}function w(){const V=c.newAttributes;for(let Q=0,fe=V.length;Q<fe;Q++)V[Q]=0}function y(V){x(V,0)}function x(V,Q){const fe=c.newAttributes,pe=c.enabledAttributes,J=c.attributeDivisors;fe[V]=1,pe[V]===0&&(a.enableVertexAttribArray(V),pe[V]=1),J[V]!==Q&&(a.vertexAttribDivisor(V,Q),J[V]=Q)}function P(){const V=c.newAttributes,Q=c.enabledAttributes;for(let fe=0,pe=Q.length;fe<pe;fe++)Q[fe]!==V[fe]&&(a.disableVertexAttribArray(fe),Q[fe]=0)}function L(V,Q,fe,pe,J,G,j){j===!0?a.vertexAttribIPointer(V,Q,fe,J,G):a.vertexAttribPointer(V,Q,fe,pe,J,G)}function R(V,Q,fe,pe){w();const J=pe.attributes,G=fe.getAttributes(),j=Q.defaultAttributeValues;for(const se in G){const Se=G[se];if(Se.location>=0){let xe=J[se];if(xe===void 0&&(se==="instanceMatrix"&&V.instanceMatrix&&(xe=V.instanceMatrix),se==="instanceColor"&&V.instanceColor&&(xe=V.instanceColor)),xe!==void 0){const z=xe.normalized,te=xe.itemSize,Ee=e.get(xe);if(Ee===void 0)continue;const Oe=Ee.buffer,He=Ee.type,le=Ee.bytesPerElement,Me=He===a.INT||He===a.UNSIGNED_INT||xe.gpuType===$p;if(xe.isInterleavedBufferAttribute){const Ae=xe.data,je=Ae.stride,rt=xe.offset;if(Ae.isInstancedInterleavedBuffer){for(let $e=0;$e<Se.locationSize;$e++)x(Se.location+$e,Ae.meshPerAttribute);V.isInstancedMesh!==!0&&pe._maxInstanceCount===void 0&&(pe._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let $e=0;$e<Se.locationSize;$e++)y(Se.location+$e);a.bindBuffer(a.ARRAY_BUFFER,Oe);for(let $e=0;$e<Se.locationSize;$e++)L(Se.location+$e,te/Se.locationSize,He,z,je*le,(rt+te/Se.locationSize*$e)*le,Me)}else{if(xe.isInstancedBufferAttribute){for(let Ae=0;Ae<Se.locationSize;Ae++)x(Se.location+Ae,xe.meshPerAttribute);V.isInstancedMesh!==!0&&pe._maxInstanceCount===void 0&&(pe._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let Ae=0;Ae<Se.locationSize;Ae++)y(Se.location+Ae);a.bindBuffer(a.ARRAY_BUFFER,Oe);for(let Ae=0;Ae<Se.locationSize;Ae++)L(Se.location+Ae,te/Se.locationSize,He,z,te*le,te/Se.locationSize*Ae*le,Me)}}else if(j!==void 0){const z=j[se];if(z!==void 0)switch(z.length){case 2:a.vertexAttrib2fv(Se.location,z);break;case 3:a.vertexAttrib3fv(Se.location,z);break;case 4:a.vertexAttrib4fv(Se.location,z);break;default:a.vertexAttrib1fv(Se.location,z)}}}}P()}function I(){N();for(const V in s){const Q=s[V];for(const fe in Q){const pe=Q[fe];for(const J in pe){const G=pe[J];for(const j in G)_(G[j].object),delete G[j];delete pe[J]}}delete s[V]}}function O(V){if(s[V.id]===void 0)return;const Q=s[V.id];for(const fe in Q){const pe=Q[fe];for(const J in pe){const G=pe[J];for(const j in G)_(G[j].object),delete G[j];delete pe[J]}}delete s[V.id]}function U(V){for(const Q in s){const fe=s[Q];for(const pe in fe){const J=fe[pe];if(J[V.id]===void 0)continue;const G=J[V.id];for(const j in G)_(G[j].object),delete G[j];delete J[V.id]}}}function A(V){for(const Q in s){const fe=s[Q],pe=V.isInstancedMesh===!0?V.id:0,J=fe[pe];if(J!==void 0){for(const G in J){const j=J[G];for(const se in j)_(j[se].object),delete j[se];delete J[G]}delete fe[pe],Object.keys(fe).length===0&&delete s[Q]}}}function N(){k(),f=!0,c!==l&&(c=l,h(c.object))}function k(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:p,reset:N,resetDefaultState:k,dispose:I,releaseStatesOfGeometry:O,releaseStatesOfObject:A,releaseStatesOfProgram:U,initAttributes:w,enableAttribute:y,disableUnusedAttributes:P}}function aC(a,e,n){let s;function l(m){s=m}function c(m,h){a.drawArrays(s,m,h),n.update(h,s,1)}function f(m,h,_){_!==0&&(a.drawArraysInstanced(s,m,h,_),n.update(h,s,_))}function p(m,h,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s,m,0,h,0,_);let v=0;for(let M=0;M<_;M++)v+=h[M];n.update(v,s,1)}this.setMode=l,this.render=c,this.renderInstances=f,this.renderMultiDraw=p}function sC(a,e,n,s){let l;function c(){if(l!==void 0)return l;if(e.has("EXT_texture_filter_anisotropic")===!0){const U=e.get("EXT_texture_filter_anisotropic");l=a.getParameter(U.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else l=0;return l}function f(U){return!(U!==Yi&&s.convert(U)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function p(U){const A=U===Wa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(U!==Si&&s.convert(U)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&U!==qi&&!A)}function m(U){if(U==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";U="mediump"}return U==="mediump"&&a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=n.precision!==void 0?n.precision:"highp";const _=m(h);_!==h&&(mt("WebGLRenderer:",h,"not supported, using",_,"instead."),h=_);const S=n.logarithmicDepthBuffer===!0,v=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control");n.reversedDepthBuffer===!0&&v===!1&&mt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const M=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),E=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),w=a.getParameter(a.MAX_TEXTURE_SIZE),y=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),x=a.getParameter(a.MAX_VERTEX_ATTRIBS),P=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),L=a.getParameter(a.MAX_VARYING_VECTORS),R=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),I=a.getParameter(a.MAX_SAMPLES),O=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:c,getMaxPrecision:m,textureFormatReadable:f,textureTypeReadable:p,precision:h,logarithmicDepthBuffer:S,reversedDepthBuffer:v,maxTextures:M,maxVertexTextures:E,maxTextureSize:w,maxCubemapSize:y,maxAttributes:x,maxVertexUniforms:P,maxVaryings:L,maxFragmentUniforms:R,maxSamples:I,samples:O}}function rC(a){const e=this;let n=null,s=0,l=!1,c=!1;const f=new Es,p=new bt,m={value:null,needsUpdate:!1};this.uniform=m,this.numPlanes=0,this.numIntersection=0,this.init=function(S,v){const M=S.length!==0||v||s!==0||l;return l=v,s=S.length,M},this.beginShadows=function(){c=!0,_(null)},this.endShadows=function(){c=!1},this.setGlobalState=function(S,v){n=_(S,v,0)},this.setState=function(S,v,M){const E=S.clippingPlanes,w=S.clipIntersection,y=S.clipShadows,x=a.get(S);if(!l||E===null||E.length===0||c&&!y)c?_(null):h();else{const P=c?0:s,L=P*4;let R=x.clippingState||null;m.value=R,R=_(E,v,L,M);for(let I=0;I!==L;++I)R[I]=n[I];x.clippingState=R,this.numIntersection=w?this.numPlanes:0,this.numPlanes+=P}};function h(){m.value!==n&&(m.value=n,m.needsUpdate=s>0),e.numPlanes=s,e.numIntersection=0}function _(S,v,M,E){const w=S!==null?S.length:0;let y=null;if(w!==0){if(y=m.value,E!==!0||y===null){const x=M+w*4,P=v.matrixWorldInverse;p.getNormalMatrix(P),(y===null||y.length<x)&&(y=new Float32Array(x));for(let L=0,R=M;L!==w;++L,R+=4)f.copy(S[L]).applyMatrix4(P,p),f.normal.toArray(y,R),y[R+3]=f.constant}m.value=y,m.needsUpdate=!0}return e.numPlanes=w,e.numIntersection=0,y}}const As=4,nx=[.125,.215,.35,.446,.526,.582],tr=20,oC=256,bl=new dm,ix=new ot;let Oh=null,Ph=0,Ih=0,Bh=!1;const lC=new re;class ax{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,s=.1,l=100,c={}){const{size:f=256,position:p=lC}=c;Oh=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Ih=this._renderer.getActiveMipmapLevel(),Bh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(f);const m=this._allocateTargets();return m.depthBuffer=!0,this._sceneToCubeUV(e,s,l,m,p),n>0&&this._blur(m,0,0,n),this._applyPMREM(m),this._cleanup(m),m}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ox(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=rx(),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())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(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(Oh,Ph,Ih),this._renderer.xr.enabled=Bh,e.scissorTest=!1,ro(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===or||e.mapping===xo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Oh=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Ih=this._renderer.getActiveMipmapLevel(),Bh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const s=n||this._allocateTargets();return this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,s={magFilter:Yn,minFilter:Yn,generateMipmaps:!1,type:Wa,format:Yi,colorSpace:Uu,depthBuffer:!1},l=sx(e,n,s);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=sx(e,n,s);const{_lodMax:c}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=cC(c)),this._blurMaterial=fC(c,e,n),this._ggxMaterial=uC(c,e,n)}return l}_compileMaterial(e){const n=new $i(new Pi,e);this._renderer.compile(n,bl)}_sceneToCubeUV(e,n,s,l,c){const m=new Li(90,1,n,s),h=[1,-1,1,1,1,1],_=[1,1,1,-1,-1,-1],S=this._renderer,v=S.autoClear,M=S.toneMapping;S.getClearColor(ix),S.toneMapping=ca,S.autoClear=!1,S.state.buffers.depth.getReversed()&&(S.setRenderTarget(l),S.clearDepth(),S.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new $i(new Us,new lm({name:"PMREM.Background",side:ri,depthWrite:!1,depthTest:!1})));const w=this._backgroundBox,y=w.material;let x=!1;const P=e.background;P?P.isColor&&(y.color.copy(P),e.background=null,x=!0):(y.color.copy(ix),x=!0);for(let L=0;L<6;L++){const R=L%3;R===0?(m.up.set(0,h[L],0),m.position.set(c.x,c.y,c.z),m.lookAt(c.x+_[L],c.y,c.z)):R===1?(m.up.set(0,0,h[L]),m.position.set(c.x,c.y,c.z),m.lookAt(c.x,c.y+_[L],c.z)):(m.up.set(0,h[L],0),m.position.set(c.x,c.y,c.z),m.lookAt(c.x,c.y,c.z+_[L]));const I=this._cubeSize;ro(l,R*I,L>2?I:0,I,I),S.setRenderTarget(l),x&&S.render(w,m),S.render(e,m)}S.toneMapping=M,S.autoClear=v,e.background=P}_textureToCubeUV(e,n){const s=this._renderer,l=e.mapping===or||e.mapping===xo;l?(this._cubemapMaterial===null&&(this._cubemapMaterial=ox()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=rx());const c=l?this._cubemapMaterial:this._equirectMaterial,f=this._lodMeshes[0];f.material=c;const p=c.uniforms;p.envMap.value=e;const m=this._cubeSize;ro(n,0,0,3*m,2*m),s.setRenderTarget(n),s.render(f,bl)}_applyPMREM(e){const n=this._renderer,s=n.autoClear;n.autoClear=!1;const l=this._lodMeshes.length;for(let c=1;c<l;c++)this._applyGGXFilter(e,c-1,c);n.autoClear=s}_applyGGXFilter(e,n,s){const l=this._renderer,c=this._pingPongRenderTarget,f=this._ggxMaterial,p=this._lodMeshes[s];p.material=f;const m=f.uniforms,h=s/(this._lodMeshes.length-1),_=n/(this._lodMeshes.length-1),S=Math.sqrt(h*h-_*_),v=0+h*1.25,M=S*v,{_lodMax:E}=this,w=this._sizeLods[s],y=3*w*(s>E-As?s-E+As:0),x=4*(this._cubeSize-w);m.envMap.value=e.texture,m.roughness.value=M,m.mipInt.value=E-n,ro(c,y,x,3*w,2*w),l.setRenderTarget(c),l.render(p,bl),m.envMap.value=c.texture,m.roughness.value=0,m.mipInt.value=E-s,ro(e,y,x,3*w,2*w),l.setRenderTarget(e),l.render(p,bl)}_blur(e,n,s,l,c){const f=this._pingPongRenderTarget;this._halfBlur(e,f,n,s,l,"latitudinal",c),this._halfBlur(f,e,s,s,l,"longitudinal",c)}_halfBlur(e,n,s,l,c,f,p){const m=this._renderer,h=this._blurMaterial;f!=="latitudinal"&&f!=="longitudinal"&&Vt("blur direction must be either latitudinal or longitudinal!");const _=3,S=this._lodMeshes[l];S.material=h;const v=h.uniforms,M=this._sizeLods[s]-1,E=isFinite(c)?Math.PI/(2*M):2*Math.PI/(2*tr-1),w=c/E,y=isFinite(c)?1+Math.floor(_*w):tr;y>tr&&mt(`sigmaRadians, ${c}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${tr}`);const x=[];let P=0;for(let U=0;U<tr;++U){const A=U/w,N=Math.exp(-A*A/2);x.push(N),U===0?P+=N:U<y&&(P+=2*N)}for(let U=0;U<x.length;U++)x[U]=x[U]/P;v.envMap.value=e.texture,v.samples.value=y,v.weights.value=x,v.latitudinal.value=f==="latitudinal",p&&(v.poleAxis.value=p);const{_lodMax:L}=this;v.dTheta.value=E,v.mipInt.value=L-s;const R=this._sizeLods[l],I=3*R*(l>L-As?l-L+As:0),O=4*(this._cubeSize-R);ro(n,I,O,3*R,2*R),m.setRenderTarget(n),m.render(S,bl)}}function cC(a){const e=[],n=[],s=[];let l=a;const c=a-As+1+nx.length;for(let f=0;f<c;f++){const p=Math.pow(2,l);e.push(p);let m=1/p;f>a-As?m=nx[f-a+As-1]:f===0&&(m=0),n.push(m);const h=1/(p-2),_=-h,S=1+h,v=[_,_,S,_,S,S,_,_,S,S,_,S],M=6,E=6,w=3,y=2,x=1,P=new Float32Array(w*E*M),L=new Float32Array(y*E*M),R=new Float32Array(x*E*M);for(let O=0;O<M;O++){const U=O%3*2/3-1,A=O>2?0:-1,N=[U,A,0,U+2/3,A,0,U+2/3,A+1,0,U,A,0,U+2/3,A+1,0,U,A+1,0];P.set(N,w*E*O),L.set(v,y*E*O);const k=[O,O,O,O,O,O];R.set(k,x*E*O)}const I=new Pi;I.setAttribute("position",new Zi(P,w)),I.setAttribute("uv",new Zi(L,y)),I.setAttribute("faceIndex",new Zi(R,x)),s.push(new $i(I,null)),l>As&&l--}return{lodMeshes:s,sizeLods:e,sigmas:n}}function sx(a,e,n){const s=new ua(a,e,n);return s.texture.mapping=Gu,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function ro(a,e,n,s,l){a.viewport.set(e,n,s,l),a.scissor.set(e,n,s,l)}function uC(a,e,n){return new ha({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:oC,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ku(),fragmentShader:`
precision highp float;
precision highp int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform float roughness;
uniform float mipInt;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
#define PI 3.14159265359
// Van der Corput radical inverse
float radicalInverse_VdC(uint bits) {
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
// Hammersley sequence
vec2 hammersley(uint i, uint N) {
return vec2(float(i) / float(N), radicalInverse_VdC(i));
}
// GGX VNDF importance sampling (Eric Heitz 2018)
// "Sampling the GGX Distribution of Visible Normals"
// https://jcgt.org/published/0007/04/01/
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
float alpha = roughness * roughness;
// Section 4.1: Orthonormal basis
vec3 T1 = vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(V, T1);
// Section 4.2: Parameterization of projected area
float r = sqrt(Xi.x);
float phi = 2.0 * PI * Xi.y;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + V.z);
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
// Section 3.4: Transform back to ellipsoid configuration
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
}
void main() {
vec3 N = normalize(vOutputDirection);
vec3 V = N; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3(0.0);
float totalWeight = 0.0;
// For very low roughness, just sample the environment directly
if (roughness < 0.001) {
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
return;
}
// Tangent space basis for VNDF sampling
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitangent = cross(N, tangent);
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
// Transform H back to world space
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float NdotL = max(dot(N, L), 0.0);
if(NdotL > 0.0) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL;
totalWeight += NdotL;
}
}
if (totalWeight > 0.0) {
prefilteredColor = prefilteredColor / totalWeight;
}
gl_FragColor = vec4(prefilteredColor, 1.0);
}
`,blending:ka,depthTest:!1,depthWrite:!1})}function fC(a,e,n){const s=new Float32Array(tr),l=new re(0,1,0);return new ha({name:"SphericalGaussianBlur",defines:{n:tr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:s},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:l}},vertexShader:ku(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:ka,depthTest:!1,depthWrite:!1})}function rx(){return new ha({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ku(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:ka,depthTest:!1,depthWrite:!1})}function ox(){return new ha({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ku(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:ka,depthTest:!1,depthWrite:!1})}function ku(){return`
precision mediump float;
precision mediump int;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}class Ry extends ua{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const s={width:e,height:e,depth:1},l=[s,s,s,s,s,s];this.texture=new by(l),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const s={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},l=new Us(5,5,5),c=new ha({name:"CubemapFromEquirect",uniforms:So(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:ri,blending:ka});c.uniforms.tEquirect.value=n;const f=new $i(l,c),p=n.minFilter;return n.minFilter===nr&&(n.minFilter=Yn),new mT(1,10,this).update(e,f),n.minFilter=p,f.geometry.dispose(),f.material.dispose(),this}clear(e,n=!0,s=!0,l=!0){const c=e.getRenderTarget();for(let f=0;f<6;f++)e.setRenderTarget(this,f),e.clear(n,s,l);e.setRenderTarget(c)}}function dC(a){let e=new WeakMap,n=new WeakMap,s=null;function l(v,M=!1){return v==null?null:M?f(v):c(v)}function c(v){if(v&&v.isTexture){const M=v.mapping;if(M===sh||M===rh)if(e.has(v)){const E=e.get(v).texture;return p(E,v.mapping)}else{const E=v.image;if(E&&E.height>0){const w=new Ry(E.height);return w.fromEquirectangularTexture(a,v),e.set(v,w),v.addEventListener("dispose",h),p(w.texture,v.mapping)}else return null}}return v}function f(v){if(v&&v.isTexture){const M=v.mapping,E=M===sh||M===rh,w=M===or||M===xo;if(E||w){let y=n.get(v);const x=y!==void 0?y.texture.pmremVersion:0;if(v.isRenderTargetTexture&&v.pmremVersion!==x)return s===null&&(s=new ax(a)),y=E?s.fromEquirectangular(v,y):s.fromCubemap(v,y),y.texture.pmremVersion=v.pmremVersion,n.set(v,y),y.texture;if(y!==void 0)return y.texture;{const P=v.image;return E&&P&&P.height>0||w&&P&&m(P)?(s===null&&(s=new ax(a)),y=E?s.fromEquirectangular(v):s.fromCubemap(v),y.texture.pmremVersion=v.pmremVersion,n.set(v,y),v.addEventListener("dispose",_),y.texture):null}}}return v}function p(v,M){return M===sh?v.mapping=or:M===rh&&(v.mapping=xo),v}function m(v){let M=0;const E=6;for(let w=0;w<E;w++)v[w]!==void 0&&M++;return M===E}function h(v){const M=v.target;M.removeEventListener("dispose",h);const E=e.get(M);E!==void 0&&(e.delete(M),E.dispose())}function _(v){const M=v.target;M.removeEventListener("dispose",_);const E=n.get(M);E!==void 0&&(n.delete(M),E.dispose())}function S(){e=new WeakMap,n=new WeakMap,s!==null&&(s.dispose(),s=null)}return{get:l,dispose:S}}function hC(a){const e={};function n(s){if(e[s]!==void 0)return e[s];const l=a.getExtension(s);return e[s]=l,l}return{has:function(s){return n(s)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(s){const l=n(s);return l===null&&po("WebGLRenderer: "+s+" extension not supported."),l}}}function pC(a,e,n,s){const l={},c=new WeakMap;function f(S){const v=S.target;v.index!==null&&e.remove(v.index);for(const E in v.attributes)e.remove(v.attributes[E]);v.removeEventListener("dispose",f),delete l[v.id];const M=c.get(v);M&&(e.remove(M),c.delete(v)),s.releaseStatesOfGeometry(v),v.isInstancedBufferGeometry===!0&&delete v._maxInstanceCount,n.memory.geometries--}function p(S,v){return l[v.id]===!0||(v.addEventListener("dispose",f),l[v.id]=!0,n.memory.geometries++),v}function m(S){const v=S.attributes;for(const M in v)e.update(v[M],a.ARRAY_BUFFER)}function h(S){const v=[],M=S.index,E=S.attributes.position;let w=0;if(E===void 0)return;if(M!==null){const P=M.array;w=M.version;for(let L=0,R=P.length;L<R;L+=3){const I=P[L+0],O=P[L+1],U=P[L+2];v.push(I,O,O,U,U,I)}}else{const P=E.array;w=E.version;for(let L=0,R=P.length/3-1;L<R;L+=3){const I=L+0,O=L+1,U=L+2;v.push(I,O,O,U,U,I)}}const y=new(E.count>=65535?xy:vy)(v,1);y.version=w;const x=c.get(S);x&&e.remove(x),c.set(S,y)}function _(S){const v=c.get(S);if(v){const M=S.index;M!==null&&v.version<M.version&&h(S)}else h(S);return c.get(S)}return{get:p,update:m,getWireframeAttribute:_}}function mC(a,e,n){let s;function l(S){s=S}let c,f;function p(S){c=S.type,f=S.bytesPerElement}function m(S,v){a.drawElements(s,v,c,S*f),n.update(v,s,1)}function h(S,v,M){M!==0&&(a.drawElementsInstanced(s,v,c,S*f,M),n.update(v,s,M))}function _(S,v,M){if(M===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(s,v,0,c,S,0,M);let w=0;for(let y=0;y<M;y++)w+=v[y];n.update(w,s,1)}this.setMode=l,this.setIndex=p,this.render=m,this.renderInstances=h,this.renderMultiDraw=_}function gC(a){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function s(c,f,p){switch(n.calls++,f){case a.TRIANGLES:n.triangles+=p*(c/3);break;case a.LINES:n.lines+=p*(c/2);break;case a.LINE_STRIP:n.lines+=p*(c-1);break;case a.LINE_LOOP:n.lines+=p*c;break;case a.POINTS:n.points+=p*c;break;default:Vt("WebGLInfo: Unknown draw mode:",f);break}}function l(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:l,update:s}}function _C(a,e,n){const s=new WeakMap,l=new gn;function c(f,p,m){const h=f.morphTargetInfluences,_=p.morphAttributes.position||p.morphAttributes.normal||p.morphAttributes.color,S=_!==void 0?_.length:0;let v=s.get(p);if(v===void 0||v.count!==S){let k=function(){A.dispose(),s.delete(p),p.removeEventListener("dispose",k)};var M=k;v!==void 0&&v.texture.dispose();const E=p.morphAttributes.position!==void 0,w=p.morphAttributes.normal!==void 0,y=p.morphAttributes.color!==void 0,x=p.morphAttributes.position||[],P=p.morphAttributes.normal||[],L=p.morphAttributes.color||[];let R=0;E===!0&&(R=1),w===!0&&(R=2),y===!0&&(R=3);let I=p.attributes.position.count*R,O=1;I>e.maxTextureSize&&(O=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const U=new Float32Array(I*O*4*S),A=new my(U,I,O,S);A.type=qi,A.needsUpdate=!0;const N=R*4;for(let V=0;V<S;V++){const Q=x[V],fe=P[V],pe=L[V],J=I*O*4*V;for(let G=0;G<Q.count;G++){const j=G*N;E===!0&&(l.fromBufferAttribute(Q,G),U[J+j+0]=l.x,U[J+j+1]=l.y,U[J+j+2]=l.z,U[J+j+3]=0),w===!0&&(l.fromBufferAttribute(fe,G),U[J+j+4]=l.x,U[J+j+5]=l.y,U[J+j+6]=l.z,U[J+j+7]=0),y===!0&&(l.fromBufferAttribute(pe,G),U[J+j+8]=l.x,U[J+j+9]=l.y,U[J+j+10]=l.z,U[J+j+11]=pe.itemSize===4?l.w:1)}}v={count:S,texture:A,size:new xt(I,O)},s.set(p,v),p.addEventListener("dispose",k)}if(f.isInstancedMesh===!0&&f.morphTexture!==null)m.getUniforms().setValue(a,"morphTexture",f.morphTexture,n);else{let E=0;for(let y=0;y<h.length;y++)E+=h[y];const w=p.morphTargetsRelative?1:1-E;m.getUniforms().setValue(a,"morphTargetBaseInfluence",w),m.getUniforms().setValue(a,"morphTargetInfluences",h)}m.getUniforms().setValue(a,"morphTargetsTexture",v.texture,n),m.getUniforms().setValue(a,"morphTargetsTextureSize",v.size)}return{update:c}}function vC(a,e,n,s,l){let c=new WeakMap;function f(h){const _=l.render.frame,S=h.geometry,v=e.get(h,S);if(c.get(v)!==_&&(e.update(v),c.set(v,_)),h.isInstancedMesh&&(h.hasEventListener("dispose",m)===!1&&h.addEventListener("dispose",m),c.get(h)!==_&&(n.update(h.instanceMatrix,a.ARRAY_BUFFER),h.instanceColor!==null&&n.update(h.instanceColor,a.ARRAY_BUFFER),c.set(h,_))),h.isSkinnedMesh){const M=h.skeleton;c.get(M)!==_&&(M.update(),c.set(M,_))}return v}function p(){c=new WeakMap}function m(h){const _=h.target;_.removeEventListener("dispose",m),s.releaseStatesOfObject(_),n.remove(_.instanceMatrix),_.instanceColor!==null&&n.remove(_.instanceColor)}return{update:f,dispose:p}}const xC={[ey]:"LINEAR_TONE_MAPPING",[ty]:"REINHARD_TONE_MAPPING",[ny]:"CINEON_TONE_MAPPING",[Kp]:"ACES_FILMIC_TONE_MAPPING",[ay]:"AGX_TONE_MAPPING",[sy]:"NEUTRAL_TONE_MAPPING",[iy]:"CUSTOM_TONE_MAPPING"};function yC(a,e,n,s,l,c){const f=new ua(e,n,{type:a,depthBuffer:l,stencilBuffer:c,samples:s?4:0,depthTexture:l?new yo(e,n):void 0}),p=new ua(e,n,{type:Wa,depthBuffer:!1,stencilBuffer:!1}),m=new Pi;m.setAttribute("position",new oi([-1,3,0,-1,-1,0,3,-1,0],3)),m.setAttribute("uv",new oi([0,2,0,0,2,0],2));const h=new oT({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
precision highp float;
uniform sampler2D tDiffuse;
varying vec2 vUv;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
#ifdef LINEAR_TONE_MAPPING
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
#elif defined( REINHARD_TONE_MAPPING )
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
#elif defined( CINEON_TONE_MAPPING )
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
#elif defined( ACES_FILMIC_TONE_MAPPING )
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
#elif defined( AGX_TONE_MAPPING )
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
#elif defined( NEUTRAL_TONE_MAPPING )
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
#elif defined( CUSTOM_TONE_MAPPING )
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
#endif
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`,depthTest:!1,depthWrite:!1}),_=new $i(m,h),S=new dm(-1,1,1,-1,0,1);let v=null,M=null,E=!1,w,y=null,x=[],P=!1;this.setSize=function(L,R){f.setSize(L,R),p.setSize(L,R);for(let I=0;I<x.length;I++){const O=x[I];O.setSize&&O.setSize(L,R)}},this.setEffects=function(L){x=L,P=x.length>0&&x[0].isRenderPass===!0;const R=f.width,I=f.height;for(let O=0;O<x.length;O++){const U=x[O];U.setSize&&U.setSize(R,I)}},this.begin=function(L,R){if(E||L.toneMapping===ca&&x.length===0)return!1;if(y=R,R!==null){const I=R.width,O=R.height;(f.width!==I||f.height!==O)&&this.setSize(I,O)}return P===!1&&L.setRenderTarget(f),w=L.toneMapping,L.toneMapping=ca,!0},this.hasRenderPass=function(){return P},this.end=function(L,R){L.toneMapping=w,E=!0;let I=f,O=p;for(let U=0;U<x.length;U++){const A=x[U];if(A.enabled!==!1&&(A.render(L,O,I,R),A.needsSwap!==!1)){const N=I;I=O,O=N}}if(v!==L.outputColorSpace||M!==L.toneMapping){v=L.outputColorSpace,M=L.toneMapping,h.defines={},Gt.getTransfer(v)===en&&(h.defines.SRGB_TRANSFER="");const U=xC[M];U&&(h.defines[U]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=I.texture,L.setRenderTarget(y),L.render(_,S),y=null,E=!1},this.isCompositing=function(){return E},this.dispose=function(){f.depthTexture&&f.depthTexture.dispose(),f.dispose(),p.dispose(),m.dispose(),h.dispose()}}const Dy=new $n,Ip=new yo(1,1),Ny=new my,Uy=new IE,Ly=new by,lx=[],cx=[],ux=new Float32Array(16),fx=new Float32Array(9),dx=new Float32Array(4);function To(a,e,n){const s=a[0];if(s<=0||s>0)return a;const l=e*n;let c=lx[l];if(c===void 0&&(c=new Float32Array(l),lx[l]=c),e!==0){s.toArray(c,0);for(let f=1,p=0;f!==e;++f)p+=n,a[f].toArray(c,p)}return c}function Un(a,e){if(a.length!==e.length)return!1;for(let n=0,s=a.length;n<s;n++)if(a[n]!==e[n])return!1;return!0}function Ln(a,e){for(let n=0,s=e.length;n<s;n++)a[n]=e[n]}function ju(a,e){let n=cx[e];n===void 0&&(n=new Int32Array(e),cx[e]=n);for(let s=0;s!==e;++s)n[s]=a.allocateTextureUnit();return n}function SC(a,e){const n=this.cache;n[0]!==e&&(a.uniform1f(this.addr,e),n[0]=e)}function MC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(a.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Un(n,e))return;a.uniform2fv(this.addr,e),Ln(n,e)}}function bC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(a.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(a.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Un(n,e))return;a.uniform3fv(this.addr,e),Ln(n,e)}}function EC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(a.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Un(n,e))return;a.uniform4fv(this.addr,e),Ln(n,e)}}function TC(a,e){const n=this.cache,s=e.elements;if(s===void 0){if(Un(n,e))return;a.uniformMatrix2fv(this.addr,!1,e),Ln(n,e)}else{if(Un(n,s))return;dx.set(s),a.uniformMatrix2fv(this.addr,!1,dx),Ln(n,s)}}function AC(a,e){const n=this.cache,s=e.elements;if(s===void 0){if(Un(n,e))return;a.uniformMatrix3fv(this.addr,!1,e),Ln(n,e)}else{if(Un(n,s))return;fx.set(s),a.uniformMatrix3fv(this.addr,!1,fx),Ln(n,s)}}function CC(a,e){const n=this.cache,s=e.elements;if(s===void 0){if(Un(n,e))return;a.uniformMatrix4fv(this.addr,!1,e),Ln(n,e)}else{if(Un(n,s))return;ux.set(s),a.uniformMatrix4fv(this.addr,!1,ux),Ln(n,s)}}function wC(a,e){const n=this.cache;n[0]!==e&&(a.uniform1i(this.addr,e),n[0]=e)}function RC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(a.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Un(n,e))return;a.uniform2iv(this.addr,e),Ln(n,e)}}function DC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(a.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Un(n,e))return;a.uniform3iv(this.addr,e),Ln(n,e)}}function NC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(a.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Un(n,e))return;a.uniform4iv(this.addr,e),Ln(n,e)}}function UC(a,e){const n=this.cache;n[0]!==e&&(a.uniform1ui(this.addr,e),n[0]=e)}function LC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(a.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Un(n,e))return;a.uniform2uiv(this.addr,e),Ln(n,e)}}function OC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(a.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Un(n,e))return;a.uniform3uiv(this.addr,e),Ln(n,e)}}function PC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(a.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Un(n,e))return;a.uniform4uiv(this.addr,e),Ln(n,e)}}function IC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l);let c;this.type===a.SAMPLER_2D_SHADOW?(Ip.compareFunction=n.isReversedDepthBuffer()?sm:am,c=Ip):c=Dy,n.setTexture2D(e||c,l)}function BC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),n.setTexture3D(e||Uy,l)}function FC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),n.setTextureCube(e||Ly,l)}function zC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),n.setTexture2DArray(e||Ny,l)}function HC(a){switch(a){case 5126:return SC;case 35664:return MC;case 35665:return bC;case 35666:return EC;case 35674:return TC;case 35675:return AC;case 35676:return CC;case 5124:case 35670:return wC;case 35667:case 35671:return RC;case 35668:case 35672:return DC;case 35669:case 35673:return NC;case 5125:return UC;case 36294:return LC;case 36295:return OC;case 36296:return PC;case 35678:case 36198:case 36298:case 36306:case 35682:return IC;case 35679:case 36299:case 36307:return BC;case 35680:case 36300:case 36308:case 36293:return FC;case 36289:case 36303:case 36311:case 36292:return zC}}function GC(a,e){a.uniform1fv(this.addr,e)}function VC(a,e){const n=To(e,this.size,2);a.uniform2fv(this.addr,n)}function kC(a,e){const n=To(e,this.size,3);a.uniform3fv(this.addr,n)}function jC(a,e){const n=To(e,this.size,4);a.uniform4fv(this.addr,n)}function XC(a,e){const n=To(e,this.size,4);a.uniformMatrix2fv(this.addr,!1,n)}function WC(a,e){const n=To(e,this.size,9);a.uniformMatrix3fv(this.addr,!1,n)}function qC(a,e){const n=To(e,this.size,16);a.uniformMatrix4fv(this.addr,!1,n)}function YC(a,e){a.uniform1iv(this.addr,e)}function ZC(a,e){a.uniform2iv(this.addr,e)}function KC(a,e){a.uniform3iv(this.addr,e)}function $C(a,e){a.uniform4iv(this.addr,e)}function QC(a,e){a.uniform1uiv(this.addr,e)}function JC(a,e){a.uniform2uiv(this.addr,e)}function ew(a,e){a.uniform3uiv(this.addr,e)}function tw(a,e){a.uniform4uiv(this.addr,e)}function nw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Un(s,c)||(a.uniform1iv(this.addr,c),Ln(s,c));let f;this.type===a.SAMPLER_2D_SHADOW?f=Ip:f=Dy;for(let p=0;p!==l;++p)n.setTexture2D(e[p]||f,c[p])}function iw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Un(s,c)||(a.uniform1iv(this.addr,c),Ln(s,c));for(let f=0;f!==l;++f)n.setTexture3D(e[f]||Uy,c[f])}function aw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Un(s,c)||(a.uniform1iv(this.addr,c),Ln(s,c));for(let f=0;f!==l;++f)n.setTextureCube(e[f]||Ly,c[f])}function sw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Un(s,c)||(a.uniform1iv(this.addr,c),Ln(s,c));for(let f=0;f!==l;++f)n.setTexture2DArray(e[f]||Ny,c[f])}function rw(a){switch(a){case 5126:return GC;case 35664:return VC;case 35665:return kC;case 35666:return jC;case 35674:return XC;case 35675:return WC;case 35676:return qC;case 5124:case 35670:return YC;case 35667:case 35671:return ZC;case 35668:case 35672:return KC;case 35669:case 35673:return $C;case 5125:return QC;case 36294:return JC;case 36295:return ew;case 36296:return tw;case 35678:case 36198:case 36298:case 36306:case 35682:return nw;case 35679:case 36299:case 36307:return iw;case 35680:case 36300:case 36308:case 36293:return aw;case 36289:case 36303:case 36311:case 36292:return sw}}class ow{constructor(e,n,s){this.id=e,this.addr=s,this.cache=[],this.type=n.type,this.setValue=HC(n.type)}}class lw{constructor(e,n,s){this.id=e,this.addr=s,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=rw(n.type)}}class cw{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,s){const l=this.seq;for(let c=0,f=l.length;c!==f;++c){const p=l[c];p.setValue(e,n[p.id],s)}}}const Fh=/(\w+)(\])?(\[|\.)?/g;function hx(a,e){a.seq.push(e),a.map[e.id]=e}function uw(a,e,n){const s=a.name,l=s.length;for(Fh.lastIndex=0;;){const c=Fh.exec(s),f=Fh.lastIndex;let p=c[1];const m=c[2]==="]",h=c[3];if(m&&(p=p|0),h===void 0||h==="["&&f+2===l){hx(n,h===void 0?new ow(p,a,e):new lw(p,a,e));break}else{let S=n.map[p];S===void 0&&(S=new cw(p),hx(n,S)),n=S}}}class wu{constructor(e,n){this.seq=[],this.map={};const s=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let f=0;f<s;++f){const p=e.getActiveUniform(n,f),m=e.getUniformLocation(n,p.name);uw(p,m,this)}const l=[],c=[];for(const f of this.seq)f.type===e.SAMPLER_2D_SHADOW||f.type===e.SAMPLER_CUBE_SHADOW||f.type===e.SAMPLER_2D_ARRAY_SHADOW?l.push(f):c.push(f);l.length>0&&(this.seq=l.concat(c))}setValue(e,n,s,l){const c=this.map[n];c!==void 0&&c.setValue(e,s,l)}setOptional(e,n,s){const l=n[s];l!==void 0&&this.setValue(e,s,l)}static upload(e,n,s,l){for(let c=0,f=n.length;c!==f;++c){const p=n[c],m=s[p.id];m.needsUpdate!==!1&&p.setValue(e,m.value,l)}}static seqWithValue(e,n){const s=[];for(let l=0,c=e.length;l!==c;++l){const f=e[l];f.id in n&&s.push(f)}return s}}function px(a,e,n){const s=a.createShader(e);return a.shaderSource(s,n),a.compileShader(s),s}const fw=37297;let dw=0;function hw(a,e){const n=a.split(`
`),s=[],l=Math.max(e-6,0),c=Math.min(e+6,n.length);for(let f=l;f<c;f++){const p=f+1;s.push(`${p===e?">":" "} ${p}: ${n[f]}`)}return s.join(`
`)}const mx=new bt;function pw(a){Gt._getMatrix(mx,Gt.workingColorSpace,a);const e=`mat3( ${mx.elements.map(n=>n.toFixed(4))} )`;switch(Gt.getTransfer(a)){case Lu:return[e,"LinearTransferOETF"];case en:return[e,"sRGBTransferOETF"];default:return mt("WebGLProgram: Unsupported color space: ",a),[e,"LinearTransferOETF"]}}function gx(a,e,n){const s=a.getShaderParameter(e,a.COMPILE_STATUS),c=(a.getShaderInfoLog(e)||"").trim();if(s&&c==="")return"";const f=/ERROR: 0:(\d+)/.exec(c);if(f){const p=parseInt(f[1]);return n.toUpperCase()+`
`+c+`
`+hw(a.getShaderSource(e),p)}else return c}function mw(a,e){const n=pw(e);return[`vec4 ${a}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
`)}const gw={[ey]:"Linear",[ty]:"Reinhard",[ny]:"Cineon",[Kp]:"ACESFilmic",[ay]:"AgX",[sy]:"Neutral",[iy]:"Custom"};function _w(a,e){const n=gw[e];return n===void 0?(mt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const yu=new re;function vw(){Gt.getLuminanceCoefficients(yu);const a=yu.x.toFixed(4),e=yu.y.toFixed(4),n=yu.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${a}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
`)}function xw(a){return[a.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",a.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Al).join(`
`)}function yw(a){const e=[];for(const n in a){const s=a[n];s!==!1&&e.push("#define "+n+" "+s)}return e.join(`
`)}function Sw(a,e){const n={},s=a.getProgramParameter(e,a.ACTIVE_ATTRIBUTES);for(let l=0;l<s;l++){const c=a.getActiveAttrib(e,l),f=c.name;let p=1;c.type===a.FLOAT_MAT2&&(p=2),c.type===a.FLOAT_MAT3&&(p=3),c.type===a.FLOAT_MAT4&&(p=4),n[f]={type:c.type,location:a.getAttribLocation(e,f),locationSize:p}}return n}function Al(a){return a!==""}function _x(a,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return a.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function vx(a,e){return a.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Mw=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bp(a){return a.replace(Mw,Ew)}const bw=new Map;function Ew(a,e){let n=wt[e];if(n===void 0){const s=bw.get(e);if(s!==void 0)n=wt[s],mt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,s);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Bp(n)}const Tw=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function xx(a){return a.replace(Tw,Aw)}function Aw(a,e,n,s){let l="";for(let c=parseInt(e);c<parseInt(n);c++)l+=s.replace(/\[\s*i\s*\]/g,"[ "+c+" ]").replace(/UNROLLED_LOOP_INDEX/g,c);return l}function yx(a){let e=`precision ${a.precision} float;
precision ${a.precision} int;
precision ${a.precision} sampler2D;
precision ${a.precision} samplerCube;
precision ${a.precision} sampler3D;
precision ${a.precision} sampler2DArray;
precision ${a.precision} sampler2DShadow;
precision ${a.precision} samplerCubeShadow;
precision ${a.precision} sampler2DArrayShadow;
precision ${a.precision} isampler2D;
precision ${a.precision} isampler3D;
precision ${a.precision} isamplerCube;
precision ${a.precision} isampler2DArray;
precision ${a.precision} usampler2D;
precision ${a.precision} usampler3D;
precision ${a.precision} usamplerCube;
precision ${a.precision} usampler2DArray;
`;return a.precision==="highp"?e+=`
#define HIGH_PRECISION`:a.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:a.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}const Cw={[bu]:"SHADOWMAP_TYPE_PCF",[Tl]:"SHADOWMAP_TYPE_VSM"};function ww(a){return Cw[a.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const Rw={[or]:"ENVMAP_TYPE_CUBE",[xo]:"ENVMAP_TYPE_CUBE",[Gu]:"ENVMAP_TYPE_CUBE_UV"};function Dw(a){return a.envMap===!1?"ENVMAP_TYPE_CUBE":Rw[a.envMapMode]||"ENVMAP_TYPE_CUBE"}const Nw={[xo]:"ENVMAP_MODE_REFRACTION"};function Uw(a){return a.envMap===!1?"ENVMAP_MODE_REFLECTION":Nw[a.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Lw={[Jx]:"ENVMAP_BLENDING_MULTIPLY",[pE]:"ENVMAP_BLENDING_MIX",[mE]:"ENVMAP_BLENDING_ADD"};function Ow(a){return a.envMap===!1?"ENVMAP_BLENDING_NONE":Lw[a.combine]||"ENVMAP_BLENDING_NONE"}function Pw(a){const e=a.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,s=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:s,maxMip:n}}function Iw(a,e,n,s){const l=a.getContext(),c=n.defines;let f=n.vertexShader,p=n.fragmentShader;const m=ww(n),h=Dw(n),_=Uw(n),S=Ow(n),v=Pw(n),M=xw(n),E=yw(c),w=l.createProgram();let y,x,P=n.glslVersion?"#version "+n.glslVersion+`
`:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E].filter(Al).join(`
`),y.length>0&&(y+=`
`),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E].filter(Al).join(`
`),x.length>0&&(x+=`
`)):(y=[yx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+_:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(Al).join(`
`),x=[yx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+_:"",n.envMap?"#define "+S:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ca?"#define TONE_MAPPING":"",n.toneMapping!==ca?wt.tonemapping_pars_fragment:"",n.toneMapping!==ca?_w("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wt.colorspace_pars_fragment,mw("linearToOutputTexel",n.outputColorSpace),vw(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(Al).join(`
`)),f=Bp(f),f=_x(f,n),f=vx(f,n),p=Bp(p),p=_x(p,n),p=vx(p,n),f=xx(f),p=xx(p),n.isRawShaderMaterial!==!0&&(P=`#version 300 es
`,y=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+y,x=["#define varying in",n.glslVersion===bv?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===bv?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+x);const L=P+y+f,R=P+x+p,I=px(l,l.VERTEX_SHADER,L),O=px(l,l.FRAGMENT_SHADER,R);l.attachShader(w,I),l.attachShader(w,O),n.index0AttributeName!==void 0?l.bindAttribLocation(w,0,n.index0AttributeName):n.hasPositionAttribute===!0&&l.bindAttribLocation(w,0,"position"),l.linkProgram(w);function U(V){if(a.debug.checkShaderErrors){const Q=l.getProgramInfoLog(w)||"",fe=l.getShaderInfoLog(I)||"",pe=l.getShaderInfoLog(O)||"",J=Q.trim(),G=fe.trim(),j=pe.trim();let se=!0,Se=!0;if(l.getProgramParameter(w,l.LINK_STATUS)===!1)if(se=!1,typeof a.debug.onShaderError=="function")a.debug.onShaderError(l,w,I,O);else{const xe=gx(l,I,"vertex"),z=gx(l,O,"fragment");Vt("WebGLProgram: Shader Error "+l.getError()+" - VALIDATE_STATUS "+l.getProgramParameter(w,l.VALIDATE_STATUS)+`
Material Name: `+V.name+`
Material Type: `+V.type+`
Program Info Log: `+J+`
`+xe+`
`+z)}else J!==""?mt("WebGLProgram: Program Info Log:",J):(G===""||j==="")&&(Se=!1);Se&&(V.diagnostics={runnable:se,programLog:J,vertexShader:{log:G,prefix:y},fragmentShader:{log:j,prefix:x}})}l.deleteShader(I),l.deleteShader(O),A=new wu(l,w),N=Sw(l,w)}let A;this.getUniforms=function(){return A===void 0&&U(this),A};let N;this.getAttributes=function(){return N===void 0&&U(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=l.getProgramParameter(w,fw)),k},this.destroy=function(){s.releaseStatesOfProgram(this),l.deleteProgram(w),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=dw++,this.cacheKey=e,this.usedTimes=1,this.program=w,this.vertexShader=I,this.fragmentShader=O,this}let Bw=0;class Fw{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,n,s){const l=this._getShaderCacheForMaterial(e);return l.has(n)===!1&&(l.add(n),n.usedTimes++),l.has(s)===!1&&(l.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const s of n)s.usedTimes--,s.usedTimes===0&&this.shaderCache.delete(s.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let s=n.get(e);return s===void 0&&(s=new Set,n.set(e,s)),s}_getShaderStage(e){const n=this.shaderCache;let s=n.get(e);return s===void 0&&(s=new zw(e),n.set(e,s)),s}}class zw{constructor(e){this.id=Bw++,this.code=e,this.usedTimes=0}}function Hw(a){return a===lr||a===Du||a===Nu}function Gw(a,e,n,s,l,c){const f=new gy,p=new Fw,m=new Set,h=[],_=new Map,S=s.logarithmicDepthBuffer;let v=s.precision;const M={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function E(A){return m.add(A),A===0?"uv":`uv${A}`}function w(A,N,k,V,Q,fe){const pe=V.fog,J=Q.geometry,G=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?V.environment:null,j=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap,se=e.get(A.envMap||G,j),Se=se&&se.mapping===Gu?se.image.height:null,xe=M[A.type];A.precision!==null&&(v=s.getMaxPrecision(A.precision),v!==A.precision&&mt("WebGLProgram.getParameters:",A.precision,"not supported, using",v,"instead."));const z=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,te=z!==void 0?z.length:0;let Ee=0;J.morphAttributes.position!==void 0&&(Ee=1),J.morphAttributes.normal!==void 0&&(Ee=2),J.morphAttributes.color!==void 0&&(Ee=3);let Oe,He,le,Me;if(xe){const Ye=oa[xe];Oe=Ye.vertexShader,He=Ye.fragmentShader}else{Oe=A.vertexShader,He=A.fragmentShader;const Ye=p.getVertexShaderStage(A),Yt=p.getFragmentShaderStage(A);p.update(A,Ye,Yt),le=Ye.id,Me=Yt.id}const Ae=a.getRenderTarget(),je=a.state.buffers.depth.getReversed(),rt=Q.isInstancedMesh===!0,$e=Q.isBatchedMesh===!0,Pt=!!A.map,gt=!!A.matcap,dt=!!se,yt=!!A.aoMap,ht=!!A.lightMap,It=!!A.bumpMap&&A.wireframe===!1,zt=!!A.normalMap,qt=!!A.displacementMap,rn=!!A.emissiveMap,ct=!!A.metalnessMap,K=!!A.roughnessMap,F=A.anisotropy>0,Ue=A.clearcoat>0,_t=A.dispersion>0,B=A.iridescence>0,C=A.sheen>0,ie=A.transmission>0,oe=F&&!!A.anisotropyMap,he=Ue&&!!A.clearcoatMap,Ne=Ue&&!!A.clearcoatNormalMap,Re=Ue&&!!A.clearcoatRoughnessMap,_e=B&&!!A.iridescenceMap,ve=B&&!!A.iridescenceThicknessMap,Ie=C&&!!A.sheenColorMap,Xe=C&&!!A.sheenRoughnessMap,Ve=!!A.specularMap,ge=!!A.specularColorMap,st=!!A.specularIntensityMap,Je=ie&&!!A.transmissionMap,tt=ie&&!!A.thicknessMap,Z=!!A.gradientMap,Le=!!A.alphaMap,ye=A.alphaTest>0,Fe=!!A.alphaHash,Ge=!!A.extensions;let Ce=ca;A.toneMapped&&(Ae===null||Ae.isXRRenderTarget===!0)&&(Ce=a.toneMapping);const Qe={shaderID:xe,shaderType:A.type,shaderName:A.name,vertexShader:Oe,fragmentShader:He,defines:A.defines,customVertexShaderID:le,customFragmentShaderID:Me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:v,batching:$e,batchingColor:$e&&Q._colorsTexture!==null,instancing:rt,instancingColor:rt&&Q.instanceColor!==null,instancingMorph:rt&&Q.morphTexture!==null,outputColorSpace:Ae===null?a.outputColorSpace:Ae.isXRRenderTarget===!0?Ae.texture.colorSpace:Gt.workingColorSpace,alphaToCoverage:!!A.alphaToCoverage,map:Pt,matcap:gt,envMap:dt,envMapMode:dt&&se.mapping,envMapCubeUVHeight:Se,aoMap:yt,lightMap:ht,bumpMap:It,normalMap:zt,displacementMap:qt,emissiveMap:rn,normalMapObjectSpace:zt&&A.normalMapType===vE,normalMapTangentSpace:zt&&A.normalMapType===Op,packedNormalMap:zt&&A.normalMapType===Op&&Hw(A.normalMap.format),metalnessMap:ct,roughnessMap:K,anisotropy:F,anisotropyMap:oe,clearcoat:Ue,clearcoatMap:he,clearcoatNormalMap:Ne,clearcoatRoughnessMap:Re,dispersion:_t,iridescence:B,iridescenceMap:_e,iridescenceThicknessMap:ve,sheen:C,sheenColorMap:Ie,sheenRoughnessMap:Xe,specularMap:Ve,specularColorMap:ge,specularIntensityMap:st,transmission:ie,transmissionMap:Je,thicknessMap:tt,gradientMap:Z,opaque:A.transparent===!1&&A.blending===ho&&A.alphaToCoverage===!1,alphaMap:Le,alphaTest:ye,alphaHash:Fe,combine:A.combine,mapUv:Pt&&E(A.map.channel),aoMapUv:yt&&E(A.aoMap.channel),lightMapUv:ht&&E(A.lightMap.channel),bumpMapUv:It&&E(A.bumpMap.channel),normalMapUv:zt&&E(A.normalMap.channel),displacementMapUv:qt&&E(A.displacementMap.channel),emissiveMapUv:rn&&E(A.emissiveMap.channel),metalnessMapUv:ct&&E(A.metalnessMap.channel),roughnessMapUv:K&&E(A.roughnessMap.channel),anisotropyMapUv:oe&&E(A.anisotropyMap.channel),clearcoatMapUv:he&&E(A.clearcoatMap.channel),clearcoatNormalMapUv:Ne&&E(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Re&&E(A.clearcoatRoughnessMap.channel),iridescenceMapUv:_e&&E(A.iridescenceMap.channel),iridescenceThicknessMapUv:ve&&E(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&E(A.sheenColorMap.channel),sheenRoughnessMapUv:Xe&&E(A.sheenRoughnessMap.channel),specularMapUv:Ve&&E(A.specularMap.channel),specularColorMapUv:ge&&E(A.specularColorMap.channel),specularIntensityMapUv:st&&E(A.specularIntensityMap.channel),transmissionMapUv:Je&&E(A.transmissionMap.channel),thicknessMapUv:tt&&E(A.thicknessMap.channel),alphaMapUv:Le&&E(A.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(zt||F),vertexNormals:!!J.attributes.normal,vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:Q.isPoints===!0&&!!J.attributes.uv&&(Pt||Le),fog:!!pe,useFog:A.fog===!0,fogExp2:!!pe&&pe.isFogExp2,flatShading:A.wireframe===!1&&(A.flatShading===!0||J.attributes.normal===void 0&&zt===!1&&(A.isMeshLambertMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isMeshPhysicalMaterial)),sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:S,reversedDepthBuffer:je,skinning:Q.isSkinnedMesh===!0,hasPositionAttribute:J.attributes.position!==void 0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:te,morphTextureStride:Ee,numDirLights:N.directional.length,numPointLights:N.point.length,numSpotLights:N.spot.length,numSpotLightMaps:N.spotLightMap.length,numRectAreaLights:N.rectArea.length,numHemiLights:N.hemi.length,numDirLightShadows:N.directionalShadowMap.length,numPointLightShadows:N.pointShadowMap.length,numSpotLightShadows:N.spotShadowMap.length,numSpotLightShadowsWithMaps:N.numSpotLightShadowsWithMaps,numLightProbes:N.numLightProbes,numLightProbeGrids:fe.length,numClippingPlanes:c.numPlanes,numClipIntersection:c.numIntersection,dithering:A.dithering,shadowMapEnabled:a.shadowMap.enabled&&k.length>0,shadowMapType:a.shadowMap.type,toneMapping:Ce,decodeVideoTexture:Pt&&A.map.isVideoTexture===!0&&Gt.getTransfer(A.map.colorSpace)===en,decodeVideoTextureEmissive:rn&&A.emissiveMap.isVideoTexture===!0&&Gt.getTransfer(A.emissiveMap.colorSpace)===en,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===Ha,flipSided:A.side===ri,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:Ge&&A.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ge&&A.extensions.multiDraw===!0||$e)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return Qe.vertexUv1s=m.has(1),Qe.vertexUv2s=m.has(2),Qe.vertexUv3s=m.has(3),m.clear(),Qe}function y(A){const N=[];if(A.shaderID?N.push(A.shaderID):(N.push(A.customVertexShaderID),N.push(A.customFragmentShaderID)),A.defines!==void 0)for(const k in A.defines)N.push(k),N.push(A.defines[k]);return A.isRawShaderMaterial===!1&&(x(N,A),P(N,A),N.push(a.outputColorSpace)),N.push(A.customProgramCacheKey),N.join()}function x(A,N){A.push(N.precision),A.push(N.outputColorSpace),A.push(N.envMapMode),A.push(N.envMapCubeUVHeight),A.push(N.mapUv),A.push(N.alphaMapUv),A.push(N.lightMapUv),A.push(N.aoMapUv),A.push(N.bumpMapUv),A.push(N.normalMapUv),A.push(N.displacementMapUv),A.push(N.emissiveMapUv),A.push(N.metalnessMapUv),A.push(N.roughnessMapUv),A.push(N.anisotropyMapUv),A.push(N.clearcoatMapUv),A.push(N.clearcoatNormalMapUv),A.push(N.clearcoatRoughnessMapUv),A.push(N.iridescenceMapUv),A.push(N.iridescenceThicknessMapUv),A.push(N.sheenColorMapUv),A.push(N.sheenRoughnessMapUv),A.push(N.specularMapUv),A.push(N.specularColorMapUv),A.push(N.specularIntensityMapUv),A.push(N.transmissionMapUv),A.push(N.thicknessMapUv),A.push(N.combine),A.push(N.fogExp2),A.push(N.sizeAttenuation),A.push(N.morphTargetsCount),A.push(N.morphAttributeCount),A.push(N.numDirLights),A.push(N.numPointLights),A.push(N.numSpotLights),A.push(N.numSpotLightMaps),A.push(N.numHemiLights),A.push(N.numRectAreaLights),A.push(N.numDirLightShadows),A.push(N.numPointLightShadows),A.push(N.numSpotLightShadows),A.push(N.numSpotLightShadowsWithMaps),A.push(N.numLightProbes),A.push(N.shadowMapType),A.push(N.toneMapping),A.push(N.numClippingPlanes),A.push(N.numClipIntersection),A.push(N.depthPacking)}function P(A,N){f.disableAll(),N.instancing&&f.enable(0),N.instancingColor&&f.enable(1),N.instancingMorph&&f.enable(2),N.matcap&&f.enable(3),N.envMap&&f.enable(4),N.normalMapObjectSpace&&f.enable(5),N.normalMapTangentSpace&&f.enable(6),N.clearcoat&&f.enable(7),N.iridescence&&f.enable(8),N.alphaTest&&f.enable(9),N.vertexColors&&f.enable(10),N.vertexAlphas&&f.enable(11),N.vertexUv1s&&f.enable(12),N.vertexUv2s&&f.enable(13),N.vertexUv3s&&f.enable(14),N.vertexTangents&&f.enable(15),N.anisotropy&&f.enable(16),N.alphaHash&&f.enable(17),N.batching&&f.enable(18),N.dispersion&&f.enable(19),N.batchingColor&&f.enable(20),N.gradientMap&&f.enable(21),N.packedNormalMap&&f.enable(22),N.vertexNormals&&f.enable(23),A.push(f.mask),f.disableAll(),N.fog&&f.enable(0),N.useFog&&f.enable(1),N.flatShading&&f.enable(2),N.logarithmicDepthBuffer&&f.enable(3),N.reversedDepthBuffer&&f.enable(4),N.skinning&&f.enable(5),N.morphTargets&&f.enable(6),N.morphNormals&&f.enable(7),N.morphColors&&f.enable(8),N.premultipliedAlpha&&f.enable(9),N.shadowMapEnabled&&f.enable(10),N.doubleSided&&f.enable(11),N.flipSided&&f.enable(12),N.useDepthPacking&&f.enable(13),N.dithering&&f.enable(14),N.transmission&&f.enable(15),N.sheen&&f.enable(16),N.opaque&&f.enable(17),N.pointsUvs&&f.enable(18),N.decodeVideoTexture&&f.enable(19),N.decodeVideoTextureEmissive&&f.enable(20),N.alphaToCoverage&&f.enable(21),N.numLightProbeGrids>0&&f.enable(22),N.hasPositionAttribute&&f.enable(23),A.push(f.mask)}function L(A){const N=M[A.type];let k;if(N){const V=oa[N];k=aT.clone(V.uniforms)}else k=A.uniforms;return k}function R(A,N){let k=_.get(N);return k!==void 0?++k.usedTimes:(k=new Iw(a,N,A,l),h.push(k),_.set(N,k)),k}function I(A){if(--A.usedTimes===0){const N=h.indexOf(A);h[N]=h[h.length-1],h.pop(),_.delete(A.cacheKey),A.destroy()}}function O(A){p.remove(A)}function U(){p.dispose()}return{getParameters:w,getProgramCacheKey:y,getUniforms:L,acquireProgram:R,releaseProgram:I,releaseShaderCache:O,programs:h,dispose:U}}function Vw(){let a=new WeakMap;function e(f){return a.has(f)}function n(f){let p=a.get(f);return p===void 0&&(p={},a.set(f,p)),p}function s(f){a.delete(f)}function l(f,p,m){a.get(f)[p]=m}function c(){a=new WeakMap}return{has:e,get:n,remove:s,update:l,dispose:c}}function kw(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.material.id!==e.material.id?a.material.id-e.material.id:a.materialVariant!==e.materialVariant?a.materialVariant-e.materialVariant:a.z!==e.z?a.z-e.z:a.id-e.id}function Sx(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.z!==e.z?e.z-a.z:a.id-e.id}function Mx(){const a=[];let e=0;const n=[],s=[],l=[];function c(){e=0,n.length=0,s.length=0,l.length=0}function f(v){let M=0;return v.isInstancedMesh&&(M+=2),v.isSkinnedMesh&&(M+=1),M}function p(v,M,E,w,y,x){let P=a[e];return P===void 0?(P={id:v.id,object:v,geometry:M,material:E,materialVariant:f(v),groupOrder:w,renderOrder:v.renderOrder,z:y,group:x},a[e]=P):(P.id=v.id,P.object=v,P.geometry=M,P.material=E,P.materialVariant=f(v),P.groupOrder=w,P.renderOrder=v.renderOrder,P.z=y,P.group=x),e++,P}function m(v,M,E,w,y,x){const P=p(v,M,E,w,y,x);E.transmission>0?s.push(P):E.transparent===!0?l.push(P):n.push(P)}function h(v,M,E,w,y,x){const P=p(v,M,E,w,y,x);E.transmission>0?s.unshift(P):E.transparent===!0?l.unshift(P):n.unshift(P)}function _(v,M,E){n.length>1&&n.sort(v||kw),s.length>1&&s.sort(M||Sx),l.length>1&&l.sort(M||Sx),E&&(n.reverse(),s.reverse(),l.reverse())}function S(){for(let v=e,M=a.length;v<M;v++){const E=a[v];if(E.id===null)break;E.id=null,E.object=null,E.geometry=null,E.material=null,E.group=null}}return{opaque:n,transmissive:s,transparent:l,init:c,push:m,unshift:h,finish:S,sort:_}}function jw(){let a=new WeakMap;function e(s,l){const c=a.get(s);let f;return c===void 0?(f=new Mx,a.set(s,[f])):l>=c.length?(f=new Mx,c.push(f)):f=c[l],f}function n(){a=new WeakMap}return{get:e,dispose:n}}function Xw(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new re,color:new ot};break;case"SpotLight":n={position:new re,direction:new re,color:new ot,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new re,color:new ot,distance:0,decay:0};break;case"HemisphereLight":n={direction:new re,skyColor:new ot,groundColor:new ot};break;case"RectAreaLight":n={color:new ot,position:new re,halfWidth:new re,halfHeight:new re};break}return a[e.id]=n,n}}}function Ww(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=n,n}}}let qw=0;function Yw(a,e){return(e.castShadow?2:0)-(a.castShadow?2:0)+(e.map?1:0)-(a.map?1:0)}function Zw(a){const e=new Xw,n=Ww(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)s.probe.push(new re);const l=new re,c=new cn,f=new cn;function p(h){let _=0,S=0,v=0;for(let N=0;N<9;N++)s.probe[N].set(0,0,0);let M=0,E=0,w=0,y=0,x=0,P=0,L=0,R=0,I=0,O=0,U=0;h.sort(Yw);for(let N=0,k=h.length;N<k;N++){const V=h[N],Q=V.color,fe=V.intensity,pe=V.distance;let J=null;if(V.shadow&&V.shadow.map&&(V.shadow.map.texture.format===lr?J=V.shadow.map.texture:J=V.shadow.map.depthTexture||V.shadow.map.texture),V.isAmbientLight)_+=Q.r*fe,S+=Q.g*fe,v+=Q.b*fe;else if(V.isLightProbe){for(let G=0;G<9;G++)s.probe[G].addScaledVector(V.sh.coefficients[G],fe);U++}else if(V.isDirectionalLight){const G=e.get(V);if(G.color.copy(V.color).multiplyScalar(V.intensity),V.castShadow){const j=V.shadow,se=n.get(V);se.shadowIntensity=j.intensity,se.shadowBias=j.bias,se.shadowNormalBias=j.normalBias,se.shadowRadius=j.radius,se.shadowMapSize=j.mapSize,s.directionalShadow[M]=se,s.directionalShadowMap[M]=J,s.directionalShadowMatrix[M]=V.shadow.matrix,P++}s.directional[M]=G,M++}else if(V.isSpotLight){const G=e.get(V);G.position.setFromMatrixPosition(V.matrixWorld),G.color.copy(Q).multiplyScalar(fe),G.distance=pe,G.coneCos=Math.cos(V.angle),G.penumbraCos=Math.cos(V.angle*(1-V.penumbra)),G.decay=V.decay,s.spot[w]=G;const j=V.shadow;if(V.map&&(s.spotLightMap[I]=V.map,I++,j.updateMatrices(V),V.castShadow&&O++),s.spotLightMatrix[w]=j.matrix,V.castShadow){const se=n.get(V);se.shadowIntensity=j.intensity,se.shadowBias=j.bias,se.shadowNormalBias=j.normalBias,se.shadowRadius=j.radius,se.shadowMapSize=j.mapSize,s.spotShadow[w]=se,s.spotShadowMap[w]=J,R++}w++}else if(V.isRectAreaLight){const G=e.get(V);G.color.copy(Q).multiplyScalar(fe),G.halfWidth.set(V.width*.5,0,0),G.halfHeight.set(0,V.height*.5,0),s.rectArea[y]=G,y++}else if(V.isPointLight){const G=e.get(V);if(G.color.copy(V.color).multiplyScalar(V.intensity),G.distance=V.distance,G.decay=V.decay,V.castShadow){const j=V.shadow,se=n.get(V);se.shadowIntensity=j.intensity,se.shadowBias=j.bias,se.shadowNormalBias=j.normalBias,se.shadowRadius=j.radius,se.shadowMapSize=j.mapSize,se.shadowCameraNear=j.camera.near,se.shadowCameraFar=j.camera.far,s.pointShadow[E]=se,s.pointShadowMap[E]=J,s.pointShadowMatrix[E]=V.shadow.matrix,L++}s.point[E]=G,E++}else if(V.isHemisphereLight){const G=e.get(V);G.skyColor.copy(V.color).multiplyScalar(fe),G.groundColor.copy(V.groundColor).multiplyScalar(fe),s.hemi[x]=G,x++}}y>0&&(a.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=qe.LTC_FLOAT_1,s.rectAreaLTC2=qe.LTC_FLOAT_2):(s.rectAreaLTC1=qe.LTC_HALF_1,s.rectAreaLTC2=qe.LTC_HALF_2)),s.ambient[0]=_,s.ambient[1]=S,s.ambient[2]=v;const A=s.hash;(A.directionalLength!==M||A.pointLength!==E||A.spotLength!==w||A.rectAreaLength!==y||A.hemiLength!==x||A.numDirectionalShadows!==P||A.numPointShadows!==L||A.numSpotShadows!==R||A.numSpotMaps!==I||A.numLightProbes!==U)&&(s.directional.length=M,s.spot.length=w,s.rectArea.length=y,s.point.length=E,s.hemi.length=x,s.directionalShadow.length=P,s.directionalShadowMap.length=P,s.pointShadow.length=L,s.pointShadowMap.length=L,s.spotShadow.length=R,s.spotShadowMap.length=R,s.directionalShadowMatrix.length=P,s.pointShadowMatrix.length=L,s.spotLightMatrix.length=R+I-O,s.spotLightMap.length=I,s.numSpotLightShadowsWithMaps=O,s.numLightProbes=U,A.directionalLength=M,A.pointLength=E,A.spotLength=w,A.rectAreaLength=y,A.hemiLength=x,A.numDirectionalShadows=P,A.numPointShadows=L,A.numSpotShadows=R,A.numSpotMaps=I,A.numLightProbes=U,s.version=qw++)}function m(h,_){let S=0,v=0,M=0,E=0,w=0;const y=_.matrixWorldInverse;for(let x=0,P=h.length;x<P;x++){const L=h[x];if(L.isDirectionalLight){const R=s.directional[S];R.direction.setFromMatrixPosition(L.matrixWorld),l.setFromMatrixPosition(L.target.matrixWorld),R.direction.sub(l),R.direction.transformDirection(y),S++}else if(L.isSpotLight){const R=s.spot[M];R.position.setFromMatrixPosition(L.matrixWorld),R.position.applyMatrix4(y),R.direction.setFromMatrixPosition(L.matrixWorld),l.setFromMatrixPosition(L.target.matrixWorld),R.direction.sub(l),R.direction.transformDirection(y),M++}else if(L.isRectAreaLight){const R=s.rectArea[E];R.position.setFromMatrixPosition(L.matrixWorld),R.position.applyMatrix4(y),f.identity(),c.copy(L.matrixWorld),c.premultiply(y),f.extractRotation(c),R.halfWidth.set(L.width*.5,0,0),R.halfHeight.set(0,L.height*.5,0),R.halfWidth.applyMatrix4(f),R.halfHeight.applyMatrix4(f),E++}else if(L.isPointLight){const R=s.point[v];R.position.setFromMatrixPosition(L.matrixWorld),R.position.applyMatrix4(y),v++}else if(L.isHemisphereLight){const R=s.hemi[w];R.direction.setFromMatrixPosition(L.matrixWorld),R.direction.transformDirection(y),w++}}}return{setup:p,setupView:m,state:s}}function bx(a){const e=new Zw(a),n=[],s=[],l=[];function c(v){S.camera=v,n.length=0,s.length=0,l.length=0}function f(v){n.push(v)}function p(v){s.push(v)}function m(v){l.push(v)}function h(){e.setup(n)}function _(v){e.setupView(n,v)}const S={lightsArray:n,shadowsArray:s,lightProbeGridArray:l,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:c,state:S,setupLights:h,setupLightsView:_,pushLight:f,pushShadow:p,pushLightProbeGrid:m}}function Kw(a){let e=new WeakMap;function n(l,c=0){const f=e.get(l);let p;return f===void 0?(p=new bx(a),e.set(l,[p])):c>=f.length?(p=new bx(a),f.push(p)):p=f[c],p}function s(){e=new WeakMap}return{get:n,dispose:s}}const $w=`void main() {
gl_Position = vec4( position, 1.0 );
}`,Qw=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
}`,Jw=[new re(1,0,0),new re(-1,0,0),new re(0,1,0),new re(0,-1,0),new re(0,0,1),new re(0,0,-1)],eR=[new re(0,-1,0),new re(0,-1,0),new re(0,0,1),new re(0,0,-1),new re(0,-1,0),new re(0,-1,0)],Ex=new cn,El=new re,zh=new re;function tR(a,e,n){let s=new cm;const l=new xt,c=new xt,f=new gn,p=new cT,m=new uT,h={},_=n.maxTextureSize,S={[Cs]:ri,[ri]:Cs,[Ha]:Ha},v=new ha({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xt},radius:{value:4}},vertexShader:$w,fragmentShader:Qw}),M=v.clone();M.defines.HORIZONTAL_PASS=1;const E=new Pi;E.setAttribute("position",new Zi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new $i(E,v),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bu;let x=this.type;this.render=function(O,U,A){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||O.length===0)return;this.type===Qx&&(mt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=bu);const N=a.getRenderTarget(),k=a.getActiveCubeFace(),V=a.getActiveMipmapLevel(),Q=a.state;Q.setBlending(ka),Q.buffers.depth.getReversed()===!0?Q.buffers.color.setClear(0,0,0,0):Q.buffers.color.setClear(1,1,1,1),Q.buffers.depth.setTest(!0),Q.setScissorTest(!1);const fe=x!==this.type;fe&&U.traverse(function(pe){pe.material&&(Array.isArray(pe.material)?pe.material.forEach(J=>J.needsUpdate=!0):pe.material.needsUpdate=!0)});for(let pe=0,J=O.length;pe<J;pe++){const G=O[pe],j=G.shadow;if(j===void 0){mt("WebGLShadowMap:",G,"has no shadow.");continue}if(j.autoUpdate===!1&&j.needsUpdate===!1)continue;l.copy(j.mapSize);const se=j.getFrameExtents();l.multiply(se),c.copy(j.mapSize),(l.x>_||l.y>_)&&(l.x>_&&(c.x=Math.floor(_/se.x),l.x=c.x*se.x,j.mapSize.x=c.x),l.y>_&&(c.y=Math.floor(_/se.y),l.y=c.y*se.y,j.mapSize.y=c.y));const Se=a.state.buffers.depth.getReversed();if(j.camera._reversedDepth=Se,j.map===null||fe===!0){if(j.map!==null&&(j.map.depthTexture!==null&&(j.map.depthTexture.dispose(),j.map.depthTexture=null),j.map.dispose()),this.type===Tl){if(G.isPointLight){mt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}j.map=new ua(l.x,l.y,{format:lr,type:Wa,minFilter:Yn,magFilter:Yn,generateMipmaps:!1}),j.map.texture.name=G.name+".shadowMap",j.map.depthTexture=new yo(l.x,l.y,qi),j.map.depthTexture.name=G.name+".shadowMapDepth",j.map.depthTexture.format=qa,j.map.depthTexture.compareFunction=null,j.map.depthTexture.minFilter=Vn,j.map.depthTexture.magFilter=Vn}else G.isPointLight?(j.map=new Ry(l.x),j.map.depthTexture=new tT(l.x,da)):(j.map=new ua(l.x,l.y),j.map.depthTexture=new yo(l.x,l.y,da)),j.map.depthTexture.name=G.name+".shadowMap",j.map.depthTexture.format=qa,this.type===bu?(j.map.depthTexture.compareFunction=Se?sm:am,j.map.depthTexture.minFilter=Yn,j.map.depthTexture.magFilter=Yn):(j.map.depthTexture.compareFunction=null,j.map.depthTexture.minFilter=Vn,j.map.depthTexture.magFilter=Vn);j.camera.updateProjectionMatrix()}const xe=j.map.isWebGLCubeRenderTarget?6:1;for(let z=0;z<xe;z++){if(j.map.isWebGLCubeRenderTarget)a.setRenderTarget(j.map,z),a.clear();else{z===0&&(a.setRenderTarget(j.map),a.clear());const te=j.getViewport(z);f.set(c.x*te.x,c.y*te.y,c.x*te.z,c.y*te.w),Q.viewport(f)}if(G.isPointLight){const te=j.camera,Ee=j.matrix,Oe=G.distance||te.far;Oe!==te.far&&(te.far=Oe,te.updateProjectionMatrix()),El.setFromMatrixPosition(G.matrixWorld),te.position.copy(El),zh.copy(te.position),zh.add(Jw[z]),te.up.copy(eR[z]),te.lookAt(zh),te.updateMatrixWorld(),Ee.makeTranslation(-El.x,-El.y,-El.z),Ex.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),j._frustum.setFromProjectionMatrix(Ex,te.coordinateSystem,te.reversedDepth)}else j.updateMatrices(G);s=j.getFrustum(),R(U,A,j.camera,G,this.type)}j.isPointLightShadow!==!0&&this.type===Tl&&P(j,A),j.needsUpdate=!1}x=this.type,y.needsUpdate=!1,a.setRenderTarget(N,k,V)};function P(O,U){const A=e.update(w);v.defines.VSM_SAMPLES!==O.blurSamples&&(v.defines.VSM_SAMPLES=O.blurSamples,M.defines.VSM_SAMPLES=O.blurSamples,v.needsUpdate=!0,M.needsUpdate=!0),O.mapPass===null&&(O.mapPass=new ua(l.x,l.y,{format:lr,type:Wa})),v.uniforms.shadow_pass.value=O.map.depthTexture,v.uniforms.resolution.value=O.mapSize,v.uniforms.radius.value=O.radius,a.setRenderTarget(O.mapPass),a.clear(),a.renderBufferDirect(U,null,A,v,w,null),M.uniforms.shadow_pass.value=O.mapPass.texture,M.uniforms.resolution.value=O.mapSize,M.uniforms.radius.value=O.radius,a.setRenderTarget(O.map),a.clear(),a.renderBufferDirect(U,null,A,M,w,null)}function L(O,U,A,N){let k=null;const V=A.isPointLight===!0?O.customDistanceMaterial:O.customDepthMaterial;if(V!==void 0)k=V;else if(k=A.isPointLight===!0?m:p,a.localClippingEnabled&&U.clipShadows===!0&&Array.isArray(U.clippingPlanes)&&U.clippingPlanes.length!==0||U.displacementMap&&U.displacementScale!==0||U.alphaMap&&U.alphaTest>0||U.map&&U.alphaTest>0||U.alphaToCoverage===!0){const Q=k.uuid,fe=U.uuid;let pe=h[Q];pe===void 0&&(pe={},h[Q]=pe);let J=pe[fe];J===void 0&&(J=k.clone(),pe[fe]=J,U.addEventListener("dispose",I)),k=J}if(k.visible=U.visible,k.wireframe=U.wireframe,N===Tl?k.side=U.shadowSide!==null?U.shadowSide:U.side:k.side=U.shadowSide!==null?U.shadowSide:S[U.side],k.alphaMap=U.alphaMap,k.alphaTest=U.alphaToCoverage===!0?.5:U.alphaTest,k.map=U.map,k.clipShadows=U.clipShadows,k.clippingPlanes=U.clippingPlanes,k.clipIntersection=U.clipIntersection,k.displacementMap=U.displacementMap,k.displacementScale=U.displacementScale,k.displacementBias=U.displacementBias,k.wireframeLinewidth=U.wireframeLinewidth,k.linewidth=U.linewidth,A.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const Q=a.properties.get(k);Q.light=A}return k}function R(O,U,A,N,k){if(O.visible===!1)return;if(O.layers.test(U.layers)&&(O.isMesh||O.isLine||O.isPoints)&&(O.castShadow||O.receiveShadow&&k===Tl)&&(!O.frustumCulled||s.intersectsObject(O))){O.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,O.matrixWorld);const fe=e.update(O),pe=O.material;if(Array.isArray(pe)){const J=fe.groups;for(let G=0,j=J.length;G<j;G++){const se=J[G],Se=pe[se.materialIndex];if(Se&&Se.visible){const xe=L(O,Se,N,k);O.onBeforeShadow(a,O,U,A,fe,xe,se),a.renderBufferDirect(A,null,fe,xe,O,se),O.onAfterShadow(a,O,U,A,fe,xe,se)}}}else if(pe.visible){const J=L(O,pe,N,k);O.onBeforeShadow(a,O,U,A,fe,J,null),a.renderBufferDirect(A,null,fe,J,O,null),O.onAfterShadow(a,O,U,A,fe,J,null)}}const Q=O.children;for(let fe=0,pe=Q.length;fe<pe;fe++)R(Q[fe],U,A,N,k)}function I(O){O.target.removeEventListener("dispose",I);for(const A in h){const N=h[A],k=O.target.uuid;k in N&&(N[k].dispose(),delete N[k])}}}function nR(a,e){function n(){let Z=!1;const Le=new gn;let ye=null;const Fe=new gn(0,0,0,0);return{setMask:function(Ge){ye!==Ge&&!Z&&(a.colorMask(Ge,Ge,Ge,Ge),ye=Ge)},setLocked:function(Ge){Z=Ge},setClear:function(Ge,Ce,Qe,Ye,Yt){Yt===!0&&(Ge*=Ye,Ce*=Ye,Qe*=Ye),Le.set(Ge,Ce,Qe,Ye),Fe.equals(Le)===!1&&(a.clearColor(Ge,Ce,Qe,Ye),Fe.copy(Le))},reset:function(){Z=!1,ye=null,Fe.set(-1,0,0,0)}}}function s(){let Z=!1,Le=!1,ye=null,Fe=null,Ge=null;return{setReversed:function(Ce){if(Le!==Ce){const Qe=e.get("EXT_clip_control");Ce?Qe.clipControlEXT(Qe.LOWER_LEFT_EXT,Qe.ZERO_TO_ONE_EXT):Qe.clipControlEXT(Qe.LOWER_LEFT_EXT,Qe.NEGATIVE_ONE_TO_ONE_EXT),Le=Ce;const Ye=Ge;Ge=null,this.setClear(Ye)}},getReversed:function(){return Le},setTest:function(Ce){Ce?Ae(a.DEPTH_TEST):je(a.DEPTH_TEST)},setMask:function(Ce){ye!==Ce&&!Z&&(a.depthMask(Ce),ye=Ce)},setFunc:function(Ce){if(Le&&(Ce=wE[Ce]),Fe!==Ce){switch(Ce){case Zh:a.depthFunc(a.NEVER);break;case Kh:a.depthFunc(a.ALWAYS);break;case $h:a.depthFunc(a.LESS);break;case vo:a.depthFunc(a.LEQUAL);break;case Qh:a.depthFunc(a.EQUAL);break;case Jh:a.depthFunc(a.GEQUAL);break;case ep:a.depthFunc(a.GREATER);break;case tp:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}Fe=Ce}},setLocked:function(Ce){Z=Ce},setClear:function(Ce){Ge!==Ce&&(Ge=Ce,Le&&(Ce=1-Ce),a.clearDepth(Ce))},reset:function(){Z=!1,ye=null,Fe=null,Ge=null,Le=!1}}}function l(){let Z=!1,Le=null,ye=null,Fe=null,Ge=null,Ce=null,Qe=null,Ye=null,Yt=null;return{setTest:function(Rt){Z||(Rt?Ae(a.STENCIL_TEST):je(a.STENCIL_TEST))},setMask:function(Rt){Le!==Rt&&!Z&&(a.stencilMask(Rt),Le=Rt)},setFunc:function(Rt,dn,Bn){(ye!==Rt||Fe!==dn||Ge!==Bn)&&(a.stencilFunc(Rt,dn,Bn),ye=Rt,Fe=dn,Ge=Bn)},setOp:function(Rt,dn,Bn){(Ce!==Rt||Qe!==dn||Ye!==Bn)&&(a.stencilOp(Rt,dn,Bn),Ce=Rt,Qe=dn,Ye=Bn)},setLocked:function(Rt){Z=Rt},setClear:function(Rt){Yt!==Rt&&(a.clearStencil(Rt),Yt=Rt)},reset:function(){Z=!1,Le=null,ye=null,Fe=null,Ge=null,Ce=null,Qe=null,Ye=null,Yt=null}}}const c=new n,f=new s,p=new l,m=new WeakMap,h=new WeakMap;let _={},S={},v={},M=new WeakMap,E=[],w=null,y=!1,x=null,P=null,L=null,R=null,I=null,O=null,U=null,A=new ot(0,0,0),N=0,k=!1,V=null,Q=null,fe=null,pe=null,J=null;const G=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let j=!1,se=0;const Se=a.getParameter(a.VERSION);Se.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec(Se)[1]),j=se>=1):Se.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec(Se)[1]),j=se>=2);let xe=null,z={};const te=a.getParameter(a.SCISSOR_BOX),Ee=a.getParameter(a.VIEWPORT),Oe=new gn().fromArray(te),He=new gn().fromArray(Ee);function le(Z,Le,ye,Fe){const Ge=new Uint8Array(4),Ce=a.createTexture();a.bindTexture(Z,Ce),a.texParameteri(Z,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(Z,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Qe=0;Qe<ye;Qe++)Z===a.TEXTURE_3D||Z===a.TEXTURE_2D_ARRAY?a.texImage3D(Le,0,a.RGBA,1,1,Fe,0,a.RGBA,a.UNSIGNED_BYTE,Ge):a.texImage2D(Le+Qe,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,Ge);return Ce}const Me={};Me[a.TEXTURE_2D]=le(a.TEXTURE_2D,a.TEXTURE_2D,1),Me[a.TEXTURE_CUBE_MAP]=le(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),Me[a.TEXTURE_2D_ARRAY]=le(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),Me[a.TEXTURE_3D]=le(a.TEXTURE_3D,a.TEXTURE_3D,1,1),c.setClear(0,0,0,1),f.setClear(1),p.setClear(0),Ae(a.DEPTH_TEST),f.setFunc(vo),It(!1),zt(vv),Ae(a.CULL_FACE),yt(ka);function Ae(Z){_[Z]!==!0&&(a.enable(Z),_[Z]=!0)}function je(Z){_[Z]!==!1&&(a.disable(Z),_[Z]=!1)}function rt(Z,Le){return v[Z]!==Le?(a.bindFramebuffer(Z,Le),v[Z]=Le,Z===a.DRAW_FRAMEBUFFER&&(v[a.FRAMEBUFFER]=Le),Z===a.FRAMEBUFFER&&(v[a.DRAW_FRAMEBUFFER]=Le),!0):!1}function $e(Z,Le){let ye=E,Fe=!1;if(Z){ye=M.get(Le),ye===void 0&&(ye=[],M.set(Le,ye));const Ge=Z.textures;if(ye.length!==Ge.length||ye[0]!==a.COLOR_ATTACHMENT0){for(let Ce=0,Qe=Ge.length;Ce<Qe;Ce++)ye[Ce]=a.COLOR_ATTACHMENT0+Ce;ye.length=Ge.length,Fe=!0}}else ye[0]!==a.BACK&&(ye[0]=a.BACK,Fe=!0);Fe&&a.drawBuffers(ye)}function Pt(Z){return w!==Z?(a.useProgram(Z),w=Z,!0):!1}const gt={[er]:a.FUNC_ADD,[$b]:a.FUNC_SUBTRACT,[Qb]:a.FUNC_REVERSE_SUBTRACT};gt[Jb]=a.MIN,gt[eE]=a.MAX;const dt={[tE]:a.ZERO,[nE]:a.ONE,[iE]:a.SRC_COLOR,[qh]:a.SRC_ALPHA,[cE]:a.SRC_ALPHA_SATURATE,[oE]:a.DST_COLOR,[sE]:a.DST_ALPHA,[aE]:a.ONE_MINUS_SRC_COLOR,[Yh]:a.ONE_MINUS_SRC_ALPHA,[lE]:a.ONE_MINUS_DST_COLOR,[rE]:a.ONE_MINUS_DST_ALPHA,[uE]:a.CONSTANT_COLOR,[fE]:a.ONE_MINUS_CONSTANT_COLOR,[dE]:a.CONSTANT_ALPHA,[hE]:a.ONE_MINUS_CONSTANT_ALPHA};function yt(Z,Le,ye,Fe,Ge,Ce,Qe,Ye,Yt,Rt){if(Z===ka){y===!0&&(je(a.BLEND),y=!1);return}if(y===!1&&(Ae(a.BLEND),y=!0),Z!==Kb){if(Z!==x||Rt!==k){if((P!==er||I!==er)&&(a.blendEquation(a.FUNC_ADD),P=er,I=er),Rt)switch(Z){case ho:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Wh:a.blendFunc(a.ONE,a.ONE);break;case xv:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case yv:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:Vt("WebGLState: Invalid blending: ",Z);break}else switch(Z){case ho:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Wh:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case xv:Vt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case yv:Vt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Vt("WebGLState: Invalid blending: ",Z);break}L=null,R=null,O=null,U=null,A.set(0,0,0),N=0,x=Z,k=Rt}return}Ge=Ge||Le,Ce=Ce||ye,Qe=Qe||Fe,(Le!==P||Ge!==I)&&(a.blendEquationSeparate(gt[Le],gt[Ge]),P=Le,I=Ge),(ye!==L||Fe!==R||Ce!==O||Qe!==U)&&(a.blendFuncSeparate(dt[ye],dt[Fe],dt[Ce],dt[Qe]),L=ye,R=Fe,O=Ce,U=Qe),(Ye.equals(A)===!1||Yt!==N)&&(a.blendColor(Ye.r,Ye.g,Ye.b,Yt),A.copy(Ye),N=Yt),x=Z,k=!1}function ht(Z,Le){Z.side===Ha?je(a.CULL_FACE):Ae(a.CULL_FACE);let ye=Z.side===ri;Le&&(ye=!ye),It(ye),Z.blending===ho&&Z.transparent===!1?yt(ka):yt(Z.blending,Z.blendEquation,Z.blendSrc,Z.blendDst,Z.blendEquationAlpha,Z.blendSrcAlpha,Z.blendDstAlpha,Z.blendColor,Z.blendAlpha,Z.premultipliedAlpha),f.setFunc(Z.depthFunc),f.setTest(Z.depthTest),f.setMask(Z.depthWrite),c.setMask(Z.colorWrite);const Fe=Z.stencilWrite;p.setTest(Fe),Fe&&(p.setMask(Z.stencilWriteMask),p.setFunc(Z.stencilFunc,Z.stencilRef,Z.stencilFuncMask),p.setOp(Z.stencilFail,Z.stencilZFail,Z.stencilZPass)),rn(Z.polygonOffset,Z.polygonOffsetFactor,Z.polygonOffsetUnits),Z.alphaToCoverage===!0?Ae(a.SAMPLE_ALPHA_TO_COVERAGE):je(a.SAMPLE_ALPHA_TO_COVERAGE)}function It(Z){V!==Z&&(Z?a.frontFace(a.CW):a.frontFace(a.CCW),V=Z)}function zt(Z){Z!==Yb?(Ae(a.CULL_FACE),Z!==Q&&(Z===vv?a.cullFace(a.BACK):Z===Zb?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):je(a.CULL_FACE),Q=Z}function qt(Z){Z!==fe&&(j&&a.lineWidth(Z),fe=Z)}function rn(Z,Le,ye){Z?(Ae(a.POLYGON_OFFSET_FILL),(pe!==Le||J!==ye)&&(pe=Le,J=ye,f.getReversed()&&(Le=-Le),a.polygonOffset(Le,ye))):je(a.POLYGON_OFFSET_FILL)}function ct(Z){Z?Ae(a.SCISSOR_TEST):je(a.SCISSOR_TEST)}function K(Z){Z===void 0&&(Z=a.TEXTURE0+G-1),xe!==Z&&(a.activeTexture(Z),xe=Z)}function F(Z,Le,ye){ye===void 0&&(xe===null?ye=a.TEXTURE0+G-1:ye=xe);let Fe=z[ye];Fe===void 0&&(Fe={type:void 0,texture:void 0},z[ye]=Fe),(Fe.type!==Z||Fe.texture!==Le)&&(xe!==ye&&(a.activeTexture(ye),xe=ye),a.bindTexture(Z,Le||Me[Z]),Fe.type=Z,Fe.texture=Le)}function Ue(){const Z=z[xe];Z!==void 0&&Z.type!==void 0&&(a.bindTexture(Z.type,null),Z.type=void 0,Z.texture=void 0)}function _t(){try{a.compressedTexImage2D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function B(){try{a.compressedTexImage3D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function C(){try{a.texSubImage2D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function ie(){try{a.texSubImage3D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function oe(){try{a.compressedTexSubImage2D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function he(){try{a.compressedTexSubImage3D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function Ne(){try{a.texStorage2D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function Re(){try{a.texStorage3D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function _e(){try{a.texImage2D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function ve(){try{a.texImage3D(...arguments)}catch(Z){Vt("WebGLState:",Z)}}function Ie(Z){return S[Z]!==void 0?S[Z]:a.getParameter(Z)}function Xe(Z,Le){S[Z]!==Le&&(a.pixelStorei(Z,Le),S[Z]=Le)}function Ve(Z){Oe.equals(Z)===!1&&(a.scissor(Z.x,Z.y,Z.z,Z.w),Oe.copy(Z))}function ge(Z){He.equals(Z)===!1&&(a.viewport(Z.x,Z.y,Z.z,Z.w),He.copy(Z))}function st(Z,Le){let ye=h.get(Le);ye===void 0&&(ye=new WeakMap,h.set(Le,ye));let Fe=ye.get(Z);Fe===void 0&&(Fe=a.getUniformBlockIndex(Le,Z.name),ye.set(Z,Fe))}function Je(Z,Le){const Fe=h.get(Le).get(Z);m.get(Le)!==Fe&&(a.uniformBlockBinding(Le,Fe,Z.__bindingPointIndex),m.set(Le,Fe))}function tt(){a.disable(a.BLEND),a.disable(a.CULL_FACE),a.disable(a.DEPTH_TEST),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SCISSOR_TEST),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ZERO),a.blendFuncSeparate(a.ONE,a.ZERO,a.ONE,a.ZERO),a.blendColor(0,0,0,0),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,0),a.depthMask(!0),a.depthFunc(a.LESS),f.setReversed(!1),a.clearDepth(1),a.stencilMask(4294967295),a.stencilFunc(a.ALWAYS,0,4294967295),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),a.clearStencil(0),a.cullFace(a.BACK),a.frontFace(a.CCW),a.polygonOffset(0,0),a.activeTexture(a.TEXTURE0),a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.useProgram(null),a.lineWidth(1),a.scissor(0,0,a.canvas.width,a.canvas.height),a.viewport(0,0,a.canvas.width,a.canvas.height),a.pixelStorei(a.PACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL),a.pixelStorei(a.PACK_ROW_LENGTH,0),a.pixelStorei(a.PACK_SKIP_PIXELS,0),a.pixelStorei(a.PACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_ROW_LENGTH,0),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,0),a.pixelStorei(a.UNPACK_SKIP_PIXELS,0),a.pixelStorei(a.UNPACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_SKIP_IMAGES,0),_={},S={},xe=null,z={},v={},M=new WeakMap,E=[],w=null,y=!1,x=null,P=null,L=null,R=null,I=null,O=null,U=null,A=new ot(0,0,0),N=0,k=!1,V=null,Q=null,fe=null,pe=null,J=null,Oe.set(0,0,a.canvas.width,a.canvas.height),He.set(0,0,a.canvas.width,a.canvas.height),c.reset(),f.reset(),p.reset()}return{buffers:{color:c,depth:f,stencil:p},enable:Ae,disable:je,bindFramebuffer:rt,drawBuffers:$e,useProgram:Pt,setBlending:yt,setMaterial:ht,setFlipSided:It,setCullFace:zt,setLineWidth:qt,setPolygonOffset:rn,setScissorTest:ct,activeTexture:K,bindTexture:F,unbindTexture:Ue,compressedTexImage2D:_t,compressedTexImage3D:B,texImage2D:_e,texImage3D:ve,pixelStorei:Xe,getParameter:Ie,updateUBOMapping:st,uniformBlockBinding:Je,texStorage2D:Ne,texStorage3D:Re,texSubImage2D:C,texSubImage3D:ie,compressedTexSubImage2D:oe,compressedTexSubImage3D:he,scissor:Ve,viewport:ge,reset:tt}}function iR(a,e,n,s,l,c,f){const p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new xt,_=new WeakMap,S=new Set;let v;const M=new WeakMap;let E=!1;try{E=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function w(B,C){return E?new OffscreenCanvas(B,C):Ou("canvas")}function y(B,C,ie){let oe=1;const he=_t(B);if((he.width>ie||he.height>ie)&&(oe=ie/Math.max(he.width,he.height)),oe<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const Ne=Math.floor(oe*he.width),Re=Math.floor(oe*he.height);v===void 0&&(v=w(Ne,Re));const _e=C?w(Ne,Re):v;return _e.width=Ne,_e.height=Re,_e.getContext("2d").drawImage(B,0,0,Ne,Re),mt("WebGLRenderer: Texture has been resized from ("+he.width+"x"+he.height+") to ("+Ne+"x"+Re+")."),_e}else return"data"in B&&mt("WebGLRenderer: Image in DataTexture is too big ("+he.width+"x"+he.height+")."),B;return B}function x(B){return B.generateMipmaps}function P(B){a.generateMipmap(B)}function L(B){return B.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?a.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function R(B,C,ie,oe,he,Ne=!1){if(B!==null){if(a[B]!==void 0)return a[B];mt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let Re;oe&&(Re=e.get("EXT_texture_norm16"),Re||mt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let _e=C;if(C===a.RED&&(ie===a.FLOAT&&(_e=a.R32F),ie===a.HALF_FLOAT&&(_e=a.R16F),ie===a.UNSIGNED_BYTE&&(_e=a.R8),ie===a.UNSIGNED_SHORT&&Re&&(_e=Re.R16_EXT),ie===a.SHORT&&Re&&(_e=Re.R16_SNORM_EXT)),C===a.RED_INTEGER&&(ie===a.UNSIGNED_BYTE&&(_e=a.R8UI),ie===a.UNSIGNED_SHORT&&(_e=a.R16UI),ie===a.UNSIGNED_INT&&(_e=a.R32UI),ie===a.BYTE&&(_e=a.R8I),ie===a.SHORT&&(_e=a.R16I),ie===a.INT&&(_e=a.R32I)),C===a.RG&&(ie===a.FLOAT&&(_e=a.RG32F),ie===a.HALF_FLOAT&&(_e=a.RG16F),ie===a.UNSIGNED_BYTE&&(_e=a.RG8),ie===a.UNSIGNED_SHORT&&Re&&(_e=Re.RG16_EXT),ie===a.SHORT&&Re&&(_e=Re.RG16_SNORM_EXT)),C===a.RG_INTEGER&&(ie===a.UNSIGNED_BYTE&&(_e=a.RG8UI),ie===a.UNSIGNED_SHORT&&(_e=a.RG16UI),ie===a.UNSIGNED_INT&&(_e=a.RG32UI),ie===a.BYTE&&(_e=a.RG8I),ie===a.SHORT&&(_e=a.RG16I),ie===a.INT&&(_e=a.RG32I)),C===a.RGB_INTEGER&&(ie===a.UNSIGNED_BYTE&&(_e=a.RGB8UI),ie===a.UNSIGNED_SHORT&&(_e=a.RGB16UI),ie===a.UNSIGNED_INT&&(_e=a.RGB32UI),ie===a.BYTE&&(_e=a.RGB8I),ie===a.SHORT&&(_e=a.RGB16I),ie===a.INT&&(_e=a.RGB32I)),C===a.RGBA_INTEGER&&(ie===a.UNSIGNED_BYTE&&(_e=a.RGBA8UI),ie===a.UNSIGNED_SHORT&&(_e=a.RGBA16UI),ie===a.UNSIGNED_INT&&(_e=a.RGBA32UI),ie===a.BYTE&&(_e=a.RGBA8I),ie===a.SHORT&&(_e=a.RGBA16I),ie===a.INT&&(_e=a.RGBA32I)),C===a.RGB&&(ie===a.UNSIGNED_SHORT&&Re&&(_e=Re.RGB16_EXT),ie===a.SHORT&&Re&&(_e=Re.RGB16_SNORM_EXT),ie===a.UNSIGNED_INT_5_9_9_9_REV&&(_e=a.RGB9_E5),ie===a.UNSIGNED_INT_10F_11F_11F_REV&&(_e=a.R11F_G11F_B10F)),C===a.RGBA){const ve=Ne?Lu:Gt.getTransfer(he);ie===a.FLOAT&&(_e=a.RGBA32F),ie===a.HALF_FLOAT&&(_e=a.RGBA16F),ie===a.UNSIGNED_BYTE&&(_e=ve===en?a.SRGB8_ALPHA8:a.RGBA8),ie===a.UNSIGNED_SHORT&&Re&&(_e=Re.RGBA16_EXT),ie===a.SHORT&&Re&&(_e=Re.RGBA16_SNORM_EXT),ie===a.UNSIGNED_SHORT_4_4_4_4&&(_e=a.RGBA4),ie===a.UNSIGNED_SHORT_5_5_5_1&&(_e=a.RGB5_A1)}return(_e===a.R16F||_e===a.R32F||_e===a.RG16F||_e===a.RG32F||_e===a.RGBA16F||_e===a.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function I(B,C){let ie;return B?C===null||C===da||C===Ul?ie=a.DEPTH24_STENCIL8:C===qi?ie=a.DEPTH32F_STENCIL8:C===Nl&&(ie=a.DEPTH24_STENCIL8,mt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):C===null||C===da||C===Ul?ie=a.DEPTH_COMPONENT24:C===qi?ie=a.DEPTH_COMPONENT32F:C===Nl&&(ie=a.DEPTH_COMPONENT16),ie}function O(B,C){return x(B)===!0||B.isFramebufferTexture&&B.minFilter!==Vn&&B.minFilter!==Yn?Math.log2(Math.max(C.width,C.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?C.mipmaps.length:1}function U(B){const C=B.target;C.removeEventListener("dispose",U),N(C),C.isVideoTexture&&_.delete(C),C.isHTMLTexture&&S.delete(C)}function A(B){const C=B.target;C.removeEventListener("dispose",A),V(C)}function N(B){const C=s.get(B);if(C.__webglInit===void 0)return;const ie=B.source,oe=M.get(ie);if(oe){const he=oe[C.__cacheKey];he.usedTimes--,he.usedTimes===0&&k(B),Object.keys(oe).length===0&&M.delete(ie)}s.remove(B)}function k(B){const C=s.get(B);a.deleteTexture(C.__webglTexture);const ie=B.source,oe=M.get(ie);delete oe[C.__cacheKey],f.memory.textures--}function V(B){const C=s.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),s.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let oe=0;oe<6;oe++){if(Array.isArray(C.__webglFramebuffer[oe]))for(let he=0;he<C.__webglFramebuffer[oe].length;he++)a.deleteFramebuffer(C.__webglFramebuffer[oe][he]);else a.deleteFramebuffer(C.__webglFramebuffer[oe]);C.__webglDepthbuffer&&a.deleteRenderbuffer(C.__webglDepthbuffer[oe])}else{if(Array.isArray(C.__webglFramebuffer))for(let oe=0;oe<C.__webglFramebuffer.length;oe++)a.deleteFramebuffer(C.__webglFramebuffer[oe]);else a.deleteFramebuffer(C.__webglFramebuffer);if(C.__webglDepthbuffer&&a.deleteRenderbuffer(C.__webglDepthbuffer),C.__webglMultisampledFramebuffer&&a.deleteFramebuffer(C.__webglMultisampledFramebuffer),C.__webglColorRenderbuffer)for(let oe=0;oe<C.__webglColorRenderbuffer.length;oe++)C.__webglColorRenderbuffer[oe]&&a.deleteRenderbuffer(C.__webglColorRenderbuffer[oe]);C.__webglDepthRenderbuffer&&a.deleteRenderbuffer(C.__webglDepthRenderbuffer)}const ie=B.textures;for(let oe=0,he=ie.length;oe<he;oe++){const Ne=s.get(ie[oe]);Ne.__webglTexture&&(a.deleteTexture(Ne.__webglTexture),f.memory.textures--),s.remove(ie[oe])}s.remove(B)}let Q=0;function fe(){Q=0}function pe(){return Q}function J(B){Q=B}function G(){const B=Q;return B>=l.maxTextures&&mt("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l.maxTextures),Q+=1,B}function j(B){const C=[];return C.push(B.wrapS),C.push(B.wrapT),C.push(B.wrapR||0),C.push(B.magFilter),C.push(B.minFilter),C.push(B.anisotropy),C.push(B.internalFormat),C.push(B.format),C.push(B.type),C.push(B.generateMipmaps),C.push(B.premultiplyAlpha),C.push(B.flipY),C.push(B.unpackAlignment),C.push(B.colorSpace),C.join()}function se(B,C){const ie=s.get(B);if(B.isVideoTexture&&F(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&ie.__version!==B.version){const oe=B.image;if(oe===null)mt("WebGLRenderer: Texture marked for update but no image data found.");else if(oe.complete===!1)mt("WebGLRenderer: Texture marked for update but image is incomplete");else{je(ie,B,C);return}}else B.isExternalTexture&&(ie.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(a.TEXTURE_2D,ie.__webglTexture,a.TEXTURE0+C)}function Se(B,C){const ie=s.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ie.__version!==B.version){je(ie,B,C);return}else B.isExternalTexture&&(ie.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(a.TEXTURE_2D_ARRAY,ie.__webglTexture,a.TEXTURE0+C)}function xe(B,C){const ie=s.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ie.__version!==B.version){je(ie,B,C);return}n.bindTexture(a.TEXTURE_3D,ie.__webglTexture,a.TEXTURE0+C)}function z(B,C){const ie=s.get(B);if(B.isCubeDepthTexture!==!0&&B.version>0&&ie.__version!==B.version){rt(ie,B,C);return}n.bindTexture(a.TEXTURE_CUBE_MAP,ie.__webglTexture,a.TEXTURE0+C)}const te={[np]:a.REPEAT,[Ga]:a.CLAMP_TO_EDGE,[ip]:a.MIRRORED_REPEAT},Ee={[Vn]:a.NEAREST,[gE]:a.NEAREST_MIPMAP_NEAREST,[Wc]:a.NEAREST_MIPMAP_LINEAR,[Yn]:a.LINEAR,[oh]:a.LINEAR_MIPMAP_NEAREST,[nr]:a.LINEAR_MIPMAP_LINEAR},Oe={[xE]:a.NEVER,[EE]:a.ALWAYS,[yE]:a.LESS,[am]:a.LEQUAL,[SE]:a.EQUAL,[sm]:a.GEQUAL,[ME]:a.GREATER,[bE]:a.NOTEQUAL};function He(B,C){if(C.type===qi&&e.has("OES_texture_float_linear")===!1&&(C.magFilter===Yn||C.magFilter===oh||C.magFilter===Wc||C.magFilter===nr||C.minFilter===Yn||C.minFilter===oh||C.minFilter===Wc||C.minFilter===nr)&&mt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(B,a.TEXTURE_WRAP_S,te[C.wrapS]),a.texParameteri(B,a.TEXTURE_WRAP_T,te[C.wrapT]),(B===a.TEXTURE_3D||B===a.TEXTURE_2D_ARRAY)&&a.texParameteri(B,a.TEXTURE_WRAP_R,te[C.wrapR]),a.texParameteri(B,a.TEXTURE_MAG_FILTER,Ee[C.magFilter]),a.texParameteri(B,a.TEXTURE_MIN_FILTER,Ee[C.minFilter]),C.compareFunction&&(a.texParameteri(B,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(B,a.TEXTURE_COMPARE_FUNC,Oe[C.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(C.magFilter===Vn||C.minFilter!==Wc&&C.minFilter!==nr||C.type===qi&&e.has("OES_texture_float_linear")===!1)return;if(C.anisotropy>1||s.get(C).__currentAnisotropy){const ie=e.get("EXT_texture_filter_anisotropic");a.texParameterf(B,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(C.anisotropy,l.getMaxAnisotropy())),s.get(C).__currentAnisotropy=C.anisotropy}}}function le(B,C){let ie=!1;B.__webglInit===void 0&&(B.__webglInit=!0,C.addEventListener("dispose",U));const oe=C.source;let he=M.get(oe);he===void 0&&(he={},M.set(oe,he));const Ne=j(C);if(Ne!==B.__cacheKey){he[Ne]===void 0&&(he[Ne]={texture:a.createTexture(),usedTimes:0},f.memory.textures++,ie=!0),he[Ne].usedTimes++;const Re=he[B.__cacheKey];Re!==void 0&&(he[B.__cacheKey].usedTimes--,Re.usedTimes===0&&k(C)),B.__cacheKey=Ne,B.__webglTexture=he[Ne].texture}return ie}function Me(B,C,ie){return Math.floor(Math.floor(B/ie)/C)}function Ae(B,C,ie,oe){const Ne=B.updateRanges;if(Ne.length===0)n.texSubImage2D(a.TEXTURE_2D,0,0,0,C.width,C.height,ie,oe,C.data);else{Ne.sort((Xe,Ve)=>Xe.start-Ve.start);let Re=0;for(let Xe=1;Xe<Ne.length;Xe++){const Ve=Ne[Re],ge=Ne[Xe],st=Ve.start+Ve.count,Je=Me(ge.start,C.width,4),tt=Me(Ve.start,C.width,4);ge.start<=st+1&&Je===tt&&Me(ge.start+ge.count-1,C.width,4)===Je?Ve.count=Math.max(Ve.count,ge.start+ge.count-Ve.start):(++Re,Ne[Re]=ge)}Ne.length=Re+1;const _e=n.getParameter(a.UNPACK_ROW_LENGTH),ve=n.getParameter(a.UNPACK_SKIP_PIXELS),Ie=n.getParameter(a.UNPACK_SKIP_ROWS);n.pixelStorei(a.UNPACK_ROW_LENGTH,C.width);for(let Xe=0,Ve=Ne.length;Xe<Ve;Xe++){const ge=Ne[Xe],st=Math.floor(ge.start/4),Je=Math.ceil(ge.count/4),tt=st%C.width,Z=Math.floor(st/C.width),Le=Je,ye=1;n.pixelStorei(a.UNPACK_SKIP_PIXELS,tt),n.pixelStorei(a.UNPACK_SKIP_ROWS,Z),n.texSubImage2D(a.TEXTURE_2D,0,tt,Z,Le,ye,ie,oe,C.data)}B.clearUpdateRanges(),n.pixelStorei(a.UNPACK_ROW_LENGTH,_e),n.pixelStorei(a.UNPACK_SKIP_PIXELS,ve),n.pixelStorei(a.UNPACK_SKIP_ROWS,Ie)}}function je(B,C,ie){let oe=a.TEXTURE_2D;(C.isDataArrayTexture||C.isCompressedArrayTexture)&&(oe=a.TEXTURE_2D_ARRAY),C.isData3DTexture&&(oe=a.TEXTURE_3D);const he=le(B,C),Ne=C.source;n.bindTexture(oe,B.__webglTexture,a.TEXTURE0+ie);const Re=s.get(Ne);if(Ne.version!==Re.__version||he===!0){if(n.activeTexture(a.TEXTURE0+ie),(typeof ImageBitmap<"u"&&C.image instanceof ImageBitmap)===!1){const ye=Gt.getPrimaries(Gt.workingColorSpace),Fe=C.colorSpace===Ts?null:Gt.getPrimaries(C.colorSpace),Ge=C.colorSpace===Ts||ye===Fe?a.NONE:a.BROWSER_DEFAULT_WEBGL;n.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,C.flipY),n.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,C.premultiplyAlpha),n.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge)}n.pixelStorei(a.UNPACK_ALIGNMENT,C.unpackAlignment);let ve=y(C.image,!1,l.maxTextureSize);ve=Ue(C,ve);const Ie=c.convert(C.format,C.colorSpace),Xe=c.convert(C.type);let Ve=R(C.internalFormat,Ie,Xe,C.normalized,C.colorSpace,C.isVideoTexture);He(oe,C);let ge;const st=C.mipmaps,Je=C.isVideoTexture!==!0,tt=Re.__version===void 0||he===!0,Z=Ne.dataReady,Le=O(C,ve);if(C.isDepthTexture)Ve=I(C.format===ir,C.type),tt&&(Je?n.texStorage2D(a.TEXTURE_2D,1,Ve,ve.width,ve.height):n.texImage2D(a.TEXTURE_2D,0,Ve,ve.width,ve.height,0,Ie,Xe,null));else if(C.isDataTexture)if(st.length>0){Je&&tt&&n.texStorage2D(a.TEXTURE_2D,Le,Ve,st[0].width,st[0].height);for(let ye=0,Fe=st.length;ye<Fe;ye++)ge=st[ye],Je?Z&&n.texSubImage2D(a.TEXTURE_2D,ye,0,0,ge.width,ge.height,Ie,Xe,ge.data):n.texImage2D(a.TEXTURE_2D,ye,Ve,ge.width,ge.height,0,Ie,Xe,ge.data);C.generateMipmaps=!1}else Je?(tt&&n.texStorage2D(a.TEXTURE_2D,Le,Ve,ve.width,ve.height),Z&&Ae(C,ve,Ie,Xe)):n.texImage2D(a.TEXTURE_2D,0,Ve,ve.width,ve.height,0,Ie,Xe,ve.data);else if(C.isCompressedTexture)if(C.isCompressedArrayTexture){Je&&tt&&n.texStorage3D(a.TEXTURE_2D_ARRAY,Le,Ve,st[0].width,st[0].height,ve.depth);for(let ye=0,Fe=st.length;ye<Fe;ye++)if(ge=st[ye],C.format!==Yi)if(Ie!==null)if(Je){if(Z)if(C.layerUpdates.size>0){const Ge=tx(ge.width,ge.height,C.format,C.type);for(const Ce of C.layerUpdates){const Qe=ge.data.subarray(Ce*Ge/ge.data.BYTES_PER_ELEMENT,(Ce+1)*Ge/ge.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,ye,0,0,Ce,ge.width,ge.height,1,Ie,Qe)}C.clearLayerUpdates()}else n.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,ye,0,0,0,ge.width,ge.height,ve.depth,Ie,ge.data)}else n.compressedTexImage3D(a.TEXTURE_2D_ARRAY,ye,Ve,ge.width,ge.height,ve.depth,0,ge.data,0,0);else mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Je?Z&&n.texSubImage3D(a.TEXTURE_2D_ARRAY,ye,0,0,0,ge.width,ge.height,ve.depth,Ie,Xe,ge.data):n.texImage3D(a.TEXTURE_2D_ARRAY,ye,Ve,ge.width,ge.height,ve.depth,0,Ie,Xe,ge.data)}else{Je&&tt&&n.texStorage2D(a.TEXTURE_2D,Le,Ve,st[0].width,st[0].height);for(let ye=0,Fe=st.length;ye<Fe;ye++)ge=st[ye],C.format!==Yi?Ie!==null?Je?Z&&n.compressedTexSubImage2D(a.TEXTURE_2D,ye,0,0,ge.width,ge.height,Ie,ge.data):n.compressedTexImage2D(a.TEXTURE_2D,ye,Ve,ge.width,ge.height,0,ge.data):mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Je?Z&&n.texSubImage2D(a.TEXTURE_2D,ye,0,0,ge.width,ge.height,Ie,Xe,ge.data):n.texImage2D(a.TEXTURE_2D,ye,Ve,ge.width,ge.height,0,Ie,Xe,ge.data)}else if(C.isDataArrayTexture)if(Je){if(tt&&n.texStorage3D(a.TEXTURE_2D_ARRAY,Le,Ve,ve.width,ve.height,ve.depth),Z)if(C.layerUpdates.size>0){const ye=tx(ve.width,ve.height,C.format,C.type);for(const Fe of C.layerUpdates){const Ge=ve.data.subarray(Fe*ye/ve.data.BYTES_PER_ELEMENT,(Fe+1)*ye/ve.data.BYTES_PER_ELEMENT);n.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,Fe,ve.width,ve.height,1,Ie,Xe,Ge)}C.clearLayerUpdates()}else n.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,ve.width,ve.height,ve.depth,Ie,Xe,ve.data)}else n.texImage3D(a.TEXTURE_2D_ARRAY,0,Ve,ve.width,ve.height,ve.depth,0,Ie,Xe,ve.data);else if(C.isData3DTexture)Je?(tt&&n.texStorage3D(a.TEXTURE_3D,Le,Ve,ve.width,ve.height,ve.depth),Z&&n.texSubImage3D(a.TEXTURE_3D,0,0,0,0,ve.width,ve.height,ve.depth,Ie,Xe,ve.data)):n.texImage3D(a.TEXTURE_3D,0,Ve,ve.width,ve.height,ve.depth,0,Ie,Xe,ve.data);else if(C.isFramebufferTexture){if(tt)if(Je)n.texStorage2D(a.TEXTURE_2D,Le,Ve,ve.width,ve.height);else{let ye=ve.width,Fe=ve.height;for(let Ge=0;Ge<Le;Ge++)n.texImage2D(a.TEXTURE_2D,Ge,Ve,ye,Fe,0,Ie,Xe,null),ye>>=1,Fe>>=1}}else if(C.isHTMLTexture){if("texElementImage2D"in a){const ye=a.canvas;if(ye.hasAttribute("layoutsubtree")||ye.setAttribute("layoutsubtree","true"),ve.parentNode!==ye){ye.appendChild(ve),S.add(C),ye.onpaint=Fe=>{const Ge=Fe.changedElements;for(const Ce of S)Ge.includes(Ce.image)&&(Ce.needsUpdate=!0)},ye.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,ve);else{const Ge=a.RGBA,Ce=a.RGBA,Qe=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,Ge,Ce,Qe,ve)}a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}}else if(st.length>0){if(Je&&tt){const ye=_t(st[0]);n.texStorage2D(a.TEXTURE_2D,Le,Ve,ye.width,ye.height)}for(let ye=0,Fe=st.length;ye<Fe;ye++)ge=st[ye],Je?Z&&n.texSubImage2D(a.TEXTURE_2D,ye,0,0,Ie,Xe,ge):n.texImage2D(a.TEXTURE_2D,ye,Ve,Ie,Xe,ge);C.generateMipmaps=!1}else if(Je){if(tt){const ye=_t(ve);n.texStorage2D(a.TEXTURE_2D,Le,Ve,ye.width,ye.height)}Z&&n.texSubImage2D(a.TEXTURE_2D,0,0,0,Ie,Xe,ve)}else n.texImage2D(a.TEXTURE_2D,0,Ve,Ie,Xe,ve);x(C)&&P(oe),Re.__version=Ne.version,C.onUpdate&&C.onUpdate(C)}B.__version=C.version}function rt(B,C,ie){if(C.image.length!==6)return;const oe=le(B,C),he=C.source;n.bindTexture(a.TEXTURE_CUBE_MAP,B.__webglTexture,a.TEXTURE0+ie);const Ne=s.get(he);if(he.version!==Ne.__version||oe===!0){n.activeTexture(a.TEXTURE0+ie);const Re=Gt.getPrimaries(Gt.workingColorSpace),_e=C.colorSpace===Ts?null:Gt.getPrimaries(C.colorSpace),ve=C.colorSpace===Ts||Re===_e?a.NONE:a.BROWSER_DEFAULT_WEBGL;n.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,C.flipY),n.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,C.premultiplyAlpha),n.pixelStorei(a.UNPACK_ALIGNMENT,C.unpackAlignment),n.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve);const Ie=C.isCompressedTexture||C.image[0].isCompressedTexture,Xe=C.image[0]&&C.image[0].isDataTexture,Ve=[];for(let Ce=0;Ce<6;Ce++)!Ie&&!Xe?Ve[Ce]=y(C.image[Ce],!0,l.maxCubemapSize):Ve[Ce]=Xe?C.image[Ce].image:C.image[Ce],Ve[Ce]=Ue(C,Ve[Ce]);const ge=Ve[0],st=c.convert(C.format,C.colorSpace),Je=c.convert(C.type),tt=R(C.internalFormat,st,Je,C.normalized,C.colorSpace),Z=C.isVideoTexture!==!0,Le=Ne.__version===void 0||oe===!0,ye=he.dataReady;let Fe=O(C,ge);He(a.TEXTURE_CUBE_MAP,C);let Ge;if(Ie){Z&&Le&&n.texStorage2D(a.TEXTURE_CUBE_MAP,Fe,tt,ge.width,ge.height);for(let Ce=0;Ce<6;Ce++){Ge=Ve[Ce].mipmaps;for(let Qe=0;Qe<Ge.length;Qe++){const Ye=Ge[Qe];C.format!==Yi?st!==null?Z?ye&&n.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe,0,0,Ye.width,Ye.height,st,Ye.data):n.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe,tt,Ye.width,Ye.height,0,Ye.data):mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe,0,0,Ye.width,Ye.height,st,Je,Ye.data):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe,tt,Ye.width,Ye.height,0,st,Je,Ye.data)}}}else{if(Ge=C.mipmaps,Z&&Le){Ge.length>0&&Fe++;const Ce=_t(Ve[0]);n.texStorage2D(a.TEXTURE_CUBE_MAP,Fe,tt,Ce.width,Ce.height)}for(let Ce=0;Ce<6;Ce++)if(Xe){Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Ve[Ce].width,Ve[Ce].height,st,Je,Ve[Ce].data):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,tt,Ve[Ce].width,Ve[Ce].height,0,st,Je,Ve[Ce].data);for(let Qe=0;Qe<Ge.length;Qe++){const Yt=Ge[Qe].image[Ce].image;Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe+1,0,0,Yt.width,Yt.height,st,Je,Yt.data):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe+1,tt,Yt.width,Yt.height,0,st,Je,Yt.data)}}else{Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,st,Je,Ve[Ce]):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,tt,st,Je,Ve[Ce]);for(let Qe=0;Qe<Ge.length;Qe++){const Ye=Ge[Qe];Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe+1,0,0,st,Je,Ye.image[Ce]):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Qe+1,tt,st,Je,Ye.image[Ce])}}}x(C)&&P(a.TEXTURE_CUBE_MAP),Ne.__version=he.version,C.onUpdate&&C.onUpdate(C)}B.__version=C.version}function $e(B,C,ie,oe,he,Ne){const Re=c.convert(ie.format,ie.colorSpace),_e=c.convert(ie.type),ve=R(ie.internalFormat,Re,_e,ie.normalized,ie.colorSpace),Ie=s.get(C),Xe=s.get(ie);if(Xe.__renderTarget=C,!Ie.__hasExternalTextures){const Ve=Math.max(1,C.width>>Ne),ge=Math.max(1,C.height>>Ne);he===a.TEXTURE_3D||he===a.TEXTURE_2D_ARRAY?n.texImage3D(he,Ne,ve,Ve,ge,C.depth,0,Re,_e,null):n.texImage2D(he,Ne,ve,Ve,ge,0,Re,_e,null)}n.bindFramebuffer(a.FRAMEBUFFER,B),K(C)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,oe,he,Xe.__webglTexture,0,ct(C)):(he===a.TEXTURE_2D||he>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,oe,he,Xe.__webglTexture,Ne),n.bindFramebuffer(a.FRAMEBUFFER,null)}function Pt(B,C,ie){if(a.bindRenderbuffer(a.RENDERBUFFER,B),C.depthBuffer){const oe=C.depthTexture,he=oe&&oe.isDepthTexture?oe.type:null,Ne=I(C.stencilBuffer,he),Re=C.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;K(C)?p.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,ct(C),Ne,C.width,C.height):ie?a.renderbufferStorageMultisample(a.RENDERBUFFER,ct(C),Ne,C.width,C.height):a.renderbufferStorage(a.RENDERBUFFER,Ne,C.width,C.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,Re,a.RENDERBUFFER,B)}else{const oe=C.textures;for(let he=0;he<oe.length;he++){const Ne=oe[he],Re=c.convert(Ne.format,Ne.colorSpace),_e=c.convert(Ne.type),ve=R(Ne.internalFormat,Re,_e,Ne.normalized,Ne.colorSpace);K(C)?p.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,ct(C),ve,C.width,C.height):ie?a.renderbufferStorageMultisample(a.RENDERBUFFER,ct(C),ve,C.width,C.height):a.renderbufferStorage(a.RENDERBUFFER,ve,C.width,C.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function gt(B,C,ie){const oe=C.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(a.FRAMEBUFFER,B),!(C.depthTexture&&C.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const he=s.get(C.depthTexture);if(he.__renderTarget=C,(!he.__webglTexture||C.depthTexture.image.width!==C.width||C.depthTexture.image.height!==C.height)&&(C.depthTexture.image.width=C.width,C.depthTexture.image.height=C.height,C.depthTexture.needsUpdate=!0),oe){if(he.__webglInit===void 0&&(he.__webglInit=!0,C.depthTexture.addEventListener("dispose",U)),he.__webglTexture===void 0){he.__webglTexture=a.createTexture(),n.bindTexture(a.TEXTURE_CUBE_MAP,he.__webglTexture),He(a.TEXTURE_CUBE_MAP,C.depthTexture);const Ie=c.convert(C.depthTexture.format),Xe=c.convert(C.depthTexture.type);let Ve;C.depthTexture.format===qa?Ve=a.DEPTH_COMPONENT24:C.depthTexture.format===ir&&(Ve=a.DEPTH24_STENCIL8);for(let ge=0;ge<6;ge++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,Ve,C.width,C.height,0,Ie,Xe,null)}}else se(C.depthTexture,0);const Ne=he.__webglTexture,Re=ct(C),_e=oe?a.TEXTURE_CUBE_MAP_POSITIVE_X+ie:a.TEXTURE_2D,ve=C.depthTexture.format===ir?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(C.depthTexture.format===qa)K(C)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,ve,_e,Ne,0,Re):a.framebufferTexture2D(a.FRAMEBUFFER,ve,_e,Ne,0);else if(C.depthTexture.format===ir)K(C)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,ve,_e,Ne,0,Re):a.framebufferTexture2D(a.FRAMEBUFFER,ve,_e,Ne,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function dt(B){const C=s.get(B),ie=B.isWebGLCubeRenderTarget===!0;if(C.__boundDepthTexture!==B.depthTexture){const oe=B.depthTexture;if(C.__depthDisposeCallback&&C.__depthDisposeCallback(),oe){const he=()=>{delete C.__boundDepthTexture,delete C.__depthDisposeCallback,oe.removeEventListener("dispose",he)};oe.addEventListener("dispose",he),C.__depthDisposeCallback=he}C.__boundDepthTexture=oe}if(B.depthTexture&&!C.__autoAllocateDepthBuffer)if(ie)for(let oe=0;oe<6;oe++)gt(C.__webglFramebuffer[oe],B,oe);else{const oe=B.texture.mipmaps;oe&&oe.length>0?gt(C.__webglFramebuffer[0],B,0):gt(C.__webglFramebuffer,B,0)}else if(ie){C.__webglDepthbuffer=[];for(let oe=0;oe<6;oe++)if(n.bindFramebuffer(a.FRAMEBUFFER,C.__webglFramebuffer[oe]),C.__webglDepthbuffer[oe]===void 0)C.__webglDepthbuffer[oe]=a.createRenderbuffer(),Pt(C.__webglDepthbuffer[oe],B,!1);else{const he=B.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Ne=C.__webglDepthbuffer[oe];a.bindRenderbuffer(a.RENDERBUFFER,Ne),a.framebufferRenderbuffer(a.FRAMEBUFFER,he,a.RENDERBUFFER,Ne)}}else{const oe=B.texture.mipmaps;if(oe&&oe.length>0?n.bindFramebuffer(a.FRAMEBUFFER,C.__webglFramebuffer[0]):n.bindFramebuffer(a.FRAMEBUFFER,C.__webglFramebuffer),C.__webglDepthbuffer===void 0)C.__webglDepthbuffer=a.createRenderbuffer(),Pt(C.__webglDepthbuffer,B,!1);else{const he=B.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Ne=C.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,Ne),a.framebufferRenderbuffer(a.FRAMEBUFFER,he,a.RENDERBUFFER,Ne)}}n.bindFramebuffer(a.FRAMEBUFFER,null)}function yt(B,C,ie){const oe=s.get(B);C!==void 0&&$e(oe.__webglFramebuffer,B,B.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),ie!==void 0&&dt(B)}function ht(B){const C=B.texture,ie=s.get(B),oe=s.get(C);B.addEventListener("dispose",A);const he=B.textures,Ne=B.isWebGLCubeRenderTarget===!0,Re=he.length>1;if(Re||(oe.__webglTexture===void 0&&(oe.__webglTexture=a.createTexture()),oe.__version=C.version,f.memory.textures++),Ne){ie.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)if(C.mipmaps&&C.mipmaps.length>0){ie.__webglFramebuffer[_e]=[];for(let ve=0;ve<C.mipmaps.length;ve++)ie.__webglFramebuffer[_e][ve]=a.createFramebuffer()}else ie.__webglFramebuffer[_e]=a.createFramebuffer()}else{if(C.mipmaps&&C.mipmaps.length>0){ie.__webglFramebuffer=[];for(let _e=0;_e<C.mipmaps.length;_e++)ie.__webglFramebuffer[_e]=a.createFramebuffer()}else ie.__webglFramebuffer=a.createFramebuffer();if(Re)for(let _e=0,ve=he.length;_e<ve;_e++){const Ie=s.get(he[_e]);Ie.__webglTexture===void 0&&(Ie.__webglTexture=a.createTexture(),f.memory.textures++)}if(B.samples>0&&K(B)===!1){ie.__webglMultisampledFramebuffer=a.createFramebuffer(),ie.__webglColorRenderbuffer=[],n.bindFramebuffer(a.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let _e=0;_e<he.length;_e++){const ve=he[_e];ie.__webglColorRenderbuffer[_e]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,ie.__webglColorRenderbuffer[_e]);const Ie=c.convert(ve.format,ve.colorSpace),Xe=c.convert(ve.type),Ve=R(ve.internalFormat,Ie,Xe,ve.normalized,ve.colorSpace,B.isXRRenderTarget===!0),ge=ct(B);a.renderbufferStorageMultisample(a.RENDERBUFFER,ge,Ve,B.width,B.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+_e,a.RENDERBUFFER,ie.__webglColorRenderbuffer[_e])}a.bindRenderbuffer(a.RENDERBUFFER,null),B.depthBuffer&&(ie.__webglDepthRenderbuffer=a.createRenderbuffer(),Pt(ie.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(a.FRAMEBUFFER,null)}}if(Ne){n.bindTexture(a.TEXTURE_CUBE_MAP,oe.__webglTexture),He(a.TEXTURE_CUBE_MAP,C);for(let _e=0;_e<6;_e++)if(C.mipmaps&&C.mipmaps.length>0)for(let ve=0;ve<C.mipmaps.length;ve++)$e(ie.__webglFramebuffer[_e][ve],B,C,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ve);else $e(ie.__webglFramebuffer[_e],B,C,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0);x(C)&&P(a.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Re){for(let _e=0,ve=he.length;_e<ve;_e++){const Ie=he[_e],Xe=s.get(Ie);let Ve=a.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(Ve=B.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),n.bindTexture(Ve,Xe.__webglTexture),He(Ve,Ie),$e(ie.__webglFramebuffer,B,Ie,a.COLOR_ATTACHMENT0+_e,Ve,0),x(Ie)&&P(Ve)}n.unbindTexture()}else{let _e=a.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(_e=B.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),n.bindTexture(_e,oe.__webglTexture),He(_e,C),C.mipmaps&&C.mipmaps.length>0)for(let ve=0;ve<C.mipmaps.length;ve++)$e(ie.__webglFramebuffer[ve],B,C,a.COLOR_ATTACHMENT0,_e,ve);else $e(ie.__webglFramebuffer,B,C,a.COLOR_ATTACHMENT0,_e,0);x(C)&&P(_e),n.unbindTexture()}B.depthBuffer&&dt(B)}function It(B){const C=B.textures;for(let ie=0,oe=C.length;ie<oe;ie++){const he=C[ie];if(x(he)){const Ne=L(B),Re=s.get(he).__webglTexture;n.bindTexture(Ne,Re),P(Ne),n.unbindTexture()}}}const zt=[],qt=[];function rn(B){if(B.samples>0){if(K(B)===!1){const C=B.textures,ie=B.width,oe=B.height;let he=a.COLOR_BUFFER_BIT;const Ne=B.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Re=s.get(B),_e=C.length>1;if(_e)for(let Ie=0;Ie<C.length;Ie++)n.bindFramebuffer(a.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.RENDERBUFFER,null),n.bindFramebuffer(a.FRAMEBUFFER,Re.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.TEXTURE_2D,null,0);n.bindFramebuffer(a.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer);const ve=B.texture.mipmaps;ve&&ve.length>0?n.bindFramebuffer(a.DRAW_FRAMEBUFFER,Re.__webglFramebuffer[0]):n.bindFramebuffer(a.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let Ie=0;Ie<C.length;Ie++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(he|=a.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(he|=a.STENCIL_BUFFER_BIT)),_e){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,Re.__webglColorRenderbuffer[Ie]);const Xe=s.get(C[Ie]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,Xe,0)}a.blitFramebuffer(0,0,ie,oe,0,0,ie,oe,he,a.NEAREST),m===!0&&(zt.length=0,qt.length=0,zt.push(a.COLOR_ATTACHMENT0+Ie),B.depthBuffer&&B.resolveDepthBuffer===!1&&(zt.push(Ne),qt.push(Ne),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,qt)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,zt))}if(n.bindFramebuffer(a.READ_FRAMEBUFFER,null),n.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),_e)for(let Ie=0;Ie<C.length;Ie++){n.bindFramebuffer(a.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.RENDERBUFFER,Re.__webglColorRenderbuffer[Ie]);const Xe=s.get(C[Ie]).__webglTexture;n.bindFramebuffer(a.FRAMEBUFFER,Re.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.TEXTURE_2D,Xe,0)}n.bindFramebuffer(a.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&m){const C=B.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[C])}}}function ct(B){return Math.min(l.maxSamples,B.samples)}function K(B){const C=s.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&C.__useRenderToTexture!==!1}function F(B){const C=f.render.frame;_.get(B)!==C&&(_.set(B,C),B.update())}function Ue(B,C){const ie=B.colorSpace,oe=B.format,he=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||ie!==Uu&&ie!==Ts&&(Gt.getTransfer(ie)===en?(oe!==Yi||he!==Si)&&mt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Vt("WebGLTextures: Unsupported texture color space:",ie)),C}function _t(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(h.width=B.naturalWidth||B.width,h.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(h.width=B.displayWidth,h.height=B.displayHeight):(h.width=B.width,h.height=B.height),h}this.allocateTextureUnit=G,this.resetTextureUnits=fe,this.getTextureUnits=pe,this.setTextureUnits=J,this.setTexture2D=se,this.setTexture2DArray=Se,this.setTexture3D=xe,this.setTextureCube=z,this.rebindTextures=yt,this.setupRenderTarget=ht,this.updateRenderTargetMipmap=It,this.updateMultisampleRenderTarget=rn,this.setupDepthRenderbuffer=dt,this.setupFrameBufferTexture=$e,this.useMultisampledRTT=K,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function aR(a,e){function n(s,l=Ts){let c;const f=Gt.getTransfer(l);if(s===Si)return a.UNSIGNED_BYTE;if(s===Qp)return a.UNSIGNED_SHORT_4_4_4_4;if(s===Jp)return a.UNSIGNED_SHORT_5_5_5_1;if(s===cy)return a.UNSIGNED_INT_5_9_9_9_REV;if(s===uy)return a.UNSIGNED_INT_10F_11F_11F_REV;if(s===oy)return a.BYTE;if(s===ly)return a.SHORT;if(s===Nl)return a.UNSIGNED_SHORT;if(s===$p)return a.INT;if(s===da)return a.UNSIGNED_INT;if(s===qi)return a.FLOAT;if(s===Wa)return a.HALF_FLOAT;if(s===fy)return a.ALPHA;if(s===dy)return a.RGB;if(s===Yi)return a.RGBA;if(s===qa)return a.DEPTH_COMPONENT;if(s===ir)return a.DEPTH_STENCIL;if(s===em)return a.RED;if(s===tm)return a.RED_INTEGER;if(s===lr)return a.RG;if(s===nm)return a.RG_INTEGER;if(s===im)return a.RGBA_INTEGER;if(s===Eu||s===Tu||s===Au||s===Cu)if(f===en)if(c=e.get("WEBGL_compressed_texture_s3tc_srgb"),c!==null){if(s===Eu)return c.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Tu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Au)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Cu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(c=e.get("WEBGL_compressed_texture_s3tc"),c!==null){if(s===Eu)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Tu)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Au)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Cu)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===ap||s===sp||s===rp||s===op)if(c=e.get("WEBGL_compressed_texture_pvrtc"),c!==null){if(s===ap)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===sp)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===rp)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===op)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===lp||s===cp||s===up||s===fp||s===dp||s===Du||s===hp)if(c=e.get("WEBGL_compressed_texture_etc"),c!==null){if(s===lp||s===cp)return f===en?c.COMPRESSED_SRGB8_ETC2:c.COMPRESSED_RGB8_ETC2;if(s===up)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:c.COMPRESSED_RGBA8_ETC2_EAC;if(s===fp)return c.COMPRESSED_R11_EAC;if(s===dp)return c.COMPRESSED_SIGNED_R11_EAC;if(s===Du)return c.COMPRESSED_RG11_EAC;if(s===hp)return c.COMPRESSED_SIGNED_RG11_EAC}else return null;if(s===pp||s===mp||s===gp||s===_p||s===vp||s===xp||s===yp||s===Sp||s===Mp||s===bp||s===Ep||s===Tp||s===Ap||s===Cp)if(c=e.get("WEBGL_compressed_texture_astc"),c!==null){if(s===pp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:c.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===mp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:c.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===gp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:c.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===_p)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:c.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===vp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:c.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===xp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:c.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===yp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:c.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Sp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:c.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Mp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:c.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===bp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:c.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Ep)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:c.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Tp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:c.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Ap)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:c.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Cp)return f===en?c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:c.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===wp||s===Rp||s===Dp)if(c=e.get("EXT_texture_compression_bptc"),c!==null){if(s===wp)return f===en?c.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:c.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Rp)return c.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Dp)return c.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Np||s===Up||s===Nu||s===Lp)if(c=e.get("EXT_texture_compression_rgtc"),c!==null){if(s===Np)return c.COMPRESSED_RED_RGTC1_EXT;if(s===Up)return c.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Nu)return c.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Lp)return c.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ul?a.UNSIGNED_INT_24_8:a[s]!==void 0?a[s]:null}return{convert:n}}const sR=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,rR=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
void main() {
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
if ( coord.x >= 1.0 ) {
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
} else {
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
}
}`;class oR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const s=new Ey(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,s=new ha({vertexShader:sR,fragmentShader:rR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new $i(new Vu(20,20),s)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class lR extends Ns{constructor(e,n){super();const s=this;let l=null,c=1,f=null,p="local-floor",m=1,h=null,_=null,S=null,v=null,M=null,E=null;const w=typeof XRWebGLBinding<"u",y=new oR,x={},P=n.getContextAttributes();let L=null,R=null;const I=[],O=[],U=new xt;let A=null;const N=new Li;N.viewport=new gn;const k=new Li;k.viewport=new gn;const V=[N,k],Q=new gT;let fe=null,pe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(le){let Me=I[le];return Me===void 0&&(Me=new ph,I[le]=Me),Me.getTargetRaySpace()},this.getControllerGrip=function(le){let Me=I[le];return Me===void 0&&(Me=new ph,I[le]=Me),Me.getGripSpace()},this.getHand=function(le){let Me=I[le];return Me===void 0&&(Me=new ph,I[le]=Me),Me.getHandSpace()};function J(le){const Me=O.indexOf(le.inputSource);if(Me===-1)return;const Ae=I[Me];Ae!==void 0&&(Ae.update(le.inputSource,le.frame,h||f),Ae.dispatchEvent({type:le.type,data:le.inputSource}))}function G(){l.removeEventListener("select",J),l.removeEventListener("selectstart",J),l.removeEventListener("selectend",J),l.removeEventListener("squeeze",J),l.removeEventListener("squeezestart",J),l.removeEventListener("squeezeend",J),l.removeEventListener("end",G),l.removeEventListener("inputsourceschange",j);for(let le=0;le<I.length;le++){const Me=O[le];Me!==null&&(O[le]=null,I[le].disconnect(Me))}fe=null,pe=null,y.reset();for(const le in x)delete x[le];e.setRenderTarget(L),M=null,v=null,S=null,l=null,R=null,He.stop(),s.isPresenting=!1,e.setPixelRatio(A),e.setSize(U.width,U.height,!1),s.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(le){c=le,s.isPresenting===!0&&mt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(le){p=le,s.isPresenting===!0&&mt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||f},this.setReferenceSpace=function(le){h=le},this.getBaseLayer=function(){return v!==null?v:M},this.getBinding=function(){return S===null&&w&&(S=new XRWebGLBinding(l,n)),S},this.getFrame=function(){return E},this.getSession=function(){return l},this.setSession=async function(le){if(l=le,l!==null){if(L=e.getRenderTarget(),l.addEventListener("select",J),l.addEventListener("selectstart",J),l.addEventListener("selectend",J),l.addEventListener("squeeze",J),l.addEventListener("squeezestart",J),l.addEventListener("squeezeend",J),l.addEventListener("end",G),l.addEventListener("inputsourceschange",j),P.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(U),w&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,je=null,rt=null;P.depth&&(rt=P.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ae=P.stencil?ir:qa,je=P.stencil?Ul:da);const $e={colorFormat:n.RGBA8,depthFormat:rt,scaleFactor:c};S=this.getBinding(),v=S.createProjectionLayer($e),l.updateRenderState({layers:[v]}),e.setPixelRatio(1),e.setSize(v.textureWidth,v.textureHeight,!1),R=new ua(v.textureWidth,v.textureHeight,{format:Yi,type:Si,depthTexture:new yo(v.textureWidth,v.textureHeight,je,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:P.stencil,colorSpace:e.outputColorSpace,samples:P.antialias?4:0,resolveDepthBuffer:v.ignoreDepthValues===!1,resolveStencilBuffer:v.ignoreDepthValues===!1})}else{const Ae={antialias:P.antialias,alpha:!0,depth:P.depth,stencil:P.stencil,framebufferScaleFactor:c};M=new XRWebGLLayer(l,n,Ae),l.updateRenderState({baseLayer:M}),e.setPixelRatio(1),e.setSize(M.framebufferWidth,M.framebufferHeight,!1),R=new ua(M.framebufferWidth,M.framebufferHeight,{format:Yi,type:Si,colorSpace:e.outputColorSpace,stencilBuffer:P.stencil,resolveDepthBuffer:M.ignoreDepthValues===!1,resolveStencilBuffer:M.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(m),h=null,f=await l.requestReferenceSpace(p),He.setContext(l),He.start(),s.isPresenting=!0,s.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(l!==null)return l.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function j(le){for(let Me=0;Me<le.removed.length;Me++){const Ae=le.removed[Me],je=O.indexOf(Ae);je>=0&&(O[je]=null,I[je].disconnect(Ae))}for(let Me=0;Me<le.added.length;Me++){const Ae=le.added[Me];let je=O.indexOf(Ae);if(je===-1){for(let $e=0;$e<I.length;$e++)if($e>=O.length){O.push(Ae),je=$e;break}else if(O[$e]===null){O[$e]=Ae,je=$e;break}if(je===-1)break}const rt=I[je];rt&&rt.connect(Ae)}}const se=new re,Se=new re;function xe(le,Me,Ae){se.setFromMatrixPosition(Me.matrixWorld),Se.setFromMatrixPosition(Ae.matrixWorld);const je=se.distanceTo(Se),rt=Me.projectionMatrix.elements,$e=Ae.projectionMatrix.elements,Pt=rt[14]/(rt[10]-1),gt=rt[14]/(rt[10]+1),dt=(rt[9]+1)/rt[5],yt=(rt[9]-1)/rt[5],ht=(rt[8]-1)/rt[0],It=($e[8]+1)/$e[0],zt=Pt*ht,qt=Pt*It,rn=je/(-ht+It),ct=rn*-ht;if(Me.matrixWorld.decompose(le.position,le.quaternion,le.scale),le.translateX(ct),le.translateZ(rn),le.matrixWorld.compose(le.position,le.quaternion,le.scale),le.matrixWorldInverse.copy(le.matrixWorld).invert(),rt[10]===-1)le.projectionMatrix.copy(Me.projectionMatrix),le.projectionMatrixInverse.copy(Me.projectionMatrixInverse);else{const K=Pt+rn,F=gt+rn,Ue=zt-ct,_t=qt+(je-ct),B=dt*gt/F*K,C=yt*gt/F*K;le.projectionMatrix.makePerspective(Ue,_t,B,C,K,F),le.projectionMatrixInverse.copy(le.projectionMatrix).invert()}}function z(le,Me){Me===null?le.matrixWorld.copy(le.matrix):le.matrixWorld.multiplyMatrices(Me.matrixWorld,le.matrix),le.matrixWorldInverse.copy(le.matrixWorld).invert()}this.updateCamera=function(le){if(l===null)return;let Me=le.near,Ae=le.far;y.texture!==null&&(y.depthNear>0&&(Me=y.depthNear),y.depthFar>0&&(Ae=y.depthFar)),Q.near=k.near=N.near=Me,Q.far=k.far=N.far=Ae,(fe!==Q.near||pe!==Q.far)&&(l.updateRenderState({depthNear:Q.near,depthFar:Q.far}),fe=Q.near,pe=Q.far),Q.layers.mask=le.layers.mask|6,N.layers.mask=Q.layers.mask&-5,k.layers.mask=Q.layers.mask&-3;const je=le.parent,rt=Q.cameras;z(Q,je);for(let $e=0;$e<rt.length;$e++)z(rt[$e],je);rt.length===2?xe(Q,N,k):Q.projectionMatrix.copy(N.projectionMatrix),te(le,Q,je)};function te(le,Me,Ae){Ae===null?le.matrix.copy(Me.matrixWorld):(le.matrix.copy(Ae.matrixWorld),le.matrix.invert(),le.matrix.multiply(Me.matrixWorld)),le.matrix.decompose(le.position,le.quaternion,le.scale),le.updateMatrixWorld(!0),le.projectionMatrix.copy(Me.projectionMatrix),le.projectionMatrixInverse.copy(Me.projectionMatrixInverse),le.isPerspectiveCamera&&(le.fov=Pp*2*Math.atan(1/le.projectionMatrix.elements[5]),le.zoom=1)}this.getCamera=function(){return Q},this.getFoveation=function(){if(!(v===null&&M===null))return m},this.setFoveation=function(le){m=le,v!==null&&(v.fixedFoveation=le),M!==null&&M.fixedFoveation!==void 0&&(M.fixedFoveation=le)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(Q)},this.getCameraTexture=function(le){return x[le]};let Ee=null;function Oe(le,Me){if(_=Me.getViewerPose(h||f),E=Me,_!==null){const Ae=_.views;M!==null&&(e.setRenderTargetFramebuffer(R,M.framebuffer),e.setRenderTarget(R));let je=!1;Ae.length!==Q.cameras.length&&(Q.cameras.length=0,je=!0);for(let gt=0;gt<Ae.length;gt++){const dt=Ae[gt];let yt=null;if(M!==null)yt=M.getViewport(dt);else{const It=S.getViewSubImage(v,dt);yt=It.viewport,gt===0&&(e.setRenderTargetTextures(R,It.colorTexture,It.depthStencilTexture),e.setRenderTarget(R))}let ht=V[gt];ht===void 0&&(ht=new Li,ht.layers.enable(gt),ht.viewport=new gn,V[gt]=ht),ht.matrix.fromArray(dt.transform.matrix),ht.matrix.decompose(ht.position,ht.quaternion,ht.scale),ht.projectionMatrix.fromArray(dt.projectionMatrix),ht.projectionMatrixInverse.copy(ht.projectionMatrix).invert(),ht.viewport.set(yt.x,yt.y,yt.width,yt.height),gt===0&&(Q.matrix.copy(ht.matrix),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale)),je===!0&&Q.cameras.push(ht)}const rt=l.enabledFeatures;if(rt&&rt.includes("depth-sensing")&&l.depthUsage=="gpu-optimized"&&w){S=s.getBinding();const gt=S.getDepthInformation(Ae[0]);gt&&gt.isValid&&gt.texture&&y.init(gt,l.renderState)}if(rt&&rt.includes("camera-access")&&w){e.state.unbindTexture(),S=s.getBinding();for(let gt=0;gt<Ae.length;gt++){const dt=Ae[gt].camera;if(dt){let yt=x[dt];yt||(yt=new Ey,x[dt]=yt);const ht=S.getCameraImage(dt);yt.sourceTexture=ht}}}}for(let Ae=0;Ae<I.length;Ae++){const je=O[Ae],rt=I[Ae];je!==null&&rt!==void 0&&rt.update(je,Me,h||f)}Ee&&Ee(le,Me),Me.detectedPlanes&&s.dispatchEvent({type:"planesdetected",data:Me}),E=null}const He=new Cy;He.setAnimationLoop(Oe),this.setAnimationLoop=function(le){Ee=le},this.dispose=function(){}}}const cR=new cn,Oy=new bt;Oy.set(-1,0,0,0,1,0,0,0,1);function uR(a,e){function n(y,x){y.matrixAutoUpdate===!0&&y.updateMatrix(),x.value.copy(y.matrix)}function s(y,x){x.color.getRGB(y.fogColor.value,Ty(a)),x.isFog?(y.fogNear.value=x.near,y.fogFar.value=x.far):x.isFogExp2&&(y.fogDensity.value=x.density)}function l(y,x,P,L,R){x.isNodeMaterial?x.uniformsNeedUpdate=!1:x.isMeshBasicMaterial?c(y,x):x.isMeshLambertMaterial?(c(y,x),x.envMap&&(y.envMapIntensity.value=x.envMapIntensity)):x.isMeshToonMaterial?(c(y,x),S(y,x)):x.isMeshPhongMaterial?(c(y,x),_(y,x),x.envMap&&(y.envMapIntensity.value=x.envMapIntensity)):x.isMeshStandardMaterial?(c(y,x),v(y,x),x.isMeshPhysicalMaterial&&M(y,x,R)):x.isMeshMatcapMaterial?(c(y,x),E(y,x)):x.isMeshDepthMaterial?c(y,x):x.isMeshDistanceMaterial?(c(y,x),w(y,x)):x.isMeshNormalMaterial?c(y,x):x.isLineBasicMaterial?(f(y,x),x.isLineDashedMaterial&&p(y,x)):x.isPointsMaterial?m(y,x,P,L):x.isSpriteMaterial?h(y,x):x.isShadowMaterial?(y.color.value.copy(x.color),y.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function c(y,x){y.opacity.value=x.opacity,x.color&&y.diffuse.value.copy(x.color),x.emissive&&y.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(y.map.value=x.map,n(x.map,y.mapTransform)),x.alphaMap&&(y.alphaMap.value=x.alphaMap,n(x.alphaMap,y.alphaMapTransform)),x.bumpMap&&(y.bumpMap.value=x.bumpMap,n(x.bumpMap,y.bumpMapTransform),y.bumpScale.value=x.bumpScale,x.side===ri&&(y.bumpScale.value*=-1)),x.normalMap&&(y.normalMap.value=x.normalMap,n(x.normalMap,y.normalMapTransform),y.normalScale.value.copy(x.normalScale),x.side===ri&&y.normalScale.value.negate()),x.displacementMap&&(y.displacementMap.value=x.displacementMap,n(x.displacementMap,y.displacementMapTransform),y.displacementScale.value=x.displacementScale,y.displacementBias.value=x.displacementBias),x.emissiveMap&&(y.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,y.emissiveMapTransform)),x.specularMap&&(y.specularMap.value=x.specularMap,n(x.specularMap,y.specularMapTransform)),x.alphaTest>0&&(y.alphaTest.value=x.alphaTest);const P=e.get(x),L=P.envMap,R=P.envMapRotation;L&&(y.envMap.value=L,y.envMapRotation.value.setFromMatrix4(cR.makeRotationFromEuler(R)).transpose(),L.isCubeTexture&&L.isRenderTargetTexture===!1&&y.envMapRotation.value.premultiply(Oy),y.reflectivity.value=x.reflectivity,y.ior.value=x.ior,y.refractionRatio.value=x.refractionRatio),x.lightMap&&(y.lightMap.value=x.lightMap,y.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,y.lightMapTransform)),x.aoMap&&(y.aoMap.value=x.aoMap,y.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,y.aoMapTransform))}function f(y,x){y.diffuse.value.copy(x.color),y.opacity.value=x.opacity,x.map&&(y.map.value=x.map,n(x.map,y.mapTransform))}function p(y,x){y.dashSize.value=x.dashSize,y.totalSize.value=x.dashSize+x.gapSize,y.scale.value=x.scale}function m(y,x,P,L){y.diffuse.value.copy(x.color),y.opacity.value=x.opacity,y.size.value=x.size*P,y.scale.value=L*.5,x.map&&(y.map.value=x.map,n(x.map,y.uvTransform)),x.alphaMap&&(y.alphaMap.value=x.alphaMap,n(x.alphaMap,y.alphaMapTransform)),x.alphaTest>0&&(y.alphaTest.value=x.alphaTest)}function h(y,x){y.diffuse.value.copy(x.color),y.opacity.value=x.opacity,y.rotation.value=x.rotation,x.map&&(y.map.value=x.map,n(x.map,y.mapTransform)),x.alphaMap&&(y.alphaMap.value=x.alphaMap,n(x.alphaMap,y.alphaMapTransform)),x.alphaTest>0&&(y.alphaTest.value=x.alphaTest)}function _(y,x){y.specular.value.copy(x.specular),y.shininess.value=Math.max(x.shininess,1e-4)}function S(y,x){x.gradientMap&&(y.gradientMap.value=x.gradientMap)}function v(y,x){y.metalness.value=x.metalness,x.metalnessMap&&(y.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,y.metalnessMapTransform)),y.roughness.value=x.roughness,x.roughnessMap&&(y.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,y.roughnessMapTransform)),x.envMap&&(y.envMapIntensity.value=x.envMapIntensity)}function M(y,x,P){y.ior.value=x.ior,x.sheen>0&&(y.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),y.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(y.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,y.sheenColorMapTransform)),x.sheenRoughnessMap&&(y.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,y.sheenRoughnessMapTransform))),x.clearcoat>0&&(y.clearcoat.value=x.clearcoat,y.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(y.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,y.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(y.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===ri&&y.clearcoatNormalScale.value.negate())),x.dispersion>0&&(y.dispersion.value=x.dispersion),x.iridescence>0&&(y.iridescence.value=x.iridescence,y.iridescenceIOR.value=x.iridescenceIOR,y.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(y.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,y.iridescenceMapTransform)),x.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),x.transmission>0&&(y.transmission.value=x.transmission,y.transmissionSamplerMap.value=P.texture,y.transmissionSamplerSize.value.set(P.width,P.height),x.transmissionMap&&(y.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,y.transmissionMapTransform)),y.thickness.value=x.thickness,x.thicknessMap&&(y.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=x.attenuationDistance,y.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(y.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(y.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=x.specularIntensity,y.specularColor.value.copy(x.specularColor),x.specularColorMap&&(y.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,y.specularColorMapTransform)),x.specularIntensityMap&&(y.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,y.specularIntensityMapTransform))}function E(y,x){x.matcap&&(y.matcap.value=x.matcap)}function w(y,x){const P=e.get(x).light;y.referencePosition.value.setFromMatrixPosition(P.matrixWorld),y.nearDistance.value=P.shadow.camera.near,y.farDistance.value=P.shadow.camera.far}return{refreshFogUniforms:s,refreshMaterialUniforms:l}}function fR(a,e,n,s){let l={},c={},f=[];const p=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function m(R,I){const O=I.program;s.uniformBlockBinding(R,O)}function h(R,I){let O=l[R.id];O===void 0&&(y(R),O=_(R),l[R.id]=O,R.addEventListener("dispose",P));const U=I.program;s.updateUBOMapping(R,U);const A=e.render.frame;c[R.id]!==A&&(v(R),c[R.id]=A)}function _(R){const I=S();R.__bindingPointIndex=I;const O=a.createBuffer(),U=R.__size,A=R.usage;return a.bindBuffer(a.UNIFORM_BUFFER,O),a.bufferData(a.UNIFORM_BUFFER,U,A),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,I,O),O}function S(){for(let R=0;R<p;R++)if(f.indexOf(R)===-1)return f.push(R),R;return Vt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function v(R){const I=l[R.id],O=R.uniforms,U=R.__cache;a.bindBuffer(a.UNIFORM_BUFFER,I);for(let A=0,N=O.length;A<N;A++){const k=O[A];if(Array.isArray(k))for(let V=0,Q=k.length;V<Q;V++)M(k[V],A,V,U);else M(k,A,0,U)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function M(R,I,O,U){if(w(R,I,O,U)===!0){const A=R.__offset,N=R.value;if(Array.isArray(N)){let k=0;for(let V=0;V<N.length;V++){const Q=N[V],fe=x(Q);E(Q,R.__data,k),typeof Q!="number"&&typeof Q!="boolean"&&!Q.isMatrix3&&!ArrayBuffer.isView(Q)&&(k+=fe.storage/Float32Array.BYTES_PER_ELEMENT)}}else E(N,R.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,A,R.__data)}}function E(R,I,O){typeof R=="number"||typeof R=="boolean"?I[0]=R:R.isMatrix3?(I[0]=R.elements[0],I[1]=R.elements[1],I[2]=R.elements[2],I[3]=0,I[4]=R.elements[3],I[5]=R.elements[4],I[6]=R.elements[5],I[7]=0,I[8]=R.elements[6],I[9]=R.elements[7],I[10]=R.elements[8],I[11]=0):ArrayBuffer.isView(R)?I.set(new R.constructor(R.buffer,R.byteOffset,I.length)):R.toArray(I,O)}function w(R,I,O,U){const A=R.value,N=I+"_"+O;if(U[N]===void 0)return typeof A=="number"||typeof A=="boolean"?U[N]=A:ArrayBuffer.isView(A)?U[N]=A.slice():U[N]=A.clone(),!0;{const k=U[N];if(typeof A=="number"||typeof A=="boolean"){if(k!==A)return U[N]=A,!0}else{if(ArrayBuffer.isView(A))return!0;if(k.equals(A)===!1)return k.copy(A),!0}}return!1}function y(R){const I=R.uniforms;let O=0;const U=16;for(let N=0,k=I.length;N<k;N++){const V=Array.isArray(I[N])?I[N]:[I[N]];for(let Q=0,fe=V.length;Q<fe;Q++){const pe=V[Q],J=Array.isArray(pe.value)?pe.value:[pe.value];for(let G=0,j=J.length;G<j;G++){const se=J[G],Se=x(se),xe=O%U,z=xe%Se.boundary,te=xe+z;O+=z,te!==0&&U-te<Se.storage&&(O+=U-te),pe.__data=new Float32Array(Se.storage/Float32Array.BYTES_PER_ELEMENT),pe.__offset=O,O+=Se.storage}}}const A=O%U;return A>0&&(O+=U-A),R.__size=O,R.__cache={},this}function x(R){const I={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(I.boundary=4,I.storage=4):R.isVector2?(I.boundary=8,I.storage=8):R.isVector3||R.isColor?(I.boundary=16,I.storage=12):R.isVector4?(I.boundary=16,I.storage=16):R.isMatrix3?(I.boundary=48,I.storage=48):R.isMatrix4?(I.boundary=64,I.storage=64):R.isTexture?mt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(R)?(I.boundary=16,I.storage=R.byteLength):mt("WebGLRenderer: Unsupported uniform value type.",R),I}function P(R){const I=R.target;I.removeEventListener("dispose",P);const O=f.indexOf(I.__bindingPointIndex);f.splice(O,1),a.deleteBuffer(l[I.id]),delete l[I.id],delete c[I.id]}function L(){for(const R in l)a.deleteBuffer(l[R]);f=[],l={},c={}}return{bind:m,update:h,dispose:L}}const dR=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]);let ra=null;function hR(){return ra===null&&(ra=new yy(dR,16,16,lr,Wa),ra.name="DFG_LUT",ra.minFilter=Yn,ra.magFilter=Yn,ra.wrapS=Ga,ra.wrapT=Ga,ra.generateMipmaps=!1,ra.needsUpdate=!0),ra}class pR{constructor(e={}){const{canvas:n=AE(),context:s=null,depth:l=!0,stencil:c=!1,alpha:f=!1,antialias:p=!1,premultipliedAlpha:m=!0,preserveDrawingBuffer:h=!1,powerPreference:_="default",failIfMajorPerformanceCaveat:S=!1,reversedDepthBuffer:v=!1,outputBufferType:M=Si}=e;this.isWebGLRenderer=!0;let E;if(s!==null){if(typeof WebGLRenderingContext<"u"&&s instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");E=s.getContextAttributes().alpha}else E=f;const w=M,y=new Set([im,nm,tm]),x=new Set([Si,da,Nl,Ul,Qp,Jp]),P=new Uint32Array(4),L=new Int32Array(4),R=new re;let I=null,O=null;const U=[],A=[];let N=null;this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ca,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let V=!1,Q=null,fe=null,pe=null,J=null;this._outputColorSpace=yi;let G=0,j=0,se=null,Se=-1,xe=null;const z=new gn,te=new gn;let Ee=null;const Oe=new ot(0);let He=0,le=n.width,Me=n.height,Ae=1,je=null,rt=null;const $e=new gn(0,0,le,Me),Pt=new gn(0,0,le,Me);let gt=!1;const dt=new cm;let yt=!1,ht=!1;const It=new cn,zt=new re,qt=new gn,rn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function K(){return se===null?Ae:1}let F=s;function Ue(T,H){return n.getContext(T,H)}try{const T={alpha:!0,depth:l,stencil:c,antialias:p,premultipliedAlpha:m,preserveDrawingBuffer:h,powerPreference:_,failIfMajorPerformanceCaveat:S};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Zp}`),n.addEventListener("webglcontextlost",Yt,!1),n.addEventListener("webglcontextrestored",Rt,!1),n.addEventListener("webglcontextcreationerror",dn,!1),F===null){const H="webgl2";if(F=Ue(H,T),F===null)throw Ue(H)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(T){throw Vt("WebGLRenderer: "+T.message),T}let _t,B,C,ie,oe,he,Ne,Re,_e,ve,Ie,Xe,Ve,ge,st,Je,tt,Z,Le,ye,Fe,Ge,Ce;function Qe(){_t=new hC(F),_t.init(),Fe=new aR(F,_t),B=new sC(F,_t,e,Fe),C=new nR(F,_t),B.reversedDepthBuffer&&v&&C.buffers.depth.setReversed(!0),fe=F.createFramebuffer(),pe=F.createFramebuffer(),J=F.createFramebuffer(),ie=new gC(F),oe=new Vw,he=new iR(F,_t,C,oe,B,Fe,ie),Ne=new dC(k),Re=new yT(F),Ge=new iC(F,Re),_e=new pC(F,Re,ie,Ge),ve=new vC(F,_e,Re,Ge,ie),Z=new _C(F,B,he),st=new rC(oe),Ie=new Gw(k,Ne,_t,B,Ge,st),Xe=new uR(k,oe),Ve=new jw,ge=new Kw(_t),tt=new nC(k,Ne,C,ve,E,m),Je=new tR(k,ve,B),Ce=new fR(F,ie,B,C),Le=new aC(F,_t,ie),ye=new mC(F,_t,ie),ie.programs=Ie.programs,k.capabilities=B,k.extensions=_t,k.properties=oe,k.renderLists=Ve,k.shadowMap=Je,k.state=C,k.info=ie}Qe(),w!==Si&&(N=new yC(w,n.width,n.height,p,l,c));const Ye=new lR(k,F);this.xr=Ye,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){const T=_t.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){const T=_t.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return Ae},this.setPixelRatio=function(T){T!==void 0&&(Ae=T,this.setSize(le,Me,!1))},this.getSize=function(T){return T.set(le,Me)},this.setSize=function(T,H,Y=!0){if(Ye.isPresenting){mt("WebGLRenderer: Can't change size while VR device is presenting.");return}le=T,Me=H,n.width=Math.floor(T*Ae),n.height=Math.floor(H*Ae),Y===!0&&(n.style.width=T+"px",n.style.height=H+"px"),N!==null&&N.setSize(n.width,n.height),this.setViewport(0,0,T,H)},this.getDrawingBufferSize=function(T){return T.set(le*Ae,Me*Ae).floor()},this.setDrawingBufferSize=function(T,H,Y){le=T,Me=H,Ae=Y,n.width=Math.floor(T*Y),n.height=Math.floor(H*Y),this.setViewport(0,0,T,H)},this.setEffects=function(T){if(w===Si){Vt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let H=0;H<T.length;H++)if(T[H].isOutputPass===!0){mt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}N.setEffects(T||[])},this.getCurrentViewport=function(T){return T.copy(z)},this.getViewport=function(T){return T.copy($e)},this.setViewport=function(T,H,Y,W){T.isVector4?$e.set(T.x,T.y,T.z,T.w):$e.set(T,H,Y,W),C.viewport(z.copy($e).multiplyScalar(Ae).round())},this.getScissor=function(T){return T.copy(Pt)},this.setScissor=function(T,H,Y,W){T.isVector4?Pt.set(T.x,T.y,T.z,T.w):Pt.set(T,H,Y,W),C.scissor(te.copy(Pt).multiplyScalar(Ae).round())},this.getScissorTest=function(){return gt},this.setScissorTest=function(T){C.setScissorTest(gt=T)},this.setOpaqueSort=function(T){je=T},this.setTransparentSort=function(T){rt=T},this.getClearColor=function(T){return T.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor(...arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha(...arguments)},this.clear=function(T=!0,H=!0,Y=!0){let W=0;if(T){let q=!1;if(se!==null){const Be=se.texture.format;q=y.has(Be)}if(q){const Be=se.texture.type,ze=x.has(Be),Pe=tt.getClearColor(),We=tt.getClearAlpha(),ke=Pe.r,nt=Pe.g,ut=Pe.b;ze?(P[0]=ke,P[1]=nt,P[2]=ut,P[3]=We,F.clearBufferuiv(F.COLOR,0,P)):(L[0]=ke,L[1]=nt,L[2]=ut,L[3]=We,F.clearBufferiv(F.COLOR,0,L))}else W|=F.COLOR_BUFFER_BIT}H&&(W|=F.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(W|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W!==0&&F.clear(W)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(T){T.setRenderer(this),Q=T},this.dispose=function(){n.removeEventListener("webglcontextlost",Yt,!1),n.removeEventListener("webglcontextrestored",Rt,!1),n.removeEventListener("webglcontextcreationerror",dn,!1),tt.dispose(),Ve.dispose(),ge.dispose(),oe.dispose(),Ne.dispose(),ve.dispose(),Ge.dispose(),Ce.dispose(),Ie.dispose(),Ye.dispose(),Ye.removeEventListener("sessionstart",St),Ye.removeEventListener("sessionend",_n),kn.stop()};function Yt(T){T.preventDefault(),Tv("WebGLRenderer: Context Lost."),V=!0}function Rt(){Tv("WebGLRenderer: Context Restored."),V=!1;const T=ie.autoReset,H=Je.enabled,Y=Je.autoUpdate,W=Je.needsUpdate,q=Je.type;Qe(),ie.autoReset=T,Je.enabled=H,Je.autoUpdate=Y,Je.needsUpdate=W,Je.type=q}function dn(T){Vt("WebGLRenderer: A WebGL context could not be created. Reason: ",T.statusMessage)}function Bn(T){const H=T.target;H.removeEventListener("dispose",Bn),De(H)}function De(T){Ze(T),oe.remove(T)}function Ze(T){const H=oe.get(T).programs;H!==void 0&&(H.forEach(function(Y){Ie.releaseProgram(Y)}),T.isShaderMaterial&&Ie.releaseShaderCache(T))}this.renderBufferDirect=function(T,H,Y,W,q,Be){H===null&&(H=rn);const ze=q.isMesh&&q.matrixWorld.determinantAffine()<0,Pe=Bi(T,H,Y,W,q);C.setMaterial(W,ze);let We=Y.index,ke=1;if(W.wireframe===!0){if(We=_e.getWireframeAttribute(Y),We===void 0)return;ke=2}const nt=Y.drawRange,ut=Y.attributes.position;let it=nt.start*ke,Et=(nt.start+nt.count)*ke;Be!==null&&(it=Math.max(it,Be.start*ke),Et=Math.min(Et,(Be.start+Be.count)*ke)),We!==null?(it=Math.max(it,0),Et=Math.min(Et,We.count)):ut!=null&&(it=Math.max(it,0),Et=Math.min(Et,ut.count));const hn=Et-it;if(hn<0||hn===1/0)return;Ge.setup(q,W,Pe,Y,We);let on,Zt=Le;if(We!==null&&(on=Re.get(We),Zt=ye,Zt.setIndex(on)),q.isMesh)W.wireframe===!0?(C.setLineWidth(W.wireframeLinewidth*K()),Zt.setMode(F.LINES)):Zt.setMode(F.TRIANGLES);else if(q.isLine){let Kt=W.linewidth;Kt===void 0&&(Kt=1),C.setLineWidth(Kt*K()),q.isLineSegments?Zt.setMode(F.LINES):q.isLineLoop?Zt.setMode(F.LINE_LOOP):Zt.setMode(F.LINE_STRIP)}else q.isPoints?Zt.setMode(F.POINTS):q.isSprite&&Zt.setMode(F.TRIANGLES);if(q.isBatchedMesh)if(_t.get("WEBGL_multi_draw"))Zt.renderMultiDraw(q._multiDrawStarts,q._multiDrawCounts,q._multiDrawCount);else{const Kt=q._multiDrawStarts,Ke=q._multiDrawCounts,jn=q._multiDrawCount,Nt=We?Re.get(We).bytesPerElement:1,wn=oe.get(W).currentProgram.getUniforms();for(let ci=0;ci<jn;ci++)wn.setValue(F,"_gl_DrawID",ci),Zt.render(Kt[ci]/Nt,Ke[ci])}else if(q.isInstancedMesh)Zt.renderInstances(it,hn,q.count);else if(Y.isInstancedBufferGeometry){const Kt=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Ke=Math.min(Y.instanceCount,Kt);Zt.renderInstances(it,hn,Ke)}else Zt.render(it,hn)};function vt(T,H,Y){T.transparent===!0&&T.side===Ha&&T.forceSinglePass===!1?(T.side=ri,T.needsUpdate=!0,Ji(T,H,Y),T.side=Cs,T.needsUpdate=!0,Ji(T,H,Y),T.side=Ha):Ji(T,H,Y)}this.compile=function(T,H,Y=null){Y===null&&(Y=T),O=ge.get(Y),O.init(H),A.push(O),Y.traverseVisible(function(q){q.isLight&&q.layers.test(H.layers)&&(O.pushLight(q),q.castShadow&&O.pushShadow(q))}),T!==Y&&T.traverseVisible(function(q){q.isLight&&q.layers.test(H.layers)&&(O.pushLight(q),q.castShadow&&O.pushShadow(q))}),O.setupLights();const W=new Set;return T.traverse(function(q){if(!(q.isMesh||q.isPoints||q.isLine||q.isSprite))return;const Be=q.material;if(Be)if(Array.isArray(Be))for(let ze=0;ze<Be.length;ze++){const Pe=Be[ze];vt(Pe,Y,q),W.add(Pe)}else vt(Be,Y,q),W.add(Be)}),O=A.pop(),W},this.compileAsync=function(T,H,Y=null){const W=this.compile(T,H,Y);return new Promise(q=>{function Be(){if(W.forEach(function(ze){oe.get(ze).currentProgram.isReady()&&W.delete(ze)}),W.size===0){q(T);return}setTimeout(Be,10)}_t.get("KHR_parallel_shader_compile")!==null?Be():setTimeout(Be,10)})};let Dt=null;function Ct(T){Dt&&Dt(T)}function St(){kn.stop()}function _n(){kn.start()}const kn=new Cy;kn.setAnimationLoop(Ct),typeof self<"u"&&kn.setContext(self),this.setAnimationLoop=function(T){Dt=T,Ye.setAnimationLoop(T),T===null?kn.stop():kn.start()},Ye.addEventListener("sessionstart",St),Ye.addEventListener("sessionend",_n),this.render=function(T,H){if(H!==void 0&&H.isCamera!==!0){Vt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(V===!0)return;Q!==null&&Q.renderStart(T,H);const Y=Ye.enabled===!0&&Ye.isPresenting===!0,W=N!==null&&(se===null||Y)&&N.begin(k,se);if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),Ye.enabled===!0&&Ye.isPresenting===!0&&(N===null||N.isCompositing()===!1)&&(Ye.cameraAutoUpdate===!0&&Ye.updateCamera(H),H=Ye.getCamera()),T.isScene===!0&&T.onBeforeRender(k,T,H,se),O=ge.get(T,A.length),O.init(H),O.state.textureUnits=he.getTextureUnits(),A.push(O),It.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),dt.setFromProjectionMatrix(It,la,H.reversedDepth),ht=this.localClippingEnabled,yt=st.init(this.clippingPlanes,ht),I=Ve.get(T,U.length),I.init(),U.push(I),Ye.enabled===!0&&Ye.isPresenting===!0){const ze=k.xr.getDepthSensingMesh();ze!==null&&pa(ze,H,-1/0,k.sortObjects)}pa(T,H,0,k.sortObjects),I.finish(),k.sortObjects===!0&&I.sort(je,rt,H.reversedDepth),ct=Ye.enabled===!1||Ye.isPresenting===!1||Ye.hasDepthSensing()===!1,ct&&tt.addToRenderList(I,T),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),yt===!0&&st.beginShadows();const q=O.state.shadowsArray;if(Je.render(q,T,H),yt===!0&&st.endShadows(),(W&&N.hasRenderPass())===!1){const ze=I.opaque,Pe=I.transmissive;if(O.setupLights(),H.isArrayCamera){const We=H.cameras;if(Pe.length>0)for(let ke=0,nt=We.length;ke<nt;ke++){const ut=We[ke];pr(ze,Pe,T,ut)}ct&&tt.render(T);for(let ke=0,nt=We.length;ke<nt;ke++){const ut=We[ke];hr(I,T,ut,ut.viewport)}}else Pe.length>0&&pr(ze,Pe,T,H),ct&&tt.render(T),hr(I,T,H)}se!==null&&j===0&&(he.updateMultisampleRenderTarget(se),he.updateRenderTargetMipmap(se)),W&&N.end(k),T.isScene===!0&&T.onAfterRender(k,T,H),Ge.resetDefaultState(),Se=-1,xe=null,A.pop(),A.length>0?(O=A[A.length-1],he.setTextureUnits(O.state.textureUnits),yt===!0&&st.setGlobalState(k.clippingPlanes,O.state.camera)):O=null,U.pop(),U.length>0?I=U[U.length-1]:I=null,Q!==null&&Q.renderEnd()};function pa(T,H,Y,W){if(T.visible===!1)return;if(T.layers.test(H.layers)){if(T.isGroup)Y=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(H);else if(T.isLightProbeGrid)O.pushLightProbeGrid(T);else if(T.isLight)O.pushLight(T),T.castShadow&&O.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||dt.intersectsSprite(T)){W&&qt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(It);const ze=ve.update(T),Pe=T.material;Pe.visible&&I.push(T,ze,Pe,Y,qt.z,null)}}else if((T.isMesh||T.isLine||T.isPoints)&&(!T.frustumCulled||dt.intersectsObject(T))){const ze=ve.update(T),Pe=T.material;if(W&&(T.boundingSphere!==void 0?(T.boundingSphere===null&&T.computeBoundingSphere(),qt.copy(T.boundingSphere.center)):(ze.boundingSphere===null&&ze.computeBoundingSphere(),qt.copy(ze.boundingSphere.center)),qt.applyMatrix4(T.matrixWorld).applyMatrix4(It)),Array.isArray(Pe)){const We=ze.groups;for(let ke=0,nt=We.length;ke<nt;ke++){const ut=We[ke],it=Pe[ut.materialIndex];it&&it.visible&&I.push(T,ze,it,Y,qt.z,ut)}}else Pe.visible&&I.push(T,ze,Pe,Y,qt.z,null)}}const Be=T.children;for(let ze=0,Pe=Be.length;ze<Pe;ze++)pa(Be[ze],H,Y,W)}function hr(T,H,Y,W){const{opaque:q,transmissive:Be,transparent:ze}=T;O.setupLightsView(Y),yt===!0&&st.setGlobalState(k.clippingPlanes,Y),W&&C.viewport(z.copy(W)),q.length>0&&ma(q,H,Y),Be.length>0&&ma(Be,H,Y),ze.length>0&&ma(ze,H,Y),C.buffers.depth.setTest(!0),C.buffers.depth.setMask(!0),C.buffers.color.setMask(!0),C.setPolygonOffset(!1)}function pr(T,H,Y,W){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(O.state.transmissionRenderTarget[W.id]===void 0){const it=_t.has("EXT_color_buffer_half_float")||_t.has("EXT_color_buffer_float");O.state.transmissionRenderTarget[W.id]=new ua(1,1,{generateMipmaps:!0,type:it?Wa:Si,minFilter:nr,samples:Math.max(4,B.samples),stencilBuffer:c,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Gt.workingColorSpace})}const Be=O.state.transmissionRenderTarget[W.id],ze=W.viewport||z;Be.setSize(ze.z*k.transmissionResolutionScale,ze.w*k.transmissionResolutionScale);const Pe=k.getRenderTarget(),We=k.getActiveCubeFace(),ke=k.getActiveMipmapLevel();k.setRenderTarget(Be),k.getClearColor(Oe),He=k.getClearAlpha(),He<1&&k.setClearColor(16777215,.5),k.clear(),ct&&tt.render(Y);const nt=k.toneMapping;k.toneMapping=ca;const ut=W.viewport;if(W.viewport!==void 0&&(W.viewport=void 0),O.setupLightsView(W),yt===!0&&st.setGlobalState(k.clippingPlanes,W),ma(T,Y,W),he.updateMultisampleRenderTarget(Be),he.updateRenderTargetMipmap(Be),_t.has("WEBGL_multisampled_render_to_texture")===!1){let it=!1;for(let Et=0,hn=H.length;Et<hn;Et++){const on=H[Et],{object:Zt,geometry:Kt,material:Ke,group:jn}=on;if(Ke.side===Ha&&Zt.layers.test(W.layers)){const Nt=Ke.side;Ke.side=ri,Ke.needsUpdate=!0,Qi(Zt,Y,W,Kt,Ke,jn),Ke.side=Nt,Ke.needsUpdate=!0,it=!0}}it===!0&&(he.updateMultisampleRenderTarget(Be),he.updateRenderTargetMipmap(Be))}k.setRenderTarget(Pe,We,ke),k.setClearColor(Oe,He),ut!==void 0&&(W.viewport=ut),k.toneMapping=nt}function ma(T,H,Y){const W=H.isScene===!0?H.overrideMaterial:null;for(let q=0,Be=T.length;q<Be;q++){const ze=T[q],{object:Pe,geometry:We,group:ke}=ze;let nt=ze.material;nt.allowOverride===!0&&W!==null&&(nt=W),Pe.layers.test(Y.layers)&&Qi(Pe,H,Y,We,nt,ke)}}function Qi(T,H,Y,W,q,Be){T.onBeforeRender(k,H,Y,W,q,Be),T.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,T.matrixWorld),T.normalMatrix.getNormalMatrix(T.modelViewMatrix),q.onBeforeRender(k,H,Y,W,T,Be),q.transparent===!0&&q.side===Ha&&q.forceSinglePass===!1?(q.side=ri,q.needsUpdate=!0,k.renderBufferDirect(Y,H,W,q,T,Be),q.side=Cs,q.needsUpdate=!0,k.renderBufferDirect(Y,H,W,q,T,Be),q.side=Ha):k.renderBufferDirect(Y,H,W,q,T,Be),T.onAfterRender(k,H,Y,W,q,Be)}function Ji(T,H,Y){H.isScene!==!0&&(H=rn);const W=oe.get(T),q=O.state.lights,Be=O.state.shadowsArray,ze=q.state.version,Pe=Ie.getParameters(T,q.state,Be,H,Y,O.state.lightProbeGridArray),We=Ie.getProgramCacheKey(Pe);let ke=W.programs;W.environment=T.isMeshStandardMaterial||T.isMeshLambertMaterial||T.isMeshPhongMaterial?H.environment:null,W.fog=H.fog;const nt=T.isMeshStandardMaterial||T.isMeshLambertMaterial&&!T.envMap||T.isMeshPhongMaterial&&!T.envMap;W.envMap=Ne.get(T.envMap||W.environment,nt),W.envMapRotation=W.environment!==null&&T.envMap===null?H.environmentRotation:T.envMapRotation,ke===void 0&&(T.addEventListener("dispose",Bn),ke=new Map,W.programs=ke);let ut=ke.get(We);if(ut!==void 0){if(W.currentProgram===ut&&W.lightsStateVersion===ze)return Ii(T,Pe),ut}else Pe.uniforms=Ie.getUniforms(T),Q!==null&&T.isNodeMaterial&&Q.build(T,Y,Pe),T.onBeforeCompile(Pe,k),ut=Ie.acquireProgram(Pe,We),ke.set(We,ut),W.uniforms=Pe.uniforms;const it=W.uniforms;return(!T.isShaderMaterial&&!T.isRawShaderMaterial||T.clipping===!0)&&(it.clippingPlanes=st.uniform),Ii(T,Pe),W.needsLights=ne(T),W.lightsStateVersion=ze,W.needsLights&&(it.ambientLightColor.value=q.state.ambient,it.lightProbe.value=q.state.probe,it.directionalLights.value=q.state.directional,it.directionalLightShadows.value=q.state.directionalShadow,it.spotLights.value=q.state.spot,it.spotLightShadows.value=q.state.spotShadow,it.rectAreaLights.value=q.state.rectArea,it.ltc_1.value=q.state.rectAreaLTC1,it.ltc_2.value=q.state.rectAreaLTC2,it.pointLights.value=q.state.point,it.pointLightShadows.value=q.state.pointShadow,it.hemisphereLights.value=q.state.hemi,it.directionalShadowMatrix.value=q.state.directionalShadowMatrix,it.spotLightMatrix.value=q.state.spotLightMatrix,it.spotLightMap.value=q.state.spotLightMap,it.pointShadowMatrix.value=q.state.pointShadowMatrix),W.lightProbeGrid=O.state.lightProbeGridArray.length>0,W.currentProgram=ut,W.uniformsList=null,ut}function li(T){if(T.uniformsList===null){const H=T.currentProgram.getUniforms();T.uniformsList=wu.seqWithValue(H.seq,T.uniforms)}return T.uniformsList}function Ii(T,H){const Y=oe.get(T);Y.outputColorSpace=H.outputColorSpace,Y.batching=H.batching,Y.batchingColor=H.batchingColor,Y.instancing=H.instancing,Y.instancingColor=H.instancingColor,Y.instancingMorph=H.instancingMorph,Y.skinning=H.skinning,Y.morphTargets=H.morphTargets,Y.morphNormals=H.morphNormals,Y.morphColors=H.morphColors,Y.morphTargetsCount=H.morphTargetsCount,Y.numClippingPlanes=H.numClippingPlanes,Y.numIntersection=H.numClipIntersection,Y.vertexAlphas=H.vertexAlphas,Y.vertexTangents=H.vertexTangents,Y.toneMapping=H.toneMapping}function ga(T,H){if(T.length===0)return null;if(T.length===1)return T[0].texture!==null?T[0]:null;R.setFromMatrixPosition(H.matrixWorld);for(let Y=0,W=T.length;Y<W;Y++){const q=T[Y];if(q.texture!==null&&q.boundingBox.containsPoint(R))return q}return null}function Bi(T,H,Y,W,q){H.isScene!==!0&&(H=rn),he.resetTextureUnits();const Be=H.fog,ze=W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial?H.environment:null,Pe=se===null?k.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:Gt.workingColorSpace,We=W.isMeshStandardMaterial||W.isMeshLambertMaterial&&!W.envMap||W.isMeshPhongMaterial&&!W.envMap,ke=Ne.get(W.envMap||ze,We),nt=W.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,ut=!!Y.attributes.tangent&&(!!W.normalMap||W.anisotropy>0),it=!!Y.morphAttributes.position,Et=!!Y.morphAttributes.normal,hn=!!Y.morphAttributes.color;let on=ca;W.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(on=k.toneMapping);const Zt=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Kt=Zt!==void 0?Zt.length:0,Ke=oe.get(W),jn=O.state.lights;if(yt===!0&&(ht===!0||T!==xe)){const Wt=T===xe&&W.id===Se;st.setState(W,T,Wt)}let Nt=!1;W.version===Ke.__version?(Ke.needsLights&&Ke.lightsStateVersion!==jn.state.version||Ke.outputColorSpace!==Pe||q.isBatchedMesh&&Ke.batching===!1||!q.isBatchedMesh&&Ke.batching===!0||q.isBatchedMesh&&Ke.batchingColor===!0&&q.colorTexture===null||q.isBatchedMesh&&Ke.batchingColor===!1&&q.colorTexture!==null||q.isInstancedMesh&&Ke.instancing===!1||!q.isInstancedMesh&&Ke.instancing===!0||q.isSkinnedMesh&&Ke.skinning===!1||!q.isSkinnedMesh&&Ke.skinning===!0||q.isInstancedMesh&&Ke.instancingColor===!0&&q.instanceColor===null||q.isInstancedMesh&&Ke.instancingColor===!1&&q.instanceColor!==null||q.isInstancedMesh&&Ke.instancingMorph===!0&&q.morphTexture===null||q.isInstancedMesh&&Ke.instancingMorph===!1&&q.morphTexture!==null||Ke.envMap!==ke||W.fog===!0&&Ke.fog!==Be||Ke.numClippingPlanes!==void 0&&(Ke.numClippingPlanes!==st.numPlanes||Ke.numIntersection!==st.numIntersection)||Ke.vertexAlphas!==nt||Ke.vertexTangents!==ut||Ke.morphTargets!==it||Ke.morphNormals!==Et||Ke.morphColors!==hn||Ke.toneMapping!==on||Ke.morphTargetsCount!==Kt||!!Ke.lightProbeGrid!=O.state.lightProbeGridArray.length>0)&&(Nt=!0):(Nt=!0,Ke.__version=W.version);let wn=Ke.currentProgram;Nt===!0&&(wn=Ji(W,H,q),Q&&W.isNodeMaterial&&Q.onUpdateProgram(W,wn,Ke));let ci=!1,Fi=!1,ui=!1;const $t=wn.getUniforms(),pn=Ke.uniforms;if(C.useProgram(wn.program)&&(ci=!0,Fi=!0,ui=!0),W.id!==Se&&(Se=W.id,Fi=!0),Ke.needsLights){const Wt=ga(O.state.lightProbeGridArray,q);Ke.lightProbeGrid!==Wt&&(Ke.lightProbeGrid=Wt,Fi=!0)}if(ci||xe!==T){C.buffers.depth.getReversed()&&T.reversedDepth!==!0&&(T._reversedDepth=!0,T.updateProjectionMatrix()),$t.setValue(F,"projectionMatrix",T.projectionMatrix),$t.setValue(F,"viewMatrix",T.matrixWorldInverse);const ea=$t.map.cameraPosition;ea!==void 0&&ea.setValue(F,zt.setFromMatrixPosition(T.matrixWorld)),B.logarithmicDepthBuffer&&$t.setValue(F,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),(W.isMeshPhongMaterial||W.isMeshToonMaterial||W.isMeshLambertMaterial||W.isMeshBasicMaterial||W.isMeshStandardMaterial||W.isShaderMaterial)&&$t.setValue(F,"isOrthographic",T.isOrthographicCamera===!0),xe!==T&&(xe=T,Fi=!0,ui=!0)}if(Ke.needsLights&&(jn.state.directionalShadowMap.length>0&&$t.setValue(F,"directionalShadowMap",jn.state.directionalShadowMap,he),jn.state.spotShadowMap.length>0&&$t.setValue(F,"spotShadowMap",jn.state.spotShadowMap,he),jn.state.pointShadowMap.length>0&&$t.setValue(F,"pointShadowMap",jn.state.pointShadowMap,he)),q.isSkinnedMesh){$t.setOptional(F,q,"bindMatrix"),$t.setOptional(F,q,"bindMatrixInverse");const Wt=q.skeleton;Wt&&(Wt.boneTexture===null&&Wt.computeBoneTexture(),$t.setValue(F,"boneTexture",Wt.boneTexture,he))}q.isBatchedMesh&&($t.setOptional(F,q,"batchingTexture"),$t.setValue(F,"batchingTexture",q._matricesTexture,he),$t.setOptional(F,q,"batchingIdTexture"),$t.setValue(F,"batchingIdTexture",q._indirectTexture,he),$t.setOptional(F,q,"batchingColorTexture"),q._colorsTexture!==null&&$t.setValue(F,"batchingColorTexture",q._colorsTexture,he));const zi=Y.morphAttributes;if((zi.position!==void 0||zi.normal!==void 0||zi.color!==void 0)&&Z.update(q,Y,wn),(Fi||Ke.receiveShadow!==q.receiveShadow)&&(Ke.receiveShadow=q.receiveShadow,$t.setValue(F,"receiveShadow",q.receiveShadow)),(W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial)&&W.envMap===null&&H.environment!==null&&(pn.envMapIntensity.value=H.environmentIntensity),pn.dfgLUT!==void 0&&(pn.dfgLUT.value=hR()),Fi){if($t.setValue(F,"toneMappingExposure",k.toneMappingExposure),Ke.needsLights&&vn(pn,ui),Be&&W.fog===!0&&Xe.refreshFogUniforms(pn,Be),Xe.refreshMaterialUniforms(pn,W,Ae,Me,O.state.transmissionRenderTarget[T.id]),Ke.needsLights&&Ke.lightProbeGrid){const Wt=Ke.lightProbeGrid;pn.probesSH.value=Wt.texture,pn.probesMin.value.copy(Wt.boundingBox.min),pn.probesMax.value.copy(Wt.boundingBox.max),pn.probesResolution.value.copy(Wt.resolution)}wu.upload(F,li(Ke),pn,he)}if(W.isShaderMaterial&&W.uniformsNeedUpdate===!0&&(wu.upload(F,li(Ke),pn,he),W.uniformsNeedUpdate=!1),W.isSpriteMaterial&&$t.setValue(F,"center",q.center),$t.setValue(F,"modelViewMatrix",q.modelViewMatrix),$t.setValue(F,"normalMatrix",q.normalMatrix),$t.setValue(F,"modelMatrix",q.matrixWorld),W.uniformsGroups!==void 0){const Wt=W.uniformsGroups;for(let ea=0,Ya=Wt.length;ea<Ya;ea++){const Ls=Wt[ea];Ce.update(Ls,wn),Ce.bind(Ls,wn)}}return wn}function vn(T,H){T.ambientLightColor.needsUpdate=H,T.lightProbe.needsUpdate=H,T.directionalLights.needsUpdate=H,T.directionalLightShadows.needsUpdate=H,T.pointLights.needsUpdate=H,T.pointLightShadows.needsUpdate=H,T.spotLights.needsUpdate=H,T.spotLightShadows.needsUpdate=H,T.rectAreaLights.needsUpdate=H,T.hemisphereLights.needsUpdate=H}function ne(T){return T.isMeshLambertMaterial||T.isMeshToonMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isShadowMaterial||T.isShaderMaterial&&T.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return se},this.setRenderTargetTextures=function(T,H,Y){const W=oe.get(T);W.__autoAllocateDepthBuffer=T.resolveDepthBuffer===!1,W.__autoAllocateDepthBuffer===!1&&(W.__useRenderToTexture=!1),oe.get(T.texture).__webglTexture=H,oe.get(T.depthTexture).__webglTexture=W.__autoAllocateDepthBuffer?void 0:Y,W.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(T,H){const Y=oe.get(T);Y.__webglFramebuffer=H,Y.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(T,H=0,Y=0){se=T,G=H,j=Y;let W=null,q=!1,Be=!1;if(T){const Pe=oe.get(T);if(Pe.__useDefaultFramebuffer!==void 0){C.bindFramebuffer(F.FRAMEBUFFER,Pe.__webglFramebuffer),z.copy(T.viewport),te.copy(T.scissor),Ee=T.scissorTest,C.viewport(z),C.scissor(te),C.setScissorTest(Ee),Se=-1;return}else if(Pe.__webglFramebuffer===void 0)he.setupRenderTarget(T);else if(Pe.__hasExternalTextures)he.rebindTextures(T,oe.get(T.texture).__webglTexture,oe.get(T.depthTexture).__webglTexture);else if(T.depthBuffer){const nt=T.depthTexture;if(Pe.__boundDepthTexture!==nt){if(nt!==null&&oe.has(nt)&&(T.width!==nt.image.width||T.height!==nt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");he.setupDepthRenderbuffer(T)}}const We=T.texture;(We.isData3DTexture||We.isDataArrayTexture||We.isCompressedArrayTexture)&&(Be=!0);const ke=oe.get(T).__webglFramebuffer;T.isWebGLCubeRenderTarget?(Array.isArray(ke[H])?W=ke[H][Y]:W=ke[H],q=!0):T.samples>0&&he.useMultisampledRTT(T)===!1?W=oe.get(T).__webglMultisampledFramebuffer:Array.isArray(ke)?W=ke[Y]:W=ke,z.copy(T.viewport),te.copy(T.scissor),Ee=T.scissorTest}else z.copy($e).multiplyScalar(Ae).floor(),te.copy(Pt).multiplyScalar(Ae).floor(),Ee=gt;if(Y!==0&&(W=fe),C.bindFramebuffer(F.FRAMEBUFFER,W)&&C.drawBuffers(T,W),C.viewport(z),C.scissor(te),C.setScissorTest(Ee),q){const Pe=oe.get(T.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+H,Pe.__webglTexture,Y)}else if(Be){const Pe=H;for(let We=0;We<T.textures.length;We++){const ke=oe.get(T.textures[We]);F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0+We,ke.__webglTexture,Y,Pe)}}else if(T!==null&&Y!==0){const Pe=oe.get(T.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,Pe.__webglTexture,Y)}Se=-1},this.readRenderTargetPixels=function(T,H,Y,W,q,Be,ze,Pe=0){if(!(T&&T.isWebGLRenderTarget)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let We=oe.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&ze!==void 0&&(We=We[ze]),We){C.bindFramebuffer(F.FRAMEBUFFER,We);try{const ke=T.textures[Pe],nt=ke.format,ut=ke.type;if(T.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+Pe),!B.textureFormatReadable(nt)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!B.textureTypeReadable(ut)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=T.width-W&&Y>=0&&Y<=T.height-q&&F.readPixels(H,Y,W,q,Fe.convert(nt),Fe.convert(ut),Be)}finally{const ke=se!==null?oe.get(se).__webglFramebuffer:null;C.bindFramebuffer(F.FRAMEBUFFER,ke)}}},this.readRenderTargetPixelsAsync=async function(T,H,Y,W,q,Be,ze,Pe=0){if(!(T&&T.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let We=oe.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&ze!==void 0&&(We=We[ze]),We)if(H>=0&&H<=T.width-W&&Y>=0&&Y<=T.height-q){C.bindFramebuffer(F.FRAMEBUFFER,We);const ke=T.textures[Pe],nt=ke.format,ut=ke.type;if(T.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+Pe),!B.textureFormatReadable(nt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!B.textureTypeReadable(ut))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const it=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,it),F.bufferData(F.PIXEL_PACK_BUFFER,Be.byteLength,F.STREAM_READ),F.readPixels(H,Y,W,q,Fe.convert(nt),Fe.convert(ut),0);const Et=se!==null?oe.get(se).__webglFramebuffer:null;C.bindFramebuffer(F.FRAMEBUFFER,Et);const hn=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await CE(F,hn,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,it),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,Be),F.deleteBuffer(it),F.deleteSync(hn),Be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,H=null,Y=0){const W=Math.pow(2,-Y),q=Math.floor(T.image.width*W),Be=Math.floor(T.image.height*W),ze=H!==null?H.x:0,Pe=H!==null?H.y:0;he.setTexture2D(T,0),F.copyTexSubImage2D(F.TEXTURE_2D,Y,0,0,ze,Pe,q,Be),C.unbindTexture()},this.copyTextureToTexture=function(T,H,Y=null,W=null,q=0,Be=0){let ze,Pe,We,ke,nt,ut,it,Et,hn;const on=T.isCompressedTexture?T.mipmaps[Be]:T.image;if(Y!==null)ze=Y.max.x-Y.min.x,Pe=Y.max.y-Y.min.y,We=Y.isBox3?Y.max.z-Y.min.z:1,ke=Y.min.x,nt=Y.min.y,ut=Y.isBox3?Y.min.z:0;else{const pn=Math.pow(2,-q);ze=Math.floor(on.width*pn),Pe=Math.floor(on.height*pn),T.isDataArrayTexture?We=on.depth:T.isData3DTexture?We=Math.floor(on.depth*pn):We=1,ke=0,nt=0,ut=0}W!==null?(it=W.x,Et=W.y,hn=W.z):(it=0,Et=0,hn=0);const Zt=Fe.convert(H.format),Kt=Fe.convert(H.type);let Ke;H.isData3DTexture?(he.setTexture3D(H,0),Ke=F.TEXTURE_3D):H.isDataArrayTexture||H.isCompressedArrayTexture?(he.setTexture2DArray(H,0),Ke=F.TEXTURE_2D_ARRAY):(he.setTexture2D(H,0),Ke=F.TEXTURE_2D),C.activeTexture(F.TEXTURE0),C.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,H.flipY),C.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),C.pixelStorei(F.UNPACK_ALIGNMENT,H.unpackAlignment);const jn=C.getParameter(F.UNPACK_ROW_LENGTH),Nt=C.getParameter(F.UNPACK_IMAGE_HEIGHT),wn=C.getParameter(F.UNPACK_SKIP_PIXELS),ci=C.getParameter(F.UNPACK_SKIP_ROWS),Fi=C.getParameter(F.UNPACK_SKIP_IMAGES);C.pixelStorei(F.UNPACK_ROW_LENGTH,on.width),C.pixelStorei(F.UNPACK_IMAGE_HEIGHT,on.height),C.pixelStorei(F.UNPACK_SKIP_PIXELS,ke),C.pixelStorei(F.UNPACK_SKIP_ROWS,nt),C.pixelStorei(F.UNPACK_SKIP_IMAGES,ut);const ui=T.isDataArrayTexture||T.isData3DTexture,$t=H.isDataArrayTexture||H.isData3DTexture;if(T.isDepthTexture){const pn=oe.get(T),zi=oe.get(H),Wt=oe.get(pn.__renderTarget),ea=oe.get(zi.__renderTarget);C.bindFramebuffer(F.READ_FRAMEBUFFER,Wt.__webglFramebuffer),C.bindFramebuffer(F.DRAW_FRAMEBUFFER,ea.__webglFramebuffer);for(let Ya=0;Ya<We;Ya++)ui&&(F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,oe.get(T).__webglTexture,q,ut+Ya),F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,oe.get(H).__webglTexture,Be,hn+Ya)),F.blitFramebuffer(ke,nt,ze,Pe,it,Et,ze,Pe,F.DEPTH_BUFFER_BIT,F.NEAREST);C.bindFramebuffer(F.READ_FRAMEBUFFER,null),C.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else if(q!==0||T.isRenderTargetTexture||oe.has(T)){const pn=oe.get(T),zi=oe.get(H);C.bindFramebuffer(F.READ_FRAMEBUFFER,pe),C.bindFramebuffer(F.DRAW_FRAMEBUFFER,J);for(let Wt=0;Wt<We;Wt++)ui?F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,pn.__webglTexture,q,ut+Wt):F.framebufferTexture2D(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,pn.__webglTexture,q),$t?F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,zi.__webglTexture,Be,hn+Wt):F.framebufferTexture2D(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,zi.__webglTexture,Be),q!==0?F.blitFramebuffer(ke,nt,ze,Pe,it,Et,ze,Pe,F.COLOR_BUFFER_BIT,F.NEAREST):$t?F.copyTexSubImage3D(Ke,Be,it,Et,hn+Wt,ke,nt,ze,Pe):F.copyTexSubImage2D(Ke,Be,it,Et,ke,nt,ze,Pe);C.bindFramebuffer(F.READ_FRAMEBUFFER,null),C.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else $t?T.isDataTexture||T.isData3DTexture?F.texSubImage3D(Ke,Be,it,Et,hn,ze,Pe,We,Zt,Kt,on.data):H.isCompressedArrayTexture?F.compressedTexSubImage3D(Ke,Be,it,Et,hn,ze,Pe,We,Zt,on.data):F.texSubImage3D(Ke,Be,it,Et,hn,ze,Pe,We,Zt,Kt,on):T.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,Be,it,Et,ze,Pe,Zt,Kt,on.data):T.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,Be,it,Et,on.width,on.height,Zt,on.data):F.texSubImage2D(F.TEXTURE_2D,Be,it,Et,ze,Pe,Zt,Kt,on);C.pixelStorei(F.UNPACK_ROW_LENGTH,jn),C.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Nt),C.pixelStorei(F.UNPACK_SKIP_PIXELS,wn),C.pixelStorei(F.UNPACK_SKIP_ROWS,ci),C.pixelStorei(F.UNPACK_SKIP_IMAGES,Fi),Be===0&&H.generateMipmaps&&F.generateMipmap(Ke),C.unbindTexture()},this.initRenderTarget=function(T){oe.get(T).__webglFramebuffer===void 0&&he.setupRenderTarget(T)},this.initTexture=function(T){T.isCubeTexture?he.setTextureCube(T,0):T.isData3DTexture?he.setTexture3D(T,0):T.isDataArrayTexture||T.isCompressedArrayTexture?he.setTexture2DArray(T,0):he.setTexture2D(T,0),C.unbindTexture()},this.resetState=function(){G=0,j=0,se=null,C.reset(),Ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return la}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Gt._getDrawingBufferColorSpace(e),n.unpackColorSpace=Gt._getUnpackColorSpace()}}const Tx={type:"change"},hm={type:"start"},Py={type:"end"},Su=new om,Ax=new Es,mR=Math.cos(70*DE.DEG2RAD),Dn=new re,si=2*Math.PI,sn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Hh=1e-6;class gR extends vT{constructor(e,n=null){super(e,n),this.state=sn.NONE,this.target=new re,this.cursor=new re,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:fo.ROTATE,MIDDLE:fo.DOLLY,RIGHT:fo.PAN},this.touches={ONE:oo.ROTATE,TWO:oo.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 re,this._lastQuaternion=new ws,this._lastTargetPosition=new re,this._quat=new ws().setFromUnitVectors(e.up,new re(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Jv,this._sphericalDelta=new Jv,this._scale=1,this._panOffset=new re,this._rotateStart=new xt,this._rotateEnd=new xt,this._rotateDelta=new xt,this._panStart=new xt,this._panEnd=new xt,this._panDelta=new xt,this._dollyStart=new xt,this._dollyEnd=new xt,this._dollyDelta=new xt,this._dollyDirection=new re,this._mouse=new xt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=vR.bind(this),this._onPointerDown=_R.bind(this),this._onPointerUp=xR.bind(this),this._onContextMenu=AR.bind(this),this._onMouseWheel=MR.bind(this),this._onKeyDown=bR.bind(this),this._onTouchStart=ER.bind(this),this._onTouchMove=TR.bind(this),this._onMouseDown=yR.bind(this),this._onMouseMove=SR.bind(this),this._interceptControlDown=CR.bind(this),this._interceptControlUp=wR.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(Tx),this.update(),this.state=sn.NONE}pan(e,n){this._pan(e,n),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){const n=this.object.position;Dn.copy(n).sub(this.target),Dn.applyQuaternion(this._quat),this._spherical.setFromVector3(Dn),this.autoRotate&&this.state===sn.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 s=this.minAzimuthAngle,l=this.maxAzimuthAngle;isFinite(s)&&isFinite(l)&&(s<-Math.PI?s+=si:s>Math.PI&&(s-=si),l<-Math.PI?l+=si:l>Math.PI&&(l-=si),s<=l?this._spherical.theta=Math.max(s,Math.min(l,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+l)/2?Math.max(s,this._spherical.theta):Math.min(l,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 c=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const f=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),c=f!=this._spherical.radius}if(Dn.setFromSpherical(this._spherical),Dn.applyQuaternion(this._quatInverse),n.copy(this.target).add(Dn),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 f=null;if(this.object.isPerspectiveCamera){const p=Dn.length();f=this._clampDistance(p*this._scale);const m=p-f;this.object.position.addScaledVector(this._dollyDirection,m),this.object.updateMatrixWorld(),c=!!m}else if(this.object.isOrthographicCamera){const p=new re(this._mouse.x,this._mouse.y,0);p.unproject(this.object);const m=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),c=m!==this.object.zoom;const h=new re(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(p),this.object.updateMatrixWorld(),f=Dn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;f!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(f).add(this.object.position):(Su.origin.copy(this.object.position),Su.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Su.direction))<mR?this.object.lookAt(this.target):(Ax.setFromNormalAndCoplanarPoint(this.object.up,this.target),Su.intersectPlane(Ax,this.target))))}else if(this.object.isOrthographicCamera){const f=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),f!==this.object.zoom&&(this.object.updateProjectionMatrix(),c=!0)}return this._scale=1,this._performCursorZoom=!1,c||this._lastPosition.distanceToSquared(this.object.position)>Hh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Hh||this._lastTargetPosition.distanceToSquared(this.target)>Hh?(this.dispatchEvent(Tx),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?si/60*this.autoRotateSpeed*e:si/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){Dn.setFromMatrixColumn(n,0),Dn.multiplyScalar(-e),this._panOffset.add(Dn)}_panUp(e,n){this.screenSpacePanning===!0?Dn.setFromMatrixColumn(n,1):(Dn.setFromMatrixColumn(n,0),Dn.crossVectors(this.object.up,Dn)),Dn.multiplyScalar(e),this._panOffset.add(Dn)}_pan(e,n){const s=this.domElement;if(this.object.isPerspectiveCamera){const l=this.object.position;Dn.copy(l).sub(this.target);let c=Dn.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*c/s.clientHeight,this.object.matrix),this._panUp(2*n*c/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/s.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,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),l=e-s.left,c=n-s.top,f=s.width,p=s.height;this._mouse.x=l/f*2-1,this._mouse.y=-(c/p)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(si*this._rotateDelta.x/n.clientHeight),this._rotateUp(si*this._rotateDelta.y/n.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 n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(si*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-si*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(si*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-si*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),l=.5*(e.pageY+n.y);this._rotateStart.set(s,l)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),l=.5*(e.pageY+n.y);this._panStart.set(s,l)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),s=e.pageX-n.x,l=e.pageY-n.y,c=Math.sqrt(s*s+l*l);this._dollyStart.set(0,c)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),l=.5*(e.pageX+s.x),c=.5*(e.pageY+s.y);this._rotateEnd.set(l,c)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(si*this._rotateDelta.x/n.clientHeight),this._rotateUp(si*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),l=.5*(e.pageY+n.y);this._panEnd.set(s,l)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),s=e.pageX-n.x,l=e.pageY-n.y,c=Math.sqrt(s*s+l*l);this._dollyEnd.set(0,c),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const f=(e.pageX+n.x)*.5,p=(e.pageY+n.y)*.5;this._updateZoomParameters(f,p)}_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 n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new xt,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function _R(a){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(a.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(a)&&(this._addPointer(a),a.pointerType==="touch"?this._onTouchStart(a):this._onMouseDown(a),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function vR(a){this.enabled!==!1&&(a.pointerType==="touch"?this._onTouchMove(a):this._onMouseMove(a))}function xR(a){switch(this._removePointer(a),this._pointers.length){case 0:this.domElement.releasePointerCapture(a.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Py),this.state=sn.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function yR(a){let e;switch(a.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case fo.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(a),this.state=sn.DOLLY;break;case fo.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=sn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=sn.ROTATE}break;case fo.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=sn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=sn.PAN}break;default:this.state=sn.NONE}this.state!==sn.NONE&&this.dispatchEvent(hm)}function SR(a){switch(this.state){case sn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(a);break;case sn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(a);break;case sn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(a);break}}function MR(a){this.enabled===!1||this.enableZoom===!1||this.state!==sn.NONE||(a.preventDefault(),this.dispatchEvent(hm),this._handleMouseWheel(this._customWheelEvent(a)),this.dispatchEvent(Py))}function bR(a){this.enabled!==!1&&this._handleKeyDown(a)}function ER(a){switch(this._trackPointer(a),this._pointers.length){case 1:switch(this.touches.ONE){case oo.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(a),this.state=sn.TOUCH_ROTATE;break;case oo.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(a),this.state=sn.TOUCH_PAN;break;default:this.state=sn.NONE}break;case 2:switch(this.touches.TWO){case oo.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(a),this.state=sn.TOUCH_DOLLY_PAN;break;case oo.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(a),this.state=sn.TOUCH_DOLLY_ROTATE;break;default:this.state=sn.NONE}break;default:this.state=sn.NONE}this.state!==sn.NONE&&this.dispatchEvent(hm)}function TR(a){switch(this._trackPointer(a),this.state){case sn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(a),this.update();break;case sn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(a),this.update();break;case sn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(a),this.update();break;case sn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(a),this.update();break;default:this.state=sn.NONE}}function AR(a){this.enabled!==!1&&a.preventDefault()}function CR(a){a.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function wR(a){a.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Xa=16,Cx=28,RR=20;function lo(a,e,n){return Math.min(n,Math.max(e,a))}function Fp(a){const e=Array.isArray(a)?a:[a];for(const n of e)n.dispose()}function Bu(a,e){e&&(a.remove(e),e.geometry.dispose(),Fp(e.material))}function DR(a){return new lT({color:a,emissive:a.clone().multiplyScalar(.58),emissiveIntensity:.48,metalness:.04,roughness:.68,vertexColors:!0})}function NR(){return new lm({blending:Wh,depthWrite:!1,opacity:.26,transparent:!0,vertexColors:!0})}function UR(a){const e=new nT(new Us(Xa,Xa,Xa)),n=new um({color:new ot(a.primaryColor).lerp(new ot("#ffffff"),.1)}),s=new My(e,n);return s.visible=a.showBounds,s}function LR(a){const e=new _T(Xa,12,new ot(a.accentColor).lerp(new ot("#ffffff"),.05),new ot(a.primaryColor).lerp(new ot("#000000"),.4));e.position.y=-Xa/2;const n=e.material;return n.opacity=.28,n.transparent=!0,e}function OR(a,e){a.primaryColor=new ot(e.primaryColor),a.accentColor=new ot(e.accentColor),a.bounds.visible=e.showBounds,a.bounds.material.color=a.primaryColor.clone().lerp(new ot("#ffffff"),.1)}function PR(a,e){const s=Xa/a*(1-lo(e.cellGap,.02,.45)),l=new Us(s,s,s),c=DR(new ot(e.primaryColor)),f=new Sy(l,c,Math.max(1,a**3));return f.instanceMatrix.setUsage(hy),f.castShadow=!0,f.receiveShadow=!0,f}function IR(a,e){const s=Xa/a*(1-lo(e.cellGap,.02,.45))*1.18,l=new Us(s,s,s),c=NR(),f=new Sy(l,c,Math.max(1,a**3));return f.instanceMatrix.setUsage(hy),f.castShadow=!1,f.receiveShadow=!1,f}const Gh=["#70f45f","#f0c94a","#35d6ff","#ff5fb7","#ff7a3d","#b28cff","#f7f7df","#42f5b0","#ffef5f","#6aa8ff"];function BR(a,e){const n=Number(a),s=Number(e);return Number.isFinite(n)&&Number.isFinite(s)?n-s:a.localeCompare(e)}function zp(a){return a.state??"occupied"}function FR(a,e){const n=[...new Set(a.map(zp))].sort(BR),s=new Map,l=new Map,c=new ot(e.primaryColor),f=new ot(e.accentColor);return n.forEach((p,m)=>{if(l.set(p,m),n.length===1){s.set(p,c.clone());return}const h=Gh[m%Gh.length],_=new ot(h);m>=Gh.length&&_.setHSL(m*.61803398875%1,.72,.56),_.lerp(f,m%2===0?.08:.16),s.set(p,_)}),{colors:s,indices:l}}function zR(a,e,n,s,l,c){const f=n>1?e.y/(n-1):.5,p=n>1?e.z/(n-1):.5,m=l.indices.get(zp(e))??0,h=Math.max(1,l.colors.size-1),_=l.colors.size>1?lo(m/h,0,1):.5;if(c.copy(l.colors.get(zp(e))??a.primaryColor),c.lerp(a.accentColor,lo(f*.08,0,.16)),s==="lattice-gas-3d"||s==="snake-3d"||s==="naga-3d"){c.lerp(new ot("#ffffff"),lo(_*.22+p*.08,0,.34)),c.multiplyScalar(1+_*.16);return}s==="generations-3d"&&c.lerp(new ot("#94a3b8"),_*.22),c.lerp(new ot("#ffffff"),lo(p*.18,0,.24)),c.offsetHSL(0,0,.05+p*.1)}function HR(a,e,n,s,l){Bu(a.scene,a.mesh),Bu(a.scene,a.glowMesh),a.mesh=PR(n,l),a.glowMesh=IR(n,l),a.scene.add(a.glowMesh),a.scene.add(a.mesh);const c=a.mesh,f=a.glowMesh,p=new Nn,m=new ot,h=new ot,_=Xa/n,S=-Xa/2+_/2,v=FR(e,l);let M=0;for(const E of e){if(M>=c.count)break;E.x<0||E.y<0||E.z<0||E.x>=n||E.y>=n||E.z>=n||(p.position.set(S+E.x*_,S+E.y*_,S+E.z*_),p.rotation.set(0,0,0),p.updateMatrix(),zR(a,E,n,s,v,m),c.setMatrixAt(M,p.matrix),c.setColorAt(M,m),h.copy(m).lerp(new ot("#ffffff"),.16).multiplyScalar(1.18),f.setMatrixAt(M,p.matrix),f.setColorAt(M,h),M+=1)}c.count=M,f.count=M,c.instanceMatrix.needsUpdate=!0,f.instanceMatrix.needsUpdate=!0,c.instanceColor&&(c.instanceColor.needsUpdate=!0),f.instanceColor&&(f.instanceColor.needsUpdate=!0)}function GR(a,e){const n=new jE;n.background=new ot("#061006");const s=new Li(42,1,.1,300);s.position.set(Cx,RR,Cx);const l=new pR({antialias:!0,alpha:!0});l.setPixelRatio(Math.min(window.devicePixelRatio,2)),l.shadowMap.enabled=!0,l.shadowMap.type=Qx,l.outputColorSpace=yi,l.toneMapping=Kp,l.toneMappingExposure=1.32,a.appendChild(l.domElement);const c=new gR(s,l.domElement);c.enableDamping=!0,c.dampingFactor=.06,c.minDistance=12,c.maxDistance=60,c.target.set(0,0,0),n.add(new pT("#f5efb7",.72)),n.add(new fT("#f5efb7","#10360d",1.18));const f=new Qv("#fff3a8",.82);f.position.set(18,28,14),f.target.position.set(0,0,0),n.add(f),n.add(f.target);const p=new Qv(e.accentColor,.72);p.position.set(-24,18,-12),n.add(p);const m=UR(e);n.add(m);const h=LR(e);n.add(h);const _={animationFrame:0,bounds:m,glowMesh:null,grid:h,mesh:null,primaryColor:new ot(e.primaryColor),accentColor:new ot(e.accentColor),resizeObserver:new ResizeObserver(()=>S()),scene:n};function S(){const E=Math.max(a.clientWidth,1),w=Math.max(a.clientHeight,1);s.aspect=E/w,s.updateProjectionMatrix(),l.setSize(E,w,!1)}function v(){c.update(),l.render(n,s)}function M(){v(),_.animationFrame=window.requestAnimationFrame(M)}return _.resizeObserver.observe(a),S(),M(),{dispose(){window.cancelAnimationFrame(_.animationFrame),_.resizeObserver.disconnect(),Bu(_.scene,_.mesh),Bu(_.scene,_.glowMesh),_.bounds.geometry.dispose(),Fp(_.bounds.material),_.grid.geometry.dispose(),Fp(_.grid.material),c.dispose(),l.dispose(),l.domElement.parentNode===a&&a.removeChild(l.domElement)},render:v,update(E){OR(_,E.options),HR(_,E.cells,E.size,E.ruleId,E.options),v()}}}function VR(a){const e=a.simulation?.grid?.size;if(!Array.isArray(e))return 16;const n=e[0];return typeof n=="number"?Math.min(30,Math.max(8,Math.round(n))):16}function kR(a){const e=a.simulation?.ruleId;return typeof e=="string"&&e.endsWith("-3d")?e:"life-3d"}function jR(a){const e=a.renderer??{};return{accentColor:typeof e.accentColor=="string"?e.accentColor:"#f0c94a",cellGap:typeof e.cellGap=="number"?e.cellGap:.14,primaryColor:typeof e.primaryColor=="string"?e.primaryColor:"#70f45f",showBounds:typeof e.showBounds=="boolean"?e.showBounds:!0}}function XR(a){const e=a.simulation?.initialCondition?.cells;return Array.isArray(e)?e.flatMap(n=>{const s=n,[l,c,f=0]=s;if(!Number.isInteger(l)||!Number.isInteger(c)||!Number.isInteger(f))return[];const p=l,m=c,h=f,_=s.length>=4?s[3]:"occupied";if(_===null||_==="none"||_==="empty")return[];const S=typeof _=="string"||typeof _=="number"?String(_):"occupied";return[{x:p,y:m,z:h,state:S}]}):[]}function WR({caption:a,settings:e}){const n=ee.useRef(null),s=ee.useRef(null),l=XR(e),c=VR(e),f=kR(e),p=ee.useMemo(()=>jR(e),[e]);return ee.useEffect(()=>{const m=n.current;if(!m)return;const h=GR(m,p);return s.current=h,h.update({cells:l,options:p,ruleId:f,size:c}),()=>{h.dispose(),s.current=null}},[]),ee.useEffect(()=>{s.current?.update({cells:l,options:p,ruleId:f,size:c})},[l,p,f,c]),g.jsxs("div",{className:"board-wrap voxel-renderer-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("div",{className:"studio-voxel-viewport",ref:n}),l.length===0?g.jsx("div",{className:"voxel-empty-hint",children:"No voxel initial condition on this node"}):null]})}const Ol=new Map;function Xu(a,e={}){if(!a.id.trim())throw new Error("CA renderer runtime id is required");if(Ol.has(a.id)&&!e.replace)throw new Error(`CA renderer runtime already registered: ${a.id}`);Ol.set(a.id,a)}function qR(){return[...Ol.values()]}function Vh(a){return qR().filter(e=>za(e,a))}function YR(a){return Ol.get(a)??[...Ol.values()].find(e=>e.aliases?.includes(a))??null}function Wu({caption:a,cells:e,settings:n,onCellsChange:s}){const l=n.renderer?.id??"2d-canvas",c=YR(l),f=sr(n);if(c&&(!f||za(c,f))){const p=c.Component;return g.jsx(p,{caption:a,cells:e,settings:n,onCellsChange:s})}return g.jsxs("div",{className:"board-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("div",{className:"renderer-empty",children:c?`Renderer ${l} does not support this CA space`:`Renderer unavailable: ${l}`})]})}function ZR({caption:a,settings:e}){return g.jsx(WR,{caption:a,settings:e})}function KR(a,e,n,s){return typeof a=="number"&&Number.isFinite(a)?Math.max(n,Math.min(s,a)):e}function $R(a){const e=a.renderer?.elementaryRule;if(typeof e=="number")return Math.max(0,Math.min(255,Math.floor(e)));const n=a.simulation?.ruleId??"",s=/(?:rule[-_\s]*)?(\d{1,3})/i.exec(n);return s?Math.max(0,Math.min(255,Number(s[1]))):110}function QR(a,e){return a.map((n,s)=>{const l=a[(s-1+a.length)%a.length]?1:0,c=a[s]?1:0,f=a[(s+1)%a.length]?1:0,p=l<<2|c<<1|f;return(e>>p&1)===1})}function JR(a){const e=a.findIndex(n=>n.some(Boolean));return e===-1?0:e}function e2({caption:a,cells:e,onCellsChange:n}){const s=ee.useRef(null),l=ee.useRef(e),c=ee.useRef(null),[f,p]=ee.useState(0),m=e[0]?.length??0,h=e.length;ee.useEffect(()=>{l.current=e},[e]),ee.useEffect(()=>{const w=s.current;if(!w)return;const y=new ResizeObserver(()=>p(x=>x+1));return y.observe(w),()=>y.disconnect()},[]),ee.useEffect(()=>{const w=s.current;if(!w||m===0||h===0)return;const y=w.getContext("2d");if(!y)return;const x=w.getBoundingClientRect(),P=window.devicePixelRatio||1,L=Math.max(1,Math.floor(x.width*P)),R=Math.max(1,Math.floor(x.height*P));(w.width!==L||w.height!==R)&&(w.width=L,w.height=R),y.setTransform(P,0,0,P,0,0),y.clearRect(0,0,x.width,x.height),y.fillStyle="#071206",y.fillRect(0,0,x.width,x.height);const I=Math.min(x.width/m,x.height/h),O=I*m,U=I*h,A=(x.width-O)/2,N=(x.height-U)/2,k=Math.max(1,Math.min(2,I*.08));y.strokeStyle="#1e3519",y.lineWidth=1;for(let V=0;V<h;V+=1)for(let Q=0;Q<m;Q+=1){const fe=A+Q*I+k/2,pe=N+V*I+k/2,J=Math.max(1,I-k);e[V][Q]?(y.fillStyle="#70f45f",y.shadowColor="rgba(112, 244, 95, 0.42)",y.shadowBlur=Math.max(0,I*.38),y.fillRect(fe,pe,J,J),y.shadowBlur=0,y.strokeStyle="#b7ffab"):(y.fillStyle="#071206",y.fillRect(fe,pe,J,J),y.strokeStyle="#1e3519"),y.strokeRect(fe+.5,pe+.5,Math.max(0,J-1),Math.max(0,J-1))}},[f,e,h,m]);function _(w){const y=s.current;if(!y||m===0||h===0)return null;const x=y.getBoundingClientRect(),P=Math.min(x.width/m,x.height/h),L=P*m,R=P*h,I=(x.width-L)/2,O=(x.height-R)/2,U=Math.floor((w.clientX-x.left-I)/P),A=Math.floor((w.clientY-x.top-O)/P);return U<0||A<0||U>=m||A>=h?null:{x:U,y:A}}function S(w,y,x){const P=l.current;if(P[y]?.[w]===x)return;const L=P.map((R,I)=>I===y?R.map((O,U)=>U===w?x:O):R);l.current=L,n(L)}function v(w){const y=_(w);if(!y)return;w.currentTarget.setPointerCapture(w.pointerId);const x=!l.current[y.y][y.x];c.current=x,S(y.x,y.y,x)}function M(w){if(c.current===null)return;const y=_(w);y&&S(y.x,y.y,c.current)}function E(w){c.current=null,w.currentTarget.hasPointerCapture(w.pointerId)&&w.currentTarget.releasePointerCapture(w.pointerId)}return g.jsxs("div",{className:"board-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("canvas",{ref:s,"aria-label":"Game of Life cell editor",className:"board-canvas",role:"img",onPointerCancel:E,onPointerDown:v,onPointerLeave:E,onPointerMove:M,onPointerUp:E})]})}function t2({caption:a,cells:e,settings:n,onCellsChange:s}){const l=ee.useRef(null),c=ee.useRef(e),[f,p]=ee.useState(0),m=e[0]?.length??0,h=Math.min(e.length-1,Math.max(0,JR(e))),_=e[h]??[],S=$R(n),v=KR(n.renderer?.historyRows,96,8,512);ee.useEffect(()=>{c.current=e},[e]),ee.useEffect(()=>{const E=l.current;if(!E)return;const w=new ResizeObserver(()=>p(y=>y+1));return w.observe(E),()=>w.disconnect()},[]),ee.useEffect(()=>{const E=l.current;if(!E||m===0||_.length===0)return;const w=E.getContext("2d");if(!w)return;const y=E.getBoundingClientRect(),x=window.devicePixelRatio||1,P=Math.max(1,Math.floor(y.width*x)),L=Math.max(1,Math.floor(y.height*x));(E.width!==P||E.height!==L)&&(E.width=P,E.height=L),w.setTransform(x,0,0,x,0,0),w.clearRect(0,0,y.width,y.height),w.fillStyle="#061006",w.fillRect(0,0,y.width,y.height);const R=y.width/m,I=y.height/v;let O=[..._];for(let U=0;U<v;U+=1){const A=U/Math.max(1,v-1);for(let N=0;N<m;N+=1)if(O[N]){const k=Math.round(190+A*55),V=Math.round(112+A*80);w.fillStyle=`rgb(${V} ${k} 92)`,w.fillRect(N*R,U*I,Math.ceil(R),Math.ceil(I))}O=QR(O,S)}w.strokeStyle="rgba(240, 201, 74, 0.32)",w.lineWidth=1,w.strokeRect(.5,.5,Math.max(0,y.width-1),Math.max(0,y.height-1))},[f,v,S,_,m]);function M(E){const w=l.current;if(!w||m===0)return;const y=w.getBoundingClientRect(),x=Math.floor((E.clientX-y.left)/y.width*m);if(x<0||x>=m)return;const L=c.current.map((R,I)=>I===h?R.map((O,U)=>U===x?!O:O):R);c.current=L,s(L)}return g.jsxs("div",{className:"board-wrap elementary-renderer-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("canvas",{ref:l,"aria-label":`Elementary cellular automaton rule ${S}`,className:"elementary-canvas",role:"img",onPointerDown:M})]})}function n2({caption:a,cells:e,onCellsChange:n}){const s=ee.useRef(null),l=ee.useRef(e),c=ee.useRef(null),[f,p]=ee.useState(0),m=e[0]?.length??0,h=e.length;ee.useEffect(()=>{l.current=e},[e]),ee.useEffect(()=>{const w=s.current;if(!w)return;const y=new ResizeObserver(()=>p(x=>x+1));return y.observe(w),()=>y.disconnect()},[]),ee.useEffect(()=>{const w=s.current;if(!w||m===0||h===0)return;const y=w.getContext("2d");if(!y)return;const x=w.getBoundingClientRect(),P=window.devicePixelRatio||1,L=Math.max(1,Math.floor(x.width*P)),R=Math.max(1,Math.floor(x.height*P));(w.width!==L||w.height!==R)&&(w.width=L,w.height=R),y.setTransform(P,0,0,P,0,0),y.clearRect(0,0,x.width,x.height);const I=Math.min(x.width/m,x.height/h),O=I*m,U=I*h,A=(x.width-O)/2,N=(x.height-U)/2;y.fillStyle="#061006",y.fillRect(0,0,x.width,x.height);for(let k=0;k<h;k+=1)for(let V=0;V<m;V+=1){const Q=A+V*I,fe=N+k*I;if(e[k][V]){const pe=y.createRadialGradient(Q+I*.5,fe+I*.52,I*.08,Q+I*.5,fe+I*.52,I*.62);pe.addColorStop(0,"#fff5b9"),pe.addColorStop(.45,"#f0c94a"),pe.addColorStop(1,"#d9481e"),y.fillStyle=pe}else y.fillStyle=(V+k)%2===0?"#143f1b":"#0d2b14";y.fillRect(Q,fe,Math.ceil(I),Math.ceil(I))}},[f,e,h,m]);function _(w){const y=s.current;if(!y||m===0||h===0)return null;const x=y.getBoundingClientRect(),P=Math.min(x.width/m,x.height/h),L=P*m,R=P*h,I=(x.width-L)/2,O=(x.height-R)/2,U=Math.floor((w.clientX-x.left-I)/P),A=Math.floor((w.clientY-x.top-O)/P);return U<0||A<0||U>=m||A>=h?null:{x:U,y:A}}function S(w,y,x){const P=l.current;if(P[y]?.[w]===x)return;const L=P.map((R,I)=>I===y?R.map((O,U)=>U===w?x:O):R);l.current=L,n(L)}function v(w){const y=_(w);if(!y)return;w.currentTarget.setPointerCapture(w.pointerId);const x=!l.current[y.y][y.x];c.current=x,S(y.x,y.y,x)}function M(w){if(c.current===null)return;const y=_(w);y&&S(y.x,y.y,c.current)}function E(w){c.current=null,w.currentTarget.hasPointerCapture(w.pointerId)&&w.currentTarget.releasePointerCapture(w.pointerId)}return g.jsxs("div",{className:"board-wrap wildfire-renderer-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("canvas",{ref:s,"aria-label":"Wildfire cellular automaton editor",className:"wildfire-canvas",role:"img",onPointerCancel:E,onPointerDown:v,onPointerLeave:E,onPointerMove:M,onPointerUp:E})]})}Xu({id:"2d-canvas",label:"2D Canvas",supportedClasses:[{dimensions:2,states:2}],Component:e2},{replace:!0});Xu({id:"elementary-1d",label:"Elementary 1D",aliases:["elementary-ca","1d-canvas"],supportedClasses:[{dimensions:1,states:2}],Component:t2},{replace:!0});Xu({id:"wildfire-2d",label:"Wildfire 2D",aliases:["forest-fire-2d"],supportedClasses:[{dimensions:2,states:2}],Component:n2},{replace:!0});Xu({id:"voxel-3d",label:"Voxel 3D",aliases:["three-voxel"],supportedClasses:[{dimensions:3,states:2},{dimensions:3,states:7}],Component:ZR},{replace:!0});function i2(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)}function a2(a){const e=new Map;for(const s of a){const l=e.get(s.parent_id)??[];l.push(s),e.set(s.parent_id,l)}function n(s){return(e.get(s)??[]).sort(i2).map(l=>({node:l,children:n(l.id)}))}return n(null)}function s2({assignedNodeId:a,nodes:e,selectedNodeId:n,onSelect:s}){const l=ee.useMemo(()=>a2(e),[e]);return l.length===0?g.jsx("p",{className:"empty",children:"This CA library has no presets."}):g.jsx("div",{className:"asset-tree",children:l.map(c=>g.jsx(Iy,{assignedNodeId:a,item:c,selectedNodeId:n,onSelect:s},c.node.id))})}function Iy({assignedNodeId:a,item:e,selectedNodeId:n,onSelect:s}){const[l,c]=ee.useState(!0),f=e.node.id===n,p=e.node.id===a;return g.jsxs("div",{className:"asset-tree-item",children:[g.jsxs("div",{className:`asset-tree-row${f?" selected":""}${p?" assigned":""}`,children:[g.jsx("button",{"aria-label":e.children.length?`${l?"Collapse":"Expand"} ${e.node.name}`:`${e.node.name} has no children`,className:"asset-tree-arrow",disabled:!e.children.length,type:"button",onClick:()=>c(m=>!m),children:e.children.length?l?"▾":"▸":"·"}),g.jsxs("button",{className:"asset-tree-select",type:"button",onClick:()=>s(e.node),children:[g.jsx("strong",{children:e.node.name}),g.jsxs("small",{children:[e.node.kind,p?" · current":""]}),e.node.description?g.jsx("span",{children:e.node.description}):null]})]}),l&&e.children.length?g.jsx("div",{className:"asset-tree-children",children:e.children.map(m=>g.jsx(Iy,{assignedNodeId:a,item:m,selectedNodeId:n,onSelect:s},m.node.id))}):null]})}function cr(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function r2(a,e){return JSON.stringify(a)===JSON.stringify(e)}function kh(a,e){let n=a;for(const s of e){if(!cr(n)||!(s in n))return;n=n[s]}return n}function o2(a,e){return a.join(".")==="simulation.initialCondition"&&cr(e)?`${Array.isArray(e.cells)?e.cells.length:0} live cells`:Array.isArray(e)?`${e.length} items`:cr(e)?"object":String(e)}function pm(a,e){const n={...a};for(const[s,l]of Object.entries(e)){const c=n[s];n[s]=cr(c)&&cr(l)?pm(c,l):l}return n}function l2(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)||a.slug.localeCompare(e.slug)}function c2(a){const e=new Map;for(const s of a){const l=e.get(s.parent_id)??[];l.push(s),e.set(s.parent_id,l)}function n(s){const l=(e.get(s)??[]).sort(l2);return l.map((c,f)=>({node:c,children:n(c.id),siblingIndex:f,siblingCount:l.length}))}return n(null)}function By(a,e,n={},s=null){const l=[];for(const c of a)if(l.push({item:c,inheritedParams:n,parentId:s}),e.has(c.node.id)){const f=pm(n,c.node.params);l.push(...By(c.children,e,f,c.node.id))}return l}function u2({assignedNodeId:a,engines:e=[],nodes:n,selectedNodeId:s,usedNodeIds:l,onCreateChild:c,onCreateGroup:f,onDelete:p,onMove:m,onRename:h,onSelect:_,onSet:S,onUnset:v}){const M=ee.useMemo(()=>c2(n),[n]),[E,w]=ee.useState(()=>new Set(n.map(U=>U.id))),[y,x]=ee.useState(""),[P,L]=ee.useState(""),R=ee.useMemo(()=>By(M,E),[E,M]);ee.useEffect(()=>{w(U=>{const A=new Set([...U].filter(N=>n.some(k=>k.id===N)));for(const N of n)U.has(N.id)||A.add(N.id);return A})},[n]),ee.useEffect(()=>{if(!P)return;function U(N){const k=N.target;k instanceof Element&&(k.closest(".tree-node-action-menu")||k.closest(".node-action-trigger")||L(""))}function A(N){N.key==="Escape"&&L("")}return document.addEventListener("pointerdown",U),document.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",U),document.removeEventListener("keydown",A)}},[P]);function I(U,A){w(N=>{const k=new Set(N);return A??!k.has(U)?k.add(U):k.delete(U),k})}function O(U){if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter"].includes(U.key))return;const A=R.findIndex(({item:V})=>V.node.id===s),N=A===-1?0:A,k=R[N];if(k){if(U.key==="ArrowDown"||U.key==="ArrowUp"){U.preventDefault();const V=U.key==="ArrowDown"?1:-1,Q=R[Math.min(Math.max(N+V,0),R.length-1)];Q&&_(Q.item.node);return}if(U.key==="ArrowRight"){U.preventDefault(),k.item.children.length&&!E.has(k.item.node.id)?I(k.item.node.id,!0):k.item.children[0]&&_(k.item.children[0].node);return}if(U.key==="ArrowLeft"){if(U.preventDefault(),E.has(k.item.node.id)&&k.item.children.length)I(k.item.node.id,!1);else if(k.parentId){const V=n.find(Q=>Q.id===k.parentId);V&&_(V)}return}U.preventDefault(),x(k.item.node.id)}}return M.length===0?g.jsx("p",{className:"empty",children:"No nodes loaded."}):g.jsx("div",{className:"preset-node-tree",role:"tree",tabIndex:0,onKeyDown:O,children:M.map(U=>g.jsx(Fy,{item:U,assignedNodeId:a,engines:e,inheritedParams:{},selectedNodeId:s,usedNodeIds:l,expandedNodeIds:E,editingNodeId:y,openMenuNodeId:P,onCreateChild:c,onCreateGroup:f,onDelete:p,onEdit:x,onMenuToggle:A=>L(N=>N===A?"":A),onMove:m,onRename:h,onSelect:_,onSet:S,onToggle:I,onUnset:v},U.node.id))})}function Fy({item:a,assignedNodeId:e,engines:n,inheritedParams:s,selectedNodeId:l,usedNodeIds:c,expandedNodeIds:f,editingNodeId:p,openMenuNodeId:m,onCreateChild:h,onCreateGroup:_,onDelete:S,onEdit:v,onMenuToggle:M,onMove:E,onRename:w,onSelect:y,onSet:x,onToggle:P,onUnset:L}){const R=f.has(a.node.id),I=m===a.node.id,O=a.node.id===l,U=a.node.id===e,A=c.has(a.node.id),N=ee.useMemo(()=>{function pe(J){return J.reduce((G,j)=>G+(c.has(j.node.id)?1:0)+pe(j.children),0)}return pe(a.children)},[a.children,c]),k=pm(s,a.node.params),V=a.node.kind==="preset_root"?"root":a.node.kind==="chapter"?"group":a.node.kind,Q=U?`${V} · assigned`:A?`${V} · used by slides`:N>0?`${V} · contains ${N} used preset${N===1?"":"s"}`:`${V} · unused`;async function fe(){M(a.node.id),window.confirm(`Delete preset "${a.node.name}"? This cannot be undone.`)&&await S(a.node)}return g.jsxs("div",{className:"tree-item",children:[g.jsxs("div",{className:`tree-node${O?" active":""}${U?" assigned":""}${A||N>0?" used":" unused"}`,children:[g.jsx("button",{"aria-label":a.children.length?`${R?"Collapse":"Expand"} ${a.node.name}`:`${a.node.name} has no children`,className:"tree-node-arrow",disabled:!a.children.length,type:"button",onClick:()=>P(a.node.id),children:a.children.length?R?"▾":"▸":"•"}),g.jsxs("button",{"aria-current":O?"true":void 0,className:"tree-node-main",role:"treeitem",type:"button",onClick:()=>y(a.node),children:[g.jsx("strong",{children:a.node.name}),g.jsx("small",{children:Q})]}),g.jsxs("div",{className:"tree-node-action-shell",children:[g.jsx("button",{"aria-expanded":I,"aria-haspopup":"menu","aria-label":`Actions for ${a.node.name}`,className:"icon-button tree-node-edit node-action-trigger",title:"Preset actions",type:"button",onClick:pe=>{pe.stopPropagation(),M(a.node.id)},children:"⋯"}),I?g.jsxs("div",{className:"tree-node-action-menu",role:"menu",children:[g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{M(a.node.id),v(a.node.id)},children:"Edit"}),g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{M(a.node.id),h(a.node)},children:"Create child preset"}),g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{M(a.node.id),_(a.node)},children:"Create child group"}),g.jsx("button",{disabled:a.siblingIndex===0,role:"menuitem",type:"button",onClick:()=>{M(a.node.id),E(a.node,-1)},children:"Move up"}),g.jsx("button",{disabled:a.siblingIndex>=a.siblingCount-1,role:"menuitem",type:"button",onClick:()=>{M(a.node.id),E(a.node,1)},children:"Move down"}),g.jsx("button",{className:"danger",role:"menuitem",type:"button",onClick:()=>{fe()},children:"Delete"})]}):null]})]}),p===a.node.id?g.jsx(g2,{engines:n,inheritedParams:s,node:a.node,resolvedParams:k,onClose:()=>v(""),onDelete:S,onRename:w,onSet:x,onUnset:L}):null,R&&a.children.length?g.jsx("div",{className:"tree-children",children:a.children.map(pe=>g.jsx(Fy,{assignedNodeId:e,engines:n,inheritedParams:k,item:pe,usedNodeIds:c,expandedNodeIds:f,editingNodeId:p,openMenuNodeId:m,onCreateChild:h,onCreateGroup:_,onDelete:S,onEdit:v,onMenuToggle:M,onMove:E,onRename:w,onSelect:y,onSet:x,onToggle:P,onUnset:L,selectedNodeId:l},pe.node.id))}):null]})}function zy(a,e=[]){if(!cr(a))return[];const n=[];for(const[s,l]of Object.entries(a)){const c=[...e,s];c.join(".")==="simulation.initialCondition"||!cr(l)?n.push({path:c,value:l}):n.push(...zy(l,c))}return n}function f2(a){const e=a.join(".");return e!=="simulation.initialCondition"&&e!=="simulation.engineId"&&e!=="simulation.neighborhoodId"&&!e.startsWith("caClass.")}function d2(a){return a==="rendererId"?["renderer","id"]:a==="ruleId"?["simulation","ruleId"]:a.startsWith("grid.")?["simulation",...a.split(".")]:a.includes(".")?a.split("."):["simulation",a]}function h2(a){return a?Object.keys(a.params_schema):[]}function p2(a,e){const n=a.join(".");return h2(e).some(s=>d2(s).join(".")===n)}function m2(a){const e=a.trim();if(e==="")return"";try{return JSON.parse(e)}catch{return a}}function wx(a){return typeof a=="string"?a:JSON.stringify(a,null,2)}function g2({engines:a,inheritedParams:e,node:n,resolvedParams:s,onClose:l,onDelete:c,onRename:f,onSet:p,onUnset:m}){const[h,_]=ee.useState(n.name),S=kh(s,["simulation","engineId"]),v=sr(s),M=typeof S=="string"?a.find(L=>L.engine_kind===S):void 0,w=(M?za(M,v):!1)?M:void 0,y=zy(s).filter(L=>f2(L.path)&&!p2(L.path,w));ee.useEffect(()=>{_(n.name)},[n.name]);async function x(){const L=h.trim();if(!L){_(n.name);return}L!==n.name&&await f(n,L)}async function P(){!window.confirm(`Delete preset "${n.name}"? This cannot be undone.`)||await c(n)===!1||l()}return g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:l,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal",role:"dialog",onMouseDown:L=>L.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preset Editor"}),g.jsx("h2",{children:"Edit preset"})]}),g.jsxs("span",{className:"win95-window-controls has-close",children:[g.jsx("span",{className:"window-control-decor",children:"_"}),g.jsx("span",{className:"window-control-decor",children:"□"}),g.jsx("button",{"aria-label":"Close",className:"window-control-button window-close-button",title:"Close",type:"button",onClick:l,children:"×"})]})]}),g.jsxs("div",{className:"property-modal-list",children:[g.jsxs("section",{className:"preset-modal-stage preset-modal-identity",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"i"}),g.jsxs("div",{children:[g.jsx("h3",{children:"Preset identity"}),g.jsx("p",{children:"Edit CA space, engine, and engine settings in the inspector."})]})]}),g.jsxs("label",{children:["Preset name",g.jsx("input",{autoFocus:!0,value:h,onChange:L=>_(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),x())}})]}),g.jsx("button",{disabled:!h.trim()||h.trim()===n.name,type:"button",onClick:()=>{x()},children:"Save name"})]}),y.map(L=>{const R=kh(n.params,L.path),I=kh(e,L.path),O=R!==void 0&&!r2(R,I);return g.jsx(_2,{inheritedValue:I,isLocal:O,node:n,path:L.path,value:L.value,onSet:p,onUnset:m},L.path.join("."))}),y.length===0?g.jsx("p",{className:"empty",children:"No properties are resolved for this node."}):null,g.jsxs("footer",{className:"preset-modal-danger",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Delete preset"}),g.jsx("small",{children:"Slides referencing this preset must be reassigned first."})]}),g.jsx("button",{className:"danger",type:"button",onClick:()=>{P()},children:"Delete"})]})]})]})})}function _2({inheritedValue:a,isLocal:e,node:n,path:s,value:l,onSet:c,onUnset:f}){const[p,m]=ee.useState(wx(l));return ee.useEffect(()=>{m(wx(l))},[l]),g.jsxs("div",{className:"property-row",children:[g.jsxs("div",{className:"property-row-meta",children:[g.jsx("strong",{children:s.join(".")}),g.jsx("span",{className:e?"local":"inherited",children:e?"local override":"inherited"}),!e&&a!==void 0?g.jsxs("small",{children:["from parent: ",o2(s,a)]}):null]}),g.jsx("textarea",{value:p,onChange:h=>m(h.target.value)}),g.jsxs("div",{className:"property-row-actions",children:[g.jsx("button",{type:"button",onClick:()=>c(n,s,m2(p)),children:"Save"}),g.jsx("button",{className:"danger",disabled:!e,type:"button",onClick:()=>f(n,s),children:"🗑"})]})]})}function v2({activeSceneId:a,canDeleteSlide:e,sceneCount:n,scenes:s,onBack:l,onDeleteSlide:c,onEditScene:f,onReorderSlides:p,onSaveNewSlide:m,onSelectScene:h}){const[_,S]=ee.useState(""),[v,M]=ee.useState(null);function E(y){return(typeof y.scene.params.caption=="string"?y.scene.params.caption:"").split(/\r?\n/,1)[0].trim()||"No caption"}function w(y,x){if(!_||_===y)return;const P=s.find(U=>U.scene.id===_);if(!P)return;const L=s.filter(U=>U.scene.id!==_),R=L.findIndex(U=>U.scene.id===y);if(R===-1)return;const I=x==="after"?R+1:R,O=[...L];O.splice(I,0,P),p(O)}return g.jsxs("aside",{className:"panel slide-panel",children:[g.jsx("div",{className:"drawer-navigation",children:g.jsx("button",{type:"button",onClick:l,children:"Back"})}),g.jsxs("div",{className:"scene-list-header",children:[g.jsx("p",{className:"eyebrow",children:"Slides"}),g.jsx("span",{children:n})]}),s.length?s.map(y=>g.jsxs("div",{className:`scene-item${y.scene.id===a?" active":""}${y.scene.id===_?" dragging":""}${v?.sceneId===y.scene.id?` drop-${v.position}`:""}`,draggable:!0,onDragEnd:()=>{S(""),M(null)},onDragOver:x=>{x.preventDefault();const P=x.currentTarget.getBoundingClientRect(),L=x.clientY>P.top+P.height/2?"after":"before";M({sceneId:y.scene.id,position:L})},onDragStart:x=>{S(y.scene.id),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",y.scene.id)},onDrop:x=>{x.preventDefault();const P=x.currentTarget.getBoundingClientRect(),L=x.clientY>P.top+P.height/2?"after":"before";w(y.scene.id,L),S(""),M(null)},children:[g.jsxs("button",{className:"scene-item-main",type:"button",onClick:()=>h(y),children:[g.jsx("span",{children:y.scene.order_index}),g.jsx("strong",{children:y.scene.title}),g.jsx("small",{className:"scene-caption-preview",children:E(y)})]}),g.jsx("button",{"aria-label":`Edit ${y.scene.title} metadata`,className:"scene-edit-button icon-button",type:"button",onClick:()=>f(y),children:"✎"})]},y.scene.id)):g.jsx("p",{className:"empty",children:"No slides yet. Choose a CA asset to create the first one."}),g.jsx("button",{className:"primary full-width",type:"button",onClick:m,children:"New slide"}),g.jsx("button",{className:"danger full-width",disabled:!e,type:"button",onClick:c,children:"Delete selected slide"})]})}const fa=24,Rx="ca-studio-skin",Hp="ca-studio-gallery-tab",Dx="ca-studio-engine-dimension",Nx="ca-studio-icg-dimension",x2="windows-95",Hy=[{id:"retro-crt",label:"Retro CRT"},{id:"clean-lab",label:"Clean Lab"},{id:"blueprint",label:"Blueprint"},{id:"paper",label:"Paper Archive"},{id:"noir",label:"Noir Terminal"},{id:"windows-95",label:"Windows 95"}],y2=["decks","cas","engines","icgs"],ar=1,rr=10,mm=5,S2=12,M2=64;function ur(){return Array.from({length:fa},()=>Array.from({length:fa},()=>!1))}function b2(){const a=ur(),e=10,n=10,s=[[1,0],[2,1],[0,2],[1,2],[2,2]];for(const[l,c]of s)a[n+c][e+l]=!0;return a}function co(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"untitled"}async function ft(a,e={}){const n=await fetch(a,{...e,headers:{"content-type":"application/json",...e.headers??{}}});if(!n.ok){const s=await n.text();throw new Error(E2(n,s))}return n.json()}function E2(a,e){const n=e.trim();if(!n)return`Request failed: ${a.status}`;const l=(/<pre>(.*?)<\/pre>/is.exec(n)?.[1]??n).replace(/<[^>]*>/g," ").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/\s+/g," ").trim();return l.startsWith("Cannot GET /api/ca/initial-condition-generators")?"Initial condition generator API is not available on this server. Restart the backend with the latest code.":l||`Request failed: ${a.status}`}function go(a){const e=a?.params?.studio;return!e||typeof e!="object"||Array.isArray(e)?{}:e}function T2(a,e){const n={...go(a)};for(const[s,l]of Object.entries(e))l===void 0?delete n[s]:n[s]=l;return{...a.params,studio:n}}function gm(a){const e=[];for(let n=0;n<a.length;n+=1)for(let s=0;s<(a[n]?.length??0);s+=1)a[n][s]&&e.push([s,n,0]);return e}function Pl(a){const e=ur();for(const n of a??[]){const[s,l]=n;Number.isInteger(s)&&Number.isInteger(l)&&s>=0&&l>=0&&s<fa&&l<fa&&(e[l][s]=!0)}return e}function Gy(a){return a.reduce((e,n)=>e+n.reduce((s,l)=>s+(l?1:0),0),0)}function Gp(a){return a?.dimensions===3}function Fu(a){return!Gp(a)}function A2(a){return[fa,a>=2?fa:1,a>=3?fa:1]}function C2(a){return a.dimensions===1?"elementary-1d":a.dimensions===3?"voxel-3d":"2d-canvas"}function w2(a){return a>=3?"3d":"2d"}function Ux(a,e,n){const s=In(a,{caClass:e,simulation:{neighborhoodId:e.neighborhoodId,grid:{size:A2(e.dimensions),boundary:"wrap",wrap:!0}},renderer:{id:n||C2(e)},camera:{mode:w2(e.dimensions)}});return e.dimensions===3&&s.simulation?.initialCondition?.cells?.length===0&&(s.simulation.initialCondition={type:"cells",cells:[]}),s}function Vy(a){if(!(a instanceof HTMLElement))return!1;const e=a.tagName.toLowerCase();return a.isContentEditable||e==="input"||e==="select"||e==="textarea"}function ky(a){return y2.includes(a)}function R2(){const a=window.sessionStorage.getItem(Hp);return ky(a)?a:"decks"}function Mo(a){return`/admin?tab=${a}`}function D2(a){return a?.startsWith("/admin/edit/")||a===Mo("engines")?a:void 0}function Lx(){const a=/^\/view\/decks\/([^/]+)/.exec(window.location.pathname);if(a)return{view:"viewer",deckId:a[1]};const e=/^\/admin\/edit\/([^/]+)/.exec(window.location.pathname);if(e){const f=new URLSearchParams(window.location.search);return{view:"edit",deckId:e[1],sceneId:f.get("scene")??void 0}}const n=/^\/admin\/libraries\/([^/]+)/.exec(window.location.pathname);if(n){const f=new URLSearchParams(window.location.search);return{view:"library",treeId:n[1],nodeId:f.get("node")??void 0,returnTo:D2(f.get("return"))}}if(/^\/admin\/icgs\/([^/]+)/.exec(window.location.pathname))return{view:"gallery",tab:"icgs"};const l=/^\/admin\/engines\/([^/]+)/.exec(window.location.pathname);if(l)return{view:"engine",engineId:l[1]};const c=new URLSearchParams(window.location.search).get("tab");return{view:"gallery",tab:ky(c)?c:R2()}}function Ui(a){window.history.pushState({},"",a),window.dispatchEvent(new PopStateEvent("popstate"))}function N2(){return{name:"Random soup",description:"Seed live cells randomly across the current voxel grid.",generatorKind:"random-soup",dimensions:2,states:2,density:.28,seed:"studio-seed"}}function jy(){return{name:"Conway Life",description:"Classic binary cellular automaton evolution rule.",engineKind:"game-of-life-2d",dimensions:2,states:2,ruleId:"B3/S23",rendererId:"2d-canvas",license:"internal",owner:"Glitch University",ipNotice:"Internal CA engine registry entry."}}function Xy(a){return{density:{type:"range",label:"Density",default:a.density,min:0,max:1,step:.01},seed:{type:"string",label:"Seed",default:a.seed}}}function Wy(a){return{density:a.density,seed:a.seed}}function qy(a){return/^B[0-8]*\/S[0-8]*$/i.test(a)?a.toUpperCase():/^rule[-_\s]*\d{1,3}$/i.test(a)?a.replace(/^rule[-_\s]*/i,"Rule "):a==="wildfire-binary"?"Binary wildfire":a==="life-3d"?"3D Life":a==="generations-3d"?"3D Generations":a==="lattice-gas-3d"?"3D Lattice gas":a==="snake-3d"?"3D Snake":a==="naga-3d"?"3D Naga":a}function U2(a){return a===1?[{value:"elementary-1d",label:"Elementary 1D"}]:a===3?[{value:"voxel-3d",label:"Voxel 3D"}]:[{value:"2d-canvas",label:"2D Canvas"},{value:"wildfire-2d",label:"Wildfire 2D"}]}function _m(a){const e=U2(a.dimensions);return{ruleId:{type:"select",label:"Rule",default:a.ruleId,options:[{value:a.ruleId,label:qy(a.ruleId)}]},rendererId:{type:"select",label:"Renderer",default:a.rendererId,options:e}}}function vm(a){return{ruleId:a.ruleId,rendererId:a.rendererId}}function L2(a){const e=a.dimensions>=3?fa:1;return{caClass:{neighborhoodId:a.neighborhoodId,dimensions:a.dimensions,states:a.states},simulation:{engineId:a.dimensions===2&&a.states===2?"game-of-life-2d":"generic-voxel-ca",ruleId:a.ruleId,neighborhoodId:a.neighborhoodId,grid:{size:[fa,fa,e],boundary:"wrap",wrap:!0}},renderer:{id:a.rendererId},camera:{mode:a.dimensions===2?"2d":"3d"}}}function _o(a,e,n,s,l,c="wrap",f=!0){return{simulation:{...l?{engineId:l}:{},ruleId:a,neighborhoodId:e,grid:{boundary:c,wrap:c==="wrap"},...f?{initialCondition:{type:"cells",cells:gm(s)}}:{}},renderer:{id:n}}}function Ds(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function O2(a,e){return JSON.stringify(a)===JSON.stringify(e)}function Yy(a,e){let n=a;for(const s of e){if(!Ds(n)||!(s in n))return;n=n[s]}return n}function xm(a){return a==="rendererId"?["renderer","id"]:a==="ruleId"?["simulation","ruleId"]:a==="edgeWrap"?["simulation","grid","wrap"]:a.startsWith("grid.")?["simulation",...a.split(".")]:a.includes(".")?a.split("."):["simulation",a]}function P2(a,e,n,s){if(n==="edgeWrap")return qp(a)==="wrap";const l=xm(n);return Yy(a,l)??Vp(n,s,e)}function Ox(a,e){return typeof a=="number"&&Number.isFinite(a)?a:e}function Px(a){return typeof a=="number"&&Number.isFinite(a)?a:void 0}function I2(a,e){return typeof e.label=="string"?e.label:a}function Vp(a,e,n){const s=n.default_params[a];return s!==void 0?s:e.default}function In(a,e){const n={...a};for(const[s,l]of Object.entries(e)){const c=n[s];n[s]=Ds(c)&&Ds(l)?In(c,l):l}return n}function B2(a){return typeof a?.scene.params.caption=="string"?a.scene.params.caption:""}function F2(a){return a?.scene.params.autoplayOnSlideChange===!0}function Ix(a,e){return Fu(sr(a))?In(a,{simulation:{initialCondition:{type:"cells",cells:gm(e)}}}):a}function kp(a,e,n=[]){const s={};for(const[l,c]of Object.entries(a)){const f=[...n,l];if(Ds(c)&&f.join(".")!=="simulation.initialCondition"){const p=kp(c,e,f);Object.keys(p).length>0&&(s[l]=p);continue}O2(c,Yy(e,f))||(s[l]=c)}return s}function Cl(a,e){if(!e.parent_id)return{};const n=new Map(a.map(c=>[c.id,c])),s=[];let l=n.get(e.parent_id);for(;l;)s.unshift(l),l=l.parent_id?n.get(l.parent_id):void 0;return s.reduce((c,f)=>In(c,f.params),{})}function z2(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)||a.slug.localeCompare(e.slug)}function jp(a,e){return a.filter(n=>n.parent_id===e).sort(z2)}function Bx(a,e){const n=jp(a,e);return n.length===0?0:Math.max(...n.map(s=>s.sort_order))+1}function Zy(a,e){if(e.length===0)return a;const[n,...s]=e,l={...a};if(s.length===0)return delete l[n],l;const c=l[n];if(!Ds(c))return l;const f=Zy(c,s);return Object.keys(f).length===0?delete l[n]:l[n]=f,l}function Ni(a,e,n){if(e.length===0)return a;const[s,...l]=e,c={...a};if(l.length===0)return c[s]=n,c;const f=c[s];return c[s]=Ni(Ds(f)?f:{},l,n),c}function H2(){const[a,e]=ee.useState(Lx),[n,s]=ee.useState(()=>{const c=window.localStorage.getItem(Rx);return Hy.some(f=>f.id===c)?c:x2});ee.useEffect(()=>{const c=()=>e(Lx());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]),ee.useEffect(()=>{document.documentElement.dataset.skin=n,window.localStorage.setItem(Rx,n)},[n]);const l=a.view==="viewer"?g.jsx(J2,{deckId:a.deckId}):a.view==="edit"?g.jsx(e3,{deckId:a.deckId,initialSceneId:a.sceneId}):a.view==="library"?g.jsx(K2,{initialNodeId:a.nodeId,returnTo:a.returnTo,treeId:a.treeId}):a.view==="engine"?g.jsx(Z2,{engineId:a.engineId}):g.jsx(k2,{initialTab:a.tab});return a.view==="viewer"?l:g.jsxs("div",{className:"admin-app",children:[g.jsx("div",{className:"admin-app-content",children:l}),g.jsx(G2,{skin:n,onSkinChange:s})]})}function G2({skin:a,onSkinChange:e}){const[n,s]=ee.useState(()=>Fx(new Date));return ee.useEffect(()=>{const l=window.setInterval(()=>s(Fx(new Date)),3e4);return()=>window.clearInterval(l)},[]),g.jsxs("footer",{className:"app-footer",children:[g.jsx("div",{className:"footer-start","aria-hidden":"true",children:"Start"}),g.jsx("p",{children:"CA Lab is developed by Glitch University."}),g.jsxs("label",{className:"skin-picker",children:[g.jsx("span",{children:"Skin"}),g.jsx("select",{value:a,onChange:l=>e(l.target.value),children:Hy.map(l=>g.jsx("option",{value:l.id,children:l.label},l.id))})]}),g.jsx("div",{className:"footer-clock","aria-label":`Current time ${n}`,children:n})]})}function Fx(a){return a.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function Ki({closeLabel:a="Close",disabled:e=!1,onClose:n}){return g.jsxs("span",{className:`win95-window-controls${n?" has-close":""}`,"aria-hidden":n?void 0:"true",children:[g.jsx("span",{className:"window-control-decor",children:"_"}),g.jsx("span",{className:"window-control-decor",children:"□"}),n?g.jsx("button",{"aria-label":a,className:"window-control-button window-close-button",disabled:e,title:a,type:"button",onClick:n,children:"×"}):g.jsx("span",{className:"window-control-decor window-close-button",children:"×"})]})}function Ky(a){const e=Math.max(ar,Math.min(rr,a));if(e>=rr)return 0;const n=720,s=60,l=(e-ar)/(rr-ar-1);return Math.round(n-(n-s)*l)}function $y(a){return a>=rr}function V2(a){return $y(a)?"MAX":Math.round(1e3/Ky(a)*10)/10}function ym(a,e){if(!$y(a)){const c=window.setInterval(e,Ky(a));return()=>window.clearInterval(c)}let n=!1,s=0;function l(){const c=performance.now();let f=0;for(;!n&&f<M2&&performance.now()-c<S2;)e(),f+=1;n||(s=window.requestAnimationFrame(l))}return s=window.requestAnimationFrame(l),()=>{n=!0,window.cancelAnimationFrame(s)}}function Qy({className:a="",speedLevel:e,onChange:n}){const s=Math.max(ar,Math.min(rr,e)),c=-132+(s-ar)/(rr-ar)*264,f=V2(s);return g.jsxs("label",{className:`studio-speed-knob ${a}`,style:{"--speed-knob-angle":`${c}deg`},title:f==="MAX"?"Simulation speed: maximum":`Simulation speed: ${f} steps/s`,children:[g.jsx("span",{className:"speed-knob-label",children:"Speed"}),g.jsx("span",{className:"speed-knob-face","aria-hidden":"true",children:g.jsx("span",{className:"speed-knob-marker"})}),g.jsx("input",{"aria-label":"Simulation speed",max:rr,min:ar,step:1,type:"range",value:s,onChange:p=>n(Number(p.target.value))}),g.jsx("span",{className:"speed-knob-readout",children:f==="MAX"?f:`${f}x`})]})}function k2({initialTab:a}){const[e,n]=ee.useState(a),[s,l]=ee.useState(()=>{const K=Number(window.sessionStorage.getItem(Dx));return K===1||K===2||K===3?K:2}),[c,f]=ee.useState(()=>{const K=Number(window.sessionStorage.getItem(Nx));return K===1||K===2||K===3?K:2}),[p,m]=ee.useState(!1),[h,_]=ee.useState([]),[S,v]=ee.useState([]),[M,E]=ee.useState([]),[w,y]=ee.useState(null),[x,P]=ee.useState(null),[L,R]=ee.useState(()=>new Set),[I,O]=ee.useState({}),[U,A]=ee.useState(()=>new Set),[N,k]=ee.useState([]),[V,Q]=ee.useState("Game of Life: Glider Deck"),[fe,pe]=ee.useState("Game of Life Presets"),[J,G]=ee.useState(()=>N2()),[j,se]=ee.useState(()=>jy()),[Se,xe]=ee.useState("Ready"),z=ee.useMemo(()=>({1:M.filter(K=>K.supported_classes.some(F=>F.dimensions===1)),2:M.filter(K=>K.supported_classes.some(F=>F.dimensions===2)),3:M.filter(K=>K.supported_classes.some(F=>F.dimensions===3))}),[M]),te=z[s],Ee=ee.useMemo(()=>({1:S.filter(K=>K.supported_classes.some(F=>F.dimensions===1)),2:S.filter(K=>K.supported_classes.some(F=>F.dimensions===2)),3:S.filter(K=>K.supported_classes.some(F=>F.dimensions===3))}),[S]),Oe=Ee[c],He=ee.useCallback(async()=>{_(await ft("/api/ca/decks"))},[]),le=ee.useCallback(async()=>{v(await ft("/api/ca/initial-condition-generators"))},[]),Me=ee.useCallback(async()=>{E(await ft("/api/ca/engines"))},[]),Ae=ee.useCallback(async()=>{k(await ft("/api/ca/preset-trees"))},[]);ee.useEffect(()=>{async function K(){try{await Promise.all([He(),Ae(),Me()])}catch(F){xe(F instanceof Error?F.message:"Load failed");return}try{await le()}catch(F){v([]),xe(F instanceof Error?F.message:"ICG list unavailable")}}K()},[He,Me,le,Ae]),ee.useEffect(()=>{n(a),window.sessionStorage.setItem(Hp,a)},[a]);function je(K){n(K),m(!1),window.sessionStorage.setItem(Hp,K),window.history.replaceState({},"",Mo(K))}function rt(K){l(K),window.sessionStorage.setItem(Dx,String(K))}function $e(){const K=s===1?"elementary-1d":s===3?"voxel-3d":"2d-canvas";se(F=>({...F,dimensions:s,rendererId:K})),m(!0)}async function Pt(K){if(L.has(K.id)){R(F=>{const Ue=new Set(F);return Ue.delete(K.id),Ue});return}if(R(F=>new Set(F).add(K.id)),!I[K.id]){A(F=>new Set(F).add(K.id));try{const F=await ft(`/api/ca/engines/${K.id}/usage`);O(Ue=>({...Ue,[K.id]:F}))}catch(F){xe(F instanceof Error?F.message:"Engine usage could not be loaded"),R(Ue=>{const _t=new Set(Ue);return _t.delete(K.id),_t})}finally{A(F=>{const Ue=new Set(F);return Ue.delete(K.id),Ue})}}}function gt(K){const F=new URLSearchParams({node:K.node_id,return:Mo("engines")});Ui(`/admin/libraries/${K.tree_id}?${F.toString()}`)}function dt(K){f(K),window.sessionStorage.setItem(Nx,String(K))}function yt(){G(K=>({...K,dimensions:c})),m(!0)}async function ht(){try{xe("Creating deck...");const K=Date.now(),F=await ft("/api/ca/decks",{method:"POST",body:JSON.stringify({slug:`${co(V)}-${K}`,title:V.trim()||"Untitled deck",params:{studio:{}}})});m(!1),Ui(`/admin/edit/${F.id}`)}catch(K){xe(K instanceof Error?K.message:"Deck create failed")}}async function It(){try{xe(`Creating node tree "${fe}"...`);const K=Date.now(),F=await ft("/api/ca/preset-trees",{method:"POST",body:JSON.stringify({slug:`${co(fe)}-${K}`,name:fe.trim()||"Untitled node tree",description:"Admin-authored CA preset tree"})});k(Ue=>[F,...Ue]),m(!1),xe(`Created node tree "${F.name}"`)}catch(K){xe(K instanceof Error?K.message:"Node tree create failed")}}async function zt(K){const F=`${K.node_count} ${K.node_count===1?"node":"nodes"}`;if(window.confirm(`Delete "${K.name}" and its ${F}? This cannot be undone.`))try{xe(`Deleting CA library "${K.name}"...`);const Ue=await fetch(`/api/ca/preset-trees/${K.id}`,{method:"DELETE"});if(!Ue.ok){const _t=await Ue.json().catch(()=>null);throw new Error(_t?.error?`Could not delete "${K.name}": ${_t.error}`:`Could not delete "${K.name}". It may still be referenced by a slide.`)}k(_t=>_t.filter(B=>B.id!==K.id)),xe(`Deleted CA library "${K.name}"`)}catch(Ue){xe(Ue instanceof Error?Ue.message:"CA library delete failed")}}async function qt(K){try{const Ue=go(K).presetTreeId,_t=Ue?h.filter(he=>he.id!==K.id&&go(he).presetTreeId===Ue):[],B=!!(Ue&&_t.length===0),C=B?`Delete "${K.title}"? It is the only deck using its preset tree, so the tree can be removed as well.`:`Delete "${K.title}"?`;if(!window.confirm(C))return;if(xe(`Deleting "${K.title}"...`),!(await fetch(`/api/ca/decks/${K.id}`,{method:"DELETE"})).ok)throw new Error("Unable to delete deck");_(he=>he.filter(Ne=>Ne.id!==K.id));let oe="";if(B&&Ue&&window.confirm("Remove the now-unused preset tree too?"))try{(await fetch(`/api/ca/preset-trees/${Ue}`,{method:"DELETE"})).ok||(oe="Deck deleted, but the preset tree could not be removed.")}catch{oe="Deck deleted, but the preset tree could not be removed."}await He(),xe(oe||`Deleted "${K.title}"`)}catch(F){xe(F instanceof Error?F.message:"Deck delete failed")}}async function rn(){try{xe(`Creating ICG "${J.name}"...`);const K=Date.now(),F=await ft("/api/ca/initial-condition-generators",{method:"POST",body:JSON.stringify({slug:`${co(J.name)}-${K}`,name:J.name,description:J.description.trim()||null,generatorKind:J.generatorKind,supportedClasses:[{dimensions:J.dimensions,states:J.states}],paramsSchema:Xy(J),defaultParams:Wy(J)})});v(Ue=>[F,...Ue]),m(!1),xe(`Created ICG "${F.name}"`)}catch(K){xe(K instanceof Error?K.message:"ICG create failed")}}async function ct(){try{xe(`Creating engine "${j.name}"...`);const K=Date.now(),F=await ft("/api/ca/engines",{method:"POST",body:JSON.stringify({slug:`${co(j.name)}-${K}`,name:j.name.trim()||"Untitled CA engine",description:j.description.trim()||null,engineKind:j.engineKind,license:j.license.trim()||null,owner:j.owner.trim()||null,ipNotice:j.ipNotice.trim()||null,supportedClasses:[{dimensions:j.dimensions,states:j.states}],paramsSchema:_m(j),defaultParams:vm(j)})});E(Ue=>[F,...Ue]),m(!1),xe(`Created engine "${F.name}"`)}catch(K){xe(K instanceof Error?K.message:"Engine create failed")}}return g.jsxs("main",{className:"shell",children:[g.jsxs("header",{className:"gallery-hero panel",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Studio Admin"}),g.jsx("h1",{children:"CA Studio"}),g.jsx("p",{children:"Explore the wonderful and strange world of cellular automata."})]}),g.jsx("div",{className:"status",children:Se}),g.jsx(Ki,{})]}),g.jsxs("nav",{"aria-label":"Gallery sections",className:"gallery-tabs",children:[g.jsx("button",{className:e==="decks"?"active":"",type:"button",onClick:()=>je("decks"),children:"Decks"}),g.jsx("button",{className:e==="cas"?"active":"",type:"button",onClick:()=>je("cas"),children:"CAs"}),g.jsx("button",{className:e==="engines"?"active":"",type:"button",onClick:()=>je("engines"),children:"CA Engines"}),g.jsx("button",{className:e==="icgs"?"active":"",type:"button",onClick:()=>je("icgs"),children:"ICGs"})]}),g.jsxs("section",{className:"panel gallery-tab-panel",children:[e==="decks"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Decks"}),g.jsx("h2",{children:"Presentations"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:h.length}),g.jsx("button",{className:"primary",type:"button",onClick:()=>m(!0),children:"New deck"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"A deck is a narrated sequence of slides. Slides can reference CA presets from a library, then add caption, playback, and recording context."}),g.jsxs("div",{className:"gallery-list",children:[h.map(K=>g.jsxs("article",{"aria-label":`Open ${K.title}`,className:"deck-card gallery-entity-card deck-entity-card panel",role:"link",tabIndex:0,onClick:()=>Ui(`/admin/edit/${K.id}`),onKeyDown:F=>{F.target===F.currentTarget&&(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),Ui(`/admin/edit/${K.id}`))},children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:K.slug}),g.jsx("strong",{children:K.title}),g.jsx("small",{children:go(K).presetTreeId?"tree selected":"choose a node tree in editor"}),g.jsxs("div",{className:"gallery-card-controls",children:[g.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),Ui(`/view/decks/${K.id}`)},children:"View"}),g.jsx("button",{"aria-label":`Delete ${K.title}`,className:"danger deck-trash-button",type:"button",onClick:F=>{F.stopPropagation(),qt(K)},children:"🗑"})]})]},K.id)),h.length===0?g.jsx("p",{className:"empty",children:"No decks yet."}):null]})]}):null,e==="cas"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CAs"}),g.jsx("h2",{children:"Preset libraries"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:N.length}),g.jsx("button",{className:"primary",type:"button",onClick:()=>m(!0),children:"New CA"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"A CA preset library is a tree of reusable simulation states. Child presets inherit renderer, rule, neighbourhood, camera, and initial-condition settings from their parents."}),g.jsxs("div",{className:"gallery-list",children:[N.map(K=>g.jsxs("article",{"aria-label":`Open ${K.name}`,className:`deck-card gallery-entity-card library-card panel${K.node_count===0?" empty-library":""}`,role:"link",tabIndex:0,onClick:()=>Ui(`/admin/libraries/${K.id}`),onKeyDown:F=>{F.target===F.currentTarget&&(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),Ui(`/admin/libraries/${K.id}`))},children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:K.slug}),g.jsx("strong",{children:K.name}),g.jsx("small",{children:K.node_count===0?"Empty library":`${K.node_count} ${K.node_count===1?"node":"nodes"}`}),g.jsx("div",{className:"gallery-card-controls gallery-card-controls-end",children:g.jsx("button",{"aria-label":`Delete ${K.name}`,className:"danger deck-trash-button",title:`Delete ${K.name}`,type:"button",onClick:F=>{F.stopPropagation(),zt(K)},children:"🗑"})})]},K.id)),N.length===0?g.jsx("p",{className:"empty",children:"No CA libraries yet."}):null]})]}):null,e==="engines"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Engines"}),g.jsx("h2",{children:"Evolution functions"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:te.length}),g.jsx("button",{className:"primary",type:"button",onClick:$e,children:"New engine"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"A CA engine is an evolution function. Presets select compatible engines by dimensions and state count; licence and ownership metadata travel with the registry entry."}),g.jsx("nav",{"aria-label":"Engine dimensions",className:"dimension-tabs",children:[1,2,3].map(K=>g.jsxs("button",{"aria-selected":s===K,className:s===K?"active":"",role:"tab",type:"button",onClick:()=>rt(K),children:[K,"D",g.jsx("span",{children:z[K].length})]},K))}),g.jsxs("div",{className:"gallery-list",children:[te.map(K=>g.jsxs("article",{className:"deck-card engine-gallery-card engine-entity-card panel",children:[g.jsxs("button",{"aria-label":`Edit ${K.name}`,className:"engine-card-main",type:"button",onClick:()=>P(K),children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:K.engine_kind}),g.jsx("strong",{children:K.name}),g.jsx("small",{children:zx(K.supported_classes)}),K.license?g.jsxs("small",{children:["License: ",K.license]}):null,K.owner?g.jsxs("small",{children:["Owner: ",K.owner]}):null]}),g.jsxs("button",{"aria-expanded":L.has(K.id),className:"engine-usage-toggle",type:"button",onClick:()=>{Pt(K)},children:[g.jsx("span",{children:L.has(K.id)?"▾":"▸"}),"Preset usage",I[K.id]?g.jsx("small",{children:I[K.id].length}):null]}),L.has(K.id)?g.jsxs("div",{className:"engine-usage-list",children:[U.has(K.id)?g.jsx("p",{className:"empty",children:"Loading presets..."}):null,!U.has(K.id)&&(I[K.id]?.length??0)===0?g.jsx("p",{className:"empty",children:"No presets currently use this engine."}):null,I[K.id]?.map(F=>g.jsxs("button",{type:"button",onClick:()=>gt(F),children:[g.jsx("span",{children:F.tree_name}),g.jsx("strong",{children:F.node_name}),g.jsx("small",{children:F.node_kind==="preset_root"?"root":F.node_kind})]},`${F.tree_id}:${F.node_id}`))]}):null]},K.id)),te.length===0?g.jsxs("p",{className:"empty",children:["No ",s,"D CA engines yet."]}):null]})]}):null,e==="icgs"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"ICGs"}),g.jsx("h2",{children:"Initial condition generators"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:Oe.length}),g.jsx("button",{className:"primary",type:"button",onClick:yt,children:"New ICG"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"An ICG is a deterministic tool that creates initial cell states for compatible CA classes. Running one writes concrete cells into a preset."}),g.jsx("nav",{"aria-label":"ICG dimensions",className:"dimension-tabs",children:[1,2,3].map(K=>g.jsxs("button",{"aria-selected":c===K,className:c===K?"active":"",role:"tab",type:"button",onClick:()=>dt(K),children:[K,"D",g.jsx("span",{children:Ee[K].length})]},K))}),g.jsxs("div",{className:"gallery-list",children:[Oe.map(K=>g.jsxs("article",{"aria-label":`Edit ${K.name}`,className:"deck-card gallery-entity-card icg-entity-card panel",role:"button",tabIndex:0,onClick:()=>y(K),onKeyDown:F=>{F.target===F.currentTarget&&(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),y(K))},children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:K.generator_kind}),g.jsx("strong",{children:K.name}),g.jsx("small",{children:zx(K.supported_classes)}),K.description?g.jsx("small",{children:K.description}):null]},K.id)),Oe.length===0?g.jsxs("p",{className:"empty",children:["No ",c,"D generators yet."]}):null]})]}):null]}),g.jsxs("div",{className:"win95-statusbar","aria-hidden":"true",children:[g.jsxs("span",{children:["Objects: ",e==="decks"?h.length:e==="cas"?N.length:e==="engines"?te.length:Oe.length]}),g.jsxs("span",{children:["Status: ",Se]}),g.jsx("span",{children:"CA Lab Studio"})]}),p?g.jsx(j2,{activeTab:e,deckName:V,engineConfig:j,icgConfig:J,treeName:fe,onClose:()=>m(!1),onCreateDeck:()=>{ht()},onCreateEngine:()=>{ct()},onCreateIcg:()=>{rn()},onCreateTree:()=>{It()},onDeckNameChange:Q,onEngineConfigChange:se,onIcgConfigChange:G,onTreeNameChange:pe}):null,x?g.jsx(X2,{engine:x,onClose:()=>P(null),onSaved:K=>{E(F=>F.map(Ue=>Ue.id===K.id?K:Ue)),P(null),xe(`Saved engine "${K.name}"`)}}):null,w?g.jsx(Y2,{generator:w,onClose:()=>y(null),onSaved:K=>{v(F=>F.map(Ue=>Ue.id===K.id?K:Ue)),y(null),xe(`Saved ICG "${K.name}"`)}}):null]})}function j2({activeTab:a,deckName:e,engineConfig:n,icgConfig:s,treeName:l,onClose:c,onCreateDeck:f,onCreateEngine:p,onCreateIcg:m,onCreateTree:h,onDeckNameChange:_,onEngineConfigChange:S,onIcgConfigChange:v,onTreeNameChange:M}){const E={decks:"deck",cas:"CA library",engines:"CA engine",icgs:"initial condition generator"},w={decks:f,cas:h,engines:p,icgs:m}[a];return ee.useEffect(()=>{function y(x){x.key==="Escape"&&c()}return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]),g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:c,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal gallery-create-modal",role:"dialog",onMouseDown:y=>y.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Create"}),g.jsxs("h2",{children:["New ",E[a]]})]}),g.jsx("div",{className:"window-action-cluster",children:g.jsx(Ki,{onClose:c})})]}),g.jsxs("div",{className:"gallery-create-body",children:[a==="decks"?g.jsxs("label",{children:["Deck name",g.jsx("input",{autoFocus:!0,value:e,onChange:y=>_(y.target.value)})]}):null,a==="cas"?g.jsxs("label",{children:["Library name",g.jsx("input",{autoFocus:!0,value:l,onChange:y=>M(y.target.value)})]}):null,a==="engines"?g.jsx(Sm,{config:n,onChange:S}):null,a==="icgs"?g.jsx(Jy,{config:s,onChange:v}):null,g.jsxs("div",{className:"gallery-create-actions",children:[g.jsx("button",{type:"button",onClick:c,children:"Cancel"}),g.jsxs("button",{className:"primary",type:"button",onClick:w,children:["Create ",E[a]]})]})]})]})})}function zx(a){return a.map(e=>`${e.dimensions}D · ${e.states} states`).join(", ")}function Jy({config:a,onChange:e}){return g.jsxs("div",{className:"root-config-fields",children:[g.jsx("p",{className:"eyebrow",children:"Initial Condition Generator"}),g.jsxs("label",{children:["Generator name",g.jsx("input",{value:a.name,onChange:n=>e(s=>({...s,name:n.target.value}))})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{value:a.description,onChange:n=>e(s=>({...s,description:n.target.value}))})]}),g.jsxs("div",{className:"root-config-grid",children:[g.jsxs("label",{children:["Dimensions",g.jsxs("select",{value:a.dimensions,onChange:n=>e(s=>({...s,dimensions:Number(n.target.value)})),children:[g.jsx("option",{value:1,children:"1D"}),g.jsx("option",{value:2,children:"2D"}),g.jsx("option",{value:3,children:"3D"})]})]}),g.jsxs("label",{children:["States",g.jsx("input",{min:2,step:1,type:"number",value:a.states,onChange:n=>e(s=>({...s,states:Math.max(2,Number(n.target.value)||2)}))})]}),g.jsxs("label",{children:["Density",g.jsx("input",{max:1,min:0,step:.01,type:"number",value:a.density,onChange:n=>e(s=>({...s,density:Math.max(0,Math.min(1,Number(n.target.value)||0))}))})]})]}),g.jsxs("label",{children:["Seed",g.jsx("input",{value:a.seed,onChange:n=>e(s=>({...s,seed:n.target.value}))})]})]})}function Sm({config:a,onChange:e}){return g.jsxs("div",{className:"root-config-fields",children:[g.jsx("p",{className:"eyebrow",children:"CA Engine"}),g.jsxs("label",{children:["Engine name",g.jsx("input",{value:a.name,onChange:n=>e(s=>({...s,name:n.target.value}))})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{value:a.description,onChange:n=>e(s=>({...s,description:n.target.value}))})]}),g.jsxs("div",{className:"root-config-grid",children:[g.jsxs("label",{children:["Engine kind",g.jsx("input",{value:a.engineKind,onChange:n=>e(s=>({...s,engineKind:n.target.value}))})]}),g.jsxs("label",{children:["Rule id",g.jsx("input",{value:a.ruleId,onChange:n=>e(s=>({...s,ruleId:n.target.value}))})]}),g.jsxs("label",{children:["Renderer",g.jsxs("select",{value:a.rendererId,onChange:n=>e(s=>({...s,rendererId:n.target.value})),children:[g.jsx("option",{value:"2d-canvas",children:"2D Canvas"}),g.jsx("option",{value:"elementary-1d",children:"Elementary 1D"}),g.jsx("option",{value:"wildfire-2d",children:"Wildfire 2D"}),g.jsx("option",{value:"voxel-3d",children:"Voxel 3D"})]})]}),g.jsxs("label",{children:["Dimensions",g.jsxs("select",{value:a.dimensions,onChange:n=>e(s=>({...s,dimensions:Number(n.target.value)})),children:[g.jsx("option",{value:1,children:"1D"}),g.jsx("option",{value:2,children:"2D"}),g.jsx("option",{value:3,children:"3D"})]})]}),g.jsxs("label",{children:["States",g.jsx("input",{min:2,step:1,type:"number",value:a.states,onChange:n=>e(s=>({...s,states:Math.max(2,Number(n.target.value)||2)}))})]}),g.jsxs("label",{children:["License",g.jsx("input",{value:a.license,onChange:n=>e(s=>({...s,license:n.target.value}))})]}),g.jsxs("label",{children:["Owner",g.jsx("input",{value:a.owner,onChange:n=>e(s=>({...s,owner:n.target.value}))})]})]}),g.jsxs("label",{children:["IP notice",g.jsx("textarea",{value:a.ipNotice,onChange:n=>e(s=>({...s,ipNotice:n.target.value}))})]})]})}function X2({engine:a,onClose:e,onSaved:n}){const[s,l]=ee.useState(()=>Xp(a)),[c,f]=ee.useState(!1),[p,m]=ee.useState("");ee.useEffect(()=>{function _(S){S.key==="Escape"&&!c&&e()}return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e,c]);async function h(){try{f(!0),m("");const _=await ft(`/api/ca/engines/${a.id}`,{method:"PATCH",body:JSON.stringify({name:s.name.trim()||"Untitled CA engine",description:s.description.trim()||null,engineKind:s.engineKind,license:s.license.trim()||null,owner:s.owner.trim()||null,ipNotice:s.ipNotice.trim()||null,supportedClasses:[{dimensions:s.dimensions,states:s.states}],paramsSchema:_m(s),defaultParams:vm(s)})});n(_)}catch(_){m(_ instanceof Error?_.message:"Engine save failed")}finally{f(!1)}}return g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:()=>{c||e()},children:g.jsxs("section",{"aria-modal":"true",className:"property-modal gallery-create-modal",role:"dialog",onMouseDown:_=>_.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Engine"}),g.jsxs("h2",{children:["Edit ",a.name]})]}),g.jsx("div",{className:"window-action-cluster",children:g.jsx(Ki,{disabled:c,onClose:e})})]}),g.jsxs("div",{className:"gallery-create-body",children:[g.jsx(Sm,{config:s,onChange:l}),p?g.jsx("p",{className:"compatibility-warning",role:"alert",children:p}):null,g.jsxs("div",{className:"gallery-create-actions",children:[g.jsx("button",{disabled:c,type:"button",onClick:e,children:"Cancel"}),g.jsx("button",{className:"primary",disabled:c,type:"button",onClick:()=>{h()},children:c?"Saving...":"Save engine"})]})]})]})})}function Hx(a){const e=a.supported_classes[0];return{name:a.name,description:a.description??"",generatorKind:a.generator_kind,dimensions:e?.dimensions??2,states:typeof e?.states=="number"?e.states:2,density:typeof a.default_params.density=="number"?a.default_params.density:.28,seed:typeof a.default_params.seed=="string"?a.default_params.seed:"studio-seed"}}function Xp(a){const e=a.supported_classes[0];return{name:a.name,description:a.description??"",engineKind:a.engine_kind,dimensions:e?.dimensions??2,states:typeof e?.states=="number"?e.states:2,ruleId:typeof a.default_params.ruleId=="string"?a.default_params.ruleId:"B3/S23",rendererId:typeof a.default_params.rendererId=="string"?a.default_params.rendererId:"2d-canvas",license:a.license??"",owner:a.owner??"",ipNotice:a.ip_notice??""}}function W2({disabled:a,engine:e,settings:n,onSet:s}){const l=e?Object.entries(e.params_schema).filter(f=>Ds(f[1])):[];if(!e)return g.jsx("p",{className:"param-empty",children:"Select a compatible engine to edit engine settings."});if(l.length===0)return g.jsx("p",{className:"param-empty",children:"This engine does not expose editable settings."});const c=l.reduce((f,p)=>{const m=typeof p[1].group=="string"?p[1].group:"Engine settings",h=f.find(_=>_.name===m);return h?h.entries.push(p):f.push({name:m,entries:[p]}),f},[]);return g.jsx("div",{className:"inspector-engine-settings",children:c.map(f=>g.jsxs("fieldset",{className:"engine-setting-group",children:[g.jsx("legend",{children:f.name}),g.jsx("div",{className:"engine-settings-grid",children:f.entries.map(([p,m])=>{const h=xm(p),_=P2(n,e,p,m);return g.jsx(q2,{disabled:a,engine:e,paramKey:p,path:h,schema:m,value:_,onSet:s},p)})})]},f.name))})}function q2({disabled:a,engine:e,paramKey:n,path:s,schema:l,value:c,onSet:f}){const p=typeof l.type=="string"?l.type:"string",m=I2(n,l);if(p==="boolean")return g.jsxs("label",{className:"engine-setting-toggle",children:[g.jsx("input",{checked:c===!0,disabled:a,type:"checkbox",onChange:h=>f(s,h.target.checked)}),g.jsx("span",{children:m})]});if(p==="select"&&Array.isArray(l.options)){const h=l.options.filter(Ds),_=new Set(h.map(E=>String(E.value))),S=String(c??""),v=String(Vp(n,l,e)??""),M=S&&!_.has(S)?S:"";return g.jsxs("label",{children:[m,g.jsxs("select",{disabled:a,value:M||S,onChange:E=>f(s,E.target.value),children:[M?g.jsxs("option",{disabled:!0,value:M,children:["Unsupported: ",M]}):null,h.map(E=>{const w=E.value;return g.jsx("option",{value:String(w),children:typeof E.label=="string"?E.label:String(w)},String(w))})]}),M?g.jsxs("small",{className:"engine-setting-warning",children:["Not supported by this engine.",g.jsxs("button",{disabled:a||!v,type:"button",onClick:()=>f(s,v),children:["Use ",qy(v)]})]}):null]})}return p==="number"||p==="range"?g.jsxs("label",{children:[m,g.jsx("input",{disabled:a,max:Px(l.max),min:Px(l.min),step:Ox(l.step,p==="range"?.01:1),type:p==="range"?"range":"number",value:typeof c=="number"?c:Ox(Vp(n,l,e),0),onChange:h=>f(s,Number(h.target.value))})]}):g.jsxs("label",{children:[m,g.jsx("input",{disabled:a,type:p==="color"?"color":"text",value:typeof c=="string"||typeof c=="number"?String(c):"",onChange:h=>f(s,h.target.value)})]})}function Y2({generator:a,onClose:e,onSaved:n}){const[s,l]=ee.useState(()=>Hx(a)),[c,f]=ee.useState(!1),[p,m]=ee.useState("");ee.useEffect(()=>{l(Hx(a)),m("")},[a]);async function h(){f(!0),m("");try{const _=await ft(`/api/ca/initial-condition-generators/${a.id}`,{method:"PATCH",body:JSON.stringify({name:s.name.trim()||"Untitled ICG",description:s.description.trim()||null,generatorKind:s.generatorKind,supportedClasses:[{dimensions:s.dimensions,states:s.states}],paramsSchema:Xy(s),defaultParams:Wy(s)})});n(_)}catch(_){m(_ instanceof Error?_.message:"ICG save failed")}finally{f(!1)}}return g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:()=>{c||e()},children:g.jsxs("section",{"aria-modal":"true",className:"property-modal gallery-create-modal",role:"dialog",onMouseDown:_=>_.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Initial Condition Generator"}),g.jsxs("h2",{children:["Edit ",a.name]})]}),g.jsx("div",{className:"window-action-cluster",children:g.jsx(Ki,{disabled:c,onClose:e})})]}),g.jsxs("div",{className:"gallery-create-body",children:[g.jsx(Jy,{config:s,onChange:l}),p?g.jsx("p",{className:"compatibility-warning",role:"alert",children:p}):null,g.jsxs("div",{className:"gallery-create-actions",children:[g.jsx("button",{disabled:c,type:"button",onClick:e,children:"Cancel"}),g.jsx("button",{className:"primary",disabled:c,type:"button",onClick:()=>{h()},children:c?"Saving...":"Save ICG"})]})]})]})})}function Z2({engineId:a}){const[e,n]=ee.useState(null),[s,l]=ee.useState(()=>jy()),[c,f]=ee.useState("Loading engine...");ee.useEffect(()=>{async function m(){try{const h=await ft(`/api/ca/engines/${a}`);n(h),l(Xp(h)),f("Engine ready")}catch(h){f(h instanceof Error?h.message:"Engine load failed")}}m()},[a]);async function p(){if(e)try{f(`Saving "${s.name}"...`);const m=await ft(`/api/ca/engines/${e.id}`,{method:"PATCH",body:JSON.stringify({name:s.name.trim()||"Untitled CA engine",description:s.description.trim()||null,engineKind:s.engineKind,license:s.license.trim()||null,owner:s.owner.trim()||null,ipNotice:s.ipNotice.trim()||null,supportedClasses:[{dimensions:s.dimensions,states:s.states}],paramsSchema:_m(s),defaultParams:vm(s)})});n(m),l(Xp(m)),f(`Saved "${m.name}"`)}catch(m){f(m instanceof Error?m.message:"Engine save failed")}}return g.jsxs("main",{className:"shell",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Engine Editor"}),g.jsx("h1",{children:e?.name??"Evolution function"})]}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("button",{type:"button",onClick:()=>Ui(Mo("engines")),children:"Gallery"}),g.jsx("div",{className:"status",children:c})]})]}),g.jsxs("section",{className:"panel icg-editor-panel",children:[g.jsx(Sm,{config:s,onChange:l}),g.jsx("button",{className:"primary",disabled:!e,type:"button",onClick:()=>{p()},children:"Save engine"})]})]})}function K2({initialNodeId:a,returnTo:e,treeId:n}){const[s,l]=ee.useState(null),[c,f]=ee.useState([]),[p,m]=ee.useState([]),[h,_]=ee.useState([]),[S,v]=ee.useState([]),[M,E]=ee.useState(""),[w,y]=ee.useState(""),[x,P]=ee.useState(""),[L,R]=ee.useState(.28),[I,O]=ee.useState(3),[U,A]=ee.useState(5),[N,k]=ee.useState(.8),[V,Q]=ee.useState("studio-seed"),[fe,pe]=ee.useState("Untitled preset"),[J,G]=ee.useState(""),[j,se]=ee.useState(2),[Se,xe]=ee.useState(2),[z,te]=ee.useState("2d-canvas"),[Ee,Oe]=ee.useState("moore"),[He,le]=ee.useState("B3/S23"),[Me,Ae]=ee.useState(""),[je,rt]=ee.useState("wrap"),[$e,Pt]=ee.useState(()=>ur()),[gt,dt]=ee.useState(null),[yt,ht]=ee.useState(0),[It,zt]=ee.useState(!1),[qt,rn]=ee.useState(mm),[ct,K]=ee.useState(!1),[F,Ue]=ee.useState(!1),[_t,B]=ee.useState(()=>!window.matchMedia("(max-width: 820px)").matches),[C,ie]=ee.useState(()=>!window.matchMedia("(max-width: 820px)").matches),[oe,he]=ee.useState("ca"),[Ne,Re]=ee.useState("Loading library..."),[_e,ve]=ee.useState(""),[Ie,Xe]=ee.useState(0),Ve=ee.useRef(!1),ge=c.find(ne=>ne.id===M)??null,st=ee.useMemo(()=>new Set(p.map(ne=>ne.node_id)),[p]),Je=ee.useMemo(()=>({dimensions:j,states:Se,neighborhoodId:Ee}),[j,Ee,Se]),tt=ge?In(In(Cl(c,ge),ge.params),In(_o(He,Ee,z,$e,Me,je,Fu(Je)),{caClass:Je})):In(_o(He,Ee,z,$e,Me,je,Fu(Je)),{caClass:Je}),Z=gt??tt,Le=sr(tt),ye=ee.useMemo(()=>h.filter(ne=>za(ne,Le)),[h,Le]),Fe=ee.useMemo(()=>ye.find(ne=>ne.id===w)??null,[ye,w]),Ge=ee.useMemo(()=>S.filter(ne=>za(ne,Le)),[S,Le]),Ce=ee.useMemo(()=>Ge.find(ne=>ne.id===x)??Ge.find(ne=>ne.engine_kind===Me),[Ge,Me,x]),Qe=ee.useMemo(()=>Vh(Le),[Le]),Ye=ee.useCallback(async()=>{const[ne,T]=await Promise.all([ft(`/api/ca/preset-trees/${n}/nodes`),ft(`/api/ca/preset-trees/${n}/node-usage`)]);return f(ne),m(T),ne},[n]),Yt=ee.useCallback(async()=>{const[ne,T,H,Y]=await Promise.all([ft("/api/ca/preset-trees"),ft(`/api/ca/preset-trees/${n}/nodes`),ft(`/api/ca/preset-trees/${n}/node-usage`),ft("/api/ca/engines")]);l(ne.find(q=>q.id===n)??null),f(T),m(H),v(Y);try{_(await ft("/api/ca/initial-condition-generators"))}catch{_([])}const W=T.find(q=>q.id===a)??T[0];W?await dn(W.id):Re("Library ready. Add the first top-level preset.")},[a,n]);ee.useEffect(()=>{Yt().catch(ne=>Re(ne instanceof Error?ne.message:"Library load failed"))},[Yt]),ee.useEffect(()=>{async function ne(){try{const[T,H]=await Promise.all([ft("/api/ca/initial-condition-generators"),ft("/api/ca/engines")]);_(T),v(H)}catch{_([]),v([])}}return window.addEventListener("focus",ne),()=>window.removeEventListener("focus",ne)},[]),ee.useEffect(()=>{w&&!ye.some(ne=>ne.id===w)&&y("")},[ye,w]),ee.useEffect(()=>{if(x&&!Ge.some(ne=>ne.id===x)){P("");return}if(!x&&Me){const ne=Ge.find(T=>T.engine_kind===Me);ne&&P(ne.id)}},[Ge,Me,x]),ee.useEffect(()=>{if(It)return ym(qt,()=>{Pt(ne=>{const T=Dl(ne,Z);return dt(T.settings),T.cells}),ht(ne=>ne+1)})},[Z,It,qt]),ee.useEffect(()=>{if(!ge||Ie===0||Ve.current)return;const ne=window.setTimeout(async()=>{try{const T=Cl(c,ge),H=kp(In(ge.params,In(_o(He,Ee,z,$e,Me,je,!1),{caClass:Je})),T);await ft(`/api/ca/preset-trees/${ge.tree_id}/nodes/${ge.id}`,{method:"PATCH",body:JSON.stringify({name:fe,description:J.trim()||null,params:H})}),f(Y=>Y.map(W=>W.id===ge.id?{...W,name:fe,description:J.trim()||null,params:H}:W)),Re("Preset saved")}catch(T){Re(T instanceof Error?T.message:"Preset autosave failed")}},450);return()=>window.clearTimeout(ne)},[je,Je,Ie,Me,Ee,J,fe,c,z,He,ge]);function Rt(){Ve.current||Xe(ne=>ne+1)}async function dn(ne){Ve.current=!0,zt(!1);const[T,H]=await Promise.all([ft(`/api/ca/preset-trees/${n}/nodes/${ne}`),ft(`/api/ca/preset-trees/${n}/nodes/${ne}/resolved`)]);E(T.id),dt(null),K(!1),pe(T.name),G(T.description??"");const Y=sr(H.params);se(Y?.dimensions??2),xe(typeof Y?.states=="number"?Y.states:Y?.states.length??2),te(H.params.renderer?.id??"2d-canvas"),Oe(H.params.simulation?.neighborhoodId??"moore"),le(H.params.simulation?.ruleId??"B3/S23"),rt(qp(H.params));const W=H.params.simulation?.engineId??"";Ae(W),P(S.find(q=>q.engine_kind===W)?.id??""),y(""),ve(""),Pt(Pl(H.params.simulation?.initialCondition?.cells)),ht(0),Re(`Loaded preset "${T.name}"`),window.setTimeout(()=>{Ve.current=!1,Xe(0),K(!1)},0)}function Bn(ne){dn(ne.id),window.matchMedia("(max-width: 820px)").matches&&B(!1)}function De(){window.matchMedia("(max-width: 820px)").matches&&ie(!1),B(!0)}function Ze(){window.matchMedia("(max-width: 820px)").matches&&B(!1),ie(!0)}async function vt(ne="shot"){const T=Date.now(),H=jp(c,null),Y=ne==="chapter"?`Group ${H.length+1}`:`Preset ${H.length+1}`;try{const W=await ft(`/api/ca/preset-trees/${n}/nodes`,{method:"POST",body:JSON.stringify({parentId:null,slug:`${co(Y)}-${T}`,name:Y,kind:ne,description:null,sortOrder:Bx(c,null),params:L2({rootName:Y,rendererId:z,neighborhoodId:Ee,dimensions:2,states:2,ruleId:He})})});await Ye(),await dn(W.id),Re(`Created preset "${W.name}"`)}catch(W){Re(W instanceof Error?W.message:"Preset create failed")}}async function Dt(ne,T="shot"){const H=Date.now(),Y=T==="chapter"?`${ne.name} group`:`${ne.name} variant`;try{const W=await ft(`/api/ca/preset-trees/${n}/nodes`,{method:"POST",body:JSON.stringify({parentId:ne.id,slug:`${co(Y)}-${H}`,name:Y,kind:T,description:null,sortOrder:Bx(c,ne.id),params:{}})});await Ye(),await dn(W.id),Re(`Created child preset "${W.name}"`)}catch(W){Re(W instanceof Error?W.message:"Preset create failed")}}async function Ct(ne){const T=new Set([ne.id]);let H=!0;for(;H;){H=!1;for(const q of c)q.parent_id&&T.has(q.parent_id)&&!T.has(q.id)&&(T.add(q.id),H=!0)}const W=p.filter(q=>T.has(q.node_id)).reduce((q,Be)=>q+Be.scene_count,0);if(W>0){const q=T.size>1?`This preset contains ${W} slide reference${W===1?"":"s"} in its subtree. Detach them before deleting it.`:`This preset is assigned to ${W} slide${W===1?"":"s"}. Detach it before deleting.`;return Re(q),!1}try{const q=await fetch(`/api/ca/preset-trees/${ne.tree_id}/nodes/${ne.id}`,{method:"DELETE"});if(!q.ok){const Pe=await q.json().catch(()=>null);throw new Error(Pe?.error??"Preset could not be deleted.")}ne.id===M&&(E(""),pe("Untitled preset"),G(""));const Be=await Ye(),ze=Be.find(Pe=>Pe.parent_id===ne.parent_id)??Be[0];return ze&&await dn(ze.id),Re(`Deleted preset "${ne.name}"`),!0}catch(q){return Re(q instanceof Error?q.message:"Preset delete failed"),!1}}async function St(ne,T){const H=jp(c,ne.parent_id),Y=H.findIndex(ze=>ze.id===ne.id),W=Y+T;if(Y===-1||W<0||W>=H.length)return;const q=[...H],[Be]=q.splice(Y,1);q.splice(W,0,Be);try{const ze=await Promise.all(q.map((We,ke)=>ft(`/api/ca/preset-trees/${We.tree_id}/nodes/${We.id}`,{method:"PATCH",body:JSON.stringify({sortOrder:ke})}))),Pe=new Map(ze.map(We=>[We.id,We]));f(We=>We.map(ke=>Pe.get(ke.id)??ke)),Re(`Moved "${ne.name}"`)}catch(ze){Re(ze instanceof Error?ze.message:"Preset reorder failed")}}async function _n(ne,T,H){let Y=Ni(ne.params,T,H);const W=T.join(".")==="caClass.dimensions"||T.join(".")==="caClass.states"||T.join(".")==="caClass.neighborhoodId",q=[];if(W){const ze=In(Cl(c,ne),Y),Pe=sr(ze),We=ze.simulation?.engineId,ke=S.find(Et=>Et.engine_kind===We),nt=ze.renderer?.id,ut=Vh(Pe);if(ke&&!za(ke,Pe)&&(Y=Ni(Y,["simulation","engineId"],null),q.push(`Evolution function "${ke.name}" was unset`)),typeof nt=="string"&&!ut.some(Et=>Et.id===nt)){const Et=ut[0];Y=Ni(Y,["renderer","id"],Et?.id??null),q.push(Et?`Renderer changed to "${Et.label}"`:"No renderer supports this dimensionality and state space")}const it=h.find(Et=>Et.id===w);ne.id===M&&it&&!za(it,Pe)&&(y(""),q.push(`Initial condition generator "${it.name}" was unset`))}const Be=await ft(`/api/ca/preset-trees/${ne.tree_id}/nodes/${ne.id}`,{method:"PATCH",body:JSON.stringify({params:Y})});f(ze=>ze.map(Pe=>Pe.id===ne.id?Be:Pe)),ne.id===M&&await dn(ne.id),q.length>0&&ve(q.join(". ")),Re(`Saved ${T.join(".")} on "${ne.name}"`)}async function kn(ne,T){const H=await ft(`/api/ca/preset-trees/${ne.tree_id}/nodes/${ne.id}`,{method:"PATCH",body:JSON.stringify({name:T})});f(Y=>Y.map(W=>W.id===ne.id?H:W)),ne.id===M&&pe(H.name),Re(`Renamed preset to "${H.name}"`)}async function pa(ne,T){const H=Zy(ne.params,T),Y=await ft(`/api/ca/preset-trees/${ne.tree_id}/nodes/${ne.id}`,{method:"PATCH",body:JSON.stringify({params:H})});f(W=>W.map(q=>q.id===ne.id?Y:q)),ne.id===M&&await dn(ne.id),Re(`Unset ${T.join(".")} on "${ne.name}"`)}function hr(ne){typeof ne?.default_params.density=="number"&&R(ne.default_params.density),typeof ne?.default_params.count=="number"&&O(ne.default_params.count),typeof ne?.default_params.length=="number"&&A(ne.default_params.length),typeof ne?.default_params.sameTypeProbability=="number"&&k(ne.default_params.sameTypeProbability),typeof ne?.default_params.seed=="string"&&Q(ne.default_params.seed)}function pr(ne){return ne.generator_kind==="naga-markov"?{count:I,length:U,sameTypeProbability:N,seed:V}:{density:Math.max(0,Math.min(1,L)),seed:V}}function ma(){if(!ge||!Le)return;const ne=ye.find(T=>T.id===w);if(ne)try{zt(!1);const T=qb(ne.generator_kind,{settings:tt,caClass:Le,params:pr(ne)}),H=In(ge.params,{simulation:{initialCondition:T}});f(Y=>Y.map(W=>W.id===ge.id?{...W,params:H}:W)),dt(In(tt,{simulation:{initialCondition:T}})),Pt(Pl(T.cells)),K(!0),ht(0),Re(`Generated unsaved initial condition on "${ge.name}"`)}catch(T){Re(T instanceof Error?T.message:"ICG apply failed")}}async function Qi(ne){const T=Ge.find(H=>H.id===ne);if(P(ne),!T){if(Ae(""),dt(null),ge)try{const H=Ni(ge.params,["simulation","engineId"],null),Y=await ft(`/api/ca/preset-trees/${ge.tree_id}/nodes/${ge.id}`,{method:"PATCH",body:JSON.stringify({params:H})});f(W=>W.map(q=>q.id===Y.id?Y:q)),Re(`Unset evolution function on "${ge.name}"`)}catch(H){Re(H instanceof Error?H.message:"Engine update failed")}return}if(Ae(T.engine_kind),dt(null),typeof T.default_params.ruleId=="string"&&le(T.default_params.ruleId),typeof T.default_params.rendererId=="string"&&Qe.some(H=>H.id===T.default_params.rendererId)&&te(T.default_params.rendererId),ge)try{let H=Ni(ge.params,["simulation","engineId"],T.engine_kind);for(const[W,q]of Object.entries(T.default_params))H=Ni(H,xm(W),q);H=Ux(H,Je,T.default_params.rendererId);const Y=await ft(`/api/ca/preset-trees/${ge.tree_id}/nodes/${ge.id}`,{method:"PATCH",body:JSON.stringify({params:H})});f(W=>W.map(q=>q.id===Y.id?Y:q)),Re(`Selected "${T.name}" for "${ge.name}"`)}catch(H){Re(H instanceof Error?H.message:"Engine update failed")}}async function Ji(ne,T){if(!ge)return;const H=ne.join(".");if(H==="simulation.ruleId"&&typeof T=="string"&&le(T),H==="renderer.id"&&typeof T=="string"&&te(T),H==="simulation.grid.boundary"&&(T==="wrap"||T==="mirror"||T==="fixed")&&rt(T),H==="simulation.grid.wrap"&&typeof T=="boolean"){rt(T?"wrap":"fixed"),dt(null);const Y=Ni(Ni(ge.params,["simulation","grid","boundary"],T?"wrap":"fixed"),["simulation","grid","wrap"],T),W=await ft(`/api/ca/preset-trees/${ge.tree_id}/nodes/${ge.id}`,{method:"PATCH",body:JSON.stringify({params:Y})});f(q=>q.map(Be=>Be.id===W.id?W:Be)),await dn(ge.id),Re(`Saved edge wrap on "${ge.name}"`);return}dt(null),_n(ge,ne,T)}function li(ne,T,H=Ee){if(!ge)return;const Y={dimensions:ne,states:T,neighborhoodId:H},W=[];let q=z,Be=!1;const ze=S.find(ke=>ke.engine_kind===Me);ze&&!za(ze,Y)&&(Be=!0,Ae(""),P(""),W.push(`Evolution function "${ze.name}" was unset`));const Pe=h.find(ke=>ke.id===w);Pe&&!za(Pe,Y)&&(y(""),W.push(`Initial condition generator "${Pe.name}" was unset`));const We=Vh(Y);We.some(ke=>ke.id===z)||(q=We[0]?.id??"",te(q),W.push(q?`Renderer changed to "${We[0].label}"`:"No renderer supports this dimensionality and state space")),se(ne),xe(T),Oe(H),dt(null),ve(W.join(". ")),f(ke=>ke.map(nt=>{if(nt.id!==ge.id)return nt;let ut=Ux(nt.params,Y,q);return ut=Ni(ut,["simulation","neighborhoodId"],H),Be&&(ut=Ni(ut,["simulation","engineId"],null)),ut=Ni(ut,["renderer","id"],q),{...nt,params:ut}})),Rt()}function Ii(ne){zt(!1),ht(0),dt(null),Pt(ne),K(!0)}function ga(){if(!ge)return;zt(!1),ht(0),Pt(ur());const ne={type:"cells",cells:[]},T=In(ge.params,{simulation:{initialCondition:ne}});f(H=>H.map(Y=>Y.id===ge.id?{...Y,params:T}:Y)),dt(In(tt,{simulation:{initialCondition:ne}})),Gp(Je)?Re(`Cleared unsaved voxel initial condition on "${ge.name}"`):Re(`Cleared unsaved initial condition on "${ge.name}"`),K(!0)}async function Bi(){if(!(!ge||F))try{Ue(!0),zt(!1);const ne=Cl(c,ge),T=Gp(Je)?Z.simulation?.initialCondition?.cells??tt.simulation?.initialCondition?.cells??[]:gm($e),H=kp(In(ge.params,{simulation:{initialCondition:{type:"cells",cells:T}}}),ne),Y=await ft(`/api/ca/preset-trees/${ge.tree_id}/nodes/${ge.id}`,{method:"PATCH",body:JSON.stringify({params:H})});f(W=>W.map(q=>q.id===Y.id?Y:q)),dt(null),K(!1),ht(0),Re(`Saved initial condition on "${ge.name}"`)}catch(ne){Re(ne instanceof Error?ne.message:"Initial condition save failed")}finally{Ue(!1)}}function vn(){zt(!1),Pt(ne=>{const T=Dl(ne,Z);return dt(T.settings),T.cells}),ht(ne=>ne+1)}return g.jsxs("main",{className:`studio-shell preset-studio-shell${C?" inspector-open":""}`,children:[g.jsxs("header",{className:"topbar preset-studio-topbar",children:[g.jsxs("div",{className:"preset-library-heading",children:[g.jsx("p",{className:"eyebrow",children:"Preset Library"}),g.jsx("h1",{children:s?.name??"Library"}),g.jsx("button",{className:"header-back-button",type:"button",onClick:()=>Ui(e??Mo("cas")),children:"Back"})]}),g.jsx("div",{className:"topbar-speed-float","aria-label":"Simulation speed",children:g.jsx(Qy,{speedLevel:qt,onChange:rn})}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("div",{className:"status",children:Ne}),g.jsx(Ki,{})]})]}),g.jsxs("section",{className:`preset-studio-workspace${_t?" tree-open":""}${C?" inspector-open":""}`,children:[g.jsx("button",{"aria-label":"Close preset drawer",className:"drawer-scrim tree-scrim",type:"button",onClick:()=>B(!1)}),g.jsxs("aside",{className:"studio-drawer preset-tree-drawer",children:[g.jsxs("div",{className:"drawer-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Presets"}),g.jsx("h2",{children:"Library tree"})]}),g.jsx(Ki,{closeLabel:"Close preset drawer",onClose:()=>B(!1)})]}),g.jsxs("div",{className:"drawer-scroll",children:[g.jsxs("div",{className:"root-selector",children:[g.jsx("button",{className:"primary",type:"button",onClick:()=>{vt()},children:"New preset"}),g.jsx("button",{type:"button",onClick:()=>{vt("chapter")},children:"New group"})]}),g.jsx("div",{className:"tree-list",children:g.jsx(u2,{engines:S,nodes:c,selectedNodeId:M,usedNodeIds:st,onCreateChild:ne=>{Dt(ne,"shot")},onCreateGroup:ne=>{Dt(ne,"chapter")},onDelete:ne=>Ct(ne),onMove:(ne,T)=>{St(ne,T)},onRename:(ne,T)=>kn(ne,T),onSelect:Bn,onSet:(ne,T,H)=>{_n(ne,T,H)},onUnset:(ne,T)=>{pa(ne,T)}})})]})]}),g.jsxs("section",{className:"preset-stage",children:[g.jsxs("div",{className:"preset-stage-toolbar",children:[g.jsxs("div",{className:"preset-stage-title",children:[g.jsx("button",{type:"button",onClick:De,children:"Presets"}),g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preset Preview"}),g.jsx("h2",{children:ge?fe:"Select a preset"})]})]}),g.jsxs("div",{className:"button-row",children:[g.jsx("button",{type:"button",onClick:vn,children:"Step"}),g.jsx("button",{className:"primary playback-button",type:"button",onClick:()=>zt(ne=>!ne),children:It?"⏸":"▶"}),g.jsx("button",{type:"button",onClick:Ze,children:"Inspector"})]})]}),g.jsxs("div",{className:`preset-renderer-stage${ct?" ic-dirty":""}`,children:[ct?g.jsxs("div",{className:"ic-dirty-banner",role:"status",children:[g.jsx("span",{children:"Unsaved initial condition"}),g.jsx("button",{className:"primary",disabled:!ge||F,type:"button",onClick:()=>{Bi()},children:F?"Saving...":"Save"})]}):null,g.jsx(Wu,{caption:"",cells:$e,settings:Z,onCellsChange:Ii})]}),g.jsxs("footer",{className:"metrics preset-stage-metrics",children:[g.jsxs("span",{children:["Generation ",g.jsx("strong",{children:yt})]}),g.jsxs("span",{children:["Live cells ",g.jsx("strong",{children:Gy($e)})]}),g.jsxs("span",{children:["Preset ",g.jsx("strong",{children:M?M.slice(0,8):"none"})]})]})]}),g.jsx("button",{"aria-label":"Close inspector",className:"drawer-scrim inspector-scrim",type:"button",onClick:()=>ie(!1)}),g.jsxs("aside",{className:"studio-drawer preset-inspector-drawer",children:[g.jsxs("div",{className:"drawer-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Inspector"}),g.jsx("h2",{children:ge?fe:"No preset selected"})]}),g.jsx(Ki,{closeLabel:"Close inspector",onClose:()=>ie(!1)})]}),g.jsxs("div",{className:"inspector-tabs",role:"tablist","aria-label":"Preset inspector sections",children:[g.jsx("button",{className:oe==="ca"?"active":"",role:"tab",type:"button",onClick:()=>he("ca"),children:"CA"}),g.jsx("button",{className:oe==="initial"?"active":"",role:"tab",type:"button",onClick:()=>he("initial"),children:"Initial State"}),g.jsx("button",{className:oe==="display"?"active":"",role:"tab",type:"button",onClick:()=>he("display"),children:"Display"})]}),g.jsxs("div",{className:"drawer-scroll inspector-body",children:[oe==="ca"?g.jsxs("div",{className:"inspector-section",children:[_e?g.jsx("div",{className:"compatibility-warning",role:"alert",children:_e}):null,g.jsxs("section",{className:"preset-modal-stage inspector-ca-stage",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"1"}),g.jsxs("div",{children:[g.jsx("h3",{children:"CA space"}),g.jsx("p",{children:"Choose dimensions, state count, and neighbourhood first."})]})]}),g.jsxs("label",{children:["Preset name",g.jsx("input",{disabled:!ge,value:fe,onChange:ne=>{pe(ne.target.value),Rt()}})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{disabled:!ge,value:J,onChange:ne=>{G(ne.target.value),Rt()}})]}),g.jsxs("div",{className:"preset-modal-class-grid inspector-ca-class-grid",children:[g.jsxs("label",{children:["Dimensions",g.jsxs("select",{disabled:!ge,value:j,onChange:ne=>{li(Number(ne.target.value),Se,Ee)},children:[g.jsx("option",{value:1,children:"1D"}),g.jsx("option",{value:2,children:"2D"}),g.jsx("option",{value:3,children:"3D"})]})]}),g.jsxs("label",{children:["States",g.jsx("input",{disabled:!ge,min:2,step:1,type:"number",value:Se,onChange:ne=>li(j,Math.max(2,Number(ne.target.value)||2),Ee)})]}),g.jsxs("label",{children:["Neighbourhood",g.jsxs("select",{disabled:!ge,value:Ee,onChange:ne=>{li(j,Se,ne.target.value)},children:[g.jsx("option",{value:"moore",children:"Moore"}),g.jsx("option",{value:"von-neumann",children:"Von Neumann"})]})]})]})]}),g.jsxs("section",{className:"preset-modal-stage inspector-ca-stage",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"2"}),g.jsxs("div",{children:[g.jsx("h3",{children:"Evolution engine"}),g.jsx("p",{children:"Only engines that support this CA space can be selected."})]})]}),g.jsxs("label",{children:["Engine",g.jsxs("select",{disabled:!ge,value:Ce?.id??"",onChange:ne=>Qi(ne.target.value),children:[g.jsx("option",{value:"",children:"Select evolution function"}),Ge.map(ne=>g.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),Ce?g.jsx("small",{className:"param-empty",children:Ce.license?`License: ${Ce.license}`:"No license metadata"}):g.jsx("p",{className:"param-empty",children:Ge.length>0?"Select an evolution function for this preset.":"No matching engine for this preset class."})]}),g.jsxs("section",{className:"preset-modal-stage inspector-ca-stage",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"3"}),g.jsxs("div",{children:[g.jsx("h3",{children:"Engine settings"}),g.jsx("p",{children:"Controls are supplied by the selected engine schema."})]})]}),g.jsx(W2,{disabled:!ge,engine:Ce,settings:tt,onSet:Ji})]})]}):null,oe==="initial"?g.jsxs("div",{className:"inspector-section",children:[g.jsxs("div",{className:"button-row initial-condition-actions",children:[g.jsx("button",{type:"button",onClick:ga,children:"Clear canvas"}),g.jsx("button",{className:"primary",disabled:!ge||!ct||F,type:"button",onClick:()=>{Bi()},children:F?"Saving...":"Save initial condition"})]}),ct?g.jsx("p",{className:"param-empty",children:"Initial condition has unsaved canvas edits."}):g.jsx("p",{className:"param-empty",children:"Canvas edits are saved explicitly so preview playback stays temporary."}),ye.length>0?g.jsxs(g.Fragment,{children:[g.jsxs("label",{children:["Generator",g.jsxs("select",{value:w,onChange:ne=>{const T=ye.find(H=>H.id===ne.target.value);y(ne.target.value),hr(T)},children:[g.jsx("option",{value:"",children:"Select generator"}),ye.map(ne=>g.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),Fe?.generator_kind==="naga-markov"?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"root-config-grid",children:g.jsxs("label",{children:["Length",g.jsx("input",{min:1,step:1,type:"number",value:U,onChange:ne=>A(Math.max(1,Number(ne.target.value)||1))})]})}),g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Naga count",g.jsx("input",{max:16,min:1,step:1,type:"range",value:I,onChange:ne=>O(Math.max(1,Number(ne.target.value)||1))})]}),g.jsx("strong",{children:I})]}),g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Same type probability",g.jsx("input",{max:1,min:0,step:.01,type:"range",value:N,onChange:ne=>k(Number(ne.target.value))})]}),g.jsxs("strong",{children:[Math.round(N*100),"%"]})]})]}):g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Density",g.jsx("input",{max:1,min:0,step:.01,type:"range",value:L,onChange:ne=>R(Number(ne.target.value))})]}),g.jsxs("strong",{children:[Math.round(L*100),"%"]})]}),g.jsxs("label",{children:["Seed",g.jsx("input",{value:V,onChange:ne=>Q(ne.target.value)})]}),g.jsx("button",{className:"primary",disabled:!ge||!w,type:"button",onClick:ma,children:"Generate initial condition"})]}):g.jsx("p",{className:"param-empty",children:"No matching generator for this preset class."})]}):null,oe==="display"?g.jsxs("div",{className:"inspector-section",children:[g.jsxs("label",{children:["Renderer",g.jsx("select",{disabled:!ge,value:z,onChange:ne=>{te(ne.target.value),Rt()},children:Qe.map(ne=>g.jsx("option",{value:ne.id,children:ne.label},ne.id))})]}),Qe.length===0?g.jsx("p",{className:"param-empty",children:"No renderer supports this dimensionality and state space."}):null,g.jsx("p",{className:"param-empty",children:"Renderer-specific display controls will appear in this inspector."})]}):null]})]})]})]})}function $2({assignedNodeId:a,assignedNodeName:e,autoplayOnSlideChange:n,caption:s,scene:l,slideTitle:c,onAutoplayChange:f,onCaptionChange:p,onClose:m,onSelectCa:h,onSlideTitleChange:_}){return g.jsx("div",{className:"modal-backdrop slide-modal-backdrop",role:"presentation",onMouseDown:m,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal slide-metadata-modal",role:"dialog",onMouseDown:S=>S.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Slide Metadata"}),g.jsx("h2",{children:l.scene.title})]}),g.jsx(Ki,{onClose:m})]}),g.jsxs("div",{className:"slide-metadata-body",children:[g.jsxs("label",{children:["Slide name",g.jsx("input",{value:c,onChange:S=>_(S.target.value)})]}),g.jsxs("label",{children:["Caption",g.jsx("textarea",{value:s,onChange:S=>p(S.target.value)})]}),g.jsxs("label",{className:"toggle-field",children:[g.jsx("input",{checked:n,type:"checkbox",onChange:S=>f(S.target.checked)}),"Autoplay on slide change"]}),g.jsxs("section",{className:"slide-ca-asset",children:[g.jsxs("div",{children:[g.jsx("span",{children:"CA preset"}),g.jsx("strong",{children:e??"No CA selected"}),g.jsx("small",{children:a?a.slice(0,8):"Select a reusable preset asset"})]}),g.jsx("button",{className:"primary",type:"button",onClick:h,children:"Select CA"})]}),g.jsxs("div",{className:"slide-metadata-grid",children:[g.jsxs("span",{children:[g.jsx("strong",{children:"Order"}),g.jsx("small",{children:l.scene.order_index})]}),g.jsxs("span",{children:[g.jsx("strong",{children:"Apply mode"}),g.jsx("small",{children:l.scene.apply_mode})]}),g.jsxs("span",{children:[g.jsx("strong",{children:"Assigned node"}),g.jsx("small",{children:a?a.slice(0,8):"none"})]}),g.jsxs("span",{children:[g.jsx("strong",{children:"Tree"}),g.jsx("small",{children:l.scene.preset_tree_id?.slice(0,8)??"none"})]})]})]})]})})}function Q2({assignedNodeId:a,loading:e,nodes:n,presetTrees:s,resolvedNode:l,selectedNode:c,selectedTreeId:f,onClose:p,onEditSelected:m,onSelectNode:h,onSelectTree:_,onUseSelected:S}){const v=Pl(l?.params.simulation?.initialCondition?.cells);return ee.useEffect(()=>{function M(E){E.key==="Escape"&&p()}return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[p]),g.jsx("div",{className:"modal-backdrop ca-asset-modal-backdrop",role:"presentation",onMouseDown:p,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal ca-asset-modal",role:"dialog",onMouseDown:M=>M.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Assets"}),g.jsx("h2",{children:"Select a preset"})]}),g.jsx(Ki,{onClose:p})]}),g.jsxs("div",{className:"ca-asset-layout",children:[g.jsxs("aside",{className:"ca-asset-browser",children:[g.jsxs("label",{children:["CA library",g.jsx("select",{value:f,onChange:M=>_(M.target.value),children:s.map(M=>g.jsxs("option",{value:M.id,children:[M.name," (",M.node_count,")"]},M.id))})]}),e?g.jsx("p",{className:"empty",children:"Loading CA presets..."}):g.jsx(s2,{assignedNodeId:a,nodes:n,selectedNodeId:c?.id,onSelect:h})]}),g.jsxs("section",{className:"ca-asset-preview",children:[g.jsxs("div",{className:"ca-asset-preview-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preview"}),g.jsx("h3",{children:c?.name??"Select a CA preset"}),c?.description?g.jsx("p",{children:c.description}):null]}),l?g.jsxs("small",{children:[l.params.caClass?.dimensions??"?","D · ",String(l.params.caClass?.states??"?")," states"]}):null]}),g.jsx("div",{className:"ca-asset-preview-stage",children:l?g.jsx(Wu,{caption:"",cells:v,settings:l.params,onCellsChange:()=>{}}):g.jsx("p",{className:"empty",children:"Choose a preset from the tree to inspect it."})}),g.jsxs("div",{className:"ca-asset-actions",children:[g.jsx("button",{type:"button",onClick:p,children:"Cancel"}),g.jsx("button",{disabled:!c||c.kind==="chapter",type:"button",onClick:m,children:"Edit CA"}),g.jsx("button",{className:"primary",disabled:!c||c.kind==="chapter",type:"button",onClick:S,children:"Use this CA"})]})]})]})]})})}function J2({deckId:a}){const[e,n]=ee.useState(null),[s,l]=ee.useState(0),[c,f]=ee.useState(()=>_o("B3/S23","moore","2d-canvas",ur())),[p,m]=ee.useState(()=>ur()),[h,_]=ee.useState(0),[S,v]=ee.useState(!1),[M,E]=ee.useState(mm),[w,y]=ee.useState("Loading viewer..."),x=ee.useRef(c),P=ee.useRef(s),L=e?.scenes[s]??null,R=ee.useMemo(()=>Ix(c,p),[p,c]);ee.useEffect(()=>{x.current=c},[c]),ee.useEffect(()=>{P.current=s},[s]);function I(A,N,k={}){const V=k.forceReinitialize===!0||A.scene.apply_mode!=="patch_existing"&&A.scene.requires_previous_scene!==!0;l(N),f(A.params),V&&(m(Pl(A.params.simulation?.initialCondition?.cells)),_(0)),v(F2(A)),y(A.scene.title)}const O=ee.useCallback((A,N={})=>{const k=e?.scenes??[];if(k.length===0)return;const V=Math.min(Math.max(A,0),k.length-1);I(k[V],V,N)},[e]),U=ee.useCallback(()=>{m(A=>{const N=Dl(A,Ix(x.current,A));return f(N.settings),x.current=N.settings,N.cells}),_(A=>A+1)},[]);return ee.useEffect(()=>{let A=!1;async function N(){try{const k=await ft(`/api/ca/decks/${a}/resolved`);if(A)return;n(k),k.scenes[0]?I(k.scenes[0],0,{forceReinitialize:!0}):y("Deck has no slides")}catch(k){A||y(k instanceof Error?k.message:"Viewer load failed")}}return N(),()=>{A=!0}},[a]),ee.useEffect(()=>{if(S)return ym(M,U)},[S,M,U]),ee.useEffect(()=>{function A(N){if(!Vy(N.target)){if(N.key==="ArrowRight"||N.key==="ArrowDown"){N.preventDefault(),O(P.current+1);return}if(N.key==="ArrowLeft"||N.key==="ArrowUp"){N.preventDefault(),O(P.current-1);return}if(N.key===" "){N.preventDefault(),v(k=>!k);return}if(N.key==="."||N.key.toLowerCase()==="s"){N.preventDefault(),v(!1),U();return}N.key.toLowerCase()==="r"&&(N.preventDefault(),O(P.current,{forceReinitialize:!0}))}}return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[O,U]),g.jsx("main",{className:"viewer-shell",children:g.jsxs("section",{className:"viewer-stage","aria-label":L?.scene.title??w,children:[g.jsx(Wu,{caption:B2(L),cells:p,settings:R,onCellsChange:()=>{}}),g.jsx("div",{className:"viewer-speed-float","aria-label":"Simulation speed",children:g.jsx(Qy,{speedLevel:M,onChange:E})}),g.jsxs("div",{className:"viewer-rec-status","aria-hidden":"true",children:[g.jsx("span",{children:e?.deck.title??"CA Deck"}),g.jsx("span",{children:L?`${s+1}/${e?.scenes.length??0}`:w}),g.jsx("span",{children:S?"REC PLAY":"REC HOLD"}),g.jsxs("span",{children:["G",h]})]})]})})}function e3({deckId:a,initialSceneId:e}){const[n,s]=ee.useState(null),[l,c]=ee.useState("Deck editor"),[f,p]=ee.useState(null),[m,h]=ee.useState([]),[_,S]=ee.useState([]),[v,M]=ee.useState(""),[E,w]=ee.useState(!1),[y,x]=ee.useState(!1),[P,L]=ee.useState(""),[R,I]=ee.useState([]),[O,U]=ee.useState(""),[A,N]=ee.useState(null),[k,V]=ee.useState(!1),[Q,fe]=ee.useState(""),[pe,J]=ee.useState("Untitled slide"),[G,j]=ee.useState("Glider"),[se,Se]=ee.useState(""),[xe,z]=ee.useState(!1),[te,Ee]=ee.useState("2d-canvas"),[Oe,He]=ee.useState("moore"),[le,Me]=ee.useState("B3/S23"),[Ae,je]=ee.useState("wrap"),[rt,$e]=ee.useState(()=>b2()),[Pt,gt]=ee.useState(null),[dt,yt]=ee.useState(0),[ht,It]=ee.useState(!1),[zt,qt]=ee.useState(mm),[rn,ct]=ee.useState("Loading deck..."),K=ee.useRef(!1),F=ee.useRef(!1),Ue=f?.scenes.find(De=>De.scene.id===v)??null,_t=f?.scenes.findIndex(De=>De.scene.id===v)??-1;go(n);const B=f?.scenes.length??0,C=_t>0,ie=_t>=0&&_t<B-1,oe=_.find(De=>De.id===Q)??null,he=Ue?.scene.preset_node_id,Ne=R.find(De=>De.id===O)??null,Re=oe?In(Cl(_,oe),oe.params):null,_e=sr(Re??void 0),ve=oe?In(Re??{},_o(le,Oe,te,rt,void 0,Ae,Fu(_e))):_o(le,Oe,te,rt,void 0,Ae),Ie=Pt??ve,Xe=ee.useCallback(async()=>{const De=await ft(`/api/ca/decks/${a}`),Ze=await ft(`/api/ca/decks/${a}/resolved`);return F.current=!0,s(De),c(De.title),p(Ze),window.setTimeout(()=>{F.current=!1},0),{deck:De,resolvedDeck:Ze}},[a]);async function Ve(De){const Ze=await ft(`/api/ca/preset-trees/${De}/nodes`);S(Ze)}async function ge(){const De=await ft("/api/ca/preset-trees");return h(De),De}async function st(De,Ze){const vt=go(De);if(vt.presetTreeId)return await Ve(vt.presetTreeId),vt;const Dt=Ze.scenes[0];if(Dt?.scene.preset_tree_id){const Ct={presetTreeId:Dt.scene.preset_tree_id,rootNodeId:void 0,rendererId:Dt.params.renderer?.id??"2d-canvas",neighborhoodId:Dt.params.simulation?.neighborhoodId??"moore",ruleId:Dt.params.simulation?.ruleId??"B3/S23"},St=await ft(`/api/ca/decks/${De.id}`,{method:"PATCH",body:JSON.stringify({params:T2(De,Ct)})});return s(St),await Ve(Ct.presetTreeId),ct("Repaired deck metadata from existing slides"),Ct}return S([]),vt}ee.useEffect(()=>{async function De(){try{const Ze=await Xe();await ge();const vt=await st(Ze.deck,Ze.resolvedDeck),Dt=Ze.resolvedDeck.scenes.find(Ct=>Ct.scene.id===e)??Ze.resolvedDeck.scenes[0];Dt?tt(Dt):(Ee(vt.rendererId??"2d-canvas"),He(vt.neighborhoodId??"moore"),Me(vt.ruleId??"B3/S23"),je("wrap"),ct(vt.presetTreeId?"Deck ready. Add the first slide.":"Deck ready. Add the first slide and select a CA asset."))}catch(Ze){ct(Ze instanceof Error?Ze.message:"Deck load failed")}}De()},[a,e,Xe]),ee.useEffect(()=>{if(ht)return ym(zt,()=>{$e(De=>{const Ze=Dl(De,Ie);return gt(Ze.settings),Ze.cells}),yt(De=>De+1)})},[Ie,ht,zt]),ee.useEffect(()=>{if(!n||F.current||l===n.title)return;const De=window.setTimeout(async()=>{const Ze=l.trim()||"Untitled deck";try{const vt=await ft(`/api/ca/decks/${n.id}`,{method:"PATCH",body:JSON.stringify({title:Ze})});s(vt),c(vt.title),ct("Deck name saved")}catch(vt){ct(vt instanceof Error?vt.message:"Deck name save failed")}},450);return()=>window.clearTimeout(De)},[n,l]),ee.useEffect(()=>{if(!Ue||K.current)return;const De=pe.trim()||"Untitled slide",Ze=typeof Ue.scene.params.caption=="string"?Ue.scene.params.caption:"",vt=Ue.scene.params.autoplayOnSlideChange===!0;if(Ue.scene.title===De&&Ze===se&&vt===xe)return;const Dt=window.setTimeout(async()=>{try{await ft(`/api/ca/scenes/${Ue.scene.id}`,{method:"PATCH",body:JSON.stringify({title:De,params:{...Ue.scene.params,caption:se,autoplayOnSlideChange:xe}})}),p(Ct=>Ct&&{...Ct,scenes:Ct.scenes.map(St=>St.scene.id===Ue.scene.id?{...St,scene:{...St.scene,title:De,params:{...St.scene.params,caption:se,autoplayOnSlideChange:xe}}}:St)}),ct("Slide settings saved")}catch(Ct){ct(Ct instanceof Error?Ct.message:"Slide settings autosave failed")}},450);return()=>window.clearTimeout(Dt)},[Ue,xe,se,pe]);async function Je(De,Ze,vt,Dt={}){K.current=!0,It(!1);const[Ct,St,_n]=await Promise.all([ft(`/api/ca/preset-trees/${De}/nodes/${Ze}`),ft(`/api/ca/preset-trees/${De}/nodes/${Ze}/resolved`),ft(`/api/ca/preset-trees/${De}/nodes`)]);S(_n),fe(Ze),gt(null),j(Ct.name||vt||"Untitled node"),Ee(St.params.renderer?.id??"2d-canvas"),He(St.params.simulation?.neighborhoodId??"moore"),Me(St.params.simulation?.ruleId??"B3/S23"),je(qp(St.params)),$e(Pl(St.params.simulation?.initialCondition?.cells)),yt(0),ct(`Loaded node "${Ct.name}"`),window.setTimeout(()=>{K.current=!1,It(Dt.runAfterLoad===!0)},0)}function tt(De){K.current=!0;const Ze=De.scene.params.autoplayOnSlideChange===!0;if(It(!1),M(De.scene.id),J(De.scene.title),Se(typeof De.scene.params.caption=="string"?De.scene.params.caption:""),z(Ze),De.scene.preset_tree_id&&De.scene.preset_node_id){gt(null),Je(De.scene.preset_tree_id,De.scene.preset_node_id,De.scene.title,{runAfterLoad:Ze});return}fe(""),gt(null),j("No CA preset"),$e(ur()),yt(0),ct(`Loaded empty slide "${De.scene.title}"`),window.setTimeout(()=>{K.current=!1},0)}function Z(De){tt(De),w(!0)}async function Le(De){U(De.id),V(!0);try{const Ze=await ft(`/api/ca/preset-trees/${De.tree_id}/nodes/${De.id}/resolved`);N(Ze)}catch(Ze){N(null),ct(Ze instanceof Error?Ze.message:"CA preview failed")}finally{V(!1)}}async function ye(De,Ze){if(!De){L(""),I([]),U(""),N(null);return}L(De),V(!0);try{const vt=await ft(`/api/ca/preset-trees/${De}/nodes`);I(vt);const Ct=vt.find(St=>St.id===Ze)??vt.find(St=>St.kind!=="chapter")??null;Ct?(U(Ct.id),N(await ft(`/api/ca/preset-trees/${De}/nodes/${Ct.id}/resolved`))):(U(""),N(null))}catch(vt){I([]),U(""),N(null),ct(vt instanceof Error?vt.message:"CA library load failed")}finally{V(!1)}}function Fe(){const De=Ue?.scene.preset_tree_id??m[0]?.id??"";w(!1),x(!0),ye(De,Ue?.scene.preset_node_id??void 0)}async function Ge(){if(!Ne||Ne.kind==="chapter"||!Ue)return;await ft(`/api/ca/scenes/${Ue.scene.id}`,{method:"PATCH",body:JSON.stringify({presetTreeId:Ne.tree_id,presetNodeId:Ne.id,params:{...Ue.scene.params,caption:se,autoplayOnSlideChange:xe}})});const Ze=(await Xe()).resolvedDeck.scenes.find(vt=>vt.scene.id===Ue.scene.id);Ze&&tt(Ze),x(!1),ct(`Assigned "${Ne.name}" to selected slide`)}async function Ce(){if(Ue)try{It(!1),ct(`Deleting slide "${Ue.scene.title}"...`);const De=Ue.scene.id,Ze=Ue.scene.title,vt=f?.scenes.findIndex(St=>St.scene.id===De)??0;await fetch(`/api/ca/scenes/${De}`,{method:"DELETE"}).then(St=>{if(!St.ok)throw new Error("Unable to delete slide")});const Dt=await Xe(),Ct=Dt.resolvedDeck.scenes[Math.min(Math.max(vt,0),Dt.resolvedDeck.scenes.length-1)];Ct?tt(Ct):(M(""),J("Untitled slide"),Se(""),z(!1)),ct(`Deleted slide "${Ze}". Preset node kept.`)}catch(De){ct(De instanceof Error?De.message:"Slide delete failed")}}async function Qe(De){if(!(!n||De.length===0))try{ct("Reordering slides...");const Ze=1e5;await Promise.all(De.map((vt,Dt)=>ft(`/api/ca/scenes/${vt.scene.id}`,{method:"PATCH",body:JSON.stringify({orderIndex:Ze+Dt})}))),await Promise.all(De.map((vt,Dt)=>ft(`/api/ca/scenes/${vt.scene.id}`,{method:"PATCH",body:JSON.stringify({orderIndex:Dt+1})}))),await Xe(),ct("Slides reordered")}catch(Ze){ct(Ze instanceof Error?Ze.message:"Slide reorder failed")}}async function Ye(){if(!n)return;ct("Creating slide...");const De=B+1,Ze=await ft(`/api/ca/decks/${n.id}/scenes`,{method:"POST",body:JSON.stringify({orderIndex:De,title:`Slide ${De}`,presetTreeId:null,presetNodeId:null,applyMode:"reinitialize",params:{caption:"",autoplayOnSlideChange:!1}})}),Dt=(await Xe()).resolvedDeck.scenes.find(Ct=>Ct.scene.id===Ze.id);Dt&&tt(Dt),ct(`Created slide ${De}. Select a CA preset.`)}function Yt(){It(!1),$e(De=>{const Ze=Dl(De,Ie);return gt(Ze.settings),Ze.cells}),yt(De=>De+1)}function Rt(De){if(!f?.scenes.length)return;const Ze=f.scenes.findIndex(Ct=>Ct.scene.id===v),vt=Math.min(Math.max(Ze===-1?0:Ze+De,0),f.scenes.length-1),Dt=f.scenes[vt];Dt&&Dt.scene.id!==v&&tt(Dt)}function dn(){if(!Ue?.scene.preset_tree_id||!Ue.scene.preset_node_id)return;const De=new URLSearchParams({node:Ue.scene.preset_node_id,return:`/admin/edit/${a}?scene=${Ue.scene.id}`});Ui(`/admin/libraries/${Ue.scene.preset_tree_id}?${De.toString()}`)}function Bn(){if(!Ne||Ne.kind==="chapter")return;const De=Ue?`/admin/edit/${a}?scene=${Ue.scene.id}`:`/admin/edit/${a}`,Ze=new URLSearchParams({node:Ne.id,return:De});Ui(`/admin/libraries/${Ne.tree_id}?${Ze.toString()}`)}return ee.useEffect(()=>{function De(Ze){if(!Vy(Ze.target)){if(Ze.key==="ArrowDown"||Ze.key==="ArrowRight"){Ze.preventDefault(),Rt(1);return}if(Ze.key==="ArrowUp"||Ze.key==="ArrowLeft"){Ze.preventDefault(),Rt(-1);return}Ze.key===" "&&(Ze.preventDefault(),It(vt=>!vt))}}return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[v,f]),g.jsxs("main",{className:"studio-shell",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"deck-title-editor",children:[g.jsx("p",{className:"eyebrow",children:"CA Studio Admin"}),g.jsx("input",{"aria-label":"Deck name",className:"deck-title-input",value:l,onChange:De=>c(De.target.value)})]}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("div",{className:"status",children:rn}),g.jsx(Ki,{})]})]}),g.jsxs("section",{className:"editor-layout",children:[g.jsx(v2,{activeSceneId:v,canDeleteSlide:!!Ue,sceneCount:B,scenes:f?.scenes??[],onBack:()=>Ui(Mo("decks")),onDeleteSlide:()=>{Ce()},onEditScene:Z,onReorderSlides:De=>{Qe(De)},onSaveNewSlide:()=>{Ye()},onSelectScene:tt}),E&&Ue?g.jsx($2,{assignedNodeId:he??void 0,assignedNodeName:G,autoplayOnSlideChange:xe,caption:se,scene:Ue,slideTitle:pe,onAutoplayChange:z,onCaptionChange:Se,onClose:()=>w(!1),onSelectCa:Fe,onSlideTitleChange:J}):null,y?g.jsx(Q2,{assignedNodeId:he??void 0,loading:k,nodes:R,presetTrees:m,resolvedNode:A,selectedNode:Ne,selectedTreeId:P,onClose:()=>x(!1),onEditSelected:Bn,onSelectNode:De=>{Le(De)},onSelectTree:De=>{ye(De)},onUseSelected:()=>{Ge()}}):null,g.jsxs("section",{className:"panel editor-panel deck-editor-panel",children:[g.jsxs("div",{className:"editor-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Visualization"}),g.jsx("h2",{children:Ue?pe:G})]}),g.jsxs("div",{className:"button-row",children:[g.jsx(Ki,{}),g.jsx("button",{"aria-label":"Previous slide",className:"deck-nav-button",disabled:!C,title:"Previous slide",type:"button",onClick:()=>Rt(-1),children:"←"}),g.jsxs("span",{className:"deck-position",children:[_t>=0?_t+1:0,"/",B]}),g.jsx("button",{"aria-label":"Next slide",className:"deck-nav-button",disabled:!ie,title:"Next slide",type:"button",onClick:()=>Rt(1),children:"→"}),g.jsx("button",{disabled:!he,type:"button",onClick:dn,children:"Edit CA"}),g.jsx("button",{disabled:!he,type:"button",onClick:Yt,children:"Step"}),g.jsx("button",{className:"primary playback-button",disabled:!he,type:"button",onClick:()=>It(De=>!De),children:ht?"⏸":"▶"})]})]}),he?g.jsx(Wu,{caption:Ue?se:"",cells:rt,settings:Ie,onCellsChange:()=>{}}):g.jsx("section",{className:"empty-slide-stage",children:g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Empty slide"}),g.jsx("h3",{children:"Select a CA preset"}),g.jsx("p",{children:"This slide has no simulation asset assigned yet."}),g.jsx("button",{className:"primary",type:"button",onClick:Fe,children:"Select CA preset"})]})}),g.jsxs("footer",{className:"metrics",children:[g.jsxs("span",{children:["Generation ",g.jsx("strong",{children:dt})]}),g.jsxs("span",{children:["Live cells ",g.jsx("strong",{children:Gy(rt)})]}),g.jsxs("span",{children:["Selected node ",g.jsx("strong",{children:Q?Q.slice(0,8):"none"})]}),g.jsxs("span",{children:["Assigned node ",g.jsx("strong",{children:he?he.slice(0,8):"none"})]})]})]})]})]})}hb.createRoot(document.getElementById("root")).render(g.jsx(ee.StrictMode,{children:g.jsx(H2,{})}));